markdown-flow-ui 0.2.13 → 0.2.15

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 (475) hide show
  1. package/README.md +7 -0
  2. package/dist/_virtual/index.es3.js +5 -4
  3. package/dist/_virtual/index.es3.js.map +1 -1
  4. package/dist/_virtual/index.es4.js +4 -5
  5. package/dist/_virtual/index.es4.js.map +1 -1
  6. package/dist/_virtual/index3.cjs +1 -1
  7. package/dist/_virtual/index4.cjs +1 -1
  8. package/dist/assets/markdown-flow-ui.css +10 -1
  9. package/dist/components/ContentRender/CodeBlock.cjs +1 -1
  10. package/dist/components/ContentRender/CodeBlock.cjs.map +1 -1
  11. package/dist/components/ContentRender/CodeBlock.d.ts +5 -0
  12. package/dist/components/ContentRender/CodeBlock.es.js +41 -38
  13. package/dist/components/ContentRender/CodeBlock.es.js.map +1 -1
  14. package/dist/components/ContentRender/ContentRender.cjs +2 -2
  15. package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
  16. package/dist/components/ContentRender/ContentRender.d.ts +9 -4
  17. package/dist/components/ContentRender/ContentRender.es.js +389 -298
  18. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  19. package/dist/components/ContentRender/IframeSandbox.cjs +7 -7
  20. package/dist/components/ContentRender/IframeSandbox.cjs.map +1 -1
  21. package/dist/components/ContentRender/IframeSandbox.d.ts +5 -1
  22. package/dist/components/ContentRender/IframeSandbox.es.js +311 -266
  23. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  24. package/dist/components/ContentRender/MarkdownFlowInput.cjs +1 -1
  25. package/dist/components/ContentRender/MarkdownFlowInput.cjs.map +1 -1
  26. package/dist/components/ContentRender/MarkdownFlowInput.d.ts +5 -1
  27. package/dist/components/ContentRender/MarkdownFlowInput.es.js +37 -32
  28. package/dist/components/ContentRender/MarkdownFlowInput.es.js.map +1 -1
  29. package/dist/components/ContentRender/SandboxApp.cjs +2 -2
  30. package/dist/components/ContentRender/SandboxApp.cjs.map +1 -1
  31. package/dist/components/ContentRender/SandboxApp.d.ts +5 -1
  32. package/dist/components/ContentRender/SandboxApp.es.js +108 -103
  33. package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
  34. package/dist/components/ContentRender/blackboard-vendor.d.ts +1 -1
  35. package/dist/components/ContentRender/contentRenderI18n.cjs +1 -1
  36. package/dist/components/ContentRender/contentRenderI18n.cjs.map +1 -1
  37. package/dist/components/ContentRender/contentRenderI18n.d.ts +6 -1
  38. package/dist/components/ContentRender/contentRenderI18n.es.js +5 -56
  39. package/dist/components/ContentRender/contentRenderI18n.es.js.map +1 -1
  40. package/dist/components/ContentRender/contentRenderI18n.test.d.ts +1 -0
  41. package/dist/components/ContentRender/index.cjs +1 -1
  42. package/dist/components/ContentRender/index.d.ts +11 -11
  43. package/dist/components/ContentRender/index.es.js +1 -2
  44. package/dist/components/ContentRender/index.es.js.map +1 -1
  45. package/dist/components/ContentRender/locales/contentRender.json.cjs +2 -0
  46. package/dist/components/ContentRender/locales/contentRender.json.cjs.map +1 -0
  47. package/dist/components/ContentRender/locales/contentRender.json.d.ts +90 -0
  48. package/dist/components/ContentRender/locales/contentRender.json.es.js +11 -0
  49. package/dist/components/ContentRender/locales/contentRender.json.es.js.map +1 -0
  50. package/dist/components/ContentRender/plugins/CustomVariable.cjs +1 -1
  51. package/dist/components/ContentRender/plugins/CustomVariable.cjs.map +1 -1
  52. package/dist/components/ContentRender/plugins/CustomVariable.d.ts +7 -3
  53. package/dist/components/ContentRender/plugins/CustomVariable.es.js +165 -151
  54. package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
  55. package/dist/components/ContentRender/plugins/MermaidChart.cjs +1 -1
  56. package/dist/components/ContentRender/plugins/MermaidChart.cjs.map +1 -1
  57. package/dist/components/ContentRender/plugins/MermaidChart.d.ts +1 -0
  58. package/dist/components/ContentRender/plugins/MermaidChart.es.js +68 -44
  59. package/dist/components/ContentRender/plugins/MermaidChart.es.js.map +1 -1
  60. package/dist/components/MarkdownFlow/MarkdownFlow.cjs +1 -1
  61. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.map +1 -1
  62. package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +12 -4
  63. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +51 -39
  64. package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
  65. package/dist/components/MarkdownFlow/ScrollToBottomButton.cjs +1 -1
  66. package/dist/components/MarkdownFlow/ScrollToBottomButton.cjs.map +1 -1
  67. package/dist/components/MarkdownFlow/ScrollToBottomButton.d.ts +31 -1
  68. package/dist/components/MarkdownFlow/ScrollToBottomButton.es.js +46 -17
  69. package/dist/components/MarkdownFlow/ScrollToBottomButton.es.js.map +1 -1
  70. package/dist/components/MarkdownFlow/ScrollToBottomControl.cjs +2 -0
  71. package/dist/components/MarkdownFlow/ScrollToBottomControl.cjs.map +1 -0
  72. package/dist/components/MarkdownFlow/ScrollToBottomControl.d.ts +18 -0
  73. package/dist/components/MarkdownFlow/ScrollToBottomControl.es.js +47 -0
  74. package/dist/components/MarkdownFlow/ScrollToBottomControl.es.js.map +1 -0
  75. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.cjs +1 -1
  76. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.cjs.map +1 -1
  77. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.d.ts +1 -1
  78. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.es.js +33 -52
  79. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.es.js.map +1 -1
  80. package/dist/components/MarkdownFlow/index.cjs +1 -1
  81. package/dist/components/MarkdownFlow/index.d.ts +9 -6
  82. package/dist/components/MarkdownFlow/index.es.js +6 -6
  83. package/dist/components/MarkdownFlow/index.es.js.map +1 -1
  84. package/dist/components/MarkdownFlow/useScrollToBottom.cjs +1 -1
  85. package/dist/components/MarkdownFlow/useScrollToBottom.cjs.map +1 -1
  86. package/dist/components/MarkdownFlow/useScrollToBottom.d.ts +40 -8
  87. package/dist/components/MarkdownFlow/useScrollToBottom.es.js +352 -83
  88. package/dist/components/MarkdownFlow/useScrollToBottom.es.js.map +1 -1
  89. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs +1 -1
  90. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.map +1 -1
  91. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.d.ts +5 -3
  92. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js +371 -324
  93. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js.map +1 -1
  94. package/dist/components/MarkdownFlowEditor/components/CustomDialog.cjs +1 -1
  95. package/dist/components/MarkdownFlowEditor/components/CustomDialog.cjs.map +1 -1
  96. package/dist/components/MarkdownFlowEditor/components/CustomDialog.d.ts +10 -0
  97. package/dist/components/MarkdownFlowEditor/components/CustomDialog.es.js +22 -19
  98. package/dist/components/MarkdownFlowEditor/components/CustomDialog.es.js.map +1 -1
  99. package/dist/components/MarkdownFlowEditor/components/CustomPopover.cjs +1 -1
  100. package/dist/components/MarkdownFlowEditor/components/CustomPopover.cjs.map +1 -1
  101. package/dist/components/MarkdownFlowEditor/components/CustomPopover.d.ts +8 -0
  102. package/dist/components/MarkdownFlowEditor/components/CustomPopover.es.js +19 -15
  103. package/dist/components/MarkdownFlowEditor/components/CustomPopover.es.js.map +1 -1
  104. package/dist/components/MarkdownFlowEditor/components/EditorToolbar.cjs +1 -1
  105. package/dist/components/MarkdownFlowEditor/components/EditorToolbar.cjs.map +1 -1
  106. package/dist/components/MarkdownFlowEditor/components/EditorToolbar.d.ts +4 -1
  107. package/dist/components/MarkdownFlowEditor/components/EditorToolbar.es.js +99 -93
  108. package/dist/components/MarkdownFlowEditor/components/EditorToolbar.es.js.map +1 -1
  109. package/dist/components/MarkdownFlowEditor/components/ImageInject.cjs +1 -1
  110. package/dist/components/MarkdownFlowEditor/components/ImageInject.cjs.map +1 -1
  111. package/dist/components/MarkdownFlowEditor/components/ImageInject.d.ts +1 -1
  112. package/dist/components/MarkdownFlowEditor/components/ImageInject.es.js +183 -182
  113. package/dist/components/MarkdownFlowEditor/components/ImageInject.es.js.map +1 -1
  114. package/dist/components/MarkdownFlowEditor/components/VariableSearchDropdown.cjs +1 -1
  115. package/dist/components/MarkdownFlowEditor/components/VariableSearchDropdown.cjs.map +1 -1
  116. package/dist/components/MarkdownFlowEditor/components/VariableSearchDropdown.d.ts +1 -1
  117. package/dist/components/MarkdownFlowEditor/components/VariableSearchDropdown.es.js +107 -103
  118. package/dist/components/MarkdownFlowEditor/components/VariableSearchDropdown.es.js.map +1 -1
  119. package/dist/components/MarkdownFlowEditor/components/VariableSelect.cjs +1 -1
  120. package/dist/components/MarkdownFlowEditor/components/VariableSelect.cjs.map +1 -1
  121. package/dist/components/MarkdownFlowEditor/components/VariableSelect.d.ts +1 -1
  122. package/dist/components/MarkdownFlowEditor/components/VariableSelect.es.js +106 -106
  123. package/dist/components/MarkdownFlowEditor/components/VariableSelect.es.js.map +1 -1
  124. package/dist/components/MarkdownFlowEditor/components/VideoInject.cjs +1 -1
  125. package/dist/components/MarkdownFlowEditor/components/VideoInject.cjs.map +1 -1
  126. package/dist/components/MarkdownFlowEditor/components/VideoInject.es.js +64 -63
  127. package/dist/components/MarkdownFlowEditor/components/VideoInject.es.js.map +1 -1
  128. package/dist/components/MarkdownFlowEditor/components/icons/ButtonIcon.cjs +1 -1
  129. package/dist/components/MarkdownFlowEditor/components/icons/ButtonIcon.cjs.map +1 -1
  130. package/dist/components/MarkdownFlowEditor/components/icons/ButtonIcon.es.js +13 -13
  131. package/dist/components/MarkdownFlowEditor/components/icons/ButtonIcon.es.js.map +1 -1
  132. package/dist/components/MarkdownFlowEditor/components/icons/SearchBracesIcon.cjs +1 -1
  133. package/dist/components/MarkdownFlowEditor/components/icons/SearchBracesIcon.cjs.map +1 -1
  134. package/dist/components/MarkdownFlowEditor/components/icons/SearchBracesIcon.es.js +12 -12
  135. package/dist/components/MarkdownFlowEditor/components/icons/SearchBracesIcon.es.js.map +1 -1
  136. package/dist/components/MarkdownFlowEditor/editor-context.d.ts +1 -1
  137. package/dist/components/MarkdownFlowEditor/editorI18n.cjs +1 -1
  138. package/dist/components/MarkdownFlowEditor/editorI18n.cjs.map +1 -1
  139. package/dist/components/MarkdownFlowEditor/editorI18n.d.ts +290 -0
  140. package/dist/components/MarkdownFlowEditor/editorI18n.es.js +12 -8
  141. package/dist/components/MarkdownFlowEditor/editorI18n.es.js.map +1 -1
  142. package/dist/components/MarkdownFlowEditor/editorI18n.test.d.ts +1 -0
  143. package/dist/components/MarkdownFlowEditor/index.d.ts +6 -6
  144. package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.cjs +2 -0
  145. package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.cjs.map +1 -0
  146. package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.d.ts +72 -0
  147. package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.es.js +140 -0
  148. package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.es.js.map +1 -0
  149. package/dist/components/MarkdownFlowEditor/locales/en-US.json.cjs +1 -1
  150. package/dist/components/MarkdownFlowEditor/locales/en-US.json.d.ts +2 -0
  151. package/dist/components/MarkdownFlowEditor/locales/en-US.json.es.js +118 -114
  152. package/dist/components/MarkdownFlowEditor/locales/en-US.json.es.js.map +1 -1
  153. package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.cjs +1 -1
  154. package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.d.ts +2 -0
  155. package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.es.js +118 -114
  156. package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.es.js.map +1 -1
  157. package/dist/components/MarkdownFlowEditor/locales/th-TH.json.cjs +2 -0
  158. package/dist/components/MarkdownFlowEditor/locales/th-TH.json.cjs.map +1 -0
  159. package/dist/components/MarkdownFlowEditor/locales/th-TH.json.d.ts +72 -0
  160. package/dist/components/MarkdownFlowEditor/locales/th-TH.json.es.js +140 -0
  161. package/dist/components/MarkdownFlowEditor/locales/th-TH.json.es.js.map +1 -0
  162. package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.cjs +1 -1
  163. package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.d.ts +2 -0
  164. package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.es.js +70 -66
  165. package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.es.js.map +1 -1
  166. package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.cjs +1 -1
  167. package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.cjs.map +1 -1
  168. package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.es.js +40 -35
  169. package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.es.js.map +1 -1
  170. package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.d.ts +1 -1
  171. package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.cjs +1 -1
  172. package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.cjs.map +1 -1
  173. package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.es.js +27 -23
  174. package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.es.js.map +1 -1
  175. package/dist/components/MarkdownFlowEditor/plugins/mediaPlaceholderLabels.cjs +2 -0
  176. package/dist/components/MarkdownFlowEditor/plugins/mediaPlaceholderLabels.cjs.map +1 -0
  177. package/dist/components/MarkdownFlowEditor/plugins/mediaPlaceholderLabels.d.ts +7 -0
  178. package/dist/components/MarkdownFlowEditor/plugins/mediaPlaceholderLabels.es.js +12 -0
  179. package/dist/components/MarkdownFlowEditor/plugins/mediaPlaceholderLabels.es.js.map +1 -0
  180. package/dist/components/MarkdownFlowEditor/utils.d.ts +1 -1
  181. package/dist/components/Slide/MarkdownSlideScaling.cjs +1 -1
  182. package/dist/components/Slide/MarkdownSlideScaling.cjs.map +1 -1
  183. package/dist/components/Slide/MarkdownSlideScaling.d.ts +1 -1
  184. package/dist/components/Slide/MarkdownSlideScaling.es.js +20 -20
  185. package/dist/components/Slide/MarkdownSlideScaling.es.js.map +1 -1
  186. package/dist/components/Slide/MobilePlayerSettingsSheet.cjs +1 -1
  187. package/dist/components/Slide/MobilePlayerSettingsSheet.cjs.map +1 -1
  188. package/dist/components/Slide/MobilePlayerSettingsSheet.d.ts +7 -2
  189. package/dist/components/Slide/MobilePlayerSettingsSheet.es.js +61 -57
  190. package/dist/components/Slide/MobilePlayerSettingsSheet.es.js.map +1 -1
  191. package/dist/components/Slide/Player.cjs +1 -1
  192. package/dist/components/Slide/Player.cjs.map +1 -1
  193. package/dist/components/Slide/Player.d.ts +6 -6
  194. package/dist/components/Slide/Player.es.js +547 -541
  195. package/dist/components/Slide/Player.es.js.map +1 -1
  196. package/dist/components/Slide/Slide.cjs +1 -1
  197. package/dist/components/Slide/Slide.cjs.map +1 -1
  198. package/dist/components/Slide/Slide.d.ts +14 -12
  199. package/dist/components/Slide/Slide.es.js +745 -726
  200. package/dist/components/Slide/Slide.es.js.map +1 -1
  201. package/dist/components/Slide/SubtitleOverlay.cjs +1 -1
  202. package/dist/components/Slide/SubtitleOverlay.cjs.map +1 -1
  203. package/dist/components/Slide/SubtitleOverlay.d.ts +2 -2
  204. package/dist/components/Slide/SubtitleOverlay.es.js +17 -17
  205. package/dist/components/Slide/SubtitleOverlay.es.js.map +1 -1
  206. package/dist/components/Slide/diff-utils.d.ts +1 -1
  207. package/dist/components/Slide/index.d.ts +12 -12
  208. package/dist/components/Slide/locales/slide.json.cjs +2 -0
  209. package/dist/components/Slide/locales/slide.json.cjs.map +1 -0
  210. package/dist/components/Slide/locales/slide.json.d.ts +205 -0
  211. package/dist/components/Slide/locales/slide.json.es.js +11 -0
  212. package/dist/components/Slide/locales/slide.json.es.js.map +1 -0
  213. package/dist/components/Slide/slideI18n.cjs +1 -1
  214. package/dist/components/Slide/slideI18n.cjs.map +1 -1
  215. package/dist/components/Slide/slideI18n.d.ts +6 -3
  216. package/dist/components/Slide/slideI18n.es.js +10 -155
  217. package/dist/components/Slide/slideI18n.es.js.map +1 -1
  218. package/dist/components/Slide/useSlide.d.ts +1 -1
  219. package/dist/components/Slide/utils/appendedMarkerAdvance.d.ts +1 -1
  220. package/dist/components/Slide/utils/audioSegments.d.ts +1 -1
  221. package/dist/components/Slide/utils/interactionResolution.d.ts +2 -2
  222. package/dist/components/Slide/utils/listenModeElementList.d.ts +2 -2
  223. package/dist/components/Slide/utils/markdownScaling.d.ts +1 -1
  224. package/dist/components/Slide/utils/playerCustomActions.d.ts +2 -2
  225. package/dist/components/Slide/utils/playerKeyboardShortcuts.cjs +1 -1
  226. package/dist/components/Slide/utils/playerKeyboardShortcuts.cjs.map +1 -1
  227. package/dist/components/Slide/utils/playerKeyboardShortcuts.d.ts +1 -1
  228. package/dist/components/Slide/utils/playerKeyboardShortcuts.es.js +20 -20
  229. package/dist/components/Slide/utils/playerKeyboardShortcuts.es.js.map +1 -1
  230. package/dist/components/Slide/utils/runStreamFixture.d.ts +1 -1
  231. package/dist/components/Slide/utils/segmentSeek.d.ts +1 -1
  232. package/dist/components/Slide/utils/silentStepAutoAdvance.d.ts +1 -1
  233. package/dist/components/Slide/utils/streamingNavigation.d.ts +1 -1
  234. package/dist/components/Slide/utils/subtitleCue.d.ts +1 -1
  235. package/dist/components/Slide/utils/subtitleJumpNavigation.d.ts +1 -1
  236. package/dist/components/index.d.ts +22 -18
  237. package/dist/components/ui/button.cjs +1 -1
  238. package/dist/components/ui/button.cjs.map +1 -1
  239. package/dist/components/ui/button.es.js +12 -13
  240. package/dist/components/ui/button.es.js.map +1 -1
  241. package/dist/components/ui/checkbox.cjs +1 -1
  242. package/dist/components/ui/checkbox.cjs.map +1 -1
  243. package/dist/components/ui/checkbox.es.js +35 -35
  244. package/dist/components/ui/checkbox.es.js.map +1 -1
  245. package/dist/components/ui/dialog.cjs +1 -1
  246. package/dist/components/ui/dialog.cjs.map +1 -1
  247. package/dist/components/ui/dialog.d.ts +5 -1
  248. package/dist/components/ui/dialog.es.js +37 -37
  249. package/dist/components/ui/dialog.es.js.map +1 -1
  250. package/dist/components/ui/input.cjs +1 -1
  251. package/dist/components/ui/input.cjs.map +1 -1
  252. package/dist/components/ui/input.es.js +4 -4
  253. package/dist/components/ui/input.es.js.map +1 -1
  254. package/dist/components/ui/inputGroup/button.cjs +1 -1
  255. package/dist/components/ui/inputGroup/button.cjs.map +1 -1
  256. package/dist/components/ui/inputGroup/button.es.js +9 -10
  257. package/dist/components/ui/inputGroup/button.es.js.map +1 -1
  258. package/dist/components/ui/inputGroup/input-group.cjs +1 -1
  259. package/dist/components/ui/inputGroup/input-group.cjs.map +1 -1
  260. package/dist/components/ui/inputGroup/input-group.d.ts +1 -1
  261. package/dist/components/ui/inputGroup/input-group.es.js +10 -10
  262. package/dist/components/ui/inputGroup/input-group.es.js.map +1 -1
  263. package/dist/components/ui/inputGroup/textarea.cjs +1 -1
  264. package/dist/components/ui/inputGroup/textarea.cjs.map +1 -1
  265. package/dist/components/ui/inputGroup/textarea.es.js +3 -3
  266. package/dist/components/ui/inputGroup/textarea.es.js.map +1 -1
  267. package/dist/components/ui/loading-overlay-card.cjs +2 -2
  268. package/dist/components/ui/loading-overlay-card.cjs.map +1 -1
  269. package/dist/components/ui/loading-overlay-card.es.js +11 -11
  270. package/dist/components/ui/loading-overlay-card.es.js.map +1 -1
  271. package/dist/components/ui/popover.cjs +1 -1
  272. package/dist/components/ui/popover.cjs.map +1 -1
  273. package/dist/components/ui/popover.es.js +6 -6
  274. package/dist/components/ui/popover.es.js.map +1 -1
  275. package/dist/components/ui/tooltip.cjs +1 -1
  276. package/dist/components/ui/tooltip.cjs.map +1 -1
  277. package/dist/components/ui/tooltip.es.js +16 -16
  278. package/dist/components/ui/tooltip.es.js.map +1 -1
  279. package/dist/editor.d.ts +2 -2
  280. package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
  281. package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
  282. package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  283. package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  284. package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  285. package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  286. package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  287. package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  288. package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  289. package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  290. package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  291. package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  292. package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  293. package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  294. package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  295. package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
  296. package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
  297. package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
  298. package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  299. package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  300. package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  301. package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
  302. package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
  303. package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
  304. package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
  305. package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
  306. package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
  307. package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  308. package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  309. package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  310. package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
  311. package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
  312. package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
  313. package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  314. package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  315. package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  316. package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  317. package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  318. package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  319. package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  320. package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  321. package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  322. package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
  323. package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
  324. package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
  325. package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
  326. package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
  327. package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  328. package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
  329. package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
  330. package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  331. package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
  332. package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
  333. package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  334. package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
  335. package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
  336. package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  337. package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  338. package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  339. package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  340. package/dist/index.cjs +1 -1
  341. package/dist/index.d.ts +2 -2
  342. package/dist/index.es.js +22 -19
  343. package/dist/index.es.js.map +1 -1
  344. package/dist/lib/locale.cjs +1 -1
  345. package/dist/lib/locale.cjs.map +1 -1
  346. package/dist/lib/locale.d.ts +5 -1
  347. package/dist/lib/locale.es.js +26 -13
  348. package/dist/lib/locale.es.js.map +1 -1
  349. package/dist/lib/locale.test.d.ts +1 -0
  350. package/dist/lib/useDetachedLanguage.cjs +2 -0
  351. package/dist/lib/useDetachedLanguage.cjs.map +1 -0
  352. package/dist/lib/useDetachedLanguage.d.ts +3 -0
  353. package/dist/lib/useDetachedLanguage.es.js +25 -0
  354. package/dist/lib/useDetachedLanguage.es.js.map +1 -0
  355. package/dist/lib/useResolvedDirection.cjs +2 -0
  356. package/dist/lib/useResolvedDirection.cjs.map +1 -0
  357. package/dist/lib/useResolvedDirection.d.ts +6 -0
  358. package/dist/lib/useResolvedDirection.es.js +37 -0
  359. package/dist/lib/useResolvedDirection.es.js.map +1 -0
  360. package/dist/markdown-flow-ui-lib.css +1 -1
  361. package/dist/node_modules/@radix-ui/react-arrow/dist/index.cjs +1 -1
  362. package/dist/node_modules/@radix-ui/react-arrow/dist/index.cjs.map +1 -1
  363. package/dist/node_modules/@radix-ui/react-arrow/dist/index.es.js +6 -6
  364. package/dist/node_modules/@radix-ui/react-arrow/dist/index.es.js.map +1 -1
  365. package/dist/node_modules/@radix-ui/react-context/dist/index.cjs +1 -1
  366. package/dist/node_modules/@radix-ui/react-context/dist/index.cjs.map +1 -1
  367. package/dist/node_modules/@radix-ui/react-context/dist/index.es.js +21 -21
  368. package/dist/node_modules/@radix-ui/react-context/dist/index.es.js.map +1 -1
  369. package/dist/node_modules/@radix-ui/react-dialog/dist/index.cjs +2 -2
  370. package/dist/node_modules/@radix-ui/react-dialog/dist/index.cjs.map +1 -1
  371. package/dist/node_modules/@radix-ui/react-dialog/dist/index.es.js +100 -100
  372. package/dist/node_modules/@radix-ui/react-dialog/dist/index.es.js.map +1 -1
  373. package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.cjs +1 -1
  374. package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.cjs.map +1 -1
  375. package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.es.js +38 -38
  376. package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.es.js.map +1 -1
  377. package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.cjs +1 -1
  378. package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.cjs.map +1 -1
  379. package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.es.js +9 -9
  380. package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.es.js.map +1 -1
  381. package/dist/node_modules/@radix-ui/react-popover/dist/index.cjs +1 -1
  382. package/dist/node_modules/@radix-ui/react-popover/dist/index.cjs.map +1 -1
  383. package/dist/node_modules/@radix-ui/react-popover/dist/index.es.js +95 -95
  384. package/dist/node_modules/@radix-ui/react-popover/dist/index.es.js.map +1 -1
  385. package/dist/node_modules/@radix-ui/react-popper/dist/index.cjs +1 -1
  386. package/dist/node_modules/@radix-ui/react-popper/dist/index.cjs.map +1 -1
  387. package/dist/node_modules/@radix-ui/react-popper/dist/index.es.js +48 -48
  388. package/dist/node_modules/@radix-ui/react-popper/dist/index.es.js.map +1 -1
  389. package/dist/node_modules/@radix-ui/react-portal/dist/index.cjs +1 -1
  390. package/dist/node_modules/@radix-ui/react-portal/dist/index.cjs.map +1 -1
  391. package/dist/node_modules/@radix-ui/react-portal/dist/index.es.js +6 -6
  392. package/dist/node_modules/@radix-ui/react-portal/dist/index.es.js.map +1 -1
  393. package/dist/node_modules/@radix-ui/react-primitive/dist/index.cjs +1 -1
  394. package/dist/node_modules/@radix-ui/react-primitive/dist/index.cjs.map +1 -1
  395. package/dist/node_modules/@radix-ui/react-primitive/dist/index.es.js +9 -9
  396. package/dist/node_modules/@radix-ui/react-primitive/dist/index.es.js.map +1 -1
  397. package/dist/node_modules/@radix-ui/react-slot/dist/index.cjs +1 -1
  398. package/dist/node_modules/@radix-ui/react-slot/dist/index.cjs.map +1 -1
  399. package/dist/node_modules/@radix-ui/react-slot/dist/index.es.js +17 -17
  400. package/dist/node_modules/@radix-ui/react-slot/dist/index.es.js.map +1 -1
  401. package/dist/node_modules/@radix-ui/react-tooltip/dist/index.cjs +1 -1
  402. package/dist/node_modules/@radix-ui/react-tooltip/dist/index.cjs.map +1 -1
  403. package/dist/node_modules/@radix-ui/react-tooltip/dist/index.es.js +100 -100
  404. package/dist/node_modules/@radix-ui/react-tooltip/dist/index.es.js.map +1 -1
  405. package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs +1 -1
  406. package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs.map +1 -1
  407. package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.es.js +6 -6
  408. package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.es.js.map +1 -1
  409. package/dist/node_modules/@uiw/react-codemirror/esm/index.cjs +1 -1
  410. package/dist/node_modules/@uiw/react-codemirror/esm/index.cjs.map +1 -1
  411. package/dist/node_modules/@uiw/react-codemirror/esm/index.es.js +27 -27
  412. package/dist/node_modules/@uiw/react-codemirror/esm/index.es.js.map +1 -1
  413. package/dist/node_modules/lucide-react/dist/esm/icons/{chevron-down.cjs → chevrons-down.cjs} +2 -2
  414. package/dist/node_modules/lucide-react/dist/esm/icons/chevrons-down.cjs.map +1 -0
  415. package/dist/node_modules/lucide-react/dist/esm/icons/{chevron-down.es.js → chevrons-down.es.js} +6 -3
  416. package/dist/node_modules/lucide-react/dist/esm/icons/chevrons-down.es.js.map +1 -0
  417. package/dist/node_modules/rc-input/es/BaseInput.cjs +1 -1
  418. package/dist/node_modules/rc-input/es/BaseInput.es.js +1 -1
  419. package/dist/node_modules/rc-textarea/es/ResizableTextArea.cjs +1 -1
  420. package/dist/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
  421. package/dist/node_modules/rc-textarea/es/TextArea.cjs +1 -1
  422. package/dist/node_modules/rc-textarea/es/TextArea.es.js +1 -1
  423. package/dist/node_modules/rc-textarea/es/index.cjs +1 -1
  424. package/dist/node_modules/rc-textarea/es/index.es.js +1 -1
  425. package/dist/node_modules/react-markdown/lib/index.cjs +1 -1
  426. package/dist/node_modules/react-markdown/lib/index.cjs.map +1 -1
  427. package/dist/node_modules/react-markdown/lib/index.es.js +39 -39
  428. package/dist/node_modules/react-markdown/lib/index.es.js.map +1 -1
  429. package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs +1 -1
  430. package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js +1 -1
  431. package/dist/renderer.cjs +1 -1
  432. package/dist/renderer.d.ts +18 -17
  433. package/dist/renderer.es.js +20 -17
  434. package/dist/renderer.es.js.map +1 -1
  435. package/dist/scroll.cjs +2 -0
  436. package/dist/scroll.cjs.map +1 -0
  437. package/dist/scroll.d.ts +6 -0
  438. package/dist/scroll.es.js +9 -0
  439. package/dist/scroll.es.js.map +1 -0
  440. package/dist/slide.d.ts +3 -3
  441. package/package.json +13 -2
  442. package/dist/_virtual/jsx-runtime.cjs +0 -2
  443. package/dist/_virtual/jsx-runtime.cjs.map +0 -1
  444. package/dist/_virtual/jsx-runtime.es.js +0 -6
  445. package/dist/_virtual/jsx-runtime.es.js.map +0 -1
  446. package/dist/_virtual/jsx-runtime.es2.js +0 -5
  447. package/dist/_virtual/jsx-runtime.es2.js.map +0 -1
  448. package/dist/_virtual/jsx-runtime2.cjs +0 -2
  449. package/dist/_virtual/jsx-runtime2.cjs.map +0 -1
  450. package/dist/_virtual/react-jsx-runtime.development.cjs +0 -2
  451. package/dist/_virtual/react-jsx-runtime.development.cjs.map +0 -1
  452. package/dist/_virtual/react-jsx-runtime.development.es.js +0 -5
  453. package/dist/_virtual/react-jsx-runtime.development.es.js.map +0 -1
  454. package/dist/_virtual/react-jsx-runtime.production.cjs +0 -2
  455. package/dist/_virtual/react-jsx-runtime.production.cjs.map +0 -1
  456. package/dist/_virtual/react-jsx-runtime.production.es.js +0 -5
  457. package/dist/_virtual/react-jsx-runtime.production.es.js.map +0 -1
  458. package/dist/lib/localeTextMap.cjs +0 -2
  459. package/dist/lib/localeTextMap.cjs.map +0 -1
  460. package/dist/lib/localeTextMap.es.js +0 -5
  461. package/dist/lib/localeTextMap.es.js.map +0 -1
  462. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs.map +0 -1
  463. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.es.js.map +0 -1
  464. package/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs +0 -24
  465. package/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs.map +0 -1
  466. package/dist/node_modules/react/cjs/react-jsx-runtime.development.es.js +0 -409
  467. package/dist/node_modules/react/cjs/react-jsx-runtime.development.es.js.map +0 -1
  468. package/dist/node_modules/react/cjs/react-jsx-runtime.production.cjs +0 -10
  469. package/dist/node_modules/react/cjs/react-jsx-runtime.production.cjs.map +0 -1
  470. package/dist/node_modules/react/cjs/react-jsx-runtime.production.es.js +0 -36
  471. package/dist/node_modules/react/cjs/react-jsx-runtime.production.es.js.map +0 -1
  472. package/dist/node_modules/react/jsx-runtime.cjs +0 -2
  473. package/dist/node_modules/react/jsx-runtime.cjs.map +0 -1
  474. package/dist/node_modules/react/jsx-runtime.es.js +0 -11
  475. package/dist/node_modules/react/jsx-runtime.es.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ContentRender.es.js","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeRaw from \"rehype-raw\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkFlow from \"remark-flow\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport type { PluggableList } from \"unified\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport { sanitizeInvalidTagName } from \"./utils/sanitize-invalid-tag-name\";\nimport { stripSvgTextLineBreaks } from \"./utils/strip-svg-text-line-breaks\";\nimport \"./contentRender.css\";\nimport \"./github-markdown-light.css\";\nimport CodeBlock from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart from \"./plugins/MermaidChart\";\nimport {\n preserveCustomVariableProperties,\n restoreCustomVariableProperties,\n} from \"./utils/custom-variable-props\";\nimport {\n highlightLanguages,\n subsetLanguages,\n} from \"./utils/highlight-languages\";\n// import { processMarkdownText } from \"./utils/process-markdown\";\nimport {\n parseMarkdownSegments,\n mermaidBlockIsComplete,\n} from \"./utils/mermaid-parse\";\nimport { normalizeInlineHtml } from \"./utils/normalize-inline-html\";\nimport IframeSandbox from \"./IframeSandbox\";\nimport {\n splitContentSegments,\n type RenderSegment,\n} from \"./utils/split-content\";\nimport {\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\n\nconst SANDBOX_TAG_HINT_PATTERN =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\\b/i;\n\n// Define component Props type\nexport interface ContentRenderProps {\n content: string;\n contentType?: string;\n /** Locale used for built-in UI text when a more specific text prop is not provided. */\n locale?: MarkdownFlowLocale;\n /**\n * Callback invoked when the custom button after content is clicked.\n * This button is rendered via the `<custom-button-after-content>` tag in markdown content.\n * @example\n * ```tsx\n * <ContentRender\n * content=\"Hello <custom-button-after-content>Ask</custom-button-after-content>\"\n * onClickCustomButtonAfterContent={() => console.log('Button clicked')}\n * />\n * ```\n */\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onTypeFinished?: () => void;\n onTypewriterStateChange?: (state: ContentRenderTypewriterState) => void;\n userInput?: string;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text (i18n support)\n copyButtonText?: string;\n // Copied state text (i18n support)\n copiedButtonText?: string;\n // Dynamic interaction format for multi-select support\n dynamicInteractionFormat?: string;\n // Loading text before first HTML block renders inside iframe (i18n support)\n sandboxLoadingText?: string;\n // Loading text while styles are being generated inside iframe\n sandboxStyleLoadingText?: string;\n // Loading text while scripts are being cached/executed inside iframe\n sandboxScriptLoadingText?: string;\n // Disable sandbox loading overlays when upper layers have already entered an error state\n disableSandboxLoadingOverlay?: boolean;\n // Fullscreen button text for iframe sandbox\n sandboxFullscreenButtonText?: string;\n // Exit fullscreen button text for iframe sandbox\n sandboxExitFullscreenButtonText?: string;\n // Sandbox render mode\n sandboxMode?: \"content\" | \"blackboard\";\n beforeSend?: (param: OnSendContentParams) => boolean;\n // tooltipMinLength?: number; // Control minimum character length for tooltip display, default 10\n}\n\nexport interface ContentRenderTypewriterState {\n isTypewriterEnabled: boolean;\n isTyping: boolean;\n isComplete: boolean;\n renderedLength: number;\n totalLength: number;\n}\n\n// Render svg string via Shadow DOM to avoid markdown wrapping\nconst SvgBlockInShadow: React.FC<{ svg: string }> = ({ svg }) => {\n const hostRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n const styleId = \"content-render-svg-style\";\n let styleEl = shadowRoot.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.id = styleId;\n // Keep intrinsic SVG width so the wrapper can scroll horizontally when needed\n styleEl.textContent = `\n svg { height: auto; display: inline-block; }\n svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }\n svg.content-render-svg-el--fixed { max-width: none; }\n `;\n shadowRoot.appendChild(styleEl);\n }\n\n const nodesToRemove = Array.from(shadowRoot.childNodes).filter(\n (node) => node !== styleEl\n );\n nodesToRemove.forEach((node) => shadowRoot.removeChild(node));\n\n const template = document.createElement(\"template\");\n const cleanedSvg = stripSvgTextLineBreaks(svg);\n template.innerHTML = cleanedSvg;\n shadowRoot.append(template.content.cloneNode(true));\n\n let hasResponsiveSvg = false;\n let hasFixedSvg = false;\n\n shadowRoot.querySelectorAll(\"svg\").forEach((svgEl) => {\n // Derive responsive sizing from viewBox so pure viewBox SVGs stay visible and fluid\n const viewBox = svgEl.getAttribute(\"viewBox\");\n if (!viewBox) return;\n\n const dimensions = viewBox\n .trim()\n .split(/[\\s,]+/)\n .map((value) => Number(value));\n\n if (dimensions.length !== 4 || dimensions.some(Number.isNaN)) return;\n\n const [, , viewBoxWidth, viewBoxHeight] = dimensions;\n const widthAttr = svgEl.getAttribute(\"width\");\n const heightAttr = svgEl.getAttribute(\"height\");\n const isRelativeLength = (value?: string | null) => {\n if (!value) return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"auto\" || normalized.endsWith(\"%\");\n };\n const toNumericLength = (value?: string | null) => {\n if (!value) return null;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"auto\" || normalized.endsWith(\"%\")) {\n return null;\n }\n const parsed = Number.parseFloat(normalized);\n return Number.isNaN(parsed) ? null : parsed;\n };\n // Treat percentage/auto sizing as responsive so viewBox drives the layout\n const isWidthRelative = isRelativeLength(widthAttr);\n const isHeightRelative = isRelativeLength(heightAttr);\n const widthMissing = !widthAttr || widthAttr === \"0\";\n const heightMissing = !heightAttr || heightAttr === \"0\";\n const numericWidth = toNumericLength(widthAttr);\n const numericHeight = toNumericLength(heightAttr);\n const matchesViewBox =\n numericWidth === viewBoxWidth && numericHeight === viewBoxHeight;\n\n // Prefer responsive layout when sizing is relative or matches the viewBox\n const shouldUseResponsiveSize =\n isWidthRelative ||\n isHeightRelative ||\n (widthMissing && heightMissing) ||\n matchesViewBox;\n\n if (shouldUseResponsiveSize) {\n hasResponsiveSvg = true;\n svgEl.classList.add(\"content-render-svg-el--responsive\");\n svgEl.classList.remove(\"content-render-svg-el--fixed\");\n svgEl.style.width = \"100%\";\n svgEl.style.height = \"auto\";\n if (!svgEl.style.aspectRatio && viewBoxHeight > 0) {\n svgEl.style.aspectRatio = `${viewBoxWidth} / ${viewBoxHeight}`;\n }\n return;\n }\n\n hasFixedSvg = true;\n svgEl.classList.add(\"content-render-svg-el--fixed\");\n svgEl.classList.remove(\"content-render-svg-el--responsive\");\n if (widthMissing && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (heightMissing && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\n\n const hostResponsive = hasResponsiveSvg && !hasFixedSvg;\n host.classList.toggle(\"content-render-svg--responsive\", hostResponsive);\n host.classList.toggle(\"content-render-svg--fixed\", !hostResponsive);\n }, [svg]);\n\n return (\n <div className=\"content-render-svg-scroll\">\n <div className=\"content-render-svg\" ref={hostRef} />\n </div>\n );\n};\n\n// Extended component interface\ntype CustomComponents = ComponentsWithCustomVariable & {\n \"custom-button-after-content\"?: React.ComponentType<{\n children: React.ReactNode;\n }>;\n};\n\ntype MarkdownComponentRuntimeValues = {\n beforeSend?: (param: OnSendContentParams) => boolean;\n locale?: MarkdownFlowLocale;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n readonly: boolean;\n renderContent: string;\n resolvedConfirmButtonText: string;\n resolvedCopiedButtonText: string;\n resolvedCopyButtonText: string;\n resolvedDefaultButtonText?: string;\n resolvedDefaultInputText?: string;\n resolvedDefaultSelectedValues?: string[];\n};\n\nconst remarkPlugins: PluggableList = [\n remarkGfm,\n remarkMath,\n remarkFlow,\n remarkBreaks,\n];\n\nconst rehypePlugins: PluggableList = [\n preserveCustomVariableProperties,\n rehypeRaw,\n sanitizeInvalidTagName,\n restoreCustomVariableProperties,\n [rehypeHighlight, { languages: highlightLanguages, subset: subsetLanguages }],\n rehypeKatex,\n];\n\nexport const MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n}> = ({ content: markdownContent, components }) => (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n);\n\nconst mergeNonSandboxSegments = (segments: RenderSegment[]) => {\n if (segments.length <= 1) return segments;\n const merged: RenderSegment[] = [];\n\n segments.forEach((segment) => {\n if (segment.type === \"sandbox\") {\n merged.push(segment);\n return;\n }\n\n const last = merged[merged.length - 1];\n if (last && last.type !== \"sandbox\") {\n merged[merged.length - 1] = {\n type: \"markdown\",\n value: `${last.value}${segment.value}`,\n };\n return;\n }\n\n merged.push({ type: \"markdown\", value: segment.value });\n });\n\n return merged;\n};\n\nconst splitTextByCharacterChunk = (value: string, chunkSize: number) => {\n const safeChunkSize = Math.max(1, chunkSize);\n const characters = Array.from(value);\n\n return {\n chunk: characters.slice(0, safeChunkSize).join(\"\"),\n rest: characters.slice(safeChunkSize).join(\"\"),\n };\n};\n\nconst areStringArraysEqual = (left?: string[], right?: string[]) => {\n if (left === right) {\n return true;\n }\n if (!left || !right || left.length !== right.length) {\n return false;\n }\n return left.every((value, index) => value === right[index]);\n};\n\nconst useStableStringArray = (values?: string[]) => {\n const valuesRef = useRef<string[] | undefined>(values);\n\n if (!areStringArraysEqual(valuesRef.current, values)) {\n valuesRef.current = values;\n }\n\n return valuesRef.current;\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n contentType,\n locale,\n customRenderBar,\n onSend,\n typingSpeed = 40,\n enableTypewriter = false,\n onTypeFinished,\n onTypewriterStateChange,\n userInput,\n interactionDefaultValueOptions,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n disableSandboxLoadingOverlay = false,\n sandboxFullscreenButtonText,\n sandboxExitFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedConfirmButtonText =\n confirmButtonText || localeTexts.confirmButtonText;\n const resolvedCopyButtonText = copyButtonText || localeTexts.copyButtonText;\n const resolvedCopiedButtonText =\n copiedButtonText || localeTexts.copiedButtonText;\n const resolvedSandboxFullscreenButtonText =\n sandboxFullscreenButtonText || localeTexts.sandboxFullscreenButtonText;\n const resolvedSandboxExitFullscreenButtonText =\n sandboxExitFullscreenButtonText ||\n localeTexts.sandboxExitFullscreenButtonText;\n const shouldApplyTypewriterByContentType =\n !contentType || contentType === \"text\";\n const isTypewriterEnabled =\n Boolean(enableTypewriter) && shouldApplyTypewriterByContentType;\n const typewriterChunkSize = 2;\n const typewriterTickMs = Math.max(0, typingSpeed);\n const [displayContent, setDisplayContent] = useState(() =>\n isTypewriterEnabled ? \"\" : content\n );\n const pendingContentRef = useRef(\"\");\n const previousTypewriterEnabledRef = useRef(isTypewriterEnabled);\n const hasReportedTypeFinishedRef = useRef(false);\n\n useEffect(() => {\n const wasTypewriterEnabled = previousTypewriterEnabledRef.current;\n previousTypewriterEnabledRef.current = isTypewriterEnabled;\n hasReportedTypeFinishedRef.current = false;\n\n if (!isTypewriterEnabled) {\n pendingContentRef.current = \"\";\n setDisplayContent(content);\n return;\n }\n\n setDisplayContent((current) => {\n const shouldRestartTyping = !wasTypewriterEnabled;\n const canContinueTyping = content.startsWith(current);\n\n if (!shouldRestartTyping && !canContinueTyping) {\n pendingContentRef.current = \"\";\n return content;\n }\n\n const nextVisibleContent =\n shouldRestartTyping || !canContinueTyping ? \"\" : current;\n\n pendingContentRef.current = content.slice(nextVisibleContent.length);\n return nextVisibleContent;\n });\n }, [content, isTypewriterEnabled]);\n\n useEffect(() => {\n if (!isTypewriterEnabled) {\n return;\n }\n\n if (\n hasReportedTypeFinishedRef.current ||\n pendingContentRef.current ||\n displayContent !== content\n ) {\n return;\n }\n\n hasReportedTypeFinishedRef.current = true;\n onTypeFinished?.();\n }, [content, displayContent, isTypewriterEnabled, onTypeFinished]);\n\n useEffect(() => {\n if (!isTypewriterEnabled || !pendingContentRef.current) {\n return undefined;\n }\n\n const typewriterTimer = window.setTimeout(() => {\n setDisplayContent((current) => {\n const { chunk, rest } = splitTextByCharacterChunk(\n pendingContentRef.current,\n typewriterChunkSize\n );\n\n if (!chunk) {\n return current;\n }\n\n pendingContentRef.current = rest;\n return `${current}${chunk}`;\n });\n }, typewriterTickMs);\n\n return () => window.clearTimeout(typewriterTimer);\n }, [\n content,\n displayContent,\n isTypewriterEnabled,\n typewriterChunkSize,\n typewriterTickMs,\n ]);\n\n const typewriterState = useMemo<ContentRenderTypewriterState>(\n () => ({\n isTypewriterEnabled,\n isTyping: isTypewriterEnabled && displayContent !== content,\n isComplete: displayContent === content,\n renderedLength: displayContent.length,\n totalLength: content.length,\n }),\n [content, displayContent, isTypewriterEnabled]\n );\n\n useEffect(() => {\n onTypewriterStateChange?.(typewriterState);\n }, [onTypewriterStateChange, typewriterState]);\n\n const renderContent = isTypewriterEnabled ? displayContent : content;\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(renderContent),\n [renderContent]\n );\n\n const interactionDefaults = useMemo(\n () =>\n getInteractionDefaultValues(\n renderContent,\n userInput,\n interactionDefaultValueOptions\n ),\n [interactionDefaultValueOptions, renderContent, userInput]\n );\n\n const resolvedDefaultButtonText =\n defaultButtonText?.trim() || interactionDefaults.buttonText;\n const resolvedDefaultInputText =\n defaultInputText?.trim() || interactionDefaults.inputText;\n const fallbackSelectedValues = useMemo(\n () =>\n userInput\n ? userInput\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined,\n [userInput]\n );\n const resolvedDefaultSelectedValues = defaultSelectedValues?.length\n ? defaultSelectedValues\n : interactionDefaults.selectedValues || fallbackSelectedValues;\n const stableDefaultSelectedValues = useStableStringArray(\n resolvedDefaultSelectedValues\n );\n const componentRuntimeValuesRef = useRef<MarkdownComponentRuntimeValues>({\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n });\n\n componentRuntimeValuesRef.current = {\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n };\n\n const components = useMemo<CustomComponents>(\n () => ({\n \"custom-button-after-content\": ({\n children,\n }: {\n children: React.ReactNode;\n }) => {\n return (\n <button\n className=\"content-render-custom-button-after-content\"\n onClick={\n componentRuntimeValuesRef.current.onClickCustomButtonAfterContent\n }\n >\n <span className=\"content-render-custom-button-after-content-inner\">\n {children}\n </span>\n </button>\n );\n },\n \"custom-variable\": (props) => (\n <CustomButtonInputVariable\n {...props}\n readonly={componentRuntimeValuesRef.current.readonly}\n defaultButtonText={\n componentRuntimeValuesRef.current.resolvedDefaultButtonText\n }\n defaultInputText={\n componentRuntimeValuesRef.current.resolvedDefaultInputText\n }\n defaultSelectedValues={\n componentRuntimeValuesRef.current.resolvedDefaultSelectedValues\n }\n onSend={componentRuntimeValuesRef.current.onSend}\n beforeSend={componentRuntimeValuesRef.current.beforeSend}\n locale={componentRuntimeValuesRef.current.locale}\n confirmButtonText={\n componentRuntimeValuesRef.current.resolvedConfirmButtonText\n }\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: (props) => {\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n };\n const match = /language-(\\w+)/.exec(className || \"\");\n const language = match?.[1];\n if (language === \"mermaid\") {\n const chartContent = children?.toString().replace(/\\n$/, \"\") || \"\";\n const frozen = mermaidBlockIsComplete(\n componentRuntimeValuesRef.current.renderContent,\n chartContent\n );\n return <MermaidChart chart={chartContent} frozen={frozen} />;\n }\n\n return (\n <code className={className} {...rest}>\n {children}\n </code>\n );\n },\n table: ({ ...props }) => (\n <div className=\"content-render-table-container\">\n <table className=\"content-render-table\" {...props} />\n </div>\n ),\n th: ({ ...props }) => <th className=\"content-render-th\" {...props} />,\n td: ({ ...props }) => <td className=\"content-render-td\" {...props} />,\n tr: ({ ...props }) => <tr className=\"content-render-tr\" {...props} />,\n li: ({ node, ...props }) => {\n const className = node?.properties?.className;\n const hasTaskListItem =\n (typeof className === \"string\" &&\n className.includes(\"task-list-item\")) ||\n (Array.isArray(className) && className.includes(\"task-list-item\"));\n if (hasTaskListItem) {\n return <li className=\"content-render-task-list-item\" {...props} />;\n }\n return <li {...props} />;\n },\n ol: ({ ...props }) => <ol className=\"content-render-ol\" {...props} />,\n ul: ({ ...props }) => <ul className=\"content-render-ul\" {...props} />,\n input: ({ ...props }) => {\n if (props.type === \"checkbox\") {\n return (\n <input\n type=\"checkbox\"\n className=\"content-render-checkbox\"\n disabled\n {...props}\n />\n );\n }\n return <input {...props} />;\n },\n a: ({ children, ...props }) => (\n <a target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ),\n pre: (props) => (\n <CodeBlock\n {...props}\n copyButtonText={\n componentRuntimeValuesRef.current.resolvedCopyButtonText\n }\n copiedButtonText={\n componentRuntimeValuesRef.current.resolvedCopiedButtonText\n }\n />\n ),\n }),\n []\n );\n\n const hasPotentialSandboxTags = useMemo(\n () => SANDBOX_TAG_HINT_PATTERN.test(renderContent),\n [renderContent]\n );\n\n const renderSegments = useMemo(\n () =>\n hasPotentialSandboxTags ? splitContentSegments(renderContent, true) : [],\n [renderContent, hasPotentialSandboxTags]\n );\n\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\n );\n const mergedRenderSegments = useMemo(\n () => mergeNonSandboxSegments(renderSegments),\n [renderSegments]\n );\n\n const segments = useMemo(\n () => parseMarkdownSegments(normalizedContent),\n [normalizedContent]\n );\n\n const renderMarkdownSegments = (raw: string, keyPrefix: string) => {\n const normalized = normalizeInlineHtml(raw);\n const parsed = parseMarkdownSegments(normalized);\n\n return parsed.map((seg, index) => {\n const key = `${keyPrefix}-${seg.type}-${index}`;\n\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={key}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart key={key} chart={seg.value} frozen={!seg.complete} />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={key} svg={seg.value} />;\n }\n\n return null;\n });\n };\n\n if (hasSandbox) {\n return (\n <div className=\"content-render markdown-body\">\n {mergedRenderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n hideFullScreen\n type=\"sandbox\"\n content={segment.value}\n className=\"content-render-iframe\"\n locale={locale}\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n disableLoadingOverlay={disableSandboxLoadingOverlay}\n fullScreenButtonText={resolvedSandboxFullscreenButtonText}\n exitFullScreenButtonText={resolvedSandboxExitFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <React.Fragment key={`md-${idx}`}>\n {renderMarkdownSegments(segment.value, `md-${idx}`)}\n </React.Fragment>\n )\n )}\n </div>\n );\n }\n\n return (\n <div className=\"content-render markdown-body\">\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={index}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={index} svg={seg.value} />;\n }\n })}\n\n {customRenderBar && (\n <div className=\"content-render-custom-bar\">\n {React.createElement(customRenderBar, {\n content,\n displayContent: normalizedContent,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SANDBOX_TAG_HINT_PATTERN","SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","cleanedSvg","stripSvgTextLineBreaks","hasResponsiveSvg","hasFixedSvg","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","isRelativeLength","normalized","toNumericLength","parsed","isWidthRelative","isHeightRelative","widthMissing","heightMissing","numericWidth","numericHeight","hostResponsive","jsx","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","ReactMarkdown","mergeNonSandboxSegments","segments","merged","segment","last","splitTextByCharacterChunk","chunkSize","safeChunkSize","characters","areStringArraysEqual","left","right","index","useStableStringArray","values","valuesRef","ContentRender","content","contentType","locale","customRenderBar","onSend","typingSpeed","enableTypewriter","onTypeFinished","onTypewriterStateChange","userInput","interactionDefaultValueOptions","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","disableSandboxLoadingOverlay","sandboxFullscreenButtonText","sandboxExitFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","localeTexts","getContentRenderLocaleTexts","resolvedConfirmButtonText","resolvedCopyButtonText","resolvedCopiedButtonText","resolvedSandboxFullscreenButtonText","resolvedSandboxExitFullscreenButtonText","isTypewriterEnabled","typewriterChunkSize","typewriterTickMs","displayContent","setDisplayContent","useState","pendingContentRef","previousTypewriterEnabledRef","hasReportedTypeFinishedRef","wasTypewriterEnabled","current","shouldRestartTyping","canContinueTyping","nextVisibleContent","typewriterTimer","chunk","rest","typewriterState","useMemo","renderContent","normalizedContent","normalizeInlineHtml","interactionDefaults","getInteractionDefaultValues","resolvedDefaultButtonText","resolvedDefaultInputText","fallbackSelectedValues","resolvedDefaultSelectedValues","stableDefaultSelectedValues","componentRuntimeValuesRef","children","props","CustomButtonInputVariable","className","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","key","idx","IframeSandbox","React","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAMA,KACJ,mGAmEIC,KAA8C,CAAC,EAAE,KAAAC,QAAU;AAC/D,QAAMC,IAAUC,EAAuB,IAAI;AAE3C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAOH,EAAQ;AACrB,QAAI,CAACG,EAAM;AACX,UAAMC,IAAaD,EAAK,cAAcA,EAAK,aAAa,EAAE,MAAM,QAAQ,GAClEE,IAAU;AAChB,QAAIC,IAAUF,EAAW,eAAeC,CAAO;AAE/C,IAAKC,MACHA,IAAU,SAAS,cAAc,OAAO,GACxCA,EAAQ,KAAKD,GAEbC,EAAQ,cAAc;AAAA;AAAA;AAAA;AAAA,SAKtBF,EAAW,YAAYE,CAAO,IAGV,MAAM,KAAKF,EAAW,UAAU,EAAE;AAAA,MACtD,CAACG,MAASA,MAASD;AAAA,IAAA,EAEP,QAAQ,CAACC,MAASH,EAAW,YAAYG,CAAI,CAAC;AAE5D,UAAM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QAAA;AAOX,UAAIuF,EAAI,SAAS;AACf,eACEtH,gBAAAA,EAAAA;AAAAA,UAAC2G;AAAA,UAAA;AAAA,YAEC,OAAOW,EAAI;AAAA,YACX,QAAQ,CAACA,EAAI;AAAA,UAAA;AAAA,UAFRvF;AAAA,QAAA;AAOX,UAAIuF,EAAI,SAAS;AACf,eAAOtH,gBAAAA,EAAAA,IAAClC,IAAA,EAA6B,KAAKwJ,EAAI,SAAhBvF,CAAuB;AAAA,IAEzD,CAAC;AAAA,IAEAQ,KACCvC,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,6BACZ,UAAA0H,GAAM,cAAcnF,GAAiB;AAAA,MACpC,SAAAH;AAAA,MACA,gBAAgBsD;AAAA,MAChB,QAAAlD;AAAA,IAAA,CACD,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"ContentRender.es.js","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeRaw from \"rehype-raw\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkFlow from \"remark-flow\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport type { PluggableList } from \"unified\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport { sanitizeInvalidTagName } from \"./utils/sanitize-invalid-tag-name\";\nimport { stripSvgTextLineBreaks } from \"./utils/strip-svg-text-line-breaks\";\nimport \"./contentRender.css\";\nimport \"./github-markdown-light.css\";\nimport \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport CodeBlock, { CodeBlockContext } from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart, { type MermaidChartProps } from \"./plugins/MermaidChart\";\nimport {\n preserveCustomVariableProperties,\n restoreCustomVariableProperties,\n} from \"./utils/custom-variable-props\";\nimport {\n highlightLanguages,\n subsetLanguages,\n} from \"./utils/highlight-languages\";\n// import { processMarkdownText } from \"./utils/process-markdown\";\nimport {\n parseMarkdownSegments,\n mermaidBlockIsComplete,\n} from \"./utils/mermaid-parse\";\nimport { normalizeInlineHtml } from \"./utils/normalize-inline-html\";\nimport IframeSandbox from \"./IframeSandbox\";\nimport {\n splitContentSegments,\n type RenderSegment,\n} from \"./utils/split-content\";\nimport {\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\n\nconst SANDBOX_TAG_HINT_PATTERN =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\\b/i;\n\n// Define component Props type\nexport interface ContentRenderProps {\n content: string;\n contentType?: string;\n /** Locale used for built-in UI text when a more specific text prop is not provided. */\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language; omitted values inherit from the host. */\n lang?: string;\n /** Overrides locale-derived direction; omitted values inherit when no locale is set. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n /**\n * Callback invoked when the custom button after content is clicked.\n * This button is rendered via the `<custom-button-after-content>` tag in markdown content.\n * @example\n * ```tsx\n * <ContentRender\n * content=\"Hello <custom-button-after-content>Ask</custom-button-after-content>\"\n * onClickCustomButtonAfterContent={() => console.log('Button clicked')}\n * />\n * ```\n */\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onTypeFinished?: () => void;\n onTypewriterStateChange?: (state: ContentRenderTypewriterState) => void;\n userInput?: string;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text (i18n support)\n copyButtonText?: string;\n // Copied state text (i18n support)\n copiedButtonText?: string;\n // Dynamic interaction format for multi-select support\n dynamicInteractionFormat?: string;\n // Loading text before first HTML block renders inside iframe (i18n support)\n sandboxLoadingText?: string;\n // Loading text while styles are being generated inside iframe\n sandboxStyleLoadingText?: string;\n // Loading text while scripts are being cached/executed inside iframe\n sandboxScriptLoadingText?: string;\n // Disable sandbox loading overlays when upper layers have already entered an error state\n disableSandboxLoadingOverlay?: boolean;\n // Fullscreen button text for iframe sandbox\n sandboxFullscreenButtonText?: string;\n // Exit fullscreen button text for iframe sandbox\n sandboxExitFullscreenButtonText?: string;\n // Sandbox render mode\n sandboxMode?: \"content\" | \"blackboard\";\n beforeSend?: (param: OnSendContentParams) => boolean;\n // tooltipMinLength?: number; // Control minimum character length for tooltip display, default 10\n}\n\nexport interface ContentRenderTypewriterState {\n isTypewriterEnabled: boolean;\n isTyping: boolean;\n isComplete: boolean;\n renderedLength: number;\n totalLength: number;\n}\n\n// Render svg string via Shadow DOM to avoid markdown wrapping\nconst SvgBlockInShadow: React.FC<{ svg: string }> = ({ svg }) => {\n const hostRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n const styleId = \"content-render-svg-style\";\n let styleEl = shadowRoot.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.id = styleId;\n // Keep intrinsic SVG width so the wrapper can scroll horizontally when needed\n styleEl.textContent = `\n svg { height: auto; display: inline-block; }\n svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }\n svg.content-render-svg-el--fixed { max-width: none; }\n `;\n shadowRoot.appendChild(styleEl);\n }\n\n const nodesToRemove = Array.from(shadowRoot.childNodes).filter(\n (node) => node !== styleEl\n );\n nodesToRemove.forEach((node) => shadowRoot.removeChild(node));\n\n const template = document.createElement(\"template\");\n const cleanedSvg = stripSvgTextLineBreaks(svg);\n template.innerHTML = cleanedSvg;\n shadowRoot.append(template.content.cloneNode(true));\n\n let hasResponsiveSvg = false;\n let hasFixedSvg = false;\n\n shadowRoot.querySelectorAll(\"svg\").forEach((svgEl) => {\n // Derive responsive sizing from viewBox so pure viewBox SVGs stay visible and fluid\n const viewBox = svgEl.getAttribute(\"viewBox\");\n if (!viewBox) return;\n\n const dimensions = viewBox\n .trim()\n .split(/[\\s,]+/)\n .map((value) => Number(value));\n\n if (dimensions.length !== 4 || dimensions.some(Number.isNaN)) return;\n\n const [, , viewBoxWidth, viewBoxHeight] = dimensions;\n const widthAttr = svgEl.getAttribute(\"width\");\n const heightAttr = svgEl.getAttribute(\"height\");\n const isRelativeLength = (value?: string | null) => {\n if (!value) return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"auto\" || normalized.endsWith(\"%\");\n };\n const toNumericLength = (value?: string | null) => {\n if (!value) return null;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"auto\" || normalized.endsWith(\"%\")) {\n return null;\n }\n const parsed = Number.parseFloat(normalized);\n return Number.isNaN(parsed) ? null : parsed;\n };\n // Treat percentage/auto sizing as responsive so viewBox drives the layout\n const isWidthRelative = isRelativeLength(widthAttr);\n const isHeightRelative = isRelativeLength(heightAttr);\n const widthMissing = !widthAttr || widthAttr === \"0\";\n const heightMissing = !heightAttr || heightAttr === \"0\";\n const numericWidth = toNumericLength(widthAttr);\n const numericHeight = toNumericLength(heightAttr);\n const matchesViewBox =\n numericWidth === viewBoxWidth && numericHeight === viewBoxHeight;\n\n // Prefer responsive layout when sizing is relative or matches the viewBox\n const shouldUseResponsiveSize =\n isWidthRelative ||\n isHeightRelative ||\n (widthMissing && heightMissing) ||\n matchesViewBox;\n\n if (shouldUseResponsiveSize) {\n hasResponsiveSvg = true;\n svgEl.classList.add(\"content-render-svg-el--responsive\");\n svgEl.classList.remove(\"content-render-svg-el--fixed\");\n svgEl.style.width = \"100%\";\n svgEl.style.height = \"auto\";\n if (!svgEl.style.aspectRatio && viewBoxHeight > 0) {\n svgEl.style.aspectRatio = `${viewBoxWidth} / ${viewBoxHeight}`;\n }\n return;\n }\n\n hasFixedSvg = true;\n svgEl.classList.add(\"content-render-svg-el--fixed\");\n svgEl.classList.remove(\"content-render-svg-el--responsive\");\n if (widthMissing && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (heightMissing && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\n\n const hostResponsive = hasResponsiveSvg && !hasFixedSvg;\n host.classList.toggle(\"content-render-svg--responsive\", hostResponsive);\n host.classList.toggle(\"content-render-svg--fixed\", !hostResponsive);\n }, [svg]);\n\n return (\n <div className=\"content-render-svg-scroll\">\n <div className=\"content-render-svg\" ref={hostRef} />\n </div>\n );\n};\n\n// Extended component interface\ntype CustomComponents = ComponentsWithCustomVariable & {\n \"custom-button-after-content\"?: React.ComponentType<{\n children: React.ReactNode;\n }>;\n};\n\ntype MarkdownComponentRuntimeValues = {\n direction?: ContentRenderProps[\"dir\"];\n language?: string;\n mermaidMessages: MermaidChartProps[\"messages\"];\n beforeSend?: (param: OnSendContentParams) => boolean;\n locale?: MarkdownFlowLocale;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n readonly: boolean;\n renderContent: string;\n resolvedConfirmButtonText: string;\n resolvedCopiedButtonText: string;\n resolvedCopyButtonText: string;\n resolvedDefaultButtonText?: string;\n resolvedDefaultInputText?: string;\n resolvedDefaultSelectedValues?: string[];\n};\n\nconst MarkdownComponentRuntimeContext =\n React.createContext<React.RefObject<MarkdownComponentRuntimeValues> | null>(\n null\n );\n\nconst MarkdownCode = (props: React.ComponentProps<\"code\">) => {\n const runtimeValuesRef = React.useContext(MarkdownComponentRuntimeContext);\n const isInCodeBlock = React.useContext(CodeBlockContext);\n if (!runtimeValuesRef) {\n throw new Error(\"Markdown code renderer requires ContentRender context.\");\n }\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n dir?: string;\n };\n const match = /language-(\\w+)/.exec(className || \"\");\n const language = match?.[1];\n if (language === \"mermaid\") {\n const chartContent = children?.toString().replace(/\\n$/, \"\") || \"\";\n const frozen = mermaidBlockIsComplete(\n runtimeValuesRef.current.renderContent,\n chartContent\n );\n return (\n <MermaidChart\n chart={chartContent}\n frozen={frozen}\n messages={runtimeValuesRef.current.mermaidMessages}\n />\n );\n }\n\n return (\n <code\n className={className}\n {...rest}\n dir={rest.dir ?? (isInCodeBlock ? undefined : \"ltr\")}\n >\n {children}\n </code>\n );\n};\n\nconst remarkPlugins: PluggableList = [\n remarkGfm,\n remarkMath,\n remarkFlow,\n remarkBreaks,\n];\n\nconst rehypePlugins: PluggableList = [\n preserveCustomVariableProperties,\n rehypeRaw,\n sanitizeInvalidTagName,\n restoreCustomVariableProperties,\n [rehypeHighlight, { languages: highlightLanguages, subset: subsetLanguages }],\n rehypeKatex,\n];\n\nexport const MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n locale?: MarkdownFlowLocale;\n}> = ({ content: markdownContent, components, locale }) => {\n const texts = getContentRenderLocaleTexts(locale);\n return (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n remarkRehypeOptions={{\n footnoteLabel: texts.footnoteLabel,\n footnoteBackLabel: (referenceIndex, rereferenceIndex) => {\n const reference =\n String(referenceIndex + 1) +\n (rereferenceIndex > 1 ? `-${rereferenceIndex}` : \"\");\n return texts.footnoteBackLabel.replace(\"{reference}\", reference);\n },\n }}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n );\n};\n\nconst mergeNonSandboxSegments = (segments: RenderSegment[]) => {\n if (segments.length <= 1) return segments;\n const merged: RenderSegment[] = [];\n\n segments.forEach((segment) => {\n if (segment.type === \"sandbox\") {\n merged.push(segment);\n return;\n }\n\n const last = merged[merged.length - 1];\n if (last && last.type !== \"sandbox\") {\n merged[merged.length - 1] = {\n type: \"markdown\",\n value: `${last.value}${segment.value}`,\n };\n return;\n }\n\n merged.push({ type: \"markdown\", value: segment.value });\n });\n\n return merged;\n};\n\nconst splitTextByCharacterChunk = (value: string, chunkSize: number) => {\n const safeChunkSize = Math.max(1, chunkSize);\n const characters = Array.from(value);\n\n return {\n chunk: characters.slice(0, safeChunkSize).join(\"\"),\n rest: characters.slice(safeChunkSize).join(\"\"),\n };\n};\n\nconst areStringArraysEqual = (left?: string[], right?: string[]) => {\n if (left === right) {\n return true;\n }\n if (!left || !right || left.length !== right.length) {\n return false;\n }\n return left.every((value, index) => value === right[index]);\n};\n\nconst useStableStringArray = (values?: string[]) => {\n const valuesRef = useRef<string[] | undefined>(values);\n\n if (!areStringArraysEqual(valuesRef.current, values)) {\n valuesRef.current = values;\n }\n\n return valuesRef.current;\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n contentType,\n locale,\n lang,\n dir,\n customRenderBar,\n onSend,\n typingSpeed = 40,\n enableTypewriter = false,\n onTypeFinished,\n onTypewriterStateChange,\n userInput,\n interactionDefaultValueOptions,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n disableSandboxLoadingOverlay = false,\n sandboxFullscreenButtonText,\n sandboxExitFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const mermaidMessages = useMemo(\n () => ({\n loading: localeTexts.mermaidLoadingText,\n emptyChart: localeTexts.mermaidEmptyChartText,\n error: localeTexts.mermaidErrorText,\n }),\n [localeTexts]\n );\n const direction = dir ?? getMarkdownFlowDirection(locale);\n const language = lang ?? getMarkdownFlowLanguage(locale);\n const resolvedConfirmButtonText =\n confirmButtonText || localeTexts.confirmButtonText;\n const resolvedCopyButtonText = copyButtonText || localeTexts.copyButtonText;\n const resolvedCopiedButtonText =\n copiedButtonText || localeTexts.copiedButtonText;\n const resolvedSandboxFullscreenButtonText =\n sandboxFullscreenButtonText || localeTexts.sandboxFullscreenButtonText;\n const resolvedSandboxExitFullscreenButtonText =\n sandboxExitFullscreenButtonText ||\n localeTexts.sandboxExitFullscreenButtonText;\n const shouldApplyTypewriterByContentType =\n !contentType || contentType === \"text\";\n const isTypewriterEnabled =\n Boolean(enableTypewriter) && shouldApplyTypewriterByContentType;\n const typewriterChunkSize = 2;\n const typewriterTickMs = Math.max(0, typingSpeed);\n const [displayContent, setDisplayContent] = useState(() =>\n isTypewriterEnabled ? \"\" : content\n );\n const pendingContentRef = useRef(\"\");\n const previousTypewriterEnabledRef = useRef(isTypewriterEnabled);\n const hasReportedTypeFinishedRef = useRef(false);\n\n useEffect(() => {\n const wasTypewriterEnabled = previousTypewriterEnabledRef.current;\n previousTypewriterEnabledRef.current = isTypewriterEnabled;\n hasReportedTypeFinishedRef.current = false;\n\n if (!isTypewriterEnabled) {\n pendingContentRef.current = \"\";\n setDisplayContent(content);\n return;\n }\n\n setDisplayContent((current) => {\n const shouldRestartTyping = !wasTypewriterEnabled;\n const canContinueTyping = content.startsWith(current);\n\n if (!shouldRestartTyping && !canContinueTyping) {\n pendingContentRef.current = \"\";\n return content;\n }\n\n const nextVisibleContent =\n shouldRestartTyping || !canContinueTyping ? \"\" : current;\n\n pendingContentRef.current = content.slice(nextVisibleContent.length);\n return nextVisibleContent;\n });\n }, [content, isTypewriterEnabled]);\n\n useEffect(() => {\n if (!isTypewriterEnabled) {\n return;\n }\n\n if (\n hasReportedTypeFinishedRef.current ||\n pendingContentRef.current ||\n displayContent !== content\n ) {\n return;\n }\n\n hasReportedTypeFinishedRef.current = true;\n onTypeFinished?.();\n }, [content, displayContent, isTypewriterEnabled, onTypeFinished]);\n\n useEffect(() => {\n if (!isTypewriterEnabled || !pendingContentRef.current) {\n return undefined;\n }\n\n const typewriterTimer = window.setTimeout(() => {\n setDisplayContent((current) => {\n const { chunk, rest } = splitTextByCharacterChunk(\n pendingContentRef.current,\n typewriterChunkSize\n );\n\n if (!chunk) {\n return current;\n }\n\n pendingContentRef.current = rest;\n return `${current}${chunk}`;\n });\n }, typewriterTickMs);\n\n return () => window.clearTimeout(typewriterTimer);\n }, [\n content,\n displayContent,\n isTypewriterEnabled,\n typewriterChunkSize,\n typewriterTickMs,\n ]);\n\n const typewriterState = useMemo<ContentRenderTypewriterState>(\n () => ({\n isTypewriterEnabled,\n isTyping: isTypewriterEnabled && displayContent !== content,\n isComplete: displayContent === content,\n renderedLength: displayContent.length,\n totalLength: content.length,\n }),\n [content, displayContent, isTypewriterEnabled]\n );\n\n useEffect(() => {\n onTypewriterStateChange?.(typewriterState);\n }, [onTypewriterStateChange, typewriterState]);\n\n const renderContent = isTypewriterEnabled ? displayContent : content;\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(renderContent),\n [renderContent]\n );\n\n const interactionDefaults = useMemo(\n () =>\n getInteractionDefaultValues(\n renderContent,\n userInput,\n interactionDefaultValueOptions\n ),\n [interactionDefaultValueOptions, renderContent, userInput]\n );\n\n const resolvedDefaultButtonText =\n defaultButtonText?.trim() || interactionDefaults.buttonText;\n const resolvedDefaultInputText =\n defaultInputText?.trim() || interactionDefaults.inputText;\n const fallbackSelectedValues = useMemo(\n () =>\n userInput\n ? userInput\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined,\n [userInput]\n );\n const resolvedDefaultSelectedValues = defaultSelectedValues?.length\n ? defaultSelectedValues\n : interactionDefaults.selectedValues || fallbackSelectedValues;\n const stableDefaultSelectedValues = useStableStringArray(\n resolvedDefaultSelectedValues\n );\n const componentRuntimeValuesRef = useRef<MarkdownComponentRuntimeValues>({\n direction,\n language,\n mermaidMessages,\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n });\n\n componentRuntimeValuesRef.current = {\n direction,\n language,\n mermaidMessages,\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n };\n\n const components = useMemo<CustomComponents>(\n () => ({\n \"custom-button-after-content\": ({\n children,\n }: {\n children: React.ReactNode;\n }) => {\n return (\n <button\n className=\"content-render-custom-button-after-content\"\n onClick={\n componentRuntimeValuesRef.current.onClickCustomButtonAfterContent\n }\n >\n <span className=\"content-render-custom-button-after-content-inner\">\n {children}\n </span>\n </button>\n );\n },\n \"custom-variable\": (props) => (\n <CustomButtonInputVariable\n {...props}\n readonly={componentRuntimeValuesRef.current.readonly}\n defaultButtonText={\n componentRuntimeValuesRef.current.resolvedDefaultButtonText\n }\n defaultInputText={\n componentRuntimeValuesRef.current.resolvedDefaultInputText\n }\n defaultSelectedValues={\n componentRuntimeValuesRef.current.resolvedDefaultSelectedValues\n }\n onSend={componentRuntimeValuesRef.current.onSend}\n beforeSend={componentRuntimeValuesRef.current.beforeSend}\n locale={componentRuntimeValuesRef.current.locale}\n dir={componentRuntimeValuesRef.current.direction}\n lang={componentRuntimeValuesRef.current.language}\n confirmButtonText={\n componentRuntimeValuesRef.current.resolvedConfirmButtonText\n }\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: MarkdownCode,\n table: ({ ...props }) => (\n <div className=\"content-render-table-container\">\n <table className=\"content-render-table\" {...props} />\n </div>\n ),\n th: ({ ...props }) => <th className=\"content-render-th\" {...props} />,\n td: ({ ...props }) => <td className=\"content-render-td\" {...props} />,\n tr: ({ ...props }) => <tr className=\"content-render-tr\" {...props} />,\n li: ({ node, ...props }) => {\n const className = node?.properties?.className;\n const hasTaskListItem =\n (typeof className === \"string\" &&\n className.includes(\"task-list-item\")) ||\n (Array.isArray(className) && className.includes(\"task-list-item\"));\n if (hasTaskListItem) {\n return <li className=\"content-render-task-list-item\" {...props} />;\n }\n return <li {...props} />;\n },\n ol: ({ ...props }) => <ol className=\"content-render-ol\" {...props} />,\n ul: ({ ...props }) => <ul className=\"content-render-ul\" {...props} />,\n input: ({ ...props }) => {\n if (props.type === \"checkbox\") {\n return (\n <input\n type=\"checkbox\"\n className=\"content-render-checkbox\"\n disabled\n {...props}\n />\n );\n }\n return <input {...props} />;\n },\n a: ({ children, ...props }) => (\n <a target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ),\n pre: (props) => (\n <CodeBlock\n {...props}\n copyButtonText={\n componentRuntimeValuesRef.current.resolvedCopyButtonText\n }\n copiedButtonText={\n componentRuntimeValuesRef.current.resolvedCopiedButtonText\n }\n />\n ),\n }),\n []\n );\n\n const hasPotentialSandboxTags = useMemo(\n () => SANDBOX_TAG_HINT_PATTERN.test(renderContent),\n [renderContent]\n );\n\n const renderSegments = useMemo(\n () =>\n hasPotentialSandboxTags ? splitContentSegments(renderContent, true) : [],\n [renderContent, hasPotentialSandboxTags]\n );\n\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\n );\n const mergedRenderSegments = useMemo(\n () => mergeNonSandboxSegments(renderSegments),\n [renderSegments]\n );\n\n const segments = useMemo(\n () => parseMarkdownSegments(normalizedContent),\n [normalizedContent]\n );\n\n const renderMarkdownSegments = (raw: string, keyPrefix: string) => {\n const normalized = normalizeInlineHtml(raw);\n const parsed = parseMarkdownSegments(normalized);\n\n return parsed.map((seg, index) => {\n const key = `${keyPrefix}-${seg.type}-${index}`;\n\n if (seg.type === \"text\") {\n return (\n <MarkdownComponentRuntimeContext.Provider\n key={key}\n value={componentRuntimeValuesRef}\n >\n <MarkdownRenderer\n locale={locale}\n components={components}\n content={seg.value}\n />\n </MarkdownComponentRuntimeContext.Provider>\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={key}\n chart={seg.value}\n frozen={!seg.complete}\n messages={mermaidMessages}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={key} svg={seg.value} />;\n }\n\n return null;\n });\n };\n\n if (hasSandbox) {\n return (\n <div\n className=\"content-render markdown-body\"\n dir={direction}\n lang={language}\n >\n {mergedRenderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n hideFullScreen\n type=\"sandbox\"\n content={segment.value}\n className=\"content-render-iframe\"\n locale={locale}\n dir={direction}\n lang={language}\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n disableLoadingOverlay={disableSandboxLoadingOverlay}\n fullScreenButtonText={resolvedSandboxFullscreenButtonText}\n exitFullScreenButtonText={resolvedSandboxExitFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <React.Fragment key={`md-${idx}`}>\n {renderMarkdownSegments(segment.value, `md-${idx}`)}\n </React.Fragment>\n )\n )}\n </div>\n );\n }\n\n return (\n <div\n className=\"content-render markdown-body\"\n dir={direction}\n lang={language}\n >\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownComponentRuntimeContext.Provider\n key={index}\n value={componentRuntimeValuesRef}\n >\n <MarkdownRenderer\n locale={locale}\n components={components}\n content={seg.value}\n />\n </MarkdownComponentRuntimeContext.Provider>\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n messages={mermaidMessages}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={index} svg={seg.value} />;\n }\n })}\n\n {customRenderBar && (\n <div className=\"content-render-custom-bar\">\n {React.createElement(customRenderBar, {\n content,\n displayContent: normalizedContent,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SANDBOX_TAG_HINT_PATTERN","SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","cleanedSvg","stripSvgTextLineBreaks","hasResponsiveSvg","hasFixedSvg","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","isRelativeLength","normalized","toNumericLength","parsed","isWidthRelative","isHeightRelative","widthMissing","heightMissing","numericWidth","numericHeight","hostResponsive","jsx","MarkdownComponentRuntimeContext","React","MarkdownCode","props","runtimeValuesRef","isInCodeBlock","CodeBlockContext","className","children","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","locale","texts","getContentRenderLocaleTexts","ReactMarkdown","referenceIndex","rereferenceIndex","reference","mergeNonSandboxSegments","segments","merged","segment","last","splitTextByCharacterChunk","chunkSize","safeChunkSize","characters","areStringArraysEqual","left","right","index","useStableStringArray","values","valuesRef","ContentRender","content","contentType","lang","dir","customRenderBar","onSend","typingSpeed","enableTypewriter","onTypeFinished","onTypewriterStateChange","userInput","interactionDefaultValueOptions","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","disableSandboxLoadingOverlay","sandboxFullscreenButtonText","sandboxExitFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","localeTexts","mermaidMessages","useMemo","direction","getMarkdownFlowDirection","language","getMarkdownFlowLanguage","resolvedConfirmButtonText","resolvedCopyButtonText","resolvedCopiedButtonText","resolvedSandboxFullscreenButtonText","resolvedSandboxExitFullscreenButtonText","isTypewriterEnabled","typewriterChunkSize","typewriterTickMs","displayContent","setDisplayContent","useState","pendingContentRef","previousTypewriterEnabledRef","hasReportedTypeFinishedRef","wasTypewriterEnabled","current","shouldRestartTyping","canContinueTyping","nextVisibleContent","typewriterTimer","chunk","typewriterState","renderContent","normalizedContent","normalizeInlineHtml","interactionDefaults","getInteractionDefaultValues","resolvedDefaultButtonText","resolvedDefaultInputText","fallbackSelectedValues","resolvedDefaultSelectedValues","stableDefaultSelectedValues","componentRuntimeValuesRef","CustomButtonInputVariable","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","key","idx","IframeSandbox","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAMA,KACJ,mGAuEIC,KAA8C,CAAC,EAAE,KAAAC,QAAU;AAC/D,QAAMC,IAAUC,EAAuB,IAAI;AAE3C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAOH,EAAQ;AACrB,QAAI,CAACG,EAAM;AACX,UAAMC,IAAaD,EAAK,cAAcA,EAAK,aAAa,EAAE,MAAM,QAAQ,GAClEE,IAAU;AAChB,QAAIC,IAAUF,EAAW,eAAeC,CAAO;AAE/C,IAAKC,MACHA,IAAU,SAAS,cAAc,OAAO,GACxCA,EAAQ,KAAKD,GAEbC,EAAQ,cAAc;AAAA;AAAA;AAAA;AAAA,SAKtBF,EAAW,YAAYE,CAAO,IAGV,MAAM,KAAKF,EAAW,UAAU,EAAE;AAAA,MACtD,CAACG,MAASA,MAASD;AAAA,IAAA,EAEP,QAAQ,CAACC,MAASH,EAAW,YAAYG,CAAI,CAAC;AAE5D,UAAMC,IAAW,SAAS,cAAc,UAAU,GAC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;AAAA,oBACA,YAAAD;AAAA,oBACA,SAASwG,EAAI;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACf;AAAA,cAPKpF;AAAA,YAAA;AAYX,cAAIoF,EAAI,SAAS;AACf,mBACE,gBAAAvI;AAAA,cAACc;AAAA,cAAA;AAAA,gBAEC,OAAOyH,EAAI;AAAA,gBACX,QAAQ,CAACA,EAAI;AAAA,gBACb,UAAUlD;AAAA,cAAA;AAAA,cAHLlC;AAAA,YAAA;AAQX,cAAIoF,EAAI,SAAS;AACf,mBAAO,gBAAAvI,EAAClC,IAAA,EAA6B,KAAKyK,EAAI,SAAhBpF,CAAuB;AAAA,QAEzD,CAAC;AAAA,QAEAS,KACC,gBAAA5D,EAAC,OAAA,EAAI,WAAU,6BACZ,UAAAE,EAAM,cAAc0D,GAAiB;AAAA,UACpC,SAAAJ;AAAA,UACA,gBAAgB0D;AAAA,UAChB,QAAArD;AAAA,QAAA,CACD,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
