markdown-flow-ui 0.1.106-beta.3 → 0.1.106-beta.5

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 (40) hide show
  1. package/dist/_virtual/index.cjs4.js +1 -1
  2. package/dist/_virtual/index.cjs5.js +1 -1
  3. package/dist/_virtual/index.cjs6.js +1 -1
  4. package/dist/_virtual/index.cjs7.js +1 -1
  5. package/dist/_virtual/index.es4.js +4 -4
  6. package/dist/_virtual/index.es5.js +4 -4
  7. package/dist/_virtual/index.es6.js +2 -5
  8. package/dist/_virtual/index.es6.js.map +1 -1
  9. package/dist/_virtual/index.es7.js +5 -2
  10. package/dist/_virtual/index.es7.js.map +1 -1
  11. package/dist/components/ContentRender/SandboxApp.cjs.js +3 -2
  12. package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
  13. package/dist/components/ContentRender/SandboxApp.es.js +13 -12
  14. package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
  15. package/dist/components/Slide/Slide.cjs.js +1 -1
  16. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  17. package/dist/components/Slide/Slide.es.js +57 -58
  18. package/dist/components/Slide/Slide.es.js.map +1 -1
  19. package/dist/components/Slide/utils/mobileScreenMode.cjs.js +1 -1
  20. package/dist/components/Slide/utils/mobileScreenMode.cjs.js.map +1 -1
  21. package/dist/components/Slide/utils/mobileScreenMode.d.ts +1 -1
  22. package/dist/components/Slide/utils/mobileScreenMode.es.js +9 -10
  23. package/dist/components/Slide/utils/mobileScreenMode.es.js.map +1 -1
  24. package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
  25. package/dist/components/ui/inputGroup/textarea.es.js +1 -1
  26. package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.cjs.js +1 -1
  27. package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
  28. package/dist/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
  29. package/dist/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
  30. package/dist/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
  31. package/dist/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
  32. package/dist/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
  33. package/dist/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
  34. package/dist/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
  35. package/dist/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
  36. package/dist/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.cjs.js +1 -1
  37. package/dist/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.es.js +1 -1
  38. package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
  39. package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
  40. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),r=require("../markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js");var s=r.__require();const t=e.getDefaultExportFromCjs(s);exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),r=require("../markdown-flow-ui/node_modules/.pnpm/style-to-js@1.1.18/node_modules/style-to-js/cjs/index.cjs.js");var t=r.__require();const o=e.getDefaultExportFromCjs(t);exports.default=o;
2
2
  //# sourceMappingURL=index.cjs4.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),r=require("../markdown-flow-ui/node_modules/.pnpm/style-to-js@1.1.18/node_modules/style-to-js/cjs/index.cjs.js");var t=r.__require();const o=e.getDefaultExportFromCjs(t);exports.default=o;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),t=require("../markdown-flow-ui/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.cjs.js");var r=t.__require();const o=e.getDefaultExportFromCjs(r);exports.default=o;
2
2
  //# sourceMappingURL=index.cjs5.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),t=require("../markdown-flow-ui/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.cjs.js");var r=t.__require();const o=e.getDefaultExportFromCjs(r);exports.default=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={};exports.__exports=e;
2
2
  //# sourceMappingURL=index.cjs6.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={};exports.__exports=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),r=require("../markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js");var s=r.__require();const t=e.getDefaultExportFromCjs(s);exports.default=t;
2
2
  //# sourceMappingURL=index.cjs7.js.map
@@ -1,8 +1,8 @@
1
1
  import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
2
- import { __require as s } from "../markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js";
3
- var e = s();
4
- const t = /* @__PURE__ */ r(e);
2
+ import { __require as o } from "../markdown-flow-ui/node_modules/.pnpm/style-to-js@1.1.18/node_modules/style-to-js/cjs/index.es.js";
3
+ var t = o();
4
+ const a = /* @__PURE__ */ r(t);
5
5
  export {
6
- t as default
6
+ a as default
7
7
  };
8
8
  //# sourceMappingURL=index.es4.js.map
@@ -1,7 +1,7 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
2
- import { __require as o } from "../markdown-flow-ui/node_modules/.pnpm/style-to-js@1.1.18/node_modules/style-to-js/cjs/index.es.js";
3
- var t = o();
4
- const a = /* @__PURE__ */ r(t);
1
+ import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.es.js";
2
+ import { __require as r } from "../markdown-flow-ui/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.es.js";
3
+ var t = r();
4
+ const a = /* @__PURE__ */ e(t);
5
5
  export {
6
6
  a as default
7
7
  };
@@ -1,8 +1,5 @@
1
- import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.es.js";
2
- import { __require as r } from "../markdown-flow-ui/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.es.js";
3
- var t = r();
4
- const a = /* @__PURE__ */ e(t);
1
+ var r = {};
5
2
  export {
6
- a as default
3
+ r as __exports
7
4
  };
8
5
  //# sourceMappingURL=index.es6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +1,8 @@
1
- var r = {};
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
2
+ import { __require as s } from "../markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js";
3
+ var e = s();
4
+ const t = /* @__PURE__ */ r(e);
2
5
  export {
3
- r as __exports
6
+ t as default
4
7
  };
5
8
  //# sourceMappingURL=index.es7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("../../_virtual/jsx-runtime.cjs.js"),s=require("react"),P=require("../ui/loading-overlay-card.cjs.js"),Q=["src","srcset","sizes","alt","class","width","height","style","loading","decoding","crossorigin","referrerpolicy","fetchpriority"],F=a=>Q.map(t=>`${t}:${a.getAttribute(t)||""}`).join("|"),J=a=>{const t=new Map;return a.querySelectorAll("img").forEach(l=>{const c=l,r=F(c),f=t.get(r)||[];f.push(c),t.set(r,f)}),t},X=(a,t)=>{const l=Array.from(a.attributes),c=new Set(l.map(r=>r.name));Array.from(t.attributes).forEach(r=>{c.has(r.name)||t.removeAttribute(r.name)}),l.forEach(r=>{t.setAttribute(r.name,r.value)})},Y=(a,t)=>{t.size&&a.querySelectorAll("img").forEach(l=>{const c=l,r=F(c),f=t.get(r),h=f?.shift();h&&(X(c,h),c.replaceWith(h),f&&f.length===0&&t.delete(r))})},Z=({html:a,styleLoadingText:t,scriptLoadingText:l,resetToken:c=0,mode:r="content",hasRootVhHeight:f=!1,stretchRootHeight:h=!1})=>{const C=s.useRef(null),[z,w]=s.useState(!1),[H,j]=s.useState(!1),I=s.useRef([]),N=s.useRef([]),q=s.useRef(0),_=s.useRef(0),g=s.useRef(null),x=s.useRef(null),b=s.useRef(!1),E=s.useRef(!1),G=s.useRef(!1),L=s.useRef(c),O=200,d=n=>{n.current&&(clearTimeout(n.current),n.current=null)},k=(n,i,u,T)=>{const p=performance.now()-u.current,S=Math.max(0,O-p);d(i),i.current=window.setTimeout(()=>{n(!1),T?.(),i.current=null},S)};s.useEffect(()=>{const n=C.current?.ownerDocument;if(!n)return;const i="sandbox-spinner-style";let u=n.getElementById(i);u||(u=n.createElement("style"),u.id=i,n.head?.appendChild(u)),u.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("../../_virtual/jsx-runtime.cjs.js"),s=require("react"),P=require("../ui/loading-overlay-card.cjs.js"),Q=["src","srcset","sizes","alt","class","width","height","style","loading","decoding","crossorigin","referrerpolicy","fetchpriority"],F=a=>Q.map(t=>`${t}:${a.getAttribute(t)||""}`).join("|"),J=a=>{const t=new Map;return a.querySelectorAll("img").forEach(u=>{const c=u,r=F(c),f=t.get(r)||[];f.push(c),t.set(r,f)}),t},X=(a,t)=>{const u=Array.from(a.attributes),c=new Set(u.map(r=>r.name));Array.from(t.attributes).forEach(r=>{c.has(r.name)||t.removeAttribute(r.name)}),u.forEach(r=>{t.setAttribute(r.name,r.value)})},Y=(a,t)=>{t.size&&a.querySelectorAll("img").forEach(u=>{const c=u,r=F(c),f=t.get(r),h=f?.shift();h&&(X(c,h),c.replaceWith(h),f&&f.length===0&&t.delete(r))})},Z=({html:a,styleLoadingText:t,scriptLoadingText:u,resetToken:c=0,mode:r="content",hasRootVhHeight:f=!1,stretchRootHeight:h=!1})=>{const A=s.useRef(null),[z,C]=s.useState(!1),[H,j]=s.useState(!1),I=s.useRef([]),N=s.useRef([]),q=s.useRef(0),_=s.useRef(0),g=s.useRef(null),x=s.useRef(null),b=s.useRef(!1),v=s.useRef(!1),G=s.useRef(!1),L=s.useRef(c),O=200,d=n=>{n.current&&(clearTimeout(n.current),n.current=null)},k=(n,i,l,T)=>{const p=performance.now()-l.current,S=Math.max(0,O-p);d(i),i.current=window.setTimeout(()=>{n(!1),T?.(),i.current=null},S)};s.useEffect(()=>{const n=A.current?.ownerDocument;if(!n)return;const i="sandbox-spinner-style";let l=n.getElementById(i);l||(l=n.createElement("style"),l.id=i,n.head?.appendChild(l)),l.textContent=`
2
2
  .sandbox-wrapper { align-items: center; }
3
3
  .sandbox-container { position: relative; width: 100%; }
4
4
  .sandbox-container svg,
@@ -6,5 +6,6 @@
6
6
  .justify-\\[safe_center\\]{
7
7
  justify-content: safe center;
8
8
  }
