/**
 * Theme-bridge + swipe-detection scripts injected into preview iframes.
 *
 * Shared by:
 *   - The server preview content route (`/preview/<sid>/...`) when serving
 *     `text/html` documents (injected before the closing `</body>`).
 *   - Any UI surface that still renders inline preview HTML via `srcdoc=`.
 *
 * Keep these scripts side-effect-light, idempotent, and self-contained — they
 * run in arbitrary user-supplied HTML documents.
 */
/** Script that mirrors the host app's theme/palette/CSS-variables into the
 *  preview iframe so dark/light/palette toggles are reflected immediately. */
export declare const PREVIEW_THEME_BRIDGE = "<script>\n(function() {\n\ttry {\n\t\t/* Standalone tab (Open-in-new-tab): parent === window, so there is no\n\t\t   host-app document to mirror. The server-injected inline <style data-bobbit-preview-theme>\n\t\t   snapshot defines :root/.dark defaults \u2014 early return and let it govern.\n\t\t   Embedded iframes (parent !== window) continue past this guard so live\n\t\t   theme toggles in the host app flow through. */\n\t\tif (parent === window) return;\n\t\tvar root = document.documentElement;\n\t\tvar parentRoot = parent.document.documentElement;\n\t\tvar parentStyles = parent.getComputedStyle(parentRoot);\n\n\t\tfunction sync() {\n\t\t\t/* Mirror dark class */\n\t\t\troot.classList.toggle('dark', parentRoot.classList.contains('dark'));\n\n\t\t\t/* Mirror data-palette attribute */\n\t\t\tvar palette = parentRoot.getAttribute('data-palette');\n\t\t\tif (palette) root.setAttribute('data-palette', palette);\n\t\t\telse root.removeAttribute('data-palette');\n\n\t\t\t/* Copy all CSS custom properties from the app stylesheet */\n\t\t\tvar vars = [];\n\t\t\ttry {\n\t\t\t\tfor (var s = 0; s < parent.document.styleSheets.length; s++) {\n\t\t\t\t\tvar sheet = parent.document.styleSheets[s];\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvar rules = sheet.cssRules || sheet.rules;\n\t\t\t\t\t\tfor (var r = 0; r < rules.length; r++) {\n\t\t\t\t\t\t\tvar rule = rules[r];\n\t\t\t\t\t\t\tif (rule.style) {\n\t\t\t\t\t\t\t\tfor (var i = 0; i < rule.style.length; i++) {\n\t\t\t\t\t\t\t\t\tvar name = rule.style[i];\n\t\t\t\t\t\t\t\t\tif (name.startsWith('--')) vars.push(name);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch(e) { /* cross-origin sheet, skip */ }\n\t\t\t\t}\n\t\t\t} catch(e) {}\n\n\t\t\t/* Deduplicate and copy computed values */\n\t\t\tvar seen = {};\n\t\t\tfor (var v = 0; v < vars.length; v++) {\n\t\t\t\tif (seen[vars[v]]) continue;\n\t\t\t\tseen[vars[v]] = true;\n\t\t\t\tvar val = parentStyles.getPropertyValue(vars[v]);\n\t\t\t\tif (val) root.style.setProperty(vars[v], val);\n\t\t\t}\n\t\t}\n\n\t\t/* Copy the app font stack */\n\t\troot.style.fontFamily = parentStyles.fontFamily;\n\n\t\t/* Initial sync */\n\t\tsync();\n\n\t\t/* Watch for class/attribute changes on the parent root element */\n\t\tvar observer = new MutationObserver(sync);\n\t\tobserver.observe(parentRoot, { attributes: true, attributeFilter: ['class', 'data-palette', 'style'] });\n\t} catch(e) { /* cross-origin or other error \u2014 degrade gracefully */ }\n})();\n</script>";
/** Script that detects horizontal swipes inside the preview iframe and
 *  forwards them to the parent via postMessage so the unified panel slider
 *  can react. Vertical gestures fall through to normal browser scrolling. */
export declare const PREVIEW_SWIPE_SCRIPT = "<script>\n(function() {\n\tvar startX = 0, startY = 0, captured = false, decided = false;\n\tdocument.addEventListener('touchstart', function(e) {\n\t\tstartX = e.touches[0].clientX;\n\t\tstartY = e.touches[0].clientY;\n\t\tcaptured = false;\n\t\tdecided = false;\n\t}, {passive: true});\n\tdocument.addEventListener('touchmove', function(e) {\n\t\tif (decided && !captured) return;\n\t\tvar dx = e.touches[0].clientX - startX;\n\t\tvar dy = e.touches[0].clientY - startY;\n\t\tif (!decided && (Math.abs(dx) > 8 || Math.abs(dy) > 8)) {\n\t\t\tdecided = true;\n\t\t\tcaptured = Math.abs(dx) > Math.abs(dy);\n\t\t\tif (captured) parent.postMessage({type:'preview-swipe-start'}, '*');\n\t\t}\n\t\tif (captured) {\n\t\t\te.preventDefault();\n\t\t\tparent.postMessage({type:'preview-swipe-move', dx: dx}, '*');\n\t\t}\n\t}, {passive: false});\n\tdocument.addEventListener('touchend', function(e) {\n\t\tif (!captured) return;\n\t\tvar dx = e.changedTouches[0].clientX - startX;\n\t\tparent.postMessage({type:'preview-swipe-end', dx: dx}, '*');\n\t\tcaptured = false;\n\t\tdecided = false;\n\t}, {passive: true});\n})();\n</script>";
/** Combined bridge scripts — convenient single string for server-side injection. */
export declare const PREVIEW_BRIDGE_SCRIPTS: string;
/**
 * Inject a `<base>` tag and the bridge scripts into an arbitrary HTML
 * document, used by the server's preview content route (`/preview/<sid>/...`).
 *
 * - `<base>` goes immediately after the first `<head>` opening tag, or, if
 *   no `<head>` exists, the function prepends `<head>${baseTag}</head>` to
 *   the body.
 * - Bridge scripts go immediately before the first `</body>`, or, if no
 *   `</body>` is present, are appended to the end of the document.
 *
 * No HTML parser dependency — pure string operations, matches the existing
 * `srcdoc` concatenation trade-off.
 */
export declare function injectBaseAndScripts(html: string, baseTag: string, scripts: string): string;
//# sourceMappingURL=preview-bridge-scripts.d.ts.map