@@ -1,15 +1,15 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M=require("../../_virtual/jsx-runtime.cjs"),t=require("react"),et=require("react-dom/client"),tt=require("./SandboxApp.cjs"),nt=require("./ContentRender.cjs"),T=require("./utils/iframe-viewport-height.cjs"),Ne=require("../../lib/sandboxInteraction.cjs"),rt=require("./utils/iframe-scaling.cjs"),ot=require("./contentRenderI18n.cjs"),it=require("./cjkFontFamily.cjs");let xe=null;const Ve=()=>(xe||(xe=Promise.resolve().then(()=>require("./blackboard-vendor.cjs"))),xe),st=/<img\b[^>]*>/i,ct=180,lt=240,ut=i=>i.split(/\s+/).filter(Boolean).map(o=>{const c=o.split(":");return c[c.length-1]!=="h-screen"&&c[c.length-1]!=="min-h-screen"?o:(c[c.length-1]="h-full",c.join(":"))}).join(" "),at=(i,o)=>!o||!i.trim()?i:i.replace(/^(\s*<[a-zA-Z][\w:-]*)(\s[^>]*?)?>/,(c,b,_="")=>{const m=_.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);if(!m)return c;const k=ut(m[2]);return k===m[2]?c:`${b}${_.replace(m[0],`class=${m[1]}${k}${m[1]}`)}>`}),ht=({content:i,type:o,className:c,locale:b,loadingText:_,styleLoadingText:m,scriptLoadingText:k,fullScreenButtonText:We,exitFullScreenButtonText:Be,hideFullScreen:qe=!1,mode:h="content",replaceRootScreenHeightWithFull:Pe=!1,enableScaling:$e=!1,disableLoadingOverlay:Q=!1})=>{const we=ot.getContentRenderLocaleTexts(b),ze=We||we.sandboxFullscreenButtonText,De=Be||we.sandboxExitFullscreenButtonText,I=t.useRef(null),x=t.useRef(null),P=t.useRef(null),O=t.useRef(()=>{}),[Le,Ge]=t.useState(480),[He,Ye]=t.useState(0),[Z,ee]=t.useState(0),te=t.useRef(!1),ne=t.useRef(!1),pe=t.useRef(0),[Re,Ue]=t.useState(0),[re,Xe]=t.useState(!1),oe=o==="sandbox",w=h==="blackboard",H=$e&&w&&o==="sandbox",j=w&&o==="sandbox",A=j&&Pe,ie=t.useRef(""),$=t.useMemo(()=>o==="sandbox"?i:"",[i,o]),s=t.useMemo(()=>at($,A),[$,A]),Se=t.useMemo(()=>A?T.inspectViewportHeightFromHtmlRootString($):T.EMPTY_ROOT_HEIGHT_META,[$,A]),se=t.useMemo(()=>A&&Se.hasFullViewportHeight,[Se.hasFullViewportHeight,A]),[z,Ee]=t.useState(s),ve=t.useRef(s),ce=t.useRef(s),N=t.useRef(null),p=t.useRef(null),ye=t.useRef(null),Ce=t.useCallback(n=>{if(typeof window>"u")return;const e=Date.now();e-pe.current<lt||(pe.current=e,window.postMessage({source:Ne.SANDBOX_INTERACTION_MESSAGE_SOURCE,type:Ne.SANDBOX_INTERACTION_MESSAGE_TYPE,eventType:n},window.location.origin))},[]),le=()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null)},Ke=()=>{p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null)};t.useEffect(()=>()=>{le(),Ke()},[]),t.useEffect(()=>{const n=ve.current;ve.current=s;const e=!!n&&s.length>n.length&&s.startsWith(n),d=st.test(s);if(!(e&&d)){le(),ce.current=s,Ee(s);return}ce.current=s,le(),N.current=window.setTimeout(()=>{Ee(ce.current),N.current=null},ct)},[s]);const D=t.useMemo(()=>j?T.inspectViewportHeightFromHtmlRootString(z).viewportHeightCss:null,[z,j]);t.useEffect(()=>{ye.current=D},[D]);const ue=!!D,V=w&&o==="sandbox"?H||se?"100%":D??`${Le}px`:void 0;t.useEffect(()=>{if(h!=="blackboard"){ie.current=s;return}const n=ie.current;!(n&&s.startsWith(n))&&n&&Ue(d=>d+1),ie.current=s},[h,s]),t.useEffect(()=>{const n=x.current;if(!n)return;const e=n.contentDocument;if(!e)return;e.open(),e.write(`<!DOCTYPE html>
2
- <html${h==="blackboard"?' style="height: 100%;"':""}>
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _=require("react/jsx-runtime"),t=require("react"),Ht=require("react-dom/client"),xt=require("./SandboxApp.cjs"),Rt=require("./ContentRender.cjs"),A=require("./utils/iframe-viewport-height.cjs"),Ye=require("../../lib/sandboxInteraction.cjs"),pt=require("./utils/iframe-scaling.cjs"),Ue=require("../../lib/locale.cjs"),St=require("../../lib/useDetachedLanguage.cjs"),Xe=require("../../lib/useResolvedDirection.cjs"),vt=require("./contentRenderI18n.cjs"),Et=require("./cjkFontFamily.cjs");let Se=null;const Ke=()=>(Se||(Se=Promise.resolve().then(()=>require("./blackboard-vendor.cjs"))),Se),Ct=/<img\b[^>]*>/i,yt=180,Mt=240,Tt=i=>i.split(/\s+/).filter(Boolean).map(o=>{const l=o.split(":");return l[l.length-1]!=="h-screen"&&l[l.length-1]!=="min-h-screen"?o:(l[l.length-1]="h-full",l.join(":"))}).join(" "),kt=(i,o)=>!o||!i.trim()?i:i.replace(/^(\s*<[a-zA-Z][\w:-]*)(\s[^>]*?)?>/,(l,h,P="")=>{const w=P.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);if(!w)return l;const I=Tt(w[2]);return I===w[2]?l:`${h}${P.replace(w[0],`class=${w[1]}${I}${w[1]}`)}>`}),Ft=({content:i,type:o,className:l,locale:h,lang:P,dir:w,loadingText:I,styleLoadingText:ve,scriptLoadingText:Ee,fullScreenButtonText:Je,exitFullScreenButtonText:Qe,hideFullScreen:Ze=!1,mode:u="content",replaceRootScreenHeightWithFull:et=!1,enableScaling:tt=!1,disableLoadingOverlay:ee=!1})=>{const Ce=vt.getContentRenderLocaleTexts(h),H=w??Ue.getMarkdownFlowDirection(h),te=P??Ue.getMarkdownFlowLanguage(h),nt=Je||Ce.sandboxFullscreenButtonText,rt=Qe||Ce.sandboxExitFullscreenButtonText,C=t.useRef(null),ye=St.useDetachedLanguage(C,te),{resolvedDirection:ne}=Xe.useResolvedDirection(C,H),Me=t.useRef(null),Te=t.useRef(null),ot=t.useCallback(n=>{Me.current=n,Te.current=n?.querySelector(".content-render")??null},[]),{resolvedDirection:it}=Xe.useResolvedDirection(Te,H),ke=H??ne,Fe=t.useRef(H);Fe.current=H;const[st,ct]=t.useState();let z;H==="auto"&&(z=ne,o==="sandbox"?z=st??ne:u==="blackboard"&&(z=it));const x=t.useRef(null),L=t.useRef(null),q=t.useRef(()=>{}),[lt,ut]=t.useState(480),[Ae,at]=t.useState(0),[re,oe]=t.useState(0),ie=t.useRef(!1),se=t.useRef(!1),_e=t.useRef(0),[De,dt]=t.useState(0),[ce,ht]=t.useState(!1),le=o==="sandbox",R=u==="blackboard",p=tt&&R&&o==="sandbox",O=R&&o==="sandbox",D=O&&et,ue=t.useRef(""),$=t.useMemo(()=>o==="sandbox"?i:"",[i,o]),s=t.useMemo(()=>kt($,D),[$,D]),Ie=t.useMemo(()=>D?A.inspectViewportHeightFromHtmlRootString($):A.EMPTY_ROOT_HEIGHT_META,[$,D]),ae=t.useMemo(()=>D&&Ie.hasFullViewportHeight,[Ie.hasFullViewportHeight,D]),[G,qe]=t.useState(s),Oe=t.useRef(s),de=t.useRef(s),V=t.useRef(null),S=t.useRef(null),Ve=t.useRef(null),he=t.useCallback(n=>{if(typeof window>"u")return;const e=Date.now();e-_e.current<Mt||(_e.current=e,window.postMessage({source:Ye.SANDBOX_INTERACTION_MESSAGE_SOURCE,type:Ye.SANDBOX_INTERACTION_MESSAGE_TYPE,eventType:n},window.location.origin))},[]);t.useEffect(()=>{if(o!=="markdown"||u!=="blackboard")return;const n=Me.current;if(!n)return;const e=()=>he("click");return n.addEventListener("click",e),()=>n.removeEventListener("click",e)},[he,u,o]);const fe=()=>{V.current!==null&&(window.clearTimeout(V.current),V.current=null)},ft=()=>{S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null)};t.useEffect(()=>()=>{fe(),ft()},[]),t.useEffect(()=>{const n=Oe.current;Oe.current=s;const e=!!n&&s.length>n.length&&s.startsWith(n),f=Ct.test(s);if(!(e&&f)){fe(),de.current=s,qe(s);return}de.current=s,fe(),V.current=window.setTimeout(()=>{qe(de.current),V.current=null},yt)},[s]);const Y=t.useMemo(()=>O?A.inspectViewportHeightFromHtmlRootString(G).viewportHeightCss:null,[G,O]);t.useEffect(()=>{Ve.current=Y},[Y]);const me=!!Y,N=R&&o==="sandbox"?p||ae?"100%":Y??`${lt}px`:void 0;t.useEffect(()=>{if(u!=="blackboard"){ue.current=s;return}const n=ue.current;!(n&&s.startsWith(n))&&n&&dt(f=>f+1),ue.current=s},[u,s]),t.useEffect(()=>{const n=x.current;if(!n)return;const e=n.contentDocument;if(!e)return;e.open(),e.write(`<!DOCTYPE html>
2
+ <html${u==="blackboard"?' style="height: 100%;"':""}>
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <style>
7
7
  :root { color-scheme: light; }
8
- html, body, #root { width: 100%; font-family: ${it.CJK_SAFE_SANS_FONT_FAMILY}; }
9
- ${h==="blackboard"?"html, body, #root { height: 100%; }":""}
10
- html, body { margin: 0; padding: 0; overflow: ${H?"hidden auto":h==="blackboard"?"auto":"hidden"}; }
8
+ html, body, #root { width: 100%; font-family: ${Et.CJK_SAFE_SANS_FONT_FAMILY}; }
9
+ ${u==="blackboard"?"html, body, #root { height: 100%; }":""}
10
+ html, body { margin: 0; padding: 0; overflow: ${p?"hidden auto":u==="blackboard"?"auto":"hidden"}; }
11
11
  *, *::before, *::after { box-sizing: border-box; }
12
- ${h!=="blackboard"?`
12
+ ${u!=="blackboard"?`
13
13
  .h-screen { height: auto !important; }
14
14
  .min-h-screen { min-height: auto !important; }
15
15
  .h-dvh, .h-svh, .h-lvh { height: auto !important; }
@@ -20,5 +20,5 @@
20
20
  <body>
21
21
  <div id="root"></div>
22
22
  </body>
23
- </html>`),e.close(),e.documentElement.setAttribute("data-theme","light"),e.documentElement.style.colorScheme="light",e.body?.style.setProperty("color-scheme","light");const d=w&&o==="sandbox",L=()=>Ce("click");d&&e.addEventListener("click",L,!0);const W=e.getElementById("root");if(!W)return;const ae=et.createRoot(W);P.current=ae;let R=!1;const Me=r=>({heightAttrValue:r.getAttribute("height"),styleAttrValue:r.getAttribute("style"),classAttrValue:r.getAttribute("class")}),Ae=r=>{const u=Array.from(r.children);return u.length===1?u[0]:null},Ze=()=>{if(!j||!x.current||!e.body)return null;const r=x.current.ownerDocument?.documentElement?.clientHeight||window.innerHeight,u=ye.current,F=u?T.parseExplicitHeight(u,r):null;if(F!==null)return Math.ceil(F);const f=e.body.querySelector(".sandbox-wrapper")?.firstElementChild;if(!f)return null;const g=Array.from(f.children),v=g.length===1?g[0]:null,K=T.inspectViewportHeightFromNodeChain(v,{getNode:Me,getSingleChild:Ae}).viewportHeightCss;if(K){const B=T.parseExplicitHeight(K,r);if(B!==null)return Math.ceil(B)}const a=T.resolveExplicitHeightFromNodeChain(v,r,{getNode:Me,getSingleChild:Ae});return a!==null?Math.ceil(a):null},he=()=>{if(!x.current||!e.body)return;if(!w){if(te.current){ne.current=!0;return}te.current=!0;const f=x.current,g=I.current?.clientWidth||0,v=f.style.height;if(g>0){const be=Math.round(g*9/16),K=Math.max(8192,g*20);f.style.height=be+"px",e.body.offsetHeight;let a=e.body.scrollHeight;const B=e.defaultView;if(B){const q=S=>{let y=0;const Oe=C=>{if(C!==S&&C.scrollHeight>C.clientHeight+1){const J=B.getComputedStyle(C).overflowY;if(J==="auto"||J==="scroll"){const je=C.getBoundingClientRect();je.top>=0&&(y=Math.max(y,Math.ceil(je.top+C.scrollHeight)))}}for(const J of C.children)Oe(J)};return Oe(S),y};a=Math.max(a,q(e.body));for(let S=0;S<8&&a>be;S++){f.style.height=a+"px",e.body.offsetHeight;const y=Math.max(e.body.scrollHeight,q(e.body));if(y<=a+1||y>=a*1.5)break;a=y}}f.style.height=v,Ye(q=>{const S=Math.min(K,Math.max(200,Math.ceil(a)));return q===S?q:S})}setTimeout(()=>{te.current=!1,ne.current&&(ne.current=!1,E())},50);return}if(H)return;const r=e.body.scrollHeight,u=e.documentElement?.scrollHeight||0,F=W?.scrollHeight||0,X=Math.max(r,u,F);if(j){const f=Ze(),g=Math.max(200,f??Math.ceil(X));Ge(v=>v===g?v:g)}},E=()=>{requestAnimationFrame(()=>{R||he()})};O.current=E,he(),E(),oe&&Ve().then(({injectBlackboardLibraries:r})=>{R||(r(e),H&&rt.injectScalingSystem(e),requestAnimationFrame(()=>{R||E()}))}).catch(()=>{R||E()});const l=I.current;let de=!!(l&&(l.clientWidth<=0||l.clientHeight<=0)),G=!1,Y=null,U=null;const Fe=()=>{if(R)return;E(),n.contentWindow?.__mdf_triggerFitContent?.()},fe=()=>!!(l&&l.clientWidth>0&&l.clientHeight>0),_e=()=>{!oe||!l||!de||G||!fe()||(G=!0,Ve().then(({refreshTailwindRuntime:r})=>{R||(Y=window.requestAnimationFrame(()=>{Y=null,G=!1;const u=e.querySelector(".sandbox-container");R||!fe()||!u?.childNodes.length||!r(e)||(de=!1,Fe(),U=window.setTimeout(()=>{U=null,Fe()},100))}))}).catch(()=>{G=!1}))},ke=typeof ResizeObserver<"u",me=oe&&l&&ke?new ResizeObserver(r=>{const u=r[0]?.contentRect,F=u?.width??l.clientWidth,X=u?.height??l.clientHeight;F>0&&X>0&&_e()}):null;me&&l&&me.observe(l);const ge=ke?new ResizeObserver(()=>he()):null;ge?.observe(e.body),W&&ge?.observe(W);const Ie=new MutationObserver(()=>{if(E(),!fe()){de=!0;return}_e()});return Ie.observe(e.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]}),()=>{R=!0,me?.disconnect(),ge?.disconnect(),Ie.disconnect(),Y!==null&&window.cancelAnimationFrame(Y),U!==null&&window.clearTimeout(U),H&&n.contentWindow?.__mdf_cleanupScaling?.(),d&&e.removeEventListener("click",L,!0),P.current===ae&&(P.current=null,O.current=()=>{}),setTimeout(()=>{ae.unmount()},0)}},[]),t.useEffect(()=>{const n=()=>{Xe(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]),t.useEffect(()=>{const n=I.current;if(!n)return;if(typeof ResizeObserver>"u"){ee(n.clientWidth);return}const e=new ResizeObserver(d=>{ee(d[0]?.contentRect.width??n.clientWidth)});return e.observe(n),ee(n.clientWidth),()=>e.disconnect()},[]);const Te=t.useMemo(()=>{if(w||Z===0||re)return;const n=Math.round(Z*9/16);return{height:Math.max(n,He)}},[w,Z,He,re]),Je=()=>{const n=I.current||x.current;if(n){if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}n.requestFullscreen&&n.requestFullscreen().catch(()=>{})}};t.useEffect(()=>{const n=P.current;if(!n)return;n.render(M.jsxRuntimeExports.jsx(tt.default,{html:z,locale:b,loadingText:_,styleLoadingText:m,scriptLoadingText:k,disableLoadingOverlay:Q,resetToken:Re,hasRootVhHeight:ue,mode:h,stretchRootHeight:se,enableScaling:H})),p.current=window.requestAnimationFrame(()=>{O.current?.(),H&&x.current?.contentWindow?.__mdf_triggerFitContent?.(),p.current=null});const e=setTimeout(()=>O.current?.(),100),d=setTimeout(()=>O.current?.(),500);return()=>{p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null),clearTimeout(e),clearTimeout(d)}},[z,b,_,m,k,Re,Q,ue,h,se,H]);const Qe=[`w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${o}`,w?"h-full overflow-auto flex flex-col":Te?"overflow-hidden flex items-center justify-center":"aspect-[16/9] overflow-hidden flex items-center justify-center"].filter(Boolean).join(" ");return M.jsxRuntimeExports.jsxs("div",{ref:I,"data-root-vh":ue?"true":"false",className:Qe,style:V?{height:V,minHeight:V}:Te,children:[!qe&&M.jsxRuntimeExports.jsx("button",{type:"button",onClick:Je,className:"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",children:re?De:ze}),h==="blackboard"&&o==="markdown"?M.jsxRuntimeExports.jsx("div",{onClick:()=>Ce("click"),children:M.jsxRuntimeExports.jsx(nt.default,{content:i,locale:b,disableSandboxLoadingOverlay:Q})}):M.jsxRuntimeExports.jsx("iframe",{ref:x,sandbox:"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allow:"fullscreen",allowFullScreen:!0,className:[c,"w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),style:{height:V??"100%",minHeight:V,margin:"auto"}})]})},dt=i=>{const o=i.mode??"content",c=!!(i.enableScaling&&o==="blackboard"&&i.type==="sandbox"),b=`${i.type}:${o}:${c?"scaled":"unscaled"}`;return M.jsxRuntimeExports.jsx(ht,{...i},b)};exports.default=dt;
23
+ </html>`),e.close(),e.documentElement.setAttribute("data-theme","light"),e.documentElement.style.colorScheme="light",e.body?.style.setProperty("color-scheme","light");const f=R&&o==="sandbox",U=()=>he("click");f&&e.addEventListener("click",U,!0);const W=e.getElementById("root");if(!W)return;const ge=Ht.createRoot(W);L.current=ge;let v=!1;const We=r=>({heightAttrValue:r.getAttribute("height"),styleAttrValue:r.getAttribute("style"),classAttrValue:r.getAttribute("class")}),Be=r=>{const c=Array.from(r.children);return c.length===1?c[0]:null},bt=()=>{if(!O||!x.current||!e.body)return null;const r=x.current.ownerDocument?.documentElement?.clientHeight||window.innerHeight,c=Ve.current,g=c?A.parseExplicitHeight(c,r):null;if(g!==null)return Math.ceil(g);const m=e.body.querySelector(".sandbox-wrapper")?.firstElementChild;if(!m)return null;const b=Array.from(m.children),T=b.length===1?b[0]:null,Q=A.inspectViewportHeightFromNodeChain(T,{getNode:We,getSingleChild:Be}).viewportHeightCss;if(Q){const B=A.parseExplicitHeight(Q,r);if(B!==null)return Math.ceil(B)}const d=A.resolveExplicitHeightFromNodeChain(T,r,{getNode:We,getSingleChild:Be});return d!==null?Math.ceil(d):null},be=()=>{if(!x.current||!e.body)return;if(!R){if(ie.current){se.current=!0;return}ie.current=!0;const m=x.current,b=C.current?.clientWidth||0,T=m.style.height;if(b>0){const pe=Math.round(b*9/16),Q=Math.max(8192,b*20);m.style.height=pe+"px",e.body.offsetHeight;let d=e.body.scrollHeight;const B=e.defaultView;if(B){const j=E=>{let k=0;const $e=F=>{if(F!==E&&F.scrollHeight>F.clientHeight+1){const Z=B.getComputedStyle(F).overflowY;if(Z==="auto"||Z==="scroll"){const Ge=F.getBoundingClientRect();Ge.top>=0&&(k=Math.max(k,Math.ceil(Ge.top+F.scrollHeight)))}}for(const Z of F.children)$e(Z)};return $e(E),k};d=Math.max(d,j(e.body));for(let E=0;E<8&&d>pe;E++){m.style.height=d+"px",e.body.offsetHeight;const k=Math.max(e.body.scrollHeight,j(e.body));if(k<=d+1||k>=d*1.5)break;d=k}}m.style.height=T,at(j=>{const E=Math.min(Q,Math.max(200,Math.ceil(d)));return j===E?j:E})}setTimeout(()=>{ie.current=!1,se.current&&(se.current=!1,y())},50);return}if(p)return;const r=e.body.scrollHeight,c=e.documentElement?.scrollHeight||0,g=W?.scrollHeight||0,M=Math.max(r,c,g);if(O){const m=bt(),b=Math.max(200,m??Math.ceil(M));ut(T=>T===b?T:b)}},y=()=>{requestAnimationFrame(()=>{v||be()})};q.current=y,be(),y(),le&&Ke().then(({injectBlackboardLibraries:r})=>{v||(r(e),p&&pt.injectScalingSystem(e),requestAnimationFrame(()=>{v||y()}))}).catch(()=>{v||y()});const a=C.current;let we=!!(a&&(a.clientWidth<=0||a.clientHeight<=0)),X=!1,K=null,J=null;const je=()=>{if(v)return;y(),n.contentWindow?.__mdf_triggerFitContent?.()},He=()=>!!(a&&a.clientWidth>0&&a.clientHeight>0),Pe=()=>{!le||!a||!we||X||!He()||(X=!0,Ke().then(({refreshTailwindRuntime:r})=>{v||(K=window.requestAnimationFrame(()=>{K=null,X=!1;const c=e.querySelector(".sandbox-container");v||!He()||!c?.childNodes.length||!r(e)||(we=!1,je(),J=window.setTimeout(()=>{J=null,je()},100))}))}).catch(()=>{X=!1}))},ze=typeof ResizeObserver<"u",xe=le&&a&&ze?new ResizeObserver(r=>{const c=r[0]?.contentRect,g=c?.width??a.clientWidth,M=c?.height??a.clientHeight;g>0&&M>0&&Pe()}):null;xe&&a&&xe.observe(a);const Re=ze?new ResizeObserver(()=>be()):null;Re?.observe(e.body),W&&Re?.observe(W);const wt=()=>{if(o!=="sandbox"||Fe.current!=="auto")return;const r=e.querySelector(".sandbox-wrapper"),c=e.defaultView;if(!r||!c)return;const g=c.getComputedStyle(r).direction==="rtl"?"rtl":"ltr";ct(M=>M===g?M:g)},Le=new MutationObserver(()=>{if(wt(),y(),!He()){we=!0;return}Pe()});return Le.observe(e.body,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","dir"]}),()=>{v=!0,xe?.disconnect(),Re?.disconnect(),Le.disconnect(),K!==null&&window.cancelAnimationFrame(K),J!==null&&window.clearTimeout(J),p&&n.contentWindow?.__mdf_cleanupScaling?.(),f&&e.removeEventListener("click",U,!0),L.current===ge&&(L.current=null,q.current=()=>{}),setTimeout(()=>{ge.unmount()},0)}},[]),t.useEffect(()=>{const n=()=>{ht(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]),t.useEffect(()=>{const n=C.current;if(!n)return;if(typeof ResizeObserver>"u"){oe(n.clientWidth);return}const e=new ResizeObserver(f=>{oe(f[0]?.contentRect.width??n.clientWidth)});return e.observe(n),oe(n.clientWidth),()=>e.disconnect()},[]);const Ne=t.useMemo(()=>{if(R||re===0||ce)return;const n=Math.round(re*9/16);return{height:Math.max(n,Ae)}},[R,re,Ae,ce]),mt=()=>{const n=C.current||x.current;if(n){if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}n.requestFullscreen&&n.requestFullscreen().catch(()=>{})}};t.useEffect(()=>{const n=L.current;if(!n)return;n.render(_.jsx(xt.default,{html:G,locale:h,dir:ke,lang:ye,loadingText:I,styleLoadingText:ve,scriptLoadingText:Ee,disableLoadingOverlay:ee,resetToken:De,hasRootVhHeight:me,mode:u,stretchRootHeight:ae,enableScaling:p})),S.current=window.requestAnimationFrame(()=>{q.current?.(),p&&x.current?.contentWindow?.__mdf_triggerFitContent?.(),S.current=null});const e=setTimeout(()=>q.current?.(),100),f=setTimeout(()=>q.current?.(),500);return()=>{S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null),clearTimeout(e),clearTimeout(f)}},[G,h,ke,ye,I,ve,Ee,De,ee,me,u,ae,p]);const gt=[`w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${o}`,R?"h-full overflow-auto flex flex-col":Ne?"overflow-hidden flex items-center justify-center":"aspect-[16/9] overflow-hidden flex items-center justify-center"].filter(Boolean).join(" ");return _.jsxs("div",{ref:C,dir:H,lang:te,"data-root-vh":me?"true":"false",className:gt,style:N?{height:N,minHeight:N}:Ne,children:[!Ze&&_.jsx("button",{type:"button",dir:z,onClick:mt,className:"absolute top-2 end-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",children:ce?rt:nt}),u==="blackboard"&&o==="markdown"?_.jsx("div",{ref:ot,children:_.jsx(Rt.default,{content:i,locale:h,dir:H,lang:te,disableSandboxLoadingOverlay:ee})}):_.jsx("iframe",{ref:x,sandbox:"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allow:"fullscreen",allowFullScreen:!0,className:[l,"w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),style:{height:N??"100%",minHeight:N,margin:"auto"}})]})},At=i=>{const o=i.mode??"content",l=!!(i.enableScaling&&o==="blackboard"&&i.type==="sandbox"),h=`${i.type}:${o}:${l?"scaled":"unscaled"}`;return _.jsx(Ft,{...i},h)};exports.default=At;
24
24
  //# sourceMappingURL=IframeSandbox.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IframeSandbox.cjs","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport SandboxApp from \"./SandboxApp\";\nimport ContentRender from \"./ContentRender\";\nimport {\n EMPTY_ROOT_HEIGHT_META,\n inspectViewportHeightFromHtmlRootString,\n inspectViewportHeightFromNodeChain,\n parseExplicitHeight,\n resolveExplicitHeightFromNodeChain,\n} from \"./utils/iframe-viewport-height\";\nimport {\n SANDBOX_INTERACTION_MESSAGE_SOURCE,\n SANDBOX_INTERACTION_MESSAGE_TYPE,\n} from \"../../lib/sandboxInteraction\";\nimport {\n injectScalingSystem,\n type ScalingWindow,\n} from \"./utils/iframe-scaling\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\nimport { CJK_SAFE_SANS_FONT_FAMILY } from \"./cjkFontFamily\";\n\ntype BlackboardVendorModule = typeof import(\"./blackboard-vendor\");\n\n// Cache the sandbox vendor loader so every iframe reuses the same preload request.\nlet blackboardVendorPromise: Promise<BlackboardVendorModule> | null = null;\n\nconst loadBlackboardVendor = () => {\n if (!blackboardVendorPromise) {\n blackboardVendorPromise = import(\"./blackboard-vendor\");\n }\n\n return blackboardVendorPromise;\n};\n\nconst COMPLETE_IMAGE_TAG_PATTERN = /<img\\b[^>]*>/i;\nconst POST_IMAGE_STREAM_DEBOUNCE_MS = 180;\nconst SANDBOX_INTERACTION_THROTTLE_MS = 240;\n\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n locale?: MarkdownFlowLocale;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n exitFullScreenButtonText?: string;\n hideFullScreen?: boolean;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n replaceRootScreenHeightWithFull?: boolean;\n enableScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst replaceRootScreenHeightToken = (className: string) =>\n className\n .split(/\\s+/)\n .filter(Boolean)\n .map((token) => {\n const segments = token.split(\":\");\n if (\n segments[segments.length - 1] !== \"h-screen\" &&\n segments[segments.length - 1] !== \"min-h-screen\"\n ) {\n return token;\n }\n segments[segments.length - 1] = \"h-full\";\n return segments.join(\":\");\n })\n .join(\" \");\n\nconst replaceRootScreenHeightWithFullClass = (\n html: string,\n enabled: boolean\n) => {\n if (!enabled || !html.trim()) {\n return html;\n }\n\n return html.replace(\n /^(\\s*<[a-zA-Z][\\w:-]*)(\\s[^>]*?)?>/,\n (match, tagStart: string, attrs = \"\") => {\n const classMatch = attrs.match(/\\bclass\\s*=\\s*([\"'])([^\"']*)\\1/i);\n\n if (!classMatch) {\n return match;\n }\n\n const nextClassName = replaceRootScreenHeightToken(classMatch[2]);\n\n if (nextClassName === classMatch[2]) {\n return match;\n }\n\n return `${tagStart}${attrs.replace(\n classMatch[0],\n `class=${classMatch[1]}${nextClassName}${classMatch[1]}`\n )}>`;\n }\n );\n};\n\nconst IframeSandboxInstance: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n locale,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n exitFullScreenButtonText,\n hideFullScreen = false,\n mode = \"content\",\n replaceRootScreenHeightWithFull = false,\n enableScaling = false,\n disableLoadingOverlay = false,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedFullScreenButtonText =\n fullScreenButtonText || localeTexts.sandboxFullscreenButtonText;\n const resolvedExitFullScreenButtonText =\n exitFullScreenButtonText || localeTexts.sandboxExitFullscreenButtonText;\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const [contentHeight, setContentHeight] = useState(0);\n const [containerWidth, setContainerWidth] = useState(0);\n const isMeasuringContentRef = useRef(false);\n const pendingHeightUpdateRef = useRef(false);\n const lastSandboxInteractionTimeRef = useRef(0);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const shouldInjectSandboxVendor = type === \"sandbox\";\n\n const isBlackboardMode = mode === \"blackboard\";\n const shouldEnableScaling =\n enableScaling && isBlackboardMode && type === \"sandbox\";\n const shouldMeasureDynamicHeight = isBlackboardMode && type === \"sandbox\";\n const shouldProcessRootScreenHeight =\n shouldMeasureDynamicHeight && replaceRootScreenHeightWithFull;\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(\n () => (type === \"sandbox\" ? content : \"\"),\n [content, type]\n );\n const normalizedHtmlContent = React.useMemo(\n () =>\n replaceRootScreenHeightWithFullClass(\n htmlContent,\n shouldProcessRootScreenHeight\n ),\n [htmlContent, shouldProcessRootScreenHeight]\n );\n const originalRootHeightMeta = React.useMemo(\n () =>\n shouldProcessRootScreenHeight\n ? inspectViewportHeightFromHtmlRootString(htmlContent)\n : EMPTY_ROOT_HEIGHT_META,\n [htmlContent, shouldProcessRootScreenHeight]\n );\n const shouldStretchRootHeight = React.useMemo(\n () =>\n shouldProcessRootScreenHeight &&\n originalRootHeightMeta.hasFullViewportHeight,\n [\n originalRootHeightMeta.hasFullViewportHeight,\n shouldProcessRootScreenHeight,\n ]\n );\n const [renderHtmlContent, setRenderHtmlContent] = useState(\n normalizedHtmlContent\n );\n const prevIncomingHtmlRef = useRef(normalizedHtmlContent);\n const pendingHtmlRef = useRef(normalizedHtmlContent);\n const deferRenderTimerRef = useRef<number | null>(null);\n const initialPaintFrameRef = useRef<number | null>(null);\n const renderViewportHeightCssRef = useRef<string | null>(null);\n\n const emitSandboxInteraction = useCallback((eventType: string) => {\n if (typeof window === \"undefined\") {\n return;\n }\n const now = Date.now();\n if (\n now - lastSandboxInteractionTimeRef.current <\n SANDBOX_INTERACTION_THROTTLE_MS\n ) {\n return;\n }\n lastSandboxInteractionTimeRef.current = now;\n window.postMessage(\n {\n source: SANDBOX_INTERACTION_MESSAGE_SOURCE,\n type: SANDBOX_INTERACTION_MESSAGE_TYPE,\n eventType,\n },\n window.location.origin\n );\n }, []);\n\n const clearDeferredRenderTimer = () => {\n if (deferRenderTimerRef.current === null) return;\n window.clearTimeout(deferRenderTimerRef.current);\n deferRenderTimerRef.current = null;\n };\n\n const clearInitialPaintFrames = () => {\n if (initialPaintFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintFrameRef.current);\n initialPaintFrameRef.current = null;\n }\n };\n\n useEffect(\n () => () => {\n clearDeferredRenderTimer();\n clearInitialPaintFrames();\n },\n []\n );\n\n useEffect(() => {\n const prevIncomingHtml = prevIncomingHtmlRef.current;\n prevIncomingHtmlRef.current = normalizedHtmlContent;\n\n const isAppendOnlyStream =\n !!prevIncomingHtml &&\n normalizedHtmlContent.length > prevIncomingHtml.length &&\n normalizedHtmlContent.startsWith(prevIncomingHtml);\n const containsCompleteImage = COMPLETE_IMAGE_TAG_PATTERN.test(\n normalizedHtmlContent\n );\n const shouldDeferRender = isAppendOnlyStream && containsCompleteImage;\n\n if (!shouldDeferRender) {\n clearDeferredRenderTimer();\n pendingHtmlRef.current = normalizedHtmlContent;\n setRenderHtmlContent(normalizedHtmlContent);\n return;\n }\n\n pendingHtmlRef.current = normalizedHtmlContent;\n clearDeferredRenderTimer();\n deferRenderTimerRef.current = window.setTimeout(() => {\n setRenderHtmlContent(pendingHtmlRef.current);\n deferRenderTimerRef.current = null;\n }, POST_IMAGE_STREAM_DEBOUNCE_MS);\n }, [normalizedHtmlContent]);\n\n const rootViewportHeightCss = React.useMemo(() => {\n if (!shouldMeasureDynamicHeight) {\n return null;\n }\n\n return inspectViewportHeightFromHtmlRootString(renderHtmlContent)\n .viewportHeightCss;\n }, [renderHtmlContent, shouldMeasureDynamicHeight]);\n\n useEffect(() => {\n renderViewportHeightCssRef.current = rootViewportHeightCss;\n }, [rootViewportHeightCss]);\n\n const hasRootVhHeight = Boolean(rootViewportHeightCss);\n const sandboxViewportHeight =\n isBlackboardMode && type === \"sandbox\"\n ? shouldEnableScaling\n ? \"100%\"\n : shouldStretchRootHeight\n ? \"100%\"\n : (rootViewportHeightCss ?? `${height}px`)\n : undefined;\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = normalizedHtmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && normalizedHtmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = normalizedHtmlContent;\n }, [mode, normalizedHtmlContent]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return undefined;\n\n const doc = iframe.contentDocument;\n if (!doc) return undefined;\n\n doc.open();\n doc.write(`<!DOCTYPE html>\n<html${mode === \"blackboard\" ? ' style=\"height: 100%;\"' : \"\"}>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <style>\n :root { color-scheme: light; }\n html, body, #root { width: 100%; font-family: ${CJK_SAFE_SANS_FONT_FAMILY}; }\n ${mode === \"blackboard\" ? \"html, body, #root { height: 100%; }\" : \"\"}\n html, body { margin: 0; padding: 0; overflow: ${shouldEnableScaling ? \"hidden auto\" : mode === \"blackboard\" ? \"auto\" : \"hidden\"}; }\n *, *::before, *::after { box-sizing: border-box; }\n ${\n mode !== \"blackboard\"\n ? `\n .h-screen { height: auto !important; }\n .min-h-screen { min-height: auto !important; }\n .h-dvh, .h-svh, .h-lvh { height: auto !important; }\n .min-h-dvh, .min-h-svh, .min-h-lvh { min-height: auto !important; }\n `\n : \"\"\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n\n // Force iframe theme to stay in light mode regardless of host OS preference.\n doc.documentElement.setAttribute(\"data-theme\", \"light\");\n doc.documentElement.style.colorScheme = \"light\";\n doc.body?.style.setProperty(\"color-scheme\", \"light\");\n\n const shouldBridgeSandboxInteraction =\n isBlackboardMode && type === \"sandbox\";\n const handleSandboxClick = () => emitSandboxInteraction(\"click\");\n\n if (shouldBridgeSandboxInteraction) {\n doc.addEventListener(\"click\", handleSandboxClick, true);\n }\n\n const rootEl = doc.getElementById(\"root\");\n if (!rootEl) return undefined;\n\n const root = createRoot(rootEl);\n rootRef.current = root;\n let isDestroyed = false;\n const getHeightInspectionNode = (node: HTMLElement) => ({\n heightAttrValue: node.getAttribute(\"height\"),\n styleAttrValue: node.getAttribute(\"style\"),\n classAttrValue: node.getAttribute(\"class\"),\n });\n const getSingleChildElement = (node: HTMLElement) => {\n const childElements = Array.from(node.children) as HTMLElement[];\n\n return childElements.length === 1 ? childElements[0] : null;\n };\n\n const resolveExplicitHeight = () => {\n if (!shouldMeasureDynamicHeight) return null;\n if (!iframeRef.current || !doc.body) return null;\n const parentViewportHeight =\n iframeRef.current.ownerDocument?.documentElement?.clientHeight ||\n window.innerHeight;\n // Reuse parsed height metadata from the current html snapshot first to\n // avoid re-inspecting the same DOM chain on every height tick.\n const precomputedViewportHeightCss = renderViewportHeightCssRef.current;\n const parsed = precomputedViewportHeightCss\n ? parseExplicitHeight(\n precomputedViewportHeightCss,\n parentViewportHeight\n )\n : null;\n\n if (parsed !== null) {\n return Math.ceil(parsed);\n }\n\n const wrapper = doc.body.querySelector(\n \".sandbox-wrapper\"\n ) as HTMLElement | null;\n const container = wrapper?.firstElementChild as HTMLElement | null;\n if (!container) return null;\n const containerChildren = Array.from(container.children) as HTMLElement[];\n const rootContentElement =\n containerChildren.length === 1 ? containerChildren[0] : null;\n const runtimeHeightMeta = inspectViewportHeightFromNodeChain(\n rootContentElement,\n {\n getNode: getHeightInspectionNode,\n getSingleChild: getSingleChildElement,\n }\n );\n const runtimeViewportHeightCss = runtimeHeightMeta.viewportHeightCss;\n\n if (runtimeViewportHeightCss) {\n const runtimeViewportHeight = parseExplicitHeight(\n runtimeViewportHeightCss,\n parentViewportHeight\n );\n\n if (runtimeViewportHeight !== null) {\n return Math.ceil(runtimeViewportHeight);\n }\n }\n\n const explicitPixelHeight = resolveExplicitHeightFromNodeChain(\n rootContentElement,\n parentViewportHeight,\n {\n getNode: getHeightInspectionNode,\n getSingleChild: getSingleChildElement,\n }\n );\n\n return explicitPixelHeight !== null\n ? Math.ceil(explicitPixelHeight)\n : null;\n };\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n\n if (!isBlackboardMode) {\n // Guard: prevent re-entrant measurement from ResizeObserver /\n // MutationObserver callbacks triggered by our own height changes.\n if (isMeasuringContentRef.current) {\n // Mark that an update was requested while the guard was active.\n // We will retry once the guard releases (see setTimeout below).\n pendingHeightUpdateRef.current = true;\n return;\n }\n isMeasuringContentRef.current = true;\n\n // Content mode height measurement strategy:\n // Temporarily set iframe height to the 16:9 minimum so that:\n // 1. vmin units are stable: vmin = min(cw, minH)/100 = minH/100,\n // consistent with the final rendered 16:9 iframe.\n // 2. Viewport-filling content (e.g. inline style=\"height:100vh\")\n // fills the 16:9 space → scrollHeight = minH, which is then\n // correctly bounded by the 16:9 minimum in contentModeStyle.\n // (Previously using cw caused such content to report 1:1 height,\n // overriding the 16:9 minimum.)\n const iframe = iframeRef.current;\n const cw = containerRef.current?.clientWidth || 0;\n const prevH = iframe.style.height;\n\n if (cw > 0) {\n const minH = Math.round((cw * 9) / 16);\n // Absolute height cap. Diverging vh-feedback (multiple `height:100vh`\n // siblings, or compound vh-relative children whose sum exceeds the\n // viewport) can otherwise grow the iframe geometrically across\n // repeated ResizeObserver/MutationObserver passes. 1:20 aspect is\n // a generous upper bound for any single sandbox slide.\n const maxH = Math.max(8192, cw * 20);\n iframe.style.height = minH + \"px\";\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n doc.body.offsetHeight; // force layout\n\n let measuredH = doc.body.scrollHeight;\n\n // Detect inner elements that clip overflowing content behind a\n // scrollbar (e.g. <div style=\"height:100vh; overflow-y:auto\"> whose\n // content is taller than the iframe). body.scrollHeight won't see\n // that overflow, so we walk the tree and factor in each scrollable\n // element's full scroll height based on its position in the iframe.\n const iframeWin = doc.defaultView;\n if (iframeWin) {\n // Returns the max natural bottom of inner elements that clip\n // content via overflow:auto/scroll (i.e. internal scrollbars).\n const getInnerScrollableHeight = (root: Element): number => {\n let maxH = 0;\n const walk = (el: Element) => {\n if (el !== root && el.scrollHeight > el.clientHeight + 1) {\n const oy = iframeWin.getComputedStyle(el).overflowY;\n if (oy === \"auto\" || oy === \"scroll\") {\n const rect = el.getBoundingClientRect();\n if (rect.top >= 0) {\n maxH = Math.max(\n maxH,\n Math.ceil(rect.top + el.scrollHeight)\n );\n }\n }\n }\n for (const child of el.children) walk(child);\n };\n walk(root);\n return maxH;\n };\n\n measuredH = Math.max(measuredH, getInnerScrollableHeight(doc.body));\n\n // Content that uses vh-relative sizing grows as the viewport\n // expands. Measure up to 8 more times at the expanded height so\n // we capture the full content height in a single updateHeight()\n // call rather than waiting for external re-triggers.\n for (let i = 0; i < 8 && measuredH > minH; i++) {\n iframe.style.height = measuredH + \"px\";\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n doc.body.offsetHeight; // force layout at expanded size\n const nextH = Math.max(\n doc.body.scrollHeight,\n getInnerScrollableHeight(doc.body)\n );\n if (nextH <= measuredH + 1) break; // stable — stop iterating\n // Geometric vh-feedback detection: vh-relative children scale\n // with the iframe viewport, so growing the iframe makes them\n // larger which grows scrollHeight — runaway divergence. Two\n // `height:100vh` siblings produce a 2× per-iteration multiplier.\n // Stop iterating; keep the prior (stable) measuredH.\n if (nextH >= measuredH * 1.5) break;\n measuredH = nextH;\n }\n }\n\n // Restore iframe to let React control it via contentModeStyle\n iframe.style.height = prevH;\n\n setContentHeight((prev) => {\n const next = Math.min(maxH, Math.max(200, Math.ceil(measuredH)));\n return prev === next ? prev : next;\n });\n }\n\n setTimeout(() => {\n isMeasuringContentRef.current = false;\n // Retry any update that was blocked while the guard was active\n // (e.g. dynamic content injected by scripts or images loading).\n if (pendingHeightUpdateRef.current) {\n pendingHeightUpdateRef.current = false;\n scheduleHeightUpdate();\n }\n }, 50);\n return;\n }\n\n // Scaling mode: viewport is fixed, content scales via font-size.\n if (shouldEnableScaling) return;\n\n // Blackboard mode: use existing measurement logic\n const bodyScrollH = doc.body.scrollHeight;\n const htmlScrollH = doc.documentElement?.scrollHeight || 0;\n const rootScrollH = rootEl?.scrollHeight || 0;\n const measuredHeight = Math.max(bodyScrollH, htmlScrollH, rootScrollH);\n\n if (shouldMeasureDynamicHeight) {\n const explicitHeight = resolveExplicitHeight();\n const nextHeight = Math.max(\n 200,\n explicitHeight ?? Math.ceil(measuredHeight)\n );\n setHeight((prevHeight) =>\n prevHeight === nextHeight ? prevHeight : nextHeight\n );\n }\n };\n const scheduleHeightUpdate = () => {\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n updateHeight();\n });\n };\n updateHeightRef.current = scheduleHeightUpdate;\n\n updateHeight();\n scheduleHeightUpdate();\n\n if (shouldInjectSandboxVendor) {\n // Inject Tailwind/DaisyUI/GSAP before rendering sandbox content to avoid FOUC.\n loadBlackboardVendor()\n .then(({ injectBlackboardLibraries }) => {\n if (isDestroyed) return;\n injectBlackboardLibraries(doc);\n if (shouldEnableScaling) {\n injectScalingSystem(doc);\n }\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n });\n })\n .catch(() => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n });\n }\n\n const hostElement = containerRef.current;\n let needsTailwindRefreshAfterHidden = Boolean(\n hostElement &&\n (hostElement.clientWidth <= 0 || hostElement.clientHeight <= 0)\n );\n let isTailwindRefreshQueued = false;\n let tailwindRefreshFrame: number | null = null;\n let tailwindRefreshTimer: number | null = null;\n const runPostTailwindRefreshLayout = () => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n const iframeWin = iframe.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_triggerFitContent?.();\n };\n const isHostVisible = () =>\n Boolean(\n hostElement &&\n hostElement.clientWidth > 0 &&\n hostElement.clientHeight > 0\n );\n const queueTailwindRefreshAfterHidden = () => {\n if (\n !shouldInjectSandboxVendor ||\n !hostElement ||\n !needsTailwindRefreshAfterHidden ||\n isTailwindRefreshQueued ||\n !isHostVisible()\n ) {\n return;\n }\n\n isTailwindRefreshQueued = true;\n loadBlackboardVendor()\n .then(({ refreshTailwindRuntime }) => {\n if (isDestroyed) return;\n\n tailwindRefreshFrame = window.requestAnimationFrame(() => {\n tailwindRefreshFrame = null;\n isTailwindRefreshQueued = false;\n\n const sandboxContainer = doc.querySelector(\".sandbox-container\");\n if (\n isDestroyed ||\n !isHostVisible() ||\n !sandboxContainer?.childNodes.length ||\n !refreshTailwindRuntime(doc)\n ) {\n return;\n }\n\n needsTailwindRefreshAfterHidden = false;\n runPostTailwindRefreshLayout();\n tailwindRefreshTimer = window.setTimeout(() => {\n tailwindRefreshTimer = null;\n runPostTailwindRefreshLayout();\n }, 100);\n });\n })\n .catch(() => {\n isTailwindRefreshQueued = false;\n });\n };\n const canObserveResize = typeof ResizeObserver !== \"undefined\";\n const hostResizeObserver =\n shouldInjectSandboxVendor && hostElement && canObserveResize\n ? new ResizeObserver((entries) => {\n const contentRect = entries[0]?.contentRect;\n const hostWidth = contentRect?.width ?? hostElement.clientWidth;\n const hostHeight = contentRect?.height ?? hostElement.clientHeight;\n const isHostSizeVisible = hostWidth > 0 && hostHeight > 0;\n\n if (!isHostSizeVisible) {\n return;\n }\n\n queueTailwindRefreshAfterHidden();\n })\n : null;\n if (hostResizeObserver && hostElement) {\n hostResizeObserver.observe(hostElement);\n }\n\n const resizeObserver = canObserveResize\n ? new ResizeObserver(() => updateHeight())\n : null;\n resizeObserver?.observe(doc.body);\n if (rootEl) {\n resizeObserver?.observe(rootEl);\n }\n\n // MutationObserver: detect DOM changes that ResizeObserver might miss\n // (e.g. content injected by scripts, images loading, dynamic rendering)\n const mutationObserver = new MutationObserver(() => {\n scheduleHeightUpdate();\n if (!isHostVisible()) {\n needsTailwindRefreshAfterHidden = true;\n return;\n }\n queueTailwindRefreshAfterHidden();\n });\n mutationObserver.observe(doc.body, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"style\", \"class\"],\n });\n\n return () => {\n isDestroyed = true;\n hostResizeObserver?.disconnect();\n resizeObserver?.disconnect();\n mutationObserver.disconnect();\n if (tailwindRefreshFrame !== null) {\n window.cancelAnimationFrame(tailwindRefreshFrame);\n }\n if (tailwindRefreshTimer !== null) {\n window.clearTimeout(tailwindRefreshTimer);\n }\n if (shouldEnableScaling) {\n const iframeWin = iframe.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_cleanupScaling?.();\n }\n if (shouldBridgeSandboxInteraction) {\n doc.removeEventListener(\"click\", handleSandboxClick, true);\n }\n if (rootRef.current === root) {\n rootRef.current = null;\n updateHeightRef.current = () => {};\n }\n // Defer unmount to avoid React warning when parent is mid-render\n setTimeout(() => {\n root.unmount();\n }, 0);\n };\n }, []);\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(Boolean(document.fullscreenElement));\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n }, []);\n\n // Track container width for computing min-height in content mode\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n if (typeof ResizeObserver === \"undefined\") {\n setContainerWidth(el.clientWidth);\n return;\n }\n const ro = new ResizeObserver((entries) => {\n setContainerWidth(entries[0]?.contentRect.width ?? el.clientWidth);\n });\n ro.observe(el);\n setContainerWidth(el.clientWidth);\n return () => ro.disconnect();\n }, []);\n\n // Content mode: min 16:9 aspect ratio, grow to fit content (no scrollbar)\n const contentModeStyle = useMemo<React.CSSProperties | undefined>(() => {\n if (isBlackboardMode || containerWidth === 0 || isFullscreen)\n return undefined;\n const minH = Math.round((containerWidth * 9) / 16);\n const h = Math.max(minH, contentHeight);\n return { height: h };\n }, [isBlackboardMode, containerWidth, contentHeight, isFullscreen]);\n\n const toggleFullscreen = () => {\n const target = containerRef.current || iframeRef.current;\n if (!target) return;\n if (document.fullscreenElement) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n if (target.requestFullscreen) {\n target.requestFullscreen().catch(() => {});\n }\n };\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n root.render(\n <SandboxApp\n html={renderHtmlContent}\n locale={locale}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n disableLoadingOverlay={disableLoadingOverlay}\n resetToken={resetToken}\n hasRootVhHeight={hasRootVhHeight}\n mode={mode}\n stretchRootHeight={shouldStretchRootHeight}\n enableScaling={shouldEnableScaling}\n />\n );\n\n // Schedule multiple measurements to catch async content (scripts, images, styles).\n initialPaintFrameRef.current = window.requestAnimationFrame(() => {\n updateHeightRef.current?.();\n if (shouldEnableScaling) {\n const iframeWin = iframeRef.current\n ?.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_triggerFitContent?.();\n }\n initialPaintFrameRef.current = null;\n });\n const t1 = setTimeout(() => updateHeightRef.current?.(), 100);\n const t2 = setTimeout(() => updateHeightRef.current?.(), 500);\n return () => {\n if (initialPaintFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintFrameRef.current);\n initialPaintFrameRef.current = null;\n }\n clearTimeout(t1);\n clearTimeout(t2);\n };\n }, [\n renderHtmlContent,\n locale,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n resetToken,\n disableLoadingOverlay,\n hasRootVhHeight,\n mode,\n shouldStretchRootHeight,\n shouldEnableScaling,\n ]);\n const containerClassName = [\n `w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${type}`,\n isBlackboardMode\n ? \"h-full overflow-auto flex flex-col\"\n : contentModeStyle\n ? \"overflow-hidden flex items-center justify-center\"\n : \"aspect-[16/9] overflow-hidden flex items-center justify-center\",\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div\n ref={containerRef}\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className={containerClassName}\n style={\n sandboxViewportHeight\n ? {\n height: sandboxViewportHeight,\n minHeight: sandboxViewportHeight,\n }\n : contentModeStyle\n }\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n className={\n \"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer\"\n }\n >\n {isFullscreen\n ? resolvedExitFullScreenButtonText\n : resolvedFullScreenButtonText}\n </button>\n )}\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <div onClick={() => emitSandboxInteraction(\"click\")}>\n <ContentRender\n content={content}\n locale={locale}\n disableSandboxLoadingOverlay={disableLoadingOverlay}\n />\n </div>\n ) : (\n <iframe\n ref={iframeRef}\n sandbox=\"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox\"\n allow=\"fullscreen\"\n allowFullScreen\n className={[className, \"w-full h-full mx-auto my-auto block\"]\n .filter(Boolean)\n .join(\" \")}\n style={{\n height: sandboxViewportHeight ?? \"100%\",\n minHeight: sandboxViewportHeight,\n margin: \"auto\",\n }}\n />\n )}\n </div>\n );\n};\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = (props) => {\n const mode = props.mode ?? \"content\";\n const shouldEnableScaling = Boolean(\n props.enableScaling && mode === \"blackboard\" && props.type === \"sandbox\"\n );\n // The iframe shell captures these initialization-only values. Remounting the\n // inner instance keeps old and new React roots from sharing cleanup refs.\n const lifecycleKey = `${props.type}:${mode}:${shouldEnableScaling ? \"scaled\" : \"unscaled\"}`;\n\n return <IframeSandboxInstance key={lifecycleKey} {...props} />;\n};\n\nexport default IframeSandbox;\n"],"names":["blackboardVendorPromise","loadBlackboardVendor","COMPLETE_IMAGE_TAG_PATTERN","POST_IMAGE_STREAM_DEBOUNCE_MS","SANDBOX_INTERACTION_THROTTLE_MS","replaceRootScreenHeightToken","className","token","segments","replaceRootScreenHeightWithFullClass","html","enabled","match","tagStart","attrs","classMatch","nextClassName","IframeSandboxInstance","content","type","locale","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","exitFullScreenButtonText","hideFullScreen","mode","replaceRootScreenHeightWithFull","enableScaling","disableLoadingOverlay","localeTexts","getContentRenderLocaleTexts","resolvedFullScreenButtonText","resolvedExitFullScreenButtonText","containerRef","useRef","iframeRef","rootRef","updateHeightRef","height","setHeight","useState","contentHeight","setContentHeight","containerWidth","setContainerWidth","isMeasuringContentRef","pendingHeightUpdateRef","lastSandboxInteractionTimeRef","resetToken","setResetToken","isFullscreen","setIsFullscreen","shouldInjectSandboxVendor","isBlackboardMode","shouldEnableScaling","shouldMeasureDynamicHeight","shouldProcessRootScreenHeight","prevHtmlRef","htmlContent","React","normalizedHtmlContent","originalRootHeightMeta","inspectViewportHeightFromHtmlRootString","EMPTY_ROOT_HEIGHT_META","shouldStretchRootHeight","renderHtmlContent","setRenderHtmlContent","prevIncomingHtmlRef","pendingHtmlRef","deferRenderTimerRef","initialPaintFrameRef","renderViewportHeightCssRef","emitSandboxInteraction","useCallback","eventType","now","SANDBOX_INTERACTION_MESSAGE_SOURCE","SANDBOX_INTERACTION_MESSAGE_TYPE","clearDeferredRenderTimer","clearInitialPaintFrames","useEffect","prevIncomingHtml","isAppendOnlyStream","containsCompleteImage","rootViewportHeightCss","hasRootVhHeight","sandboxViewportHeight","prev","iframe","doc","CJK_SAFE_SANS_FONT_FAMILY","shouldBridgeSandboxInteraction","handleSandboxClick","rootEl","root","createRoot","isDestroyed","getHeightInspectionNode","node","getSingleChildElement","childElements","resolveExplicitHeight","parentViewportHeight","precomputedViewportHeightCss","parsed","parseExplicitHeight","container","containerChildren","rootContentElement","runtimeViewportHeightCss","inspectViewportHeightFromNodeChain","runtimeViewportHeight","explicitPixelHeight","resolveExplicitHeightFromNodeChain","updateHeight","cw","prevH","minH","maxH","measuredH","iframeWin","getInnerScrollableHeight","walk","el","oy","rect","child","i","nextH","next","scheduleHeightUpdate","bodyScrollH","htmlScrollH","rootScrollH","measuredHeight","explicitHeight","nextHeight","prevHeight","injectBlackboardLibraries","injectScalingSystem","hostElement","needsTailwindRefreshAfterHidden","isTailwindRefreshQueued","tailwindRefreshFrame","tailwindRefreshTimer","runPostTailwindRefreshLayout","isHostVisible","queueTailwindRefreshAfterHidden","refreshTailwindRuntime","sandboxContainer","canObserveResize","hostResizeObserver","entries","contentRect","hostWidth","hostHeight","resizeObserver","mutationObserver","onFullscreenChange","ro","contentModeStyle","useMemo","toggleFullscreen","target","jsx","SandboxApp","t1","t2","containerClassName","jsxs","ContentRender","IframeSandbox","props","lifecycleKey"],"mappings":"ieAgCA,IAAIA,GAAkE,KAEtE,MAAMC,GAAuB,KACtBD,KACHA,GAA0B,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,yBAAqB,CAAA,GAGjDA,IAGHE,GAA6B,gBAC7BC,GAAgC,IAChCC,GAAkC,IAmBlCC,GAAgCC,GACpCA,EACG,MAAM,KAAK,EACX,OAAO,OAAO,EACd,IAAKC,GAAU,CACd,MAAMC,EAAWD,EAAM,MAAM,GAAG,EAChC,OACEC,EAASA,EAAS,OAAS,CAAC,IAAM,YAClCA,EAASA,EAAS,OAAS,CAAC,IAAM,eAE3BD,GAETC,EAASA,EAAS,OAAS,CAAC,EAAI,SACzBA,EAAS,KAAK,GAAG,EAC1B,CAAC,EACA,KAAK,GAAG,EAEPC,GAAuC,CAC3CC,EACAC,IAEI,CAACA,GAAW,CAACD,EAAK,OACbA,EAGF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AAA,kBAAAA,IAACM,GAAAA,QAAA,CACC,QAAA1J,EACA,OAAAE,EACA,6BAA8BU,CAAA,CAAA,EAElC,EAEAwI,EAAAA,kBAAAA,IAAC,SAAA,CACC,IAAKjI,EACL,QAAQ,8EACR,MAAM,aACN,gBAAe,GACf,UAAW,CAAC/B,EAAW,qCAAqC,EACzD,OAAO,OAAO,EACd,KAAK,GAAG,EACX,MAAO,CACL,OAAQkF,GAAyB,OACjC,UAAWA,EACX,OAAQ,MAAA,CACV,CAAA,CACF,CAAA,CAAA,CAIR,EAEMqF,GAA+CC,GAAU,CAC7D,MAAMnJ,EAAOmJ,EAAM,MAAQ,UACrBtH,EAAsB,GAC1BsH,EAAM,eAAiBnJ,IAAS,cAAgBmJ,EAAM,OAAS,WAI3DC,EAAe,GAAGD,EAAM,IAAI,IAAInJ,CAAI,IAAI6B,EAAsB,SAAW,UAAU,GAEzF,OAAO8G,EAAAA,kBAAAA,IAACrJ,GAAA,CAA0C,GAAG6J,CAAA,EAAlBC,CAAyB,CAC9D"}
1
+ {"version":3,"file":"IframeSandbox.cjs","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport SandboxApp from \"./SandboxApp\";\nimport ContentRender from \"./ContentRender\";\nimport {\n EMPTY_ROOT_HEIGHT_META,\n inspectViewportHeightFromHtmlRootString,\n inspectViewportHeightFromNodeChain,\n parseExplicitHeight,\n resolveExplicitHeightFromNodeChain,\n} from \"./utils/iframe-viewport-height\";\nimport {\n SANDBOX_INTERACTION_MESSAGE_SOURCE,\n SANDBOX_INTERACTION_MESSAGE_TYPE,\n} from \"../../lib/sandboxInteraction\";\nimport {\n injectScalingSystem,\n type ScalingWindow,\n} from \"./utils/iframe-scaling\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport { useDetachedLanguage } from \"../../lib/useDetachedLanguage\";\nimport { useResolvedDirection } from \"../../lib/useResolvedDirection\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\nimport { CJK_SAFE_SANS_FONT_FAMILY } from \"./cjkFontFamily\";\n\ntype BlackboardVendorModule = typeof import(\"./blackboard-vendor\");\n\n// Cache the sandbox vendor loader so every iframe reuses the same preload request.\nlet blackboardVendorPromise: Promise<BlackboardVendorModule> | null = null;\n\nconst loadBlackboardVendor = () => {\n if (!blackboardVendorPromise) {\n blackboardVendorPromise = import(\"./blackboard-vendor\");\n }\n\n return blackboardVendorPromise;\n};\n\nconst COMPLETE_IMAGE_TAG_PATTERN = /<img\\b[^>]*>/i;\nconst POST_IMAGE_STREAM_DEBOUNCE_MS = 180;\nconst SANDBOX_INTERACTION_THROTTLE_MS = 240;\n\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language without changing authored HTML language. */\n lang?: string;\n /** Overrides locale-derived direction without replacing authored HTML direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n exitFullScreenButtonText?: string;\n hideFullScreen?: boolean;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n replaceRootScreenHeightWithFull?: boolean;\n enableScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst replaceRootScreenHeightToken = (className: string) =>\n className\n .split(/\\s+/)\n .filter(Boolean)\n .map((token) => {\n const segments = token.split(\":\");\n if (\n segments[segments.length - 1] !== \"h-screen\" &&\n segments[segments.length - 1] !== \"min-h-screen\"\n ) {\n return token;\n }\n segments[segments.length - 1] = \"h-full\";\n return segments.join(\":\");\n })\n .join(\" \");\n\nconst replaceRootScreenHeightWithFullClass = (\n html: string,\n enabled: boolean\n) => {\n if (!enabled || !html.trim()) {\n return html;\n }\n\n return html.replace(\n /^(\\s*<[a-zA-Z][\\w:-]*)(\\s[^>]*?)?>/,\n (match, tagStart: string, attrs = \"\") => {\n const classMatch = attrs.match(/\\bclass\\s*=\\s*([\"'])([^\"']*)\\1/i);\n\n if (!classMatch) {\n return match;\n }\n\n const nextClassName = replaceRootScreenHeightToken(classMatch[2]);\n\n if (nextClassName === classMatch[2]) {\n return match;\n }\n\n return `${tagStart}${attrs.replace(\n classMatch[0],\n `class=${classMatch[1]}${nextClassName}${classMatch[1]}`\n )}>`;\n }\n );\n};\n\nconst IframeSandboxInstance: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n locale,\n lang,\n dir,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n exitFullScreenButtonText,\n hideFullScreen = false,\n mode = \"content\",\n replaceRootScreenHeightWithFull = false,\n enableScaling = false,\n disableLoadingOverlay = false,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const direction = dir ?? getMarkdownFlowDirection(locale);\n const language = lang ?? getMarkdownFlowLanguage(locale);\n const resolvedFullScreenButtonText =\n fullScreenButtonText || localeTexts.sandboxFullscreenButtonText;\n const resolvedExitFullScreenButtonText =\n exitFullScreenButtonText || localeTexts.sandboxExitFullscreenButtonText;\n const containerRef = useRef<HTMLDivElement>(null);\n const sandboxLanguage = useDetachedLanguage(containerRef, language);\n const { resolvedDirection } = useResolvedDirection(containerRef, direction);\n const markdownContainerRef = useRef<HTMLDivElement>(null);\n const markdownContentRef = useRef<HTMLElement>(null);\n const setMarkdownContentContainerRef = useCallback(\n (node: HTMLDivElement | null) => {\n markdownContainerRef.current = node;\n markdownContentRef.current =\n node?.querySelector<HTMLElement>(\".content-render\") ?? null;\n },\n []\n );\n const { resolvedDirection: markdownContentDirection } = useResolvedDirection(\n markdownContentRef,\n direction\n );\n const sandboxDirection = direction ?? resolvedDirection;\n const requestedDirectionRef = useRef(direction);\n requestedDirectionRef.current = direction;\n // Auto direction cannot inspect text across the iframe document boundary.\n // Mirror the rendered sandbox direction to host controls instead.\n const [sandboxContentDirection, setSandboxContentDirection] = useState<\n \"ltr\" | \"rtl\"\n >();\n let fullscreenControlDirection: \"ltr\" | \"rtl\" | undefined;\n if (direction === \"auto\") {\n fullscreenControlDirection = resolvedDirection;\n if (type === \"sandbox\") {\n fullscreenControlDirection = sandboxContentDirection ?? resolvedDirection;\n } else if (mode === \"blackboard\") {\n fullscreenControlDirection = markdownContentDirection;\n }\n }\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const [contentHeight, setContentHeight] = useState(0);\n const [containerWidth, setContainerWidth] = useState(0);\n const isMeasuringContentRef = useRef(false);\n const pendingHeightUpdateRef = useRef(false);\n const lastSandboxInteractionTimeRef = useRef(0);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const shouldInjectSandboxVendor = type === \"sandbox\";\n\n const isBlackboardMode = mode === \"blackboard\";\n const shouldEnableScaling =\n enableScaling && isBlackboardMode && type === \"sandbox\";\n const shouldMeasureDynamicHeight = isBlackboardMode && type === \"sandbox\";\n const shouldProcessRootScreenHeight =\n shouldMeasureDynamicHeight && replaceRootScreenHeightWithFull;\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(\n () => (type === \"sandbox\" ? content : \"\"),\n [content, type]\n );\n const normalizedHtmlContent = React.useMemo(\n () =>\n replaceRootScreenHeightWithFullClass(\n htmlContent,\n shouldProcessRootScreenHeight\n ),\n [htmlContent, shouldProcessRootScreenHeight]\n );\n const originalRootHeightMeta = React.useMemo(\n () =>\n shouldProcessRootScreenHeight\n ? inspectViewportHeightFromHtmlRootString(htmlContent)\n : EMPTY_ROOT_HEIGHT_META,\n [htmlContent, shouldProcessRootScreenHeight]\n );\n const shouldStretchRootHeight = React.useMemo(\n () =>\n shouldProcessRootScreenHeight &&\n originalRootHeightMeta.hasFullViewportHeight,\n [\n originalRootHeightMeta.hasFullViewportHeight,\n shouldProcessRootScreenHeight,\n ]\n );\n const [renderHtmlContent, setRenderHtmlContent] = useState(\n normalizedHtmlContent\n );\n const prevIncomingHtmlRef = useRef(normalizedHtmlContent);\n const pendingHtmlRef = useRef(normalizedHtmlContent);\n const deferRenderTimerRef = useRef<number | null>(null);\n const initialPaintFrameRef = useRef<number | null>(null);\n const renderViewportHeightCssRef = useRef<string | null>(null);\n\n const emitSandboxInteraction = useCallback((eventType: string) => {\n if (typeof window === \"undefined\") {\n return;\n }\n const now = Date.now();\n if (\n now - lastSandboxInteractionTimeRef.current <\n SANDBOX_INTERACTION_THROTTLE_MS\n ) {\n return;\n }\n lastSandboxInteractionTimeRef.current = now;\n window.postMessage(\n {\n source: SANDBOX_INTERACTION_MESSAGE_SOURCE,\n type: SANDBOX_INTERACTION_MESSAGE_TYPE,\n eventType,\n },\n window.location.origin\n );\n }, []);\n\n useEffect(() => {\n if (type !== \"markdown\" || mode !== \"blackboard\") return;\n const container = markdownContainerRef.current;\n if (!container) return;\n const handleClick = () => emitSandboxInteraction(\"click\");\n container.addEventListener(\"click\", handleClick);\n return () => container.removeEventListener(\"click\", handleClick);\n }, [emitSandboxInteraction, mode, type]);\n\n const clearDeferredRenderTimer = () => {\n if (deferRenderTimerRef.current === null) return;\n window.clearTimeout(deferRenderTimerRef.current);\n deferRenderTimerRef.current = null;\n };\n\n const clearInitialPaintFrames = () => {\n if (initialPaintFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintFrameRef.current);\n initialPaintFrameRef.current = null;\n }\n };\n\n useEffect(\n () => () => {\n clearDeferredRenderTimer();\n clearInitialPaintFrames();\n },\n []\n );\n\n useEffect(() => {\n const prevIncomingHtml = prevIncomingHtmlRef.current;\n prevIncomingHtmlRef.current = normalizedHtmlContent;\n\n const isAppendOnlyStream =\n !!prevIncomingHtml &&\n normalizedHtmlContent.length > prevIncomingHtml.length &&\n normalizedHtmlContent.startsWith(prevIncomingHtml);\n const containsCompleteImage = COMPLETE_IMAGE_TAG_PATTERN.test(\n normalizedHtmlContent\n );\n const shouldDeferRender = isAppendOnlyStream && containsCompleteImage;\n\n if (!shouldDeferRender) {\n clearDeferredRenderTimer();\n pendingHtmlRef.current = normalizedHtmlContent;\n setRenderHtmlContent(normalizedHtmlContent);\n return;\n }\n\n pendingHtmlRef.current = normalizedHtmlContent;\n clearDeferredRenderTimer();\n deferRenderTimerRef.current = window.setTimeout(() => {\n setRenderHtmlContent(pendingHtmlRef.current);\n deferRenderTimerRef.current = null;\n }, POST_IMAGE_STREAM_DEBOUNCE_MS);\n }, [normalizedHtmlContent]);\n\n const rootViewportHeightCss = React.useMemo(() => {\n if (!shouldMeasureDynamicHeight) {\n return null;\n }\n\n return inspectViewportHeightFromHtmlRootString(renderHtmlContent)\n .viewportHeightCss;\n }, [renderHtmlContent, shouldMeasureDynamicHeight]);\n\n useEffect(() => {\n renderViewportHeightCssRef.current = rootViewportHeightCss;\n }, [rootViewportHeightCss]);\n\n const hasRootVhHeight = Boolean(rootViewportHeightCss);\n const sandboxViewportHeight =\n isBlackboardMode && type === \"sandbox\"\n ? shouldEnableScaling\n ? \"100%\"\n : shouldStretchRootHeight\n ? \"100%\"\n : (rootViewportHeightCss ?? `${height}px`)\n : undefined;\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = normalizedHtmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && normalizedHtmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = normalizedHtmlContent;\n }, [mode, normalizedHtmlContent]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return undefined;\n\n const doc = iframe.contentDocument;\n if (!doc) return undefined;\n\n doc.open();\n doc.write(`<!DOCTYPE html>\n<html${mode === \"blackboard\" ? ' style=\"height: 100%;\"' : \"\"}>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <style>\n :root { color-scheme: light; }\n html, body, #root { width: 100%; font-family: ${CJK_SAFE_SANS_FONT_FAMILY}; }\n ${mode === \"blackboard\" ? \"html, body, #root { height: 100%; }\" : \"\"}\n html, body { margin: 0; padding: 0; overflow: ${shouldEnableScaling ? \"hidden auto\" : mode === \"blackboard\" ? \"auto\" : \"hidden\"}; }\n *, *::before, *::after { box-sizing: border-box; }\n ${\n mode !== \"blackboard\"\n ? `\n .h-screen { height: auto !important; }\n .min-h-screen { min-height: auto !important; }\n .h-dvh, .h-svh, .h-lvh { height: auto !important; }\n .min-h-dvh, .min-h-svh, .min-h-lvh { min-height: auto !important; }\n `\n : \"\"\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n\n // Force iframe theme to stay in light mode regardless of host OS preference.\n doc.documentElement.setAttribute(\"data-theme\", \"light\");\n doc.documentElement.style.colorScheme = \"light\";\n doc.body?.style.setProperty(\"color-scheme\", \"light\");\n\n const shouldBridgeSandboxInteraction =\n isBlackboardMode && type === \"sandbox\";\n const handleSandboxClick = () => emitSandboxInteraction(\"click\");\n\n if (shouldBridgeSandboxInteraction) {\n doc.addEventListener(\"click\", handleSandboxClick, true);\n }\n\n const rootEl = doc.getElementById(\"root\");\n if (!rootEl) return undefined;\n\n const root = createRoot(rootEl);\n rootRef.current = root;\n let isDestroyed = false;\n const getHeightInspectionNode = (node: HTMLElement) => ({\n heightAttrValue: node.getAttribute(\"height\"),\n styleAttrValue: node.getAttribute(\"style\"),\n classAttrValue: node.getAttribute(\"class\"),\n });\n const getSingleChildElement = (node: HTMLElement) => {\n const childElements = Array.from(node.children) as HTMLElement[];\n\n return childElements.length === 1 ? childElements[0] : null;\n };\n\n const resolveExplicitHeight = () => {\n if (!shouldMeasureDynamicHeight) return null;\n if (!iframeRef.current || !doc.body) return null;\n const parentViewportHeight =\n iframeRef.current.ownerDocument?.documentElement?.clientHeight ||\n window.innerHeight;\n // Reuse parsed height metadata from the current html snapshot first to\n // avoid re-inspecting the same DOM chain on every height tick.\n const precomputedViewportHeightCss = renderViewportHeightCssRef.current;\n const parsed = precomputedViewportHeightCss\n ? parseExplicitHeight(\n precomputedViewportHeightCss,\n parentViewportHeight\n )\n : null;\n\n if (parsed !== null) {\n return Math.ceil(parsed);\n }\n\n const wrapper = doc.body.querySelector(\n \".sandbox-wrapper\"\n ) as HTMLElement | null;\n const container = wrapper?.firstElementChild as HTMLElement | null;\n if (!container) return null;\n const containerChildren = Array.from(container.children) as HTMLElement[];\n const rootContentElement =\n containerChildren.length === 1 ? containerChildren[0] : null;\n const runtimeHeightMeta = inspectViewportHeightFromNodeChain(\n rootContentElement,\n {\n getNode: getHeightInspectionNode,\n getSingleChild: getSingleChildElement,\n }\n );\n const runtimeViewportHeightCss = runtimeHeightMeta.viewportHeightCss;\n\n if (runtimeViewportHeightCss) {\n const runtimeViewportHeight = parseExplicitHeight(\n runtimeViewportHeightCss,\n parentViewportHeight\n );\n\n if (runtimeViewportHeight !== null) {\n return Math.ceil(runtimeViewportHeight);\n }\n }\n\n const explicitPixelHeight = resolveExplicitHeightFromNodeChain(\n rootContentElement,\n parentViewportHeight,\n {\n getNode: getHeightInspectionNode,\n getSingleChild: getSingleChildElement,\n }\n );\n\n return explicitPixelHeight !== null\n ? Math.ceil(explicitPixelHeight)\n : null;\n };\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n\n if (!isBlackboardMode) {\n // Guard: prevent re-entrant measurement from ResizeObserver /\n // MutationObserver callbacks triggered by our own height changes.\n if (isMeasuringContentRef.current) {\n // Mark that an update was requested while the guard was active.\n // We will retry once the guard releases (see setTimeout below).\n pendingHeightUpdateRef.current = true;\n return;\n }\n isMeasuringContentRef.current = true;\n\n // Content mode height measurement strategy:\n // Temporarily set iframe height to the 16:9 minimum so that:\n // 1. vmin units are stable: vmin = min(cw, minH)/100 = minH/100,\n // consistent with the final rendered 16:9 iframe.\n // 2. Viewport-filling content (e.g. inline style=\"height:100vh\")\n // fills the 16:9 space → scrollHeight = minH, which is then\n // correctly bounded by the 16:9 minimum in contentModeStyle.\n // (Previously using cw caused such content to report 1:1 height,\n // overriding the 16:9 minimum.)\n const iframe = iframeRef.current;\n const cw = containerRef.current?.clientWidth || 0;\n const prevH = iframe.style.height;\n\n if (cw > 0) {\n const minH = Math.round((cw * 9) / 16);\n // Absolute height cap. Diverging vh-feedback (multiple `height:100vh`\n // siblings, or compound vh-relative children whose sum exceeds the\n // viewport) can otherwise grow the iframe geometrically across\n // repeated ResizeObserver/MutationObserver passes. 1:20 aspect is\n // a generous upper bound for any single sandbox slide.\n const maxH = Math.max(8192, cw * 20);\n iframe.style.height = minH + \"px\";\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n doc.body.offsetHeight; // force layout\n\n let measuredH = doc.body.scrollHeight;\n\n // Detect inner elements that clip overflowing content behind a\n // scrollbar (e.g. <div style=\"height:100vh; overflow-y:auto\"> whose\n // content is taller than the iframe). body.scrollHeight won't see\n // that overflow, so we walk the tree and factor in each scrollable\n // element's full scroll height based on its position in the iframe.\n const iframeWin = doc.defaultView;\n if (iframeWin) {\n // Returns the max natural bottom of inner elements that clip\n // content via overflow:auto/scroll (i.e. internal scrollbars).\n const getInnerScrollableHeight = (root: Element): number => {\n let maxH = 0;\n const walk = (el: Element) => {\n if (el !== root && el.scrollHeight > el.clientHeight + 1) {\n const oy = iframeWin.getComputedStyle(el).overflowY;\n if (oy === \"auto\" || oy === \"scroll\") {\n const rect = el.getBoundingClientRect();\n if (rect.top >= 0) {\n maxH = Math.max(\n maxH,\n Math.ceil(rect.top + el.scrollHeight)\n );\n }\n }\n }\n for (const child of el.children) walk(child);\n };\n walk(root);\n return maxH;\n };\n\n measuredH = Math.max(measuredH, getInnerScrollableHeight(doc.body));\n\n // Content that uses vh-relative sizing grows as the viewport\n // expands. Measure up to 8 more times at the expanded height so\n // we capture the full content height in a single updateHeight()\n // call rather than waiting for external re-triggers.\n for (let i = 0; i < 8 && measuredH > minH; i++) {\n iframe.style.height = measuredH + \"px\";\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n doc.body.offsetHeight; // force layout at expanded size\n const nextH = Math.max(\n doc.body.scrollHeight,\n getInnerScrollableHeight(doc.body)\n );\n if (nextH <= measuredH + 1) break; // stable — stop iterating\n // Geometric vh-feedback detection: vh-relative children scale\n // with the iframe viewport, so growing the iframe makes them\n // larger which grows scrollHeight — runaway divergence. Two\n // `height:100vh` siblings produce a 2× per-iteration multiplier.\n // Stop iterating; keep the prior (stable) measuredH.\n if (nextH >= measuredH * 1.5) break;\n measuredH = nextH;\n }\n }\n\n // Restore iframe to let React control it via contentModeStyle\n iframe.style.height = prevH;\n\n setContentHeight((prev) => {\n const next = Math.min(maxH, Math.max(200, Math.ceil(measuredH)));\n return prev === next ? prev : next;\n });\n }\n\n setTimeout(() => {\n isMeasuringContentRef.current = false;\n // Retry any update that was blocked while the guard was active\n // (e.g. dynamic content injected by scripts or images loading).\n if (pendingHeightUpdateRef.current) {\n pendingHeightUpdateRef.current = false;\n scheduleHeightUpdate();\n }\n }, 50);\n return;\n }\n\n // Scaling mode: viewport is fixed, content scales via font-size.\n if (shouldEnableScaling) return;\n\n // Blackboard mode: use existing measurement logic\n const bodyScrollH = doc.body.scrollHeight;\n const htmlScrollH = doc.documentElement?.scrollHeight || 0;\n const rootScrollH = rootEl?.scrollHeight || 0;\n const measuredHeight = Math.max(bodyScrollH, htmlScrollH, rootScrollH);\n\n if (shouldMeasureDynamicHeight) {\n const explicitHeight = resolveExplicitHeight();\n const nextHeight = Math.max(\n 200,\n explicitHeight ?? Math.ceil(measuredHeight)\n );\n setHeight((prevHeight) =>\n prevHeight === nextHeight ? prevHeight : nextHeight\n );\n }\n };\n const scheduleHeightUpdate = () => {\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n updateHeight();\n });\n };\n updateHeightRef.current = scheduleHeightUpdate;\n\n updateHeight();\n scheduleHeightUpdate();\n\n if (shouldInjectSandboxVendor) {\n // Inject Tailwind/DaisyUI/GSAP before rendering sandbox content to avoid FOUC.\n loadBlackboardVendor()\n .then(({ injectBlackboardLibraries }) => {\n if (isDestroyed) return;\n injectBlackboardLibraries(doc);\n if (shouldEnableScaling) {\n injectScalingSystem(doc);\n }\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n });\n })\n .catch(() => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n });\n }\n\n const hostElement = containerRef.current;\n let needsTailwindRefreshAfterHidden = Boolean(\n hostElement &&\n (hostElement.clientWidth <= 0 || hostElement.clientHeight <= 0)\n );\n let isTailwindRefreshQueued = false;\n let tailwindRefreshFrame: number | null = null;\n let tailwindRefreshTimer: number | null = null;\n const runPostTailwindRefreshLayout = () => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n const iframeWin = iframe.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_triggerFitContent?.();\n };\n const isHostVisible = () =>\n Boolean(\n hostElement &&\n hostElement.clientWidth > 0 &&\n hostElement.clientHeight > 0\n );\n const queueTailwindRefreshAfterHidden = () => {\n if (\n !shouldInjectSandboxVendor ||\n !hostElement ||\n !needsTailwindRefreshAfterHidden ||\n isTailwindRefreshQueued ||\n !isHostVisible()\n ) {\n return;\n }\n\n isTailwindRefreshQueued = true;\n loadBlackboardVendor()\n .then(({ refreshTailwindRuntime }) => {\n if (isDestroyed) return;\n\n tailwindRefreshFrame = window.requestAnimationFrame(() => {\n tailwindRefreshFrame = null;\n isTailwindRefreshQueued = false;\n\n const sandboxContainer = doc.querySelector(\".sandbox-container\");\n if (\n isDestroyed ||\n !isHostVisible() ||\n !sandboxContainer?.childNodes.length ||\n !refreshTailwindRuntime(doc)\n ) {\n return;\n }\n\n needsTailwindRefreshAfterHidden = false;\n runPostTailwindRefreshLayout();\n tailwindRefreshTimer = window.setTimeout(() => {\n tailwindRefreshTimer = null;\n runPostTailwindRefreshLayout();\n }, 100);\n });\n })\n .catch(() => {\n isTailwindRefreshQueued = false;\n });\n };\n const canObserveResize = typeof ResizeObserver !== \"undefined\";\n const hostResizeObserver =\n shouldInjectSandboxVendor && hostElement && canObserveResize\n ? new ResizeObserver((entries) => {\n const contentRect = entries[0]?.contentRect;\n const hostWidth = contentRect?.width ?? hostElement.clientWidth;\n const hostHeight = contentRect?.height ?? hostElement.clientHeight;\n const isHostSizeVisible = hostWidth > 0 && hostHeight > 0;\n\n if (!isHostSizeVisible) {\n return;\n }\n\n queueTailwindRefreshAfterHidden();\n })\n : null;\n if (hostResizeObserver && hostElement) {\n hostResizeObserver.observe(hostElement);\n }\n\n const resizeObserver = canObserveResize\n ? new ResizeObserver(() => updateHeight())\n : null;\n resizeObserver?.observe(doc.body);\n if (rootEl) {\n resizeObserver?.observe(rootEl);\n }\n\n const syncSandboxContentDirection = () => {\n if (type !== \"sandbox\" || requestedDirectionRef.current !== \"auto\") {\n return;\n }\n const wrapper = doc.querySelector<HTMLElement>(\".sandbox-wrapper\");\n const view = doc.defaultView;\n if (!wrapper || !view) return;\n const nextDirection =\n view.getComputedStyle(wrapper).direction === \"rtl\" ? \"rtl\" : \"ltr\";\n setSandboxContentDirection((currentDirection) =>\n currentDirection === nextDirection ? currentDirection : nextDirection\n );\n };\n\n // MutationObserver: detect DOM changes that ResizeObserver might miss\n // (e.g. content injected by scripts, images loading, dynamic rendering)\n const mutationObserver = new MutationObserver(() => {\n syncSandboxContentDirection();\n scheduleHeightUpdate();\n if (!isHostVisible()) {\n needsTailwindRefreshAfterHidden = true;\n return;\n }\n queueTailwindRefreshAfterHidden();\n });\n mutationObserver.observe(doc.body, {\n childList: true,\n characterData: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"style\", \"class\", \"dir\"],\n });\n\n return () => {\n isDestroyed = true;\n hostResizeObserver?.disconnect();\n resizeObserver?.disconnect();\n mutationObserver.disconnect();\n if (tailwindRefreshFrame !== null) {\n window.cancelAnimationFrame(tailwindRefreshFrame);\n }\n if (tailwindRefreshTimer !== null) {\n window.clearTimeout(tailwindRefreshTimer);\n }\n if (shouldEnableScaling) {\n const iframeWin = iframe.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_cleanupScaling?.();\n }\n if (shouldBridgeSandboxInteraction) {\n doc.removeEventListener(\"click\", handleSandboxClick, true);\n }\n if (rootRef.current === root) {\n rootRef.current = null;\n updateHeightRef.current = () => {};\n }\n // Defer unmount to avoid React warning when parent is mid-render\n setTimeout(() => {\n root.unmount();\n }, 0);\n };\n }, []);\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(Boolean(document.fullscreenElement));\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n }, []);\n\n // Track container width for computing min-height in content mode\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n if (typeof ResizeObserver === \"undefined\") {\n setContainerWidth(el.clientWidth);\n return;\n }\n const ro = new ResizeObserver((entries) => {\n setContainerWidth(entries[0]?.contentRect.width ?? el.clientWidth);\n });\n ro.observe(el);\n setContainerWidth(el.clientWidth);\n return () => ro.disconnect();\n }, []);\n\n // Content mode: min 16:9 aspect ratio, grow to fit content (no scrollbar)\n const contentModeStyle = useMemo<React.CSSProperties | undefined>(() => {\n if (isBlackboardMode || containerWidth === 0 || isFullscreen)\n return undefined;\n const minH = Math.round((containerWidth * 9) / 16);\n const h = Math.max(minH, contentHeight);\n return { height: h };\n }, [isBlackboardMode, containerWidth, contentHeight, isFullscreen]);\n\n const toggleFullscreen = () => {\n const target = containerRef.current || iframeRef.current;\n if (!target) return;\n if (document.fullscreenElement) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n if (target.requestFullscreen) {\n target.requestFullscreen().catch(() => {});\n }\n };\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n root.render(\n <SandboxApp\n html={renderHtmlContent}\n locale={locale}\n dir={sandboxDirection}\n lang={sandboxLanguage}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n disableLoadingOverlay={disableLoadingOverlay}\n resetToken={resetToken}\n hasRootVhHeight={hasRootVhHeight}\n mode={mode}\n stretchRootHeight={shouldStretchRootHeight}\n enableScaling={shouldEnableScaling}\n />\n );\n\n // Schedule multiple measurements to catch async content (scripts, images, styles).\n initialPaintFrameRef.current = window.requestAnimationFrame(() => {\n updateHeightRef.current?.();\n if (shouldEnableScaling) {\n const iframeWin = iframeRef.current\n ?.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_triggerFitContent?.();\n }\n initialPaintFrameRef.current = null;\n });\n const t1 = setTimeout(() => updateHeightRef.current?.(), 100);\n const t2 = setTimeout(() => updateHeightRef.current?.(), 500);\n return () => {\n if (initialPaintFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintFrameRef.current);\n initialPaintFrameRef.current = null;\n }\n clearTimeout(t1);\n clearTimeout(t2);\n };\n }, [\n renderHtmlContent,\n locale,\n sandboxDirection,\n sandboxLanguage,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n resetToken,\n disableLoadingOverlay,\n hasRootVhHeight,\n mode,\n shouldStretchRootHeight,\n shouldEnableScaling,\n ]);\n const containerClassName = [\n `w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${type}`,\n isBlackboardMode\n ? \"h-full overflow-auto flex flex-col\"\n : contentModeStyle\n ? \"overflow-hidden flex items-center justify-center\"\n : \"aspect-[16/9] overflow-hidden flex items-center justify-center\",\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div\n ref={containerRef}\n dir={direction}\n lang={language}\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className={containerClassName}\n style={\n sandboxViewportHeight\n ? {\n height: sandboxViewportHeight,\n minHeight: sandboxViewportHeight,\n }\n : contentModeStyle\n }\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n dir={fullscreenControlDirection}\n onClick={toggleFullscreen}\n className={\n \"absolute top-2 end-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer\"\n }\n >\n {isFullscreen\n ? resolvedExitFullScreenButtonText\n : resolvedFullScreenButtonText}\n </button>\n )}\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <div ref={setMarkdownContentContainerRef}>\n <ContentRender\n content={content}\n locale={locale}\n dir={direction}\n lang={language}\n disableSandboxLoadingOverlay={disableLoadingOverlay}\n />\n </div>\n ) : (\n <iframe\n ref={iframeRef}\n sandbox=\"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox\"\n allow=\"fullscreen\"\n allowFullScreen\n className={[className, \"w-full h-full mx-auto my-auto block\"]\n .filter(Boolean)\n .join(\" \")}\n style={{\n height: sandboxViewportHeight ?? \"100%\",\n minHeight: sandboxViewportHeight,\n margin: \"auto\",\n }}\n />\n )}\n </div>\n );\n};\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = (props) => {\n const mode = props.mode ?? \"content\";\n const shouldEnableScaling = Boolean(\n props.enableScaling && mode === \"blackboard\" && props.type === \"sandbox\"\n );\n // The iframe shell captures these initialization-only values. Remounting the\n // inner instance keeps old and new React roots from sharing cleanup refs.\n const lifecycleKey = `${props.type}:${mode}:${shouldEnableScaling ? \"scaled\" : \"unscaled\"}`;\n\n return <IframeSandboxInstance key={lifecycleKey} {...props} />;\n};\n\nexport default IframeSandbox;\n"],"names":["blackboardVendorPromise","loadBlackboardVendor","COMPLETE_IMAGE_TAG_PATTERN","POST_IMAGE_STREAM_DEBOUNCE_MS","SANDBOX_INTERACTION_THROTTLE_MS","replaceRootScreenHeightToken","className","token","segments","replaceRootScreenHeightWithFullClass","html","enabled","match","tagStart","attrs","classMatch","nextClassName","IframeSandboxInstance","content","type","locale","lang","dir","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","exitFullScreenButtonText","hideFullScreen","mode","replaceRootScreenHeightWithFull","enableScaling","disableLoadingOverlay","localeTexts","getContentRenderLocaleTexts","direction","getMarkdownFlowDirection","language","getMarkdownFlowLanguage","resolvedFullScreenButtonText","resolvedExitFullScreenButtonText","containerRef","useRef","sandboxLanguage","useDetachedLanguage","resolvedDirection","useResolvedDirection","markdownContainerRef","markdownContentRef","setMarkdownContentContainerRef","useCallback","node","markdownContentDirection","sandboxDirection","requestedDirectionRef","sandboxContentDirection","setSandboxContentDirection","useState","fullscreenControlDirection","iframeRef","rootRef","updateHeightRef","height","setHeight","contentHeight","setContentHeight","containerWidth","setContainerWidth","isMeasuringContentRef","pendingHeightUpdateRef","lastSandboxInteractionTimeRef","resetToken","setResetToken","isFullscreen","setIsFullscreen","shouldInjectSandboxVendor","isBlackboardMode","shouldEnableScaling","shouldMeasureDynamicHeight","shouldProcessRootScreenHeight","prevHtmlRef","htmlContent","React","normalizedHtmlContent","originalRootHeightMeta","inspectViewportHeightFromHtmlRootString","EMPTY_ROOT_HEIGHT_META","shouldStretchRootHeight","renderHtmlContent","setRenderHtmlContent","prevIncomingHtmlRef","pendingHtmlRef","deferRenderTimerRef","initialPaintFrameRef","renderViewportHeightCssRef","emitSandboxInteraction","eventType","now","SANDBOX_INTERACTION_MESSAGE_SOURCE","SANDBOX_INTERACTION_MESSAGE_TYPE","useEffect","container","handleClick","clearDeferredRenderTimer","clearInitialPaintFrames","prevIncomingHtml","isAppendOnlyStream","containsCompleteImage","rootViewportHeightCss","hasRootVhHeight","sandboxViewportHeight","prev","iframe","doc","CJK_SAFE_SANS_FONT_FAMILY","shouldBridgeSandboxInteraction","handleSandboxClick","rootEl","root","createRoot","isDestroyed","getHeightInspectionNode","getSingleChildElement","childElements","resolveExplicitHeight","parentViewportHeight","precomputedViewportHeightCss","parsed","parseExplicitHeight","containerChildren","rootContentElement","runtimeViewportHeightCss","inspectViewportHeightFromNodeChain","runtimeViewportHeight","explicitPixelHeight","resolveExplicitHeightFromNodeChain","updateHeight","cw","prevH","minH","maxH","measuredH","iframeWin","getInnerScrollableHeight","walk","el","oy","rect","child","i","nextH","next","scheduleHeightUpdate","bodyScrollH","htmlScrollH","rootScrollH","measuredHeight","explicitHeight","nextHeight","prevHeight","injectBlackboardLibraries","injectScalingSystem","hostElement","needsTailwindRefreshAfterHidden","isTailwindRefreshQueued","tailwindRefreshFrame","tailwindRefreshTimer","runPostTailwindRefreshLayout","isHostVisible","queueTailwindRefreshAfterHidden","refreshTailwindRuntime","sandboxContainer","canObserveResize","hostResizeObserver","entries","contentRect","hostWidth","hostHeight","resizeObserver","syncSandboxContentDirection","wrapper","view","nextDirection","currentDirection","mutationObserver","onFullscreenChange","ro","contentModeStyle","useMemo","toggleFullscreen","target","jsx","SandboxApp","t1","t2","containerClassName","jsxs","ContentRender","IframeSandbox","props","lifecycleKey"],"mappings":"wlBAsCA,IAAIA,GAAkE,KAEtE,MAAMC,GAAuB,KACtBD,KACHA,GAA0B,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,yBAAqB,CAAA,GAGjDA,IAGHE,GAA6B,gBAC7BC,GAAgC,IAChCC,GAAkC,IAuBlCC,GAAgCC,GACpCA,EACG,MAAM,KAAK,EACX,OAAO,OAAO,EACd,IAAKC,GAAU,CACd,MAAMC,EAAWD,EAAM,MAAM,GAAG,EAChC,OACEC,EAASA,EAAS,OAAS,CAAC,IAAM,YAClCA,EAASA,EAAS,OAAS,CAAC,IAAM,eAE3BD,GAETC,EAASA,EAAS,OAAS,CAAC,EAAI,SACzBA,EAAS,KAAK,GAAG,EAC1B,CAAC,EACA,KAAK,GAAG,EAEPC,GAAuC,CAC3CC,EACAC,IAEI,CAACA,GAAW,CAACD,EAAK,OACbA,EAGFA,EAAK,QACV,qCACA,CAACE,EAAOC,EAAkBC,EAAQ,KAAO,CACvC,MAAMC,EAAaD,EAAM,MAAM,iCAAiC,EAEhE,GAAI,CAACC,EACH,OAAOH,EAGT,MAAMI,EAAgBX,GAA6BU,EAAW,CAAC,CAAC,EAEhE,OAAIC,IAAkBD,EAAW,CAAC,EACzBH,EAGF,GAAGC,CAAQ,GAAGC,EAAM,QACzBC,EAAW,CAAC,EACZ,SAASA,EAAW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,KAAME,GACN,6BAA8BL,EAAA,CAAA,EAElC,EAEA+J,EAAAA,IAAC,SAAA,CACC,IAAKpI,EACL,QAAQ,8EACR,MAAM,aACN,gBAAe,GACf,UAAW,CAACrD,EAAW,qCAAqC,EACzD,OAAO,OAAO,EACd,KAAK,GAAG,EACX,MAAO,CACL,OAAQwG,GAAyB,OACjC,UAAWA,EACX,OAAQ,MAAA,CACV,CAAA,CACF,CAAA,CAAA,CAIR,EAEMwF,GAA+CC,GAAU,CAC7D,MAAM1K,EAAO0K,EAAM,MAAQ,UACrB1H,EAAsB,GAC1B0H,EAAM,eAAiB1K,IAAS,cAAgB0K,EAAM,OAAS,WAI3DC,EAAe,GAAGD,EAAM,IAAI,IAAI1K,CAAI,IAAIgD,EAAsB,SAAW,UAAU,GAEzF,OAAOkH,EAAAA,IAAC9K,GAAA,CAA0C,GAAGsL,CAAA,EAAlBC,CAAyB,CAC9D"}
@@ -1,9 +1,13 @@
1
1
  import { default as React } from 'react';
2
- import { MarkdownFlowLocale } from '../../lib/locale';
2
+ import { MarkdownFlowLocale } from '../../lib/locale.js';
3
3
  export interface IframeSandboxProps {
4
4
  content: string;
5
5
  className?: string;
6
6
  locale?: MarkdownFlowLocale;
7
+ /** Overrides the locale-derived language without changing authored HTML language. */
8
+ lang?: string;
9
+ /** Overrides locale-derived direction without replacing authored HTML direction. */
10
+ dir?: React.HTMLAttributes<HTMLDivElement>["dir"];
7
11
  loadingText?: string;
8
12
  styleLoadingText?: string;
9
13
  scriptLoadingText?: string;