tempo-sdk 0.0.45 → 0.0.51

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.
Files changed (38) hide show
  1. package/dist/assets/editor.d.ts +1 -1
  2. package/dist/assets/editor.js +4 -2
  3. package/dist/assets/editor.js.map +1 -1
  4. package/dist/assets/index.d.ts +112 -24
  5. package/dist/assets/index.js +309 -1
  6. package/dist/assets/index.js.map +1 -1
  7. package/dist/assets/parser.d.ts +14 -3
  8. package/dist/assets/parser.js +7 -3
  9. package/dist/canvas/index.d.ts +1 -1
  10. package/dist/canvas/index.js +3 -2
  11. package/dist/canvas/index.js.map +1 -1
  12. package/dist/canvas/interact-projection.js +2 -1
  13. package/dist/canvas/svelte.d.ts +1 -1
  14. package/dist/canvas/svelte.js +1 -1
  15. package/dist/chunk-DI2ZFAWL.js +14 -0
  16. package/dist/chunk-DI2ZFAWL.js.map +1 -0
  17. package/dist/chunk-DX6XAXCK.js +827 -0
  18. package/dist/chunk-DX6XAXCK.js.map +1 -0
  19. package/dist/{chunk-7AJVPFFG.js → chunk-LFYKJJC5.js} +3 -3
  20. package/dist/{chunk-7AJVPFFG.js.map → chunk-LFYKJJC5.js.map} +1 -1
  21. package/dist/{chunk-IWULHYPW.js → chunk-O65OD3NA.js} +216 -19
  22. package/dist/chunk-O65OD3NA.js.map +1 -0
  23. package/dist/{chunk-7O6DPEMF.js → chunk-PULSTDX2.js} +9 -3
  24. package/dist/chunk-PULSTDX2.js.map +1 -0
  25. package/dist/{chunk-FIIU52RN.js → chunk-ZZYNOX24.js} +22 -810
  26. package/dist/chunk-ZZYNOX24.js.map +1 -0
  27. package/dist/index.js +86 -13
  28. package/dist/index.js.map +1 -1
  29. package/dist/nextjs/plugin.js +1 -1
  30. package/dist/nextjs.cjs +2 -2
  31. package/dist/nextjs.cjs.map +1 -1
  32. package/dist/nextjs.js +1 -1
  33. package/dist/{storyboard-xVaRTJAu.d.ts → storyboard-CBHki7Aw.d.ts} +2 -1
  34. package/dist/{types-B-dRoF2T.d.ts → types-C7cvcY6T.d.ts} +5 -1
  35. package/package.json +2 -2
  36. package/dist/chunk-7O6DPEMF.js.map +0 -1
  37. package/dist/chunk-FIIU52RN.js.map +0 -1
  38. package/dist/chunk-IWULHYPW.js.map +0 -1
