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

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 (60) 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.cjs.js.map +1 -1
  3. 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
  4. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
  5. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.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.cjs.js +1 -1
  7. 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
  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.cjs.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/c4Diagram-YG6GDRKO.es.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.cjs.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-S3R3BYOJ.es.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.cjs.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/chunk-TZMSLE5B.es.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.cjs.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/ganttDiagram-LVOFAZNH.es.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.cjs.js +1 -1
  17. 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
  18. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
  19. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
  20. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
  21. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
  22. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
  23. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
  24. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
  25. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
  26. 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
  27. 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
  28. package/dist/_virtual/index.cjs10.js +1 -1
  29. package/dist/_virtual/index.cjs11.js +1 -1
  30. package/dist/_virtual/index.cjs4.js +1 -1
  31. package/dist/_virtual/index.cjs6.js +1 -1
  32. package/dist/_virtual/index.cjs8.js +1 -1
  33. package/dist/_virtual/index.cjs9.js +1 -1
  34. package/dist/_virtual/index.es10.js +3 -2
  35. package/dist/_virtual/index.es10.js.map +1 -1
  36. package/dist/_virtual/index.es11.js +2 -3
  37. package/dist/_virtual/index.es11.js.map +1 -1
  38. package/dist/_virtual/index.es4.js +4 -4
  39. package/dist/_virtual/index.es6.js +4 -4
  40. package/dist/_virtual/index.es8.js +2 -3
  41. package/dist/_virtual/index.es8.js.map +1 -1
  42. package/dist/_virtual/index.es9.js +3 -2
  43. package/dist/_virtual/index.es9.js.map +1 -1
  44. package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
  45. package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
  46. package/dist/components/ContentRender/ContentRender.es.js +140 -216
  47. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  48. package/dist/components/ContentRender/IframeSandbox.cjs.js +3 -3
  49. package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
  50. package/dist/components/ContentRender/IframeSandbox.es.js +46 -44
  51. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  52. package/dist/components/ContentRender/index.cjs.js +1 -1
  53. package/dist/components/ContentRender/index.es.js +6 -5
  54. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
  55. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
  56. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +2 -2
  57. package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
  58. package/dist/components/ui/inputGroup/textarea.es.js +1 -1
  59. package/dist/markdown-flow-ui-lib.css +1 -1
  60. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("../../_virtual/jsx-runtime.cjs.js"),o=require("react"),Te=require("react-dom/client"),Ne=require("./SandboxApp.cjs.js"),Pe=require("./utils/split-content.cjs.js"),_e=require("./ContentRender.cjs.js"),de=require("../../lib/sandboxInteraction.cjs.js");let K=null;const Fe=()=>(K||(K=Promise.resolve().then(()=>require("./blackboard-vendor.cjs.js")).then(e=>e.injectBlackboardLibraries)),K),Ve=()=>{const e=performance.now(),t=new Date().toISOString();return console.log("[IframeSandbox][SandboxLoad] start",{startedAt:t}),Fe().then(n=>(console.log("[IframeSandbox][SandboxLoad] done",{startedAt:t,endedAt:new Date().toISOString(),durationMs:Number((performance.now()-e).toFixed(2))}),n)).catch(n=>{throw console.error("[IframeSandbox][SandboxLoad] failed",{startedAt:t,endedAt:new Date().toISOString(),durationMs:Number((performance.now()-e).toFixed(2)),error:n}),n})},Oe=/<img\b[^>]*>/i,De=180,je=240,ke=/<img\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi,he=new Map,j=new Set,Le=e=>{const t=Array.from(e.matchAll(ke));return Array.from(new Set(t.map(n=>n[1]?.trim()).filter(n=>!!n)))},Be=e=>{if(!e)return Promise.resolve();const t=he.get(e);if(t)return t;const n=new Promise(i=>{if(typeof window>"u"){j.add(e),i();return}const s=new window.Image;s.decoding="sync",s.loading="eager",s.fetchPriority="high";const c=()=>{(typeof s.decode=="function"?s.decode().catch(()=>{}):Promise.resolve()).finally(()=>{j.add(e),i()})};s.onload=()=>{c()},s.onerror=()=>{j.add(e),i()},s.src=e,s.complete&&s.naturalWidth>0&&c()});return he.set(e,n),n},me=(e=[])=>Promise.allSettled(e.map(t=>Be(t))),ge=e=>e.split(/\s+/).filter(Boolean).map(t=>t.split(":").pop()||t),k=e=>{const t=e.trim().toLowerCase();if(!t)return null;const n=t.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);return n?`${n[1]}${n[2].toLowerCase()}`:null},Q=e=>{if(!e.trim())return null;const t=ge(e);if(t.includes("h-screen")||t.includes("h-dvh")||t.includes("min-h-screen")||t.includes("min-h-dvh"))return"100dvh";if(t.includes("h-svh")||t.includes("min-h-svh"))return"100svh";if(t.includes("h-lvh")||t.includes("min-h-lvh"))return"100lvh";const n=t.find(s=>/^(h|min-h)-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(s));if(!n)return null;const i=n.match(/^(h|min-h)-\[([0-9.]+)(vh|dvh|svh|lvh)\]$/i);return i?`${i[2]}${i[3].toLowerCase()}`:null},$e=new Set(["base","link","meta","script","style","template","title"]),pe=e=>!$e.has(e.tagName.toLowerCase()),qe=e=>Array.from(e.childNodes).find(t=>t.nodeType===Node.ELEMENT_NODE&&pe(t))||null,ze=e=>{const t=[];let n=qe(e);for(;n;){t.push(n);const i=Array.from(n.children).filter(s=>pe(s));if(i.length!==1)break;n=i[0]}return t},Ge=e=>{const t=e.getAttribute("height"),n=t?k(t):null;if(n)return n;const i=e.getAttribute("style")?.match(/\bheight\s*:\s*([^;]+)/i)?.[1]||null,s=i?k(i):null;return s||Q(e.getAttribute("class")||"")},be=e=>e==="100vh"||e==="100dvh"||e==="100svh"||e==="100lvh",we=e=>{const t=ze(e);let n=null,i=!1;return t.forEach(s=>{const c=Ge(s);!n&&c&&(n=c),be(c)&&(i=!0)}),{viewportHeightCss:n,hasFullViewportHeight:i}},Xe=e=>{const t=e.trim();if(!t)return{viewportHeightCss:null,hasFullViewportHeight:!1};const i=t.match(/^<([a-zA-Z][\w:-]*)(\s[^>]*?)?>/)?.[2]||"",s=i.match(/\bheight\s*=\s*["']([^"']+)["']/i)?.[1],m=i.match(/\bstyle\s*=\s*["']([^"']+)["']/i)?.[1]?.match(/\bheight\s*:\s*([^;]+)/i)?.[1],y=i.match(/\bclass\s*=\s*["']([^"']+)["']/i)?.[1],h=(s?k(s):null)||(m?k(m):null)||(y?Q(y):null);return{viewportHeightCss:h,hasFullViewportHeight:be(h)}},fe=e=>{const t=e.trim();if(!t)return{viewportHeightCss:null,hasFullViewportHeight:!1};if(typeof document>"u")return Xe(t);const n=document.createElement("template");return n.innerHTML=t,we(n.content)},Ue=e=>e.split(/\s+/).filter(Boolean).map(t=>{const n=t.split(":");return n[n.length-1]!=="h-screen"&&n[n.length-1]!=="min-h-screen"?t:(n[n.length-1]="h-full",n.join(":"))}).join(" "),We=(e,t)=>!t||!e.trim()?e:e.replace(/^(\s*<[a-zA-Z][\w:-]*)(\s[^>]*?)?>/,(n,i,s="")=>{const c=s.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);if(!c)return n;const m=Ue(c[2]);return m===c[2]?n:`${i}${s.replace(c[0],`class=${c[1]}${m}${c[1]}`)}>`}),Ye=({content:e,type:t,className:n,loadingText:i,styleLoadingText:s,scriptLoadingText:c,fullScreenButtonText:m,hideFullScreen:y=!1,mode:h="content",replaceRootScreenHeightWithFull:N=!1})=>{const ee=o.useRef(null),S=o.useRef(null),L=o.useRef(null),te=o.useRef(null),B=o.useRef(()=>{}),[xe,ve]=o.useState(480),ne=o.useRef(0),[re,Ee]=o.useState(0),[Re,Se]=o.useState(!1),[,$]=o.useState(!0),He=t==="sandbox",q=h==="blackboard",z=o.useRef(""),P=o.useMemo(()=>{const r=Pe.splitContentSegments(e).filter(p=>p.type==="sandbox");return(h==="blackboard"?r[r.length-1]?.value||"":r.map(p=>p.value).join(`
2
- `))||""},[e,h]),a=o.useMemo(()=>We(P,N),[P,N]),A=o.useMemo(()=>Le(a),[a]),oe=o.useMemo(()=>fe(P),[P]),se=o.useMemo(()=>N&&oe.hasFullViewportHeight,[oe.hasFullViewportHeight,N]),[_,G]=o.useState(a),ie=o.useRef(a),X=o.useRef(a),C=o.useRef(null),M=o.useRef(null),U=o.useRef(null),W=o.useRef(0),H=o.useCallback(l=>{if(typeof window>"u")return;const r=Date.now();r-ne.current<je||(ne.current=r,window.postMessage({source:de.SANDBOX_INTERACTION_MESSAGE_SOURCE,type:de.SANDBOX_INTERACTION_MESSAGE_TYPE,eventType:l},window.location.origin))},[]),le=()=>{C.current!==null&&(window.clearTimeout(C.current),C.current=null)},ye=()=>{M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),U.current!==null&&(window.cancelAnimationFrame(U.current),U.current=null)};o.useEffect(()=>()=>{le(),ye()},[]),o.useEffect(()=>{me(A)},[A]),o.useEffect(()=>{const l=ie.current;ie.current=a;const r=!!l&&a.length>l.length&&a.startsWith(l),g=Oe.test(a),p=r&&g&&A.some(x=>!j.has(x)),F=r&&g;if(X.current=a,le(),p){const x=W.current+1;W.current=x,me(A).then(()=>{W.current===x&&G(X.current)});return}if(!F){G(a);return}C.current=window.setTimeout(()=>{G(X.current),C.current=null},De)},[A,a]);const ce=o.useMemo(()=>fe(_).viewportHeightCss,[_]),ae=!!ce,I=q&&t==="sandbox"?se?"100%":ce??`${xe}px`:void 0;o.useEffect(()=>{if(h!=="blackboard"){z.current=a;return}const l=z.current;!(l&&a.startsWith(l))&&l&&Ee(g=>g+1),z.current=a},[h,a]),o.useEffect(()=>{const l=S.current;if(!l)return;const r=l.contentDocument;if(!r)return;r.open(),r.write(`<!DOCTYPE html>
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("../../_virtual/jsx-runtime.cjs.js"),o=require("react"),Ne=require("react-dom/client"),Pe=require("./SandboxApp.cjs.js"),_e=require("./utils/split-content.cjs.js"),Fe=require("./ContentRender.cjs.js"),de=require("../../lib/sandboxInteraction.cjs.js");let K=null;const ge=()=>(K||(K=Promise.resolve().then(()=>require("./blackboard-vendor.cjs.js")).then(e=>e.injectBlackboardLibraries)),K);typeof window<"u"&&ge();const Ve=()=>{const e=performance.now(),t=new Date().toISOString();return console.log("[IframeSandbox][SandboxLoad] start",{startedAt:t}),ge().then(n=>(console.log("[IframeSandbox][SandboxLoad] done",{startedAt:t,endedAt:new Date().toISOString(),durationMs:Number((performance.now()-e).toFixed(2))}),n)).catch(n=>{throw console.error("[IframeSandbox][SandboxLoad] failed",{startedAt:t,endedAt:new Date().toISOString(),durationMs:Number((performance.now()-e).toFixed(2)),error:n}),n})},Oe=/<img\b[^>]*>/i,De=180,je=240,ke=/<img\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi,he=new Map,j=new Set,Le=e=>{const t=Array.from(e.matchAll(ke));return Array.from(new Set(t.map(n=>n[1]?.trim()).filter(n=>!!n)))},Be=e=>{if(!e)return Promise.resolve();const t=he.get(e);if(t)return t;const n=new Promise(i=>{if(typeof window>"u"){j.add(e),i();return}const s=new window.Image;s.decoding="sync",s.loading="eager",s.fetchPriority="high";const c=()=>{(typeof s.decode=="function"?s.decode().catch(()=>{}):Promise.resolve()).finally(()=>{j.add(e),i()})};s.onload=()=>{c()},s.onerror=()=>{j.add(e),i()},s.src=e,s.complete&&s.naturalWidth>0&&c()});return he.set(e,n),n},me=(e=[])=>Promise.allSettled(e.map(t=>Be(t))),pe=e=>e.split(/\s+/).filter(Boolean).map(t=>t.split(":").pop()||t),k=e=>{const t=e.trim().toLowerCase();if(!t)return null;const n=t.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);return n?`${n[1]}${n[2].toLowerCase()}`:null},Q=e=>{if(!e.trim())return null;const t=pe(e);if(t.includes("h-screen")||t.includes("h-dvh")||t.includes("min-h-screen")||t.includes("min-h-dvh"))return"100dvh";if(t.includes("h-svh")||t.includes("min-h-svh"))return"100svh";if(t.includes("h-lvh")||t.includes("min-h-lvh"))return"100lvh";const n=t.find(s=>/^(h|min-h)-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(s));if(!n)return null;const i=n.match(/^(h|min-h)-\[([0-9.]+)(vh|dvh|svh|lvh)\]$/i);return i?`${i[2]}${i[3].toLowerCase()}`:null},$e=new Set(["base","link","meta","script","style","template","title"]),be=e=>!$e.has(e.tagName.toLowerCase()),qe=e=>Array.from(e.childNodes).find(t=>t.nodeType===Node.ELEMENT_NODE&&be(t))||null,ze=e=>{const t=[];let n=qe(e);for(;n;){t.push(n);const i=Array.from(n.children).filter(s=>be(s));if(i.length!==1)break;n=i[0]}return t},Ge=e=>{const t=e.getAttribute("height"),n=t?k(t):null;if(n)return n;const i=e.getAttribute("style")?.match(/\bheight\s*:\s*([^;]+)/i)?.[1]||null,s=i?k(i):null;return s||Q(e.getAttribute("class")||"")},we=e=>e==="100vh"||e==="100dvh"||e==="100svh"||e==="100lvh",ve=e=>{const t=ze(e);let n=null,i=!1;return t.forEach(s=>{const c=Ge(s);!n&&c&&(n=c),we(c)&&(i=!0)}),{viewportHeightCss:n,hasFullViewportHeight:i}},Xe=e=>{const t=e.trim();if(!t)return{viewportHeightCss:null,hasFullViewportHeight:!1};const i=t.match(/^<([a-zA-Z][\w:-]*)(\s[^>]*?)?>/)?.[2]||"",s=i.match(/\bheight\s*=\s*["']([^"']+)["']/i)?.[1],m=i.match(/\bstyle\s*=\s*["']([^"']+)["']/i)?.[1]?.match(/\bheight\s*:\s*([^;]+)/i)?.[1],y=i.match(/\bclass\s*=\s*["']([^"']+)["']/i)?.[1],h=(s?k(s):null)||(m?k(m):null)||(y?Q(y):null);return{viewportHeightCss:h,hasFullViewportHeight:we(h)}},fe=e=>{const t=e.trim();if(!t)return{viewportHeightCss:null,hasFullViewportHeight:!1};if(typeof document>"u")return Xe(t);const n=document.createElement("template");return n.innerHTML=t,ve(n.content)},Ue=e=>e.split(/\s+/).filter(Boolean).map(t=>{const n=t.split(":");return n[n.length-1]!=="h-screen"&&n[n.length-1]!=="min-h-screen"?t:(n[n.length-1]="h-full",n.join(":"))}).join(" "),We=(e,t)=>!t||!e.trim()?e:e.replace(/^(\s*<[a-zA-Z][\w:-]*)(\s[^>]*?)?>/,(n,i,s="")=>{const c=s.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);if(!c)return n;const m=Ue(c[2]);return m===c[2]?n:`${i}${s.replace(c[0],`class=${c[1]}${m}${c[1]}`)}>`}),Ye=({content:e,type:t,className:n,loadingText:i,styleLoadingText:s,scriptLoadingText:c,fullScreenButtonText:m,hideFullScreen:y=!1,mode:h="content",replaceRootScreenHeightWithFull:N=!1})=>{const ee=o.useRef(null),S=o.useRef(null),L=o.useRef(null),te=o.useRef(null),B=o.useRef(()=>{}),[xe,Ee]=o.useState(480),ne=o.useRef(0),[re,Re]=o.useState(0),[Se,He]=o.useState(!1),[,$]=o.useState(!0),ye=t==="sandbox",q=h==="blackboard",z=o.useRef(""),P=o.useMemo(()=>{const r=_e.splitContentSegments(e).filter(p=>p.type==="sandbox");return(h==="blackboard"?r[r.length-1]?.value||"":r.map(p=>p.value).join(`
2
+ `))||""},[e,h]),a=o.useMemo(()=>We(P,N),[P,N]),A=o.useMemo(()=>Le(a),[a]),oe=o.useMemo(()=>fe(P),[P]),se=o.useMemo(()=>N&&oe.hasFullViewportHeight,[oe.hasFullViewportHeight,N]),[_,G]=o.useState(a),ie=o.useRef(a),X=o.useRef(a),C=o.useRef(null),M=o.useRef(null),U=o.useRef(null),W=o.useRef(0),H=o.useCallback(l=>{if(typeof window>"u")return;const r=Date.now();r-ne.current<je||(ne.current=r,window.postMessage({source:de.SANDBOX_INTERACTION_MESSAGE_SOURCE,type:de.SANDBOX_INTERACTION_MESSAGE_TYPE,eventType:l},window.location.origin))},[]),le=()=>{C.current!==null&&(window.clearTimeout(C.current),C.current=null)},Ae=()=>{M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),U.current!==null&&(window.cancelAnimationFrame(U.current),U.current=null)};o.useEffect(()=>()=>{le(),Ae()},[]),o.useEffect(()=>{me(A)},[A]),o.useEffect(()=>{const l=ie.current;ie.current=a;const r=!!l&&a.length>l.length&&a.startsWith(l),g=Oe.test(a),p=r&&g&&A.some(v=>!j.has(v)),F=r&&g;if(X.current=a,le(),p){const v=W.current+1;W.current=v,me(A).then(()=>{W.current===v&&G(X.current)});return}if(!F){G(a);return}C.current=window.setTimeout(()=>{G(X.current),C.current=null},De)},[A,a]);const ce=o.useMemo(()=>fe(_).viewportHeightCss,[_]),ae=!!ce,I=q&&t==="sandbox"?se?"100%":ce??`${xe}px`:void 0;o.useEffect(()=>{if(h!=="blackboard"){z.current=a;return}const l=z.current;!(l&&a.startsWith(l))&&l&&Re(g=>g+1),z.current=a},[h,a]),o.useEffect(()=>{const l=S.current;if(!l)return;const r=l.contentDocument;if(!r)return;r.open(),r.write(`<!DOCTYPE html>
3
3
  <html${h==="blackboard"?' style="height: 100%;"':""}>
4
4
  <head>
5
5
  <meta charset="utf-8" />
@@ -14,5 +14,5 @@
14
14
  <body>
15
15
  <div id="root"></div>
16
16
  </body>
17
- </html>`),r.close(),r.documentElement.setAttribute("data-theme","light"),r.documentElement.style.colorScheme="light",r.body?.style.setProperty("color-scheme","light"),te.current=r;const g=q&&t==="sandbox",p=()=>H("pointerdown"),F=()=>H("mousedown"),x=()=>H("touchstart");g&&(r.addEventListener("pointerdown",p,!0),r.addEventListener("mousedown",F,!0),r.addEventListener("touchstart",x,!0));const V=r.getElementById("root");if(!V)return;const ue=Te.createRoot(V);L.current=ue;let T=!1;const Y=(u,b)=>{const d=u.trim().toLowerCase();if(!d)return null;const v=Number.parseFloat(d);return Number.isNaN(v)?null:/(dvh|svh|lvh|vh)$/i.test(d)?v/100*b:d.endsWith("px")||/^[0-9.]+$/.test(d)?v:null},Me=(u,b)=>{if(!u.trim())return null;const d=Q(u);if(d)return Y(d,b);const f=ge(u).find(D=>/^h-\[[0-9.]+px\]$/i.test(D));if(!f)return null;const E=f.match(/^h-\[([0-9.]+)px\]$/i);if(!E)return null;const R=Number.parseFloat(E[1]);return Number.isNaN(R)?null:R},Ie=()=>{if(!S.current||!r.body)return null;const u=S.current.ownerDocument?.documentElement?.clientHeight||window.innerHeight,{viewportHeightCss:b}=we(r.body),d=b?Y(b,u):null;if(d!==null)return Math.ceil(d);const f=r.body.querySelector(".sandbox-wrapper")?.querySelector(".sandbox-container > *");if(!f)return null;const E=f.style.height||f.getAttribute("height"),R=E?Y(E,u):null;if(R!==null)return Math.ceil(R);const D=Me(f.getAttribute("class")||"",u);return D!==null?Math.ceil(D):null},Z=()=>{if(!S.current||!r.body)return;const u=r.body.getBoundingClientRect(),b=r.documentElement?.getBoundingClientRect(),d=u.height,v=b?.height||0,f=Math.max(d,v),E=Ie(),R=Math.max(200,E??Math.ceil(f));ve(R)},O=()=>{requestAnimationFrame(()=>{T||Z()})};B.current=O,Z(),O(),He?Ve().then(u=>{T||(u(r),requestAnimationFrame(()=>{T||($(!0),O())}))}).catch(()=>{T||($(!0),O())}):$(!0);const J=new ResizeObserver(()=>Z());return J.observe(r.body),V&&J.observe(V),()=>{T=!0,J.disconnect(),g&&(r.removeEventListener("pointerdown",p,!0),r.removeEventListener("mousedown",F,!0),r.removeEventListener("touchstart",x,!0)),setTimeout(()=>{ue.unmount(),L.current=null,te.current=null,B.current=()=>{}},0)}},[]),o.useEffect(()=>{const l=()=>{Se(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",l),()=>document.removeEventListener("fullscreenchange",l)},[]);const Ae=()=>{const l=ee.current||S.current;if(l){if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}l.requestFullscreen&&l.requestFullscreen().catch(()=>{})}};o.useEffect(()=>{const l=L.current;l&&(l.render(w.jsxRuntimeExports.jsx(Ne.default,{html:_,loadingText:i,styleLoadingText:s,scriptLoadingText:c,fullScreenButtonText:m,hideFullScreen:y,resetToken:re,hasRootVhHeight:ae,mode:h,stretchRootHeight:se})),M.current=window.requestAnimationFrame(()=>{B.current?.(),M.current=null}))},[_,i,s,c,m,re,h]);const Ce=["w-full relative content-render-iframe-sandbox",q?"h-full overflow-auto flex flex-col":"aspect-[16/9] overflow-hidden flex items-center justify-center"].filter(Boolean).join(" ");return w.jsxRuntimeExports.jsxs("div",{ref:ee,"data-root-vh":ae?"true":"false",className:Ce,style:I?{height:I,minHeight:I}:void 0,children:[!y&&w.jsxRuntimeExports.jsx("button",{type:"button",onClick:Ae,className:"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",children:Re?"退出全屏":m||"全屏浏览"}),h==="blackboard"&&t==="markdown"?w.jsxRuntimeExports.jsx("div",{onMouseDown:()=>H("mousedown"),onPointerDown:()=>H("pointerdown"),onTouchStart:()=>H("touchstart"),children:w.jsxRuntimeExports.jsx(_e.default,{content:e})}):w.jsxRuntimeExports.jsxs(w.jsxRuntimeExports.Fragment,{children:[null,w.jsxRuntimeExports.jsx("iframe",{ref:S,sandbox:"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allow:"fullscreen",allowFullScreen:!0,className:[n,"w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),style:{height:I??"100%",minHeight:I,margin:"auto",visibility:"visible"}}),null]})]})};exports.default=Ye;
17
+ </html>`),r.close(),r.documentElement.setAttribute("data-theme","light"),r.documentElement.style.colorScheme="light",r.body?.style.setProperty("color-scheme","light"),te.current=r;const g=q&&t==="sandbox",p=()=>H("pointerdown"),F=()=>H("mousedown"),v=()=>H("touchstart");g&&(r.addEventListener("pointerdown",p,!0),r.addEventListener("mousedown",F,!0),r.addEventListener("touchstart",v,!0));const V=r.getElementById("root");if(!V)return;const ue=Ne.createRoot(V);L.current=ue;let T=!1;const Y=(u,b)=>{const d=u.trim().toLowerCase();if(!d)return null;const x=Number.parseFloat(d);return Number.isNaN(x)?null:/(dvh|svh|lvh|vh)$/i.test(d)?x/100*b:d.endsWith("px")||/^[0-9.]+$/.test(d)?x:null},Ie=(u,b)=>{if(!u.trim())return null;const d=Q(u);if(d)return Y(d,b);const f=pe(u).find(D=>/^h-\[[0-9.]+px\]$/i.test(D));if(!f)return null;const E=f.match(/^h-\[([0-9.]+)px\]$/i);if(!E)return null;const R=Number.parseFloat(E[1]);return Number.isNaN(R)?null:R},Te=()=>{if(!S.current||!r.body)return null;const u=S.current.ownerDocument?.documentElement?.clientHeight||window.innerHeight,{viewportHeightCss:b}=ve(r.body),d=b?Y(b,u):null;if(d!==null)return Math.ceil(d);const f=r.body.querySelector(".sandbox-wrapper")?.querySelector(".sandbox-container > *");if(!f)return null;const E=f.style.height||f.getAttribute("height"),R=E?Y(E,u):null;if(R!==null)return Math.ceil(R);const D=Ie(f.getAttribute("class")||"",u);return D!==null?Math.ceil(D):null},Z=()=>{if(!S.current||!r.body)return;const u=r.body.getBoundingClientRect(),b=r.documentElement?.getBoundingClientRect(),d=u.height,x=b?.height||0,f=Math.max(d,x),E=Te(),R=Math.max(200,E??Math.ceil(f));Ee(R)},O=()=>{requestAnimationFrame(()=>{T||Z()})};B.current=O,Z(),O(),ye?Ve().then(u=>{T||(u(r),requestAnimationFrame(()=>{T||($(!0),O())}))}).catch(()=>{T||($(!0),O())}):$(!0);const J=new ResizeObserver(()=>Z());return J.observe(r.body),V&&J.observe(V),()=>{T=!0,J.disconnect(),g&&(r.removeEventListener("pointerdown",p,!0),r.removeEventListener("mousedown",F,!0),r.removeEventListener("touchstart",v,!0)),setTimeout(()=>{ue.unmount(),L.current=null,te.current=null,B.current=()=>{}},0)}},[]),o.useEffect(()=>{const l=()=>{He(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",l),()=>document.removeEventListener("fullscreenchange",l)},[]);const Ce=()=>{const l=ee.current||S.current;if(l){if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}l.requestFullscreen&&l.requestFullscreen().catch(()=>{})}};o.useEffect(()=>{const l=L.current;l&&(l.render(w.jsxRuntimeExports.jsx(Pe.default,{html:_,loadingText:i,styleLoadingText:s,scriptLoadingText:c,fullScreenButtonText:m,hideFullScreen:y,resetToken:re,hasRootVhHeight:ae,mode:h,stretchRootHeight:se})),M.current=window.requestAnimationFrame(()=>{B.current?.(),M.current=null}))},[_,i,s,c,m,re,h]);const Me=["w-full relative content-render-iframe-sandbox",q?"h-full overflow-auto flex flex-col":"aspect-[16/9] overflow-hidden flex items-center justify-center"].filter(Boolean).join(" ");return w.jsxRuntimeExports.jsxs("div",{ref:ee,"data-root-vh":ae?"true":"false",className:Me,style:I?{height:I,minHeight:I}:void 0,children:[!y&&w.jsxRuntimeExports.jsx("button",{type:"button",onClick:Ce,className:"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",children:Se?"退出全屏":m||"全屏浏览"}),h==="blackboard"&&t==="markdown"?w.jsxRuntimeExports.jsx("div",{onMouseDown:()=>H("mousedown"),onPointerDown:()=>H("pointerdown"),onTouchStart:()=>H("touchstart"),children:w.jsxRuntimeExports.jsx(Fe.default,{content:e})}):w.jsxRuntimeExports.jsxs(w.jsxRuntimeExports.Fragment,{children:[null,w.jsxRuntimeExports.jsx("iframe",{ref:S,sandbox:"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allow:"fullscreen",allowFullScreen:!0,className:[n,"w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),style:{height:I??"100%",minHeight:I,margin:"auto",visibility:"visible"}}),null]})]})};exports.default=Ye;
18
18
  //# sourceMappingURL=IframeSandbox.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IframeSandbox.cjs.js","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport { Loader2 } from \"lucide-react\";\nimport SandboxApp from \"./SandboxApp\";\nimport { splitContentSegments } from \"./utils/split-content\";\nimport ContentRender from \"./ContentRender\";\nimport {\n SANDBOX_INTERACTION_MESSAGE_SOURCE,\n SANDBOX_INTERACTION_MESSAGE_TYPE,\n} from \"../../lib/sandboxInteraction\";\n\ntype InjectBlackboardLibraries =\n typeof import(\"./blackboard-vendor\").injectBlackboardLibraries;\n\n// Cache the sandbox vendor loader so every iframe reuses the same preload request.\nlet blackboardVendorPromise: Promise<InjectBlackboardLibraries> | null = null;\n\nconst loadBlackboardVendor = () => {\n if (!blackboardVendorPromise) {\n blackboardVendorPromise = import(\"./blackboard-vendor\").then(\n (m) => m.injectBlackboardLibraries\n );\n }\n\n return blackboardVendorPromise;\n};\n\nconst loadBlackboardVendorOnDemandWithMetrics = () => {\n const loadStart = performance.now();\n const startedAt = new Date().toISOString();\n console.log(\"[IframeSandbox][SandboxLoad] start\", { startedAt });\n\n return loadBlackboardVendor()\n .then((inject) => {\n console.log(\"[IframeSandbox][SandboxLoad] done\", {\n startedAt,\n endedAt: new Date().toISOString(),\n durationMs: Number((performance.now() - loadStart).toFixed(2)),\n });\n return inject;\n })\n .catch((error) => {\n console.error(\"[IframeSandbox][SandboxLoad] failed\", {\n startedAt,\n endedAt: new Date().toISOString(),\n durationMs: Number((performance.now() - loadStart).toFixed(2)),\n error,\n });\n throw error;\n });\n};\n\nconst COMPLETE_IMAGE_TAG_PATTERN = /<img\\b[^>]*>/i;\nconst POST_IMAGE_STREAM_DEBOUNCE_MS = 180;\nconst SANDBOX_INTERACTION_THROTTLE_MS = 240;\nconst COMPLETE_IMAGE_SOURCE_PATTERN =\n /<img\\b[^>]*\\bsrc\\s*=\\s*[\"']([^\"']+)[\"'][^>]*>/gi;\nconst SANDBOX_IMAGE_PRELOAD_CACHE = new Map<string, Promise<void>>();\nconst SANDBOX_IMAGE_READY_CACHE = new Set<string>();\n\nconst extractCompleteImageSources = (html: string) => {\n const matches = Array.from(html.matchAll(COMPLETE_IMAGE_SOURCE_PATTERN));\n return Array.from(\n new Set(\n matches\n .map((match) => match[1]?.trim())\n .filter((src): src is string => Boolean(src))\n )\n );\n};\n\nconst preloadSandboxImage = (src: string) => {\n if (!src) {\n return Promise.resolve();\n }\n\n const cached = SANDBOX_IMAGE_PRELOAD_CACHE.get(src);\n if (cached) {\n return cached;\n }\n\n const nextPromise = new Promise<void>((resolve) => {\n if (typeof window === \"undefined\") {\n SANDBOX_IMAGE_READY_CACHE.add(src);\n resolve();\n return;\n }\n\n const image = new window.Image();\n image.decoding = \"sync\";\n image.loading = \"eager\";\n image.fetchPriority = \"high\";\n\n const settleWhenRenderable = () => {\n const decodePromise =\n typeof image.decode === \"function\"\n ? image.decode().catch(() => undefined)\n : Promise.resolve();\n\n void decodePromise.finally(() => {\n SANDBOX_IMAGE_READY_CACHE.add(src);\n resolve();\n });\n };\n\n image.onload = () => {\n settleWhenRenderable();\n };\n image.onerror = () => {\n SANDBOX_IMAGE_READY_CACHE.add(src);\n resolve();\n };\n image.src = src;\n\n if (image.complete && image.naturalWidth > 0) {\n settleWhenRenderable();\n }\n });\n\n SANDBOX_IMAGE_PRELOAD_CACHE.set(src, nextPromise);\n return nextPromise;\n};\n\nconst preloadSandboxImages = (sources: string[] = []) =>\n Promise.allSettled(sources.map((source) => preloadSandboxImage(source)));\n\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n hideFullScreen?: boolean;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n replaceRootScreenHeightWithFull?: boolean;\n}\n\nconst normalizeTailwindHeightTokens = (className: string) =>\n className\n .split(/\\s+/)\n .filter(Boolean)\n .map((token) => token.split(\":\").pop() || token);\n\nconst parseViewportHeightCss = (value: string) => {\n const normalized = value.trim().toLowerCase();\n if (!normalized) return null;\n const matched = normalized.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);\n if (!matched) return null;\n return `${matched[1]}${matched[2].toLowerCase()}`;\n};\n\nconst extractViewportHeightFromTailwindClass = (className: string) => {\n if (!className.trim()) return null;\n const normalizedTokens = normalizeTailwindHeightTokens(className);\n if (\n normalizedTokens.includes(\"h-screen\") ||\n normalizedTokens.includes(\"h-dvh\") ||\n normalizedTokens.includes(\"min-h-screen\") ||\n normalizedTokens.includes(\"min-h-dvh\")\n ) {\n return \"100dvh\";\n }\n if (\n normalizedTokens.includes(\"h-svh\") ||\n normalizedTokens.includes(\"min-h-svh\")\n ) {\n return \"100svh\";\n }\n if (\n normalizedTokens.includes(\"h-lvh\") ||\n normalizedTokens.includes(\"min-h-lvh\")\n ) {\n return \"100lvh\";\n }\n const arbitraryToken = normalizedTokens.find((token) =>\n /^(h|min-h)-\\[[0-9.]+(vh|dvh|svh|lvh)\\]$/i.test(token)\n );\n if (!arbitraryToken) return null;\n const matched = arbitraryToken.match(\n /^(h|min-h)-\\[([0-9.]+)(vh|dvh|svh|lvh)\\]$/i\n );\n if (!matched) return null;\n return `${matched[2]}${matched[3].toLowerCase()}`;\n};\n\nconst SANDBOX_IGNORED_TAG_NAMES = new Set([\n \"base\",\n \"link\",\n \"meta\",\n \"script\",\n \"style\",\n \"template\",\n \"title\",\n]);\n\nconst isSandboxRenderableElement = (element: Element) =>\n !SANDBOX_IGNORED_TAG_NAMES.has(element.tagName.toLowerCase());\n\nconst getFirstRenderableElementChild = (root: ParentNode) =>\n Array.from(root.childNodes).find(\n (node): node is HTMLElement =>\n node.nodeType === Node.ELEMENT_NODE &&\n isSandboxRenderableElement(node as HTMLElement)\n ) || null;\n\nconst getInspectableSandboxElementChain = (root: ParentNode) => {\n const chain: HTMLElement[] = [];\n let current = getFirstRenderableElementChild(root);\n\n while (current) {\n chain.push(current);\n\n const childElements = Array.from(current.children).filter(\n (element): element is HTMLElement => isSandboxRenderableElement(element)\n );\n\n if (childElements.length !== 1) {\n break;\n }\n\n current = childElements[0];\n }\n\n return chain;\n};\n\nconst extractViewportHeightFromElement = (element: HTMLElement) => {\n const heightAttrValue = element.getAttribute(\"height\");\n const attrViewportHeight = heightAttrValue\n ? parseViewportHeightCss(heightAttrValue)\n : null;\n\n if (attrViewportHeight) {\n return attrViewportHeight;\n }\n\n const styleHeightValue =\n element.getAttribute(\"style\")?.match(/\\bheight\\s*:\\s*([^;]+)/i)?.[1] ||\n null;\n const styleViewportHeight = styleHeightValue\n ? parseViewportHeightCss(styleHeightValue)\n : null;\n\n if (styleViewportHeight) {\n return styleViewportHeight;\n }\n\n return extractViewportHeightFromTailwindClass(\n element.getAttribute(\"class\") || \"\"\n );\n};\n\nconst isFullViewportHeightCss = (value: string | null) =>\n value === \"100vh\" ||\n value === \"100dvh\" ||\n value === \"100svh\" ||\n value === \"100lvh\";\n\nconst inspectSandboxPrimaryHeight = (root: ParentNode) => {\n const inspectableElements = getInspectableSandboxElementChain(root);\n let viewportHeightCss: string | null = null;\n let hasFullViewportHeight = false;\n\n inspectableElements.forEach((element) => {\n const elementViewportHeight = extractViewportHeightFromElement(element);\n\n if (!viewportHeightCss && elementViewportHeight) {\n viewportHeightCss = elementViewportHeight;\n }\n\n if (isFullViewportHeightCss(elementViewportHeight)) {\n hasFullViewportHeight = true;\n }\n });\n\n return {\n viewportHeightCss,\n hasFullViewportHeight,\n };\n};\n\nconst inspectRootHeightFromHtmlString = (html: string) => {\n const normalized = html.trim();\n\n if (!normalized) {\n return {\n viewportHeightCss: null,\n hasFullViewportHeight: false,\n };\n }\n\n const rootMatch = normalized.match(/^<([a-zA-Z][\\w:-]*)(\\s[^>]*?)?>/);\n const attrs = rootMatch?.[2] || \"\";\n const heightAttrValue = attrs.match(/\\bheight\\s*=\\s*[\"']([^\"']+)[\"']/i)?.[1];\n const styleAttrValue = attrs.match(/\\bstyle\\s*=\\s*[\"']([^\"']+)[\"']/i)?.[1];\n const styleHeightValue = styleAttrValue?.match(\n /\\bheight\\s*:\\s*([^;]+)/i\n )?.[1];\n const classAttrValue = attrs.match(/\\bclass\\s*=\\s*[\"']([^\"']+)[\"']/i)?.[1];\n const viewportHeightCss =\n (heightAttrValue ? parseViewportHeightCss(heightAttrValue) : null) ||\n (styleHeightValue ? parseViewportHeightCss(styleHeightValue) : null) ||\n (classAttrValue\n ? extractViewportHeightFromTailwindClass(classAttrValue)\n : null);\n\n return {\n viewportHeightCss,\n hasFullViewportHeight: isFullViewportHeightCss(viewportHeightCss),\n };\n};\n\nconst inspectSandboxPrimaryHeightFromHtml = (html: string) => {\n const normalized = html.trim();\n\n if (!normalized) {\n return {\n viewportHeightCss: null,\n hasFullViewportHeight: false,\n };\n }\n\n if (typeof document === \"undefined\") {\n return inspectRootHeightFromHtmlString(normalized);\n }\n\n const template = document.createElement(\"template\");\n template.innerHTML = normalized;\n\n return inspectSandboxPrimaryHeight(template.content);\n};\n\nconst replaceRootScreenHeightToken = (className: string) =>\n className\n .split(/\\s+/)\n .filter(Boolean)\n .map((token) => {\n const segments = token.split(\":\");\n if (\n segments[segments.length - 1] !== \"h-screen\" &&\n segments[segments.length - 1] !== \"min-h-screen\"\n ) {\n return token;\n }\n segments[segments.length - 1] = \"h-full\";\n return segments.join(\":\");\n })\n .join(\" \");\n\nconst replaceRootScreenHeightWithFullClass = (\n html: string,\n enabled: boolean\n) => {\n if (!enabled || !html.trim()) {\n return html;\n }\n\n return html.replace(\n /^(\\s*<[a-zA-Z][\\w:-]*)(\\s[^>]*?)?>/,\n (match, tagStart: string, attrs = \"\") => {\n const classMatch = attrs.match(/\\bclass\\s*=\\s*([\"'])([^\"']*)\\1/i);\n\n if (!classMatch) {\n return match;\n }\n\n const nextClassName = replaceRootScreenHeightToken(classMatch[2]);\n\n if (nextClassName === classMatch[2]) {\n return match;\n }\n\n return `${tagStart}${attrs.replace(\n classMatch[0],\n `class=${classMatch[1]}${nextClassName}${classMatch[1]}`\n )}>`;\n }\n );\n};\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n hideFullScreen = false,\n mode = \"content\",\n replaceRootScreenHeightWithFull = false,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const docRef = useRef<Document | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const lastSandboxInteractionTimeRef = useRef(0);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [, setIsSandboxVendorReady] = useState(true);\n const shouldInjectSandboxVendor = type === \"sandbox\";\n\n const isBlackboardMode = mode === \"blackboard\";\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(() => {\n const segments = splitContentSegments(content);\n // console.log('segments=====', segments);\n const sandboxSegments = segments.filter((seg) => seg.type === \"sandbox\");\n const sandboxContent =\n mode === \"blackboard\"\n ? sandboxSegments[sandboxSegments.length - 1]?.value || \"\"\n : sandboxSegments.map((seg) => seg.value).join(\"\\n\");\n return sandboxContent || \"\";\n }, [content, mode]);\n const normalizedHtmlContent = React.useMemo(\n () =>\n replaceRootScreenHeightWithFullClass(\n htmlContent,\n replaceRootScreenHeightWithFull\n ),\n [htmlContent, replaceRootScreenHeightWithFull]\n );\n const completeImageSources = React.useMemo(\n () => extractCompleteImageSources(normalizedHtmlContent),\n [normalizedHtmlContent]\n );\n const htmlHeightMeta = React.useMemo(\n () => inspectSandboxPrimaryHeightFromHtml(htmlContent),\n [htmlContent]\n );\n const shouldStretchRootHeight = React.useMemo(\n () =>\n replaceRootScreenHeightWithFull && htmlHeightMeta.hasFullViewportHeight,\n [htmlHeightMeta.hasFullViewportHeight, replaceRootScreenHeightWithFull]\n );\n const [renderHtmlContent, setRenderHtmlContent] = useState(\n normalizedHtmlContent\n );\n const prevIncomingHtmlRef = useRef(normalizedHtmlContent);\n const pendingHtmlRef = useRef(normalizedHtmlContent);\n const deferRenderTimerRef = useRef<number | null>(null);\n const initialPaintFrameRef = useRef<number | null>(null);\n const initialPaintCommitFrameRef = useRef<number | null>(null);\n const imagePreloadRequestIdRef = useRef(0);\n\n const emitSandboxInteraction = useCallback((eventType: string) => {\n if (typeof window === \"undefined\") {\n return;\n }\n const now = Date.now();\n if (\n now - lastSandboxInteractionTimeRef.current <\n SANDBOX_INTERACTION_THROTTLE_MS\n ) {\n return;\n }\n lastSandboxInteractionTimeRef.current = now;\n window.postMessage(\n {\n source: SANDBOX_INTERACTION_MESSAGE_SOURCE,\n type: SANDBOX_INTERACTION_MESSAGE_TYPE,\n eventType,\n },\n window.location.origin\n );\n }, []);\n\n const clearDeferredRenderTimer = () => {\n if (deferRenderTimerRef.current === null) return;\n window.clearTimeout(deferRenderTimerRef.current);\n deferRenderTimerRef.current = null;\n };\n\n const clearInitialPaintFrames = () => {\n if (initialPaintFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintFrameRef.current);\n initialPaintFrameRef.current = null;\n }\n if (initialPaintCommitFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintCommitFrameRef.current);\n initialPaintCommitFrameRef.current = null;\n }\n };\n\n useEffect(\n () => () => {\n clearDeferredRenderTimer();\n clearInitialPaintFrames();\n },\n []\n );\n\n useEffect(() => {\n void preloadSandboxImages(completeImageSources);\n }, [completeImageSources]);\n\n useEffect(() => {\n const prevIncomingHtml = prevIncomingHtmlRef.current;\n prevIncomingHtmlRef.current = normalizedHtmlContent;\n\n const isAppendOnlyStream =\n !!prevIncomingHtml &&\n normalizedHtmlContent.length > prevIncomingHtml.length &&\n normalizedHtmlContent.startsWith(prevIncomingHtml);\n const containsCompleteImage = COMPLETE_IMAGE_TAG_PATTERN.test(\n normalizedHtmlContent\n );\n const hasPendingImagePreload =\n isAppendOnlyStream &&\n containsCompleteImage &&\n completeImageSources.some(\n (source) => !SANDBOX_IMAGE_READY_CACHE.has(source)\n );\n const shouldDeferRender = isAppendOnlyStream && containsCompleteImage;\n\n pendingHtmlRef.current = normalizedHtmlContent;\n clearDeferredRenderTimer();\n\n if (hasPendingImagePreload) {\n const requestId = imagePreloadRequestIdRef.current + 1;\n imagePreloadRequestIdRef.current = requestId;\n\n void preloadSandboxImages(completeImageSources).then(() => {\n if (imagePreloadRequestIdRef.current !== requestId) {\n return;\n }\n\n setRenderHtmlContent(pendingHtmlRef.current);\n });\n return;\n }\n\n if (!shouldDeferRender) {\n setRenderHtmlContent(normalizedHtmlContent);\n return;\n }\n\n deferRenderTimerRef.current = window.setTimeout(() => {\n setRenderHtmlContent(pendingHtmlRef.current);\n deferRenderTimerRef.current = null;\n }, POST_IMAGE_STREAM_DEBOUNCE_MS);\n }, [completeImageSources, normalizedHtmlContent]);\n\n const rootViewportHeightCss = React.useMemo(\n () =>\n inspectSandboxPrimaryHeightFromHtml(renderHtmlContent).viewportHeightCss,\n [renderHtmlContent]\n );\n const hasRootVhHeight = Boolean(rootViewportHeightCss);\n const sandboxViewportHeight =\n isBlackboardMode && type === \"sandbox\"\n ? shouldStretchRootHeight\n ? \"100%\"\n : (rootViewportHeightCss ?? `${height}px`)\n : undefined;\n const shouldShowHtmlFallbackWhilePreparingSandbox = false;\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = normalizedHtmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && normalizedHtmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = normalizedHtmlContent;\n }, [mode, normalizedHtmlContent]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return undefined;\n\n const doc = iframe.contentDocument;\n if (!doc) return undefined;\n\n doc.open();\n doc.write(`<!DOCTYPE html>\n<html${mode === \"blackboard\" ? ' style=\"height: 100%;\"' : \"\"}>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <style>\n :root { color-scheme: light; }\n html, body, #root { width: 100%; height: 100%; }\n html, body { margin: 0; padding: 0; overflow: auto; }\n *, *::before, *::after { box-sizing: border-box; }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n\n // Force iframe theme to stay in light mode regardless of host OS preference.\n doc.documentElement.setAttribute(\"data-theme\", \"light\");\n doc.documentElement.style.colorScheme = \"light\";\n doc.body?.style.setProperty(\"color-scheme\", \"light\");\n\n docRef.current = doc;\n\n const shouldBridgeSandboxInteraction =\n isBlackboardMode && type === \"sandbox\";\n const handleSandboxPointerDown = () =>\n emitSandboxInteraction(\"pointerdown\");\n const handleSandboxMouseDown = () => emitSandboxInteraction(\"mousedown\");\n const handleSandboxTouchStart = () => emitSandboxInteraction(\"touchstart\");\n\n if (shouldBridgeSandboxInteraction) {\n doc.addEventListener(\"pointerdown\", handleSandboxPointerDown, true);\n doc.addEventListener(\"mousedown\", handleSandboxMouseDown, true);\n doc.addEventListener(\"touchstart\", handleSandboxTouchStart, true);\n }\n\n const rootEl = doc.getElementById(\"root\");\n if (!rootEl) return undefined;\n\n const root = createRoot(rootEl);\n rootRef.current = root;\n let isDestroyed = false;\n\n const parseExplicitHeight = (\n value: string,\n parentViewportHeight: number\n ) => {\n const normalized = value.trim().toLowerCase();\n if (!normalized) return null;\n const numeric = Number.parseFloat(normalized);\n if (Number.isNaN(numeric)) return null;\n if (/(dvh|svh|lvh|vh)$/i.test(normalized)) {\n return (numeric / 100) * parentViewportHeight;\n }\n if (normalized.endsWith(\"px\") || /^[0-9.]+$/.test(normalized)) {\n return numeric;\n }\n return null;\n };\n const parseTailwindHeightClass = (\n className: string,\n parentViewportHeight: number\n ) => {\n if (!className.trim()) return null;\n const viewportHeightCss =\n extractViewportHeightFromTailwindClass(className);\n if (viewportHeightCss) {\n return parseExplicitHeight(viewportHeightCss, parentViewportHeight);\n }\n const normalizedTokens = normalizeTailwindHeightTokens(className);\n const arbitraryToken = normalizedTokens.find((token) =>\n /^h-\\[[0-9.]+px\\]$/i.test(token)\n );\n if (!arbitraryToken) return null;\n const matched = arbitraryToken.match(/^h-\\[([0-9.]+)px\\]$/i);\n if (!matched) return null;\n const numeric = Number.parseFloat(matched[1]);\n if (Number.isNaN(numeric)) return null;\n return numeric;\n };\n\n const resolveExplicitHeight = () => {\n if (!iframeRef.current || !doc.body) return null;\n const parentViewportHeight =\n iframeRef.current.ownerDocument?.documentElement?.clientHeight ||\n window.innerHeight;\n const { viewportHeightCss } = inspectSandboxPrimaryHeight(doc.body);\n const parsed = viewportHeightCss\n ? parseExplicitHeight(viewportHeightCss, parentViewportHeight)\n : null;\n\n if (parsed !== null) {\n return Math.ceil(parsed);\n }\n\n const wrapper = doc.body.querySelector(\n \".sandbox-wrapper\"\n ) as HTMLElement | null;\n const target = wrapper?.querySelector(\n \".sandbox-container > *\"\n ) as HTMLElement | null;\n\n if (!target) return null;\n\n const heightValue = target.style.height || target.getAttribute(\"height\");\n const explicitPixelHeight = heightValue\n ? parseExplicitHeight(heightValue, parentViewportHeight)\n : null;\n\n if (explicitPixelHeight !== null) {\n return Math.ceil(explicitPixelHeight);\n }\n\n const classHeight = parseTailwindHeightClass(\n target.getAttribute(\"class\") || \"\",\n parentViewportHeight\n );\n\n return classHeight !== null ? Math.ceil(classHeight) : null;\n };\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n const bodyRect = doc.body.getBoundingClientRect();\n const htmlRect = doc.documentElement?.getBoundingClientRect();\n const bodyHeight = bodyRect.height;\n const htmlHeight = htmlRect?.height || 0;\n const contentHeight = Math.max(bodyHeight, htmlHeight);\n const explicitHeight = resolveExplicitHeight();\n const nextHeight = Math.max(\n 200,\n explicitHeight ?? Math.ceil(contentHeight)\n );\n setHeight(nextHeight);\n };\n const scheduleHeightUpdate = () => {\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n updateHeight();\n });\n };\n updateHeightRef.current = scheduleHeightUpdate;\n\n updateHeight();\n scheduleHeightUpdate();\n\n if (!shouldInjectSandboxVendor) {\n setIsSandboxVendorReady(true);\n } else {\n // Inject Tailwind/DaisyUI/GSAP before rendering sandbox content to avoid FOUC.\n loadBlackboardVendorOnDemandWithMetrics()\n .then((inject) => {\n if (isDestroyed) return;\n inject(doc);\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n setIsSandboxVendorReady(true);\n scheduleHeightUpdate();\n });\n })\n .catch(() => {\n if (isDestroyed) return;\n setIsSandboxVendorReady(true);\n scheduleHeightUpdate();\n });\n }\n\n const resizeObserver = new ResizeObserver(() => updateHeight());\n resizeObserver.observe(doc.body);\n if (rootEl) {\n resizeObserver.observe(rootEl);\n }\n\n return () => {\n isDestroyed = true;\n resizeObserver.disconnect();\n if (shouldBridgeSandboxInteraction) {\n doc.removeEventListener(\"pointerdown\", handleSandboxPointerDown, true);\n doc.removeEventListener(\"mousedown\", handleSandboxMouseDown, true);\n doc.removeEventListener(\"touchstart\", handleSandboxTouchStart, true);\n }\n // Defer unmount to avoid React warning when parent is mid-render\n setTimeout(() => {\n root.unmount();\n rootRef.current = null;\n docRef.current = null;\n updateHeightRef.current = () => {};\n }, 0);\n };\n }, []);\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(Boolean(document.fullscreenElement));\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n }, []);\n\n const toggleFullscreen = () => {\n const target = containerRef.current || iframeRef.current;\n if (!target) return;\n if (document.fullscreenElement) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n if (target.requestFullscreen) {\n target.requestFullscreen().catch(() => {});\n }\n };\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n root.render(\n <SandboxApp\n html={renderHtmlContent}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n fullScreenButtonText={fullScreenButtonText}\n hideFullScreen={hideFullScreen}\n resetToken={resetToken}\n hasRootVhHeight={hasRootVhHeight}\n mode={mode}\n stretchRootHeight={shouldStretchRootHeight}\n />\n );\n\n initialPaintFrameRef.current = window.requestAnimationFrame(() => {\n updateHeightRef.current?.();\n initialPaintFrameRef.current = null;\n });\n }, [\n renderHtmlContent,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken,\n mode,\n ]);\n const containerClassName = [\n \"w-full relative content-render-iframe-sandbox\",\n isBlackboardMode\n ? \"h-full overflow-auto flex flex-col\"\n : \"aspect-[16/9] overflow-hidden flex items-center justify-center\",\n ]\n .filter(Boolean)\n .join(\" \");\n\n const shouldShowSandboxLoading = false;\n\n return (\n <div\n ref={containerRef}\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className={containerClassName}\n style={\n sandboxViewportHeight\n ? {\n height: sandboxViewportHeight,\n minHeight: sandboxViewportHeight,\n }\n : undefined\n }\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n className={\n \"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer\"\n }\n >\n {isFullscreen ? \"退出全屏\" : fullScreenButtonText || \"全屏浏览\"}\n </button>\n )}\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <div\n onMouseDown={() => emitSandboxInteraction(\"mousedown\")}\n onPointerDown={() => emitSandboxInteraction(\"pointerdown\")}\n onTouchStart={() => emitSandboxInteraction(\"touchstart\")}\n >\n <ContentRender content={content} />\n </div>\n ) : (\n <>\n {shouldShowHtmlFallbackWhilePreparingSandbox ? (\n <div\n aria-hidden\n className=\"absolute inset-0 z-10 overflow-hidden\"\n style={{\n height: sandboxViewportHeight ?? \"100%\",\n minHeight: sandboxViewportHeight,\n }}\n >\n <div\n className=\"h-full w-full\"\n dangerouslySetInnerHTML={{ __html: renderHtmlContent }}\n />\n </div>\n ) : null}\n <iframe\n ref={iframeRef}\n sandbox=\"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox\"\n allow=\"fullscreen\"\n allowFullScreen\n className={[className, \"w-full h-full mx-auto my-auto block\"]\n .filter(Boolean)\n .join(\" \")}\n style={{\n height: sandboxViewportHeight ?? \"100%\",\n minHeight: sandboxViewportHeight,\n margin: \"auto\",\n visibility: \"visible\",\n }}\n />\n {shouldShowSandboxLoading ? (\n <div className=\"pointer-events-none absolute inset-0 z-20 flex items-center justify-center\">\n <Loader2\n aria-label={loadingText || \"Preparing sandbox styles\"}\n className=\"text-primary h-7 w-7 animate-spin\"\n />\n </div>\n ) : null}\n </>\n )}\n </div>\n );\n};\n\nexport default IframeSandbox;\n"],"names":["blackboardVendorPromise","loadBlackboardVendor","m","loadBlackboardVendorOnDemandWithMetrics","loadStart","startedAt","inject","error","COMPLETE_IMAGE_TAG_PATTERN","POST_IMAGE_STREAM_DEBOUNCE_MS","SANDBOX_INTERACTION_THROTTLE_MS","COMPLETE_IMAGE_SOURCE_PATTERN","SANDBOX_IMAGE_PRELOAD_CACHE","SANDBOX_IMAGE_READY_CACHE","extractCompleteImageSources","html","matches","match","src","preloadSandboxImage","cached","nextPromise","resolve","image","settleWhenRenderable","preloadSandboxImages","sources","source","normalizeTailwindHeightTokens","className","token","parseViewportHeightCss","value","normalized","matched","extractViewportHeightFromTailwindClass","normalizedTokens","arbitraryToken","SANDBOX_IGNORED_TAG_NAMES","isSandboxRenderableElement","element","getFirstRenderableElementChild","root","node","getInspectableSandboxElementChain","chain","current","childElements","extractViewportHeightFromElement","heightAttrValue","attrViewportHeight","styleHeightValue","styleViewportHeight","isFullViewportHeightCss","inspectSandboxPrimaryHeight","inspectableElements","viewportHeightCss","hasFullViewportHeight","elementViewportHeight","inspectRootHeightFromHtmlString","attrs","classAttrValue","inspectSandboxPrimaryHeightFromHtml","template","replaceRootScreenHeightToken","segments","replaceRootScreenHeightWithFullClass","enabled","tagStart","classMatch","nextClassName","IframeSandbox","content","type","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","hideFullScreen","mode","replaceRootScreenHeightWithFull","containerRef","useRef","iframeRef","rootRef","docRef","updateHeightRef","height","setHeight","useState","lastSandboxInteractionTimeRef","resetToken","setResetToken","isFullscreen","setIsFullscreen","setIsSandboxVendorReady","shouldInjectSandboxVendor","isBlackboardMode","prevHtmlRef","htmlContent","React","sandboxSegments","splitContentSegments","seg","normalizedHtmlContent","completeImageSources","htmlHeightMeta","shouldStretchRootHeight","renderHtmlContent","setRenderHtmlContent","prevIncomingHtmlRef","pendingHtmlRef","deferRenderTimerRef","initialPaintFrameRef","initialPaintCommitFrameRef","imagePreloadRequestIdRef","emitSandboxInteraction","useCallback","eventType","now","SANDBOX_INTERACTION_MESSAGE_SOURCE","SANDBOX_INTERACTION_MESSAGE_TYPE","clearDeferredRenderTimer","clearInitialPaintFrames","useEffect","prevIncomingHtml","isAppendOnlyStream","containsCompleteImage","hasPendingImagePreload","shouldDeferRender","requestId","rootViewportHeightCss","hasRootVhHeight","sandboxViewportHeight","prev","iframe","doc","shouldBridgeSandboxInteraction","handleSandboxPointerDown","handleSandboxMouseDown","handleSandboxTouchStart","rootEl","createRoot","isDestroyed","parseExplicitHeight","parentViewportHeight","numeric","parseTailwindHeightClass","resolveExplicitHeight","parsed","target","heightValue","explicitPixelHeight","classHeight","updateHeight","bodyRect","htmlRect","bodyHeight","htmlHeight","contentHeight","explicitHeight","nextHeight","scheduleHeightUpdate","resizeObserver","onFullscreenChange","toggleFullscreen","jsx","SandboxApp","containerClassName","jsxs","Content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AAU,OAAO,sBAAsB,IAAM,CAChE3B,EAAgB,UAAA,EAChB2B,EAAqB,QAAU,IACjC,CAAC,EACH,EAAG,CACDL,EACAlC,EACAC,EACAC,EACAC,EACAc,GACAZ,CAAA,CACD,EACD,MAAMyF,GAAqB,CACzB,gDACAvE,EACI,qCACA,gEAAA,EAEH,OAAO,OAAO,EACd,KAAK,GAAG,EAIX,OACEwE,EAAAA,kBAAAA,KAAC,MAAA,CACC,IAAKxF,GACL,eAAcmD,GAAkB,OAAS,QACzC,UAAWoC,GACX,MACEnC,EACI,CACE,OAAQA,EACR,UAAWA,CAAA,EAEb,OAGL,SAAA,CAAA,CAACvD,GACAwF,EAAAA,kBAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAASD,GACT,UACE,qFAGD,SAAAxE,GAAe,OAAShB,GAAwB,MAAA,CAAA,EAGpDE,IAAS,cAAgBN,IAAS,WACjC6F,EAAAA,kBAAAA,IAAC,MAAA,CACC,YAAa,IAAMlD,EAAuB,WAAW,EACrD,cAAe,IAAMA,EAAuB,aAAa,EACzD,aAAc,IAAMA,EAAuB,YAAY,EAEvD,SAAAkD,EAAAA,kBAAAA,IAACI,YAAc,QAAAlG,CAAA,CAAkB,CAAA,CAAA,EAGnCiG,EAAAA,kBAAAA,KAAAE,6BAAA,CACG,SAAA,CAcG,KACJL,EAAAA,kBAAAA,IAAC,SAAA,CACC,IAAKnF,EACL,QAAQ,8EACR,MAAM,aACN,gBAAe,GACf,UAAW,CAACtD,EAAW,qCAAqC,EACzD,OAAO,OAAO,EACd,KAAK,GAAG,EACX,MAAO,CACL,OAAQwG,GAAyB,OACjC,UAAWA,EACX,OAAQ,OACR,WAAY,SAAA,CACd,CAAA,EASE,IAAA,CAAA,CACN,CAAA,CAAA,CAAA,CAIR"}
1
+ {"version":3,"file":"IframeSandbox.cjs.js","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport { Loader2 } from \"lucide-react\";\nimport SandboxApp from \"./SandboxApp\";\nimport { splitContentSegments } from \"./utils/split-content\";\nimport ContentRender from \"./ContentRender\";\nimport {\n SANDBOX_INTERACTION_MESSAGE_SOURCE,\n SANDBOX_INTERACTION_MESSAGE_TYPE,\n} from \"../../lib/sandboxInteraction\";\n\ntype InjectBlackboardLibraries =\n typeof import(\"./blackboard-vendor\").injectBlackboardLibraries;\n\n// Cache the sandbox vendor loader so every iframe reuses the same preload request.\nlet blackboardVendorPromise: Promise<InjectBlackboardLibraries> | null = null;\n\nconst loadBlackboardVendor = () => {\n if (!blackboardVendorPromise) {\n blackboardVendorPromise = import(\"./blackboard-vendor\").then(\n (m) => m.injectBlackboardLibraries\n );\n }\n\n return blackboardVendorPromise;\n};\n\nif (typeof window !== \"undefined\") {\n // Warm sandbox vendor in browser so the first iframe render can start sooner.\n void loadBlackboardVendor();\n}\n\nconst loadBlackboardVendorOnDemandWithMetrics = () => {\n const loadStart = performance.now();\n const startedAt = new Date().toISOString();\n console.log(\"[IframeSandbox][SandboxLoad] start\", { startedAt });\n\n return loadBlackboardVendor()\n .then((inject) => {\n console.log(\"[IframeSandbox][SandboxLoad] done\", {\n startedAt,\n endedAt: new Date().toISOString(),\n durationMs: Number((performance.now() - loadStart).toFixed(2)),\n });\n return inject;\n })\n .catch((error) => {\n console.error(\"[IframeSandbox][SandboxLoad] failed\", {\n startedAt,\n endedAt: new Date().toISOString(),\n durationMs: Number((performance.now() - loadStart).toFixed(2)),\n error,\n });\n throw error;\n });\n};\n\nconst COMPLETE_IMAGE_TAG_PATTERN = /<img\\b[^>]*>/i;\nconst POST_IMAGE_STREAM_DEBOUNCE_MS = 180;\nconst SANDBOX_INTERACTION_THROTTLE_MS = 240;\nconst COMPLETE_IMAGE_SOURCE_PATTERN =\n /<img\\b[^>]*\\bsrc\\s*=\\s*[\"']([^\"']+)[\"'][^>]*>/gi;\nconst SANDBOX_IMAGE_PRELOAD_CACHE = new Map<string, Promise<void>>();\nconst SANDBOX_IMAGE_READY_CACHE = new Set<string>();\n\nconst extractCompleteImageSources = (html: string) => {\n const matches = Array.from(html.matchAll(COMPLETE_IMAGE_SOURCE_PATTERN));\n return Array.from(\n new Set(\n matches\n .map((match) => match[1]?.trim())\n .filter((src): src is string => Boolean(src))\n )\n );\n};\n\nconst preloadSandboxImage = (src: string) => {\n if (!src) {\n return Promise.resolve();\n }\n\n const cached = SANDBOX_IMAGE_PRELOAD_CACHE.get(src);\n if (cached) {\n return cached;\n }\n\n const nextPromise = new Promise<void>((resolve) => {\n if (typeof window === \"undefined\") {\n SANDBOX_IMAGE_READY_CACHE.add(src);\n resolve();\n return;\n }\n\n const image = new window.Image();\n image.decoding = \"sync\";\n image.loading = \"eager\";\n image.fetchPriority = \"high\";\n\n const settleWhenRenderable = () => {\n const decodePromise =\n typeof image.decode === \"function\"\n ? image.decode().catch(() => undefined)\n : Promise.resolve();\n\n void decodePromise.finally(() => {\n SANDBOX_IMAGE_READY_CACHE.add(src);\n resolve();\n });\n };\n\n image.onload = () => {\n settleWhenRenderable();\n };\n image.onerror = () => {\n SANDBOX_IMAGE_READY_CACHE.add(src);\n resolve();\n };\n image.src = src;\n\n if (image.complete && image.naturalWidth > 0) {\n settleWhenRenderable();\n }\n });\n\n SANDBOX_IMAGE_PRELOAD_CACHE.set(src, nextPromise);\n return nextPromise;\n};\n\nconst preloadSandboxImages = (sources: string[] = []) =>\n Promise.allSettled(sources.map((source) => preloadSandboxImage(source)));\n\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n hideFullScreen?: boolean;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n replaceRootScreenHeightWithFull?: boolean;\n}\n\nconst normalizeTailwindHeightTokens = (className: string) =>\n className\n .split(/\\s+/)\n .filter(Boolean)\n .map((token) => token.split(\":\").pop() || token);\n\nconst parseViewportHeightCss = (value: string) => {\n const normalized = value.trim().toLowerCase();\n if (!normalized) return null;\n const matched = normalized.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);\n if (!matched) return null;\n return `${matched[1]}${matched[2].toLowerCase()}`;\n};\n\nconst extractViewportHeightFromTailwindClass = (className: string) => {\n if (!className.trim()) return null;\n const normalizedTokens = normalizeTailwindHeightTokens(className);\n if (\n normalizedTokens.includes(\"h-screen\") ||\n normalizedTokens.includes(\"h-dvh\") ||\n normalizedTokens.includes(\"min-h-screen\") ||\n normalizedTokens.includes(\"min-h-dvh\")\n ) {\n return \"100dvh\";\n }\n if (\n normalizedTokens.includes(\"h-svh\") ||\n normalizedTokens.includes(\"min-h-svh\")\n ) {\n return \"100svh\";\n }\n if (\n normalizedTokens.includes(\"h-lvh\") ||\n normalizedTokens.includes(\"min-h-lvh\")\n ) {\n return \"100lvh\";\n }\n const arbitraryToken = normalizedTokens.find((token) =>\n /^(h|min-h)-\\[[0-9.]+(vh|dvh|svh|lvh)\\]$/i.test(token)\n );\n if (!arbitraryToken) return null;\n const matched = arbitraryToken.match(\n /^(h|min-h)-\\[([0-9.]+)(vh|dvh|svh|lvh)\\]$/i\n );\n if (!matched) return null;\n return `${matched[2]}${matched[3].toLowerCase()}`;\n};\n\nconst SANDBOX_IGNORED_TAG_NAMES = new Set([\n \"base\",\n \"link\",\n \"meta\",\n \"script\",\n \"style\",\n \"template\",\n \"title\",\n]);\n\nconst isSandboxRenderableElement = (element: Element) =>\n !SANDBOX_IGNORED_TAG_NAMES.has(element.tagName.toLowerCase());\n\nconst getFirstRenderableElementChild = (root: ParentNode) =>\n Array.from(root.childNodes).find(\n (node): node is HTMLElement =>\n node.nodeType === Node.ELEMENT_NODE &&\n isSandboxRenderableElement(node as HTMLElement)\n ) || null;\n\nconst getInspectableSandboxElementChain = (root: ParentNode) => {\n const chain: HTMLElement[] = [];\n let current = getFirstRenderableElementChild(root);\n\n while (current) {\n chain.push(current);\n\n const childElements = Array.from(current.children).filter(\n (element): element is HTMLElement => isSandboxRenderableElement(element)\n );\n\n if (childElements.length !== 1) {\n break;\n }\n\n current = childElements[0];\n }\n\n return chain;\n};\n\nconst extractViewportHeightFromElement = (element: HTMLElement) => {\n const heightAttrValue = element.getAttribute(\"height\");\n const attrViewportHeight = heightAttrValue\n ? parseViewportHeightCss(heightAttrValue)\n : null;\n\n if (attrViewportHeight) {\n return attrViewportHeight;\n }\n\n const styleHeightValue =\n element.getAttribute(\"style\")?.match(/\\bheight\\s*:\\s*([^;]+)/i)?.[1] ||\n null;\n const styleViewportHeight = styleHeightValue\n ? parseViewportHeightCss(styleHeightValue)\n : null;\n\n if (styleViewportHeight) {\n return styleViewportHeight;\n }\n\n return extractViewportHeightFromTailwindClass(\n element.getAttribute(\"class\") || \"\"\n );\n};\n\nconst isFullViewportHeightCss = (value: string | null) =>\n value === \"100vh\" ||\n value === \"100dvh\" ||\n value === \"100svh\" ||\n value === \"100lvh\";\n\nconst inspectSandboxPrimaryHeight = (root: ParentNode) => {\n const inspectableElements = getInspectableSandboxElementChain(root);\n let viewportHeightCss: string | null = null;\n let hasFullViewportHeight = false;\n\n inspectableElements.forEach((element) => {\n const elementViewportHeight = extractViewportHeightFromElement(element);\n\n if (!viewportHeightCss && elementViewportHeight) {\n viewportHeightCss = elementViewportHeight;\n }\n\n if (isFullViewportHeightCss(elementViewportHeight)) {\n hasFullViewportHeight = true;\n }\n });\n\n return {\n viewportHeightCss,\n hasFullViewportHeight,\n };\n};\n\nconst inspectRootHeightFromHtmlString = (html: string) => {\n const normalized = html.trim();\n\n if (!normalized) {\n return {\n viewportHeightCss: null,\n hasFullViewportHeight: false,\n };\n }\n\n const rootMatch = normalized.match(/^<([a-zA-Z][\\w:-]*)(\\s[^>]*?)?>/);\n const attrs = rootMatch?.[2] || \"\";\n const heightAttrValue = attrs.match(/\\bheight\\s*=\\s*[\"']([^\"']+)[\"']/i)?.[1];\n const styleAttrValue = attrs.match(/\\bstyle\\s*=\\s*[\"']([^\"']+)[\"']/i)?.[1];\n const styleHeightValue = styleAttrValue?.match(\n /\\bheight\\s*:\\s*([^;]+)/i\n )?.[1];\n const classAttrValue = attrs.match(/\\bclass\\s*=\\s*[\"']([^\"']+)[\"']/i)?.[1];\n const viewportHeightCss =\n (heightAttrValue ? parseViewportHeightCss(heightAttrValue) : null) ||\n (styleHeightValue ? parseViewportHeightCss(styleHeightValue) : null) ||\n (classAttrValue\n ? extractViewportHeightFromTailwindClass(classAttrValue)\n : null);\n\n return {\n viewportHeightCss,\n hasFullViewportHeight: isFullViewportHeightCss(viewportHeightCss),\n };\n};\n\nconst inspectSandboxPrimaryHeightFromHtml = (html: string) => {\n const normalized = html.trim();\n\n if (!normalized) {\n return {\n viewportHeightCss: null,\n hasFullViewportHeight: false,\n };\n }\n\n if (typeof document === \"undefined\") {\n return inspectRootHeightFromHtmlString(normalized);\n }\n\n const template = document.createElement(\"template\");\n template.innerHTML = normalized;\n\n return inspectSandboxPrimaryHeight(template.content);\n};\n\nconst replaceRootScreenHeightToken = (className: string) =>\n className\n .split(/\\s+/)\n .filter(Boolean)\n .map((token) => {\n const segments = token.split(\":\");\n if (\n segments[segments.length - 1] !== \"h-screen\" &&\n segments[segments.length - 1] !== \"min-h-screen\"\n ) {\n return token;\n }\n segments[segments.length - 1] = \"h-full\";\n return segments.join(\":\");\n })\n .join(\" \");\n\nconst replaceRootScreenHeightWithFullClass = (\n html: string,\n enabled: boolean\n) => {\n if (!enabled || !html.trim()) {\n return html;\n }\n\n return html.replace(\n /^(\\s*<[a-zA-Z][\\w:-]*)(\\s[^>]*?)?>/,\n (match, tagStart: string, attrs = \"\") => {\n const classMatch = attrs.match(/\\bclass\\s*=\\s*([\"'])([^\"']*)\\1/i);\n\n if (!classMatch) {\n return match;\n }\n\n const nextClassName = replaceRootScreenHeightToken(classMatch[2]);\n\n if (nextClassName === classMatch[2]) {\n return match;\n }\n\n return `${tagStart}${attrs.replace(\n classMatch[0],\n `class=${classMatch[1]}${nextClassName}${classMatch[1]}`\n )}>`;\n }\n );\n};\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n hideFullScreen = false,\n mode = \"content\",\n replaceRootScreenHeightWithFull = false,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const docRef = useRef<Document | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const lastSandboxInteractionTimeRef = useRef(0);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [, setIsSandboxVendorReady] = useState(true);\n const shouldInjectSandboxVendor = type === \"sandbox\";\n\n const isBlackboardMode = mode === \"blackboard\";\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(() => {\n const segments = splitContentSegments(content);\n // console.log('segments=====', segments);\n const sandboxSegments = segments.filter((seg) => seg.type === \"sandbox\");\n const sandboxContent =\n mode === \"blackboard\"\n ? sandboxSegments[sandboxSegments.length - 1]?.value || \"\"\n : sandboxSegments.map((seg) => seg.value).join(\"\\n\");\n return sandboxContent || \"\";\n }, [content, mode]);\n const normalizedHtmlContent = React.useMemo(\n () =>\n replaceRootScreenHeightWithFullClass(\n htmlContent,\n replaceRootScreenHeightWithFull\n ),\n [htmlContent, replaceRootScreenHeightWithFull]\n );\n const completeImageSources = React.useMemo(\n () => extractCompleteImageSources(normalizedHtmlContent),\n [normalizedHtmlContent]\n );\n const htmlHeightMeta = React.useMemo(\n () => inspectSandboxPrimaryHeightFromHtml(htmlContent),\n [htmlContent]\n );\n const shouldStretchRootHeight = React.useMemo(\n () =>\n replaceRootScreenHeightWithFull && htmlHeightMeta.hasFullViewportHeight,\n [htmlHeightMeta.hasFullViewportHeight, replaceRootScreenHeightWithFull]\n );\n const [renderHtmlContent, setRenderHtmlContent] = useState(\n normalizedHtmlContent\n );\n const prevIncomingHtmlRef = useRef(normalizedHtmlContent);\n const pendingHtmlRef = useRef(normalizedHtmlContent);\n const deferRenderTimerRef = useRef<number | null>(null);\n const initialPaintFrameRef = useRef<number | null>(null);\n const initialPaintCommitFrameRef = useRef<number | null>(null);\n const imagePreloadRequestIdRef = useRef(0);\n\n const emitSandboxInteraction = useCallback((eventType: string) => {\n if (typeof window === \"undefined\") {\n return;\n }\n const now = Date.now();\n if (\n now - lastSandboxInteractionTimeRef.current <\n SANDBOX_INTERACTION_THROTTLE_MS\n ) {\n return;\n }\n lastSandboxInteractionTimeRef.current = now;\n window.postMessage(\n {\n source: SANDBOX_INTERACTION_MESSAGE_SOURCE,\n type: SANDBOX_INTERACTION_MESSAGE_TYPE,\n eventType,\n },\n window.location.origin\n );\n }, []);\n\n const clearDeferredRenderTimer = () => {\n if (deferRenderTimerRef.current === null) return;\n window.clearTimeout(deferRenderTimerRef.current);\n deferRenderTimerRef.current = null;\n };\n\n const clearInitialPaintFrames = () => {\n if (initialPaintFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintFrameRef.current);\n initialPaintFrameRef.current = null;\n }\n if (initialPaintCommitFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintCommitFrameRef.current);\n initialPaintCommitFrameRef.current = null;\n }\n };\n\n useEffect(\n () => () => {\n clearDeferredRenderTimer();\n clearInitialPaintFrames();\n },\n []\n );\n\n useEffect(() => {\n void preloadSandboxImages(completeImageSources);\n }, [completeImageSources]);\n\n useEffect(() => {\n const prevIncomingHtml = prevIncomingHtmlRef.current;\n prevIncomingHtmlRef.current = normalizedHtmlContent;\n\n const isAppendOnlyStream =\n !!prevIncomingHtml &&\n normalizedHtmlContent.length > prevIncomingHtml.length &&\n normalizedHtmlContent.startsWith(prevIncomingHtml);\n const containsCompleteImage = COMPLETE_IMAGE_TAG_PATTERN.test(\n normalizedHtmlContent\n );\n const hasPendingImagePreload =\n isAppendOnlyStream &&\n containsCompleteImage &&\n completeImageSources.some(\n (source) => !SANDBOX_IMAGE_READY_CACHE.has(source)\n );\n const shouldDeferRender = isAppendOnlyStream && containsCompleteImage;\n\n pendingHtmlRef.current = normalizedHtmlContent;\n clearDeferredRenderTimer();\n\n if (hasPendingImagePreload) {\n const requestId = imagePreloadRequestIdRef.current + 1;\n imagePreloadRequestIdRef.current = requestId;\n\n void preloadSandboxImages(completeImageSources).then(() => {\n if (imagePreloadRequestIdRef.current !== requestId) {\n return;\n }\n\n setRenderHtmlContent(pendingHtmlRef.current);\n });\n return;\n }\n\n if (!shouldDeferRender) {\n setRenderHtmlContent(normalizedHtmlContent);\n return;\n }\n\n deferRenderTimerRef.current = window.setTimeout(() => {\n setRenderHtmlContent(pendingHtmlRef.current);\n deferRenderTimerRef.current = null;\n }, POST_IMAGE_STREAM_DEBOUNCE_MS);\n }, [completeImageSources, normalizedHtmlContent]);\n\n const rootViewportHeightCss = React.useMemo(\n () =>\n inspectSandboxPrimaryHeightFromHtml(renderHtmlContent).viewportHeightCss,\n [renderHtmlContent]\n );\n const hasRootVhHeight = Boolean(rootViewportHeightCss);\n const sandboxViewportHeight =\n isBlackboardMode && type === \"sandbox\"\n ? shouldStretchRootHeight\n ? \"100%\"\n : (rootViewportHeightCss ?? `${height}px`)\n : undefined;\n const shouldShowHtmlFallbackWhilePreparingSandbox = false;\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = normalizedHtmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && normalizedHtmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = normalizedHtmlContent;\n }, [mode, normalizedHtmlContent]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return undefined;\n\n const doc = iframe.contentDocument;\n if (!doc) return undefined;\n\n doc.open();\n doc.write(`<!DOCTYPE html>\n<html${mode === \"blackboard\" ? ' style=\"height: 100%;\"' : \"\"}>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <style>\n :root { color-scheme: light; }\n html, body, #root { width: 100%; height: 100%; }\n html, body { margin: 0; padding: 0; overflow: auto; }\n *, *::before, *::after { box-sizing: border-box; }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n\n // Force iframe theme to stay in light mode regardless of host OS preference.\n doc.documentElement.setAttribute(\"data-theme\", \"light\");\n doc.documentElement.style.colorScheme = \"light\";\n doc.body?.style.setProperty(\"color-scheme\", \"light\");\n\n docRef.current = doc;\n\n const shouldBridgeSandboxInteraction =\n isBlackboardMode && type === \"sandbox\";\n const handleSandboxPointerDown = () =>\n emitSandboxInteraction(\"pointerdown\");\n const handleSandboxMouseDown = () => emitSandboxInteraction(\"mousedown\");\n const handleSandboxTouchStart = () => emitSandboxInteraction(\"touchstart\");\n\n if (shouldBridgeSandboxInteraction) {\n doc.addEventListener(\"pointerdown\", handleSandboxPointerDown, true);\n doc.addEventListener(\"mousedown\", handleSandboxMouseDown, true);\n doc.addEventListener(\"touchstart\", handleSandboxTouchStart, true);\n }\n\n const rootEl = doc.getElementById(\"root\");\n if (!rootEl) return undefined;\n\n const root = createRoot(rootEl);\n rootRef.current = root;\n let isDestroyed = false;\n\n const parseExplicitHeight = (\n value: string,\n parentViewportHeight: number\n ) => {\n const normalized = value.trim().toLowerCase();\n if (!normalized) return null;\n const numeric = Number.parseFloat(normalized);\n if (Number.isNaN(numeric)) return null;\n if (/(dvh|svh|lvh|vh)$/i.test(normalized)) {\n return (numeric / 100) * parentViewportHeight;\n }\n if (normalized.endsWith(\"px\") || /^[0-9.]+$/.test(normalized)) {\n return numeric;\n }\n return null;\n };\n const parseTailwindHeightClass = (\n className: string,\n parentViewportHeight: number\n ) => {\n if (!className.trim()) return null;\n const viewportHeightCss =\n extractViewportHeightFromTailwindClass(className);\n if (viewportHeightCss) {\n return parseExplicitHeight(viewportHeightCss, parentViewportHeight);\n }\n const normalizedTokens = normalizeTailwindHeightTokens(className);\n const arbitraryToken = normalizedTokens.find((token) =>\n /^h-\\[[0-9.]+px\\]$/i.test(token)\n );\n if (!arbitraryToken) return null;\n const matched = arbitraryToken.match(/^h-\\[([0-9.]+)px\\]$/i);\n if (!matched) return null;\n const numeric = Number.parseFloat(matched[1]);\n if (Number.isNaN(numeric)) return null;\n return numeric;\n };\n\n const resolveExplicitHeight = () => {\n if (!iframeRef.current || !doc.body) return null;\n const parentViewportHeight =\n iframeRef.current.ownerDocument?.documentElement?.clientHeight ||\n window.innerHeight;\n const { viewportHeightCss } = inspectSandboxPrimaryHeight(doc.body);\n const parsed = viewportHeightCss\n ? parseExplicitHeight(viewportHeightCss, parentViewportHeight)\n : null;\n\n if (parsed !== null) {\n return Math.ceil(parsed);\n }\n\n const wrapper = doc.body.querySelector(\n \".sandbox-wrapper\"\n ) as HTMLElement | null;\n const target = wrapper?.querySelector(\n \".sandbox-container > *\"\n ) as HTMLElement | null;\n\n if (!target) return null;\n\n const heightValue = target.style.height || target.getAttribute(\"height\");\n const explicitPixelHeight = heightValue\n ? parseExplicitHeight(heightValue, parentViewportHeight)\n : null;\n\n if (explicitPixelHeight !== null) {\n return Math.ceil(explicitPixelHeight);\n }\n\n const classHeight = parseTailwindHeightClass(\n target.getAttribute(\"class\") || \"\",\n parentViewportHeight\n );\n\n return classHeight !== null ? Math.ceil(classHeight) : null;\n };\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n const bodyRect = doc.body.getBoundingClientRect();\n const htmlRect = doc.documentElement?.getBoundingClientRect();\n const bodyHeight = bodyRect.height;\n const htmlHeight = htmlRect?.height || 0;\n const contentHeight = Math.max(bodyHeight, htmlHeight);\n const explicitHeight = resolveExplicitHeight();\n const nextHeight = Math.max(\n 200,\n explicitHeight ?? Math.ceil(contentHeight)\n );\n setHeight(nextHeight);\n };\n const scheduleHeightUpdate = () => {\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n updateHeight();\n });\n };\n updateHeightRef.current = scheduleHeightUpdate;\n\n updateHeight();\n scheduleHeightUpdate();\n\n if (!shouldInjectSandboxVendor) {\n setIsSandboxVendorReady(true);\n } else {\n // Inject Tailwind/DaisyUI/GSAP before rendering sandbox content to avoid FOUC.\n loadBlackboardVendorOnDemandWithMetrics()\n .then((inject) => {\n if (isDestroyed) return;\n inject(doc);\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n setIsSandboxVendorReady(true);\n scheduleHeightUpdate();\n });\n })\n .catch(() => {\n if (isDestroyed) return;\n setIsSandboxVendorReady(true);\n scheduleHeightUpdate();\n });\n }\n\n const resizeObserver = new ResizeObserver(() => updateHeight());\n resizeObserver.observe(doc.body);\n if (rootEl) {\n resizeObserver.observe(rootEl);\n }\n\n return () => {\n isDestroyed = true;\n resizeObserver.disconnect();\n if (shouldBridgeSandboxInteraction) {\n doc.removeEventListener(\"pointerdown\", handleSandboxPointerDown, true);\n doc.removeEventListener(\"mousedown\", handleSandboxMouseDown, true);\n doc.removeEventListener(\"touchstart\", handleSandboxTouchStart, true);\n }\n // Defer unmount to avoid React warning when parent is mid-render\n setTimeout(() => {\n root.unmount();\n rootRef.current = null;\n docRef.current = null;\n updateHeightRef.current = () => {};\n }, 0);\n };\n }, []);\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(Boolean(document.fullscreenElement));\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n }, []);\n\n const toggleFullscreen = () => {\n const target = containerRef.current || iframeRef.current;\n if (!target) return;\n if (document.fullscreenElement) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n if (target.requestFullscreen) {\n target.requestFullscreen().catch(() => {});\n }\n };\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n root.render(\n <SandboxApp\n html={renderHtmlContent}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n fullScreenButtonText={fullScreenButtonText}\n hideFullScreen={hideFullScreen}\n resetToken={resetToken}\n hasRootVhHeight={hasRootVhHeight}\n mode={mode}\n stretchRootHeight={shouldStretchRootHeight}\n />\n );\n\n initialPaintFrameRef.current = window.requestAnimationFrame(() => {\n updateHeightRef.current?.();\n initialPaintFrameRef.current = null;\n });\n }, [\n renderHtmlContent,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken,\n mode,\n ]);\n const containerClassName = [\n \"w-full relative content-render-iframe-sandbox\",\n isBlackboardMode\n ? \"h-full overflow-auto flex flex-col\"\n : \"aspect-[16/9] overflow-hidden flex items-center justify-center\",\n ]\n .filter(Boolean)\n .join(\" \");\n\n const shouldShowSandboxLoading = false;\n\n return (\n <div\n ref={containerRef}\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className={containerClassName}\n style={\n sandboxViewportHeight\n ? {\n height: sandboxViewportHeight,\n minHeight: sandboxViewportHeight,\n }\n : undefined\n }\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n className={\n \"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer\"\n }\n >\n {isFullscreen ? \"退出全屏\" : fullScreenButtonText || \"全屏浏览\"}\n </button>\n )}\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <div\n onMouseDown={() => emitSandboxInteraction(\"mousedown\")}\n onPointerDown={() => emitSandboxInteraction(\"pointerdown\")}\n onTouchStart={() => emitSandboxInteraction(\"touchstart\")}\n >\n <ContentRender content={content} />\n </div>\n ) : (\n <>\n {shouldShowHtmlFallbackWhilePreparingSandbox ? (\n <div\n aria-hidden\n className=\"absolute inset-0 z-10 overflow-hidden\"\n style={{\n height: sandboxViewportHeight ?? \"100%\",\n minHeight: sandboxViewportHeight,\n }}\n >\n <div\n className=\"h-full w-full\"\n dangerouslySetInnerHTML={{ __html: renderHtmlContent }}\n />\n </div>\n ) : null}\n <iframe\n ref={iframeRef}\n sandbox=\"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox\"\n allow=\"fullscreen\"\n allowFullScreen\n className={[className, \"w-full h-full mx-auto my-auto block\"]\n .filter(Boolean)\n .join(\" \")}\n style={{\n height: sandboxViewportHeight ?? \"100%\",\n minHeight: sandboxViewportHeight,\n margin: \"auto\",\n visibility: \"visible\",\n }}\n />\n {shouldShowSandboxLoading ? (\n <div className=\"pointer-events-none absolute inset-0 z-20 flex items-center justify-center\">\n <Loader2\n aria-label={loadingText || \"Preparing sandbox styles\"}\n className=\"text-primary h-7 w-7 animate-spin\"\n />\n </div>\n ) : null}\n </>\n )}\n </div>\n );\n};\n\nexport default IframeSandbox;\n"],"names":["blackboardVendorPromise","loadBlackboardVendor","m","loadBlackboardVendorOnDemandWithMetrics","loadStart","startedAt","inject","error","COMPLETE_IMAGE_TAG_PATTERN","POST_IMAGE_STREAM_DEBOUNCE_MS","SANDBOX_INTERACTION_THROTTLE_MS","COMPLETE_IMAGE_SOURCE_PATTERN","SANDBOX_IMAGE_PRELOAD_CACHE","SANDBOX_IMAGE_READY_CACHE","extractCompleteImageSources","html","matches","match","src","preloadSandboxImage","cached","nextPromise","resolve","image","settleWhenRenderable","preloadSandboxImages","sources","source","normalizeTailwindHeightTokens","className","token","parseViewportHeightCss","value","normalized","matched","extractViewportHeightFromTailwindClass","normalizedTokens","arbitraryToken","SANDBOX_IGNORED_TAG_NAMES","isSandboxRenderableElement","element","getFirstRenderableElementChild","root","node","getInspectableSandboxElementChain","chain","current","childElements","extractViewportHeightFromElement","heightAttrValue","attrViewportHeight","styleHeightValue","styleViewportHeight","isFullViewportHeightCss","inspectSandboxPrimaryHeight","inspectableElements","viewportHeightCss","hasFullViewportHeight","elementViewportHeight","inspectRootHeightFromHtmlString","attrs","classAttrValue","inspectSandboxPrimaryHeightFromHtml","template","replaceRootScreenHeightToken","segments","replaceRootScreenHeightWithFullClass","enabled","tagStart","classMatch","nextClassName","IframeSandbox","content","type","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","hideFullScreen","mode","replaceRootScreenHeightWithFull","containerRef","useRef","iframeRef","rootRef","docRef","updateHeightRef","height","setHeight","useState","lastSandboxInteractionTimeRef","resetToken","setResetToken","isFullscreen","setIsFullscreen","setIsSandboxVendorReady","shouldInjectSandboxVendor","isBlackboardMode","prevHtmlRef","htmlContent","React","sandboxSegments","splitContentSegments","seg","normalizedHtmlContent","completeImageSources","htmlHeightMeta","shouldStretchRootHeight","renderHtmlContent","setRenderHtmlContent","prevIncomingHtmlRef","pendingHtmlRef","deferRenderTimerRef","initialPaintFrameRef","initialPaintCommitFrameRef","imagePreloadRequestIdRef","emitSandboxInteraction","useCallback","eventType","now","SANDBOX_INTERACTION_MESSAGE_SOURCE","SANDBOX_INTERACTION_MESSAGE_TYPE","clearDeferredRenderTimer","clearInitialPaintFrames","useEffect","prevIncomingHtml","isAppendOnlyStream","containsCompleteImage","hasPendingImagePreload","shouldDeferRender","requestId","rootViewportHeightCss","hasRootVhHeight","sandboxViewportHeight","prev","iframe","doc","shouldBridgeSandboxInteraction","handleSandboxPointerDown","handleSandboxMouseDown","handleSandboxTouchStart","rootEl","createRoot","isDestroyed","parseExplicitHeight","parentViewportHeight","numeric","parseTailwindHeightClass","resolveExplicitHeight","parsed","target","heightValue","explicitPixelHeight","classHeight","updateHeight","bodyRect","htmlRect","bodyHeight","htmlHeight","contentHeight","explicitHeight","nextHeight","scheduleHeightUpdate","resizeObserver","onFullscreenChange","toggleFullscreen","jsx","SandboxApp","containerClassName","jsxs","ContentRender","Fragment"],"mappings":"uXAeA,IAAIA,EAAqE,KAEzE,MAAMC,GAAuB,KACtBD,IACHA,EAA0B,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,4BAAqB,CAAA,EAAE,KACrDE,GAAMA,EAAE,yBAAA,GAINF,GAGL,OAAO,OAAW,KAEfC,GAAA,EAGP,MAAME,GAA0C,IAAM,CACpD,MAAMC,EAAY,YAAY,IAAA,EACxBC,EAAY,IAAI,KAAA,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AAAA,kBAAAA,KAAC,MAAA,CACC,IAAKxF,GACL,eAAcmD,GAAkB,OAAS,QACzC,UAAWoC,GACX,MACEnC,EACI,CACE,OAAQA,EACR,UAAWA,CAAA,EAEb,OAGL,SAAA,CAAA,CAACvD,GACAwF,EAAAA,kBAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAASD,GACT,UACE,qFAGD,SAAAxE,GAAe,OAAShB,GAAwB,MAAA,CAAA,EAGpDE,IAAS,cAAgBN,IAAS,WACjC6F,EAAAA,kBAAAA,IAAC,MAAA,CACC,YAAa,IAAMlD,EAAuB,WAAW,EACrD,cAAe,IAAMA,EAAuB,aAAa,EACzD,aAAc,IAAMA,EAAuB,YAAY,EAEvD,SAAAkD,EAAAA,kBAAAA,IAACI,YAAc,QAAAlG,CAAA,CAAkB,CAAA,CAAA,EAGnCiG,EAAAA,kBAAAA,KAAAE,6BAAA,CACG,SAAA,CAcG,KACJL,EAAAA,kBAAAA,IAAC,SAAA,CACC,IAAKnF,EACL,QAAQ,8EACR,MAAM,aACN,gBAAe,GACf,UAAW,CAACtD,EAAW,qCAAqC,EACzD,OAAO,OAAO,EACd,KAAK,GAAG,EACX,MAAO,CACL,OAAQwG,GAAyB,OACjC,UAAWA,EACX,OAAQ,OACR,WAAY,SAAA,CACd,CAAA,EASE,IAAA,CAAA,CACN,CAAA,CAAA,CAAA,CAIR"}
@@ -1,16 +1,18 @@
1
1
  import { j as w } from "../../_virtual/jsx-runtime.es.js";
2
- import C, { useRef as d, useState as F, useCallback as _e, useEffect as S } from "react";
3
- import { createRoot as Fe } from "react-dom/client";
4
- import Ve from "./SandboxApp.es.js";
5
- import { splitContentSegments as Pe } from "./utils/split-content.es.js";
6
- import Oe from "./ContentRender.es.js";
7
- import { SANDBOX_INTERACTION_MESSAGE_TYPE as De, SANDBOX_INTERACTION_MESSAGE_SOURCE as ke } from "../../lib/sandboxInteraction.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
8
  let te = null;
9
- const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
9
+ const be = () => (te || (te = import("./blackboard-vendor.es.js").then(
10
10
  (e) => e.injectBlackboardLibraries
11
- )), te), Be = () => {
11
+ )), te);
12
+ typeof window < "u" && be();
13
+ const Be = () => {
12
14
  const e = performance.now(), t = (/* @__PURE__ */ new Date()).toISOString();
13
- return console.log("[IframeSandbox][SandboxLoad] start", { startedAt: t }), Le().then((n) => (console.log("[IframeSandbox][SandboxLoad] done", {
15
+ return console.log("[IframeSandbox][SandboxLoad] start", { startedAt: t }), be().then((n) => (console.log("[IframeSandbox][SandboxLoad] done", {
14
16
  startedAt: t,
15
17
  endedAt: (/* @__PURE__ */ new Date()).toISOString(),
16
18
  durationMs: Number((performance.now() - e).toFixed(2))
@@ -55,14 +57,14 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
55
57
  }, o.src = e, o.complete && o.naturalWidth > 0 && l();
56
58
  });
57
59
  return fe.set(e, n), n;
58
- }, ge = (e = []) => Promise.allSettled(e.map((t) => Xe(t))), be = (e) => e.split(/\s+/).filter(Boolean).map((t) => t.split(":").pop() || t), j = (e) => {
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) => {
59
61
  const t = e.trim().toLowerCase();
60
62
  if (!t) return null;
61
63
  const n = t.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);
62
64
  return n ? `${n[1]}${n[2].toLowerCase()}` : null;
63
65
  }, ne = (e) => {
64
66
  if (!e.trim()) return null;
65
- const t = be(e);
67
+ const t = we(e);
66
68
  if (t.includes("h-screen") || t.includes("h-dvh") || t.includes("min-h-screen") || t.includes("min-h-dvh"))
67
69
  return "100dvh";
68
70
  if (t.includes("h-svh") || t.includes("min-h-svh"))
@@ -85,15 +87,15 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
85
87
  "style",
86
88
  "template",
87
89
  "title"
88
- ]), we = (e) => !Ue.has(e.tagName.toLowerCase()), We = (e) => Array.from(e.childNodes).find(
89
- (t) => t.nodeType === Node.ELEMENT_NODE && we(t)
90
+ ]), ve = (e) => !Ue.has(e.tagName.toLowerCase()), We = (e) => Array.from(e.childNodes).find(
91
+ (t) => t.nodeType === Node.ELEMENT_NODE && ve(t)
90
92
  ) || null, Ye = (e) => {
91
93
  const t = [];
92
94
  let n = We(e);
93
95
  for (; n; ) {
94
96
  t.push(n);
95
97
  const s = Array.from(n.children).filter(
96
- (o) => we(o)
98
+ (o) => ve(o)
97
99
  );
98
100
  if (s.length !== 1)
99
101
  break;
@@ -108,12 +110,12 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
108
110
  return o || ne(
109
111
  e.getAttribute("class") || ""
110
112
  );
111
- }, ve = (e) => e === "100vh" || e === "100dvh" || e === "100svh" || e === "100lvh", xe = (e) => {
113
+ }, xe = (e) => e === "100vh" || e === "100dvh" || e === "100svh" || e === "100lvh", Ee = (e) => {
112
114
  const t = Ye(e);
113
115
  let n = null, s = !1;
114
116
  return t.forEach((o) => {
115
117
  const l = Ze(o);
116
- !n && l && (n = l), ve(l) && (s = !0);
118
+ !n && l && (n = l), xe(l) && (s = !0);
117
119
  }), {
118
120
  viewportHeightCss: n,
119
121
  hasFullViewportHeight: s
@@ -130,7 +132,7 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
130
132
  )?.[1], R = s.match(/\bclass\s*=\s*["']([^"']+)["']/i)?.[1], h = (o ? j(o) : null) || (m ? j(m) : null) || (R ? ne(R) : null);
131
133
  return {
132
134
  viewportHeightCss: h,
133
- hasFullViewportHeight: ve(h)
135
+ hasFullViewportHeight: xe(h)
134
136
  };
135
137
  }, pe = (e) => {
136
138
  const t = e.trim();
@@ -142,7 +144,7 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
142
144
  if (typeof document > "u")
143
145
  return Je(t);
144
146
  const n = document.createElement("template");
145
- return n.innerHTML = t, xe(n.content);
147
+ return n.innerHTML = t, Ee(n.content);
146
148
  }, Ke = (e) => e.split(/\s+/).filter(Boolean).map((t) => {
147
149
  const n = t.split(":");
148
150
  return n[n.length - 1] !== "h-screen" && n[n.length - 1] !== "min-h-screen" ? t : (n[n.length - 1] = "h-full", n.join(":"));
@@ -171,8 +173,8 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
171
173
  replaceRootScreenHeightWithFull: V = !1
172
174
  }) => {
173
175
  const re = d(null), y = d(null), z = d(null), oe = d(null), G = d(() => {
174
- }), [Ee, He] = F(480), se = d(0), [ie, Se] = F(0), [ye, Ae] = F(!1), [, q] = F(!0), Ce = t === "sandbox", X = h === "blackboard", U = d(""), P = C.useMemo(() => {
175
- const r = Pe(e).filter((p) => p.type === "sandbox");
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");
176
178
  return (h === "blackboard" ? r[r.length - 1]?.value || "" : r.map((p) => p.value).join(`
177
179
  `)) || "";
178
180
  }, [e, h]), c = C.useMemo(
@@ -192,26 +194,26 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
192
194
  [le.hasFullViewportHeight, V]
193
195
  ), [O, W] = F(
194
196
  c
195
- ), ae = d(c), Y = d(c), M = d(null), T = d(null), Z = d(null), J = d(0), A = _e((i) => {
197
+ ), ae = d(c), Y = d(c), M = d(null), T = d(null), Z = d(null), J = d(0), A = Fe((i) => {
196
198
  if (typeof window > "u")
197
199
  return;
198
200
  const r = Date.now();
199
201
  r - se.current < ze || (se.current = r, window.postMessage(
200
202
  {
201
- source: ke,
202
- type: De,
203
+ source: Le,
204
+ type: ke,
203
205
  eventType: i
204
206
  },
205
207
  window.location.origin
206
208
  ));
207
209
  }, []), ue = () => {
208
210
  M.current !== null && (window.clearTimeout(M.current), M.current = null);
209
- }, Re = () => {
211
+ }, Ie = () => {
210
212
  T.current !== null && (window.cancelAnimationFrame(T.current), T.current = null), Z.current !== null && (window.cancelAnimationFrame(Z.current), Z.current = null);
211
213
  };
212
214
  S(
213
215
  () => () => {
214
- ue(), Re();
216
+ ue(), Ie();
215
217
  },
216
218
  []
217
219
  ), S(() => {
@@ -242,14 +244,14 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
242
244
  const de = C.useMemo(
243
245
  () => pe(O).viewportHeightCss,
244
246
  [O]
245
- ), he = !!de, N = X && t === "sandbox" ? ce ? "100%" : de ?? `${Ee}px` : void 0;
247
+ ), he = !!de, N = X && t === "sandbox" ? ce ? "100%" : de ?? `${He}px` : void 0;
246
248
  S(() => {
247
249
  if (h !== "blackboard") {
248
250
  U.current = c;
249
251
  return;
250
252
  }
251
253
  const i = U.current;
252
- !(i && c.startsWith(i)) && i && Se((g) => g + 1), U.current = c;
254
+ !(i && c.startsWith(i)) && i && ye((g) => g + 1), U.current = c;
253
255
  }, [h, c]), S(() => {
254
256
  const i = y.current;
255
257
  if (!i) return;
@@ -275,7 +277,7 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
275
277
  g && (r.addEventListener("pointerdown", p, !0), r.addEventListener("mousedown", D, !0), r.addEventListener("touchstart", v, !0));
276
278
  const k = r.getElementById("root");
277
279
  if (!k) return;
278
- const me = Fe(k);
280
+ const me = Ve(k);
279
281
  z.current = me;
280
282
  let _ = !1;
281
283
  const K = (a, b) => {
@@ -283,12 +285,12 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
283
285
  if (!u) return null;
284
286
  const x = Number.parseFloat(u);
285
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;
286
- }, Te = (a, b) => {
288
+ }, Ne = (a, b) => {
287
289
  if (!a.trim()) return null;
288
290
  const u = ne(a);
289
291
  if (u)
290
292
  return K(u, b);
291
- const f = be(a).find(
293
+ const f = we(a).find(
292
294
  (B) => /^h-\[[0-9.]+px\]$/i.test(B)
293
295
  );
294
296
  if (!f) return null;
@@ -296,9 +298,9 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
296
298
  if (!E) return null;
297
299
  const H = Number.parseFloat(E[1]);
298
300
  return Number.isNaN(H) ? null : H;
299
- }, Ne = () => {
301
+ }, _e = () => {
300
302
  if (!y.current || !r.body) return null;
301
- const a = y.current.ownerDocument?.documentElement?.clientHeight || window.innerHeight, { viewportHeightCss: b } = xe(r.body), u = b ? K(b, a) : null;
303
+ const a = y.current.ownerDocument?.documentElement?.clientHeight || window.innerHeight, { viewportHeightCss: b } = Ee(r.body), u = b ? K(b, a) : null;
302
304
  if (u !== null)
303
305
  return Math.ceil(u);
304
306
  const f = r.body.querySelector(
@@ -310,24 +312,24 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
310
312
  const E = f.style.height || f.getAttribute("height"), H = E ? K(E, a) : null;
311
313
  if (H !== null)
312
314
  return Math.ceil(H);
313
- const B = Te(
315
+ const B = Ne(
314
316
  f.getAttribute("class") || "",
315
317
  a
316
318
  );
317
319
  return B !== null ? Math.ceil(B) : null;
318
320
  }, Q = () => {
319
321
  if (!y.current || !r.body) return;
320
- const a = r.body.getBoundingClientRect(), b = r.documentElement?.getBoundingClientRect(), u = a.height, x = b?.height || 0, f = Math.max(u, x), E = Ne(), H = Math.max(
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(
321
323
  200,
322
324
  E ?? Math.ceil(f)
323
325
  );
324
- He(H);
326
+ Se(H);
325
327
  }, L = () => {
326
328
  requestAnimationFrame(() => {
327
329
  _ || Q();
328
330
  });
329
331
  };
330
- G.current = L, Q(), L(), Ce ? Be().then((a) => {
332
+ G.current = L, Q(), L(), Re ? Be().then((a) => {
331
333
  _ || (a(r), requestAnimationFrame(() => {
332
334
  _ || (q(!0), L());
333
335
  }));
@@ -343,11 +345,11 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
343
345
  };
344
346
  }, []), S(() => {
345
347
  const i = () => {
346
- Ae(!!document.fullscreenElement);
348
+ Ce(!!document.fullscreenElement);
347
349
  };
348
350
  return document.addEventListener("fullscreenchange", i), () => document.removeEventListener("fullscreenchange", i);
349
351
  }, []);
350
- const Ie = () => {
352
+ const Me = () => {
351
353
  const i = re.current || y.current;
352
354
  if (i) {
353
355
  if (document.fullscreenElement) {
@@ -363,7 +365,7 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
363
365
  const i = z.current;
364
366
  i && (i.render(
365
367
  /* @__PURE__ */ w.jsx(
366
- Ve,
368
+ Pe,
367
369
  {
368
370
  html: O,
369
371
  loadingText: s,
@@ -389,7 +391,7 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
389
391
  ie,
390
392
  h
391
393
  ]);
392
- const Me = [
394
+ const Te = [
393
395
  "w-full relative content-render-iframe-sandbox",
394
396
  X ? "h-full overflow-auto flex flex-col" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
395
397
  ].filter(Boolean).join(" ");
@@ -398,7 +400,7 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
398
400
  {
399
401
  ref: re,
400
402
  "data-root-vh": he ? "true" : "false",
401
- className: Me,
403
+ className: Te,
402
404
  style: N ? {
403
405
  height: N,
404
406
  minHeight: N
@@ -408,9 +410,9 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
408
410
  "button",
409
411
  {
410
412
  type: "button",
411
- onClick: Ie,
413
+ onClick: Me,
412
414
  className: "absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",
413
- children: ye ? "退出全屏" : m || "全屏浏览"
415
+ children: Ae ? "退出全屏" : m || "全屏浏览"
414
416
  }
415
417
  ),
416
418
  h === "blackboard" && t === "markdown" ? /* @__PURE__ */ w.jsx(
@@ -419,7 +421,7 @@ const Le = () => (te || (te = import("./blackboard-vendor.es.js").then(
419
421
  onMouseDown: () => A("mousedown"),
420
422
  onPointerDown: () => A("pointerdown"),
421
423
  onTouchStart: () => A("touchstart"),
422
- children: /* @__PURE__ */ w.jsx(Oe, { content: e })
424
+ children: /* @__PURE__ */ w.jsx(De, { content: e })
423
425
  }
424
426
  ) : /* @__PURE__ */ w.jsxs(w.Fragment, { children: [
425
427
  null,