9
- `},[]),s.useEffect(()=>{c!==L.current&&(G.current=!1,L.current=c),d(g),d(x),b.current=!1,E.current=!1;const n=C.current;if(!n)return;const i=n.ownerDocument,u=i?.body;if(!u)return;const T=J(n);I.current.forEach(e=>e.remove()),I.current=[],N.current.forEach(e=>e.remove()),N.current=[],w(!1),j(!1);const p=i.createElement("div");p.innerHTML=a;const S=(a.match(/<script[\s>]/gi)||[]).length,V=(a.match(/<\/script>/gi)||[]).length,$=S>0&&S===V,y=[];Array.from(p.querySelectorAll("style, script")).forEach(e=>{if(e.tagName.toLowerCase()==="style"){const o=i.createElement("style");o.textContent=e.textContent||"",Array.from(e.attributes).forEach(m=>{o.setAttribute(m.name,m.value)}),y.push(o)}else{const o=i.createElement("script");Array.from(e.attributes).forEach(m=>{o.setAttribute(m.name,m.value)}),o.textContent=e.textContent||"",y.push(o)}e.remove()}),Y(p,T);const B=y.some(e=>e.tagName.toLowerCase()==="style"),D=y.some(e=>e.tagName.toLowerCase()==="script");B&&(b.current=!0,q.current=performance.now(),d(g),w(!0)),D&&(E.current=!0,_.current=performance.now(),d(x),j(!0)),!!p.firstElementChild&&(G.current=!0);const K=Array.from(p.childNodes);n.replaceChildren(...K),y.forEach(e=>{if(e.tagName.toLowerCase()==="style"){i.head?.appendChild(e),I.current.push(e);return}if($){const o=e,m=o.textContent||"";if(!o.src)try{new Function(m)}catch{o.remove();return}try{u.appendChild(o),N.current.push(o)}catch{o.remove()}}else e.remove()}),requestAnimationFrame(()=>{B&&k(w,g,q,()=>{b.current=!1}),D&&k(j,x,_,()=>{E.current=!1})})},[a,c]),s.useEffect(()=>()=>{d(g),d(x)},[]);const R=H||E.current?l||"Building scripts cache...":z||b.current?t||"Building styles...":null,M=r==="blackboard",v=M&&h,W={position:"relative",width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:v?"flex-start":M?"space-around":"flex-start"},U={pointerEvents:R?"none":void 0,margin:M?void 0:"auto 0",width:"100%",height:v?"100%":void 0,minHeight:v?0:void 0,flex:v?"1 1 auto":void 0};return A.jsxRuntimeExports.jsxs("div",{"data-root-vh":f?"true":"false",className:"sandbox-wrapper",style:W,"aria-busy":!!R,children:[A.jsxRuntimeExports.jsx("div",{ref:C,className:"sandbox-container",style:U}),R&&A.jsxRuntimeExports.jsx("div",{style:{position:"absolute",inset:0,zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:A.jsxRuntimeExports.jsx(P.default,{message:R})})]})};exports.default=Z;
9
+ .overflow-y-auto { overflow-y: visible !important; }
10
+ `},[]),s.useEffect(()=>{c!==L.current&&(G.current=!1,L.current=c),d(g),d(x),b.current=!1,v.current=!1;const n=A.current;if(!n)return;const i=n.ownerDocument,l=i?.body;if(!l)return;const T=J(n);I.current.forEach(e=>e.remove()),I.current=[],N.current.forEach(e=>e.remove()),N.current=[],C(!1),j(!1);const p=i.createElement("div");p.innerHTML=a;const S=(a.match(/<script[\s>]/gi)||[]).length,V=(a.match(/<\/script>/gi)||[]).length,$=S>0&&S===V,y=[];Array.from(p.querySelectorAll("style, script")).forEach(e=>{if(e.tagName.toLowerCase()==="style"){const o=i.createElement("style");o.textContent=e.textContent||"",Array.from(e.attributes).forEach(m=>{o.setAttribute(m.name,m.value)}),y.push(o)}else{const o=i.createElement("script");Array.from(e.attributes).forEach(m=>{o.setAttribute(m.name,m.value)}),o.textContent=e.textContent||"",y.push(o)}e.remove()}),Y(p,T);const B=y.some(e=>e.tagName.toLowerCase()==="style"),D=y.some(e=>e.tagName.toLowerCase()==="script");B&&(b.current=!0,q.current=performance.now(),d(g),C(!0)),D&&(v.current=!0,_.current=performance.now(),d(x),j(!0)),!!p.firstElementChild&&(G.current=!0);const K=Array.from(p.childNodes);n.replaceChildren(...K),y.forEach(e=>{if(e.tagName.toLowerCase()==="style"){i.head?.appendChild(e),I.current.push(e);return}if($){const o=e,m=o.textContent||"";if(!o.src)try{new Function(m)}catch{o.remove();return}try{l.appendChild(o),N.current.push(o)}catch{o.remove()}}else e.remove()}),requestAnimationFrame(()=>{B&&k(C,g,q,()=>{b.current=!1}),D&&k(j,x,_,()=>{v.current=!1})})},[a,c]),s.useEffect(()=>()=>{d(g),d(x)},[]);const E=H||v.current?u||"Building scripts cache...":z||b.current?t||"Building styles...":null,M=r==="blackboard",R=M&&h,W={position:"relative",width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:R?"flex-start":M?"space-around":"flex-start"},U={pointerEvents:E?"none":void 0,margin:M?void 0:"auto 0",width:"100%",height:R?"100%":void 0,minHeight:R?0:void 0,flex:R?"1 1 auto":void 0};return w.jsxRuntimeExports.jsxs("div",{"data-root-vh":f?"true":"false",className:"sandbox-wrapper",style:W,"aria-busy":!!E,children:[w.jsxRuntimeExports.jsx("div",{ref:A,className:"sandbox-container",style:U}),E&&w.jsxRuntimeExports.jsx("div",{style:{position:"absolute",inset:0,zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:w.jsxRuntimeExports.jsx(P.default,{message:E})})]})};exports.default=Z;
10
11
  //# sourceMappingURL=SandboxApp.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SandboxApp.cjs.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\n\nexport interface SandboxAppProps {\n html: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n mode?: \"content\" | \"blackboard\";\n hasRootVhHeight?: boolean;\n stretchRootHeight?: boolean;\n}\n\nconst IMAGE_REUSE_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"alt\",\n \"class\",\n \"width\",\n \"height\",\n \"style\",\n \"loading\",\n \"decoding\",\n \"crossorigin\",\n \"referrerpolicy\",\n \"fetchpriority\",\n];\n\nconst getImageReuseKey = (image: HTMLImageElement) =>\n IMAGE_REUSE_ATTRIBUTES.map(\n (attribute) => `${attribute}:${image.getAttribute(attribute) || \"\"}`\n ).join(\"|\");\n\nconst collectReusableImages = (root: ParentNode) => {\n const imageMap = new Map<string, HTMLImageElement[]>();\n root.querySelectorAll(\"img\").forEach((node) => {\n const image = node as HTMLImageElement;\n const key = getImageReuseKey(image);\n const bucket = imageMap.get(key) || [];\n bucket.push(image);\n imageMap.set(key, bucket);\n });\n return imageMap;\n};\n\nconst syncImageAttributes = (\n sourceImage: HTMLImageElement,\n targetImage: HTMLImageElement\n) => {\n const sourceAttributes = Array.from(sourceImage.attributes);\n const sourceAttributeNames = new Set(\n sourceAttributes.map((attribute) => attribute.name)\n );\n\n Array.from(targetImage.attributes).forEach((attribute) => {\n if (!sourceAttributeNames.has(attribute.name)) {\n targetImage.removeAttribute(attribute.name);\n }\n });\n\n sourceAttributes.forEach((attribute) => {\n targetImage.setAttribute(attribute.name, attribute.value);\n });\n};\n\nconst reuseRenderedImages = (\n root: ParentNode,\n imageMap: Map<string, HTMLImageElement[]>\n) => {\n if (!imageMap.size) return;\n\n root.querySelectorAll(\"img\").forEach((node) => {\n const nextImage = node as HTMLImageElement;\n const key = getImageReuseKey(nextImage);\n const bucket = imageMap.get(key);\n const preservedImage = bucket?.shift();\n if (!preservedImage) return;\n\n syncImageAttributes(nextImage, preservedImage);\n nextImage.replaceWith(preservedImage);\n\n if (bucket && bucket.length === 0) {\n imageMap.delete(key);\n }\n });\n};\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n mode = \"content\",\n hasRootVhHeight = false,\n stretchRootHeight = false,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n doc.head?.appendChild(styleEl);\n }\n styleEl.textContent = `\n .sandbox-wrapper { align-items: center; }\n .sandbox-container { position: relative; width: 100%; }\n .sandbox-container svg,\n .sandbox-container img { display: block; margin-left: auto; margin-right: auto; }\n .justify-\\\\[safe_center\\\\]{\n justify-content: safe center;\n }\n `;\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n const reusableImages = collectReusableImages(container);\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n // const hasRenderedBefore = hasRenderedContentRef.current;\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n const wrapper = doc.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n reuseRenderedImages(wrapper, reusableImages);\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n const contentNodes = Array.from(wrapper.childNodes);\n container.replaceChildren(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n const overlayMessage = (() => {\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n return null;\n })();\n\n const isBlackboard = mode === \"blackboard\";\n const shouldStretchRootHeight = isBlackboard && stretchRootHeight;\n const sandboxWrapperStyle: React.CSSProperties = {\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n // Keep blackboard scroll behavior while centering content in non-blackboard mode\n justifyContent: shouldStretchRootHeight\n ? \"flex-start\"\n : isBlackboard\n ? \"space-around\"\n : \"flex-start\",\n };\n const sandboxContainerStyle: React.CSSProperties = {\n pointerEvents: overlayMessage ? \"none\" : undefined,\n margin: isBlackboard ? undefined : \"auto 0\",\n width: \"100%\",\n height: shouldStretchRootHeight ? \"100%\" : undefined,\n minHeight: shouldStretchRootHeight ? 0 : undefined,\n flex: shouldStretchRootHeight ? \"1 1 auto\" : undefined,\n };\n\n return (\n <div\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className=\"sandbox-wrapper\"\n style={sandboxWrapperStyle}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n className=\"sandbox-container\"\n style={sandboxContainerStyle}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n zIndex: 20,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <LoadingOverlayCard message={overlayMessage} />\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["IMAGE_REUSE_ATTRIBUTES","getImageReuseKey","image","attribute","collectReusableImages","root","imageMap","node","key","bucket","syncImageAttributes","sourceImage","targetImage","sourceAttributes","sourceAttributeNames","reuseRenderedImages","nextImage","preservedImage","SandboxApp","html","styleLoadingText","scriptLoadingText","resetToken","mode","hasRootVhHeight","stretchRootHeight","containerRef","useRef","isGeneratingStyles","setIsGeneratingStyles","useState","isGeneratingScripts","setIsGeneratingScripts","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","reusableImages","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","contentNodes","scriptNode","scriptText","overlayMessage","isBlackboard","shouldStretchRootHeight","sandboxWrapperStyle","sandboxContainerStyle","jsxs","jsx","LoadingOverlayCard"],"mappings":"mOAaMA,EAAyB,CAC7B,MACA,SACA,QACA,MACA,QACA,QACA,SACA,QACA,UACA,WACA,cACA,iBACA,eACF,EAEMC,EAAoBC,GACxBF,EAAuB,IACpBG,GAAc,GAAGA,CAAS,IAAID,EAAM,aAAaC,CAAS,GAAK,EAAE,EACpE,EAAE,KAAK,GAAG,EAENC,EAAyBC,GAAqB,CAClD,MAAMC,MAAe,IACrB,OAAAD,EAAK,iBAAiB,KAAK,EAAE,QAASE,GAAS,CAC7C,MAAML,EAAQK,EACRC,EAAMP,EAAiBC,CAAK,EAC5BO,EAASH,EAAS,IAAIE,CAAG,GAAK,CAAA,EACpCC,EAAO,KAAKP,CAAK,EACjBI,EAAS,IAAIE,EAAKC,CAAM,CAC1B,CAAC,EACMH,CACT,EAEMI,EAAsB,CAC1BC,EACAC,IACG,CACH,MAAMC,EAAmB,MAAM,KAAKF,EAAY,UAAU,EACpDG,EAAuB,IAAI,IAC/BD,EAAiB,IAAKV,GAAcA,EAAU,IAAI,CAAA,EAGpD,MAAM,KAAKS,EAAY,UAAU,EAAE,QAAST,GAAc,CACnDW,EAAqB,IAAIX,EAAU,IAAI,GAC1CS,EAAY,gBAAgBT,EAAU,IAAI,CAE9C,CAAC,EAEDU,EAAiB,QAASV,GAAc,CACtCS,EAAY,aAAaT,EAAU,KAAMA,EAAU,KAAK,CAC1D,CAAC,CACH,EAEMY,EAAsB,CA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AM,EAAAA,kBAAAA,IAAC,MAAA,CACC,IAAKpD,EACL,UAAU,oBACV,MAAOkD,CAAA,CAAA,EAERJ,GACCM,EAAAA,kBAAAA,IAAC,MAAA,CACC,MAAO,CACL,SAAU,WACV,MAAO,EACP,OAAQ,GACR,QAAS,OACT,WAAY,SACZ,eAAgB,SAChB,cAAe,MAAA,EAGjB,SAAAA,EAAAA,kBAAAA,IAACC,EAAAA,QAAA,CAAmB,QAASP,CAAA,CAAgB,CAAA,CAAA,CAC/C,CAAA,CAAA,CAIR"}