@@ -0,0 +1,827 @@
1
+ // ../../modules/iframe-projection/html/watch-head.ts
2
+ var INCLUDE_TAGS = /* @__PURE__ */ new Set(["STYLE", "META", "BASE", "LINK"]);
3
+ var INCLUDE_LINK_RELS = /* @__PURE__ */ new Set(["stylesheet"]);
4
+ var instance = null;
5
+ function getHeadTracker() {
6
+ if (!instance) {
7
+ instance = new HeadTrackerImpl();
8
+ }
9
+ return instance;
10
+ }
11
+ var HeadSubscriptionImpl = class {
12
+ constructor(doc, callback, onUnsubscribe) {
13
+ this.hasMutations = false;
14
+ this.doc = doc;
15
+ this.callback = callback;
16
+ this.onUnsubscribe = onUnsubscribe;
17
+ }
18
+ flush(isInitial) {
19
+ if (!isInitial && !this.hasMutations) {
20
+ return void 0;
21
+ }
22
+ this.hasMutations = false;
23
+ return captureHead(this.doc);
24
+ }
25
+ unsubscribe() {
26
+ this.onUnsubscribe();
27
+ }
28
+ /** Called by tracker when relevant mutation detected */
29
+ notifyMutation(details) {
30
+ this.hasMutations = true;
31
+ this.callback(details);
32
+ }
33
+ };
34
+ var HeadTrackerImpl = class {
35
+ constructor() {
36
+ this.docObservers = /* @__PURE__ */ new Map();
37
+ this.activeSubscriptions = 0;
38
+ }
39
+ subscribe(doc, onMutation) {
40
+ let docState = this.docObservers.get(doc);
41
+ if (!docState) {
42
+ docState = this.createDocObserver(doc);
43
+ this.docObservers.set(doc, docState);
44
+ }
45
+ const subscription = new HeadSubscriptionImpl(doc, onMutation, () => {
46
+ this.unsubscribe(doc, subscription);
47
+ });
48
+ docState.subscriptions.add(subscription);
49
+ this.activeSubscriptions += 1;
50
+ return subscription;
51
+ }
52
+ createDocObserver(doc) {
53
+ const subscriptions = /* @__PURE__ */ new Set();
54
+ const notify = (details) => {
55
+ for (const sub of subscriptions) {
56
+ sub.notifyMutation(details);
57
+ }
58
+ };
59
+ const observeHead = (head) => {
60
+ const observer = new MutationObserver((mutations) => {
61
+ const details = this.readRelevantMutations(mutations, head);
62
+ if (!details) return;
63
+ notify(details);
64
+ });
65
+ observer.observe(head, {
66
+ childList: true,
67
+ subtree: true,
68
+ attributes: true,
69
+ characterData: true
70
+ });
71
+ return observer;
72
+ };
73
+ if (doc.head) {
74
+ return { observer: observeHead(doc.head), subscriptions };
75
+ }
76
+ const bootstrap = new MutationObserver(() => {
77
+ const head = doc.head;
78
+ if (!head) return;
79
+ bootstrap.disconnect();
80
+ state.observer = observeHead(head);
81
+ notify({ stylesheetPaths: [] });
82
+ });
83
+ bootstrap.observe(doc, { childList: true, subtree: true });
84
+ const state = { observer: bootstrap, subscriptions };
85
+ return state;
86
+ }
87
+ unsubscribe(doc, sub) {
88
+ const docState = this.docObservers.get(doc);
89
+ if (!docState) return;
90
+ if (!docState.subscriptions.delete(sub)) return;
91
+ this.activeSubscriptions = Math.max(0, this.activeSubscriptions - 1);
92
+ if (docState.subscriptions.size === 0) {
93
+ docState.observer.disconnect();
94
+ this.docObservers.delete(doc);
95
+ }
96
+ }
97
+ /**
98
+ * Check if mutations contain changes to elements we care about.
99
+ * This filtering runs once per mutation batch (not once per subscription).
100
+ */
101
+ readRelevantMutations(mutations, head) {
102
+ let relevant = false;
103
+ const stylesheetPaths = /* @__PURE__ */ new Set();
104
+ const collectStylesheetPath = (node) => {
105
+ const element = node instanceof Element ? node : node?.parentElement ?? null;
106
+ if (!element) return;
107
+ const candidates = [
108
+ element,
109
+ ...element.querySelectorAll(
110
+ "style[data-vite-dev-id], link[rel~='stylesheet']"
111
+ )
112
+ ];
113
+ for (const candidate of candidates) {
114
+ if (candidate instanceof HTMLStyleElement) {
115
+ const id = candidate.getAttribute("data-vite-dev-id")?.trim();
116
+ if (id) stylesheetPaths.add(id);
117
+ } else if (candidate instanceof HTMLLinkElement && shouldIncludeLink(candidate)) {
118
+ const href = candidate.getAttribute("href")?.trim() || candidate.href;
119
+ if (href) stylesheetPaths.add(href);
120
+ }
121
+ }
122
+ };
123
+ for (const mutation of mutations) {
124
+ const target = mutation.target;
125
+ const element = target instanceof Element ? target : target.parentElement;
126
+ if (!element || !head.contains(element) && target !== head) continue;
127
+ const tagName = element.tagName;
128
+ if (INCLUDE_TAGS.has(tagName)) {
129
+ if (tagName === "LINK") {
130
+ if (!shouldIncludeLink(element)) continue;
131
+ }
132
+ relevant = true;
133
+ collectStylesheetPath(element);
134
+ }
135
+ if (mutation.type === "childList" && target === head) {
136
+ relevant = true;
137
+ }
138
+ if (mutation.type === "childList") {
139
+ for (const node of mutation.addedNodes) collectStylesheetPath(node);
140
+ for (const node of mutation.removedNodes) collectStylesheetPath(node);
141
+ }
142
+ }
143
+ return relevant ? { stylesheetPaths: [...stylesheetPaths] } : null;
144
+ }
145
+ destroy() {
146
+ for (const docState of this.docObservers.values()) {
147
+ docState.observer.disconnect();
148
+ docState.subscriptions.clear();
149
+ }
150
+ this.docObservers.clear();
151
+ this.activeSubscriptions = 0;
152
+ }
153
+ readPerfSnapshot() {
154
+ return {
155
+ observers: this.docObservers.size,
156
+ subscriptions: this.activeSubscriptions
157
+ };
158
+ }
159
+ };
160
+ function captureHead(doc) {
161
+ const head = doc.head;
162
+ if (!head) return "";
163
+ const baseURI = doc.baseURI;
164
+ const fragments = [];
165
+ for (const child of Array.from(head.children)) {
166
+ const tagName = child.tagName;
167
+ if (!INCLUDE_TAGS.has(tagName)) continue;
168
+ if (tagName === "LINK") {
169
+ if (!shouldIncludeLink(child)) continue;
170
+ if (isDisabledStylesheet(child)) continue;
171
+ }
172
+ if (tagName === "META") {
173
+ const httpEquiv = child.getAttribute("http-equiv")?.toLowerCase();
174
+ const name = child.getAttribute("name")?.toLowerCase();
175
+ if (httpEquiv === "content-security-policy" || name === "content-security-policy") {
176
+ continue;
177
+ }
178
+ }
179
+ let clone = child.cloneNode(true);
180
+ materializeStyleElementCssom(child, clone);
181
+ if (tagName === "LINK") {
182
+ clone = materializeStylesheetLinkCssom(child, clone);
183
+ }
184
+ resolveUrls(clone, baseURI);
185
+ if (clone.tagName === "LINK") {
186
+ clone.removeAttribute("crossorigin");
187
+ } else if (clone.tagName === "STYLE") {
188
+ escapeStyleForHtmlSerialization(clone);
189
+ }
190
+ fragments.push(clone.outerHTML);
191
+ }
192
+ fragments.push(...captureAdoptedStyleSheets(doc));
193
+ return fragments.join("\n");
194
+ }
195
+ function materializeStylesheetLinkCssom(source, clone) {
196
+ const link = source;
197
+ const cssText = serializeCssRules(link.sheet);
198
+ if (!cssText) {
199
+ return clone;
200
+ }
201
+ const style = source.ownerDocument.createElement("style");
202
+ for (const attribute of Array.from(source.attributes)) {
203
+ if ([
204
+ "as",
205
+ "crossorigin",
206
+ "fetchpriority",
207
+ "href",
208
+ "integrity",
209
+ "referrerpolicy",
210
+ "rel"
211
+ ].includes(attribute.name.toLowerCase())) {
212
+ continue;
213
+ }
214
+ style.setAttribute(attribute.name, attribute.value);
215
+ }
216
+ style.setAttribute("data-projection-stylesheet-href", link.href);
217
+ style.textContent = absolutifyCssReferences(cssText, link.href);
218
+ return style;
219
+ }
220
+ function materializeStyleElementCssom(source, clone) {
221
+ if (source.tagName !== "STYLE" || clone.tagName !== "STYLE") {
222
+ return;
223
+ }
224
+ const style = source;
225
+ const text = style.textContent ?? "";
226
+ if (text.trim().length > 0) {
227
+ return;
228
+ }
229
+ const cssText = serializeCssRules(style.sheet);
230
+ if (cssText) {
231
+ clone.textContent = cssText;
232
+ }
233
+ }
234
+ function captureAdoptedStyleSheets(doc) {
235
+ const sheets = Array.from(doc.adoptedStyleSheets ?? []);
236
+ if (sheets.length === 0) {
237
+ return [];
238
+ }
239
+ const fragments = [];
240
+ for (const sheet of sheets) {
241
+ const cssText = serializeCssRules(sheet);
242
+ if (!cssText) {
243
+ continue;
244
+ }
245
+ const style = doc.createElement("style");
246
+ style.setAttribute("data-projection-adopted-stylesheet", "true");
247
+ style.textContent = cssText;
248
+ escapeStyleForHtmlSerialization(style);
249
+ fragments.push(style.outerHTML);
250
+ }
251
+ return fragments;
252
+ }
253
+ function escapeStyleForHtmlSerialization(style) {
254
+ style.textContent = (style.textContent ?? "").replace(/<\//gi, "<\\/");
255
+ }
256
+ function serializeCssRules(sheet) {
257
+ if (!sheet) {
258
+ return "";
259
+ }
260
+ try {
261
+ return Array.from(sheet.cssRules).map((rule) => rule.cssText).join("\n");
262
+ } catch {
263
+ return "";
264
+ }
265
+ }
266
+ function absolutifyCssReferences(cssText, baseHref) {
267
+ if (!/^https?:/i.test(baseHref)) {
268
+ return cssText;
269
+ }
270
+ const resolve = (value) => {
271
+ const trimmed = value.trim();
272
+ if (!trimmed || trimmed.startsWith("#") || /^(?:data|blob|javascript):/i.test(trimmed)) {
273
+ return /^javascript:/i.test(trimmed) ? "" : trimmed;
274
+ }
275
+ try {
276
+ return new URL(trimmed, baseHref).href;
277
+ } catch {
278
+ return trimmed;
279
+ }
280
+ };
281
+ return cssText.replace(
282
+ /url\(\s*(["']?)([^"')]+)\1\s*\)/gi,
283
+ (_match, quote, value) => `url(${quote}${resolve(value)}${quote})`
284
+ ).replace(
285
+ /@import\s+(["'])([^"']+)\1/gi,
286
+ (_match, quote, value) => `@import ${quote}${resolve(value)}${quote}`
287
+ );
288
+ }
289
+ function shouldIncludeLink(element) {
290
+ const rel = element.getAttribute("rel");
291
+ if (!rel) {
292
+ return false;
293
+ }
294
+ return rel.toLowerCase().split(/\s+/).some((token) => INCLUDE_LINK_RELS.has(token));
295
+ }
296
+ function isDisabledStylesheet(element) {
297
+ const link = element;
298
+ return link.disabled || link.sheet?.disabled === true;
299
+ }
300
+ function resolveUrls(element, baseURI) {
301
+ if (!baseURI || !baseURI.startsWith("http")) {
302
+ return;
303
+ }
304
+ const href = element.getAttribute("href");
305
+ if (href && !isAbsoluteUrl(href)) {
306
+ try {
307
+ element.setAttribute("href", new URL(href, baseURI).href);
308
+ } catch {
309
+ }
310
+ }
311
+ const src = element.getAttribute("src");
312
+ if (src && !isAbsoluteUrl(src)) {
313
+ try {
314
+ element.setAttribute("src", new URL(src, baseURI).href);
315
+ } catch {
316
+ }
317
+ }
318
+ }
319
+ function isAbsoluteUrl(url) {
320
+ return /^(https?:)?\/\//i.test(url) || url.startsWith("data:");
321
+ }
322
+
323
+ // ../../modules/iframe-projection/shared/capture-perf.ts
324
+ var counters = {
325
+ styleReadCount: 0,
326
+ identityNodesVisited: 0,
327
+ sourceVersionDomScanNodes: 0,
328
+ sourceVersionFiberSerializeNodes: 0,
329
+ sourceVersionFiberReductionNodes: 0,
330
+ sourceVersionFallbackScanNodes: 0
331
+ };
332
+ var producerReferencesByDocument = /* @__PURE__ */ new Map();
333
+ var activeDocumentProducers = 0;
334
+ var activeRootObservers = 0;
335
+ var activeReactCommitSubscriptions = 0;
336
+ function registerDocumentCaptureProducer(document2) {
337
+ const references = producerReferencesByDocument.get(document2) ?? 0;
338
+ if (references === 0) activeDocumentProducers += 1;
339
+ producerReferencesByDocument.set(document2, references + 1);
340
+ activeReactCommitSubscriptions += 1;
341
+ let active = true;
342
+ return () => {
343
+ if (!active) return;
344
+ active = false;
345
+ const current = producerReferencesByDocument.get(document2) ?? 0;
346
+ if (current <= 1) {
347
+ producerReferencesByDocument.delete(document2);
348
+ activeDocumentProducers = Math.max(0, activeDocumentProducers - 1);
349
+ } else {
350
+ producerReferencesByDocument.set(document2, current - 1);
351
+ }
352
+ activeReactCommitSubscriptions = Math.max(
353
+ 0,
354
+ activeReactCommitSubscriptions - 1
355
+ );
356
+ };
357
+ }
358
+ function registerCaptureRootObserver() {
359
+ activeRootObservers += 1;
360
+ let active = true;
361
+ return () => {
362
+ if (!active) return;
363
+ active = false;
364
+ activeRootObservers = Math.max(0, activeRootObservers - 1);
365
+ };
366
+ }
367
+ function readCaptureProducerCardinality() {
368
+ return {
369
+ activeDocumentProducers,
370
+ activeRootObservers,
371
+ reactCommitSubscriptions: activeReactCommitSubscriptions
372
+ };
373
+ }
374
+ function countCaptureStyleRead() {
375
+ counters.styleReadCount += 1;
376
+ }
377
+ function countIdentityNodeVisited() {
378
+ counters.identityNodesVisited += 1;
379
+ }
380
+ function resetCaptureFlushCounters() {
381
+ counters.styleReadCount = 0;
382
+ counters.identityNodesVisited = 0;
383
+ counters.sourceVersionDomScanNodes = 0;
384
+ counters.sourceVersionFiberSerializeNodes = 0;
385
+ counters.sourceVersionFiberReductionNodes = 0;
386
+ counters.sourceVersionFallbackScanNodes = 0;
387
+ }
388
+ function readCaptureFlushCounters() {
389
+ return { ...counters };
390
+ }
391
+
392
+ // ../../modules/iframe-projection/html/declared-facts.ts
393
+ var SOURCE_ANNOTATED_SELECTOR = "[data-tempo-filepath], [data-tempo-html-filepath]";
394
+ var NAMESPACES = [
395
+ {
396
+ filepathAttr: "data-tempo-filepath",
397
+ positionAttr: "data-tempo-position",
398
+ modifiedTsAttr: "data-tempo-modifiedts",
399
+ sourceVersionAttr: "data-tempo-source-version"
400
+ },
401
+ {
402
+ filepathAttr: "data-tempo-html-filepath",
403
+ positionAttr: "data-tempo-html-offset",
404
+ modifiedTsAttr: "data-tempo-html-modifiedts",
405
+ sourceVersionAttr: "data-tempo-html-source-version"
406
+ }
407
+ ];
408
+ function computeDeclaredFacts(targetElement, captureRoot, scopeSelector, portalElements) {
409
+ const observedVersions = {};
410
+ const observedSourceVersions = {};
411
+ const anchorSet = /* @__PURE__ */ new Set();
412
+ const visit = (element) => {
413
+ for (const ns of NAMESPACES) {
414
+ const filepath = element.getAttribute(ns.filepathAttr);
415
+ if (filepath == null || filepath.length === 0) continue;
416
+ const modifiedTsRaw = element.getAttribute(ns.modifiedTsAttr);
417
+ if (modifiedTsRaw != null) {
418
+ const modifiedTs = Number(modifiedTsRaw);
419
+ if (!Number.isNaN(modifiedTs)) {
420
+ const existing = observedVersions[filepath];
421
+ if (existing === void 0 || modifiedTs > existing) {
422
+ observedVersions[filepath] = modifiedTs;
423
+ const version = element.getAttribute(ns.sourceVersionAttr);
424
+ if (version != null && version.length > 0) {
425
+ observedSourceVersions[filepath] = version;
426
+ } else {
427
+ delete observedSourceVersions[filepath];
428
+ }
429
+ }
430
+ }
431
+ }
432
+ const position = element.getAttribute(ns.positionAttr);
433
+ if (position != null && position.length > 0) {
434
+ anchorSet.add(`${filepath} ${position}`);
435
+ }
436
+ }
437
+ };
438
+ const walkRoots = [targetElement, ...portalElements];
439
+ for (const root of walkRoots) {
440
+ if (root.matches(SOURCE_ANNOTATED_SELECTOR)) visit(root);
441
+ for (const annotated of root.querySelectorAll(SOURCE_ANNOTATED_SELECTOR)) {
442
+ visit(annotated);
443
+ }
444
+ }
445
+ const complete = targetElement === captureRoot;
446
+ return {
447
+ complete,
448
+ scopeSelector: complete ? null : scopeSelector,
449
+ observedVersions,
450
+ observedSourceVersions,
451
+ containedAnchors: Array.from(anchorSet),
452
+ renderError: computeRenderError(captureRoot)
453
+ };
454
+ }
455
+ function computeRenderError(captureRoot) {
456
+ const errorElement = captureRoot.matches('[data-render-error="true"]') ? captureRoot : captureRoot.querySelector('[data-render-error="true"]');
457
+ if (!errorElement) return null;
458
+ return {
459
+ message: errorElement.getAttribute("data-render-error-message")
460
+ };
461
+ }
462
+
463
+ // ../../modules/iframe-projection/html/displayability.ts
464
+ var IGNORED_CONTENT_TAGS = /* @__PURE__ */ new Set([
465
+ "DATALIST",
466
+ "LINK",
467
+ "META",
468
+ "NOSCRIPT",
469
+ "SCRIPT",
470
+ "STYLE",
471
+ "TEMPLATE"
472
+ ]);
473
+ var VISUAL_ASSET_TAGS = /* @__PURE__ */ new Set([
474
+ "AUDIO",
475
+ "CANVAS",
476
+ "EMBED",
477
+ "IFRAME",
478
+ "IMG",
479
+ "INPUT",
480
+ "OBJECT",
481
+ "SELECT",
482
+ "SVG",
483
+ "TEXTAREA",
484
+ "VIDEO"
485
+ ]);
486
+ function measureComputedDisplayability(captureRoot, supplementalRoots = []) {
487
+ const doc = captureRoot.ownerDocument;
488
+ const view = doc.defaultView;
489
+ if (!view || !captureRoot.isConnected || supplementalRoots.some(
490
+ (root) => root.ownerDocument !== doc || !root.isConnected
491
+ )) {
492
+ return null;
493
+ }
494
+ const result = {
495
+ version: 1,
496
+ elementCount: 0,
497
+ paintedElementCount: 0,
498
+ nonEmptyTextNodeCount: 0,
499
+ visualAssetCount: 0
500
+ };
501
+ try {
502
+ const rootBlocked = hasBlockingElementInChain(captureRoot, view);
503
+ const rootTextVisible = !rootBlocked && elementHasVisibleComputedVisibility(captureRoot, view);
504
+ for (const child of Array.from(captureRoot.childNodes)) {
505
+ visitNode(child, rootBlocked, rootTextVisible, view, result);
506
+ }
507
+ for (const supplementalRoot of supplementalRoots) {
508
+ visitNode(
509
+ supplementalRoot,
510
+ hasBlockingElementInChain(supplementalRoot.parentElement, view),
511
+ true,
512
+ view,
513
+ result
514
+ );
515
+ }
516
+ } catch {
517
+ return null;
518
+ }
519
+ return result;
520
+ }
521
+ function visitNode(node, blockedByAncestor, parentTextVisible, view, result) {
522
+ if (node.nodeType === 3) {
523
+ if (!blockedByAncestor && parentTextVisible && (node.textContent?.trim().length ?? 0) > 0) {
524
+ result.nonEmptyTextNodeCount += 1;
525
+ }
526
+ return;
527
+ }
528
+ if (node.nodeType !== 1) return;
529
+ const element = node;
530
+ const blocked = blockedByAncestor || elementBlocksSubtree(element, view);
531
+ if (blocked) return;
532
+ const visible = elementHasVisibleComputedVisibility(element, view);
533
+ if (visible) {
534
+ result.elementCount += 1;
535
+ if (elementPaintsOwnPixels(element, view)) {
536
+ result.paintedElementCount = (result.paintedElementCount ?? 0) + 1;
537
+ }
538
+ if (VISUAL_ASSET_TAGS.has(element.tagName)) {
539
+ result.visualAssetCount += 1;
540
+ }
541
+ }
542
+ for (const child of Array.from(element.childNodes)) {
543
+ visitNode(child, false, visible, view, result);
544
+ }
545
+ }
546
+ function elementPaintsOwnPixels(element, view) {
547
+ countCaptureStyleRead();
548
+ const style = view.getComputedStyle(element);
549
+ if (colorCanPaint(style.backgroundColor)) return true;
550
+ if (style.backgroundImage && style.backgroundImage !== "none") return true;
551
+ if (style.boxShadow && style.boxShadow !== "none") return true;
552
+ if (style.outlineStyle !== "none" && parseFloat(style.outlineWidth) > 0 && colorCanPaint(style.outlineColor)) {
553
+ return true;
554
+ }
555
+ for (const side of ["Top", "Right", "Bottom", "Left"]) {
556
+ if (style[`border${side}Style`] !== "none" && parseFloat(style[`border${side}Width`]) > 0 && colorCanPaint(style[`border${side}Color`])) {
557
+ return true;
558
+ }
559
+ }
560
+ return false;
561
+ }
562
+ function colorCanPaint(value) {
563
+ const normalized = value.trim().toLowerCase().replace(/ /g, "");
564
+ if (!normalized || normalized === "transparent") return false;
565
+ return !(/^rgba\([^)]*,0(?:\.0+)?\)$/.test(normalized) || /^rgb\([^)]*\/0(?:\.0+)?\)$/.test(normalized));
566
+ }
567
+ function hasBlockingElementInChain(start, view) {
568
+ for (let element = start; element; element = element.parentElement) {
569
+ if (elementBlocksSubtree(element, view)) return true;
570
+ }
571
+ return false;
572
+ }
573
+ function elementBlocksSubtree(element, view) {
574
+ if (IGNORED_CONTENT_TAGS.has(element.tagName)) return true;
575
+ if (element.hasAttribute("hidden")) return true;
576
+ if (element.tagName === "DIALOG" && !element.hasAttribute("open")) {
577
+ return true;
578
+ }
579
+ if (element.tagName === "INPUT" && element.getAttribute("type")?.trim().toLowerCase() === "hidden") {
580
+ return true;
581
+ }
582
+ countCaptureStyleRead();
583
+ const style = view.getComputedStyle(element);
584
+ const opacity = style.opacity.trim();
585
+ return style.display === "none" || opacity.length > 0 && Number(opacity) <= 0 || style.getPropertyValue("content-visibility") === "hidden";
586
+ }
587
+ function elementHasVisibleComputedVisibility(element, view) {
588
+ countCaptureStyleRead();
589
+ const visibility = view.getComputedStyle(element).visibility;
590
+ return visibility !== "hidden" && visibility !== "collapse";
591
+ }
592
+
593
+ // ../../modules/iframe-projection/html/selectors.ts
594
+ function generateSelector(element, root) {
595
+ if (!root) {
596
+ if (element === document.documentElement) return ":root";
597
+ if (element === document.head) return "head";
598
+ if (element === document.body) return "body";
599
+ }
600
+ if (root && element === root) return "";
601
+ const parts = [];
602
+ let current = element;
603
+ const stopAt = root ?? document.documentElement;
604
+ while (current && current !== stopAt) {
605
+ const parent = current.parentElement;
606
+ if (!parent) break;
607
+ const tagName = current.tagName.toLowerCase();
608
+ let index = 1;
609
+ let sibling = current.previousElementSibling;
610
+ while (sibling) {
611
+ if (sibling.tagName === current.tagName) index++;
612
+ sibling = sibling.previousElementSibling;
613
+ }
614
+ let sameTypeSiblings = 0;
615
+ for (const child of parent.children) {
616
+ if (child.tagName === current.tagName) sameTypeSiblings++;
617
+ }
618
+ if (sameTypeSiblings > 1) {
619
+ parts.unshift(`${tagName}:nth-of-type(${index})`);
620
+ } else {
621
+ parts.unshift(tagName);
622
+ }
623
+ current = parent;
624
+ }
625
+ if (parts.length === 0) {
626
+ if (element === document.body) return "body";
627
+ if (element === document.head) return "head";
628
+ return "";
629
+ }
630
+ const path = parts.join(" > ");
631
+ if (root) return `:scope > ${path}`;
632
+ return path;
633
+ }
634
+ function findLowestCommonAncestor(nodes) {
635
+ if (nodes.size === 0) return null;
636
+ const ancestorChains = [];
637
+ for (const node of nodes) {
638
+ const chain = [];
639
+ let current = node instanceof Element ? node : node.parentElement;
640
+ while (current && current !== document) {
641
+ if (current instanceof Element) {
642
+ chain.unshift(current);
643
+ }
644
+ current = current.parentNode;
645
+ }
646
+ if (chain.length > 0) {
647
+ ancestorChains.push(chain);
648
+ }
649
+ }
650
+ if (ancestorChains.length === 0) {
651
+ return document.documentElement;
652
+ }
653
+ let lca = document.documentElement;
654
+ const firstChain = ancestorChains[0];
655
+ const minLength = Math.min(...ancestorChains.map((c) => c.length));
656
+ for (let i = 0; i < minLength; i++) {
657
+ const candidate = firstChain[i];
658
+ if (candidate && ancestorChains.every((chain) => chain[i] === candidate)) {
659
+ lca = candidate;
660
+ } else {
661
+ break;
662
+ }
663
+ }
664
+ return lca;
665
+ }
666
+
667
+ // ../../modules/iframe-projection/html/capture.ts
668
+ function capture(element) {
669
+ return captureWithSupplementalRoots(element, []);
670
+ }
671
+ function captureWithSupplementalRoots(element, supplementalRoots) {
672
+ syncFormStateToAttributes(element);
673
+ const selector = generateSelector(element, element);
674
+ const html = removeScriptTags(element.innerHTML);
675
+ const attributes = captureAttributes(element);
676
+ const documentElementAttributes = element.ownerDocument ? captureAttributes(element.ownerDocument.documentElement) : void 0;
677
+ const bodyAttributes = element.ownerDocument?.body ? captureAttributes(element.ownerDocument.body) : void 0;
678
+ const baseUrl = element.ownerDocument?.baseURI;
679
+ const states = collectElementStates(element);
680
+ const displayability = measureComputedDisplayability(
681
+ element,
682
+ supplementalRoots
683
+ );
684
+ return {
685
+ // Whole-surface one-shot: the element is both the capture root and the
686
+ // serialized scope, so `complete` is true and there is no scope selector.
687
+ declared: computeDeclaredFacts(element, element, "", supplementalRoots),
688
+ ...displayability && { displayability },
689
+ dom: {
690
+ selector,
691
+ html,
692
+ attributes,
693
+ documentElementAttributes,
694
+ bodyAttributes
695
+ },
696
+ states,
697
+ baseUrl
698
+ };
699
+ }
700
+ function syncFormStateToAttributes(root) {
701
+ for (const input of root.querySelectorAll(
702
+ 'input[type="checkbox"], input[type="radio"]'
703
+ )) {
704
+ const el = input;
705
+ if (el.checked) {
706
+ el.setAttribute("checked", "");
707
+ } else {
708
+ el.removeAttribute("checked");
709
+ }
710
+ }
711
+ for (const input of root.querySelectorAll(
712
+ 'input:not([type="checkbox"]):not([type="radio"])'
713
+ )) {
714
+ const el = input;
715
+ if (el.value !== el.getAttribute("value")) {
716
+ el.setAttribute("value", el.value);
717
+ }
718
+ }
719
+ for (const textarea of root.querySelectorAll("textarea")) {
720
+ const el = textarea;
721
+ if (el.value !== el.textContent) {
722
+ el.textContent = el.value;
723
+ }
724
+ if (el.hasAttribute("value")) {
725
+ el.removeAttribute("value");
726
+ }
727
+ }
728
+ for (const select of root.querySelectorAll("select")) {
729
+ const el = select;
730
+ for (const option of el.options) {
731
+ if (option.selected) {
732
+ option.setAttribute("selected", "");
733
+ } else {
734
+ option.removeAttribute("selected");
735
+ }
736
+ }
737
+ }
738
+ }
739
+ function removeScriptTags(html) {
740
+ return html.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "");
741
+ }
742
+ function captureAttributes(element) {
743
+ const attrs = {};
744
+ for (const attr of Array.from(element.attributes)) {
745
+ attrs[attr.name] = attr.value;
746
+ }
747
+ return attrs;
748
+ }
749
+ function collectElementStates(root, options = {}) {
750
+ const { includeDocumentScroll = true } = options;
751
+ const states = [];
752
+ for (const input of root.querySelectorAll("input")) {
753
+ const el = input;
754
+ const isCheckable = el.type === "checkbox" || el.type === "radio";
755
+ const hasNonDefault = isCheckable ? el.checked !== el.defaultChecked : el.value !== el.defaultValue;
756
+ if (hasNonDefault) {
757
+ const selector = generateSelector(el, root);
758
+ if (isCheckable) {
759
+ states.push({ selector, checked: el.checked });
760
+ } else {
761
+ states.push({ selector, value: el.value });
762
+ }
763
+ }
764
+ }
765
+ for (const textarea of root.querySelectorAll("textarea")) {
766
+ const el = textarea;
767
+ if (el.value !== el.defaultValue) {
768
+ const selector = generateSelector(el, root);
769
+ states.push({ selector, value: el.value });
770
+ }
771
+ }
772
+ for (const select of root.querySelectorAll("select")) {
773
+ const el = select;
774
+ for (const option of el.options) {
775
+ if (option.selected !== option.defaultSelected) {
776
+ const selector = generateSelector(option, root);
777
+ states.push({ selector, selected: option.selected });
778
+ }
779
+ }
780
+ }
781
+ states.push({
782
+ selector: "",
783
+ scrollTop: root.scrollTop,
784
+ scrollLeft: root.scrollLeft
785
+ });
786
+ if (includeDocumentScroll) {
787
+ const scrollingEl = root.ownerDocument?.scrollingElement;
788
+ if (scrollingEl && scrollingEl !== root) {
789
+ states.push({
790
+ selector: ":root",
791
+ scrollTop: scrollingEl.scrollTop,
792
+ scrollLeft: scrollingEl.scrollLeft
793
+ });
794
+ }
795
+ }
796
+ for (const el of root.querySelectorAll("*")) {
797
+ if (el.scrollTop > 0 || el.scrollLeft > 0) {
798
+ const selector = generateSelector(el, root);
799
+ states.push({
800
+ selector,
801
+ scrollTop: el.scrollTop,
802
+ scrollLeft: el.scrollLeft
803
+ });
804
+ }
805
+ }
806
+ return states;
807
+ }
808
+
809
+ export {
810
+ getHeadTracker,
811
+ captureHead,
812
+ registerDocumentCaptureProducer,
813
+ registerCaptureRootObserver,
814
+ readCaptureProducerCardinality,
815
+ countCaptureStyleRead,
816
+ countIdentityNodeVisited,
817
+ resetCaptureFlushCounters,
818
+ readCaptureFlushCounters,
819
+ generateSelector,
820
+ findLowestCommonAncestor,
821
+ capture,
822
+ captureWithSupplementalRoots,
823
+ removeScriptTags,
824
+ captureAttributes,
825
+ collectElementStates
826
+ };
827
+ //# sourceMappingURL=chunk-DX6XAXCK.js.map