@base44-preview/vite-plugin 1.0.18-pr.80.1ee8db5 → 1.0.18-pr.80.79b32f2
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/injections/auto-popup-suppressor.d.ts.map +1 -1
- package/dist/injections/auto-popup-suppressor.js +85 -94
- package/dist/injections/auto-popup-suppressor.js.map +1 -1
- package/dist/statics/index.mjs +7 -7
- package/dist/statics/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/injections/auto-popup-suppressor.ts +85 -91
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-popup-suppressor.d.ts","sourceRoot":"","sources":["../../src/injections/auto-popup-suppressor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auto-popup-suppressor.d.ts","sourceRoot":"","sources":["../../src/injections/auto-popup-suppressor.ts"],"names":[],"mappings":"AAuCA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAIF,wBAAgB,mCAAmC,IAAI,6BAA6B,CAgGnF"}
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// Two-stage heuristic:
|
|
7
7
|
//
|
|
8
8
|
// 1. BACKDROP MATCH — element must be `position: fixed`, cover ≥90% of the
|
|
9
|
-
// viewport on both axes, have z-index
|
|
10
|
-
// (translucent background OR backdrop-filter). This is the
|
|
11
|
-
// fingerprint.
|
|
9
|
+
// viewport on both axes, have a popup-level z-index, and show backdrop-
|
|
10
|
+
// like styles (translucent background OR backdrop-filter). This is the
|
|
11
|
+
// modal-overlay fingerprint.
|
|
12
12
|
//
|
|
13
13
|
// 2. PANEL SWEEP — once we've hidden any backdrop, sweep the whole document
|
|
14
14
|
// for fixed/high-z elements whose bbox falls in a "modal-shaped" band
|
|
@@ -31,7 +31,8 @@ const REFERENCE_VH_BASE_VAR = "--base44-reference-vh-base";
|
|
|
31
31
|
const FULL_VIEWPORT_RATIO = 0.9;
|
|
32
32
|
const MODAL_PANEL_MIN_RATIO = 0.15;
|
|
33
33
|
const MODAL_PANEL_MAX_RATIO = 0.95;
|
|
34
|
-
const
|
|
34
|
+
const POPUP_Z_INDEX_THRESHOLD = 40;
|
|
35
|
+
// ── Public API ──────────────────────────────────────────────────────────────
|
|
35
36
|
export function createAutoPopupSuppressorController() {
|
|
36
37
|
let observer = null;
|
|
37
38
|
let domReadyHandler = null;
|
|
@@ -40,71 +41,81 @@ export function createAutoPopupSuppressorController() {
|
|
|
40
41
|
// mutation batches are also hidden. Without this, a Content node that
|
|
41
42
|
// mounts after its Overlay's batch wouldn't be matched in-flight.
|
|
42
43
|
let backdropEverDetected = false;
|
|
43
|
-
|
|
44
|
+
// Single decision per element. One getComputedStyle call — backdrop and
|
|
45
|
+
// panel checks share the position/z-index preconditions. Without sharing,
|
|
46
|
+
// every non-matching node in a React commit's added subtree would pay for
|
|
47
|
+
// two style recalcs, which is the MutationObserver hot path.
|
|
48
|
+
const classify = (el, vp) => {
|
|
49
|
+
if (!(el instanceof HTMLElement))
|
|
50
|
+
return;
|
|
44
51
|
if (el.hasAttribute(SUPPRESSED_ATTR))
|
|
45
52
|
return;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
sweepDocumentForModalPanels();
|
|
49
|
-
};
|
|
50
|
-
const scanNode = (root) => {
|
|
51
|
-
if (!document.body)
|
|
53
|
+
const style = window.getComputedStyle(el);
|
|
54
|
+
if (style.position !== "fixed")
|
|
52
55
|
return;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
: root instanceof Element
|
|
57
|
-
? [root]
|
|
58
|
-
: [];
|
|
59
|
-
for (const startRoot of startRoots) {
|
|
60
|
-
checkNode(startRoot, vw, vh);
|
|
61
|
-
const candidates = startRoot.querySelectorAll(`*:not([${SUPPRESSED_ATTR}])`);
|
|
62
|
-
for (let i = 0; i < candidates.length; i++) {
|
|
63
|
-
const el = candidates[i];
|
|
64
|
-
if (el)
|
|
65
|
-
checkNode(el, vw, vh);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const checkNode = (el, vw, vh) => {
|
|
70
|
-
if (matchesBackdrop(el, vw, vh)) {
|
|
56
|
+
if (!hasPopupZIndex(style))
|
|
57
|
+
return;
|
|
58
|
+
if (coversFullViewport(el, vp) && hasBackdropLook(el, style)) {
|
|
71
59
|
hideBackdrop(el);
|
|
60
|
+
return;
|
|
72
61
|
}
|
|
73
|
-
|
|
74
|
-
el instanceof HTMLElement &&
|
|
75
|
-
matchesModalPanel(el, vw, vh)) {
|
|
62
|
+
if (backdropEverDetected && hasModalShapeBbox(el, vp)) {
|
|
76
63
|
applyHide(el);
|
|
77
64
|
}
|
|
78
65
|
};
|
|
79
|
-
const
|
|
80
|
-
|
|
66
|
+
const hideBackdrop = (el) => {
|
|
67
|
+
if (el.hasAttribute(SUPPRESSED_ATTR))
|
|
68
|
+
return;
|
|
69
|
+
applyHide(el);
|
|
70
|
+
backdropEverDetected = true;
|
|
71
|
+
sweepDocumentForModalPanels(viewportForGates());
|
|
72
|
+
};
|
|
73
|
+
const scanSubtree = (root, vp) => {
|
|
74
|
+
classify(root, vp);
|
|
75
|
+
const descendants = root.querySelectorAll(`*:not([${SUPPRESSED_ATTR}])`);
|
|
76
|
+
for (let i = 0; i < descendants.length; i++) {
|
|
77
|
+
const el = descendants[i];
|
|
78
|
+
if (el)
|
|
79
|
+
classify(el, vp);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const attachObserver = () => {
|
|
81
83
|
if (observer)
|
|
82
84
|
return;
|
|
85
|
+
// viewportForGates is read once per mutation batch, not per added node —
|
|
86
|
+
// a busy React commit can deliver dozens of added subtrees in one tick.
|
|
83
87
|
observer = new MutationObserver((mutations) => {
|
|
88
|
+
const vp = viewportForGates();
|
|
84
89
|
for (const m of mutations) {
|
|
85
90
|
if (m.type !== "childList")
|
|
86
91
|
continue;
|
|
87
92
|
for (let i = 0; i < m.addedNodes.length; i++) {
|
|
88
93
|
const node = m.addedNodes[i];
|
|
89
94
|
if (node instanceof Element)
|
|
90
|
-
|
|
95
|
+
scanSubtree(node, vp);
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
98
|
});
|
|
94
99
|
observer.observe(document.documentElement, { childList: true, subtree: true });
|
|
95
100
|
};
|
|
101
|
+
const start = () => {
|
|
102
|
+
if (!document.body)
|
|
103
|
+
return;
|
|
104
|
+
scanSubtree(document.body, viewportForGates());
|
|
105
|
+
attachObserver();
|
|
106
|
+
};
|
|
96
107
|
return {
|
|
97
108
|
suppress: () => {
|
|
98
109
|
if (active)
|
|
99
110
|
return;
|
|
100
111
|
active = true;
|
|
101
112
|
if (document.body) {
|
|
102
|
-
|
|
113
|
+
start();
|
|
103
114
|
}
|
|
104
115
|
else {
|
|
105
116
|
domReadyHandler = () => {
|
|
106
117
|
domReadyHandler = null;
|
|
107
|
-
|
|
118
|
+
start();
|
|
108
119
|
};
|
|
109
120
|
document.addEventListener("DOMContentLoaded", domReadyHandler);
|
|
110
121
|
}
|
|
@@ -123,76 +134,56 @@ export function createAutoPopupSuppressorController() {
|
|
|
123
134
|
},
|
|
124
135
|
};
|
|
125
136
|
}
|
|
126
|
-
// ──
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
// node in every added subtree, so this is the hot path.
|
|
133
|
-
function matchesBackdrop(el, vw, vh) {
|
|
134
|
-
if (!(el instanceof HTMLElement))
|
|
135
|
-
return false;
|
|
136
|
-
if (el.hasAttribute(SUPPRESSED_ATTR))
|
|
137
|
-
return false;
|
|
138
|
-
const style = window.getComputedStyle(el);
|
|
139
|
-
if (style.position !== "fixed")
|
|
140
|
-
return false;
|
|
141
|
-
if (!coversFullViewport(el, vw, vh))
|
|
142
|
-
return false;
|
|
143
|
-
if (!hasHighZIndex(style))
|
|
144
|
-
return false;
|
|
145
|
-
return hasBackdropLook(el, style);
|
|
146
|
-
}
|
|
147
|
-
// Stage 2: identify the content panel paired with a backdrop. Runs both as a
|
|
148
|
-
// document-wide sweep after a backdrop hide AND as an inline check on each
|
|
149
|
-
// newly-added node once `backdropEverDetected` is set.
|
|
150
|
-
function matchesModalPanel(el, vw, vh) {
|
|
151
|
-
if (el.hasAttribute(SUPPRESSED_ATTR))
|
|
152
|
-
return false;
|
|
153
|
-
const style = window.getComputedStyle(el);
|
|
154
|
-
if (style.position !== "fixed")
|
|
155
|
-
return false;
|
|
156
|
-
if (!hasHighZIndex(style))
|
|
157
|
-
return false;
|
|
158
|
-
return hasModalShapeBbox(el, vw, vh);
|
|
159
|
-
}
|
|
160
|
-
function sweepDocumentForModalPanels() {
|
|
137
|
+
// ── Document-wide panel sweep ───────────────────────────────────────────────
|
|
138
|
+
// Triggered once per backdrop hide. Walks the whole document for unhidden
|
|
139
|
+
// fixed/high-z elements whose bbox falls inside the modal-shape band — picks
|
|
140
|
+
// up content panels regardless of how they're nested or which portal they
|
|
141
|
+
// went through.
|
|
142
|
+
function sweepDocumentForModalPanels(vp) {
|
|
161
143
|
if (!document.body)
|
|
162
144
|
return;
|
|
163
|
-
|
|
164
|
-
if (vw <= 0 || vh <= 0)
|
|
145
|
+
if (vp.vw <= 0 || vp.vh <= 0)
|
|
165
146
|
return;
|
|
166
147
|
const candidates = document.body.querySelectorAll(`*:not([${SUPPRESSED_ATTR}])`);
|
|
167
148
|
for (let i = 0; i < candidates.length; i++) {
|
|
168
149
|
const el = candidates[i];
|
|
169
|
-
if (el &&
|
|
150
|
+
if (el && isModalPanel(el, vp))
|
|
170
151
|
applyHide(el);
|
|
171
152
|
}
|
|
172
153
|
}
|
|
154
|
+
function isModalPanel(el, vp) {
|
|
155
|
+
if (el.hasAttribute(SUPPRESSED_ATTR))
|
|
156
|
+
return false;
|
|
157
|
+
const style = window.getComputedStyle(el);
|
|
158
|
+
if (style.position !== "fixed")
|
|
159
|
+
return false;
|
|
160
|
+
if (!hasPopupZIndex(style))
|
|
161
|
+
return false;
|
|
162
|
+
return hasModalShapeBbox(el, vp);
|
|
163
|
+
}
|
|
173
164
|
// ── Gate predicates ─────────────────────────────────────────────────────────
|
|
174
|
-
function coversFullViewport(el,
|
|
175
|
-
if (vw <= 0 || vh <= 0)
|
|
165
|
+
function coversFullViewport(el, vp) {
|
|
166
|
+
if (vp.vw <= 0 || vp.vh <= 0)
|
|
176
167
|
return false;
|
|
177
168
|
const rect = el.getBoundingClientRect();
|
|
178
|
-
return (rect.width >= vw * FULL_VIEWPORT_RATIO &&
|
|
179
|
-
rect.height >= vh * FULL_VIEWPORT_RATIO);
|
|
169
|
+
return (rect.width >= vp.vw * FULL_VIEWPORT_RATIO &&
|
|
170
|
+
rect.height >= vp.vh * FULL_VIEWPORT_RATIO);
|
|
180
171
|
}
|
|
181
172
|
// "Modal-shaped" = small enough not to be a sidebar/full-screen overlay
|
|
182
173
|
// (≤95% on both axes), big enough not to be a nav/footer/toast (≥15% on both
|
|
183
174
|
// axes). Calibrated against shadcn Dialog content (≈25–50% × 30–50%), top
|
|
184
175
|
// nav (height fails ≤15%), sidebar (height fails ≥95%), toast (height fails
|
|
185
176
|
// ≤15%).
|
|
186
|
-
function hasModalShapeBbox(el,
|
|
177
|
+
function hasModalShapeBbox(el, vp) {
|
|
187
178
|
const rect = el.getBoundingClientRect();
|
|
188
|
-
return (rect.width >= vw * MODAL_PANEL_MIN_RATIO &&
|
|
189
|
-
rect.height >= vh * MODAL_PANEL_MIN_RATIO &&
|
|
190
|
-
rect.width <= vw * MODAL_PANEL_MAX_RATIO &&
|
|
191
|
-
rect.height <= vh * MODAL_PANEL_MAX_RATIO);
|
|
179
|
+
return (rect.width >= vp.vw * MODAL_PANEL_MIN_RATIO &&
|
|
180
|
+
rect.height >= vp.vh * MODAL_PANEL_MIN_RATIO &&
|
|
181
|
+
rect.width <= vp.vw * MODAL_PANEL_MAX_RATIO &&
|
|
182
|
+
rect.height <= vp.vh * MODAL_PANEL_MAX_RATIO);
|
|
192
183
|
}
|
|
193
|
-
function
|
|
184
|
+
function hasPopupZIndex(style) {
|
|
194
185
|
const z = parseInt(style.zIndex, 10);
|
|
195
|
-
return Number.isFinite(z) && z >=
|
|
186
|
+
return Number.isFinite(z) && z >= POPUP_Z_INDEX_THRESHOLD;
|
|
196
187
|
}
|
|
197
188
|
// True if the element looks like a modal backdrop: translucent fill OR a
|
|
198
189
|
// backdrop-filter (e.g. blur). Also returns true if the element's own bg is
|
|
@@ -211,7 +202,7 @@ function hasBackdropLook(el, style) {
|
|
|
211
202
|
const cs = window.getComputedStyle(child);
|
|
212
203
|
if (cs.position !== "fixed" && cs.position !== "absolute")
|
|
213
204
|
continue;
|
|
214
|
-
if (!
|
|
205
|
+
if (!hasPopupZIndex(cs))
|
|
215
206
|
continue;
|
|
216
207
|
if (isTranslucent(cs.backgroundColor))
|
|
217
208
|
return true;
|
|
@@ -249,13 +240,7 @@ function parseAlpha(value) {
|
|
|
249
240
|
return 1;
|
|
250
241
|
return null;
|
|
251
242
|
}
|
|
252
|
-
// ── DOM ops
|
|
253
|
-
function applyHide(el) {
|
|
254
|
-
if (el.hasAttribute(SUPPRESSED_ATTR))
|
|
255
|
-
return;
|
|
256
|
-
el.setAttribute(SUPPRESSED_ATTR, "1");
|
|
257
|
-
el.style.setProperty("display", "none", "important");
|
|
258
|
-
}
|
|
243
|
+
// ── Viewport + DOM ops ──────────────────────────────────────────────────────
|
|
259
244
|
// Viewport dimensions used for percentage gates. Width comes from
|
|
260
245
|
// `innerWidth` (unaffected by canvas auto-fit). Height prefers the reference
|
|
261
246
|
// vh set by page-height-bridge — without that, after the iframe auto-resizes
|
|
@@ -270,4 +255,10 @@ function viewportForGates() {
|
|
|
270
255
|
: (window.innerHeight || document.documentElement.clientHeight || 0);
|
|
271
256
|
return { vw, vh };
|
|
272
257
|
}
|
|
258
|
+
function applyHide(el) {
|
|
259
|
+
if (el.hasAttribute(SUPPRESSED_ATTR))
|
|
260
|
+
return;
|
|
261
|
+
el.setAttribute(SUPPRESSED_ATTR, "1");
|
|
262
|
+
el.style.setProperty("display", "none", "important");
|
|
263
|
+
}
|
|
273
264
|
//# sourceMappingURL=auto-popup-suppressor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-popup-suppressor.js","sourceRoot":"","sources":["../../src/injections/auto-popup-suppressor.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,0EAA0E;AAC1E,8EAA8E;AAC9E,wCAAwC;AACxC,EAAE;AACF,uBAAuB;AACvB,EAAE;AACF,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"auto-popup-suppressor.js","sourceRoot":"","sources":["../../src/injections/auto-popup-suppressor.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,0EAA0E;AAC1E,8EAA8E;AAC9E,wCAAwC;AACxC,EAAE;AACF,uBAAuB;AACvB,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,kCAAkC;AAClC,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,6EAA6E;AAC7E,qEAAqE;AACrE,0EAA0E;AAC1E,qDAAqD;AACrD,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,0BAA0B;AAC1B,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,sDAAsD;AAEtD,MAAM,eAAe,GAAG,8BAA8B,CAAC;AACvD,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAE3D,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AASnC,+EAA+E;AAE/E,MAAM,UAAU,mCAAmC;IACjD,IAAI,QAAQ,GAA4B,IAAI,CAAC;IAC7C,IAAI,eAAe,GAAwB,IAAI,CA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AC5E,mCAAmC;AACnC,SAAS,gBAAgB;IACvB,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAC,eAAe,CAAC,WAAW,IAAI,CAAC,CAAC;IAC1E,MAAM,MAAM,GAAG,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IACtF,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC;QACxC,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,QAAQ,CAAC,eAAe,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC;IACvE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;AACpB,CAAC;AAED,SAAS,SAAS,CAAC,EAAW;IAC5B,IAAI,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC;QAAE,OAAO;IAC7C,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IACrC,EAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACxE,CAAC"}
|
package/dist/statics/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
function
|
|
2
|
-
[data-visual-edit-active] *:not([${
|
|
3
|
-
[data-visual-edit-active] *:not([${
|
|
4
|
-
[data-visual-edit-active] *:not([${
|
|
1
|
+
function Ee(e,t){let n=t.top<27,r=t.height>=54,s=t.width>=window.innerWidth-4,c=s?"8px":"-2px",f=s?"8px":"4px";n&&r?(e.style.top="2px",e.style.left=f):n?(e.style.top=`${t.height+2}px`,e.style.left=c):(e.style.top="-27px",e.style.left=c)}function q(e){let t=e;return!!(t.dataset?.sourceLocation||t.dataset?.visualSelectorId)}function _(e){let t=e;return t.dataset?.sourceLocation||t.dataset?.visualSelectorId||null}var j=["src"],M="data-vite-plugin-element";function H(e){if(!e)return[];let t=Array.from(document.querySelectorAll(`[data-source-location="${e}"]`));return t.length>0?t:Array.from(document.querySelectorAll(`[data-visual-selector-id="${e}"]`))}function ge(e,t){e.forEach(n=>{n.setAttribute("class",t)})}function he(e,t,n){j.includes(t)&&e.forEach(r=>{r.setAttribute(t,n)})}function ve(e,t){let n={};for(let r of t){let s=e.getAttribute(r);s!==null&&(n[r]=s)}return n}function ye(){if(document.getElementById("freeze-animations"))return;document.documentElement.setAttribute("data-visual-edit-active","");let e=document.createElement("style");e.id="freeze-animations",e.textContent=`
|
|
2
|
+
[data-visual-edit-active] *:not([${M}]):not([${M}] *),
|
|
3
|
+
[data-visual-edit-active] *:not([${M}]):not([${M}] *)::before,
|
|
4
|
+
[data-visual-edit-active] *:not([${M}]):not([${M}] *)::after {
|
|
5
5
|
animation-play-state: paused !important;
|
|
6
6
|
transition: none !important;
|
|
7
7
|
}
|
|
8
8
|
`;let t=document.createElement("style");t.id="freeze-pointer-events",t.textContent=`
|
|
9
9
|
[data-visual-edit-active] * { pointer-events: none !important; }
|
|
10
|
-
[${
|
|
11
|
-
`;let n=document.head||document.documentElement;n.appendChild(e),n.appendChild(t),document.getAnimations().forEach(
|
|
10
|
+
[${M}], [${M}] * { pointer-events: auto !important; }
|
|
11
|
+
`;let n=document.head||document.documentElement;n.appendChild(e),n.appendChild(t),document.getAnimations().forEach(r=>{let s=r.effect?.target;if(!(s instanceof Element&&s.closest(`[${M}]`)))try{r.finish()}catch{r.pause()}})}function be(){let e=document.getElementById("freeze-animations");e&&(e.remove(),document.getElementById("freeze-pointer-events")?.remove(),document.documentElement.removeAttribute("data-visual-edit-active"),document.getAnimations().forEach(t=>{if(t.playState==="paused")try{t.play()}catch{}}))}function Z(e,t){let n=document.getElementById("freeze-pointer-events");n&&(n.disabled=!0);let r=document.elementFromPoint(e,t);return n&&(n.disabled=!1),r?.closest("[data-source-location], [data-visual-selector-id]")??null}function Le(e,t,n){let r=Z(e,t);if(!r)return null;let s=_(r);return s===n?null:s}var Te={position:"absolute",backgroundColor:"#ffffff",border:"1px solid #e2e8f0",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",fontSize:"12px",minWidth:"120px",maxHeight:"200px",overflowY:"auto",zIndex:"10001",padding:"4px 0",pointerEvents:"auto"},we={padding:"4px 12px",cursor:"pointer",color:"#334155",backgroundColor:"transparent",whiteSpace:"nowrap",lineHeight:"1.5",fontWeight:"400"},X="#526cff",Se="#DBEAFE",Ie="600",J="#f1f5f9",Me=10,Q='<svg width="12" height="12" viewBox="0 0 24 24" style="vertical-align:middle;margin-left:4px"><path d="M6 9l6 6 6-6" stroke="currentColor" stroke-width="2" fill="none"/></svg>',Ce='<svg width="12" height="12" viewBox="0 0 24 24" style="vertical-align:middle;margin-left:4px"><path d="M18 15l-6-6-6 6" stroke="currentColor" stroke-width="2" fill="none"/></svg>',B="data-chevron",Ae=12,V="data-layer-dropdown",_e=2,De=2;function ee(e,t){for(let n of Object.keys(t))e.style.setProperty(n.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`),t[n])}function He(e){return e.tagName}function te(e,t){let n={element:e,tagName:e.tagName.toLowerCase(),selectorId:_(e)};return t!==void 0&&(n.depth=t),n}function xe(e,t,n){let r=[];function s(c,f){if(!(f>t))for(let u=0;u<c.children.length;u++){let h=c.children[u];if(q(h)){let m={element:h,tagName:h.tagName.toLowerCase(),selectorId:_(h)};n!==void 0&&(m.depth=n+f-1),r.push(m),s(h,f+1)}else s(h,f)}}return s(e,1),r}function at(e){let t=[],n=e.parentElement;for(;n&&n!==document.documentElement&&n!==document.body&&t.length<_e;)q(n)&&t.push(te(n)),n=n.parentElement;return t.reverse(),t}function dt(e,t){return t.forEach((n,r)=>{e.push({...n,depth:r})}),t.length}function Oe(e,t,n){e.push(te(t,n));let r=xe(t,De,n+1);e.push(...r)}function ct(e){return e.at(-1)?.element??null}function ut(e,t){let n=xe(e,1);return n.some(r=>r.element===t)||n.push(te(t)),n}function mt(e,t,n,r){let s=_(n),c=new Set;for(let f of t)if(f.element===n)Oe(e,n,r),s&&c.add(s);else{let u=f.selectorId;if(u!=null){if(u===s||c.has(u))continue;c.add(u)}e.push({...f,depth:r})}}function Ne(e){let t=at(e),n=[],r=dt(n,t),s=ct(t);if(s){let c=ut(s,e);mt(n,c,e,r)}else Oe(n,e,r);return n}var P=null,ne=null,W=null,$=null,F=null;function ft(e,t,{onSelect:n,onHover:r,onHoverEnd:s}){let c=document.createElement("div");c.textContent=He(e),ee(c,we);let f=e.depth??0;return f>0&&(c.style.paddingLeft=`${Ae+f*Me}px`),t&&(c.style.color=X,c.style.backgroundColor=Se,c.style.fontWeight=Ie),c.addEventListener("mouseenter",()=>{t||(c.style.backgroundColor=J),r&&r(e)}),c.addEventListener("mouseleave",()=>{t||(c.style.backgroundColor="transparent"),s&&s()}),c.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault(),n(e)}),c}function pt(e,t,n){let r=document.createElement("div");return r.setAttribute(V,"true"),r.setAttribute(M,"true"),ee(r,Te),e.forEach(s=>{let c=s.element===t;r.appendChild(ft(s,c,n))}),r}function Re(e){if(e.querySelector(`[${B}]`))return;let t=document.createElement("span");t.setAttribute(B,"true"),t.style.display="inline-flex",t.innerHTML=Q,e.appendChild(t),e.style.display="inline-flex",e.style.alignItems="center",e.style.cursor="pointer",e.style.userSelect="none",e.style.whiteSpace="nowrap",e.style.pointerEvents="auto",e.setAttribute(V,"true"),e.setAttribute(M,"true")}function Et(e,t,n,{onSelect:r,onHover:s,onHoverEnd:c}){let f=Array.from(e.children),u=t.findIndex(m=>m.element===n),h=m=>{if(u>=0&&u<f.length){let v=f[u];v.style.color!==X&&(v.style.backgroundColor="transparent")}if(u=m,u>=0&&u<f.length){let v=f[u];v.style.color!==X&&(v.style.backgroundColor=J),v.scrollIntoView({block:"nearest"}),s&&u>=0&&u<t.length&&s(t[u])}};F=m=>{m.key==="ArrowDown"?(m.preventDefault(),m.stopPropagation(),h(u<f.length-1?u+1:0)):m.key==="ArrowUp"?(m.preventDefault(),m.stopPropagation(),h(u>0?u-1:f.length-1)):m.key==="Enter"&&u>=0&&u<t.length&&(m.preventDefault(),m.stopPropagation(),c&&c(),r(t[u]),x())},document.addEventListener("keydown",F,!0)}function gt(e,t){let n=!0;W=r=>{if(n){n=!1;return}let s=r.target;!e.contains(s)&&s!==t&&x()},document.addEventListener("mousedown",W,!0)}function Pe(e,t,n,r){x();let s=pt(t,n,{...r,onSelect:u=>{r.onHoverEnd&&r.onHoverEnd(),r.onSelect(u),x()}}),c=e.parentElement;if(!c)return;s.style.top=`${e.offsetTop+e.offsetHeight+2}px`,s.style.left=`${e.offsetLeft}px`,c.appendChild(s),P=s,ne=e;let f=e.querySelector(`[${B}]`);f&&(f.innerHTML=Ce),$=r.onHoverEnd??null,Et(s,t,n,r),gt(s,e)}function x(){let e=ne?.querySelector(`[${B}]`);e&&(e.innerHTML=Q),ne=null,$&&($(),$=null),P&&P.parentNode&&P.remove(),P=null,W&&(document.removeEventListener("mousedown",W,!0),W=null),F&&(document.removeEventListener("keydown",F,!0),F=null)}function ke(){return P!==null}function Be(e){let t=null,n=null,r=null,s=()=>{t&&t.parentNode&&t.remove(),t=null},c=L=>{s(),_(L.element)!==e.getSelectedElementId()&&(t=e.createPreviewOverlay(L.element))},f=L=>{s(),x(),n&&(document.removeEventListener("keydown",n,!0),n=null),r=null;let i=e.selectElement(L.element);m(i,L.element)},u=()=>{n&&(document.removeEventListener("keydown",n,!0),n=null),r&&(f(r),r=null)},h=(L,i,d,S,C)=>{L.stopPropagation(),L.preventDefault(),ke()?(x(),u()):(r={element:d,tagName:d.tagName.toLowerCase(),selectorId:C},e.onDeselect(),n=w=>{w.key==="Escape"&&(w.stopPropagation(),x(),u())},document.addEventListener("keydown",n,!0),Pe(i,S,d,{onSelect:f,onHover:c,onHoverEnd:s}))},m=(L,i)=>{if(!L)return;let d=L.querySelector("div");if(!d)return;let S=Ne(i);if(S.length<=1)return;let C=_(i);Re(d),d.addEventListener("click",w=>{h(w,d,i,S,C)})};return{attachToOverlay:m,cleanup:()=>{s(),x()}}}var oe="visual-edit-focus-styles",ht=["div","p","h1","h2","h3","h4","h5","h6","span","li","td","a","button","label"],re=e=>!!e.dataset.arrField,vt=e=>!(!ht.includes(e.tagName.toLowerCase())||!e.textContent?.trim()||e.querySelector("img, video, canvas, svg")||e.children?.length>0),Ve=()=>{if(document.getElementById(oe))return;let e=document.createElement("style");e.id=oe,e.textContent=`
|
|
12
12
|
[data-selected="true"][contenteditable="true"]:focus {
|
|
13
13
|
outline: none !important;
|
|
14
14
|
}
|
|
15
|
-
`,document.head.appendChild(e)},Ve=()=>{document.getElementById(oe)?.remove()},We=e=>{let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},yt=e=>!(e instanceof HTMLElement)||!vt(e)?!1:re(e)?!0:e.dataset.dynamicContent!=="true",ie=e=>!(e instanceof HTMLElement)||e.dataset.selected!=="true"?!1:yt(e);var bt=500;function se(e){let t=null,n=null,o=!1,i=new WeakMap,c=()=>{let s=e.getSelectedElementId();if(!s)return;let d=e.findElementsById(s);e.getSelectedOverlays().forEach((I,T)=>{T<d.length&&d[T]&&e.positionOverlay(I,d[T])})},f=s=>{let d=s.dataset.originalTextContent,w=s.textContent,I=s,T=s.getBoundingClientRect(),O={type:"inline-edit",elementInfo:{tagName:s.tagName,classes:I.className?.baseVal||s.className||"",visualSelectorId:e.getSelectedElementId(),content:w,dataSourceLocation:s.dataset.sourceLocation,isDynamicContent:s.dataset.dynamicContent==="true",linenumber:s.dataset.linenumber,filename:s.dataset.filename,position:{top:T.top,left:T.left,right:T.right,bottom:T.bottom,width:T.width,height:T.height,centerX:T.left+T.width/2,centerY:T.top+T.height/2}},originalContent:d,newContent:w};re(s)&&(O.arrIndex=s.dataset.arrIndex,O.arrVariableName=s.dataset.arrVariableName,O.arrField=s.dataset.arrField),window.parent.postMessage(O,"*"),s.dataset.originalTextContent=w||""},u=s=>{n&&clearTimeout(n),n=setTimeout(()=>f(s),bt)},p=s=>{c(),u(s)},m=function(){p(this)},v=s=>{Be(),s.dataset.originalTextContent=s.textContent||"",s.dataset.originalCursor=s.style.cursor,s.contentEditable="true",s.setAttribute(C,"true");let d=new AbortController;i.set(s,d),s.addEventListener("input",m,{signal:d.signal}),s.style.cursor="text",We(s),setTimeout(()=>{s.isConnected&&s.focus()},0)},S=s=>{let d=i.get(s);d&&(d.abort(),i.delete(s)),s.isConnected&&(Ve(),s.contentEditable="false",s.removeAttribute(C),delete s.dataset.originalTextContent,s.dataset.originalCursor!==void 0&&(s.style.cursor=s.dataset.originalCursor,delete s.dataset.originalCursor))};return{get enabled(){return o},set enabled(s){o=s},isEditing(){return t!==null},getCurrentElement(){return t},canEdit(s){return ie(s)},startEditing(s){t=s,e.getSelectedOverlays().forEach(d=>{d.style.display="none"}),v(s),window.parent.postMessage({type:"content-editing-started",visualSelectorId:e.getSelectedElementId()},"*")},stopEditing(){if(!t)return;n&&(clearTimeout(n),n=null),S(t),e.getSelectedOverlays().forEach(d=>{d.style.display=""}),c(),window.parent.postMessage({type:"content-editing-ended",visualSelectorId:e.getSelectedElementId()},"*"),t=null},markElementsSelected(s){s.forEach(d=>{d instanceof HTMLElement&&(d.dataset.selected="true")})},clearSelectedMarks(s){s&&e.findElementsById(s).forEach(d=>{d instanceof HTMLElement&&delete d.dataset.selected})},handleToggleMessage(s){if(!o)return;let d=e.findElementsById(s.dataSourceLocation);if(d.length===0||!(d[0]instanceof HTMLElement))return;let w=d[0];if(s.inlineEditingMode){if(!ie(w))return;e.getSelectedElementId()!==s.dataSourceLocation&&(this.stopEditing(),e.clearSelection(),this.markElementsSelected(d),e.createSelectionOverlays(d,s.dataSourceLocation)),this.startEditing(w)}else t===w&&this.stopEditing()},cleanup(){this.stopEditing()}}}var le="__theme-font-preview";function Lt(e){return e instanceof Element?e:e instanceof Node?e.parentElement:null}function Tt(e){return Lt(e)?.closest(`[${C}]`)!=null}function Fe(){let e=!1,t=i=>{if(Tt(i.target))return;if(i.preventDefault(),i.ctrlKey||i.metaKey){window.parent.postMessage({type:"canvas-wheel-zoom",data:{deltaY:i.deltaY,deltaMode:i.deltaMode,clientX:i.clientX,clientY:i.clientY,ctrlKey:i.ctrlKey,metaKey:i.metaKey}},"*");return}let c={deltaX:i.deltaX,deltaY:i.deltaY,deltaMode:i.deltaMode,clientX:i.clientX,clientY:i.clientY,shiftKey:i.shiftKey,ctrlKey:!1,metaKey:!1};window.parent.postMessage({type:"canvas-wheel-pan",data:c},"*")};return{enable:()=>{e||(e=!0,window.addEventListener("wheel",t,{capture:!0,passive:!1}))},disable:()=>{e&&(e=!1,window.removeEventListener("wheel",t,!0))}}}var ae="--base44-reference-vh-base";function $e(){let e=null,t=null,n,o,i="*",c=()=>{n!==void 0&&(window.clearTimeout(n),n=void 0),o!==void 0&&(window.clearTimeout(o),o=void 0)};return{freezeVhUnits:f=>{let u=St(f);if(wt(u),e){t?.();return}e=[],t=It(e)},measurePageHeight:(f,u=2e3)=>{i=f,c(),n=window.setTimeout(()=>{n=void 0,t?.();let p=Ye()+1500,m=-1,v=0,S=d=>{o=void 0,window.parent.postMessage({type:"page-height-measured",height:d},i)},s=()=>{o=void 0;let d=Ct();if(d===m?v++:(v=1,m=d),v>=3||Ye()>=p){S(d);return}o=window.setTimeout(s,16)};s()},u)},teardown:()=>{if(e){for(let f of e)f();e=null,t=null}c()}}}function Ye(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function St(e){if(e!==void 0)return e;let t=window.innerHeight||0;return t>=400?t:900}function wt(e){document.documentElement.style.setProperty(ae,`${e}px`)}function It(e){let t=/(\d+(?:\.\d+)?)(?:d|s|l)?vh\b/g,n=new WeakSet,o=new WeakMap,i=new WeakSet,c=new Set,f=new WeakSet,u=E=>E.replace(t,(h,L)=>`calc(var(${ae}) * ${Mt(L)})`),p=E=>{if(f.has(E))return;let L=window.getComputedStyle(E).overflowY;L!=="auto"&&L!=="scroll"||(f.add(E),E.style.setProperty("overflow-y","visible","important"))},m=E=>{p(E),E.querySelectorAll("*").forEach(p)},v=E=>{let h=E.style;if(!h||h.length===0)return;let L=[];for(let M=0;M<h.length;M++){let D=h[M];D&&L.push(D)}for(let M of L){let D=h.getPropertyValue(M);if(!D||D.indexOf("vh")===-1)continue;let k=u(D);k!==D&&h.setProperty(M,k,h.getPropertyPriority(M))}},s=Rt(()=>{document.querySelectorAll("style").forEach(E=>{if(w(E),n.has(E))return;n.add(E);let h=E.textContent;if(!h||h.indexOf("vh")===-1)return;let L=u(h);L!==h&&(E.textContent=L)});for(let E=0;E<document.styleSheets.length;E++){let h=document.styleSheets[E];if(!h)continue;let L;try{L=h.cssRules}catch{continue}o.get(h)!==L.length&&(Ue(L,u),o.set(h,L.length))}document.querySelectorAll('[style*="vh"]').forEach(v),document.body&&m(document.body)},16),d=s.trigger;e.push(s.cancel);let w=E=>{if(i.has(E))return;i.add(E);let h=new MutationObserver(()=>{n.delete(E),d()});h.observe(E,{characterData:!0,childList:!0,subtree:!0}),c.add(h)};e.push(()=>{for(let E of c)E.disconnect();c.clear()}),d(),document.readyState==="loading"&&(document.addEventListener("DOMContentLoaded",d),e.push(()=>document.removeEventListener("DOMContentLoaded",d))),window.addEventListener("load",d),e.push(()=>window.removeEventListener("load",d));let I=new MutationObserver(E=>{for(let h of E)if(Xe(h.addedNodes)||Xe(h.removedNodes)){d();return}});e.push(()=>I.disconnect());let T=()=>{document.head&&I.observe(document.head,{childList:!0,subtree:!1})};document.head?T():(document.addEventListener("DOMContentLoaded",T),e.push(()=>document.removeEventListener("DOMContentLoaded",T)));let O=E=>{if(!(E instanceof Element))return;let h=E.getAttribute("style");h&&h.indexOf("vh")!==-1&&v(E),E.querySelectorAll('[style*="vh"]').forEach(v),m(E)},Y=new MutationObserver(E=>{for(let h of E)if(h.type==="attributes"){let L=h.target;if(!(L instanceof Element))continue;let M=L.getAttribute("style");if(!M||M.indexOf("vh")===-1)continue;v(L)}else if(h.type==="childList")for(let L=0;L<h.addedNodes.length;L++){let M=h.addedNodes[L];M&&O(M)}});return e.push(()=>Y.disconnect()),(()=>{let E=document.documentElement;E&&Y.observe(E,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0})})(),d}function Mt(e){return String(Number((parseFloat(e)/100).toFixed(6)))}function Ue(e,t){for(let n=0;n<e.length;n++){let o=e[n];if(!o)continue;o.cssRules&&Ue(o.cssRules,t);let i=o.style;if(i)for(let c=0;c<i.length;c++){let f=i[c];if(!f)continue;let u=i.getPropertyValue(f);if(!u||u.indexOf("vh")===-1)continue;let p=t(u);p!==u&&i.setProperty(f,p,i.getPropertyPriority(f))}}}function Xe(e){for(let t=0;t<e.length;t++){let n=e[t];if(n instanceof HTMLStyleElement||n instanceof HTMLLinkElement)return!0}return!1}function Ct(){let e=Math.max(document.documentElement.scrollHeight,document.body?.scrollHeight??0),t=At(),n=Math.max(window.innerHeight||0,document.documentElement.clientHeight,t),o=_t(n);return o>0?Math.ceil(Math.max(o,t)):Math.ceil(Math.max(e,t))}function At(){let e=document.documentElement.style.getPropertyValue(ae),t=parseFloat(e);return Number.isFinite(t)?t:0}function _t(e){if(!document.body)return 0;let t=[document.body,...Array.from(document.body.querySelectorAll("*"))],n=new WeakMap,o=window.scrollY+e;for(let i=t.length-1;i>=0;i--){let c=t[i];if(!c)continue;let f=Dt(c,n),u=xt(c),p=Nt(u,f,e,o)?0:u.bottom;n.set(c,Math.max(f,p))}return n.get(document.body)??0}function Dt(e,t){let n=0;for(let o=0;o<e.children.length;o++){let i=e.children[o];i&&(n=Math.max(n,t.get(i)??0))}return n}function xt(e){let t=window.getComputedStyle(e);if(Ot(t))return{bottom:0,height:0};let n=e.getBoundingClientRect();return n.width===0&&n.height===0?{bottom:0,height:0}:{bottom:n.bottom+window.scrollY+Ht(t),height:n.height}}function Ht(e){let t=parseFloat(e.marginBottom);return Number.isFinite(t)?t:0}function Ot(e){return e.position==="fixed"?!0:e.position==="absolute"&&e.pointerEvents==="none"}function Nt(e,t,n,o){return t>0&&Math.abs(e.bottom-o)<=1&&Math.abs(e.height-n)<=1&&e.bottom-t>8}function Rt(e,t){let n;return{trigger:()=>{n!==void 0&&window.clearTimeout(n),n=window.setTimeout(e,t)},cancel:()=>{n!==void 0&&(window.clearTimeout(n),n=void 0)}}}var N="data-base44-suppressed-popup",Pt="--base44-reference-vh-base";function Ke(){let e=null,t=null,n=!1,o=!1,i=p=>{p.hasAttribute(N)||(de(p),o=!0,Bt())},c=p=>{if(!document.body)return;let{vw:m,vh:v}=qe(),S=p===document?[document.body]:p instanceof Element?[p]:[];for(let s of S){f(s,m,v);let d=s.querySelectorAll(`*:not([${N}])`);for(let w=0;w<d.length;w++){let I=d[w];I&&f(I,m,v)}}},f=(p,m,v)=>{kt(p,m,v)?i(p):o&&p instanceof HTMLElement&&Ge(p,m,v)&&de(p)},u=()=>{c(document),!e&&(e=new MutationObserver(p=>{for(let m of p)if(m.type==="childList")for(let v=0;v<m.addedNodes.length;v++){let S=m.addedNodes[v];S instanceof Element&&c(S)}}),e.observe(document.documentElement,{childList:!0,subtree:!0}))};return{suppress:()=>{n||(n=!0,document.body?u():(t=()=>{t=null,u()},document.addEventListener("DOMContentLoaded",t)))},teardown:()=>{n=!1,o=!1,e&&(e.disconnect(),e=null),t&&(document.removeEventListener("DOMContentLoaded",t),t=null)}}}function kt(e,t,n){if(!(e instanceof HTMLElement)||e.hasAttribute(N))return!1;let o=window.getComputedStyle(e);return o.position!=="fixed"||!Vt(e,t,n)||!ce(o)?!1:Ft(e,o)}function Ge(e,t,n){if(e.hasAttribute(N))return!1;let o=window.getComputedStyle(e);return o.position!=="fixed"||!ce(o)?!1:Wt(e,t,n)}function Bt(){if(!document.body)return;let{vw:e,vh:t}=qe();if(e<=0||t<=0)return;let n=document.body.querySelectorAll(`*:not([${N}])`);for(let o=0;o<n.length;o++){let i=n[o];i&&Ge(i,e,t)&&de(i)}}function Vt(e,t,n){if(t<=0||n<=0)return!1;let o=e.getBoundingClientRect();return o.width>=t*.9&&o.height>=n*.9}function Wt(e,t,n){let o=e.getBoundingClientRect();return o.width>=t*.15&&o.height>=n*.15&&o.width<=t*.95&&o.height<=n*.95}function ce(e){let t=parseInt(e.zIndex,10);return Number.isFinite(t)&&t>=40}function Ft(e,t){if(ze(t.backgroundColor)||t.backdropFilter&&t.backdropFilter!=="none")return!0;let n=e.querySelectorAll("*");for(let o=0;o<n.length;o++){let i=n[o];if(!i)continue;let c=window.getComputedStyle(i);if(!(c.position!=="fixed"&&c.position!=="absolute")&&ce(c)&&(ze(c.backgroundColor)||c.backdropFilter&&c.backdropFilter!=="none"))return!0}return!1}function ze(e){let t=Yt(e);return t!==null&&t>0&&t<1}function Yt(e){if(!e)return null;let t=/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*([0-9.]+)\s*)?\)$/.exec(e);if(t)return t[1]===void 0?1:parseFloat(t[1]);let n=/\/\s*([0-9.]+)(%?)\s*\)$/.exec(e);if(n){let o=parseFloat(n[1]);return n[2]==="%"?o/100:o}return/^[a-z]+\s*\(/.test(e)?1:null}function de(e){e.hasAttribute(N)||(e.setAttribute(N,"1"),e.style.setProperty("display","none","important"))}function qe(){let e=window.innerWidth||document.documentElement.clientWidth||0,t=document.documentElement.style.getPropertyValue(Pt),n=parseFloat(t),o=Number.isFinite(n)&&n>0?n:window.innerHeight||document.documentElement.clientHeight||0;return{vw:e,vh:o}}var U=50;function Xt(){let e=Fe(),t=$e(),n=Ke(),o=!1,i=!1,c=!1,f=[],u=[],p=[],m=null,v=null,S=(l=!1)=>{let r=document.createElement("div");return r.style.position="absolute",r.style.pointerEvents="none",r.style.transition="all 0.1s ease-in-out",r.style.zIndex="9999",l?r.style.border="2px solid #2563EB":(r.style.border="2px solid #95a5fc",r.style.backgroundColor="rgba(99, 102, 241, 0.05)"),r},s=(l,r,a=!1)=>{if(!r||!o)return;r.offsetWidth;let y=r.getBoundingClientRect();l.style.top=`${y.top+window.scrollY}px`,l.style.left=`${y.left+window.scrollX}px`,l.style.width=`${y.width}px`,l.style.height=`${y.height}px`;let b=l.querySelector("div");b||(b=document.createElement("div"),b.textContent=r.tagName.toLowerCase(),b.style.position="absolute",b.style.left="-2px",b.style.padding="2px 8px",b.style.fontSize="11px",b.style.fontWeight=a?"500":"400",b.style.color=a?"#ffffff":"#526cff",b.style.backgroundColor=a?"#2563EB":"#DBEAFE",b.style.borderRadius="3px",b.style.minWidth="24px",b.style.textAlign="center",l.appendChild(b)),pe(b,y)},d=se({findElementsById:x,getSelectedElementId:()=>m,getSelectedOverlays:()=>u,positionOverlay:s,clearSelection:()=>{d.clearSelectedMarks(m),T(),m=null,v=null},createSelectionOverlays:(l,r)=>{l.forEach(a=>{let g=S(!0);document.body.appendChild(g),u.push(g),s(g,a,!0)}),m=r}}),w=()=>{d.clearSelectedMarks(m),T(),m=null,v=null},I=()=>{f.forEach(l=>{l&&l.parentNode&&l.remove()}),f=[],p=[]},T=()=>{u.forEach(l=>{l&&l.parentNode&&l.remove()}),u=[]},O=["p","h1","h2","h3","h4","h5","h6","span","a","label"],Y=l=>{let r=l,a=l.getBoundingClientRect(),g=l,y=O.includes(l.tagName?.toLowerCase()),b=r.closest("[data-arr-variable-name]"),A=b?.dataset?.arrVariableName||null,R=b?.dataset?.arrIndex,ot=R!=null?parseInt(R,10):null,rt=r.dataset?.arrField||null,it=r.closest("[data-collection-id]"),st=r.closest("[data-collection-item-field]"),lt=r.closest("[data-collection-item-id]");window.parent.postMessage({type:"element-selected",tagName:l.tagName,classes:g.className?.baseVal||l.className||"",visualSelectorId:_(l),content:y?r.innerText:void 0,dataSourceLocation:r.dataset.sourceLocation,isDynamicContent:r.dataset.dynamicContent==="true",linenumber:r.dataset.linenumber,filename:r.dataset.filename,position:{top:a.top,left:a.left,right:a.right,bottom:a.bottom,width:a.width,height:a.height,centerX:a.left+a.width/2,centerY:a.top+a.height/2},attributes:he(l,j),isTextElement:y,staticArrayName:A,staticArrayIndex:ot,staticArrayField:rt,collectionId:it?.dataset?.collectionId||null,collectionItemField:st?.dataset?.collectionItemField||null,collectionItemId:lt?.dataset?.collectionItemId||null},"*")},z=l=>{let r=_(l);return T(),x(r||null).forEach(g=>{let y=S(!0);document.body.appendChild(y),u.push(y),s(y,g,!0)}),m=r||null,v=l,I(),Y(l),u[0]},E=()=>{m=null,window.parent.postMessage({type:"unselect-element"},"*")},h=null,L=null,M=()=>{I(),h=null},D=l=>{let r=x(l);I(),r.forEach(a=>{let g=S(!1);document.body.appendChild(g),f.push(g),s(g,a)}),p=r,h=l},k=l=>{!o||i||d.isEditing()||L===null&&(L=requestAnimationFrame(()=>{if(L=null,c){M();return}let r=be(l.clientX,l.clientY,m);if(!r){M();return}h!==r&&D(r)}))},K=()=>{L!==null&&(cancelAnimationFrame(L),L=null),M()},ue=l=>{if(!o)return;let r=l.target;if(r.closest(`[${V}]`)||d.enabled&&r instanceof HTMLElement&&r.contentEditable==="true")return;if(d.isEditing()){l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation(),d.stopEditing();return}if(c){l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation(),window.parent.postMessage({type:"close-dropdowns"},"*");return}l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation();let a=Z(l.clientX,l.clientY);if(!a)return;let g=a,y=_(a);if(m===y&&g.dataset.selected==="true"&&d.enabled&&d.canEdit(g)){d.startEditing(g);return}d.stopEditing(),d.enabled&&d.markElementsSelected(x(y));let A=z(a);me.attachToOverlay(A,a)},je=()=>{d.stopEditing(),w()},Ze=(l,r)=>{let a=x(l);a.length!==0&&(Ee(a,r),setTimeout(()=>{m===l&&u.forEach((g,y)=>{y<a.length&&s(g,a[y])}),p.length>0&&p[0]?.dataset?.visualSelectorId===l&&f.forEach((b,A)=>{A<p.length&&s(b,p[A])})},U))},Je=(l,r,a)=>{let g=x(l);g.length!==0&&(ge(g,r,a),setTimeout(()=>{m===l&&u.forEach((y,b)=>{b<g.length&&s(y,g[b])})},U))},Qe=(l,r,a)=>{let g=x(l);g.length!==0&&(a!=null&&(g=g.filter(y=>y.dataset.arrIndex===String(a))),g.forEach(y=>{y.innerText=r}),setTimeout(()=>{m===l&&u.forEach((y,b)=>{b<g.length&&s(y,g[b])})},U))},me=ke({createPreviewOverlay:l=>{let r=S(!1);return r.style.zIndex="9998",document.body.appendChild(r),s(r,l),r},getSelectedElementId:()=>m,selectElement:z,onDeselect:E}),et=l=>{o=l,l?(document.body.style.cursor="crosshair",ve(),document.addEventListener("mousemove",k),document.addEventListener("mouseleave",K),document.addEventListener("click",ue,!0)):(e.disable(),ye(),d.stopEditing(),w(),me.cleanup(),K(),document.body.style.cursor="default",document.removeEventListener("mousemove",k),document.removeEventListener("mouseleave",K),document.removeEventListener("click",ue,!0))},fe=()=>{if(m){let l=v;if(l&&l.isConnected){let r=l.getBoundingClientRect(),a=window.innerHeight,g=window.innerWidth,y=r.top<a&&r.bottom>0&&r.left<g&&r.right>0,b={top:r.top,left:r.left,right:r.right,bottom:r.bottom,width:r.width,height:r.height,centerX:r.left+r.width/2,centerY:r.top+r.height/2};window.parent.postMessage({type:"element-position-update",position:b,isInViewport:y,visualSelectorId:m},"*")}}},tt=l=>{let r=l.data;switch(r.type){case"toggle-visual-edit-mode":et(r.data.enabled),r.data.specs?.newInlineEditEnabled!==void 0&&(d.enabled=r.data.specs.newInlineEditEnabled);break;case"update-classes":r.data&&r.data.classes!==void 0?Ze(r.data.visualSelectorId,r.data.classes):console.warn("[VisualEditAgent] Invalid update-classes message:",r);break;case"update-attribute":r.data&&r.data.visualSelectorId&&r.data.attribute!==void 0&&r.data.value!==void 0?Je(r.data.visualSelectorId,r.data.attribute,r.data.value):console.warn("[VisualEditAgent] Invalid update-attribute message:",r);break;case"unselect-element":je();break;case"refresh-page":window.location.reload();break;case"update-content":r.data&&r.data.content!==void 0?Qe(r.data.visualSelectorId,r.data.content,r.data.arrIndex):console.warn("[VisualEditAgent] Invalid update-content message:",r);break;case"request-element-position":if(m&&v&&v.isConnected){let a=v.getBoundingClientRect(),g=window.innerHeight,y=window.innerWidth,b=a.top<g&&a.bottom>0&&a.left<y&&a.right>0,A={top:a.top,left:a.left,right:a.right,bottom:a.bottom,width:a.width,height:a.height,centerX:a.left+a.width/2,centerY:a.top+a.height/2};window.parent.postMessage({type:"element-position-update",position:A,isInViewport:b,visualSelectorId:m},"*")}break;case"popover-drag-state":r.data&&r.data.isDragging!==void 0&&(i=r.data.isDragging,r.data.isDragging&&I());break;case"dropdown-state":r.data&&r.data.isOpen!==void 0&&(c=r.data.isOpen,r.data.isOpen&&I());break;case"update-theme-variables":if(r.data?.variables){let a=r.data.mode==="dark"?document.querySelector(".dark"):document.documentElement;if(a)for(let[g,y]of Object.entries(r.data.variables))a.style.setProperty(g,y)}break;case"inject-font-import":if(r.data?.fontUrl){let a=document.getElementById(le);a||(a=document.createElement("style"),a.id=le,document.head.appendChild(a)),a.textContent=`@import url('${r.data.fontUrl}');`}break;case"toggle-inline-edit-mode":r.data&&d.handleToggleMessage(r.data);break;case"freeze-vh-units":t.freezeVhUnits(typeof r.referenceVhBase=="number"?r.referenceVhBase:void 0);break;case"measure-page-height":t.measurePageHeight(l.origin&&l.origin!=="null"?l.origin:"*",typeof r.settleMs=="number"?r.settleMs:void 0);break;case"suppress-auto-popups":n.suppress();break;case"toggle-canvas-wheel-zoom-bridge":e.enable();break;default:break}},G=()=>{if(m){let l=x(m);u.forEach((r,a)=>{a<l.length&&s(r,l[a])})}p.length>0&&f.forEach((l,r)=>{r<p.length&&s(l,p[r])})};document.querySelectorAll("[data-linenumber]:not([data-visual-selector-id])").forEach((l,r)=>{let a=l,g=`visual-id-${a.dataset.filename}-${a.dataset.linenumber}-${r}`;a.dataset.visualSelectorId=g});let nt=new MutationObserver(l=>{l.some(a=>{let g=b=>{if(b.nodeType===Node.ELEMENT_NODE){let A=b;if(A.dataset&&A.dataset.visualSelectorId)return!0;for(let R=0;R<A.children.length;R++)if(g(A.children[R]))return!0}return!1};return a.type==="attributes"&&(a.attributeName==="style"||a.attributeName==="class"||a.attributeName==="width"||a.attributeName==="height")&&g(a.target)})&&setTimeout(G,U)});window.addEventListener("message",tt),window.addEventListener("scroll",fe,!0),document.addEventListener("scroll",fe,!0),window.addEventListener("resize",G),window.addEventListener("scroll",G),nt.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class","width","height"]}),window.parent.postMessage({type:"visual-edit-agent-ready"},"*")}export{Xt as setupVisualEditAgent};
|
|
15
|
+
`,document.head.appendChild(e)},We=()=>{document.getElementById(oe)?.remove()},Fe=e=>{let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},yt=e=>!(e instanceof HTMLElement)||!vt(e)?!1:re(e)?!0:e.dataset.dynamicContent!=="true",ie=e=>!(e instanceof HTMLElement)||e.dataset.selected!=="true"?!1:yt(e);var bt=500;function se(e){let t=null,n=null,r=!1,s=new WeakMap,c=()=>{let i=e.getSelectedElementId();if(!i)return;let d=e.findElementsById(i);e.getSelectedOverlays().forEach((C,w)=>{w<d.length&&d[w]&&e.positionOverlay(C,d[w])})},f=i=>{let d=i.dataset.originalTextContent,S=i.textContent,C=i,w=i.getBoundingClientRect(),O={type:"inline-edit",elementInfo:{tagName:i.tagName,classes:C.className?.baseVal||i.className||"",visualSelectorId:e.getSelectedElementId(),content:S,dataSourceLocation:i.dataset.sourceLocation,isDynamicContent:i.dataset.dynamicContent==="true",linenumber:i.dataset.linenumber,filename:i.dataset.filename,position:{top:w.top,left:w.left,right:w.right,bottom:w.bottom,width:w.width,height:w.height,centerX:w.left+w.width/2,centerY:w.top+w.height/2}},originalContent:d,newContent:S};re(i)&&(O.arrIndex=i.dataset.arrIndex,O.arrVariableName=i.dataset.arrVariableName,O.arrField=i.dataset.arrField),window.parent.postMessage(O,"*"),i.dataset.originalTextContent=S||""},u=i=>{n&&clearTimeout(n),n=setTimeout(()=>f(i),bt)},h=i=>{c(),u(i)},m=function(){h(this)},v=i=>{Ve(),i.dataset.originalTextContent=i.textContent||"",i.dataset.originalCursor=i.style.cursor,i.contentEditable="true",i.setAttribute(M,"true");let d=new AbortController;s.set(i,d),i.addEventListener("input",m,{signal:d.signal}),i.style.cursor="text",Fe(i),setTimeout(()=>{i.isConnected&&i.focus()},0)},L=i=>{let d=s.get(i);d&&(d.abort(),s.delete(i)),i.isConnected&&(We(),i.contentEditable="false",i.removeAttribute(M),delete i.dataset.originalTextContent,i.dataset.originalCursor!==void 0&&(i.style.cursor=i.dataset.originalCursor,delete i.dataset.originalCursor))};return{get enabled(){return r},set enabled(i){r=i},isEditing(){return t!==null},getCurrentElement(){return t},canEdit(i){return ie(i)},startEditing(i){t=i,e.getSelectedOverlays().forEach(d=>{d.style.display="none"}),v(i),window.parent.postMessage({type:"content-editing-started",visualSelectorId:e.getSelectedElementId()},"*")},stopEditing(){if(!t)return;n&&(clearTimeout(n),n=null),L(t),e.getSelectedOverlays().forEach(d=>{d.style.display=""}),c(),window.parent.postMessage({type:"content-editing-ended",visualSelectorId:e.getSelectedElementId()},"*"),t=null},markElementsSelected(i){i.forEach(d=>{d instanceof HTMLElement&&(d.dataset.selected="true")})},clearSelectedMarks(i){i&&e.findElementsById(i).forEach(d=>{d instanceof HTMLElement&&delete d.dataset.selected})},handleToggleMessage(i){if(!r)return;let d=e.findElementsById(i.dataSourceLocation);if(d.length===0||!(d[0]instanceof HTMLElement))return;let S=d[0];if(i.inlineEditingMode){if(!ie(S))return;e.getSelectedElementId()!==i.dataSourceLocation&&(this.stopEditing(),e.clearSelection(),this.markElementsSelected(d),e.createSelectionOverlays(d,i.dataSourceLocation)),this.startEditing(S)}else t===S&&this.stopEditing()},cleanup(){this.stopEditing()}}}var le="__theme-font-preview";function Lt(e){return e instanceof Element?e:e instanceof Node?e.parentElement:null}function Tt(e){return Lt(e)?.closest(`[${M}]`)!=null}function Ye(){let e=!1,t=s=>{if(Tt(s.target))return;if(s.preventDefault(),s.ctrlKey||s.metaKey){window.parent.postMessage({type:"canvas-wheel-zoom",data:{deltaY:s.deltaY,deltaMode:s.deltaMode,clientX:s.clientX,clientY:s.clientY,ctrlKey:s.ctrlKey,metaKey:s.metaKey}},"*");return}let c={deltaX:s.deltaX,deltaY:s.deltaY,deltaMode:s.deltaMode,clientX:s.clientX,clientY:s.clientY,shiftKey:s.shiftKey,ctrlKey:!1,metaKey:!1};window.parent.postMessage({type:"canvas-wheel-pan",data:c},"*")};return{enable:()=>{e||(e=!0,window.addEventListener("wheel",t,{capture:!0,passive:!1}))},disable:()=>{e&&(e=!1,window.removeEventListener("wheel",t,!0))}}}var ae="--base44-reference-vh-base";function Ue(){let e=null,t=null,n,r,s="*",c=()=>{n!==void 0&&(window.clearTimeout(n),n=void 0),r!==void 0&&(window.clearTimeout(r),r=void 0)};return{freezeVhUnits:f=>{let u=wt(f);if(St(u),e){t?.();return}e=[],t=It(e)},measurePageHeight:(f,u=2e3)=>{s=f,c(),n=window.setTimeout(()=>{n=void 0,t?.();let h=Xe()+1500,m=-1,v=0,L=d=>{r=void 0,window.parent.postMessage({type:"page-height-measured",height:d},s)},i=()=>{r=void 0;let d=Ct();if(d===m?v++:(v=1,m=d),v>=3||Xe()>=h){L(d);return}r=window.setTimeout(i,16)};i()},u)},teardown:()=>{if(e){for(let f of e)f();e=null,t=null}c()}}}function Xe(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function wt(e){if(e!==void 0)return e;let t=window.innerHeight||0;return t>=400?t:900}function St(e){document.documentElement.style.setProperty(ae,`${e}px`)}function It(e){let t=/(\d+(?:\.\d+)?)(?:d|s|l)?vh\b/g,n=new WeakSet,r=new WeakMap,s=new WeakSet,c=new Set,f=new WeakSet,u=p=>p.replace(t,(g,T)=>`calc(var(${ae}) * ${Mt(T)})`),h=p=>{if(f.has(p))return;let T=window.getComputedStyle(p).overflowY;T!=="auto"&&T!=="scroll"||(f.add(p),p.style.setProperty("overflow-y","visible","important"))},m=p=>{h(p),p.querySelectorAll("*").forEach(h)},v=p=>{let g=p.style;if(!g||g.length===0)return;let T=[];for(let I=0;I<g.length;I++){let D=g[I];D&&T.push(D)}for(let I of T){let D=g.getPropertyValue(I);if(!D||D.indexOf("vh")===-1)continue;let k=u(D);k!==D&&g.setProperty(I,k,g.getPropertyPriority(I))}},i=Rt(()=>{document.querySelectorAll("style").forEach(p=>{if(S(p),n.has(p))return;n.add(p);let g=p.textContent;if(!g||g.indexOf("vh")===-1)return;let T=u(g);T!==g&&(p.textContent=T)});for(let p=0;p<document.styleSheets.length;p++){let g=document.styleSheets[p];if(!g)continue;let T;try{T=g.cssRules}catch{continue}r.get(g)!==T.length&&(ze(T,u),r.set(g,T.length))}document.querySelectorAll('[style*="vh"]').forEach(v),document.body&&m(document.body)},16),d=i.trigger;e.push(i.cancel);let S=p=>{if(s.has(p))return;s.add(p);let g=new MutationObserver(()=>{n.delete(p),d()});g.observe(p,{characterData:!0,childList:!0,subtree:!0}),c.add(g)};e.push(()=>{for(let p of c)p.disconnect();c.clear()}),d(),document.readyState==="loading"&&(document.addEventListener("DOMContentLoaded",d),e.push(()=>document.removeEventListener("DOMContentLoaded",d))),window.addEventListener("load",d),e.push(()=>window.removeEventListener("load",d));let C=new MutationObserver(p=>{for(let g of p)if($e(g.addedNodes)||$e(g.removedNodes)){d();return}});e.push(()=>C.disconnect());let w=()=>{document.head&&C.observe(document.head,{childList:!0,subtree:!1})};document.head?w():(document.addEventListener("DOMContentLoaded",w),e.push(()=>document.removeEventListener("DOMContentLoaded",w)));let O=p=>{if(!(p instanceof Element))return;let g=p.getAttribute("style");g&&g.indexOf("vh")!==-1&&v(p),p.querySelectorAll('[style*="vh"]').forEach(v),m(p)},Y=new MutationObserver(p=>{for(let g of p)if(g.type==="attributes"){let T=g.target;if(!(T instanceof Element))continue;let I=T.getAttribute("style");if(!I||I.indexOf("vh")===-1)continue;v(T)}else if(g.type==="childList")for(let T=0;T<g.addedNodes.length;T++){let I=g.addedNodes[T];I&&O(I)}});return e.push(()=>Y.disconnect()),(()=>{let p=document.documentElement;p&&Y.observe(p,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0})})(),d}function Mt(e){return String(Number((parseFloat(e)/100).toFixed(6)))}function ze(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(!r)continue;r.cssRules&&ze(r.cssRules,t);let s=r.style;if(s)for(let c=0;c<s.length;c++){let f=s[c];if(!f)continue;let u=s.getPropertyValue(f);if(!u||u.indexOf("vh")===-1)continue;let h=t(u);h!==u&&s.setProperty(f,h,s.getPropertyPriority(f))}}}function $e(e){for(let t=0;t<e.length;t++){let n=e[t];if(n instanceof HTMLStyleElement||n instanceof HTMLLinkElement)return!0}return!1}function Ct(){let e=Math.max(document.documentElement.scrollHeight,document.body?.scrollHeight??0),t=At(),n=Math.max(window.innerHeight||0,document.documentElement.clientHeight,t),r=_t(n);return r>0?Math.ceil(Math.max(r,t)):Math.ceil(Math.max(e,t))}function At(){let e=document.documentElement.style.getPropertyValue(ae),t=parseFloat(e);return Number.isFinite(t)?t:0}function _t(e){if(!document.body)return 0;let t=[document.body,...Array.from(document.body.querySelectorAll("*"))],n=new WeakMap,r=window.scrollY+e;for(let s=t.length-1;s>=0;s--){let c=t[s];if(!c)continue;let f=Dt(c,n),u=Ht(c),h=Nt(u,f,e,r)?0:u.bottom;n.set(c,Math.max(f,h))}return n.get(document.body)??0}function Dt(e,t){let n=0;for(let r=0;r<e.children.length;r++){let s=e.children[r];s&&(n=Math.max(n,t.get(s)??0))}return n}function Ht(e){let t=window.getComputedStyle(e);if(Ot(t))return{bottom:0,height:0};let n=e.getBoundingClientRect();return n.width===0&&n.height===0?{bottom:0,height:0}:{bottom:n.bottom+window.scrollY+xt(t),height:n.height}}function xt(e){let t=parseFloat(e.marginBottom);return Number.isFinite(t)?t:0}function Ot(e){return e.position==="fixed"?!0:e.position==="absolute"&&e.pointerEvents==="none"}function Nt(e,t,n,r){return t>0&&Math.abs(e.bottom-r)<=1&&Math.abs(e.height-n)<=1&&e.bottom-t>8}function Rt(e,t){let n;return{trigger:()=>{n!==void 0&&window.clearTimeout(n),n=window.setTimeout(e,t)},cancel:()=>{n!==void 0&&(window.clearTimeout(n),n=void 0)}}}var N="data-base44-suppressed-popup",Pt="--base44-reference-vh-base";function Ge(){let e=null,t=null,n=!1,r=!1,s=(m,v)=>{if(!(m instanceof HTMLElement)||m.hasAttribute(N))return;let L=window.getComputedStyle(m);if(L.position==="fixed"&&ue(L)){if(Vt(m,v)&&Wt(m,L)){c(m);return}r&&qe(m,v)&&ce(m)}},c=m=>{m.hasAttribute(N)||(ce(m),r=!0,kt(de()))},f=(m,v)=>{s(m,v);let L=m.querySelectorAll(`*:not([${N}])`);for(let i=0;i<L.length;i++){let d=L[i];d&&s(d,v)}},u=()=>{e||(e=new MutationObserver(m=>{let v=de();for(let L of m)if(L.type==="childList")for(let i=0;i<L.addedNodes.length;i++){let d=L.addedNodes[i];d instanceof Element&&f(d,v)}}),e.observe(document.documentElement,{childList:!0,subtree:!0}))},h=()=>{document.body&&(f(document.body,de()),u())};return{suppress:()=>{n||(n=!0,document.body?h():(t=()=>{t=null,h()},document.addEventListener("DOMContentLoaded",t)))},teardown:()=>{n=!1,r=!1,e&&(e.disconnect(),e=null),t&&(document.removeEventListener("DOMContentLoaded",t),t=null)}}}function kt(e){if(!document.body||e.vw<=0||e.vh<=0)return;let t=document.body.querySelectorAll(`*:not([${N}])`);for(let n=0;n<t.length;n++){let r=t[n];r&&Bt(r,e)&&ce(r)}}function Bt(e,t){if(e.hasAttribute(N))return!1;let n=window.getComputedStyle(e);return n.position!=="fixed"||!ue(n)?!1:qe(e,t)}function Vt(e,t){if(t.vw<=0||t.vh<=0)return!1;let n=e.getBoundingClientRect();return n.width>=t.vw*.9&&n.height>=t.vh*.9}function qe(e,t){let n=e.getBoundingClientRect();return n.width>=t.vw*.15&&n.height>=t.vh*.15&&n.width<=t.vw*.95&&n.height<=t.vh*.95}function ue(e){let t=parseInt(e.zIndex,10);return Number.isFinite(t)&&t>=40}function Wt(e,t){if(Ke(t.backgroundColor)||t.backdropFilter&&t.backdropFilter!=="none")return!0;let n=e.querySelectorAll("*");for(let r=0;r<n.length;r++){let s=n[r];if(!s)continue;let c=window.getComputedStyle(s);if(!(c.position!=="fixed"&&c.position!=="absolute")&&ue(c)&&(Ke(c.backgroundColor)||c.backdropFilter&&c.backdropFilter!=="none"))return!0}return!1}function Ke(e){let t=Ft(e);return t!==null&&t>0&&t<1}function Ft(e){if(!e)return null;let t=/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*([0-9.]+)\s*)?\)$/.exec(e);if(t)return t[1]===void 0?1:parseFloat(t[1]);let n=/\/\s*([0-9.]+)(%?)\s*\)$/.exec(e);if(n){let r=parseFloat(n[1]);return n[2]==="%"?r/100:r}return/^[a-z]+\s*\(/.test(e)?1:null}function de(){let e=window.innerWidth||document.documentElement.clientWidth||0,t=document.documentElement.style.getPropertyValue(Pt),n=parseFloat(t),r=Number.isFinite(n)&&n>0?n:window.innerHeight||document.documentElement.clientHeight||0;return{vw:e,vh:r}}function ce(e){e.hasAttribute(N)||(e.setAttribute(N,"1"),e.style.setProperty("display","none","important"))}var U=50;function Yt(){let e=Ye(),t=Ue(),n=Ge(),r=!1,s=!1,c=!1,f=[],u=[],h=[],m=null,v=null,L=(l=!1)=>{let o=document.createElement("div");return o.style.position="absolute",o.style.pointerEvents="none",o.style.transition="all 0.1s ease-in-out",o.style.zIndex="9999",l?o.style.border="2px solid #2563EB":(o.style.border="2px solid #95a5fc",o.style.backgroundColor="rgba(99, 102, 241, 0.05)"),o},i=(l,o,a=!1)=>{if(!o||!r)return;o.offsetWidth;let y=o.getBoundingClientRect();l.style.top=`${y.top+window.scrollY}px`,l.style.left=`${y.left+window.scrollX}px`,l.style.width=`${y.width}px`,l.style.height=`${y.height}px`;let b=l.querySelector("div");b||(b=document.createElement("div"),b.textContent=o.tagName.toLowerCase(),b.style.position="absolute",b.style.left="-2px",b.style.padding="2px 8px",b.style.fontSize="11px",b.style.fontWeight=a?"500":"400",b.style.color=a?"#ffffff":"#526cff",b.style.backgroundColor=a?"#2563EB":"#DBEAFE",b.style.borderRadius="3px",b.style.minWidth="24px",b.style.textAlign="center",l.appendChild(b)),Ee(b,y)},d=se({findElementsById:H,getSelectedElementId:()=>m,getSelectedOverlays:()=>u,positionOverlay:i,clearSelection:()=>{d.clearSelectedMarks(m),w(),m=null,v=null},createSelectionOverlays:(l,o)=>{l.forEach(a=>{let E=L(!0);document.body.appendChild(E),u.push(E),i(E,a,!0)}),m=o}}),S=()=>{d.clearSelectedMarks(m),w(),m=null,v=null},C=()=>{f.forEach(l=>{l&&l.parentNode&&l.remove()}),f=[],h=[]},w=()=>{u.forEach(l=>{l&&l.parentNode&&l.remove()}),u=[]},O=["p","h1","h2","h3","h4","h5","h6","span","a","label"],Y=l=>{let o=l,a=l.getBoundingClientRect(),E=l,y=O.includes(l.tagName?.toLowerCase()),b=o.closest("[data-arr-variable-name]"),A=b?.dataset?.arrVariableName||null,R=b?.dataset?.arrIndex,ot=R!=null?parseInt(R,10):null,rt=o.dataset?.arrField||null,it=o.closest("[data-collection-id]"),st=o.closest("[data-collection-item-field]"),lt=o.closest("[data-collection-item-id]");window.parent.postMessage({type:"element-selected",tagName:l.tagName,classes:E.className?.baseVal||l.className||"",visualSelectorId:_(l),content:y?o.innerText:void 0,dataSourceLocation:o.dataset.sourceLocation,isDynamicContent:o.dataset.dynamicContent==="true",linenumber:o.dataset.linenumber,filename:o.dataset.filename,position:{top:a.top,left:a.left,right:a.right,bottom:a.bottom,width:a.width,height:a.height,centerX:a.left+a.width/2,centerY:a.top+a.height/2},attributes:ve(l,j),isTextElement:y,staticArrayName:A,staticArrayIndex:ot,staticArrayField:rt,collectionId:it?.dataset?.collectionId||null,collectionItemField:st?.dataset?.collectionItemField||null,collectionItemId:lt?.dataset?.collectionItemId||null},"*")},z=l=>{let o=_(l);return w(),H(o||null).forEach(E=>{let y=L(!0);document.body.appendChild(y),u.push(y),i(y,E,!0)}),m=o||null,v=l,C(),Y(l),u[0]},p=()=>{m=null,window.parent.postMessage({type:"unselect-element"},"*")},g=null,T=null,I=()=>{C(),g=null},D=l=>{let o=H(l);C(),o.forEach(a=>{let E=L(!1);document.body.appendChild(E),f.push(E),i(E,a)}),h=o,g=l},k=l=>{!r||s||d.isEditing()||T===null&&(T=requestAnimationFrame(()=>{if(T=null,c){I();return}let o=Le(l.clientX,l.clientY,m);if(!o){I();return}g!==o&&D(o)}))},K=()=>{T!==null&&(cancelAnimationFrame(T),T=null),I()},me=l=>{if(!r)return;let o=l.target;if(o.closest(`[${V}]`)||d.enabled&&o instanceof HTMLElement&&o.contentEditable==="true")return;if(d.isEditing()){l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation(),d.stopEditing();return}if(c){l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation(),window.parent.postMessage({type:"close-dropdowns"},"*");return}l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation();let a=Z(l.clientX,l.clientY);if(!a)return;let E=a,y=_(a);if(m===y&&E.dataset.selected==="true"&&d.enabled&&d.canEdit(E)){d.startEditing(E);return}d.stopEditing(),d.enabled&&d.markElementsSelected(H(y));let A=z(a);fe.attachToOverlay(A,a)},je=()=>{d.stopEditing(),S()},Ze=(l,o)=>{let a=H(l);a.length!==0&&(ge(a,o),setTimeout(()=>{m===l&&u.forEach((E,y)=>{y<a.length&&i(E,a[y])}),h.length>0&&h[0]?.dataset?.visualSelectorId===l&&f.forEach((b,A)=>{A<h.length&&i(b,h[A])})},U))},Je=(l,o,a)=>{let E=H(l);E.length!==0&&(he(E,o,a),setTimeout(()=>{m===l&&u.forEach((y,b)=>{b<E.length&&i(y,E[b])})},U))},Qe=(l,o,a)=>{let E=H(l);E.length!==0&&(a!=null&&(E=E.filter(y=>y.dataset.arrIndex===String(a))),E.forEach(y=>{y.innerText=o}),setTimeout(()=>{m===l&&u.forEach((y,b)=>{b<E.length&&i(y,E[b])})},U))},fe=Be({createPreviewOverlay:l=>{let o=L(!1);return o.style.zIndex="9998",document.body.appendChild(o),i(o,l),o},getSelectedElementId:()=>m,selectElement:z,onDeselect:p}),et=l=>{r=l,l?(document.body.style.cursor="crosshair",ye(),document.addEventListener("mousemove",k),document.addEventListener("mouseleave",K),document.addEventListener("click",me,!0)):(e.disable(),be(),d.stopEditing(),S(),fe.cleanup(),K(),document.body.style.cursor="default",document.removeEventListener("mousemove",k),document.removeEventListener("mouseleave",K),document.removeEventListener("click",me,!0))},pe=()=>{if(m){let l=v;if(l&&l.isConnected){let o=l.getBoundingClientRect(),a=window.innerHeight,E=window.innerWidth,y=o.top<a&&o.bottom>0&&o.left<E&&o.right>0,b={top:o.top,left:o.left,right:o.right,bottom:o.bottom,width:o.width,height:o.height,centerX:o.left+o.width/2,centerY:o.top+o.height/2};window.parent.postMessage({type:"element-position-update",position:b,isInViewport:y,visualSelectorId:m},"*")}}},tt=l=>{let o=l.data;switch(o.type){case"toggle-visual-edit-mode":et(o.data.enabled),o.data.specs?.newInlineEditEnabled!==void 0&&(d.enabled=o.data.specs.newInlineEditEnabled);break;case"update-classes":o.data&&o.data.classes!==void 0?Ze(o.data.visualSelectorId,o.data.classes):console.warn("[VisualEditAgent] Invalid update-classes message:",o);break;case"update-attribute":o.data&&o.data.visualSelectorId&&o.data.attribute!==void 0&&o.data.value!==void 0?Je(o.data.visualSelectorId,o.data.attribute,o.data.value):console.warn("[VisualEditAgent] Invalid update-attribute message:",o);break;case"unselect-element":je();break;case"refresh-page":window.location.reload();break;case"update-content":o.data&&o.data.content!==void 0?Qe(o.data.visualSelectorId,o.data.content,o.data.arrIndex):console.warn("[VisualEditAgent] Invalid update-content message:",o);break;case"request-element-position":if(m&&v&&v.isConnected){let a=v.getBoundingClientRect(),E=window.innerHeight,y=window.innerWidth,b=a.top<E&&a.bottom>0&&a.left<y&&a.right>0,A={top:a.top,left:a.left,right:a.right,bottom:a.bottom,width:a.width,height:a.height,centerX:a.left+a.width/2,centerY:a.top+a.height/2};window.parent.postMessage({type:"element-position-update",position:A,isInViewport:b,visualSelectorId:m},"*")}break;case"popover-drag-state":o.data&&o.data.isDragging!==void 0&&(s=o.data.isDragging,o.data.isDragging&&C());break;case"dropdown-state":o.data&&o.data.isOpen!==void 0&&(c=o.data.isOpen,o.data.isOpen&&C());break;case"update-theme-variables":if(o.data?.variables){let a=o.data.mode==="dark"?document.querySelector(".dark"):document.documentElement;if(a)for(let[E,y]of Object.entries(o.data.variables))a.style.setProperty(E,y)}break;case"inject-font-import":if(o.data?.fontUrl){let a=document.getElementById(le);a||(a=document.createElement("style"),a.id=le,document.head.appendChild(a)),a.textContent=`@import url('${o.data.fontUrl}');`}break;case"toggle-inline-edit-mode":o.data&&d.handleToggleMessage(o.data);break;case"freeze-vh-units":t.freezeVhUnits(typeof o.referenceVhBase=="number"?o.referenceVhBase:void 0);break;case"measure-page-height":t.measurePageHeight(l.origin&&l.origin!=="null"?l.origin:"*",typeof o.settleMs=="number"?o.settleMs:void 0);break;case"suppress-auto-popups":n.suppress();break;case"toggle-canvas-wheel-zoom-bridge":e.enable();break;default:break}},G=()=>{if(m){let l=H(m);u.forEach((o,a)=>{a<l.length&&i(o,l[a])})}h.length>0&&f.forEach((l,o)=>{o<h.length&&i(l,h[o])})};document.querySelectorAll("[data-linenumber]:not([data-visual-selector-id])").forEach((l,o)=>{let a=l,E=`visual-id-${a.dataset.filename}-${a.dataset.linenumber}-${o}`;a.dataset.visualSelectorId=E});let nt=new MutationObserver(l=>{l.some(a=>{let E=b=>{if(b.nodeType===Node.ELEMENT_NODE){let A=b;if(A.dataset&&A.dataset.visualSelectorId)return!0;for(let R=0;R<A.children.length;R++)if(E(A.children[R]))return!0}return!1};return a.type==="attributes"&&(a.attributeName==="style"||a.attributeName==="class"||a.attributeName==="width"||a.attributeName==="height")&&E(a.target)})&&setTimeout(G,U)});window.addEventListener("message",tt),window.addEventListener("scroll",pe,!0),document.addEventListener("scroll",pe,!0),window.addEventListener("resize",G),window.addEventListener("scroll",G),nt.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class","width","height"]}),window.parent.postMessage({type:"visual-edit-agent-ready"},"*")}export{Yt as setupVisualEditAgent};
|
|
16
16
|
//# sourceMappingURL=index.mjs.map
|