markdown-flow-ui 0.1.100-beta.39 → 0.1.100-beta.40

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 (58) hide show
  1. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
  2. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
  3. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
  4. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js +1 -1
  5. package/dist/Documents/ai-shifu/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
  6. package/dist/Documents/ai-shifu/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
  7. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js +1 -1
  8. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.es.js +1 -1
  9. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js +1 -1
  10. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.es.js +1 -1
  11. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js +1 -1
  12. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.es.js +1 -1
  13. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js +1 -1
  14. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.es.js +1 -1
  15. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js +1 -1
  16. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.es.js +1 -1
  17. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.cjs.js +1 -1
  18. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.es.js +1 -1
  19. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.cjs.js +1 -1
  20. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.es.js +1 -1
  21. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
  22. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
  23. package/dist/_virtual/index.cjs10.js +1 -1
  24. package/dist/_virtual/index.cjs11.js +1 -1
  25. package/dist/_virtual/index.cjs5.js +1 -1
  26. package/dist/_virtual/index.cjs6.js +1 -1
  27. package/dist/_virtual/index.cjs7.js +1 -1
  28. package/dist/_virtual/index.cjs8.js +1 -1
  29. package/dist/_virtual/index.cjs9.js +1 -1
  30. package/dist/_virtual/index.es10.js +2 -3
  31. package/dist/_virtual/index.es10.js.map +1 -1
  32. package/dist/_virtual/index.es11.js +3 -2
  33. package/dist/_virtual/index.es11.js.map +1 -1
  34. package/dist/_virtual/index.es5.js +4 -4
  35. package/dist/_virtual/index.es6.js +4 -4
  36. package/dist/_virtual/index.es7.js +3 -2
  37. package/dist/_virtual/index.es7.js.map +1 -1
  38. package/dist/_virtual/index.es8.js +2 -2
  39. package/dist/_virtual/index.es9.js +2 -3
  40. package/dist/_virtual/index.es9.js.map +1 -1
  41. package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
  42. package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
  43. package/dist/components/ContentRender/ContentRender.es.js +211 -140
  44. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  45. package/dist/components/ContentRender/IframeSandbox.cjs.js +4 -4
  46. package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
  47. package/dist/components/ContentRender/IframeSandbox.es.js +211 -260
  48. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  49. package/dist/components/ContentRender/SandboxApp.cjs.js +2 -2
  50. package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
  51. package/dist/components/ContentRender/SandboxApp.es.js +109 -135
  52. package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
  53. package/dist/components/ContentRender/index.cjs.js +1 -1
  54. package/dist/components/ContentRender/index.es.js +5 -6
  55. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
  56. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
  57. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +2 -2
  58. package/package.json +1 -1
