"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[4222],{44222:(e,n,r)=>{r.r(n),r.d(n,{createMarkdownParser:()=>d,default:()=>l});var a=r(68211),t=r(62246),i=r(95587),o=r(40488);new a.Token("@jupyterlab/mermaid:IMermaidManager","a manager for rendering mermaid text-based diagrams");const s=new a.Token("@jupyterlab/mermaid:IMermaidMarkdown","a manager for rendering mermaid text-based diagrams in markdown fenced code blocks"),c="```~~~";function d(e,n){return{render:r=>u.render(r,e,n)}}const l={id:"@jupyterlab/markedparser-extension:plugin",description:"Provides the Markdown parser.",autoStart:!0,provides:o.IMarkdownParser,requires:[i.IEditorLanguageRegistry],optional:[s],activate:(e,n,r)=>d(n,{blocks:r?[r]:[]})};var u;!function(e){let n=null,i=null,o=[],s=null,d={},l=new t.LruCache;async function u(e){if(i)return i;if(n)return await n.promise;o=(null==e?void 0:e.blocks)||[],o=o.sort(((e,n)=>{var r,a;return(null!==(r=e.rank)&&void 0!==r?r:1/0)-(null!==(a=n.rank)&&void 0!==a?a:1/0)})),n=new a.PromiseDelegate;const[{marked:t,Renderer:s},c]=await Promise.all([r.e(5321).then(r.bind(r,95321)),f()]);for(const e of c)t.use(e);return d={async:!0,gfm:!0,walkTokens:m,renderer:g(s)},i=t,n.resolve(i),i}async function f(){return Promise.all([(async()=>(await r.e(8530).then(r.bind(r,78530))).gfmHeadingId())(),(async()=>(await r.e(6818).then(r.bind(r,56818))).mangle())()])}function g(e){const n=new e,r=n.code;return n.code=(e,a)=>{for(const n of o)if(n.languages.includes(a)){const r=n.render(e);if(null!=r)return r}const t=`${a}${c}${e}${c}`,i=l.get(t);return null!=i?i:r.call(n,e,a)},n}async function m(e){if("code"===e.type){if(e.lang)for(const n of o)if(n.languages.includes(e.lang))return void await n.walk(e.text);await async function(e){const{lang:n,text:r}=e;if(!n||!s)return;const a=`${n}${c}${r}${c}`;if(l.get(a))return;const t=document.createElement("div");try{await s.highlight(r,s.findBest(n),t);const e=`<pre><code class="language-${n}">${t.innerHTML}</code></pre>`;l.set(a,e)}catch(e){console.error(`Failed to highlight ${n} code`,e)}finally{t.remove()}}(e)}}e.render=async function(e,n,r){return s=n,i||(i=await u(r)),i(e,d)},e.initializeMarked=u}(u||(u={}))}}]);