markdown-flow-ui 0.2.5 → 0.2.7-dev.1

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 (52) hide show
  1. package/dist/_virtual/index.cjs8.js +1 -1
  2. package/dist/_virtual/index.cjs9.js +1 -1
  3. package/dist/_virtual/index.es8.js +2 -2
  4. package/dist/_virtual/index.es9.js +2 -2
  5. package/dist/assets/markdown-flow-ui.css +1 -1
  6. package/dist/components/ContentRender/CodeBlock.cjs.js.map +1 -1
  7. package/dist/components/ContentRender/CodeBlock.d.ts +1 -1
  8. package/dist/components/ContentRender/CodeBlock.es.js.map +1 -1
  9. package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
  10. package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
  11. package/dist/components/ContentRender/ContentRender.es.js +212 -191
  12. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  13. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js +1 -1
  14. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js.map +1 -1
  15. package/dist/components/ContentRender/plugins/CustomVariable.es.js +49 -43
  16. package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
  17. package/dist/components/MarkdownFlowEditor/locales/en-US.json.d.ts +70 -0
  18. package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.d.ts +70 -0
  19. package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.d.ts +70 -0
  20. package/dist/components/Slide/Slide.cjs.js +1 -1
  21. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  22. package/dist/components/Slide/Slide.es.js +258 -254
  23. package/dist/components/Slide/Slide.es.js.map +1 -1
  24. package/dist/components/Slide/diff-utils.cjs.js +4 -4
  25. package/dist/components/Slide/diff-utils.cjs.js.map +1 -1
  26. package/dist/components/Slide/diff-utils.es.js +49 -49
  27. package/dist/components/Slide/diff-utils.es.js.map +1 -1
  28. package/dist/components/Slide/types.d.ts +1 -0
  29. package/dist/components/ui/inputGroup/input-group.cjs.js +1 -1
  30. package/dist/components/ui/inputGroup/input-group.cjs.js.map +1 -1
  31. package/dist/components/ui/inputGroup/input-group.d.ts +21 -1
  32. package/dist/components/ui/inputGroup/input-group.es.js +19 -17
  33. package/dist/components/ui/inputGroup/input-group.es.js.map +1 -1
  34. package/dist/components/ui/inputGroup/textarea.cjs.js.map +1 -1
  35. package/dist/components/ui/inputGroup/textarea.d.ts +2 -1
  36. package/dist/components/ui/inputGroup/textarea.es.js.map +1 -1
  37. package/dist/lib/mobileDevice.cjs.js +1 -1
  38. package/dist/lib/mobileDevice.cjs.js.map +1 -1
  39. package/dist/lib/mobileDevice.d.ts +1 -3
  40. package/dist/lib/mobileDevice.es.js +29 -38
  41. package/dist/lib/mobileDevice.es.js.map +1 -1
  42. package/dist/markdown-flow-ui-lib.css +1 -1
  43. package/dist/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
  44. package/dist/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
  45. package/dist/node_modules/classnames/index.cjs.js +1 -1
  46. package/dist/node_modules/classnames/index.es.js +1 -1
  47. package/package.json +1 -1
  48. package/dist/components/ContentRender/ContentRender.stories.d.ts +0 -37
  49. package/dist/components/ContentRender/MarkdownFlowInput.stories.d.ts +0 -33
  50. package/dist/components/MarkdownFlow/MarkdownFlow.stories.d.ts +0 -31
  51. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.stories.d.ts +0 -64
  52. package/dist/components/Slide/Slide.stories.d.ts +0 -2590
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlock.cjs.js","sources":["../../../src/components/ContentRender/CodeBlock.tsx"],"sourcesContent":["import React, { useState, ReactNode } from \"react\";\nimport \"./CodeBlock.css\";\nimport { Copy, Check } from \"lucide-react\";\n\n/**\n * Props for the CodeBlock component.\n */\nexport interface CodeBlockProps {\n /** The code content and nested elements to render.*/\n children: React.ReactNode;\n /** Optional CSS class name for the pre element. */\n className?: string;\n /** Text to display on the copy button (i18n support). */\n copyButtonText?: string;\n /** Text to display when code is copied (i18n support). */\n copiedButtonText?: string;\n}\n\nconst getCodeString = (children: ReactNode): string => {\n let text = \"\";\n React.Children.forEach(children, (child) => {\n if (typeof child === \"string\") {\n text += child;\n } else if (\n React.isValidElement(child) &&\n (child?.props as { children?: ReactNode })?.children\n ) {\n text += getCodeString((child.props as { children: ReactNode }).children);\n }\n });\n return text;\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n children,\n className: preClassName,\n copyButtonText = \"Copy\",\n copiedButtonText = \"Copied\",\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = React.useRef<number | null>(null);\n\n React.useEffect(() => {\n // Cleanup timeout on component unmount\n return () => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n };\n }, []);\n\n let codeClassName = \"\";\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = child.props as { className?: string };\n if (childProps.className) {\n codeClassName = childProps.className;\n }\n }\n });\n\n const match = /language-(\\w+)/.exec(codeClassName || \"\");\n const language = match ? match[1] : \"\";\n\n const handleCopy = async () => {\n const codeString = getCodeString(children);\n try {\n await navigator.clipboard.writeText(codeString);\n setIsCopied(true);\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = window.setTimeout(() => {\n setIsCopied(false);\n }, 2000);\n } catch (err) {\n console.error(\"Failed to copy text: \", err);\n }\n };\n\n return (\n <div className=\"code-block-container\">\n <div className=\"code-block-header\">\n <span className=\"language-name\">{language}</span>\n <button onClick={handleCopy} className=\"copy-button\">\n {isCopied ? (\n <Check className=\"copy-icon\" />\n ) : (\n <Copy className=\"copy-icon\" />\n )}\n {isCopied ? copiedButtonText : copyButtonText}\n </button>\n </div>\n <pre className={preClassName}>{children}</pre>\n </div>\n );\n};\n\nCodeBlock.displayName = \"CodeBlock\";\nexport default CodeBlock;\n"],"names":["getCodeString","children","text","React","child","CodeBlock","preClassName","copyButtonText","copiedButtonText","isCopied","setIsCopied","useState","timeoutRef","codeClassName","childProps","match","language","handleCopy","codeString","err","jsxs","jsx","Check","Copy"],"mappings":"6WAkBMA,EAAiBC,GAAgC,CACrD,IAAIC,EAAO,GACX,OAAAC,EAAM,SAAS,QAAQF,EAAWG,GAAU,CACtC,OAAOA,GAAU,SACnBF,GAAQE,EAERD,EAAM,eAAeC,CAAK,GACzBA,GAAO,OAAoC,WAE5CF,GAAQF,EAAeI,EAAM,MAAkC,QAAQ,EAE3E,CAAC,EACMF,CACT,EAEMG,EAAsC,CAAC,CAC3C,SAAAJ,EACA,UAAWK,EACX,eAAAC,EAAiB,OACjB,iBAAAC,EAAmB,QACrB,IAAM,CACJ,KAAM,CAACC,EAAUC,CAAW,EAAIC,EAAAA,SAAS,EAAK,EACxCC,EAAaT,EAAM,OAAsB,IAAI,EAEnDA,EAAM,UAAU,IAEP,IAAM,CACPS,EAAW,SACb,OAAO,aAAaA,EAAW,OAAO,CAE1C,EACC,CAAA,CAAE,EAEL,IAAIC,EAAgB,GACpBV,EAAM,SAAS,QAAQF,EAAWG,GAAU,CAC1C,GAAID,EAAM,eAAeC,CAAK,EAAG,CAC/B,MAAMU,EAAaV,EAAM,MACrBU,EAAW,YACbD,EAAgBC,EAAW,UAE/B,CACF,CAAC,EAED,MAAMC,EAAQ,iBAAiB,KAAKF,GAAiB,EAAE,EACjDG,EAAWD,EAAQA,EAAM,CAAC,EAAI,GAE9BE,EAAa,SAAY,CAC7B,MAAMC,EAAalB,EAAcC,CAAQ,EACzC,GAAI,CACF,MAAM,UAAU,UAAU,UAAUiB,CAAU,EAC9CR,EAAY,EAAI,EAEZE,EAAW,SACb,OAAO,aAAaA,EAAW,OAAO,EAExCA,EAAW,QAAU,OAAO,WAAW,IAAM,CAC3CF,EAAY,EAAK,CACnB,EAAG,GAAI,CACT,OAASS,EAAK,CACZ,QAAQ,MAAM,wBAAyBA,CAAG,CAC5C,CACF,EAEA,OACEC,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,uBACb,SAAA,CAAAA,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,oBACb,SAAA,CAAAC,EAAAA,kBAAAA,IAAC,OAAA,CAAK,UAAU,gBAAiB,SAAAL,EAAS,EAC1CI,EAAAA,kBAAAA,KAAC,SAAA,CAAO,QAASH,EAAY,UAAU,cACpC,SAAA,CAAAR,EACCY,EAAAA,kBAAAA,IAACC,WAAM,UAAU,WAAA,CAAY,EAE7BD,EAAAA,kBAAAA,IAACE,EAAAA,QAAA,CAAK,UAAU,WAAA,CAAY,EAE7Bd,EAAWD,EAAmBD,CAAA,CAAA,CACjC,CAAA,EACF,EACAc,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAWf,EAAe,SAAAL,CAAA,CAAS,CAAA,EAC1C,CAEJ,EAEAI,EAAU,YAAc"}
1
+ {"version":3,"file":"CodeBlock.cjs.js","sources":["../../../src/components/ContentRender/CodeBlock.tsx"],"sourcesContent":["import React, { useState, ReactNode } from \"react\";\nimport \"./CodeBlock.css\";\nimport { Copy, Check } from \"lucide-react\";\n\n/**\n * Props for the CodeBlock component.\n */\nexport interface CodeBlockProps {\n /** The code content and nested elements to render.*/\n children?: React.ReactNode;\n /** Optional CSS class name for the pre element. */\n className?: string;\n /** Text to display on the copy button (i18n support). */\n copyButtonText?: string;\n /** Text to display when code is copied (i18n support). */\n copiedButtonText?: string;\n}\n\nconst getCodeString = (children: ReactNode): string => {\n let text = \"\";\n React.Children.forEach(children, (child) => {\n if (typeof child === \"string\") {\n text += child;\n } else if (\n React.isValidElement(child) &&\n (child?.props as { children?: ReactNode })?.children\n ) {\n text += getCodeString((child.props as { children: ReactNode }).children);\n }\n });\n return text;\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n children,\n className: preClassName,\n copyButtonText = \"Copy\",\n copiedButtonText = \"Copied\",\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = React.useRef<number | null>(null);\n\n React.useEffect(() => {\n // Cleanup timeout on component unmount\n return () => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n };\n }, []);\n\n let codeClassName = \"\";\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = child.props as { className?: string };\n if (childProps.className) {\n codeClassName = childProps.className;\n }\n }\n });\n\n const match = /language-(\\w+)/.exec(codeClassName || \"\");\n const language = match ? match[1] : \"\";\n\n const handleCopy = async () => {\n const codeString = getCodeString(children);\n try {\n await navigator.clipboard.writeText(codeString);\n setIsCopied(true);\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = window.setTimeout(() => {\n setIsCopied(false);\n }, 2000);\n } catch (err) {\n console.error(\"Failed to copy text: \", err);\n }\n };\n\n return (\n <div className=\"code-block-container\">\n <div className=\"code-block-header\">\n <span className=\"language-name\">{language}</span>\n <button onClick={handleCopy} className=\"copy-button\">\n {isCopied ? (\n <Check className=\"copy-icon\" />\n ) : (\n <Copy className=\"copy-icon\" />\n )}\n {isCopied ? copiedButtonText : copyButtonText}\n </button>\n </div>\n <pre className={preClassName}>{children}</pre>\n </div>\n );\n};\n\nCodeBlock.displayName = \"CodeBlock\";\nexport default CodeBlock;\n"],"names":["getCodeString","children","text","React","child","CodeBlock","preClassName","copyButtonText","copiedButtonText","isCopied","setIsCopied","useState","timeoutRef","codeClassName","childProps","match","language","handleCopy","codeString","err","jsxs","jsx","Check","Copy"],"mappings":"6WAkBMA,EAAiBC,GAAgC,CACrD,IAAIC,EAAO,GACX,OAAAC,EAAM,SAAS,QAAQF,EAAWG,GAAU,CACtC,OAAOA,GAAU,SACnBF,GAAQE,EAERD,EAAM,eAAeC,CAAK,GACzBA,GAAO,OAAoC,WAE5CF,GAAQF,EAAeI,EAAM,MAAkC,QAAQ,EAE3E,CAAC,EACMF,CACT,EAEMG,EAAsC,CAAC,CAC3C,SAAAJ,EACA,UAAWK,EACX,eAAAC,EAAiB,OACjB,iBAAAC,EAAm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AAA,kBAAAA,IAAC,MAAA,CAAI,UAAWf,EAAe,SAAAL,CAAA,CAAS,CAAA,EAC1C,CAEJ,EAEAI,EAAU,YAAc"}
@@ -4,7 +4,7 @@ import { default as React } from 'react';
4
4
  */