@@ -1,85 +1,50 @@
1
- import { j as w } from "../../_virtual/jsx-runtime.es.js";
2
- import C, { useRef as d, useState as F, useCallback as Fe, useEffect as S } from "react";
3
- import { createRoot as Ve } from "react-dom/client";
4
- import Pe from "./SandboxApp.es.js";
5
- import { splitContentSegments as Oe } from "./utils/split-content.es.js";
6
- import De from "./ContentRender.es.js";
7
- import { SANDBOX_INTERACTION_MESSAGE_TYPE as ke, SANDBOX_INTERACTION_MESSAGE_SOURCE as Le } from "../../lib/sandboxInteraction.es.js";
8
- let te = null;
9
- const be = () => (te || (te = import("./blackboard-vendor.es.js").then(
10
- (e) => e.injectBlackboardLibraries
11
- )), te);
12
- typeof window < "u" && be();
13
- const Be = () => {
14
- const e = performance.now(), t = (/* @__PURE__ */ new Date()).toISOString();
15
- return console.log("[IframeSandbox][SandboxLoad] start", { startedAt: t }), be().then((n) => (console.log("[IframeSandbox][SandboxLoad] done", {
16
- startedAt: t,
1
+ import { j as b } from "../../_virtual/jsx-runtime.es.js";
2
+ import N, { useRef as d, useState as V, useCallback as Ae, useEffect as y } from "react";
3
+ import { createRoot as Re } from "react-dom/client";
4
+ import Te from "./SandboxApp.es.js";
5
+ import { splitContentSegments as Me } from "./utils/split-content.es.js";
6
+ import Ne from "./ContentRender.es.js";
7
+ import { SANDBOX_INTERACTION_MESSAGE_TYPE as Ve, SANDBOX_INTERACTION_MESSAGE_SOURCE as Fe } from "../../lib/sandboxInteraction.es.js";
8
+ let U = null;
9
+ const Ie = () => (U || (U = import("./blackboard-vendor.es.js").then(
10
+ (t) => t.injectBlackboardLibraries
11
+ )), U), ke = () => {
12
+ const t = performance.now(), e = (/* @__PURE__ */ new Date()).toISOString();
13
+ return console.log("[IframeSandbox][SandboxLoad] start", { startedAt: e }), Ie().then((n) => (console.log("[IframeSandbox][SandboxLoad] done", {
14
+ startedAt: e,
17
15
  endedAt: (/* @__PURE__ */ new Date()).toISOString(),
18
- durationMs: Number((performance.now() - e).toFixed(2))
16
+ durationMs: Number((performance.now() - t).toFixed(2))
19
17
  }), n)).catch((n) => {
20
18
  throw console.error("[IframeSandbox][SandboxLoad] failed", {
21
- startedAt: t,
19
+ startedAt: e,
22
20
  endedAt: (/* @__PURE__ */ new Date()).toISOString(),
23
- durationMs: Number((performance.now() - e).toFixed(2)),
21
+ durationMs: Number((performance.now() - t).toFixed(2)),
24
22
  error: n
25
23
  }), n;
26
24
  });
27
- }, $e = /<img\b[^>]*>/i, je = 180, ze = 240, Ge = /<img\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi, fe = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Set(), qe = (e) => {
28
- const t = Array.from(e.matchAll(Ge));
29
- return Array.from(
30
- new Set(
31
- t.map((n) => n[1]?.trim()).filter((n) => !!n)
32
- )
33
- );
34
- }, Xe = (e) => {
35
- if (!e)
36
- return Promise.resolve();
37
- const t = fe.get(e);
38
- if (t)
39
- return t;
40
- const n = new Promise((s) => {
41
- if (typeof window > "u") {
42
- $.add(e), s();
43
- return;
44
- }
45
- const o = new window.Image();
46
- o.decoding = "sync", o.loading = "eager", o.fetchPriority = "high";
47
- const l = () => {
48
- (typeof o.decode == "function" ? o.decode().catch(() => {
49
- }) : Promise.resolve()).finally(() => {
50
- $.add(e), s();
51
- });
52
- };
53
- o.onload = () => {
54
- l();
55
- }, o.onerror = () => {
56
- $.add(e), s();
57
- }, o.src = e, o.complete && o.naturalWidth > 0 && l();
58
- });
59
- return fe.set(e, n), n;
60
- }, ge = (e = []) => Promise.allSettled(e.map((t) => Xe(t))), we = (e) => e.split(/\s+/).filter(Boolean).map((t) => t.split(":").pop() || t), j = (e) => {
61
- const t = e.trim().toLowerCase();
62
- if (!t) return null;
63
- const n = t.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);
25
+ }, De = /<img\b[^>]*>/i, Oe = 180, _e = 240, he = (t) => t.split(/\s+/).filter(Boolean).map((e) => e.split(":").pop() || e), L = (t) => {
26
+ const e = t.trim().toLowerCase();
27
+ if (!e) return null;
28
+ const n = e.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);
64
29
  return n ? `${n[1]}${n[2].toLowerCase()}` : null;
65
- }, ne = (e) => {
66
- if (!e.trim()) return null;
67
- const t = we(e);
68
- if (t.includes("h-screen") || t.includes("h-dvh") || t.includes("min-h-screen") || t.includes("min-h-dvh"))
30
+ }, W = (t) => {
31
+ if (!t.trim()) return null;
32
+ const e = he(t);
33
+ if (e.includes("h-screen") || e.includes("h-dvh") || e.includes("min-h-screen") || e.includes("min-h-dvh"))
69
34
  return "100dvh";
70
- if (t.includes("h-svh") || t.includes("min-h-svh"))
35
+ if (e.includes("h-svh") || e.includes("min-h-svh"))
71
36
  return "100svh";
72
- if (t.includes("h-lvh") || t.includes("min-h-lvh"))
37
+ if (e.includes("h-lvh") || e.includes("min-h-lvh"))
73
38
  return "100lvh";
74
- const n = t.find(
75
- (o) => /^(h|min-h)-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(o)
39
+ const n = e.find(
40
+ (i) => /^(h|min-h)-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(i)
76
41
  );
77
42
  if (!n) return null;
78
43
  const s = n.match(
79
44
  /^(h|min-h)-\[([0-9.]+)(vh|dvh|svh|lvh)\]$/i
80
45
  );
81
46
  return s ? `${s[2]}${s[3].toLowerCase()}` : null;
82
- }, Ue = /* @__PURE__ */ new Set([
47
+ }, Le = /* @__PURE__ */ new Set([
83
48
  "base",
84
49
  "link",
85
50
  "meta",
@@ -87,175 +52,161 @@ const Be = () => {
87
52
  "style",
88
53
  "template",
89
54
  "title"
90
- ]), ve = (e) => !Ue.has(e.tagName.toLowerCase()), We = (e) => Array.from(e.childNodes).find(
91
- (t) => t.nodeType === Node.ELEMENT_NODE && ve(t)
92
- ) || null, Ye = (e) => {
93
- const t = [];
94
- let n = We(e);
55
+ ]), de = (t) => !Le.has(t.tagName.toLowerCase()), $e = (t) => Array.from(t.childNodes).find(
56
+ (e) => e.nodeType === Node.ELEMENT_NODE && de(e)
57
+ ) || null, je = (t) => {
58
+ const e = [];
59
+ let n = $e(t);
95
60
  for (; n; ) {
96
- t.push(n);
61
+ e.push(n);
97
62
  const s = Array.from(n.children).filter(
98
- (o) => ve(o)
63
+ (i) => de(i)
99
64
  );
100
65
  if (s.length !== 1)
101
66
  break;
102
67
  n = s[0];
103
68
  }
104
- return t;
105
- }, Ze = (e) => {
106
- const t = e.getAttribute("height"), n = t ? j(t) : null;
69
+ return e;
70
+ }, Be = (t) => {
71
+ const e = t.getAttribute("height"), n = e ? L(e) : null;
107
72
  if (n)
108
73
  return n;
109
- const s = e.getAttribute("style")?.match(/\bheight\s*:\s*([^;]+)/i)?.[1] || null, o = s ? j(s) : null;
110
- return o || ne(
111
- e.getAttribute("class") || ""
74
+ const s = t.getAttribute("style")?.match(/\bheight\s*:\s*([^;]+)/i)?.[1] || null, i = s ? L(s) : null;
75
+ return i || W(
76
+ t.getAttribute("class") || ""
112
77
  );
113
- }, xe = (e) => e === "100vh" || e === "100dvh" || e === "100svh" || e === "100lvh", Ee = (e) => {
114
- const t = Ye(e);
78
+ }, me = (t) => t === "100vh" || t === "100dvh" || t === "100svh" || t === "100lvh", fe = (t) => {
79
+ const e = je(t);
115
80
  let n = null, s = !1;
116
- return t.forEach((o) => {
117
- const l = Ze(o);
118
- !n && l && (n = l), xe(l) && (s = !0);
81
+ return e.forEach((i) => {
82
+ const l = Be(i);
83
+ !n && l && (n = l), me(l) && (s = !0);
119
84
  }), {
120
85
  viewportHeightCss: n,
121
86
  hasFullViewportHeight: s
122
87
  };
123
- }, Je = (e) => {
124
- const t = e.trim();
125
- if (!t)
88
+ }, ze = (t) => {
89
+ const e = t.trim();
90
+ if (!e)
126
91
  return {
127
92
  viewportHeightCss: null,
128
93
  hasFullViewportHeight: !1
129
94
  };
130
- const s = t.match(/^<([a-zA-Z][\w:-]*)(\s[^>]*?)?>/)?.[2] || "", o = s.match(/\bheight\s*=\s*["']([^"']+)["']/i)?.[1], m = s.match(/\bstyle\s*=\s*["']([^"']+)["']/i)?.[1]?.match(
95
+ const s = e.match(/^<([a-zA-Z][\w:-]*)(\s[^>]*?)?>/)?.[2] || "", i = s.match(/\bheight\s*=\s*["']([^"']+)["']/i)?.[1], m = s.match(/\bstyle\s*=\s*["']([^"']+)["']/i)?.[1]?.match(
131
96
  /\bheight\s*:\s*([^;]+)/i
132
- )?.[1], R = s.match(/\bclass\s*=\s*["']([^"']+)["']/i)?.[1], h = (o ? j(o) : null) || (m ? j(m) : null) || (R ? ne(R) : null);
97
+ )?.[1], C = s.match(/\bclass\s*=\s*["']([^"']+)["']/i)?.[1], h = (i ? L(i) : null) || (m ? L(m) : null) || (C ? W(C) : null);
133
98
  return {
134
99
  viewportHeightCss: h,
135
- hasFullViewportHeight: xe(h)
100
+ hasFullViewportHeight: me(h)
136
101
  };
137
- }, pe = (e) => {
138
- const t = e.trim();
139
- if (!t)
102
+ }, ue = (t) => {
103
+ const e = t.trim();
104
+ if (!e)
140
105
  return {
141
106
  viewportHeightCss: null,
142
107
  hasFullViewportHeight: !1
143
108
  };
144
109
  if (typeof document > "u")
145
- return Je(t);
110
+ return ze(e);
146
111
  const n = document.createElement("template");
147
- return n.innerHTML = t, Ee(n.content);
148
- }, Ke = (e) => e.split(/\s+/).filter(Boolean).map((t) => {
149
- const n = t.split(":");
150
- return n[n.length - 1] !== "h-screen" && n[n.length - 1] !== "min-h-screen" ? t : (n[n.length - 1] = "h-full", n.join(":"));
151
- }).join(" "), Qe = (e, t) => !t || !e.trim() ? e : e.replace(
112
+ return n.innerHTML = e, fe(n.content);
113
+ }, Pe = (t) => t.split(/\s+/).filter(Boolean).map((e) => {
114
+ const n = e.split(":");
115
+ return n[n.length - 1] !== "h-screen" && n[n.length - 1] !== "min-h-screen" ? e : (n[n.length - 1] = "h-full", n.join(":"));
116
+ }).join(" "), qe = (t, e) => !e || !t.trim() ? t : t.replace(
152
117
  /^(\s*<[a-zA-Z][\w:-]*)(\s[^>]*?)?>/,
153
- (n, s, o = "") => {
154
- const l = o.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
118
+ (n, s, i = "") => {
119
+ const l = i.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
155
120
  if (!l)
156
121
  return n;
157
- const m = Ke(l[2]);
158
- return m === l[2] ? n : `${s}${o.replace(
122
+ const m = Pe(l[2]);
123
+ return m === l[2] ? n : `${s}${i.replace(
159
124
  l[0],
160
125
  `class=${l[1]}${m}${l[1]}`
161
126
  )}>`;
162
127
  }
163
- ), lt = ({
164
- content: e,
165
- type: t,
128
+ ), Ke = ({
129
+ content: t,
130
+ type: e,
166
131
  className: n,
167
132
  loadingText: s,
168
- styleLoadingText: o,
133
+ styleLoadingText: i,
169
134
  scriptLoadingText: l,
170
135
  fullScreenButtonText: m,
171
- hideFullScreen: R = !1,
136
+ hideFullScreen: C = !1,
172
137
  mode: h = "content",
173
- replaceRootScreenHeightWithFull: V = !1
138
+ replaceRootScreenHeightWithFull: F = !1
174
139
  }) => {
175
- const re = d(null), y = d(null), z = d(null), oe = d(null), G = d(() => {
176
- }), [He, Se] = F(480), se = d(0), [ie, ye] = F(0), [Ae, Ce] = F(!1), [, q] = F(!0), Re = t === "sandbox", X = h === "blackboard", U = d(""), P = C.useMemo(() => {
177
- const r = Oe(e).filter((p) => p.type === "sandbox");
178
- return (h === "blackboard" ? r[r.length - 1]?.value || "" : r.map((p) => p.value).join(`
140
+ const Y = d(null), E = d(null), $ = d(null), Z = d(null), j = d(() => {
141
+ }), [ge, pe] = V(480), J = d(0), [K, be] = V(0), [we, ve] = V(!1), [, B] = V(!0), xe = e === "sandbox", z = h === "blackboard", P = d(""), I = N.useMemo(() => {
142
+ const r = Me(t).filter((g) => g.type === "sandbox");
143
+ return (h === "blackboard" ? r[r.length - 1]?.value || "" : r.map((g) => g.value).join(`
179
144
  `)) || "";
180
- }, [e, h]), c = C.useMemo(
181
- () => Qe(
182
- P,
183
- V
145
+ }, [t, h]), c = N.useMemo(
146
+ () => qe(
147
+ I,
148
+ F
184
149
  ),
185
- [P, V]
186
- ), I = C.useMemo(
187
- () => qe(c),
188
- [c]
189
- ), le = C.useMemo(
190
- () => pe(P),
191
- [P]
192
- ), ce = C.useMemo(
193
- () => V && le.hasFullViewportHeight,
194
- [le.hasFullViewportHeight, V]
195
- ), [O, W] = F(
150
+ [I, F]
151
+ ), Q = N.useMemo(
152
+ () => ue(I),
153
+ [I]
154
+ ), ee = N.useMemo(
155
+ () => F && Q.hasFullViewportHeight,
156
+ [Q.hasFullViewportHeight, F]
157
+ ), [k, te] = V(
196
158
  c
197
- ), ae = d(c), Y = d(c), M = d(null), T = d(null), Z = d(null), J = d(0), A = Fe((i) => {
159
+ ), ne = d(c), re = d(c), A = d(null), R = d(null), S = Ae((o) => {
198
160
  if (typeof window > "u")
199
161
  return;
200
162
  const r = Date.now();
201
- r - se.current < ze || (se.current = r, window.postMessage(
163
+ r - J.current < _e || (J.current = r, window.postMessage(
202
164
  {
203
- source: Le,
204
- type: ke,
205
- eventType: i
165
+ source: Fe,
166
+ type: Ve,
167
+ eventType: o
206
168
  },
207
169
  window.location.origin
208
170
  ));
209
- }, []), ue = () => {
210
- M.current !== null && (window.clearTimeout(M.current), M.current = null);
211
- }, Ie = () => {
212
- T.current !== null && (window.cancelAnimationFrame(T.current), T.current = null), Z.current !== null && (window.cancelAnimationFrame(Z.current), Z.current = null);
171
+ }, []), oe = () => {
172
+ A.current !== null && (window.clearTimeout(A.current), A.current = null);
173
+ }, He = () => {
174
+ R.current !== null && (window.cancelAnimationFrame(R.current), R.current = null);
213
175
  };
214
- S(
176
+ y(
215
177
  () => () => {
216
- ue(), Ie();
178
+ oe(), He();
217
179
  },
218
180
  []
219
- ), S(() => {
220
- ge(I);
221
- }, [I]), S(() => {
222
- const i = ae.current;
223
- ae.current = c;
224
- const r = !!i && c.length > i.length && c.startsWith(i), g = $e.test(
181
+ ), y(() => {
182
+ const o = ne.current;
183
+ ne.current = c;
184
+ const r = !!o && c.length > o.length && c.startsWith(o), w = De.test(
225
185
  c
226
- ), p = r && g && I.some(
227
- (v) => !$.has(v)
228
- ), D = r && g;
229
- if (Y.current = c, ue(), p) {
230
- const v = J.current + 1;
231
- J.current = v, ge(I).then(() => {
232
- J.current === v && W(Y.current);
233
- });
234
- return;
235
- }
236
- if (!D) {
237
- W(c);
186
+ ), g = r && w;
187
+ if (re.current = c, oe(), !g) {
188
+ te(c);
238
189
  return;
239
190
  }
240
- M.current = window.setTimeout(() => {
241
- W(Y.current), M.current = null;
242
- }, je);
243
- }, [I, c]);
244
- const de = C.useMemo(
245
- () => pe(O).viewportHeightCss,
246
- [O]
247
- ), he = !!de, N = X && t === "sandbox" ? ce ? "100%" : de ?? `${He}px` : void 0;
248
- S(() => {
191
+ A.current = window.setTimeout(() => {
192
+ te(re.current), A.current = null;
193
+ }, Oe);
194
+ }, [c]);
195
+ const se = N.useMemo(
196
+ () => ue(k).viewportHeightCss,
197
+ [k]
198
+ ), ie = !!se, T = z && e === "sandbox" ? ee ? "100%" : se ?? `${ge}px` : void 0;
199
+ y(() => {
249
200
  if (h !== "blackboard") {
250
- U.current = c;
201
+ P.current = c;
251
202
  return;
252
203
  }
253
- const i = U.current;
254
- !(i && c.startsWith(i)) && i && ye((g) => g + 1), U.current = c;
255
- }, [h, c]), S(() => {
256
- const i = y.current;
257
- if (!i) return;
258
- const r = i.contentDocument;
204
+ const o = P.current;
205
+ !(o && c.startsWith(o)) && o && be((w) => w + 1), P.current = c;
206
+ }, [h, c]), y(() => {
207
+ const o = E.current;
208
+ if (!o) return;
209
+ const r = o.contentDocument;
259
210
  if (!r) return;
260
211
  r.open(), r.write(`<!DOCTYPE html>
261
212
  <html${h === "blackboard" ? ' style="height: 100%;"' : ""}>
@@ -272,35 +223,35 @@ const Be = () => {
272
223
  <body>
273
224
  <div id="root"></div>
274
225
  </body>
275
- </html>`), r.close(), r.documentElement.setAttribute("data-theme", "light"), r.documentElement.style.colorScheme = "light", r.body?.style.setProperty("color-scheme", "light"), oe.current = r;
276
- const g = X && t === "sandbox", p = () => A("pointerdown"), D = () => A("mousedown"), v = () => A("touchstart");
277
- g && (r.addEventListener("pointerdown", p, !0), r.addEventListener("mousedown", D, !0), r.addEventListener("touchstart", v, !0));
278
- const k = r.getElementById("root");
279
- if (!k) return;
280
- const me = Ve(k);
281
- z.current = me;
282
- let _ = !1;
283
- const K = (a, b) => {
226
+ </html>`), r.close(), r.documentElement.setAttribute("data-theme", "light"), r.documentElement.style.colorScheme = "light", r.body?.style.setProperty("color-scheme", "light"), Z.current = r;
227
+ const w = z && e === "sandbox", g = () => S("pointerdown"), le = () => S("mousedown"), ce = () => S("touchstart");
228
+ w && (r.addEventListener("pointerdown", g, !0), r.addEventListener("mousedown", le, !0), r.addEventListener("touchstart", ce, !0));
229
+ const D = r.getElementById("root");
230
+ if (!D) return;
231
+ const ae = Re(D);
232
+ $.current = ae;
233
+ let M = !1;
234
+ const q = (a, p) => {
284
235
  const u = a.trim().toLowerCase();
285
236
  if (!u) return null;
286
- const x = Number.parseFloat(u);
287
- return Number.isNaN(x) ? null : /(dvh|svh|lvh|vh)$/i.test(u) ? x / 100 * b : u.endsWith("px") || /^[0-9.]+$/.test(u) ? x : null;
288
- }, Ne = (a, b) => {
237
+ const v = Number.parseFloat(u);
238
+ return Number.isNaN(v) ? null : /(dvh|svh|lvh|vh)$/i.test(u) ? v / 100 * p : u.endsWith("px") || /^[0-9.]+$/.test(u) ? v : null;
239
+ }, ye = (a, p) => {
289
240
  if (!a.trim()) return null;
290
- const u = ne(a);
241
+ const u = W(a);
291
242
  if (u)
292
- return K(u, b);
293
- const f = we(a).find(
294
- (B) => /^h-\[[0-9.]+px\]$/i.test(B)
243
+ return q(u, p);
244
+ const f = he(a).find(
245
+ (_) => /^h-\[[0-9.]+px\]$/i.test(_)
295
246
  );
296
247
  if (!f) return null;
297
- const E = f.match(/^h-\[([0-9.]+)px\]$/i);
298
- if (!E) return null;
299
- const H = Number.parseFloat(E[1]);
248
+ const x = f.match(/^h-\[([0-9.]+)px\]$/i);
249
+ if (!x) return null;
250
+ const H = Number.parseFloat(x[1]);
300
251
  return Number.isNaN(H) ? null : H;
301
- }, _e = () => {
302
- if (!y.current || !r.body) return null;
303
- const a = y.current.ownerDocument?.documentElement?.clientHeight || window.innerHeight, { viewportHeightCss: b } = Ee(r.body), u = b ? K(b, a) : null;
252
+ }, Ce = () => {
253
+ if (!E.current || !r.body) return null;
254
+ const a = E.current.ownerDocument?.documentElement?.clientHeight || window.innerHeight, { viewportHeightCss: p } = fe(r.body), u = p ? q(p, a) : null;
304
255
  if (u !== null)
305
256
  return Math.ceil(u);
306
257
  const f = r.body.querySelector(
@@ -309,133 +260,133 @@ const Be = () => {
309
260
  ".sandbox-container > *"
310
261
  );
311
262
  if (!f) return null;
312
- const E = f.style.height || f.getAttribute("height"), H = E ? K(E, a) : null;
263
+ const x = f.style.height || f.getAttribute("height"), H = x ? q(x, a) : null;
313
264
  if (H !== null)
314
265
  return Math.ceil(H);
315
- const B = Ne(
266
+ const _ = ye(
316
267
  f.getAttribute("class") || "",
317
268
  a
318
269
  );
319
- return B !== null ? Math.ceil(B) : null;
320
- }, Q = () => {
321
- if (!y.current || !r.body) return;
322
- const a = r.body.getBoundingClientRect(), b = r.documentElement?.getBoundingClientRect(), u = a.height, x = b?.height || 0, f = Math.max(u, x), E = _e(), H = Math.max(
270
+ return _ !== null ? Math.ceil(_) : null;
271
+ }, G = () => {
272
+ if (!E.current || !r.body) return;
273
+ const a = r.body.getBoundingClientRect(), p = r.documentElement?.getBoundingClientRect(), u = a.height, v = p?.height || 0, f = Math.max(u, v), x = Ce(), H = Math.max(
323
274
  200,
324
- E ?? Math.ceil(f)
275
+ x ?? Math.ceil(f)
325
276
  );
326
- Se(H);
327
- }, L = () => {
277
+ pe(H);
278
+ }, O = () => {
328
279
  requestAnimationFrame(() => {
329
- _ || Q();
280
+ M || G();
330
281
  });
331
282
  };
332
- G.current = L, Q(), L(), Re ? Be().then((a) => {
333
- _ || (a(r), requestAnimationFrame(() => {
334
- _ || (q(!0), L());
283
+ j.current = O, G(), O(), xe ? ke().then((a) => {
284
+ M || (a(r), requestAnimationFrame(() => {
285
+ M || (B(!0), O());
335
286
  }));
336
287
  }).catch(() => {
337
- _ || (q(!0), L());
338
- }) : q(!0);
339
- const ee = new ResizeObserver(() => Q());
340
- return ee.observe(r.body), k && ee.observe(k), () => {
341
- _ = !0, ee.disconnect(), g && (r.removeEventListener("pointerdown", p, !0), r.removeEventListener("mousedown", D, !0), r.removeEventListener("touchstart", v, !0)), setTimeout(() => {
342
- me.unmount(), z.current = null, oe.current = null, G.current = () => {
288
+ M || (B(!0), O());
289
+ }) : B(!0);
290
+ const X = new ResizeObserver(() => G());
291
+ return X.observe(r.body), D && X.observe(D), () => {
292
+ M = !0, X.disconnect(), w && (r.removeEventListener("pointerdown", g, !0), r.removeEventListener("mousedown", le, !0), r.removeEventListener("touchstart", ce, !0)), setTimeout(() => {
293
+ ae.unmount(), $.current = null, Z.current = null, j.current = () => {
343
294
  };
344
295
  }, 0);
345
296
  };
346
- }, []), S(() => {
347
- const i = () => {
348
- Ce(!!document.fullscreenElement);
297
+ }, []), y(() => {
298
+ const o = () => {
299
+ ve(!!document.fullscreenElement);
349
300
  };
350
- return document.addEventListener("fullscreenchange", i), () => document.removeEventListener("fullscreenchange", i);
301
+ return document.addEventListener("fullscreenchange", o), () => document.removeEventListener("fullscreenchange", o);
351
302
  }, []);
352
- const Me = () => {
353
- const i = re.current || y.current;
354
- if (i) {
303
+ const Ee = () => {
304
+ const o = Y.current || E.current;
305
+ if (o) {
355
306
  if (document.fullscreenElement) {
356
307
  document.exitFullscreen().catch(() => {
357
308
  });
358
309
  return;
359
310
  }
360
- i.requestFullscreen && i.requestFullscreen().catch(() => {
311
+ o.requestFullscreen && o.requestFullscreen().catch(() => {
361
312
  });
362
313
  }
363
314
  };
364
- S(() => {
365
- const i = z.current;
366
- i && (i.render(
367
- /* @__PURE__ */ w.jsx(
368
- Pe,
315
+ y(() => {
316
+ const o = $.current;
317
+ o && (o.render(
318
+ /* @__PURE__ */ b.jsx(
319
+ Te,
369
320
  {
370
- html: O,
321
+ html: k,
371
322
  loadingText: s,
372
- styleLoadingText: o,
323
+ styleLoadingText: i,
373
324
  scriptLoadingText: l,
374
325
  fullScreenButtonText: m,
375
- hideFullScreen: R,
376
- resetToken: ie,
377
- hasRootVhHeight: he,
326
+ hideFullScreen: C,
327
+ resetToken: K,
328
+ hasRootVhHeight: ie,
378
329
  mode: h,
379
- stretchRootHeight: ce
330
+ stretchRootHeight: ee
380
331
  }
381
332
  )
382
- ), T.current = window.requestAnimationFrame(() => {
383
- G.current?.(), T.current = null;
333
+ ), R.current = window.requestAnimationFrame(() => {
334
+ j.current?.(), R.current = null;
384
335
  }));
385
336
  }, [
386
- O,
337
+ k,
387
338
  s,
388
- o,
339
+ i,
389
340
  l,
390
341
  m,
391
- ie,
342
+ K,
392
343
  h
393
344
  ]);
394
- const Te = [
345
+ const Se = [
395
346
  "w-full relative content-render-iframe-sandbox",
396
- X ? "h-full overflow-auto flex flex-col" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
347
+ z ? "h-full overflow-auto flex flex-col" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
397
348
  ].filter(Boolean).join(" ");
398
- return /* @__PURE__ */ w.jsxs(
349
+ return /* @__PURE__ */ b.jsxs(
399
350
  "div",
400
351
  {
401
- ref: re,
402
- "data-root-vh": he ? "true" : "false",
403
- className: Te,
404
- style: N ? {
405
- height: N,
406
- minHeight: N
352
+ ref: Y,
353
+ "data-root-vh": ie ? "true" : "false",
354
+ className: Se,
355
+ style: T ? {
356
+ height: T,
357
+ minHeight: T
407
358
  } : void 0,
408
359
  children: [
409
- !R && /* @__PURE__ */ w.jsx(
360
+ !C && /* @__PURE__ */ b.jsx(
410
361
  "button",
411
362
  {
412
363
  type: "button",
413
- onClick: Me,
364
+ onClick: Ee,
414
365
  className: "absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",
415
- children: Ae ? "退出全屏" : m || "全屏浏览"
366
+ children: we ? "退出全屏" : m || "全屏浏览"
416
367
  }
417
368
  ),
418
- h === "blackboard" && t === "markdown" ? /* @__PURE__ */ w.jsx(
369
+ h === "blackboard" && e === "markdown" ? /* @__PURE__ */ b.jsx(
419
370
  "div",
420
371
  {
421
- onMouseDown: () => A("mousedown"),
422
- onPointerDown: () => A("pointerdown"),
423
- onTouchStart: () => A("touchstart"),
424
- children: /* @__PURE__ */ w.jsx(De, { content: e })
372
+ onMouseDown: () => S("mousedown"),
373
+ onPointerDown: () => S("pointerdown"),
374
+ onTouchStart: () => S("touchstart"),
375
+ children: /* @__PURE__ */ b.jsx(Ne, { content: t })
425
376
  }
426
- ) : /* @__PURE__ */ w.jsxs(w.Fragment, { children: [
377
+ ) : /* @__PURE__ */ b.jsxs(b.Fragment, { children: [
427
378
  null,
428
- /* @__PURE__ */ w.jsx(
379
+ /* @__PURE__ */ b.jsx(
429
380
  "iframe",
430
381
  {
431
- ref: y,
382
+ ref: E,
432
383
  sandbox: "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",
433
384
  allow: "fullscreen",
434
385
  allowFullScreen: !0,
435
386
  className: [n, "w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),
436
387
  style: {
437
- height: N ?? "100%",
438
- minHeight: N,
388
+ height: T ?? "100%",
389
+ minHeight: T,
439
390
  margin: "auto",
440
391
  visibility: "visible"
441
392
  }
@@ -448,6 +399,6 @@ const Be = () => {
448
399
  );
449
400
  };
450
401
  export {
451
- lt as default
402
+ Ke as default
452
403
  };
453
404
  //# sourceMappingURL=IframeSandbox.es.js.map