@ohhwells/bridge 0.1.170-next.453 → 0.1.170-next.454

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) {
@@ -6970,6 +7100,127 @@ function rewriteIconSlot(tree, path, ref) {
6970
7100
  return next;
6971
7101
  }
6972
7102
 
7103
+ // src/lib/ai-remove-block.ts
7104
+ function blockPathFromEditKey(sectionId, key) {
7105
+ const prefix = aiSlotKeyPrefixFor(sectionId);
7106
+ if (!key.startsWith(prefix)) return void 0;
7107
+ const path = [];
7108
+ for (const part of key.slice(prefix.length).split(".")) {
7109
+ if (/^[rbc]\d+$/.test(part)) path.push(part);
7110
+ else break;
7111
+ }
7112
+ if (path.length < 2 || !/^r\d+$/.test(path[0]) || !/^b\d+$/.test(path[1])) return void 0;
7113
+ return path.join(".");
7114
+ }
7115
+ function parseBlockPath(path) {
7116
+ const segs = [];
7117
+ for (const part of path.split(".")) {
7118
+ const match = part.match(/^([rbc])(\d+)$/);
7119
+ if (!match) return void 0;
7120
+ segs.push({ kind: match[1], index: Number(match[2]) });
7121
+ }
7122
+ if (segs.length < 2 || segs[0].kind !== "r" || segs[1].kind !== "b") return void 0;
7123
+ return segs;
7124
+ }
7125
+ function cloneTree(tree) {
7126
+ return JSON.parse(JSON.stringify(tree));
7127
+ }
7128
+ function nodeAtPath2(tree, segs) {
7129
+ let node = tree.rows?.[segs[0].index]?.blocks?.[segs[1].index];
7130
+ for (let i = 2; i < segs.length; i += 1) {
7131
+ if (segs[i].kind !== "c") return null;
7132
+ node = node?.children?.[segs[i].index];
7133
+ }
7134
+ return node ?? null;
7135
+ }
7136
+ function unwrapPromoted(node) {
7137
+ if (node.promoted === true && node.slots?.layout === "stack" && (node.children?.length ?? 0) === 1) {
7138
+ const only = { ...node.children[0] };
7139
+ if (node.slot) only.slot = node.slot;
7140
+ only.span = node.span;
7141
+ return only;
7142
+ }
7143
+ return node;
7144
+ }
7145
+ function removeBlockAtPath(tree, path) {
7146
+ const segs = parseBlockPath(path);
7147
+ if (!segs) return { ok: false, reasons: [`invalid block path "${path}"`] };
7148
+ const next = cloneTree(tree);
7149
+ const rowIndex = segs[0].index;
7150
+ const row = next.rows[rowIndex];
7151
+ if (!row) return { ok: false, reasons: [`row ${rowIndex} not found`] };
7152
+ if (segs.length === 2) {
7153
+ const blockIndex = segs[1].index;
7154
+ if (!row.blocks[blockIndex]) return { ok: false, reasons: [`block ${path} not found`] };
7155
+ row.blocks.splice(blockIndex, 1);
7156
+ if (row.blocks.length === 0) {
7157
+ next.rows.splice(rowIndex, 1);
7158
+ } else if (row.blocks.length === 1) {
7159
+ row.blocks[0] = { ...row.blocks[0], span: 12 };
7160
+ delete row.blocks[0].slot;
7161
+ }
7162
+ } else {
7163
+ let parent = row.blocks[segs[1].index];
7164
+ for (let i = 2; i < segs.length - 1; i += 1) {
7165
+ if (!parent?.children || segs[i].kind !== "c") {
7166
+ return { ok: false, reasons: [`block ${path} not found`] };
7167
+ }
7168
+ parent = parent.children[segs[i].index];
7169
+ }
7170
+ const childIndex = segs[segs.length - 1].index;
7171
+ if (!parent?.children || segs[segs.length - 1].kind !== "c" || !parent.children[childIndex]) {
7172
+ return { ok: false, reasons: [`block ${path} not found`] };
7173
+ }
7174
+ parent.children.splice(childIndex, 1);
7175
+ if (segs.length === 3) {
7176
+ row.blocks[segs[1].index] = unwrapPromoted(parent);
7177
+ if (row.blocks[segs[1].index].type === "group" && (row.blocks[segs[1].index].children?.length ?? 0) === 0) {
7178
+ row.blocks.splice(segs[1].index, 1);
7179
+ if (row.blocks.length === 0) next.rows.splice(rowIndex, 1);
7180
+ }
7181
+ if (next.rows[rowIndex]?.blocks.length === 1) {
7182
+ next.rows[rowIndex].blocks[0] = { ...next.rows[rowIndex].blocks[0], span: 12 };
7183
+ delete next.rows[rowIndex].blocks[0].slot;
7184
+ }
7185
+ } else {
7186
+ const grand = row.blocks[segs[1].index];
7187
+ let cursor = grand;
7188
+ for (let i = 2; i < segs.length - 2; i += 1) {
7189
+ cursor = cursor?.children?.[segs[i].index];
7190
+ }
7191
+ const containerIndex = segs[segs.length - 2].index;
7192
+ if (cursor?.children?.[containerIndex]) {
7193
+ cursor.children[containerIndex] = unwrapPromoted(parent);
7194
+ }
7195
+ }
7196
+ }
7197
+ if (next.rows.length === 0) {
7198
+ return { ok: false, reasons: ["a section must keep at least one block"] };
7199
+ }
7200
+ return { ok: true, tree: next };
7201
+ }
7202
+ function planAiBlockRemoval(aiSectionsRaw, editKey) {
7203
+ if (!editKey || !editKey.startsWith("ai.")) return null;
7204
+ const state = parseAiSectionsState(aiSectionsRaw);
7205
+ const entry = state.sections.find((s) => editKey.startsWith(aiSlotKeyPrefixFor(s.id)));
7206
+ if (!entry) return null;
7207
+ const path = blockPathFromEditKey(entry.id, editKey);
7208
+ if (!path) return null;
7209
+ const segs = parseBlockPath(path);
7210
+ if (!segs) return null;
7211
+ const node = nodeAtPath2(entry.tree, segs);
7212
+ if (!node) return null;
7213
+ const removed = removeBlockAtPath(entry.tree, path);
7214
+ if (!removed.ok) return removed;
7215
+ return { ok: true, tree: removed.tree, path, entry };
7216
+ }
7217
+ var planAiTextBlockRemoval = planAiBlockRemoval;
7218
+ function canRemoveAiBlock(aiSectionsRaw, editKey) {
7219
+ const plan = planAiBlockRemoval(aiSectionsRaw, editKey);
7220
+ return plan?.ok === true;
7221
+ }
7222
+ var canRemoveAiTextBlock = canRemoveAiBlock;
7223
+
6973
7224
  // src/lib/ai-footer-tree.ts
6974
7225
  var FOOTER_COLUMN_SPANS = [12, 6, 4, 3];
6975
7226
  var FOOTER_COLUMN_BLOCKS = [
@@ -8183,12 +8434,19 @@ function footerBodyStyle(fallbackFont, color, weight = 500) {
8183
8434
  }
8184
8435
  var str = (value) => typeof value === "string" ? value : "";
8185
8436
  var cardRadius = (slots) => slots.cornerStyle === "sharp" ? 0 : AI_TREE_TOKENS.radiusCard;
8186
- var blockAlignStyle = (blockAlign) => blockAlign ? {
8187
- display: "flex",
8188
- flexDirection: "column",
8189
- alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
8190
- textAlign: blockAlign
8191
- } : {};
8437
+ var HUG_ALIGN_TYPES = /* @__PURE__ */ new Set(["button", "button-row", "rating"]);
8438
+ var blockAlignStyle = (blockAlign, blockType) => {
8439
+ if (!blockAlign) return {};
8440
+ if (blockType && HUG_ALIGN_TYPES.has(blockType)) {
8441
+ return {
8442
+ display: "flex",
8443
+ flexDirection: "column",
8444
+ alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
8445
+ textAlign: blockAlign
8446
+ };
8447
+ }
8448
+ return { width: "100%", textAlign: blockAlign, boxSizing: "border-box" };
8449
+ };
8192
8450
  var fullBleedBlock = (block) => block.type === "carousel" || block.type === "group" && str(block.slots?.layout) === "overlap";
8193
8451
  var featureLines = (value) => value.split(/\n|<br\s*\/?>/i).map((line) => line.trim()).filter(Boolean);
8194
8452
  var AI_MOBILE_CSS = [
@@ -8738,7 +8996,13 @@ function TextBlock({
8738
8996
  "div",
8739
8997
  {
8740
8998
  ...textAttrs(ctx, `${path}.content`),
8741
- style: { ...typeStyle(spec, font), color: ctx.brand.palette.dark, textAlign: align },
8999
+ style: {
9000
+ ...typeStyle(spec, font),
9001
+ color: ctx.brand.palette.dark,
9002
+ textAlign: align,
9003
+ width: "100%",
9004
+ boxSizing: "border-box"
9005
+ },
8742
9006
  dangerouslySetInnerHTML: { __html: str(slots.content) }
8743
9007
  }
8744
9008
  );
@@ -8749,7 +9013,7 @@ function SectionHeaderBlock({ node, ctx, path }) {
8749
9013
  const children = node.children ?? [];
8750
9014
  const buttonRowIdx = children.findIndex((c) => c.type === "button-row");
8751
9015
  const buttonRow = buttonRowIdx >= 0 ? children[buttonRowIdx] : void 0;
8752
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { textAlign: align }, children: [
9016
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { textAlign: align, width: "100%", boxSizing: "border-box" }, children: [
8753
9017
  str(slots.tagline) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
8754
9018
  "div",
8755
9019
  {
@@ -10368,10 +10632,10 @@ function renderNode(node, ctx, path, ambientAlign) {
10368
10632
  gridColumn: `span ${typeof child.span === "number" ? Math.min(12, Math.max(1, child.span)) : 12}`,
10369
10633
  minWidth: 0
10370
10634
  } : { minWidth: 0 },
10371
- // A child's own `align` (or the group's inherited `ambientAlign`, e.g. from an
10372
- // `overlap` overlay layer — see renderNode) positions it within this column; a stack
10373
- // child otherwise stretches full-width (unchanged pre-existing behaviour).
10374
- ...blockAlignStyle(child.align ?? ambientAlign)
10635
+ // Same ambient as renderNode below: child's own align, else the group's, else the
10636
+ // inherited ambient (overlap overlay / section). Copy fills the column; button-row
10637
+ // etc. still hug via flex alignItems.
10638
+ ...blockAlignStyle(child.align ?? node.align ?? ambientAlign, child.type)
10375
10639
  },
10376
10640
  children: renderNode(child, ctx, `${path}.c${i}`, node.align ?? ambientAlign)
10377
10641
  },
@@ -10740,12 +11004,7 @@ function AiTreeRenderer({
10740
11004
  if (fillHeight) return "stretch";
10741
11005
  return (distributed ?? settings.verticalPosition) === "top" ? "start" : "center";
10742
11006
  };
10743
- const cellAlignStyle = (blockAlign) => blockAlign ? {
10744
- display: "flex",
10745
- flexDirection: "column",
10746
- alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
10747
- textAlign: blockAlign
10748
- } : {};
11007
+ const cellAlignStyle = (blockAlign, blockType) => blockAlignStyle(blockAlign, blockType);
10749
11008
  const needsOverlayClearance = fillHeight && pad === 0;
10750
11009
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10751
11010
  "section",
@@ -10807,11 +11066,11 @@ function AiTreeRenderer({
10807
11066
  gridColumn: `span ${Math.min(12, Math.max(1, block.span))}`,
10808
11067
  minWidth: 0,
10809
11068
  // Cascades the section's min-height stretch (see `fillHeight` above) down to
10810
- // this cell; `cellAlignStyle` below overrides to `flex` when the block also has
10811
- // its own horizontal `align`, which takes priority for that block.
11069
+ // this cell; `cellAlignStyle` below overrides when the block also has its own
11070
+ // horizontal `align` (flex hug for buttons; width 100% for text).
10812
11071
  ...fillHeight ? { display: "grid" } : {},
10813
11072
  // Horizontal placement of the block's content within its column.
10814
- ...fullBleedBlock(block) ? {} : cellAlignStyle(block.align),
11073
+ ...fullBleedBlock(block) ? {} : cellAlignStyle(block.align, block.type),
10815
11074
  // space-between: each column becomes a flex column whose content spreads over
10816
11075
  // the full row height instead of clumping at the top.
10817
11076
  ...distributed === "space-between" ? { display: "flex", flexDirection: "column", justifyContent: "space-between" } : {}
@@ -11536,7 +11795,7 @@ var import_client2 = require("react-dom/client");
11536
11795
  var import_react_dom2 = require("react-dom");
11537
11796
  var import_jsx_runtime3 = require("react/jsx-runtime");
11538
11797
  var CONTAINER_ATTR2 = "data-ohw-ai-footer";
11539
- var HIDDEN_ATTR = "data-ohw-ai-footer-replaced";
11798
+ var HIDDEN_ATTR2 = "data-ohw-ai-footer-replaced";
11540
11799
  var mounted2 = null;
11541
11800
  var mountOptions = {};
11542
11801
  var capturedSurface;
@@ -11566,12 +11825,12 @@ function findTemplateFooter() {
11566
11825
  function hideTemplateFooter(footer) {
11567
11826
  if (!footer) return;
11568
11827
  footer.style.display = "none";
11569
- footer.setAttribute(HIDDEN_ATTR, "");
11828
+ footer.setAttribute(HIDDEN_ATTR2, "");
11570
11829
  }
11571
11830
  function showTemplateFooter() {
11572
- for (const el of document.querySelectorAll(`[${HIDDEN_ATTR}]`)) {
11831
+ for (const el of document.querySelectorAll(`[${HIDDEN_ATTR2}]`)) {
11573
11832
  el.style.removeProperty("display");
11574
- el.removeAttribute(HIDDEN_ATTR);
11833
+ el.removeAttribute(HIDDEN_ATTR2);
11575
11834
  }
11576
11835
  }
11577
11836
  function unmountAiFooter() {
@@ -11766,7 +12025,7 @@ function pickFooterColumnIndex(columnBlockCounts) {
11766
12025
  }
11767
12026
 
11768
12027
  // src/lib/ai-footer-edits.ts
11769
- function cloneTree(tree) {
12028
+ function cloneTree2(tree) {
11770
12029
  return JSON.parse(JSON.stringify(tree));
11771
12030
  }
11772
12031
  function rebalanceFooterColumnSpans(columns) {
@@ -11844,7 +12103,7 @@ function countFooterLinkLists(tree) {
11844
12103
  return collectLinkListBlocks(tree).length;
11845
12104
  }
11846
12105
  function packFooterTreeBrand(tree) {
11847
- const next = cloneTree(tree);
12106
+ const next = cloneTree2(tree);
11848
12107
  const brand = collectBrandBlocks(next);
11849
12108
  const lists = collectLinkListBlocks(next);
11850
12109
  if (lists.length === 0) {
@@ -11929,7 +12188,7 @@ function ensureFooterTree(tree, opts) {
11929
12188
  return tree ?? buildDefaultFooterTree(opts);
11930
12189
  }
11931
12190
  function appendFooterSocial(tree, entry) {
11932
- const next = cloneTree(tree);
12191
+ const next = cloneTree2(tree);
11933
12192
  const platform = entry.platform.trim().toLowerCase();
11934
12193
  const href = entry.href.trim();
11935
12194
  for (const col2 of next.columns) {
@@ -11958,7 +12217,7 @@ function appendFooterSocial(tree, entry) {
11958
12217
  return next;
11959
12218
  }
11960
12219
  function insertFooterHours(tree, hours, title = "Hours") {
11961
- const next = cloneTree(tree);
12220
+ const next = cloneTree2(tree);
11962
12221
  const idx = pickFooterColumnIndex(next.columns.map((c) => c.blocks.length));
11963
12222
  const col = next.columns[idx] ?? next.columns[0];
11964
12223
  if (!col) return next;
@@ -11985,7 +12244,7 @@ function addFooterLinkColumn(tree, column) {
11985
12244
  return next;
11986
12245
  }
11987
12246
  function removeFooterBlock(tree, predicate) {
11988
- const next = cloneTree(tree);
12247
+ const next = cloneTree2(tree);
11989
12248
  for (let c = 0; c < next.columns.length; c++) {
11990
12249
  const col = next.columns[c];
11991
12250
  if (!col) continue;
@@ -12021,7 +12280,7 @@ function foldAiFooterSlotOverride(tree, key, value) {
12021
12280
  const path = key.slice(prefix.length);
12022
12281
  const brandMatch = path.match(/^brand\.b(\d+)\.(.+)$/);
12023
12282
  if (!brandMatch) return null;
12024
- const next = cloneTree(tree);
12283
+ const next = cloneTree2(tree);
12025
12284
  const brands = [];
12026
12285
  for (const col of next.columns) {
12027
12286
  for (const block2 of col.blocks) {
@@ -12066,7 +12325,7 @@ function textOf2(el) {
12066
12325
  return (el?.textContent ?? "").replace(/\s+/g, " ").trim();
12067
12326
  }
12068
12327
  function syncFooterTreeLinksFromDom(tree) {
12069
- const next = cloneTree(tree);
12328
+ const next = cloneTree2(tree);
12070
12329
  syncSocialRowsFromDom(next);
12071
12330
  const domCols = listFooterColumns().map((col) => {
12072
12331
  const heading = getFooterColumnHeadingEl(col);
@@ -12548,7 +12807,7 @@ var PLACEHOLDER_RE = /\[[A-Za-z][A-Za-z0-9 _/&#'.-]{0,30}\]-?/g;
12548
12807
  var HAS_PLACEHOLDER_RE = /\[[A-Za-z][A-Za-z0-9 _/&#'.-]{0,30}\]/;
12549
12808
  var SKIPPED_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "NOSCRIPT", "TEXTAREA", "CODE", "PRE"]);
12550
12809
  var TEXT_ATTRS = ["alt", "title", "aria-label", "placeholder"];
12551
- var HIDDEN_ATTR2 = "data-ohw-placeholder-hidden";
12810
+ var HIDDEN_ATTR3 = "data-ohw-placeholder-hidden";
12552
12811
  function hasPlaceholder(text) {
12553
12812
  return HAS_PLACEHOLDER_RE.test(text);
12554
12813
  }
@@ -12567,10 +12826,10 @@ function skipped(el) {
12567
12826
  }
12568
12827
  function hideIfEmptied(el) {
12569
12828
  const control = el?.closest("a, button");
12570
- if (!control || control.hasAttribute(HIDDEN_ATTR2)) return;
12829
+ if (!control || control.hasAttribute(HIDDEN_ATTR3)) return;
12571
12830
  if ((control.textContent ?? "").trim()) return;
12572
12831
  if (control.querySelector("img, svg, picture, video")) return;
12573
- control.setAttribute(HIDDEN_ATTR2, "");
12832
+ control.setAttribute(HIDDEN_ATTR3, "");
12574
12833
  control.style.display = "none";
12575
12834
  }
12576
12835
  function stripElementAttrs(el) {
@@ -17719,10 +17978,10 @@ function ItemInteractionLayer({
17719
17978
  }
17720
17979
 
17721
17980
  // src/lib/forms.ts
17722
- var FORM_SELECTOR = '[data-ohw-editable="form"]';
17981
+ var FORM_SELECTOR2 = '[data-ohw-editable="form"]';
17723
17982
  function getFormElement(el) {
17724
17983
  if (!el) return null;
17725
- return el.closest(FORM_SELECTOR);
17984
+ return el.closest(FORM_SELECTOR2);
17726
17985
  }
17727
17986
  function formKeyOf(form) {
17728
17987
  return form.getAttribute("data-ohw-key");
@@ -17783,7 +18042,7 @@ function clearSubmitError(form) {
17783
18042
  if (note) note.style.display = "none";
17784
18043
  }
17785
18044
  var SUCCESS_TEXT_ATTR = "data-ohw-form-success-text";
17786
- var HIDDEN_ATTR3 = "data-ohw-form-hidden";
18045
+ var HIDDEN_ATTR4 = "data-ohw-form-hidden";
17787
18046
  var DEFAULT_SUCCESS_TEXT = "Thanks! We'll be in touch.";
17788
18047
  function formSuccessKey(formKey) {
17789
18048
  return `${formKey}-success`;
@@ -17809,13 +18068,13 @@ function setFormViewState(form, formKey, state, initialText) {
17809
18068
  Array.from(form.children).forEach((child) => {
17810
18069
  if (!(child instanceof HTMLElement) || child === success) return;
17811
18070
  if (state === "success") {
17812
- if (!child.hasAttribute(HIDDEN_ATTR3)) {
17813
- child.setAttribute(HIDDEN_ATTR3, child.style.display);
18071
+ if (!child.hasAttribute(HIDDEN_ATTR4)) {
18072
+ child.setAttribute(HIDDEN_ATTR4, child.style.display);
17814
18073
  child.style.display = "none";
17815
18074
  }
17816
- } else if (child.hasAttribute(HIDDEN_ATTR3)) {
17817
- child.style.display = child.getAttribute(HIDDEN_ATTR3) ?? "";
17818
- child.removeAttribute(HIDDEN_ATTR3);
18075
+ } else if (child.hasAttribute(HIDDEN_ATTR4)) {
18076
+ child.style.display = child.getAttribute(HIDDEN_ATTR4) ?? "";
18077
+ child.removeAttribute(HIDDEN_ATTR4);
17819
18078
  }
17820
18079
  });
17821
18080
  success.style.display = state === "success" ? "" : "none";
@@ -17834,7 +18093,7 @@ function bindPublishedForms(apiUrl, subdomain, content = {}) {
17834
18093
  "submit",
17835
18094
  async (e) => {
17836
18095
  const target = e.target;
17837
- const form = target?.closest(FORM_SELECTOR);
18096
+ const form = target?.closest(FORM_SELECTOR2);
17838
18097
  if (!form || !(form instanceof HTMLFormElement)) return;
17839
18098
  const formKey = formKeyOf(form);
17840
18099
  if (!formKey) return;
@@ -17880,7 +18139,7 @@ function apiBase() {
17880
18139
  function bridgeVersion() {
17881
18140
  try {
17882
18141
  if (true) {
17883
- return "0.1.170-next.453";
18142
+ return "0.1.170-next.454";
17884
18143
  }
17885
18144
  } catch {
17886
18145
  }
@@ -17894,7 +18153,7 @@ function stampBridgeVersionOnDocument() {
17894
18153
  return;
17895
18154
  }
17896
18155
  try {
17897
- const v = true ? "0.1.170-next.453" : "";
18156
+ const v = true ? "0.1.170-next.454" : "";
17898
18157
  if (v) {
17899
18158
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
17900
18159
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -18555,6 +18814,7 @@ function MediaOverlay({
18555
18814
  onFadeOutComplete,
18556
18815
  onReplace,
18557
18816
  onSelect,
18817
+ onDelete,
18558
18818
  onVideoSettingsChange
18559
18819
  }) {
18560
18820
  const { rect } = hover;
@@ -18708,35 +18968,69 @@ function MediaOverlay({
18708
18968
  }
18709
18969
  ),
18710
18970
  showChrome && replaceMode !== "none" && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
18711
- Button,
18971
+ "div",
18712
18972
  {
18713
- "data-ohw-media-overlay": "",
18714
- variant: "outline",
18715
- size: "sm",
18716
- "aria-label": replaceLabel,
18717
- className: "gap-1.5 cursor-pointer hover:bg-background",
18973
+ className: "flex items-center gap-1.5",
18718
18974
  style: {
18719
- ...OVERLAY_BUTTON_STYLE,
18720
- // Icon-only is a square of the same height, so the pair can never differ vertically.
18721
- // `minWidth` has to go too: the button's own size carries `min-w-[64px]`, and a
18722
- // minimum beats a width — the square came out wider than the avatar it sat on.
18723
- ...replaceMode === "icon" && buttonSize ? {
18724
- width: buttonSize.height,
18725
- minWidth: buttonSize.height,
18726
- padding: 0,
18727
- justifyContent: "center"
18728
- } : null,
18729
- // Don't let Replace steal clicks when text (e.g. nav) sits on top of this media.
18975
+ // Parent overlay is pointer-events:none; controls opt back in (unless text sits on top).
18730
18976
  pointerEvents: hover.hasTextOverlap || cueOnly ? "none" : "auto"
18731
18977
  },
18732
- onMouseDown: (e) => e.preventDefault(),
18733
- onClick: (e) => {
18734
- e.stopPropagation();
18735
- onReplace(hover.key);
18736
- },
18978
+ onClick: (e) => e.stopPropagation(),
18737
18979
  children: [
18738
- 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 }),
18739
- replaceMode === "full" ? replaceLabel : null
18980
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
18981
+ Button,
18982
+ {
18983
+ "data-ohw-media-overlay": "",
18984
+ variant: "outline",
18985
+ size: "sm",
18986
+ "aria-label": replaceLabel,
18987
+ className: "gap-1.5 cursor-pointer hover:bg-background",
18988
+ style: {
18989
+ ...OVERLAY_BUTTON_STYLE,
18990
+ // Icon-only is a square of the same height, so the pair can never differ vertically.
18991
+ // `minWidth` has to go too: the button's own size carries `min-w-[64px]`, and a
18992
+ // minimum beats a width — the square came out wider than the avatar it sat on.
18993
+ ...replaceMode === "icon" && buttonSize ? {
18994
+ width: buttonSize.height,
18995
+ minWidth: buttonSize.height,
18996
+ padding: 0,
18997
+ justifyContent: "center"
18998
+ } : null
18999
+ },
19000
+ onMouseDown: (e) => e.preventDefault(),
19001
+ onClick: (e) => {
19002
+ e.stopPropagation();
19003
+ onReplace(hover.key);
19004
+ },
19005
+ children: [
19006
+ 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 }),
19007
+ replaceMode === "full" ? replaceLabel : null
19008
+ ]
19009
+ }
19010
+ ),
19011
+ selected && onDelete ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
19012
+ Button,
19013
+ {
19014
+ "data-ohw-media-overlay": "",
19015
+ variant: "outline",
19016
+ size: "sm",
19017
+ "aria-label": "Delete",
19018
+ title: "Delete",
19019
+ className: "cursor-pointer hover:bg-background",
19020
+ style: {
19021
+ ...OVERLAY_BUTTON_STYLE,
19022
+ minWidth: 0,
19023
+ padding: buttonSize ? `0 ${(buttonSize.height - 14) / 2}px` : "0 8px",
19024
+ height: buttonSize?.height
19025
+ },
19026
+ onMouseDown: (e) => e.preventDefault(),
19027
+ onClick: (e) => {
19028
+ e.stopPropagation();
19029
+ onDelete(hover.key);
19030
+ },
19031
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react5.Trash2, { size: 14 })
19032
+ }
19033
+ ) : null
18740
19034
  ]
18741
19035
  }
18742
19036
  )
@@ -26240,7 +26534,10 @@ function FloatingToolbar({
26240
26534
  onCommand,
26241
26535
  activeCommands,
26242
26536
  showEditLink,
26243
- onEditLink
26537
+ onEditLink,
26538
+ showDelete,
26539
+ onDelete,
26540
+ deleteDisabled
26244
26541
  }) {
26245
26542
  const localRef = import_react25.default.useRef(null);
26246
26543
  const [measuredW, setMeasuredW] = import_react25.default.useState(330);
@@ -26267,7 +26564,7 @@ function FloatingToolbar({
26267
26564
  const ro = new ResizeObserver(update);
26268
26565
  ro.observe(node);
26269
26566
  return () => ro.disconnect();
26270
- }, [showEditLink, activeCommands]);
26567
+ }, [showEditLink, showDelete, activeCommands]);
26271
26568
  const { top, left, transform } = calcToolbarPos(rect, parentScroll, measuredW);
26272
26569
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
26273
26570
  "div",
@@ -26332,7 +26629,28 @@ function FloatingToolbar({
26332
26629
  },
26333
26630
  children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react22.Link, { className: "size-4 shrink-0", "aria-hidden": true })
26334
26631
  }
26335
- ) : null
26632
+ ) : null,
26633
+ showDelete ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
26634
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CustomToolbarDivider, {}),
26635
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
26636
+ CustomToolbarButton,
26637
+ {
26638
+ type: "button",
26639
+ title: "Delete",
26640
+ disabled: deleteDisabled,
26641
+ onMouseDown: (e) => {
26642
+ e.preventDefault();
26643
+ e.stopPropagation();
26644
+ if (!deleteDisabled) onDelete?.();
26645
+ },
26646
+ onClick: (e) => {
26647
+ e.preventDefault();
26648
+ e.stopPropagation();
26649
+ },
26650
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react22.Trash2, { className: "size-4 shrink-0", "aria-hidden": true })
26651
+ }
26652
+ )
26653
+ ] }) : null
26336
26654
  ] })
26337
26655
  }
26338
26656
  );
@@ -26946,6 +27264,8 @@ function OhhwellsBridge() {
26946
27264
  const [activeCommands, setActiveCommands] = (0, import_react25.useState)(/* @__PURE__ */ new Set());
26947
27265
  const [sectionGap, setSectionGap] = (0, import_react25.useState)(null);
26948
27266
  const [toolbarShowEditLink, setToolbarShowEditLink] = (0, import_react25.useState)(false);
27267
+ const [toolbarShowAiBlockDelete, setToolbarShowAiBlockDelete] = (0, import_react25.useState)(false);
27268
+ const deletingAiBlockRef = (0, import_react25.useRef)(false);
26949
27269
  const hoveredNavContainerRef = (0, import_react25.useRef)(null);
26950
27270
  const [hoveredNavContainerRect, setHoveredNavContainerRect] = (0, import_react25.useState)(null);
26951
27271
  const hoveredItemElRef = (0, import_react25.useRef)(null);
@@ -27369,6 +27689,7 @@ function OhhwellsBridge() {
27369
27689
  setMaxBadge(null);
27370
27690
  setActiveCommands(/* @__PURE__ */ new Set());
27371
27691
  setToolbarShowEditLink(false);
27692
+ setToolbarShowAiBlockDelete(false);
27372
27693
  postToParent2({ type: "ow:exit-edit" });
27373
27694
  }, [postToParent2]);
27374
27695
  const clearSelectedAttr = (0, import_react25.useCallback)(() => {
@@ -27539,6 +27860,7 @@ function OhhwellsBridge() {
27539
27860
  setMaxBadge(null);
27540
27861
  setActiveCommands(/* @__PURE__ */ new Set());
27541
27862
  setToolbarShowEditLink(false);
27863
+ setToolbarShowAiBlockDelete(false);
27542
27864
  postToParent2({ type: "ow:exit-edit" });
27543
27865
  reselectNavigationItem(navAnchor);
27544
27866
  }, [postToParent2, reselectNavigationItem]);
@@ -28709,6 +29031,13 @@ function OhhwellsBridge() {
28709
29031
  }
28710
29032
  }
28711
29033
  setToolbarShowEditLink(Boolean(getHrefKeyFromElement(el)));
29034
+ setToolbarShowAiBlockDelete(
29035
+ canRemoveAiBlock(aiSectionsRef.current, el.dataset.ohwKey ?? null) || canSoftHideEditable(el, {
29036
+ isNavFooterItem: Boolean(
29037
+ getNavigationItemAnchor(el) && isNavFooterScopedNavigationItem(el) && !isCtaButton(el)
29038
+ )
29039
+ })
29040
+ );
28712
29041
  const navAnchor = getNavigationItemAnchor(el);
28713
29042
  if (navAnchor) {
28714
29043
  if (isNestedNavChild(navAnchor)) {
@@ -28865,6 +29194,7 @@ function OhhwellsBridge() {
28865
29194
  applySocialsDisplayFromContent(content);
28866
29195
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
28867
29196
  syncButtonsFromContent(document, content);
29197
+ applyHiddenEditablesToDom(content);
28868
29198
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
28869
29199
  if (typeof content[STYLE_STORE_KEY] === "string") {
28870
29200
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
@@ -29093,6 +29423,7 @@ function OhhwellsBridge() {
29093
29423
  applySocialsDisplayFromContent(content);
29094
29424
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
29095
29425
  syncButtonsFromContent(document, content);
29426
+ applyHiddenEditablesToDom(content);
29096
29427
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
29097
29428
  if (typeof content[STYLE_STORE_KEY] === "string") {
29098
29429
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
@@ -29231,6 +29562,7 @@ function OhhwellsBridge() {
29231
29562
  applySocialsDisplayFromContent(content);
29232
29563
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
29233
29564
  syncButtonsFromContent(document, content);
29565
+ applyHiddenEditablesToDom(content);
29234
29566
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
29235
29567
  document.querySelectorAll("footer [data-ohw-href-key]").forEach((el) => {
29236
29568
  if (isFooterHrefKey(el.getAttribute("data-ohw-href-key")) || getSocialItem(el)) {
@@ -31385,6 +31717,7 @@ function OhhwellsBridge() {
31385
31717
  reconcileNavbarItemsFromContent(editContentRef.current);
31386
31718
  reconcileFooterOrderFromContent(editContentRef.current);
31387
31719
  syncButtonsFromContent(document, editContentRef.current);
31720
+ applyHiddenEditablesToDom(editContentRef.current);
31388
31721
  if (selectedElRef.current && !selectedElRef.current.isConnected) deselectRef.current();
31389
31722
  syncNavigationDragCursorAttrs();
31390
31723
  if (typeof content[STYLE_STORE_KEY] === "string") {
@@ -32194,7 +32527,7 @@ function OhhwellsBridge() {
32194
32527
  return;
32195
32528
  }
32196
32529
  }
32197
- if ((e.key === "Delete" || e.key === "Backspace") && selectedElRef.current && !activeElRef.current && !linkPopoverOpenRef.current) {
32530
+ if ((e.key === "Delete" || e.key === "Backspace") && !activeElRef.current && !linkPopoverOpenRef.current && (selectedElRef.current || selectedMediaElRef.current || selectedIconElRef.current)) {
32198
32531
  if (handleDeleteSelectedRef.current()) {
32199
32532
  e.preventDefault();
32200
32533
  return;
@@ -33143,7 +33476,7 @@ function OhhwellsBridge() {
33143
33476
  postToParent2({
33144
33477
  type: "ow:ready",
33145
33478
  version: "1",
33146
- bridgeVersion: "0.1.170-next.453",
33479
+ bridgeVersion: "0.1.170-next.454",
33147
33480
  path: pathname,
33148
33481
  nodes: collectEditableNodes(editContentRef.current),
33149
33482
  sections
@@ -33500,7 +33833,154 @@ function OhhwellsBridge() {
33500
33833
  enforceLinkHrefs();
33501
33834
  return true;
33502
33835
  }, []);
33836
+ const deleteAiBlock = (0, import_react25.useCallback)(
33837
+ (editKey, opts) => {
33838
+ if (!opts?.fromToolbar && activeElRef.current) return false;
33839
+ if (deletingAiBlockRef.current) return false;
33840
+ const plan = planAiBlockRemoval(aiSectionsRef.current, editKey);
33841
+ if (!plan) return false;
33842
+ if (!plan.ok) {
33843
+ postToParent2({
33844
+ type: "ow:toast",
33845
+ title: plan.reasons[0] ?? "That block cannot be deleted",
33846
+ toastType: "error"
33847
+ });
33848
+ return true;
33849
+ }
33850
+ const { tree: nextTree, entry } = plan;
33851
+ const previous = aiSectionsRef.current;
33852
+ deletingAiBlockRef.current = true;
33853
+ void requestValidateTree5(postToParent2, nextTree).then(({ ok, reasons }) => {
33854
+ deletingAiBlockRef.current = false;
33855
+ if (!ok) {
33856
+ postToParent2({
33857
+ type: "ow:toast",
33858
+ title: reasons[0] ?? "That change is not allowed.",
33859
+ toastType: "error"
33860
+ });
33861
+ return;
33862
+ }
33863
+ clearMediaSelectionRef.current();
33864
+ clearIconSelectionRef.current();
33865
+ applyTreeLocalRef.current?.({
33866
+ id: entry.id,
33867
+ mode: "replace",
33868
+ targetSectionId: entry.id,
33869
+ tree: nextTree,
33870
+ label: entry.label,
33871
+ media: entry.media,
33872
+ ...entry.brand ? { brand: entry.brand } : {},
33873
+ skipScrollIntoView: true
33874
+ });
33875
+ const actionId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `delete-block-${Date.now()}`;
33876
+ pendingDeleteUndoRef.current = {
33877
+ actionId,
33878
+ restore: () => {
33879
+ clearInteractionChromeRef.current();
33880
+ aiSectionsRef.current = previous;
33881
+ applyAiSectionsToDom(parseAiSectionsState(previous));
33882
+ const restoreHeight = document.body.scrollHeight;
33883
+ if (restoreHeight > 50) postToParent2({ type: "ow:height", height: restoreHeight });
33884
+ postToParent2({ type: "ow:change", nodes: [{ key: AI_SECTIONS_KEY, text: previous }] });
33885
+ postToParent2({
33886
+ type: "ow:ai-sections-changed",
33887
+ sections: collectSections(),
33888
+ nodes: collectEditableNodes(editContentRef.current)
33889
+ });
33890
+ }
33891
+ };
33892
+ postToParent2({
33893
+ type: "ow:toast",
33894
+ title: "Block deleted",
33895
+ toastType: "success",
33896
+ actionLabel: "Undo",
33897
+ actionId,
33898
+ duration: 6e3
33899
+ });
33900
+ });
33901
+ return true;
33902
+ },
33903
+ [postToParent2]
33904
+ );
33905
+ const softHideTemplateEditable = (0, import_react25.useCallback)(
33906
+ (el, opts) => {
33907
+ if (!opts?.fromToolbar && activeElRef.current) return false;
33908
+ if (!canSoftHideEditable(el, {
33909
+ isNavFooterItem: Boolean(
33910
+ getNavigationItemAnchor(el) && isNavFooterScopedNavigationItem(el) && !isCtaButton(el)
33911
+ )
33912
+ })) {
33913
+ return false;
33914
+ }
33915
+ const previousContent = editContentRef.current;
33916
+ const result = softHideEditableInDom(el, previousContent);
33917
+ if (!result) return false;
33918
+ editContentRef.current = result.content;
33919
+ postToParent2({ type: "ow:change", nodes: result.nodes });
33920
+ clearMediaSelectionRef.current();
33921
+ clearIconSelectionRef.current();
33922
+ clearInteractionChromeRef.current();
33923
+ clearFormPickRef.current?.();
33924
+ deselectRef.current();
33925
+ const actionId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `hide-editable-${Date.now()}`;
33926
+ const hiddenKey = result.key;
33927
+ pendingDeleteUndoRef.current = {
33928
+ actionId,
33929
+ restore: () => {
33930
+ clearInteractionChromeRef.current();
33931
+ const restored = softUnhideEditableInDom(hiddenKey, editContentRef.current);
33932
+ editContentRef.current = restored.content;
33933
+ postToParent2({ type: "ow:change", nodes: restored.nodes });
33934
+ const restoreHeight = document.body.scrollHeight;
33935
+ if (restoreHeight > 50) postToParent2({ type: "ow:height", height: restoreHeight });
33936
+ }
33937
+ };
33938
+ postToParent2({
33939
+ type: "ow:toast",
33940
+ title: "Block deleted",
33941
+ toastType: "success",
33942
+ actionLabel: "Undo",
33943
+ actionId,
33944
+ duration: 6e3
33945
+ });
33946
+ return true;
33947
+ },
33948
+ [postToParent2]
33949
+ );
33950
+ const deleteFromToolbar = (0, import_react25.useCallback)(
33951
+ (editKey, el) => {
33952
+ if (!editKey && !el) return false;
33953
+ if (editKey && canRemoveAiBlock(aiSectionsRef.current, editKey)) {
33954
+ return deleteAiBlock(editKey, { fromToolbar: true });
33955
+ }
33956
+ const target = el ?? (editKey ? document.querySelector(`[data-ohw-key="${editKey.replace(/"/g, '\\"')}"]`) : null);
33957
+ if (target) return softHideTemplateEditable(target, { fromToolbar: true });
33958
+ return false;
33959
+ },
33960
+ [deleteAiBlock, softHideTemplateEditable]
33961
+ );
33962
+ const resolveSelectedAiBlockKey = (0, import_react25.useCallback)(() => {
33963
+ const candidates = [
33964
+ activeElRef.current?.dataset.ohwKey,
33965
+ selectedMediaElRef.current?.dataset.ohwKey,
33966
+ selectedMedia?.key,
33967
+ selectedIconElRef.current?.dataset.ohwKey,
33968
+ selectedElRef.current?.getAttribute("data-ohw-href-key"),
33969
+ selectedElRef.current?.dataset.ohwKey,
33970
+ selectedElRef.current?.querySelector("[data-ohw-key]")?.dataset.ohwKey
33971
+ ];
33972
+ for (const key of candidates) {
33973
+ if (key && canRemoveAiBlock(aiSectionsRef.current, key)) return key;
33974
+ }
33975
+ return null;
33976
+ }, [selectedMedia]);
33503
33977
  const handleDeleteSelected = (0, import_react25.useCallback)(() => {
33978
+ if (!activeElRef.current) {
33979
+ const aiKey = resolveSelectedAiBlockKey();
33980
+ if (aiKey && deleteAiBlock(aiKey)) return true;
33981
+ const mediaEl = selectedMediaElRef.current;
33982
+ if (mediaEl && softHideTemplateEditable(mediaEl, { fromToolbar: true })) return true;
33983
+ }
33504
33984
  const selected = selectedElRef.current;
33505
33985
  if (!selected) return false;
33506
33986
  if (isCtaButton(selected)) {
@@ -33559,7 +34039,7 @@ function OhhwellsBridge() {
33559
34039
  }
33560
34040
  }
33561
34041
  return deleted;
33562
- }, [postToParent2]);
34042
+ }, [postToParent2, deleteAiBlock, softHideTemplateEditable, resolveSelectedAiBlockKey]);
33563
34043
  handleDeleteSelectedRef.current = handleDeleteSelected;
33564
34044
  runPendingDeleteUndoRef.current = runPendingDeleteUndo;
33565
34045
  const handleLinkPopoverSubmit = (0, import_react25.useCallback)(
@@ -33777,6 +34257,13 @@ function OhhwellsBridge() {
33777
34257
  isUploading: false,
33778
34258
  onReplace: handleMediaReplace,
33779
34259
  onSelect: handleMediaSelect,
34260
+ onDelete: canRemoveAiBlock(aiSectionsRef.current, selectedMedia.key) || selectedMediaElRef.current != null && canSoftHideEditable(selectedMediaElRef.current, {
34261
+ isNavFooterItem: Boolean(
34262
+ getNavigationItemAnchor(selectedMediaElRef.current) && isNavFooterScopedNavigationItem(selectedMediaElRef.current) && !isCtaButton(selectedMediaElRef.current)
34263
+ )
34264
+ }) ? (key) => {
34265
+ deleteFromToolbar(key, selectedMediaElRef.current);
34266
+ } : void 0,
33780
34267
  onVideoSettingsChange: handleVideoSettingsChange
33781
34268
  }
33782
34269
  ),
@@ -33941,7 +34428,24 @@ function OhhwellsBridge() {
33941
34428
  children: state
33942
34429
  },
33943
34430
  state
33944
- )) })
34431
+ )) }),
34432
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "mx-0.5 h-5 w-px bg-border" }),
34433
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
34434
+ "button",
34435
+ {
34436
+ type: "button",
34437
+ "aria-label": "Delete form",
34438
+ title: "Delete",
34439
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/80",
34440
+ onClick: () => {
34441
+ setFieldTypePickerOpen(false);
34442
+ const form = formPickElRef.current;
34443
+ if (!form) return;
34444
+ softHideTemplateEditable(form, { fromToolbar: true });
34445
+ },
34446
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react22.Trash2, { size: 15, "aria-hidden": true })
34447
+ }
34448
+ )
33945
34449
  ]
33946
34450
  }
33947
34451
  )
@@ -34110,7 +34614,15 @@ function OhhwellsBridge() {
34110
34614
  onCommand: handleCommand,
34111
34615
  activeCommands,
34112
34616
  showEditLink,
34113
- onEditLink: openLinkPopoverForActive
34617
+ onEditLink: openLinkPopoverForActive,
34618
+ showDelete: toolbarShowAiBlockDelete,
34619
+ deleteDisabled: deletingAiBlockRef.current,
34620
+ onDelete: () => {
34621
+ const el = activeElRef.current;
34622
+ const key = el?.dataset.ohwKey;
34623
+ if (!key) return;
34624
+ deleteFromToolbar(key, el);
34625
+ }
34114
34626
  }
34115
34627
  )
34116
34628
  ] }),
@@ -34340,6 +34852,7 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
34340
34852
  FOOTER_COLUMN_BLOCKS,
34341
34853
  FOOTER_COLUMN_SPANS,
34342
34854
  FOOTER_SOCIAL_PLATFORMS,
34855
+ HIDDEN_EDITABLES_KEY,
34343
34856
  ItemActionToolbar,
34344
34857
  ItemInteractionLayer,
34345
34858
  LinkEditorPanel,
@@ -34362,9 +34875,14 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
34362
34875
  addFooterLinkColumn,
34363
34876
  appendFooterSocial,
34364
34877
  applyBrandChrome,
34878
+ applyHiddenEditablesToDom,
34365
34879
  applyStickySearchParams,
34880
+ blockPathFromEditKey,
34366
34881
  buildDefaultFooterTree,
34367
34882
  buildTarget,
34883
+ canRemoveAiBlock,
34884
+ canRemoveAiTextBlock,
34885
+ canSoftHideEditable,
34368
34886
  dropIndicatorVariants,
34369
34887
  ensureFooterTree,
34370
34888
  filterAvailablePages,
@@ -34375,6 +34893,7 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
34375
34893
  insertFooterHours,
34376
34894
  isDeadPageHref,
34377
34895
  isEditSessionActive,
34896
+ isEditableKeyHidden,
34378
34897
  isPlainLeftClick,
34379
34898
  isRenderableFooterTree,
34380
34899
  isRenderableTree,
@@ -34385,15 +34904,22 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
34385
34904
  parseAiFooterState,
34386
34905
  parseAiSectionsState,
34387
34906
  parseTarget,
34907
+ planAiBlockRemoval,
34908
+ planAiTextBlockRemoval,
34388
34909
  planBuildPageSync,
34910
+ readHiddenEditables,
34389
34911
  recordOverriddenPaths,
34390
34912
  releaseTemplateLogoIfReplaced,
34913
+ removeBlockAtPath,
34391
34914
  removeFooterBlock,
34392
34915
  resetOverriddenPathsCache,
34393
34916
  resolveFooterCopyright,
34917
+ resolveSoftHideTarget,
34394
34918
  resolveStickyNavigation,
34395
34919
  serializeAiFooterState,
34396
34920
  shouldFetchContentForPath,
34921
+ softHideEditableInDom,
34922
+ softUnhideEditableInDom,
34397
34923
  stepViableSlide,
34398
34924
  stripPlaceholderText,
34399
34925
  stripPlaceholders,
@@ -34401,6 +34927,8 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
34401
34927
  toggleVariants,
34402
34928
  useOhwCarousel,
34403
34929
  validateUrlInput,
34404
- viableSlides
34930
+ viableSlides,
34931
+ withHiddenEditable,
34932
+ withoutHiddenEditable
34405
34933
  });
34406
34934
  //# sourceMappingURL=index.cjs.map