mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-28 17:57:48 +02:00
1 line
No EOL
44 KiB
JavaScript
1 line
No EOL
44 KiB
JavaScript
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["59172"],{41918:function(e,n,t){t.d(n,{Z:()=>r});let r="/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport React, {useState} from 'react';\n\nexport default function MyComponent() {\n const [bool, setBool] = useState(false);\n return (\n <div>\n <p>MyComponent rendered !</p>\n <p>bool={bool ? 'true' : 'false'}</p>\n <p>\n <button onClick={() => setBool((b) => !b)}>toggle bool</button>\n </p>\n </div>\n );\n}\n"},78230:function(e,n,t){t.r(n),t.d(n,{Highlight:()=>f,frontMatter:()=>m,contentTitle:()=>p,assets:()=>x,default:()=>b,toc:()=>g,metadata:()=>r});var r=JSON.parse('{"id":"guides/markdown-features/react","title":"MDX and React","description":"Using the power of React in Docusaurus Markdown documents, thanks to MDX","source":"@site/docs/guides/markdown-features/markdown-features-react.mdx","sourceDirName":"guides/markdown-features","slug":"/markdown-features/react","permalink":"/docs/markdown-features/react","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/edit/main/website/docs/guides/markdown-features/markdown-features-react.mdx","tags":[],"version":"current","lastUpdatedBy":"dependabot[bot]","lastUpdatedAt":1744702265000,"frontMatter":{"id":"react","description":"Using the power of React in Docusaurus Markdown documents, thanks to MDX","slug":"/markdown-features/react"},"sidebar":"docs","previous":{"title":"Markdown Features","permalink":"/docs/markdown-features"},"next":{"title":"Tabs","permalink":"/docs/markdown-features/tabs"}}'),s=t(85893),o=t(80980),a=t(14522),i=t(15398),l=t(58636),c=t(27817),d=t(41918);function u(e){let n={code:"code",p:"p",...(0,o.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{children:["Hello ",e.name]}),"\n",(0,s.jsxs)(n.p,{children:["This is text some content from ",(0,s.jsx)(n.code,{children:"_markdown-partial-example.md"}),"."]})]})}function h(e={}){let{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(u,{...e})}):u(e)}t(78596);let m={id:"react",description:"Using the power of React in Docusaurus Markdown documents, thanks to MDX",slug:"/markdown-features/react"},p="MDX and React",x={},f=({children:e,color:n})=>(0,s.jsx)("span",{style:{backgroundColor:n,borderRadius:"2px",color:"#fff",padding:"0.2rem"},children:e}),g=[{value:"Exporting components",id:"exporting-components",level:3},{value:"Importing components",id:"importing-components",level:3},{value:"MDX component scope",id:"mdx-component-scope",level:3},{value:"Markdown and JSX interoperability",id:"markdown-and-jsx-interoperability",level:3},{value:"Importing code snippets",id:"importing-code-snippets",level:2},{value:"Importing Markdown",id:"importing-markdown",level:2},{value:"Available exports",id:"available-exports",level:2}];function j(e){let n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"mdx-and-react",children:"MDX and React"})}),"\n","\n",(0,s.jsxs)(n.p,{children:["Docusaurus has built-in support for ",(0,s.jsx)(n.a,{href:"https://mdxjs.com/",children:"MDX"}),", which allows you to write JSX within your Markdown files and render them as React components."]}),"\n",(0,s.jsxs)(n.p,{children:["Check out the ",(0,s.jsx)(n.a,{href:"https://mdxjs.com/",children:"MDX docs"})," to see what fancy stuff you can do with MDX."]}),"\n",(0,s.jsxs)(n.admonition,{title:"Debugging MDX",type:"tip",children:[(0,s.jsx)(n.p,{children:"The MDX format is quite strict, and you may get compilation errors."}),(0,s.jsxs)(n.p,{children:["Use the ",(0,s.jsx)(n.strong,{children:(0,s.jsx)(n.a,{href:"https://mdxjs.com/playground/",children:"MDX playground"})})," to debug them and make sure your syntax is valid."]})]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["Prettier, the most popular formatter, ",(0,s.jsx)(n.a,{href:"https://github.com/prettier/prettier/issues/12209",children:"supports only the legacy MDX v1"}),". If you get an unintentional formatting result, you may want to add ",(0,s.jsx)(n.code,{children:"{/* prettier-ignore */}"})," before the problematic area, or add ",(0,s.jsx)(n.code,{children:"*.mdx"})," to your ",(0,s.jsx)(n.code,{children:".prettierignore"}),", until Prettier has proper support for MDX v3. ",(0,s.jsxs)(n.a,{href:"https://github.com/orgs/mdx-js/discussions/2067",children:["One of the main authors of MDX recommends ",(0,s.jsx)(n.code,{children:"remark-cli"})," with ",(0,s.jsx)(n.code,{children:"remark-mdx"})]}),"."]})}),"\n",(0,s.jsx)(n.h3,{id:"exporting-components",children:"Exporting components"}),"\n",(0,s.jsxs)(n.p,{children:["To define any custom component within an MDX file, you have to export it: only paragraphs that start with ",(0,s.jsx)(n.code,{children:"export"})," will be parsed as components instead of prose."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-jsx",children:"export const Highlight = ({children, color}) => (\n <span\n style={{\n backgroundColor: color,\n borderRadius: '2px',\n color: '#fff',\n padding: '0.2rem',\n }}>\n {children}\n </span>\n);\n\n<Highlight color=\"#25c2a0\">Docusaurus green</Highlight> and <Highlight color=\"#1877F2\">Facebook blue</Highlight> are my favorite colors.\n\nI can write **Markdown** alongside my _JSX_!\n"})}),"\n",(0,s.jsx)(n.p,{children:"Notice how it renders both the markup from your React component and the Markdown syntax:"}),"\n","\n",(0,s.jsxs)(a.Z,{minHeight:240,children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f,{color:"#25c2a0",children:"Docusaurus green"}),"\n"," ","and ",(0,s.jsx)(f,{color:"#1877F2",children:"Facebook blue"})," are my favorite colors."]}),(0,s.jsxs)(n.p,{children:["I can write ",(0,s.jsx)(n.strong,{children:"Markdown"})," alongside my ",(0,s.jsx)(n.em,{children:"JSX"}),"!"]})]}),"\n",(0,s.jsxs)(n.admonition,{title:"MDX is JSX",type:"warning",children:[(0,s.jsx)(n.p,{children:"Since all doc files are parsed using MDX, anything that looks like HTML is actually JSX. Therefore, if you need to inline-style a component, follow JSX flavor and provide style objects."}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-jsx",children:"/* Instead of this: */\n<span style=\"background-color: red\">Foo</span>\n/* Use this: */\n<span style={{backgroundColor: 'red'}}>Foo</span>\n"})})]}),"\n",(0,s.jsx)(n.h3,{id:"importing-components",children:"Importing components"}),"\n",(0,s.jsx)(n.p,{children:"You can also import your own components defined in other files or third-party components installed via npm."}),"\n","\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-md",children:"\x3c!-- Docusaurus theme component --\x3e\nimport TOCInline from '@theme/TOCInline';\n\x3c!-- External component --\x3e\nimport Button from '@mui/material/Button';\n\x3c!-- Custom component --\x3e\nimport BrowserWindow from '@site/src/components/BrowserWindow';\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"@site"})," alias points to your website's directory, usually where the ",(0,s.jsx)(n.code,{children:"docusaurus.config.js"})," file is. Using an alias instead of relative paths (",(0,s.jsx)(n.code,{children:"'../../src/components/BrowserWindow'"}),") saves you from updating import paths when moving files around, or when ",(0,s.jsx)(n.a,{href:"/docs/versioning",children:"versioning docs"})," and ",(0,s.jsx)(n.a,{href:"/docs/i18n/tutorial",children:"translating"}),"."]})}),"\n",(0,s.jsxs)(n.p,{children:["While declaring components within Markdown is very convenient for simple cases, it becomes hard to maintain because of limited editor support, risks of parsing errors, and low reusability. Use a separate ",(0,s.jsx)(n.code,{children:".js"})," file when your component involves complex JS logic:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-jsx",metastring:'title="src/components/Highlight.js"',children:"import React from 'react';\n\nexport default function Highlight({children, color}) {\n return (\n <span\n style={{\n backgroundColor: color,\n borderRadius: '2px',\n color: '#fff',\n padding: '0.2rem',\n }}>\n {children}\n </span>\n );\n}\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-md",metastring:'title="markdown-file.mdx"',children:"import Highlight from '@site/src/components/Highlight';\n\n<Highlight color=\"#25c2a0\">Docusaurus green</Highlight>\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["If you use the same component across a lot of files, you don't need to import it everywhere\u2014consider adding it to the global scope. ",(0,s.jsx)(n.a,{href:"#mdx-component-scope",children:"See below"})]})}),"\n",(0,s.jsx)(n.h3,{id:"mdx-component-scope",children:"MDX component scope"}),"\n",(0,s.jsxs)(n.p,{children:["Apart from ",(0,s.jsx)(n.a,{href:"#importing-components",children:"importing a component"})," and ",(0,s.jsx)(n.a,{href:"#exporting-components",children:"exporting a component"}),", a third way to use a component in MDX is to ",(0,s.jsx)(n.strong,{children:"register it to the global scope"}),", which will make it automatically available in every MDX file, without any import statements."]}),"\n",(0,s.jsx)(n.p,{children:"For example, given this MDX file:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-md",children:"- a\n- list!\n\nAnd some <Highlight>custom markup</Highlight>...\n"})}),"\n",(0,s.jsxs)(n.p,{children:["It will be compiled to a React component containing ",(0,s.jsx)(n.code,{children:"ul"}),", ",(0,s.jsx)(n.code,{children:"li"}),", ",(0,s.jsx)(n.code,{children:"p"}),", and ",(0,s.jsx)(n.code,{children:"Highlight"})," elements. ",(0,s.jsx)(n.code,{children:"Highlight"})," is not a native html element: you need to provide your own React component implementation for it."]}),"\n",(0,s.jsxs)(n.p,{children:["In Docusaurus, the MDX component scope is provided by the ",(0,s.jsx)(n.code,{children:"@theme/MDXComponents"})," file. It's not a React component, ",(0,s.jsx)(n.em,{children:"per se"}),", unlike most other exports under the ",(0,s.jsx)(n.code,{children:"@theme/"})," alias: it is a record from tag names like ",(0,s.jsx)(n.code,{children:"Highlight"})," to their React component implementations."]}),"\n",(0,s.jsxs)(n.p,{children:["If you ",(0,s.jsx)(n.a,{href:"/docs/swizzling",children:"swizzle"})," this component, you will find all tags that have been implemented, and you can further customize our implementation by swizzling the respective sub-component, like ",(0,s.jsx)(n.code,{children:"@theme/MDXComponents/Code"})," (which is used to render ",(0,s.jsx)(n.a,{href:"/docs/markdown-features/code-blocks",children:"Markdown code blocks"}),")."]}),"\n",(0,s.jsxs)(n.p,{children:["If you want to register extra tag names (like the ",(0,s.jsx)(n.code,{children:"<Highlight>"})," tag above), you should consider ",(0,s.jsxs)(n.a,{href:"/docs/swizzling#wrapping",children:["wrapping ",(0,s.jsx)(n.code,{children:"@theme/MDXComponents"})]}),", so you don't have to maintain all the existing mappings. Since the swizzle CLI doesn't allow wrapping non-component files yet, you should manually create the wrapper:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-js",metastring:'title="src/theme/MDXComponents.js"',children:"import React from 'react';\n// Import the original mapper\nimport MDXComponents from '@theme-original/MDXComponents';\n// highlight-next-line\nimport Highlight from '@site/src/components/Highlight';\n\nexport default {\n // Re-use the default mapping\n ...MDXComponents,\n // Map the \"<Highlight>\" tag to our Highlight component\n // `Highlight` will receive all props that were passed to `<Highlight>` in MDX\n // highlight-next-line\n Highlight,\n};\n"})}),"\n",(0,s.jsxs)(n.p,{children:["And now, you can freely use ",(0,s.jsx)(n.code,{children:"<Highlight>"})," in every page, without writing the import statement:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-md",children:'I can conveniently use <Highlight color="#25c2a0">Docusaurus green</Highlight> everywhere!\n'})}),"\n",(0,s.jsx)(a.Z,{children:(0,s.jsxs)(n.p,{children:["I can conveniently use ",(0,s.jsx)(f,{color:"#25c2a0",children:"Docusaurus green"})," everywhere!"]})}),"\n",(0,s.jsxs)(n.admonition,{type:"warning",children:[(0,s.jsxs)(n.p,{children:["We use ",(0,s.jsx)(n.strong,{children:"upper-case"})," tag names like ",(0,s.jsx)(n.code,{children:"Highlight"})," on purpose."]}),(0,s.jsx)(n.p,{children:"From MDX v3+ onward (Docusaurus v3+), lower-case tag names are always rendered as native html elements, and will not use any component mapping you provide."})]}),"\n",(0,s.jsxs)(n.admonition,{type:"warning",children:[(0,s.jsxs)(n.p,{children:["This feature is powered by ",(0,s.jsxs)(n.a,{href:"https://mdxjs.com/docs/using-mdx/#mdx-provider",children:["an ",(0,s.jsx)(n.code,{children:"MDXProvider"})]}),". If you are importing Markdown in a React page, you have to supply this provider yourself through the ",(0,s.jsx)(n.code,{children:"MDXContent"})," theme component."]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-jsx",metastring:'title="src/pages/index.js"',children:"import React from 'react';\nimport FeatureDisplay from './_featureDisplay.mdx';\n// highlight-next-line\nimport MDXContent from '@theme/MDXContent';\n\nexport default function LandingPage() {\n return (\n <div>\n {/* highlight-start */}\n <MDXContent>\n <FeatureDisplay />\n </MDXContent>\n {/* highlight-end */}\n </div>\n );\n}\n"})}),(0,s.jsxs)(n.p,{children:["If you don't wrap your imported MDX with ",(0,s.jsx)(n.code,{children:"MDXContent"}),", the global scope will not be available."]})]}),"\n",(0,s.jsx)(n.h3,{id:"markdown-and-jsx-interoperability",children:"Markdown and JSX interoperability"}),"\n",(0,s.jsxs)(n.p,{children:["Docusaurus v3 is using ",(0,s.jsx)(n.a,{href:"https://mdxjs.com/blog/v3/",children:"MDX v3"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"https://mdxjs.com/docs/what-is-mdx/#mdx-syntax",children:"MDX syntax"})," is mostly compatible with ",(0,s.jsx)(n.a,{href:"https://commonmark.org/",children:"CommonMark"}),", but is much stricter because your ",(0,s.jsx)(n.code,{children:".mdx"})," files can use JSX and are compiled into real React components (check the ",(0,s.jsx)(n.a,{href:"https://mdxjs.com/playground/",children:"playground"}),")."]}),"\n",(0,s.jsxs)(n.p,{children:["Some valid CommonMark features won't work with MDX (",(0,s.jsx)(n.a,{href:"https://mdxjs.com/docs/what-is-mdx/#markdown",children:"more info"}),"), notably:"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Indented code blocks: use triple backticks instead"}),"\n",(0,s.jsxs)(n.li,{children:["Autolinks (",(0,s.jsx)(n.code,{children:"<http://localhost:3000>"}),"): use regular link syntax instead (",(0,s.jsx)(n.code,{children:"[http://localhost:3000](http://localhost:3000)"}),")"]}),"\n",(0,s.jsxs)(n.li,{children:["HTML syntax (",(0,s.jsx)(n.code,{children:'<p style="color: red;">'}),"): use JSX instead (",(0,s.jsx)(n.code,{children:"<p style={{color: 'red'}}>"}),")"]}),"\n",(0,s.jsxs)(n.li,{children:["Unescaped ",(0,s.jsx)(n.code,{children:"{"})," and ",(0,s.jsx)(n.code,{children:"<"}),": escape them with ",(0,s.jsx)(n.code,{children:"\\"})," instead (",(0,s.jsx)(n.code,{children:"\\{"})," and ",(0,s.jsx)(n.code,{children:"\\<"}),")"]}),"\n"]}),"\n",(0,s.jsxs)(n.admonition,{title:"Experimental CommonMark support",type:"danger",children:[(0,s.jsxs)(n.p,{children:["Docusaurus v3 makes it possible to opt-in for a less strict, standard ",(0,s.jsx)(n.a,{href:"https://commonmark.org/",children:"CommonMark"})," support with the following options:"]}),(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["The ",(0,s.jsx)(n.code,{children:"mdx.format: md"})," front matter"]}),"\n",(0,s.jsxs)(n.li,{children:["The ",(0,s.jsx)(n.code,{children:".md"})," file extension combined with the ",(0,s.jsx)(n.code,{children:'siteConfig.markdown.format: "detect"'})," configuration"]}),"\n"]}),(0,s.jsxs)(n.p,{children:["This feature is ",(0,s.jsx)(n.strong,{children:"experimental"})," and currently has a few ",(0,s.jsx)(n.a,{href:"https://github.com/facebook/docusaurus/issues/9092",children:"limitations"}),"."]})]}),"\n",(0,s.jsx)(n.h2,{id:"importing-code-snippets",children:"Importing code snippets"}),"\n",(0,s.jsxs)(n.p,{children:["You can not only import a file containing a component definition, but also import any code file as raw text, and then insert it in a code block, thanks to ",(0,s.jsx)(n.a,{href:"https://webpack.js.org/loaders/raw-loader/",children:"Webpack raw-loader"}),". In order to use ",(0,s.jsx)(n.code,{children:"raw-loader"}),", you first need to install it in your project:"]}),"\n",(0,s.jsxs)(i.Z,{groupId:"npm2yarn",children:[(0,s.jsx)(l.Z,{value:"npm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"npm install --save raw-loader\n"})})}),(0,s.jsx)(l.Z,{value:"yarn",label:"Yarn",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"yarn add raw-loader\n"})})}),(0,s.jsx)(l.Z,{value:"pnpm",label:"pnpm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"pnpm add raw-loader\n"})})}),(0,s.jsx)(l.Z,{value:"bun",label:"Bun",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"bun add raw-loader\n"})})})]}),"\n",(0,s.jsx)(n.p,{children:"Now you can import code snippets from another file as it is:"}),"\n","\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-jsx",metastring:'title="myMarkdownFile.mdx"',children:"import CodeBlock from '@theme/CodeBlock';\nimport MyComponentSource from '!!raw-loader!./myComponent';\n\n<CodeBlock language=\"jsx\">{MyComponentSource}</CodeBlock>\n"})}),"\n","\n",(0,s.jsx)(a.Z,{children:(0,s.jsx)(c.Z,{language:"jsx",children:d.Z})}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"/docs/markdown-features/code-blocks#usage-in-jsx",children:"using code blocks in JSX"})," for more details of the ",(0,s.jsx)(n.code,{children:"<CodeBlock>"})," component."]}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["You have to use ",(0,s.jsx)(n.code,{children:"<CodeBlock>"})," rather than the Markdown triple-backtick ",(0,s.jsx)(n.code,{children:"```"}),", because the latter will ship out any of its content as-is, but you want to interpolate the imported text here."]})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsx)(n.p,{children:"This feature is experimental and might be subject to breaking API changes in the future."})}),"\n",(0,s.jsx)(n.h2,{id:"importing-markdown",children:"Importing Markdown"}),"\n",(0,s.jsxs)(n.p,{children:["You can use Markdown files as components and import them elsewhere, either in Markdown files or in React pages. Each MDX file default-exports its page content as a React component. In the ",(0,s.jsx)(n.code,{children:"import"})," statement, you can default-import this component with any name, but it must be capitalized following React's naming rules."]}),"\n",(0,s.jsxs)(n.p,{children:["By convention, using the ",(0,s.jsxs)(n.strong,{children:[(0,s.jsx)(n.code,{children:"_"})," filename prefix"]})," will not create any doc page and means the Markdown file is a ",(0,s.jsx)(n.strong,{children:'"partial"'}),", to be imported by other files."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-md",metastring:'title="_markdown-partial-example.mdx"',children:"<span>Hello {props.name}</span>\n\nThis is text some content from `_markdown-partial-example.mdx`.\n"})}),"\n","\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-jsx",metastring:'title="someOtherDoc.mdx"',children:"import PartialExample from './_markdown-partial-example.mdx';\n\n<PartialExample name=\"Sebastien\" />\n"})}),"\n","\n",(0,s.jsx)(a.Z,{children:(0,s.jsx)(h,{name:"Sebastien"})}),"\n",(0,s.jsx)(n.p,{children:"This way, you can reuse content among multiple pages and avoid duplicating materials."}),"\n",(0,s.jsx)(n.h2,{id:"available-exports",children:"Available exports"}),"\n",(0,s.jsx)(n.p,{children:"Within the MDX page, the following variables are available as globals:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"frontMatter"}),": the front matter as a record of string keys and values;"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"toc"}),": the table of contents, as a tree of headings. See also ",(0,s.jsx)(n.a,{href:"/docs/markdown-features/toc#inline-table-of-contents",children:"Inline TOC"})," for a more concrete use-case."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"contentTitle"}),": the Markdown title, which is the first ",(0,s.jsx)(n.code,{children:"h1"})," heading in the Markdown text. It's ",(0,s.jsx)(n.code,{children:"undefined"})," if there isn't one (e.g. title specified in the front matter)."]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-jsx",children:"import TOCInline from '@theme/TOCInline';\nimport CodeBlock from '@theme/CodeBlock';\n\nThe table of contents for this page, serialized:\n\n<CodeBlock className=\"language-json\">{JSON.stringify(toc, null, 2)}</CodeBlock>\n\nThe front matter of this page:\n\n<ul>\n {Object.entries(frontMatter).map(([key, value]) => <li key={key}><b>{key}</b>: {value}</li>)}\n</ul>\n\n<p>The title of this page is: <b>{contentTitle}</b></p>\n"})}),"\n","\n",(0,s.jsxs)(a.Z,{children:[(0,s.jsx)(n.p,{children:"The table of contents for this page, serialized:"}),(0,s.jsx)(c.Z,{className:"language-json",children:JSON.stringify(g,null,2)}),(0,s.jsx)(n.p,{children:"The front matter of this page:"}),(0,s.jsx)("ul",{children:Object.entries(m).map(([e,n])=>(0,s.jsxs)("li",{children:[(0,s.jsx)("b",{children:e}),": ",n]},e))}),(0,s.jsxs)("p",{children:["The title of this page is: ",(0,s.jsx)("b",{children:p})]})]})]})}function b(e={}){let{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(j,{...e})}):j(e)}},78596:function(e,n,t){t.d(n,{Z:()=>o});var r=t(85893);t(67294);var s=t(89477);function o(e){let{toc:n,minHeadingLevel:t,maxHeadingLevel:o}=e;return(0,r.jsx)("div",{className:"tableOfContentsInline_2sru",children:(0,r.jsx)(s.Z,{toc:n,minHeadingLevel:t,maxHeadingLevel:o,className:"table-of-contents",linkClassName:null})})}},89477:function(e,n,t){t.d(n,{Z:()=>c});var r=t(85893),s=t(67294),o=t(26378);function a(e){let n=e.getBoundingClientRect();return n.top===n.bottom?a(e.parentNode):n}var i=t(35363);let l=s.memo(function e(n){let{toc:t,className:s,linkClassName:o,isChild:a}=n;return t.length?(0,r.jsx)("ul",{className:a?void 0:s,children:t.map(n=>(0,r.jsxs)("li",{children:[(0,r.jsx)(i.Z,{to:`#${n.id}`,className:o??void 0,dangerouslySetInnerHTML:{__html:n.value}}),(0,r.jsx)(e,{isChild:!0,toc:n.children,className:s,linkClassName:o})]},n.id))}):null});function c(e){let{toc:n,className:t="table-of-contents table-of-contents__left-border",linkClassName:i="table-of-contents__link",linkActiveClassName:c,minHeadingLevel:d,maxHeadingLevel:u,...h}=e,m=(0,o.L)(),p=d??m.tableOfContents.minHeadingLevel,x=u??m.tableOfContents.maxHeadingLevel,f=function(e){let{toc:n,minHeadingLevel:t,maxHeadingLevel:r}=e;return(0,s.useMemo)(()=>(function e(n){let{toc:t,minHeadingLevel:r,maxHeadingLevel:s}=n;return t.flatMap(n=>{let t=e({toc:n.children,minHeadingLevel:r,maxHeadingLevel:s});return n.level>=r&&n.level<=s?[{...n,children:t}]:t})})({toc:function(e){let n=e.map(e=>({...e,parentIndex:-1,children:[]})),t=Array(7).fill(-1);n.forEach((e,n)=>{let r=t.slice(2,e.level);e.parentIndex=Math.max(...r),t[e.level]=n});let r=[];return n.forEach(e=>{let{parentIndex:t,...s}=e;t>=0?n[t].children.push(s):r.push(s)}),r}(n),minHeadingLevel:t,maxHeadingLevel:r}),[n,t,r])}({toc:n,minHeadingLevel:p,maxHeadingLevel:x});var g=(0,s.useMemo)(()=>{if(i&&c)return{linkClassName:i,linkActiveClassName:c,minHeadingLevel:p,maxHeadingLevel:x}},[i,c,p,x]);let j=(0,s.useRef)(void 0),b=function(){let e=(0,s.useRef)(0),{navbar:{hideOnScroll:n}}=(0,o.L)();return(0,s.useEffect)(()=>{e.current=n?0:document.querySelector(".navbar").clientHeight},[n]),e}();return(0,s.useEffect)(()=>{if(!g)return()=>{};let{linkClassName:e,linkActiveClassName:n,minHeadingLevel:t,maxHeadingLevel:r}=g;function s(){let s=Array.from(document.getElementsByClassName(e)),o=function(e,n){let{anchorTopOffset:t}=n,r=e.find(e=>a(e).top>=t);if(r){var s;return(s=a(r)).top>0&&s.bottom<window.innerHeight/2?r:e[e.indexOf(r)-1]??null}return e[e.length-1]??null}(function(e){let{minHeadingLevel:n,maxHeadingLevel:t}=e,r=[];for(let e=n;e<=t;e+=1)r.push(`h${e}.anchor`);return Array.from(document.querySelectorAll(r.join()))}({minHeadingLevel:t,maxHeadingLevel:r}),{anchorTopOffset:b.current}),i=s.find(e=>o&&o.id===decodeURIComponent(e.href.substring(e.href.indexOf("#")+1)));s.forEach(e=>{e===i?(j.current&&j.current!==e&&j.current.classList.remove(n),e.classList.add(n),j.current=e):e.classList.remove(n)})}return document.addEventListener("scroll",s),document.addEventListener("resize",s),s(),()=>{document.removeEventListener("scroll",s),document.removeEventListener("resize",s)}},[g,b]),(0,r.jsx)(l,{toc:f,className:t,linkClassName:i,...h})}},58636:function(e,n,t){t.d(n,{Z:()=>o});var r=t(85893);t(67294);var s=t(90496);function o(e){let{children:n,hidden:t,className:o}=e;return(0,r.jsx)("div",{role:"tabpanel",className:(0,s.Z)("tabItem_pnkT",o),hidden:t,children:n})}},15398:function(e,n,t){t.d(n,{Z:()=>j});var r=t(85893),s=t(67294),o=t(90496),a=t(54947),i=t(3620),l=t(844),c=t(97486),d=t(32263),u=t(16971);function h(e){return s.Children.toArray(e).filter(e=>"\n"!==e).map(e=>{if(!e||(0,s.isValidElement)(e)&&function(e){let{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)})?.filter(Boolean)??[]}function m(e){let{value:n,tabValues:t}=e;return t.some(e=>e.value===n)}var p=t(71607);function x(e){let{className:n,block:t,selectedValue:s,selectValue:i,tabValues:l}=e,c=[],{blockElementScrollPositionUntilNextRender:d}=(0,a.o5)(),u=e=>{let n=e.currentTarget,t=l[c.indexOf(n)].value;t!==s&&(d(n),i(t))},h=e=>{let n=null;switch(e.key){case"Enter":u(e);break;case"ArrowRight":{let t=c.indexOf(e.currentTarget)+1;n=c[t]??c[0];break}case"ArrowLeft":{let t=c.indexOf(e.currentTarget)-1;n=c[t]??c[c.length-1]}}n?.focus()};return(0,r.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,o.Z)("tabs",{"tabs--block":t},n),children:l.map(e=>{let{value:n,label:t,attributes:a}=e;return(0,r.jsx)("li",{role:"tab",tabIndex:s===n?0:-1,"aria-selected":s===n,ref:e=>{c.push(e)},onKeyDown:h,onClick:u,...a,className:(0,o.Z)("tabs__item","tabItem_AQgk",a?.className,{"tabs__item--active":s===n}),children:t??n},n)})})}function f(e){let{lazy:n,children:t,selectedValue:a}=e,i=(Array.isArray(t)?t:[t]).filter(Boolean);if(n){let e=i.find(e=>e.props.value===a);return e?(0,s.cloneElement)(e,{className:(0,o.Z)("margin-top--md",e.props.className)}):null}return(0,r.jsx)("div",{className:"margin-top--md",children:i.map((e,n)=>(0,s.cloneElement)(e,{key:n,hidden:e.props.value!==a}))})}function g(e){let n=function(e){let{defaultValue:n,queryString:t=!1,groupId:r}=e,o=function(e){let{values:n,children:t}=e;return(0,s.useMemo)(()=>{let e=n??h(t).map(e=>{let{props:{value:n,label:t,attributes:r,default:s}}=e;return{value:n,label:t,attributes:r,default:s}}),r=(0,d.lx)(e,(e,n)=>e.value===n.value);if(r.length>0)throw Error(`Docusaurus error: Duplicate values "${r.map(e=>e.value).join(", ")}" found in <Tabs>. Every value needs to be unique.`);return e},[n,t])}(e),[a,p]=(0,s.useState)(()=>(function(e){let{defaultValue:n,tabValues:t}=e;if(0===t.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(n){if(!m({value:n,tabValues:t}))throw Error(`Docusaurus error: The <Tabs> has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${t.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}let r=t.find(e=>e.default)??t[0];if(!r)throw Error("Unexpected error: 0 tabValues");return r.value})({defaultValue:n,tabValues:o})),[x,f]=function(e){let{queryString:n=!1,groupId:t}=e,r=(0,i.k6)(),o=function(e){let{queryString:n=!1,groupId:t}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!t)throw Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return t??null}({queryString:n,groupId:t});return[(0,c._X)(o),(0,s.useCallback)(e=>{if(!o)return;let n=new URLSearchParams(r.location.search);n.set(o,e),r.replace({...r.location,search:n.toString()})},[o,r])]}({queryString:t,groupId:r}),[g,j]=function(e){let{groupId:n}=e,t=n?`docusaurus.tab.${n}`:null,[r,o]=(0,u.Nk)(t);return[r,(0,s.useCallback)(e=>{t&&o.set(e)},[t,o])]}({groupId:r}),b=(()=>{let e=x??g;return m({value:e,tabValues:o})?e:null})();return(0,l.Z)(()=>{b&&p(b)},[b]),{selectedValue:a,selectValue:(0,s.useCallback)(e=>{if(!m({value:e,tabValues:o}))throw Error(`Can't select invalid tab value=${e}`);p(e),f(e),j(e)},[f,j,o]),tabValues:o}}(e);return(0,r.jsxs)("div",{className:(0,o.Z)("tabs-container","tabList_Qoir"),children:[(0,r.jsx)(x,{...n,...e}),(0,r.jsx)(f,{...n,...e})]})}function j(e){let n=(0,p.Z)();return(0,r.jsx)(g,{...e,children:h(e.children)},String(n))}},56497:function(e,n,t){t.d(n,{Z:()=>o});var r=t(85893);t(67294);var s=t(71607);function o(e){let{children:n,fallback:t}=e;return(0,s.Z)()?(0,r.jsx)(r.Fragment,{children:n?.()}):t??null}},14522:function(e,n,t){t.d(n,{Z:()=>i});var r=t(85893);t(67294);var s=t(90496);let o="dot_giz1",a="bar_rrRL";function i(e){let{children:n,minHeight:t,url:i="http://localhost:3000",style:l,bodyStyle:c}=e;return(0,r.jsxs)("div",{className:"browserWindow_my1Q",style:{...l,minHeight:t},children:[(0,r.jsxs)("div",{className:"browserWindowHeader_jXSR",children:[(0,r.jsxs)("div",{className:"buttons_uHc7",children:[(0,r.jsx)("span",{className:o,style:{background:"#f25f58"}}),(0,r.jsx)("span",{className:o,style:{background:"#fbbe3c"}}),(0,r.jsx)("span",{className:o,style:{background:"#58cb42"}})]}),(0,r.jsx)("div",{className:(0,s.Z)("browserWindowAddressBar_Pd8y","text--truncate"),children:i}),(0,r.jsx)("div",{className:"browserWindowMenuIcon_Vhuh",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:a}),(0,r.jsx)("span",{className:a}),(0,r.jsx)("span",{className:a})]})})]}),(0,r.jsx)("div",{className:"browserWindowBody_Idgs",style:c,children:n})]})}},27817:function(e,n,t){t.d(n,{Z:()=>ex});var r={};t.r(r),t.d(r,{ButtonExample:()=>eu});var s=t(85893),o=t(67294),a=t(71607),i=t(90496),l=t(45245),c=t(26378);function d(){let{prism:e}=(0,c.L)(),{colorMode:n}=(0,l.I)(),t=e.theme,r=e.darkTheme||t;return"dark"===n?r:t}var u=t(55951),h=t(6324),m=t.n(h),p=t(50923);let x=/title=(?<quote>["'])(?<title>.*?)\1/,f=/\{(?<range>[\d,-]+)\}/,g={js:{start:"\\/\\/",end:""},jsBlock:{start:"\\/\\*",end:"\\*\\/"},jsx:{start:"\\{\\s*\\/\\*",end:"\\*\\/\\s*\\}"},bash:{start:"#",end:""},html:{start:"\x3c!--",end:"--\x3e"}},j={...g,lua:{start:"--",end:""},wasm:{start:"\\;\\;",end:""},tex:{start:"%",end:""},vb:{start:"['\u2018\u2019]",end:""},vbnet:{start:"(?:_\\s*)?['\u2018\u2019]",end:""},rem:{start:"[Rr][Ee][Mm]\\b",end:""},f90:{start:"!",end:""},ml:{start:"\\(\\*",end:"\\*\\)"},cobol:{start:"\\*>",end:""}},b=Object.keys(g);function v(e,n){let t=e.map(e=>{let{start:t,end:r}=j[e];return`(?:${t}\\s*(${n.flatMap(e=>[e.line,e.block?.start,e.block?.end].filter(Boolean)).join("|")})\\s*${r})`}).join("|");return RegExp(`^\\s*(?:${t})\\s*$`)}let w=(0,o.createContext)(null);function y(e){let{metadata:n,wordWrap:t,children:r}=e,a=(0,o.useMemo)(()=>({metadata:n,wordWrap:t}),[n,t]);return(0,s.jsx)(w.Provider,{value:a,children:r})}function k(){let e=(0,o.useContext)(w);if(null===e)throw new p.i6("CodeBlockContextProvider");return e}function N(e){let{as:n,...t}=e,r=function(e){let n={color:"--prism-color",backgroundColor:"--prism-background-color"},t={};return Object.entries(e.plain).forEach(e=>{let[r,s]=e,o=n[r];o&&"string"==typeof s&&(t[o]=s)}),t}(d());return(0,s.jsx)(n,{...t,style:r,className:(0,i.Z)(t.className,"codeBlockContainer_jDV4",u.k.common.codeBlock)})}let C={codeBlock:"codeBlock_Gebt",codeBlockStandalone:"codeBlockStandalone_i_cY",codeBlockLines:"codeBlockLines_FJaf",codeBlockLinesWithNumbering:"codeBlockLinesWithNumbering_FU9Q"};function M(e){let{children:n,className:t}=e;return(0,s.jsx)(N,{as:"pre",tabIndex:0,className:(0,i.Z)(C.codeBlockStandalone,"thin-scrollbar",t),children:(0,s.jsx)("code",{className:C.codeBlockLines,children:n})})}let B={attributes:!0,characterData:!0,childList:!0,subtree:!0};function D(e){let{children:n}=e;return n}var I=t(7316);function L(e){let{line:n,token:t,...r}=e;return(0,s.jsx)("span",{...r})}let T={codeLine:"codeLine_qRmp",codeLineNumber:"codeLineNumber_dS_J",codeLineContent:"codeLineContent_XF5l"};function X(e){let{line:n,classNames:t,showLineNumbers:r,getLineProps:o,getTokenProps:a}=e,l=function(e){let n=1===e.length&&"\n"===e[0].content?e[0]:void 0;return n?[{...n,content:""}]:e}(n),c=o({line:l,className:(0,i.Z)(t,r&&T.codeLine)}),d=l.map((e,n)=>{let t=a({token:e});return(0,s.jsx)(L,{...t,line:l,token:e,children:t.children},n)});return(0,s.jsxs)("span",{...c,children:[r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:T.codeLineNumber}),(0,s.jsx)("span",{className:T.codeLineContent,children:d})]}):d,(0,s.jsx)("br",{})]})}let E=o.forwardRef((e,n)=>(0,s.jsx)("pre",{ref:n,tabIndex:0,...e,className:(0,i.Z)(e.className,C.codeBlock,"thin-scrollbar")}));function S(e){let{metadata:n}=k();return(0,s.jsx)("code",{...e,className:(0,i.Z)(e.className,C.codeBlockLines,void 0!==n.lineNumbersStart&&C.codeBlockLinesWithNumbering),style:{...e.style,counterReset:void 0===n.lineNumbersStart?void 0:`line-count ${n.lineNumbersStart-1}`}})}function _(e){let{className:n}=e,{metadata:t,wordWrap:r}=k(),o=d(),{code:a,language:l,lineNumbersStart:c,lineClassNames:u}=t;return(0,s.jsx)(I.y$,{theme:o,code:a,language:l,children:e=>{let{className:t,style:o,tokens:a,getLineProps:l,getTokenProps:d}=e;return(0,s.jsx)(E,{ref:r.codeBlockRef,className:(0,i.Z)(n,t),style:o,children:(0,s.jsx)(S,{children:a.map((e,n)=>(0,s.jsx)(X,{line:e,getLineProps:l,getTokenProps:d,classNames:u[n],showLineNumbers:void 0!==c},n))})})}})}var H=t(56497),Z=t(44771),R=t(77827);function A(e){let{className:n,...t}=e;return(0,s.jsx)("button",{type:"button",...t,className:(0,i.Z)("clean-btn",n)})}function O(e){return(0,s.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,s.jsx)("path",{fill:"currentColor",d:"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"})})}function F(e){return(0,s.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,s.jsx)("path",{fill:"currentColor",d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})}let W={copyButtonCopied:"copyButtonCopied_wDuR",copyButtonIcons:"copyButtonIcons_gMWc",copyButtonIcon:"copyButtonIcon_GXfb",copyButtonSuccessIcon:"copyButtonSuccessIcon_ktUX"};function z(e){let{className:n}=e,{copyCode:t,isCopied:r}=function(){let{metadata:{code:e}}=k(),[n,t]=(0,o.useState)(!1),r=(0,o.useRef)(void 0),s=(0,o.useCallback)(()=>{(0,Z.Z)(e),t(!0),r.current=window.setTimeout(()=>{t(!1)},1e3)},[e]);return(0,o.useEffect)(()=>()=>window.clearTimeout(r.current),[]),{copyCode:s,isCopied:n}}();return(0,s.jsx)(A,{"aria-label":r?(0,R.I)({id:"theme.CodeBlock.copied",message:"Copied",description:"The copied button label on code blocks"}):(0,R.I)({id:"theme.CodeBlock.copyButtonAriaLabel",message:"Copy code to clipboard",description:"The ARIA label for copy code blocks button"}),title:(0,R.I)({id:"theme.CodeBlock.copy",message:"Copy",description:"The copy button label on code blocks"}),className:(0,i.Z)(n,W.copyButton,r&&W.copyButtonCopied),onClick:t,children:(0,s.jsxs)("span",{className:W.copyButtonIcons,"aria-hidden":"true",children:[(0,s.jsx)(O,{className:W.copyButtonIcon}),(0,s.jsx)(F,{className:W.copyButtonSuccessIcon})]})})}function $(e){return(0,s.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,s.jsx)("path",{fill:"currentColor",d:"M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"})})}let J={wordWrapButtonIcon:"wordWrapButtonIcon___5r",wordWrapButtonEnabled:"wordWrapButtonEnabled_nam_"};function U(e){let{className:n}=e,{wordWrap:t}=k();if(!(t.isEnabled||t.isCodeScrollable))return!1;let r=(0,R.I)({id:"theme.CodeBlock.wordWrapToggle",message:"Toggle word wrap",description:"The title attribute for toggle word wrapping button of code block lines"});return(0,s.jsx)(A,{onClick:()=>t.toggle(),className:(0,i.Z)(n,t.isEnabled&&J.wordWrapButtonEnabled),"aria-label":r,title:r,children:(0,s.jsx)($,{className:J.wordWrapButtonIcon,"aria-hidden":"true"})})}function P(e){let{className:n}=e;return(0,s.jsx)(H.Z,{children:()=>(0,s.jsxs)("div",{className:(0,i.Z)(n,"buttonGroup_KXnS"),children:[(0,s.jsx)(U,{}),(0,s.jsx)(z,{})]})})}let q={codeBlockContent:"codeBlockContent_cKMj",codeBlockTitle:"codeBlockTitle_U6Q0"};function V(e){let{className:n}=e,{metadata:t}=k();return(0,s.jsxs)(N,{as:"div",className:(0,i.Z)(n,t.className),children:[t.title&&(0,s.jsx)("div",{className:q.codeBlockTitle,children:(0,s.jsx)(D,{children:t.title})}),(0,s.jsxs)("div",{className:q.codeBlockContent,children:[(0,s.jsx)(_,{}),(0,s.jsx)(P,{})]})]})}function Y(e){let n=function(e){let{prism:n}=(0,c.L)();return function(e){var n,t,r;let s=(t=(n={language:e.language,defaultLanguage:e.defaultLanguage,className:e.className}).language??function(e){if(!e)return;let n=e.split(" ").find(e=>e.startsWith("language-"));return n?.replace(/language-/,"")}(n.className)??n.defaultLanguage,t?.toLowerCase()??"text"),{lineClassNames:o,code:a}=function(e,n){let t=e.replace(/\r?\n$/,"");return function(e,n){let{metastring:t,magicComments:r}=n;if(t&&f.test(t)){let n=t.match(f).groups.range;if(0===r.length)throw Error(`A highlight range has been given in code block's metastring (\`\`\` ${t}), but no magic comment config is available. Docusaurus applies the first magic comment entry's className for metastring ranges.`);let s=r[0].className;return{lineClassNames:Object.fromEntries(m()(n).filter(e=>e>0).map(e=>[e-1,[s]])),code:e}}return null}(t,{...n})??function(e,n){let{language:t,magicComments:r}=n;if(void 0===t)return{lineClassNames:{},code:e};let s=function(e,n){switch(e){case"js":case"javascript":case"ts":case"typescript":return v(["js","jsBlock"],n);case"jsx":case"tsx":return v(["js","jsBlock","jsx"],n);case"html":return v(["js","jsBlock","html"],n);case"python":case"py":case"bash":return v(["bash"],n);case"markdown":case"md":return v(["html","jsx","bash"],n);case"tex":case"latex":case"matlab":return v(["tex"],n);case"lua":case"haskell":return v(["lua"],n);case"sql":return v(["lua","jsBlock"],n);case"wasm":return v(["wasm"],n);case"vb":case"vba":case"visual-basic":return v(["vb","rem"],n);case"vbnet":return v(["vbnet","rem"],n);case"batch":return v(["rem"],n);case"basic":return v(["rem","f90"],n);case"fsharp":return v(["js","ml"],n);case"ocaml":case"sml":return v(["ml"],n);case"fortran":return v(["f90"],n);case"cobol":return v(["cobol"],n);default:return v(b,n)}}(t,r),o=e.split(/\r?\n/),a=Object.fromEntries(r.map(e=>[e.className,{start:0,range:""}])),i=Object.fromEntries(r.filter(e=>e.line).map(e=>{let{className:n,line:t}=e;return[t,n]})),l=Object.fromEntries(r.filter(e=>e.block).map(e=>{let{className:n,block:t}=e;return[t.start,n]})),c=Object.fromEntries(r.filter(e=>e.block).map(e=>{let{className:n,block:t}=e;return[t.end,n]}));for(let e=0;e<o.length;){let n=o[e].match(s);if(!n){e+=1;continue}let t=n.slice(1).find(e=>void 0!==e);i[t]?a[i[t]].range+=`${e},`:l[t]?a[l[t]].start=e:c[t]&&(a[c[t]].range+=`${a[c[t]].start}-${e-1},`),o.splice(e,1)}let d={};return Object.entries(a).forEach(e=>{let[n,{range:t}]=e;m()(t).forEach(e=>{d[e]??=[],d[e].push(n)})}),{code:o.join("\n"),lineClassNames:d}}(t,{...n})}(e.code,{metastring:e.metastring,magicComments:e.magicComments,language:s}),l=function(e){let{className:n,language:t}=e;return(0,i.Z)(n,t&&!n?.includes(`language-${t}`)&&`language-${t}`)}({className:e.className,language:s}),c=(r=e.metastring,(r?.match(x)?.groups.title??"")||e.title),d=function(e){let{showLineNumbers:n,metastring:t}=e;if("boolean"==typeof n)return n?1:void 0;if("number"==typeof n)return n;let r=t?.split(" ").find(e=>e.startsWith("showLineNumbers"));if(r)return r.startsWith("showLineNumbers=")?parseInt(r.replace("showLineNumbers=",""),10):1}({showLineNumbers:e.showLineNumbers,metastring:e.metastring});return{codeInput:e.code,code:a,className:l,language:s,title:c,lineNumbersStart:d,lineClassNames:o}}({code:e.children,className:e.className,metastring:e.metastring,magicComments:n.magicComments,defaultLanguage:n.defaultLanguage,language:e.language,title:e.title,showLineNumbers:e.showLineNumbers})}(e),t=function(){let[e,n]=(0,o.useState)(!1),[t,r]=(0,o.useState)(!1),s=(0,o.useRef)(null),a=(0,o.useCallback)(()=>{let t=s.current.querySelector("code");e?t.removeAttribute("style"):(t.style.whiteSpace="pre-wrap",t.style.overflowWrap="anywhere"),n(e=>!e)},[s,e]),i=(0,o.useCallback)(()=>{let{scrollWidth:e,clientWidth:n}=s.current;r(e>n||s.current.querySelector("code").hasAttribute("style"))},[s]),[l,c]=(0,o.useState)(),d=(0,o.useCallback)(()=>{c(s.current?.closest("[role=tabpanel][hidden]"))},[s,c]);return(0,o.useEffect)(()=>{d()},[d]),!function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:B,r=(0,p.zX)(n),s=(0,p.Ql)(t);(0,o.useEffect)(()=>{let n=new MutationObserver(r);return e&&n.observe(e,s),()=>n.disconnect()},[e,r,s])}(l,e=>{e.forEach(e=>{"attributes"===e.type&&"hidden"===e.attributeName&&(i(),d())})},{attributes:!0,characterData:!1,childList:!1,subtree:!1}),(0,o.useEffect)(()=>{i()},[e,i]),(0,o.useEffect)(()=>(window.addEventListener("resize",i,{passive:!0}),()=>{window.removeEventListener("resize",i)}),[i]),{codeBlockRef:s,isEnabled:e,isCodeScrollable:t,toggle:a}}();return(0,s.jsx)(y,{metadata:n,wordWrap:t,children:(0,s.jsx)(V,{})})}function Q(e){let{children:n,...t}=e,r=(0,a.Z)(),i=o.Children.toArray(n).some(e=>(0,o.isValidElement)(e))?n:Array.isArray(n)?n.join(""):n;return(0,s.jsx)("string"==typeof i?Y:M,{...t,children:i},String(r))}var G=t(10075);let K=e=>`${e};`;function ee(e){let{code:n,children:t,...r}=e,o=d(),a=r.metastring?.includes("noInline")??!1;return(0,s.jsx)(G.nu,{noInline:a,theme:o,...r,code:n?.replace(/\n$/,""),transformCode:r.transformCode??K,children:t})}function en(e){let{children:n}=e;return(0,s.jsx)("div",{className:"playgroundContainer_TDLX",children:n})}var et=t(85108),er=t(67490);function es(e){let{children:n}=e;return(0,s.jsx)("div",{className:(0,i.Z)("playgroundHeader_h_Hu"),children:n})}function eo(){return(0,s.jsx)("div",{children:"Loading..."})}function ea(){return(0,s.jsx)(H.Z,{fallback:(0,s.jsx)(eo,{}),children:()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(er.Z,{fallback:e=>(0,s.jsx)(et.Ac,{...e}),children:(0,s.jsx)(G.i5,{})}),(0,s.jsx)(G.IF,{})]})})}function ei(){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(es,{children:(0,s.jsx)(R.Z,{id:"theme.Playground.result",description:"The result label of the live codeblocks",children:"Result"})}),(0,s.jsx)("div",{className:"playgroundPreview_u2xE",children:(0,s.jsx)(ea,{})})]})}function el(){let e=(0,a.Z)();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(es,{children:(0,s.jsx)(R.Z,{id:"theme.Playground.liveEditor",description:"The live editor label of the live codeblocks",children:"Live Editor"})}),(0,s.jsx)(G.uz,{className:"playgroundEditor_uqZ4"},String(e))]})}function ec(){let{playgroundPosition:e}=(0,c.L)().liveCodeBlock;return(0,s.jsx)(s.Fragment,{children:"top"===e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ei,{}),(0,s.jsx)(el,{})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(el,{}),(0,s.jsx)(ei,{})]})})}function ed(e){let{children:n,transformCode:t,...r}=e;return(0,s.jsx)(en,{children:(0,s.jsx)(ee,{code:n,...r,children:(0,s.jsx)(ec,{})})})}function eu(e){return(0,s.jsx)("button",{type:"button",...e,style:{backgroundColor:"white",color:"black",border:"solid red",borderRadius:20,padding:10,cursor:"pointer",...e.style}})}let eh={React:o,...o,...r};function em(e){return(0,s.jsx)(ed,{scope:eh,...e})}function ep(e){return e.live?(0,s.jsx)(em,{...e}):(0,s.jsx)(Q,{...e})}function ex(e){return(0,s.jsx)(ep,{...e})}}}]); |