markdown-flow-ui 0.1.112-beta.2 → 0.1.112-beta.3
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/_virtual/index.cjs10.js +1 -1
- package/dist/_virtual/index.cjs5.js +1 -1
- package/dist/_virtual/index.cjs6.js +1 -1
- package/dist/_virtual/index.cjs8.js +1 -1
- package/dist/_virtual/index.cjs9.js +1 -1
- package/dist/_virtual/index.es10.js +2 -2
- package/dist/_virtual/index.es5.js +4 -4
- package/dist/_virtual/index.es6.js +4 -4
- package/dist/_virtual/index.es8.js +2 -3
- package/dist/_virtual/index.es8.js.map +1 -1
- package/dist/_virtual/index.es9.js +3 -2
- package/dist/_virtual/index.es9.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +1 -0
- package/dist/components/ContentRender/ContentRender.es.js +118 -116
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.cjs.js +2 -2
- package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.d.ts +1 -0
- package/dist/components/ContentRender/IframeSandbox.es.js +108 -100
- package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.cjs.js +2 -2
- package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.d.ts +1 -0
- package/dist/components/ContentRender/SandboxApp.es.js +90 -87
- package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
- package/dist/components/Slide/Slide.cjs.js +1 -1
- package/dist/components/Slide/Slide.cjs.js.map +1 -1
- package/dist/components/Slide/Slide.d.ts +1 -9
- package/dist/components/Slide/Slide.es.js +585 -668
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/Slide.stories.d.ts +0 -12
- package/dist/components/Slide/constants.cjs.js +1 -1
- package/dist/components/Slide/constants.cjs.js.map +1 -1
- package/dist/components/Slide/constants.d.ts +0 -4
- package/dist/components/Slide/constants.es.js +2 -6
- package/dist/components/Slide/constants.es.js.map +1 -1
- package/dist/components/Slide/index.d.ts +1 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js.map +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/dist/slide.cjs.js +1 -1
- package/dist/slide.es.js +4 -6
- package/dist/slide.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { useRef as i, useState as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import { j as R } from "../../_virtual/jsx-runtime.es.js";
|
|
2
|
+
import { useRef as i, useState as V, useEffect as I } from "react";
|
|
3
|
+
import Y from "../ui/loading-overlay-card.es.js";
|
|
4
|
+
const Z = [
|
|
5
5
|
"src",
|
|
6
6
|
"srcset",
|
|
7
7
|
"sizes",
|
|
@@ -15,48 +15,49 @@ const Y = [
|
|
|
15
15
|
"crossorigin",
|
|
16
16
|
"referrerpolicy",
|
|
17
17
|
"fetchpriority"
|
|
18
|
-
],
|
|
18
|
+
], W = (c) => Z.map(
|
|
19
19
|
(t) => `${t}:${c.getAttribute(t) || ""}`
|
|
20
|
-
).join("|"),
|
|
20
|
+
).join("|"), ee = (c) => {
|
|
21
21
|
const t = /* @__PURE__ */ new Map();
|
|
22
|
-
return c.querySelectorAll("img").forEach((
|
|
23
|
-
const o =
|
|
24
|
-
|
|
22
|
+
return c.querySelectorAll("img").forEach((f) => {
|
|
23
|
+
const o = f, n = W(o), m = t.get(n) || [];
|
|
24
|
+
m.push(o), t.set(n, m);
|
|
25
25
|
}), t;
|
|
26
|
-
},
|
|
27
|
-
const
|
|
28
|
-
|
|
26
|
+
}, te = (c, t) => {
|
|
27
|
+
const f = Array.from(c.attributes), o = new Set(
|
|
28
|
+
f.map((n) => n.name)
|
|
29
29
|
);
|
|
30
30
|
Array.from(t.attributes).forEach((n) => {
|
|
31
31
|
o.has(n.name) || t.removeAttribute(n.name);
|
|
32
|
-
}),
|
|
32
|
+
}), f.forEach((n) => {
|
|
33
33
|
t.setAttribute(n.name, n.value);
|
|
34
34
|
});
|
|
35
|
-
},
|
|
36
|
-
t.size && c.querySelectorAll("img").forEach((
|
|
37
|
-
const o =
|
|
38
|
-
h && (
|
|
35
|
+
}, re = (c, t) => {
|
|
36
|
+
t.size && c.querySelectorAll("img").forEach((f) => {
|
|
37
|
+
const o = f, n = W(o), m = t.get(n), h = m?.shift();
|
|
38
|
+
h && (te(o, h), o.replaceWith(h), m && m.length === 0 && t.delete(n));
|
|
39
39
|
});
|
|
40
|
-
},
|
|
40
|
+
}, ie = ({
|
|
41
41
|
html: c,
|
|
42
42
|
styleLoadingText: t,
|
|
43
|
-
scriptLoadingText:
|
|
43
|
+
scriptLoadingText: f,
|
|
44
44
|
resetToken: o = 0,
|
|
45
45
|
mode: n = "content",
|
|
46
|
-
hasRootVhHeight:
|
|
46
|
+
hasRootVhHeight: m = !1,
|
|
47
47
|
stretchRootHeight: h = !1,
|
|
48
|
-
enableScaling:
|
|
48
|
+
enableScaling: G = !1,
|
|
49
|
+
disableLoadingOverlay: N = !1
|
|
49
50
|
}) => {
|
|
50
|
-
const
|
|
51
|
+
const j = i(null), [U, E] = V(!1), [$, w] = V(!1), T = i([]), _ = i([]), k = i(0), B = i(0), y = i(null), g = i(null), x = i(!1), v = i(!1), F = i(!1), L = i(o), K = 200, u = (r) => {
|
|
51
52
|
r.current && (clearTimeout(r.current), r.current = null);
|
|
52
|
-
},
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
r(!1),
|
|
56
|
-
},
|
|
53
|
+
}, q = (r, a, l, D) => {
|
|
54
|
+
const p = performance.now() - l.current, A = Math.max(0, K - p);
|
|
55
|
+
u(a), a.current = window.setTimeout(() => {
|
|
56
|
+
r(!1), D?.(), a.current = null;
|
|
57
|
+
}, A);
|
|
57
58
|
};
|
|
58
|
-
|
|
59
|
-
const r =
|
|
59
|
+
I(() => {
|
|
60
|
+
const r = j.current?.ownerDocument;
|
|
60
61
|
if (!r) return;
|
|
61
62
|
const a = "sandbox-spinner-style";
|
|
62
63
|
let l = r.getElementById(a);
|
|
@@ -70,115 +71,117 @@ const Y = [
|
|
|
70
71
|
}
|
|
71
72
|
.overflow-y-auto { overflow-y: visible !important; }
|
|
72
73
|
`;
|
|
73
|
-
}, []),
|
|
74
|
-
o !==
|
|
75
|
-
const r =
|
|
74
|
+
}, []), I(() => {
|
|
75
|
+
o !== L.current && (F.current = !1, L.current = o), u(y), u(g), x.current = !1, v.current = !1;
|
|
76
|
+
const r = j.current;
|
|
76
77
|
if (!r) return;
|
|
77
78
|
const a = r.ownerDocument, l = a?.body;
|
|
78
79
|
if (!l) return;
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
Array.from(
|
|
80
|
+
const D = ee(r);
|
|
81
|
+
T.current.forEach((e) => e.remove()), T.current = [], _.current.forEach((e) => e.remove()), _.current = [], E(!1), w(!1);
|
|
82
|
+
const p = a.createElement("div");
|
|
83
|
+
p.innerHTML = c;
|
|
84
|
+
const A = (c.match(/<script[\s>]/gi) || []).length, O = (c.match(/<\/script>/gi) || []).length, P = A > 0 && A === O, b = [];
|
|
85
|
+
Array.from(p.querySelectorAll("style, script")).forEach((e) => {
|
|
85
86
|
if (e.tagName.toLowerCase() === "style") {
|
|
86
87
|
const s = a.createElement("style");
|
|
87
|
-
s.textContent = e.textContent || "", Array.from(e.attributes).forEach((
|
|
88
|
-
s.setAttribute(
|
|
89
|
-
}),
|
|
88
|
+
s.textContent = e.textContent || "", Array.from(e.attributes).forEach((d) => {
|
|
89
|
+
s.setAttribute(d.name, d.value);
|
|
90
|
+
}), b.push(s);
|
|
90
91
|
} else {
|
|
91
92
|
const s = a.createElement("script");
|
|
92
|
-
Array.from(e.attributes).forEach((
|
|
93
|
-
s.setAttribute(
|
|
94
|
-
}), s.textContent = e.textContent || "",
|
|
93
|
+
Array.from(e.attributes).forEach((d) => {
|
|
94
|
+
s.setAttribute(d.name, d.value);
|
|
95
|
+
}), s.textContent = e.textContent || "", b.push(s);
|
|
95
96
|
}
|
|
96
97
|
e.remove();
|
|
97
|
-
}),
|
|
98
|
-
const
|
|
98
|
+
}), re(p, D);
|
|
99
|
+
const z = b.some(
|
|
99
100
|
(e) => e.tagName.toLowerCase() === "style"
|
|
100
|
-
),
|
|
101
|
+
), H = b.some(
|
|
101
102
|
(e) => e.tagName.toLowerCase() === "script"
|
|
102
103
|
);
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
r.replaceChildren(...
|
|
104
|
+
z && (x.current = !0, k.current = performance.now(), u(y), E(!0)), H && (v.current = !0, B.current = performance.now(), u(g), w(!0)), !!p.firstElementChild && (F.current = !0);
|
|
105
|
+
const X = Array.from(p.childNodes);
|
|
106
|
+
r.replaceChildren(...X), b.forEach((e) => {
|
|
106
107
|
if (e.tagName.toLowerCase() === "style") {
|
|
107
|
-
a.head?.appendChild(e),
|
|
108
|
+
a.head?.appendChild(e), T.current.push(e);
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
|
-
if (
|
|
111
|
-
const s = e,
|
|
111
|
+
if (P) {
|
|
112
|
+
const s = e, d = s.textContent || "";
|
|
112
113
|
if (!s.src)
|
|
113
114
|
try {
|
|
114
|
-
new Function(
|
|
115
|
+
new Function(d);
|
|
115
116
|
} catch {
|
|
116
117
|
s.remove();
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
120
|
try {
|
|
120
|
-
l.appendChild(s),
|
|
121
|
+
l.appendChild(s), _.current.push(s);
|
|
121
122
|
} catch {
|
|
122
123
|
s.remove();
|
|
123
124
|
}
|
|
124
125
|
} else
|
|
125
126
|
e.remove();
|
|
126
|
-
}),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
}), G && r.ownerDocument?.defaultView?.__mdf_triggerFitContent?.(), requestAnimationFrame(() => {
|
|
128
|
+
z && q(
|
|
129
|
+
E,
|
|
130
|
+
y,
|
|
131
|
+
k,
|
|
131
132
|
() => {
|
|
132
|
-
|
|
133
|
+
x.current = !1;
|
|
133
134
|
}
|
|
134
|
-
),
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
), H && q(
|
|
136
|
+
w,
|
|
137
|
+
g,
|
|
138
|
+
B,
|
|
138
139
|
() => {
|
|
139
|
-
|
|
140
|
+
v.current = !1;
|
|
140
141
|
}
|
|
141
142
|
);
|
|
142
143
|
});
|
|
143
|
-
}, [c, o,
|
|
144
|
+
}, [c, o, G]), I(
|
|
144
145
|
() => () => {
|
|
145
|
-
|
|
146
|
+
u(y), u(g);
|
|
146
147
|
},
|
|
147
148
|
[]
|
|
148
|
-
)
|
|
149
|
-
|
|
149
|
+
), I(() => {
|
|
150
|
+
N && (u(y), u(g), x.current = !1, v.current = !1, E(!1), w(!1));
|
|
151
|
+
}, [N]);
|
|
152
|
+
const S = N ? null : $ || v.current ? f || "Building scripts cache..." : U || x.current ? t || "Building styles..." : null, M = n === "blackboard", C = M && h, Q = {
|
|
150
153
|
position: "relative",
|
|
151
154
|
width: "100%",
|
|
152
155
|
height: "100%",
|
|
153
156
|
display: "flex",
|
|
154
157
|
flexDirection: "column",
|
|
155
158
|
// Keep blackboard scroll behavior while centering content in non-blackboard mode
|
|
156
|
-
justifyContent:
|
|
157
|
-
},
|
|
158
|
-
pointerEvents:
|
|
159
|
-
margin:
|
|
159
|
+
justifyContent: C ? "flex-start" : M ? "space-around" : "flex-start"
|
|
160
|
+
}, J = {
|
|
161
|
+
pointerEvents: S ? "none" : void 0,
|
|
162
|
+
margin: M ? void 0 : "auto 0",
|
|
160
163
|
width: "100%",
|
|
161
|
-
height:
|
|
162
|
-
minHeight:
|
|
163
|
-
flex:
|
|
164
|
+
height: C ? "100%" : void 0,
|
|
165
|
+
minHeight: C ? 0 : void 0,
|
|
166
|
+
flex: C ? "1 1 auto" : void 0
|
|
164
167
|
};
|
|
165
|
-
return /* @__PURE__ */
|
|
168
|
+
return /* @__PURE__ */ R.jsxs(
|
|
166
169
|
"div",
|
|
167
170
|
{
|
|
168
|
-
"data-root-vh":
|
|
171
|
+
"data-root-vh": m ? "true" : "false",
|
|
169
172
|
className: "sandbox-wrapper",
|
|
170
|
-
style:
|
|
171
|
-
"aria-busy": !!
|
|
173
|
+
style: Q,
|
|
174
|
+
"aria-busy": !!S,
|
|
172
175
|
children: [
|
|
173
|
-
/* @__PURE__ */
|
|
176
|
+
/* @__PURE__ */ R.jsx(
|
|
174
177
|
"div",
|
|
175
178
|
{
|
|
176
|
-
ref:
|
|
179
|
+
ref: j,
|
|
177
180
|
className: "sandbox-container",
|
|
178
|
-
style:
|
|
181
|
+
style: J
|
|
179
182
|
}
|
|
180
183
|
),
|
|
181
|
-
|
|
184
|
+
S && /* @__PURE__ */ R.jsx(
|
|
182
185
|
"div",
|
|
183
186
|
{
|
|
184
187
|
style: {
|
|
@@ -190,7 +193,7 @@ const Y = [
|
|
|
190
193
|
justifyContent: "center",
|
|
191
194
|
pointerEvents: "none"
|
|
192
195
|
},
|
|
193
|
-
children: /* @__PURE__ */
|
|
196
|
+
children: /* @__PURE__ */ R.jsx(Y, { message: S })
|
|
194
197
|
}
|
|
195
198
|
)
|
|
196
199
|
]
|
|
@@ -198,6 +201,6 @@ const Y = [
|
|
|
198
201
|
);
|
|
199
202
|
};
|
|
200
203
|
export {
|
|
201
|
-
|
|
204
|
+
ie as default
|
|
202
205
|
};
|
|
203
206
|
//# sourceMappingURL=SandboxApp.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxApp.es.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\nimport type { ScalingWindow } from \"./utils/iframe-scaling\";\n\nexport interface SandboxAppProps {\n html: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n mode?: \"content\" | \"blackboard\";\n hasRootVhHeight?: boolean;\n stretchRootHeight?: boolean;\n enableScaling?: boolean;\n}\n\nconst IMAGE_REUSE_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"alt\",\n \"class\",\n \"width\",\n \"height\",\n \"style\",\n \"loading\",\n \"decoding\",\n \"crossorigin\",\n \"referrerpolicy\",\n \"fetchpriority\",\n];\n\nconst getImageReuseKey = (image: HTMLImageElement) =>\n IMAGE_REUSE_ATTRIBUTES.map(\n (attribute) => `${attribute}:${image.getAttribute(attribute) || \"\"}`\n ).join(\"|\");\n\nconst collectReusableImages = (root: ParentNode) => {\n const imageMap = new Map<string, HTMLImageElement[]>();\n root.querySelectorAll(\"img\").forEach((node) => {\n const image = node as HTMLImageElement;\n const key = getImageReuseKey(image);\n const bucket = imageMap.get(key) || [];\n bucket.push(image);\n imageMap.set(key, bucket);\n });\n return imageMap;\n};\n\nconst syncImageAttributes = (\n sourceImage: HTMLImageElement,\n targetImage: HTMLImageElement\n) => {\n const sourceAttributes = Array.from(sourceImage.attributes);\n const sourceAttributeNames = new Set(\n sourceAttributes.map((attribute) => attribute.name)\n );\n\n Array.from(targetImage.attributes).forEach((attribute) => {\n if (!sourceAttributeNames.has(attribute.name)) {\n targetImage.removeAttribute(attribute.name);\n }\n });\n\n sourceAttributes.forEach((attribute) => {\n targetImage.setAttribute(attribute.name, attribute.value);\n });\n};\n\nconst reuseRenderedImages = (\n root: ParentNode,\n imageMap: Map<string, HTMLImageElement[]>\n) => {\n if (!imageMap.size) return;\n\n root.querySelectorAll(\"img\").forEach((node) => {\n const nextImage = node as HTMLImageElement;\n const key = getImageReuseKey(nextImage);\n const bucket = imageMap.get(key);\n const preservedImage = bucket?.shift();\n if (!preservedImage) return;\n\n syncImageAttributes(nextImage, preservedImage);\n nextImage.replaceWith(preservedImage);\n\n if (bucket && bucket.length === 0) {\n imageMap.delete(key);\n }\n });\n};\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n mode = \"content\",\n hasRootVhHeight = false,\n stretchRootHeight = false,\n enableScaling = false,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n doc.head?.appendChild(styleEl);\n }\n styleEl.textContent = `\n .sandbox-wrapper { align-items: center; }\n .sandbox-container { position: relative; width: 100%; }\n .sandbox-container svg,\n .sandbox-container img { display: block; margin-left: auto; margin-right: auto; }\n .justify-\\\\[safe_center\\\\]{\n justify-content: safe center;\n }\n .overflow-y-auto { overflow-y: visible !important; }\n `;\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n const reusableImages = collectReusableImages(container);\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n // const hasRenderedBefore = hasRenderedContentRef.current;\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n const wrapper = doc.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n reuseRenderedImages(wrapper, reusableImages);\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n const contentNodes = Array.from(wrapper.childNodes);\n container.replaceChildren(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n if (enableScaling) {\n const win = container.ownerDocument?.defaultView as ScalingWindow | null;\n win?.__mdf_triggerFitContent?.();\n }\n\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken, enableScaling]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n const overlayMessage = (() => {\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n return null;\n })();\n\n const isBlackboard = mode === \"blackboard\";\n const shouldStretchRootHeight = isBlackboard && stretchRootHeight;\n const sandboxWrapperStyle: React.CSSProperties = {\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n // Keep blackboard scroll behavior while centering content in non-blackboard mode\n justifyContent: shouldStretchRootHeight\n ? \"flex-start\"\n : isBlackboard\n ? \"space-around\"\n : \"flex-start\",\n };\n const sandboxContainerStyle: React.CSSProperties = {\n pointerEvents: overlayMessage ? \"none\" : undefined,\n margin: isBlackboard ? undefined : \"auto 0\",\n width: \"100%\",\n height: shouldStretchRootHeight ? \"100%\" : undefined,\n minHeight: shouldStretchRootHeight ? 0 : undefined,\n flex: shouldStretchRootHeight ? \"1 1 auto\" : undefined,\n };\n\n return (\n <div\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className=\"sandbox-wrapper\"\n style={sandboxWrapperStyle}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n className=\"sandbox-container\"\n style={sandboxContainerStyle}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n zIndex: 20,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <LoadingOverlayCard message={overlayMessage} />\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["IMAGE_REUSE_ATTRIBUTES","getImageReuseKey","image","attribute","collectReusableImages","root","imageMap","node","key","bucket","syncImageAttributes","sourceImage","targetImage","sourceAttributes","sourceAttributeNames","reuseRenderedImages","nextImage","preservedImage","SandboxApp","html","styleLoadingText","scriptLoadingText","resetToken","mode","hasRootVhHeight","stretchRootHeight","enableScaling","containerRef","useRef","isGeneratingStyles","setIsGeneratingStyles","useState","isGeneratingScripts","setIsGeneratingScripts","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","reusableImages","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","contentNodes","scriptNode","scriptText","overlayMessage","isBlackboard","shouldStretchRootHeight","sandboxWrapperStyle","sandboxContainerStyle","jsxs","jsx","LoadingOverlayCard"],"mappings":";;;AAeA,MAAMA,IAAyB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAmB,CAACC,MACxBF,EAAuB;AAAA,EACrB,CAACG,MAAc,GAAGA,CAAS,IAAID,EAAM,aAAaC,CAAS,KAAK,EAAE;AACpE,EAAE,KAAK,GAAG,GAENC,IAA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AAkB,SAAS;AAAA,MACzC,WAAU;AAAA,MACV,OAAOoD;AAAA,MACP,aAAW,CAAC,CAACH;AAAA,MAEb,UAAA;AAAA,QAAAM,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAKpD;AAAA,YACL,WAAU;AAAA,YACV,OAAOkD;AAAA,UAAA;AAAA,QAAA;AAAA,QAERJ,KACCM,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,eAAe;AAAA,YAAA;AAAA,YAGjB,UAAAA,gBAAAA,EAAAA,IAACC,GAAA,EAAmB,SAASP,EAAA,CAAgB;AAAA,UAAA;AAAA,QAAA;AAAA,MAC/C;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
1
|
+
{"version":3,"file":"SandboxApp.es.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\nimport type { ScalingWindow } from \"./utils/iframe-scaling\";\n\nexport interface SandboxAppProps {\n html: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n mode?: \"content\" | \"blackboard\";\n hasRootVhHeight?: boolean;\n stretchRootHeight?: boolean;\n enableScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst IMAGE_REUSE_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"alt\",\n \"class\",\n \"width\",\n \"height\",\n \"style\",\n \"loading\",\n \"decoding\",\n \"crossorigin\",\n \"referrerpolicy\",\n \"fetchpriority\",\n];\n\nconst getImageReuseKey = (image: HTMLImageElement) =>\n IMAGE_REUSE_ATTRIBUTES.map(\n (attribute) => `${attribute}:${image.getAttribute(attribute) || \"\"}`\n ).join(\"|\");\n\nconst collectReusableImages = (root: ParentNode) => {\n const imageMap = new Map<string, HTMLImageElement[]>();\n root.querySelectorAll(\"img\").forEach((node) => {\n const image = node as HTMLImageElement;\n const key = getImageReuseKey(image);\n const bucket = imageMap.get(key) || [];\n bucket.push(image);\n imageMap.set(key, bucket);\n });\n return imageMap;\n};\n\nconst syncImageAttributes = (\n sourceImage: HTMLImageElement,\n targetImage: HTMLImageElement\n) => {\n const sourceAttributes = Array.from(sourceImage.attributes);\n const sourceAttributeNames = new Set(\n sourceAttributes.map((attribute) => attribute.name)\n );\n\n Array.from(targetImage.attributes).forEach((attribute) => {\n if (!sourceAttributeNames.has(attribute.name)) {\n targetImage.removeAttribute(attribute.name);\n }\n });\n\n sourceAttributes.forEach((attribute) => {\n targetImage.setAttribute(attribute.name, attribute.value);\n });\n};\n\nconst reuseRenderedImages = (\n root: ParentNode,\n imageMap: Map<string, HTMLImageElement[]>\n) => {\n if (!imageMap.size) return;\n\n root.querySelectorAll(\"img\").forEach((node) => {\n const nextImage = node as HTMLImageElement;\n const key = getImageReuseKey(nextImage);\n const bucket = imageMap.get(key);\n const preservedImage = bucket?.shift();\n if (!preservedImage) return;\n\n syncImageAttributes(nextImage, preservedImage);\n nextImage.replaceWith(preservedImage);\n\n if (bucket && bucket.length === 0) {\n imageMap.delete(key);\n }\n });\n};\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n mode = \"content\",\n hasRootVhHeight = false,\n stretchRootHeight = false,\n enableScaling = false,\n disableLoadingOverlay = false,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n doc.head?.appendChild(styleEl);\n }\n styleEl.textContent = `\n .sandbox-wrapper { align-items: center; }\n .sandbox-container { position: relative; width: 100%; }\n .sandbox-container svg,\n .sandbox-container img { display: block; margin-left: auto; margin-right: auto; }\n .justify-\\\\[safe_center\\\\]{\n justify-content: safe center;\n }\n .overflow-y-auto { overflow-y: visible !important; }\n `;\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n const reusableImages = collectReusableImages(container);\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n // const hasRenderedBefore = hasRenderedContentRef.current;\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n const wrapper = doc.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n reuseRenderedImages(wrapper, reusableImages);\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n const contentNodes = Array.from(wrapper.childNodes);\n container.replaceChildren(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n if (enableScaling) {\n const win = container.ownerDocument?.defaultView as ScalingWindow | null;\n win?.__mdf_triggerFitContent?.();\n }\n\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken, enableScaling]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n useEffect(() => {\n if (!disableLoadingOverlay) {\n return;\n }\n\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n }, [disableLoadingOverlay]);\n\n const overlayMessage = (() => {\n if (disableLoadingOverlay) {\n return null;\n }\n\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n return null;\n })();\n\n const isBlackboard = mode === \"blackboard\";\n const shouldStretchRootHeight = isBlackboard && stretchRootHeight;\n const sandboxWrapperStyle: React.CSSProperties = {\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n // Keep blackboard scroll behavior while centering content in non-blackboard mode\n justifyContent: shouldStretchRootHeight\n ? \"flex-start\"\n : isBlackboard\n ? \"space-around\"\n : \"flex-start\",\n };\n const sandboxContainerStyle: React.CSSProperties = {\n pointerEvents: overlayMessage ? \"none\" : undefined,\n margin: isBlackboard ? undefined : \"auto 0\",\n width: \"100%\",\n height: shouldStretchRootHeight ? \"100%\" : undefined,\n minHeight: shouldStretchRootHeight ? 0 : undefined,\n flex: shouldStretchRootHeight ? \"1 1 auto\" : undefined,\n };\n\n return (\n <div\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className=\"sandbox-wrapper\"\n style={sandboxWrapperStyle}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n className=\"sandbox-container\"\n style={sandboxContainerStyle}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n zIndex: 20,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <LoadingOverlayCard message={overlayMessage} />\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["IMAGE_REUSE_ATTRIBUTES","getImageReuseKey","image","attribute","collectReusableImages","root","imageMap","node","key","bucket","syncImageAttributes","sourceImage","targetImage","sourceAttributes","sourceAttributeNames","reuseRenderedImages","nextImage","preservedImage","SandboxApp","html","styleLoadingText","scriptLoadingText","resetToken","mode","hasRootVhHeight","stretchRootHeight","enableScaling","disableLoadingOverlay","containerRef","useRef","isGeneratingStyles","setIsGeneratingStyles","useState","isGeneratingScripts","setIsGeneratingScripts","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","reusableImages","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","contentNodes","scriptNode","scriptText","overlayMessage","isBlackboard","shouldStretchRootHeight","sandboxWrapperStyle","sandboxContainerStyle","jsxs","jsx","LoadingOverlayCard"],"mappings":";;;AAgBA,MAAMA,IAAyB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAmB,CAACC,MACxBF,EAAuB;AAAA,EACrB,CAACG,MAAc,GAAGA,CAAS,IAAID,EAAM,aAAaC,CAAS,KAAK,EAAE;AACpE,EAAE,KAAK,GAAG,GAENC,KAAwB,CAACC,MAAqB;AAClD,QAAMC,wBAAe,IAAA;AACrB,SAAAD,EAAK,iBAAiB,KAAK,EAAE,QAAQ,CAACE,MAAS;AAC7C,UAAML,IAAQK,GACRC,IAAMP,EAAiBC,CAAK,GAC5BO,IAASH,EAAS,IAAIE,CAAG,KAAK,CAAA;AACpC,IAAAC,EAAO,KAAKP,CAAK,GACjBI,EAAS,IAAIE,GAAKC,CAAM;AAAA,EAC1B,CAAC,GACMH;AACT,GAEMI,KAAsB,CAC1BC,GACAC,MACG;AACH,QAAMC,IAAmB,MAAM,KAAKF,EAAY,UAAU,GACpDG,IAAuB,IAAI;AAAA,IAC/BD,EAAiB,IAAI,CAACV,MAAcA,EAAU,IAAI;AAAA,EAAA;AAGpD,QAAM,KAAKS,EAAY,UAAU,EAAE,QAAQ,CAACT,MAAc;AACxD,IAAKW,EAAqB,IAAIX,EAAU,IAAI,KAC1CS,EAAY,gBAAgBT,EAAU,IAAI;AAAA,EAE9C,CAAC,GAEDU,EAAiB,QAAQ,CAACV,MAAc;AACtC,IAAAS,EAAY,aAAaT,EAAU,MAAMA,EAAU,KAAK;AAAA,EAC1D,CAAC;AACH,GAEMY,KAAsB,CAC1BV,GACAC,MACG;AACH,EAAKA,EAAS,QAEdD,EAAK,iBAA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AC/C;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),An=require("../../lib/sandboxInteraction.cjs.js"),Y=require("../../lib/utils.cjs.js"),In=require("../ui/loading-overlay-card.cjs.js"),_n=require("../ContentRender/ContentRender.cjs.js"),jt=require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");const Pt=require("../../lib/interaction-defaults.cjs.js"),Ie=require("../../lib/mobileDevice.cjs.js"),wn=require("./Player.cjs.js"),Cn=require("./SubtitleOverlay.cjs.js"),ze=require("./constants.cjs.js"),Tn=require("./SlideFullscreenHint.cjs.js"),Mn=require("./useSlide.cjs.js"),kn=require("./useWakePlayerFromIframe.cjs.js"),ce=require("./utils/mobileScreenMode.cjs.js"),jn=require("./utils/interactionPlayback.cjs.js"),Pn=require("./utils/appendedMarkerAdvance.cjs.js"),On=require("./utils/playbackSequence.cjs.js"),Ot=require("./utils/playerCustomActions.cjs.js"),Fn=require("./utils/playbackTimeStore.cjs.js"),qn=require("./utils/playerToggleMode.cjs.js");;/* empty css */const Bn=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/chevron-left.cjs.js"),Ln=2e3,Nn=300,Vn=160,Kn=16,Ft=t.memo(({content:s,title:o,defaultButtonText:C,defaultInputText:T,defaultSelectedValues:F,confirmButtonText:q,copyButtonText:N,copiedButtonText:X,onSend:_e,readonly:we=!1})=>r.jsxRuntimeExports.jsxs("div",{className:"slide-player__interaction-card",children:[r.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-header",children:r.jsxRuntimeExports.jsx("p",{className:"slide-player__interaction-title",children:o})}),r.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-body",children:r.jsxRuntimeExports.jsx(_n.default,{content:s,defaultButtonText:C,defaultInputText:T,defaultSelectedValues:F,confirmButtonText:q,copyButtonText:N,copiedButtonText:X,onSend:_e,readonly:we,enableTypewriter:!1,sandboxMode:"content"})})]}));Ft.displayName="InteractionOverlayCard";const Dn=(s,o)=>s.length===o.length&&s.every((C,T)=>{const F=o[T];return C.sequence_number===F?.sequence_number&&C.type===F?.type&&C.content===F?.content}),Un=s=>typeof s=="string"?`string:${s.length}:${s.slice(-32)}`:typeof s=="number"||typeof s=="boolean"?`primitive:${String(s)}`:t.isValidElement(s)?`element:${String(s.key??"")}`:Array.isArray(s)?`array:${s.length}`:s==null?"null":`object:${typeof s}`,Hn=s=>(s??[]).map(o=>[String(o.segment_index??"none"),o.is_final?"1":"0",String(o.duration_ms??0),String(o.audio_url??""),String(o.audio_data?.length??0)].join(":")).join(","),$n=s=>s.map((o,C)=>[String(o.sequence_number??C),String(o.type),Un(o.content),String(o.audio_url??""),Hn(o.audio_segments),o.is_renderable===!1?"hidden":"visible",o.is_new?"new":"stable",o.is_speakable?"speakable":"silent",String(o.user_input??""),o.readonly?"readonly":"editable"].join("|")).join("||"),Wn=({elementList:s=[],isStreaming:o=!1,showPlayer:C=!0,playerAlwaysVisible:T=!1,playerClassName:F,fullscreenHeader:q,playerCustomActions:N,playerCustomActionPauseOnActive:X=!0,bufferingText:_e="Buffering...",interactionTitle:we,interactionTexts:de,playerTexts:Ge,playerAutoHideDelay:Ce=3e3,markerAutoAdvanceDelay:Ye=Ln,streamInactivityTimeoutMs:Te=ze.DEFAULT_STREAM_INACTIVITY_TIMEOUT_MS,interactionDefaultValueOptions:fe,onSend:Xe,onPlayerVisibilityChange:Me,onMobileViewModeChange:Je,onError:Qe,onStepChange:Ze,enableIframeScaling:qt=!0,className:Bt,onPointerDown:et,...Lt})=>{const me=t.useRef(null),tt=t.useRef(null),ke=t.useRef(null),nt=t.useRef(null),J=t.useRef(null),Q=t.useRef(null),Z=t.useRef(null),ee=t.useRef(null),te=t.useRef(null),rt=t.useRef(null),st=t.useRef([]),je=t.useRef(null),pe=t.useRef(!1),Pe=t.useRef(!1),ne=t.useRef(!1),V=t.useRef(null),ot=t.useRef(null),lt=t.useRef({markerCount:0,currentIndex:-1,canGoNext:!1}),{currentElementList:M,stepElementLists:ut,slideElementList:k,currentIndex:f,audioList:p,currentAudioSequenceIndexes:he,currentStepHasSpeakableElement:x,currentInteractionElement:d,canGoPrev:Nt,canGoNext:S,handlePrev:it,handleNext:E}=Mn.default(s),re=t.useMemo(()=>{if(!(f<0))return k[f]},[f,k]),Vt=k.filter(e=>e.is_renderable!==!1).length===1,v=C&&(k.length>0||p.length>0||!!d),R=t.useMemo(()=>he.map(e=>p[e]?.audioKey).filter(e=>!!e),[p,he]),[at,be]=t.useState(!0),[xe,se]=t.useState(!1),[oe,ct]=t.useState(!0),[h,K]=t.useState(null),[Kt,Dt]=t.useState(!1),[D,Oe]=t.useState(!1),[A,dt]=t.useState(!1),[Ut,Fe]=t.useState(!1),[ft,Ht]=t.useState(!0),[qe,Be]=t.useState(!1),[u,Le]=t.useState(),[ye,Se]=t.useState(!1),[$t,le]=t.useState(0),[Wt,zt]=t.useState(!1),I=t.useMemo(()=>Ie.isMobileDevice(),[]),[ve,Ne]=t.useState(ce.DEFAULT_MOBILE_VIEW_MODE),[mt,Ve]=t.useState(!1),[Ke,pt]=t.useState(()=>I?Ie.isLandscapeViewport():!1),[Gt,ge]=t.useState(!1),U=t.useMemo(()=>Fn.createPlaybackTimeStore(),[]),{effectiveMobileViewMode:P,isImmersiveMobileFullscreen:H,isNativeMobileFullscreen:ht,shouldRotateFullscreenViewport:Yt}=t.useMemo(()=>ce.resolveMobileViewModeState({hasManualMobileViewMode:mt,isMobileDevice:I,mobileViewMode:ve}),[mt,I,Ke,ve]),bt=t.useRef(P),_=v&&(T||at),Xt=H&&_,Jt=H&&_,Qt=H||ht,Zt=Ge?.fullscreenHintText??ze.DEFAULT_SLIDE_PLAYER_TEXTS.fullscreenHintText,De=t.useMemo(()=>$n(s),[s]),i=t.useCallback((e,n,l)=>{Dt(e)},[]),xt=t.useCallback(e=>{i(e,e?"external-show-buffering":"external-hide-buffering")},[i]),en=t.useCallback(e=>{Ve(!0),Ne(e)},[]),yt=t.useCallback(()=>{Ve(!1),Ne(ce.DEFAULT_MOBILE_VIEW_MODE)},[]),tn=t.useCallback(()=>{yt(),q?.onBack?.()},[q,yt]),nn=t.useCallback(()=>{ge(!1)},[]),St=t.useCallback(e=>{Be(e)},[]),vt=t.useCallback(()=>{Be(e=>!e)},[]),{mountedStepStates:rn,currentMountedStateIndex:sn}=t.useMemo(()=>{const e=[],n=new Map;return ut.forEach((l,m)=>{const a=e.findIndex(c=>Dn(c.elementList,l));if(a>=0){e[a]?.sourceStepIndexes.push(m),n.set(m,a);return}e.push({elementList:l,sourceStepIndexes:[m]}),n.set(m,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:f>=0?n.get(f)??-1:-1}},[f,ut]),gt=t.useMemo(()=>String(f),[f]),b=t.useMemo(()=>h?p.findIndex(e=>(e.audioKey??"")===h):-1,[p,h]),Ue=t.useMemo(()=>b>=0?p[b]:void 0,[p,b]),on=Ue?.element?.subtitle_cues??[],Ee=t.useMemo(()=>R[0]??"none",[R]),He=t.useMemo(()=>({currentElement:Ot.resolvePlayerCustomActionElement({currentAudioIndex:b,currentAudioSequenceIndexes:he,audioList:p,currentInteractionElement:u,currentStepElement:re}),currentIndex:f,currentStepElement:re,isActive:qe,setActive:St,toggleActive:vt}),[u,p,b,he,f,re,qe,St,vt]),$e=t.useMemo(()=>Ot.getPlayerCustomActionCount(N,He),[He,N]),ln=t.useMemo(()=>({"--slide-player-custom-action-count":String($e),"--slide-player-mobile-control-count":String($e+4)}),[$e]),Et=R.length>0,Rt=t.useMemo(()=>d?`${d.sequence_number??"none"}:${String(d.content??"")}`:"none",[d]),ue=t.useMemo(()=>[gt,Rt].join("|"),[Rt,gt]),un=t.useMemo(()=>[ue,Ue?.audioKey??"none",String(b)].join("|"),[b,Ue?.audioKey,ue]),At=!!t.useMemo(()=>!Ee||Ee==="none"?"":p.find(n=>n.audioKey===Ee)?.audioUrl?.trim()??"",[p,Ee]),O=X&&!!N&&qe,ie=t.useMemo(()=>qn.shouldUseAutoAdvanceToggle({canGoNext:S,currentAudioIndex:b,currentStepHasSpeakableElement:x,hasInteraction:!!d}),[S,b,d,x]),B=t.useCallback(()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},[]),j=t.useCallback(()=>{Z.current!==null&&(window.clearTimeout(Z.current),Z.current=null)},[]),w=t.useCallback(()=>{ee.current!==null&&(window.clearTimeout(ee.current),ee.current=null)},[]),$=t.useCallback(()=>{Q.current!==null&&(window.clearTimeout(Q.current),Q.current=null)},[]),W=t.useCallback(()=>{te.current!==null&&(window.clearTimeout(te.current),te.current=null)},[]),z=t.useCallback(()=>{$(),j(),w(),K(null),U.reset(),i(!1,"reset-audio-sequence"),dt(!1),Fe(!1),Le(void 0),Se(!1),le(0)},[$,j,w,U,i]),G=t.useCallback(()=>{const e=R[0];return e?(K(e),!0):!1},[R]),Re=t.useCallback(()=>{j(),w(),Se(!1),le(0),!G()&&S&&E()},[S,j,w,E,G]),It=t.useCallback(e=>{if(w(),!e)return;const n=()=>{ee.current=null,le(Vn),Se(!0),V.current=null};ee.current=window.setTimeout(n,Nn)},[w]),y=t.useCallback((e=xe)=>{v&&(be(!0),B(),!(T||!e||Ce<=0)&&(J.current=window.setTimeout(()=>{be(!1),J.current=null},Ce)))},[B,xe,T,Ce,v]),ae=!!(d?.readonly||d?.user_input?.trim()),L=!!d&&!ae;t.useEffect(()=>{ct(!0),X&&Be(!1)},[f,X]),t.useEffect(()=>()=>{$(),B(),j(),w(),W()},[$,j,w,B,W]),t.useEffect(()=>{if(!o||Te<=0){W(),je.current=null,Pe.current=!1,ne.current=!1,Oe(!1);return}const e=!Pe.current,n=je.current!==De;return Pe.current=!0,(e||n)&&(je.current=De,ne.current&&(ne.current=!1,Oe(!1))),W(),te.current=window.setTimeout(()=>{te.current=null,!ne.current&&(ne.current=!0,Oe(!0),i(!1,"stream-inactivity-timeout"),Qe?.({code:ze.SLIDE_ERROR_CODES.STREAM_INACTIVITY_TIMEOUT,setBufferingLoadingVisible:xt}))},Te),()=>{W()}},[W,o,Qe,xt,De,Te,i]),t.useEffect(()=>(Me?.(_),()=>{Me?.(!1)}),[Me,_]),t.useEffect(()=>{I||ve===ce.DEFAULT_MOBILE_VIEW_MODE||(Ve(!1),Ne(ce.DEFAULT_MOBILE_VIEW_MODE))},[I,ve]),t.useEffect(()=>{if(!I){pt(!1);return}const e=()=>{pt(Ie.isLandscapeViewport())};return e(),Ie.subscribeMobileDeviceChange(e)},[I]),t.useEffect(()=>{Je?.(P)},[P,Je]),t.useEffect(()=>{const l=bt.current!=="fullscreen"&&P==="fullscreen"&&!Ke;if(bt.current=P,!I){ge(!1);return}if(l){ge(!0);return}P!=="fullscreen"&&ge(!1)},[P,I,Ke]),t.useEffect(()=>{Ze?.(re,f)},[f,re,Ze]),t.useEffect(()=>{const e=lt.current,n=Pn.shouldAutoAdvanceIntoAppendedMarker({previousMarkerCount:e.markerCount,nextMarkerCount:k.length,previousIndex:e.currentIndex,previousCanGoNext:e.canGoNext,nextCanGoNext:S,currentAudioKey:h,hasCompletedCurrentStepAudio:A,hasResolvedCurrentInteraction:ae,currentStepHasSpeakableElement:x,currentInteractionElement:d,isAutoAdvanceEnabled:oe,shouldUseSilentStepAutoAdvanceToggle:ie});lt.current={markerCount:k.length,currentIndex:f,canGoNext:S},n&&E()},[S,h,f,d,x,E,A,ae,oe,ie,k.length]),t.useEffect(()=>{if(!v){B(),be(!1);return}if(T){B(),be(!0);return}xe||y(!0)},[B,xe,T,v,y]),t.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.origin===window.location.origin&&An.isSandboxInteractionMessage(n.data)&&n.data.eventType==="click"&&v&&(se(!0),y(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[v,y]),kn.default({sectionRef:me,enabled:v,onWake:()=>{se(!0),y(!0)}}),t.useEffect(()=>{const{hasPlaybackContextChanged:e,shouldInitializeAudioSequence:n}=On.getPlaybackSequenceTransition({previousResetKey:ot.current,nextResetKey:ue,currentAudioKey:h,hasCompletedCurrentStepAudio:A});ot.current=ue;const l=V.current===f&&!!d,m=jn.shouldPresentInteractionOverlay({hasInteraction:!!d,shouldBlockPlaybackForInteraction:L,shouldOpenInteractionOverlayAfterAudio:l,hasPlaybackContextChanged:e,hasResolvedCurrentInteraction:ae,currentStepHasSpeakableElement:x});if(e&&z(),!(M.length===0&&!d)&&!O){if(d&&Le(d),m){It(d);return}if(w(),V.current=null,!!n&&!G()){if(x){if(D){i(!1,"step-wait-suppressed-after-timeout");return}i(!0,"step-waiting-for-first-audio");return}if(S&&!(ie&&!oe))return Q.current=window.setTimeout(()=>{Q.current=null,E()},Ye),()=>{$()}}}},[S,$,M.length,d,h,ue,x,Ye,E,A,D,oe,ae,L,w,z,It,G,O,ie,i]),t.useEffect(()=>{if(D||O||!x||L){i(!1,"loading-hidden-blocked-state",{shouldPausePlaybackForCustomAction:O,shouldBlockPlaybackForInteraction:L});return}if(A){i(!1,"loading-hidden-step-audio-completed");return}if(Et){i(!1,"loading-hidden-audio-available");return}i(!0,"loading-visible-awaiting-step-audio")},[D,Et,x,A,O,L,i]),t.useEffect(()=>{h||R.length===0||O||!x||L||A||G()},[h,R,x,A,O,L,G]),t.useEffect(()=>{!h||b>=0||K(null)},[b,h]),t.useEffect(()=>{b>=0||U.reset()},[b,U]),t.useEffect(()=>{Fe(!1)},[un]);const _t=t.useMemo(()=>{if(!u)return{};const e=!!u.user_input?.trim();return Pt.getInteractionDefaultValues(typeof u.content=="string"?u.content:void 0,u.user_input,e?void 0:fe)},[u,fe]),an=t.useMemo(()=>{if(!u)return;const e=!!u.user_input?.trim();return Pt.getInteractionDefaultSelectedValues(typeof u.content=="string"?u.content:void 0,u.user_input,e?void 0:fe)},[u,fe]),wt=!!u?.user_input?.trim(),Ct=!!u?.readonly||wt,Tt=Ct||wt,We=!!u&&ye,cn=t.useCallback(e=>{const l=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");Le(m=>!m||!l?m:{...m,user_input:l}),Xe?.(e,u),Re()},[u,Re,Xe]);t.useEffect(()=>{const e=()=>{zt(document.fullscreenElement===me.current)};return e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),t.useEffect(()=>{if(!We){le(0);return}const e=rt.current;if(!e)return;const n=()=>{const m=Math.ceil(e.getBoundingClientRect().height);le(m+Kn)};if(n(),typeof ResizeObserver>"u")return;const l=new ResizeObserver(()=>{n()});return l.observe(e),()=>{l.disconnect()}},[We]),t.useEffect(()=>{if(j(),!(!ye||!Tt))return Z.current=window.setTimeout(()=>{Z.current=null,Re()},2e3),()=>{j()}},[j,Re,ye,Tt]);const dn=(e,n={})=>e?e.type==="slot"?r.jsxRuntimeExports.jsx(r.jsxRuntimeExports.Fragment,{children:e.content}):e.type==="html"?r.jsxRuntimeExports.jsx(jt.default,{className:"content-render-iframe",hideFullScreen:!0,mode:"blackboard",replaceRootScreenHeightWithFull:n.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content,enableScaling:qt}):r.jsxRuntimeExports.jsx(jt.default,{className:"content-render-iframe",hideFullScreen:!0,mode:"blackboard",type:"markdown",content:e.content}):null,fn=(e=[],n=!1)=>{if(e.length===0)return null;const l=e.filter(a=>a.is_renderable!==!1).length,m=e.reduce((a,c,g)=>c.is_renderable!==!1?g:a,-1);return r.jsxRuntimeExports.jsx("div",{className:"slide-stage__content flex w-full flex-col gap-4",children:e.map((a,c)=>{const g=a.type==="html"&&a.is_renderable===!1;return r.jsxRuntimeExports.jsx("div",{ref:n&&c===m?nt:null,"aria-hidden":g||void 0,className:Y.cn("w-full shrink-0",l===1&&a.is_renderable!==!1&&"slide-element--single",g?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":a.is_renderable===!1&&"hidden"),children:dn(a,{replaceRootScreenHeightWithFull:l===1&&a.type==="html"&&a.is_renderable!==!1})},a.sequence_number??`${a.type}-${c}`)})})},mn=t.useCallback(()=>{const e=me.current;if(e){if(document.fullscreenElement===e){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},[]),Mt=t.useCallback(()=>{const e=ke.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),pn=t.useCallback(()=>{pe.current=!0,V.current=null,se(!0),i(!1,"player-prev"),y(!0),z(),it()},[it,z,y,i]),hn=t.useCallback(()=>{pe.current=!0,V.current=null,se(!0),i(!1,"player-next"),y(!0),z(),E()},[E,z,y,i]),bn=t.useCallback(e=>{if(D||!x||A){i(!1,"player-loading-change-ignored",{loading:e});return}i(e,e?"player-reported-loading":"player-reported-ready")},[x,A,D,i]),xn=t.useCallback(e=>{const n=p[e]?.audioKey;if(!n||!h||n!==h)return;const l=R.findIndex(c=>c===n);if(l<0){K(null);return}const m=l+1,a=R[m];if(a){K(a);return}if(K(null),dt(!0),i(!1,"player-ended-step-complete"),S){const c=f+1,g=k[c];At&&g?.type==="interaction"&&(V.current=c),E()}},[p,S,f,h,R,E,At,k,i]),yn=t.useCallback(()=>{u&&Se(e=>!e)},[u]),kt=t.useCallback(e=>{e.stopPropagation(),_&&y(!0)},[at,y]),Sn=t.useCallback(e=>{et?.(e)},[et]),vn=t.useCallback(()=>{se(!0),y(!0)},[y]),Ae=t.useMemo(()=>M.map((e,n)=>`${e.sequence_number??`${e.type}-${n}`}:${String(e.is_new??"")}`),[M]);return t.useEffect(()=>{const e=st.current,m=(e.length>0&&e.length<Ae.length&&e.every((c,g)=>c===Ae[g])?M.slice(e.length):[]).some(c=>c.is_new===!1);if(st.current=Ae,!m)return;const a=window.requestAnimationFrame(()=>{const c=ke.current,g=nt.current;if(!c||!g)return;const gn=c.getBoundingClientRect(),En=g.getBoundingClientRect(),Rn=c.scrollTop+(En.top-gn.top);c.scrollTo({top:Math.max(Rn,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(a)}},[M,Ae]),t.useEffect(()=>{if(!pe.current||(pe.current=!1,M.length===0))return;const e=window.requestAnimationFrame(()=>{Mt()});return()=>{window.cancelAnimationFrame(e)}},[M,Mt]),r.jsxRuntimeExports.jsxs("section",{ref:me,className:Y.cn("relative h-full w-full",I&&"slide--mobile-device",H&&"slide--mobile-landscape",ht&&"slide--mobile-landscape-native",Bt),onClick:vn,onPointerDown:Sn,...Lt,children:[Qt?r.jsxRuntimeExports.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]"}):null,r.jsxRuntimeExports.jsxs("div",{ref:tt,className:Y.cn("slide__viewport relative h-full min-h-0 w-full",H&&"slide__viewport--mobile-landscape",H&&!Yt&&"slide__viewport--mobile-landscape-native"),children:[Xt?r.jsxRuntimeExports.jsxs("div",{className:"slide-landscape-header",children:[r.jsxRuntimeExports.jsx("button",{"aria-label":q?.backAriaLabel??"Back",className:"slide-landscape-header__back",onClick:tn,type:"button",children:r.jsxRuntimeExports.jsx(Bn.default,{className:"h-6 w-6 text-white",strokeWidth:2.25})}),q?.content?r.jsxRuntimeExports.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:q.content}):null]}):null,r.jsxRuntimeExports.jsx("div",{className:Y.cn("h-full min-h-0 w-full",Jt&&"slide__viewport-content--with-header",Vt?"slide-content--single":"grid gap-4"),children:M.length>0?r.jsxRuntimeExports.jsx("div",{className:"slide-stage",children:r.jsxRuntimeExports.jsx("div",{ref:ke,className:"slide-stage__layer w-full",children:rn.map((e,n)=>{const l=n===sn;return r.jsxRuntimeExports.jsx("div",{"aria-hidden":!l||void 0,className:"w-full h-full",style:{display:l?void 0:"none"},children:fn(e.elementList,l)},e.sourceStepIndexes[0]??n)})})}):null}),Kt?r.jsxRuntimeExports.jsx(In.default,{message:_e,className:"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2"}):null,r.jsxRuntimeExports.jsx(Tn.default,{onClose:nn,open:Gt,text:Zt}),r.jsxRuntimeExports.jsx(Cn.default,{extraBottomOffset:$t,hasPlayerGap:_,isEnabled:ft&&Ut,isPlayerHidden:v&&!_,playbackTimeStore:U,subtitleCues:on}),We?r.jsxRuntimeExports.jsx("div",{ref:rt,className:Y.cn("slide-interaction-overlay",_&&v?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone"),onClick:kt,onPointerDown:kt,style:ln,children:r.jsxRuntimeExports.jsx(Ft,{content:String(u?.content??""),defaultButtonText:_t.buttonText??"",defaultInputText:_t.inputText??"",defaultSelectedValues:an,confirmButtonText:de?.confirmButtonText,copyButtonText:de?.copyButtonText,copiedButtonText:de?.copiedButtonText,onSend:cn,readonly:Ct,title:de?.title??we??"Submit the content below to continue."})}):null,v?r.jsxRuntimeExports.jsx(wn.default,{audioList:p,className:Y.cn("absolute left-1/2 bottom-6 z-[2] -translate-x-1/2",F,!_&&"pointer-events-none opacity-0"),currentAudioIndex:b,defaultPlaying:!0,isPlaybackPaused:O,isAutoAdvanceEnabled:oe,hasInteraction:!!u,isInteractionOpen:ye,isSubtitleEnabled:ft,onAutoAdvanceToggle:ct,onLoadingChange:bn,onPlaybackStarted:()=>{Fe(!0)},onPlaybackTimeChange:U.setTime,onSubtitleToggle:()=>{Ht(e=>!e)},nextDisabled:!S,onEnded:xn,onFullscreen:mn,isFullscreen:Wt,mobileViewMode:P,settingsPortalContainer:tt.current,onMobileViewModeChange:en,onInteractionToggle:yn,onNext:hn,onPrev:pn,prevDisabled:!Nt,showControls:_,texts:Ge,customActionContext:He,customActions:N,useAutoAdvanceToggle:ie}):null]})]})};exports.default=Wn;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),dn=require("../../lib/sandboxInteraction.cjs.js"),G=require("../../lib/utils.cjs.js"),fn=require("../ui/loading-overlay-card.cjs.js"),mn=require("../ContentRender/ContentRender.cjs.js"),St=require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");const yt=require("../../lib/interaction-defaults.cjs.js"),ye=require("../../lib/mobileDevice.cjs.js"),pn=require("./Player.cjs.js"),hn=require("./SubtitleOverlay.cjs.js"),xn=require("./constants.cjs.js"),bn=require("./SlideFullscreenHint.cjs.js"),vn=require("./useSlide.cjs.js"),En=require("./useWakePlayerFromIframe.cjs.js"),ue=require("./utils/mobileScreenMode.cjs.js"),Sn=require("./utils/interactionPlayback.cjs.js"),yn=require("./utils/appendedMarkerAdvance.cjs.js"),gn=require("./utils/playbackSequence.cjs.js"),gt=require("./utils/playerCustomActions.cjs.js"),Rn=require("./utils/playbackTimeStore.cjs.js"),In=require("./utils/playerToggleMode.cjs.js");;/* empty css */const An=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/chevron-left.cjs.js"),wn=2e3,Cn=300,Mn=160,_n=16,Rt=t.memo(({content:q,title:B,defaultButtonText:v,defaultInputText:$,defaultSelectedValues:E,confirmButtonText:N,copyButtonText:Y,copiedButtonText:ge,onSend:Re,readonly:O=!1})=>r.jsxRuntimeExports.jsxs("div",{className:"slide-player__interaction-card",children:[r.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-header",children:r.jsxRuntimeExports.jsx("p",{className:"slide-player__interaction-title",children:B})}),r.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-body",children:r.jsxRuntimeExports.jsx(mn.default,{content:q,defaultButtonText:v,defaultInputText:$,defaultSelectedValues:E,confirmButtonText:N,copyButtonText:Y,copiedButtonText:ge,onSend:Re,readonly:O,enableTypewriter:!1,sandboxMode:"content"})})]}));Rt.displayName="InteractionOverlayCard";const kn=(q,B)=>q.length===B.length&&q.every((v,$)=>{const E=B[$];return v.sequence_number===E?.sequence_number&&v.type===E?.type&&v.content===E?.content}),Tn=({elementList:q=[],showPlayer:B=!0,playerAlwaysVisible:v=!1,playerClassName:$,fullscreenHeader:E,playerCustomActions:N,playerCustomActionPauseOnActive:Y=!0,bufferingText:ge="Buffering...",interactionTitle:Re,interactionTexts:O,playerTexts:Oe,playerAutoHideDelay:Ie=3e3,markerAutoAdvanceDelay:Le=wn,interactionDefaultValueOptions:ie,onSend:Ve,onPlayerVisibilityChange:Ae,onMobileViewModeChange:Ke,onStepChange:De,enableIframeScaling:It=!0,disableLoadingOverlay:g=!1,className:At,onPointerDown:He,...wt})=>{const ce=t.useRef(null),Ue=t.useRef(null),we=t.useRef(null),We=t.useRef(null),X=t.useRef(null),J=t.useRef(null),Q=t.useRef(null),Z=t.useRef(null),ze=t.useRef(null),Ge=t.useRef([]),ae=t.useRef(!1),L=t.useRef(null),$e=t.useRef(null),Ye=t.useRef({markerCount:0,currentIndex:-1,canGoNext:!1}),{currentElementList:_,stepElementLists:Xe,slideElementList:k,currentIndex:c,audioList:d,currentAudioSequenceIndexes:de,currentStepHasSpeakableElement:h,currentInteractionElement:i,canGoPrev:Ct,canGoNext:b,handlePrev:Je,handleNext:R}=vn.default(q),ee=t.useMemo(()=>{if(!(c<0))return k[c]},[c,k]),Mt=k.filter(e=>e.is_renderable!==!1).length===1,S=B&&(k.length>0||d.length>0||!!i),I=t.useMemo(()=>de.map(e=>d[e]?.audioKey).filter(e=>!!e),[d,de]),[Qe,fe]=t.useState(!0),[me,te]=t.useState(!1),[ne,Ze]=t.useState(!0),[f,V]=t.useState(null),[_t,m]=t.useState(!1),[A,et]=t.useState(!1),[kt,Ce]=t.useState(!1),[tt,Tt]=t.useState(!0),[Me,_e]=t.useState(!1),[s,ke]=t.useState(),[pe,he]=t.useState(!1),[jt,re]=t.useState(0),[Pt,Ft]=t.useState(!1),w=t.useMemo(()=>ye.isMobileDevice(),[]),[xe,Te]=t.useState(ue.DEFAULT_MOBILE_VIEW_MODE),[nt,je]=t.useState(!1),[Pe,rt]=t.useState(()=>w?ye.isLandscapeViewport():!1),[qt,be]=t.useState(!1),K=t.useMemo(()=>Rn.createPlaybackTimeStore(),[]),{effectiveMobileViewMode:j,isImmersiveMobileFullscreen:D,isNativeMobileFullscreen:st,shouldRotateFullscreenViewport:Bt}=t.useMemo(()=>ue.resolveMobileViewModeState({hasManualMobileViewMode:nt,isMobileDevice:w,mobileViewMode:xe}),[nt,w,Pe,xe]),ot=t.useRef(j),C=S&&(v||Qe),Nt=D&&C,Ot=D&&C,Lt=D||st,Vt=Oe?.fullscreenHintText??xn.DEFAULT_SLIDE_PLAYER_TEXTS.fullscreenHintText,Kt=t.useCallback(e=>{je(!0),Te(e)},[]),lt=t.useCallback(()=>{je(!1),Te(ue.DEFAULT_MOBILE_VIEW_MODE)},[]),Dt=t.useCallback(()=>{lt(),E?.onBack?.()},[E,lt]),Ht=t.useCallback(()=>{be(!1)},[]),ut=t.useCallback(e=>{_e(e)},[]),it=t.useCallback(()=>{_e(e=>!e)},[]),{mountedStepStates:Ut,currentMountedStateIndex:Wt}=t.useMemo(()=>{const e=[],n=new Map;return Xe.forEach((o,a)=>{const l=e.findIndex(u=>kn(u.elementList,o));if(l>=0){e[l]?.sourceStepIndexes.push(a),n.set(a,l);return}e.push({elementList:o,sourceStepIndexes:[a]}),n.set(a,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:c>=0?n.get(c)??-1:-1}},[c,Xe]),ct=t.useMemo(()=>String(c),[c]),p=t.useMemo(()=>f?d.findIndex(e=>(e.audioKey??"")===f):-1,[d,f]),Fe=t.useMemo(()=>p>=0?d[p]:void 0,[d,p]),zt=Fe?.element?.subtitle_cues??[],ve=t.useMemo(()=>I[0]??"none",[I]),qe=t.useMemo(()=>({currentElement:gt.resolvePlayerCustomActionElement({currentAudioIndex:p,currentAudioSequenceIndexes:de,audioList:d,currentInteractionElement:s,currentStepElement:ee}),currentIndex:c,currentStepElement:ee,isActive:Me,setActive:ut,toggleActive:it}),[s,d,p,de,c,ee,Me,ut,it]),Be=t.useMemo(()=>gt.getPlayerCustomActionCount(N,qe),[qe,N]),Gt=t.useMemo(()=>({"--slide-player-custom-action-count":String(Be),"--slide-player-mobile-control-count":String(Be+4)}),[Be]),at=I.length>0,dt=t.useMemo(()=>i?`${i.sequence_number??"none"}:${String(i.content??"")}`:"none",[i]),se=t.useMemo(()=>[ct,dt].join("|"),[dt,ct]),$t=t.useMemo(()=>[se,Fe?.audioKey??"none",String(p)].join("|"),[p,Fe?.audioKey,se]),ft=!!t.useMemo(()=>!ve||ve==="none"?"":d.find(n=>n.audioKey===ve)?.audioUrl?.trim()??"",[d,ve]),P=Y&&!!N&&Me,oe=t.useMemo(()=>In.shouldUseAutoAdvanceToggle({canGoNext:b,currentAudioIndex:p,currentStepHasSpeakableElement:h,hasInteraction:!!i}),[b,p,i,h]),F=t.useCallback(()=>{X.current!==null&&(window.clearTimeout(X.current),X.current=null)},[]),T=t.useCallback(()=>{Q.current!==null&&(window.clearTimeout(Q.current),Q.current=null)},[]),M=t.useCallback(()=>{Z.current!==null&&(window.clearTimeout(Z.current),Z.current=null)},[]),H=t.useCallback(()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},[]),U=t.useCallback(()=>{H(),T(),M(),V(null),K.reset(),m(!1),et(!1),Ce(!1),ke(void 0),he(!1),re(0)},[H,T,M,K]),W=t.useCallback(()=>{const e=I[0];return e?(V(e),!0):!1},[I]),Ee=t.useCallback(()=>{T(),M(),he(!1),re(0),!W()&&b&&R()},[b,T,M,R,W]),mt=t.useCallback(e=>{if(M(),!e)return;const n=()=>{Z.current=null,re(Mn),he(!0),L.current=null};Z.current=window.setTimeout(n,Cn)},[M]),x=t.useCallback((e=me)=>{S&&(fe(!0),F(),!(v||!e||Ie<=0)&&(X.current=window.setTimeout(()=>{fe(!1),X.current=null},Ie)))},[F,me,v,Ie,S]),le=!!(i?.readonly||i?.user_input?.trim()),z=!!i&&!le;t.useEffect(()=>{Ze(!0),Y&&_e(!1)},[c,Y]),t.useEffect(()=>()=>{H(),F(),T(),M()},[H,T,M,F]),t.useEffect(()=>(Ae?.(C),()=>{Ae?.(!1)}),[Ae,C]),t.useEffect(()=>{w||xe===ue.DEFAULT_MOBILE_VIEW_MODE||(je(!1),Te(ue.DEFAULT_MOBILE_VIEW_MODE))},[w,xe]),t.useEffect(()=>{if(!w){rt(!1);return}const e=()=>{rt(ye.isLandscapeViewport())};return e(),ye.subscribeMobileDeviceChange(e)},[w]),t.useEffect(()=>{Ke?.(j)},[j,Ke]),t.useEffect(()=>{const o=ot.current!=="fullscreen"&&j==="fullscreen"&&!Pe;if(ot.current=j,!w){be(!1);return}if(o){be(!0);return}j!=="fullscreen"&&be(!1)},[j,w,Pe]),t.useEffect(()=>{De?.(ee,c)},[c,ee,De]),t.useEffect(()=>{const e=Ye.current,n=yn.shouldAutoAdvanceIntoAppendedMarker({previousMarkerCount:e.markerCount,nextMarkerCount:k.length,previousIndex:e.currentIndex,previousCanGoNext:e.canGoNext,nextCanGoNext:b,currentAudioKey:f,hasCompletedCurrentStepAudio:A,hasResolvedCurrentInteraction:le,currentStepHasSpeakableElement:h,currentInteractionElement:i,isAutoAdvanceEnabled:ne,shouldUseSilentStepAutoAdvanceToggle:oe});Ye.current={markerCount:k.length,currentIndex:c,canGoNext:b},n&&R()},[b,f,c,i,h,R,A,le,ne,oe,k.length]),t.useEffect(()=>{if(!S){F(),fe(!1);return}if(v){F(),fe(!0);return}me||x(!0)},[F,me,v,S,x]),t.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.origin===window.location.origin&&dn.isSandboxInteractionMessage(n.data)&&n.data.eventType==="click"&&S&&(te(!0),x(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[S,x]),En.default({sectionRef:ce,enabled:S,onWake:()=>{te(!0),x(!0)}}),t.useEffect(()=>{const{hasPlaybackContextChanged:e,shouldInitializeAudioSequence:n}=gn.getPlaybackSequenceTransition({previousResetKey:$e.current,nextResetKey:se,currentAudioKey:f,hasCompletedCurrentStepAudio:A});$e.current=se;const o=L.current===c&&!!i,a=Sn.shouldPresentInteractionOverlay({hasInteraction:!!i,shouldBlockPlaybackForInteraction:z,shouldOpenInteractionOverlayAfterAudio:o,hasPlaybackContextChanged:e,hasResolvedCurrentInteraction:le,currentStepHasSpeakableElement:h});if(e&&U(),!(_.length===0&&!i)&&!P){if(i&&ke(i),a){mt(i);return}if(M(),L.current=null,!!n&&!W()){if(h){if(g){m(!1);return}m(!0);return}if(b&&!(oe&&!ne))return J.current=window.setTimeout(()=>{J.current=null,R()},Le),()=>{H()}}}},[b,H,_.length,i,f,se,h,Le,R,A,g,ne,le,z,M,U,mt,W,P,oe]),t.useEffect(()=>{if(g||P||!h||z){m(!1);return}if(A){m(!1);return}if(at){m(!1);return}m(!0)},[at,h,A,g,P,z]),t.useEffect(()=>{f||I.length===0||P||!h||z||A||W()},[f,I,h,A,P,z,W]),t.useEffect(()=>{!f||p>=0||V(null)},[p,f]),t.useEffect(()=>{p>=0||K.reset()},[p,K]),t.useEffect(()=>{Ce(!1)},[$t]);const pt=t.useMemo(()=>{if(!s)return{};const e=!!s.user_input?.trim();return yt.getInteractionDefaultValues(typeof s.content=="string"?s.content:void 0,s.user_input,e?void 0:ie)},[s,ie]),Yt=t.useMemo(()=>{if(!s)return;const e=!!s.user_input?.trim();return yt.getInteractionDefaultSelectedValues(typeof s.content=="string"?s.content:void 0,s.user_input,e?void 0:ie)},[s,ie]),ht=!!s?.user_input?.trim(),xt=!!s?.readonly||ht,bt=xt||ht,Ne=!!s&&pe,Xt=t.useCallback(e=>{const o=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");ke(a=>!a||!o?a:{...a,user_input:o}),Ve?.(e,s),Ee()},[s,Ee,Ve]);t.useEffect(()=>{const e=()=>{Ft(document.fullscreenElement===ce.current)};return e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),t.useEffect(()=>{if(!Ne){re(0);return}const e=ze.current;if(!e)return;const n=()=>{const a=Math.ceil(e.getBoundingClientRect().height);re(a+_n)};if(n(),typeof ResizeObserver>"u")return;const o=new ResizeObserver(()=>{n()});return o.observe(e),()=>{o.disconnect()}},[Ne]),t.useEffect(()=>{if(T(),!(!pe||!bt))return Q.current=window.setTimeout(()=>{Q.current=null,Ee()},2e3),()=>{T()}},[T,Ee,pe,bt]);const Jt=(e,n={})=>e?e.type==="slot"?r.jsxRuntimeExports.jsx(r.jsxRuntimeExports.Fragment,{children:e.content}):e.type==="html"?r.jsxRuntimeExports.jsx(St.default,{className:"content-render-iframe",disableLoadingOverlay:g,hideFullScreen:!0,mode:"blackboard",replaceRootScreenHeightWithFull:n.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content,enableScaling:It}):r.jsxRuntimeExports.jsx(St.default,{className:"content-render-iframe",disableLoadingOverlay:g,hideFullScreen:!0,mode:"blackboard",type:"markdown",content:e.content}):null,Qt=(e=[],n=!1)=>{if(e.length===0)return null;const o=e.filter(l=>l.is_renderable!==!1).length,a=e.reduce((l,u,y)=>u.is_renderable!==!1?y:l,-1);return r.jsxRuntimeExports.jsx("div",{className:"slide-stage__content flex w-full flex-col gap-4",children:e.map((l,u)=>{const y=l.type==="html"&&l.is_renderable===!1;return r.jsxRuntimeExports.jsx("div",{ref:n&&u===a?We:null,"aria-hidden":y||void 0,className:G.cn("w-full shrink-0",o===1&&l.is_renderable!==!1&&"slide-element--single",y?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":l.is_renderable===!1&&"hidden"),children:Jt(l,{replaceRootScreenHeightWithFull:o===1&&l.type==="html"&&l.is_renderable!==!1})},l.sequence_number??`${l.type}-${u}`)})})},Zt=t.useCallback(()=>{const e=ce.current;if(e){if(document.fullscreenElement===e){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},[]),vt=t.useCallback(()=>{const e=we.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),en=t.useCallback(()=>{ae.current=!0,L.current=null,te(!0),m(!1),x(!0),U(),Je()},[Je,U,x]),tn=t.useCallback(()=>{ae.current=!0,L.current=null,te(!0),m(!1),x(!0),U(),R()},[R,U,x]),nn=t.useCallback(e=>{if(g){m(!1);return}if(!h||A){m(!1);return}m(e)},[h,A,g]);t.useEffect(()=>{g&&m(!1)},[g]);const rn=t.useCallback(e=>{const n=d[e]?.audioKey;if(!n||!f||n!==f)return;const o=I.findIndex(u=>u===n);if(o<0){V(null);return}const a=o+1,l=I[a];if(l){V(l);return}if(V(null),et(!0),m(!1),b){const u=c+1,y=k[u];ft&&y?.type==="interaction"&&(L.current=u),R()}},[d,b,c,f,I,R,ft,k]),sn=t.useCallback(()=>{s&&he(e=>!e)},[s]),Et=t.useCallback(e=>{e.stopPropagation(),C&&x(!0)},[Qe,x]),on=t.useCallback(e=>{He?.(e)},[He]),ln=t.useCallback(()=>{te(!0),x(!0)},[x]),Se=t.useMemo(()=>_.map((e,n)=>`${e.sequence_number??`${e.type}-${n}`}:${String(e.is_new??"")}`),[_]);return t.useEffect(()=>{const e=Ge.current,a=(e.length>0&&e.length<Se.length&&e.every((u,y)=>u===Se[y])?_.slice(e.length):[]).some(u=>u.is_new===!1);if(Ge.current=Se,!a)return;const l=window.requestAnimationFrame(()=>{const u=we.current,y=We.current;if(!u||!y)return;const un=u.getBoundingClientRect(),cn=y.getBoundingClientRect(),an=u.scrollTop+(cn.top-un.top);u.scrollTo({top:Math.max(an,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(l)}},[_,Se]),t.useEffect(()=>{if(!ae.current||(ae.current=!1,_.length===0))return;const e=window.requestAnimationFrame(()=>{vt()});return()=>{window.cancelAnimationFrame(e)}},[_,vt]),r.jsxRuntimeExports.jsxs("section",{ref:ce,className:G.cn("relative h-full w-full",w&&"slide--mobile-device",D&&"slide--mobile-landscape",st&&"slide--mobile-landscape-native",At),onClick:ln,onPointerDown:on,...wt,children:[Lt?r.jsxRuntimeExports.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]"}):null,r.jsxRuntimeExports.jsxs("div",{ref:Ue,className:G.cn("slide__viewport relative h-full min-h-0 w-full",D&&"slide__viewport--mobile-landscape",D&&!Bt&&"slide__viewport--mobile-landscape-native"),children:[Nt?r.jsxRuntimeExports.jsxs("div",{className:"slide-landscape-header",children:[r.jsxRuntimeExports.jsx("button",{"aria-label":E?.backAriaLabel??"Back",className:"slide-landscape-header__back",onClick:Dt,type:"button",children:r.jsxRuntimeExports.jsx(An.default,{className:"h-6 w-6 text-white",strokeWidth:2.25})}),E?.content?r.jsxRuntimeExports.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:E.content}):null]}):null,r.jsxRuntimeExports.jsx("div",{className:G.cn("h-full min-h-0 w-full",Ot&&"slide__viewport-content--with-header",Mt?"slide-content--single":"grid gap-4"),children:_.length>0?r.jsxRuntimeExports.jsx("div",{className:"slide-stage",children:r.jsxRuntimeExports.jsx("div",{ref:we,className:"slide-stage__layer w-full",children:Ut.map((e,n)=>{const o=n===Wt;return r.jsxRuntimeExports.jsx("div",{"aria-hidden":!o||void 0,className:"w-full h-full",style:{display:o?void 0:"none"},children:Qt(e.elementList,o)},e.sourceStepIndexes[0]??n)})})}):null}),_t?r.jsxRuntimeExports.jsx(fn.default,{message:ge,className:"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2"}):null,r.jsxRuntimeExports.jsx(bn.default,{onClose:Ht,open:qt,text:Vt}),r.jsxRuntimeExports.jsx(hn.default,{extraBottomOffset:jt,hasPlayerGap:C,isEnabled:tt&&kt,isPlayerHidden:S&&!C,playbackTimeStore:K,subtitleCues:zt}),Ne?r.jsxRuntimeExports.jsx("div",{ref:ze,className:G.cn("slide-interaction-overlay",C&&S?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone"),onClick:Et,onPointerDown:Et,style:Gt,children:r.jsxRuntimeExports.jsx(Rt,{content:String(s?.content??""),defaultButtonText:pt.buttonText??"",defaultInputText:pt.inputText??"",defaultSelectedValues:Yt,confirmButtonText:O?.confirmButtonText,copyButtonText:O?.copyButtonText,copiedButtonText:O?.copiedButtonText,onSend:Xt,readonly:xt,title:O?.title??Re??"Submit the content below to continue."})}):null,S?r.jsxRuntimeExports.jsx(pn.default,{audioList:d,className:G.cn("absolute left-1/2 bottom-6 z-[2] -translate-x-1/2",$,!C&&"pointer-events-none opacity-0"),currentAudioIndex:p,defaultPlaying:!0,isPlaybackPaused:P,isAutoAdvanceEnabled:ne,hasInteraction:!!s,isInteractionOpen:pe,isSubtitleEnabled:tt,onAutoAdvanceToggle:Ze,onLoadingChange:nn,onPlaybackStarted:()=>{Ce(!0)},onPlaybackTimeChange:K.setTime,onSubtitleToggle:()=>{Tt(e=>!e)},nextDisabled:!b,onEnded:rn,onFullscreen:Zt,isFullscreen:Pt,mobileViewMode:j,settingsPortalContainer:Ue.current,onMobileViewModeChange:Kt,onInteractionToggle:sn,onNext:tn,onPrev:en,prevDisabled:!Ct,showControls:C,texts:Oe,customActionContext:qe,customActions:N,useAutoAdvanceToggle:oe}):null]})]})};exports.default=Tn;
|
|
2
2
|
//# sourceMappingURL=Slide.cjs.js.map
|