@ohhwells/bridge 0.1.173 → 0.1.174

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 useLayoutEffect6, 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; }`,
@@ -12576,9 +12579,1035 @@ function useNavDropdownToggle(isEditMode) {
12576
12579
  }, [pathname, isEditMode]);
12577
12580
  }
12578
12581
 
12579
- // src/useHashLinkScroll.ts
12582
+ // src/useBackgroundTone.ts
12580
12583
  import { useEffect as useEffect4 } from "react";
12581
12584
 
12585
+ // src/lib/background-tone.ts
12586
+ var TONE_THRESHOLD = 0.5;
12587
+ var TONE_ATTR = "data-ohw-tone";
12588
+ var TONE_FIX_ATTR = "data-ohw-tone-fix";
12589
+ var TONE_CHANGE_EVENT = "ohw:tone-change";
12590
+ var IMAGE_COVER_RATIO = 0.8;
12591
+ var SURFACE_MIN_PX = 24;
12592
+ var OPAQUE_ALPHA = 0.9;
12593
+ var VISIBLE_ALPHA = 0.05;
12594
+ var SAMPLE_SIZE = 32;
12595
+ var SAMPLE_TIMEOUT_MS = 3e3;
12596
+ var WHITE = { r: 255, g: 255, b: 255, a: 1 };
12597
+ var SECTION_SELECTOR = "[data-ohw-section]";
12598
+ var TEXT_SELECTOR = '[data-ohw-editable="text"], [data-ohw-editable="plain"], [data-ohw-field-label]';
12599
+ var BUTTON_SELECTOR = CTA_BUTTON_SELECTOR;
12600
+ var PICKED_BUTTON_TEXT_VARS = ["--brand-button-primary-text", "--brand-button-secondary-text"];
12601
+ var MEASURING_ATTR = "data-ohw-tone-measuring";
12602
+ var TONE_FIX_LINE_ATTR = "data-ohw-tone-fix-line";
12603
+ var INK_FIX_STYLE_ID = "ohw-tone-ink-fix";
12604
+ var INK_MIN_CONTRAST = 3;
12605
+ var IMAGE_TEXT_MIN_CONTRAST = 3;
12606
+ var NEVER_SURFACE = /* @__PURE__ */ new Set(["IMG", "SVG", "VIDEO", "CANVAS", "IFRAME", "PICTURE", "PATH", "SCRIPT", "STYLE"]);
12607
+ var clamp01 = (n) => Math.min(1, Math.max(0, n));
12608
+ function num(raw, percentOf = 1) {
12609
+ if (!raw || raw === "none") return 0;
12610
+ return raw.endsWith("%") ? parseFloat(raw) / 100 * percentOf : parseFloat(raw);
12611
+ }
12612
+ function alphaOf(raw) {
12613
+ return raw == null ? 1 : clamp01(num(raw, 1));
12614
+ }
12615
+ function linearToSrgb255(v) {
12616
+ const c = clamp01(v);
12617
+ return 255 * (c <= 31308e-7 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055);
12618
+ }
12619
+ function oklabToRgba(L, A, B, a) {
12620
+ const l = (L + 0.3963377774 * A + 0.2158037573 * B) ** 3;
12621
+ const m = (L - 0.1055613458 * A - 0.0638541728 * B) ** 3;
12622
+ const s = (L - 0.0894841775 * A - 1.291485548 * B) ** 3;
12623
+ return {
12624
+ r: linearToSrgb255(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
12625
+ g: linearToSrgb255(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
12626
+ b: linearToSrgb255(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),
12627
+ a
12628
+ };
12629
+ }
12630
+ function parseCssColor(input) {
12631
+ if (!input) return null;
12632
+ const value = input.trim().toLowerCase();
12633
+ if (value === "transparent") return { r: 0, g: 0, b: 0, a: 0 };
12634
+ const hex = value.match(/^#([0-9a-f]{3,8})$/);
12635
+ if (hex) {
12636
+ const raw = hex[1];
12637
+ const short = raw.length <= 4;
12638
+ const part = (i) => parseInt(short ? raw[i] + raw[i] : raw.slice(i * 2, i * 2 + 2), 16);
12639
+ if (![3, 4, 6, 8].includes(raw.length)) return null;
12640
+ return { r: part(0), g: part(1), b: part(2), a: raw.length === 4 || raw.length === 8 ? part(3) / 255 : 1 };
12641
+ }
12642
+ const fn = value.match(/^([a-z]+)\((.*)\)$/);
12643
+ if (!fn) return null;
12644
+ const [, name, body] = fn;
12645
+ const [channelsRaw, slashAlpha] = body.split("/").map((s) => s.trim());
12646
+ const parts = channelsRaw.split(/[\s,]+/).filter(Boolean);
12647
+ if (name === "rgb" || name === "rgba") {
12648
+ if (parts.length < 3) return null;
12649
+ const alpha = slashAlpha ?? parts[3];
12650
+ return { r: num(parts[0], 255), g: num(parts[1], 255), b: num(parts[2], 255), a: alphaOf(alpha) };
12651
+ }
12652
+ if (name === "color") {
12653
+ const [space, r2, g, b] = parts;
12654
+ if (space !== "srgb" || b == null) return null;
12655
+ return { r: num(r2) * 255, g: num(g) * 255, b: num(b) * 255, a: alphaOf(slashAlpha) };
12656
+ }
12657
+ if (name === "oklch") {
12658
+ if (parts.length < 3) return null;
12659
+ const L = num(parts[0]);
12660
+ const C = num(parts[1], 0.4);
12661
+ const h = num(parts[2].replace("deg", "")) * Math.PI / 180;
12662
+ return oklabToRgba(L, C * Math.cos(h), C * Math.sin(h), alphaOf(slashAlpha));
12663
+ }
12664
+ if (name === "oklab") {
12665
+ if (parts.length < 3) return null;
12666
+ return oklabToRgba(num(parts[0]), num(parts[1], 0.4), num(parts[2], 0.4), alphaOf(slashAlpha));
12667
+ }
12668
+ return null;
12669
+ }
12670
+ function compositeColor(fg, bg) {
12671
+ const a = fg.a + bg.a * (1 - fg.a);
12672
+ if (a < 1e-3) return { r: bg.r, g: bg.g, b: bg.b, a: 0 };
12673
+ const mix = (f, b) => (f * fg.a + b * bg.a * (1 - fg.a)) / a;
12674
+ return { r: mix(fg.r, bg.r), g: mix(fg.g, bg.g), b: mix(fg.b, bg.b), a };
12675
+ }
12676
+ function relativeLuminanceOf(color) {
12677
+ const channel = (value) => {
12678
+ const s = clamp01(value / 255);
12679
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
12680
+ };
12681
+ return 0.2126 * channel(color.r) + 0.7152 * channel(color.g) + 0.0722 * channel(color.b);
12682
+ }
12683
+ function toneOfLuminance(luminance) {
12684
+ return luminance >= TONE_THRESHOLD ? "light" : "dark";
12685
+ }
12686
+ function toneOfColor(color) {
12687
+ return toneOfLuminance(relativeLuminanceOf(color));
12688
+ }
12689
+ function contrastRatioOf(a, b) {
12690
+ const la = relativeLuminanceOf(a);
12691
+ const lb = relativeLuminanceOf(b);
12692
+ return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
12693
+ }
12694
+ function splitTopLevel(value) {
12695
+ const out = [];
12696
+ let depth = 0;
12697
+ let start = 0;
12698
+ for (let i = 0; i < value.length; i++) {
12699
+ const ch = value[i];
12700
+ if (ch === "(") depth++;
12701
+ else if (ch === ")") depth--;
12702
+ else if (ch === "," && depth === 0) {
12703
+ out.push(value.slice(start, i).trim());
12704
+ start = i + 1;
12705
+ }
12706
+ }
12707
+ const last = value.slice(start).trim();
12708
+ if (last) out.push(last);
12709
+ return out;
12710
+ }
12711
+ var COLOR_TOKEN = /(?:rgba?|color|oklch|oklab)\([^()]*\)|#[0-9a-f]{3,8}\b|\btransparent\b/gi;
12712
+ function gradientStopColors(layer) {
12713
+ if (!/gradient\(/i.test(layer)) return [];
12714
+ return (layer.match(COLOR_TOKEN) ?? []).map(parseCssColor).filter((c) => c !== null);
12715
+ }
12716
+ function compositeGradient(stops, behind) {
12717
+ if (stops.length === 0) return behind;
12718
+ const sum = { r: 0, g: 0, b: 0, a: 0 };
12719
+ for (const stop of stops) {
12720
+ const c = compositeColor(stop, behind);
12721
+ sum.r += c.r;
12722
+ sum.g += c.g;
12723
+ sum.b += c.b;
12724
+ sum.a += c.a;
12725
+ }
12726
+ const n = stops.length;
12727
+ return { r: sum.r / n, g: sum.g / n, b: sum.b / n, a: sum.a / n };
12728
+ }
12729
+ function stopPosition(token, length) {
12730
+ const n = parseFloat(token);
12731
+ if (!Number.isFinite(n)) return null;
12732
+ if (token.trim().endsWith("%")) return n / 100;
12733
+ return length > 0 ? n / length : null;
12734
+ }
12735
+ function gradientDirection(arg, w, h) {
12736
+ const a = arg.trim().toLowerCase();
12737
+ const deg = a.match(/^(-?[\d.]+)(deg|turn|rad|grad)$/);
12738
+ if (deg) {
12739
+ const v2 = parseFloat(deg[1]);
12740
+ const rad = deg[2] === "turn" ? v2 * 2 * Math.PI : deg[2] === "rad" ? v2 : deg[2] === "grad" ? v2 * Math.PI / 200 : v2 * Math.PI / 180;
12741
+ return { dx: Math.sin(rad), dy: -Math.cos(rad) };
12742
+ }
12743
+ if (!a.startsWith("to ")) return null;
12744
+ const sx = a.includes("right") ? 1 : a.includes("left") ? -1 : 0;
12745
+ const sy = a.includes("bottom") ? 1 : a.includes("top") ? -1 : 0;
12746
+ const v = sx !== 0 && sy !== 0 ? { dx: sx * h, dy: sy * w } : { dx: sx, dy: sy };
12747
+ const len = Math.hypot(v.dx, v.dy);
12748
+ return len > 0 ? { dx: v.dx / len, dy: v.dy / len } : null;
12749
+ }
12750
+ function linearGradientColourAt(layer, px2, py, w, h) {
12751
+ const m = layer.trim().match(/^linear-gradient\((.*)\)$/i);
12752
+ if (!m) return null;
12753
+ const args = splitTopLevel(m[1]);
12754
+ let dir = { dx: 0, dy: 1 };
12755
+ if (args.length > 0 && !parseCssColor((args[0].match(COLOR_TOKEN) ?? [""])[0])) {
12756
+ const parsed = gradientDirection(args[0], w, h);
12757
+ if (!parsed) return null;
12758
+ dir = parsed;
12759
+ args.shift();
12760
+ }
12761
+ const length = Math.abs(w * dir.dx) + Math.abs(h * dir.dy);
12762
+ const stops = [];
12763
+ for (const arg of args) {
12764
+ const colourToken = (arg.match(COLOR_TOKEN) ?? [])[0];
12765
+ const color = colourToken ? parseCssColor(colourToken) : null;
12766
+ if (!color) continue;
12767
+ const rest = arg.replace(colourToken, "").trim().split(/\s+/).filter(Boolean);
12768
+ if (rest.length === 0) stops.push({ color, at: null });
12769
+ for (const token of rest.slice(0, 2)) stops.push({ color, at: stopPosition(token, length) });
12770
+ }
12771
+ if (stops.length === 0) return null;
12772
+ if (stops[0].at === null) stops[0].at = 0;
12773
+ if (stops[stops.length - 1].at === null) stops[stops.length - 1].at = 1;
12774
+ for (let i = 1; i < stops.length; i++) {
12775
+ if (stops[i].at !== null) {
12776
+ stops[i].at = Math.max(stops[i].at, stops[i - 1].at);
12777
+ continue;
12778
+ }
12779
+ let j = i;
12780
+ while (stops[j].at === null) j++;
12781
+ const from = stops[i - 1].at;
12782
+ const span = j - (i - 1);
12783
+ for (let k = i; k < j; k++) stops[k].at = from + (stops[j].at - from) * (k - (i - 1)) / span;
12784
+ }
12785
+ const t = length > 0 ? ((px2 - w / 2) * dir.dx + (py - h / 2) * dir.dy) / length + 0.5 : 0.5;
12786
+ if (t <= stops[0].at) return stops[0].color;
12787
+ const last = stops[stops.length - 1];
12788
+ if (t >= last.at) return last.color;
12789
+ for (let i = 1; i < stops.length; i++) {
12790
+ const a = stops[i - 1];
12791
+ const b = stops[i];
12792
+ if (t > b.at) continue;
12793
+ const f = b.at > a.at ? (t - a.at) / (b.at - a.at) : 1;
12794
+ const alpha = a.color.a + (b.color.a - a.color.a) * f;
12795
+ const mix = (x, y) => (x * a.color.a + (y * b.color.a - x * a.color.a) * f) / (alpha || 1);
12796
+ 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 };
12797
+ }
12798
+ return last.color;
12799
+ }
12800
+ function positionOffset(token, free) {
12801
+ if (!token) return free / 2;
12802
+ if (token === "left" || token === "top") return 0;
12803
+ if (token === "right" || token === "bottom") return free;
12804
+ if (token === "center") return free / 2;
12805
+ if (token.endsWith("%")) return parseFloat(token) / 100 * free;
12806
+ if (token.endsWith("px")) return parseFloat(token);
12807
+ return free / 2;
12808
+ }
12809
+ function mapRegionToImage(region, element, image, fit, position) {
12810
+ const { width: w, height: h } = element;
12811
+ const { width: iw, height: ih } = image;
12812
+ if (w <= 0 || h <= 0 || iw <= 0 || ih <= 0) return null;
12813
+ let dw = iw;
12814
+ let dh = ih;
12815
+ const f = fit.trim().toLowerCase();
12816
+ if (f === "cover" || f === "contain" || f === "scale-down") {
12817
+ let s = f === "cover" ? Math.max(w / iw, h / ih) : Math.min(w / iw, h / ih);
12818
+ if (f === "scale-down") s = Math.min(1, s);
12819
+ dw = iw * s;
12820
+ dh = ih * s;
12821
+ } else if (f === "fill") {
12822
+ dw = w;
12823
+ dh = h;
12824
+ } else if (f !== "none" && f !== "auto" && f !== "auto auto") {
12825
+ const [sw, sh] = f.split(/\s+/);
12826
+ const size = (token, full, natural, other) => {
12827
+ if (!token || token === "auto") return other ?? natural;
12828
+ return token.endsWith("%") ? parseFloat(token) / 100 * full : parseFloat(token);
12829
+ };
12830
+ dw = size(sw, w, iw, null);
12831
+ dh = sh && sh !== "auto" ? size(sh, h, ih, null) : dw / iw * ih;
12832
+ }
12833
+ const [px2, py] = position.trim().toLowerCase().split(/\s+/);
12834
+ const ox = positionOffset(px2, w - dw);
12835
+ const oy = positionOffset(py, h - dh);
12836
+ const sx = Math.max(0, (region.x - ox) / dw * iw);
12837
+ const sy = Math.max(0, (region.y - oy) / dh * ih);
12838
+ const ex = Math.min(iw, (region.x + region.width - ox) / dw * iw);
12839
+ const ey = Math.min(ih, (region.y + region.height - oy) / dh * ih);
12840
+ if (ex - sx < 1 || ey - sy < 1) return null;
12841
+ return { x: sx, y: sy, width: ex - sx, height: ey - sy };
12842
+ }
12843
+ var imageCache = /* @__PURE__ */ new Map();
12844
+ function loadImage(url, onSettled) {
12845
+ const cached = imageCache.get(url);
12846
+ if (cached) {
12847
+ if (cached.state === "loading") cached.waiters.add(onSettled);
12848
+ return cached;
12849
+ }
12850
+ const entry = { state: "loading", waiters: /* @__PURE__ */ new Set([onSettled]) };
12851
+ imageCache.set(url, entry);
12852
+ const img = new Image();
12853
+ img.crossOrigin = "anonymous";
12854
+ img.decoding = "async";
12855
+ let done = false;
12856
+ const settle = (ok) => {
12857
+ if (done) return;
12858
+ done = true;
12859
+ clearTimeout(timer);
12860
+ if (!ok) console.debug?.("[ohw-tone] image sampling unavailable, reading as Light", url);
12861
+ imageCache.set(url, ok ? { state: "ok", img } : { state: "fail" });
12862
+ for (const waiter of entry.waiters) waiter();
12863
+ };
12864
+ const timer = setTimeout(() => settle(false), SAMPLE_TIMEOUT_MS);
12865
+ img.onload = () => settle(img.naturalWidth > 0);
12866
+ img.onerror = () => settle(false);
12867
+ img.src = url;
12868
+ return entry;
12869
+ }
12870
+ var sampleCanvas = null;
12871
+ function sampleImage(img, region) {
12872
+ try {
12873
+ sampleCanvas ?? (sampleCanvas = document.createElement("canvas"));
12874
+ sampleCanvas.width = SAMPLE_SIZE;
12875
+ sampleCanvas.height = SAMPLE_SIZE;
12876
+ const ctx = sampleCanvas.getContext("2d", { willReadFrequently: true });
12877
+ if (!ctx) return null;
12878
+ ctx.clearRect(0, 0, SAMPLE_SIZE, SAMPLE_SIZE);
12879
+ const r2 = region ?? { x: 0, y: 0, width: img.naturalWidth, height: img.naturalHeight };
12880
+ ctx.drawImage(img, r2.x, r2.y, r2.width, r2.height, 0, 0, SAMPLE_SIZE, SAMPLE_SIZE);
12881
+ const data = ctx.getImageData(0, 0, SAMPLE_SIZE, SAMPLE_SIZE).data;
12882
+ let r0 = 0;
12883
+ let g0 = 0;
12884
+ let b0 = 0;
12885
+ let weight = 0;
12886
+ for (let i = 0; i < data.length; i += 4) {
12887
+ const a = data[i + 3] / 255;
12888
+ r0 += data[i] * a;
12889
+ g0 += data[i + 1] * a;
12890
+ b0 += data[i + 2] * a;
12891
+ weight += a;
12892
+ }
12893
+ const pixels = data.length / 4;
12894
+ if (weight === 0) return { r: 0, g: 0, b: 0, a: 0 };
12895
+ return { r: r0 / weight, g: g0 / weight, b: b0 / weight, a: weight / pixels };
12896
+ } catch {
12897
+ return null;
12898
+ }
12899
+ }
12900
+ function browserDeps() {
12901
+ return {
12902
+ style: (el) => getComputedStyle(el),
12903
+ rect: (el) => {
12904
+ const r2 = el.getBoundingClientRect();
12905
+ return { x: r2.left, y: r2.top, width: r2.width, height: r2.height };
12906
+ },
12907
+ sample: (url, region, onReady) => {
12908
+ const entry = loadImage(url, onReady);
12909
+ if (entry.state === "loading") return "loading";
12910
+ if (entry.state === "fail") return null;
12911
+ const natural = { width: entry.img.naturalWidth, height: entry.img.naturalHeight };
12912
+ return sampleImage(entry.img, region(natural));
12913
+ },
12914
+ pseudo: (el, which) => getComputedStyle(el, which)
12915
+ };
12916
+ }
12917
+ function bgLayers(style) {
12918
+ const value = style.backgroundImage;
12919
+ return value && value !== "none" ? splitTopLevel(value) : [];
12920
+ }
12921
+ function urlOf(layer) {
12922
+ const m = layer.match(/^url\(\s*(['"]?)(.*?)\1\s*\)$/i);
12923
+ return m ? m[2] : null;
12924
+ }
12925
+ function paintOver(style, behind, at) {
12926
+ let color = behind;
12927
+ let painted = false;
12928
+ let opaque = false;
12929
+ const own = parseCssColor(style.backgroundColor);
12930
+ if (own && own.a > VISIBLE_ALPHA) {
12931
+ color = compositeColor(own, color);
12932
+ painted = true;
12933
+ opaque = own.a >= OPAQUE_ALPHA;
12934
+ }
12935
+ for (const layer of bgLayers(style).reverse()) {
12936
+ const stops = gradientStopColors(layer);
12937
+ if (stops.length === 0) continue;
12938
+ const point = at ? linearGradientColourAt(layer, at.x, at.y, at.width, at.height) : null;
12939
+ color = point ? compositeColor(point, color) : compositeGradient(stops, color);
12940
+ painted = true;
12941
+ if (stops.every((s) => s.a >= OPAQUE_ALPHA)) opaque = true;
12942
+ }
12943
+ return { color, opaque, painted };
12944
+ }
12945
+ function area(b) {
12946
+ return Math.max(0, b.width) * Math.max(0, b.height);
12947
+ }
12948
+ function intersect(a, b) {
12949
+ const x = Math.max(a.x, b.x);
12950
+ const y = Math.max(a.y, b.y);
12951
+ 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 };
12952
+ }
12953
+ function union(a, b) {
12954
+ if (!a) return b;
12955
+ const x = Math.min(a.x, b.x);
12956
+ const y = Math.min(a.y, b.y);
12957
+ 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 };
12958
+ }
12959
+ function covers(deps, el, section) {
12960
+ const sectionArea = area(section);
12961
+ return sectionArea > 0 && area(intersect(deps.rect(el), section)) >= IMAGE_COVER_RATIO * sectionArea;
12962
+ }
12963
+ function colourBehind(deps, el) {
12964
+ const chain = [];
12965
+ for (let p = el.parentElement; p; p = p.parentElement) chain.push(p);
12966
+ let color = WHITE;
12967
+ for (const ancestor of chain.reverse()) color = paintOver(deps.style(ancestor), color).color;
12968
+ return color;
12969
+ }
12970
+ function findImages(deps, section) {
12971
+ const out = [];
12972
+ const candidates = [section, ...Array.from(section.querySelectorAll("*"))];
12973
+ for (const el of candidates) {
12974
+ if (el !== section && el.closest(SECTION_SELECTOR) !== section) continue;
12975
+ const style = deps.style(el);
12976
+ if (style.display === "none" || style.visibility === "hidden") continue;
12977
+ if (el.tagName === "IMG") {
12978
+ const img = el;
12979
+ const url = img.currentSrc || img.src;
12980
+ if (url && style.objectFit === "cover") out.push({ el, url, urlLayer: -1 });
12981
+ continue;
12982
+ }
12983
+ const layers = bgLayers(style);
12984
+ const urlLayer = layers.findIndex((l) => urlOf(l) !== null);
12985
+ if (urlLayer >= 0) out.push({ el, url: urlOf(layers[urlLayer]), urlLayer });
12986
+ }
12987
+ return out;
12988
+ }
12989
+ function findImageHosts(deps, section, images, sectionImage, onReady) {
12990
+ const out = /* @__PURE__ */ new Map();
12991
+ for (const image of images) {
12992
+ if (image.el === sectionImage?.el) continue;
12993
+ let host = null;
12994
+ for (let p = image.urlLayer < 0 ? image.el.parentElement : image.el; p && p !== section; p = p.parentElement) {
12995
+ if (!covers(deps, image.el, deps.rect(p))) break;
12996
+ host = p;
12997
+ }
12998
+ if (!host || out.has(host)) continue;
12999
+ const box = deps.rect(host);
13000
+ if (box.width < SURFACE_MIN_PX || box.height < SURFACE_MIN_PX) continue;
13001
+ if (!textRegion(deps, host, deps.rect(image.el))) continue;
13002
+ out.set(host, imageSectionColour(deps, host, box, image, onReady));
13003
+ }
13004
+ return out;
13005
+ }
13006
+ function findOverlays(deps, section, image, box) {
13007
+ const out = [];
13008
+ for (const el of Array.from(section.querySelectorAll("*"))) {
13009
+ if (el === image || el.contains(image)) continue;
13010
+ const after = image.contains(el) || Boolean(
13011
+ image.compareDocumentPosition(el) & 4
13012
+ /* DOCUMENT_POSITION_FOLLOWING */
13013
+ );
13014
+ if (!after) continue;
13015
+ const style = deps.style(el);
13016
+ const paint3 = paintOver(style, { r: 0, g: 0, b: 0, a: 0 });
13017
+ if (paint3.painted && covers(deps, el, box)) out.push(el);
13018
+ }
13019
+ return out;
13020
+ }
13021
+ function findPseudoOverlays(deps, section, image, overlays, box) {
13022
+ if (!deps.pseudo) return [];
13023
+ const out = [];
13024
+ const read = (host, which) => {
13025
+ let style;
13026
+ try {
13027
+ style = deps.pseudo(host, which);
13028
+ } catch {
13029
+ return;
13030
+ }
13031
+ if (!style || !style.content || style.content === "none" || style.content === "normal") return;
13032
+ if (style.display === "none" || style.position !== "absolute" && style.position !== "fixed") return;
13033
+ if (!paintOver(style, { r: 0, g: 0, b: 0, a: 0 }).painted) return;
13034
+ const hostBox = deps.rect(host);
13035
+ const px2 = (v) => /^-?[\d.]+px$/.test(v) ? parseFloat(v) : NaN;
13036
+ let pseudoBox;
13037
+ const w = px2(style.width);
13038
+ const h = px2(style.height);
13039
+ if (Number.isFinite(w) && Number.isFinite(h)) {
13040
+ pseudoBox = { x: hostBox.x + (px2(style.left) || 0), y: hostBox.y + (px2(style.top) || 0), width: w, height: h };
13041
+ } else if ([style.top, style.left, style.right, style.bottom].every((v) => px2(v) === 0)) {
13042
+ pseudoBox = hostBox;
13043
+ } else {
13044
+ return;
13045
+ }
13046
+ const sectionArea = area(box);
13047
+ if (sectionArea > 0 && area(intersect(pseudoBox, box)) >= IMAGE_COVER_RATIO * sectionArea) out.push({ style, box: pseudoBox });
13048
+ };
13049
+ if (image.tagName !== "IMG") {
13050
+ read(image, "::before");
13051
+ read(image, "::after");
13052
+ }
13053
+ for (let p = image.parentElement; p && section.contains(p); p = p.parentElement) {
13054
+ read(p, "::after");
13055
+ if (p === section) break;
13056
+ }
13057
+ for (const overlay of overlays) {
13058
+ read(overlay, "::before");
13059
+ read(overlay, "::after");
13060
+ }
13061
+ return out;
13062
+ }
13063
+ function textRegion(deps, section, imageBox) {
13064
+ let region = null;
13065
+ for (const el of Array.from(section.querySelectorAll(TEXT_SELECTOR))) {
13066
+ const box = intersect(deps.rect(el), imageBox);
13067
+ if (box.width > 0 && box.height > 0) region = union(region, box);
13068
+ }
13069
+ return region ? { ...region, x: region.x - imageBox.x, y: region.y - imageBox.y } : null;
13070
+ }
13071
+ function opacityOf(style) {
13072
+ const n = parseFloat(style.opacity);
13073
+ return Number.isFinite(n) ? clamp01(n) : 1;
13074
+ }
13075
+ function imageSectionColour(deps, section, box, image, onReady) {
13076
+ const imageStyle = deps.style(image.el);
13077
+ const imageBox = deps.rect(image.el);
13078
+ const isImg = image.urlLayer < 0;
13079
+ const fit = isImg ? imageStyle.objectFit : splitTopLevel(imageStyle.backgroundSize)[image.urlLayer] ?? "auto";
13080
+ const position = isImg ? imageStyle.objectPosition : splitTopLevel(imageStyle.backgroundPosition)[image.urlLayer] ?? "0% 0%";
13081
+ const visible = intersect(imageBox, box);
13082
+ const fallback = { x: visible.x - imageBox.x, y: visible.y - imageBox.y, width: visible.width, height: visible.height };
13083
+ const region = textRegion(deps, section, imageBox) ?? fallback;
13084
+ const overlays = findOverlays(deps, section, image.el, box);
13085
+ const skip = /* @__PURE__ */ new Set([image.el, ...overlays]);
13086
+ for (let p = image.el.parentElement; p && p !== section && section.contains(p); p = p.parentElement) skip.add(p);
13087
+ const behind = colourBehind(deps, image.el);
13088
+ const above = isImg ? "" : bgLayers(imageStyle).slice(0, image.urlLayer).join(", ");
13089
+ const overlayParts = [
13090
+ ...findPseudoOverlays(deps, section, image.el, overlays, box),
13091
+ ...overlays.map((el) => ({ style: deps.style(el), box: deps.rect(el) }))
13092
+ ];
13093
+ const compose = (area2, point) => {
13094
+ const sampled = deps.sample(image.url, (natural) => mapRegionToImage(area2, imageBox, natural, fit, position), onReady);
13095
+ if (sampled === "loading" || sampled === null) return sampled;
13096
+ const atIn = (b) => point ? { x: point.x - b.x, y: point.y - b.y, width: b.width, height: b.height } : void 0;
13097
+ let color2 = behind;
13098
+ if (!isImg) color2 = paintOver({ backgroundColor: imageStyle.backgroundColor, backgroundImage: "none" }, color2).color;
13099
+ color2 = compositeColor({ ...sampled, a: sampled.a * opacityOf(imageStyle) }, color2);
13100
+ if (above) color2 = paintOver({ backgroundColor: "transparent", backgroundImage: above }, color2, atIn(imageBox)).color;
13101
+ for (const overlay of overlayParts) {
13102
+ const layer = paintOver(overlay.style, { r: 0, g: 0, b: 0, a: 0 }, atIn(overlay.box)).color;
13103
+ color2 = compositeColor({ ...layer, a: layer.a * opacityOf(overlay.style) }, color2);
13104
+ }
13105
+ return color2;
13106
+ };
13107
+ const color = compose(region);
13108
+ if (color === "loading" || color === null) return { color, skip };
13109
+ const at = (box2) => {
13110
+ const local = intersect(box2, imageBox);
13111
+ if (local.width <= 0 || local.height <= 0) return null;
13112
+ const result = compose(
13113
+ { x: local.x - imageBox.x, y: local.y - imageBox.y, width: local.width, height: local.height },
13114
+ { x: local.x + local.width / 2, y: local.y + local.height / 2 }
13115
+ );
13116
+ return result === "loading" ? null : result;
13117
+ };
13118
+ return { color, skip, at };
13119
+ }
13120
+ function writeTone(el, tone) {
13121
+ const previous = el.getAttribute(TONE_ATTR);
13122
+ if (previous === tone) return;
13123
+ el.setAttribute(TONE_ATTR, tone);
13124
+ const Event2 = el.ownerDocument?.defaultView?.CustomEvent ?? CustomEvent;
13125
+ el.dispatchEvent(new Event2(TONE_CHANGE_EVENT, { bubbles: true, detail: { tone, previous } }));
13126
+ }
13127
+ function isEditorBackground(el) {
13128
+ return el.hasAttribute("data-ohw-style-bg") || el.hasAttribute("data-ohw-style-bgcolor");
13129
+ }
13130
+ function hasPickedColour(el, context) {
13131
+ for (let node = el; node && node !== context; node = node.parentElement) {
13132
+ const style = node.style;
13133
+ if (style?.color && style.getPropertyPriority("color") === "important") return true;
13134
+ }
13135
+ return false;
13136
+ }
13137
+ var TEXT_SPOTS = [
13138
+ [1 / 6, 1 / 4],
13139
+ [1 / 2, 1 / 4],
13140
+ [5 / 6, 1 / 4],
13141
+ [1 / 6, 3 / 4],
13142
+ [1 / 2, 3 / 4],
13143
+ [5 / 6, 3 / 4]
13144
+ ];
13145
+ function fixInks(doc) {
13146
+ const view = doc?.defaultView;
13147
+ const root = doc?.documentElement;
13148
+ const read = (names, fallback) => {
13149
+ if (!view || !root) return fallback;
13150
+ let style;
13151
+ try {
13152
+ style = view.getComputedStyle(root);
13153
+ } catch {
13154
+ return fallback;
13155
+ }
13156
+ for (const name of names) {
13157
+ const parsed = parseCssColor(style.getPropertyValue(name).trim());
13158
+ if (parsed) return parsed;
13159
+ }
13160
+ return fallback;
13161
+ };
13162
+ return {
13163
+ dark: read(["--ohw-brand-dark", "--color-dark"], { r: 12, g: 10, b: 9, a: 1 }),
13164
+ light: read(["--ohw-brand-light", "--color-light"], WHITE)
13165
+ };
13166
+ }
13167
+ function glyphBox(el) {
13168
+ try {
13169
+ const range = el.ownerDocument?.createRange?.();
13170
+ if (!range) return null;
13171
+ range.selectNodeContents(el);
13172
+ const r2 = range.getBoundingClientRect?.();
13173
+ range.detach?.();
13174
+ return r2 && r2.width > 0 && r2.height > 0 ? { x: r2.left, y: r2.top, width: r2.width, height: r2.height } : null;
13175
+ } catch {
13176
+ return null;
13177
+ }
13178
+ }
13179
+ function worstContrast(ink, spots) {
13180
+ let worst = Infinity;
13181
+ for (const bg of spots) worst = Math.min(worst, contrastRatioOf(compositeColor(ink, bg), bg));
13182
+ return worst;
13183
+ }
13184
+ function spotsOf(box, at) {
13185
+ const spots = [];
13186
+ if (box.width <= 0 || box.height <= 0) return spots;
13187
+ const w = box.width / 3;
13188
+ const h = box.height / 2;
13189
+ for (const [fx, fy] of TEXT_SPOTS) {
13190
+ const bg = at({ x: box.x + fx * box.width - w / 2, y: box.y + fy * box.height - h / 2, width: w, height: h });
13191
+ if (bg) spots.push(bg);
13192
+ }
13193
+ return spots;
13194
+ }
13195
+ function fixTextOnImage(el, text, box, at, inks) {
13196
+ if (!text) return;
13197
+ const spots = spotsOf(box, at);
13198
+ if (spots.length === 0 || worstContrast(text, spots) >= IMAGE_TEXT_MIN_CONTRAST) return;
13199
+ const darkWorks = worstContrast(inks.dark, spots) >= IMAGE_TEXT_MIN_CONTRAST;
13200
+ const lightWorks = worstContrast(inks.light, spots) >= IMAGE_TEXT_MIN_CONTRAST;
13201
+ if (darkWorks && (!lightWorks || worstContrast(inks.dark, spots) >= worstContrast(inks.light, spots))) {
13202
+ el.setAttribute(TONE_FIX_ATTR, "light");
13203
+ } else if (lightWorks) {
13204
+ el.setAttribute(TONE_FIX_ATTR, "dark");
13205
+ }
13206
+ }
13207
+ var KEYED_TEXT_SELECTOR = "[data-ohw-key]:not([data-ohw-editable])";
13208
+ function hasOwnText(el) {
13209
+ for (const node of Array.from(el.childNodes)) if (node.nodeType === 3 && node.textContent?.trim()) return true;
13210
+ return false;
13211
+ }
13212
+ function hiddenWithin(deps, el, stop) {
13213
+ for (let node = el; node && node !== stop; node = node.parentElement) {
13214
+ const style = deps.style(node);
13215
+ if (style.visibility === "hidden" || opacityOf(style) < VISIBLE_ALPHA) return true;
13216
+ }
13217
+ return false;
13218
+ }
13219
+ function fixTextContrast(deps, section, resolved, imageContexts, pending) {
13220
+ let inks = null;
13221
+ const texts = new Set(Array.from(section.querySelectorAll(TEXT_SELECTOR)));
13222
+ const keyed = /* @__PURE__ */ new Set();
13223
+ for (const el of Array.from(section.querySelectorAll(KEYED_TEXT_SELECTOR))) {
13224
+ if (!texts.has(el) && hasOwnText(el)) keyed.add(el);
13225
+ }
13226
+ for (const el of [...texts, ...keyed]) {
13227
+ const overlayRoot = el.closest(OVERLAY_ROOT_SELECTOR);
13228
+ if (overlayRoot && !onOwnSurface(deps, el, overlayRoot)) continue;
13229
+ const context = el.closest(`[${TONE_ATTR}]`);
13230
+ if (context && pending.has(context)) continue;
13231
+ const bg = context ? resolved.get(context) : void 0;
13232
+ const imageAt = context ? imageContexts.get(context) : void 0;
13233
+ const onImage = !!imageAt;
13234
+ if (!context || !bg || !isEditorBackground(context) && !onImage || keyed.has(el) && !onImage) {
13235
+ el.removeAttribute(TONE_FIX_ATTR);
13236
+ continue;
13237
+ }
13238
+ if (imageAt && !isEditorBackground(context) && hiddenWithin(deps, el, context)) continue;
13239
+ const had = el.getAttribute(TONE_FIX_ATTR);
13240
+ if (had) el.removeAttribute(TONE_FIX_ATTR);
13241
+ if (imageAt && !isEditorBackground(context)) {
13242
+ if (!hasPickedColour(el, context)) {
13243
+ inks ?? (inks = fixInks(section.ownerDocument));
13244
+ fixTextOnImage(el, parseCssColor(deps.style(el).color), glyphBox(el) ?? deps.rect(el), imageAt, inks);
13245
+ }
13246
+ continue;
13247
+ }
13248
+ const text = parseCssColor(deps.style(el).color);
13249
+ const bgTone = toneOfColor(bg);
13250
+ const needsFix = text !== null && toneOfColor(compositeColor(text, bg)) === bgTone;
13251
+ if (needsFix) el.setAttribute(TONE_FIX_ATTR, bgTone);
13252
+ }
13253
+ }
13254
+ function pickedButtonInks(doc) {
13255
+ const root = doc?.documentElement;
13256
+ const inks = [];
13257
+ for (const name of PICKED_BUTTON_TEXT_VARS) {
13258
+ const raw = root?.style?.getPropertyValue(name).trim();
13259
+ if (!raw) continue;
13260
+ const ink = parseCssColor(raw);
13261
+ if (!ink) return "any";
13262
+ inks.push(ink);
13263
+ }
13264
+ return inks;
13265
+ }
13266
+ function sameColour(a, b) {
13267
+ return Math.abs(a.r - b.r) < 2 && Math.abs(a.g - b.g) < 2 && Math.abs(a.b - b.b) < 2;
13268
+ }
13269
+ function unreadableOn(ink, bg) {
13270
+ if (!ink) return false;
13271
+ const seen = compositeColor(ink, bg);
13272
+ return toneOfColor(seen) === toneOfColor(bg) && contrastRatioOf(seen, bg) < INK_MIN_CONTRAST;
13273
+ }
13274
+ function fixButtonInk(deps, section, painted) {
13275
+ const buttons = Array.from(section.querySelectorAll(BUTTON_SELECTOR));
13276
+ if (buttons.length === 0) return;
13277
+ const picked = pickedButtonInks(section.ownerDocument);
13278
+ for (const button of buttons) {
13279
+ const icons = Array.from(button.querySelectorAll("svg"));
13280
+ const chips = [];
13281
+ for (const icon of icons) if (icon.parentElement && icon.parentElement !== button) chips.push(icon.parentElement);
13282
+ const targets = [button, ...chips, ...icons];
13283
+ for (const el of targets) {
13284
+ el.setAttribute(MEASURING_ATTR, "");
13285
+ if (!chips.includes(el)) el.removeAttribute(TONE_FIX_ATTR);
13286
+ }
13287
+ try {
13288
+ const own = button;
13289
+ if (picked === "any" || button.hasAttribute("data-ohw-btn-variant") || own.style?.color) continue;
13290
+ const fresh = (el) => {
13291
+ const behind = el?.parentElement ? painted.get(el.parentElement) : void 0;
13292
+ return el && behind && painted.has(el) ? paintOver(deps.style(el), behind).color : void 0;
13293
+ };
13294
+ const fill = fresh(button);
13295
+ if (!fill) continue;
13296
+ const ink = parseCssColor(deps.style(button).color);
13297
+ if (ink && picked.some((p) => sameColour(p, ink))) continue;
13298
+ if (unreadableOn(ink, fill)) button.setAttribute(TONE_FIX_ATTR, toneOfColor(fill));
13299
+ for (const icon of icons) {
13300
+ const behind = fresh(icon.parentElement);
13301
+ if (behind && unreadableOn(parseCssColor(deps.style(icon).color), behind)) {
13302
+ icon.setAttribute(TONE_FIX_ATTR, toneOfColor(behind));
13303
+ }
13304
+ }
13305
+ } finally {
13306
+ void deps.style(button).color;
13307
+ for (const el of targets) el.removeAttribute(MEASURING_ATTR);
13308
+ }
13309
+ }
13310
+ }
13311
+ var INK_FIX_CSS = `[${MEASURING_ATTR}] { transition: none !important; }
13312
+ [${TONE_FIX_ATTR}="dark"] { color: var(--ohw-brand-light, var(--color-light, #FFFFFF)) !important; }
13313
+ [${TONE_FIX_ATTR}="light"] { color: var(--ohw-brand-dark, var(--color-dark, #0C0A09)) !important; }
13314
+ [${TONE_FIX_LINE_ATTR}="dark"] { border-bottom-color: var(--ohw-brand-light, var(--color-light, #FFFFFF)) !important; }
13315
+ [${TONE_FIX_LINE_ATTR}="light"] { border-bottom-color: var(--ohw-brand-dark, var(--color-dark, #0C0A09)) !important; }`;
13316
+ function ensureInkFixStyles(doc) {
13317
+ if (doc.getElementById(INK_FIX_STYLE_ID)) return;
13318
+ const style = doc.createElement("style");
13319
+ style.id = INK_FIX_STYLE_ID;
13320
+ style.textContent = INK_FIX_CSS;
13321
+ doc.head?.appendChild(style);
13322
+ }
13323
+ var sectionPhotos = /* @__PURE__ */ new WeakMap();
13324
+ var OVERLAY_ROOT_SELECTOR = "[data-ohw-nav-root]";
13325
+ function onOwnSurface(deps, el, root) {
13326
+ for (let node = el; node; node = node.parentElement) {
13327
+ if (paintOver(deps.style(node), { r: 0, g: 0, b: 0, a: 0 }).painted) return true;
13328
+ if (node === root) break;
13329
+ }
13330
+ return false;
13331
+ }
13332
+ function contains(box, x, y) {
13333
+ return x >= box.x && x <= box.x + box.width && y >= box.y && y <= box.y + box.height;
13334
+ }
13335
+ function fixOverlayText(deps, doc) {
13336
+ const roots = Array.from(doc.querySelectorAll(OVERLAY_ROOT_SELECTOR));
13337
+ if (roots.length === 0) return;
13338
+ const photoSections = topSections(doc).filter((s) => sectionPhotos.has(s));
13339
+ const boxes = new Map(photoSections.map((s) => [s, deps.rect(s)]));
13340
+ let inks = null;
13341
+ for (const root of roots) {
13342
+ const items = [];
13343
+ for (const el of Array.from(root.querySelectorAll(TEXT_SELECTOR))) {
13344
+ if (onOwnSurface(deps, el, root)) continue;
13345
+ const box = glyphBox(el) ?? deps.rect(el);
13346
+ const cx2 = box.x + box.width / 2;
13347
+ const cy = box.y + box.height / 2;
13348
+ const under = photoSections.find((s) => contains(boxes.get(s), cx2, cy));
13349
+ const photo = under ? sectionPhotos.get(under) : void 0;
13350
+ if (photo === "loading") continue;
13351
+ el.removeAttribute(TONE_FIX_ATTR);
13352
+ for (let node = el; node; node = node.parentElement) {
13353
+ node.removeAttribute(TONE_FIX_LINE_ATTR);
13354
+ if (node === root) break;
13355
+ }
13356
+ if (!photo || el.closest(BUTTON_SELECTOR)) continue;
13357
+ if (hasPickedColour(el, doc.documentElement) || hiddenWithin(deps, el, null)) continue;
13358
+ const text = parseCssColor(deps.style(el).color);
13359
+ const spots = spotsOf(box, photo);
13360
+ if (text && spots.length > 0) items.push({ el, text, spots, line: underlineOf(deps, el, root) });
13361
+ }
13362
+ inks ?? (inks = fixInks(doc));
13363
+ fixBarInk(items, inks);
13364
+ for (const item of items) {
13365
+ const fix = item.el.getAttribute(TONE_FIX_ATTR);
13366
+ if (fix) item.line?.setAttribute(TONE_FIX_LINE_ATTR, fix);
13367
+ }
13368
+ }
13369
+ }
13370
+ function underlineOf(deps, el, root) {
13371
+ const text = parseCssColor(deps.style(el).color);
13372
+ if (!text) return null;
13373
+ for (let node = el; node; node = node.parentElement) {
13374
+ const style = deps.style(node);
13375
+ const line = parseCssColor(style.borderBottomColor);
13376
+ if (line && line.a > VISIBLE_ALPHA && parseFloat(style.borderBottomWidth ?? "0") > 0 && style.borderBottomStyle !== "none" && sameColour(line, text)) {
13377
+ return node;
13378
+ }
13379
+ if (node === root) break;
13380
+ }
13381
+ return null;
13382
+ }
13383
+ function fixBarInk(items, inks) {
13384
+ if (!items.some((item) => worstContrast(item.text, item.spots) < IMAGE_TEXT_MIN_CONTRAST)) return;
13385
+ const score = (ink) => {
13386
+ let readable = 0;
13387
+ let worst = Infinity;
13388
+ for (const item of items) {
13389
+ const c = worstContrast(ink, item.spots);
13390
+ if (c >= IMAGE_TEXT_MIN_CONTRAST) readable++;
13391
+ worst = Math.min(worst, c);
13392
+ }
13393
+ return { readable, worst };
13394
+ };
13395
+ const dark = score(inks.dark);
13396
+ const light = score(inks.light);
13397
+ if (dark.readable === 0 && light.readable === 0) return;
13398
+ const useDark = dark.readable > light.readable || dark.readable === light.readable && dark.worst >= light.worst;
13399
+ const fix = useDark ? "light" : "dark";
13400
+ for (const item of items) {
13401
+ if (toneOfColor(item.text) === (useDark ? "dark" : "light")) continue;
13402
+ item.el.setAttribute(TONE_FIX_ATTR, fix);
13403
+ }
13404
+ }
13405
+ function computeSection(deps, section, onReady) {
13406
+ const box = deps.rect(section);
13407
+ const resolved = /* @__PURE__ */ new Map();
13408
+ const painted = /* @__PURE__ */ new Map();
13409
+ const written = /* @__PURE__ */ new Set();
13410
+ const imageContexts = /* @__PURE__ */ new Map();
13411
+ const pending = /* @__PURE__ */ new Set();
13412
+ let base;
13413
+ let skip = /* @__PURE__ */ new Set();
13414
+ const images = box.width > 0 && box.height > 0 ? findImages(deps, section) : [];
13415
+ const image = images.find((candidate) => covers(deps, candidate.el, box)) ?? null;
13416
+ if (image) {
13417
+ const result = imageSectionColour(deps, section, box, image, onReady);
13418
+ if (result.color === "loading") {
13419
+ sectionPhotos.set(section, "loading");
13420
+ return;
13421
+ }
13422
+ skip = result.skip;
13423
+ base = result.color ?? WHITE;
13424
+ writeTone(section, result.color ? toneOfColor(base) : "light");
13425
+ if (result.color && result.at) {
13426
+ imageContexts.set(section, result.at);
13427
+ sectionPhotos.set(section, result.at);
13428
+ } else {
13429
+ sectionPhotos.delete(section);
13430
+ }
13431
+ } else {
13432
+ sectionPhotos.delete(section);
13433
+ base = paintOver(deps.style(section), colourBehind(deps, section)).color;
13434
+ writeTone(section, toneOfColor(base));
13435
+ }
13436
+ resolved.set(section, base);
13437
+ painted.set(section, base);
13438
+ written.add(section);
13439
+ const hosts = findImageHosts(deps, section, images, image, onReady);
13440
+ for (const hosted of hosts.values()) for (const el of hosted.skip) skip.add(el);
13441
+ const visit = (parent, behind, context) => {
13442
+ for (const child of Array.from(parent.children)) {
13443
+ if (NEVER_SURFACE.has(child.tagName.toUpperCase())) continue;
13444
+ const hosted = hosts.get(child);
13445
+ if (hosted) {
13446
+ written.add(child);
13447
+ if (hosted.color === "loading") {
13448
+ pending.add(child);
13449
+ painted.set(child, behind);
13450
+ visit(child, behind, context);
13451
+ continue;
13452
+ }
13453
+ const color = hosted.color ?? WHITE;
13454
+ writeTone(child, hosted.color ? toneOfColor(color) : "light");
13455
+ if (hosted.color && hosted.at) imageContexts.set(child, hosted.at);
13456
+ resolved.set(child, color);
13457
+ painted.set(child, color);
13458
+ visit(child, color, color);
13459
+ continue;
13460
+ }
13461
+ if (skip.has(child)) {
13462
+ painted.set(child, behind);
13463
+ visit(child, behind, context);
13464
+ continue;
13465
+ }
13466
+ const style = deps.style(child);
13467
+ if (style.display === "none") continue;
13468
+ const paint3 = paintOver(style, behind);
13469
+ painted.set(child, paint3.color);
13470
+ let nextContext = context;
13471
+ const forced = isEditorBackground(child) || child.matches(SECTION_SELECTOR);
13472
+ if (forced || paint3.painted && paint3.opaque) {
13473
+ const rect = deps.rect(child);
13474
+ const bigEnough = rect.width >= SURFACE_MIN_PX && rect.height >= SURFACE_MIN_PX;
13475
+ const differs = Math.abs(relativeLuminanceOf(paint3.color) - relativeLuminanceOf(context)) > 0.01 || toneOfColor(paint3.color) !== toneOfColor(context);
13476
+ if (forced || bigEnough && differs) {
13477
+ writeTone(child, toneOfColor(paint3.color));
13478
+ resolved.set(child, paint3.color);
13479
+ written.add(child);
13480
+ nextContext = paint3.color;
13481
+ }
13482
+ }
13483
+ visit(child, paint3.color, nextContext);
13484
+ }
13485
+ };
13486
+ visit(section, base, base);
13487
+ for (const stale of Array.from(section.querySelectorAll(`[${TONE_ATTR}]`))) {
13488
+ if (!written.has(stale)) stale.removeAttribute(TONE_ATTR);
13489
+ }
13490
+ fixTextContrast(deps, section, resolved, imageContexts, pending);
13491
+ fixButtonInk(deps, section, painted);
13492
+ }
13493
+ function topSections(root) {
13494
+ return Array.from(root.querySelectorAll(SECTION_SELECTOR)).filter((el) => !el.parentElement?.closest(SECTION_SELECTOR));
13495
+ }
13496
+ function computeBackgroundTones(doc, options = {}) {
13497
+ const deps = options.deps ?? browserDeps();
13498
+ const sections = options.only ? Array.from(options.only) : topSections(doc);
13499
+ for (const section of sections) {
13500
+ if (!section.isConnected) continue;
13501
+ computeSection(deps, section, () => options.onImageReady?.(section));
13502
+ }
13503
+ fixOverlayText(deps, doc);
13504
+ }
13505
+ function toneFor(el) {
13506
+ const value = el?.closest(`[${TONE_ATTR}]`)?.getAttribute(TONE_ATTR);
13507
+ return value === "dark" ? "dark" : "light";
13508
+ }
13509
+ var WATCHED_ATTRS = [
13510
+ "style",
13511
+ "class",
13512
+ "src",
13513
+ "srcset",
13514
+ "data-ohw-style-bg",
13515
+ "data-ohw-style-bgcolor",
13516
+ "data-ohw-style-cardbg",
13517
+ // The editor's Default / Hover toggle forces :hover rules through this attribute.
13518
+ "data-ohw-active-state"
13519
+ ];
13520
+ var VISIBILITY_TRANSITIONS = /* @__PURE__ */ new Set(["opacity", "visibility"]);
13521
+ function outermostSection(node) {
13522
+ let el = node instanceof Element ? node : node?.parentElement ?? null;
13523
+ let top = null;
13524
+ while (el) {
13525
+ const section = el.closest(SECTION_SELECTOR);
13526
+ if (!section) break;
13527
+ top = section;
13528
+ el = section.parentElement;
13529
+ }
13530
+ return top;
13531
+ }
13532
+ function mountBackgroundTone(doc = document) {
13533
+ const win = doc.defaultView;
13534
+ if (!win) return () => void 0;
13535
+ const dirty = /* @__PURE__ */ new Set();
13536
+ let all = true;
13537
+ let frame = 0;
13538
+ const run = () => {
13539
+ frame = 0;
13540
+ const only = all ? void 0 : Array.from(dirty);
13541
+ all = false;
13542
+ dirty.clear();
13543
+ computeBackgroundTones(doc, { only, onImageReady: (section) => schedule(section) });
13544
+ };
13545
+ function schedule(section) {
13546
+ if (section) dirty.add(section);
13547
+ else all = true;
13548
+ if (!frame) frame = win.requestAnimationFrame(run);
13549
+ }
13550
+ ensureInkFixStyles(doc);
13551
+ const observer = new MutationObserver((records) => {
13552
+ for (const record of records) {
13553
+ const target = record.target;
13554
+ if (target === doc.documentElement || doc.head?.contains(target)) {
13555
+ schedule();
13556
+ continue;
13557
+ }
13558
+ const section = outermostSection(target);
13559
+ if (section) {
13560
+ schedule(section);
13561
+ continue;
13562
+ }
13563
+ const targetEl = target instanceof Element ? target : target.parentElement;
13564
+ if (targetEl?.closest(OVERLAY_ROOT_SELECTOR)) {
13565
+ if (!frame) frame = win.requestAnimationFrame(run);
13566
+ continue;
13567
+ }
13568
+ for (const added of Array.from(record.addedNodes)) {
13569
+ if (added instanceof Element && (added.matches(SECTION_SELECTOR) || added.querySelector(SECTION_SELECTOR))) {
13570
+ schedule();
13571
+ break;
13572
+ }
13573
+ }
13574
+ }
13575
+ });
13576
+ observer.observe(doc.documentElement, {
13577
+ subtree: true,
13578
+ childList: true,
13579
+ characterData: true,
13580
+ attributes: true,
13581
+ attributeFilter: WATCHED_ATTRS
13582
+ });
13583
+ const onResize = () => schedule();
13584
+ const onTransitionEnd = (event) => {
13585
+ if (!VISIBILITY_TRANSITIONS.has(event.propertyName)) return;
13586
+ const section = outermostSection(event.target);
13587
+ if (section) schedule(section);
13588
+ };
13589
+ win.addEventListener("resize", onResize);
13590
+ win.addEventListener("load", onResize);
13591
+ doc.addEventListener("transitionend", onTransitionEnd, true);
13592
+ doc.fonts?.ready.then(() => schedule()).catch(() => void 0);
13593
+ schedule();
13594
+ return () => {
13595
+ observer.disconnect();
13596
+ win.removeEventListener("resize", onResize);
13597
+ win.removeEventListener("load", onResize);
13598
+ doc.removeEventListener("transitionend", onTransitionEnd, true);
13599
+ if (frame) win.cancelAnimationFrame(frame);
13600
+ };
13601
+ }
13602
+
13603
+ // src/useBackgroundTone.ts
13604
+ function useBackgroundTone() {
13605
+ useEffect4(() => mountBackgroundTone(), []);
13606
+ }
13607
+
13608
+ // src/useHashLinkScroll.ts
13609
+ import { useEffect as useEffect5 } from "react";
13610
+
12582
13611
  // src/lib/scroll-to-section.ts
12583
13612
  var MAX_ATTEMPTS = 12;
12584
13613
  var RETRY_MS = 100;
@@ -12631,7 +13660,7 @@ function samePageSectionId(anchor) {
12631
13660
  return id || null;
12632
13661
  }
12633
13662
  function useHashLinkScroll(isEditMode) {
12634
- useEffect4(() => {
13663
+ useEffect5(() => {
12635
13664
  if (isEditMode) return;
12636
13665
  const onClick = (e) => {
12637
13666
  if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
@@ -12646,7 +13675,7 @@ function useHashLinkScroll(isEditMode) {
12646
13675
  }
12647
13676
 
12648
13677
  // src/usePublishedPlaceholderStrip.ts
12649
- import { useEffect as useEffect5 } from "react";
13678
+ import { useEffect as useEffect6 } from "react";
12650
13679
 
12651
13680
  // src/lib/strip-placeholders.ts
12652
13681
  var PLACEHOLDER_RE = /\[[A-Za-z][A-Za-z0-9 _/&#'.-]{0,30}\]-?/g;
@@ -12733,7 +13762,7 @@ function stripTextNode(node) {
12733
13762
 
12734
13763
  // src/usePublishedPlaceholderStrip.ts
12735
13764
  function usePublishedPlaceholderStrip(isEditMode) {
12736
- useEffect5(() => {
13765
+ useEffect6(() => {
12737
13766
  if (isEditMode) return;
12738
13767
  stripPlaceholders(document.body);
12739
13768
  const observer = new MutationObserver((records) => {
@@ -12754,7 +13783,7 @@ function usePublishedPlaceholderStrip(isEditMode) {
12754
13783
  }
12755
13784
 
12756
13785
  // src/ui/SchedulingWidget.tsx
12757
- import { useCallback, useEffect as useEffect6, useId, useMemo, useRef, useState as useState3 } from "react";
13786
+ import { useCallback, useEffect as useEffect7, useId, useMemo, useRef, useState as useState3 } from "react";
12758
13787
 
12759
13788
  // src/ui/EmailCaptureModal.tsx
12760
13789
  import { useState as useState2 } from "react";
@@ -13072,7 +14101,7 @@ function ScheduleView({ schedule, dates, selectedIdx, onSelectDate, onOpenModal
13072
14101
  setCanScrollLeft(el.scrollLeft > 0);
13073
14102
  setCanScrollRight(el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
13074
14103
  };
13075
- useEffect6(() => {
14104
+ useEffect7(() => {
13076
14105
  const el = scrollRef.current;
13077
14106
  if (!el) return;
13078
14107
  updateScrollState();
@@ -13330,7 +14359,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
13330
14359
  });
13331
14360
  }, []);
13332
14361
  const [selectedIdx, setSelectedIdx] = useState3(0);
13333
- useEffect6(() => {
14362
+ useEffect7(() => {
13334
14363
  if (!schedule?.classes) return;
13335
14364
  for (let i = 0; i < dates.length; i++) {
13336
14365
  if (schedule.classes.some((c) => classRunsOnDate(c, dates[i], schedule.type))) {
@@ -13339,7 +14368,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
13339
14368
  }
13340
14369
  }
13341
14370
  }, [schedule, dates]);
13342
- useEffect6(() => {
14371
+ useEffect7(() => {
13343
14372
  if (typeof window === "undefined") return;
13344
14373
  const onVisible = () => {
13345
14374
  if (!document.hidden) void refetchLiveSchedule();
@@ -13351,7 +14380,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
13351
14380
  document.removeEventListener("visibilitychange", onVisible);
13352
14381
  };
13353
14382
  }, [refetchLiveSchedule]);
13354
- useEffect6(() => {
14383
+ useEffect7(() => {
13355
14384
  if (typeof window === "undefined") return;
13356
14385
  const isInEditor = window.self !== window.top;
13357
14386
  setInEditor(isInEditor);
@@ -17985,7 +19014,7 @@ function apiBase() {
17985
19014
  function bridgeVersion() {
17986
19015
  try {
17987
19016
  if (true) {
17988
- return "0.1.173";
19017
+ return "0.1.174";
17989
19018
  }
17990
19019
  } catch {
17991
19020
  }
@@ -17999,7 +19028,7 @@ function stampBridgeVersionOnDocument() {
17999
19028
  return;
18000
19029
  }
18001
19030
  try {
18002
- const v = true ? "0.1.173" : "";
19031
+ const v = true ? "0.1.174" : "";
18003
19032
  if (v) {
18004
19033
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
18005
19034
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -18940,7 +19969,7 @@ function CarouselOverlay({
18940
19969
  }
18941
19970
 
18942
19971
  // src/ui/ai-section/AiSectionOverlay.tsx
18943
- import { useCallback as useCallback2, useEffect as useEffect8, useRef as useRef4, useState as useState7 } from "react";
19972
+ import { useCallback as useCallback2, useEffect as useEffect9, useRef as useRef4, useState as useState7 } from "react";
18944
19973
  import { Check, X } from "lucide-react";
18945
19974
 
18946
19975
  // src/lib/ai-change-highlight.ts
@@ -19073,7 +20102,7 @@ function readRect(instanceId) {
19073
20102
  }
19074
20103
  function useLiveSectionRect(sectionId) {
19075
20104
  const [rect, setRect] = useState7(null);
19076
- useEffect8(() => {
20105
+ useEffect9(() => {
19077
20106
  if (!sectionId) {
19078
20107
  setRect(null);
19079
20108
  return;
@@ -19113,7 +20142,7 @@ function readNavToggleRect() {
19113
20142
  }
19114
20143
  function useLiveNavToggleHole(active) {
19115
20144
  const [rect, setRect] = useState7(null);
19116
- useEffect8(() => {
20145
+ useEffect9(() => {
19117
20146
  if (!active) {
19118
20147
  setRect(null);
19119
20148
  return;
@@ -19237,7 +20266,7 @@ function AiSectionOverlay({
19237
20266
  reviewIdRef.current = reviewId;
19238
20267
  const selectedIdRef = useRef4(null);
19239
20268
  selectedIdRef.current = selectedId;
19240
- useEffect8(() => {
20269
+ useEffect9(() => {
19241
20270
  onSelectionChange?.(selectedId);
19242
20271
  }, [selectedId, onSelectionChange]);
19243
20272
  const report = useCallback2(
@@ -19263,7 +20292,7 @@ function AiSectionOverlay({
19263
20292
  },
19264
20293
  [report]
19265
20294
  );
19266
- useEffect8(() => {
20295
+ useEffect9(() => {
19267
20296
  apiRef.current = {
19268
20297
  selectFromElement,
19269
20298
  handleBackgroundClick: (target, clientX, clientY) => {
@@ -19288,7 +20317,7 @@ function AiSectionOverlay({
19288
20317
  apiRef.current = null;
19289
20318
  };
19290
20319
  }, [apiRef, selectFromElement, report]);
19291
- useEffect8(() => {
20320
+ useEffect9(() => {
19292
20321
  const onMessage = (e) => {
19293
20322
  if (e.data?.type === "ow:ai-select" && e.data.sectionId === null) {
19294
20323
  selectedIdRef.current = null;
@@ -19313,10 +20342,10 @@ function AiSectionOverlay({
19313
20342
  window.addEventListener("message", onMessage);
19314
20343
  return () => window.removeEventListener("message", onMessage);
19315
20344
  }, [postToParent2]);
19316
- useEffect8(() => installAiChangeHighlight((el) => selectFromElement(el)), [selectFromElement]);
19317
- useEffect8(() => installHistoryKeyRelay(), []);
20345
+ useEffect9(() => installAiChangeHighlight((el) => selectFromElement(el)), [selectFromElement]);
20346
+ useEffect9(() => installHistoryKeyRelay(), []);
19318
20347
  const [hoveredId, setHoveredId] = useState7(null);
19319
- useEffect8(() => {
20348
+ useEffect9(() => {
19320
20349
  const onMove = (e) => {
19321
20350
  const t = e.target;
19322
20351
  if (!(t instanceof Element)) return;
@@ -19341,7 +20370,7 @@ function AiSectionOverlay({
19341
20370
  document.documentElement.removeEventListener("mouseleave", onLeave);
19342
20371
  };
19343
20372
  }, []);
19344
- useEffect8(() => {
20373
+ useEffect9(() => {
19345
20374
  const onKeyDown = (e) => {
19346
20375
  if (e.key !== "Escape") return;
19347
20376
  if (reviewIdRef.current) return;
@@ -19365,7 +20394,7 @@ function AiSectionOverlay({
19365
20394
  [postToParent2]
19366
20395
  );
19367
20396
  const [navDropdownForceOpen, setNavDropdownForceOpen] = useState7(false);
19368
- useEffect8(() => {
20397
+ useEffect9(() => {
19369
20398
  const update = () => {
19370
20399
  setNavDropdownForceOpen(Boolean(document.querySelector("[data-ohw-nav-force-open]")));
19371
20400
  };
@@ -19384,7 +20413,7 @@ function AiSectionOverlay({
19384
20413
  const navToggleHole = useLiveNavToggleHole(Boolean(reviewId));
19385
20414
  const hoverRect = useLiveSectionRect(reviewId || hoveredId === selectedId ? null : hoveredId);
19386
20415
  const showSelectionBorder = Boolean(selectionRect) && !navDropdownForceOpen;
19387
- useEffect8(() => {
20416
+ useEffect9(() => {
19388
20417
  const selectedEl = activeSelectionId ? findSectionElement(activeSelectionId) : null;
19389
20418
  if (!activeSelectionId || !selectionRect || selectedEl && isChromeSection(selectedEl)) {
19390
20419
  postToParent2({ type: "ow:section-rect", instanceId: null, rect: null });
@@ -19504,7 +20533,7 @@ function AiSectionOverlay({
19504
20533
  }
19505
20534
 
19506
20535
  // src/ui/ai-section/AiMediaStripOverlay.tsx
19507
- import { useCallback as useCallback3, useEffect as useEffect9, useRef as useRef5, useState as useState8 } from "react";
20536
+ import { useCallback as useCallback3, useEffect as useEffect10, useRef as useRef5, useState as useState8 } from "react";
19508
20537
  import { Star } from "lucide-react";
19509
20538
 
19510
20539
  // src/lib/ai-media-strip-tree.ts
@@ -19667,7 +20696,7 @@ function readRect2(ref) {
19667
20696
  }
19668
20697
  function useLiveItemRect(ref) {
19669
20698
  const [rect, setRect] = useState8(null);
19670
- useEffect9(() => {
20699
+ useEffect10(() => {
19671
20700
  if (!ref) {
19672
20701
  setRect(null);
19673
20702
  return;
@@ -19763,7 +20792,7 @@ function Pill({
19763
20792
  }
19764
20793
  function AltInput({ value, onCommit }) {
19765
20794
  const [draft, setDraft] = useState8(value);
19766
- useEffect9(() => setDraft(value), [value]);
20795
+ useEffect10(() => setDraft(value), [value]);
19767
20796
  return /* @__PURE__ */ jsxs11(
19768
20797
  "div",
19769
20798
  {
@@ -19852,7 +20881,7 @@ var HTTP_URL_RE = /^https?:\/\/\S+$/i;
19852
20881
  function LinkInput({ value, onCommit }) {
19853
20882
  const [draft, setDraft] = useState8(value);
19854
20883
  const [invalid, setInvalid] = useState8(false);
19855
- useEffect9(() => {
20884
+ useEffect10(() => {
19856
20885
  setDraft(value);
19857
20886
  setInvalid(false);
19858
20887
  }, [value]);
@@ -20047,7 +21076,7 @@ function AiMediaStripOverlay({
20047
21076
  const [error, setError] = useState8(null);
20048
21077
  const activeRef = useRef5(null);
20049
21078
  activeRef.current = active;
20050
- useEffect9(() => {
21079
+ useEffect10(() => {
20051
21080
  const onMove = (e) => {
20052
21081
  const t = e.target;
20053
21082
  if (!(t instanceof HTMLElement)) return;
@@ -20077,7 +21106,7 @@ function AiMediaStripOverlay({
20077
21106
  document.documentElement.removeEventListener("mouseleave", onLeave);
20078
21107
  };
20079
21108
  }, []);
20080
- useEffect9(() => {
21109
+ useEffect10(() => {
20081
21110
  const onClick = (e) => {
20082
21111
  const current = activeRef.current;
20083
21112
  if (!current) return;
@@ -20092,7 +21121,7 @@ function AiMediaStripOverlay({
20092
21121
  document.addEventListener("click", onClick, true);
20093
21122
  return () => document.removeEventListener("click", onClick, true);
20094
21123
  }, []);
20095
- useEffect9(() => {
21124
+ useEffect10(() => {
20096
21125
  const onBlur = () => {
20097
21126
  if (!activeRef.current) return;
20098
21127
  setActive(null);
@@ -20101,7 +21130,7 @@ function AiMediaStripOverlay({
20101
21130
  window.addEventListener("blur", onBlur);
20102
21131
  return () => window.removeEventListener("blur", onBlur);
20103
21132
  }, []);
20104
- useEffect9(() => {
21133
+ useEffect10(() => {
20105
21134
  const onKeyDown = (e) => {
20106
21135
  if (e.key !== "Escape") return;
20107
21136
  if (!activeRef.current) return;
@@ -20265,7 +21294,7 @@ function AiMediaStripOverlay({
20265
21294
  }
20266
21295
 
20267
21296
  // 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";
21297
+ import { useCallback as useCallback4, useEffect as useEffect11, useLayoutEffect as useLayoutEffect4, useRef as useRef6, useState as useState9 } from "react";
20269
21298
  import { Check as Check2, ChevronDown as ChevronDown3, Minus, Plus as Plus2, Star as Star2 } from "lucide-react";
20270
21299
  import { Fragment as Fragment8, jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
20271
21300
  var PRIMARY4 = "var(--ohw-primary, #0885FE)";
@@ -20309,7 +21338,7 @@ function readGridRect(ref) {
20309
21338
  }
20310
21339
  function useLiveCardRect(ref, grid = false) {
20311
21340
  const [rect, setRect] = useState9(null);
20312
- useEffect10(() => {
21341
+ useEffect11(() => {
20313
21342
  if (!ref) {
20314
21343
  setRect(null);
20315
21344
  return;
@@ -20603,7 +21632,7 @@ function AiPricingCardOverlay({
20603
21632
  const [error, setError] = useState9(null);
20604
21633
  const activeRef = useRef6(null);
20605
21634
  activeRef.current = active;
20606
- useEffect10(() => {
21635
+ useEffect11(() => {
20607
21636
  const onMove = (e) => {
20608
21637
  const ref = cardRefFromTarget(e.target);
20609
21638
  const t = e.target;
@@ -20621,7 +21650,7 @@ function AiPricingCardOverlay({
20621
21650
  document.documentElement.removeEventListener("mouseleave", onLeave);
20622
21651
  };
20623
21652
  }, []);
20624
- useEffect10(() => {
21653
+ useEffect11(() => {
20625
21654
  const onClick = (e) => {
20626
21655
  const t = e.target;
20627
21656
  if (!(t instanceof Element)) return;
@@ -20633,7 +21662,7 @@ function AiPricingCardOverlay({
20633
21662
  document.addEventListener("click", onClick, true);
20634
21663
  return () => document.removeEventListener("click", onClick, true);
20635
21664
  }, []);
20636
- useEffect10(() => {
21665
+ useEffect11(() => {
20637
21666
  const onBlur = () => {
20638
21667
  if (!activeRef.current) return;
20639
21668
  setActive(null);
@@ -20642,7 +21671,7 @@ function AiPricingCardOverlay({
20642
21671
  window.addEventListener("blur", onBlur);
20643
21672
  return () => window.removeEventListener("blur", onBlur);
20644
21673
  }, []);
20645
- useEffect10(() => {
21674
+ useEffect11(() => {
20646
21675
  const onKeyDown = (e) => {
20647
21676
  if (e.key !== "Escape") return;
20648
21677
  if (!activeRef.current) return;
@@ -20747,7 +21776,7 @@ function AiPricingCardOverlay({
20747
21776
  }
20748
21777
 
20749
21778
  // src/ui/ai-section/AiVideoOverlay.tsx
20750
- import { useCallback as useCallback5, useEffect as useEffect11, useRef as useRef7, useState as useState10 } from "react";
21779
+ import { useCallback as useCallback5, useEffect as useEffect12, useRef as useRef7, useState as useState10 } from "react";
20751
21780
  import { Star as Star3 } from "lucide-react";
20752
21781
 
20753
21782
  // src/lib/ai-video-tree.ts
@@ -20813,7 +21842,7 @@ function readRect4(ref) {
20813
21842
  }
20814
21843
  function useLiveBlockRect(ref) {
20815
21844
  const [rect, setRect] = useState10(null);
20816
- useEffect11(() => {
21845
+ useEffect12(() => {
20817
21846
  if (!ref) {
20818
21847
  setRect(null);
20819
21848
  return;
@@ -20893,7 +21922,7 @@ function watchUrl(id) {
20893
21922
  function VideoUrlInput({ value, onCommit }) {
20894
21923
  const [draft, setDraft] = useState10(value ? watchUrl(value) : "");
20895
21924
  const [invalid, setInvalid] = useState10(false);
20896
- useEffect11(() => {
21925
+ useEffect12(() => {
20897
21926
  setDraft(value ? watchUrl(value) : "");
20898
21927
  setInvalid(false);
20899
21928
  }, [value]);
@@ -21036,7 +22065,7 @@ function AiVideoOverlay({
21036
22065
  const [error, setError] = useState10(null);
21037
22066
  const activeRef = useRef7(null);
21038
22067
  activeRef.current = active;
21039
- useEffect11(() => {
22068
+ useEffect12(() => {
21040
22069
  const onMove = (e) => {
21041
22070
  const t = e.target;
21042
22071
  if (!(t instanceof HTMLElement)) return;
@@ -21066,7 +22095,7 @@ function AiVideoOverlay({
21066
22095
  document.documentElement.removeEventListener("mouseleave", onLeave);
21067
22096
  };
21068
22097
  }, []);
21069
- useEffect11(() => {
22098
+ useEffect12(() => {
21070
22099
  const onClick = (e) => {
21071
22100
  const current = activeRef.current;
21072
22101
  if (!current) return;
@@ -21081,7 +22110,7 @@ function AiVideoOverlay({
21081
22110
  document.addEventListener("click", onClick, true);
21082
22111
  return () => document.removeEventListener("click", onClick, true);
21083
22112
  }, []);
21084
- useEffect11(() => {
22113
+ useEffect12(() => {
21085
22114
  const onBlur = () => {
21086
22115
  if (!activeRef.current) return;
21087
22116
  setActive(null);
@@ -21090,7 +22119,7 @@ function AiVideoOverlay({
21090
22119
  window.addEventListener("blur", onBlur);
21091
22120
  return () => window.removeEventListener("blur", onBlur);
21092
22121
  }, []);
21093
- useEffect11(() => {
22122
+ useEffect12(() => {
21094
22123
  const onKeyDown = (e) => {
21095
22124
  if (e.key !== "Escape") return;
21096
22125
  if (!activeRef.current) return;
@@ -21199,7 +22228,7 @@ function AiVideoOverlay({
21199
22228
  }
21200
22229
 
21201
22230
  // src/ui/ai-section/AiFadeCarouselOverlay.tsx
21202
- import { useCallback as useCallback6, useEffect as useEffect12, useRef as useRef8, useState as useState11 } from "react";
22231
+ import { useCallback as useCallback6, useEffect as useEffect13, useRef as useRef8, useState as useState11 } from "react";
21203
22232
  import { Star as Star4 } from "lucide-react";
21204
22233
 
21205
22234
  // src/lib/ai-carousel-tree.ts
@@ -21273,7 +22302,7 @@ function readRect5(ref) {
21273
22302
  }
21274
22303
  function useLiveItemRect2(ref) {
21275
22304
  const [rect, setRect] = useState11(null);
21276
- useEffect12(() => {
22305
+ useEffect13(() => {
21277
22306
  if (!ref) {
21278
22307
  setRect(null);
21279
22308
  return;
@@ -21489,10 +22518,10 @@ function AiFadeCarouselOverlay({
21489
22518
  const skeletonRef = useRef8(null);
21490
22519
  const activeRef = useRef8(null);
21491
22520
  activeRef.current = active;
21492
- useEffect12(() => {
22521
+ useEffect13(() => {
21493
22522
  setAutoplayOverride(null);
21494
22523
  }, [active?.sectionId, active?.index]);
21495
- useEffect12(() => {
22524
+ useEffect13(() => {
21496
22525
  if (!swapping?.fadingOut || !skeletonRef.current) return;
21497
22526
  const anim = skeletonRef.current.animate([{ opacity: 1 }, { opacity: 0 }], {
21498
22527
  duration: MEDIA_UPLOAD_FADE_MS,
@@ -21502,7 +22531,7 @@ function AiFadeCarouselOverlay({
21502
22531
  anim.finished.then(() => setSwapping(null)).catch(() => setSwapping(null));
21503
22532
  return () => anim.cancel();
21504
22533
  }, [swapping?.fadingOut]);
21505
- useEffect12(() => {
22534
+ useEffect13(() => {
21506
22535
  const onMove = (e) => {
21507
22536
  const t = e.target;
21508
22537
  if (!(t instanceof Element)) return;
@@ -21536,7 +22565,7 @@ function AiFadeCarouselOverlay({
21536
22565
  document.documentElement.removeEventListener("mouseleave", onLeave);
21537
22566
  };
21538
22567
  }, []);
21539
- useEffect12(() => {
22568
+ useEffect13(() => {
21540
22569
  const onClick = (e) => {
21541
22570
  const current = activeRef.current;
21542
22571
  if (!current) return;
@@ -21551,7 +22580,7 @@ function AiFadeCarouselOverlay({
21551
22580
  document.addEventListener("click", onClick, true);
21552
22581
  return () => document.removeEventListener("click", onClick, true);
21553
22582
  }, []);
21554
- useEffect12(() => {
22583
+ useEffect13(() => {
21555
22584
  const onBlur = () => {
21556
22585
  if (!activeRef.current) return;
21557
22586
  setActive(null);
@@ -21560,7 +22589,7 @@ function AiFadeCarouselOverlay({
21560
22589
  window.addEventListener("blur", onBlur);
21561
22590
  return () => window.removeEventListener("blur", onBlur);
21562
22591
  }, []);
21563
- useEffect12(() => {
22592
+ useEffect13(() => {
21564
22593
  const onKeyDown = (e) => {
21565
22594
  if (e.key !== "Escape") return;
21566
22595
  if (!activeRef.current) return;
@@ -21716,6 +22745,51 @@ function AiFadeCarouselOverlay({
21716
22745
  import { createPortal as createPortal3 } from "react-dom";
21717
22746
  import { usePathname as usePathname3, useRouter as useRouter3, useSearchParams } from "next/navigation";
21718
22747
 
22748
+ // src/lib/seeable.ts
22749
+ var MIN_SEEN_OPACITY = 0.05;
22750
+ function isSeeable(el) {
22751
+ const view = el.ownerDocument?.defaultView;
22752
+ if (!view) return true;
22753
+ for (let node = el; node && node !== el.ownerDocument.documentElement; node = node.parentElement) {
22754
+ const style = view.getComputedStyle(node);
22755
+ if (style.display === "none" || style.visibility === "hidden") return false;
22756
+ const opacity = parseFloat(style.opacity);
22757
+ if (Number.isFinite(opacity) && opacity < MIN_SEEN_OPACITY) return false;
22758
+ }
22759
+ return true;
22760
+ }
22761
+ function shownAs(el) {
22762
+ if (isSeeable(el)) return el;
22763
+ const key = el.getAttribute("data-ohw-key");
22764
+ if (!key) return null;
22765
+ const twin = Array.from(el.ownerDocument.querySelectorAll("[data-ohw-key]")).find(
22766
+ (other) => other !== el && other.getAttribute("data-ohw-key") === key && isSeeable(other)
22767
+ );
22768
+ return twin ?? null;
22769
+ }
22770
+ function hitsShown(el, x, y) {
22771
+ const shown = shownAs(el);
22772
+ if (!shown) return false;
22773
+ const r2 = shown.getBoundingClientRect();
22774
+ return x >= r2.left && x <= r2.right && y >= r2.top && y <= r2.bottom;
22775
+ }
22776
+ function findHiddenTwinAt(selector, x, y) {
22777
+ return Array.from(document.querySelectorAll(selector)).find(
22778
+ (el) => !isSeeable(el) && hitsShown(el, x, y)
22779
+ ) ?? null;
22780
+ }
22781
+ function stateCardFor(el, x, y) {
22782
+ const own = el.closest("[data-ohw-editable-state]");
22783
+ if (own) return own;
22784
+ return Array.from(document.querySelectorAll("[data-ohw-editable-state]")).find((card) => {
22785
+ const r2 = card.getBoundingClientRect();
22786
+ return x >= r2.left && x <= r2.right && y >= r2.top && y <= r2.bottom;
22787
+ }) ?? null;
22788
+ }
22789
+ function hoverFrame(el) {
22790
+ return shownAs(el) ?? el;
22791
+ }
22792
+
21719
22793
  // src/lib/media-overlay-guards.ts
21720
22794
  var BRIDGE_CHROME_SELECTOR = [
21721
22795
  "[data-ohw-toolbar]",
@@ -21756,7 +22830,9 @@ function findButtonAtPoint(x, y, media) {
21756
22830
  // markup, so the bbox sweep that makes real CTAs win over a full-bleed hero image
21757
22831
  // (OHH-798) claimed them too and drew the editable-item hover frame around a control
21758
22832
  // that isn't content. They move the slideshow; there is nothing there to edit.
21759
- !el.closest("[data-ohw-carousel-control]")
22833
+ !el.closest("[data-ohw-carousel-control]") && // Faded out but still laid out: rebound's instructor card keeps BOOK NOW in an opacity-0
22834
+ // hover panel, so the Default view framed (and clicked) a button nobody can see.
22835
+ isSeeable(el)
21760
22836
  );
21761
22837
  if (hits.length === 0) return null;
21762
22838
  return hits.reduce((best, el) => best.contains(el) ? el : best);
@@ -21857,7 +22933,7 @@ function mergePrefetchedSections(prev, fetched, livePath, liveSections) {
21857
22933
  }
21858
22934
 
21859
22935
  // src/ui/link-modal/LinkPopover.tsx
21860
- import { useEffect as useEffect16 } from "react";
22936
+ import { useEffect as useEffect17 } from "react";
21861
22937
 
21862
22938
  // src/ui/dialog.tsx
21863
22939
  import * as React9 from "react";
@@ -22057,7 +23133,7 @@ function SectionTreeItem({
22057
23133
  }
22058
23134
 
22059
23135
  // src/ui/link-modal/UrlOrPageInput.tsx
22060
- import { useEffect as useEffect13, useId as useId2, useRef as useRef9, useState as useState12 } from "react";
23136
+ import { useEffect as useEffect14, useId as useId2, useRef as useRef9, useState as useState12 } from "react";
22061
23137
 
22062
23138
  // src/ui/input.tsx
22063
23139
  import * as React10 from "react";
@@ -22129,7 +23205,7 @@ function UrlOrPageInput({
22129
23205
  const inputRef = useRef9(null);
22130
23206
  const rootRef = useRef9(null);
22131
23207
  const [isFocused, setIsFocused] = useState12(false);
22132
- useEffect13(() => {
23208
+ useEffect14(() => {
22133
23209
  if (!dropdownOpen) return;
22134
23210
  const isOutside = (e) => {
22135
23211
  const root = rootRef.current;
@@ -22337,7 +23413,7 @@ function LinkEditorPanel({ state, onClose }) {
22337
23413
  }
22338
23414
 
22339
23415
  // 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";
23416
+ import { useCallback as useCallback7, useEffect as useEffect15, useMemo as useMemo2, useRef as useRef10, useState as useState13 } from "react";
22341
23417
  import { createPortal as createPortal2 } from "react-dom";
22342
23418
  import { ArrowLeft as ArrowLeft2, Check as Check3 } from "lucide-react";
22343
23419
  import { usePathname as usePathname2, useRouter as useRouter2 } from "next/navigation";
@@ -22399,7 +23475,7 @@ function useSectionRects(sectionIdsKey, enabled) {
22399
23475
  () => sectionIdsKey ? sectionIdsKey.split("\0") : [],
22400
23476
  [sectionIdsKey]
22401
23477
  );
22402
- useEffect14(() => {
23478
+ useEffect15(() => {
22403
23479
  if (!enabled || sectionIds.length === 0) {
22404
23480
  setRects((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Map());
22405
23481
  return;
@@ -22454,12 +23530,12 @@ function SectionPickerOverlay({
22454
23530
  );
22455
23531
  const normalizedTarget = normalizePath(pagePath);
22456
23532
  const isOnTargetPage = normalizePath(pathname) === normalizedTarget;
22457
- useEffect14(() => {
23533
+ useEffect15(() => {
22458
23534
  if (isOnTargetPage) return;
22459
23535
  const search = readPreservedSearch();
22460
23536
  router.push(`${normalizedTarget}${search}`);
22461
23537
  }, [isOnTargetPage, normalizedTarget, router]);
22462
- useEffect14(() => {
23538
+ useEffect15(() => {
22463
23539
  document.documentElement.setAttribute("data-ohw-section-picking", "");
22464
23540
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => {
22465
23541
  el.removeAttribute("data-ohw-hovered");
@@ -22497,7 +23573,7 @@ function SectionPickerOverlay({
22497
23573
  },
22498
23574
  []
22499
23575
  );
22500
- useEffect14(() => {
23576
+ useEffect15(() => {
22501
23577
  const applyClip = (iframeOffsetTop, visibleCanvasTop, canvasH, promptBarH = 0) => {
22502
23578
  const next = getIframeVisibleClip({
22503
23579
  iframeOffsetTop,
@@ -22541,12 +23617,12 @@ function SectionPickerOverlay({
22541
23617
  window.removeEventListener("resize", onResize);
22542
23618
  };
22543
23619
  }, [applyHoverAt]);
22544
- useEffect14(() => {
23620
+ useEffect15(() => {
22545
23621
  const ptr = pointerRef.current;
22546
23622
  if (!ptr) return;
22547
23623
  applyHoverAt(ptr.x, ptr.y, rects);
22548
23624
  }, [rects, applyHoverAt]);
22549
- useEffect14(() => {
23625
+ useEffect15(() => {
22550
23626
  const rememberPointer = (clientX, clientY) => {
22551
23627
  pointerRef.current = { x: clientX, y: clientY };
22552
23628
  const top = iframeOffsetTopRef.current;
@@ -22578,7 +23654,7 @@ function SectionPickerOverlay({
22578
23654
  },
22579
23655
  [selectedId, onSelect]
22580
23656
  );
22581
- useEffect14(() => {
23657
+ useEffect15(() => {
22582
23658
  const onKeyDown = (e) => {
22583
23659
  if (e.key === "Escape") {
22584
23660
  e.preventDefault();
@@ -22701,7 +23777,7 @@ function SectionPickerOverlay({
22701
23777
  }
22702
23778
 
22703
23779
  // src/ui/link-modal/useLinkModalState.ts
22704
- import { useCallback as useCallback8, useEffect as useEffect15, useMemo as useMemo3, useState as useState14 } from "react";
23780
+ import { useCallback as useCallback8, useEffect as useEffect16, useMemo as useMemo3, useState as useState14 } from "react";
22705
23781
  function useLinkModalState({
22706
23782
  open,
22707
23783
  mode,
@@ -22728,7 +23804,7 @@ function useLinkModalState({
22728
23804
  setDropdownOpen(false);
22729
23805
  setUrlError("");
22730
23806
  }, []);
22731
- useEffect15(() => {
23807
+ useEffect16(() => {
22732
23808
  if (!open) return;
22733
23809
  if (mode === "edit" && initialTarget) {
22734
23810
  const { pageRoute } = parseTarget(initialTarget);
@@ -22894,7 +23970,7 @@ function LinkPopover({
22894
23970
  onSubmit
22895
23971
  });
22896
23972
  const sectionPickerActive = state.showSectionPicker && Boolean(state.selectedPage);
22897
- useEffect16(() => {
23973
+ useEffect17(() => {
22898
23974
  if (!open) return;
22899
23975
  if (sectionPickerActive) {
22900
23976
  postToParent({ type: "ui:unlock" });
@@ -23137,7 +24213,7 @@ function addFooterColumnWithPersist({
23137
24213
  // src/ui/FloatingPanel.tsx
23138
24214
  import {
23139
24215
  useCallback as useCallback9,
23140
- useEffect as useEffect17,
24216
+ useEffect as useEffect18,
23141
24217
  useLayoutEffect as useLayoutEffect5,
23142
24218
  useRef as useRef11,
23143
24219
  useState as useState15
@@ -23221,10 +24297,10 @@ function FloatingPanel({
23221
24297
  x: clampX(home.x, measured.w),
23222
24298
  y: fittedY
23223
24299
  };
23224
- useEffect17(() => {
24300
+ useEffect18(() => {
23225
24301
  setLiveScroll(parentScroll);
23226
24302
  }, [parentScroll]);
23227
- useEffect17(() => {
24303
+ useEffect18(() => {
23228
24304
  if (!open) return;
23229
24305
  const onParentScroll = (e) => {
23230
24306
  if (e.data?.type !== "ow:parent-scroll") return;
@@ -23309,11 +24385,11 @@ function FloatingPanel({
23309
24385
  } catch {
23310
24386
  }
23311
24387
  }, []);
23312
- useEffect17(() => {
24388
+ useEffect18(() => {
23313
24389
  if (open) return;
23314
24390
  document.documentElement.removeAttribute("data-ohw-panel-dragging");
23315
24391
  }, [open]);
23316
- useEffect17(() => () => document.documentElement.removeAttribute("data-ohw-panel-dragging"), []);
24392
+ useEffect18(() => () => document.documentElement.removeAttribute("data-ohw-panel-dragging"), []);
23317
24393
  if (!open) return null;
23318
24394
  return /* @__PURE__ */ jsxs22(
23319
24395
  "div",
@@ -23833,7 +24909,7 @@ function hitTestNavDropSlot(clientX, clientY, draggedHrefKey, draggedEl) {
23833
24909
  }
23834
24910
 
23835
24911
  // src/useNavItemDrag.ts
23836
- import { useCallback as useCallback10, useEffect as useEffect18, useRef as useRef12, useState as useState16 } from "react";
24912
+ import { useCallback as useCallback10, useEffect as useEffect19, useRef as useRef12, useState as useState16 } from "react";
23837
24913
  function useNavItemDrag({
23838
24914
  isEditMode,
23839
24915
  editContentRef,
@@ -24066,7 +25142,7 @@ function useNavItemDrag({
24066
25142
  },
24067
25143
  []
24068
25144
  );
24069
- useEffect18(() => {
25145
+ useEffect19(() => {
24070
25146
  if (!isEditMode) return;
24071
25147
  const THRESHOLD = 10;
24072
25148
  const resolveWasSelected = (el) => {
@@ -24225,7 +25301,7 @@ function useNavItemDrag({
24225
25301
  }
24226
25302
 
24227
25303
  // src/useSectionDrag.ts
24228
- import { useCallback as useCallback11, useEffect as useEffect19, useRef as useRef13, useState as useState17 } from "react";
25304
+ import { useCallback as useCallback11, useEffect as useEffect20, useRef as useRef13, useState as useState17 } from "react";
24229
25305
 
24230
25306
  // src/lib/section-dnd.ts
24231
25307
  function isFooterSection(el) {
@@ -24452,7 +25528,7 @@ function useSectionDrag({
24452
25528
  },
24453
25529
  [footerDragRef, navDragRef]
24454
25530
  );
24455
- useEffect19(() => {
25531
+ useEffect20(() => {
24456
25532
  if (!isEditMode) return;
24457
25533
  const onPointerDown = (e) => {
24458
25534
  if (e.button !== 0) return;
@@ -24777,7 +25853,7 @@ function deleteSelectedNavFooterItem(deps) {
24777
25853
  }
24778
25854
 
24779
25855
  // src/lib/build-page-sync.ts
24780
- import { useEffect as useEffect20 } from "react";
25856
+ import { useEffect as useEffect21 } from "react";
24781
25857
  var CHROME_KEY_RE = /^(nav|footer|header|navbar)[-_]/u;
24782
25858
  function normalisePath(path) {
24783
25859
  const trimmed = path.trim().replace(/[?#].*$/u, "");
@@ -24842,12 +25918,12 @@ function collectLinks() {
24842
25918
  document.querySelectorAll("[data-ohw-href-key]").forEach((el) => {
24843
25919
  const hrefKey = el.getAttribute("data-ohw-href-key") ?? "";
24844
25920
  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;
25921
+ const area2 = isNavbarHrefKey(hrefKey) ? "nav" : isFooterHrefKey(hrefKey) ? "footer" : CHROME_KEY_RE.test(hrefKey) ? "chrome" : null;
25922
+ if (!area2) return;
24847
25923
  const label = labelEl(el);
24848
- if (!label && area !== "chrome") return;
25924
+ if (!label && area2 !== "chrome") return;
24849
25925
  seen.add(hrefKey);
24850
- links.push({ hrefKey, href: linkHref(el), label: label?.textContent ?? el.textContent ?? "", area });
25926
+ links.push({ hrefKey, href: linkHref(el), label: label?.textContent ?? el.textContent ?? "", area: area2 });
24851
25927
  });
24852
25928
  return links;
24853
25929
  }
@@ -24890,7 +25966,7 @@ function applyBuildPageSync(msg, deps) {
24890
25966
  return plan.remove.length + plan.relabel.length + plan.retarget.length;
24891
25967
  }
24892
25968
  function useBuildPageSync(isEditMode, editContentRef, postToParent2) {
24893
- useEffect20(() => {
25969
+ useEffect21(() => {
24894
25970
  if (!isEditMode) return;
24895
25971
  const onMessage = (e) => {
24896
25972
  if (e.source !== window.parent || e.data?.type !== "ow:pages-sync") return;
@@ -26637,7 +27713,7 @@ function OhhwellsBridge() {
26637
27713
  const searchParams = useSearchParams();
26638
27714
  const isEditMode = isEditSessionActive();
26639
27715
  const [bridgeRoot, setBridgeRoot] = useState18(null);
26640
- useEffect21(() => {
27716
+ useEffect22(() => {
26641
27717
  const figtreeFontId = "ohw-figtree-font";
26642
27718
  if (!document.getElementById(figtreeFontId)) {
26643
27719
  const preconnect1 = Object.assign(document.createElement("link"), { rel: "preconnect", href: "https://fonts.googleapis.com" });
@@ -26676,7 +27752,7 @@ function OhhwellsBridge() {
26676
27752
  }, 0);
26677
27753
  return () => window.clearTimeout(t);
26678
27754
  }, [subdomainFromQuery, subdomain]);
26679
- useEffect21(() => {
27755
+ useEffect22(() => {
26680
27756
  if (!subdomainFromQuery || typeof window === "undefined") return;
26681
27757
  const url = new URL(window.location.href);
26682
27758
  if (!url.searchParams.has("subdomain")) return;
@@ -26687,6 +27763,7 @@ function OhhwellsBridge() {
26687
27763
  useLinkHrefGuardian(pathname, subdomain, isEditMode);
26688
27764
  useSavedLinkNavigation(isEditMode);
26689
27765
  useNavDropdownToggle(isEditMode);
27766
+ useBackgroundTone();
26690
27767
  useHashLinkScroll(isEditMode);
26691
27768
  usePublishedPlaceholderStrip(isEditMode);
26692
27769
  const postToParent2 = useCallback12((data) => {
@@ -26697,14 +27774,14 @@ function OhhwellsBridge() {
26697
27774
  const [fetchState, setFetchState] = useState18("idle");
26698
27775
  const [showBranding, setShowBranding] = useState18(false);
26699
27776
  const autoSaveTimers = useRef14(/* @__PURE__ */ new Map());
26700
- useEffect21(() => {
27777
+ useEffect22(() => {
26701
27778
  stampBridgeVersionOnDocument();
26702
27779
  }, []);
26703
- useEffect21(() => {
27780
+ useEffect22(() => {
26704
27781
  if (isEditMode) return;
26705
27782
  return armLoaderHangBeacon(subdomain, fetchState);
26706
27783
  }, [isEditMode, subdomain, fetchState]);
26707
- useEffect21(() => {
27784
+ useEffect22(() => {
26708
27785
  if (isEditMode || !subdomain) return;
26709
27786
  const onError = (event) => {
26710
27787
  reportOutageBeacon({
@@ -26845,7 +27922,7 @@ function OhhwellsBridge() {
26845
27922
  }, []);
26846
27923
  const selectMediaElementRef = useRef14(selectMediaElement);
26847
27924
  selectMediaElementRef.current = selectMediaElement;
26848
- useEffect21(() => {
27925
+ useEffect22(() => {
26849
27926
  if (!selectedMedia) return;
26850
27927
  const update = () => {
26851
27928
  const el = selectedMediaElRef.current;
@@ -26873,6 +27950,8 @@ function OhhwellsBridge() {
26873
27950
  const editStylesRef = useRef14(null);
26874
27951
  const activateRef = useRef14(() => {
26875
27952
  });
27953
+ const stateChangeRef = useRef14(() => {
27954
+ });
26876
27955
  const deactivateRef = useRef14(() => {
26877
27956
  });
26878
27957
  const selectRef = useRef14(() => {
@@ -27060,7 +28139,7 @@ function OhhwellsBridge() {
27060
28139
  const [fieldDragging, setFieldDragging] = useState18(false);
27061
28140
  const clearFormPickRef = useRef14(clearFormPick);
27062
28141
  clearFormPickRef.current = clearFormPick;
27063
- useEffect21(() => {
28142
+ useEffect22(() => {
27064
28143
  const el = fieldPickElRef.current;
27065
28144
  if (!el || fieldPickRect === null) return;
27066
28145
  const observer = new ResizeObserver(() => {
@@ -27069,7 +28148,7 @@ function OhhwellsBridge() {
27069
28148
  observer.observe(el);
27070
28149
  return () => observer.disconnect();
27071
28150
  }, [fieldPickRect !== null, fieldPickState]);
27072
- useEffect21(() => {
28151
+ useEffect22(() => {
27073
28152
  const el = formPickElRef.current;
27074
28153
  if (!el || formPickRect === null) return;
27075
28154
  const observer = new ResizeObserver(() => {
@@ -27098,7 +28177,7 @@ function OhhwellsBridge() {
27098
28177
  const hoveredItemElRef = useRef14(null);
27099
28178
  const [hoveredItemRect, setHoveredItemRect] = useState18(null);
27100
28179
  const [hoveredTextRect, setHoveredTextRect] = useState18(null);
27101
- useEffect21(() => {
28180
+ useEffect22(() => {
27102
28181
  const sync = () => {
27103
28182
  const el = document.querySelector(
27104
28183
  '[data-ohw-hovered]:not([contenteditable]):not([data-ohw-href-key]):not([data-ohw-editable="form"] *)'
@@ -27199,7 +28278,7 @@ function OhhwellsBridge() {
27199
28278
  const linkPopoverGraceUntilRef = useRef14(0);
27200
28279
  setLinkPopoverRef.current = setLinkPopover;
27201
28280
  linkPopoverSessionRef.current = linkPopover;
27202
- useEffect21(() => {
28281
+ useEffect22(() => {
27203
28282
  setSectionOrderPersistHandler((entries) => {
27204
28283
  const currentPath = window.location.pathname;
27205
28284
  const merged = mergePageSectionOrder(editContentRef.current[SECTION_ORDER_KEY], currentPath, entries);
@@ -27209,7 +28288,7 @@ function OhhwellsBridge() {
27209
28288
  });
27210
28289
  return () => setSectionOrderPersistHandler(null);
27211
28290
  }, []);
27212
- useEffect21(() => {
28291
+ useEffect22(() => {
27213
28292
  setAiFooterMountOptions({
27214
28293
  resolvePageHref: (pageOrAnchorId) => {
27215
28294
  const [pageId, anchor] = pageOrAnchorId.split("#");
@@ -27293,7 +28372,7 @@ function OhhwellsBridge() {
27293
28372
  }, [isEditMode, pathname]);
27294
28373
  const runSectionsPrefetchRef = useRef14(runSectionsPrefetch);
27295
28374
  runSectionsPrefetchRef.current = runSectionsPrefetch;
27296
- useEffect21(() => {
28375
+ useEffect22(() => {
27297
28376
  if (!linkPopover) {
27298
28377
  document.documentElement.removeAttribute("data-ohw-link-popover-open");
27299
28378
  return;
@@ -27321,7 +28400,7 @@ function OhhwellsBridge() {
27321
28400
  document.documentElement.removeAttribute("data-ohw-link-popover-open");
27322
28401
  };
27323
28402
  }, [linkPopover, postToParent2]);
27324
- useEffect21(() => {
28403
+ useEffect22(() => {
27325
28404
  if (!isEditMode) return;
27326
28405
  const useFixtures = shouldUseDevFixtures();
27327
28406
  if (useFixtures) {
@@ -27347,7 +28426,7 @@ function OhhwellsBridge() {
27347
28426
  if (!useFixtures) postToParent2({ type: "ow:request-site-pages" });
27348
28427
  return () => window.removeEventListener("message", onSitePages);
27349
28428
  }, [isEditMode, postToParent2]);
27350
- useEffect21(() => {
28429
+ useEffect22(() => {
27351
28430
  if (!isEditMode) return;
27352
28431
  const deps = {
27353
28432
  getEditContent: () => editContentRef.current,
@@ -27384,14 +28463,14 @@ function OhhwellsBridge() {
27384
28463
  window.addEventListener("message", onPageMessage);
27385
28464
  return () => window.removeEventListener("message", onPageMessage);
27386
28465
  }, [isEditMode, postToParent2]);
27387
- useEffect21(() => {
28466
+ useEffect22(() => {
27388
28467
  if (!isEditMode || shouldUseDevFixtures()) return;
27389
28468
  void loadAllSectionsManifest().then((manifest) => {
27390
28469
  if (Object.keys(manifest).length === 0) return;
27391
28470
  setSectionsByPath((prev) => ({ ...manifest, ...prev }));
27392
28471
  });
27393
28472
  }, [isEditMode]);
27394
- useEffect21(() => {
28473
+ useEffect22(() => {
27395
28474
  const update = () => {
27396
28475
  const el = activeElRef.current ?? selectedElRef.current;
27397
28476
  if (el) setToolbarRect(getEditMeasureEl(el).getBoundingClientRect());
@@ -28652,7 +29731,7 @@ function OhhwellsBridge() {
28652
29731
  },
28653
29732
  [postToParent2]
28654
29733
  );
28655
- useEffect21(() => {
29734
+ useEffect22(() => {
28656
29735
  const onDragOver = (e) => {
28657
29736
  const dragged = buttonCollectionDragRef.current;
28658
29737
  if (!dragged) return;
@@ -28723,7 +29802,7 @@ function OhhwellsBridge() {
28723
29802
  setLogoSizeDraft(null);
28724
29803
  deselectRef.current();
28725
29804
  }, []);
28726
- useEffect21(() => {
29805
+ useEffect22(() => {
28727
29806
  const session = floatingPanel && floatingPanel.kind === "logo-size" ? floatingPanel : null;
28728
29807
  if (!session || !logoSizeDraft) {
28729
29808
  postToParentRef.current({ type: "ow:logo-size-panel", open: false });
@@ -28888,7 +29967,7 @@ function OhhwellsBridge() {
28888
29967
  deselectRef.current = deselect;
28889
29968
  closeFloatingPanelOnlyRef.current = closeFloatingPanelOnly;
28890
29969
  const lastSiteWideScopeRef = useRef14(null);
28891
- useEffect21(() => {
29970
+ useEffect22(() => {
28892
29971
  if (!isEditMode) {
28893
29972
  if (lastSiteWideScopeRef.current !== false) {
28894
29973
  lastSiteWideScopeRef.current = false;
@@ -29069,7 +30148,7 @@ function OhhwellsBridge() {
29069
30148
  cancelled = true;
29070
30149
  };
29071
30150
  }, [subdomain, isEditMode]);
29072
- useEffect21(() => {
30151
+ useEffect22(() => {
29073
30152
  if (!isEditMode) return;
29074
30153
  const resolveIndex = (form, clientY) => {
29075
30154
  const wrappers = listFieldWrappers(form).filter((el) => fieldKeyOf(el) !== fieldDragRef.current?.key);
@@ -29110,7 +30189,7 @@ function OhhwellsBridge() {
29110
30189
  window.removeEventListener("drop", onDrop, true);
29111
30190
  };
29112
30191
  }, [buildFieldDropSlots, isEditMode, persistFields, selectField]);
29113
- useEffect21(() => {
30192
+ useEffect22(() => {
29114
30193
  if (!isEditMode) return;
29115
30194
  const mark = () => document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
29116
30195
  markFormFields(form);
@@ -29122,7 +30201,7 @@ function OhhwellsBridge() {
29122
30201
  });
29123
30202
  return () => observer.disconnect();
29124
30203
  }, [isEditMode, fetchState, pathname]);
29125
- useEffect21(() => {
30204
+ useEffect22(() => {
29126
30205
  if (!isEditMode) return;
29127
30206
  let saveTimer = null;
29128
30207
  const onInput = (e) => {
@@ -29144,14 +30223,14 @@ function OhhwellsBridge() {
29144
30223
  document.addEventListener("input", onInput, true);
29145
30224
  return () => document.removeEventListener("input", onInput, true);
29146
30225
  }, [isEditMode, persistFields]);
29147
- useEffect21(() => {
30226
+ useEffect22(() => {
29148
30227
  if (isEditMode || fetchState !== "done") return;
29149
30228
  const content = contentCache.get(subdomain) ?? {};
29150
30229
  document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
29151
30230
  reconcileFieldsFromContent(form, content);
29152
30231
  });
29153
30232
  }, [isEditMode, fetchState, subdomain]);
29154
- useEffect21(() => {
30233
+ useEffect22(() => {
29155
30234
  if (!isEditMode) return;
29156
30235
  const swallow = (e) => {
29157
30236
  const target = e.target;
@@ -29160,14 +30239,14 @@ function OhhwellsBridge() {
29160
30239
  document.addEventListener("submit", swallow, true);
29161
30240
  return () => document.removeEventListener("submit", swallow, true);
29162
30241
  }, [isEditMode]);
29163
- useEffect21(() => {
30242
+ useEffect22(() => {
29164
30243
  if (isEditMode || fetchState !== "done") return;
29165
30244
  console.log("env", process.env.NEXT_PUBLIC_FLOWOPS_API_URL);
29166
30245
  const apiUrl = process.env.NEXT_PUBLIC_FLOWOPS_API_URL ?? "https://flowops-backend-staging-2yfdh7pwpq-as.a.run.app";
29167
30246
  console.log({ apiUrl, subdomain });
29168
30247
  bindPublishedForms(apiUrl, subdomain, contentCache.get(subdomain) ?? {});
29169
30248
  }, [isEditMode, fetchState, subdomain]);
29170
- useEffect21(() => {
30249
+ useEffect22(() => {
29171
30250
  if (!subdomain || isEditMode) return;
29172
30251
  let debounceTimer = null;
29173
30252
  let observer = null;
@@ -29294,10 +30373,10 @@ function OhhwellsBridge() {
29294
30373
  const visible = Boolean(subdomain) && fetchState !== "done";
29295
30374
  el.style.display = visible ? "flex" : "none";
29296
30375
  }, [subdomain, fetchState]);
29297
- useEffect21(() => {
30376
+ useEffect22(() => {
29298
30377
  postToParent2({ type: "ow:navigation", path: pathname });
29299
30378
  }, [pathname, postToParent2]);
29300
- useEffect21(() => {
30379
+ useEffect22(() => {
29301
30380
  if (!subdomain || isEditMode) return;
29302
30381
  const content = contentCache.get(subdomain);
29303
30382
  if (!content) return;
@@ -29315,7 +30394,7 @@ function OhhwellsBridge() {
29315
30394
  }
29316
30395
  applyAiFooterFromContent(content);
29317
30396
  }, [pathname, subdomain, isEditMode]);
29318
- useEffect21(() => {
30397
+ useEffect22(() => {
29319
30398
  if (!isEditMode) return;
29320
30399
  if (linkPopoverSessionRef.current?.intent === "add-nav") return;
29321
30400
  if (document.querySelector("[data-ohw-section-picker]")) return;
@@ -29323,12 +30402,12 @@ function OhhwellsBridge() {
29323
30402
  deselectRef.current();
29324
30403
  deactivateRef.current();
29325
30404
  }, [pathname, isEditMode]);
29326
- useEffect21(() => {
30405
+ useEffect22(() => {
29327
30406
  if (!isEditMode) return;
29328
30407
  initSectionInstancesFromContent(editContentRef.current, pathname);
29329
30408
  initItemInstancesFromContent(editContentRef.current);
29330
30409
  }, [pathname, isEditMode]);
29331
- useEffect21(() => {
30410
+ useEffect22(() => {
29332
30411
  if (!isEditMode) return;
29333
30412
  const observer = new MutationObserver(() => {
29334
30413
  const drawer = document.querySelector("[data-ohw-nav-drawer]");
@@ -29339,7 +30418,7 @@ function OhhwellsBridge() {
29339
30418
  observer.observe(document.body, { childList: true, subtree: true });
29340
30419
  return () => observer.disconnect();
29341
30420
  }, [isEditMode, pathname]);
29342
- useEffect21(() => {
30421
+ useEffect22(() => {
29343
30422
  const contentForNav = () => {
29344
30423
  if (isEditMode) return editContentRef.current;
29345
30424
  if (!subdomain) return {};
@@ -29413,7 +30492,7 @@ function OhhwellsBridge() {
29413
30492
  observer?.disconnect();
29414
30493
  };
29415
30494
  }, [isEditMode, pathname, subdomain, fetchState, resyncSelectedNavigationItem]);
29416
- useEffect21(() => {
30495
+ useEffect22(() => {
29417
30496
  if (!isEditMode) return;
29418
30497
  let applying = false;
29419
30498
  let rafId = null;
@@ -29451,7 +30530,7 @@ function OhhwellsBridge() {
29451
30530
  observer.disconnect();
29452
30531
  };
29453
30532
  }, [isEditMode, pathname]);
29454
- useEffect21(() => {
30533
+ useEffect22(() => {
29455
30534
  if (!isEditMode) return;
29456
30535
  let lastPosted = 0;
29457
30536
  const measure = () => {
@@ -29495,7 +30574,7 @@ function OhhwellsBridge() {
29495
30574
  window.removeEventListener("resize", handleResize);
29496
30575
  };
29497
30576
  }, [pathname, isEditMode, postToParent2]);
29498
- useEffect21(() => {
30577
+ useEffect22(() => {
29499
30578
  if (isEditMode) return;
29500
30579
  const handleClick = (e) => {
29501
30580
  if (!isPlainLeftClick(e)) return;
@@ -29509,7 +30588,7 @@ function OhhwellsBridge() {
29509
30588
  document.addEventListener("click", handleClick, true);
29510
30589
  return () => document.removeEventListener("click", handleClick, true);
29511
30590
  }, [isEditMode, router, pathname]);
29512
- useEffect21(() => {
30591
+ useEffect22(() => {
29513
30592
  if (!isEditMode) {
29514
30593
  editStylesRef.current?.base.remove();
29515
30594
  editStylesRef.current?.forceHover.remove();
@@ -29957,6 +31036,16 @@ function OhhwellsBridge() {
29957
31036
  const inner = target.closest("svg")?.querySelectorAll("[data-ohw-editable]");
29958
31037
  if (inner && inner.length === 1) editable = inner[0];
29959
31038
  }
31039
+ const hiddenTwin = !editable || isMediaEditable(editable) ? findHiddenTwinAt(NON_MEDIA_SELECTOR, e.clientX, e.clientY) : null;
31040
+ if (hiddenTwin) {
31041
+ editable = hiddenTwin;
31042
+ const card = stateCardFor(hiddenTwin, e.clientX, e.clientY);
31043
+ const hoverState = card && !card.hasAttribute("data-ohw-active-state") ? deriveStates(card.dataset.ohwEditableState ?? "")[1] : void 0;
31044
+ if (card && hoverState) {
31045
+ activeStateElRef.current = card;
31046
+ stateChangeRef.current(hoverState);
31047
+ }
31048
+ }
29960
31049
  if (editable && !(editable instanceof HTMLElement)) {
29961
31050
  e.preventDefault();
29962
31051
  e.stopPropagation();
@@ -30314,6 +31403,8 @@ function OhhwellsBridge() {
30314
31403
  if (!editable) return;
30315
31404
  const editableRect = editable.getBoundingClientRect();
30316
31405
  if (editableRect.width <= 0 || editableRect.height <= 0) return;
31406
+ const shownEditable = shownAs(editable);
31407
+ if (!shownEditable || shownEditable !== editable && !hitsShown(editable, e.clientX, e.clientY)) return;
30317
31408
  const selected = selectedElRef.current;
30318
31409
  if (selected && (selected === editable || selected.contains(editable))) return;
30319
31410
  if (!isMediaEditable(editable) && !editable.hasAttribute("contenteditable")) {
@@ -30328,7 +31419,7 @@ function OhhwellsBridge() {
30328
31419
  hoveredItemElRef.current = hoverTarget;
30329
31420
  setHoveredItemRect(hoverTarget.getBoundingClientRect());
30330
31421
  } else if (!isInsideNavigationItem(editable) && !isSelectedForHoverRef.current(hoverTarget)) {
30331
- hoverTarget.setAttribute("data-ohw-hovered", "");
31422
+ hoverFrame(hoverTarget).setAttribute("data-ohw-hovered", "");
30332
31423
  if (editable.closest("footer") || editable.closest('[data-ohw-section="footer"]')) {
30333
31424
  hoveredNavContainerRef.current = null;
30334
31425
  setHoveredNavContainerRect(null);
@@ -30790,8 +31881,7 @@ function OhhwellsBridge() {
30790
31881
  document.querySelectorAll(NON_MEDIA_SELECTOR)
30791
31882
  ).find((el) => {
30792
31883
  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;
31884
+ return hitsShown(el, x2, y2);
30795
31885
  });
30796
31886
  if (imageUnhoverTimerRef.current) {
30797
31887
  clearTimeout(imageUnhoverTimerRef.current);
@@ -30837,7 +31927,7 @@ function OhhwellsBridge() {
30837
31927
  }
30838
31928
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
30839
31929
  if (textEditable && !textEditable.closest("[data-ohw-href-key]") && !isSelectedForHoverRef.current(textEditable)) {
30840
- textEditable.setAttribute("data-ohw-hovered", "");
31930
+ hoverFrame(textEditable).setAttribute("data-ohw-hovered", "");
30841
31931
  }
30842
31932
  return;
30843
31933
  }
@@ -30849,7 +31939,7 @@ function OhhwellsBridge() {
30849
31939
  }
30850
31940
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
30851
31941
  if (textEditable && !textEditable.closest("[data-ohw-href-key]") && !isSelectedForHoverRef.current(textEditable)) {
30852
- textEditable.setAttribute("data-ohw-hovered", "");
31942
+ hoverFrame(textEditable).setAttribute("data-ohw-hovered", "");
30853
31943
  }
30854
31944
  return;
30855
31945
  }
@@ -30893,8 +31983,7 @@ function OhhwellsBridge() {
30893
31983
  ).find((el) => {
30894
31984
  if (!isNavigationItem2(el) || isCtaButton(el)) return false;
30895
31985
  if (!isNavItemPointerTarget(el)) return false;
30896
- const er = el.getBoundingClientRect();
30897
- return x2 >= er.left && x2 <= er.right && y2 >= er.top && y2 <= er.bottom;
31986
+ return hitsShown(el, x2, y2);
30898
31987
  });
30899
31988
  if (navLinkHit) {
30900
31989
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
@@ -30910,8 +31999,7 @@ function OhhwellsBridge() {
30910
31999
  document.querySelectorAll(NON_MEDIA_SELECTOR)
30911
32000
  ).find((el) => {
30912
32001
  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;
32002
+ return hitsShown(el, x2, y2);
30915
32003
  });
30916
32004
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
30917
32005
  if (textEl && !textEl.hasAttribute("contenteditable")) {
@@ -30926,7 +32014,7 @@ function OhhwellsBridge() {
30926
32014
  } else if (!textEl.closest("[data-ohw-href-key]") && !isSelectedForHoverRef.current(textEl)) {
30927
32015
  hoveredItemElRef.current = null;
30928
32016
  setHoveredItemRect(null);
30929
- textEl.setAttribute("data-ohw-hovered", "");
32017
+ hoverFrame(textEl).setAttribute("data-ohw-hovered", "");
30930
32018
  } else {
30931
32019
  hoveredItemElRef.current = null;
30932
32020
  setHoveredItemRect(null);
@@ -32807,8 +33895,7 @@ function OhhwellsBridge() {
32807
33895
  const textEditable = Array.from(
32808
33896
  document.querySelectorAll(NON_MEDIA_SELECTOR)
32809
33897
  ).find((el) => {
32810
- const r2 = el.getBoundingClientRect();
32811
- return clientX >= r2.left && clientX <= r2.right && clientY >= r2.top && clientY <= r2.bottom;
33898
+ return hitsShown(el, clientX, clientY);
32812
33899
  });
32813
33900
  if (textEditable) {
32814
33901
  const hrefCtx = getHrefKeyFromElement(textEditable);
@@ -32995,7 +34082,7 @@ function OhhwellsBridge() {
32995
34082
  if (imageShowTimerRef.current) clearTimeout(imageShowTimerRef.current);
32996
34083
  };
32997
34084
  }, [isEditMode, refreshStateRules]);
32998
- useEffect21(() => {
34085
+ useEffect22(() => {
32999
34086
  if (!isEditMode) return;
33000
34087
  const THRESHOLD = 10;
33001
34088
  const resolveWasSelected = (el) => {
@@ -33151,7 +34238,7 @@ function OhhwellsBridge() {
33151
34238
  unlockFooterDragInteraction();
33152
34239
  };
33153
34240
  }, [isEditMode]);
33154
- useEffect21(() => {
34241
+ useEffect22(() => {
33155
34242
  if (!isEditMode) return;
33156
34243
  const THRESHOLD = 10;
33157
34244
  const onPointerDown = (e) => {
@@ -33242,7 +34329,7 @@ function OhhwellsBridge() {
33242
34329
  document.removeEventListener("selectstart", blockSelectStart, true);
33243
34330
  };
33244
34331
  }, [isEditMode, persistButtonCollectionDrag, refreshButtonDragVisuals]);
33245
- useEffect21(() => {
34332
+ useEffect22(() => {
33246
34333
  const handler = (e) => {
33247
34334
  if (e.data?.type !== "ow:request-schedule-config") return;
33248
34335
  const insertAfterVal = e.data.insertAfter;
@@ -33258,7 +34345,7 @@ function OhhwellsBridge() {
33258
34345
  window.addEventListener("message", handler);
33259
34346
  return () => window.removeEventListener("message", handler);
33260
34347
  }, [processConfigRequest]);
33261
- useEffect21(() => {
34348
+ useEffect22(() => {
33262
34349
  if (!isEditMode) return;
33263
34350
  document.querySelectorAll("[data-ohw-active-state]").forEach((el) => {
33264
34351
  el.removeAttribute("data-ohw-active-state");
@@ -33282,7 +34369,7 @@ function OhhwellsBridge() {
33282
34369
  postToParent2({
33283
34370
  type: "ow:ready",
33284
34371
  version: "1",
33285
- bridgeVersion: "0.1.173",
34372
+ bridgeVersion: "0.1.174",
33286
34373
  path: pathname,
33287
34374
  nodes: collectEditableNodes(editContentRef.current),
33288
34375
  sections
@@ -33294,7 +34381,7 @@ function OhhwellsBridge() {
33294
34381
  clearTimeout(timer);
33295
34382
  };
33296
34383
  }, [pathname, isEditMode, refreshStateRules, postToParent2]);
33297
- useEffect21(() => {
34384
+ useEffect22(() => {
33298
34385
  scrollToHashSectionWhenReady();
33299
34386
  const onHashChange = () => scrollToHashSectionWhenReady();
33300
34387
  window.addEventListener("hashchange", onHashChange);
@@ -33336,7 +34423,7 @@ function OhhwellsBridge() {
33336
34423
  if (el) setToolbarRect(getEditMeasureEl(el).getBoundingClientRect());
33337
34424
  refreshActiveCommandsRef.current();
33338
34425
  }, []);
33339
- useEffect21(() => {
34426
+ useEffect22(() => {
33340
34427
  const session = floatingPanel && floatingPanel.kind === "logo-size" ? floatingPanel : null;
33341
34428
  if (!session || !logoSizeDraft) return;
33342
34429
  const onPanelAction = (e) => {
@@ -33387,6 +34474,7 @@ function OhhwellsBridge() {
33387
34474
  }
33388
34475
  setToggleState((prev) => prev ? { ...prev, activeState: state } : null);
33389
34476
  }, [deactivate]);
34477
+ stateChangeRef.current = handleStateChange;
33390
34478
  const reselectAfterLinkPopover = useCallback12(
33391
34479
  (hrefKey) => {
33392
34480
  requestAnimationFrame(() => {
@@ -34670,6 +35758,10 @@ export {
34670
35758
  SITE_OG_IMAGE_KEY,
34671
35759
  SchedulingWidget,
34672
35760
  TEMPLATE_LOGO_ATTR,
35761
+ TONE_ATTR,
35762
+ TONE_CHANGE_EVENT,
35763
+ TONE_FIX_ATTR,
35764
+ TONE_THRESHOLD,
34673
35765
  Toggle,
34674
35766
  ToggleGroup,
34675
35767
  ToggleGroupItem,
@@ -34688,11 +35780,16 @@ export {
34688
35780
  canRemoveAiBlock,
34689
35781
  canRemoveAiTextBlock,
34690
35782
  canSoftHideEditable,
35783
+ compositeColor,
35784
+ compositeGradient,
35785
+ computeBackgroundTones,
35786
+ contrastRatioOf,
34691
35787
  dropIndicatorVariants,
34692
35788
  ensureFooterTree,
34693
35789
  filterAvailablePages,
34694
35790
  foldAlignIntoTrees,
34695
35791
  getEditModeInitialState,
35792
+ gradientStopColors,
34696
35793
  hasMountedContentNodes,
34697
35794
  indexCollectionItems,
34698
35795
  insertFooterHours,
@@ -34704,16 +35801,21 @@ export {
34704
35801
  isRenderableTree,
34705
35802
  isStickySearchParam,
34706
35803
  isValidUrl,
35804
+ linearGradientColourAt,
35805
+ mapRegionToImage,
34707
35806
  matchCollectionItemClick,
35807
+ mountBackgroundTone,
34708
35808
  nextViableSlide,
34709
35809
  parseAiFooterState,
34710
35810
  parseAiSectionsState,
35811
+ parseCssColor,
34711
35812
  parseTarget,
34712
35813
  planAiBlockRemoval,
34713
35814
  planAiTextBlockRemoval,
34714
35815
  planBuildPageSync,
34715
35816
  readHiddenEditables,
34716
35817
  recordOverriddenPaths,
35818
+ relativeLuminanceOf,
34717
35819
  releaseTemplateLogoIfReplaced,
34718
35820
  removeBlockAtPath,
34719
35821
  removeFooterBlock,
@@ -34725,11 +35827,15 @@ export {
34725
35827
  shouldFetchContentForPath,
34726
35828
  softHideEditableInDom,
34727
35829
  softUnhideEditableInDom,
35830
+ splitTopLevel,
34728
35831
  stepViableSlide,
34729
35832
  stripPlaceholderText,
34730
35833
  stripPlaceholders,
34731
35834
  stripTextAlignCss,
34732
35835
  toggleVariants,
35836
+ toneFor,
35837
+ toneOfColor,
35838
+ toneOfLuminance,
34733
35839
  useOhwCarousel,
34734
35840
  validateUrlInput,
34735
35841
  viableSlides,