@ohhwells/bridge 0.1.173 → 0.1.174-next.462

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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  // src/OhhwellsBridge.tsx
4
- import React12, { useCallback as useCallback12, useEffect as useEffect21, useLayoutEffect as useLayoutEffect6, useRef as useRef14, useState as useState18 } from "react";
4
+ import React12, { useCallback as useCallback12, useEffect as useEffect22, useLayoutEffect as useLayoutEffect7, useRef as useRef14, useState as useState18 } from "react";
5
5
  import { createRoot as createRoot3 } from "react-dom/client";
6
6
  import { flushSync as flushSync3 } from "react-dom";
7
7
 
@@ -480,10 +480,10 @@ function logoTextElement(root) {
480
480
  if (root.matches(SELECTOR)) return root;
481
481
  const marked = root.querySelector(SELECTOR);
482
482
  if (marked) return marked;
483
- const hasOwnText = Array.from(root.childNodes).some(
483
+ const hasOwnText2 = Array.from(root.childNodes).some(
484
484
  (node) => node.nodeType === Node.TEXT_NODE && node.textContent?.trim()
485
485
  );
486
- return hasOwnText ? root : null;
486
+ return hasOwnText2 ? root : null;
487
487
  }
488
488
  var TEMPLATE_LOGO_ATTR = "data-ohw-template-logo";
489
489
  function releaseTemplateLogoIfReplaced(img, url) {
@@ -6087,8 +6087,11 @@ function styleSheetCss() {
6087
6087
  for (const [tone, value] of Object.entries(BG_VALUES)) {
6088
6088
  rules.push(`[data-ohw-style-bg="${tone}"] { background: ${value} !important; }`);
6089
6089
  }
6090
+ const lightText = "var(--ohw-brand-light, var(--color-light, #FFFFFF))";
6091
+ const darkText = "var(--ohw-brand-dark, var(--color-dark, #0C0A09))";
6090
6092
  rules.push(
6091
- `[data-ohw-style-bg="accent"] { color: var(--ohw-brand-light, var(--color-light, #FFFFFF)) !important; }`
6093
+ `:is([data-ohw-style-bg], [data-ohw-style-bgcolor])[data-ohw-tone="dark"], [data-ohw-tone-fix="dark"] { color: ${lightText} !important; }`,
6094
+ `:is([data-ohw-style-bg], [data-ohw-style-bgcolor])[data-ohw-tone="light"], [data-ohw-tone-fix="light"] { color: ${darkText} !important; }`
6092
6095
  );
6093
6096
  rules.push(
6094
6097
  `[data-ohw-style-distribution="space-between"] { display: flex !important; flex-direction: column; justify-content: space-between; }`,
@@ -6876,6 +6879,21 @@ function pricingCardFeatureCount(tree, index) {
6876
6879
  const target = findPricingCollection(tree)?.children?.[index];
6877
6880
  return target ? pricingFeatureList(target).length : 0;
6878
6881
  }
6882
+ function prevailingFeatureIcon(features) {
6883
+ const counts = /* @__PURE__ */ new Map();
6884
+ for (const row of features) {
6885
+ const key = `${row.icon ?? ""}|${row.iconColor ?? ""}`;
6886
+ const entry = counts.get(key) ?? { count: 0, ...row.icon ? { icon: row.icon } : {}, ...row.iconColor ? { iconColor: row.iconColor } : {} };
6887
+ entry.count += 1;
6888
+ counts.set(key, entry);
6889
+ }
6890
+ let best = null;
6891
+ for (const entry of counts.values()) {
6892
+ if (!best || entry.count > best.count) best = entry;
6893
+ }
6894
+ if (!best) return {};
6895
+ return { ...best.icon ? { icon: best.icon } : {}, ...best.iconColor ? { iconColor: best.iconColor } : {} };
6896
+ }
6879
6897
  function addPricingCardFeature(tree, index, text) {
6880
6898
  return withPricingCollection(tree, (collection) => {
6881
6899
  const children = collection.children;
@@ -6884,7 +6902,7 @@ function addPricingCardFeature(tree, index, text) {
6884
6902
  const features = pricingFeatureList(target);
6885
6903
  if (features.length >= PRICING_FEATURES_MAX) return false;
6886
6904
  target.slots = target.slots ?? {};
6887
- target.slots.features = [...features, { text }];
6905
+ target.slots.features = [...features, { text, ...prevailingFeatureIcon(features) }];
6888
6906
  return true;
6889
6907
  });
6890
6908
  }
@@ -8397,7 +8415,7 @@ var AI_MOBILE_CSS = [
8397
8415
  // page's first section. Top only (bottom needs no nav clearance); ~96px approximates the
8398
8416
  // template nav's own height (measured ~94px) — there's no shared `--ohw-header-h` var to read
8399
8417
  // an exact figure from (no live measurement exists), so this is a safe approximation, not a
8400
- // pixel-exact fit. Horizontal spacing already comes from `data-ai-container`.
8418
+ // pixel-exact fit. Horizontal spacing already comes from `data-ai-section-inner`.
8401
8419
  '[data-ai-overlay-clearance] [data-ai-overlap-layer="overlay"]{padding-top:96px}',
8402
8420
  // A full-bleed carousel's height is pure arithmetic: it spans the whole window, so 16/9 turns
8403
8421
  // window width straight into height. Measured at 16/9 it came out ~90% of the viewport at EVERY
@@ -8413,8 +8431,10 @@ var AI_MOBILE_CSS = [
8413
8431
  "[data-ai-section]{overflow-x:hidden}",
8414
8432
  // `:not([data-ai-full-bleed])`: this `!important` gutter beat the inline `padding: 0` that a
8415
8433
  // full-bleed section's container sets, so a carousel/media hero that is edge-to-edge on desktop
8416
- // still got a 20px band of section background down both sides on a phone.
8417
- "[data-ai-container]:not([data-ai-full-bleed]){padding:0 20px !important}",
8434
+ // still got a 20px band of section background down both sides on a phone. The footer's own
8435
+ // container keeps the unguarded rule below — `data-ai-full-bleed` can never appear on it.
8436
+ "[data-ai-section-inner]:not([data-ai-full-bleed]){padding:0 20px !important}",
8437
+ "[data-ai-container]{padding:0 20px !important}",
8418
8438
  "[data-ai-row]{display:flex !important;flex-direction:column !important;align-items:stretch !important}",
8419
8439
  "[data-ai-cell]{width:100%;min-width:0}",
8420
8440
  // The rule above turns every row into a COLUMN flex container on phones, which silently breaks
@@ -8619,6 +8639,31 @@ function pricingCardEmphasis(featured, ctx, hasBg) {
8619
8639
  function textAttrs(ctx, path) {
8620
8640
  return ctx.keyFor ? { "data-ohw-key": ctx.keyFor(path), "data-ohw-editable": "text" } : {};
8621
8641
  }
8642
+ var AI_RESPONSIVE_CSS = [
8643
+ "@media (max-width: 960px) {",
8644
+ " [data-ai-responsive] [data-ai-grid] { grid-template-columns: repeat(2, 1fr) !important; }",
8645
+ ' [data-ai-responsive] [data-ai-grid="1"] { grid-template-columns: 1fr !important; }',
8646
+ "}",
8647
+ "@media (max-width: 640px) {",
8648
+ " [data-ai-responsive] [data-ai-grid] { grid-template-columns: 1fr !important; }",
8649
+ " [data-ai-responsive] [data-ai-columns] > * { grid-column: 1 / -1 !important; }",
8650
+ // Group containers flatten to a column on phones; span placements come along for free.
8651
+ // `:not([data-ai-group="overlap"])` for the same reason as the twin pair in AI_MOBILE_CSS — see
8652
+ // the comment there. This sheet's copy is the narrower selector, so without the exemption it
8653
+ // flattens an `overlap` hero below 640px even though the other rule stands down: measured a 390px
8654
+ // viewport with the heading/CTA in flow *under* the image, 219px of section background where the
8655
+ // layered text used to be.
8656
+ ' [data-ai-responsive] [data-ai-group]:not([data-ai-group="overlap"]) { display: flex !important; flex-direction: column !important; }',
8657
+ ' [data-ai-responsive] [data-ai-group]:not([data-ai-group="overlap"]) > * { grid-column: auto !important; }',
8658
+ // `:not([data-ai-full-bleed])` for the same reason as the twin rule in AI_MOBILE_CSS: this one
8659
+ // is narrower (0,2,0 vs 0,1,0) and also `!important`, so without the guard it wins outright and
8660
+ // a full-bleed hero gets its 20px side band back below 640px only — the one width where the
8661
+ // other rule had already been taught to stand down.
8662
+ " [data-ai-responsive] [data-ai-section-inner]:not([data-ai-full-bleed]) { padding-left: 20px !important; padding-right: 20px !important; }",
8663
+ " [data-ai-responsive] { overflow-x: hidden; }",
8664
+ " [data-ai-responsive] img { max-width: 100%; }",
8665
+ "}"
8666
+ ].join("\n");
8622
8667
  var TRANSPARENT_PX = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
8623
8668
  function MediaBox({
8624
8669
  refValue,
@@ -8673,7 +8718,7 @@ function MediaBox({
8673
8718
  position: fill ? "absolute" : void 0,
8674
8719
  inset: fill ? 0 : void 0,
8675
8720
  width: fill ? "100%" : fixedSize ? "auto" : "100%",
8676
- height: fill ? "100%" : void 0,
8721
+ height: fill ? "100%" : fixedSize ? height : void 0,
8677
8722
  aspectRatio: fill ? void 0 : aspectRatio,
8678
8723
  minHeight: fill || fixedSize ? void 0 : height ?? (aspectRatio ? void 0 : 180),
8679
8724
  borderRadius: radius,
@@ -10175,7 +10220,7 @@ function CollectionBlock({ node, ctx, path }) {
10175
10220
  return /* @__PURE__ */ jsx(
10176
10221
  "div",
10177
10222
  {
10178
- "data-ai-grid": "",
10223
+ "data-ai-grid": String(itemsPerRow),
10179
10224
  "data-ohw-pricing-collection": isPricing ? "" : void 0,
10180
10225
  style: {
10181
10226
  display: "grid",
@@ -10477,7 +10522,7 @@ function renderNode(node, ctx, path, ambientAlign) {
10477
10522
  },
10478
10523
  children: [
10479
10524
  i > 0 && ctx.heroOverlapFullBleed ? (
10480
- // The section's `data-ai-container` gave up its max-width/gutter so the base
10525
+ // The section's `data-ai-section-inner` gave up its max-width/gutter so the base
10481
10526
  // layer (this group's i===0 sibling) can span edge-to-edge — reintroduced here,
10482
10527
  // scoped to just the overlay text, so a heading/copy/CTA stack doesn't stretch
10483
10528
  // the full section width instead of reading at the usual content width.
@@ -10891,6 +10936,7 @@ function AiTreeRenderer({
10891
10936
  ...fillHeight ? { "data-ai-fill-height": "" } : {},
10892
10937
  ...needsOverlayClearance ? { "data-ai-overlay-clearance": "" } : {},
10893
10938
  ...bgAttrs,
10939
+ "data-ai-responsive": "",
10894
10940
  style: {
10895
10941
  position: "relative",
10896
10942
  padding: `${padCss} 0`,
@@ -10904,12 +10950,13 @@ function AiTreeRenderer({
10904
10950
  ...fillHeight ? { display: "grid" } : {}
10905
10951
  },
10906
10952
  children: [
10907
- isOverlay && backgroundUrl && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, background: `rgba(255,255,255,${overlayAlpha})` } }),
10953
+ /* @__PURE__ */ jsx("style", { children: AI_RESPONSIVE_CSS }),
10908
10954
  /* @__PURE__ */ jsx("style", { children: AI_MOBILE_CSS }),
10955
+ isOverlay && backgroundUrl && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, background: `rgba(255,255,255,${overlayAlpha})` } }),
10909
10956
  /* @__PURE__ */ jsx(
10910
10957
  "div",
10911
10958
  {
10912
- "data-ai-container": "",
10959
+ "data-ai-section-inner": "",
10913
10960
  ...fullBleedMedia ? { "data-ai-full-bleed": "" } : {},
10914
10961
  style: {
10915
10962
  position: "relative",
@@ -10926,7 +10973,7 @@ function AiTreeRenderer({
10926
10973
  children: tree.rows.map((row, r2) => /* @__PURE__ */ jsx(
10927
10974
  "div",
10928
10975
  {
10929
- "data-ai-row": "",
10976
+ "data-ai-columns": "",
10930
10977
  style: {
10931
10978
  display: "grid",
10932
10979
  gridTemplateColumns: "repeat(12, 1fr)",
@@ -11588,9 +11635,10 @@ function applyAiSectionsToDom(state, options) {
11588
11635
  if (existing && existing.serialized === serialized && existing.container.isConnected) {
11589
11636
  continue;
11590
11637
  }
11591
- const isNewMount = !existing || !existing.container.isConnected;
11592
11638
  let container = existing?.container;
11639
+ let isNewMount = false;
11593
11640
  if (!container || !container.isConnected) {
11641
+ isNewMount = true;
11594
11642
  existing?.root.unmount();
11595
11643
  container?.remove();
11596
11644
  container = document.createElement("div");
@@ -11928,6 +11976,34 @@ function minSpanForFooterBlock(type) {
11928
11976
  return 3;
11929
11977
  }
11930
11978
  }
11979
+ function readLiveSocialItems() {
11980
+ const root = getFooterRoot();
11981
+ const row = root?.querySelector("[data-ohw-socials-row]");
11982
+ if (!row) return [];
11983
+ const items = [];
11984
+ for (const anchor of Array.from(row.querySelectorAll("a[href]"))) {
11985
+ const href = anchor.getAttribute("href")?.trim() ?? "";
11986
+ const aria = anchor.getAttribute("aria-label")?.trim().toLowerCase() ?? "";
11987
+ const platform = FOOTER_SOCIAL_PLATFORMS.find((name) => aria === name) ?? FOOTER_SOCIAL_PLATFORMS.find((name) => href.toLowerCase().includes(name));
11988
+ if (!platform || !/^https?:\/\//i.test(href)) continue;
11989
+ items.push({ platform, href });
11990
+ }
11991
+ return items;
11992
+ }
11993
+ function syncSocialRowsFromDom(tree) {
11994
+ const root = getFooterRoot();
11995
+ if (!root) return;
11996
+ const row = root.querySelector("[data-ohw-socials-row]");
11997
+ const live = readLiveSocialItems();
11998
+ if (row && live.length === 0) return;
11999
+ for (const col of tree.columns) {
12000
+ col.blocks = col.blocks.flatMap((block) => {
12001
+ if (block.type !== "social-row") return [block];
12002
+ if (!row) return [];
12003
+ return [{ ...block, items: live.map((item) => ({ platform: item.platform, href: item.href })) }];
12004
+ });
12005
+ }
12006
+ }
11931
12007
  function collectBrandBlocks(tree) {
11932
12008
  const brand = [];
11933
12009
  for (const col of tree.columns) {
@@ -12173,6 +12249,7 @@ function textOf2(el) {
12173
12249
  }
12174
12250
  function syncFooterTreeLinksFromDom(tree) {
12175
12251
  const next = cloneTree2(tree);
12252
+ syncSocialRowsFromDom(next);
12176
12253
  const domCols = listFooterColumns().map((col) => {
12177
12254
  const heading = getFooterColumnHeadingEl(col);
12178
12255
  const title = heading ? textOf2(heading) : void 0;
@@ -12576,9 +12653,1035 @@ function useNavDropdownToggle(isEditMode) {
12576
12653
  }, [pathname, isEditMode]);
12577
12654
  }
12578
12655
 
12579
- // src/useHashLinkScroll.ts
12656
+ // src/useBackgroundTone.ts
12580
12657
  import { useEffect as useEffect4 } from "react";
12581
12658
 
12659
+ // src/lib/background-tone.ts
12660
+ var TONE_THRESHOLD = 0.5;
12661
+ var TONE_ATTR = "data-ohw-tone";
12662
+ var TONE_FIX_ATTR = "data-ohw-tone-fix";
12663
+ var TONE_CHANGE_EVENT = "ohw:tone-change";
12664
+ var IMAGE_COVER_RATIO = 0.8;
12665
+ var SURFACE_MIN_PX = 24;
12666
+ var OPAQUE_ALPHA = 0.9;
12667
+ var VISIBLE_ALPHA = 0.05;
12668
+ var SAMPLE_SIZE = 32;
12669
+ var SAMPLE_TIMEOUT_MS = 3e3;
12670
+ var WHITE = { r: 255, g: 255, b: 255, a: 1 };
12671
+ var SECTION_SELECTOR = "[data-ohw-section]";
12672
+ var TEXT_SELECTOR = '[data-ohw-editable="text"], [data-ohw-editable="plain"], [data-ohw-field-label]';
12673
+ var BUTTON_SELECTOR = CTA_BUTTON_SELECTOR;
12674
+ var PICKED_BUTTON_TEXT_VARS = ["--brand-button-primary-text", "--brand-button-secondary-text"];
12675
+ var MEASURING_ATTR = "data-ohw-tone-measuring";
12676
+ var TONE_FIX_LINE_ATTR = "data-ohw-tone-fix-line";
12677
+ var INK_FIX_STYLE_ID = "ohw-tone-ink-fix";
12678
+ var INK_MIN_CONTRAST = 3;
12679
+ var IMAGE_TEXT_MIN_CONTRAST = 3;
12680
+ var NEVER_SURFACE = /* @__PURE__ */ new Set(["IMG", "SVG", "VIDEO", "CANVAS", "IFRAME", "PICTURE", "PATH", "SCRIPT", "STYLE"]);
12681
+ var clamp01 = (n) => Math.min(1, Math.max(0, n));
12682
+ function num(raw, percentOf = 1) {
12683
+ if (!raw || raw === "none") return 0;
12684
+ return raw.endsWith("%") ? parseFloat(raw) / 100 * percentOf : parseFloat(raw);
12685
+ }
12686
+ function alphaOf(raw) {
12687
+ return raw == null ? 1 : clamp01(num(raw, 1));
12688
+ }
12689
+ function linearToSrgb255(v) {
12690
+ const c = clamp01(v);
12691
+ return 255 * (c <= 31308e-7 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055);
12692
+ }
12693
+ function oklabToRgba(L, A, B, a) {
12694
+ const l = (L + 0.3963377774 * A + 0.2158037573 * B) ** 3;
12695
+ const m = (L - 0.1055613458 * A - 0.0638541728 * B) ** 3;
12696
+ const s = (L - 0.0894841775 * A - 1.291485548 * B) ** 3;
12697
+ return {
12698
+ r: linearToSrgb255(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
12699
+ g: linearToSrgb255(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
12700
+ b: linearToSrgb255(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),
12701
+ a
12702
+ };
12703
+ }
12704
+ function parseCssColor(input) {
12705
+ if (!input) return null;
12706
+ const value = input.trim().toLowerCase();
12707
+ if (value === "transparent") return { r: 0, g: 0, b: 0, a: 0 };
12708
+ const hex = value.match(/^#([0-9a-f]{3,8})$/);
12709
+ if (hex) {
12710
+ const raw = hex[1];
12711
+ const short = raw.length <= 4;
12712
+ const part = (i) => parseInt(short ? raw[i] + raw[i] : raw.slice(i * 2, i * 2 + 2), 16);
12713
+ if (![3, 4, 6, 8].includes(raw.length)) return null;
12714
+ return { r: part(0), g: part(1), b: part(2), a: raw.length === 4 || raw.length === 8 ? part(3) / 255 : 1 };
12715
+ }
12716
+ const fn = value.match(/^([a-z]+)\((.*)\)$/);
12717
+ if (!fn) return null;
12718
+ const [, name, body] = fn;
12719
+ const [channelsRaw, slashAlpha] = body.split("/").map((s) => s.trim());
12720
+ const parts = channelsRaw.split(/[\s,]+/).filter(Boolean);
12721
+ if (name === "rgb" || name === "rgba") {
12722
+ if (parts.length < 3) return null;
12723
+ const alpha = slashAlpha ?? parts[3];
12724
+ return { r: num(parts[0], 255), g: num(parts[1], 255), b: num(parts[2], 255), a: alphaOf(alpha) };
12725
+ }
12726
+ if (name === "color") {
12727
+ const [space, r2, g, b] = parts;
12728
+ if (space !== "srgb" || b == null) return null;
12729
+ return { r: num(r2) * 255, g: num(g) * 255, b: num(b) * 255, a: alphaOf(slashAlpha) };
12730
+ }
12731
+ if (name === "oklch") {
12732
+ if (parts.length < 3) return null;
12733
+ const L = num(parts[0]);
12734
+ const C = num(parts[1], 0.4);
12735
+ const h = num(parts[2].replace("deg", "")) * Math.PI / 180;
12736
+ return oklabToRgba(L, C * Math.cos(h), C * Math.sin(h), alphaOf(slashAlpha));
12737
+ }
12738
+ if (name === "oklab") {
12739
+ if (parts.length < 3) return null;
12740
+ return oklabToRgba(num(parts[0]), num(parts[1], 0.4), num(parts[2], 0.4), alphaOf(slashAlpha));
12741
+ }
12742
+ return null;
12743
+ }
12744
+ function compositeColor(fg, bg) {
12745
+ const a = fg.a + bg.a * (1 - fg.a);
12746
+ if (a < 1e-3) return { r: bg.r, g: bg.g, b: bg.b, a: 0 };
12747
+ const mix = (f, b) => (f * fg.a + b * bg.a * (1 - fg.a)) / a;
12748
+ return { r: mix(fg.r, bg.r), g: mix(fg.g, bg.g), b: mix(fg.b, bg.b), a };
12749
+ }
12750
+ function relativeLuminanceOf(color) {
12751
+ const channel = (value) => {
12752
+ const s = clamp01(value / 255);
12753
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
12754
+ };
12755
+ return 0.2126 * channel(color.r) + 0.7152 * channel(color.g) + 0.0722 * channel(color.b);
12756
+ }
12757
+ function toneOfLuminance(luminance) {
12758
+ return luminance >= TONE_THRESHOLD ? "light" : "dark";
12759
+ }
12760
+ function toneOfColor(color) {
12761
+ return toneOfLuminance(relativeLuminanceOf(color));
12762
+ }
12763
+ function contrastRatioOf(a, b) {
12764
+ const la = relativeLuminanceOf(a);
12765
+ const lb = relativeLuminanceOf(b);
12766
+ return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
12767
+ }
12768
+ function splitTopLevel(value) {
12769
+ const out = [];
12770
+ let depth = 0;
12771
+ let start = 0;
12772
+ for (let i = 0; i < value.length; i++) {
12773
+ const ch = value[i];
12774
+ if (ch === "(") depth++;
12775
+ else if (ch === ")") depth--;
12776
+ else if (ch === "," && depth === 0) {
12777
+ out.push(value.slice(start, i).trim());
12778
+ start = i + 1;
12779
+ }
12780
+ }
12781
+ const last = value.slice(start).trim();
12782
+ if (last) out.push(last);
12783
+ return out;
12784
+ }
12785
+ var COLOR_TOKEN = /(?:rgba?|color|oklch|oklab)\([^()]*\)|#[0-9a-f]{3,8}\b|\btransparent\b/gi;
12786
+ function gradientStopColors(layer) {
12787
+ if (!/gradient\(/i.test(layer)) return [];
12788
+ return (layer.match(COLOR_TOKEN) ?? []).map(parseCssColor).filter((c) => c !== null);
12789
+ }
12790
+ function compositeGradient(stops, behind) {
12791
+ if (stops.length === 0) return behind;
12792
+ const sum = { r: 0, g: 0, b: 0, a: 0 };
12793
+ for (const stop of stops) {
12794
+ const c = compositeColor(stop, behind);
12795
+ sum.r += c.r;
12796
+ sum.g += c.g;
12797
+ sum.b += c.b;
12798
+ sum.a += c.a;
12799
+ }
12800
+ const n = stops.length;
12801
+ return { r: sum.r / n, g: sum.g / n, b: sum.b / n, a: sum.a / n };
12802
+ }
12803
+ function stopPosition(token, length) {
12804
+ const n = parseFloat(token);
12805
+ if (!Number.isFinite(n)) return null;
12806
+ if (token.trim().endsWith("%")) return n / 100;
12807
+ return length > 0 ? n / length : null;
12808
+ }
12809
+ function gradientDirection(arg, w, h) {
12810
+ const a = arg.trim().toLowerCase();
12811
+ const deg = a.match(/^(-?[\d.]+)(deg|turn|rad|grad)$/);
12812
+ if (deg) {
12813
+ const v2 = parseFloat(deg[1]);
12814
+ const rad = deg[2] === "turn" ? v2 * 2 * Math.PI : deg[2] === "rad" ? v2 : deg[2] === "grad" ? v2 * Math.PI / 200 : v2 * Math.PI / 180;
12815
+ return { dx: Math.sin(rad), dy: -Math.cos(rad) };
12816
+ }
12817
+ if (!a.startsWith("to ")) return null;
12818
+ const sx = a.includes("right") ? 1 : a.includes("left") ? -1 : 0;
12819
+ const sy = a.includes("bottom") ? 1 : a.includes("top") ? -1 : 0;
12820
+ const v = sx !== 0 && sy !== 0 ? { dx: sx * h, dy: sy * w } : { dx: sx, dy: sy };
12821
+ const len = Math.hypot(v.dx, v.dy);
12822
+ return len > 0 ? { dx: v.dx / len, dy: v.dy / len } : null;
12823
+ }
12824
+ function linearGradientColourAt(layer, px2, py, w, h) {
12825
+ const m = layer.trim().match(/^linear-gradient\((.*)\)$/i);
12826
+ if (!m) return null;
12827
+ const args = splitTopLevel(m[1]);
12828
+ let dir = { dx: 0, dy: 1 };
12829
+ if (args.length > 0 && !parseCssColor((args[0].match(COLOR_TOKEN) ?? [""])[0])) {
12830
+ const parsed = gradientDirection(args[0], w, h);
12831
+ if (!parsed) return null;
12832
+ dir = parsed;
12833
+ args.shift();
12834
+ }
12835
+ const length = Math.abs(w * dir.dx) + Math.abs(h * dir.dy);
12836
+ const stops = [];
12837
+ for (const arg of args) {
12838
+ const colourToken = (arg.match(COLOR_TOKEN) ?? [])[0];
12839
+ const color = colourToken ? parseCssColor(colourToken) : null;
12840
+ if (!color) continue;
12841
+ const rest = arg.replace(colourToken, "").trim().split(/\s+/).filter(Boolean);
12842
+ if (rest.length === 0) stops.push({ color, at: null });
12843
+ for (const token of rest.slice(0, 2)) stops.push({ color, at: stopPosition(token, length) });
12844
+ }
12845
+ if (stops.length === 0) return null;
12846
+ if (stops[0].at === null) stops[0].at = 0;
12847
+ if (stops[stops.length - 1].at === null) stops[stops.length - 1].at = 1;
12848
+ for (let i = 1; i < stops.length; i++) {
12849
+ if (stops[i].at !== null) {
12850
+ stops[i].at = Math.max(stops[i].at, stops[i - 1].at);
12851
+ continue;
12852
+ }
12853
+ let j = i;
12854
+ while (stops[j].at === null) j++;
12855
+ const from = stops[i - 1].at;
12856
+ const span = j - (i - 1);
12857
+ for (let k = i; k < j; k++) stops[k].at = from + (stops[j].at - from) * (k - (i - 1)) / span;
12858
+ }
12859
+ const t = length > 0 ? ((px2 - w / 2) * dir.dx + (py - h / 2) * dir.dy) / length + 0.5 : 0.5;
12860
+ if (t <= stops[0].at) return stops[0].color;
12861
+ const last = stops[stops.length - 1];
12862
+ if (t >= last.at) return last.color;
12863
+ for (let i = 1; i < stops.length; i++) {
12864
+ const a = stops[i - 1];
12865
+ const b = stops[i];
12866
+ if (t > b.at) continue;
12867
+ const f = b.at > a.at ? (t - a.at) / (b.at - a.at) : 1;
12868
+ const alpha = a.color.a + (b.color.a - a.color.a) * f;
12869
+ const mix = (x, y) => (x * a.color.a + (y * b.color.a - x * a.color.a) * f) / (alpha || 1);
12870
+ return { r: mix(a.color.r, b.color.r), g: mix(a.color.g, b.color.g), b: mix(a.color.b, b.color.b), a: alpha };
12871
+ }
12872
+ return last.color;
12873
+ }
12874
+ function positionOffset(token, free) {
12875
+ if (!token) return free / 2;
12876
+ if (token === "left" || token === "top") return 0;
12877
+ if (token === "right" || token === "bottom") return free;
12878
+ if (token === "center") return free / 2;
12879
+ if (token.endsWith("%")) return parseFloat(token) / 100 * free;
12880
+ if (token.endsWith("px")) return parseFloat(token);
12881
+ return free / 2;
12882
+ }
12883
+ function mapRegionToImage(region, element, image, fit, position) {
12884
+ const { width: w, height: h } = element;
12885
+ const { width: iw, height: ih } = image;
12886
+ if (w <= 0 || h <= 0 || iw <= 0 || ih <= 0) return null;
12887
+ let dw = iw;
12888
+ let dh = ih;
12889
+ const f = fit.trim().toLowerCase();
12890
+ if (f === "cover" || f === "contain" || f === "scale-down") {
12891
+ let s = f === "cover" ? Math.max(w / iw, h / ih) : Math.min(w / iw, h / ih);
12892
+ if (f === "scale-down") s = Math.min(1, s);
12893
+ dw = iw * s;
12894
+ dh = ih * s;
12895
+ } else if (f === "fill") {
12896
+ dw = w;
12897
+ dh = h;
12898
+ } else if (f !== "none" && f !== "auto" && f !== "auto auto") {
12899
+ const [sw, sh] = f.split(/\s+/);
12900
+ const size = (token, full, natural, other) => {
12901
+ if (!token || token === "auto") return other ?? natural;
12902
+ return token.endsWith("%") ? parseFloat(token) / 100 * full : parseFloat(token);
12903
+ };
12904
+ dw = size(sw, w, iw, null);
12905
+ dh = sh && sh !== "auto" ? size(sh, h, ih, null) : dw / iw * ih;
12906
+ }
12907
+ const [px2, py] = position.trim().toLowerCase().split(/\s+/);
12908
+ const ox = positionOffset(px2, w - dw);
12909
+ const oy = positionOffset(py, h - dh);
12910
+ const sx = Math.max(0, (region.x - ox) / dw * iw);
12911
+ const sy = Math.max(0, (region.y - oy) / dh * ih);
12912
+ const ex = Math.min(iw, (region.x + region.width - ox) / dw * iw);
12913
+ const ey = Math.min(ih, (region.y + region.height - oy) / dh * ih);
12914
+ if (ex - sx < 1 || ey - sy < 1) return null;
12915
+ return { x: sx, y: sy, width: ex - sx, height: ey - sy };
12916
+ }
12917
+ var imageCache = /* @__PURE__ */ new Map();
12918
+ function loadImage(url, onSettled) {
12919
+ const cached = imageCache.get(url);
12920
+ if (cached) {
12921
+ if (cached.state === "loading") cached.waiters.add(onSettled);
12922
+ return cached;
12923
+ }
12924
+ const entry = { state: "loading", waiters: /* @__PURE__ */ new Set([onSettled]) };
12925
+ imageCache.set(url, entry);
12926
+ const img = new Image();
12927
+ img.crossOrigin = "anonymous";
12928
+ img.decoding = "async";
12929
+ let done = false;
12930
+ const settle = (ok) => {
12931
+ if (done) return;
12932
+ done = true;
12933
+ clearTimeout(timer);
12934
+ if (!ok) console.debug?.("[ohw-tone] image sampling unavailable, reading as Light", url);
12935
+ imageCache.set(url, ok ? { state: "ok", img } : { state: "fail" });
12936
+ for (const waiter of entry.waiters) waiter();
12937
+ };
12938
+ const timer = setTimeout(() => settle(false), SAMPLE_TIMEOUT_MS);
12939
+ img.onload = () => settle(img.naturalWidth > 0);
12940
+ img.onerror = () => settle(false);
12941
+ img.src = url;
12942
+ return entry;
12943
+ }
12944
+ var sampleCanvas = null;
12945
+ function sampleImage(img, region) {
12946
+ try {
12947
+ sampleCanvas ?? (sampleCanvas = document.createElement("canvas"));
12948
+ sampleCanvas.width = SAMPLE_SIZE;
12949
+ sampleCanvas.height = SAMPLE_SIZE;
12950
+ const ctx = sampleCanvas.getContext("2d", { willReadFrequently: true });
12951
+ if (!ctx) return null;
12952
+ ctx.clearRect(0, 0, SAMPLE_SIZE, SAMPLE_SIZE);
12953
+ const r2 = region ?? { x: 0, y: 0, width: img.naturalWidth, height: img.naturalHeight };
12954
+ ctx.drawImage(img, r2.x, r2.y, r2.width, r2.height, 0, 0, SAMPLE_SIZE, SAMPLE_SIZE);
12955
+ const data = ctx.getImageData(0, 0, SAMPLE_SIZE, SAMPLE_SIZE).data;
12956
+ let r0 = 0;
12957
+ let g0 = 0;
12958
+ let b0 = 0;
12959
+ let weight = 0;
12960
+ for (let i = 0; i < data.length; i += 4) {
12961
+ const a = data[i + 3] / 255;
12962
+ r0 += data[i] * a;
12963
+ g0 += data[i + 1] * a;
12964
+ b0 += data[i + 2] * a;
12965
+ weight += a;
12966
+ }
12967
+ const pixels = data.length / 4;
12968
+ if (weight === 0) return { r: 0, g: 0, b: 0, a: 0 };
12969
+ return { r: r0 / weight, g: g0 / weight, b: b0 / weight, a: weight / pixels };
12970
+ } catch {
12971
+ return null;
12972
+ }
12973
+ }
12974
+ function browserDeps() {
12975
+ return {
12976
+ style: (el) => getComputedStyle(el),
12977
+ rect: (el) => {
12978
+ const r2 = el.getBoundingClientRect();
12979
+ return { x: r2.left, y: r2.top, width: r2.width, height: r2.height };
12980
+ },
12981
+ sample: (url, region, onReady) => {
12982
+ const entry = loadImage(url, onReady);
12983
+ if (entry.state === "loading") return "loading";
12984
+ if (entry.state === "fail") return null;
12985
+ const natural = { width: entry.img.naturalWidth, height: entry.img.naturalHeight };
12986
+ return sampleImage(entry.img, region(natural));
12987
+ },
12988
+ pseudo: (el, which) => getComputedStyle(el, which)
12989
+ };
12990
+ }
12991
+ function bgLayers(style) {
12992
+ const value = style.backgroundImage;
12993
+ return value && value !== "none" ? splitTopLevel(value) : [];
12994
+ }
12995
+ function urlOf(layer) {
12996
+ const m = layer.match(/^url\(\s*(['"]?)(.*?)\1\s*\)$/i);
12997
+ return m ? m[2] : null;
12998
+ }
12999
+ function paintOver(style, behind, at) {
13000
+ let color = behind;
13001
+ let painted = false;
13002
+ let opaque = false;
13003
+ const own = parseCssColor(style.backgroundColor);
13004
+ if (own && own.a > VISIBLE_ALPHA) {
13005
+ color = compositeColor(own, color);
13006
+ painted = true;
13007
+ opaque = own.a >= OPAQUE_ALPHA;
13008
+ }
13009
+ for (const layer of bgLayers(style).reverse()) {
13010
+ const stops = gradientStopColors(layer);
13011
+ if (stops.length === 0) continue;
13012
+ const point = at ? linearGradientColourAt(layer, at.x, at.y, at.width, at.height) : null;
13013
+ color = point ? compositeColor(point, color) : compositeGradient(stops, color);
13014
+ painted = true;
13015
+ if (stops.every((s) => s.a >= OPAQUE_ALPHA)) opaque = true;
13016
+ }
13017
+ return { color, opaque, painted };
13018
+ }
13019
+ function area(b) {
13020
+ return Math.max(0, b.width) * Math.max(0, b.height);
13021
+ }
13022
+ function intersect(a, b) {
13023
+ const x = Math.max(a.x, b.x);
13024
+ const y = Math.max(a.y, b.y);
13025
+ return { x, y, width: Math.min(a.x + a.width, b.x + b.width) - x, height: Math.min(a.y + a.height, b.y + b.height) - y };
13026
+ }
13027
+ function union(a, b) {
13028
+ if (!a) return b;
13029
+ const x = Math.min(a.x, b.x);
13030
+ const y = Math.min(a.y, b.y);
13031
+ return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
13032
+ }
13033
+ function covers(deps, el, section) {
13034
+ const sectionArea = area(section);
13035
+ return sectionArea > 0 && area(intersect(deps.rect(el), section)) >= IMAGE_COVER_RATIO * sectionArea;
13036
+ }
13037
+ function colourBehind(deps, el) {
13038
+ const chain = [];
13039
+ for (let p = el.parentElement; p; p = p.parentElement) chain.push(p);
13040
+ let color = WHITE;
13041
+ for (const ancestor of chain.reverse()) color = paintOver(deps.style(ancestor), color).color;
13042
+ return color;
13043
+ }
13044
+ function findImages(deps, section) {
13045
+ const out = [];
13046
+ const candidates = [section, ...Array.from(section.querySelectorAll("*"))];
13047
+ for (const el of candidates) {
13048
+ if (el !== section && el.closest(SECTION_SELECTOR) !== section) continue;
13049
+ const style = deps.style(el);
13050
+ if (style.display === "none" || style.visibility === "hidden") continue;
13051
+ if (el.tagName === "IMG") {
13052
+ const img = el;
13053
+ const url = img.currentSrc || img.src;
13054
+ if (url && style.objectFit === "cover") out.push({ el, url, urlLayer: -1 });
13055
+ continue;
13056
+ }
13057
+ const layers = bgLayers(style);
13058
+ const urlLayer = layers.findIndex((l) => urlOf(l) !== null);
13059
+ if (urlLayer >= 0) out.push({ el, url: urlOf(layers[urlLayer]), urlLayer });
13060
+ }
13061
+ return out;
13062
+ }
13063
+ function findImageHosts(deps, section, images, sectionImage, onReady) {
13064
+ const out = /* @__PURE__ */ new Map();
13065
+ for (const image of images) {
13066
+ if (image.el === sectionImage?.el) continue;
13067
+ let host = null;
13068
+ for (let p = image.urlLayer < 0 ? image.el.parentElement : image.el; p && p !== section; p = p.parentElement) {
13069
+ if (!covers(deps, image.el, deps.rect(p))) break;
13070
+ host = p;
13071
+ }
13072
+ if (!host || out.has(host)) continue;
13073
+ const box = deps.rect(host);
13074
+ if (box.width < SURFACE_MIN_PX || box.height < SURFACE_MIN_PX) continue;
13075
+ if (!textRegion(deps, host, deps.rect(image.el))) continue;
13076
+ out.set(host, imageSectionColour(deps, host, box, image, onReady));
13077
+ }
13078
+ return out;
13079
+ }
13080
+ function findOverlays(deps, section, image, box) {
13081
+ const out = [];
13082
+ for (const el of Array.from(section.querySelectorAll("*"))) {
13083
+ if (el === image || el.contains(image)) continue;
13084
+ const after = image.contains(el) || Boolean(
13085
+ image.compareDocumentPosition(el) & 4
13086
+ /* DOCUMENT_POSITION_FOLLOWING */
13087
+ );
13088
+ if (!after) continue;
13089
+ const style = deps.style(el);
13090
+ const paint3 = paintOver(style, { r: 0, g: 0, b: 0, a: 0 });
13091
+ if (paint3.painted && covers(deps, el, box)) out.push(el);
13092
+ }
13093
+ return out;
13094
+ }
13095
+ function findPseudoOverlays(deps, section, image, overlays, box) {
13096
+ if (!deps.pseudo) return [];
13097
+ const out = [];
13098
+ const read = (host, which) => {
13099
+ let style;
13100
+ try {
13101
+ style = deps.pseudo(host, which);
13102
+ } catch {
13103
+ return;
13104
+ }
13105
+ if (!style || !style.content || style.content === "none" || style.content === "normal") return;
13106
+ if (style.display === "none" || style.position !== "absolute" && style.position !== "fixed") return;
13107
+ if (!paintOver(style, { r: 0, g: 0, b: 0, a: 0 }).painted) return;
13108
+ const hostBox = deps.rect(host);
13109
+ const px2 = (v) => /^-?[\d.]+px$/.test(v) ? parseFloat(v) : NaN;
13110
+ let pseudoBox;
13111
+ const w = px2(style.width);
13112
+ const h = px2(style.height);
13113
+ if (Number.isFinite(w) && Number.isFinite(h)) {
13114
+ pseudoBox = { x: hostBox.x + (px2(style.left) || 0), y: hostBox.y + (px2(style.top) || 0), width: w, height: h };
13115
+ } else if ([style.top, style.left, style.right, style.bottom].every((v) => px2(v) === 0)) {
13116
+ pseudoBox = hostBox;
13117
+ } else {
13118
+ return;
13119
+ }
13120
+ const sectionArea = area(box);
13121
+ if (sectionArea > 0 && area(intersect(pseudoBox, box)) >= IMAGE_COVER_RATIO * sectionArea) out.push({ style, box: pseudoBox });
13122
+ };
13123
+ if (image.tagName !== "IMG") {
13124
+ read(image, "::before");
13125
+ read(image, "::after");
13126
+ }
13127
+ for (let p = image.parentElement; p && section.contains(p); p = p.parentElement) {
13128
+ read(p, "::after");
13129
+ if (p === section) break;
13130
+ }
13131
+ for (const overlay of overlays) {
13132
+ read(overlay, "::before");
13133
+ read(overlay, "::after");
13134
+ }
13135
+ return out;
13136
+ }
13137
+ function textRegion(deps, section, imageBox) {
13138
+ let region = null;
13139
+ for (const el of Array.from(section.querySelectorAll(TEXT_SELECTOR))) {
13140
+ const box = intersect(deps.rect(el), imageBox);
13141
+ if (box.width > 0 && box.height > 0) region = union(region, box);
13142
+ }
13143
+ return region ? { ...region, x: region.x - imageBox.x, y: region.y - imageBox.y } : null;
13144
+ }
13145
+ function opacityOf(style) {
13146
+ const n = parseFloat(style.opacity);
13147
+ return Number.isFinite(n) ? clamp01(n) : 1;
13148
+ }
13149
+ function imageSectionColour(deps, section, box, image, onReady) {
13150
+ const imageStyle = deps.style(image.el);
13151
+ const imageBox = deps.rect(image.el);
13152
+ const isImg = image.urlLayer < 0;
13153
+ const fit = isImg ? imageStyle.objectFit : splitTopLevel(imageStyle.backgroundSize)[image.urlLayer] ?? "auto";
13154
+ const position = isImg ? imageStyle.objectPosition : splitTopLevel(imageStyle.backgroundPosition)[image.urlLayer] ?? "0% 0%";
13155
+ const visible = intersect(imageBox, box);
13156
+ const fallback = { x: visible.x - imageBox.x, y: visible.y - imageBox.y, width: visible.width, height: visible.height };
13157
+ const region = textRegion(deps, section, imageBox) ?? fallback;
13158
+ const overlays = findOverlays(deps, section, image.el, box);
13159
+ const skip = /* @__PURE__ */ new Set([image.el, ...overlays]);
13160
+ for (let p = image.el.parentElement; p && p !== section && section.contains(p); p = p.parentElement) skip.add(p);
13161
+ const behind = colourBehind(deps, image.el);
13162
+ const above = isImg ? "" : bgLayers(imageStyle).slice(0, image.urlLayer).join(", ");
13163
+ const overlayParts = [
13164
+ ...findPseudoOverlays(deps, section, image.el, overlays, box),
13165
+ ...overlays.map((el) => ({ style: deps.style(el), box: deps.rect(el) }))
13166
+ ];
13167
+ const compose = (area2, point) => {
13168
+ const sampled = deps.sample(image.url, (natural) => mapRegionToImage(area2, imageBox, natural, fit, position), onReady);
13169
+ if (sampled === "loading" || sampled === null) return sampled;
13170
+ const atIn = (b) => point ? { x: point.x - b.x, y: point.y - b.y, width: b.width, height: b.height } : void 0;
13171
+ let color2 = behind;
13172
+ if (!isImg) color2 = paintOver({ backgroundColor: imageStyle.backgroundColor, backgroundImage: "none" }, color2).color;
13173
+ color2 = compositeColor({ ...sampled, a: sampled.a * opacityOf(imageStyle) }, color2);
13174
+ if (above) color2 = paintOver({ backgroundColor: "transparent", backgroundImage: above }, color2, atIn(imageBox)).color;
13175
+ for (const overlay of overlayParts) {
13176
+ const layer = paintOver(overlay.style, { r: 0, g: 0, b: 0, a: 0 }, atIn(overlay.box)).color;
13177
+ color2 = compositeColor({ ...layer, a: layer.a * opacityOf(overlay.style) }, color2);
13178
+ }
13179
+ return color2;
13180
+ };
13181
+ const color = compose(region);
13182
+ if (color === "loading" || color === null) return { color, skip };
13183
+ const at = (box2) => {
13184
+ const local = intersect(box2, imageBox);
13185
+ if (local.width <= 0 || local.height <= 0) return null;
13186
+ const result = compose(
13187
+ { x: local.x - imageBox.x, y: local.y - imageBox.y, width: local.width, height: local.height },
13188
+ { x: local.x + local.width / 2, y: local.y + local.height / 2 }
13189
+ );
13190
+ return result === "loading" ? null : result;
13191
+ };
13192
+ return { color, skip, at };
13193
+ }
13194
+ function writeTone(el, tone) {
13195
+ const previous = el.getAttribute(TONE_ATTR);
13196
+ if (previous === tone) return;
13197
+ el.setAttribute(TONE_ATTR, tone);
13198
+ const Event2 = el.ownerDocument?.defaultView?.CustomEvent ?? CustomEvent;
13199
+ el.dispatchEvent(new Event2(TONE_CHANGE_EVENT, { bubbles: true, detail: { tone, previous } }));
13200
+ }
13201
+ function isEditorBackground(el) {
13202
+ return el.hasAttribute("data-ohw-style-bg") || el.hasAttribute("data-ohw-style-bgcolor");
13203
+ }
13204
+ function hasPickedColour(el, context) {
13205
+ for (let node = el; node && node !== context; node = node.parentElement) {
13206
+ const style = node.style;
13207
+ if (style?.color && style.getPropertyPriority("color") === "important") return true;
13208
+ }
13209
+ return false;
13210
+ }
13211
+ var TEXT_SPOTS = [
13212
+ [1 / 6, 1 / 4],
13213
+ [1 / 2, 1 / 4],
13214
+ [5 / 6, 1 / 4],
13215
+ [1 / 6, 3 / 4],
13216
+ [1 / 2, 3 / 4],
13217
+ [5 / 6, 3 / 4]
13218
+ ];
13219
+ function fixInks(doc) {
13220
+ const view = doc?.defaultView;
13221
+ const root = doc?.documentElement;
13222
+ const read = (names, fallback) => {
13223
+ if (!view || !root) return fallback;
13224
+ let style;
13225
+ try {
13226
+ style = view.getComputedStyle(root);
13227
+ } catch {
13228
+ return fallback;
13229
+ }
13230
+ for (const name of names) {
13231
+ const parsed = parseCssColor(style.getPropertyValue(name).trim());
13232
+ if (parsed) return parsed;
13233
+ }
13234
+ return fallback;
13235
+ };
13236
+ return {
13237
+ dark: read(["--ohw-brand-dark", "--color-dark"], { r: 12, g: 10, b: 9, a: 1 }),
13238
+ light: read(["--ohw-brand-light", "--color-light"], WHITE)
13239
+ };
13240
+ }
13241
+ function glyphBox(el) {
13242
+ try {
13243
+ const range = el.ownerDocument?.createRange?.();
13244
+ if (!range) return null;
13245
+ range.selectNodeContents(el);
13246
+ const r2 = range.getBoundingClientRect?.();
13247
+ range.detach?.();
13248
+ return r2 && r2.width > 0 && r2.height > 0 ? { x: r2.left, y: r2.top, width: r2.width, height: r2.height } : null;
13249
+ } catch {
13250
+ return null;
13251
+ }
13252
+ }
13253
+ function worstContrast(ink, spots) {
13254
+ let worst = Infinity;
13255
+ for (const bg of spots) worst = Math.min(worst, contrastRatioOf(compositeColor(ink, bg), bg));
13256
+ return worst;
13257
+ }
13258
+ function spotsOf(box, at) {
13259
+ const spots = [];
13260
+ if (box.width <= 0 || box.height <= 0) return spots;
13261
+ const w = box.width / 3;
13262
+ const h = box.height / 2;
13263
+ for (const [fx, fy] of TEXT_SPOTS) {
13264
+ const bg = at({ x: box.x + fx * box.width - w / 2, y: box.y + fy * box.height - h / 2, width: w, height: h });
13265
+ if (bg) spots.push(bg);
13266
+ }
13267
+ return spots;
13268
+ }
13269
+ function fixTextOnImage(el, text, box, at, inks) {
13270
+ if (!text) return;
13271
+ const spots = spotsOf(box, at);
13272
+ if (spots.length === 0 || worstContrast(text, spots) >= IMAGE_TEXT_MIN_CONTRAST) return;
13273
+ const darkWorks = worstContrast(inks.dark, spots) >= IMAGE_TEXT_MIN_CONTRAST;
13274
+ const lightWorks = worstContrast(inks.light, spots) >= IMAGE_TEXT_MIN_CONTRAST;
13275
+ if (darkWorks && (!lightWorks || worstContrast(inks.dark, spots) >= worstContrast(inks.light, spots))) {
13276
+ el.setAttribute(TONE_FIX_ATTR, "light");
13277
+ } else if (lightWorks) {
13278
+ el.setAttribute(TONE_FIX_ATTR, "dark");
13279
+ }
13280
+ }
13281
+ var KEYED_TEXT_SELECTOR = "[data-ohw-key]:not([data-ohw-editable])";
13282
+ function hasOwnText(el) {
13283
+ for (const node of Array.from(el.childNodes)) if (node.nodeType === 3 && node.textContent?.trim()) return true;
13284
+ return false;
13285
+ }
13286
+ function hiddenWithin(deps, el, stop) {
13287
+ for (let node = el; node && node !== stop; node = node.parentElement) {
13288
+ const style = deps.style(node);
13289
+ if (style.visibility === "hidden" || opacityOf(style) < VISIBLE_ALPHA) return true;
13290
+ }
13291
+ return false;
13292
+ }
13293
+ function fixTextContrast(deps, section, resolved, imageContexts, pending) {
13294
+ let inks = null;
13295
+ const texts = new Set(Array.from(section.querySelectorAll(TEXT_SELECTOR)));
13296
+ const keyed = /* @__PURE__ */ new Set();
13297
+ for (const el of Array.from(section.querySelectorAll(KEYED_TEXT_SELECTOR))) {
13298
+ if (!texts.has(el) && hasOwnText(el)) keyed.add(el);
13299
+ }
13300
+ for (const el of [...texts, ...keyed]) {
13301
+ const overlayRoot = el.closest(OVERLAY_ROOT_SELECTOR);
13302
+ if (overlayRoot && !onOwnSurface(deps, el, overlayRoot)) continue;
13303
+ const context = el.closest(`[${TONE_ATTR}]`);
13304
+ if (context && pending.has(context)) continue;
13305
+ const bg = context ? resolved.get(context) : void 0;
13306
+ const imageAt = context ? imageContexts.get(context) : void 0;
13307
+ const onImage = !!imageAt;
13308
+ if (!context || !bg || !isEditorBackground(context) && !onImage || keyed.has(el) && !onImage) {
13309
+ el.removeAttribute(TONE_FIX_ATTR);
13310
+ continue;
13311
+ }
13312
+ if (imageAt && !isEditorBackground(context) && hiddenWithin(deps, el, context)) continue;
13313
+ const had = el.getAttribute(TONE_FIX_ATTR);
13314
+ if (had) el.removeAttribute(TONE_FIX_ATTR);
13315
+ if (imageAt && !isEditorBackground(context)) {
13316
+ if (!hasPickedColour(el, context)) {
13317
+ inks ?? (inks = fixInks(section.ownerDocument));
13318
+ fixTextOnImage(el, parseCssColor(deps.style(el).color), glyphBox(el) ?? deps.rect(el), imageAt, inks);
13319
+ }
13320
+ continue;
13321
+ }
13322
+ const text = parseCssColor(deps.style(el).color);
13323
+ const bgTone = toneOfColor(bg);
13324
+ const needsFix = text !== null && toneOfColor(compositeColor(text, bg)) === bgTone;
13325
+ if (needsFix) el.setAttribute(TONE_FIX_ATTR, bgTone);
13326
+ }
13327
+ }
13328
+ function pickedButtonInks(doc) {
13329
+ const root = doc?.documentElement;
13330
+ const inks = [];
13331
+ for (const name of PICKED_BUTTON_TEXT_VARS) {
13332
+ const raw = root?.style?.getPropertyValue(name).trim();
13333
+ if (!raw) continue;
13334
+ const ink = parseCssColor(raw);
13335
+ if (!ink) return "any";
13336
+ inks.push(ink);
13337
+ }
13338
+ return inks;
13339
+ }
13340
+ function sameColour(a, b) {
13341
+ return Math.abs(a.r - b.r) < 2 && Math.abs(a.g - b.g) < 2 && Math.abs(a.b - b.b) < 2;
13342
+ }
13343
+ function unreadableOn(ink, bg) {
13344
+ if (!ink) return false;
13345
+ const seen = compositeColor(ink, bg);
13346
+ return toneOfColor(seen) === toneOfColor(bg) && contrastRatioOf(seen, bg) < INK_MIN_CONTRAST;
13347
+ }
13348
+ function fixButtonInk(deps, section, painted) {
13349
+ const buttons = Array.from(section.querySelectorAll(BUTTON_SELECTOR));
13350
+ if (buttons.length === 0) return;
13351
+ const picked = pickedButtonInks(section.ownerDocument);
13352
+ for (const button of buttons) {
13353
+ const icons = Array.from(button.querySelectorAll("svg"));
13354
+ const chips = [];
13355
+ for (const icon of icons) if (icon.parentElement && icon.parentElement !== button) chips.push(icon.parentElement);
13356
+ const targets = [button, ...chips, ...icons];
13357
+ for (const el of targets) {
13358
+ el.setAttribute(MEASURING_ATTR, "");
13359
+ if (!chips.includes(el)) el.removeAttribute(TONE_FIX_ATTR);
13360
+ }
13361
+ try {
13362
+ const own = button;
13363
+ if (picked === "any" || button.hasAttribute("data-ohw-btn-variant") || own.style?.color) continue;
13364
+ const fresh = (el) => {
13365
+ const behind = el?.parentElement ? painted.get(el.parentElement) : void 0;
13366
+ return el && behind && painted.has(el) ? paintOver(deps.style(el), behind).color : void 0;
13367
+ };
13368
+ const fill = fresh(button);
13369
+ if (!fill) continue;
13370
+ const ink = parseCssColor(deps.style(button).color);
13371
+ if (ink && picked.some((p) => sameColour(p, ink))) continue;
13372
+ if (unreadableOn(ink, fill)) button.setAttribute(TONE_FIX_ATTR, toneOfColor(fill));
13373
+ for (const icon of icons) {
13374
+ const behind = fresh(icon.parentElement);
13375
+ if (behind && unreadableOn(parseCssColor(deps.style(icon).color), behind)) {
13376
+ icon.setAttribute(TONE_FIX_ATTR, toneOfColor(behind));
13377
+ }
13378
+ }
13379
+ } finally {
13380
+ void deps.style(button).color;
13381
+ for (const el of targets) el.removeAttribute(MEASURING_ATTR);
13382
+ }
13383
+ }
13384
+ }
13385
+ var INK_FIX_CSS = `[${MEASURING_ATTR}] { transition: none !important; }
13386
+ [${TONE_FIX_ATTR}="dark"] { color: var(--ohw-brand-light, var(--color-light, #FFFFFF)) !important; }
13387
+ [${TONE_FIX_ATTR}="light"] { color: var(--ohw-brand-dark, var(--color-dark, #0C0A09)) !important; }
13388
+ [${TONE_FIX_LINE_ATTR}="dark"] { border-bottom-color: var(--ohw-brand-light, var(--color-light, #FFFFFF)) !important; }
13389
+ [${TONE_FIX_LINE_ATTR}="light"] { border-bottom-color: var(--ohw-brand-dark, var(--color-dark, #0C0A09)) !important; }`;
13390
+ function ensureInkFixStyles(doc) {
13391
+ if (doc.getElementById(INK_FIX_STYLE_ID)) return;
13392
+ const style = doc.createElement("style");
13393
+ style.id = INK_FIX_STYLE_ID;
13394
+ style.textContent = INK_FIX_CSS;
13395
+ doc.head?.appendChild(style);
13396
+ }
13397
+ var sectionPhotos = /* @__PURE__ */ new WeakMap();
13398
+ var OVERLAY_ROOT_SELECTOR = "[data-ohw-nav-root]";
13399
+ function onOwnSurface(deps, el, root) {
13400
+ for (let node = el; node; node = node.parentElement) {
13401
+ if (paintOver(deps.style(node), { r: 0, g: 0, b: 0, a: 0 }).painted) return true;
13402
+ if (node === root) break;
13403
+ }
13404
+ return false;
13405
+ }
13406
+ function contains(box, x, y) {
13407
+ return x >= box.x && x <= box.x + box.width && y >= box.y && y <= box.y + box.height;
13408
+ }
13409
+ function fixOverlayText(deps, doc) {
13410
+ const roots = Array.from(doc.querySelectorAll(OVERLAY_ROOT_SELECTOR));
13411
+ if (roots.length === 0) return;
13412
+ const photoSections = topSections(doc).filter((s) => sectionPhotos.has(s));
13413
+ const boxes = new Map(photoSections.map((s) => [s, deps.rect(s)]));
13414
+ let inks = null;
13415
+ for (const root of roots) {
13416
+ const items = [];
13417
+ for (const el of Array.from(root.querySelectorAll(TEXT_SELECTOR))) {
13418
+ if (onOwnSurface(deps, el, root)) continue;
13419
+ const box = glyphBox(el) ?? deps.rect(el);
13420
+ const cx2 = box.x + box.width / 2;
13421
+ const cy = box.y + box.height / 2;
13422
+ const under = photoSections.find((s) => contains(boxes.get(s), cx2, cy));
13423
+ const photo = under ? sectionPhotos.get(under) : void 0;
13424
+ if (photo === "loading") continue;
13425
+ el.removeAttribute(TONE_FIX_ATTR);
13426
+ for (let node = el; node; node = node.parentElement) {
13427
+ node.removeAttribute(TONE_FIX_LINE_ATTR);
13428
+ if (node === root) break;
13429
+ }
13430
+ if (!photo || el.closest(BUTTON_SELECTOR)) continue;
13431
+ if (hasPickedColour(el, doc.documentElement) || hiddenWithin(deps, el, null)) continue;
13432
+ const text = parseCssColor(deps.style(el).color);
13433
+ const spots = spotsOf(box, photo);
13434
+ if (text && spots.length > 0) items.push({ el, text, spots, line: underlineOf(deps, el, root) });
13435
+ }
13436
+ inks ?? (inks = fixInks(doc));
13437
+ fixBarInk(items, inks);
13438
+ for (const item of items) {
13439
+ const fix = item.el.getAttribute(TONE_FIX_ATTR);
13440
+ if (fix) item.line?.setAttribute(TONE_FIX_LINE_ATTR, fix);
13441
+ }
13442
+ }
13443
+ }
13444
+ function underlineOf(deps, el, root) {
13445
+ const text = parseCssColor(deps.style(el).color);
13446
+ if (!text) return null;
13447
+ for (let node = el; node; node = node.parentElement) {
13448
+ const style = deps.style(node);
13449
+ const line = parseCssColor(style.borderBottomColor);
13450
+ if (line && line.a > VISIBLE_ALPHA && parseFloat(style.borderBottomWidth ?? "0") > 0 && style.borderBottomStyle !== "none" && sameColour(line, text)) {
13451
+ return node;
13452
+ }
13453
+ if (node === root) break;
13454
+ }
13455
+ return null;
13456
+ }
13457
+ function fixBarInk(items, inks) {
13458
+ if (!items.some((item) => worstContrast(item.text, item.spots) < IMAGE_TEXT_MIN_CONTRAST)) return;
13459
+ const score = (ink) => {
13460
+ let readable = 0;
13461
+ let worst = Infinity;
13462
+ for (const item of items) {
13463
+ const c = worstContrast(ink, item.spots);
13464
+ if (c >= IMAGE_TEXT_MIN_CONTRAST) readable++;
13465
+ worst = Math.min(worst, c);
13466
+ }
13467
+ return { readable, worst };
13468
+ };
13469
+ const dark = score(inks.dark);
13470
+ const light = score(inks.light);
13471
+ if (dark.readable === 0 && light.readable === 0) return;
13472
+ const useDark = dark.readable > light.readable || dark.readable === light.readable && dark.worst >= light.worst;
13473
+ const fix = useDark ? "light" : "dark";
13474
+ for (const item of items) {
13475
+ if (toneOfColor(item.text) === (useDark ? "dark" : "light")) continue;
13476
+ item.el.setAttribute(TONE_FIX_ATTR, fix);
13477
+ }
13478
+ }
13479
+ function computeSection(deps, section, onReady) {
13480
+ const box = deps.rect(section);
13481
+ const resolved = /* @__PURE__ */ new Map();
13482
+ const painted = /* @__PURE__ */ new Map();
13483
+ const written = /* @__PURE__ */ new Set();
13484
+ const imageContexts = /* @__PURE__ */ new Map();
13485
+ const pending = /* @__PURE__ */ new Set();
13486
+ let base;
13487
+ let skip = /* @__PURE__ */ new Set();
13488
+ const images = box.width > 0 && box.height > 0 ? findImages(deps, section) : [];
13489
+ const image = images.find((candidate) => covers(deps, candidate.el, box)) ?? null;
13490
+ if (image) {
13491
+ const result = imageSectionColour(deps, section, box, image, onReady);
13492
+ if (result.color === "loading") {
13493
+ sectionPhotos.set(section, "loading");
13494
+ return;
13495
+ }
13496
+ skip = result.skip;
13497
+ base = result.color ?? WHITE;
13498
+ writeTone(section, result.color ? toneOfColor(base) : "light");
13499
+ if (result.color && result.at) {
13500
+ imageContexts.set(section, result.at);
13501
+ sectionPhotos.set(section, result.at);
13502
+ } else {
13503
+ sectionPhotos.delete(section);
13504
+ }
13505
+ } else {
13506
+ sectionPhotos.delete(section);
13507
+ base = paintOver(deps.style(section), colourBehind(deps, section)).color;
13508
+ writeTone(section, toneOfColor(base));
13509
+ }
13510
+ resolved.set(section, base);
13511
+ painted.set(section, base);
13512
+ written.add(section);
13513
+ const hosts = findImageHosts(deps, section, images, image, onReady);
13514
+ for (const hosted of hosts.values()) for (const el of hosted.skip) skip.add(el);
13515
+ const visit = (parent, behind, context) => {
13516
+ for (const child of Array.from(parent.children)) {
13517
+ if (NEVER_SURFACE.has(child.tagName.toUpperCase())) continue;
13518
+ const hosted = hosts.get(child);
13519
+ if (hosted) {
13520
+ written.add(child);
13521
+ if (hosted.color === "loading") {
13522
+ pending.add(child);
13523
+ painted.set(child, behind);
13524
+ visit(child, behind, context);
13525
+ continue;
13526
+ }
13527
+ const color = hosted.color ?? WHITE;
13528
+ writeTone(child, hosted.color ? toneOfColor(color) : "light");
13529
+ if (hosted.color && hosted.at) imageContexts.set(child, hosted.at);
13530
+ resolved.set(child, color);
13531
+ painted.set(child, color);
13532
+ visit(child, color, color);
13533
+ continue;
13534
+ }
13535
+ if (skip.has(child)) {
13536
+ painted.set(child, behind);
13537
+ visit(child, behind, context);
13538
+ continue;
13539
+ }
13540
+ const style = deps.style(child);
13541
+ if (style.display === "none") continue;
13542
+ const paint3 = paintOver(style, behind);
13543
+ painted.set(child, paint3.color);
13544
+ let nextContext = context;
13545
+ const forced = isEditorBackground(child) || child.matches(SECTION_SELECTOR);
13546
+ if (forced || paint3.painted && paint3.opaque) {
13547
+ const rect = deps.rect(child);
13548
+ const bigEnough = rect.width >= SURFACE_MIN_PX && rect.height >= SURFACE_MIN_PX;
13549
+ const differs = Math.abs(relativeLuminanceOf(paint3.color) - relativeLuminanceOf(context)) > 0.01 || toneOfColor(paint3.color) !== toneOfColor(context);
13550
+ if (forced || bigEnough && differs) {
13551
+ writeTone(child, toneOfColor(paint3.color));
13552
+ resolved.set(child, paint3.color);
13553
+ written.add(child);
13554
+ nextContext = paint3.color;
13555
+ }
13556
+ }
13557
+ visit(child, paint3.color, nextContext);
13558
+ }
13559
+ };
13560
+ visit(section, base, base);
13561
+ for (const stale of Array.from(section.querySelectorAll(`[${TONE_ATTR}]`))) {
13562
+ if (!written.has(stale)) stale.removeAttribute(TONE_ATTR);
13563
+ }
13564
+ fixTextContrast(deps, section, resolved, imageContexts, pending);
13565
+ fixButtonInk(deps, section, painted);
13566
+ }
13567
+ function topSections(root) {
13568
+ return Array.from(root.querySelectorAll(SECTION_SELECTOR)).filter((el) => !el.parentElement?.closest(SECTION_SELECTOR));
13569
+ }
13570
+ function computeBackgroundTones(doc, options = {}) {
13571
+ const deps = options.deps ?? browserDeps();
13572
+ const sections = options.only ? Array.from(options.only) : topSections(doc);
13573
+ for (const section of sections) {
13574
+ if (!section.isConnected) continue;
13575
+ computeSection(deps, section, () => options.onImageReady?.(section));
13576
+ }
13577
+ fixOverlayText(deps, doc);
13578
+ }
13579
+ function toneFor(el) {
13580
+ const value = el?.closest(`[${TONE_ATTR}]`)?.getAttribute(TONE_ATTR);
13581
+ return value === "dark" ? "dark" : "light";
13582
+ }
13583
+ var WATCHED_ATTRS = [
13584
+ "style",
13585
+ "class",
13586
+ "src",
13587
+ "srcset",
13588
+ "data-ohw-style-bg",
13589
+ "data-ohw-style-bgcolor",
13590
+ "data-ohw-style-cardbg",
13591
+ // The editor's Default / Hover toggle forces :hover rules through this attribute.
13592
+ "data-ohw-active-state"
13593
+ ];
13594
+ var VISIBILITY_TRANSITIONS = /* @__PURE__ */ new Set(["opacity", "visibility"]);
13595
+ function outermostSection(node) {
13596
+ let el = node instanceof Element ? node : node?.parentElement ?? null;
13597
+ let top = null;
13598
+ while (el) {
13599
+ const section = el.closest(SECTION_SELECTOR);
13600
+ if (!section) break;
13601
+ top = section;
13602
+ el = section.parentElement;
13603
+ }
13604
+ return top;
13605
+ }
13606
+ function mountBackgroundTone(doc = document) {
13607
+ const win = doc.defaultView;
13608
+ if (!win) return () => void 0;
13609
+ const dirty = /* @__PURE__ */ new Set();
13610
+ let all = true;
13611
+ let frame = 0;
13612
+ const run = () => {
13613
+ frame = 0;
13614
+ const only = all ? void 0 : Array.from(dirty);
13615
+ all = false;
13616
+ dirty.clear();
13617
+ computeBackgroundTones(doc, { only, onImageReady: (section) => schedule(section) });
13618
+ };
13619
+ function schedule(section) {
13620
+ if (section) dirty.add(section);
13621
+ else all = true;
13622
+ if (!frame) frame = win.requestAnimationFrame(run);
13623
+ }
13624
+ ensureInkFixStyles(doc);
13625
+ const observer = new MutationObserver((records) => {
13626
+ for (const record of records) {
13627
+ const target = record.target;
13628
+ if (target === doc.documentElement || doc.head?.contains(target)) {
13629
+ schedule();
13630
+ continue;
13631
+ }
13632
+ const section = outermostSection(target);
13633
+ if (section) {
13634
+ schedule(section);
13635
+ continue;
13636
+ }
13637
+ const targetEl = target instanceof Element ? target : target.parentElement;
13638
+ if (targetEl?.closest(OVERLAY_ROOT_SELECTOR)) {
13639
+ if (!frame) frame = win.requestAnimationFrame(run);
13640
+ continue;
13641
+ }
13642
+ for (const added of Array.from(record.addedNodes)) {
13643
+ if (added instanceof Element && (added.matches(SECTION_SELECTOR) || added.querySelector(SECTION_SELECTOR))) {
13644
+ schedule();
13645
+ break;
13646
+ }
13647
+ }
13648
+ }
13649
+ });
13650
+ observer.observe(doc.documentElement, {
13651
+ subtree: true,
13652
+ childList: true,
13653
+ characterData: true,
13654
+ attributes: true,
13655
+ attributeFilter: WATCHED_ATTRS
13656
+ });
13657
+ const onResize = () => schedule();
13658
+ const onTransitionEnd = (event) => {
13659
+ if (!VISIBILITY_TRANSITIONS.has(event.propertyName)) return;
13660
+ const section = outermostSection(event.target);
13661
+ if (section) schedule(section);
13662
+ };
13663
+ win.addEventListener("resize", onResize);
13664
+ win.addEventListener("load", onResize);
13665
+ doc.addEventListener("transitionend", onTransitionEnd, true);
13666
+ doc.fonts?.ready.then(() => schedule()).catch(() => void 0);
13667
+ schedule();
13668
+ return () => {
13669
+ observer.disconnect();
13670
+ win.removeEventListener("resize", onResize);
13671
+ win.removeEventListener("load", onResize);
13672
+ doc.removeEventListener("transitionend", onTransitionEnd, true);
13673
+ if (frame) win.cancelAnimationFrame(frame);
13674
+ };
13675
+ }
13676
+
13677
+ // src/useBackgroundTone.ts
13678
+ function useBackgroundTone() {
13679
+ useEffect4(() => mountBackgroundTone(), []);
13680
+ }
13681
+
13682
+ // src/useHashLinkScroll.ts
13683
+ import { useEffect as useEffect5 } from "react";
13684
+
12582
13685
  // src/lib/scroll-to-section.ts
12583
13686
  var MAX_ATTEMPTS = 12;
12584
13687
  var RETRY_MS = 100;
@@ -12631,7 +13734,7 @@ function samePageSectionId(anchor) {
12631
13734
  return id || null;
12632
13735
  }
12633
13736
  function useHashLinkScroll(isEditMode) {
12634
- useEffect4(() => {
13737
+ useEffect5(() => {
12635
13738
  if (isEditMode) return;
12636
13739
  const onClick = (e) => {
12637
13740
  if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
@@ -12646,7 +13749,7 @@ function useHashLinkScroll(isEditMode) {
12646
13749
  }
12647
13750
 
12648
13751
  // src/usePublishedPlaceholderStrip.ts
12649
- import { useEffect as useEffect5 } from "react";
13752
+ import { useEffect as useEffect6 } from "react";
12650
13753
 
12651
13754
  // src/lib/strip-placeholders.ts
12652
13755
  var PLACEHOLDER_RE = /\[[A-Za-z][A-Za-z0-9 _/&#'.-]{0,30}\]-?/g;
@@ -12733,7 +13836,7 @@ function stripTextNode(node) {
12733
13836
 
12734
13837
  // src/usePublishedPlaceholderStrip.ts
12735
13838
  function usePublishedPlaceholderStrip(isEditMode) {
12736
- useEffect5(() => {
13839
+ useEffect6(() => {
12737
13840
  if (isEditMode) return;
12738
13841
  stripPlaceholders(document.body);
12739
13842
  const observer = new MutationObserver((records) => {
@@ -12754,7 +13857,7 @@ function usePublishedPlaceholderStrip(isEditMode) {
12754
13857
  }
12755
13858
 
12756
13859
  // src/ui/SchedulingWidget.tsx
12757
- import { useCallback, useEffect as useEffect6, useId, useMemo, useRef, useState as useState3 } from "react";
13860
+ import { useCallback, useEffect as useEffect7, useId, useMemo, useRef, useState as useState3 } from "react";
12758
13861
 
12759
13862
  // src/ui/EmailCaptureModal.tsx
12760
13863
  import { useState as useState2 } from "react";
@@ -13072,7 +14175,7 @@ function ScheduleView({ schedule, dates, selectedIdx, onSelectDate, onOpenModal
13072
14175
  setCanScrollLeft(el.scrollLeft > 0);
13073
14176
  setCanScrollRight(el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
13074
14177
  };
13075
- useEffect6(() => {
14178
+ useEffect7(() => {
13076
14179
  const el = scrollRef.current;
13077
14180
  if (!el) return;
13078
14181
  updateScrollState();
@@ -13330,7 +14433,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
13330
14433
  });
13331
14434
  }, []);
13332
14435
  const [selectedIdx, setSelectedIdx] = useState3(0);
13333
- useEffect6(() => {
14436
+ useEffect7(() => {
13334
14437
  if (!schedule?.classes) return;
13335
14438
  for (let i = 0; i < dates.length; i++) {
13336
14439
  if (schedule.classes.some((c) => classRunsOnDate(c, dates[i], schedule.type))) {
@@ -13339,7 +14442,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
13339
14442
  }
13340
14443
  }
13341
14444
  }, [schedule, dates]);
13342
- useEffect6(() => {
14445
+ useEffect7(() => {
13343
14446
  if (typeof window === "undefined") return;
13344
14447
  const onVisible = () => {
13345
14448
  if (!document.hidden) void refetchLiveSchedule();
@@ -13351,7 +14454,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
13351
14454
  document.removeEventListener("visibilitychange", onVisible);
13352
14455
  };
13353
14456
  }, [refetchLiveSchedule]);
13354
- useEffect6(() => {
14457
+ useEffect7(() => {
13355
14458
  if (typeof window === "undefined") return;
13356
14459
  const isInEditor = window.self !== window.top;
13357
14460
  setInEditor(isInEditor);
@@ -17985,7 +19088,7 @@ function apiBase() {
17985
19088
  function bridgeVersion() {
17986
19089
  try {
17987
19090
  if (true) {
17988
- return "0.1.173";
19091
+ return "0.1.174-next.462";
17989
19092
  }
17990
19093
  } catch {
17991
19094
  }
@@ -17999,7 +19102,7 @@ function stampBridgeVersionOnDocument() {
17999
19102
  return;
18000
19103
  }
18001
19104
  try {
18002
- const v = true ? "0.1.173" : "";
19105
+ const v = true ? "0.1.174-next.462" : "";
18003
19106
  if (v) {
18004
19107
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
18005
19108
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -18680,6 +19783,7 @@ function MediaOverlay({
18680
19783
  (prev) => prev && prev.fullWidth === width && prev.height === height ? prev : { fullWidth: width, height }
18681
19784
  );
18682
19785
  }, [isVideo]);
19786
+ const replaceLabel = isVideo ? "Replace video" : hover.elementType === "bg-image" ? "Replace background" : "Replace image";
18683
19787
  const replaceMode = buttonSize ? replaceButtonMode({ width: rect.width, height: rect.height }, buttonSize) : "none";
18684
19788
  const box = {
18685
19789
  position: "fixed",
@@ -18778,10 +19882,9 @@ function MediaOverlay({
18778
19882
  className: "flex items-center justify-center cursor-pointer",
18779
19883
  style: {
18780
19884
  ...box,
18781
- // When text overlays this media, let clicks fall THROUGH to the text underneath. In the
18782
- // parent this needed a whole `ow:click-at` round-trip to re-hit-test inside the iframe;
18783
- // in-document, pointer-events does it natively. The button below opts back in, so
18784
- // Replace still works.
19885
+ // Bare media takes the click: the first selects it, the next opens the picker. Text on
19886
+ // top and cueOnly let clicks fall through. Navbar, logo and buttons over a hero image
19887
+ // never reach here: probeImageAt dismisses the overlay before it can cover them.
18785
19888
  pointerEvents: hover.hasTextOverlap || cueOnly ? "none" : "auto",
18786
19889
  // Selected: a firm component ring with no wash, so the image reads as chosen rather
18787
19890
  // than hovered. Hover keeps the existing tinted preview.
@@ -18809,15 +19912,18 @@ function MediaOverlay({
18809
19912
  },
18810
19913
  children: [
18811
19914
  isVideo ? /* @__PURE__ */ jsx17(Film, { size: 14 }) : /* @__PURE__ */ jsx17(ImageIcon, { size: 14 }),
18812
- isVideo ? "Replace video" : "Replace image"
19915
+ replaceLabel
18813
19916
  ]
18814
19917
  }
18815
19918
  ),
18816
- replaceMode === "none" || cueOnly ? null : /* @__PURE__ */ jsxs8(
19919
+ showChrome && replaceMode !== "none" && /* @__PURE__ */ jsxs8(
18817
19920
  "div",
18818
19921
  {
18819
19922
  className: "flex items-center gap-1.5",
18820
- style: { pointerEvents: hover.hasTextOverlap || cueOnly ? "none" : "auto" },
19923
+ style: {
19924
+ // Parent overlay is pointer-events:none; controls opt back in (unless text sits on top).
19925
+ pointerEvents: hover.hasTextOverlap || cueOnly ? "none" : "auto"
19926
+ },
18821
19927
  onClick: (e) => e.stopPropagation(),
18822
19928
  children: [
18823
19929
  /* @__PURE__ */ jsxs8(
@@ -18826,7 +19932,7 @@ function MediaOverlay({
18826
19932
  "data-ohw-media-overlay": "",
18827
19933
  variant: "outline",
18828
19934
  size: "sm",
18829
- "aria-label": isVideo ? "Replace video" : "Replace image",
19935
+ "aria-label": replaceLabel,
18830
19936
  className: "gap-1.5 cursor-pointer hover:bg-background",
18831
19937
  style: {
18832
19938
  ...OVERLAY_BUTTON_STYLE,
@@ -18847,7 +19953,7 @@ function MediaOverlay({
18847
19953
  },
18848
19954
  children: [
18849
19955
  isVideo ? /* @__PURE__ */ jsx17(Film, { size: 14 }) : /* @__PURE__ */ jsx17(ImageIcon, { size: 14 }),
18850
- replaceMode === "full" ? isVideo ? "Replace video" : hover.elementType === "bg-image" ? "Replace background" : "Replace image" : null
19956
+ replaceMode === "full" ? replaceLabel : null
18851
19957
  ]
18852
19958
  }
18853
19959
  ),
@@ -18940,7 +20046,7 @@ function CarouselOverlay({
18940
20046
  }
18941
20047
 
18942
20048
  // src/ui/ai-section/AiSectionOverlay.tsx
18943
- import { useCallback as useCallback2, useEffect as useEffect8, useRef as useRef4, useState as useState7 } from "react";
20049
+ import { useCallback as useCallback2, useEffect as useEffect9, useRef as useRef4, useState as useState7 } from "react";
18944
20050
  import { Check, X } from "lucide-react";
18945
20051
 
18946
20052
  // src/lib/ai-change-highlight.ts
@@ -19073,7 +20179,7 @@ function readRect(instanceId) {
19073
20179
  }
19074
20180
  function useLiveSectionRect(sectionId) {
19075
20181
  const [rect, setRect] = useState7(null);
19076
- useEffect8(() => {
20182
+ useEffect9(() => {
19077
20183
  if (!sectionId) {
19078
20184
  setRect(null);
19079
20185
  return;
@@ -19113,7 +20219,7 @@ function readNavToggleRect() {
19113
20219
  }
19114
20220
  function useLiveNavToggleHole(active) {
19115
20221
  const [rect, setRect] = useState7(null);
19116
- useEffect8(() => {
20222
+ useEffect9(() => {
19117
20223
  if (!active) {
19118
20224
  setRect(null);
19119
20225
  return;
@@ -19237,7 +20343,7 @@ function AiSectionOverlay({
19237
20343
  reviewIdRef.current = reviewId;
19238
20344
  const selectedIdRef = useRef4(null);
19239
20345
  selectedIdRef.current = selectedId;
19240
- useEffect8(() => {
20346
+ useEffect9(() => {
19241
20347
  onSelectionChange?.(selectedId);
19242
20348
  }, [selectedId, onSelectionChange]);
19243
20349
  const report = useCallback2(
@@ -19263,7 +20369,7 @@ function AiSectionOverlay({
19263
20369
  },
19264
20370
  [report]
19265
20371
  );
19266
- useEffect8(() => {
20372
+ useEffect9(() => {
19267
20373
  apiRef.current = {
19268
20374
  selectFromElement,
19269
20375
  handleBackgroundClick: (target, clientX, clientY) => {
@@ -19288,7 +20394,7 @@ function AiSectionOverlay({
19288
20394
  apiRef.current = null;
19289
20395
  };
19290
20396
  }, [apiRef, selectFromElement, report]);
19291
- useEffect8(() => {
20397
+ useEffect9(() => {
19292
20398
  const onMessage = (e) => {
19293
20399
  if (e.data?.type === "ow:ai-select" && e.data.sectionId === null) {
19294
20400
  selectedIdRef.current = null;
@@ -19313,10 +20419,10 @@ function AiSectionOverlay({
19313
20419
  window.addEventListener("message", onMessage);
19314
20420
  return () => window.removeEventListener("message", onMessage);
19315
20421
  }, [postToParent2]);
19316
- useEffect8(() => installAiChangeHighlight((el) => selectFromElement(el)), [selectFromElement]);
19317
- useEffect8(() => installHistoryKeyRelay(), []);
20422
+ useEffect9(() => installAiChangeHighlight((el) => selectFromElement(el)), [selectFromElement]);
20423
+ useEffect9(() => installHistoryKeyRelay(), []);
19318
20424
  const [hoveredId, setHoveredId] = useState7(null);
19319
- useEffect8(() => {
20425
+ useEffect9(() => {
19320
20426
  const onMove = (e) => {
19321
20427
  const t = e.target;
19322
20428
  if (!(t instanceof Element)) return;
@@ -19341,7 +20447,7 @@ function AiSectionOverlay({
19341
20447
  document.documentElement.removeEventListener("mouseleave", onLeave);
19342
20448
  };
19343
20449
  }, []);
19344
- useEffect8(() => {
20450
+ useEffect9(() => {
19345
20451
  const onKeyDown = (e) => {
19346
20452
  if (e.key !== "Escape") return;
19347
20453
  if (reviewIdRef.current) return;
@@ -19365,7 +20471,7 @@ function AiSectionOverlay({
19365
20471
  [postToParent2]
19366
20472
  );
19367
20473
  const [navDropdownForceOpen, setNavDropdownForceOpen] = useState7(false);
19368
- useEffect8(() => {
20474
+ useEffect9(() => {
19369
20475
  const update = () => {
19370
20476
  setNavDropdownForceOpen(Boolean(document.querySelector("[data-ohw-nav-force-open]")));
19371
20477
  };
@@ -19384,7 +20490,7 @@ function AiSectionOverlay({
19384
20490
  const navToggleHole = useLiveNavToggleHole(Boolean(reviewId));
19385
20491
  const hoverRect = useLiveSectionRect(reviewId || hoveredId === selectedId ? null : hoveredId);
19386
20492
  const showSelectionBorder = Boolean(selectionRect) && !navDropdownForceOpen;
19387
- useEffect8(() => {
20493
+ useEffect9(() => {
19388
20494
  const selectedEl = activeSelectionId ? findSectionElement(activeSelectionId) : null;
19389
20495
  if (!activeSelectionId || !selectionRect || selectedEl && isChromeSection(selectedEl)) {
19390
20496
  postToParent2({ type: "ow:section-rect", instanceId: null, rect: null });
@@ -19504,8 +20610,24 @@ function AiSectionOverlay({
19504
20610
  }
19505
20611
 
19506
20612
  // src/ui/ai-section/AiMediaStripOverlay.tsx
19507
- import { useCallback as useCallback3, useEffect as useEffect9, useRef as useRef5, useState as useState8 } from "react";
19508
- import { Star } from "lucide-react";
20613
+ import { useCallback as useCallback3, useEffect as useEffect10, useLayoutEffect as useLayoutEffect4, useRef as useRef5, useState as useState8 } from "react";
20614
+ import {
20615
+ AlignCenter,
20616
+ AlignLeft,
20617
+ AlignRight,
20618
+ ArrowLeft as ArrowLeft2,
20619
+ ArrowRight as ArrowRight2,
20620
+ Check as Check2,
20621
+ ChevronDown as ChevronDown3,
20622
+ Image as ImageIcon2,
20623
+ ImageMinus,
20624
+ ImagePlus,
20625
+ Link as LinkIcon,
20626
+ Minus,
20627
+ Palette,
20628
+ Plus as Plus2,
20629
+ Star
20630
+ } from "lucide-react";
19509
20631
 
19510
20632
  // src/lib/ai-media-strip-tree.ts
19511
20633
  var MEDIA_STRIP_ITEM_MIN = 1;
@@ -19619,14 +20741,6 @@ function setMediaStripItemAsset(tree, index, assetId) {
19619
20741
  return true;
19620
20742
  });
19621
20743
  }
19622
- function setMediaStripItemAlt(tree, index, alt) {
19623
- return withMediaStrip(tree, (block) => {
19624
- const items = block.items;
19625
- if (index < 0 || index >= items.length) return false;
19626
- items[index] = { ...items[index], alt };
19627
- return true;
19628
- });
19629
- }
19630
20744
  function setMediaStripItemLink(tree, index, link) {
19631
20745
  return withMediaStrip(tree, (block) => {
19632
20746
  const items = block.items;
@@ -19644,11 +20758,117 @@ function setMediaStripItemLink(tree, index, link) {
19644
20758
  });
19645
20759
  }
19646
20760
 
20761
+ // src/ui/dialog.tsx
20762
+ import * as React9 from "react";
20763
+ import { Dialog as DialogPrimitive } from "radix-ui";
20764
+ import { X as X2 } from "lucide-react";
20765
+ import { jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
20766
+ function Dialog2({
20767
+ ...props
20768
+ }) {
20769
+ return /* @__PURE__ */ jsx20(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
20770
+ }
20771
+ function DialogPortal({
20772
+ ...props
20773
+ }) {
20774
+ return /* @__PURE__ */ jsx20(DialogPrimitive.Portal, { ...props });
20775
+ }
20776
+ function DialogOverlay({
20777
+ className,
20778
+ ...props
20779
+ }) {
20780
+ return /* @__PURE__ */ jsx20(
20781
+ DialogPrimitive.Overlay,
20782
+ {
20783
+ "data-slot": "dialog-overlay",
20784
+ "data-ohw-link-modal-root": "",
20785
+ className: cn("fixed inset-0 z-[2147483646] bg-black/50", className),
20786
+ ...props
20787
+ }
20788
+ );
20789
+ }
20790
+ var DialogContent = React9.forwardRef(
20791
+ ({ className, children, showCloseButton = true, container, ...props }, ref) => {
20792
+ const positionMode = container ? "absolute" : "fixed";
20793
+ return /* @__PURE__ */ jsxs11(DialogPortal, { container: container ?? void 0, children: [
20794
+ /* @__PURE__ */ jsx20(DialogOverlay, { className: cn(positionMode, "inset-0") }),
20795
+ /* @__PURE__ */ jsxs11(
20796
+ DialogPrimitive.Content,
20797
+ {
20798
+ ref,
20799
+ "data-slot": "dialog-content",
20800
+ className: cn(
20801
+ positionMode,
20802
+ "left-1/2 top-1/2 z-[2147483647] flex w-full max-w-[448px] -translate-x-1/2 -translate-y-1/2 flex-col overflow-visible",
20803
+ "rounded-xl border border-border bg-background font-sans shadow-lg outline-none",
20804
+ container ? "max-h-[calc(100%-32px)]" : "max-h-[calc(100vh-32px)]",
20805
+ className
20806
+ ),
20807
+ onMouseDown: (e) => e.stopPropagation(),
20808
+ ...props,
20809
+ children: [
20810
+ children,
20811
+ showCloseButton ? /* @__PURE__ */ jsx20(
20812
+ DialogPrimitive.Close,
20813
+ {
20814
+ type: "button",
20815
+ className: "absolute right-[9px] top-[9px] rounded-sm p-1.5 text-foreground hover:bg-muted/50",
20816
+ "aria-label": "Close",
20817
+ children: /* @__PURE__ */ jsx20(X2, { size: 16, "aria-hidden": true })
20818
+ }
20819
+ ) : null
20820
+ ]
20821
+ }
20822
+ )
20823
+ ] });
20824
+ }
20825
+ );
20826
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
20827
+ function DialogHeader({
20828
+ className,
20829
+ ...props
20830
+ }) {
20831
+ return /* @__PURE__ */ jsx20("div", { className: cn("flex flex-col gap-1.5", className), ...props });
20832
+ }
20833
+ function DialogFooter({
20834
+ className,
20835
+ ...props
20836
+ }) {
20837
+ return /* @__PURE__ */ jsx20(
20838
+ "div",
20839
+ {
20840
+ className: cn("flex items-center justify-end gap-2", className),
20841
+ ...props
20842
+ }
20843
+ );
20844
+ }
20845
+ var DialogTitle = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx20(
20846
+ DialogPrimitive.Title,
20847
+ {
20848
+ ref,
20849
+ className: cn(
20850
+ "text-lg font-semibold leading-none tracking-tight text-card-foreground",
20851
+ className
20852
+ ),
20853
+ ...props
20854
+ }
20855
+ ));
20856
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
20857
+ var DialogDescription = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx20(
20858
+ DialogPrimitive.Description,
20859
+ {
20860
+ ref,
20861
+ className: cn("text-sm text-muted-foreground", className),
20862
+ ...props
20863
+ }
20864
+ ));
20865
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
20866
+ var DialogClose = DialogPrimitive.Close;
20867
+
19647
20868
  // src/ui/ai-section/AiMediaStripOverlay.tsx
19648
- import { Fragment as Fragment7, jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
19649
- var PRIMARY3 = "#0885FE";
19650
- var OHW_BLUE = `var(--ohw-primary, ${PRIMARY3})`;
19651
- var OHW_BLUE_DARK = `color-mix(in srgb, var(--ohw-primary, ${PRIMARY3}) 60%, #000000)`;
20869
+ import { Fragment as Fragment7, jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
20870
+ var PRIMARY3 = "var(--ohw-primary, #0885FE)";
20871
+ var CHROME_SELECTOR = "[data-ohw-toolbar], [data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-link-modal-root], [data-ohw-section-picker], [data-ohw-ai-review], [data-ohw-more-menu]";
19652
20872
  function findMediaStripItemElement(sectionId, index) {
19653
20873
  const sectionEl2 = findByInstanceId(sectionId);
19654
20874
  if (!sectionEl2) return null;
@@ -19658,22 +20878,43 @@ function findMediaStripItemElement(sectionId, index) {
19658
20878
  }
19659
20879
  return null;
19660
20880
  }
19661
- function readRect2(ref) {
19662
- const el = ref && findMediaStripItemElement(ref.sectionId, ref.index);
20881
+ function itemRefFromTarget(target) {
20882
+ if (!(target instanceof Element)) return null;
20883
+ if (target.closest(CHROME_SELECTOR)) return null;
20884
+ const itemEl = target.closest("[data-ohw-media-strip-item]");
20885
+ if (!itemEl) return null;
20886
+ const sectionEl2 = itemEl.closest("[data-ohw-section]");
20887
+ const unit = sectionEl2 ? movableUnit(sectionEl2) : null;
20888
+ const sectionId = unit ? instanceIdOf(unit) || null : null;
20889
+ const index = Number(itemEl.dataset.ohwMediaStripIndex);
20890
+ if (!sectionId || Number.isNaN(index)) return null;
20891
+ return { sectionId, index };
20892
+ }
20893
+ function sameRef(a, b) {
20894
+ return a?.sectionId === b?.sectionId && a?.index === b?.index;
20895
+ }
20896
+ function rectOf(el) {
19663
20897
  if (!el) return null;
19664
20898
  const r2 = el.getBoundingClientRect();
19665
20899
  if (r2.width <= 0 || r2.height <= 0) return null;
19666
20900
  return { top: r2.top, left: r2.left, width: r2.width, height: r2.height };
19667
20901
  }
19668
- function useLiveItemRect(ref) {
20902
+ function readRect2(ref) {
20903
+ return rectOf(ref && findMediaStripItemElement(ref.sectionId, ref.index));
20904
+ }
20905
+ function readStripRect(ref) {
20906
+ const item = ref && findMediaStripItemElement(ref.sectionId, ref.index);
20907
+ return rectOf(item?.closest("[data-ohw-media-strip]") ?? item);
20908
+ }
20909
+ function useLiveItemRect(ref, strip = false) {
19669
20910
  const [rect, setRect] = useState8(null);
19670
- useEffect9(() => {
20911
+ useEffect10(() => {
19671
20912
  if (!ref) {
19672
20913
  setRect(null);
19673
20914
  return;
19674
20915
  }
19675
20916
  const update = () => {
19676
- const next = readRect2(ref);
20917
+ const next = strip ? readStripRect(ref) : readRect2(ref);
19677
20918
  setRect(
19678
20919
  (prev) => prev && next && prev.top === next.top && prev.left === next.left && prev.width === next.width && prev.height === next.height ? prev : next
19679
20920
  );
@@ -19688,9 +20929,49 @@ function useLiveItemRect(ref) {
19688
20929
  window.removeEventListener("resize", update);
19689
20930
  clearInterval(interval);
19690
20931
  };
19691
- }, [ref?.sectionId, ref?.index]);
20932
+ }, [ref?.sectionId, ref?.index, strip]);
19692
20933
  return rect;
19693
20934
  }
20935
+ var TOOLBAR_STRIP_GAP = 52;
20936
+ var TOOLBAR_STRIP_GAP_MOBILE = 42;
20937
+ var TOOLBAR_EDGE_MARGIN2 = 4;
20938
+ function StripToolbarSlot({ stripRect, children }) {
20939
+ const slotRef = useRef5(null);
20940
+ const [shift, setShift] = useState8(0);
20941
+ const centerX = stripRect.left + stripRect.width / 2;
20942
+ useLayoutEffect4(() => {
20943
+ const slot = slotRef.current;
20944
+ if (!slot) return;
20945
+ const clamp = () => {
20946
+ const w = slot.offsetWidth;
20947
+ if (w <= 0) return;
20948
+ const half = w / 2;
20949
+ const clamped = Math.max(TOOLBAR_EDGE_MARGIN2 + half, Math.min(centerX, window.innerWidth - TOOLBAR_EDGE_MARGIN2 - half));
20950
+ setShift((prev) => Math.abs(prev - (clamped - centerX)) < 0.5 ? prev : clamped - centerX);
20951
+ };
20952
+ clamp();
20953
+ const ro = new ResizeObserver(clamp);
20954
+ ro.observe(slot);
20955
+ return () => ro.disconnect();
20956
+ }, [centerX, children]);
20957
+ const mobile = window.innerWidth <= 480;
20958
+ return /* @__PURE__ */ jsx21(
20959
+ "div",
20960
+ {
20961
+ ref: slotRef,
20962
+ "data-ohw-bridge": "",
20963
+ "data-ohw-item-interaction": "",
20964
+ className: "pointer-events-auto fixed",
20965
+ style: {
20966
+ top: stripRect.top - (mobile ? TOOLBAR_STRIP_GAP_MOBILE : TOOLBAR_STRIP_GAP),
20967
+ left: centerX + shift,
20968
+ transform: "translate(-50%, -100%)",
20969
+ zIndex: 2147483645
20970
+ },
20971
+ children
20972
+ }
20973
+ );
20974
+ }
19694
20975
  function requestValidateTree(postToParent2, tree) {
19695
20976
  return new Promise((resolve) => {
19696
20977
  const id = `ai-validate-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
@@ -19727,116 +21008,72 @@ function requestAssetPick(postToParent2) {
19727
21008
  postToParent2({ type: "ow:asset-pick", id });
19728
21009
  });
19729
21010
  }
19730
- function Pill({
21011
+ function ToolbarAction({
19731
21012
  label,
19732
21013
  onClick,
19733
- disabled,
19734
- active
21014
+ disabled = false,
21015
+ active = false,
21016
+ children
19735
21017
  }) {
19736
- return /* @__PURE__ */ jsx20(
19737
- "button",
19738
- {
19739
- type: "button",
19740
- onClick,
19741
- disabled,
19742
- style: {
19743
- height: 28,
19744
- padding: "0 10px",
19745
- display: "inline-flex",
19746
- alignItems: "center",
19747
- gap: 4,
19748
- borderRadius: 999,
19749
- border: "none",
19750
- cursor: disabled ? "default" : "pointer",
19751
- background: active ? OHW_BLUE_DARK : "#ffffff",
19752
- color: active ? "#ffffff" : OHW_BLUE_DARK,
19753
- opacity: disabled ? 0.4 : 1,
19754
- fontSize: 12,
19755
- lineHeight: "16px",
19756
- fontFamily: "Figtree, ui-sans-serif, system-ui, sans-serif",
19757
- whiteSpace: "nowrap",
19758
- flex: "0 0 auto"
19759
- },
19760
- children: label
19761
- }
19762
- );
21018
+ const button = /* @__PURE__ */ jsx21(CustomToolbarButton, { type: "button", "aria-label": label, disabled, active, onClick, className: "size-8", children });
21019
+ return /* @__PURE__ */ jsxs12(Tooltip, { children: [
21020
+ /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: disabled ? /* @__PURE__ */ jsx21("span", { className: "inline-flex", children: button }) : button }),
21021
+ /* @__PURE__ */ jsx21(TooltipContent, { side: "bottom", sideOffset: 8, children: label })
21022
+ ] });
19763
21023
  }
19764
- function AltInput({ value, onCommit }) {
19765
- const [draft, setDraft] = useState8(value);
19766
- useEffect9(() => setDraft(value), [value]);
19767
- return /* @__PURE__ */ jsxs11(
19768
- "div",
19769
- {
19770
- style: {
19771
- display: "flex",
19772
- alignItems: "center",
19773
- gap: 6,
19774
- height: 28,
19775
- padding: "0 12px",
19776
- borderRadius: 999,
19777
- background: "#ffffff",
19778
- width: "100%",
19779
- maxWidth: 260,
19780
- boxSizing: "border-box"
19781
- },
19782
- children: [
19783
- /* @__PURE__ */ jsx20(
19784
- "span",
19785
- {
19786
- style: {
19787
- flex: "0 0 auto",
19788
- color: OHW_BLUE_DARK,
19789
- fontSize: 10,
19790
- fontWeight: 700,
19791
- textTransform: "uppercase",
19792
- letterSpacing: 0.4
19793
- },
19794
- children: "Alt"
19795
- }
19796
- ),
19797
- /* @__PURE__ */ jsx20(
19798
- "input",
21024
+ function ToolbarSeparator() {
21025
+ return /* @__PURE__ */ jsx21("span", { "aria-hidden": true, className: "mx-0.5 block h-6 w-px shrink-0 bg-border" });
21026
+ }
21027
+ function OptionMenu({
21028
+ label,
21029
+ value,
21030
+ options,
21031
+ onChange
21032
+ }) {
21033
+ const current = options.find((o) => o.value === value) ?? options[0];
21034
+ return /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1.5 pl-1.5", children: [
21035
+ /* @__PURE__ */ jsx21("span", { className: "text-xs text-muted-foreground", children: label }),
21036
+ /* @__PURE__ */ jsxs12(DropdownMenu, { modal: false, children: [
21037
+ /* @__PURE__ */ jsx21(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs12(
21038
+ "button",
21039
+ {
21040
+ type: "button",
21041
+ "aria-label": label,
21042
+ className: "inline-flex h-8 min-w-[76px] items-center gap-[7px] rounded-[6px] bg-transparent px-2 text-[13px] font-medium text-foreground transition-colors hover:bg-muted data-[state=open]:bg-muted",
21043
+ children: [
21044
+ /* @__PURE__ */ jsx21("span", { className: "flex-1 text-left", children: current.label }),
21045
+ /* @__PURE__ */ jsx21(ChevronDown3, { size: 16, style: { pointerEvents: "none" } })
21046
+ ]
21047
+ }
21048
+ ) }),
21049
+ /* @__PURE__ */ jsx21(DropdownMenuContent, { align: "end", sideOffset: 8, className: "w-[132px] min-w-[132px] p-1", children: options.map((option) => {
21050
+ const selected = option.value === value;
21051
+ return /* @__PURE__ */ jsxs12(
21052
+ DropdownMenuItem,
19799
21053
  {
19800
- type: "text",
19801
- value: draft,
19802
- onChange: (e) => setDraft(e.target.value),
19803
- onBlur: () => {
19804
- if (draft !== value) onCommit(draft);
19805
- },
19806
- onKeyDown: (e) => {
19807
- if (e.key === "Enter") e.currentTarget.blur();
19808
- if (e.key === "Escape") {
19809
- setDraft(value);
19810
- e.currentTarget.blur();
19811
- }
19812
- },
19813
- placeholder: "Describe this image",
19814
- "aria-label": "Image alt text",
19815
- style: {
19816
- flex: 1,
19817
- minWidth: 0,
19818
- border: "none",
19819
- outline: "none",
19820
- background: "transparent",
19821
- fontSize: 12,
19822
- lineHeight: "16px",
19823
- fontFamily: "Figtree, ui-sans-serif, system-ui, sans-serif",
19824
- color: "#1f2937"
19825
- }
19826
- }
19827
- )
19828
- ]
19829
- }
19830
- );
21054
+ role: "menuitemradio",
21055
+ "aria-checked": selected,
21056
+ onSelect: () => onChange(option.value),
21057
+ className: cn("grid grid-cols-[1fr_16px] gap-2 py-2 pl-2 pr-2 text-[13px]", selected && "bg-muted"),
21058
+ children: [
21059
+ /* @__PURE__ */ jsx21("span", { children: option.label }),
21060
+ selected && /* @__PURE__ */ jsx21(Check2, { size: 16, className: "text-bridge-primary" })
21061
+ ]
21062
+ },
21063
+ option.value
21064
+ );
21065
+ }) })
21066
+ ] })
21067
+ ] });
19831
21068
  }
19832
21069
  var VARIANTS = [
19833
21070
  { value: "logos", label: "Logos" },
19834
21071
  { value: "reel", label: "Reel" }
19835
21072
  ];
19836
21073
  var ALIGNS = [
19837
- { value: "left", label: "Left" },
19838
- { value: "center", label: "Center" },
19839
- { value: "right", label: "Right" }
21074
+ { value: "left", label: "Align left", Icon: AlignLeft },
21075
+ { value: "center", label: "Align center", Icon: AlignCenter },
21076
+ { value: "right", label: "Align right", Icon: AlignRight }
19840
21077
  ];
19841
21078
  var HOVERS = [
19842
21079
  { value: "none", label: "None" },
@@ -19844,104 +21081,104 @@ var HOVERS = [
19844
21081
  { value: "zoom", label: "Zoom" },
19845
21082
  { value: "fade", label: "Fade" }
19846
21083
  ];
19847
- var TREATMENTS = [
19848
- { value: "color", label: "Color" },
19849
- { value: "grayscale", label: "Grayscale" }
19850
- ];
19851
21084
  var HTTP_URL_RE = /^https?:\/\/\S+$/i;
19852
- function LinkInput({ value, onCommit }) {
19853
- const [draft, setDraft] = useState8(value);
21085
+ function LinkModal({
21086
+ href,
21087
+ linkTarget,
21088
+ onClose,
21089
+ onSave
21090
+ }) {
21091
+ const [draft, setDraft] = useState8(href);
21092
+ const [newTab, setNewTab] = useState8(linkTarget !== "same-tab");
19854
21093
  const [invalid, setInvalid] = useState8(false);
19855
- useEffect9(() => {
19856
- setDraft(value);
19857
- setInvalid(false);
19858
- }, [value]);
19859
- const commit2 = () => {
21094
+ const save = () => {
19860
21095
  const next = draft.trim();
19861
- if (next === value) return setInvalid(false);
19862
- if (next && !HTTP_URL_RE.test(next)) return setInvalid(true);
19863
- setInvalid(false);
19864
- onCommit(next);
19865
- };
19866
- return /* @__PURE__ */ jsxs11(
19867
- "div",
19868
- {
19869
- style: {
19870
- display: "flex",
19871
- alignItems: "center",
19872
- gap: 6,
19873
- height: 28,
19874
- padding: "0 12px",
19875
- borderRadius: 999,
19876
- background: "#ffffff",
19877
- width: "100%",
19878
- maxWidth: 260,
19879
- boxSizing: "border-box",
19880
- boxShadow: invalid ? "inset 0 0 0 1.5px #EF4444" : "none"
19881
- },
19882
- children: [
19883
- /* @__PURE__ */ jsx20(
19884
- "span",
19885
- {
19886
- style: {
19887
- flex: "0 0 auto",
19888
- color: OHW_BLUE_DARK,
19889
- fontSize: 10,
19890
- fontWeight: 700,
19891
- textTransform: "uppercase",
19892
- letterSpacing: 0.4
19893
- },
19894
- children: "Link"
19895
- }
19896
- ),
19897
- /* @__PURE__ */ jsx20(
19898
- "input",
19899
- {
19900
- type: "text",
19901
- inputMode: "url",
19902
- value: draft,
19903
- onChange: (e) => setDraft(e.target.value),
19904
- onBlur: commit2,
19905
- onKeyDown: (e) => {
19906
- if (e.key === "Enter") e.currentTarget.blur();
19907
- if (e.key === "Escape") {
19908
- setDraft(value);
19909
- setInvalid(false);
19910
- e.currentTarget.blur();
19911
- }
19912
- },
19913
- placeholder: "https://example.com",
19914
- "aria-label": "Image link URL",
19915
- "aria-invalid": invalid,
19916
- style: {
19917
- flex: 1,
19918
- minWidth: 0,
19919
- border: "none",
19920
- outline: "none",
19921
- background: "transparent",
19922
- fontSize: 12,
19923
- lineHeight: "16px",
19924
- fontFamily: "Figtree, ui-sans-serif, system-ui, sans-serif",
19925
- color: "#1f2937"
19926
- }
19927
- }
19928
- )
19929
- ]
21096
+ if (next && !HTTP_URL_RE.test(next)) {
21097
+ setInvalid(true);
21098
+ return;
19930
21099
  }
19931
- );
21100
+ onSave(next, newTab ? "new-tab" : "same-tab");
21101
+ onClose();
21102
+ };
21103
+ return /* @__PURE__ */ jsx21(Dialog2, { open: true, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs12(DialogContent, { "data-ohw-link-modal-root": "", className: "max-w-[400px] gap-4 p-5", children: [
21104
+ /* @__PURE__ */ jsx21(DialogHeader, { children: /* @__PURE__ */ jsx21(DialogTitle, { className: "text-base", children: "Image link" }) }),
21105
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-3", children: [
21106
+ /* @__PURE__ */ jsx21(
21107
+ "input",
21108
+ {
21109
+ autoFocus: true,
21110
+ type: "text",
21111
+ inputMode: "url",
21112
+ value: draft,
21113
+ onChange: (e) => {
21114
+ setDraft(e.target.value);
21115
+ setInvalid(false);
21116
+ },
21117
+ onKeyDown: (e) => {
21118
+ if (e.key === "Enter") save();
21119
+ },
21120
+ placeholder: "https://example.com",
21121
+ "aria-label": "Image link URL",
21122
+ "aria-invalid": invalid,
21123
+ className: cn(
21124
+ "h-9 w-full rounded-[6px] border border-border bg-background px-3 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/70 focus:border-bridge-primary",
21125
+ invalid && "border-destructive focus:border-destructive"
21126
+ )
21127
+ }
21128
+ ),
21129
+ invalid && /* @__PURE__ */ jsx21("p", { className: "text-xs text-destructive", children: "Enter a full URL starting with http:// or https://" }),
21130
+ /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-2 text-[13px] text-foreground", children: [
21131
+ /* @__PURE__ */ jsx21("input", { type: "checkbox", checked: newTab, onChange: (e) => setNewTab(e.target.checked) }),
21132
+ "Open in new tab"
21133
+ ] })
21134
+ ] }),
21135
+ /* @__PURE__ */ jsxs12(DialogFooter, { children: [
21136
+ href && /* @__PURE__ */ jsx21(
21137
+ "button",
21138
+ {
21139
+ type: "button",
21140
+ onClick: () => {
21141
+ onSave("", "new-tab");
21142
+ onClose();
21143
+ },
21144
+ className: "mr-auto rounded-[6px] px-3 py-2 text-[13px] font-medium text-destructive transition-colors hover:bg-muted",
21145
+ children: "Remove link"
21146
+ }
21147
+ ),
21148
+ /* @__PURE__ */ jsx21(
21149
+ "button",
21150
+ {
21151
+ type: "button",
21152
+ onClick: onClose,
21153
+ className: "rounded-[6px] px-3 py-2 text-[13px] font-medium text-foreground transition-colors hover:bg-muted",
21154
+ children: "Cancel"
21155
+ }
21156
+ ),
21157
+ /* @__PURE__ */ jsx21(
21158
+ "button",
21159
+ {
21160
+ type: "button",
21161
+ onClick: save,
21162
+ className: "rounded-[6px] bg-bridge-primary px-3 py-2 text-[13px] font-medium text-primary-foreground transition-opacity hover:opacity-90",
21163
+ children: "Save"
21164
+ }
21165
+ )
21166
+ ] })
21167
+ ] }) });
19932
21168
  }
19933
21169
  function MediaStripToolbar({
19934
21170
  entry,
19935
21171
  index,
19936
21172
  pending,
19937
21173
  error,
21174
+ itemEditOn,
21175
+ onToggleItemEdit,
19938
21176
  onSetVariant,
19939
21177
  onSetAlign,
19940
21178
  onSetHover,
19941
21179
  onSetTreatment,
19942
21180
  onResize,
19943
- onSetAlt,
19944
- onSetLink,
21181
+ onOpenLink,
19945
21182
  onAddItem,
19946
21183
  onRemoveItem,
19947
21184
  onChangeImage,
@@ -19950,81 +21187,102 @@ function MediaStripToolbar({
19950
21187
  }) {
19951
21188
  const items = mediaStripItems(entry.tree);
19952
21189
  const itemCount = items.length;
19953
- const currentAlt = items[index]?.alt ?? "";
19954
- const currentHref2 = items[index]?.href ?? "";
19955
- const currentTarget = items[index]?.linkTarget === "same-tab" ? "same-tab" : "new-tab";
19956
21190
  const slots = findMediaStripSlots(entry.tree);
19957
21191
  const variant = slots?.variant === "reel" ? "reel" : "logos";
19958
21192
  const align = slots?.align === "left" || slots?.align === "right" ? slots.align : "center";
19959
21193
  const hover = slots?.hover === "none" || slots?.hover === "lift" || slots?.hover === "zoom" || slots?.hover === "fade" ? slots.hover : "lift";
19960
21194
  const treatment = slots?.treatment === "color" || slots?.treatment === "grayscale" ? slots.treatment : variant === "logos" ? "grayscale" : "color";
19961
21195
  const sizeValue = variant === "logos" ? typeof slots?.logoMaxHeight === "number" ? slots.logoMaxHeight : 48 : typeof slots?.cardWidth === "number" ? slots.cardWidth : 240;
19962
- const isMobile = window.innerWidth <= 480;
19963
- const rowStyle = isMobile ? {
19964
- display: "flex",
19965
- gap: 6,
19966
- flexWrap: "nowrap",
19967
- justifyContent: "center",
19968
- overflowX: "auto",
19969
- WebkitOverflowScrolling: "touch",
19970
- width: "100%",
19971
- scrollbarWidth: "none"
19972
- } : { display: "flex", gap: 6, flexWrap: "nowrap", justifyContent: "center" };
19973
- return /* @__PURE__ */ jsxs11(
21196
+ const mobile = window.innerWidth <= 480;
21197
+ const gatedLabel = (label) => itemEditOn ? label : "Turn on the star to edit this image";
21198
+ return /* @__PURE__ */ jsx21(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs12(
19974
21199
  "div",
19975
21200
  {
19976
21201
  "data-ohw-bridge": "",
19977
21202
  "data-ohw-toolbar": "",
19978
21203
  onMouseDown: (e) => e.stopPropagation(),
19979
- style: {
19980
- display: "flex",
19981
- flexDirection: "column",
19982
- gap: 6,
19983
- alignItems: "center",
19984
- background: OHW_BLUE,
19985
- padding: 8,
19986
- borderRadius: 12,
19987
- boxShadow: "0 8px 24px rgba(0,0,0,0.25)",
19988
- pointerEvents: pending ? "none" : "auto",
19989
- opacity: pending ? 0.6 : 1,
19990
- maxWidth: isMobile ? "calc(100vw - 24px)" : "none"
19991
- },
21204
+ className: cn("flex flex-col items-center gap-1.5 font-sans", pending && "pointer-events-none opacity-60"),
21205
+ style: { maxWidth: mobile ? "calc(100vw - 24px)" : void 0 },
19992
21206
  children: [
19993
- /* @__PURE__ */ jsxs11("div", { style: rowStyle, children: [
19994
- VARIANTS.map((v) => /* @__PURE__ */ jsx20(Pill, { label: v.label, active: variant === v.value, onClick: () => onSetVariant(v.value) }, v.value)),
19995
- ALIGNS.map((a) => /* @__PURE__ */ jsx20(Pill, { label: a.label, active: align === a.value, onClick: () => onSetAlign(a.value) }, a.value))
19996
- ] }),
19997
- /* @__PURE__ */ jsxs11("div", { style: rowStyle, children: [
19998
- HOVERS.map((h) => /* @__PURE__ */ jsx20(Pill, { label: h.label, active: hover === h.value, onClick: () => onSetHover(h.value) }, h.value)),
19999
- TREATMENTS.map((t) => /* @__PURE__ */ jsx20(Pill, { label: t.label, active: treatment === t.value, onClick: () => onSetTreatment(t.value) }, t.value))
20000
- ] }),
20001
- /* @__PURE__ */ jsxs11("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
20002
- /* @__PURE__ */ jsx20(Pill, { label: "\u2212", onClick: () => onResize(-8) }),
20003
- /* @__PURE__ */ jsxs11("span", { style: { color: "#ffffff", fontSize: 12, minWidth: 34, textAlign: "center" }, children: [
20004
- sizeValue,
20005
- "px"
20006
- ] }),
20007
- /* @__PURE__ */ jsx20(Pill, { label: "+", onClick: () => onResize(8) })
20008
- ] }),
20009
- /* @__PURE__ */ jsx20("div", { style: { display: "flex", justifyContent: "center", width: "100%" }, children: /* @__PURE__ */ jsx20(AltInput, { value: currentAlt, onCommit: onSetAlt }) }),
20010
- /* @__PURE__ */ jsx20("div", { style: { display: "flex", justifyContent: "center", width: "100%" }, children: /* @__PURE__ */ jsx20(LinkInput, { value: currentHref2, onCommit: (href) => onSetLink(href, currentTarget) }) }),
20011
- currentHref2 && /* @__PURE__ */ jsxs11("div", { style: rowStyle, children: [
20012
- /* @__PURE__ */ jsx20(Pill, { label: "New tab", active: currentTarget === "new-tab", onClick: () => onSetLink(currentHref2, "new-tab") }),
20013
- /* @__PURE__ */ jsx20(Pill, { label: "Same tab", active: currentTarget === "same-tab", onClick: () => onSetLink(currentHref2, "same-tab") })
20014
- ] }),
20015
- /* @__PURE__ */ jsxs11("div", { style: rowStyle, children: [
20016
- /* @__PURE__ */ jsx20(Pill, { label: "Change Image", onClick: onChangeImage }),
20017
- /* @__PURE__ */ jsx20(Pill, { label: "+ Item", onClick: onAddItem }),
20018
- /* @__PURE__ */ jsx20(Pill, { label: "\u2212 Item", onClick: onRemoveItem, disabled: itemCount <= 1 })
20019
- ] }),
20020
- /* @__PURE__ */ jsxs11("div", { style: rowStyle, children: [
20021
- /* @__PURE__ */ jsx20(Pill, { label: "\u2190 Move", onClick: onMoveLeft, disabled: index <= 0 }),
20022
- /* @__PURE__ */ jsx20(Pill, { label: "\u2192 Move", onClick: onMoveRight, disabled: index >= itemCount - 1 })
20023
- ] }),
20024
- error && /* @__PURE__ */ jsx20("div", { style: { color: "#FCA5A5", fontSize: 11, maxWidth: 220, textAlign: "center" }, children: error })
21207
+ /* @__PURE__ */ jsxs12(
21208
+ "div",
21209
+ {
21210
+ className: cn(
21211
+ "flex items-center gap-1 rounded-[10px] border border-border bg-background p-1 whitespace-nowrap",
21212
+ "shadow-[0px_10px_15px_-3px_rgba(0,0,0,0.1),0px_4px_6px_-4px_rgba(0,0,0,0.1)]",
21213
+ mobile ? "flex-wrap justify-center" : "flex-nowrap"
21214
+ ),
21215
+ children: [
21216
+ /* @__PURE__ */ jsxs12(Tooltip, { children: [
21217
+ /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx21(
21218
+ CustomToolbarButton,
21219
+ {
21220
+ type: "button",
21221
+ "aria-label": itemEditOn ? "Done editing this image" : "Edit this image",
21222
+ "aria-pressed": itemEditOn,
21223
+ onClick: onToggleItemEdit,
21224
+ className: "group size-8",
21225
+ children: /* @__PURE__ */ jsx21(
21226
+ Star,
21227
+ {
21228
+ size: 16,
21229
+ fill: "currentColor",
21230
+ strokeWidth: 0,
21231
+ className: cn(
21232
+ "transition-colors",
21233
+ itemEditOn ? "text-[#f59e0b] group-hover:text-[#d97706]" : "text-[#d6d3d1] group-hover:text-[#fbbf24]"
21234
+ ),
21235
+ style: { pointerEvents: "none" }
21236
+ }
21237
+ )
21238
+ }
21239
+ ) }),
21240
+ /* @__PURE__ */ jsx21(TooltipContent, { side: "bottom", sideOffset: 8, children: itemEditOn ? "Done editing this image" : "Edit this image" })
21241
+ ] }),
21242
+ /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
21243
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: gatedLabel("Change image"), onClick: onChangeImage, disabled: !itemEditOn, children: /* @__PURE__ */ jsx21(ImageIcon2, { size: 16, style: { pointerEvents: "none" } }) }),
21244
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: gatedLabel("Link"), onClick: onOpenLink, disabled: !itemEditOn, children: /* @__PURE__ */ jsx21(LinkIcon, { size: 16, style: { pointerEvents: "none" } }) }),
21245
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: gatedLabel("Move left"), onClick: onMoveLeft, disabled: !itemEditOn || index <= 0, children: /* @__PURE__ */ jsx21(ArrowLeft2, { size: 16, style: { pointerEvents: "none" } }) }),
21246
+ /* @__PURE__ */ jsx21(
21247
+ ToolbarAction,
21248
+ {
21249
+ label: gatedLabel("Move right"),
21250
+ onClick: onMoveRight,
21251
+ disabled: !itemEditOn || index >= itemCount - 1,
21252
+ children: /* @__PURE__ */ jsx21(ArrowRight2, { size: 16, style: { pointerEvents: "none" } })
21253
+ }
21254
+ ),
21255
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: gatedLabel("Remove image"), onClick: onRemoveItem, disabled: !itemEditOn || itemCount <= 1, children: /* @__PURE__ */ jsx21(ImageMinus, { size: 16, style: { pointerEvents: "none" } }) }),
21256
+ /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
21257
+ /* @__PURE__ */ jsx21(OptionMenu, { label: "Layout", value: variant, options: VARIANTS, onChange: onSetVariant }),
21258
+ /* @__PURE__ */ jsx21(OptionMenu, { label: "Hover", value: hover, options: HOVERS, onChange: onSetHover }),
21259
+ /* @__PURE__ */ jsx21(
21260
+ ToolbarAction,
21261
+ {
21262
+ label: treatment === "grayscale" ? "Show in color" : "Show grayscale",
21263
+ active: treatment === "grayscale",
21264
+ onClick: () => onSetTreatment(treatment === "grayscale" ? "color" : "grayscale"),
21265
+ children: /* @__PURE__ */ jsx21(Palette, { size: 16, style: { pointerEvents: "none" } })
21266
+ }
21267
+ ),
21268
+ /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
21269
+ ALIGNS.map(({ value, label, Icon }) => /* @__PURE__ */ jsx21(ToolbarAction, { label, active: align === value, onClick: () => onSetAlign(value), children: /* @__PURE__ */ jsx21(Icon, { size: 16, style: { pointerEvents: "none" } }) }, value)),
21270
+ /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
21271
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: "Smaller", onClick: () => onResize(-8), children: /* @__PURE__ */ jsx21(Minus, { size: 16, style: { pointerEvents: "none" } }) }),
21272
+ /* @__PURE__ */ jsxs12("span", { className: "min-w-[40px] text-center text-xs tabular-nums text-muted-foreground", children: [
21273
+ sizeValue,
21274
+ "px"
21275
+ ] }),
21276
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: "Larger", onClick: () => onResize(8), children: /* @__PURE__ */ jsx21(Plus2, { size: 16, style: { pointerEvents: "none" } }) }),
21277
+ /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
21278
+ /* @__PURE__ */ jsx21(ToolbarAction, { label: "Add image", onClick: onAddItem, children: /* @__PURE__ */ jsx21(ImagePlus, { size: 16, style: { pointerEvents: "none" } }) })
21279
+ ]
21280
+ }
21281
+ ),
21282
+ error && /* @__PURE__ */ jsx21("div", { className: "max-w-[260px] rounded-md bg-background px-2 py-1 text-center text-[11px] text-destructive shadow-sm", children: error })
20025
21283
  ]
20026
21284
  }
20027
- );
21285
+ ) });
20028
21286
  }
20029
21287
  function findMediaStripSlots(tree) {
20030
21288
  const stack = tree.rows.flatMap((row) => row.blocks);
@@ -20043,31 +21301,23 @@ function AiMediaStripOverlay({
20043
21301
  }) {
20044
21302
  const [hover, setHover] = useState8(null);
20045
21303
  const [active, setActive] = useState8(null);
21304
+ const [itemEditOn, setItemEditOn] = useState8(false);
21305
+ const [linkOpen, setLinkOpen] = useState8(false);
20046
21306
  const [pending, setPending] = useState8(false);
20047
21307
  const [error, setError] = useState8(null);
20048
21308
  const activeRef = useRef5(null);
20049
21309
  activeRef.current = active;
20050
- useEffect9(() => {
21310
+ const linkOpenRef = useRef5(false);
21311
+ linkOpenRef.current = linkOpen;
21312
+ useEffect10(() => {
20051
21313
  const onMove = (e) => {
21314
+ const ref = itemRefFromTarget(e.target);
20052
21315
  const t = e.target;
20053
- if (!(t instanceof HTMLElement)) return;
20054
- if (t.closest("[data-ohw-toolbar], [data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-link-modal-root], [data-ohw-section-picker], [data-ohw-ai-review]")) {
20055
- return;
20056
- }
20057
- const itemEl = t.closest("[data-ohw-media-strip-item]");
20058
- if (!itemEl) {
20059
- setHover(null);
20060
- return;
20061
- }
20062
- const sectionEl2 = itemEl.closest("[data-ohw-section]");
20063
- const unit = sectionEl2 ? movableUnit(sectionEl2) : null;
20064
- const sectionId = unit ? instanceIdOf(unit) || null : null;
20065
- const index = Number(itemEl.dataset.ohwMediaStripIndex);
20066
- if (!sectionId || Number.isNaN(index)) {
20067
- setHover(null);
20068
- return;
20069
- }
20070
- setHover({ sectionId, index });
21316
+ const overEditable = Boolean(t?.closest?.("[data-ohw-editable]"));
21317
+ setHover((prev) => {
21318
+ const next = ref && !overEditable ? ref : null;
21319
+ return sameRef(prev, next) ? prev : next;
21320
+ });
20071
21321
  };
20072
21322
  const onLeave = () => setHover(null);
20073
21323
  document.addEventListener("mousemove", onMove, { passive: true });
@@ -20077,35 +21327,40 @@ function AiMediaStripOverlay({
20077
21327
  document.documentElement.removeEventListener("mouseleave", onLeave);
20078
21328
  };
20079
21329
  }, []);
20080
- useEffect9(() => {
21330
+ useEffect10(() => {
20081
21331
  const onClick = (e) => {
20082
- const current = activeRef.current;
20083
- if (!current) return;
20084
21332
  const t = e.target;
20085
- if (!(t instanceof HTMLElement)) return;
20086
- if (t.closest("[data-ohw-item-interaction]")) return;
20087
- const itemEl = findMediaStripItemElement(current.sectionId, current.index);
20088
- if (itemEl && itemEl.contains(t)) return;
20089
- setActive(null);
21333
+ if (!(t instanceof Element)) return;
21334
+ if (t.closest(CHROME_SELECTOR)) return;
21335
+ const ref = itemRefFromTarget(t);
21336
+ if (sameRef(activeRef.current, ref)) return;
21337
+ if (ref) clearInteractionChromeRef.current();
21338
+ setItemEditOn(false);
20090
21339
  setError(null);
21340
+ setActive(ref);
20091
21341
  };
20092
21342
  document.addEventListener("click", onClick, true);
20093
21343
  return () => document.removeEventListener("click", onClick, true);
20094
- }, []);
20095
- useEffect9(() => {
21344
+ }, [clearInteractionChromeRef]);
21345
+ useEffect10(() => {
20096
21346
  const onBlur = () => {
20097
21347
  if (!activeRef.current) return;
20098
21348
  setActive(null);
21349
+ setItemEditOn(false);
21350
+ setLinkOpen(false);
20099
21351
  setError(null);
20100
21352
  };
20101
21353
  window.addEventListener("blur", onBlur);
20102
21354
  return () => window.removeEventListener("blur", onBlur);
20103
21355
  }, []);
20104
- useEffect9(() => {
21356
+ useEffect10(() => {
20105
21357
  const onKeyDown = (e) => {
20106
21358
  if (e.key !== "Escape") return;
20107
21359
  if (!activeRef.current) return;
21360
+ if (linkOpenRef.current) return;
21361
+ if (document.querySelector('[data-ohw-more-menu][data-state="open"]')) return;
20108
21362
  setActive(null);
21363
+ setItemEditOn(false);
20109
21364
  setError(null);
20110
21365
  };
20111
21366
  document.addEventListener("keydown", onKeyDown);
@@ -20139,137 +21394,133 @@ function AiMediaStripOverlay({
20139
21394
  tree: nextTree,
20140
21395
  label: entry.label,
20141
21396
  media: extraMedia ? { ...entry.media, ...extraMedia } : entry.media,
20142
- ...entry.brand ? { brand: entry.brand } : {}
21397
+ ...entry.brand ? { brand: entry.brand } : {},
21398
+ // The user is already looking at the strip they just edited — recentering the viewport
21399
+ // on every edit reads as the section jumping around.
21400
+ skipScrollIntoView: true
20143
21401
  });
20144
21402
  return true;
20145
21403
  },
20146
21404
  [findEntry, postToParent2, applyTreeLocalRef]
20147
21405
  );
20148
21406
  const activeEntry = active ? findEntry(active.sectionId) : null;
20149
- const hoverHandleRect = useLiveItemRect(!active && hover ? hover : null);
20150
21407
  const activeItemRect = useLiveItemRect(active);
20151
- const TOOLBAR_APPROX_H = 170;
20152
- const toolbarState = activeItemRect && activeItemRect.top < TOOLBAR_APPROX_H ? "active-bottom" : "active-top";
20153
- return /* @__PURE__ */ jsxs11(Fragment7, { children: [
20154
- hoverHandleRect && hover && /* @__PURE__ */ jsx20(
20155
- "button",
20156
- {
20157
- type: "button",
20158
- "data-ohw-toolbar": "",
20159
- onClick: () => {
20160
- clearInteractionChromeRef.current();
20161
- setActive(hover);
20162
- },
20163
- "aria-label": "Configure media item",
20164
- style: {
20165
- position: "fixed",
20166
- top: hoverHandleRect.top + 8,
20167
- left: hoverHandleRect.left + hoverHandleRect.width - 36,
20168
- width: 28,
20169
- height: 28,
20170
- borderRadius: 8,
20171
- border: `1.5px dashed ${PRIMARY3}`,
20172
- background: "#ffffff",
20173
- color: PRIMARY3,
20174
- display: "flex",
20175
- alignItems: "center",
20176
- justifyContent: "center",
20177
- cursor: "pointer",
20178
- zIndex: 2147483643,
20179
- fontSize: 14,
20180
- fontWeight: 700
20181
- },
20182
- children: /* @__PURE__ */ jsx20(Star, { size: 14, style: { pointerEvents: "none" } })
20183
- }
20184
- ),
20185
- activeItemRect && active && activeEntry && /* @__PURE__ */ jsx20(
20186
- ItemInteractionLayer,
20187
- {
20188
- rect: activeItemRect,
20189
- state: toolbarState,
20190
- toolbar: /* @__PURE__ */ jsx20(
20191
- MediaStripToolbar,
20192
- {
20193
- entry: activeEntry,
20194
- index: active.index,
20195
- pending,
20196
- error,
20197
- onSetVariant: (variant) => runMutation(active.sectionId, (tree) => setMediaStripVariant(tree, variant)),
20198
- onSetAlign: (align) => runMutation(active.sectionId, (tree) => setMediaStripAlign(tree, align)),
20199
- onSetHover: (hoverPreset) => runMutation(active.sectionId, (tree) => setMediaStripHover(tree, hoverPreset)),
20200
- onSetTreatment: (treatment) => runMutation(active.sectionId, (tree) => setMediaStripTreatment(tree, treatment)),
20201
- onResize: (delta) => {
20202
- const slots = findMediaStripSlots(activeEntry.tree);
20203
- const variant = slots?.variant === "reel" ? "reel" : "logos";
20204
- const current = variant === "logos" ? typeof slots?.logoMaxHeight === "number" ? slots.logoMaxHeight : 48 : typeof slots?.cardWidth === "number" ? slots.cardWidth : 240;
20205
- void runMutation(active.sectionId, (tree) => setMediaStripSizing(tree, current + delta));
20206
- },
20207
- onSetAlt: (alt) => {
20208
- void runMutation(active.sectionId, (tree) => setMediaStripItemAlt(tree, active.index, alt));
20209
- },
20210
- onSetLink: (href, linkTarget) => {
21408
+ const activeStripRect = useLiveItemRect(active, true);
21409
+ const hoverRect = useLiveItemRect(hover && !sameRef(hover, active) ? hover : null);
21410
+ const activeItems = activeEntry ? mediaStripItems(activeEntry.tree) : [];
21411
+ const activeItem = active ? activeItems[active.index] : void 0;
21412
+ const activeHref = activeItem?.href ?? "";
21413
+ const activeTarget = activeItem?.linkTarget === "same-tab" ? "same-tab" : "new-tab";
21414
+ return /* @__PURE__ */ jsxs12(Fragment7, { children: [
21415
+ hoverRect && /* @__PURE__ */ jsx21(ItemInteractionLayer, { rect: hoverRect, state: "hover" }),
21416
+ activeItemRect && activeStripRect && active && activeEntry && /* @__PURE__ */ jsxs12(Fragment7, { children: [
21417
+ /* @__PURE__ */ jsx21(ItemInteractionLayer, { rect: activeItemRect, state: "active-top" }),
21418
+ /* @__PURE__ */ jsx21(StripToolbarSlot, { stripRect: activeStripRect, children: /* @__PURE__ */ jsx21(
21419
+ MediaStripToolbar,
21420
+ {
21421
+ entry: activeEntry,
21422
+ index: active.index,
21423
+ pending,
21424
+ error,
21425
+ itemEditOn,
21426
+ onToggleItemEdit: () => setItemEditOn((on) => !on),
21427
+ onSetVariant: (variant) => runMutation(active.sectionId, (tree) => setMediaStripVariant(tree, variant)),
21428
+ onSetAlign: (align) => runMutation(active.sectionId, (tree) => setMediaStripAlign(tree, align)),
21429
+ onSetHover: (hoverPreset) => runMutation(active.sectionId, (tree) => setMediaStripHover(tree, hoverPreset)),
21430
+ onSetTreatment: (treatment) => runMutation(active.sectionId, (tree) => setMediaStripTreatment(tree, treatment)),
21431
+ onResize: (delta) => {
21432
+ const slots = findMediaStripSlots(activeEntry.tree);
21433
+ const variant = slots?.variant === "reel" ? "reel" : "logos";
21434
+ const current = variant === "logos" ? typeof slots?.logoMaxHeight === "number" ? slots.logoMaxHeight : 48 : typeof slots?.cardWidth === "number" ? slots.cardWidth : 240;
21435
+ void runMutation(active.sectionId, (tree) => setMediaStripSizing(tree, current + delta));
21436
+ },
21437
+ onOpenLink: () => setLinkOpen(true),
21438
+ onAddItem: () => {
21439
+ void requestAssetPick(postToParent2).then((picked) => {
21440
+ if (!picked) return;
21441
+ const item = { assetId: picked.assetId, alt: "Logo" };
20211
21442
  void runMutation(
20212
21443
  active.sectionId,
20213
- (tree) => setMediaStripItemLink(tree, active.index, href ? { href, linkTarget } : {})
20214
- );
20215
- },
20216
- onAddItem: () => {
20217
- void requestAssetPick(postToParent2).then((picked) => {
20218
- if (!picked) return;
20219
- const item = { assetId: picked.assetId, alt: "Logo" };
20220
- void runMutation(
20221
- active.sectionId,
20222
- (tree) => addMediaStripItem(tree, item, active.index),
20223
- { [picked.assetId]: picked.url }
20224
- ).then((applied) => {
20225
- if (applied) setActive({ sectionId: active.sectionId, index: active.index + 1 });
20226
- });
21444
+ (tree) => addMediaStripItem(tree, item, active.index),
21445
+ { [picked.assetId]: picked.url }
21446
+ ).then((applied) => {
21447
+ if (applied) setActive({ sectionId: active.sectionId, index: active.index + 1 });
20227
21448
  });
20228
- },
20229
- onChangeImage: () => {
20230
- void requestAssetPick(postToParent2).then((picked) => {
20231
- if (!picked) return;
20232
- void runMutation(
20233
- active.sectionId,
20234
- (tree) => setMediaStripItemAsset(tree, active.index, picked.assetId),
20235
- { [picked.assetId]: picked.url }
20236
- );
20237
- });
20238
- },
20239
- onRemoveItem: () => {
20240
- void runMutation(active.sectionId, (tree) => removeMediaStripItem(tree, active.index)).then(
20241
- (applied) => {
20242
- if (applied) setActive(null);
20243
- }
20244
- );
20245
- },
20246
- onMoveLeft: () => {
20247
- void runMutation(active.sectionId, (tree) => reorderMediaStripItem(tree, active.index, -1)).then(
20248
- (applied) => {
20249
- if (applied) setActive({ sectionId: active.sectionId, index: active.index - 1 });
20250
- }
20251
- );
20252
- },
20253
- onMoveRight: () => {
20254
- void runMutation(active.sectionId, (tree) => reorderMediaStripItem(tree, active.index, 1)).then(
20255
- (applied) => {
20256
- if (applied) setActive({ sectionId: active.sectionId, index: active.index + 1 });
20257
- }
21449
+ });
21450
+ },
21451
+ onChangeImage: () => {
21452
+ void requestAssetPick(postToParent2).then((picked) => {
21453
+ if (!picked) return;
21454
+ void runMutation(
21455
+ active.sectionId,
21456
+ (tree) => setMediaStripItemAsset(tree, active.index, picked.assetId),
21457
+ { [picked.assetId]: picked.url }
20258
21458
  );
20259
- }
21459
+ });
21460
+ },
21461
+ onRemoveItem: () => {
21462
+ void runMutation(active.sectionId, (tree) => removeMediaStripItem(tree, active.index)).then(
21463
+ (applied) => {
21464
+ if (applied) setActive(null);
21465
+ }
21466
+ );
21467
+ },
21468
+ onMoveLeft: () => {
21469
+ void runMutation(active.sectionId, (tree) => reorderMediaStripItem(tree, active.index, -1)).then(
21470
+ (applied) => {
21471
+ if (applied) setActive({ sectionId: active.sectionId, index: active.index - 1 });
21472
+ }
21473
+ );
21474
+ },
21475
+ onMoveRight: () => {
21476
+ void runMutation(active.sectionId, (tree) => reorderMediaStripItem(tree, active.index, 1)).then(
21477
+ (applied) => {
21478
+ if (applied) setActive({ sectionId: active.sectionId, index: active.index + 1 });
21479
+ }
21480
+ );
20260
21481
  }
20261
- )
20262
- }
20263
- )
21482
+ }
21483
+ ) }),
21484
+ /* @__PURE__ */ jsx21(
21485
+ "div",
21486
+ {
21487
+ "data-ohw-bridge": "",
21488
+ "data-ohw-item-interaction": "",
21489
+ "aria-hidden": true,
21490
+ className: "pointer-events-none fixed rounded-[4px] px-[7px] py-[3px] font-sans text-[11px] font-medium leading-none text-primary-foreground whitespace-nowrap",
21491
+ style: {
21492
+ top: activeItemRect.top + activeItemRect.height + 10,
21493
+ left: activeItemRect.left - 5,
21494
+ background: PRIMARY3,
21495
+ zIndex: 2147483644
21496
+ },
21497
+ children: "Media item"
21498
+ }
21499
+ ),
21500
+ linkOpen && /* @__PURE__ */ jsx21(
21501
+ LinkModal,
21502
+ {
21503
+ href: activeHref,
21504
+ linkTarget: activeTarget,
21505
+ onClose: () => setLinkOpen(false),
21506
+ onSave: (href, linkTarget) => {
21507
+ void runMutation(
21508
+ active.sectionId,
21509
+ (tree) => setMediaStripItemLink(tree, active.index, href ? { href, linkTarget } : {})
21510
+ );
21511
+ }
21512
+ }
21513
+ )
21514
+ ] })
20264
21515
  ] });
20265
21516
  }
20266
21517
 
20267
21518
  // src/ui/ai-section/AiPricingCardOverlay.tsx
20268
- import { useCallback as useCallback4, useEffect as useEffect10, useLayoutEffect as useLayoutEffect4, useRef as useRef6, useState as useState9 } from "react";
20269
- import { Check as Check2, ChevronDown as ChevronDown3, Minus, Plus as Plus2, Star as Star2 } from "lucide-react";
20270
- import { Fragment as Fragment8, jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
21519
+ import { useCallback as useCallback4, useEffect as useEffect11, useLayoutEffect as useLayoutEffect5, useRef as useRef6, useState as useState9 } from "react";
21520
+ import { Check as Check3, ChevronDown as ChevronDown4, Minus as Minus2, Plus as Plus3, Star as Star2 } from "lucide-react";
21521
+ import { Fragment as Fragment8, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
20271
21522
  var PRIMARY4 = "var(--ohw-primary, #0885FE)";
20272
- var CHROME_SELECTOR = "[data-ohw-toolbar], [data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-link-modal-root], [data-ohw-section-picker], [data-ohw-ai-review], [data-ohw-more-menu]";
21523
+ var CHROME_SELECTOR2 = "[data-ohw-toolbar], [data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-link-modal-root], [data-ohw-section-picker], [data-ohw-ai-review], [data-ohw-more-menu]";
20273
21524
  function findPricingCardElement(sectionId, index) {
20274
21525
  const sectionEl2 = findByInstanceId(sectionId);
20275
21526
  if (!sectionEl2) return null;
@@ -20281,7 +21532,7 @@ function findPricingCardElement(sectionId, index) {
20281
21532
  }
20282
21533
  function cardRefFromTarget(target) {
20283
21534
  if (!(target instanceof Element)) return null;
20284
- if (target.closest(CHROME_SELECTOR)) return null;
21535
+ if (target.closest(CHROME_SELECTOR2)) return null;
20285
21536
  const cardEl = target.closest("[data-ohw-pricing-card]");
20286
21537
  if (!cardEl) return null;
20287
21538
  const sectionEl2 = cardEl.closest("[data-ohw-section]");
@@ -20291,25 +21542,25 @@ function cardRefFromTarget(target) {
20291
21542
  if (!sectionId || Number.isNaN(index)) return null;
20292
21543
  return { sectionId, index };
20293
21544
  }
20294
- function sameRef(a, b) {
21545
+ function sameRef2(a, b) {
20295
21546
  return a?.sectionId === b?.sectionId && a?.index === b?.index;
20296
21547
  }
20297
- function rectOf(el) {
21548
+ function rectOf2(el) {
20298
21549
  if (!el) return null;
20299
21550
  const r2 = el.getBoundingClientRect();
20300
21551
  if (r2.width <= 0 || r2.height <= 0) return null;
20301
21552
  return { top: r2.top, left: r2.left, width: r2.width, height: r2.height };
20302
21553
  }
20303
21554
  function readRect3(ref) {
20304
- return rectOf(ref && findPricingCardElement(ref.sectionId, ref.index));
21555
+ return rectOf2(ref && findPricingCardElement(ref.sectionId, ref.index));
20305
21556
  }
20306
21557
  function readGridRect(ref) {
20307
21558
  const card = ref && findPricingCardElement(ref.sectionId, ref.index);
20308
- return rectOf(card?.closest("[data-ohw-pricing-collection]") ?? card);
21559
+ return rectOf2(card?.closest("[data-ohw-pricing-collection]") ?? card);
20309
21560
  }
20310
21561
  function useLiveCardRect(ref, grid = false) {
20311
21562
  const [rect, setRect] = useState9(null);
20312
- useEffect10(() => {
21563
+ useEffect11(() => {
20313
21564
  if (!ref) {
20314
21565
  setRect(null);
20315
21566
  return;
@@ -20335,19 +21586,19 @@ function useLiveCardRect(ref, grid = false) {
20335
21586
  }
20336
21587
  var TOOLBAR_GRID_GAP = 52;
20337
21588
  var TOOLBAR_GRID_GAP_MOBILE = 42;
20338
- var TOOLBAR_EDGE_MARGIN2 = 4;
21589
+ var TOOLBAR_EDGE_MARGIN3 = 4;
20339
21590
  function GridToolbarSlot({ gridRect, children }) {
20340
21591
  const slotRef = useRef6(null);
20341
21592
  const [shift, setShift] = useState9(0);
20342
21593
  const centerX = gridRect.left + gridRect.width / 2;
20343
- useLayoutEffect4(() => {
21594
+ useLayoutEffect5(() => {
20344
21595
  const slot = slotRef.current;
20345
21596
  if (!slot) return;
20346
21597
  const clamp = () => {
20347
21598
  const w = slot.offsetWidth;
20348
21599
  if (w <= 0) return;
20349
21600
  const half = w / 2;
20350
- const clamped = Math.max(TOOLBAR_EDGE_MARGIN2 + half, Math.min(centerX, window.innerWidth - TOOLBAR_EDGE_MARGIN2 - half));
21601
+ const clamped = Math.max(TOOLBAR_EDGE_MARGIN3 + half, Math.min(centerX, window.innerWidth - TOOLBAR_EDGE_MARGIN3 - half));
20351
21602
  setShift((prev) => Math.abs(prev - (clamped - centerX)) < 0.5 ? prev : clamped - centerX);
20352
21603
  };
20353
21604
  clamp();
@@ -20356,7 +21607,7 @@ function GridToolbarSlot({ gridRect, children }) {
20356
21607
  return () => ro.disconnect();
20357
21608
  }, [centerX, children]);
20358
21609
  const mobile = window.innerWidth <= 480;
20359
- return /* @__PURE__ */ jsx21(
21610
+ return /* @__PURE__ */ jsx22(
20360
21611
  "div",
20361
21612
  {
20362
21613
  ref: slotRef,
@@ -20391,7 +21642,7 @@ function requestValidateTree2(postToParent2, tree) {
20391
21642
  });
20392
21643
  }
20393
21644
  function StyleSwatch({ style }) {
20394
- return /* @__PURE__ */ jsx21(
21645
+ return /* @__PURE__ */ jsx22(
20395
21646
  "span",
20396
21647
  {
20397
21648
  "aria-hidden": true,
@@ -20405,35 +21656,35 @@ function StyleSwatch({ style }) {
20405
21656
  );
20406
21657
  }
20407
21658
  function ButtonGlyph() {
20408
- return /* @__PURE__ */ jsxs12("svg", { width: "18", height: "12", viewBox: "0 0 18 12", fill: "none", "aria-hidden": true, style: { pointerEvents: "none" }, children: [
20409
- /* @__PURE__ */ jsx21("rect", { x: "0.75", y: "0.75", width: "16.5", height: "10.5", rx: "3", stroke: "currentColor", strokeWidth: "1.5" }),
20410
- /* @__PURE__ */ jsx21("path", { d: "M5.5 6H12.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
21659
+ return /* @__PURE__ */ jsxs13("svg", { width: "18", height: "12", viewBox: "0 0 18 12", fill: "none", "aria-hidden": true, style: { pointerEvents: "none" }, children: [
21660
+ /* @__PURE__ */ jsx22("rect", { x: "0.75", y: "0.75", width: "16.5", height: "10.5", rx: "3", stroke: "currentColor", strokeWidth: "1.5" }),
21661
+ /* @__PURE__ */ jsx22("path", { d: "M5.5 6H12.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
20411
21662
  ] });
20412
21663
  }
20413
21664
  function FeatureGlyph({ mode }) {
20414
- return /* @__PURE__ */ jsxs12("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", "aria-hidden": true, style: { pointerEvents: "none" }, children: [
20415
- /* @__PURE__ */ jsx21("circle", { cx: "8", cy: "8", r: "7.25", stroke: "currentColor", strokeWidth: "1.5" }),
20416
- /* @__PURE__ */ jsx21("path", { d: "M5 8.2L7.2 10.3L11 6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
20417
- /* @__PURE__ */ jsx21("circle", { cx: "13.5", cy: "13.5", r: "4.25", fill: "var(--ohw-background, #ffffff)", stroke: "var(--ohw-background, #ffffff)", strokeWidth: "1" }),
20418
- /* @__PURE__ */ jsx21("circle", { cx: "13.5", cy: "13.5", r: "3.75", fill: "var(--ohw-background, #ffffff)", stroke: PRIMARY4, strokeWidth: "1" }),
20419
- /* @__PURE__ */ jsx21("path", { d: "M11.5 13.5H15.5", stroke: PRIMARY4, strokeWidth: "1.5", strokeLinecap: "round" }),
20420
- mode === "add" && /* @__PURE__ */ jsx21("path", { d: "M13.5 11.5V15.5", stroke: PRIMARY4, strokeWidth: "1.5", strokeLinecap: "round" })
21665
+ return /* @__PURE__ */ jsxs13("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", "aria-hidden": true, style: { pointerEvents: "none" }, children: [
21666
+ /* @__PURE__ */ jsx22("circle", { cx: "8", cy: "8", r: "7.25", stroke: "currentColor", strokeWidth: "1.5" }),
21667
+ /* @__PURE__ */ jsx22("path", { d: "M5 8.2L7.2 10.3L11 6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
21668
+ /* @__PURE__ */ jsx22("circle", { cx: "13.5", cy: "13.5", r: "4.25", fill: "var(--ohw-background, #ffffff)", stroke: "var(--ohw-background, #ffffff)", strokeWidth: "1" }),
21669
+ /* @__PURE__ */ jsx22("circle", { cx: "13.5", cy: "13.5", r: "3.75", fill: "var(--ohw-background, #ffffff)", stroke: PRIMARY4, strokeWidth: "1" }),
21670
+ /* @__PURE__ */ jsx22("path", { d: "M11.5 13.5H15.5", stroke: PRIMARY4, strokeWidth: "1.5", strokeLinecap: "round" }),
21671
+ mode === "add" && /* @__PURE__ */ jsx22("path", { d: "M13.5 11.5V15.5", stroke: PRIMARY4, strokeWidth: "1.5", strokeLinecap: "round" })
20421
21672
  ] });
20422
21673
  }
20423
- function ToolbarAction({
21674
+ function ToolbarAction2({
20424
21675
  label,
20425
21676
  onClick,
20426
21677
  disabled = false,
20427
21678
  children
20428
21679
  }) {
20429
- const button = /* @__PURE__ */ jsx21(CustomToolbarButton, { type: "button", "aria-label": label, disabled, onClick, className: "size-8", children });
20430
- return /* @__PURE__ */ jsxs12(Tooltip, { children: [
20431
- /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: disabled ? /* @__PURE__ */ jsx21("span", { className: "inline-flex", children: button }) : button }),
20432
- /* @__PURE__ */ jsx21(TooltipContent, { side: "bottom", sideOffset: 8, children: label })
21680
+ const button = /* @__PURE__ */ jsx22(CustomToolbarButton, { type: "button", "aria-label": label, disabled, onClick, className: "size-8", children });
21681
+ return /* @__PURE__ */ jsxs13(Tooltip, { children: [
21682
+ /* @__PURE__ */ jsx22(TooltipTrigger, { asChild: true, children: disabled ? /* @__PURE__ */ jsx22("span", { className: "inline-flex", children: button }) : button }),
21683
+ /* @__PURE__ */ jsx22(TooltipContent, { side: "bottom", sideOffset: 8, children: label })
20433
21684
  ] });
20434
21685
  }
20435
- function ToolbarSeparator() {
20436
- return /* @__PURE__ */ jsx21("span", { "aria-hidden": true, className: "mx-0.5 block h-6 w-px shrink-0 bg-border" });
21686
+ function ToolbarSeparator2() {
21687
+ return /* @__PURE__ */ jsx22("span", { "aria-hidden": true, className: "mx-0.5 block h-6 w-px shrink-0 bg-border" });
20437
21688
  }
20438
21689
  function CardStyleMenu({
20439
21690
  value,
@@ -20441,7 +21692,7 @@ function CardStyleMenu({
20441
21692
  disabled = false
20442
21693
  }) {
20443
21694
  const current = PRICING_CARD_STYLES.find((s) => s.value === value) ?? PRICING_CARD_STYLES[0];
20444
- const trigger = /* @__PURE__ */ jsxs12(
21695
+ const trigger = /* @__PURE__ */ jsxs13(
20445
21696
  "button",
20446
21697
  {
20447
21698
  type: "button",
@@ -20452,28 +21703,28 @@ function CardStyleMenu({
20452
21703
  disabled && "cursor-not-allowed opacity-40 hover:bg-transparent"
20453
21704
  ),
20454
21705
  children: [
20455
- /* @__PURE__ */ jsx21(StyleSwatch, { style: current.value }),
20456
- /* @__PURE__ */ jsx21("span", { className: "flex-1 text-left", children: current.label }),
20457
- /* @__PURE__ */ jsx21(ChevronDown3, { size: 16, style: { pointerEvents: "none" } })
21706
+ /* @__PURE__ */ jsx22(StyleSwatch, { style: current.value }),
21707
+ /* @__PURE__ */ jsx22("span", { className: "flex-1 text-left", children: current.label }),
21708
+ /* @__PURE__ */ jsx22(ChevronDown4, { size: 16, style: { pointerEvents: "none" } })
20458
21709
  ]
20459
21710
  }
20460
21711
  );
20461
21712
  if (disabled) {
20462
- return /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1.5 pl-1.5", children: [
20463
- /* @__PURE__ */ jsx21("span", { className: "text-xs text-muted-foreground opacity-50", children: "Card style" }),
20464
- /* @__PURE__ */ jsxs12(Tooltip, { children: [
20465
- /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx21("span", { className: "inline-flex", children: trigger }) }),
20466
- /* @__PURE__ */ jsx21(TooltipContent, { side: "bottom", sideOffset: 8, children: "Mark as featured to edit card style" })
21713
+ return /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1.5 pl-1.5", children: [
21714
+ /* @__PURE__ */ jsx22("span", { className: "text-xs text-muted-foreground opacity-50", children: "Card style" }),
21715
+ /* @__PURE__ */ jsxs13(Tooltip, { children: [
21716
+ /* @__PURE__ */ jsx22(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx22("span", { className: "inline-flex", children: trigger }) }),
21717
+ /* @__PURE__ */ jsx22(TooltipContent, { side: "bottom", sideOffset: 8, children: "Mark as featured to edit card style" })
20467
21718
  ] })
20468
21719
  ] });
20469
21720
  }
20470
- return /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1.5 pl-1.5", children: [
20471
- /* @__PURE__ */ jsx21("span", { className: "text-xs text-muted-foreground", children: "Card style" }),
20472
- /* @__PURE__ */ jsxs12(DropdownMenu, { modal: false, children: [
20473
- /* @__PURE__ */ jsx21(DropdownMenuTrigger, { asChild: true, children: trigger }),
20474
- /* @__PURE__ */ jsx21(DropdownMenuContent, { align: "end", sideOffset: 8, className: "w-[152px] min-w-[152px] p-1", children: PRICING_CARD_STYLES.map((style) => {
21721
+ return /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1.5 pl-1.5", children: [
21722
+ /* @__PURE__ */ jsx22("span", { className: "text-xs text-muted-foreground", children: "Card style" }),
21723
+ /* @__PURE__ */ jsxs13(DropdownMenu, { modal: false, children: [
21724
+ /* @__PURE__ */ jsx22(DropdownMenuTrigger, { asChild: true, children: trigger }),
21725
+ /* @__PURE__ */ jsx22(DropdownMenuContent, { align: "end", sideOffset: 8, className: "w-[152px] min-w-[152px] p-1", children: PRICING_CARD_STYLES.map((style) => {
20475
21726
  const selected = style.value === value;
20476
- return /* @__PURE__ */ jsxs12(
21727
+ return /* @__PURE__ */ jsxs13(
20477
21728
  DropdownMenuItem,
20478
21729
  {
20479
21730
  role: "menuitemradio",
@@ -20481,9 +21732,9 @@ function CardStyleMenu({
20481
21732
  onSelect: () => onChange(style.value),
20482
21733
  className: cn("grid grid-cols-[18px_1fr_16px] gap-2 py-2 pl-2 pr-2 text-[13px]", selected && "bg-muted"),
20483
21734
  children: [
20484
- /* @__PURE__ */ jsx21(StyleSwatch, { style: style.value }),
20485
- /* @__PURE__ */ jsx21("span", { children: style.label }),
20486
- selected && /* @__PURE__ */ jsx21(Check2, { size: 16, className: "text-bridge-primary" })
21735
+ /* @__PURE__ */ jsx22(StyleSwatch, { style: style.value }),
21736
+ /* @__PURE__ */ jsx22("span", { children: style.label }),
21737
+ selected && /* @__PURE__ */ jsx22(Check3, { size: 16, className: "text-bridge-primary" })
20487
21738
  ]
20488
21739
  },
20489
21740
  style.value
@@ -20513,7 +21764,7 @@ function PricingCardToolbar({
20513
21764
  const style = pricingCardStyle(entry.tree, index);
20514
21765
  const featuredTag = pricingCardFeaturedTag(entry.tree, index);
20515
21766
  const mobile = window.innerWidth <= 480;
20516
- return /* @__PURE__ */ jsx21(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs12(
21767
+ return /* @__PURE__ */ jsx22(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs13(
20517
21768
  "div",
20518
21769
  {
20519
21770
  "data-ohw-bridge": "",
@@ -20525,7 +21776,7 @@ function PricingCardToolbar({
20525
21776
  ),
20526
21777
  style: { maxWidth: mobile ? "calc(100vw - 24px)" : void 0 },
20527
21778
  children: [
20528
- /* @__PURE__ */ jsxs12(
21779
+ /* @__PURE__ */ jsxs13(
20529
21780
  "div",
20530
21781
  {
20531
21782
  className: cn(
@@ -20534,8 +21785,8 @@ function PricingCardToolbar({
20534
21785
  mobile ? "flex-wrap justify-center" : "flex-nowrap"
20535
21786
  ),
20536
21787
  children: [
20537
- /* @__PURE__ */ jsxs12(Tooltip, { children: [
20538
- /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx21(
21788
+ /* @__PURE__ */ jsxs13(Tooltip, { children: [
21789
+ /* @__PURE__ */ jsx22(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx22(
20539
21790
  CustomToolbarButton,
20540
21791
  {
20541
21792
  type: "button",
@@ -20543,7 +21794,7 @@ function PricingCardToolbar({
20543
21794
  "aria-pressed": featuredTag,
20544
21795
  onClick: () => onSetFeaturedTag(!featuredTag),
20545
21796
  className: "group size-8",
20546
- children: /* @__PURE__ */ jsx21(
21797
+ children: /* @__PURE__ */ jsx22(
20547
21798
  Star2,
20548
21799
  {
20549
21800
  size: 16,
@@ -20558,25 +21809,25 @@ function PricingCardToolbar({
20558
21809
  )
20559
21810
  }
20560
21811
  ) }),
20561
- /* @__PURE__ */ jsx21(TooltipContent, { side: "bottom", sideOffset: 8, children: featuredTag ? "Unmark featured" : "Mark as featured" })
21812
+ /* @__PURE__ */ jsx22(TooltipContent, { side: "bottom", sideOffset: 8, children: featuredTag ? "Unmark featured" : "Mark as featured" })
20562
21813
  ] }),
20563
- /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20564
- /* @__PURE__ */ jsx21(CardStyleMenu, { value: style, onChange: onSetStyle, disabled: !featuredTag }),
20565
- /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20566
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Add button", onClick: onAddButton, disabled: buttonCount >= 2, children: /* @__PURE__ */ jsx21(ButtonGlyph, {}) }),
20567
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Remove button", onClick: onRemoveButton, disabled: buttonCount === 0, children: /* @__PURE__ */ jsxs12("span", { className: "relative inline-flex", children: [
20568
- /* @__PURE__ */ jsx21(ButtonGlyph, {}),
20569
- /* @__PURE__ */ jsx21(Minus, { size: 10, strokeWidth: 2.5, className: "absolute -right-1.5 -top-1.5 rounded-full bg-background text-bridge-primary" })
21814
+ /* @__PURE__ */ jsx22(ToolbarSeparator2, {}),
21815
+ /* @__PURE__ */ jsx22(CardStyleMenu, { value: style, onChange: onSetStyle, disabled: !featuredTag }),
21816
+ /* @__PURE__ */ jsx22(ToolbarSeparator2, {}),
21817
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Add button", onClick: onAddButton, disabled: buttonCount >= 2, children: /* @__PURE__ */ jsx22(ButtonGlyph, {}) }),
21818
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Remove button", onClick: onRemoveButton, disabled: buttonCount === 0, children: /* @__PURE__ */ jsxs13("span", { className: "relative inline-flex", children: [
21819
+ /* @__PURE__ */ jsx22(ButtonGlyph, {}),
21820
+ /* @__PURE__ */ jsx22(Minus2, { size: 10, strokeWidth: 2.5, className: "absolute -right-1.5 -top-1.5 rounded-full bg-background text-bridge-primary" })
20570
21821
  ] }) }),
20571
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Add feature", onClick: onAddFeature, disabled: featureCount >= 10, children: /* @__PURE__ */ jsx21(FeatureGlyph, { mode: "add" }) }),
20572
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Remove feature", onClick: onRemoveFeature, disabled: featureCount <= 1, children: /* @__PURE__ */ jsx21(FeatureGlyph, { mode: "remove" }) }),
20573
- /* @__PURE__ */ jsx21(ToolbarSeparator, {}),
20574
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Add tier", onClick: onAddTier, disabled: collectionCount >= 4, children: /* @__PURE__ */ jsx21(Plus2, { size: 16, style: { pointerEvents: "none" } }) }),
20575
- /* @__PURE__ */ jsx21(ToolbarAction, { label: "Remove tier", onClick: onRemoveTier, disabled: collectionCount <= 1, children: /* @__PURE__ */ jsx21(Minus, { size: 16, style: { pointerEvents: "none" } }) })
21822
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Add feature", onClick: onAddFeature, disabled: featureCount >= 10, children: /* @__PURE__ */ jsx22(FeatureGlyph, { mode: "add" }) }),
21823
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Remove feature", onClick: onRemoveFeature, disabled: featureCount <= 1, children: /* @__PURE__ */ jsx22(FeatureGlyph, { mode: "remove" }) }),
21824
+ /* @__PURE__ */ jsx22(ToolbarSeparator2, {}),
21825
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Add tier", onClick: onAddTier, disabled: collectionCount >= 4, children: /* @__PURE__ */ jsx22(Plus3, { size: 16, style: { pointerEvents: "none" } }) }),
21826
+ /* @__PURE__ */ jsx22(ToolbarAction2, { label: "Remove tier", onClick: onRemoveTier, disabled: collectionCount <= 1, children: /* @__PURE__ */ jsx22(Minus2, { size: 16, style: { pointerEvents: "none" } }) })
20576
21827
  ]
20577
21828
  }
20578
21829
  ),
20579
- error && /* @__PURE__ */ jsx21("div", { className: "max-w-[260px] rounded-md bg-background px-2 py-1 text-center text-[11px] text-destructive shadow-sm", children: error })
21830
+ error && /* @__PURE__ */ jsx22("div", { className: "max-w-[260px] rounded-md bg-background px-2 py-1 text-center text-[11px] text-destructive shadow-sm", children: error })
20580
21831
  ]
20581
21832
  }
20582
21833
  ) });
@@ -20603,14 +21854,14 @@ function AiPricingCardOverlay({
20603
21854
  const [error, setError] = useState9(null);
20604
21855
  const activeRef = useRef6(null);
20605
21856
  activeRef.current = active;
20606
- useEffect10(() => {
21857
+ useEffect11(() => {
20607
21858
  const onMove = (e) => {
20608
21859
  const ref = cardRefFromTarget(e.target);
20609
21860
  const t = e.target;
20610
21861
  const overEditable = Boolean(t?.closest?.("[data-ohw-editable], [data-ohw-role], a, button"));
20611
21862
  setHover((prev) => {
20612
21863
  const next = ref && !overEditable ? ref : null;
20613
- return sameRef(prev, next) ? prev : next;
21864
+ return sameRef2(prev, next) ? prev : next;
20614
21865
  });
20615
21866
  };
20616
21867
  const onLeave = () => setHover(null);
@@ -20621,19 +21872,19 @@ function AiPricingCardOverlay({
20621
21872
  document.documentElement.removeEventListener("mouseleave", onLeave);
20622
21873
  };
20623
21874
  }, []);
20624
- useEffect10(() => {
21875
+ useEffect11(() => {
20625
21876
  const onClick = (e) => {
20626
21877
  const t = e.target;
20627
21878
  if (!(t instanceof Element)) return;
20628
- if (t.closest(CHROME_SELECTOR)) return;
21879
+ if (t.closest(CHROME_SELECTOR2)) return;
20629
21880
  const ref = cardRefFromTarget(t);
20630
- setActive((prev) => sameRef(prev, ref) ? prev : ref);
20631
- if (!ref || !sameRef(activeRef.current, ref)) setError(null);
21881
+ setActive((prev) => sameRef2(prev, ref) ? prev : ref);
21882
+ if (!ref || !sameRef2(activeRef.current, ref)) setError(null);
20632
21883
  };
20633
21884
  document.addEventListener("click", onClick, true);
20634
21885
  return () => document.removeEventListener("click", onClick, true);
20635
21886
  }, []);
20636
- useEffect10(() => {
21887
+ useEffect11(() => {
20637
21888
  const onBlur = () => {
20638
21889
  if (!activeRef.current) return;
20639
21890
  setActive(null);
@@ -20642,7 +21893,7 @@ function AiPricingCardOverlay({
20642
21893
  window.addEventListener("blur", onBlur);
20643
21894
  return () => window.removeEventListener("blur", onBlur);
20644
21895
  }, []);
20645
- useEffect10(() => {
21896
+ useEffect11(() => {
20646
21897
  const onKeyDown = (e) => {
20647
21898
  if (e.key !== "Escape") return;
20648
21899
  if (!activeRef.current) return;
@@ -20693,12 +21944,12 @@ function AiPricingCardOverlay({
20693
21944
  const activeEntry = active ? findEntry(active.sectionId) : null;
20694
21945
  const activeCardRect = useLiveCardRect(active);
20695
21946
  const activeGridRect = useLiveCardRect(active, true);
20696
- const hoverRect = useLiveCardRect(hover && !sameRef(hover, active) ? hover : null);
20697
- return /* @__PURE__ */ jsxs12(Fragment8, { children: [
20698
- hoverRect && /* @__PURE__ */ jsx21(ItemInteractionLayer, { rect: hoverRect, state: "hover" }),
20699
- activeCardRect && activeGridRect && active && activeEntry && /* @__PURE__ */ jsxs12(Fragment8, { children: [
20700
- /* @__PURE__ */ jsx21(ItemInteractionLayer, { rect: activeCardRect, state: "active-top" }),
20701
- /* @__PURE__ */ jsx21(GridToolbarSlot, { gridRect: activeGridRect, children: /* @__PURE__ */ jsx21(
21947
+ const hoverRect = useLiveCardRect(hover && !sameRef2(hover, active) ? hover : null);
21948
+ return /* @__PURE__ */ jsxs13(Fragment8, { children: [
21949
+ hoverRect && /* @__PURE__ */ jsx22(ItemInteractionLayer, { rect: hoverRect, state: "hover" }),
21950
+ activeCardRect && activeGridRect && active && activeEntry && /* @__PURE__ */ jsxs13(Fragment8, { children: [
21951
+ /* @__PURE__ */ jsx22(ItemInteractionLayer, { rect: activeCardRect, state: "active-top" }),
21952
+ /* @__PURE__ */ jsx22(GridToolbarSlot, { gridRect: activeGridRect, children: /* @__PURE__ */ jsx22(
20702
21953
  PricingCardToolbar,
20703
21954
  {
20704
21955
  entry: activeEntry,
@@ -20726,7 +21977,7 @@ function AiPricingCardOverlay({
20726
21977
  onRemoveFeature: () => runMutation(active.sectionId, (tree) => removePricingCardFeature(tree, active.index))
20727
21978
  }
20728
21979
  ) }),
20729
- /* @__PURE__ */ jsx21(
21980
+ /* @__PURE__ */ jsx22(
20730
21981
  "div",
20731
21982
  {
20732
21983
  "data-ohw-bridge": "",
@@ -20747,7 +21998,7 @@ function AiPricingCardOverlay({
20747
21998
  }
20748
21999
 
20749
22000
  // src/ui/ai-section/AiVideoOverlay.tsx
20750
- import { useCallback as useCallback5, useEffect as useEffect11, useRef as useRef7, useState as useState10 } from "react";
22001
+ import { useCallback as useCallback5, useEffect as useEffect12, useRef as useRef7, useState as useState10 } from "react";
20751
22002
  import { Star as Star3 } from "lucide-react";
20752
22003
 
20753
22004
  // src/lib/ai-video-tree.ts
@@ -20791,10 +22042,10 @@ function clearVideo(tree, path) {
20791
22042
  }
20792
22043
 
20793
22044
  // src/ui/ai-section/AiVideoOverlay.tsx
20794
- import { Fragment as Fragment9, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
22045
+ import { Fragment as Fragment9, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
20795
22046
  var PRIMARY5 = "#0885FE";
20796
- var OHW_BLUE2 = `var(--ohw-primary, ${PRIMARY5})`;
20797
- var OHW_BLUE_DARK2 = `color-mix(in srgb, var(--ohw-primary, ${PRIMARY5}) 60%, #000000)`;
22047
+ var OHW_BLUE = `var(--ohw-primary, ${PRIMARY5})`;
22048
+ var OHW_BLUE_DARK = `color-mix(in srgb, var(--ohw-primary, ${PRIMARY5}) 60%, #000000)`;
20798
22049
  function findVideoBlockElement(sectionId, path) {
20799
22050
  const sectionEl2 = findByInstanceId(sectionId);
20800
22051
  if (!sectionEl2) return null;
@@ -20813,7 +22064,7 @@ function readRect4(ref) {
20813
22064
  }
20814
22065
  function useLiveBlockRect(ref) {
20815
22066
  const [rect, setRect] = useState10(null);
20816
- useEffect11(() => {
22067
+ useEffect12(() => {
20817
22068
  if (!ref) {
20818
22069
  setRect(null);
20819
22070
  return;
@@ -20854,12 +22105,12 @@ function requestValidateTree3(postToParent2, tree) {
20854
22105
  postToParent2({ type: "ow:ai-validate-tree-request", id, tree });
20855
22106
  });
20856
22107
  }
20857
- function Pill2({
22108
+ function Pill({
20858
22109
  label,
20859
22110
  onClick,
20860
22111
  disabled
20861
22112
  }) {
20862
- return /* @__PURE__ */ jsx22(
22113
+ return /* @__PURE__ */ jsx23(
20863
22114
  "button",
20864
22115
  {
20865
22116
  type: "button",
@@ -20875,7 +22126,7 @@ function Pill2({
20875
22126
  border: "none",
20876
22127
  cursor: disabled ? "default" : "pointer",
20877
22128
  background: "#ffffff",
20878
- color: OHW_BLUE_DARK2,
22129
+ color: OHW_BLUE_DARK,
20879
22130
  opacity: disabled ? 0.4 : 1,
20880
22131
  fontSize: 12,
20881
22132
  lineHeight: "16px",
@@ -20893,7 +22144,7 @@ function watchUrl(id) {
20893
22144
  function VideoUrlInput({ value, onCommit }) {
20894
22145
  const [draft, setDraft] = useState10(value ? watchUrl(value) : "");
20895
22146
  const [invalid, setInvalid] = useState10(false);
20896
- useEffect11(() => {
22147
+ useEffect12(() => {
20897
22148
  setDraft(value ? watchUrl(value) : "");
20898
22149
  setInvalid(false);
20899
22150
  }, [value]);
@@ -20918,8 +22169,8 @@ function VideoUrlInput({ value, onCommit }) {
20918
22169
  onCommit(id);
20919
22170
  }
20920
22171
  };
20921
- return /* @__PURE__ */ jsxs13("div", { style: { display: "flex", flexDirection: "column", gap: 4, width: "100%", maxWidth: 280 }, children: [
20922
- /* @__PURE__ */ jsxs13(
22172
+ return /* @__PURE__ */ jsxs14("div", { style: { display: "flex", flexDirection: "column", gap: 4, width: "100%", maxWidth: 280 }, children: [
22173
+ /* @__PURE__ */ jsxs14(
20923
22174
  "div",
20924
22175
  {
20925
22176
  style: {
@@ -20935,12 +22186,12 @@ function VideoUrlInput({ value, onCommit }) {
20935
22186
  boxShadow: invalid ? "inset 0 0 0 1.5px #EF4444" : "none"
20936
22187
  },
20937
22188
  children: [
20938
- /* @__PURE__ */ jsx22(
22189
+ /* @__PURE__ */ jsx23(
20939
22190
  "span",
20940
22191
  {
20941
22192
  style: {
20942
22193
  flex: "0 0 auto",
20943
- color: OHW_BLUE_DARK2,
22194
+ color: OHW_BLUE_DARK,
20944
22195
  fontSize: 10,
20945
22196
  lineHeight: "16px",
20946
22197
  fontWeight: 700,
@@ -20950,7 +22201,7 @@ function VideoUrlInput({ value, onCommit }) {
20950
22201
  children: "Video"
20951
22202
  }
20952
22203
  ),
20953
- /* @__PURE__ */ jsx22(
22204
+ /* @__PURE__ */ jsx23(
20954
22205
  "input",
20955
22206
  {
20956
22207
  type: "text",
@@ -20987,7 +22238,7 @@ function VideoUrlInput({ value, onCommit }) {
20987
22238
  ]
20988
22239
  }
20989
22240
  ),
20990
- invalid && /* @__PURE__ */ jsx22("div", { style: { color: "#FCA5A5", fontSize: 11, textAlign: "center" }, children: "That doesn't look like a YouTube link \u2014 try pasting the video URL again." })
22241
+ invalid && /* @__PURE__ */ jsx23("div", { style: { color: "#FCA5A5", fontSize: 11, textAlign: "center" }, children: "That doesn't look like a YouTube link \u2014 try pasting the video URL again." })
20991
22242
  ] });
20992
22243
  }
20993
22244
  function VideoToolbar({
@@ -20997,7 +22248,7 @@ function VideoToolbar({
20997
22248
  onSetVideoId,
20998
22249
  onRemove
20999
22250
  }) {
21000
- return /* @__PURE__ */ jsxs13(
22251
+ return /* @__PURE__ */ jsxs14(
21001
22252
  "div",
21002
22253
  {
21003
22254
  "data-ohw-bridge": "",
@@ -21009,7 +22260,7 @@ function VideoToolbar({
21009
22260
  gap: 6,
21010
22261
  alignItems: "center",
21011
22262
  width: 280,
21012
- background: OHW_BLUE2,
22263
+ background: OHW_BLUE,
21013
22264
  padding: 8,
21014
22265
  borderRadius: 12,
21015
22266
  boxShadow: "0 8px 24px rgba(0,0,0,0.25)",
@@ -21017,9 +22268,9 @@ function VideoToolbar({
21017
22268
  opacity: pending ? 0.6 : 1
21018
22269
  },
21019
22270
  children: [
21020
- /* @__PURE__ */ jsx22(VideoUrlInput, { value: videoId, onCommit: onSetVideoId }),
21021
- /* @__PURE__ */ jsx22(Pill2, { label: "Remove video", onClick: onRemove, disabled: !videoId }),
21022
- error && /* @__PURE__ */ jsx22("div", { style: { color: "#FCA5A5", fontSize: 11, maxWidth: 220, textAlign: "center" }, children: error })
22271
+ /* @__PURE__ */ jsx23(VideoUrlInput, { value: videoId, onCommit: onSetVideoId }),
22272
+ /* @__PURE__ */ jsx23(Pill, { label: "Remove video", onClick: onRemove, disabled: !videoId }),
22273
+ error && /* @__PURE__ */ jsx23("div", { style: { color: "#FCA5A5", fontSize: 11, maxWidth: 220, textAlign: "center" }, children: error })
21023
22274
  ]
21024
22275
  }
21025
22276
  );
@@ -21036,7 +22287,7 @@ function AiVideoOverlay({
21036
22287
  const [error, setError] = useState10(null);
21037
22288
  const activeRef = useRef7(null);
21038
22289
  activeRef.current = active;
21039
- useEffect11(() => {
22290
+ useEffect12(() => {
21040
22291
  const onMove = (e) => {
21041
22292
  const t = e.target;
21042
22293
  if (!(t instanceof HTMLElement)) return;
@@ -21066,7 +22317,7 @@ function AiVideoOverlay({
21066
22317
  document.documentElement.removeEventListener("mouseleave", onLeave);
21067
22318
  };
21068
22319
  }, []);
21069
- useEffect11(() => {
22320
+ useEffect12(() => {
21070
22321
  const onClick = (e) => {
21071
22322
  const current = activeRef.current;
21072
22323
  if (!current) return;
@@ -21081,7 +22332,7 @@ function AiVideoOverlay({
21081
22332
  document.addEventListener("click", onClick, true);
21082
22333
  return () => document.removeEventListener("click", onClick, true);
21083
22334
  }, []);
21084
- useEffect11(() => {
22335
+ useEffect12(() => {
21085
22336
  const onBlur = () => {
21086
22337
  if (!activeRef.current) return;
21087
22338
  setActive(null);
@@ -21090,7 +22341,7 @@ function AiVideoOverlay({
21090
22341
  window.addEventListener("blur", onBlur);
21091
22342
  return () => window.removeEventListener("blur", onBlur);
21092
22343
  }, []);
21093
- useEffect11(() => {
22344
+ useEffect12(() => {
21094
22345
  const onKeyDown = (e) => {
21095
22346
  if (e.key !== "Escape") return;
21096
22347
  if (!activeRef.current) return;
@@ -21139,8 +22390,8 @@ function AiVideoOverlay({
21139
22390
  const activeBlockRect = useLiveBlockRect(active);
21140
22391
  const TOOLBAR_APPROX_H = 90;
21141
22392
  const toolbarState = activeBlockRect && activeBlockRect.top < TOOLBAR_APPROX_H ? "active-bottom" : "active-top";
21142
- return /* @__PURE__ */ jsxs13(Fragment9, { children: [
21143
- hoverHandleRect && hover && /* @__PURE__ */ jsx22(
22393
+ return /* @__PURE__ */ jsxs14(Fragment9, { children: [
22394
+ hoverHandleRect && hover && /* @__PURE__ */ jsx23(
21144
22395
  "button",
21145
22396
  {
21146
22397
  type: "button",
@@ -21168,15 +22419,15 @@ function AiVideoOverlay({
21168
22419
  fontSize: 14,
21169
22420
  fontWeight: 700
21170
22421
  },
21171
- children: /* @__PURE__ */ jsx22(Star3, { size: 14, style: { pointerEvents: "none" } })
22422
+ children: /* @__PURE__ */ jsx23(Star3, { size: 14, style: { pointerEvents: "none" } })
21172
22423
  }
21173
22424
  ),
21174
- activeBlockRect && active && activeEntry && /* @__PURE__ */ jsx22(
22425
+ activeBlockRect && active && activeEntry && /* @__PURE__ */ jsx23(
21175
22426
  ItemInteractionLayer,
21176
22427
  {
21177
22428
  rect: activeBlockRect,
21178
22429
  state: toolbarState,
21179
- toolbar: /* @__PURE__ */ jsx22(
22430
+ toolbar: /* @__PURE__ */ jsx23(
21180
22431
  VideoToolbar,
21181
22432
  {
21182
22433
  videoId: videoIdAt(activeEntry.tree, active.path),
@@ -21199,7 +22450,7 @@ function AiVideoOverlay({
21199
22450
  }
21200
22451
 
21201
22452
  // src/ui/ai-section/AiFadeCarouselOverlay.tsx
21202
- import { useCallback as useCallback6, useEffect as useEffect12, useRef as useRef8, useState as useState11 } from "react";
22453
+ import { useCallback as useCallback6, useEffect as useEffect13, useRef as useRef8, useState as useState11 } from "react";
21203
22454
  import { Star as Star4 } from "lucide-react";
21204
22455
 
21205
22456
  // src/lib/ai-carousel-tree.ts
@@ -21251,10 +22502,10 @@ function setCarouselAutoplay(tree, on) {
21251
22502
  }
21252
22503
 
21253
22504
  // src/ui/ai-section/AiFadeCarouselOverlay.tsx
21254
- import { Fragment as Fragment10, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
22505
+ import { Fragment as Fragment10, jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
21255
22506
  var PRIMARY6 = "#0885FE";
21256
- var OHW_BLUE3 = `var(--ohw-primary, ${PRIMARY6})`;
21257
- var OHW_BLUE_DARK3 = `color-mix(in srgb, var(--ohw-primary, ${PRIMARY6}) 60%, #000000)`;
22507
+ var OHW_BLUE2 = `var(--ohw-primary, ${PRIMARY6})`;
22508
+ var OHW_BLUE_DARK2 = `color-mix(in srgb, var(--ohw-primary, ${PRIMARY6}) 60%, #000000)`;
21258
22509
  function findCarouselItemElement(sectionId, index) {
21259
22510
  const sectionEl2 = findByInstanceId(sectionId);
21260
22511
  if (!sectionEl2) return null;
@@ -21273,7 +22524,7 @@ function readRect5(ref) {
21273
22524
  }
21274
22525
  function useLiveItemRect2(ref) {
21275
22526
  const [rect, setRect] = useState11(null);
21276
- useEffect12(() => {
22527
+ useEffect13(() => {
21277
22528
  if (!ref) {
21278
22529
  setRect(null);
21279
22530
  return;
@@ -21333,8 +22584,8 @@ function requestAssetPick2(postToParent2) {
21333
22584
  postToParent2({ type: "ow:asset-pick", id });
21334
22585
  });
21335
22586
  }
21336
- function Pill3({ label, onClick, disabled }) {
21337
- return /* @__PURE__ */ jsx23(
22587
+ function Pill2({ label, onClick, disabled }) {
22588
+ return /* @__PURE__ */ jsx24(
21338
22589
  "button",
21339
22590
  {
21340
22591
  type: "button",
@@ -21350,7 +22601,7 @@ function Pill3({ label, onClick, disabled }) {
21350
22601
  border: "none",
21351
22602
  cursor: disabled ? "default" : "pointer",
21352
22603
  background: "#ffffff",
21353
- color: OHW_BLUE_DARK3,
22604
+ color: OHW_BLUE_DARK2,
21354
22605
  opacity: disabled ? 0.4 : 1,
21355
22606
  fontSize: 12,
21356
22607
  lineHeight: "16px",
@@ -21368,7 +22619,7 @@ function TogglePill({
21368
22619
  onToggle,
21369
22620
  disabled
21370
22621
  }) {
21371
- return /* @__PURE__ */ jsxs14(
22622
+ return /* @__PURE__ */ jsxs15(
21372
22623
  "button",
21373
22624
  {
21374
22625
  type: "button",
@@ -21387,7 +22638,7 @@ function TogglePill({
21387
22638
  border: "none",
21388
22639
  cursor: disabled ? "default" : "pointer",
21389
22640
  background: "#ffffff",
21390
- color: OHW_BLUE_DARK3,
22641
+ color: OHW_BLUE_DARK2,
21391
22642
  opacity: disabled ? 0.4 : 1,
21392
22643
  fontSize: 12,
21393
22644
  lineHeight: "16px",
@@ -21397,7 +22648,7 @@ function TogglePill({
21397
22648
  },
21398
22649
  children: [
21399
22650
  label,
21400
- /* @__PURE__ */ jsx23(
22651
+ /* @__PURE__ */ jsx24(
21401
22652
  "span",
21402
22653
  {
21403
22654
  "aria-hidden": true,
@@ -21410,10 +22661,10 @@ function TogglePill({
21410
22661
  // Off is a grey track, not a washed-out blue: the pill's own white background already
21411
22662
  // carries the brand colour in the text, and a pale blue track next to it read as
21412
22663
  // "disabled control" rather than "switch that is off".
21413
- background: on ? OHW_BLUE_DARK3 : "#CBD5E1",
22664
+ background: on ? OHW_BLUE_DARK2 : "#CBD5E1",
21414
22665
  transition: "background 120ms ease"
21415
22666
  },
21416
- children: /* @__PURE__ */ jsx23(
22667
+ children: /* @__PURE__ */ jsx24(
21417
22668
  "span",
21418
22669
  {
21419
22670
  style: {
@@ -21442,7 +22693,7 @@ function CarouselSlideToolbar({
21442
22693
  onChangeImage,
21443
22694
  onToggleAutoplay
21444
22695
  }) {
21445
- return /* @__PURE__ */ jsxs14(
22696
+ return /* @__PURE__ */ jsxs15(
21446
22697
  "div",
21447
22698
  {
21448
22699
  "data-ohw-bridge": "",
@@ -21453,7 +22704,7 @@ function CarouselSlideToolbar({
21453
22704
  flexDirection: "column",
21454
22705
  gap: 6,
21455
22706
  alignItems: "center",
21456
- background: OHW_BLUE3,
22707
+ background: OHW_BLUE2,
21457
22708
  padding: 8,
21458
22709
  borderRadius: 12,
21459
22710
  boxShadow: "0 8px 24px rgba(0,0,0,0.25)",
@@ -21465,11 +22716,11 @@ function CarouselSlideToolbar({
21465
22716
  pointerEvents: pending ? "none" : "auto"
21466
22717
  },
21467
22718
  children: [
21468
- /* @__PURE__ */ jsxs14("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
21469
- /* @__PURE__ */ jsx23(Pill3, { label: "Change Image", onClick: onChangeImage }),
21470
- /* @__PURE__ */ jsx23(TogglePill, { label: "Autoplay", on: autoplay, onToggle: onToggleAutoplay })
22719
+ /* @__PURE__ */ jsxs15("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
22720
+ /* @__PURE__ */ jsx24(Pill2, { label: "Change Image", onClick: onChangeImage }),
22721
+ /* @__PURE__ */ jsx24(TogglePill, { label: "Autoplay", on: autoplay, onToggle: onToggleAutoplay })
21471
22722
  ] }),
21472
- error && /* @__PURE__ */ jsx23("div", { style: { color: "#FCA5A5", fontSize: 11, maxWidth: 220, textAlign: "center" }, children: error })
22723
+ error && /* @__PURE__ */ jsx24("div", { style: { color: "#FCA5A5", fontSize: 11, maxWidth: 220, textAlign: "center" }, children: error })
21473
22724
  ]
21474
22725
  }
21475
22726
  );
@@ -21489,10 +22740,10 @@ function AiFadeCarouselOverlay({
21489
22740
  const skeletonRef = useRef8(null);
21490
22741
  const activeRef = useRef8(null);
21491
22742
  activeRef.current = active;
21492
- useEffect12(() => {
22743
+ useEffect13(() => {
21493
22744
  setAutoplayOverride(null);
21494
22745
  }, [active?.sectionId, active?.index]);
21495
- useEffect12(() => {
22746
+ useEffect13(() => {
21496
22747
  if (!swapping?.fadingOut || !skeletonRef.current) return;
21497
22748
  const anim = skeletonRef.current.animate([{ opacity: 1 }, { opacity: 0 }], {
21498
22749
  duration: MEDIA_UPLOAD_FADE_MS,
@@ -21502,7 +22753,7 @@ function AiFadeCarouselOverlay({
21502
22753
  anim.finished.then(() => setSwapping(null)).catch(() => setSwapping(null));
21503
22754
  return () => anim.cancel();
21504
22755
  }, [swapping?.fadingOut]);
21505
- useEffect12(() => {
22756
+ useEffect13(() => {
21506
22757
  const onMove = (e) => {
21507
22758
  const t = e.target;
21508
22759
  if (!(t instanceof Element)) return;
@@ -21536,7 +22787,7 @@ function AiFadeCarouselOverlay({
21536
22787
  document.documentElement.removeEventListener("mouseleave", onLeave);
21537
22788
  };
21538
22789
  }, []);
21539
- useEffect12(() => {
22790
+ useEffect13(() => {
21540
22791
  const onClick = (e) => {
21541
22792
  const current = activeRef.current;
21542
22793
  if (!current) return;
@@ -21551,7 +22802,7 @@ function AiFadeCarouselOverlay({
21551
22802
  document.addEventListener("click", onClick, true);
21552
22803
  return () => document.removeEventListener("click", onClick, true);
21553
22804
  }, []);
21554
- useEffect12(() => {
22805
+ useEffect13(() => {
21555
22806
  const onBlur = () => {
21556
22807
  if (!activeRef.current) return;
21557
22808
  setActive(null);
@@ -21560,7 +22811,7 @@ function AiFadeCarouselOverlay({
21560
22811
  window.addEventListener("blur", onBlur);
21561
22812
  return () => window.removeEventListener("blur", onBlur);
21562
22813
  }, []);
21563
- useEffect12(() => {
22814
+ useEffect13(() => {
21564
22815
  const onKeyDown = (e) => {
21565
22816
  if (e.key !== "Escape") return;
21566
22817
  if (!activeRef.current) return;
@@ -21609,8 +22860,8 @@ function AiFadeCarouselOverlay({
21609
22860
  const activeItemRect = useLiveItemRect2(active);
21610
22861
  const TOOLBAR_APPROX_H = 90;
21611
22862
  const toolbarState = activeItemRect && activeItemRect.top < TOOLBAR_APPROX_H ? "active-bottom" : "active-top";
21612
- return /* @__PURE__ */ jsxs14(Fragment10, { children: [
21613
- hoverHandleRect && hover && /* @__PURE__ */ jsx23(
22863
+ return /* @__PURE__ */ jsxs15(Fragment10, { children: [
22864
+ hoverHandleRect && hover && /* @__PURE__ */ jsx24(
21614
22865
  "button",
21615
22866
  {
21616
22867
  type: "button",
@@ -21639,10 +22890,10 @@ function AiFadeCarouselOverlay({
21639
22890
  fontSize: 14,
21640
22891
  fontWeight: 700
21641
22892
  },
21642
- children: /* @__PURE__ */ jsx23(Star4, { size: 14, style: { pointerEvents: "none" } })
22893
+ children: /* @__PURE__ */ jsx24(Star4, { size: 14, style: { pointerEvents: "none" } })
21643
22894
  }
21644
22895
  ),
21645
- swapping && /* @__PURE__ */ jsx23(
22896
+ swapping && /* @__PURE__ */ jsx24(
21646
22897
  "div",
21647
22898
  {
21648
22899
  ref: skeletonRef,
@@ -21660,15 +22911,15 @@ function AiFadeCarouselOverlay({
21660
22911
  zIndex: 2147483646,
21661
22912
  pointerEvents: "none"
21662
22913
  },
21663
- children: /* @__PURE__ */ jsx23("style", { children: MEDIA_SKELETON_CSS })
22914
+ children: /* @__PURE__ */ jsx24("style", { children: MEDIA_SKELETON_CSS })
21664
22915
  }
21665
22916
  ),
21666
- activeItemRect && active && activeEntry && /* @__PURE__ */ jsx23(
22917
+ activeItemRect && active && activeEntry && /* @__PURE__ */ jsx24(
21667
22918
  ItemInteractionLayer,
21668
22919
  {
21669
22920
  rect: activeItemRect,
21670
22921
  state: toolbarState,
21671
- toolbar: /* @__PURE__ */ jsx23(
22922
+ toolbar: /* @__PURE__ */ jsx24(
21672
22923
  CarouselSlideToolbar,
21673
22924
  {
21674
22925
  pending,
@@ -21716,6 +22967,51 @@ function AiFadeCarouselOverlay({
21716
22967
  import { createPortal as createPortal3 } from "react-dom";
21717
22968
  import { usePathname as usePathname3, useRouter as useRouter3, useSearchParams } from "next/navigation";
21718
22969
 
22970
+ // src/lib/seeable.ts
22971
+ var MIN_SEEN_OPACITY = 0.05;
22972
+ function isSeeable(el) {
22973
+ const view = el.ownerDocument?.defaultView;
22974
+ if (!view) return true;
22975
+ for (let node = el; node && node !== el.ownerDocument.documentElement; node = node.parentElement) {
22976
+ const style = view.getComputedStyle(node);
22977
+ if (style.display === "none" || style.visibility === "hidden") return false;
22978
+ const opacity = parseFloat(style.opacity);
22979
+ if (Number.isFinite(opacity) && opacity < MIN_SEEN_OPACITY) return false;
22980
+ }
22981
+ return true;
22982
+ }
22983
+ function shownAs(el) {
22984
+ if (isSeeable(el)) return el;
22985
+ const key = el.getAttribute("data-ohw-key");
22986
+ if (!key) return null;
22987
+ const twin = Array.from(el.ownerDocument.querySelectorAll("[data-ohw-key]")).find(
22988
+ (other) => other !== el && other.getAttribute("data-ohw-key") === key && isSeeable(other)
22989
+ );
22990
+ return twin ?? null;
22991
+ }
22992
+ function hitsShown(el, x, y) {
22993
+ const shown = shownAs(el);
22994
+ if (!shown) return false;
22995
+ const r2 = shown.getBoundingClientRect();
22996
+ return x >= r2.left && x <= r2.right && y >= r2.top && y <= r2.bottom;
22997
+ }
22998
+ function findHiddenTwinAt(selector, x, y) {
22999
+ return Array.from(document.querySelectorAll(selector)).find(
23000
+ (el) => !isSeeable(el) && hitsShown(el, x, y)
23001
+ ) ?? null;
23002
+ }
23003
+ function stateCardFor(el, x, y) {
23004
+ const own = el.closest("[data-ohw-editable-state]");
23005
+ if (own) return own;
23006
+ return Array.from(document.querySelectorAll("[data-ohw-editable-state]")).find((card) => {
23007
+ const r2 = card.getBoundingClientRect();
23008
+ return x >= r2.left && x <= r2.right && y >= r2.top && y <= r2.bottom;
23009
+ }) ?? null;
23010
+ }
23011
+ function hoverFrame(el) {
23012
+ return shownAs(el) ?? el;
23013
+ }
23014
+
21719
23015
  // src/lib/media-overlay-guards.ts
21720
23016
  var BRIDGE_CHROME_SELECTOR = [
21721
23017
  "[data-ohw-toolbar]",
@@ -21756,7 +23052,9 @@ function findButtonAtPoint(x, y, media) {
21756
23052
  // markup, so the bbox sweep that makes real CTAs win over a full-bleed hero image
21757
23053
  // (OHH-798) claimed them too and drew the editable-item hover frame around a control
21758
23054
  // that isn't content. They move the slideshow; there is nothing there to edit.
21759
- !el.closest("[data-ohw-carousel-control]")
23055
+ !el.closest("[data-ohw-carousel-control]") && // Faded out but still laid out: rebound's instructor card keeps BOOK NOW in an opacity-0
23056
+ // hover panel, so the Default view framed (and clicked) a button nobody can see.
23057
+ isSeeable(el)
21760
23058
  );
21761
23059
  if (hits.length === 0) return null;
21762
23060
  return hits.reduce((best, el) => best.contains(el) ? el : best);
@@ -21857,120 +23155,13 @@ function mergePrefetchedSections(prev, fetched, livePath, liveSections) {
21857
23155
  }
21858
23156
 
21859
23157
  // src/ui/link-modal/LinkPopover.tsx
21860
- import { useEffect as useEffect16 } from "react";
21861
-
21862
- // src/ui/dialog.tsx
21863
- import * as React9 from "react";
21864
- import { Dialog as DialogPrimitive } from "radix-ui";
21865
- import { X as X2 } from "lucide-react";
21866
- import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
21867
- function Dialog2({
21868
- ...props
21869
- }) {
21870
- return /* @__PURE__ */ jsx24(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
21871
- }
21872
- function DialogPortal({
21873
- ...props
21874
- }) {
21875
- return /* @__PURE__ */ jsx24(DialogPrimitive.Portal, { ...props });
21876
- }
21877
- function DialogOverlay({
21878
- className,
21879
- ...props
21880
- }) {
21881
- return /* @__PURE__ */ jsx24(
21882
- DialogPrimitive.Overlay,
21883
- {
21884
- "data-slot": "dialog-overlay",
21885
- "data-ohw-link-modal-root": "",
21886
- className: cn("fixed inset-0 z-[2147483646] bg-black/50", className),
21887
- ...props
21888
- }
21889
- );
21890
- }
21891
- var DialogContent = React9.forwardRef(
21892
- ({ className, children, showCloseButton = true, container, ...props }, ref) => {
21893
- const positionMode = container ? "absolute" : "fixed";
21894
- return /* @__PURE__ */ jsxs15(DialogPortal, { container: container ?? void 0, children: [
21895
- /* @__PURE__ */ jsx24(DialogOverlay, { className: cn(positionMode, "inset-0") }),
21896
- /* @__PURE__ */ jsxs15(
21897
- DialogPrimitive.Content,
21898
- {
21899
- ref,
21900
- "data-slot": "dialog-content",
21901
- className: cn(
21902
- positionMode,
21903
- "left-1/2 top-1/2 z-[2147483647] flex w-full max-w-[448px] -translate-x-1/2 -translate-y-1/2 flex-col overflow-visible",
21904
- "rounded-xl border border-border bg-background font-sans shadow-lg outline-none",
21905
- container ? "max-h-[calc(100%-32px)]" : "max-h-[calc(100vh-32px)]",
21906
- className
21907
- ),
21908
- onMouseDown: (e) => e.stopPropagation(),
21909
- ...props,
21910
- children: [
21911
- children,
21912
- showCloseButton ? /* @__PURE__ */ jsx24(
21913
- DialogPrimitive.Close,
21914
- {
21915
- type: "button",
21916
- className: "absolute right-[9px] top-[9px] rounded-sm p-1.5 text-foreground hover:bg-muted/50",
21917
- "aria-label": "Close",
21918
- children: /* @__PURE__ */ jsx24(X2, { size: 16, "aria-hidden": true })
21919
- }
21920
- ) : null
21921
- ]
21922
- }
21923
- )
21924
- ] });
21925
- }
21926
- );
21927
- DialogContent.displayName = DialogPrimitive.Content.displayName;
21928
- function DialogHeader({
21929
- className,
21930
- ...props
21931
- }) {
21932
- return /* @__PURE__ */ jsx24("div", { className: cn("flex flex-col gap-1.5", className), ...props });
21933
- }
21934
- function DialogFooter({
21935
- className,
21936
- ...props
21937
- }) {
21938
- return /* @__PURE__ */ jsx24(
21939
- "div",
21940
- {
21941
- className: cn("flex items-center justify-end gap-2", className),
21942
- ...props
21943
- }
21944
- );
21945
- }
21946
- var DialogTitle = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx24(
21947
- DialogPrimitive.Title,
21948
- {
21949
- ref,
21950
- className: cn(
21951
- "text-lg font-semibold leading-none tracking-tight text-card-foreground",
21952
- className
21953
- ),
21954
- ...props
21955
- }
21956
- ));
21957
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
21958
- var DialogDescription = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx24(
21959
- DialogPrimitive.Description,
21960
- {
21961
- ref,
21962
- className: cn("text-sm text-muted-foreground", className),
21963
- ...props
21964
- }
21965
- ));
21966
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
21967
- var DialogClose = DialogPrimitive.Close;
23158
+ import { useEffect as useEffect17 } from "react";
21968
23159
 
21969
23160
  // src/ui/link-modal/LinkEditorPanel.tsx
21970
23161
  import { Info, X as X4 } from "lucide-react";
21971
23162
 
21972
23163
  // src/ui/link-modal/DestinationBreadcrumb.tsx
21973
- import { ArrowRight as ArrowRight2, File, GalleryVertical } from "lucide-react";
23164
+ import { ArrowRight as ArrowRight3, File, GalleryVertical } from "lucide-react";
21974
23165
  import { jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
21975
23166
  function DestinationBreadcrumb({
21976
23167
  pageTitle,
@@ -21984,7 +23175,7 @@ function DestinationBreadcrumb({
21984
23175
  /* @__PURE__ */ jsx25("span", { className: "text-sm font-medium leading-none text-foreground!", children: pageTitle })
21985
23176
  ] }),
21986
23177
  /* @__PURE__ */ jsx25(
21987
- ArrowRight2,
23178
+ ArrowRight3,
21988
23179
  {
21989
23180
  size: 16,
21990
23181
  className: "shrink-0 text-muted-foreground",
@@ -22057,7 +23248,7 @@ function SectionTreeItem({
22057
23248
  }
22058
23249
 
22059
23250
  // src/ui/link-modal/UrlOrPageInput.tsx
22060
- import { useEffect as useEffect13, useId as useId2, useRef as useRef9, useState as useState12 } from "react";
23251
+ import { useEffect as useEffect14, useId as useId2, useRef as useRef9, useState as useState12 } from "react";
22061
23252
 
22062
23253
  // src/ui/input.tsx
22063
23254
  import * as React10 from "react";
@@ -22096,7 +23287,7 @@ function Label({ className, ...props }) {
22096
23287
  }
22097
23288
 
22098
23289
  // src/ui/link-modal/UrlOrPageInput.tsx
22099
- import { ChevronDown as ChevronDown4, File as File2, X as X3 } from "lucide-react";
23290
+ import { ChevronDown as ChevronDown5, File as File2, X as X3 } from "lucide-react";
22100
23291
  import { jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
22101
23292
  function FieldChevron({
22102
23293
  onClick
@@ -22109,7 +23300,7 @@ function FieldChevron({
22109
23300
  onClick,
22110
23301
  "aria-label": "Open page list",
22111
23302
  tabIndex: -1,
22112
- children: /* @__PURE__ */ jsx29(ChevronDown4, { size: 16 })
23303
+ children: /* @__PURE__ */ jsx29(ChevronDown5, { size: 16 })
22113
23304
  }
22114
23305
  );
22115
23306
  }
@@ -22129,7 +23320,7 @@ function UrlOrPageInput({
22129
23320
  const inputRef = useRef9(null);
22130
23321
  const rootRef = useRef9(null);
22131
23322
  const [isFocused, setIsFocused] = useState12(false);
22132
- useEffect13(() => {
23323
+ useEffect14(() => {
22133
23324
  if (!dropdownOpen) return;
22134
23325
  const isOutside = (e) => {
22135
23326
  const root = rootRef.current;
@@ -22337,9 +23528,9 @@ function LinkEditorPanel({ state, onClose }) {
22337
23528
  }
22338
23529
 
22339
23530
  // src/ui/link-modal/SectionPickerOverlay.tsx
22340
- import { useCallback as useCallback7, useEffect as useEffect14, useMemo as useMemo2, useRef as useRef10, useState as useState13 } from "react";
23531
+ import { useCallback as useCallback7, useEffect as useEffect15, useMemo as useMemo2, useRef as useRef10, useState as useState13 } from "react";
22341
23532
  import { createPortal as createPortal2 } from "react-dom";
22342
- import { ArrowLeft as ArrowLeft2, Check as Check3 } from "lucide-react";
23533
+ import { ArrowLeft as ArrowLeft3, Check as Check4 } from "lucide-react";
22343
23534
  import { usePathname as usePathname2, useRouter as useRouter2 } from "next/navigation";
22344
23535
 
22345
23536
  // src/lib/parent-scroll.ts
@@ -22399,7 +23590,7 @@ function useSectionRects(sectionIdsKey, enabled) {
22399
23590
  () => sectionIdsKey ? sectionIdsKey.split("\0") : [],
22400
23591
  [sectionIdsKey]
22401
23592
  );
22402
- useEffect14(() => {
23593
+ useEffect15(() => {
22403
23594
  if (!enabled || sectionIds.length === 0) {
22404
23595
  setRects((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Map());
22405
23596
  return;
@@ -22454,12 +23645,12 @@ function SectionPickerOverlay({
22454
23645
  );
22455
23646
  const normalizedTarget = normalizePath(pagePath);
22456
23647
  const isOnTargetPage = normalizePath(pathname) === normalizedTarget;
22457
- useEffect14(() => {
23648
+ useEffect15(() => {
22458
23649
  if (isOnTargetPage) return;
22459
23650
  const search = readPreservedSearch();
22460
23651
  router.push(`${normalizedTarget}${search}`);
22461
23652
  }, [isOnTargetPage, normalizedTarget, router]);
22462
- useEffect14(() => {
23653
+ useEffect15(() => {
22463
23654
  document.documentElement.setAttribute("data-ohw-section-picking", "");
22464
23655
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => {
22465
23656
  el.removeAttribute("data-ohw-hovered");
@@ -22497,7 +23688,7 @@ function SectionPickerOverlay({
22497
23688
  },
22498
23689
  []
22499
23690
  );
22500
- useEffect14(() => {
23691
+ useEffect15(() => {
22501
23692
  const applyClip = (iframeOffsetTop, visibleCanvasTop, canvasH, promptBarH = 0) => {
22502
23693
  const next = getIframeVisibleClip({
22503
23694
  iframeOffsetTop,
@@ -22541,12 +23732,12 @@ function SectionPickerOverlay({
22541
23732
  window.removeEventListener("resize", onResize);
22542
23733
  };
22543
23734
  }, [applyHoverAt]);
22544
- useEffect14(() => {
23735
+ useEffect15(() => {
22545
23736
  const ptr = pointerRef.current;
22546
23737
  if (!ptr) return;
22547
23738
  applyHoverAt(ptr.x, ptr.y, rects);
22548
23739
  }, [rects, applyHoverAt]);
22549
- useEffect14(() => {
23740
+ useEffect15(() => {
22550
23741
  const rememberPointer = (clientX, clientY) => {
22551
23742
  pointerRef.current = { x: clientX, y: clientY };
22552
23743
  const top = iframeOffsetTopRef.current;
@@ -22578,7 +23769,7 @@ function SectionPickerOverlay({
22578
23769
  },
22579
23770
  [selectedId, onSelect]
22580
23771
  );
22581
- useEffect14(() => {
23772
+ useEffect15(() => {
22582
23773
  const onKeyDown = (e) => {
22583
23774
  if (e.key === "Escape") {
22584
23775
  e.preventDefault();
@@ -22616,7 +23807,7 @@ function SectionPickerOverlay({
22616
23807
  className: "h-8 min-w-0 gap-1 border-border bg-background px-2 py-1.5 shadow-sm hover:bg-muted cursor-pointer",
22617
23808
  onClick: onBack,
22618
23809
  children: [
22619
- /* @__PURE__ */ jsx31(ArrowLeft2, { className: "size-4 shrink-0", "aria-hidden": true }),
23810
+ /* @__PURE__ */ jsx31(ArrowLeft3, { className: "size-4 shrink-0", "aria-hidden": true }),
22620
23811
  "Back"
22621
23812
  ]
22622
23813
  }
@@ -22685,7 +23876,7 @@ function SectionPickerOverlay({
22685
23876
  className: "absolute right-3 top-3 flex size-8 items-center justify-center rounded-full text-white",
22686
23877
  style: { backgroundColor: "var(--ohw-primary, #0885fe)" },
22687
23878
  "aria-hidden": true,
22688
- children: /* @__PURE__ */ jsx31(Check3, { className: "size-5" })
23879
+ children: /* @__PURE__ */ jsx31(Check4, { className: "size-5" })
22689
23880
  }
22690
23881
  ) : null
22691
23882
  ]
@@ -22701,7 +23892,7 @@ function SectionPickerOverlay({
22701
23892
  }
22702
23893
 
22703
23894
  // src/ui/link-modal/useLinkModalState.ts
22704
- import { useCallback as useCallback8, useEffect as useEffect15, useMemo as useMemo3, useState as useState14 } from "react";
23895
+ import { useCallback as useCallback8, useEffect as useEffect16, useMemo as useMemo3, useState as useState14 } from "react";
22705
23896
  function useLinkModalState({
22706
23897
  open,
22707
23898
  mode,
@@ -22728,7 +23919,7 @@ function useLinkModalState({
22728
23919
  setDropdownOpen(false);
22729
23920
  setUrlError("");
22730
23921
  }, []);
22731
- useEffect15(() => {
23922
+ useEffect16(() => {
22732
23923
  if (!open) return;
22733
23924
  if (mode === "edit" && initialTarget) {
22734
23925
  const { pageRoute } = parseTarget(initialTarget);
@@ -22894,7 +24085,7 @@ function LinkPopover({
22894
24085
  onSubmit
22895
24086
  });
22896
24087
  const sectionPickerActive = state.showSectionPicker && Boolean(state.selectedPage);
22897
- useEffect16(() => {
24088
+ useEffect17(() => {
22898
24089
  if (!open) return;
22899
24090
  if (sectionPickerActive) {
22900
24091
  postToParent({ type: "ui:unlock" });
@@ -23069,6 +24260,7 @@ function shouldUseDevFixtures() {
23069
24260
  function getLogoElement(el) {
23070
24261
  const marked = el.closest('[data-ohw-role="logo"], [data-ohw-logo]');
23071
24262
  if (marked) return marked;
24263
+ if (el.closest('[data-ohw-editable="icon"]')) return null;
23072
24264
  const root = el.closest("nav, [data-ohw-nav-root], footer");
23073
24265
  if (!root) return null;
23074
24266
  const anchor = el.closest("a");
@@ -23137,8 +24329,8 @@ function addFooterColumnWithPersist({
23137
24329
  // src/ui/FloatingPanel.tsx
23138
24330
  import {
23139
24331
  useCallback as useCallback9,
23140
- useEffect as useEffect17,
23141
- useLayoutEffect as useLayoutEffect5,
24332
+ useEffect as useEffect18,
24333
+ useLayoutEffect as useLayoutEffect6,
23142
24334
  useRef as useRef11,
23143
24335
  useState as useState15
23144
24336
  } from "react";
@@ -23221,10 +24413,10 @@ function FloatingPanel({
23221
24413
  x: clampX(home.x, measured.w),
23222
24414
  y: fittedY
23223
24415
  };
23224
- useEffect17(() => {
24416
+ useEffect18(() => {
23225
24417
  setLiveScroll(parentScroll);
23226
24418
  }, [parentScroll]);
23227
- useEffect17(() => {
24419
+ useEffect18(() => {
23228
24420
  if (!open) return;
23229
24421
  const onParentScroll = (e) => {
23230
24422
  if (e.data?.type !== "ow:parent-scroll") return;
@@ -23235,7 +24427,7 @@ function FloatingPanel({
23235
24427
  return () => window.removeEventListener("message", onParentScroll);
23236
24428
  }, [open]);
23237
24429
  const positionRef = useRef11(position);
23238
- useLayoutEffect5(() => {
24430
+ useLayoutEffect6(() => {
23239
24431
  if (!open) {
23240
24432
  positionRef.current = position;
23241
24433
  return;
@@ -23245,7 +24437,7 @@ function FloatingPanel({
23245
24437
  }
23246
24438
  positionRef.current = position;
23247
24439
  }, [open, position, liveScroll, parentScroll]);
23248
- useLayoutEffect5(() => {
24440
+ useLayoutEffect6(() => {
23249
24441
  if (!open || !panelRef.current) return;
23250
24442
  const el = panelRef.current;
23251
24443
  const header = el.querySelector("[data-ohw-floating-panel-header]");
@@ -23309,11 +24501,11 @@ function FloatingPanel({
23309
24501
  } catch {
23310
24502
  }
23311
24503
  }, []);
23312
- useEffect17(() => {
24504
+ useEffect18(() => {
23313
24505
  if (open) return;
23314
24506
  document.documentElement.removeAttribute("data-ohw-panel-dragging");
23315
24507
  }, [open]);
23316
- useEffect17(() => () => document.documentElement.removeAttribute("data-ohw-panel-dragging"), []);
24508
+ useEffect18(() => () => document.documentElement.removeAttribute("data-ohw-panel-dragging"), []);
23317
24509
  if (!open) return null;
23318
24510
  return /* @__PURE__ */ jsxs22(
23319
24511
  "div",
@@ -23454,7 +24646,7 @@ function SocialsDisplayPanel({ display, onChange, className }) {
23454
24646
  }
23455
24647
 
23456
24648
  // src/ui/button-style-panel.tsx
23457
- import { Check as Check4 } from "lucide-react";
24649
+ import { Check as Check5 } from "lucide-react";
23458
24650
  import { jsx as jsx35, jsxs as jsxs24 } from "react/jsx-runtime";
23459
24651
  var SIZE_LABEL = { s: "S", m: "M", l: "L" };
23460
24652
  function ButtonStylePanel({
@@ -23525,7 +24717,7 @@ function ButtonStylePanel({
23525
24717
  {
23526
24718
  className: "absolute right-0.5 top-0.5 flex size-5 items-center justify-center rounded-full bg-primary text-primary-foreground",
23527
24719
  "aria-hidden": true,
23528
- children: /* @__PURE__ */ jsx35(Check4, { className: "size-3", strokeWidth: 3 })
24720
+ children: /* @__PURE__ */ jsx35(Check5, { className: "size-3", strokeWidth: 3 })
23529
24721
  }
23530
24722
  ) : null
23531
24723
  ]
@@ -23833,7 +25025,7 @@ function hitTestNavDropSlot(clientX, clientY, draggedHrefKey, draggedEl) {
23833
25025
  }
23834
25026
 
23835
25027
  // src/useNavItemDrag.ts
23836
- import { useCallback as useCallback10, useEffect as useEffect18, useRef as useRef12, useState as useState16 } from "react";
25028
+ import { useCallback as useCallback10, useEffect as useEffect19, useRef as useRef12, useState as useState16 } from "react";
23837
25029
  function useNavItemDrag({
23838
25030
  isEditMode,
23839
25031
  editContentRef,
@@ -24066,7 +25258,7 @@ function useNavItemDrag({
24066
25258
  },
24067
25259
  []
24068
25260
  );
24069
- useEffect18(() => {
25261
+ useEffect19(() => {
24070
25262
  if (!isEditMode) return;
24071
25263
  const THRESHOLD = 10;
24072
25264
  const resolveWasSelected = (el) => {
@@ -24225,7 +25417,7 @@ function useNavItemDrag({
24225
25417
  }
24226
25418
 
24227
25419
  // src/useSectionDrag.ts
24228
- import { useCallback as useCallback11, useEffect as useEffect19, useRef as useRef13, useState as useState17 } from "react";
25420
+ import { useCallback as useCallback11, useEffect as useEffect20, useRef as useRef13, useState as useState17 } from "react";
24229
25421
 
24230
25422
  // src/lib/section-dnd.ts
24231
25423
  function isFooterSection(el) {
@@ -24452,7 +25644,7 @@ function useSectionDrag({
24452
25644
  },
24453
25645
  [footerDragRef, navDragRef]
24454
25646
  );
24455
- useEffect19(() => {
25647
+ useEffect20(() => {
24456
25648
  if (!isEditMode) return;
24457
25649
  const onPointerDown = (e) => {
24458
25650
  if (e.button !== 0) return;
@@ -24557,7 +25749,7 @@ function useSectionDrag({
24557
25749
  }
24558
25750
 
24559
25751
  // src/ui/footer-container-chrome.tsx
24560
- import { Plus as Plus3 } from "lucide-react";
25752
+ import { Plus as Plus4 } from "lucide-react";
24561
25753
  import { jsx as jsx36, jsxs as jsxs25 } from "react/jsx-runtime";
24562
25754
  function FooterContainerChrome({
24563
25755
  rect,
@@ -24598,7 +25790,7 @@ function FooterContainerChrome({
24598
25790
  if (addDisabled) return;
24599
25791
  onAdd();
24600
25792
  },
24601
- children: /* @__PURE__ */ jsx36(Plus3, { className: "size-4 shrink-0 text-foreground", "aria-hidden": true })
25793
+ children: /* @__PURE__ */ jsx36(Plus4, { className: "size-4 shrink-0 text-foreground", "aria-hidden": true })
24602
25794
  }
24603
25795
  ) }),
24604
25796
  /* @__PURE__ */ jsx36(TooltipContent, { side: "bottom", sideOffset: 9, children: addDisabled ? "Maximum columns reached" : "Add item" })
@@ -24777,7 +25969,7 @@ function deleteSelectedNavFooterItem(deps) {
24777
25969
  }
24778
25970
 
24779
25971
  // src/lib/build-page-sync.ts
24780
- import { useEffect as useEffect20 } from "react";
25972
+ import { useEffect as useEffect21 } from "react";
24781
25973
  var CHROME_KEY_RE = /^(nav|footer|header|navbar)[-_]/u;
24782
25974
  function normalisePath(path) {
24783
25975
  const trimmed = path.trim().replace(/[?#].*$/u, "");
@@ -24842,12 +26034,12 @@ function collectLinks() {
24842
26034
  document.querySelectorAll("[data-ohw-href-key]").forEach((el) => {
24843
26035
  const hrefKey = el.getAttribute("data-ohw-href-key") ?? "";
24844
26036
  if (seen.has(hrefKey)) return;
24845
- const area = isNavbarHrefKey(hrefKey) ? "nav" : isFooterHrefKey(hrefKey) ? "footer" : CHROME_KEY_RE.test(hrefKey) ? "chrome" : null;
24846
- if (!area) return;
26037
+ const area2 = isNavbarHrefKey(hrefKey) ? "nav" : isFooterHrefKey(hrefKey) ? "footer" : CHROME_KEY_RE.test(hrefKey) ? "chrome" : null;
26038
+ if (!area2) return;
24847
26039
  const label = labelEl(el);
24848
- if (!label && area !== "chrome") return;
26040
+ if (!label && area2 !== "chrome") return;
24849
26041
  seen.add(hrefKey);
24850
- links.push({ hrefKey, href: linkHref(el), label: label?.textContent ?? el.textContent ?? "", area });
26042
+ links.push({ hrefKey, href: linkHref(el), label: label?.textContent ?? el.textContent ?? "", area: area2 });
24851
26043
  });
24852
26044
  return links;
24853
26045
  }
@@ -24890,7 +26082,7 @@ function applyBuildPageSync(msg, deps) {
24890
26082
  return plan.remove.length + plan.relabel.length + plan.retarget.length;
24891
26083
  }
24892
26084
  function useBuildPageSync(isEditMode, editContentRef, postToParent2) {
24893
- useEffect20(() => {
26085
+ useEffect21(() => {
24894
26086
  if (!isEditMode) return;
24895
26087
  const onMessage = (e) => {
24896
26088
  if (e.source !== window.parent || e.data?.type !== "ow:pages-sync") return;
@@ -25005,7 +26197,7 @@ function retargetPageLinks(change, deps) {
25005
26197
  }
25006
26198
 
25007
26199
  // src/ui/navbar-container-chrome.tsx
25008
- import { Plus as Plus4 } from "lucide-react";
26200
+ import { Plus as Plus5 } from "lucide-react";
25009
26201
  import { jsx as jsx37 } from "react/jsx-runtime";
25010
26202
  function NavbarContainerChrome({
25011
26203
  rect,
@@ -25041,7 +26233,7 @@ function NavbarContainerChrome({
25041
26233
  e.stopPropagation();
25042
26234
  onAdd();
25043
26235
  },
25044
- children: /* @__PURE__ */ jsx37(Plus4, { className: "size-4 shrink-0 text-foreground", "aria-hidden": true })
26236
+ children: /* @__PURE__ */ jsx37(Plus5, { className: "size-4 shrink-0 text-foreground", "aria-hidden": true })
25045
26237
  }
25046
26238
  )
25047
26239
  }
@@ -25113,7 +26305,7 @@ function Badge({ className, variant, ...props }) {
25113
26305
  }
25114
26306
 
25115
26307
  // src/OhhwellsBridge.tsx
25116
- import { Brush as Brush2, Link as Link2, Plus as Plus5, Settings, Trash2 as Trash24 } from "lucide-react";
26308
+ import { Brush as Brush2, Link as Link2, Plus as Plus6, Settings, Trash2 as Trash24 } from "lucide-react";
25117
26309
  import { Fragment as Fragment13, jsx as jsx40, jsxs as jsxs26 } from "react/jsx-runtime";
25118
26310
  var PRIMARY7 = "#0885FE";
25119
26311
  var IMAGE_FADE_MS = 300;
@@ -25891,7 +27083,7 @@ function getNavigationSelectionParent(el) {
25891
27083
  if (!isFooterLinksContainer(el) && (el.hasAttribute("data-ohw-footer-col") || el.hasAttribute("data-ohw-footer-column") || isInferredFooterGroup2(el))) {
25892
27084
  return resolveFooterLinksContainerFrom(el);
25893
27085
  }
25894
- if (el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-nav-drawer") || isFooterLinksContainer(el)) {
27086
+ if (el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-nav-drawer") || el.hasAttribute("data-ohw-footer-col") || el.hasAttribute("data-ohw-footer-column") || isFooterLinksContainer(el) || isInferredFooterGroup2(el)) {
25895
27087
  return getNavigationRoot(el);
25896
27088
  }
25897
27089
  return null;
@@ -26113,7 +27305,6 @@ var ICONS = {
26113
27305
  insertUnorderedList: '<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>',
26114
27306
  insertOrderedList: '<line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/>'
26115
27307
  };
26116
- var HEIGHT_SETTLE_DELAYS = [150, 400, 800];
26117
27308
  var SELECTION_CHROME_GAP2 = 4;
26118
27309
  var TOOLBAR_STROKE_GAP2 = 4;
26119
27310
  var TOOLBAR_OFFSET_FROM_ELEMENT = SELECTION_CHROME_GAP2 + TOOLBAR_STROKE_GAP2;
@@ -26211,7 +27402,7 @@ function applyVisibleViewport(el, parentScroll) {
26211
27402
  el.style.top = `${top}px`;
26212
27403
  el.style.height = `${height}px`;
26213
27404
  }
26214
- var TOOLBAR_EDGE_MARGIN3 = 4;
27405
+ var TOOLBAR_EDGE_MARGIN4 = 4;
26215
27406
  function clampToolbarToClip(top, transform, rect, clip, approxH, gap) {
26216
27407
  const isAbove = transform.includes("translateY(-100%)");
26217
27408
  let visualTop = isAbove ? top - approxH : top;
@@ -26238,8 +27429,8 @@ function clampToolbarToClip(top, transform, rect, clip, approxH, gap) {
26238
27429
  function clampToolbarLeft(centerX, toolbarWidth) {
26239
27430
  const half = toolbarWidth / 2;
26240
27431
  return Math.max(
26241
- TOOLBAR_EDGE_MARGIN3 + half,
26242
- Math.min(centerX, window.innerWidth - TOOLBAR_EDGE_MARGIN3 - half)
27432
+ TOOLBAR_EDGE_MARGIN4 + half,
27433
+ Math.min(centerX, window.innerWidth - TOOLBAR_EDGE_MARGIN4 - half)
26243
27434
  );
26244
27435
  }
26245
27436
  function calcToolbarPos(rect, parentScroll, toolbarW = 306) {
@@ -26637,7 +27828,7 @@ function OhhwellsBridge() {
26637
27828
  const searchParams = useSearchParams();
26638
27829
  const isEditMode = isEditSessionActive();
26639
27830
  const [bridgeRoot, setBridgeRoot] = useState18(null);
26640
- useEffect21(() => {
27831
+ useEffect22(() => {
26641
27832
  const figtreeFontId = "ohw-figtree-font";
26642
27833
  if (!document.getElementById(figtreeFontId)) {
26643
27834
  const preconnect1 = Object.assign(document.createElement("link"), { rel: "preconnect", href: "https://fonts.googleapis.com" });
@@ -26664,7 +27855,7 @@ function OhhwellsBridge() {
26664
27855
  }, []);
26665
27856
  const subdomainFromQuery = searchParams.get("subdomain");
26666
27857
  const [subdomain, setSubdomain] = useState18(() => resolveSubdomain(subdomainFromQuery));
26667
- useLayoutEffect6(() => {
27858
+ useLayoutEffect7(() => {
26668
27859
  const next = resolveSubdomain(subdomainFromQuery);
26669
27860
  if (next !== subdomain) setSubdomain(next);
26670
27861
  if (next) return;
@@ -26676,7 +27867,7 @@ function OhhwellsBridge() {
26676
27867
  }, 0);
26677
27868
  return () => window.clearTimeout(t);
26678
27869
  }, [subdomainFromQuery, subdomain]);
26679
- useEffect21(() => {
27870
+ useEffect22(() => {
26680
27871
  if (!subdomainFromQuery || typeof window === "undefined") return;
26681
27872
  const url = new URL(window.location.href);
26682
27873
  if (!url.searchParams.has("subdomain")) return;
@@ -26687,6 +27878,7 @@ function OhhwellsBridge() {
26687
27878
  useLinkHrefGuardian(pathname, subdomain, isEditMode);
26688
27879
  useSavedLinkNavigation(isEditMode);
26689
27880
  useNavDropdownToggle(isEditMode);
27881
+ useBackgroundTone();
26690
27882
  useHashLinkScroll(isEditMode);
26691
27883
  usePublishedPlaceholderStrip(isEditMode);
26692
27884
  const postToParent2 = useCallback12((data) => {
@@ -26697,14 +27889,14 @@ function OhhwellsBridge() {
26697
27889
  const [fetchState, setFetchState] = useState18("idle");
26698
27890
  const [showBranding, setShowBranding] = useState18(false);
26699
27891
  const autoSaveTimers = useRef14(/* @__PURE__ */ new Map());
26700
- useEffect21(() => {
27892
+ useEffect22(() => {
26701
27893
  stampBridgeVersionOnDocument();
26702
27894
  }, []);
26703
- useEffect21(() => {
27895
+ useEffect22(() => {
26704
27896
  if (isEditMode) return;
26705
27897
  return armLoaderHangBeacon(subdomain, fetchState);
26706
27898
  }, [isEditMode, subdomain, fetchState]);
26707
- useEffect21(() => {
27899
+ useEffect22(() => {
26708
27900
  if (isEditMode || !subdomain) return;
26709
27901
  const onError = (event) => {
26710
27902
  reportOutageBeacon({
@@ -26845,7 +28037,7 @@ function OhhwellsBridge() {
26845
28037
  }, []);
26846
28038
  const selectMediaElementRef = useRef14(selectMediaElement);
26847
28039
  selectMediaElementRef.current = selectMediaElement;
26848
- useEffect21(() => {
28040
+ useEffect22(() => {
26849
28041
  if (!selectedMedia) return;
26850
28042
  const update = () => {
26851
28043
  const el = selectedMediaElRef.current;
@@ -26873,6 +28065,8 @@ function OhhwellsBridge() {
26873
28065
  const editStylesRef = useRef14(null);
26874
28066
  const activateRef = useRef14(() => {
26875
28067
  });
28068
+ const stateChangeRef = useRef14(() => {
28069
+ });
26876
28070
  const deactivateRef = useRef14(() => {
26877
28071
  });
26878
28072
  const selectRef = useRef14(() => {
@@ -27060,7 +28254,7 @@ function OhhwellsBridge() {
27060
28254
  const [fieldDragging, setFieldDragging] = useState18(false);
27061
28255
  const clearFormPickRef = useRef14(clearFormPick);
27062
28256
  clearFormPickRef.current = clearFormPick;
27063
- useEffect21(() => {
28257
+ useEffect22(() => {
27064
28258
  const el = fieldPickElRef.current;
27065
28259
  if (!el || fieldPickRect === null) return;
27066
28260
  const observer = new ResizeObserver(() => {
@@ -27069,7 +28263,7 @@ function OhhwellsBridge() {
27069
28263
  observer.observe(el);
27070
28264
  return () => observer.disconnect();
27071
28265
  }, [fieldPickRect !== null, fieldPickState]);
27072
- useEffect21(() => {
28266
+ useEffect22(() => {
27073
28267
  const el = formPickElRef.current;
27074
28268
  if (!el || formPickRect === null) return;
27075
28269
  const observer = new ResizeObserver(() => {
@@ -27098,7 +28292,7 @@ function OhhwellsBridge() {
27098
28292
  const hoveredItemElRef = useRef14(null);
27099
28293
  const [hoveredItemRect, setHoveredItemRect] = useState18(null);
27100
28294
  const [hoveredTextRect, setHoveredTextRect] = useState18(null);
27101
- useEffect21(() => {
28295
+ useEffect22(() => {
27102
28296
  const sync = () => {
27103
28297
  const el = document.querySelector(
27104
28298
  '[data-ohw-hovered]:not([contenteditable]):not([data-ohw-href-key]):not([data-ohw-editable="form"] *)'
@@ -27148,21 +28342,6 @@ function OhhwellsBridge() {
27148
28342
  const [isItemDragging, setIsItemDragging] = useState18(false);
27149
28343
  const [isFooterFrameSelection, setIsFooterFrameSelection] = useState18(false);
27150
28344
  isFooterFrameSelectionRef.current = isFooterFrameSelection;
27151
- const [floatingPanel, setFloatingPanel] = useState18(null);
27152
- const floatingPanelOpenRef = useRef14(false);
27153
- floatingPanelOpenRef.current = floatingPanel !== null;
27154
- const floatingPanelRef = useRef14(null);
27155
- floatingPanelRef.current = floatingPanel;
27156
- const [floatingPanelPos, setFloatingPanelPos] = useState18(null);
27157
- const buttonCollectionDragRef = useRef14(null);
27158
- const buttonDropInsertIndexRef = useRef14(null);
27159
- const [buttonDropSlots, setButtonDropSlots] = useState18([]);
27160
- const [activeButtonDropIndex, setActiveButtonDropIndex] = useState18(null);
27161
- const buttonPointerDragRef = useRef14(null);
27162
- const [buttonStyleTick, setButtonStyleTick] = useState18(0);
27163
- const [logoSizeDraft, setLogoSizeDraft] = useState18(null);
27164
- const [editorViewport, setEditorViewport] = useState18("desktop");
27165
- const [parentScrollSnap, setParentScrollSnap] = useState18(null);
27166
28345
  const [navDropdownPreviewOpen, setNavDropdownPreviewOpen] = useState18(null);
27167
28346
  const [footerHeadingVisible, setFooterHeadingVisible] = useState18(null);
27168
28347
  const footerDragRef = useRef14(null);
@@ -27189,6 +28368,21 @@ function OhhwellsBridge() {
27189
28368
  const stylesRef = useRef14("");
27190
28369
  const appliedDrawerRef = useRef14(null);
27191
28370
  const pendingDeleteUndoRef = useRef14(null);
28371
+ const [floatingPanel, setFloatingPanel] = useState18(null);
28372
+ const floatingPanelOpenRef = useRef14(false);
28373
+ const floatingPanelRef = useRef14(null);
28374
+ floatingPanelRef.current = floatingPanel;
28375
+ const setFloatingPanelRef = useRef14(setFloatingPanel);
28376
+ const [floatingPanelPos, setFloatingPanelPos] = useState18(null);
28377
+ const buttonCollectionDragRef = useRef14(null);
28378
+ const buttonDropInsertIndexRef = useRef14(null);
28379
+ const [buttonDropSlots, setButtonDropSlots] = useState18([]);
28380
+ const [activeButtonDropIndex, setActiveButtonDropIndex] = useState18(null);
28381
+ const buttonPointerDragRef = useRef14(null);
28382
+ const [buttonStyleTick, setButtonStyleTick] = useState18(0);
28383
+ const [logoSizeDraft, setLogoSizeDraft] = useState18(null);
28384
+ const [editorViewport, setEditorViewport] = useState18("desktop");
28385
+ const [parentScrollSnap, setParentScrollSnap] = useState18(null);
27192
28386
  const [sitePages, setSitePages] = useState18([]);
27193
28387
  const collectionItemsRef = useRef14(/* @__PURE__ */ new Map());
27194
28388
  const [sectionsByPath, setSectionsByPath] = useState18({});
@@ -27198,8 +28392,19 @@ function OhhwellsBridge() {
27198
28392
  const linkPopoverOpenRef = useRef14(false);
27199
28393
  const linkPopoverGraceUntilRef = useRef14(0);
27200
28394
  setLinkPopoverRef.current = setLinkPopover;
28395
+ setFloatingPanelRef.current = setFloatingPanel;
27201
28396
  linkPopoverSessionRef.current = linkPopover;
27202
- useEffect21(() => {
28397
+ floatingPanelOpenRef.current = Boolean(floatingPanel);
28398
+ useEffect22(() => {
28399
+ const syncViewport = () => {
28400
+ const next = window.innerWidth <= 480 ? "mobile" : "desktop";
28401
+ setEditorViewport((prev) => prev === next ? prev : next);
28402
+ };
28403
+ syncViewport();
28404
+ window.addEventListener("resize", syncViewport);
28405
+ return () => window.removeEventListener("resize", syncViewport);
28406
+ }, []);
28407
+ useEffect22(() => {
27203
28408
  setSectionOrderPersistHandler((entries) => {
27204
28409
  const currentPath = window.location.pathname;
27205
28410
  const merged = mergePageSectionOrder(editContentRef.current[SECTION_ORDER_KEY], currentPath, entries);
@@ -27209,7 +28414,7 @@ function OhhwellsBridge() {
27209
28414
  });
27210
28415
  return () => setSectionOrderPersistHandler(null);
27211
28416
  }, []);
27212
- useEffect21(() => {
28417
+ useEffect22(() => {
27213
28418
  setAiFooterMountOptions({
27214
28419
  resolvePageHref: (pageOrAnchorId) => {
27215
28420
  const [pageId, anchor] = pageOrAnchorId.split("#");
@@ -27293,7 +28498,7 @@ function OhhwellsBridge() {
27293
28498
  }, [isEditMode, pathname]);
27294
28499
  const runSectionsPrefetchRef = useRef14(runSectionsPrefetch);
27295
28500
  runSectionsPrefetchRef.current = runSectionsPrefetch;
27296
- useEffect21(() => {
28501
+ useEffect22(() => {
27297
28502
  if (!linkPopover) {
27298
28503
  document.documentElement.removeAttribute("data-ohw-link-popover-open");
27299
28504
  return;
@@ -27321,7 +28526,7 @@ function OhhwellsBridge() {
27321
28526
  document.documentElement.removeAttribute("data-ohw-link-popover-open");
27322
28527
  };
27323
28528
  }, [linkPopover, postToParent2]);
27324
- useEffect21(() => {
28529
+ useEffect22(() => {
27325
28530
  if (!isEditMode) return;
27326
28531
  const useFixtures = shouldUseDevFixtures();
27327
28532
  if (useFixtures) {
@@ -27347,7 +28552,7 @@ function OhhwellsBridge() {
27347
28552
  if (!useFixtures) postToParent2({ type: "ow:request-site-pages" });
27348
28553
  return () => window.removeEventListener("message", onSitePages);
27349
28554
  }, [isEditMode, postToParent2]);
27350
- useEffect21(() => {
28555
+ useEffect22(() => {
27351
28556
  if (!isEditMode) return;
27352
28557
  const deps = {
27353
28558
  getEditContent: () => editContentRef.current,
@@ -27384,14 +28589,14 @@ function OhhwellsBridge() {
27384
28589
  window.addEventListener("message", onPageMessage);
27385
28590
  return () => window.removeEventListener("message", onPageMessage);
27386
28591
  }, [isEditMode, postToParent2]);
27387
- useEffect21(() => {
28592
+ useEffect22(() => {
27388
28593
  if (!isEditMode || shouldUseDevFixtures()) return;
27389
28594
  void loadAllSectionsManifest().then((manifest) => {
27390
28595
  if (Object.keys(manifest).length === 0) return;
27391
28596
  setSectionsByPath((prev) => ({ ...manifest, ...prev }));
27392
28597
  });
27393
28598
  }, [isEditMode]);
27394
- useEffect21(() => {
28599
+ useEffect22(() => {
27395
28600
  const update = () => {
27396
28601
  const el = activeElRef.current ?? selectedElRef.current;
27397
28602
  if (el) setToolbarRect(getEditMeasureEl(el).getBoundingClientRect());
@@ -28652,7 +29857,7 @@ function OhhwellsBridge() {
28652
29857
  },
28653
29858
  [postToParent2]
28654
29859
  );
28655
- useEffect21(() => {
29860
+ useEffect22(() => {
28656
29861
  const onDragOver = (e) => {
28657
29862
  const dragged = buttonCollectionDragRef.current;
28658
29863
  if (!dragged) return;
@@ -28723,7 +29928,7 @@ function OhhwellsBridge() {
28723
29928
  setLogoSizeDraft(null);
28724
29929
  deselectRef.current();
28725
29930
  }, []);
28726
- useEffect21(() => {
29931
+ useEffect22(() => {
28727
29932
  const session = floatingPanel && floatingPanel.kind === "logo-size" ? floatingPanel : null;
28728
29933
  if (!session || !logoSizeDraft) {
28729
29934
  postToParentRef.current({ type: "ow:logo-size-panel", open: false });
@@ -28888,7 +30093,7 @@ function OhhwellsBridge() {
28888
30093
  deselectRef.current = deselect;
28889
30094
  closeFloatingPanelOnlyRef.current = closeFloatingPanelOnly;
28890
30095
  const lastSiteWideScopeRef = useRef14(null);
28891
- useEffect21(() => {
30096
+ useEffect22(() => {
28892
30097
  if (!isEditMode) {
28893
30098
  if (lastSiteWideScopeRef.current !== false) {
28894
30099
  lastSiteWideScopeRef.current = false;
@@ -28914,7 +30119,7 @@ function OhhwellsBridge() {
28914
30119
  isFooterFrameSelection,
28915
30120
  postToParent2
28916
30121
  ]);
28917
- useLayoutEffect6(() => {
30122
+ useLayoutEffect7(() => {
28918
30123
  if (!subdomain || isEditMode) {
28919
30124
  setFetchState("done");
28920
30125
  return;
@@ -28941,6 +30146,7 @@ function OhhwellsBridge() {
28941
30146
  applyAiFooterFromContent(content);
28942
30147
  if (typeof content[STYLE_STORE_KEY] === "string") {
28943
30148
  stylesRef.current = content[STYLE_STORE_KEY];
30149
+ document.querySelectorAll('[data-ohw-editable="form"]').forEach((f) => markFormFields(f));
28944
30150
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
28945
30151
  }
28946
30152
  applyBrandChrome(content);
@@ -28951,12 +30157,12 @@ function OhhwellsBridge() {
28951
30157
  if (key === "__ohw_sections") continue;
28952
30158
  if (key === AI_SECTIONS_KEY) continue;
28953
30159
  if (key === AI_FOOTER_KEY) continue;
30160
+ if (key === LOGO_PLACEHOLDER_KEY) continue;
30161
+ if (LOGO_IMAGE_KEYS.includes(key)) continue;
28954
30162
  if (key === BRAND_KIT_KEY) continue;
28955
30163
  if (key === STYLE_STORE_KEY) continue;
28956
30164
  if (BRAND_CHROME_KEYS.has(key)) continue;
28957
- if (key === LOGO_PLACEHOLDER_KEY) continue;
28958
30165
  if (key === CUSTOM_CODE_AFTER_HEAD_KEY || key === CUSTOM_CODE_BEFORE_HEAD_KEY) continue;
28959
- if (LOGO_IMAGE_KEYS.includes(key)) continue;
28960
30166
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
28961
30167
  continue;
28962
30168
  }
@@ -29069,7 +30275,7 @@ function OhhwellsBridge() {
29069
30275
  cancelled = true;
29070
30276
  };
29071
30277
  }, [subdomain, isEditMode]);
29072
- useEffect21(() => {
30278
+ useEffect22(() => {
29073
30279
  if (!isEditMode) return;
29074
30280
  const resolveIndex = (form, clientY) => {
29075
30281
  const wrappers = listFieldWrappers(form).filter((el) => fieldKeyOf(el) !== fieldDragRef.current?.key);
@@ -29110,7 +30316,7 @@ function OhhwellsBridge() {
29110
30316
  window.removeEventListener("drop", onDrop, true);
29111
30317
  };
29112
30318
  }, [buildFieldDropSlots, isEditMode, persistFields, selectField]);
29113
- useEffect21(() => {
30319
+ useEffect22(() => {
29114
30320
  if (!isEditMode) return;
29115
30321
  const mark = () => document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
29116
30322
  markFormFields(form);
@@ -29122,7 +30328,7 @@ function OhhwellsBridge() {
29122
30328
  });
29123
30329
  return () => observer.disconnect();
29124
30330
  }, [isEditMode, fetchState, pathname]);
29125
- useEffect21(() => {
30331
+ useEffect22(() => {
29126
30332
  if (!isEditMode) return;
29127
30333
  let saveTimer = null;
29128
30334
  const onInput = (e) => {
@@ -29144,14 +30350,14 @@ function OhhwellsBridge() {
29144
30350
  document.addEventListener("input", onInput, true);
29145
30351
  return () => document.removeEventListener("input", onInput, true);
29146
30352
  }, [isEditMode, persistFields]);
29147
- useEffect21(() => {
30353
+ useEffect22(() => {
29148
30354
  if (isEditMode || fetchState !== "done") return;
29149
30355
  const content = contentCache.get(subdomain) ?? {};
29150
30356
  document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
29151
30357
  reconcileFieldsFromContent(form, content);
29152
30358
  });
29153
30359
  }, [isEditMode, fetchState, subdomain]);
29154
- useEffect21(() => {
30360
+ useEffect22(() => {
29155
30361
  if (!isEditMode) return;
29156
30362
  const swallow = (e) => {
29157
30363
  const target = e.target;
@@ -29160,14 +30366,14 @@ function OhhwellsBridge() {
29160
30366
  document.addEventListener("submit", swallow, true);
29161
30367
  return () => document.removeEventListener("submit", swallow, true);
29162
30368
  }, [isEditMode]);
29163
- useEffect21(() => {
30369
+ useEffect22(() => {
29164
30370
  if (isEditMode || fetchState !== "done") return;
29165
30371
  console.log("env", process.env.NEXT_PUBLIC_FLOWOPS_API_URL);
29166
30372
  const apiUrl = process.env.NEXT_PUBLIC_FLOWOPS_API_URL ?? "https://flowops-backend-staging-2yfdh7pwpq-as.a.run.app";
29167
30373
  console.log({ apiUrl, subdomain });
29168
30374
  bindPublishedForms(apiUrl, subdomain, contentCache.get(subdomain) ?? {});
29169
30375
  }, [isEditMode, fetchState, subdomain]);
29170
- useEffect21(() => {
30376
+ useEffect22(() => {
29171
30377
  if (!subdomain || isEditMode) return;
29172
30378
  let debounceTimer = null;
29173
30379
  let observer = null;
@@ -29191,17 +30397,18 @@ function OhhwellsBridge() {
29191
30397
  }
29192
30398
  applyAiFooterFromContent(content);
29193
30399
  if (typeof content[STYLE_STORE_KEY] === "string") {
30400
+ document.querySelectorAll('[data-ohw-editable="form"]').forEach((f) => markFormFields(f));
29194
30401
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
29195
30402
  }
29196
30403
  for (const [key, val] of Object.entries(content)) {
29197
30404
  if (key === "__ohw_sections") continue;
29198
30405
  if (key === AI_SECTIONS_KEY) continue;
29199
30406
  if (key === AI_FOOTER_KEY) continue;
30407
+ if (key === LOGO_PLACEHOLDER_KEY) continue;
30408
+ if (LOGO_IMAGE_KEYS.includes(key)) continue;
29200
30409
  if (key === BRAND_KIT_KEY) continue;
29201
30410
  if (key === STYLE_STORE_KEY) continue;
29202
30411
  if (BRAND_CHROME_KEYS.has(key)) continue;
29203
- if (key === LOGO_PLACEHOLDER_KEY) continue;
29204
- if (LOGO_IMAGE_KEYS.includes(key)) continue;
29205
30412
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
29206
30413
  continue;
29207
30414
  }
@@ -29288,16 +30495,16 @@ function OhhwellsBridge() {
29288
30495
  if (debounceTimer) clearTimeout(debounceTimer);
29289
30496
  };
29290
30497
  }, [subdomain, isEditMode, pathname]);
29291
- useLayoutEffect6(() => {
30498
+ useLayoutEffect7(() => {
29292
30499
  const el = document.getElementById("ohw-loader");
29293
30500
  if (!el) return;
29294
30501
  const visible = Boolean(subdomain) && fetchState !== "done";
29295
30502
  el.style.display = visible ? "flex" : "none";
29296
30503
  }, [subdomain, fetchState]);
29297
- useEffect21(() => {
30504
+ useEffect22(() => {
29298
30505
  postToParent2({ type: "ow:navigation", path: pathname });
29299
30506
  }, [pathname, postToParent2]);
29300
- useEffect21(() => {
30507
+ useEffect22(() => {
29301
30508
  if (!subdomain || isEditMode) return;
29302
30509
  const content = contentCache.get(subdomain);
29303
30510
  if (!content) return;
@@ -29315,7 +30522,7 @@ function OhhwellsBridge() {
29315
30522
  }
29316
30523
  applyAiFooterFromContent(content);
29317
30524
  }, [pathname, subdomain, isEditMode]);
29318
- useEffect21(() => {
30525
+ useEffect22(() => {
29319
30526
  if (!isEditMode) return;
29320
30527
  if (linkPopoverSessionRef.current?.intent === "add-nav") return;
29321
30528
  if (document.querySelector("[data-ohw-section-picker]")) return;
@@ -29323,12 +30530,12 @@ function OhhwellsBridge() {
29323
30530
  deselectRef.current();
29324
30531
  deactivateRef.current();
29325
30532
  }, [pathname, isEditMode]);
29326
- useEffect21(() => {
30533
+ useEffect22(() => {
29327
30534
  if (!isEditMode) return;
29328
30535
  initSectionInstancesFromContent(editContentRef.current, pathname);
29329
30536
  initItemInstancesFromContent(editContentRef.current);
29330
30537
  }, [pathname, isEditMode]);
29331
- useEffect21(() => {
30538
+ useEffect22(() => {
29332
30539
  if (!isEditMode) return;
29333
30540
  const observer = new MutationObserver(() => {
29334
30541
  const drawer = document.querySelector("[data-ohw-nav-drawer]");
@@ -29339,7 +30546,7 @@ function OhhwellsBridge() {
29339
30546
  observer.observe(document.body, { childList: true, subtree: true });
29340
30547
  return () => observer.disconnect();
29341
30548
  }, [isEditMode, pathname]);
29342
- useEffect21(() => {
30549
+ useEffect22(() => {
29343
30550
  const contentForNav = () => {
29344
30551
  if (isEditMode) return editContentRef.current;
29345
30552
  if (!subdomain) return {};
@@ -29413,7 +30620,7 @@ function OhhwellsBridge() {
29413
30620
  observer?.disconnect();
29414
30621
  };
29415
30622
  }, [isEditMode, pathname, subdomain, fetchState, resyncSelectedNavigationItem]);
29416
- useEffect21(() => {
30623
+ useEffect22(() => {
29417
30624
  if (!isEditMode) return;
29418
30625
  let applying = false;
29419
30626
  let rafId = null;
@@ -29451,7 +30658,7 @@ function OhhwellsBridge() {
29451
30658
  observer.disconnect();
29452
30659
  };
29453
30660
  }, [isEditMode, pathname]);
29454
- useEffect21(() => {
30661
+ useEffect22(() => {
29455
30662
  if (!isEditMode) return;
29456
30663
  let lastPosted = 0;
29457
30664
  const measure = () => {
@@ -29473,29 +30680,14 @@ function OhhwellsBridge() {
29473
30680
  const t2 = setTimeout(measure, 500);
29474
30681
  const ro = new ResizeObserver(schedule);
29475
30682
  ro.observe(document.body);
29476
- let lastWidth = window.innerWidth;
29477
- let resizeTimers = [];
29478
- const clearResizeTimers = () => {
29479
- resizeTimers.forEach(clearTimeout);
29480
- resizeTimers = [];
29481
- };
29482
- const handleResize = () => {
29483
- if (window.innerWidth === lastWidth) return;
29484
- lastWidth = window.innerWidth;
29485
- clearResizeTimers();
29486
- resizeTimers = HEIGHT_SETTLE_DELAYS.map((delay) => setTimeout(measure, delay));
29487
- };
29488
- window.addEventListener("resize", handleResize);
29489
30683
  return () => {
29490
30684
  clearTimeout(t1);
29491
30685
  clearTimeout(t2);
29492
30686
  if (raf != null) cancelAnimationFrame(raf);
29493
30687
  ro.disconnect();
29494
- clearResizeTimers();
29495
- window.removeEventListener("resize", handleResize);
29496
30688
  };
29497
30689
  }, [pathname, isEditMode, postToParent2]);
29498
- useEffect21(() => {
30690
+ useEffect22(() => {
29499
30691
  if (isEditMode) return;
29500
30692
  const handleClick = (e) => {
29501
30693
  if (!isPlainLeftClick(e)) return;
@@ -29509,7 +30701,7 @@ function OhhwellsBridge() {
29509
30701
  document.addEventListener("click", handleClick, true);
29510
30702
  return () => document.removeEventListener("click", handleClick, true);
29511
30703
  }, [isEditMode, router, pathname]);
29512
- useEffect21(() => {
30704
+ useEffect22(() => {
29513
30705
  if (!isEditMode) {
29514
30706
  editStylesRef.current?.base.remove();
29515
30707
  editStylesRef.current?.forceHover.remove();
@@ -29789,6 +30981,13 @@ function OhhwellsBridge() {
29789
30981
  if (target.closest("[data-ohw-state-toggle]")) return;
29790
30982
  if (target.closest("[data-ohw-max-badge]")) return;
29791
30983
  if (isInsideLinkEditor(target)) return;
30984
+ if (isInsideFloatingPanel(target)) return;
30985
+ if (target.closest("[data-ohw-form-toolbar]")) return;
30986
+ if (target.closest(
30987
+ '[data-ohw-field-toolbar], [data-ohw-field-type-picker], [data-radix-popper-content-wrapper], [role="menu"], [data-slot="dropdown-menu-content"]'
30988
+ )) {
30989
+ return;
30990
+ }
29792
30991
  if (selectedMediaElRef.current && !selectedMediaElRef.current.contains(target) && !target.closest("[data-ohw-media-overlay], [data-ohw-edit-chrome], [data-ohw-item-interaction]")) {
29793
30992
  clearMediaSelectionRef.current();
29794
30993
  }
@@ -29812,8 +31011,6 @@ function OhhwellsBridge() {
29812
31011
  return;
29813
31012
  }
29814
31013
  }
29815
- if (isInsideFloatingPanel(target)) return;
29816
- if (target.closest("[data-ohw-form-toolbar]")) return;
29817
31014
  const collectionItem = matchCollectionItemClick(target, collectionItemsRef.current);
29818
31015
  if (collectionItem) {
29819
31016
  e.preventDefault();
@@ -29825,11 +31022,6 @@ function OhhwellsBridge() {
29825
31022
  });
29826
31023
  return;
29827
31024
  }
29828
- if (target.closest(
29829
- '[data-ohw-field-toolbar], [data-ohw-field-type-picker], [data-radix-popper-content-wrapper], [role="menu"], [data-slot="dropdown-menu-content"]'
29830
- )) {
29831
- return;
29832
- }
29833
31025
  {
29834
31026
  const formEl = getFormElement(target);
29835
31027
  const onSuccessText = target.closest(`[${SUCCESS_TEXT_ATTR}]`);
@@ -29957,6 +31149,16 @@ function OhhwellsBridge() {
29957
31149
  const inner = target.closest("svg")?.querySelectorAll("[data-ohw-editable]");
29958
31150
  if (inner && inner.length === 1) editable = inner[0];
29959
31151
  }
31152
+ const hiddenTwin = !editable || isMediaEditable(editable) ? findHiddenTwinAt(NON_MEDIA_SELECTOR, e.clientX, e.clientY) : null;
31153
+ if (hiddenTwin) {
31154
+ editable = hiddenTwin;
31155
+ const card = stateCardFor(hiddenTwin, e.clientX, e.clientY);
31156
+ const hoverState = card && !card.hasAttribute("data-ohw-active-state") ? deriveStates(card.dataset.ohwEditableState ?? "")[1] : void 0;
31157
+ if (card && hoverState) {
31158
+ activeStateElRef.current = card;
31159
+ stateChangeRef.current(hoverState);
31160
+ }
31161
+ }
29960
31162
  if (editable && !(editable instanceof HTMLElement)) {
29961
31163
  e.preventDefault();
29962
31164
  e.stopPropagation();
@@ -29983,9 +31185,13 @@ function OhhwellsBridge() {
29983
31185
  if (isIconEditable(editable) && !getSocialItem(editable)) {
29984
31186
  e.preventDefault();
29985
31187
  e.stopPropagation();
29986
- selectIconElementRef.current(editable);
29987
31188
  const aiIcon = editable.hasAttribute("data-ai-icon");
29988
31189
  const featureIcon = aiIcon && /\.features\.\d+\.icon$/.test(editable.dataset.ohwKey ?? "");
31190
+ if (aiIcon) {
31191
+ aiSectionApiRef.current?.selectFromElement(editable);
31192
+ } else {
31193
+ selectIconElementRef.current(editable);
31194
+ }
29989
31195
  postToParentRef.current({
29990
31196
  type: "ow:icon-pick",
29991
31197
  key: editable.dataset.ohwKey ?? "",
@@ -30213,6 +31419,9 @@ function OhhwellsBridge() {
30213
31419
  setHoveredItemRect(null);
30214
31420
  hoveredNavContainerRef.current = null;
30215
31421
  setHoveredNavContainerRect(null);
31422
+ siblingHintElRef.current = null;
31423
+ setSiblingHintRect(null);
31424
+ setSiblingHintRects([]);
30216
31425
  return;
30217
31426
  }
30218
31427
  {
@@ -30314,6 +31523,8 @@ function OhhwellsBridge() {
30314
31523
  if (!editable) return;
30315
31524
  const editableRect = editable.getBoundingClientRect();
30316
31525
  if (editableRect.width <= 0 || editableRect.height <= 0) return;
31526
+ const shownEditable = shownAs(editable);
31527
+ if (!shownEditable || shownEditable !== editable && !hitsShown(editable, e.clientX, e.clientY)) return;
30317
31528
  const selected = selectedElRef.current;
30318
31529
  if (selected && (selected === editable || selected.contains(editable))) return;
30319
31530
  if (!isMediaEditable(editable) && !editable.hasAttribute("contenteditable")) {
@@ -30328,12 +31539,11 @@ function OhhwellsBridge() {
30328
31539
  hoveredItemElRef.current = hoverTarget;
30329
31540
  setHoveredItemRect(hoverTarget.getBoundingClientRect());
30330
31541
  } else if (!isInsideNavigationItem(editable) && !isSelectedForHoverRef.current(hoverTarget)) {
30331
- hoverTarget.setAttribute("data-ohw-hovered", "");
31542
+ hoverFrame(hoverTarget).setAttribute("data-ohw-hovered", "");
30332
31543
  if (editable.closest("footer") || editable.closest('[data-ohw-section="footer"]')) {
30333
31544
  hoveredNavContainerRef.current = null;
30334
31545
  setHoveredNavContainerRect(null);
30335
31546
  hoveredItemElRef.current = editable;
30336
- setHoveredItemRect(isSelectedForHoverRef.current(editable) ? null : editable.getBoundingClientRect());
30337
31547
  }
30338
31548
  }
30339
31549
  }
@@ -30790,8 +32000,7 @@ function OhhwellsBridge() {
30790
32000
  document.querySelectorAll(NON_MEDIA_SELECTOR)
30791
32001
  ).find((el) => {
30792
32002
  if (el.closest("[data-ohw-nav-children]") && !getNavigationItemAnchor(el)) return false;
30793
- const er = el.getBoundingClientRect();
30794
- return x2 >= er.left && x2 <= er.right && y2 >= er.top && y2 <= er.bottom;
32003
+ return hitsShown(el, x2, y2);
30795
32004
  });
30796
32005
  if (imageUnhoverTimerRef.current) {
30797
32006
  clearTimeout(imageUnhoverTimerRef.current);
@@ -30837,7 +32046,7 @@ function OhhwellsBridge() {
30837
32046
  }
30838
32047
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
30839
32048
  if (textEditable && !textEditable.closest("[data-ohw-href-key]") && !isSelectedForHoverRef.current(textEditable)) {
30840
- textEditable.setAttribute("data-ohw-hovered", "");
32049
+ hoverFrame(textEditable).setAttribute("data-ohw-hovered", "");
30841
32050
  }
30842
32051
  return;
30843
32052
  }
@@ -30849,7 +32058,7 @@ function OhhwellsBridge() {
30849
32058
  }
30850
32059
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
30851
32060
  if (textEditable && !textEditable.closest("[data-ohw-href-key]") && !isSelectedForHoverRef.current(textEditable)) {
30852
- textEditable.setAttribute("data-ohw-hovered", "");
32061
+ hoverFrame(textEditable).setAttribute("data-ohw-hovered", "");
30853
32062
  }
30854
32063
  return;
30855
32064
  }
@@ -30893,8 +32102,7 @@ function OhhwellsBridge() {
30893
32102
  ).find((el) => {
30894
32103
  if (!isNavigationItem2(el) || isCtaButton(el)) return false;
30895
32104
  if (!isNavItemPointerTarget(el)) return false;
30896
- const er = el.getBoundingClientRect();
30897
- return x2 >= er.left && x2 <= er.right && y2 >= er.top && y2 <= er.bottom;
32105
+ return hitsShown(el, x2, y2);
30898
32106
  });
30899
32107
  if (navLinkHit) {
30900
32108
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
@@ -30910,8 +32118,7 @@ function OhhwellsBridge() {
30910
32118
  document.querySelectorAll(NON_MEDIA_SELECTOR)
30911
32119
  ).find((el) => {
30912
32120
  if (el.closest("[data-ohw-nav-children]") && !getNavigationItemAnchor(el)) return false;
30913
- const er = el.getBoundingClientRect();
30914
- return x2 >= er.left && x2 <= er.right && y2 >= er.top && y2 <= er.bottom;
32121
+ return hitsShown(el, x2, y2);
30915
32122
  });
30916
32123
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
30917
32124
  if (textEl && !textEl.hasAttribute("contenteditable")) {
@@ -30926,7 +32133,7 @@ function OhhwellsBridge() {
30926
32133
  } else if (!textEl.closest("[data-ohw-href-key]") && !isSelectedForHoverRef.current(textEl)) {
30927
32134
  hoveredItemElRef.current = null;
30928
32135
  setHoveredItemRect(null);
30929
- textEl.setAttribute("data-ohw-hovered", "");
32136
+ hoverFrame(textEl).setAttribute("data-ohw-hovered", "");
30930
32137
  } else {
30931
32138
  hoveredItemElRef.current = null;
30932
32139
  setHoveredItemRect(null);
@@ -31043,7 +32250,11 @@ function OhhwellsBridge() {
31043
32250
  };
31044
32251
  const handleMouseMove = (e) => {
31045
32252
  const { clientX, clientY } = e;
31046
- if (pointOwnedByFloatingPanel(clientX, clientY)) return;
32253
+ if (pointOwnedByFloatingPanel(clientX, clientY)) {
32254
+ dismissImageHover();
32255
+ clearImageHover();
32256
+ return;
32257
+ }
31047
32258
  if (isNavDrawerOpen() && isPointOutsideOpenDrawer(clientX, clientY)) {
31048
32259
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
31049
32260
  formHoverElRef.current = null;
@@ -31072,7 +32283,12 @@ function OhhwellsBridge() {
31072
32283
  setHoveredItemRect(null);
31073
32284
  hoveredNavContainerRef.current = null;
31074
32285
  setHoveredNavContainerRect(null);
32286
+ siblingHintElRef.current = null;
32287
+ setSiblingHintRect(null);
32288
+ setSiblingHintRects([]);
31075
32289
  dismissImageHover();
32290
+ clearImageHover();
32291
+ setSectionGap(null);
31076
32292
  return;
31077
32293
  }
31078
32294
  if (probeSocialsRowAt(clientX, clientY)) return;
@@ -31084,7 +32300,11 @@ function OhhwellsBridge() {
31084
32300
  if (e.data?.type !== "ow:pointer-sync") return;
31085
32301
  const { clientX, clientY } = e.data;
31086
32302
  if (typeof clientX !== "number" || typeof clientY !== "number") return;
31087
- if (pointOwnedByFloatingPanel(clientX, clientY)) return;
32303
+ if (pointOwnedByFloatingPanel(clientX, clientY)) {
32304
+ dismissImageHover();
32305
+ clearImageHover();
32306
+ return;
32307
+ }
31088
32308
  if (isNavDrawerOpen() && isPointOutsideOpenDrawer(clientX, clientY)) return;
31089
32309
  if (probeSocialsRowAt(clientX, clientY)) return;
31090
32310
  probeSectionGapAt(clientX, clientY);
@@ -31464,6 +32684,7 @@ function OhhwellsBridge() {
31464
32684
  applyAiFooterFromContent(content);
31465
32685
  if (typeof content[STYLE_STORE_KEY] === "string") {
31466
32686
  stylesRef.current = content[STYLE_STORE_KEY];
32687
+ document.querySelectorAll('[data-ohw-editable="form"]').forEach((f) => markFormFields(f));
31467
32688
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
31468
32689
  }
31469
32690
  applyBrandChrome(content);
@@ -31478,12 +32699,12 @@ function OhhwellsBridge() {
31478
32699
  }
31479
32700
  if (key === AI_SECTIONS_KEY) continue;
31480
32701
  if (key === AI_FOOTER_KEY) continue;
32702
+ if (key === LOGO_PLACEHOLDER_KEY) continue;
32703
+ if (LOGO_IMAGE_KEYS.includes(key) && !String(val ?? "").trim()) continue;
31481
32704
  if (key === BRAND_KIT_KEY) continue;
31482
32705
  if (key === STYLE_STORE_KEY) continue;
31483
32706
  if (BRAND_CHROME_KEYS.has(key)) continue;
31484
- if (key === LOGO_PLACEHOLDER_KEY) continue;
31485
32707
  if (key === CUSTOM_CODE_AFTER_HEAD_KEY || key === CUSTOM_CODE_BEFORE_HEAD_KEY) continue;
31486
- if (LOGO_IMAGE_KEYS.includes(key) && !String(val ?? "").trim()) continue;
31487
32708
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
31488
32709
  continue;
31489
32710
  }
@@ -32155,6 +33376,12 @@ function OhhwellsBridge() {
32155
33376
  closeLinkPopoverRef.current();
32156
33377
  return;
32157
33378
  }
33379
+ if (floatingPanelOpenRef.current) {
33380
+ setFloatingPanelRef.current(null);
33381
+ deselectRef.current();
33382
+ deactivateRef.current();
33383
+ return;
33384
+ }
32158
33385
  deselectRef.current();
32159
33386
  deactivateRef.current();
32160
33387
  clearMediaSelectionRef.current();
@@ -32807,8 +34034,7 @@ function OhhwellsBridge() {
32807
34034
  const textEditable = Array.from(
32808
34035
  document.querySelectorAll(NON_MEDIA_SELECTOR)
32809
34036
  ).find((el) => {
32810
- const r2 = el.getBoundingClientRect();
32811
- return clientX >= r2.left && clientX <= r2.right && clientY >= r2.top && clientY <= r2.bottom;
34037
+ return hitsShown(el, clientX, clientY);
32812
34038
  });
32813
34039
  if (textEditable) {
32814
34040
  const hrefCtx = getHrefKeyFromElement(textEditable);
@@ -32985,17 +34211,17 @@ function OhhwellsBridge() {
32985
34211
  window.removeEventListener("message", handleDuplicateSection);
32986
34212
  window.removeEventListener("message", handleDeactivate);
32987
34213
  window.removeEventListener("message", handleSelectNav);
32988
- document.documentElement.removeAttribute("data-ohw-panel-dragging");
32989
34214
  window.removeEventListener("message", handleToastAction);
32990
34215
  window.removeEventListener("message", handleFormCount);
32991
34216
  window.removeEventListener("message", handleUiEscape);
34217
+ document.documentElement.removeAttribute("data-ohw-panel-dragging");
32992
34218
  autoSaveTimers.current.forEach(clearTimeout);
32993
34219
  autoSaveTimers.current.clear();
32994
34220
  if (imageUnhoverTimerRef.current) clearTimeout(imageUnhoverTimerRef.current);
32995
34221
  if (imageShowTimerRef.current) clearTimeout(imageShowTimerRef.current);
32996
34222
  };
32997
34223
  }, [isEditMode, refreshStateRules]);
32998
- useEffect21(() => {
34224
+ useEffect22(() => {
32999
34225
  if (!isEditMode) return;
33000
34226
  const THRESHOLD = 10;
33001
34227
  const resolveWasSelected = (el) => {
@@ -33151,7 +34377,7 @@ function OhhwellsBridge() {
33151
34377
  unlockFooterDragInteraction();
33152
34378
  };
33153
34379
  }, [isEditMode]);
33154
- useEffect21(() => {
34380
+ useEffect22(() => {
33155
34381
  if (!isEditMode) return;
33156
34382
  const THRESHOLD = 10;
33157
34383
  const onPointerDown = (e) => {
@@ -33242,7 +34468,7 @@ function OhhwellsBridge() {
33242
34468
  document.removeEventListener("selectstart", blockSelectStart, true);
33243
34469
  };
33244
34470
  }, [isEditMode, persistButtonCollectionDrag, refreshButtonDragVisuals]);
33245
- useEffect21(() => {
34471
+ useEffect22(() => {
33246
34472
  const handler = (e) => {
33247
34473
  if (e.data?.type !== "ow:request-schedule-config") return;
33248
34474
  const insertAfterVal = e.data.insertAfter;
@@ -33258,7 +34484,7 @@ function OhhwellsBridge() {
33258
34484
  window.addEventListener("message", handler);
33259
34485
  return () => window.removeEventListener("message", handler);
33260
34486
  }, [processConfigRequest]);
33261
- useEffect21(() => {
34487
+ useEffect22(() => {
33262
34488
  if (!isEditMode) return;
33263
34489
  document.querySelectorAll("[data-ohw-active-state]").forEach((el) => {
33264
34490
  el.removeAttribute("data-ohw-active-state");
@@ -33282,7 +34508,7 @@ function OhhwellsBridge() {
33282
34508
  postToParent2({
33283
34509
  type: "ow:ready",
33284
34510
  version: "1",
33285
- bridgeVersion: "0.1.173",
34511
+ bridgeVersion: "0.1.174-next.462",
33286
34512
  path: pathname,
33287
34513
  nodes: collectEditableNodes(editContentRef.current),
33288
34514
  sections
@@ -33294,7 +34520,7 @@ function OhhwellsBridge() {
33294
34520
  clearTimeout(timer);
33295
34521
  };
33296
34522
  }, [pathname, isEditMode, refreshStateRules, postToParent2]);
33297
- useEffect21(() => {
34523
+ useEffect22(() => {
33298
34524
  scrollToHashSectionWhenReady();
33299
34525
  const onHashChange = () => scrollToHashSectionWhenReady();
33300
34526
  window.addEventListener("hashchange", onHashChange);
@@ -33336,7 +34562,7 @@ function OhhwellsBridge() {
33336
34562
  if (el) setToolbarRect(getEditMeasureEl(el).getBoundingClientRect());
33337
34563
  refreshActiveCommandsRef.current();
33338
34564
  }, []);
33339
- useEffect21(() => {
34565
+ useEffect22(() => {
33340
34566
  const session = floatingPanel && floatingPanel.kind === "logo-size" ? floatingPanel : null;
33341
34567
  if (!session || !logoSizeDraft) return;
33342
34568
  const onPanelAction = (e) => {
@@ -33387,6 +34613,7 @@ function OhhwellsBridge() {
33387
34613
  }
33388
34614
  setToggleState((prev) => prev ? { ...prev, activeState: state } : null);
33389
34615
  }, [deactivate]);
34616
+ stateChangeRef.current = handleStateChange;
33390
34617
  const reselectAfterLinkPopover = useCallback12(
33391
34618
  (hrefKey) => {
33392
34619
  requestAnimationFrame(() => {
@@ -34172,7 +35399,7 @@ function OhhwellsBridge() {
34172
35399
  className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/80",
34173
35400
  onClick: () => setFieldTypePickerOpen((open) => !open),
34174
35401
  "data-ohw-add-field": "",
34175
- children: /* @__PURE__ */ jsx40(Plus5, { size: 15, "aria-hidden": true })
35402
+ children: /* @__PURE__ */ jsx40(Plus6, { size: 15, "aria-hidden": true })
34176
35403
  }
34177
35404
  ),
34178
35405
  /* @__PURE__ */ jsx40("div", { className: "mx-0.5 h-5 w-px bg-border" }),
@@ -34670,6 +35897,10 @@ export {
34670
35897
  SITE_OG_IMAGE_KEY,
34671
35898
  SchedulingWidget,
34672
35899
  TEMPLATE_LOGO_ATTR,
35900
+ TONE_ATTR,
35901
+ TONE_CHANGE_EVENT,
35902
+ TONE_FIX_ATTR,
35903
+ TONE_THRESHOLD,
34673
35904
  Toggle,
34674
35905
  ToggleGroup,
34675
35906
  ToggleGroupItem,
@@ -34688,11 +35919,16 @@ export {
34688
35919
  canRemoveAiBlock,
34689
35920
  canRemoveAiTextBlock,
34690
35921
  canSoftHideEditable,
35922
+ compositeColor,
35923
+ compositeGradient,
35924
+ computeBackgroundTones,
35925
+ contrastRatioOf,
34691
35926
  dropIndicatorVariants,
34692
35927
  ensureFooterTree,
34693
35928
  filterAvailablePages,
34694
35929
  foldAlignIntoTrees,
34695
35930
  getEditModeInitialState,
35931
+ gradientStopColors,
34696
35932
  hasMountedContentNodes,
34697
35933
  indexCollectionItems,
34698
35934
  insertFooterHours,
@@ -34704,16 +35940,21 @@ export {
34704
35940
  isRenderableTree,
34705
35941
  isStickySearchParam,
34706
35942
  isValidUrl,
35943
+ linearGradientColourAt,
35944
+ mapRegionToImage,
34707
35945
  matchCollectionItemClick,
35946
+ mountBackgroundTone,
34708
35947
  nextViableSlide,
34709
35948
  parseAiFooterState,
34710
35949
  parseAiSectionsState,
35950
+ parseCssColor,
34711
35951
  parseTarget,
34712
35952
  planAiBlockRemoval,
34713
35953
  planAiTextBlockRemoval,
34714
35954
  planBuildPageSync,
34715
35955
  readHiddenEditables,
34716
35956
  recordOverriddenPaths,
35957
+ relativeLuminanceOf,
34717
35958
  releaseTemplateLogoIfReplaced,
34718
35959
  removeBlockAtPath,
34719
35960
  removeFooterBlock,
@@ -34725,11 +35966,15 @@ export {
34725
35966
  shouldFetchContentForPath,
34726
35967
  softHideEditableInDom,
34727
35968
  softUnhideEditableInDom,
35969
+ splitTopLevel,
34728
35970
  stepViableSlide,
34729
35971
  stripPlaceholderText,
34730
35972
  stripPlaceholders,
34731
35973
  stripTextAlignCss,
34732
35974
  toggleVariants,
35975
+ toneFor,
35976
+ toneOfColor,
35977
+ toneOfLuminance,
34733
35978
  useOhwCarousel,
34734
35979
  validateUrlInput,
34735
35980
  viableSlides,