5
5
  export interface CodeBlockProps {
6
6
  /** The code content and nested elements to render.*/
7
- children: React.ReactNode;
7
+ children?: React.ReactNode;
8
8
  /** Optional CSS class name for the pre element. */
9
9
  className?: string;
10
10
  /** Text to display on the copy button (i18n support). */
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlock.es.js","sources":["../../../src/components/ContentRender/CodeBlock.tsx"],"sourcesContent":["import React, { useState, ReactNode } from \"react\";\nimport \"./CodeBlock.css\";\nimport { Copy, Check } from \"lucide-react\";\n\n/**\n * Props for the CodeBlock component.\n */\nexport interface CodeBlockProps {\n /** The code content and nested elements to render.*/\n children: React.ReactNode;\n /** Optional CSS class name for the pre element. */\n className?: string;\n /** Text to display on the copy button (i18n support). */\n copyButtonText?: string;\n /** Text to display when code is copied (i18n support). */\n copiedButtonText?: string;\n}\n\nconst getCodeString = (children: ReactNode): string => {\n let text = \"\";\n React.Children.forEach(children, (child) => {\n if (typeof child === \"string\") {\n text += child;\n } else if (\n React.isValidElement(child) &&\n (child?.props as { children?: ReactNode })?.children\n ) {\n text += getCodeString((child.props as { children: ReactNode }).children);\n }\n });\n return text;\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n children,\n className: preClassName,\n copyButtonText = \"Copy\",\n copiedButtonText = \"Copied\",\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = React.useRef<number | null>(null);\n\n React.useEffect(() => {\n // Cleanup timeout on component unmount\n return () => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n };\n }, []);\n\n let codeClassName = \"\";\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = child.props as { className?: string };\n if (childProps.className) {\n codeClassName = childProps.className;\n }\n }\n });\n\n const match = /language-(\\w+)/.exec(codeClassName || \"\");\n const language = match ? match[1] : \"\";\n\n const handleCopy = async () => {\n const codeString = getCodeString(children);\n try {\n await navigator.clipboard.writeText(codeString);\n setIsCopied(true);\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = window.setTimeout(() => {\n setIsCopied(false);\n }, 2000);\n } catch (err) {\n console.error(\"Failed to copy text: \", err);\n }\n };\n\n return (\n <div className=\"code-block-container\">\n <div className=\"code-block-header\">\n <span className=\"language-name\">{language}</span>\n <button onClick={handleCopy} className=\"copy-button\">\n {isCopied ? (\n <Check className=\"copy-icon\" />\n ) : (\n <Copy className=\"copy-icon\" />\n )}\n {isCopied ? copiedButtonText : copyButtonText}\n </button>\n </div>\n <pre className={preClassName}>{children}</pre>\n </div>\n );\n};\n\nCodeBlock.displayName = \"CodeBlock\";\nexport default CodeBlock;\n"],"names":["getCodeString","children","text","React","child","CodeBlock","preClassName","copyButtonText","copiedButtonText","isCopied","setIsCopied","useState","timeoutRef","codeClassName","childProps","match","language","handleCopy","codeString","err","jsxs","jsx","Check","Copy"],"mappings":";;;;;AAkBA,MAAMA,IAAgB,CAACC,MAAgC;AACrD,MAAIC,IAAO;AACXC,SAAAA,EAAM,SAAS,QAAQF,GAAU,CAACG,MAAU;AAC1C,IAAI,OAAOA,KAAU,WACnBF,KAAQE,IAERD,EAAM,eAAeC,CAAK,KACzBA,GAAO,OAAoC,aAE5CF,KAAQF,EAAeI,EAAM,MAAkC,QAAQ;AAAA,EAE3E,CAAC,GACMF;AACT,GAEMG,IAAsC,CAAC;AAAA,EAC3C,UAAAJ;AAAA,EACA,WAAWK;AAAA,EACX,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AACrB,MAAM;AACJ,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK,GACxCC,IAAaT,EAAM,OAAsB,IAAI;AAEnDA,EAAAA,EAAM,UAAU,MAEP,MAAM;AACX,IAAIS,EAAW,WACb,OA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,EAAA,CAAS;AAAA,EAAA,GAC1C;AAEJ;AAEAI,EAAU,cAAc;"}
1
+ {"version":3,"file":"CodeBlock.es.js","sources":["../../../src/components/ContentRender/CodeBlock.tsx"],"sourcesContent":["import React, { useState, ReactNode } from \"react\";\nimport \"./CodeBlock.css\";\nimport { Copy, Check } from \"lucide-react\";\n\n/**\n * Props for the CodeBlock component.\n */\nexport interface CodeBlockProps {\n /** The code content and nested elements to render.*/\n children?: React.ReactNode;\n /** Optional CSS class name for the pre element. */\n className?: string;\n /** Text to display on the copy button (i18n support). */\n copyButtonText?: string;\n /** Text to display when code is copied (i18n support). */\n copiedButtonText?: string;\n}\n\nconst getCodeString = (children: ReactNode): string => {\n let text = \"\";\n React.Children.forEach(children, (child) => {\n if (typeof child === \"string\") {\n text += child;\n } else if (\n React.isValidElement(child) &&\n (child?.props as { children?: ReactNode })?.children\n ) {\n text += getCodeString((child.props as { children: ReactNode }).children);\n }\n });\n return text;\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n children,\n className: preClassName,\n copyButtonText = \"Copy\",\n copiedButtonText = \"Copied\",\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = React.useRef<number | null>(null);\n\n React.useEffect(() => {\n // Cleanup timeout on component unmount\n return () => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n };\n }, []);\n\n let codeClassName = \"\";\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = child.props as { className?: string };\n if (childProps.className) {\n codeClassName = childProps.className;\n }\n }\n });\n\n const match = /language-(\\w+)/.exec(codeClassName || \"\");\n const language = match ? match[1] : \"\";\n\n const handleCopy = async () => {\n const codeString = getCodeString(children);\n try {\n await navigator.clipboard.writeText(codeString);\n setIsCopied(true);\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = window.setTimeout(() => {\n setIsCopied(false);\n }, 2000);\n } catch (err) {\n console.error(\"Failed to copy text: \", err);\n }\n };\n\n return (\n <div className=\"code-block-container\">\n <div className=\"code-block-header\">\n <span className=\"language-name\">{language}</span>\n <button onClick={handleCopy} className=\"copy-button\">\n {isCopied ? (\n <Check className=\"copy-icon\" />\n ) : (\n <Copy className=\"copy-icon\" />\n )}\n {isCopied ? copiedButtonText : copyButtonText}\n </button>\n </div>\n <pre className={preClassName}>{children}</pre>\n </div>\n );\n};\n\nCodeBlock.displayName = \"CodeBlock\";\nexport default CodeBlock;\n"],"names":["getCodeString","children","text","React","child","CodeBlock","preClassName","copyButtonText","copiedButtonText","isCopied","setIsCopied","useState","timeoutRef","codeClassName","childProps","match","language","handleCopy","codeString","err","jsxs","jsx","Check","Copy"],"mappings":";;;;;AAkBA,MAAMA,IAAgB,CAACC,MAAgC;AACrD,MAAIC,IAAO;AACXC,SAAAA,EAAM,SAAS,QAAQF,GAAU,CAACG,MAAU;AAC1C,IAAI,OAAOA,KAAU,WACnBF,KAAQE,IAERD,EAAM,eAAeC,CAAK,KACzBA,GAAO,OAAoC,aAE5CF,KAAQF,EAAeI,EAAM,MAAkC,QAAQ;AAAA,EAE3E,CAAC,GACMF;AACT,GAEMG,IAAsC,CAAC;AAAA,EAC3C,UAAAJ;AAAA,EACA,WAAWK;AAAA,EACX,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AACrB,MAAM;AACJ,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK,GACxCC,IAAaT,EAAM,OAAsB,IAAI;AAEnDA,EAAAA,EAAM,UAAU,MAEP,MAAM;AACX,IAAIS,EAAW,WACb,OAAO,aAAaA,EAAW,OAAO;AAAA,EAE1C,GACC,CAAA,CAAE;AAEL,MAAIC,IAAgB;AACpBV,EAAAA,EAAM,SAAS,QAAQF,GAAU,CAACG,MAAU;AAC1C,QAAID,EAAM,eAAeC,CAAK,GAAG;AAC/B,YAAMU,IAAaV,EAAM;AACzB,MAAIU,EAAW,cACbD,IAAgBC,EAAW;AAAA,IAE/B;AAAA,EACF,CAAC;AAED,QAAMC,IAAQ,iBAAiB,KAAKF,KAAiB,EAAE,GACjDG,IAAWD,IAAQA,EAAM,CAAC,IAAI,IAE9BE,IAAa,YAAY;AAC7B,UAAMC,IAAalB,EAAcC,CAAQ;AACzC,QAAI;AACF,YAAM,UAAU,UAAU,UAAUiB,CAAU,GAC9CR,EAAY,EAAI,GAEZE,EAAW,WACb,OAAO,aAAaA,EAAW,OAAO,GAExCA,EAAW,UAAU,OAAO,WAAW,MAAM;AAC3C,QAAAF,EAAY,EAAK;AAAA,MACnB,GAAG,GAAI;AAAA,IACT,SAASS,GAAK;AACZ,cAAQ,MAAM,yBAAyBA,CAAG;AAAA,IAC5C;AAAA,EACF;AAEA,SACEC,gBAAAA,EAAAA,KAAC,OAAA,EAAI,WAAU,wBACb,UAAA;AAAA,IAAAA,gBAAAA,EAAAA,KAAC,OAAA,EAAI,WAAU,qBACb,UAAA;AAAA,MAAAC,gBAAAA,EAAAA,IAAC,QAAA,EAAK,WAAU,iBAAiB,UAAAL,GAAS;AAAA,MAC1CI,gBAAAA,EAAAA,KAAC,UAAA,EAAO,SAASH,GAAY,WAAU,eACpC,UAAA;AAAA,QAAAR,IACCY,gBAAAA,EAAAA,IAACC,KAAM,WAAU,YAAA,CAAY,IAE7BD,gBAAAA,EAAAA,IAACE,GAAA,EAAK,WAAU,YAAA,CAAY;AAAA,QAE7Bd,IAAWD,IAAmBD;AAAA,MAAA,EAAA,CACjC;AAAA,IAAA,GACF;AAAA,IACAc,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAWf,GAAe,UAAAL,EAAA,CAAS;AAAA,EAAA,GAC1C;AAEJ;AAEAI,EAAU,cAAc;"}
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../_virtual/jsx-runtime.cjs.js");;/* empty css */;/* empty css */const r=require("react"),ve=require("../../_virtual/index.cjs.js"),ye=require("./utils/sanitize-invalid-tag-name.cjs.js"),Re=require("./utils/strip-svg-text-line-breaks.cjs.js");;/* empty css */;/* empty css */const be=require("./CodeBlock.cjs.js"),Te=require("./plugins/CustomVariable.cjs.js"),G=require("./plugins/MermaidChart.cjs.js"),oe=require("./utils/custom-variable-props.cjs.js"),ie=require("./utils/highlight-languages.cjs.js"),X=require("./utils/mermaid-parse.cjs.js"),ae=require("./utils/normalize-inline-html.cjs.js"),we=require("./IframeSandbox.cjs.js"),Ee=require("./utils/split-content.cjs.js"),Ne=require("../../lib/interaction-defaults.cjs.js"),ke=require("./contentRenderI18n.cjs.js"),Se=require("../../node_modules/react-markdown/lib/index.cjs.js"),Be=require("../../node_modules/rehype-raw/lib/index.cjs.js"),Ce=require("../../node_modules/rehype-highlight/lib/index.cjs.js"),qe=require("../../node_modules/rehype-katex/lib/index.cjs.js"),Le=require("../../node_modules/remark-gfm/lib/index.cjs.js"),Me=require("../../node_modules/remark-math/lib/index.cjs.js"),$e=require("../../node_modules/remark-breaks/lib/index.cjs.js"),Ae=/<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\b/i,ce=({svg:n})=>{const i=r.useRef(null);return r.useEffect(()=>{const a=i.current;if(!a)return;const c=a.shadowRoot??a.attachShadow({mode:"open"}),N="content-render-svg-style";let p=c.getElementById(N);p||(p=document.createElement("style"),p.id=N,p.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../_virtual/jsx-runtime.cjs.js");;/* empty css */;/* empty css */const r=require("react"),ve=require("../../_virtual/index.cjs.js"),Re=require("./utils/sanitize-invalid-tag-name.cjs.js"),ye=require("./utils/strip-svg-text-line-breaks.cjs.js");;/* empty css */;/* empty css */const be=require("./CodeBlock.cjs.js"),Te=require("./plugins/CustomVariable.cjs.js"),X=require("./plugins/MermaidChart.cjs.js"),ue=require("./utils/custom-variable-props.cjs.js"),ce=require("./utils/highlight-languages.cjs.js"),J=require("./utils/mermaid-parse.cjs.js"),le=require("./utils/normalize-inline-html.cjs.js"),we=require("./IframeSandbox.cjs.js"),Ee=require("./utils/split-content.cjs.js"),Ne=require("../../lib/interaction-defaults.cjs.js"),ke=require("./contentRenderI18n.cjs.js"),Be=require("../../node_modules/react-markdown/lib/index.cjs.js"),Se=require("../../node_modules/rehype-raw/lib/index.cjs.js"),Ce=require("../../node_modules/rehype-highlight/lib/index.cjs.js"),qe=require("../../node_modules/rehype-katex/lib/index.cjs.js"),Le=require("../../node_modules/remark-gfm/lib/index.cjs.js"),Me=require("../../node_modules/remark-math/lib/index.cjs.js"),$e=require("../../node_modules/remark-breaks/lib/index.cjs.js"),ze=/<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\b/i,de=({svg:n})=>{const a=r.useRef(null);return r.useEffect(()=>{const i=a.current;if(!i)return;const u=i.shadowRoot??i.attachShadow({mode:"open"}),y="content-render-svg-style";let h=u.getElementById(y);h||(h=document.createElement("style"),h.id=y,h.textContent=`
2
2
  svg { height: auto; display: inline-block; }
3
3
  svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }
4
4
  svg.content-render-svg-el--fixed { max-width: none; }
5
- `,c.appendChild(p)),Array.from(c.childNodes).filter(o=>o!==p).forEach(o=>c.removeChild(o));const k=document.createElement("template"),q=Re.stripSvgTextLineBreaks(n);k.innerHTML=q,c.append(k.content.cloneNode(!0));let h=!1,S=!1;c.querySelectorAll("svg").forEach(o=>{const B=o.getAttribute("viewBox");if(!B)return;const C=B.trim().split(/[\s,]+/).map(m=>Number(m));if(C.length!==4||C.some(Number.isNaN))return;const[,,R,v]=C,b=o.getAttribute("width"),T=o.getAttribute("height"),M=m=>{if(!m)return!1;const f=m.trim().toLowerCase();return f==="auto"||f.endsWith("%")},$=m=>{if(!m)return null;const f=m.trim().toLowerCase();if(f==="auto"||f.endsWith("%"))return null;const I=Number.parseFloat(f);return Number.isNaN(I)?null:I},V=M(b),F=M(T),A=!b||b==="0",z=!T||T==="0",P=$(b),H=$(T);if(V||F||A&&z||P===R&&H===v){h=!0,o.classList.add("content-render-svg-el--responsive"),o.classList.remove("content-render-svg-el--fixed"),o.style.width="100%",o.style.height="auto",!o.style.aspectRatio&&v>0&&(o.style.aspectRatio=`${R} / ${v}`);return}S=!0,o.classList.add("content-render-svg-el--fixed"),o.classList.remove("content-render-svg-el--responsive"),A&&R>0&&o.setAttribute("width",`${R}`),z&&v>0&&o.setAttribute("height",`${v}`)});const L=h&&!S;a.classList.toggle("content-render-svg--responsive",L),a.classList.toggle("content-render-svg--fixed",!L)},[n]),t.jsxRuntimeExports.jsx("div",{className:"content-render-svg-scroll",children:t.jsxRuntimeExports.jsx("div",{className:"content-render-svg",ref:i})})},ze=[Le.default,Me.default,ve.default,$e.default],Ie=[oe.preserveCustomVariableProperties,Be.default,ye.sanitizeInvalidTagName,oe.restoreCustomVariableProperties,[Ce.default,{languages:ie.highlightLanguages,subset:ie.subsetLanguages}],qe.default],J=({content:n,components:i})=>t.jsxRuntimeExports.jsx("div",{className:"markdown-renderer",children:t.jsxRuntimeExports.jsx(Se.Markdown,{remarkPlugins:ze,rehypePlugins:Ie,components:i,children:n})}),Ve=n=>{if(n.length<=1)return n;const i=[];return n.forEach(a=>{if(a.type==="sandbox"){i.push(a);return}const c=i[i.length-1];if(c&&c.type!=="sandbox"){i[i.length-1]={type:"markdown",value:`${c.value}${a.value}`};return}i.push({type:"markdown",value:a.value})}),i},Fe=(n,i)=>{const a=Math.max(1,i),c=Array.from(n);return{chunk:c.slice(0,a).join(""),rest:c.slice(a).join("")}},Pe=({content:n,contentType:i,locale:a,customRenderBar:c,onSend:N,typingSpeed:p=40,enableTypewriter:K=!1,onTypeFinished:k,onTypewriterStateChange:q,userInput:h,interactionDefaultValueOptions:S,defaultButtonText:L,defaultInputText:o,defaultSelectedValues:B,readonly:C=!1,confirmButtonText:R,copyButtonText:v,copiedButtonText:b,sandboxLoadingText:T,sandboxStyleLoadingText:M,sandboxScriptLoadingText:$,disableSandboxLoadingOverlay:V=!1,sandboxFullscreenButtonText:F,sandboxExitFullscreenButtonText:A,sandboxMode:z="content",onClickCustomButtonAfterContent:P,beforeSend:H})=>{const w=ke.getContentRenderLocaleTexts(a),Q=R||w.confirmButtonText,m=v||w.copyButtonText,f=b||w.copiedButtonText,I=F||w.sandboxFullscreenButtonText,ue=A||w.sandboxExitFullscreenButtonText,l=!!K&&(!i||i==="text"),Y=2,Z=Math.max(0,p),[g,D]=r.useState(()=>l?"":n),y=r.useRef(""),ee=r.useRef(l),W=r.useRef(!1);r.useEffect(()=>{const e=ee.current;if(ee.current=l,W.current=!1,!l){y.current="",D(n);return}D(s=>{const u=!e,j=n.startsWith(s);if(!u&&!j)return y.current="",n;const d=u||!j?"":s;return y.current=n.slice(d.length),d})},[n,l]),r.useEffect(()=>{l&&(W.current||y.current||g!==n||(W.current=!0,k?.()))},[n,g,l,k]),r.useEffect(()=>{if(!l||!y.current)return;const e=window.setTimeout(()=>{D(s=>{const{chunk:u,rest:j}=Fe(y.current,Y);return u?(y.current=j,`${s}${u}`):s})},Z);return()=>window.clearTimeout(e)},[n,g,l,Y,Z]);const te=r.useMemo(()=>({isTypewriterEnabled:l,isTyping:l&&g!==n,isComplete:g===n,renderedLength:g.length,totalLength:n.length}),[n,g,l]);r.useEffect(()=>{q?.(te)},[q,te]);const x=l?g:n,_=r.useMemo(()=>ae.normalizeInlineHtml(x),[x]),O=r.useMemo(()=>Ne.getInteractionDefaultValues(x,h,S),[S,x,h]),le=L?.trim()||O.buttonText,de=o?.trim()||O.inputText,me=r.useMemo(()=>h?h.split(",").map(e=>e.trim()).filter(Boolean):void 0,[h]),xe=B?.length?B:O.selectedValues||me,ne={"custom-button-after-content":({children:e})=>t.jsxRuntimeExports.jsx("button",{className:"content-render-custom-button-after-content",onClick:P,children:t.jsxRuntimeExports.jsx("span",{className:"content-render-custom-button-after-content-inner",children:e})}),"custom-variable":e=>t.jsxRuntimeExports.jsx(Te.default,{...e,readonly:C,defaultButtonText:le,defaultInputText:de,defaultSelectedValues:xe,onSend:N,beforeSend:H,locale:a,confirmButtonText:Q}),code:e=>{const{className:s,children:u,...j}=e;if(/language-(\w+)/.exec(s||"")?.[1]==="mermaid"){const E=u?.toString().replace(/\n$/,"")||"",je=X.mermaidBlockIsComplete(x,E);return t.jsxRuntimeExports.jsx(G.default,{chart:E,frozen:je})}return t.jsxRuntimeExports.jsx("code",{className:s,...j,children:u})},table:({...e})=>t.jsxRuntimeExports.jsx("div",{className:"content-render-table-container",children:t.jsxRuntimeExports.jsx("table",{className:"content-render-table",...e})}),th:({...e})=>t.jsxRuntimeExports.jsx("th",{className:"content-render-th",...e}),td:({...e})=>t.jsxRuntimeExports.jsx("td",{className:"content-render-td",...e}),tr:({...e})=>t.jsxRuntimeExports.jsx("tr",{className:"content-render-tr",...e}),li:({node:e,...s})=>{const u=e?.properties?.className;return typeof u=="string"&&u.includes("task-list-item")||Array.isArray(u)&&u.includes("task-list-item")?t.jsxRuntimeExports.jsx("li",{className:"content-render-task-list-item",...s}):t.jsxRuntimeExports.jsx("li",{...s})},ol:({...e})=>t.jsxRuntimeExports.jsx("ol",{className:"content-render-ol",...e}),ul:({...e})=>t.jsxRuntimeExports.jsx("ul",{className:"content-render-ul",...e}),input:({...e})=>e.type==="checkbox"?t.jsxRuntimeExports.jsx("input",{type:"checkbox",className:"content-render-checkbox",disabled:!0,...e}):t.jsxRuntimeExports.jsx("input",{...e}),a:({children:e,...s})=>t.jsxRuntimeExports.jsx("a",{target:"_blank",rel:"noopener noreferrer",...s,children:e}),pre:e=>t.jsxRuntimeExports.jsx(be.default,{...e,copyButtonText:m,copiedButtonText:f})},se=r.useMemo(()=>Ae.test(x),[x]),U=r.useMemo(()=>se?Ee.splitContentSegments(x,!0):[],[x,se]),pe=U.some(e=>e.type==="sandbox"),he=r.useMemo(()=>Ve(U),[U]),fe=r.useMemo(()=>X.parseMarkdownSegments(_),[_]),ge=(e,s)=>{const u=ae.normalizeInlineHtml(e);return X.parseMarkdownSegments(u).map((d,re)=>{const E=`${s}-${d.type}-${re}`;return d.type==="text"?t.jsxRuntimeExports.jsx(J,{components:ne,content:d.value},E):d.type==="mermaid"?t.jsxRuntimeExports.jsx(G.default,{chart:d.value,frozen:!d.complete},E):d.type==="svg"?t.jsxRuntimeExports.jsx(ce,{svg:d.value},E):null})};return pe?t.jsxRuntimeExports.jsx("div",{className:"content-render markdown-body",children:he.map((e,s)=>e.type==="sandbox"?t.jsxRuntimeExports.jsx(we.default,{hideFullScreen:!0,type:"sandbox",content:e.value,className:"content-render-iframe",locale:a,loadingText:T,styleLoadingText:M,scriptLoadingText:$,disableLoadingOverlay:V,fullScreenButtonText:I,exitFullScreenButtonText:ue,mode:z},`sandbox-${s}`):t.jsxRuntimeExports.jsx(r.Fragment,{children:ge(e.value,`md-${s}`)},`md-${s}`))}):t.jsxRuntimeExports.jsxs("div",{className:"content-render markdown-body",children:[fe.map((e,s)=>{if(e.type==="text")return t.jsxRuntimeExports.jsx(J,{components:ne,content:e.value},s);if(e.type==="mermaid")return t.jsxRuntimeExports.jsx(G.default,{chart:e.value,frozen:!e.complete},s);if(e.type==="svg")return t.jsxRuntimeExports.jsx(ce,{svg:e.value},s)}),c&&t.jsxRuntimeExports.jsx("div",{className:"content-render-custom-bar",children:r.createElement(c,{content:n,displayContent:_,onSend:N})})]})};exports.MarkdownRenderer=J;exports.default=Pe;
5
+ `,u.appendChild(h)),Array.from(u.childNodes).filter(o=>o!==h).forEach(o=>u.removeChild(o));const B=document.createElement("template"),q=ye.stripSvgTextLineBreaks(n);B.innerHTML=q,u.append(B.content.cloneNode(!0));let f=!1,S=!1;u.querySelectorAll("svg").forEach(o=>{const C=o.getAttribute("viewBox");if(!C)return;const b=C.trim().split(/[\s,]+/).map(m=>Number(m));if(b.length!==4||b.some(Number.isNaN))return;const[,,T,v]=b,w=o.getAttribute("width"),E=o.getAttribute("height"),M=m=>{if(!m)return!1;const p=m.trim().toLowerCase();return p==="auto"||p.endsWith("%")},$=m=>{if(!m)return null;const p=m.trim().toLowerCase();if(p==="auto"||p.endsWith("%"))return null;const F=Number.parseFloat(p);return Number.isNaN(F)?null:F},P=M(w),H=M(E),z=!w||w==="0",A=!E||E==="0",I=$(w),V=$(E);if(P||H||z&&A||I===T&&V===v){f=!0,o.classList.add("content-render-svg-el--responsive"),o.classList.remove("content-render-svg-el--fixed"),o.style.width="100%",o.style.height="auto",!o.style.aspectRatio&&v>0&&(o.style.aspectRatio=`${T} / ${v}`);return}S=!0,o.classList.add("content-render-svg-el--fixed"),o.classList.remove("content-render-svg-el--responsive"),z&&T>0&&o.setAttribute("width",`${T}`),A&&v>0&&o.setAttribute("height",`${v}`)});const L=f&&!S;i.classList.toggle("content-render-svg--responsive",L),i.classList.toggle("content-render-svg--fixed",!L)},[n]),t.jsxRuntimeExports.jsx("div",{className:"content-render-svg-scroll",children:t.jsxRuntimeExports.jsx("div",{className:"content-render-svg",ref:a})})},Ae=[Le.default,Me.default,ve.default,$e.default],Ie=[ue.preserveCustomVariableProperties,Se.default,Re.sanitizeInvalidTagName,ue.restoreCustomVariableProperties,[Ce.default,{languages:ce.highlightLanguages,subset:ce.subsetLanguages}],qe.default],K=({content:n,components:a})=>t.jsxRuntimeExports.jsx("div",{className:"markdown-renderer",children:t.jsxRuntimeExports.jsx(Be.Markdown,{remarkPlugins:Ae,rehypePlugins:Ie,components:a,children:n})}),Ve=n=>{if(n.length<=1)return n;const a=[];return n.forEach(i=>{if(i.type==="sandbox"){a.push(i);return}const u=a[a.length-1];if(u&&u.type!=="sandbox"){a[a.length-1]={type:"markdown",value:`${u.value}${i.value}`};return}a.push({type:"markdown",value:i.value})}),a},Fe=(n,a)=>{const i=Math.max(1,a),u=Array.from(n);return{chunk:u.slice(0,i).join(""),rest:u.slice(i).join("")}},Pe=({content:n,contentType:a,locale:i,customRenderBar:u,onSend:y,typingSpeed:h=40,enableTypewriter:Q=!1,onTypeFinished:B,onTypewriterStateChange:q,userInput:f,interactionDefaultValueOptions:S,defaultButtonText:L,defaultInputText:o,defaultSelectedValues:C,readonly:b=!1,confirmButtonText:T,copyButtonText:v,copiedButtonText:w,sandboxLoadingText:E,sandboxStyleLoadingText:M,sandboxScriptLoadingText:$,disableSandboxLoadingOverlay:P=!1,sandboxFullscreenButtonText:H,sandboxExitFullscreenButtonText:z,sandboxMode:A="content",onClickCustomButtonAfterContent:I,beforeSend:V})=>{const N=ke.getContentRenderLocaleTexts(i),D=T||N.confirmButtonText,m=v||N.copyButtonText,p=w||N.copiedButtonText,F=H||N.sandboxFullscreenButtonText,me=z||N.sandboxExitFullscreenButtonText,l=!!Q&&(!a||a==="text"),Y=2,Z=Math.max(0,h),[g,W]=r.useState(()=>l?"":n),R=r.useRef(""),ee=r.useRef(l),_=r.useRef(!1);r.useEffect(()=>{const e=ee.current;if(ee.current=l,_.current=!1,!l){R.current="",W(n);return}W(s=>{const c=!e,j=n.startsWith(s);if(!c&&!j)return R.current="",n;const d=c||!j?"":s;return R.current=n.slice(d.length),d})},[n,l]),r.useEffect(()=>{l&&(_.current||R.current||g!==n||(_.current=!0,B?.()))},[n,g,l,B]),r.useEffect(()=>{if(!l||!R.current)return;const e=window.setTimeout(()=>{W(s=>{const{chunk:c,rest:j}=Fe(R.current,Y);return c?(R.current=j,`${s}${c}`):s})},Z);return()=>window.clearTimeout(e)},[n,g,l,Y,Z]);const te=r.useMemo(()=>({isTypewriterEnabled:l,isTyping:l&&g!==n,isComplete:g===n,renderedLength:g.length,totalLength:n.length}),[n,g,l]);r.useEffect(()=>{q?.(te)},[q,te]);const x=l?g:n,O=r.useMemo(()=>le.normalizeInlineHtml(x),[x]),U=r.useMemo(()=>Ne.getInteractionDefaultValues(x,f,S),[S,x,f]),ne=L?.trim()||U.buttonText,se=o?.trim()||U.inputText,xe=r.useMemo(()=>f?f.split(",").map(e=>e.trim()).filter(Boolean):void 0,[f]),re=C?.length?C:U.selectedValues||xe,oe=r.useMemo(()=>({"custom-button-after-content":({children:e})=>t.jsxRuntimeExports.jsx("button",{className:"content-render-custom-button-after-content",onClick:I,children:t.jsxRuntimeExports.jsx("span",{className:"content-render-custom-button-after-content-inner",children:e})}),"custom-variable":e=>t.jsxRuntimeExports.jsx(Te.default,{...e,readonly:b,defaultButtonText:ne,defaultInputText:se,defaultSelectedValues:re,onSend:y,beforeSend:V,locale:i,confirmButtonText:D}),code:e=>{const{className:s,children:c,...j}=e;if(/language-(\w+)/.exec(s||"")?.[1]==="mermaid"){const k=c?.toString().replace(/\n$/,"")||"",je=J.mermaidBlockIsComplete(x,k);return t.jsxRuntimeExports.jsx(X.default,{chart:k,frozen:je})}return t.jsxRuntimeExports.jsx("code",{className:s,...j,children:c})},table:({...e})=>t.jsxRuntimeExports.jsx("div",{className:"content-render-table-container",children:t.jsxRuntimeExports.jsx("table",{className:"content-render-table",...e})}),th:({...e})=>t.jsxRuntimeExports.jsx("th",{className:"content-render-th",...e}),td:({...e})=>t.jsxRuntimeExports.jsx("td",{className:"content-render-td",...e}),tr:({...e})=>t.jsxRuntimeExports.jsx("tr",{className:"content-render-tr",...e}),li:({node:e,...s})=>{const c=e?.properties?.className;return typeof c=="string"&&c.includes("task-list-item")||Array.isArray(c)&&c.includes("task-list-item")?t.jsxRuntimeExports.jsx("li",{className:"content-render-task-list-item",...s}):t.jsxRuntimeExports.jsx("li",{...s})},ol:({...e})=>t.jsxRuntimeExports.jsx("ol",{className:"content-render-ol",...e}),ul:({...e})=>t.jsxRuntimeExports.jsx("ul",{className:"content-render-ul",...e}),input:({...e})=>e.type==="checkbox"?t.jsxRuntimeExports.jsx("input",{type:"checkbox",className:"content-render-checkbox",disabled:!0,...e}):t.jsxRuntimeExports.jsx("input",{...e}),a:({children:e,...s})=>t.jsxRuntimeExports.jsx("a",{target:"_blank",rel:"noopener noreferrer",...s,children:e}),pre:e=>t.jsxRuntimeExports.jsx(be.default,{...e,copyButtonText:m,copiedButtonText:p})}),[V,i,I,y,b,x,D,p,m,ne,se,re]),ie=r.useMemo(()=>ze.test(x),[x]),G=r.useMemo(()=>ie?Ee.splitContentSegments(x,!0):[],[x,ie]),pe=G.some(e=>e.type==="sandbox"),he=r.useMemo(()=>Ve(G),[G]),fe=r.useMemo(()=>J.parseMarkdownSegments(O),[O]),ge=(e,s)=>{const c=le.normalizeInlineHtml(e);return J.parseMarkdownSegments(c).map((d,ae)=>{const k=`${s}-${d.type}-${ae}`;return d.type==="text"?t.jsxRuntimeExports.jsx(K,{components:oe,content:d.value},k):d.type==="mermaid"?t.jsxRuntimeExports.jsx(X.default,{chart:d.value,frozen:!d.complete},k):d.type==="svg"?t.jsxRuntimeExports.jsx(de,{svg:d.value},k):null})};return pe?t.jsxRuntimeExports.jsx("div",{className:"content-render markdown-body",children:he.map((e,s)=>e.type==="sandbox"?t.jsxRuntimeExports.jsx(we.default,{hideFullScreen:!0,type:"sandbox",content:e.value,className:"content-render-iframe",locale:i,loadingText:E,styleLoadingText:M,scriptLoadingText:$,disableLoadingOverlay:P,fullScreenButtonText:F,exitFullScreenButtonText:me,mode:A},`sandbox-${s}`):t.jsxRuntimeExports.jsx(r.Fragment,{children:ge(e.value,`md-${s}`)},`md-${s}`))}):t.jsxRuntimeExports.jsxs("div",{className:"content-render markdown-body",children:[fe.map((e,s)=>{if(e.type==="text")return t.jsxRuntimeExports.jsx(K,{components:oe,content:e.value},s);if(e.type==="mermaid")return t.jsxRuntimeExports.jsx(X.default,{chart:e.value,frozen:!e.complete},s);if(e.type==="svg")return t.jsxRuntimeExports.jsx(de,{svg:e.value},s)}),u&&t.jsxRuntimeExports.jsx("div",{className:"content-render-custom-bar",children:r.createElement(u,{content:n,displayContent:O,onSend:y})})]})};exports.MarkdownRenderer=K;exports.default=Pe;
6
6
  //# sourceMappingURL=ContentRender.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContentRender.cjs.js","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport 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 { 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\nconst remarkPlugins = [remarkGfm, remarkMath, remarkFlow, remarkBreaks];\n\nconst rehypePlugins = [\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 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\n const components: CustomComponents = {\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={onClickCustomButtonAfterContent}\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={readonly}\n defaultButtonText={resolvedDefaultButtonText}\n defaultInputText={resolvedDefaultInputText}\n defaultSelectedValues={resolvedDefaultSelectedValues}\n onSend={onSend}\n beforeSend={beforeSend}\n locale={locale}\n confirmButtonText={resolvedConfirmButtonText}\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(renderContent, chartContent);\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={resolvedCopyButtonText}\n copiedButtonText={resolvedCopiedButtonText}\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","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","children","props","CustomButtonInputVariable","className","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","index","key","idx","IframeSandbox","React","jsxs"],"mappings":"k9CA+CMA,GACJ,kGAmEIC,GAA8C,CAAC,CAAE,IAAAC,KAAU,CAC/D,MAAMC,EAAUC,EAAAA,OAAuB,IAAI,EAE3CC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAOH,EAAQ,QACrB,GAAI,CAACG,EAAM,OACX,MAAMC,EAAaD,EAAK,YAAcA,EAAK,aAAa,CAAE,KAAM,OAAQ,EAClEE,EAAU,2BAChB,IAAIC,EAAUF,EAAW,eAAeC,CAAO,EAE1CC,IACHA,EAAU,SAAS,cAAc,OAAO,EACxCA,EAAQ,GAAKD,EAEbC,EAAQ,YAAc;AAAA;AAAA;AAAA;AAAA,QAKtBF,EAAW,YAAYE,CAAO,GAGV,MAAM,KAAKF,EAAW,UAAU,EAAE,OACrDG,GAASA,IAASD,CAAA,EAEP,QAASC,GAASH,EAAW,YAAYG,CAAI,CAAC,EAE5D,MAAMC,EAAW,SAAS,cAAc,UAAU,EAC5CC,EAAaC,GAAAA,uBAAuBX,CAAG,EAC7CS,EAAS,UAAYC,EACrBL,E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EAAI,OAAS,OACf,OACE7G,EAAAA,kBAAAA,IAACe,EAAA,CAEC,WAAAE,GACA,QAAS4F,EAAI,KAAA,EAFRC,CAAA,EAOX,GAAID,EAAI,OAAS,UACf,OACE7G,EAAAA,kBAAAA,IAACkG,EAAAA,QAAA,CAEC,MAAOW,EAAI,MACX,OAAQ,CAACA,EAAI,QAAA,EAFRC,CAAA,EAOX,GAAID,EAAI,OAAS,MACf,OAAO7G,EAAAA,kBAAAA,IAAClC,GAAA,CAA6B,IAAK+I,EAAI,OAAhBC,CAAuB,CAEzD,CAAC,EAEA9E,GACChC,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,4BACZ,SAAAkH,EAAM,cAAclF,EAAiB,CACpC,QAAAH,EACA,eAAgBsD,EAChB,OAAAlD,CAAA,CACD,CAAA,CACH,CAAA,EAEJ,CAEJ"}
1
+ {"version":3,"file":"ContentRender.cjs.js","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport 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\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 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\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={onClickCustomButtonAfterContent}\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={readonly}\n defaultButtonText={resolvedDefaultButtonText}\n defaultInputText={resolvedDefaultInputText}\n defaultSelectedValues={resolvedDefaultSelectedValues}\n onSend={onSend}\n beforeSend={beforeSend}\n locale={locale}\n confirmButtonText={resolvedConfirmButtonText}\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(renderContent, chartContent);\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={resolvedCopyButtonText}\n copiedButtonText={resolvedCopiedButtonText}\n />\n ),\n }),\n [\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues,\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","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","children","props","CustomButtonInputVariable","className","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","index","key","idx","IframeSandbox","React","jsxs"],"mappings":"k9CAgDMA,GACJ,kGAmEIC,GAA8C,CAAC,CAAE,IAAAC,KAAU,CAC/D,MAAMC,EAAUC,EAAAA,OAAuB,IAAI,EAE3CC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAOH,EAAQ,QACrB,GAAI,CAACG,EAAM,OACX,MAAMC,EAAaD,EAAK,YAAcA,EAAK,aAAa,CAAE,KAAM,OAAQ,EAClEE,EAAU,2BAChB,IAAIC,EAAUF,EAAW,eAAeC,CAAO,EAE1CC,IACHA,EAAU,SAAS,cAAc,OAAO,EACxCA,EAAQ,GAAKD,EAEbC,EAAQ,YAAc;AAAA;AAAA;AAAA;AAAA,QAKtBF,EAAW,YAAYE,CAAO,GAGV,MAAM,KAAKF,EAAW,UAAU,EAAE,OACrDG,GAASA,IAASD,CAAA,EAEP,QAASC,GAASH,EAAW,YAAYG,CAAI,CAAC,EAE5D,MAAMC,EAAW,SAAS,cAAc,UAAU,EAC5CC,EAAaC,GAAAA,uBAAuBX,CAAG,EAC7CS,EAAS,UAAYC,EACrBL,EAAW,OAAOI,EAAS,QAAQ,UAAU,EAAI,CAAC,EAElD,IAAIG,EAAmB,GACnBC,EAAc,GAElBR,EAAW,iBAAiB,KAAK,EAAE,QAASS,GAAU,CAEpD,MAAMC,EAAUD,EAAM,aAAa,SAAS,EAC5C,GAAI,CAACC,EAAS,OAEd,MAAMC,EAAaD,EAChB,KAAA,EACA,MAAM,QAAQ,EACd,IAAKE,GAAU,OAAOA,CAAK,CAAC,EAE/B,GAAID,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