1
+ {"version":3,"file":"SandboxApp.cjs.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\n\nexport interface SandboxAppProps {\n html: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n mode?: \"content\" | \"blackboard\";\n hasRootVhHeight?: boolean;\n stretchRootHeight?: boolean;\n}\n\nconst IMAGE_REUSE_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"alt\",\n \"class\",\n \"width\",\n \"height\",\n \"style\",\n \"loading\",\n \"decoding\",\n \"crossorigin\",\n \"referrerpolicy\",\n \"fetchpriority\",\n];\n\nconst getImageReuseKey = (image: HTMLImageElement) =>\n IMAGE_REUSE_ATTRIBUTES.map(\n (attribute) => `${attribute}:${image.getAttribute(attribute) || \"\"}`\n ).join(\"|\");\n\nconst collectReusableImages = (root: ParentNode) => {\n const imageMap = new Map<string, HTMLImageElement[]>();\n root.querySelectorAll(\"img\").forEach((node) => {\n const image = node as HTMLImageElement;\n const key = getImageReuseKey(image);\n const bucket = imageMap.get(key) || [];\n bucket.push(image);\n imageMap.set(key, bucket);\n });\n return imageMap;\n};\n\nconst syncImageAttributes = (\n sourceImage: HTMLImageElement,\n targetImage: HTMLImageElement\n) => {\n const sourceAttributes = Array.from(sourceImage.attributes);\n const sourceAttributeNames = new Set(\n sourceAttributes.map((attribute) => attribute.name)\n );\n\n Array.from(targetImage.attributes).forEach((attribute) => {\n if (!sourceAttributeNames.has(attribute.name)) {\n targetImage.removeAttribute(attribute.name);\n }\n });\n\n sourceAttributes.forEach((attribute) => {\n targetImage.setAttribute(attribute.name, attribute.value);\n });\n};\n\nconst reuseRenderedImages = (\n root: ParentNode,\n imageMap: Map<string, HTMLImageElement[]>\n) => {\n if (!imageMap.size) return;\n\n root.querySelectorAll(\"img\").forEach((node) => {\n const nextImage = node as HTMLImageElement;\n const key = getImageReuseKey(nextImage);\n const bucket = imageMap.get(key);\n const preservedImage = bucket?.shift();\n if (!preservedImage) return;\n\n syncImageAttributes(nextImage, preservedImage);\n nextImage.replaceWith(preservedImage);\n\n if (bucket && bucket.length === 0) {\n imageMap.delete(key);\n }\n });\n};\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n mode = \"content\",\n hasRootVhHeight = false,\n stretchRootHeight = false,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n doc.head?.appendChild(styleEl);\n }\n styleEl.textContent = `\n .sandbox-wrapper { align-items: center; }\n .sandbox-container { position: relative; width: 100%; }\n .sandbox-container svg,\n .sandbox-container img { display: block; margin-left: auto; margin-right: auto; }\n .justify-\\\\[safe_center\\\\]{\n justify-content: safe center;\n }\n .overflow-y-auto { overflow-y: visible !important; }\n `;\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n const reusableImages = collectReusableImages(container);\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n // const hasRenderedBefore = hasRenderedContentRef.current;\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n const wrapper = doc.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n reuseRenderedImages(wrapper, reusableImages);\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n const contentNodes = Array.from(wrapper.childNodes);\n container.replaceChildren(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n const overlayMessage = (() => {\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n return null;\n })();\n\n const isBlackboard = mode === \"blackboard\";\n const shouldStretchRootHeight = isBlackboard && stretchRootHeight;\n const sandboxWrapperStyle: React.CSSProperties = {\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n // Keep blackboard scroll behavior while centering content in non-blackboard mode\n justifyContent: shouldStretchRootHeight\n ? \"flex-start\"\n : isBlackboard\n ? \"space-around\"\n : \"flex-start\",\n };\n const sandboxContainerStyle: React.CSSProperties = {\n pointerEvents: overlayMessage ? \"none\" : undefined,\n margin: isBlackboard ? undefined : \"auto 0\",\n width: \"100%\",\n height: shouldStretchRootHeight ? \"100%\" : undefined,\n minHeight: shouldStretchRootHeight ? 0 : undefined,\n flex: shouldStretchRootHeight ? \"1 1 auto\" : undefined,\n };\n\n return (\n <div\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className=\"sandbox-wrapper\"\n style={sandboxWrapperStyle}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n className=\"sandbox-container\"\n style={sandboxContainerStyle}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n zIndex: 20,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <LoadingOverlayCard message={overlayMessage} />\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["IMAGE_REUSE_ATTRIBUTES","getImageReuseKey","image","attribute","collectReusableImages","root","imageMap","node","key","bucket","syncImageAttributes","sourceImage","targetImage","sourceAttributes","sourceAttributeNames","reuseRenderedImages","nextImage","preservedImage","SandboxApp","html","styleLoadingText","scriptLoadingText","resetToken","mode","hasRootVhHeight","stretchRootHeight","containerRef","useRef","isGeneratingStyles","setIsGeneratingStyles","useState","isGeneratingScripts","setIsGeneratingScripts","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","reusableImages","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","contentNodes","scriptNode","scriptText","overlayMessage","isBlackboard","shouldStretchRootHeight","sandboxWrapperStyle","sandboxContainerStyle","jsxs","jsx","LoadingOverlayCard"],"mappings":"mOAaMA,EAAyB,CAC7B,MACA,SACA,QACA,MACA,QACA,QACA,SACA,QACA,UACA,WACA,cACA,iBACA,eACF,EAEMC,EAAoBC,GACxBF,EAAuB,IACpBG,GAAc,GAAGA,CAAS,IAAID,EAAM,aAAaC,CAAS,GAAK,EAAE,EACpE,EAAE,KAAK,GAAG,EAENC,EAAyBC,GAAqB,CAClD,MAAMC,MAAe,IACrB,OAAAD,EAAK,iBAAiB,KAAK,EAAE,QAASE,GAAS,CAC7C,MAAML,EAAQK,EACRC,EAAMP,EAAiBC,CAAK,EAC5BO,EAASH,EAAS,IAAIE,CAAG,GAAK,CAAA,EACpCC,EAAO,KAAKP,CAAK,EACjBI,EAAS,IAAIE,EAAKC,CAAM,CAC1B,CAAC,EACMH,CACT,EAEMI,EAAsB,CAC1BC,EACAC,IACG,CACH,MAAMC,EAAmB,MAAM,KAAKF,EAAY,UA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,aACAD,EACE,eACA,YAAA,EAEFG,EAA6C,CACjD,cAAeJ,EAAiB,OAAS,OACzC,OAAQC,EAAe,OAAY,SACnC,MAAO,OACP,OAAQC,EAA0B,OAAS,OAC3C,UAAWA,EAA0B,EAAI,OACzC,KAAMA,EAA0B,WAAa,MAAA,EAG/C,OACEG,EAAAA,kBAAAA,KAAC,MAAA,CACC,eAAcrD,EAAkB,OAAS,QACzC,UAAU,kBACV,MAAOmD,EACP,YAAW,CAAC,CAACH,EAEb,SAAA,CAAAM,EAAAA,kBAAAA,IAAC,MAAA,CACC,IAAKpD,EACL,UAAU,oBACV,MAAOkD,CAAA,CAAA,EAERJ,GACCM,EAAAA,kBAAAA,IAAC,MAAA,CACC,MAAO,CACL,SAAU,WACV,MAAO,EACP,OAAQ,GACR,QAAS,OACT,WAAY,SACZ,eAAgB,SAChB,cAAe,MAAA,EAGjB,SAAAA,EAAAA,kBAAAA,IAACC,EAAAA,QAAA,CAAmB,QAASP,CAAA,CAAgB,CAAA,CAAA,CAC/C,CAAA,CAAA,CAIR"}
@@ -1,4 +1,4 @@
1
- import { j as C } from "../../_virtual/jsx-runtime.es.js";
1
+ import { j as A } from "../../_virtual/jsx-runtime.es.js";
2
2
  import { useRef as i, useState as z, useEffect as M } from "react";
3
3
  import P from "../ui/loading-overlay-card.es.js";
4
4
  const X = [
@@ -46,16 +46,16 @@ const X = [
46
46
  hasRootVhHeight: f = !1,
47
47
  stretchRootHeight: h = !1
48
48
  }) => {
49
- const w = i(null), [W, R] = z(!1), [O, I] = z(!1), N = i([]), j = i([]), G = i(0), k = i(0), g = i(null), x = i(null), b = i(!1), v = i(!1), B = i(!1), D = i(o), U = 200, d = (s) => {
49
+ const C = i(null), [W, R] = z(!1), [O, I] = z(!1), N = i([]), j = i([]), G = i(0), k = i(0), g = i(null), x = i(null), b = i(!1), v = i(!1), B = i(!1), D = i(o), U = 200, d = (s) => {
50
50
  s.current && (clearTimeout(s.current), s.current = null);
51
51
  }, _ = (s, a, l, L) => {
52
- const m = performance.now() - l.current, A = Math.max(0, U - m);
52
+ const m = performance.now() - l.current, w = Math.max(0, U - m);
53
53
  d(a), a.current = window.setTimeout(() => {
54
54
  s(!1), L?.(), a.current = null;
55
- }, A);
55
+ }, w);
56
56
  };
57
57
  M(() => {
58
- const s = w.current?.ownerDocument;
58
+ const s = C.current?.ownerDocument;
59
59
  if (!s) return;
60
60
  const a = "sandbox-spinner-style";
61
61
  let l = s.getElementById(a);
@@ -67,10 +67,11 @@ const X = [
67
67
  .justify-\\[safe_center\\]{
68
68
  justify-content: safe center;
69
69
  }
70
+ .overflow-y-auto { overflow-y: visible !important; }
70
71
  `;
71
72
  }, []), M(() => {
72
73
  o !== D.current && (B.current = !1, D.current = o), d(g), d(x), b.current = !1, v.current = !1;
73
- const s = w.current;
74
+ const s = C.current;
74
75
  if (!s) return;
75
76
  const a = s.ownerDocument, l = a?.body;
76
77
  if (!l) return;
@@ -78,7 +79,7 @@ const X = [
78
79
  N.current.forEach((e) => e.remove()), N.current = [], j.current.forEach((e) => e.remove()), j.current = [], R(!1), I(!1);
79
80
  const m = a.createElement("div");
80
81
  m.innerHTML = c;
81
- const A = (c.match(/<script[\s>]/gi) || []).length, K = (c.match(/<\/script>/gi) || []).length, Q = A > 0 && A === K, y = [];
82
+ const w = (c.match(/<script[\s>]/gi) || []).length, K = (c.match(/<\/script>/gi) || []).length, Q = w > 0 && w === K, y = [];
82
83
  Array.from(m.querySelectorAll("style, script")).forEach((e) => {
83
84
  if (e.tagName.toLowerCase() === "style") {
84
85
  const n = a.createElement("style");
@@ -160,7 +161,7 @@ const X = [
160
161
  minHeight: S ? 0 : void 0,
161
162
  flex: S ? "1 1 auto" : void 0
162
163
  };
163
- return /* @__PURE__ */ C.jsxs(
164
+ return /* @__PURE__ */ A.jsxs(
164
165
  "div",
165
166
  {
166
167
  "data-root-vh": f ? "true" : "false",
@@ -168,15 +169,15 @@ const X = [
168
169
  style: V,
169
170
  "aria-busy": !!E,
170
171
  children: [
171
- /* @__PURE__ */ C.jsx(
172
+ /* @__PURE__ */ A.jsx(
172
173
  "div",
173
174
  {
174
- ref: w,
175
+ ref: C,
175
176
  className: "sandbox-container",
176
177
  style: $
177
178
  }
178
179
  ),
179
- E && /* @__PURE__ */ C.jsx(
180
+ E && /* @__PURE__ */ A.jsx(
180
181
  "div",
181
182
  {
182
183
  style: {
@@ -188,7 +189,7 @@ const X = [
188
189
  justifyContent: "center",
189
190
  pointerEvents: "none"
190
191
  },
191
- children: /* @__PURE__ */ C.jsx(P, { message: E })
192
+ children: /* @__PURE__ */ A.jsx(P, { message: E })
192
193
  }
193
194
  )
194
195
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"SandboxApp.es.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\n\nexport interface SandboxAppProps {\n html: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n mode?: \"content\" | \"blackboard\";\n hasRootVhHeight?: boolean;\n stretchRootHeight?: boolean;\n}\n\nconst IMAGE_REUSE_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"alt\",\n \"class\",\n \"width\",\n \"height\",\n \"style\",\n \"loading\",\n \"decoding\",\n \"crossorigin\",\n \"referrerpolicy\",\n \"fetchpriority\",\n];\n\nconst getImageReuseKey = (image: HTMLImageElement) =>\n IMAGE_REUSE_ATTRIBUTES.map(\n (attribute) => `${attribute}:${image.getAttribute(attribute) || \"\"}`\n ).join(\"|\");\n\nconst collectReusableImages = (root: ParentNode) => {\n const imageMap = new Map<string, HTMLImageElement[]>();\n root.querySelectorAll(\"img\").forEach((node) => {\n const image = node as HTMLImageElement;\n const key = getImageReuseKey(image);\n const bucket = imageMap.get(key) || [];\n bucket.push(image);\n imageMap.set(key, bucket);\n });\n return imageMap;\n};\n\nconst syncImageAttributes = (\n sourceImage: HTMLImageElement,\n targetImage: HTMLImageElement\n) => {\n const sourceAttributes = Array.from(sourceImage.attributes);\n const sourceAttributeNames = new Set(\n sourceAttributes.map((attribute) => attribute.name)\n );\n\n Array.from(targetImage.attributes).forEach((attribute) => {\n if (!sourceAttributeNames.has(attribute.name)) {\n targetImage.removeAttribute(attribute.name);\n }\n });\n\n sourceAttributes.forEach((attribute) => {\n targetImage.setAttribute(attribute.name, attribute.value);\n });\n};\n\nconst reuseRenderedImages = (\n root: ParentNode,\n imageMap: Map<string, HTMLImageElement[]>\n) => {\n if (!imageMap.size) return;\n\n root.querySelectorAll(\"img\").forEach((node) => {\n const nextImage = node as HTMLImageElement;\n const key = getImageReuseKey(nextImage);\n const bucket = imageMap.get(key);\n const preservedImage = bucket?.shift();\n if (!preservedImage) return;\n\n syncImageAttributes(nextImage, preservedImage);\n nextImage.replaceWith(preservedImage);\n\n if (bucket && bucket.length === 0) {\n imageMap.delete(key);\n }\n });\n};\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n mode = \"content\",\n hasRootVhHeight = false,\n stretchRootHeight = false,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n doc.head?.appendChild(styleEl);\n }\n styleEl.textContent = `\n .sandbox-wrapper { align-items: center; }\n .sandbox-container { position: relative; width: 100%; }\n .sandbox-container svg,\n .sandbox-container img { display: block; margin-left: auto; margin-right: auto; }\n .justify-\\\\[safe_center\\\\]{\n justify-content: safe center;\n }\n `;\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n const reusableImages = collectReusableImages(container);\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n // const hasRenderedBefore = hasRenderedContentRef.current;\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n const wrapper = doc.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n reuseRenderedImages(wrapper, reusableImages);\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n const contentNodes = Array.from(wrapper.childNodes);\n container.replaceChildren(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n const overlayMessage = (() => {\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n return null;\n })();\n\n const isBlackboard = mode === \"blackboard\";\n const shouldStretchRootHeight = isBlackboard && stretchRootHeight;\n const sandboxWrapperStyle: React.CSSProperties = {\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n // Keep blackboard scroll behavior while centering content in non-blackboard mode\n justifyContent: shouldStretchRootHeight\n ? \"flex-start\"\n : isBlackboard\n ? \"space-around\"\n : \"flex-start\",\n };\n const sandboxContainerStyle: React.CSSProperties = {\n pointerEvents: overlayMessage ? \"none\" : undefined,\n margin: isBlackboard ? undefined : \"auto 0\",\n width: \"100%\",\n height: shouldStretchRootHeight ? \"100%\" : undefined,\n minHeight: shouldStretchRootHeight ? 0 : undefined,\n flex: shouldStretchRootHeight ? \"1 1 auto\" : undefined,\n };\n\n return (\n <div\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className=\"sandbox-wrapper\"\n style={sandboxWrapperStyle}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n className=\"sandbox-container\"\n style={sandboxContainerStyle}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n zIndex: 20,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <LoadingOverlayCard message={overlayMessage} />\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["IMAGE_REUSE_ATTRIBUTES","getImageReuseKey","image","attribute","collectReusableImages","root","imageMap","node","key","bucket","syncImageAttributes","sourceImage","targetImage","sourceAttributes","sourceAttributeNames","reuseRenderedImages","nextImage","preservedImage","SandboxApp","html","styleLoadingText","scriptLoadingText","resetToken","mode","hasRootVhHeight","stretchRootHeight","containerRef","useRef","isGeneratingStyles","setIsGeneratingStyles","useState","isGeneratingScripts","setIsGeneratingScripts","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","reusableImages","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","contentNodes","scriptNode","scriptText","overlayMessage","isBlackboard","shouldStretchRootHeight","sandboxWrapperStyle","sandboxContainerStyle","jsxs","jsx","LoadingOverlayCard"],"mappings":";;;AAaA,MAAMA,IAAyB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAmB,CAACC,MACxBF,EAAuB;AAAA,EACrB,CAACG,MAAc,GAAGA,CAAS,IAAID,EAAM,aAAaC,CAAS,KAAK,EAAE;AACpE,EAAE,KAAK,GAAG,GAENC,IAAwB,CAACC,MAAqB;AAClD,QAAMC,wBAAe,IAAA;AACrB,SAAAD,EAAK,iBAAiB,KAAK,EAAE,QAAQ,CAACE,MAAS;AAC7C,UAAML,IAAQK,GACRC,IAAMP,EAAiBC,CAAK,GAC5BO,IAASH,EAAS,IAAIE,CAAG,KAAK,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A,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,eAAe;AAAA,YAAA;AAAA,YAGjB,UAAAA,gBAAAA,EAAAA,IAACC,GAAA,EAAmB,SAASP,EAAA,CAAgB;AAAA,UAAA;AAAA,QAAA;AAAA,MAC/C;AAAA,IAAA;AAAA,EAAA;AAIR;"}
1
+ {"version":3,"file":"SandboxApp.es.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\n\nexport interface SandboxAppProps {\n html: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n mode?: \"content\" | \"blackboard\";\n hasRootVhHeight?: boolean;\n stretchRootHeight?: boolean;\n}\n\nconst IMAGE_REUSE_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"alt\",\n \"class\",\n \"width\",\n \"height\",\n \"style\",\n \"loading\",\n \"decoding\",\n \"crossorigin\",\n \"referrerpolicy\",\n \"fetchpriority\",\n];\n\nconst getImageReuseKey = (image: HTMLImageElement) =>\n IMAGE_REUSE_ATTRIBUTES.map(\n (attribute) => `${attribute}:${image.getAttribute(attribute) || \"\"}`\n ).join(\"|\");\n\nconst collectReusableImages = (root: ParentNode) => {\n const imageMap = new Map<string, HTMLImageElement[]>();\n root.querySelectorAll(\"img\").forEach((node) => {\n const image = node as HTMLImageElement;\n const key = getImageReuseKey(image);\n const bucket = imageMap.get(key) || [];\n bucket.push(image);\n imageMap.set(key, bucket);\n });\n return imageMap;\n};\n\nconst syncImageAttributes = (\n sourceImage: HTMLImageElement,\n targetImage: HTMLImageElement\n) => {\n const sourceAttributes = Array.from(sourceImage.attributes);\n const sourceAttributeNames = new Set(\n sourceAttributes.map((attribute) => attribute.name)\n );\n\n Array.from(targetImage.attributes).forEach((attribute) => {\n if (!sourceAttributeNames.has(attribute.name)) {\n targetImage.removeAttribute(attribute.name);\n }\n });\n\n sourceAttributes.forEach((attribute) => {\n targetImage.setAttribute(attribute.name, attribute.value);\n });\n};\n\nconst reuseRenderedImages = (\n root: ParentNode,\n imageMap: Map<string, HTMLImageElement[]>\n) => {\n if (!imageMap.size) return;\n\n root.querySelectorAll(\"img\").forEach((node) => {\n const nextImage = node as HTMLImageElement;\n const key = getImageReuseKey(nextImage);\n const bucket = imageMap.get(key);\n const preservedImage = bucket?.shift();\n if (!preservedImage) return;\n\n syncImageAttributes(nextImage, preservedImage);\n nextImage.replaceWith(preservedImage);\n\n if (bucket && bucket.length === 0) {\n imageMap.delete(key);\n }\n });\n};\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n mode = \"content\",\n hasRootVhHeight = false,\n stretchRootHeight = false,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n doc.head?.appendChild(styleEl);\n }\n styleEl.textContent = `\n .sandbox-wrapper { align-items: center; }\n .sandbox-container { position: relative; width: 100%; }\n .sandbox-container svg,\n .sandbox-container img { display: block; margin-left: auto; margin-right: auto; }\n .justify-\\\\[safe_center\\\\]{\n justify-content: safe center;\n }\n .overflow-y-auto { overflow-y: visible !important; }\n `;\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n const reusableImages = collectReusableImages(container);\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n // const hasRenderedBefore = hasRenderedContentRef.current;\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n const wrapper = doc.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n reuseRenderedImages(wrapper, reusableImages);\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n const contentNodes = Array.from(wrapper.childNodes);\n container.replaceChildren(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n const overlayMessage = (() => {\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n return null;\n })();\n\n const isBlackboard = mode === \"blackboard\";\n const shouldStretchRootHeight = isBlackboard && stretchRootHeight;\n const sandboxWrapperStyle: React.CSSProperties = {\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n // Keep blackboard scroll behavior while centering content in non-blackboard mode\n justifyContent: shouldStretchRootHeight\n ? \"flex-start\"\n : isBlackboard\n ? \"space-around\"\n : \"flex-start\",\n };\n const sandboxContainerStyle: React.CSSProperties = {\n pointerEvents: overlayMessage ? \"none\" : undefined,\n margin: isBlackboard ? undefined : \"auto 0\",\n width: \"100%\",\n height: shouldStretchRootHeight ? \"100%\" : undefined,\n minHeight: shouldStretchRootHeight ? 0 : undefined,\n flex: shouldStretchRootHeight ? \"1 1 auto\" : undefined,\n };\n\n return (\n <div\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className=\"sandbox-wrapper\"\n style={sandboxWrapperStyle}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n className=\"sandbox-container\"\n style={sandboxContainerStyle}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n zIndex: 20,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <LoadingOverlayCard message={overlayMessage} />\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["IMAGE_REUSE_ATTRIBUTES","getImageReuseKey","image","attribute","collectReusableImages","root","imageMap","node","key","bucket","syncImageAttributes","sourceImage","targetImage","sourceAttributes","sourceAttributeNames","reuseRenderedImages","nextImage","preservedImage","SandboxApp","html","styleLoadingText","scriptLoadingText","resetToken","mode","hasRootVhHeight","stretchRootHeight","containerRef","useRef","isGeneratingStyles","setIsGeneratingStyles","useState","isGeneratingScripts","setIsGeneratingScripts","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","reusableImages","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","contentNodes","scriptNode","scriptText","overlayMessage","isBlackboard","shouldStretchRootHeight","sandboxWrapperStyle","sandboxContainerStyle","jsxs","jsx","LoadingOverlayCard"],"mappings":";;;AAaA,MAAMA,IAAyB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAmB,CAACC,MACxBF,EAAuB;AAAA,EACrB,CAACG,MAAc,GAAGA,CAAS,IAAID,EAAM,aAAaC,CAAS,KAAK,EAAE;AACpE,EAAE,KAAK,GAAG,GAENC,IAAwB,CAACC,MAAqB;AAClD,QAAMC,wBAAe,IAAA;AACrB,SAAAD,EAAK,iBAAiB,KAAK,EAAE,QAAQ,CAACE,MAAS;AAC7C,UAAML,IAAQK,GACRC,IAAMP,EAAiBC,CAAK,GAC5BO,IAASH,EAAS,IAAIE,CAAG,KAAK,CAAA;AACpC,IAAAC,EAAO,KAAKP,CAAK,GACjBI,EAAS,IAAIE,GAAKC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A,cACV,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,eAAe;AAAA,YAAA;AAAA,YAGjB,UAAAA,gBAAAA,EAAAA,IAACC,GAAA,EAAmB,SAASP,EAAA,CAAgB;AAAA,UAAA;AAAA,QAAA;AAAA,MAC/C;AAAA,IAAA;AAAA,EAAA;AAIR;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),zt=require("../../lib/sandboxInteraction.cjs.js"),U=require("../../lib/utils.cjs.js"),Gt=require("../ui/loading-overlay-card.cjs.js"),Yt=require("../ContentRender/ContentRender.cjs.js"),it=require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");const ct=require("../../lib/interaction-defaults.cjs.js"),pe=require("../../lib/mobileDevice.cjs.js"),Xt=require("./Player.cjs.js"),Jt=require("./constants.cjs.js"),Qt=require("./SlideFullscreenHint.cjs.js"),Zt=require("./useSlide.cjs.js"),en=require("./useWakePlayerFromIframe.cjs.js"),Q=require("./utils/mobileScreenMode.cjs.js"),tn=require("./utils/interactionPlayback.cjs.js"),nn=require("./utils/playbackSequence.cjs.js"),at=require("./utils/playerCustomActions.cjs.js"),rn=require("./utils/playerToggleMode.cjs.js");;/* empty css */const sn=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/chevron-left.cjs.js"),on=2e3,dt=t.memo(({content:T,title:P,defaultButtonText:p,defaultInputText:W,defaultSelectedValues:h,confirmButtonText:F,copyButtonText:$,copiedButtonText:he,onSend:xe,readonly:q=!1})=>n.jsxRuntimeExports.jsxs("div",{className:"slide-player__interaction-card",children:[n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-header",children:n.jsxRuntimeExports.jsx("p",{className:"slide-player__interaction-title",children:P})}),n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-body",children:n.jsxRuntimeExports.jsx(Yt.default,{content:T,defaultButtonText:p,defaultInputText:W,defaultSelectedValues:h,confirmButtonText:F,copyButtonText:$,copiedButtonText:he,onSend:xe,readonly:q,enableTypewriter:!1,sandboxMode:"content"})}),n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-arrow"})]}));dt.displayName="InteractionOverlayCard";const ln=(T,P)=>T.length===P.length&&T.every((p,W)=>{const h=P[W];return p.sequence_number===h?.sequence_number&&p.type===h?.type&&p.content===h?.content}),un=({elementList:T=[],showPlayer:P=!0,playerAlwaysVisible:p=!1,playerClassName:W,fullscreenHeader:h,playerCustomActions:F,playerCustomActionPauseOnActive:$=!0,bufferingText:he="Buffering...",interactionTitle:xe,interactionTexts:q,playerTexts:je,playerAutoHideDelay:ve=3e3,markerAutoAdvanceDelay:ke=on,interactionDefaultValueOptions:Z,onSend:Te,onPlayerVisibilityChange:be,onMobileViewModeChange:Pe,onStepChange:Fe,className:ft,onPointerDown:qe,...mt})=>{const ee=t.useRef(null),Be=t.useRef(null),ge=t.useRef(null),Le=t.useRef(null),z=t.useRef(null),G=t.useRef(null),Y=t.useRef(null),Ne=t.useRef([]),te=t.useRef(!1),B=t.useRef(null),Ve=t.useRef(null),{currentElementList:y,stepElementLists:Oe,slideElementList:L,currentIndex:c,audioList:f,currentAudioSequenceIndexes:ne,currentStepHasSpeakableElement:x,currentInteractionElement:i,canGoPrev:pt,canGoNext:w,handlePrev:Ke,handleNext:I}=Zt.default(T),X=t.useMemo(()=>{if(!(c<0))return L[c]},[c,L]),ht=L.filter(e=>e.is_renderable!==!1).length===1,g=P&&(L.length>0||f.length>0||!!i),E=t.useMemo(()=>ne.map(e=>f[e]?.audioKey).filter(e=>!!e),[f,ne]),[De,re]=t.useState(!0),[se,J]=t.useState(!1),[Ee,He]=t.useState(!0),[m,N]=t.useState(null),[xt,v]=t.useState(!1),[A,Ue]=t.useState(!1),[Se,ye]=t.useState(!1),[s,oe]=t.useState(),[le,ue]=t.useState(!1),[vt,bt]=t.useState(!1),S=t.useMemo(()=>pe.isMobileDevice(),[]);console.log("navigator.userAgent",navigator.userAgent);const[ie,we]=t.useState(Q.DEFAULT_MOBILE_VIEW_MODE),[We,Re]=t.useState(!1),[ce,$e]=t.useState(()=>S?pe.isLandscapeViewport():!1),[gt,ae]=t.useState(!1),{effectiveMobileViewMode:M,isImmersiveMobileFullscreen:V,isNativeMobileFullscreen:ze,shouldRotateFullscreenViewport:Et}=t.useMemo(()=>Q.resolveMobileViewModeState({hasManualMobileViewMode:We,isMobileDevice:S,isViewportFullscreenPreferred:ce,mobileViewMode:ie}),[We,S,ce,ie]),Ge=t.useRef(M),_=g&&(p||De),St=V&&_,yt=V&&_,wt=V||ze,Rt=je?.fullscreenHintText??Jt.DEFAULT_SLIDE_PLAYER_TEXTS.fullscreenHintText,It=t.useCallback(e=>{Re(!0),we(e)},[]),Ye=t.useCallback(()=>{Re(!1),we(Q.DEFAULT_MOBILE_VIEW_MODE)},[]),At=t.useCallback(()=>{Ye(),h?.onBack?.()},[h,Ye]),Mt=t.useCallback(()=>{ae(!1)},[]),Xe=t.useCallback(e=>{ye(e)},[]),Je=t.useCallback(()=>{ye(e=>!e)},[]),{mountedStepStates:_t,currentMountedStateIndex:Ct}=t.useMemo(()=>{const e=[],r=new Map;return Oe.forEach((l,a)=>{const o=e.findIndex(u=>ln(u.elementList,l));if(o>=0){e[o]?.sourceStepIndexes.push(a),r.set(a,o);return}e.push({elementList:l,sourceStepIndexes:[a]}),r.set(a,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:c>=0?r.get(c)??-1:-1}},[c,Oe]),Qe=t.useMemo(()=>String(c),[c]),C=t.useMemo(()=>m?f.findIndex(e=>(e.audioKey??"")===m):-1,[f,m]),de=t.useMemo(()=>E[0]??"none",[E]),Ie=t.useMemo(()=>({currentElement:at.resolvePlayerCustomActionElement({currentAudioIndex:C,currentAudioSequenceIndexes:ne,audioList:f,currentInteractionElement:s,currentStepElement:X}),currentIndex:c,currentStepElement:X,isActive:Se,setActive:Xe,toggleActive:Je}),[s,f,C,ne,c,X,Se,Xe,Je]),Ae=t.useMemo(()=>at.getPlayerCustomActionCount(F,Ie),[Ie,F]),jt=t.useMemo(()=>({"--slide-player-custom-action-count":String(Ae),"--slide-player-mobile-control-count":String(Ae+4)}),[Ae]),Ze=E.length>0,et=t.useMemo(()=>i?`${i.sequence_number??"none"}:${String(i.content??"")}`:"none",[i]),Me=t.useMemo(()=>[Qe,et].join("|"),[et,Qe]),tt=!!t.useMemo(()=>!de||de==="none"?"":f.find(r=>r.audioKey===de)?.audioUrl?.trim()??"",[f,de]),j=$&&!!F&&Se,_e=t.useMemo(()=>rn.shouldUseAutoAdvanceToggle({canGoNext:w,currentAudioIndex:C,currentStepHasSpeakableElement:x,hasInteraction:!!i}),[w,C,i,x]),k=t.useCallback(()=>{z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),R=t.useCallback(()=>{Y.current!==null&&(window.clearTimeout(Y.current),Y.current=null)},[]),O=t.useCallback(()=>{G.current!==null&&(window.clearTimeout(G.current),G.current=null)},[]),K=t.useCallback(()=>{O(),R(),N(null),v(!1),Ue(!1),oe(void 0),ue(!1)},[O,R]),D=t.useCallback(()=>{const e=E[0];return e?(N(e),!0):!1},[E]),fe=t.useCallback(()=>{R(),ue(!1),!D()&&w&&I()},[w,R,I,D]),d=t.useCallback((e=se)=>{g&&(re(!0),k(),!(p||!e||ve<=0)&&(z.current=window.setTimeout(()=>{re(!1),z.current=null},ve)))},[k,se,p,ve,g]),Ce=!!(i?.readonly||i?.user_input?.trim()),H=!!i&&!Ce;t.useEffect(()=>{He(!0),$&&ye(!1)},[c,$]),t.useEffect(()=>()=>{O(),k(),R()},[O,R,k]),t.useEffect(()=>(be?.(_),()=>{be?.(!1)}),[be,_]),t.useEffect(()=>{S||ie===Q.DEFAULT_MOBILE_VIEW_MODE||(Re(!1),we(Q.DEFAULT_MOBILE_VIEW_MODE))},[S,ie]),t.useEffect(()=>{if(!S){$e(!1);return}const e=()=>{$e(pe.isLandscapeViewport())};return e(),pe.subscribeMobileDeviceChange(e)},[S]),t.useEffect(()=>{Pe?.(M)},[M,Pe]),t.useEffect(()=>{const l=Ge.current!=="fullscreen"&&M==="fullscreen"&&!ce;if(Ge.current=M,!S){ae(!1);return}if(l){ae(!0);return}M!=="fullscreen"&&ae(!1)},[M,S,ce]),t.useEffect(()=>{Fe?.(X,c)},[c,X,Fe]),t.useEffect(()=>{if(!g){k(),re(!1);return}if(p){k(),re(!0);return}se||d(!0)},[k,se,p,g,d]),t.useEffect(()=>{if(typeof window>"u")return;const e=r=>{r.origin===window.location.origin&&zt.isSandboxInteractionMessage(r.data)&&r.data.eventType==="click"&&g&&(J(!0),d(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[g,d]),en.default({sectionRef:ee,enabled:g,onWake:()=>{J(!0),d(!0)}}),t.useEffect(()=>{const{hasPlaybackContextChanged:e,shouldInitializeAudioSequence:r}=nn.getPlaybackSequenceTransition({previousResetKey:Ve.current,nextResetKey:Me,currentAudioKey:m,hasCompletedCurrentStepAudio:A});Ve.current=Me;const l=B.current===c&&!!i,a=tn.shouldPresentInteractionOverlay({hasInteraction:!!i,shouldBlockPlaybackForInteraction:H,shouldOpenInteractionOverlayAfterAudio:l,hasPlaybackContextChanged:e,hasResolvedCurrentInteraction:Ce,currentStepHasSpeakableElement:x});if(e&&K(),!(y.length===0&&!i)&&!j){if(a){oe(i),ue(!0),B.current=null;return}if(i&&(oe(i),B.current=null),!!r&&!D()){if(x){v(!0);return}if(w&&!(_e&&!Ee))return G.current=window.setTimeout(()=>{G.current=null,I()},ke),()=>{O()}}}},[w,O,y.length,i,m,Me,x,ke,I,A,Ee,Ce,H,K,D,j,_e]),t.useEffect(()=>{if(j||!x||H){v(!1);return}if(A){v(!1);return}if(Ze){v(!1);return}v(!0)},[Ze,x,A,j,H]),t.useEffect(()=>{m||E.length===0||j||!x||H||A||D()},[m,E,x,A,j,H,D]),t.useEffect(()=>{!m||C>=0||N(null)},[C,m]);const nt=t.useMemo(()=>{if(!s)return{};const e=!!s.user_input?.trim();return ct.getInteractionDefaultValues(typeof s.content=="string"?s.content:void 0,s.user_input,e?void 0:Z)},[s,Z]),kt=t.useMemo(()=>{if(!s)return;const e=!!s.user_input?.trim();return ct.getInteractionDefaultSelectedValues(typeof s.content=="string"?s.content:void 0,s.user_input,e?void 0:Z)},[s,Z]),rt=!!s?.user_input?.trim(),st=!!s?.readonly||rt,ot=st||rt,Tt=t.useCallback(e=>{const l=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");oe(a=>!a||!l?a:{...a,user_input:l}),Te?.(e,s),fe()},[s,fe,Te]);t.useEffect(()=>{const e=()=>{bt(document.fullscreenElement===ee.current)};return e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),t.useEffect(()=>{if(R(),!(!le||!ot))return Y.current=window.setTimeout(()=>{Y.current=null,fe()},2e3),()=>{R()}},[R,fe,le,ot]);const Pt=(e,r={})=>e?e.type==="slot"?n.jsxRuntimeExports.jsx(n.jsxRuntimeExports.Fragment,{children:e.content}):e.type==="html"?n.jsxRuntimeExports.jsx(it.default,{className:"content-render-iframe",hideFullScreen:!0,mode:"blackboard",replaceRootScreenHeightWithFull:r.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content}):n.jsxRuntimeExports.jsx(it.default,{className:"content-render-iframe",hideFullScreen:!0,mode:"blackboard",type:"markdown",content:e.content}):null,Ft=(e=[],r=!1)=>{if(e.length===0)return null;const l=e.filter(o=>o.is_renderable!==!1).length,a=e.reduce((o,u,b)=>u.is_renderable!==!1?b:o,-1);return n.jsxRuntimeExports.jsx("div",{className:"slide-stage__content flex w-full flex-col gap-4",children:e.map((o,u)=>{const b=o.type==="html"&&o.is_renderable===!1;return n.jsxRuntimeExports.jsx("div",{ref:r&&u===a?Le:null,"aria-hidden":b||void 0,className:U.cn("w-full shrink-0",l===1&&o.is_renderable!==!1&&"slide-element--single",b?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":o.is_renderable===!1&&"hidden"),children:Pt(o,{replaceRootScreenHeightWithFull:l===1&&o.type==="html"&&o.is_renderable!==!1})},o.sequence_number??`${o.type}-${u}`)})})},qt=t.useCallback(()=>{const e=ee.current;if(e){if(document.fullscreenElement===e){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},[]),lt=t.useCallback(()=>{const e=ge.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),Bt=t.useCallback(()=>{te.current=!0,B.current=null,J(!0),v(!1),d(!0),K(),Ke()},[Ke,K,d]),Lt=t.useCallback(()=>{te.current=!0,B.current=null,J(!0),v(!1),d(!0),K(),I()},[I,K,d]),Nt=t.useCallback(e=>{if(!x||A){v(!1);return}v(e)},[x,A]),Vt=t.useCallback(e=>{const r=f[e]?.audioKey;if(!r||!m||r!==m)return;const l=E.findIndex(u=>u===r);if(l<0){N(null);return}const a=l+1,o=E[a];if(o){N(o);return}if(N(null),Ue(!0),v(!1),w){const u=c+1,b=L[u];tt&&b?.type==="interaction"&&(B.current=u),I()}},[f,w,c,m,E,I,tt,L]),Ot=t.useCallback(()=>{s&&ue(e=>!e)},[s]),ut=t.useCallback(e=>{e.stopPropagation(),_&&d(!0)},[De,d]),Kt=t.useCallback(e=>{qe?.(e)},[qe]),Dt=t.useCallback(()=>{J(!0),d(!0)},[d]),Ht=!!s&&le,me=t.useMemo(()=>y.map((e,r)=>`${e.sequence_number??`${e.type}-${r}`}:${String(e.is_new??"")}`),[y]);return t.useEffect(()=>{const e=Ne.current,a=(e.length>0&&e.length<me.length&&e.every((u,b)=>u===me[b])?y.slice(e.length):[]).some(u=>u.is_new===!1);if(Ne.current=me,!a)return;const o=window.requestAnimationFrame(()=>{const u=ge.current,b=Le.current;if(!u||!b)return;const Ut=u.getBoundingClientRect(),Wt=b.getBoundingClientRect(),$t=u.scrollTop+(Wt.top-Ut.top);u.scrollTo({top:Math.max($t,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(o)}},[y,me]),t.useEffect(()=>{if(!te.current||(te.current=!1,y.length===0))return;const e=window.requestAnimationFrame(()=>{lt()});return()=>{window.cancelAnimationFrame(e)}},[y,lt]),n.jsxRuntimeExports.jsxs("section",{ref:ee,className:U.cn("relative h-full w-full",S&&"slide--mobile-device",V&&"slide--mobile-landscape",ze&&"slide--mobile-landscape-native",ft),onClick:Dt,onPointerDown:Kt,...mt,children:[wt?n.jsxRuntimeExports.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]"}):null,n.jsxRuntimeExports.jsxs("div",{ref:Be,className:U.cn("slide__viewport relative h-full min-h-0 w-full",V&&"slide__viewport--mobile-landscape",V&&!Et&&"slide__viewport--mobile-landscape-native"),children:[St?n.jsxRuntimeExports.jsxs("div",{className:"slide-landscape-header",children:[n.jsxRuntimeExports.jsx("button",{"aria-label":h?.backAriaLabel??"Back",className:"slide-landscape-header__back",onClick:At,type:"button",children:n.jsxRuntimeExports.jsx(sn.default,{className:"h-6 w-6 text-white",strokeWidth:2.25})}),h?.content?n.jsxRuntimeExports.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:h.content}):null]}):null,n.jsxRuntimeExports.jsx("div",{className:U.cn("h-full min-h-0 w-full",yt&&"slide__viewport-content--with-header",ht?"slide-content--single":"grid gap-4"),children:y.length>0?n.jsxRuntimeExports.jsx("div",{className:"slide-stage",children:n.jsxRuntimeExports.jsx("div",{ref:ge,className:"slide-stage__layer w-full",children:_t.map((e,r)=>{const l=r===Ct;return n.jsxRuntimeExports.jsx("div",{"aria-hidden":!l||void 0,className:"w-full h-full",style:{display:l?void 0:"none"},children:Ft(e.elementList,l)},e.sourceStepIndexes[0]??r)})})}):null}),xt?n.jsxRuntimeExports.jsx(Gt.default,{message:he,className:"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2"}):null,n.jsxRuntimeExports.jsx(Qt.default,{onClose:Mt,open:gt,text:Rt}),Ht?n.jsxRuntimeExports.jsx("div",{className:U.cn("slide-interaction-overlay",_&&g?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone"),onClick:ut,onPointerDown:ut,style:jt,children:n.jsxRuntimeExports.jsx(dt,{content:String(s?.content??""),defaultButtonText:nt.buttonText??"",defaultInputText:nt.inputText??"",defaultSelectedValues:kt,confirmButtonText:q?.confirmButtonText,copyButtonText:q?.copyButtonText,copiedButtonText:q?.copiedButtonText,onSend:Tt,readonly:st,title:q?.title??xe??"Submit the content below to continue."})}):null,g?n.jsxRuntimeExports.jsx(Xt.default,{audioList:f,className:U.cn("absolute left-1/2 bottom-6 z-[2] -translate-x-1/2",W,!_&&"pointer-events-none opacity-0"),currentAudioIndex:C,defaultPlaying:!0,isPlaybackPaused:j,isAutoAdvanceEnabled:Ee,hasInteraction:!!s,isInteractionOpen:le,onAutoAdvanceToggle:He,onLoadingChange:Nt,nextDisabled:!w,onEnded:Vt,onFullscreen:qt,isFullscreen:vt,mobileViewMode:M,settingsPortalContainer:Be.current,onMobileViewModeChange:It,onInteractionToggle:Ot,onNext:Lt,onPrev:Bt,prevDisabled:!pt,showControls:_,texts:je,customActionContext:Ie,customActions:F,useAutoAdvanceToggle:_e}):null]})]})};exports.default=un;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),zt=require("../../lib/sandboxInteraction.cjs.js"),U=require("../../lib/utils.cjs.js"),Gt=require("../ui/loading-overlay-card.cjs.js"),Yt=require("../ContentRender/ContentRender.cjs.js"),it=require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");const ct=require("../../lib/interaction-defaults.cjs.js"),me=require("../../lib/mobileDevice.cjs.js"),Xt=require("./Player.cjs.js"),Jt=require("./constants.cjs.js"),Qt=require("./SlideFullscreenHint.cjs.js"),Zt=require("./useSlide.cjs.js"),en=require("./useWakePlayerFromIframe.cjs.js"),Q=require("./utils/mobileScreenMode.cjs.js"),tn=require("./utils/interactionPlayback.cjs.js"),nn=require("./utils/playbackSequence.cjs.js"),at=require("./utils/playerCustomActions.cjs.js"),rn=require("./utils/playerToggleMode.cjs.js");;/* empty css */const sn=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/chevron-left.cjs.js"),on=2e3,dt=t.memo(({content:T,title:P,defaultButtonText:p,defaultInputText:W,defaultSelectedValues:h,confirmButtonText:F,copyButtonText:$,copiedButtonText:pe,onSend:he,readonly:q=!1})=>n.jsxRuntimeExports.jsxs("div",{className:"slide-player__interaction-card",children:[n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-header",children:n.jsxRuntimeExports.jsx("p",{className:"slide-player__interaction-title",children:P})}),n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-body",children:n.jsxRuntimeExports.jsx(Yt.default,{content:T,defaultButtonText:p,defaultInputText:W,defaultSelectedValues:h,confirmButtonText:F,copyButtonText:$,copiedButtonText:pe,onSend:he,readonly:q,enableTypewriter:!1,sandboxMode:"content"})}),n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-arrow"})]}));dt.displayName="InteractionOverlayCard";const ln=(T,P)=>T.length===P.length&&T.every((p,W)=>{const h=P[W];return p.sequence_number===h?.sequence_number&&p.type===h?.type&&p.content===h?.content}),un=({elementList:T=[],showPlayer:P=!0,playerAlwaysVisible:p=!1,playerClassName:W,fullscreenHeader:h,playerCustomActions:F,playerCustomActionPauseOnActive:$=!0,bufferingText:pe="Buffering...",interactionTitle:he,interactionTexts:q,playerTexts:je,playerAutoHideDelay:xe=3e3,markerAutoAdvanceDelay:ke=on,interactionDefaultValueOptions:Z,onSend:Te,onPlayerVisibilityChange:ve,onMobileViewModeChange:Pe,onStepChange:Fe,className:ft,onPointerDown:qe,...mt})=>{const ee=t.useRef(null),Be=t.useRef(null),be=t.useRef(null),Le=t.useRef(null),z=t.useRef(null),G=t.useRef(null),Y=t.useRef(null),Ne=t.useRef([]),te=t.useRef(!1),B=t.useRef(null),Ve=t.useRef(null),{currentElementList:y,stepElementLists:Oe,slideElementList:L,currentIndex:c,audioList:f,currentAudioSequenceIndexes:ne,currentStepHasSpeakableElement:x,currentInteractionElement:i,canGoPrev:pt,canGoNext:w,handlePrev:Ke,handleNext:I}=Zt.default(T),X=t.useMemo(()=>{if(!(c<0))return L[c]},[c,L]),ht=L.filter(e=>e.is_renderable!==!1).length===1,g=P&&(L.length>0||f.length>0||!!i),E=t.useMemo(()=>ne.map(e=>f[e]?.audioKey).filter(e=>!!e),[f,ne]),[De,re]=t.useState(!0),[se,J]=t.useState(!1),[ge,He]=t.useState(!0),[m,N]=t.useState(null),[xt,v]=t.useState(!1),[A,Ue]=t.useState(!1),[Ee,Se]=t.useState(!1),[s,oe]=t.useState(),[le,ue]=t.useState(!1),[vt,bt]=t.useState(!1),S=t.useMemo(()=>me.isMobileDevice(),[]);console.log("navigator.userAgent",navigator.userAgent);const[ie,ye]=t.useState(Q.DEFAULT_MOBILE_VIEW_MODE),[We,we]=t.useState(!1),[Re,$e]=t.useState(()=>S?me.isLandscapeViewport():!1),[gt,ce]=t.useState(!1),{effectiveMobileViewMode:M,isImmersiveMobileFullscreen:V,isNativeMobileFullscreen:ze,shouldRotateFullscreenViewport:Et}=t.useMemo(()=>Q.resolveMobileViewModeState({hasManualMobileViewMode:We,isMobileDevice:S,mobileViewMode:ie}),[We,S,Re,ie]),Ge=t.useRef(M),_=g&&(p||De),St=V&&_,yt=V&&_,wt=V||ze,Rt=je?.fullscreenHintText??Jt.DEFAULT_SLIDE_PLAYER_TEXTS.fullscreenHintText,It=t.useCallback(e=>{we(!0),ye(e)},[]),Ye=t.useCallback(()=>{we(!1),ye(Q.DEFAULT_MOBILE_VIEW_MODE)},[]),At=t.useCallback(()=>{Ye(),h?.onBack?.()},[h,Ye]),Mt=t.useCallback(()=>{ce(!1)},[]),Xe=t.useCallback(e=>{Se(e)},[]),Je=t.useCallback(()=>{Se(e=>!e)},[]),{mountedStepStates:_t,currentMountedStateIndex:Ct}=t.useMemo(()=>{const e=[],r=new Map;return Oe.forEach((l,a)=>{const o=e.findIndex(u=>ln(u.elementList,l));if(o>=0){e[o]?.sourceStepIndexes.push(a),r.set(a,o);return}e.push({elementList:l,sourceStepIndexes:[a]}),r.set(a,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:c>=0?r.get(c)??-1:-1}},[c,Oe]),Qe=t.useMemo(()=>String(c),[c]),C=t.useMemo(()=>m?f.findIndex(e=>(e.audioKey??"")===m):-1,[f,m]),ae=t.useMemo(()=>E[0]??"none",[E]),Ie=t.useMemo(()=>({currentElement:at.resolvePlayerCustomActionElement({currentAudioIndex:C,currentAudioSequenceIndexes:ne,audioList:f,currentInteractionElement:s,currentStepElement:X}),currentIndex:c,currentStepElement:X,isActive:Ee,setActive:Xe,toggleActive:Je}),[s,f,C,ne,c,X,Ee,Xe,Je]),Ae=t.useMemo(()=>at.getPlayerCustomActionCount(F,Ie),[Ie,F]),jt=t.useMemo(()=>({"--slide-player-custom-action-count":String(Ae),"--slide-player-mobile-control-count":String(Ae+4)}),[Ae]),Ze=E.length>0,et=t.useMemo(()=>i?`${i.sequence_number??"none"}:${String(i.content??"")}`:"none",[i]),Me=t.useMemo(()=>[Qe,et].join("|"),[et,Qe]),tt=!!t.useMemo(()=>!ae||ae==="none"?"":f.find(r=>r.audioKey===ae)?.audioUrl?.trim()??"",[f,ae]),j=$&&!!F&&Ee,_e=t.useMemo(()=>rn.shouldUseAutoAdvanceToggle({canGoNext:w,currentAudioIndex:C,currentStepHasSpeakableElement:x,hasInteraction:!!i}),[w,C,i,x]),k=t.useCallback(()=>{z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),R=t.useCallback(()=>{Y.current!==null&&(window.clearTimeout(Y.current),Y.current=null)},[]),O=t.useCallback(()=>{G.current!==null&&(window.clearTimeout(G.current),G.current=null)},[]),K=t.useCallback(()=>{O(),R(),N(null),v(!1),Ue(!1),oe(void 0),ue(!1)},[O,R]),D=t.useCallback(()=>{const e=E[0];return e?(N(e),!0):!1},[E]),de=t.useCallback(()=>{R(),ue(!1),!D()&&w&&I()},[w,R,I,D]),d=t.useCallback((e=se)=>{g&&(re(!0),k(),!(p||!e||xe<=0)&&(z.current=window.setTimeout(()=>{re(!1),z.current=null},xe)))},[k,se,p,xe,g]),Ce=!!(i?.readonly||i?.user_input?.trim()),H=!!i&&!Ce;t.useEffect(()=>{He(!0),$&&Se(!1)},[c,$]),t.useEffect(()=>()=>{O(),k(),R()},[O,R,k]),t.useEffect(()=>(ve?.(_),()=>{ve?.(!1)}),[ve,_]),t.useEffect(()=>{S||ie===Q.DEFAULT_MOBILE_VIEW_MODE||(we(!1),ye(Q.DEFAULT_MOBILE_VIEW_MODE))},[S,ie]),t.useEffect(()=>{if(!S){$e(!1);return}const e=()=>{$e(me.isLandscapeViewport())};return e(),me.subscribeMobileDeviceChange(e)},[S]),t.useEffect(()=>{Pe?.(M)},[M,Pe]),t.useEffect(()=>{const l=Ge.current!=="fullscreen"&&M==="fullscreen"&&!Re;if(Ge.current=M,!S){ce(!1);return}if(l){ce(!0);return}M!=="fullscreen"&&ce(!1)},[M,S,Re]),t.useEffect(()=>{Fe?.(X,c)},[c,X,Fe]),t.useEffect(()=>{if(!g){k(),re(!1);return}if(p){k(),re(!0);return}se||d(!0)},[k,se,p,g,d]),t.useEffect(()=>{if(typeof window>"u")return;const e=r=>{r.origin===window.location.origin&&zt.isSandboxInteractionMessage(r.data)&&r.data.eventType==="click"&&g&&(J(!0),d(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[g,d]),en.default({sectionRef:ee,enabled:g,onWake:()=>{J(!0),d(!0)}}),t.useEffect(()=>{const{hasPlaybackContextChanged:e,shouldInitializeAudioSequence:r}=nn.getPlaybackSequenceTransition({previousResetKey:Ve.current,nextResetKey:Me,currentAudioKey:m,hasCompletedCurrentStepAudio:A});Ve.current=Me;const l=B.current===c&&!!i,a=tn.shouldPresentInteractionOverlay({hasInteraction:!!i,shouldBlockPlaybackForInteraction:H,shouldOpenInteractionOverlayAfterAudio:l,hasPlaybackContextChanged:e,hasResolvedCurrentInteraction:Ce,currentStepHasSpeakableElement:x});if(e&&K(),!(y.length===0&&!i)&&!j){if(a){oe(i),ue(!0),B.current=null;return}if(i&&(oe(i),B.current=null),!!r&&!D()){if(x){v(!0);return}if(w&&!(_e&&!ge))return G.current=window.setTimeout(()=>{G.current=null,I()},ke),()=>{O()}}}},[w,O,y.length,i,m,Me,x,ke,I,A,ge,Ce,H,K,D,j,_e]),t.useEffect(()=>{if(j||!x||H){v(!1);return}if(A){v(!1);return}if(Ze){v(!1);return}v(!0)},[Ze,x,A,j,H]),t.useEffect(()=>{m||E.length===0||j||!x||H||A||D()},[m,E,x,A,j,H,D]),t.useEffect(()=>{!m||C>=0||N(null)},[C,m]);const nt=t.useMemo(()=>{if(!s)return{};const e=!!s.user_input?.trim();return ct.getInteractionDefaultValues(typeof s.content=="string"?s.content:void 0,s.user_input,e?void 0:Z)},[s,Z]),kt=t.useMemo(()=>{if(!s)return;const e=!!s.user_input?.trim();return ct.getInteractionDefaultSelectedValues(typeof s.content=="string"?s.content:void 0,s.user_input,e?void 0:Z)},[s,Z]),rt=!!s?.user_input?.trim(),st=!!s?.readonly||rt,ot=st||rt,Tt=t.useCallback(e=>{const l=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");oe(a=>!a||!l?a:{...a,user_input:l}),Te?.(e,s),de()},[s,de,Te]);t.useEffect(()=>{const e=()=>{bt(document.fullscreenElement===ee.current)};return e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),t.useEffect(()=>{if(R(),!(!le||!ot))return Y.current=window.setTimeout(()=>{Y.current=null,de()},2e3),()=>{R()}},[R,de,le,ot]);const Pt=(e,r={})=>e?e.type==="slot"?n.jsxRuntimeExports.jsx(n.jsxRuntimeExports.Fragment,{children:e.content}):e.type==="html"?n.jsxRuntimeExports.jsx(it.default,{className:"content-render-iframe",hideFullScreen:!0,mode:"blackboard",replaceRootScreenHeightWithFull:r.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content}):n.jsxRuntimeExports.jsx(it.default,{className:"content-render-iframe",hideFullScreen:!0,mode:"blackboard",type:"markdown",content:e.content}):null,Ft=(e=[],r=!1)=>{if(e.length===0)return null;const l=e.filter(o=>o.is_renderable!==!1).length,a=e.reduce((o,u,b)=>u.is_renderable!==!1?b:o,-1);return n.jsxRuntimeExports.jsx("div",{className:"slide-stage__content flex w-full flex-col gap-4",children:e.map((o,u)=>{const b=o.type==="html"&&o.is_renderable===!1;return n.jsxRuntimeExports.jsx("div",{ref:r&&u===a?Le:null,"aria-hidden":b||void 0,className:U.cn("w-full shrink-0",l===1&&o.is_renderable!==!1&&"slide-element--single",b?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":o.is_renderable===!1&&"hidden"),children:Pt(o,{replaceRootScreenHeightWithFull:l===1&&o.type==="html"&&o.is_renderable!==!1})},o.sequence_number??`${o.type}-${u}`)})})},qt=t.useCallback(()=>{const e=ee.current;if(e){if(document.fullscreenElement===e){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},[]),lt=t.useCallback(()=>{const e=be.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),Bt=t.useCallback(()=>{te.current=!0,B.current=null,J(!0),v(!1),d(!0),K(),Ke()},[Ke,K,d]),Lt=t.useCallback(()=>{te.current=!0,B.current=null,J(!0),v(!1),d(!0),K(),I()},[I,K,d]),Nt=t.useCallback(e=>{if(!x||A){v(!1);return}v(e)},[x,A]),Vt=t.useCallback(e=>{const r=f[e]?.audioKey;if(!r||!m||r!==m)return;const l=E.findIndex(u=>u===r);if(l<0){N(null);return}const a=l+1,o=E[a];if(o){N(o);return}if(N(null),Ue(!0),v(!1),w){const u=c+1,b=L[u];tt&&b?.type==="interaction"&&(B.current=u),I()}},[f,w,c,m,E,I,tt,L]),Ot=t.useCallback(()=>{s&&ue(e=>!e)},[s]),ut=t.useCallback(e=>{e.stopPropagation(),_&&d(!0)},[De,d]),Kt=t.useCallback(e=>{qe?.(e)},[qe]),Dt=t.useCallback(()=>{J(!0),d(!0)},[d]),Ht=!!s&&le,fe=t.useMemo(()=>y.map((e,r)=>`${e.sequence_number??`${e.type}-${r}`}:${String(e.is_new??"")}`),[y]);return t.useEffect(()=>{const e=Ne.current,a=(e.length>0&&e.length<fe.length&&e.every((u,b)=>u===fe[b])?y.slice(e.length):[]).some(u=>u.is_new===!1);if(Ne.current=fe,!a)return;const o=window.requestAnimationFrame(()=>{const u=be.current,b=Le.current;if(!u||!b)return;const Ut=u.getBoundingClientRect(),Wt=b.getBoundingClientRect(),$t=u.scrollTop+(Wt.top-Ut.top);u.scrollTo({top:Math.max($t,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(o)}},[y,fe]),t.useEffect(()=>{if(!te.current||(te.current=!1,y.length===0))return;const e=window.requestAnimationFrame(()=>{lt()});return()=>{window.cancelAnimationFrame(e)}},[y,lt]),n.jsxRuntimeExports.jsxs("section",{ref:ee,className:U.cn("relative h-full w-full",S&&"slide--mobile-device",V&&"slide--mobile-landscape",ze&&"slide--mobile-landscape-native",ft),onClick:Dt,onPointerDown:Kt,...mt,children:[wt?n.jsxRuntimeExports.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]"}):null,n.jsxRuntimeExports.jsxs("div",{ref:Be,className:U.cn("slide__viewport relative h-full min-h-0 w-full",V&&"slide__viewport--mobile-landscape",V&&!Et&&"slide__viewport--mobile-landscape-native"),children:[St?n.jsxRuntimeExports.jsxs("div",{className:"slide-landscape-header",children:[n.jsxRuntimeExports.jsx("button",{"aria-label":h?.backAriaLabel??"Back",className:"slide-landscape-header__back",onClick:At,type:"button",children:n.jsxRuntimeExports.jsx(sn.default,{className:"h-6 w-6 text-white",strokeWidth:2.25})}),h?.content?n.jsxRuntimeExports.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:h.content}):null]}):null,n.jsxRuntimeExports.jsx("div",{className:U.cn("h-full min-h-0 w-full",yt&&"slide__viewport-content--with-header",ht?"slide-content--single":"grid gap-4"),children:y.length>0?n.jsxRuntimeExports.jsx("div",{className:"slide-stage",children:n.jsxRuntimeExports.jsx("div",{ref:be,className:"slide-stage__layer w-full",children:_t.map((e,r)=>{const l=r===Ct;return n.jsxRuntimeExports.jsx("div",{"aria-hidden":!l||void 0,className:"w-full h-full",style:{display:l?void 0:"none"},children:Ft(e.elementList,l)},e.sourceStepIndexes[0]??r)})})}):null}),xt?n.jsxRuntimeExports.jsx(Gt.default,{message:pe,className:"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2"}):null,n.jsxRuntimeExports.jsx(Qt.default,{onClose:Mt,open:gt,text:Rt}),Ht?n.jsxRuntimeExports.jsx("div",{className:U.cn("slide-interaction-overlay",_&&g?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone"),onClick:ut,onPointerDown:ut,style:jt,children:n.jsxRuntimeExports.jsx(dt,{content:String(s?.content??""),defaultButtonText:nt.buttonText??"",defaultInputText:nt.inputText??"",defaultSelectedValues:kt,confirmButtonText:q?.confirmButtonText,copyButtonText:q?.copyButtonText,copiedButtonText:q?.copiedButtonText,onSend:Tt,readonly:st,title:q?.title??he??"Submit the content below to continue."})}):null,g?n.jsxRuntimeExports.jsx(Xt.default,{audioList:f,className:U.cn("absolute left-1/2 bottom-6 z-[2] -translate-x-1/2",W,!_&&"pointer-events-none opacity-0"),currentAudioIndex:C,defaultPlaying:!0,isPlaybackPaused:j,isAutoAdvanceEnabled:ge,hasInteraction:!!s,isInteractionOpen:le,onAutoAdvanceToggle:He,onLoadingChange:Nt,nextDisabled:!w,onEnded:Vt,onFullscreen:qt,isFullscreen:vt,mobileViewMode:M,settingsPortalContainer:Be.current,onMobileViewModeChange:It,onInteractionToggle:Ot,onNext:Lt,onPrev:Bt,prevDisabled:!pt,showControls:_,texts:je,customActionContext:Ie,customActions:F,useAutoAdvanceToggle:_e}):null]})]})};exports.default=un;
2
2
  //# sourceMappingURL=Slide.cjs.js.map