@mdxeditor/editor 0.0.1 → 0.1.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Petyo Ivanov
3
+ Copyright (c) 2023 Petyo Ivanov
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty,t=(t,n,r)=>(((t,n,r)=>{n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r})(t,"symbol"!=typeof n?n+"":n,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@lexical/react/LexicalComposer"),r=require("@lexical/react/LexicalContentEditable"),a=require("@lexical/react/LexicalErrorBoundary"),o=require("@lexical/react/LexicalHorizontalRulePlugin"),l=require("@lexical/react/LexicalLinkPlugin"),i=require("@lexical/react/LexicalListPlugin"),s=require("@lexical/react/LexicalRichTextPlugin"),c=require("@lexical/react/LexicalTabIndentationPlugin"),d=require("classnames"),u=require("lexical"),m=require("react"),p=require("mdast-util-directive"),h=require("mdast-util-frontmatter"),g=require("mdast-util-gfm-table"),E=require("mdast-util-mdx"),v=require("mdast-util-to-markdown"),f=require("@lexical/code"),w=require("@lexical/link"),k=require("@lexical/list"),x=require("@lexical/react/LexicalHorizontalRuleNode"),y=require("@lexical/rich-text"),C=require("mdast-util-from-markdown"),_=require("micromark-extension-directive"),b=require("micromark-extension-frontmatter"),N=require("micromark-extension-gfm-table"),T=require("micromark-extension-mdxjs"),S=require("@lexical/utils"),M=require("@lexical/react/LexicalComposerContext"),L=require("@lexical/selection"),H=require("@lexical/react/LexicalHistoryPlugin"),A=require("@radix-ui/react-popover"),O=require("@radix-ui/react-tooltip"),V=require("downshift"),R=require("@lexical/markdown"),D=require("@lexical/react/LexicalMarkdownShortcutPlugin"),I=require("@codesandbox/sandpack-react"),P=require("js-yaml"),B=require("react-hook-form"),$=require("@lexical/react/LexicalNestedComposer"),Z=require("mdast-util-to-hast"),U=require("hast-util-raw"),F=require("hast-util-sanitize"),K=require("hast-util-to-html"),z=require("@radix-ui/react-toolbar"),j=require("@codemirror/lang-markdown"),q=require("react-diff-view"),W=require("unidiff"),J=require("@radix-ui/react-select"),G=require("@radix-ui/react-dialog");function Y(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const Q=Y(m),X=Y(A),ee=Y(O),te=Y(z),ne=Y(J),re=Y(G);class ae extends u.ElementNode{constructor(e,n){super(n),t(this,"__kind"),this.__kind=e||"note"}static getType(){return"admonition"}getKind(){return this.getLatest().__kind}setKind(e){e!==this.getKind()&&(this.getWritable().__kind=e)}static clone(e){return new ae(e.__kind,e.__key)}createDOM(e){const t=document.createElement("div");return S.addClassNamesToElement(t,e.theme.admonition[this.__kind]),t}updateDOM(e,t){return!1}static importJSON(e){return oe(e.kind)}exportJSON(){return{...super.exportJSON(),type:"admonition"}}insertNewAfter(e,t){const n=oe();return this.insertAfter(n,t),n}collapseAtStart(){const e=u.$createParagraphNode();return this.getChildren().forEach((t=>e.append(t))),this.replace(e),!0}}function oe(e){return u.$applyNodeReplacement(new ae(e))}function le(e){return e instanceof ae}function ie(e,t){return t(e),e}function se(){}class ce extends u.DecoratorNode{constructor(e,n,r,a){super(a),t(this,"__code"),t(this,"__meta"),t(this,"__language"),t(this,"__focusEmitter",function(){let e=se;return{publish:()=>{e()},subscribe:t=>{e=t}}}()),this.__code=e,this.__meta=r,this.__language=n}static getType(){return"codeblock"}static clone(e){return new ce(e.__code,e.__language,e.__meta,e.__key)}static importJSON(e){const{code:t,meta:n,language:r}=e;return de({code:t,language:r,meta:n})}exportJSON(){return{code:this.getCode(),language:this.getLanguage(),meta:this.getMeta(),type:"codeblock",version:1}}createDOM(e){return document.createElement("div")}updateDOM(){return!1}getCode(){return this.getLatest().__code}getMeta(){return this.getLatest().__meta}getLanguage(){return this.getLatest().__language}setCode(e){e!==this.__code&&(this.getWritable().__code=e)}setMeta(e){e!==this.__meta&&(this.getWritable().__meta=e)}setLanguage(e){e!==this.__language&&(this.getWritable().__language=e)}select(){this.__focusEmitter.publish()}decorate(e,{theme:{nodeDecoratorComponents:{CodeBlockEditor:t}}}){return m.createElement(t,{nodeKey:this.getKey(),code:this.getCode(),meta:this.getMeta(),language:this.getLanguage(),onChange:e=>this.setCode(e),focusEmitter:this.__focusEmitter})}}function de({code:e,language:t,meta:n}){return new ce(e,t,n)}function ue(e){return e instanceof ce}class me extends u.DecoratorNode{constructor(e,n){super(n),t(this,"__yaml"),this.__yaml=e}static getType(){return"frontmatter"}static clone(e){return new me(e.__yaml,e.__key)}static importJSON(e){const{yaml:t}=e;return pe({yaml:t})}exportJSON(){return{yaml:this.getYaml(),type:"frontmatter",version:1}}createDOM(e){return document.createElement("div")}updateDOM(){return!1}getYaml(){return this.getLatest().__yaml}setYaml(e){e!==this.__yaml&&(this.getWritable().__yaml=e)}decorate(e,{theme:{nodeDecoratorComponents:{FrontmatterEditor:t}}}){return m.createElement(t,{yaml:this.getYaml(),onChange:t=>null==e?void 0:e.update((()=>{this.setYaml(t)}))})}}function pe({yaml:e}){return new me(e)}function he(e){return e instanceof me}function ge(e){if(e instanceof HTMLImageElement){const{alt:t,src:n,title:r}=e;return{node:ve({altText:t,src:n,title:r})}}return null}class Ee extends u.DecoratorNode{constructor(e,n,r,a){super(a),t(this,"__src"),t(this,"__altText"),t(this,"__title"),this.__src=e,this.__title=r,this.__altText=n}static getType(){return"image"}static clone(e){return new Ee(e.__src,e.__altText,e.__title,e.__key)}static importJSON(e){const{altText:t,title:n,src:r}=e;return ve({altText:t,title:n,src:r})}exportDOM(){const e=document.createElement("img");return e.setAttribute("src",this.__src),e.setAttribute("alt",this.__altText),this.__title&&e.setAttribute("title",this.__title),{element:e}}static importDOM(){return{img:()=>({conversion:ge,priority:0})}}exportJSON(){return{altText:this.getAltText(),title:this.getTitle(),src:this.getSrc(),type:"image",version:1}}createDOM(e){const t=document.createElement("span"),n=e.theme.image;return void 0!==n&&(t.className=n),t}updateDOM(){return!1}getSrc(){return this.__src}getAltText(){return this.__altText}getTitle(){return this.__title}setTitle(e){this.getWritable().__title=e}decorate(){return m.createElement("img",{title:this.__title,src:this.__src,alt:this.__altText})}}function ve({altText:e,title:t,src:n,key:r}){return new Ee(n,e,t,r)}function fe(e){return e instanceof Ee}const we={text:{bold:"_bold_1xdbx_1",italic:"_italic_1xdbx_5",underline:"_underline_1xdbx_9",code:"_code_1xdbx_43",strikethrough:"_strikethrough_1xdbx_25",subscript:"_subscript_1xdbx_33",superscript:"_superscript_1xdbx_38",underlineStrikethrough:"_underlineStrikethrough_1xdbx_29"},list:{nested:{listitem:"_nestedListItem_1xdbx_50"}},admonition:{danger:"_admonitionDanger_1xdbx_54",info:"_admonitionInfo_1xdbx_54",note:"_admonitionNote_1xdbx_54",tip:"_admonitionTip_1xdbx_54",caution:"_admonitionCaution_1xdbx_54"}},ke={type:"root",format:"left",indent:0,direction:"ltr",version:1,children:[{type:"paragraph",version:1,direction:"ltr",format:"left",indent:0,children:[]}]},xe={type:"root",format:"left",indent:0,direction:"ltr",version:1,children:[]};class ye extends u.DecoratorNode{constructor({name:e,kind:n,attributes:r,state:a,updateFn:o,key:l}){if(super(l),t(this,"__kind"),t(this,"__name"),t(this,"__attributes"),t(this,"__editor"),this.__name=e,this.__kind=n,this.__attributes=r,this.__editor=u.createEditor(),a){const e=this.__editor.parseEditorState(a);e.isEmpty()||this.__editor.setEditorState(e)}else if(o){const e=this.__editor.parseEditorState({root:"text"===this.getKind()?ke:xe},(()=>{if("text"===this.getKind()){const e=u.$getRoot().getFirstChildOrThrow();o(e)}else o(u.$getRoot())}));e.isEmpty()||this.__editor.setEditorState(e)}}static getType(){return"jsx"}static clone(e){return new ye({name:e.__name,kind:e.__kind,attributes:e.__attributes,state:e.__editor.getEditorState().toJSON()})}static importJSON(e){const{name:t,kind:n,attributes:r,state:a}=e;return Ce({kind:n,name:t,attributes:r,state:a})}exportJSON(){return{name:this.getName(),kind:this.getKind(),attributes:this.getAttributes(),state:this.__editor.getEditorState().toJSON(),type:"jsx",version:1}}inNestedEditor(e){this.__editor.getEditorState().read(e)}getChildren(){if("flow"===this.getKey())return u.$getRoot().getChildren()||[];{const e=u.$getRoot().getFirstChild();return e&&e.getChildren()||[]}}createDOM(){return"flow"===this.getKey()?document.createElement("div"):document.createElement("span")}updateDOM(){return!1}getName(){return this.__name}getKind(){return this.__kind}getAttributes(){return this.__attributes}updateAttributes(e){this.getWritable().__attributes=Object.entries(e).map((([e,t])=>({name:e,value:t})))}decorate(e,{theme:{nodeDecoratorComponents:{JsxEditor:t}}}){return m.createElement(t,{attributes:this.getAttributes(),componentName:this.getName(),kind:this.getKind(),editor:this.__editor,onSubmit:e=>this.updateAttributes(e),theme:we})}}function Ce(e){return new ye(e)}function _e(e){return e instanceof ye}class be extends u.DecoratorNode{constructor(e,n,r,a){super(a),t(this,"__code"),t(this,"__meta"),t(this,"__language"),t(this,"__focusEmitter",function(){let e=se;return{publish:()=>{e()},subscribe:t=>{e=t}}}()),this.__code=e,this.__meta=r,this.__language=n}static getType(){return"sandpack"}static clone(e){return new be(e.__code,e.__language,e.__meta,e.__key)}static importJSON(e){const{code:t,meta:n,language:r}=e;return Ne({code:t,language:r,meta:n})}exportJSON(){return{code:this.getCode(),language:this.getLanguage(),meta:this.getMeta(),type:"sandpack",version:1}}createDOM(e){return document.createElement("div")}updateDOM(){return!1}getCode(){return this.getLatest().__code}getMeta(){return this.getLatest().__meta}getLanguage(){return this.getLatest().__language}setCode(e){e!==this.__code&&(this.getWritable().__code=e)}setMeta(e){e!==this.__meta&&(this.getWritable().__meta=e)}setLanguage(e){e!==this.__language&&(this.getWritable().__language=e)}select(){this.__focusEmitter.publish()}decorate(e,{theme:{nodeDecoratorComponents:{SandpackEditor:t}}}){return m.createElement(t,{nodeKey:this.getKey(),code:this.getCode(),meta:this.getMeta(),onChange:e=>this.setCode(e),focusEmitter:this.__focusEmitter})}}function Ne({code:e,language:t,meta:n}){return new be(e,t,n)}function Te(e){return e instanceof be}const Se={type:"tableCell",children:[]};class Me extends u.DecoratorNode{constructor(e,n){super(n),t(this,"__mdastNode"),t(this,"focusEmitter",function(){let e=se;return{publish:t=>{e(t)},subscribe:t=>{e=t}}}()),this.__mdastNode=e||{type:"table",children:[]}}static getType(){return"table"}static clone(e){return new Me(structuredClone(e.__mdastNode),e.__key)}static importJSON(e){return He(e.mdastNode)}exportJSON(){return{mdastNode:structuredClone(this.__mdastNode),type:"table",version:1}}getMdastNode(){return this.__mdastNode}getRowCount(){return this.__mdastNode.children.length}getColCount(){var e;return(null==(e=this.__mdastNode.children[0])?void 0:e.children.length)||0}createDOM(){return document.createElement("div")}updateDOM(){return!1}updateCellContents(e,t,n){const r=this.getWritable().__mdastNode,a=r.children[t],o=a.children,l=o[e],i=Array.from(o),s={...l,children:n},c={...a,children:i};i[e]=s,r.children[t]=c}insertColumnAt(e){const t=this.getWritable().__mdastNode;for(let n=0;n<t.children.length;n++){const r=t.children[n],a=r.children,o=Array.from(a),l={...r,children:o};o.splice(e,0,structuredClone(Se)),t.children[n]=l}t.align&&t.align.length>0&&t.align.splice(e,0,"left")}deleteColumnAt(e){const t=this.getWritable().__mdastNode;for(let n=0;n<t.children.length;n++){const r=t.children[n],a=r.children,o=Array.from(a),l={...r,hildren:o};o.splice(e,1),t.children[n]=l}}insertRowAt(e){const t=this.getWritable().__mdastNode,n={type:"tableRow",children:Array.from({length:this.getColCount()},(()=>structuredClone(Se)))};t.children.splice(e,0,n)}deleteRowAt(e){this.getWritable().__mdastNode.children.splice(e,1)}addRowToBottom(){this.insertRowAt(this.getRowCount())}addColumnToRight(){this.insertColumnAt(this.getColCount())}setColumnAlign(e,t){const n=this.getWritable().__mdastNode;null==n.align&&(n.align=[]),n.align[e]=t}decorate(e,{theme:{nodeDecoratorComponents:{TableEditor:t}}}){return m.createElement(t,{lexicalTable:this,mdastNode:this.__mdastNode,parentEditor:e})}select(e){this.focusEmitter.publish(e)}isInline(){return!1}}function Le(e){return e instanceof Me}function He(e){return new Me(e)}const Ae={testLexicalNode:u.$isRootNode,visitLexicalNode:({actions:e})=>{e.addAndStepInto("root")}},Oe={testLexicalNode:u.$isParagraphNode,visitLexicalNode:({actions:e})=>{e.addAndStepInto("paragraph")}},Ve={testLexicalNode:he,visitLexicalNode:({actions:e,lexicalNode:t})=>{e.addAndStepInto("yaml",{value:t.getYaml()})}},Re={testLexicalNode:w.$isLinkNode,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto("link",{url:e.getURL(),title:e.getTitle()})}},De={testLexicalNode:y.$isHeadingNode,visitLexicalNode:({lexicalNode:e,actions:t})=>{const n=parseInt(e.getTag()[1],10);t.addAndStepInto("heading",{depth:n})}},Ie={testLexicalNode:k.$isListNode,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto("list",{ordered:"number"===e.getListType(),spread:!1})}},Pe={testLexicalNode:k.$isListItemNode,visitLexicalNode:({lexicalNode:e,mdastParent:t,actions:n})=>{const r=e.getChildren(),a=r[0];if(1===r.length&&k.$isListNode(a)){const r=t.children.at(-1);n.visitChildren(e,r)}else{const r=n.appendToParent(t,{type:"listItem",spread:!1,children:[{type:"paragraph",children:[]}]});n.visitChildren(e,r.children[0])}}},Be={testLexicalNode:y.$isQuoteNode,visitLexicalNode:({lexicalNode:e,mdastParent:t,actions:n})=>{const r=n.appendToParent(t,{type:"blockquote",children:[{type:"paragraph",children:[]}]});n.visitChildren(e,r.children[0])}},$e={testLexicalNode:le,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto("containerDirective",{name:e.getKind()})}},Ze={testLexicalNode:Te,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto("code",{value:e.getCode(),lang:e.getLanguage(),meta:e.getMeta()})}},Ue={testLexicalNode:ue,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto("code",{value:e.getCode(),lang:e.getLanguage(),meta:e.getMeta()})}};function Fe(e){return"text"===e.type}const Ke={testLexicalNode:u.$isLineBreakNode,visitLexicalNode:({mdastParent:e,actions:t})=>{t.appendToParent(e,{type:"text",value:"\n"})}},ze={LexicalRootVisitor:Ae,LexicalParagraphVisitor:Oe,LexicalFrontmatterVisitor:Ve,LexicalTextVisitor:{shouldJoin:(e,t)=>["text","emphasis","strong","mdxJsxTextElement"].includes(e.type)&&e.type===t.type,join:(e,t)=>Fe(e)&&Fe(t)?{type:"text",value:e.value+t.value}:{...e,children:[...e.children,...t.children]},testLexicalNode:u.$isTextNode,visitLexicalNode:({lexicalNode:e,mdastParent:t,actions:n})=>{const r=e.getPreviousSibling(),a=u.$isTextNode(r)?r.getFormat():0,o=e.getTextContent(),l=e.getFormat()??0;if(16&l)return void n.addAndStepInto("inlineCode",{value:o});let i=t;a&l&2&&(i=n.appendToParent(i,{type:"emphasis",children:[]})),a&l&1&&(i=n.appendToParent(i,{type:"strong",children:[]})),a&l&8&&(i=n.appendToParent(i,{type:"mdxJsxTextElement",name:"u",children:[],attributes:[]})),2&l&&!(2&a)&&(i=n.appendToParent(i,{type:"emphasis",children:[]})),1&l&&!(1&a)&&(i=n.appendToParent(i,{type:"strong",children:[]})),8&l&&!(8&a)&&(i=n.appendToParent(i,{type:"mdxJsxTextElement",name:"u",children:[],attributes:[]})),n.appendToParent(i,{type:"text",value:o})}},LexicalLinebreakVisitor:Ke,LexicalLinkVisitor:Re,LexicalHeadingVisitor:De,LexicalListVisitor:Ie,LexicalListItemVisitor:Pe,LexicalQuoteVisitor:Be,SandpackNodeVisitor:Ze,CodeBlockVisitor:Ue,LexicalThematicBreakVisitor:{testLexicalNode:x.$isHorizontalRuleNode,visitLexicalNode({actions:e}){e.addAndStepInto("thematicBreak")}},AdmonitionVisitor:$e,LexicalImageVisitor:{testLexicalNode:fe,visitLexicalNode({lexicalNode:e,actions:t}){t.addAndStepInto("image",{url:e.getSrc(),alt:e.getAltText(),title:e.getTitle()})}},JsxVisitor:{testLexicalNode:_e,visitLexicalNode({mdastParent:e,lexicalNode:t,actions:n}){const r="text"===t.getKind()?"mdxJsxTextElement":"mdxJsxFlowElement";n.registerReferredComponent(t.getName());const a={type:r,name:t.getName(),attributes:t.getAttributes(),children:[]};n.appendToParent(e,a),t.inNestedEditor((()=>{n.visitChildren(t,a)}))}},LexicalTableVisitor:{testLexicalNode:Le,visitLexicalNode({actions:e,mdastParent:t,lexicalNode:n}){e.appendToParent(t,n.getMdastNode())}}};function je({root:e,visitors:t,jsxComponentDescriptors:n}){let r=null;const a=new Set;function o(e){a.add(e)}function l(e,n){if(null===r)return r=n,r;if(!function(e){return e.children instanceof Array}(e))throw new Error("Attempting to append children to a non-parent");const a=e.children,o=a.at(-1);if(o){const e=t.find((e=>{var t;return null==(t=e.shouldJoin)?void 0:t.call(e,o,n)}));if(e){const t=e.join(o,n);return a.splice(a.length-1,1,t),t}}return a.push(n),n}function i(e,t){e.getChildren().forEach((e=>{s(e,t)}))}function s(e,n){var r;const a=t.find((t=>{var n;return null==(n=t.testLexicalNode)?void 0:n.call(t,e)}));if(!a)throw new Error(`no lexical visitor found for ${e.getType()}`,{cause:e});null==(r=a.visitLexicalNode)||r.call(a,{lexicalNode:e,mdastParent:n,actions:{addAndStepInto(t,r={},a=!0){const o={type:t,...r,...a?{children:[]}:{}};l(n,o),u.$isElementNode(e)&&a&&i(e,o)},appendToParent:l,visitChildren:i,registerReferredComponent:o}})}if(s(e,null),null===r)throw new Error("traversal ended with no root element");const c=new Map,d=new Map;for(const u of a){const e=n.find((e=>e.name===u));if(!e)throw new Error(`Component ${u} is used but not imported`);if(e.defaultExport)d.set(u,e.source);else{const{source:t}=e,n=c.get(t);n?n.push(u):c.set(t,[u])}}const m=Array.from(c).map((([e,t])=>({type:"mdxjsEsm",value:`import { ${t.join(", ")} } from '${e}'`})));m.push(...Array.from(d).map((([e,t])=>({type:"mdxjsEsm",value:`import ${e} from '${t}'`}))));const p=r,h=p.children.find((e=>"yaml"===e.type));return h?p.children.splice(p.children.indexOf(h)+1,0,...m):p.children.unshift(...m),Je(p,[]),p}const qe=/\s+$/,We=/^\s+/;function Je(e,t){if("strong"===e.type||"emphasis"===e.type){const n=e.children.at(-1);if("text"===(null==n?void 0:n.type)){const r=n.value.match(qe);if(r){n.value=n.value.replace(qe,"");const a=t.at(-1);a&&(a.children.splice(a.children.indexOf(e)+1,0,{type:"text",value:r[0]}),Je(a,t.slice(0,-1)))}}const r=e.children.at(0);if("text"===(null==r?void 0:r.type)){const n=r.value.match(We);if(n){r.value=r.value.replace(We,"");const a=t.at(-1);a&&(a.children.splice(a.children.indexOf(e),0,{type:"text",value:n[0]}),Je(a,t.slice(0,-1)))}}}if(Object.hasOwn(e,"children")){const n=e;n.children.forEach((e=>Je(e,[...t,n])))}}const Ge={mdxToMarkdown:E.mdxToMarkdown(),frontmatterToMarkdown:h.frontmatterToMarkdown("yaml"),directiveToMarkdown:p.directiveToMarkdown,gfmTableToMarkdown:g.gfmTableToMarkdown({tableCellPadding:!0,tablePipeAlign:!0})},Ye={listItemIndent:"one"};const Qe={MdastRootVisitor:{testNode:"root",visitNode({actions:e,mdastNode:t,lexicalParent:n}){e.visitChildren(t,n)}},MdastParagraphVisitor:{testNode:"paragraph",visitNode:function({mdastNode:e,lexicalParent:t,actions:n}){k.$isListItemNode(t)||y.$isQuoteNode(t)||le(t)?n.visitChildren(e,t):n.addAndStepInto(u.$createParagraphNode())}},MdastTextVisitor:{testNode:"text",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(u.$createTextNode(e.value).setFormat(t.getParentFormatting()))}},MdastFormattingVisitor:{testNode:e=>"emphasis"===e.type||"strong"===e.type||"mdxJsxTextElement"===e.type&&"u"===(null==e?void 0:e.name),visitNode({mdastNode:e,lexicalParent:t,actions:n}){"emphasis"===e.type?n.addFormatting(2):"strong"===e.type?n.addFormatting(1):"mdxJsxTextElement"===e.type&&"u"===e.name&&n.addFormatting(8),n.visitChildren(e,t)}},MdastInlineCodeVisitor:{testNode:"inlineCode",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(u.$createTextNode(e.value).setFormat(16))}},MdastLinkVisitor:{testNode:"link",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(w.$createLinkNode(e.url,{title:e.title}))}},MdastHeadingVisitor:{testNode:"heading",visitNode:function({mdastNode:e,actions:t}){t.addAndStepInto(y.$createHeadingNode(`h${e.depth}`))}},MdastListVisitor:{testNode:"list",visitNode:function({mdastNode:e,lexicalParent:t,actions:n}){const r=k.$createListNode(e.ordered?"number":"bullet");if(k.$isListItemNode(t)){const e=k.$createListItemNode();e.append(r),t.insertAfter(e)}else t.append(r);n.visitChildren(e,r)}},MdastListItemVisitor:{testNode:"listItem",visitNode({actions:e}){e.addAndStepInto(k.$createListItemNode())}},MdastBlockQuoteVisitor:{testNode:"blockquote",visitNode({actions:e}){e.addAndStepInto(y.$createQuoteNode())}},MdastCodeVisitor:{testNode:"code",visitNode({mdastNode:e,actions:t}){var n;const r=(null==(n=e.meta)?void 0:n.startsWith("live"))?Ne:de;t.addAndStepInto(r({code:e.value,language:e.lang,meta:e.meta}))}},MdastThematicBreakVisitor:{testNode:"thematicBreak",visitNode({actions:e}){e.addAndStepInto(x.$createHorizontalRuleNode())}},MdastImageVisitor:{testNode:"image",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(ve({src:e.url,altText:e.alt||"",title:e.title||""}))}},MdastFrontmatterVisitor:{testNode:"yaml",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(pe({yaml:e.value}))}},MdastAdmonitionVisitor:{testNode:"containerDirective",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(oe(e.name))}},MdastMdxJsEsmVisitor:{testNode:"mdxjsEsm",visitNode(){}},MdastMdxJsxElementVisitor:{testNode:e=>"mdxJsxTextElement"===e.type||"mdxJsxFlowElement"===e.type,visitNode({lexicalParent:e,mdastNode:t,actions:n}){e.append(Ce({name:t.name,kind:"mdxJsxTextElement"===t.type?"text":"flow",attributes:t.attributes,updateFn:e=>{n.visitChildren(t,e)}}))}},MdastTableVisitor:{testNode:"table",visitNode({mdastNode:e,lexicalParent:t}){t.append(He(e))}}};function Xe(e){return e.children instanceof Array}const et={mdxFromMarkdown:E.mdxFromMarkdown(),frontmatterFromMarkdown:h.frontmatterFromMarkdown("yaml"),directiveFromMarkdown:p.directiveFromMarkdown,gfmTableFromMarkdown:g.gfmTableFromMarkdown},tt={mdxjs:T.mdxjs(),frontmatter:b.frontmatter(),directive:_.directive(),gfmTable:N.gfmTable};function nt({root:e,markdown:t,visitors:n,syntaxExtensions:r,mdastExtensions:a}){const o=C.fromMarkdown(t,{extensions:r,mdastExtensions:a});0===o.children.length&&o.children.push({type:"paragraph",children:[]}),rt({root:e,mdastRoot:o,visitors:n})}function rt({root:e,mdastRoot:t,visitors:n}){const r=new WeakMap;function a(e,t){if(!Xe(e))throw new Error("Attempting to visit children of a non-parent");e.children.forEach((n=>o(n,t,e)))}function o(e,t,o){const l=n.find((t=>"string"==typeof t.testNode?t.testNode===e.type:t.testNode(e)));if(!l)throw new Error(`no unist visitor found for ${e.type}`,{cause:e});l.visitNode({mdastNode:e,lexicalParent:t,actions:{visitChildren:a,addAndStepInto(n){t.append(n),Xe(e)&&a(e,n)},addFormatting(t){r.set(e,t|(r.get(o)??0))},getParentFormatting:()=>r.get(o)??0}})}o(t,e,null)}const at={ParagraphNode:u.ParagraphNode,LinkNode:w.LinkNode,HeadingNode:y.HeadingNode,QuoteNode:y.QuoteNode,ListNode:k.ListNode,ListItemNode:k.ListItemNode,HorizontalRuleNode:x.HorizontalRuleNode,ImageNode:Ee,SandpackNode:be,CodeBlockNode:ce,FrontmatterNode:me,AdmonitionNode:ae,JsxNode:ye,CodeNode:f.CodeNode,TableNode:Me};function ot(){const e=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0"))),t=crypto.getRandomValues(new Uint8Array(16));return t[6]=15&t[6]|64,t[8]=63&t[8]|128,[...t.entries()].map((([t,n])=>[4,6,8,10].includes(t)?`-${e[n]}`:e[n])).join("")}function lt(e,t){return e===t}class it{constructor(){t(this,"map",new Map)}getOrCreate(e){let t=this.map.get(e);return t||(t=new Set,this.map.set(e,t)),t}get(e){return this.map.get(e)}use(e,t){const n=this.get(e);void 0!==n&&t(n)}delete(e){return this.map.delete(e)}}class st{constructor(e=new Map){t(this,"map"),this.map=e}clone(){return new st(new Map(this.map))}increment(e){const t=this.map.get(e)??0;this.map.set(e,t+1)}decrement(e,t){let n=this.map.get(e);void 0!==n&&(n-=1,this.map.set(e,n),0===n&&t())}}const ct=Symbol("NO_VALUE");function dt(){const e=new it,t=new Map,n=new it,r=new Map,a=new Map,o={};function l(e=ct,t=!1){const n=ot();return e!==ct&&r.set(n,e),!1!==t&&a.set(n,!0===t?lt:t),{key:n,toString:()=>n}}function i({key:t},n){const r=e.getOrCreate(t);return r.add(n),()=>r.delete(n)}function s({key:e},n){return t.set(e,n),()=>t.delete(e)}function c(...e){const[t]=e.slice(-1),n=e.slice(0,-1);return 1===n.length?i(n[0],t):function(e,t){const n=l();return h({map:e=>(...t)=>{e(t)},sink:n,sources:e}),i(n,t)}(n,t)}function d(e){const t=[],r=new Set,a=new it,o=new st,l=new it;function i(e,s=0){o.increment(e),r.has(e)||(a.use(e,(e=>{s=Math.max(...Array.from(e).map((e=>t.indexOf(e))))+1})),n.use(e,(t=>{t.forEach((t=>{t.sources.has(e)?(l.getOrCreate(t.sink).add(t),i(t.sink,s)):a.getOrCreate(t.sink).add(e)}))})),r.add(e),t.splice(s,0,e))}return e.forEach((e=>i(e))),{participatingNodeKeys:t,pendingPulls:a,projections:l,refCount:o}}const u=new Map;function m(o){var l;const i=Object.keys(o),s=i.join(",");u.has(s)||u.set(s,d(i));const c=u.get(s),m=c.refCount.clone(),p=c.participatingNodeKeys.slice(),h=new Map(r);function g(e){n.use(e,(t=>{t.forEach((({sources:t,sink:n})=>{t.has(e)&&m.decrement(n,(()=>{p.splice(p.indexOf(n),1),g(n)}))}))}))}let E;for(;E=p.shift();){let n=!1;const i=e=>{a.has(E)&&a.get(E)(r.get(E),e)?n=!1:(n=!0,h.set(E,e),r.has(E)&&r.set(E,e))};if(Object.prototype.hasOwnProperty.call(o,E)?i(o[E]):c.projections.use(E,(e=>{e.forEach((e=>{const t=[...Array.from(e.sources),...Array.from(e.pulls)].map((e=>h.get(e)));e.map(i)(...t)}))})),n){const n=h.get(E);e.use(E,(e=>{e.forEach((e=>e(n)))})),null==(l=t.get(E))||l(n)}else g(E)}}function p(e){return new Set(e.map((e=>e.key)))}function h({sources:e,pulls:t=[],map:r,sink:{key:a}}){const o={map:r,pulls:p(t),sink:a,sources:p(e)};[...e,...t].forEach((({key:e})=>{n.getOrCreate(e).add(o)})),u.clear()}function g(...e){const t={};for(let n=0;n<e.length;n+=2){t[e[n].key]=e[n+1]}m(t)}function E(e){m(Object.entries(e).reduce(((e,[t,n])=>ie(e,(e=>e[o[t].key]=n))),{}))}return{combine:function(...e){const t=l();return h({map:e=>(...t)=>e(t),sink:t,sources:e}),t},connect:h,debug:function(){Object.entries(o).forEach((([e,t])=>{r.get(t.key)}))},derive:function(e,t){return ie(l(t,!0),(t=>{h({map:e=>t=>e(t),sink:t,sources:[e]})}))},getKeyValue:function(e){return r.get(o[e].key)},getValue:function(e){return r.get(e.key)},getKeyValues:function(e){return e.map((e=>r.get(o[e].key)))},label:function(e){Object.assign(o,e)},labels:o,link:function(e,t){h({map:e=>t=>e(t),sink:t,sources:[e]})},node:l,o:{delayWithMicrotask:function(){return e=>{const t=l();return c(e,(e=>queueMicrotask((()=>g(t,e))))),t}},debounceTime:function(e){return t=>{const n=l();let r,a;return c(t,(t=>{r=t,a&&clearTimeout(a),a=setTimeout((()=>{g(n,r)}),e)})),n}},filter:function(e){return t=>{const n=l();return h({map:t=>n=>e(n)&&t(n),sink:n,sources:[t]}),n}},map:function(e){return t=>{const n=l();return h({map:t=>n=>{t(e(n))},sink:n,sources:[t]}),n}},mapTo:function(e){return t=>{const n=l();return h({map:t=>()=>t(e),sink:n,sources:[t]}),n}},onNext:function(e){return t=>{const n=l();let r=ct;return c(t,(e=>r=e)),h({map:e=>t=>{r!==ct&&(e([r,t]),r=ct)},sink:n,sources:[e]}),n}},scan:function(e,t){return n=>{const r=l();return h({map:n=>r=>n(t=e(t,r)),sink:r,sources:[n]}),r}},throttleTime:function(e){return t=>{const n=l();let r,a;return c(t,(t=>{r=t,a||(a=setTimeout((()=>{a=void 0,g(n,r)}),e))})),n}},withLatestFrom:function(...e){return t=>{const n=l();return h({map:e=>(...t)=>e(t),pulls:e,sink:n,sources:[t]}),n}},once:function(){return e=>{const t=l();let n=!1;return h({map:e=>t=>{n||(n=!0,e(t))},sink:t,sources:[e]}),t}},passOnlyAfterNodeHasEmittedBefore:function(e,t){return n=>{const a=l();let o=0;return c(e,(()=>o=Date.now())),h({map:e=>n=>{Date.now()<o+r.get(t.key)&&e(n)},sink:a,sources:[n]}),a}}},pipe:function(e,...t){for(const n of t)e=n(e);return e},pub:g,pubIn:m,pubKey:function(e,t){E({[e]:t})},pubKeys:E,resetSingletonSubs:function(){t.clear()},singletonSub:s,singletonSubKey:function(e,t){return s(o[e],t)},spread:function(e,t){return t.map(((t,n)=>ie(l(t,!0),(t=>{h({map:e=>t=>{e(t[n])},sink:t,sources:[e]})}))))},sub:c,subKey:function(e,t){return c(o[e],t)},subKeys:function(e,t){return c(...e.map((e=>o[e])).concat(t))}}}const ut="undefined"!=typeof document?Q.useLayoutEffect:Q.useEffect,mt=m.createContext(void 0);function pt(e,t=[],n=ot()){return[{constructor:e,dependencies:t,id:n},{id:n}]}const ht=new Map([["number",k.INSERT_ORDERED_LIST_COMMAND],["bullet",k.INSERT_UNORDERED_LIST_COMMAND],["",k.REMOVE_LIST_COMMAND]]);const[gt,Et]=pt((e=>{const t=e.node(null,!0),n=e.node(H.createEmptyHistoryState()),r=e.derive(t,null),a=e.node(0,!0),o=e.node(null),l=e.node(null),i=e.node(null),s=e.node(),c=e.node(),d=e.node(),m=e.node(),p=e.node(),h=e.node(),g=e.node(),E=e.node(),v=e.node([]),f=e.node(!1,!0),w=e.node({type:"lexical"}),C=e.node(null),_=e.node(null),b=e.node(null),N=e.node([]),T=e.node([]);function M(){const t=u.$getSelection();u.$isRangeSelection(t)&&e.pubKeys({currentSelection:t,currentFormat:t.format})}return e.link(e.pipe(E,e.o.withLatestFrom(v),e.o.map((([e,t])=>[...t,e]))),v),e.sub(e.pipe(c,e.o.withLatestFrom(r)),(([e,t])=>{null==t||t.dispatchCommand(ht.get(e),void 0)})),e.sub(e.pipe(s,e.o.withLatestFrom(r)),(([e,t])=>{null==t||t.dispatchCommand(u.FORMAT_TEXT_COMMAND,e)})),e.sub(e.pipe(m,e.o.withLatestFrom(r)),(([,e])=>{null==e||e.dispatchCommand(x.INSERT_HORIZONTAL_RULE_COMMAND,void 0)})),e.sub(e.pipe(g,e.o.withLatestFrom(r)),(([e,t])=>{null==t||t.getEditorState().read((()=>{const n=u.$getSelection();if(u.$isRangeSelection(n)){null!==n.focus.getNode()&&t.update((()=>{const t=ve({altText:"",src:e,title:""});S.$insertNodeToNearestRoot(t)}))}}))})),e.sub(e.pipe(h,e.o.withLatestFrom(r)),(([,e])=>{null==e||e.update((()=>{const e=u.$getRoot().getFirstChild();if(!he(e)){const t=pe({yaml:'"": ""'});e?e.insertBefore(t):u.$getRoot().append(t)}}))})),e.sub(e.pipe(p,e.o.withLatestFrom(r)),(([,e])=>{null==e||e.getEditorState().read((()=>{const t=u.$getSelection();if(u.$isRangeSelection(t)){null!==t.focus.getNode()&&e.update((()=>{const e=He({type:"table",children:[{type:"tableRow",children:[{type:"tableCell",children:[]}]}]});S.$insertNodeToNearestRoot(e),setTimeout((()=>{e.select([0,0])}),50)}))}}))})),e.sub(e.pipe(d,e.o.withLatestFrom(r)),(([e,t])=>{if(t)switch(e){case"paragraph":(e=>{e.update((()=>{const e=u.$getSelection();(u.$isRangeSelection(e)||u.DEPRECATED_$isGridSelection(e))&&L.$setBlocksType(e,(()=>u.$createParagraphNode()))}))})(t);break;case"quote":(e=>{e.update((()=>{const e=u.$getSelection();(u.$isRangeSelection(e)||u.DEPRECATED_$isGridSelection(e))&&L.$setBlocksType(e,(()=>y.$createQuoteNode()))}))})(t);break;case"note":case"tip":case"danger":case"caution":case"info":((e,t)=>{e.update((()=>{const e=u.$getSelection();(u.$isRangeSelection(e)||u.DEPRECATED_$isGridSelection(e))&&L.$setBlocksType(e,(()=>oe(t)))}))})(t,e);break;default:((e,t)=>{e.update((()=>{const e=u.$getSelection();(u.$isRangeSelection(e)||u.DEPRECATED_$isGridSelection(e))&&L.$setBlocksType(e,(()=>y.$createHeadingNode(t)))}))})(t,e)}})),e.sub(e.pipe(o,e.o.withLatestFrom(r)),(([t,n])=>{if(!t||!n)return;const r=t.anchor.getNode();let a="root"===r.getKey()?r:S.$findMatchingParent(r,(e=>{const t=e.getParent();return null!==t&&u.$isRootOrShadowRoot(t)}));null===a&&(a=r.getTopLevelElementOrThrow());const o=a.getKey();if(null!==n.getElementByKey(o))if(k.$isListNode(a)){const t=S.$getNearestNodeOfType(r,k.ListNode),n=t?t.getListType():a.getListType();e.pubIn({[l.key]:n,[i.key]:""})}else{e.pub(l,null);const t=y.$isHeadingNode(a)?a.getTag():le(a)?a.getKind():a.getType();e.pubIn({[l.key]:null,[i.key]:t})}})),e.sub(t,(t=>{t&&t.registerCommand(u.SELECTION_CHANGE_COMMAND,((t,n)=>(e.pubIn({[r.key]:n,[f.key]:!0}),M(),!1)),u.COMMAND_PRIORITY_CRITICAL)})),e.pipe(e.combine(v,r),e.o.scan(((n,[r,a])=>(n.forEach((e=>e())),a?r.map((n=>n(a,e.getValue(t)))):[])),[])),e.pub(E,(e=>e.registerUpdateListener((({editorState:e})=>{e.read((()=>{M()}))})))),e.pub(E,(n=>n.registerCommand(u.BLUR_COMMAND,(n=>{var r;return!(null==(r=e.getValue(t).getRootElement())?void 0:r.contains(n.relatedTarget))&&e.pub(f,!1),!1}),u.COMMAND_PRIORITY_LOW))),{editor:t,activeEditor:r,currentFormat:a,currentSelection:o,currentListType:l,currentBlockType:i,applyFormat:s,applyListType:c,applyBlockType:d,insertHorizontalRule:m,insertFrontmatter:h,insertImage:g,insertTable:p,createEditorSubscription:E,editorSubscriptions:v,activeEditorType:w,inFocus:f,historyState:n,editorRootElementRef:C,markdownParseOptions:_,lexicalConvertOptions:b,lexicalNodes:N,imageAutocompleteSuggestions:T}}),[]);function vt(e){const t=u.$getSelection(),n=window.getSelection(),r=document.activeElement,a=e.getRootElement();if(null!==t&&null!==n&&null!==a&&a.contains(n.anchorNode)&&e.isEditable()){const e=n.getRangeAt(0);let t;if(n.anchorNode===a){let e=a;for(;null!=e.firstElementChild;)e=e.firstElementChild;t=e.getBoundingClientRect()}else t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX,width:t.width,height:t.height}}return r&&r.className,null}function ft(e,t){return ie({markdown:""},(n=>{e.getEditorState().read((()=>{n.markdown=function({root:e,toMarkdownOptions:t,toMarkdownExtensions:n,visitors:r,jsxComponentDescriptors:a}){return v.toMarkdown(je({root:e,visitors:r,jsxComponentDescriptors:a}),{extensions:n,...t})}({root:u.$getRoot(),...t})}))})).markdown}const[wt,kt]=pt((e=>({jsxComponentDescriptors:e.node([])})),[]),[xt]=pt(((e,[{editor:t,markdownParseOptions:n,lexicalConvertOptions:r},{jsxComponentDescriptors:a}])=>{const o=e.node("editor"),l=e.node(""),i=e.node("");return e.sub(e.pipe(o,e.o.scan(((e,t)=>({current:e.next,next:t})),{current:"editor",next:"editor"}),e.o.withLatestFrom(t,l,a,n,r)),(([{current:t},n,r,a,o,i])=>{"editor"===t?n&&e.pub(l,ft(n,{jsxComponentDescriptors:a,...i})):"markdown"===t&&(null==n||n.update((()=>{u.$getRoot().clear(),nt({root:u.$getRoot(),markdown:r,...o})})))})),{viewMode:o,headMarkdown:i,markdownSource:l}}),[Et,kt]),yt={defaultPreset:"react",presets:[{name:"react",meta:"live react",label:"React",sandpackTemplate:"react",sandpackTheme:"light",snippetFileName:"/App.js",snippetLanguage:"jsx",initialSnippetContent:'\nexport default function App() {\n return (\n <div className="App">\n <h1>Hello CodeSandbox</h1>\n <h2>Start editing to see some magic happen!</h2>\n </div>\n );\n}\n'}]},[Ct]=pt(((e,[{activeEditor:t,activeEditorType:n,createEditorSubscription:r}])=>{const a=e.node(yt),o=e.node(),l=e.node();return e.pub(r,(t=>t.registerCommand(u.FOCUS_COMMAND,(()=>(e.pub(n,{type:"lexical"}),!1)),u.COMMAND_PRIORITY_LOW))),e.sub(e.pipe(o,e.o.withLatestFrom(t,a)),(([e,t,n])=>{null==t||t.getEditorState().read((()=>{const r=u.$getSelection();if(u.$isRangeSelection(r)){const a=r.focus.getNode(),o=e?n.presets.find((t=>t.meta===e)):n.presets.find((e=>e.name==n.defaultPreset));if(!o)throw new Error(`No sandpack preset found with ${e}`);null!==a&&t.update((()=>{const e=Ne({code:o.initialSnippetContent||"",language:o.snippetLanguage||"jsx",meta:o.meta});S.$insertNodeToNearestRoot(e),setTimeout((()=>e.select()),80)}))}}))})),e.sub(e.pipe(l,e.o.withLatestFrom(t)),(([,e])=>{null==e||e.getEditorState().read((()=>{const t=u.$getSelection();if(u.$isRangeSelection(t)){null!==t.focus.getNode()&&e.update((()=>{const e=de({code:"",language:"jsx",meta:""});S.$insertNodeToNearestRoot(e),setTimeout((()=>e.select()),80)}))}}))})),{insertSandpack:o,insertCodeBlock:l,sandpackConfig:a}}),[Et]);function _t(e){const t=function(e){const t=e.anchor,n=e.focus,r=e.anchor.getNode(),a=e.focus.getNode();return r===a?r:e.isBackward()?L.$isAtNodeEnd(n)?r:a:L.$isAtNodeEnd(t)?r:a}(e),n=t.getParent();return w.$isLinkNode(n)?n:w.$isLinkNode(t)?t:null}const[bt,Nt]=pt(((e,[{activeEditor:t,currentSelection:n,createEditorSubscription:r}])=>{const a=e.node(!1),o=e.node(),l=e.node({type:"inactive"},!0),i=e.node(),s=e.node(),c=e.node(),d=e.node(),m=e.node(),p=e.node(),h=e.node([]);return e.sub(e.pipe(p,e.o.withLatestFrom(n,t),e.o.filter((([,e])=>u.$isRangeSelection(e)))),(([,t,n])=>{null==n||n.getEditorState().read((()=>{const r=_t(t),a=vt(n);r?e.pub(l,{type:"edit",initialUrl:r.getURL(),url:r.getURL(),linkNodeKey:r.getKey(),rectangle:a}):e.pub(l,{type:"edit",initialUrl:"",url:"",linkNodeKey:"",rectangle:a})}))})),e.sub(e.pipe(m,e.o.withLatestFrom(t)),(([,e])=>{null==e||e.dispatchCommand(w.TOGGLE_LINK_COMMAND,null)})),e.pub(r,(t=>t.registerCommand(u.KEY_ESCAPE_COMMAND,(()=>"preview"===e.getValue(l).type&&(e.pub(l,{type:"inactive"}),!0)),u.COMMAND_PRIORITY_LOW))),e.pub(r,(t=>t.registerCommand(u.KEY_MODIFIER_COMMAND,(t=>!("k"!==t.key||!t.metaKey)&&(e.pub(p,!0),!0)),u.COMMAND_PRIORITY_HIGH))),e.link(e.pipe(d,e.o.withLatestFrom(l),e.o.map((([,e])=>{if("preview"===e.type)return{type:"edit",initialUrl:e.url,url:e.url,linkNodeKey:e.linkNodeKey,rectangle:e.rectangle};throw new Error("Cannot switch to edit mode when not in preview mode")}))),l),e.sub(e.pipe(c,e.o.withLatestFrom(l,t)),(([,t,n])=>{if("edit"!==t.type)throw new Error("Cannot apply link edit when not in edit mode");{const r=t.url.trim();""!==r.trim()?(null==n||n.dispatchCommand(w.TOGGLE_LINK_COMMAND,r),e.pub(l,{type:"preview",linkNodeKey:t.linkNodeKey,rectangle:t.rectangle,url:r})):(""!==t.initialUrl&&(null==n||n.dispatchCommand(w.TOGGLE_LINK_COMMAND,null)),e.pub(l,{type:"inactive"}))}})),e.link(e.pipe(i,e.o.withLatestFrom(l),e.o.map((([e,t])=>{if("edit"===t.type)return{...t,url:e};throw new Error("Cannot update link url when not in edit mode")}))),l),e.link(e.pipe(s,e.o.withLatestFrom(l,t),e.o.map((([,e,t])=>{if("edit"===e.type)return null==t||t.focus(),""===e.initialUrl?{type:"inactive"}:{type:"preview",url:e.initialUrl,linkNodeKey:e.linkNodeKey,rectangle:e.rectangle};throw new Error("Cannot cancel edit when not in edit mode")}))),l),e.link(e.pipe(e.combine(n,o),e.o.withLatestFrom(t,l),e.o.map((([[e],t])=>{if(u.$isRangeSelection(e)&&t){const n=_t(e);return n?{type:"preview",url:n.getURL(),linkNodeKey:n.getKey(),rectangle:vt(t)}:{type:"inactive"}}return{type:"inactive"}}))),l),{dialogState:a,onWindowChange:o,linkDialogState:l,updateLinkUrl:i,switchFromPreviewToLinkEdit:d,cancelLinkEdit:s,removeLink:m,openLinkEditDialog:p,applyLinkChanges:c,linkAutocompleteSuggestions:h}}),[Et]),[Tt,St]=pt(((e,[{createEditorSubscription:t,lexicalConvertOptions:n},{jsxComponentDescriptors:r}])=>{const a=e.node();return e.pub(t,((t,o)=>t.registerUpdateListener((({dirtyElements:t,dirtyLeaves:l,prevEditorState:i,tags:s})=>{if(0===t.size&&0===l.size||s.has("history-merge")||i.isEmpty())return;const c=e.getValue(r),d=e.getValue(n);e.pub(a,ft(o,{jsxComponentDescriptors:c,...d}))})))),{onChange:a}}),[Et,kt]),[Mt,Lt]=pt((e=>({toolbarComponents:e.node([])})),[]),{Component:Ht,usePublisher:At,useEmitterValues:Ot}=function(e,t,n){const r=Object.keys(t.required||{}),a=Object.keys(t.optional||{}),o=Object.keys(t.methods||{}),l=Object.keys(t.events||{}),i=mt;function s(e,n){const o={};for(const a of r){o[t.required[a]]=n[a]}for(const r of a){const e=n[r];if(void 0!==e){o[t.optional[r]]=e}}e.suppressFlushSync=!0,e.pubKeys(o),e.suppressFlushSync=!1}const c=m.forwardRef(((c,d)=>{const u=m.useMemo((()=>ie(e(),(e=>s(e,c)))),[]);var p;ut((()=>{s(u,c),u.resetSingletonSubs();for(const e of l)e in c&&u.singletonSubKey(t.events[e],c[e]);return()=>{u.resetSingletonSubs()}}),[c]),m.useImperativeHandle(d,(p=function(e){return o.reduce(((n,r)=>{const a=t.methods[r];return n[r]=t=>{e.pubKey(a,t)},n}),{})}(u),()=>p));const h=c.children;return m.createElement(i.Provider,{value:u},n?m.createElement(n,function(e,t){const n={},r={};let a=0;const o=e.length;for(;a<o;)r[e[a]]=1,a+=1;for(const l in t)Object.prototype.hasOwnProperty.call(r,l)||(n[l]=t[l]);return n}([...r,...a,...l],c),h):h)}));return c.displayName="Gurx Component",{Component:c,useEmitter:(e,t)=>{const n=m.useContext(i);ut((()=>n.subKey(e,t)),[t])},useEmitterValues:(...e)=>{const t=m.useContext(i),[n,r]=m.useState((()=>t.getKeyValues(e)));return ut((()=>null==t?void 0:t.subKeys(e,(n=>{const a=()=>{r(1===e.length?[n]:n)};t.suppressFlushSync,a()}))),[e]),n},usePubKeys:()=>m.useContext(i).pubKeys,usePublisher:e=>{const t=Q.useContext(i);return m.useCallback((n=>{t.pubKey(e,n)}),[e,t])}}}(function(...e){return()=>function(...e){const t=new Map,n=dt(),r=({id:a,constructor:o,dependencies:l})=>{if(t.has(a))return t.get(a);const i=o(n,l.map((t=>r(e.find((e=>e.id===t.id))))));return n.label(i),t.set(a,i),i};return e.forEach(r),n}(...e)}(gt,xt,Ct,bt,wt,Tt,Mt),{required:{markdownSource:"markdownSource",headMarkdown:"headMarkdown",jsxComponentDescriptors:"jsxComponentDescriptors",sandpackConfig:"sandpackConfig",toolbarComponents:"toolbarComponents",markdownParseOptions:"markdownParseOptions",lexicalConvertOptions:"lexicalConvertOptions",lexicalNodes:"lexicalNodes"},optional:{editorRootElementRef:"editorRootElementRef",viewMode:"viewMode",linkAutocompleteSuggestions:"linkAutocompleteSuggestions",imageAutocompleteSuggestions:"imageAutocompleteSuggestions"},events:{onChange:"onChange"}},(({children:e})=>m.createElement("div",null,m.createElement(Vt,null),e))),Vt=()=>{const e=At("editor"),[t]=M.useLexicalComposerContext();return m.useEffect((()=>e(t)),[t,e]),null},Rt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4 9.55 18Z"}))),Dt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M6.4 19 5 17.6l5.6-5.6L5 6.4 6.4 5l5.6 5.6L17.6 5 19 6.4 13.4 12l5.6 5.6-1.4 1.4-5.6-5.6L6.4 19Z"}))),It=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M7 18V2h13v16H7Zm2-2h9V4H9v12Zm-6 6V6h2v14h11v2H3Z"}))),Pt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 19h1.4l8.625-8.625-1.4-1.4L5 17.6V19ZM19.3 8.925l-4.25-4.2L17.875 1.9 22.1 6.125l-2.8 2.8ZM3 21v-4.25l10.6-10.6 4.25 4.25L7.25 21H3Z"}))),Bt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m19.25 16.45-1.5-1.55a3.05 3.05 0 0 0 1.625-1.063A2.867 2.867 0 0 0 20 12c0-.833-.292-1.542-.875-2.125A2.893 2.893 0 0 0 17 9h-4V7h4c1.383 0 2.563.487 3.538 1.462C21.513 9.437 22 10.617 22 12c0 .95-.246 1.825-.737 2.625a4.79 4.79 0 0 1-2.013 1.825ZM15.85 13l-2-2H16v2h-.15Zm3.95 9.6L1.4 4.2l1.4-1.4 18.4 18.4-1.4 1.4ZM11 17H7c-1.383 0-2.562-.488-3.537-1.463C2.488 14.562 2 13.383 2 12c0-1.15.35-2.175 1.05-3.075.7-.9 1.6-1.492 2.7-1.775L7.6 9H7c-.833 0-1.542.292-2.125.875A2.893 2.893 0 0 0 4 12c0 .833.292 1.542.875 2.125A2.893 2.893 0 0 0 7 15h4v2Zm-3-4v-2h1.625l1.975 2H8Z"}))),$t=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 21V3h9v2H5v14h14v-7h2v9H3Zm6.7-5.3-1.4-1.4L17.6 5H14V3h7v7h-2V6.4l-9.3 9.3Z"}))),Zt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m12 15-5-5h10l-5 5Z"}))),Ut={editorRoot:"_editorRoot_1nlu3_43",editorWrapper:"_editorWrapper_1nlu3_121",nestedListItem:"_nestedListItem_1nlu3_125",toolbarRoot:"_toolbarRoot_1nlu3_129",toolbarModeSwitch:"_toolbarModeSwitch_1nlu3_150",toolbarToggleItem:"_toolbarToggleItem_1nlu3_159",toolbarGroupOfGroups:"_toolbarGroupOfGroups_1nlu3_169",toolbarToggleSingleGroup:"_toolbarToggleSingleGroup_1nlu3_173",toolbarButton:"_toolbarButton_1nlu3_187",toolbarNodeKindSelectContainer:"_toolbarNodeKindSelectContainer_1nlu3_216",toolbarButtonDropdownContainer:"_toolbarButtonDropdownContainer_1nlu3_217",toolbarNodeKindSelectTrigger:"_toolbarNodeKindSelectTrigger_1nlu3_230",toolbarButtonSelectTrigger:"_toolbarButtonSelectTrigger_1nlu3_231",toolbarNodeKindSelectItem:"_toolbarNodeKindSelectItem_1nlu3_264",toolbarNodeKindSelectDropdownArrow:"_toolbarNodeKindSelectDropdownArrow_1nlu3_287",contentEditable:"_contentEditable_1nlu3_291",sandpackWrapper:"_sandpackWrapper_1nlu3_299",frontmatterWrapper:"_frontmatterWrapper_1nlu3_303",frontmatterToggleButton:"_frontmatterToggleButton_1nlu3_313",frontmatterEditorTable:"_frontmatterEditorTable_1nlu3_321",iconButton:"_iconButton_1nlu3_339",frontmatterInput:"_frontmatterInput_1nlu3_345",primaryButton:"_primaryButton_1nlu3_360",linkDialogEditForm:"_linkDialogEditForm_1nlu3_370",linkDialogInputContainer:"_linkDialogInputContainer_1nlu3_376",linkDialogInputWrapper:"_linkDialogInputWrapper_1nlu3_382",linkDialogInput:"_linkDialogInput_1nlu3_376",linkDialogAutocompleteContainer:"_linkDialogAutocompleteContainer_1nlu3_412",linkDialogAnchor:"_linkDialogAnchor_1nlu3_457",linkDialogPopoverContent:"_linkDialogPopoverContent_1nlu3_471",tableColumnEditorPopoverContent:"_tableColumnEditorPopoverContent_1nlu3_471",dialogContent:"_dialogContent_1nlu3_471",linkDialogPreviewAnchor:"_linkDialogPreviewAnchor_1nlu3_485",tooltipContent:"_tooltipContent_1nlu3_507",actionButton:"_actionButton_1nlu3_519",primaryActionButton:"_primaryActionButton_1nlu3_525",tableEditor:"_tableEditor_1nlu3_534",toolCell:"_toolCell_1nlu3_545",tableColumnEditorTrigger:"_tableColumnEditorTrigger_1nlu3_562",tableRowEditorTrigger:"_tableRowEditorTrigger_1nlu3_562",addRowButton:"_addRowButton_1nlu3_562",addColumnButton:"_addColumnButton_1nlu3_562",tableColumnEditorToolbar:"_tableColumnEditorToolbar_1nlu3_596",toggleGroupRoot:"_toggleGroupRoot_1nlu3_608",tableToolsColumn:"_tableToolsColumn_1nlu3_625",leftAlignedCell:"_leftAlignedCell_1nlu3_633",rightAlignedCell:"_rightAlignedCell_1nlu3_637",centeredCell:"_centeredCell_1nlu3_641",dialogOverlay:"_dialogOverlay_1nlu3_669",overlayShow:"_overlayShow_1nlu3_1",contentShow:"_contentShow_1nlu3_1"};u.createCommand();const Ft=20;function Kt({initialUrl:e,onSubmit:t,onCancel:n,linkAutocompleteSuggestions:r}){const[a,o]=m.useState(r.slice(0,Ft)),{isOpen:l,getToggleButtonProps:i,getMenuProps:s,getInputProps:c,highlightedIndex:u,getItemProps:p,selectedItem:h}=V.useCombobox({initialInputValue:e,onInputValueChange({inputValue:e}){e=(null==e?void 0:e.toLowerCase())||"";const t=[];for(const n of r)if(n.toLowerCase().includes(e)&&(t.push(n),t.length>=Ft))break;o(t)},items:a,itemToString:e=>e??""}),g=m.useCallback((e=>{var n;"Escape"===e.key?null==(n=e.target.form)||n.reset():"Enter"!==e.key||l&&0!==a.length||(e.preventDefault(),t(e.target.value))}),[l,a,t]),E=c(),v={...E,onKeyDown:e=>{g(e),E.onKeyDown(e)}},f=l&&a.length>0;return m.createElement("form",{onSubmit:e=>{e.preventDefault(),t(h||"")},onReset:n,className:d(Ut.linkDialogEditForm)},m.createElement("div",{className:Ut.linkDialogInputContainer},m.createElement("div",{"data-visible-dropdown":f,className:Ut.linkDialogInputWrapper},m.createElement("input",{className:Ut.linkDialogInput,...v,autoFocus:!0,size:30,"data-editor-dialog":!0}),m.createElement("button",{"aria-label":"toggle menu",type:"button",...i()},m.createElement(Zt,null))),m.createElement("div",{className:Ut.linkDialogAutocompleteContainer},m.createElement("ul",{...s(),"data-visible":f},a.map(((e,t)=>m.createElement("li",{"data-selected":h===e,"data-highlighted":u===t,key:`${e}${t}`,...p({item:e,index:t})},e)))))),m.createElement(jt,{type:"submit",title:"Set URL","aria-label":"Set URL"},m.createElement(Rt,null)),m.createElement(jt,{type:"reset",title:"Cancel change","aria-label":"Cancel change"},m.createElement(Dt,null)))}function zt(){const[e]=Ot("editorRootElementRef"),t=At("onWindowChange"),[n,r,a]=Ot("linkDialogState","linkAutocompleteSuggestions","activeEditor"),o=At("updateLinkUrl"),l=At("cancelLinkEdit"),i=At("switchFromPreviewToLinkEdit"),s=At("removeLink"),c=At("applyLinkChanges");m.useEffect((()=>{const e=()=>{null==a||a.getEditorState().read((()=>{t(!0)}))};return window.addEventListener("resize",e),window.addEventListener("scroll",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e)}}),[a,t]);const[u,p]=m.useState(!1),h=null==n?void 0:n.rectangle,g=m.useCallback((e=>{o(e),c(!0)}),[c,o]),E="preview"===n.type&&n.url.startsWith("http");return m.createElement(X.Root,{open:"inactive"!==n.type},m.createElement(X.Anchor,{"data-visible":"edit"===n.type,className:Ut.linkDialogAnchor,style:{top:null==h?void 0:h.top,left:null==h?void 0:h.left,width:null==h?void 0:h.width,height:null==h?void 0:h.height}}),m.createElement(X.Portal,{container:null==e?void 0:e.current},m.createElement(X.Content,{className:d(Ut.linkDialogPopoverContent),sideOffset:5,onOpenAutoFocus:e=>e.preventDefault(),key:n.linkNodeKey},"edit"===n.type&&m.createElement(Kt,{initialUrl:n.url,onSubmit:g,onCancel:l.bind(null,!0),linkAutocompleteSuggestions:r}),"preview"===n.type&&m.createElement(m.Fragment,null,m.createElement("a",{className:Ut.linkDialogPreviewAnchor,href:n.url,...E?{target:"_blank",rel:"noreferrer"}:{},title:E?`Open ${n.url} in new window`:n.url},m.createElement("span",null,n.url),E&&m.createElement($t,null)),m.createElement(jt,{onClick:()=>i(!0),title:"Edit link URL","aria-label":"Edit link URL"},m.createElement(Pt,null)),m.createElement(ee.Provider,null,m.createElement(ee.Root,{open:u},m.createElement(ee.Trigger,{asChild:!0},m.createElement(jt,{title:"Copy to clipboard","aria-label":"Copy link URL",onClick:()=>{window.navigator.clipboard.writeText(n.url).then((()=>{p(!0),setTimeout((()=>p(!1)),1e3)}))}},u?m.createElement(Rt,null):m.createElement(It,null))),m.createElement(ee.Portal,{container:null==e?void 0:e.current},m.createElement(ee.Content,{className:d(Ut.tooltipContent),sideOffset:5},"Copied!",m.createElement(ee.Arrow,null))))),m.createElement(jt,{title:"Remove link","aria-label":"Remove link",onClick:()=>s(!0)},m.createElement(Bt,null))))))}const jt=m.forwardRef((({className:e,...t},n)=>m.createElement("button",{className:d(Ut.actionButton,e),ref:n,...t})));function qt(e){const t=u.$getSelection();if(!u.$isRangeSelection(t))return!1;const n=function(e){const t=e.getNodes();return 0===t.length?new Set([e.anchor.getNode().getParentOrThrow(),e.focus.getNode().getParentOrThrow()]):new Set(t.map((e=>u.$isElementNode(e)?e:e.getParentOrThrow())))}(t);let r=0;for(const a of n)if(k.$isListNode(a))r=Math.max(k.$getListDepth(a)+1,r);else if(k.$isListItemNode(a)){const e=a.getParent();if(1===(null==e?void 0:e.getChildren().length)){const t=null==e?void 0:e.getParent();if(k.$isListItemNode(t)&&1===t.getChildren().length)return!1}if(!k.$isListNode(e))throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");r=Math.max(k.$getListDepth(e)+1,r)}return r<=e}function Wt({maxDepth:e}){const[t]=M.useLexicalComposerContext();return m.useEffect((()=>t.registerCommand(u.INDENT_CONTENT_COMMAND,(()=>!qt(e??7)),u.COMMAND_PRIORITY_CRITICAL)),[t,e]),null}const Jt=()=>{return m.createElement(D.MarkdownShortcutPlugin,{transformers:(e=R.TRANSFORMERS,e.find((e=>e===R.CODE)).replace=(e,t,n)=>{const r=de({code:"",language:n?n[1]:"",meta:""});e.replace(r),setTimeout((()=>r.select()),80)},e)});var e};function Gt(e,t,n){const[r]=Ot("activeEditor"),a=At("activeEditorType"),o=m.useRef(null),l=m.useRef(!1),i=m.useRef(!1),s=m.useCallback((()=>{a({type:t,nodeKey:e})}),[e,a,t]),c=m.useCallback((t=>{var n,a,s,c;if("ArrowDown"===t.key){const t=null==(a=null==(n=null==o?void 0:o.current)?void 0:n.getCodemirror())?void 0:a.state;if(t){t.doc.length===t.selection.ranges[0].to&&(l.current?(null==r||r.update((()=>{var t,n;const r=u.$getNodeByKey(e);r.getNextSibling()?(null==(n=null==(t=null==o?void 0:o.current)?void 0:t.getCodemirror())||n.contentDOM.blur(),r.selectNext()):r.insertAfter(u.$createParagraphNode())})),l.current=!1):l.current=!0)}}else if("ArrowUp"===t.key){const t=null==(c=null==(s=null==o?void 0:o.current)?void 0:s.getCodemirror())?void 0:c.state;if(t){0===t.selection.ranges[0].from&&(i.current?(null==r||r.update((()=>{var t,n;const r=u.$getNodeByKey(e);r.getPreviousSibling()&&(null==(n=null==(t=null==o?void 0:o.current)?void 0:t.getCodemirror())||n.contentDOM.blur(),r.selectPrevious())})),i.current=!1):i.current=!0)}}else"Enter"===t.key&&t.stopPropagation()}),[r,e]);return m.useEffect((()=>{const e=o.current;return setTimeout((()=>{var t,n,r,a;null==(n=null==(t=null==e?void 0:e.getCodemirror())?void 0:t.contentDOM)||n.addEventListener("focus",s),null==(a=null==(r=null==e?void 0:e.getCodemirror())?void 0:r.contentDOM)||a.addEventListener("keydown",c)}),100),()=>{var t,n;null==(t=null==e?void 0:e.getCodemirror())||t.contentDOM.removeEventListener("focus",s),null==(n=null==e?void 0:e.getCodemirror())||n.contentDOM.removeEventListener("keydown",c)}}),[o,s,c,n]),o}const Yt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M10 17V7l5 5-5 5Z"}))),Qt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m12 15-5-5h10l-5 5Z"}))),Xt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 17V6.5H4V5h4V4h4v1h4v1.5h-1V17H5Zm1.5-1.5h7v-9h-7v9ZM8 14h1.5V8H8v6Zm2.5 0H12V8h-1.5v6Z"}))),en=m.forwardRef((({className:e,autofocusIfEmpty:t,...n},r)=>(n.autoFocus=Boolean(!n.value&&t),m.createElement("input",{className:d(Ut.frontmatterInput,e),...n,ref:r})))),tn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m9.25 22-.4-3.2a3.79 3.79 0 0 1-.613-.3 8.266 8.266 0 0 1-.562-.375L4.7 19.375l-2.75-4.75 2.575-1.95a2.387 2.387 0 0 1-.025-.338v-.675c0-.108.008-.22.025-.337L1.95 9.375l2.75-4.75 2.975 1.25c.183-.133.375-.258.575-.375.2-.117.4-.217.6-.3l.4-3.2h5.5l.4 3.2c.217.083.42.183.612.3.192.117.38.242.563.375l2.975-1.25 2.75 4.75-2.575 1.95c.017.117.025.23.025.338v.675c0 .108-.017.22-.05.337l2.575 1.95-2.75 4.75-2.95-1.25a6.842 6.842 0 0 1-.575.375c-.2.117-.4.217-.6.3l-.4 3.2h-5.5Zm2.8-6.5c.967 0 1.792-.342 2.475-1.025A3.372 3.372 0 0 0 15.55 12c0-.967-.342-1.792-1.025-2.475A3.373 3.373 0 0 0 12.05 8.5c-.983 0-1.813.342-2.488 1.025A3.393 3.393 0 0 0 8.55 12c0 .967.337 1.792 1.012 2.475.676.683 1.505 1.025 2.488 1.025Zm0-2c-.417 0-.77-.146-1.063-.438A1.446 1.446 0 0 1 10.55 12c0-.417.146-.77.438-1.063a1.446 1.446 0 0 1 1.062-.437c.417 0 .77.146 1.063.438.291.291.437.645.437 1.062 0 .417-.146.77-.438 1.063a1.447 1.447 0 0 1-1.062.437ZM11 20h1.975l.35-2.65a5.61 5.61 0 0 0 1.438-.588c.441-.258.845-.57 1.212-.937l2.475 1.025.975-1.7-2.15-1.625c.083-.233.142-.48.175-.738a6.153 6.153 0 0 0 0-1.575 3.535 3.535 0 0 0-.175-.737l2.15-1.625-.975-1.7-2.475 1.05a5.556 5.556 0 0 0-1.213-.962 5.607 5.607 0 0 0-1.437-.588L13 4h-1.975l-.35 2.65c-.517.133-.996.33-1.438.587a6.015 6.015 0 0 0-1.212.938L5.55 7.15l-.975 1.7 2.15 1.6c-.083.25-.142.5-.175.75a6.122 6.122 0 0 0 0 1.575c.033.25.092.5.175.75l-2.15 1.625.975 1.7 2.475-1.05c.367.383.77.704 1.212.962.442.259.921.455 1.438.588L11 20Z"}))),nn=m.forwardRef(((e,t)=>m.createElement(X.Content,{...e,className:"",ref:t}))),rn=m.forwardRef(((e,t)=>m.createElement(X.Trigger,{...e,className:"",ref:t})));const an=({attributes:e,componentName:t,onSubmit:n})=>{const[r,a]=m.useState(!1),o=m.useCallback((e=>{n(e),a(!1)}),[n]);return m.createElement(X.Root,{open:r,onOpenChange:e=>a(e)},m.createElement(rn,null,m.createElement(tn,null)),m.createElement(X.Portal,null,m.createElement(nn,null,m.createElement(on,{attributes:e,componentName:t,onSubmit:o}))))},on=({attributes:e,componentName:t,onSubmit:n})=>{const[r]=Ot("jsxComponentDescriptors"),a=r.find((e=>e.name===t)),[o]=M.useLexicalComposerContext(),{register:l,handleSubmit:i}=B.useForm({defaultValues:e.reduce(((e,t)=>(e[t.name]=t.value,e)),{})});return m.createElement("form",{onSubmit:i((e=>{o.update((()=>{n(e)}))}))},m.createElement("table",null,m.createElement("thead",null,m.createElement("tr",null,m.createElement("th",null,"Attribute"),m.createElement("th",null,"Value"))),m.createElement("tbody",null,a.props.map((e=>m.createElement("tr",{key:e.name},m.createElement("td",null," ",e.name," "),m.createElement("td",null,m.createElement("input",{...l(e.name)}))))))),m.createElement("button",{type:"submit"},"Submit"))},ln=({onChange:e,snippetFileName:t})=>{const{sandpack:n}=I.useSandpack();return e(n.files[t].code),null};const sn=e=>{const t={type:"root",children:e.mdastChildren},n=U.raw(Z.toHast(t,{allowDangerousHtml:!0})),r=F.sanitize(n),a=K.toHtml(r);return m.createElement("span",{dangerouslySetInnerHTML:{__html:a||"&nbsp;"}})},cn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M6 14c-.55 0-1.02-.196-1.412-.588A1.926 1.926 0 0 1 4 12c0-.55.196-1.02.588-1.412A1.926 1.926 0 0 1 6 10c.55 0 1.02.196 1.412.588.392.391.588.862.588 1.412 0 .55-.196 1.02-.588 1.412A1.926 1.926 0 0 1 6 14Zm6 0c-.55 0-1.02-.196-1.412-.588A1.926 1.926 0 0 1 10 12c0-.55.196-1.02.588-1.412A1.926 1.926 0 0 1 12 10c.55 0 1.02.196 1.412.588.392.391.588.862.588 1.412 0 .55-.196 1.02-.588 1.412A1.926 1.926 0 0 1 12 14Zm6 0c-.55 0-1.02-.196-1.413-.588A1.926 1.926 0 0 1 16 12c0-.55.196-1.02.587-1.412A1.926 1.926 0 0 1 18 10c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412 0 .55-.196 1.02-.587 1.412A1.926 1.926 0 0 1 18 14Z"}))),dn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 17v-1.5h14V17H3Zm0-3.125v-1.5h10v1.5H3Zm0-3.125v-1.5h14v1.5H3Zm0-3.125v-1.5h10v1.5H3ZM3 4.5V3h14v1.5H3Z"}))),un=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 17v-1.5h14V17H3Zm3-3.125v-1.5h8v1.5H6ZM3 10.75v-1.5h14v1.5H3Zm3-3.125v-1.5h8v1.5H6ZM3 4.5V3h14v1.5H3Z"}))),mn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 17v-1.5h14V17H3Zm4-3.125v-1.5h10v1.5H7ZM3 10.75v-1.5h14v1.5H3Zm4-3.125v-1.5h10v1.5H7ZM3 4.5V3h14v1.5H3Z"}))),pn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 20h20v20H0z",transform:"rotate(-90 0 20)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M15.75 4.5H13v2.75h-1.5V4.5H8.75V3h2.75V.25H13V3h2.75v1.5ZM13 17H5V3h2.25v1.5H6.5v11h5V8.75H13V17Z"}))),hn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z",transform:"matrix(0 -1 -1 0 20 20)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M4.25 4.5H7v2.75h1.5V4.5h2.75V3H8.5V.25H7V3H4.25v1.5ZM7 17h8V3h-2.25v1.5h.75v11h-5V8.75H7V17Z"}))),gn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M6.5 17a1.45 1.45 0 0 1-1.06-.44A1.445 1.445 0 0 1 5 15.5v-10H4V4h4V3h4v1h4v1.5h-1v9.991c0 .423-.147.78-.44 1.072A1.45 1.45 0 0 1 13.5 17h-7Zm7-11.5h-7v10h7v-10ZM8 14h1.5V7H8v7Zm2.5 0H12V7h-1.5v7Z"}))),En=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z",transform:"matrix(-1 0 0 1 20 0)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M4.5 16.75V14h2.75v-1.5H4.5V9.75H3v2.75H.25V14H3v2.75h1.5ZM17 14V6H3v2.25h1.5V7.5h11v5H8.75V14H17Z"}))),vn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M20 20h20v20H20z",transform:"rotate(180 20 20)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M4.5 3.25V6h2.75v1.5H4.5v2.75H3V7.5H.25V6H3V3.25h1.5ZM17 6v8H3v-2.25h1.5v.75h11v-5H8.75V6H17Z"}))),fn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M20 20h20v20H20z",transform:"rotate(180 20 20)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M10.5 3.25V6h2.75v1.5H10.5v2.75H9V7.5H6.25V6H9V3.25h1.5ZM17 6v8H3V6h2.5v1.5h-1v5h11v-5H14V6h3Z"}))),wn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z",transform:"matrix(0 -1 -1 0 20 20)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3.25 10.5H6v2.75h1.5V10.5h2.75V9H7.5V6.25H6V9H3.25v1.5ZM6 17h8V3H6v2.5h1.5v-1h5v11h-5V14H6v3Z"}))),kn=()=>{const[e]=Ot("historyState");return m.createElement(H.HistoryPlugin,{externalHistoryState:e})},xn={center:Ut.centeredCell,left:Ut.leftAlignedCell,right:Ut.rightAlignedCell},yn=({align:e,...t})=>{const[n,r]=t.activeCellTuple,a=n&&n[0]===t.colIndex&&n[1]===t.rowIndex,o=xn[e||"left"];return m.createElement("td",{className:o,"data-active":a,onClick:()=>{r([t.colIndex,t.rowIndex])}},a?m.createElement(Cn,{...t}):m.createElement(sn,{mdastChildren:t.contents}))},Cn=({activeCellTuple:e,parentEditor:t,lexicalTable:n,contents:o,colIndex:l,rowIndex:i})=>{const[c,d,p,h]=Ot("markdownParseOptions","lexicalConvertOptions","jsxComponentDescriptors","lexicalNodes"),[g]=m.useState((()=>{let r=!1;const a=u.createEditor({nodes:h,theme:we});function s(o){r||(r=!0,a.getEditorState().read((()=>{const e=je({root:u.$getRoot(),jsxComponentDescriptors:p,...d});t.update((()=>{n.updateCellContents(l,i,e.children[0].children)}))})),e[1](o))}return a.registerCommand(u.KEY_TAB_COMMAND,(e=>{e.preventDefault();return s(e.shiftKey?[l-1,i]:[l+1,i]),!0}),u.COMMAND_PRIORITY_CRITICAL),a.registerCommand(u.KEY_ENTER_COMMAND,(e=>{null==e||e.preventDefault();return s((null==e?void 0:e.shiftKey)?[l,i-1]:[l,i+1]),!0}),u.COMMAND_PRIORITY_CRITICAL),a.registerCommand(u.BLUR_COMMAND,(e=>{const t=e.relatedTarget;return void 0===(null==t?void 0:t.dataset.editorDialog)&&(s(null),!0)}),u.COMMAND_PRIORITY_CRITICAL),a.registerRootListener((e=>{e&&a.focus()})),a.update((()=>{rt({root:u.$getRoot(),mdastRoot:{type:"root",children:[{type:"paragraph",children:o}]},visitors:c.visitors})})),a}));return m.createElement($.LexicalNestedComposer,{initialEditor:g},m.createElement(s.RichTextPlugin,{contentEditable:m.createElement(r.ContentEditable,{autoFocus:!0}),placeholder:m.createElement("div",null),ErrorBoundary:a}),m.createElement(kn,null))},_n=({parentEditor:e,highlightedCoordinates:t,align:n,lexicalTable:r,colIndex:a,setActiveCellWithBoundaries:o})=>{const[l]=Ot("editorRootElementRef"),i=m.useCallback((t=>{e.update((()=>{r.insertColumnAt(t)})),o([t,0])}),[e,r,o]),s=m.useCallback((t=>{e.update((()=>{r.deleteColumnAt(t)}))}),[e,r]),c=m.useCallback(((t,n)=>{e.update((()=>{r.setColumnAlign(t,n)}))}),[e,r]);return m.createElement(X.Root,null,m.createElement(X.PopoverTrigger,{className:Ut.tableColumnEditorTrigger,"data-active":t[0]===a+1,title:"Column menu"},m.createElement(cn,null)),m.createElement(X.Portal,{container:null==l?void 0:l.current},m.createElement(X.PopoverContent,{className:d(Ut.tableColumnEditorPopoverContent),onOpenAutoFocus:e=>e.preventDefault(),sideOffset:5,side:"top"},m.createElement(te.Root,{className:Ut.tableColumnEditorToolbar},m.createElement(te.ToggleGroup,{className:Ut.toggleGroupRoot,onValueChange:e=>{c(a,e)},value:n||"left",type:"single","aria-label":"Text alignment"},m.createElement(te.ToggleItem,{value:"left",title:"Align left"},m.createElement(dn,null)),m.createElement(te.ToggleItem,{value:"center",title:"Align center"},m.createElement(un,null)),m.createElement(te.ToggleItem,{value:"right",title:"Align right"},m.createElement(mn,null))),m.createElement(te.Separator,null),m.createElement(te.Button,{onClick:i.bind(null,a),title:"Insert a column to the left of this one"},m.createElement(pn,null)),m.createElement(te.Button,{onClick:i.bind(null,a+1),title:"Insert a column to the right of this one"},m.createElement(hn,null)),m.createElement(te.Button,{onClick:s.bind(null,a),title:"Delete this column"},m.createElement(gn,null))))))},bn=({parentEditor:e,highlightedCoordinates:t,lexicalTable:n,rowIndex:r,setActiveCellWithBoundaries:a})=>{const[o]=Ot("editorRootElementRef"),l=m.useCallback((t=>{e.update((()=>{n.insertRowAt(t)})),a([0,t])}),[e,n,a]),i=m.useCallback((t=>{e.update((()=>{n.deleteRowAt(t)}))}),[e,n]);return m.createElement(X.Root,null,m.createElement(X.PopoverTrigger,{className:Ut.tableColumnEditorTrigger,"data-active":t[1]===r},m.createElement(cn,null)),m.createElement(X.Portal,{container:null==o?void 0:o.current},m.createElement(X.PopoverContent,{className:d(Ut.tableColumnEditorPopoverContent),onOpenAutoFocus:e=>e.preventDefault(),sideOffset:5,side:"bottom"},m.createElement(te.Root,{className:Ut.tableColumnEditorToolbar},m.createElement(te.Button,{onClick:l.bind(null,r),title:"Insert a row above this one"},m.createElement(En,null)),m.createElement(te.Button,{onClick:l.bind(null,r+1),title:"Insert a row below this one"},m.createElement(vn,null)),m.createElement(te.Button,{onClick:i.bind(null,r),title:"Delete this row"},m.createElement(gn,null))))))};function Nn({oldText:e,newText:t}){const n=W.formatLines(W.diffLines(e,t),{context:3});if(""===n.trim())return m.createElement("div",null,"No changes");const[r]=q.parseDiff(n,{nearbySequences:"zip"});return m.createElement(q.Diff,{viewType:"split",diffType:"modify",hunks:r.hunks||[]},(e=>e.map((e=>m.createElement(q.Hunk,{key:e.content,hunk:e})))))}function Tn(){const[e,t]=Ot("markdownSource","headMarkdown");return m.createElement(Nn,{oldText:t,newText:e})}const Sn=({children:e})=>{const[t]=Ot("viewMode");return m.createElement("div",null,m.createElement("div",{style:{display:"editor"===t?"block":"none"}},e),"diff"===t?m.createElement(Tn,null):null,"markdown"===t?m.createElement(Mn,null):null)},Mn=()=>{const[e]=Ot("markdownSource"),t=At("markdownSource"),n=m.useRef(null);return m.createElement("div",null,m.createElement(I.SandpackProvider,null,m.createElement(I.CodeEditor,{showLineNumbers:!0,additionalLanguages:[{name:"markdown",extensions:["md"],language:j.markdown()}],initMode:"lazy",filePath:"file.md",code:e,onCodeUpdate:t,ref:n})))},Ln=m.forwardRef((({children:e,className:t,...n},r)=>m.createElement(ne.Item,{...n,ref:r,className:d(t,Ut.toolbarNodeKindSelectItem)},m.createElement(ne.ItemText,null,e)))),Hn=({placeholder:e})=>m.createElement(ne.Trigger,{"aria-label":e,className:Ut.toolbarNodeKindSelectTrigger},m.createElement(ne.Value,{placeholder:e}),m.createElement(ne.Icon,{className:Ut.toolbarNodeKindSelectDropdownArrow},m.createElement(Zt,null))),An=({children:e,className:t=Ut.toolbarNodeKindSelectContainer})=>{const[n]=Ot("editorRootElementRef");return m.createElement(ne.Portal,{container:null==n?void 0:n.current},m.createElement(ne.Content,{className:t,onCloseAutoFocus:e=>e.preventDefault(),position:"popper"},m.createElement(ne.Viewport,null,e)))},On=({children:e,title:t,className:n})=>m.createElement(ne.Trigger,{className:d(Ut.toolbarButtonSelectTrigger,n),title:t},e,m.createElement(ne.Icon,{className:Ut.toolbarNodeKindSelectDropdownArrow},m.createElement(Zt,null)));function Vn(){const[e,t]=Ot("activeEditorType","activeEditor"),n=m.useMemo((()=>{let n;return t.getEditorState().read((()=>{const t=u.$getNodeByKey(e.nodeKey);n=t.getLanguage()})),n}),[t,e]);return m.createElement(ne.Root,{value:n,onValueChange:n=>{t.update((()=>{const t=u.$getNodeByKey(e.nodeKey);t.setLanguage(n),setTimeout((()=>{t.select()}),80)}))}},m.createElement(Hn,{placeholder:"Language"}),m.createElement(An,null,m.createElement(Ln,{value:"js"},"JavaScript"),m.createElement(Ln,{value:"ts"},"TypeScript"),m.createElement(Ln,{value:"css"},"CSS")))}const Rn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 21V6H4V4h5V3h6v1h5v2h-1v15H5Zm2-2h10V6H7v13Zm2-2h2V8H9v9Zm4 0h2V8h-2v9Z"}))),Dn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m8 18-6-6 6-6 1.425 1.425-4.6 4.6L9.4 16.6 8 18Zm8 0-1.425-1.425 4.6-4.6L14.6 7.4 16 6l6 6-6 6Z"}))),In=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m5 15.95 6 3.475v-6.85L5 9.1v6.85Zm8 3.475 6-3.475V9.1l-6 3.475v6.85Zm-6.925-12L12 10.85l5.925-3.425L12 4 6.075 7.425ZM3 17.125V6.875L12 1.7l9 5.175v10.25L12 22.3l-9-5.175Z"}))),Pn=e=>Q.createElement("svg",{width:25,height:24,viewBox:"0 0 25 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Q.createElement("mask",{id:"mask0_318_257",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:0,y:0,width:25,height:24},Q.createElement("rect",{x:.929688,width:24,height:24,fill:"#D9D9D9"})),Q.createElement("g",{mask:"url(#mask0_318_257)"},Q.createElement("path",{d:"M12.4297 12H14.4297V10H16.4297V8H14.4297V6H12.4297V8H10.4297V10H12.4297V12ZM10.4297 16H16.4297V14H10.4297V16ZM5.92969 20V2H14.9297L20.9297 8V20H5.92969ZM7.92969 18H18.9297V9L13.9297 4H7.92969V18Z",fill:"currentColor"}))),Bn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M6.8 19V5h5.525c1.083 0 2.083.333 3 1 .917.667 1.375 1.592 1.375 2.775 0 .85-.192 1.504-.575 1.962-.383.459-.742.788-1.075.988.417.183.88.525 1.388 1.025.508.5.762 1.25.762 2.25 0 1.483-.542 2.521-1.625 3.113-1.083.591-2.1.887-3.05.887H6.8Zm3.025-2.8h2.6c.8 0 1.287-.204 1.462-.613.175-.408.263-.704.263-.887 0-.183-.088-.48-.263-.888-.175-.408-.687-.612-1.537-.612H9.825v3Zm0-5.7h2.325c.55 0 .95-.142 1.2-.425a1.4 1.4 0 0 0 .375-.95c0-.4-.142-.725-.425-.975-.283-.25-.65-.375-1.1-.375H9.825V10.5Z"}))),$n=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 19v-2.5h4l3-9H8V5h10v2.5h-3.5l-3 9H15V19H5Z"}))),Zn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M9 19v-2h12v2H9Zm0-6v-2h12v2H9Zm0-6V5h12v2H9ZM5 20a1.93 1.93 0 0 1-1.413-.587A1.928 1.928 0 0 1 3 18c0-.55.196-1.021.587-1.413A1.928 1.928 0 0 1 5 16c.55 0 1.02.196 1.412.587.392.392.588.863.588 1.413s-.196 1.021-.588 1.413A1.925 1.925 0 0 1 5 20Zm0-6c-.55 0-1.021-.196-1.413-.588A1.925 1.925 0 0 1 3 12c0-.55.196-1.021.587-1.413A1.928 1.928 0 0 1 5 10c.55 0 1.02.196 1.412.587.392.392.588.863.588 1.413s-.196 1.02-.588 1.412A1.923 1.923 0 0 1 5 14Zm0-6c-.55 0-1.021-.196-1.413-.588A1.925 1.925 0 0 1 3 6c0-.55.196-1.02.587-1.412A1.927 1.927 0 0 1 5 4c.55 0 1.02.196 1.412.588C6.804 4.979 7 5.45 7 6c0 .55-.196 1.02-.588 1.412A1.923 1.923 0 0 1 5 8Z"}))),Un=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 22v-1.5h2.5v-.75H4v-1.5h1.5v-.75H3V16h4v2.25L6 19l1 .75V22H3Zm0-7v-3.75h2.5v-.75H3V9h4v3.75H4.5v.75H7V15H3Zm1.5-7V3.5H3V2h3v6H4.5ZM9 19v-2h12v2H9Zm0-6v-2h12v2H9Zm0-6V5h12v2H9Z"}))),Fn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 21v-2h14v2H5Zm7-4c-1.683 0-2.992-.525-3.925-1.575-.933-1.05-1.4-2.442-1.4-4.175V3H9.25v8.4c0 .933.233 1.692.7 2.275.467.583 1.15.875 2.05.875.9 0 1.583-.292 2.05-.875.467-.583.7-1.342.7-2.275V3h2.575v8.25c0 1.733-.467 3.125-1.4 4.175C14.992 16.475 13.683 17 12 17Z"}))),Kn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 21v-6h2v4h4v2H3Zm12 0v-2h4v-4h2v6h-6Zm-6.4-5.4L5 12l3.6-3.6L10 9.825 7.825 12 10 14.175 8.6 15.6Zm6.8 0L14 14.175 16.175 12 14 9.825 15.4 8.4 19 12l-3.6 3.6ZM3 9V3h6v2H5v4H3Zm16 0V5h-4V3h6v6h-2Z"}))),zn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 7h4v2H5z"}),Q.createElement("path",{d:"M5 7h4v2H5zm0 7h4v2H5z"}),Q.createElement("path",{d:"M5 14h4v2H5zm5-7h4v2h-4z"}),Q.createElement("path",{d:"M10 7h4v2h-4zm0 7h4v2h-4z"}),Q.createElement("path",{d:"M10 14h4v2h-4zm5-7h4v2h-4z"}),Q.createElement("path",{d:"M15 7h4v2h-4zm0 7h4v2h-4z"}),Q.createElement("path",{d:"M15 14h4v2h-4z"}))),jn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M4 13v-2h16v2H4Z"}))),qn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M11 17H7c-1.383 0-2.562-.488-3.537-1.463C2.488 14.562 2 13.383 2 12s.488-2.563 1.463-3.538C4.438 7.487 5.617 7 7 7h4v2H7c-.833 0-1.542.292-2.125.875A2.893 2.893 0 0 0 4 12c0 .833.292 1.542.875 2.125A2.893 2.893 0 0 0 7 15h4v2Zm-3-4v-2h8v2H8Zm5 4v-2h4c.833 0 1.542-.292 2.125-.875A2.893 2.893 0 0 0 20 12c0-.833-.292-1.542-.875-2.125A2.893 2.893 0 0 0 17 9h-4V7h4c1.383 0 2.563.487 3.538 1.462C21.513 9.437 22 10.617 22 12s-.487 2.562-1.462 3.537C19.563 16.512 18.383 17 17 17h-4Z"}))),Wn=e=>Q.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Q.createElement("mask",{id:"mask0_46_56",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:0,y:0,width:24,height:24},Q.createElement("rect",{width:24,height:24,fill:"#D9D9D9"})),Q.createElement("g",{mask:"url(#mask0_46_56)"},Q.createElement("path",{d:"M19 19L14 14L15.4 12.575L18 15.175V5H20V15.175L22.6 12.575L24 14L19 19Z",fill:"currentColor"}),Q.createElement("path",{d:"M13 19H10.5V9L6.5 15L2.5 9V19H0V5H2.5L6.5 11L10.5 5H13V19Z",fill:"currentColor"}))),Jn=e=>Q.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Q.createElement("mask",{id:"mask0_318_249",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:0,y:0,width:24,height:24},Q.createElement("rect",{width:24,height:24,fill:"#D9D9D9"})),Q.createElement("g",{mask:"url(#mask0_318_249)"},Q.createElement("path",{d:"M5 21V19H19V21H5Z",fill:"currentColor"}),Q.createElement("path",{d:"M6.80005 17V3H12.325C13.4084 3 14.4084 3.33333 15.325 4C16.2417 4.66667 16.7001 5.59167 16.7001 6.775C16.7001 7.625 16.5084 8.279 16.125 8.737C15.7417 9.19567 15.3834 9.525 15.05 9.725C15.4667 9.90833 15.9294 10.25 16.438 10.75C16.946 11.25 17.2001 12 17.2001 13C17.2001 14.4833 16.6584 15.521 15.575 16.113C14.4917 16.7043 13.475 17 12.525 17H6.80005ZM9.82505 14.2H12.425C13.225 14.2 13.7124 13.9957 13.887 13.587C14.0624 13.179 14.15 12.8833 14.15 12.7C14.15 12.5167 14.0624 12.2207 13.887 11.812C13.7124 11.404 13.2 11.2 12.35 11.2H9.82505V14.2ZM9.82505 8.5H12.15C12.7 8.5 13.1 8.35833 13.35 8.075C13.6 7.79167 13.725 7.475 13.725 7.125C13.725 6.725 13.5834 6.4 13.3 6.15C13.0167 5.9 12.65 5.775 12.2 5.775H9.82505V8.5Z",fill:"currentColor"}))),Gn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 21V3h18v18H3ZM5 9h14V5H5v4Zm5.325 5h3.35v-3h-3.35v3Zm0 5h3.35v-3h-3.35v3ZM5 14h3.325v-3H5v3Zm10.675 0H19v-3h-3.325v3ZM5 19h3.325v-3H5v3Zm10.675 0H19v-3h-3.325v3Z"}),Q.createElement("path",{d:"M8.325 9h2V5h-2v4Zm5.35 0h2V5h-2v4Z"}))),Yn=()=>{const[e]=Ot("currentBlockType"),t=At("applyBlockType");return m.createElement(ne.Root,{value:e||"",onValueChange:t},m.createElement(Hn,{placeholder:"Block type"}),m.createElement(An,null,m.createElement(Ln,{value:"paragraph"},"Paragraph"),m.createElement(Ln,{value:"quote"},"Quote"),m.createElement(ne.Separator,null),m.createElement(Ln,{value:"h1"},"Heading 1"),m.createElement(Ln,{value:"h2"},"Heading 2"),m.createElement(Ln,{value:"h3"},"Heading 3"),m.createElement(Ln,{value:"h4"},"Heading 4"),m.createElement(Ln,{value:"h5"},"Heading 5"),m.createElement(Ln,{value:"h6"},"Heading 6"),m.createElement(ne.Separator,null),m.createElement(Ln,{value:"info"},"Info")))},Qn=e=>Q.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Q.createElement("mask",{id:"mask0_343_38",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:0,y:0,width:24,height:24},Q.createElement("rect",{width:24,height:24,fill:"#D9D9D9"})),Q.createElement("g",{mask:"url(#mask0_343_38)"},Q.createElement("path",{d:"M3 21V3H14V5H5V19H19V10H21V21H3ZM17 9V7H15V5H17V3H19V5H21V7H19V9H17ZM6 17H18L14.25 12L11.25 16L9 13L6 17Z",fill:"currentColor"}))),Xn=m.forwardRef(((e,t)=>{const[n,r]=Ot("editorRootElementRef","imageAutocompleteSuggestions"),[a,o]=m.useState(!1),l=At("insertImage");console.log(r);const i=m.useCallback((e=>{l(e),o(!1)}),[l]);return m.createElement(re.Root,{open:a,onOpenChange:o},m.createElement(re.Trigger,{asChild:!0},m.createElement(te.Button,{className:Ut.toolbarButton,...e,ref:t},m.createElement(Qn,null))),m.createElement(re.Portal,{container:n.current},m.createElement(re.Overlay,{className:Ut.dialogOverlay}),m.createElement(re.Content,{className:Ut.dialogContent},m.createElement(er,{initialUrl:"",onSubmit:i,imageAutocompleteSuggestions:r}))))}));u.createCommand();const er=({initialUrl:e,onSubmit:t,imageAutocompleteSuggestions:n})=>{const[r,a]=m.useState(n.slice(0,20)),{isOpen:o,getToggleButtonProps:l,getMenuProps:i,getInputProps:s,highlightedIndex:c,getItemProps:u,selectedItem:p}=V.useCombobox({initialInputValue:e,onInputValueChange({inputValue:e}){e=(null==e?void 0:e.toLowerCase())||"";const t=[];for(const r of n)if(r.toLowerCase().includes(e)&&(t.push(r),t.length>=20))break;a(t)},items:r,itemToString:e=>e??""}),h=m.useCallback((e=>{var n;"Escape"===e.key?null==(n=e.target.form)||n.reset():"Enter"!==e.key||o&&0!==r.length||(e.preventDefault(),t(e.target.value))}),[o,r,t]),g=s(),E={...g,onKeyDown:e=>{h(e),g.onKeyDown(e)}},v=o&&r.length>0;return m.createElement("form",{onSubmit:e=>{e.preventDefault(),t(p||"")},className:d(Ut.linkDialogEditForm)},m.createElement("div",{className:Ut.linkDialogInputContainer},m.createElement("div",{"data-visible-dropdown":v,className:Ut.linkDialogInputWrapper},m.createElement("input",{placeholder:"Paste or select an image url",className:Ut.linkDialogInput,...E,autoFocus:!0,size:30,"data-editor-dialog":!0}),m.createElement("button",{"aria-label":"toggle menu",type:"button",...l()},m.createElement(Zt,null))),m.createElement("div",{className:Ut.linkDialogAutocompleteContainer},m.createElement("ul",{...i(),"data-visible":v},r.map(((e,t)=>m.createElement("li",{"data-selected":p===e,"data-highlighted":c===t,key:`${e}${t}`,...u({item:e,index:t})},e)))))),m.createElement(tr,{type:"submit",title:"Insert image","aria-label":"Insert image",className:Ut.primaryActionButton},m.createElement(Rt,null)),m.createElement(re.Close,{className:Ut.actionButton},m.createElement(Dt,null)))},tr=m.forwardRef((({className:e,...t},n)=>m.createElement("button",{className:d(Ut.actionButton,e),ref:n,...t}))),nr=m.forwardRef((({className:e,...t},n)=>m.createElement(te.ToggleItem,{className:d(e,Ut.toolbarToggleItem),...t,ref:n}))),rr=m.forwardRef(((e,t)=>m.createElement(te.Button,{className:Ut.toolbarButton,...e,ref:t}))),ar=m.forwardRef((({children:e,className:t,...n},r)=>m.createElement(te.ToggleGroup,{...n,type:"single",ref:r,className:d(Ut.toolbarToggleSingleGroup,t)},e))),or=m.forwardRef((({on:e,children:t,...n},r)=>m.createElement(ar,{...n,value:e?"on":"off",ref:r},m.createElement(nr,{value:"on"},t)))),lr=({children:e})=>m.createElement("div",{className:Ut.toolbarGroupOfGroups},e),ir=te.ToolbarSeparator,sr=()=>{const[e]=Ot("currentFormat","currentListType"),t=At("applyFormat");return m.createElement(lr,null,m.createElement(or,{"aria-label":"Bold",on:0!=(1&e),onValueChange:t.bind(null,"bold")},m.createElement(Bn,null)),m.createElement(or,{"aria-label":"Italic",on:0!=(2&e),onValueChange:t.bind(null,"italic")},m.createElement($n,null)),m.createElement(or,{"aria-label":"Underline",on:0!=(8&e),onValueChange:t.bind(null,"underline")},m.createElement(Fn,{style:{transform:"translateY(2px)"}})))},cr=()=>{const[e]=Ot("currentListType"),t=At("applyListType");return m.createElement(lr,null,m.createElement(ar,{"aria-label":"List type",onValueChange:t,value:e||"",onFocus:e=>e.preventDefault()},m.createElement(nr,{value:"bullet","aria-label":"Bulleted list"},m.createElement(Zn,null)),m.createElement(nr,{value:"number","aria-label":"Numbered list"},m.createElement(Un,null))))},dr=()=>{const e=At("openLinkEditDialog");return m.createElement(rr,{onClick:e.bind(null,!0)},m.createElement(qn,null))},ur=()=>{const e=At("insertTable");return m.createElement(rr,{onClick:e.bind(null,!0)},m.createElement(Gn,null))},mr=()=>{const e=At("insertCodeBlock");return m.createElement(rr,{onClick:e.bind(null,!0)},m.createElement(Kn,null))},pr=()=>{const e=At("insertSandpack"),[t]=Ot("sandpackConfig");return m.createElement(m.Fragment,null,1===t.presets.length?m.createElement(rr,{onClick:e.bind(null,"")},m.createElement(In,null)):m.createElement(ne.Root,{value:"",onValueChange:e},m.createElement(On,{title:"Insert live code snippet"},m.createElement(In,null)),m.createElement(An,{className:Ut.toolbarButtonDropdownContainer},t.presets.map((e=>m.createElement(Ln,{key:e.name,value:e.meta},e.label))))))},hr=()=>{const e=At("insertFrontmatter");return m.createElement(rr,{onClick:e.bind(null,!0)},m.createElement(zn,null))},gr=()=>{const[e]=Ot("viewMode","activeEditorType"),t=At("viewMode");return m.createElement(ar,{"aria-label":"View Mode",onValueChange:e=>{""!==e&&t(e)},value:e,className:Ut.toolbarModeSwitch},m.createElement(nr,{value:"editor","aria-label":"Rich text",title:"Rich text"},m.createElement(Jn,null)),m.createElement(nr,{value:"diff","aria-label":"View diff",title:"Diff"},m.createElement(Pn,null)),m.createElement(nr,{value:"markdown","aria-label":"View Markdown",title:"Markdown"},m.createElement(Wn,null)))},Er={BlockTypeSelect:Yn,BoldItalicUnderlineButtons:sr,CodeBlockButton:mr,FrontmatterButton:hr,GroupGroup:lr,HorizontalRuleIcon:jn,LinkButton:dr,ListButtons:cr,SandpackButton:pr,TableButton:ur,ToggleItem:nr,ToggleSingleGroup:ar,ToggleSingleGroupWithItem:or,ToolbarButton:rr,ToolbarSeparator:ir,ImageButton:Xn},vr=()=>{const[e,t]=Ot("activeEditorType","viewMode");return m.createElement(te.Root,{className:Ut.toolbarRoot,"aria-label":"Formatting options"},"editor"===t&&("lexical"===e.type?m.createElement(kr,null):"codeblock"===e.type?m.createElement(fr,null):m.createElement(wr,null)),m.createElement(ir,null),m.createElement(gr,null))},fr=()=>{const[e,t]=Ot("activeEditor","activeEditorType");return m.createElement(m.Fragment,null,m.createElement(Vn,null),m.createElement(rr,{onClick:()=>{e.update((()=>{const e=u.$getNodeByKey(t.nodeKey);e.selectNext(),e.remove()}))}},m.createElement(Rn,null)))},wr=()=>{const[e,t]=Ot("activeEditor","activeEditorType");return m.createElement(m.Fragment,null,m.createElement(rr,{onClick:()=>{e.update((()=>{const e=u.$getNodeByKey(t.nodeKey);e.selectNext(),e.remove()}))}},m.createElement(Rn,null)))},kr=()=>{const[e]=Ot("toolbarComponents");return m.createElement(m.Fragment,null,e.map(((e,t)=>m.createElement(e,{key:t}))))},xr={FrontmatterEditor:({yaml:e,onChange:t})=>{const[n,r]=m.useState(!0),a=m.useMemo((()=>e?Object.entries(P.load(e)).map((([e,t])=>({key:e,value:t}))):[]),[e]),{register:o,control:l,watch:i}=B.useForm({defaultValues:{yamlConfig:a}}),{fields:s,append:c,remove:d}=B.useFieldArray({control:l,name:"yamlConfig"});return m.useEffect((()=>{const e=i((({yamlConfig:e})=>{const n=e.reduce(((e,{key:t,value:n})=>(t&&n&&(e[t]=n),e)),{});t(P.dump(n).trim())}));return()=>e.unsubscribe()}),[i,t]),m.createElement("div",{className:Ut.frontmatterWrapper,"data-expanded":n,"data-editor-type":"frontmatter"},m.createElement("button",{className:Ut.frontmatterToggleButton,onClick:e=>{e.preventDefault(),r((e=>!e))}},n?m.createElement(Qt,null):m.createElement(Yt,null),"Document frontmatter"),n&&m.createElement("form",null,m.createElement("table",{className:Ut.frontmatterEditorTable},m.createElement("colgroup",null,m.createElement("col",null),m.createElement("col",null),m.createElement("col",null)),m.createElement("thead",null,m.createElement("tr",null,m.createElement("th",null,"Key"),m.createElement("th",null,"Value"),m.createElement("th",null))),m.createElement("tbody",null,s.map(((e,t)=>m.createElement("tr",{key:e.id},m.createElement("td",null,m.createElement(en,{...o(`yamlConfig.${t}.key`,{required:!0}),autofocusIfEmpty:!0})),m.createElement("td",null,m.createElement(en,{...o(`yamlConfig.${t}.value`,{required:!0})})),m.createElement("td",null,m.createElement("button",{type:"button",onClick:()=>d(t),className:Ut.iconButton},m.createElement(Xt,null))))))),m.createElement("tfoot",null,m.createElement("tr",null,m.createElement("td",null,m.createElement("button",{className:Ut.primaryButton,type:"button",onClick:()=>{c({key:"",value:""})}},"Add new key")))))))},JsxEditor:function({kind:e,attributes:t,componentName:n,editor:o,onSubmit:l,theme:i}){return"flow"===e?m.createElement("div",null,m.createElement("div",null,n),m.createElement($.LexicalNestedComposer,{initialEditor:o,initialTheme:i},m.createElement(s.RichTextPlugin,{contentEditable:m.createElement(r.ContentEditable,null),placeholder:m.createElement("div",null,"Type here.."),ErrorBoundary:a}))):m.createElement("span",null,m.createElement("span",null,m.createElement(an,{attributes:t,componentName:n,onSubmit:l})),m.createElement("span",null,n,m.createElement($.LexicalNestedComposer,{initialEditor:o,initialTheme:i},m.createElement(s.RichTextPlugin,{contentEditable:m.createElement(r.ContentEditable,{style:{padding:5,border:"1px solid red"}}),placeholder:m.createElement("div",null,"Type here.."),ErrorBoundary:a}))))},SandpackEditor:({nodeKey:e,code:t,meta:n,onChange:r,focusEmitter:a})=>{const[o]=M.useLexicalComposerContext(),[l]=Ot("sandpackConfig"),i=Gt(e,"sandpack","jsx"),s=At("activeEditorType");m.useEffect((()=>{a.subscribe((()=>{var t,n;null==(n=null==(t=null==i?void 0:i.current)?void 0:t.getCodemirror())||n.focus(),s({type:"sandpack",nodeKey:e})}))}),[a,i,s,e]);const c=m.useCallback((e=>{o.update((()=>{r(e)}))}),[r,o]),d=function(e,t){return t.presets.find((t=>t.meta===e))||t.presets.find((e=>e.name===t.defaultPreset))}(n,l);if(!d)throw new Error(`No sandpack preset found for meta: ${n}`);return m.createElement(I.SandpackProvider,{template:d.sandpackTemplate,theme:d.sandpackTheme,files:{[d.snippetFileName]:t,...Object.entries(d.files||{}).reduce(((e,[t,n])=>({...e,[t]:{code:n,readOnly:!0}})),{})},customSetup:{dependencies:d.dependencies}},m.createElement(I.SandpackLayout,null,m.createElement(I.SandpackCodeEditor,{showLineNumbers:!0,showInlineErrors:!0,ref:i}),m.createElement(I.SandpackPreview,null)),m.createElement(ln,{onChange:c,snippetFileName:d.snippetFileName}))},CodeBlockEditor:({nodeKey:e,code:t,language:n,onChange:r,focusEmitter:a})=>{const[o]=Ot("activeEditor"),l=Gt(e,"codeblock",n),i=At("activeEditorType");m.useEffect((()=>{a.subscribe((()=>{var t,n;null==(n=null==(t=null==l?void 0:l.current)?void 0:t.getCodemirror())||n.focus(),i({type:"codeblock",nodeKey:e})}))}),[a,l,i,e]);const s=m.useCallback((e=>{null==o||o.update((()=>{r(e)}))}),[r,o]);return m.createElement("div",{className:Ut.sandpackWrapper},m.createElement(I.SandpackProvider,null,m.createElement(I.CodeEditor,{showLineNumbers:!0,initMode:"immediate",key:n,filePath:`file.${n||"txt"}`,code:t,onCodeUpdate:s,ref:l})))},TableEditor:({mdastNode:e,parentEditor:t,lexicalTable:n})=>{const[r,a]=m.useState(null),o=m.useCallback((e=>{const r=n.getColCount();if(null===e)return void a(null);let[o,l]=e;return o>r-1&&(o=0,l++),o<0&&(o=r-1,l-=1),l>n.getRowCount()-1?(a(null),void t.update((()=>{if(n.getLatest().getNextSibling())n.getLatest().selectNext();else{const e=u.$createParagraphNode();n.insertAfter(e),e.select()}}))):l<0?(a(null),void t.update((()=>{n.getLatest().selectPrevious()}))):void a([o,l])}),[n,t]);m.useEffect((()=>{n.focusEmitter.subscribe(o)}),[n,o]);const l=m.useCallback((()=>{t.update((()=>{n.addRowToBottom()})),o([0,n.getRowCount()])}),[t,n,o]),i=m.useCallback((()=>{t.update((()=>{n.addColumnToRight()})),o([n.getColCount(),0])}),[t,n,o]),[s,c]=m.useState([-1,-1]),d=m.useCallback((e=>{let t=e.target;for(;t&&!["TH","TD"].includes(t.tagName);){if(t===e.currentTarget)return;t=t.parentElement}if(null===t)return;const n=t.parentElement,r="TFOOT"===n.parentElement.tagName?-1:Array.from(n.children).indexOf(t),a="TH"===t.tagName?-1:Array.from(n.parentElement.children).indexOf(n);c([r,a])}),[]);return m.createElement("table",{className:Ut.tableEditor,onMouseOver:d,onMouseLeave:()=>c([-1,-1])},m.createElement("colgroup",null,m.createElement("col",null),Array.from({length:e.children[0].children.length},((t,n)=>{const r=(e.align||[])[n]||"left",a=xn[r];return m.createElement("col",{key:n,className:a})})),m.createElement("col",null)),m.createElement("thead",null,m.createElement("tr",null,m.createElement("th",{className:Ut.tableToolsColumn,"data-tool-cell":!0},m.createElement("button",{className:Ut.iconButton,title:"Delete table",onClick:()=>{t.update((()=>{n.selectNext(),n.remove()}))}},m.createElement(gn,null))),Array.from({length:e.children[0].children.length},((r,a)=>m.createElement("th",{key:a,"data-tool-cell":!0},m.createElement(_n,{setActiveCellWithBoundaries:o,parentEditor:t,colIndex:a,highlightedCoordinates:s,lexicalTable:n,align:(e.align||[])[a]})))),m.createElement("th",{className:Ut.tableToolsColumn}))),m.createElement("tbody",null,e.children.map(((a,l)=>m.createElement("tr",{key:l},m.createElement("td",{className:Ut.toolCell,"data-tool-cell":!0},m.createElement(bn,{setActiveCellWithBoundaries:o,parentEditor:t,rowIndex:l,highlightedCoordinates:s,lexicalTable:n})),a.children.map(((a,i)=>{var s;return m.createElement(yn,{align:null==(s=e.align)?void 0:s[i],key:i,contents:a.children,rowIndex:l,colIndex:i,lexicalTable:n,parentEditor:t,activeCellTuple:[r,o]})})),0===l&&m.createElement("th",{rowSpan:n.getRowCount(),"data-tool-cell":!0},m.createElement("button",{className:Ut.addColumnButton,onClick:i},m.createElement(wn,null))))))),m.createElement("tfoot",null,m.createElement("tr",null,m.createElement("th",null),m.createElement("th",{colSpan:n.getColCount()},m.createElement("button",{className:Ut.addRowButton,onClick:l},m.createElement(fn,null))),m.createElement("th",null))))}},yr=[sr,ir,()=>{const[e]=Ot("currentFormat","currentListType"),t=At("applyFormat");return m.createElement(lr,null,m.createElement(or,{"aria-label":"Inline code",on:0!=(16&e),onValueChange:t.bind(null,"code")},m.createElement(Dn,null)))},ir,cr,ir,Yn,ir,dr,Xn,ur,()=>{const e=At("insertHorizontalRule");return m.createElement(rr,{onClick:e.bind(null,!0)},m.createElement(jn,null))},hr,ir,mr,pr],Cr={defaultPreset:"react",presets:[{name:"react",meta:"live react",label:"React",sandpackTemplate:"react",sandpackTheme:"light",snippetFileName:"/App.js",snippetLanguage:"jsx",initialSnippetContent:'\nexport default function App() {\n return (\n <div className="App">\n <h1>Hello CodeSandbox</h1>\n <h2>Start editing to see some magic happen!</h2>\n </div>\n );\n}\n'.trim()}]},_r={markdownParse:{defaultVisitors:Qe,defaultSyntaxExtensions:tt,defaultMdastExtensions:et},lexicalConvert:{defaultVisitors:ze,defaultExtensions:Ge,defaultMarkdownOptions:Ye},defaultLexicalNodes:at};Object.defineProperty(exports,"AdmonitionKind",{enumerable:!0,get:()=>u.AdmonitionKind}),exports.$createAdmonitionNode=oe,exports.$createCodeBlockNode=de,exports.$createFrontmatterNode=pe,exports.$createImageNode=ve,exports.$createJsxNode=Ce,exports.$createSandpackNode=Ne,exports.$createTableNode=He,exports.$isAdmonitionNode=le,exports.$isCodeBlockNode=ue,exports.$isFrontmatterNode=he,exports.$isImageNode=fe,exports.$isJsxNode=_e,exports.$isSandpackNode=Te,exports.$isTableNode=Le,exports.AdmonitionNode=ae,exports.CodeBlockNode=ce,exports.FrontmatterNode=me,exports.ImageNode=Ee,exports.JsxNode=ye,exports.MDXEditor=({markdown:e,headMarkdown:t,jsxComponentDescriptors:p=[],sandpackConfig:h=Cr,onChange:g,viewMode:E,linkAutocompleteSuggestions:v,imageAutoCompleteSuggestions:f,className:w,contentEditableClassName:k,toolbarComponents:x=yr,markdownParseOptions:{syntaxExtensions:y=Object.values(tt),mdastExtensions:C=Object.values(et),visitors:_=Object.values(Qe)}={},lexicalConvertOptions:{extensions:b=Object.values(Ge),markdownOptions:N=Ye,visitors:T=Object.values(ze)}={},lexicalNodes:S=Object.values(at)})=>{const M=m.useRef(null);return m.createElement("div",{className:d(Ut.editorRoot,Ut.editorWrapper,w),ref:M},m.createElement(n.LexicalComposer,{initialConfig:{editorState:()=>{nt({root:u.$getRoot(),visitors:_,mdastExtensions:C,markdown:e,syntaxExtensions:y})},namespace:"MDXEditor",theme:{...we,nodeDecoratorComponents:xr},nodes:S,onError:e=>console.error(e)}},m.createElement(Ht,{markdownSource:e,headMarkdown:t||e,jsxComponentDescriptors:p,sandpackConfig:h,onChange:g,viewMode:E,linkAutocompleteSuggestions:v,imageAutocompleteSuggestions:f,editorRootElementRef:M,toolbarComponents:x,markdownParseOptions:{visitors:_,mdastExtensions:C,syntaxExtensions:y},lexicalConvertOptions:{visitors:T,toMarkdownOptions:N,toMarkdownExtensions:b},lexicalNodes:S},m.createElement(vr,null),m.createElement(Sn,null,m.createElement(s.RichTextPlugin,{contentEditable:m.createElement(r.ContentEditable,{className:d(Ut.contentEditable,k)}),placeholder:m.createElement("div",null),ErrorBoundary:a})),m.createElement(l.LinkPlugin,null),m.createElement(o.HorizontalRulePlugin,null),m.createElement(i.ListPlugin,null),m.createElement(Wt,{maxDepth:7}),m.createElement(c.TabIndentationPlugin,null),m.createElement(zt,null),m.createElement(kn,null),m.createElement(Jt,null))))},exports.SandpackNode=be,exports.TableNode=Me,exports.ToolbarComponents=Er,exports.defaultMdxOptionValues=_r;
1
+ "use strict";var e=Object.defineProperty,t=(t,n,r)=>(((t,n,r)=>{n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r})(t,"symbol"!=typeof n?n+"":n,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@lexical/react/LexicalComposer"),r=require("@lexical/react/LexicalContentEditable"),a=require("@lexical/react/LexicalErrorBoundary"),o=require("@lexical/react/LexicalHorizontalRulePlugin"),l=require("@lexical/react/LexicalLinkPlugin"),i=require("@lexical/react/LexicalListPlugin"),s=require("@lexical/react/LexicalRichTextPlugin"),c=require("@lexical/react/LexicalTabIndentationPlugin"),d=require("classnames"),u=require("lexical"),m=require("react"),p=require("mdast-util-directive"),h=require("mdast-util-frontmatter"),g=require("mdast-util-gfm-table"),E=require("mdast-util-mdx"),v=require("mdast-util-to-markdown"),f=require("@lexical/code"),w=require("@lexical/link"),k=require("@lexical/list"),x=require("@lexical/react/LexicalHorizontalRuleNode"),y=require("@lexical/rich-text"),C=require("mdast-util-from-markdown"),_=require("micromark-extension-directive"),b=require("micromark-extension-frontmatter"),N=require("micromark-extension-gfm-table"),T=require("micromark-extension-mdxjs"),S=require("@lexical/utils"),M=require("@lexical/react/LexicalComposerContext"),L=require("@lexical/selection"),H=require("@lexical/react/LexicalHistoryPlugin"),A=require("@radix-ui/react-popover"),O=require("@radix-ui/react-tooltip"),V=require("downshift"),R=require("@lexical/markdown"),I=require("@lexical/react/LexicalMarkdownShortcutPlugin"),D=require("@codesandbox/sandpack-react"),P=require("js-yaml"),B=require("react-hook-form"),$=require("@lexical/react/LexicalNestedComposer"),Z=require("mdast-util-to-hast"),U=require("hast-util-raw"),F=require("hast-util-sanitize"),K=require("hast-util-to-html"),z=require("@radix-ui/react-toolbar"),j=require("@codemirror/lang-markdown"),q=require("react-diff-view"),W=require("unidiff"),J=require("@radix-ui/react-select"),G=require("@radix-ui/react-dialog");function Y(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const Q=Y(m),X=Y(A),ee=Y(O),te=Y(z),ne=Y(J),re=Y(G);class ae extends u.ElementNode{constructor(e,n){super(n),t(this,"__kind"),this.__kind=e||"note"}static getType(){return"admonition"}getKind(){return this.getLatest().__kind}setKind(e){e!==this.getKind()&&(this.getWritable().__kind=e)}static clone(e){return new ae(e.__kind,e.__key)}createDOM(e){const t=document.createElement("div");return S.addClassNamesToElement(t,e.theme.admonition[this.__kind]),t}updateDOM(e,t){return!1}static importJSON(e){return oe(e.kind)}exportJSON(){return{...super.exportJSON(),type:"admonition"}}insertNewAfter(e,t){const n=oe();return this.insertAfter(n,t),n}collapseAtStart(){const e=u.$createParagraphNode();return this.getChildren().forEach((t=>e.append(t))),this.replace(e),!0}}function oe(e){return u.$applyNodeReplacement(new ae(e))}function le(e){return e instanceof ae}function ie(e,t){return t(e),e}function se(){}class ce extends u.DecoratorNode{constructor(e,n,r,a){super(a),t(this,"__code"),t(this,"__meta"),t(this,"__language"),t(this,"__focusEmitter",function(){let e=se;return{publish:()=>{e()},subscribe:t=>{e=t}}}()),this.__code=e,this.__meta=r,this.__language=n}static getType(){return"codeblock"}static clone(e){return new ce(e.__code,e.__language,e.__meta,e.__key)}static importJSON(e){const{code:t,meta:n,language:r}=e;return de({code:t,language:r,meta:n})}exportJSON(){return{code:this.getCode(),language:this.getLanguage(),meta:this.getMeta(),type:"codeblock",version:1}}createDOM(e){return document.createElement("div")}updateDOM(){return!1}getCode(){return this.getLatest().__code}getMeta(){return this.getLatest().__meta}getLanguage(){return this.getLatest().__language}setCode(e){e!==this.__code&&(this.getWritable().__code=e)}setMeta(e){e!==this.__meta&&(this.getWritable().__meta=e)}setLanguage(e){e!==this.__language&&(this.getWritable().__language=e)}select(){this.__focusEmitter.publish()}decorate(e,{theme:{nodeDecoratorComponents:{CodeBlockEditor:t}}}){return m.createElement(t,{nodeKey:this.getKey(),code:this.getCode(),meta:this.getMeta(),language:this.getLanguage(),onChange:e=>this.setCode(e),focusEmitter:this.__focusEmitter})}}function de({code:e,language:t,meta:n}){return new ce(e,t,n)}function ue(e){return e instanceof ce}class me extends u.DecoratorNode{constructor(e,n){super(n),t(this,"__yaml"),this.__yaml=e}static getType(){return"frontmatter"}static clone(e){return new me(e.__yaml,e.__key)}static importJSON(e){const{yaml:t}=e;return pe({yaml:t})}exportJSON(){return{yaml:this.getYaml(),type:"frontmatter",version:1}}createDOM(e){return document.createElement("div")}updateDOM(){return!1}getYaml(){return this.getLatest().__yaml}setYaml(e){e!==this.__yaml&&(this.getWritable().__yaml=e)}decorate(e,{theme:{nodeDecoratorComponents:{FrontmatterEditor:t}}}){return m.createElement(t,{yaml:this.getYaml(),onChange:t=>null==e?void 0:e.update((()=>{this.setYaml(t)}))})}}function pe({yaml:e}){return new me(e)}function he(e){return e instanceof me}function ge(e){if(e instanceof HTMLImageElement){const{alt:t,src:n,title:r}=e;return{node:ve({altText:t,src:n,title:r})}}return null}class Ee extends u.DecoratorNode{constructor(e,n,r,a){super(a),t(this,"__src"),t(this,"__altText"),t(this,"__title"),this.__src=e,this.__title=r,this.__altText=n}static getType(){return"image"}static clone(e){return new Ee(e.__src,e.__altText,e.__title,e.__key)}static importJSON(e){const{altText:t,title:n,src:r}=e;return ve({altText:t,title:n,src:r})}exportDOM(){const e=document.createElement("img");return e.setAttribute("src",this.__src),e.setAttribute("alt",this.__altText),this.__title&&e.setAttribute("title",this.__title),{element:e}}static importDOM(){return{img:()=>({conversion:ge,priority:0})}}exportJSON(){return{altText:this.getAltText(),title:this.getTitle(),src:this.getSrc(),type:"image",version:1}}createDOM(e){const t=document.createElement("span"),n=e.theme.image;return void 0!==n&&(t.className=n),t}updateDOM(){return!1}getSrc(){return this.__src}getAltText(){return this.__altText}getTitle(){return this.__title}setTitle(e){this.getWritable().__title=e}decorate(){return m.createElement("img",{title:this.__title,src:this.__src,alt:this.__altText})}}function ve({altText:e,title:t,src:n,key:r}){return new Ee(n,e,t,r)}function fe(e){return e instanceof Ee}const we={text:{bold:"_bold_1xdbx_1",italic:"_italic_1xdbx_5",underline:"_underline_1xdbx_9",code:"_code_1xdbx_43",strikethrough:"_strikethrough_1xdbx_25",subscript:"_subscript_1xdbx_33",superscript:"_superscript_1xdbx_38",underlineStrikethrough:"_underlineStrikethrough_1xdbx_29"},list:{nested:{listitem:"_nestedListItem_1xdbx_50"}},admonition:{danger:"_admonitionDanger_1xdbx_54",info:"_admonitionInfo_1xdbx_54",note:"_admonitionNote_1xdbx_54",tip:"_admonitionTip_1xdbx_54",caution:"_admonitionCaution_1xdbx_54"}},ke={type:"root",format:"left",indent:0,direction:"ltr",version:1,children:[{type:"paragraph",version:1,direction:"ltr",format:"left",indent:0,children:[]}]},xe={type:"root",format:"left",indent:0,direction:"ltr",version:1,children:[]};class ye extends u.DecoratorNode{constructor({name:e,kind:n,attributes:r,state:a,updateFn:o,key:l}){if(super(l),t(this,"__kind"),t(this,"__name"),t(this,"__attributes"),t(this,"__editor"),this.__name=e,this.__kind=n,this.__attributes=r,this.__editor=u.createEditor(),a){const e=this.__editor.parseEditorState(a);e.isEmpty()||this.__editor.setEditorState(e)}else if(o){const e=this.__editor.parseEditorState({root:"text"===this.getKind()?ke:xe},(()=>{if("text"===this.getKind()){const e=u.$getRoot().getFirstChildOrThrow();o(e)}else o(u.$getRoot())}));e.isEmpty()||this.__editor.setEditorState(e)}}static getType(){return"jsx"}static clone(e){return new ye({name:e.__name,kind:e.__kind,attributes:e.__attributes,state:e.__editor.getEditorState().toJSON()})}static importJSON(e){const{name:t,kind:n,attributes:r,state:a}=e;return Ce({kind:n,name:t,attributes:r,state:a})}exportJSON(){return{name:this.getName(),kind:this.getKind(),attributes:this.getAttributes(),state:this.__editor.getEditorState().toJSON(),type:"jsx",version:1}}inNestedEditor(e){this.__editor.getEditorState().read(e)}getChildren(){if("flow"===this.getKey())return u.$getRoot().getChildren()||[];{const e=u.$getRoot().getFirstChild();return e&&e.getChildren()||[]}}createDOM(){return"flow"===this.getKey()?document.createElement("div"):document.createElement("span")}updateDOM(){return!1}getName(){return this.__name}getKind(){return this.__kind}getAttributes(){return this.__attributes}updateAttributes(e){this.getWritable().__attributes=Object.entries(e).map((([e,t])=>({name:e,value:t})))}decorate(e,{theme:{nodeDecoratorComponents:{JsxEditor:t}}}){return m.createElement(t,{attributes:this.getAttributes(),componentName:this.getName(),kind:this.getKind(),editor:this.__editor,onSubmit:e=>this.updateAttributes(e),theme:we})}}function Ce(e){return new ye(e)}function _e(e){return e instanceof ye}class be extends u.DecoratorNode{constructor(e,n,r,a){super(a),t(this,"__code"),t(this,"__meta"),t(this,"__language"),t(this,"__focusEmitter",function(){let e=se;return{publish:()=>{e()},subscribe:t=>{e=t}}}()),this.__code=e,this.__meta=r,this.__language=n}static getType(){return"sandpack"}static clone(e){return new be(e.__code,e.__language,e.__meta,e.__key)}static importJSON(e){const{code:t,meta:n,language:r}=e;return Ne({code:t,language:r,meta:n})}exportJSON(){return{code:this.getCode(),language:this.getLanguage(),meta:this.getMeta(),type:"sandpack",version:1}}createDOM(e){return document.createElement("div")}updateDOM(){return!1}getCode(){return this.getLatest().__code}getMeta(){return this.getLatest().__meta}getLanguage(){return this.getLatest().__language}setCode(e){e!==this.__code&&(this.getWritable().__code=e)}setMeta(e){e!==this.__meta&&(this.getWritable().__meta=e)}setLanguage(e){e!==this.__language&&(this.getWritable().__language=e)}select(){this.__focusEmitter.publish()}decorate(e,{theme:{nodeDecoratorComponents:{SandpackEditor:t}}}){return m.createElement(t,{nodeKey:this.getKey(),code:this.getCode(),meta:this.getMeta(),onChange:e=>this.setCode(e),focusEmitter:this.__focusEmitter})}}function Ne({code:e,language:t,meta:n}){return new be(e,t,n)}function Te(e){return e instanceof be}const Se={type:"tableCell",children:[]};class Me extends u.DecoratorNode{constructor(e,n){super(n),t(this,"__mdastNode"),t(this,"focusEmitter",function(){let e=se;return{publish:t=>{e(t)},subscribe:t=>{e=t}}}()),this.__mdastNode=e||{type:"table",children:[]}}static getType(){return"table"}static clone(e){return new Me(structuredClone(e.__mdastNode),e.__key)}static importJSON(e){return He(e.mdastNode)}exportJSON(){return{mdastNode:structuredClone(this.__mdastNode),type:"table",version:1}}getMdastNode(){return this.__mdastNode}getRowCount(){return this.__mdastNode.children.length}getColCount(){var e;return(null==(e=this.__mdastNode.children[0])?void 0:e.children.length)||0}createDOM(){return document.createElement("div")}updateDOM(){return!1}updateCellContents(e,t,n){const r=this.getWritable().__mdastNode,a=r.children[t],o=a.children,l=o[e],i=Array.from(o),s={...l,children:n},c={...a,children:i};i[e]=s,r.children[t]=c}insertColumnAt(e){const t=this.getWritable().__mdastNode;for(let n=0;n<t.children.length;n++){const r=t.children[n],a=r.children,o=Array.from(a),l={...r,children:o};o.splice(e,0,structuredClone(Se)),t.children[n]=l}t.align&&t.align.length>0&&t.align.splice(e,0,"left")}deleteColumnAt(e){const t=this.getWritable().__mdastNode;for(let n=0;n<t.children.length;n++){const r=t.children[n],a=r.children,o=Array.from(a),l={...r,hildren:o};o.splice(e,1),t.children[n]=l}}insertRowAt(e){const t=this.getWritable().__mdastNode,n={type:"tableRow",children:Array.from({length:this.getColCount()},(()=>structuredClone(Se)))};t.children.splice(e,0,n)}deleteRowAt(e){this.getWritable().__mdastNode.children.splice(e,1)}addRowToBottom(){this.insertRowAt(this.getRowCount())}addColumnToRight(){this.insertColumnAt(this.getColCount())}setColumnAlign(e,t){const n=this.getWritable().__mdastNode;null==n.align&&(n.align=[]),n.align[e]=t}decorate(e,{theme:{nodeDecoratorComponents:{TableEditor:t}}}){return m.createElement(t,{lexicalTable:this,mdastNode:this.__mdastNode,parentEditor:e})}select(e){this.focusEmitter.publish(e)}isInline(){return!1}}function Le(e){return e instanceof Me}function He(e){return new Me(e)}const Ae={testLexicalNode:u.$isRootNode,visitLexicalNode:({actions:e})=>{e.addAndStepInto("root")}},Oe={testLexicalNode:u.$isParagraphNode,visitLexicalNode:({actions:e})=>{e.addAndStepInto("paragraph")}},Ve={testLexicalNode:he,visitLexicalNode:({actions:e,lexicalNode:t})=>{e.addAndStepInto("yaml",{value:t.getYaml()})}},Re={testLexicalNode:w.$isLinkNode,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto("link",{url:e.getURL(),title:e.getTitle()})}},Ie={testLexicalNode:y.$isHeadingNode,visitLexicalNode:({lexicalNode:e,actions:t})=>{const n=parseInt(e.getTag()[1],10);t.addAndStepInto("heading",{depth:n})}},De={testLexicalNode:k.$isListNode,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto("list",{ordered:"number"===e.getListType(),spread:!1})}},Pe={testLexicalNode:k.$isListItemNode,visitLexicalNode:({lexicalNode:e,mdastParent:t,actions:n})=>{const r=e.getChildren(),a=r[0];if(1===r.length&&k.$isListNode(a)){const r=t.children.at(-1);n.visitChildren(e,r)}else{const r=n.appendToParent(t,{type:"listItem",spread:!1,children:[{type:"paragraph",children:[]}]});n.visitChildren(e,r.children[0])}}},Be={testLexicalNode:y.$isQuoteNode,visitLexicalNode:({lexicalNode:e,mdastParent:t,actions:n})=>{const r=n.appendToParent(t,{type:"blockquote",children:[{type:"paragraph",children:[]}]});n.visitChildren(e,r.children[0])}},$e={testLexicalNode:le,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto("containerDirective",{name:e.getKind()})}},Ze={testLexicalNode:Te,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto("code",{value:e.getCode(),lang:e.getLanguage(),meta:e.getMeta()})}},Ue={testLexicalNode:ue,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto("code",{value:e.getCode(),lang:e.getLanguage(),meta:e.getMeta()})}};function Fe(e){return"text"===e.type}const Ke={testLexicalNode:u.$isLineBreakNode,visitLexicalNode:({mdastParent:e,actions:t})=>{t.appendToParent(e,{type:"text",value:"\n"})}},ze={LexicalRootVisitor:Ae,LexicalParagraphVisitor:Oe,LexicalFrontmatterVisitor:Ve,LexicalTextVisitor:{shouldJoin:(e,t)=>["text","emphasis","strong","mdxJsxTextElement"].includes(e.type)&&e.type===t.type,join:(e,t)=>Fe(e)&&Fe(t)?{type:"text",value:e.value+t.value}:{...e,children:[...e.children,...t.children]},testLexicalNode:u.$isTextNode,visitLexicalNode:({lexicalNode:e,mdastParent:t,actions:n})=>{const r=e.getPreviousSibling(),a=u.$isTextNode(r)?r.getFormat():0,o=e.getTextContent(),l=e.getFormat()??0;if(16&l)return void n.addAndStepInto("inlineCode",{value:o});let i=t;a&l&2&&(i=n.appendToParent(i,{type:"emphasis",children:[]})),a&l&1&&(i=n.appendToParent(i,{type:"strong",children:[]})),a&l&8&&(i=n.appendToParent(i,{type:"mdxJsxTextElement",name:"u",children:[],attributes:[]})),2&l&&!(2&a)&&(i=n.appendToParent(i,{type:"emphasis",children:[]})),1&l&&!(1&a)&&(i=n.appendToParent(i,{type:"strong",children:[]})),8&l&&!(8&a)&&(i=n.appendToParent(i,{type:"mdxJsxTextElement",name:"u",children:[],attributes:[]})),n.appendToParent(i,{type:"text",value:o})}},LexicalLinebreakVisitor:Ke,LexicalLinkVisitor:Re,LexicalHeadingVisitor:Ie,LexicalListVisitor:De,LexicalListItemVisitor:Pe,LexicalQuoteVisitor:Be,SandpackNodeVisitor:Ze,CodeBlockVisitor:Ue,LexicalThematicBreakVisitor:{testLexicalNode:x.$isHorizontalRuleNode,visitLexicalNode({actions:e}){e.addAndStepInto("thematicBreak")}},AdmonitionVisitor:$e,LexicalImageVisitor:{testLexicalNode:fe,visitLexicalNode({lexicalNode:e,actions:t}){t.addAndStepInto("image",{url:e.getSrc(),alt:e.getAltText(),title:e.getTitle()})}},JsxVisitor:{testLexicalNode:_e,visitLexicalNode({mdastParent:e,lexicalNode:t,actions:n}){const r="text"===t.getKind()?"mdxJsxTextElement":"mdxJsxFlowElement";n.registerReferredComponent(t.getName());const a={type:r,name:t.getName(),attributes:t.getAttributes(),children:[]};n.appendToParent(e,a),t.inNestedEditor((()=>{n.visitChildren(t,a)}))}},LexicalTableVisitor:{testLexicalNode:Le,visitLexicalNode({actions:e,mdastParent:t,lexicalNode:n}){e.appendToParent(t,n.getMdastNode())}}};function je({root:e,visitors:t,jsxComponentDescriptors:n}){let r=null;const a=new Set;function o(e){a.add(e)}function l(e,n){if(null===r)return r=n,r;if(!function(e){return e.children instanceof Array}(e))throw new Error("Attempting to append children to a non-parent");const a=e.children,o=a.at(-1);if(o){const e=t.find((e=>{var t;return null==(t=e.shouldJoin)?void 0:t.call(e,o,n)}));if(e){const t=e.join(o,n);return a.splice(a.length-1,1,t),t}}return a.push(n),n}function i(e,t){e.getChildren().forEach((e=>{s(e,t)}))}function s(e,n){var r;const a=t.find((t=>{var n;return null==(n=t.testLexicalNode)?void 0:n.call(t,e)}));if(!a)throw new Error(`no lexical visitor found for ${e.getType()}`,{cause:e});null==(r=a.visitLexicalNode)||r.call(a,{lexicalNode:e,mdastParent:n,actions:{addAndStepInto(t,r={},a=!0){const o={type:t,...r,...a?{children:[]}:{}};l(n,o),u.$isElementNode(e)&&a&&i(e,o)},appendToParent:l,visitChildren:i,registerReferredComponent:o}})}if(s(e,null),null===r)throw new Error("traversal ended with no root element");const c=new Map,d=new Map;for(const u of a){const e=n.find((e=>e.name===u));if(!e)throw new Error(`Component ${u} is used but not imported`);if(e.defaultExport)d.set(u,e.source);else{const{source:t}=e,n=c.get(t);n?n.push(u):c.set(t,[u])}}const m=Array.from(c).map((([e,t])=>({type:"mdxjsEsm",value:`import { ${t.join(", ")} } from '${e}'`})));m.push(...Array.from(d).map((([e,t])=>({type:"mdxjsEsm",value:`import ${e} from '${t}'`}))));const p=r,h=p.children.find((e=>"yaml"===e.type));return h?p.children.splice(p.children.indexOf(h)+1,0,...m):p.children.unshift(...m),Je(p,[]),p}const qe=/\s+$/,We=/^\s+/;function Je(e,t){if("strong"===e.type||"emphasis"===e.type){const n=e.children.at(-1);if("text"===(null==n?void 0:n.type)){const r=n.value.match(qe);if(r){n.value=n.value.replace(qe,"");const a=t.at(-1);a&&(a.children.splice(a.children.indexOf(e)+1,0,{type:"text",value:r[0]}),Je(a,t.slice(0,-1)))}}const r=e.children.at(0);if("text"===(null==r?void 0:r.type)){const n=r.value.match(We);if(n){r.value=r.value.replace(We,"");const a=t.at(-1);a&&(a.children.splice(a.children.indexOf(e),0,{type:"text",value:n[0]}),Je(a,t.slice(0,-1)))}}}if(Object.hasOwn(e,"children")){const n=e;n.children.forEach((e=>Je(e,[...t,n])))}}const Ge={mdxToMarkdown:E.mdxToMarkdown(),frontmatterToMarkdown:h.frontmatterToMarkdown("yaml"),directiveToMarkdown:p.directiveToMarkdown,gfmTableToMarkdown:g.gfmTableToMarkdown({tableCellPadding:!0,tablePipeAlign:!0})},Ye={listItemIndent:"one"};const Qe={MdastRootVisitor:{testNode:"root",visitNode({actions:e,mdastNode:t,lexicalParent:n}){e.visitChildren(t,n)}},MdastParagraphVisitor:{testNode:"paragraph",visitNode:function({mdastNode:e,lexicalParent:t,actions:n}){k.$isListItemNode(t)||y.$isQuoteNode(t)||le(t)?n.visitChildren(e,t):n.addAndStepInto(u.$createParagraphNode())}},MdastTextVisitor:{testNode:"text",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(u.$createTextNode(e.value).setFormat(t.getParentFormatting()))}},MdastFormattingVisitor:{testNode:e=>"emphasis"===e.type||"strong"===e.type||"mdxJsxTextElement"===e.type&&"u"===(null==e?void 0:e.name),visitNode({mdastNode:e,lexicalParent:t,actions:n}){"emphasis"===e.type?n.addFormatting(2):"strong"===e.type?n.addFormatting(1):"mdxJsxTextElement"===e.type&&"u"===e.name&&n.addFormatting(8),n.visitChildren(e,t)}},MdastInlineCodeVisitor:{testNode:"inlineCode",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(u.$createTextNode(e.value).setFormat(16))}},MdastLinkVisitor:{testNode:"link",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(w.$createLinkNode(e.url,{title:e.title}))}},MdastHeadingVisitor:{testNode:"heading",visitNode:function({mdastNode:e,actions:t}){t.addAndStepInto(y.$createHeadingNode(`h${e.depth}`))}},MdastListVisitor:{testNode:"list",visitNode:function({mdastNode:e,lexicalParent:t,actions:n}){const r=k.$createListNode(e.ordered?"number":"bullet");if(k.$isListItemNode(t)){const e=k.$createListItemNode();e.append(r),t.insertAfter(e)}else t.append(r);n.visitChildren(e,r)}},MdastListItemVisitor:{testNode:"listItem",visitNode({actions:e}){e.addAndStepInto(k.$createListItemNode())}},MdastBlockQuoteVisitor:{testNode:"blockquote",visitNode({actions:e}){e.addAndStepInto(y.$createQuoteNode())}},MdastCodeVisitor:{testNode:"code",visitNode({mdastNode:e,actions:t}){var n;const r=(null==(n=e.meta)?void 0:n.startsWith("live"))?Ne:de;t.addAndStepInto(r({code:e.value,language:e.lang,meta:e.meta}))}},MdastThematicBreakVisitor:{testNode:"thematicBreak",visitNode({actions:e}){e.addAndStepInto(x.$createHorizontalRuleNode())}},MdastImageVisitor:{testNode:"image",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(ve({src:e.url,altText:e.alt||"",title:e.title||""}))}},MdastFrontmatterVisitor:{testNode:"yaml",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(pe({yaml:e.value}))}},MdastAdmonitionVisitor:{testNode:"containerDirective",visitNode({mdastNode:e,actions:t}){t.addAndStepInto(oe(e.name))}},MdastMdxJsEsmVisitor:{testNode:"mdxjsEsm",visitNode(){}},MdastMdxJsxElementVisitor:{testNode:e=>"mdxJsxTextElement"===e.type||"mdxJsxFlowElement"===e.type,visitNode({lexicalParent:e,mdastNode:t,actions:n}){e.append(Ce({name:t.name,kind:"mdxJsxTextElement"===t.type?"text":"flow",attributes:t.attributes,updateFn:e=>{n.visitChildren(t,e)}}))}},MdastTableVisitor:{testNode:"table",visitNode({mdastNode:e,lexicalParent:t}){t.append(He(e))}}};function Xe(e){return e.children instanceof Array}const et={mdxFromMarkdown:E.mdxFromMarkdown(),frontmatterFromMarkdown:h.frontmatterFromMarkdown("yaml"),directiveFromMarkdown:p.directiveFromMarkdown,gfmTableFromMarkdown:g.gfmTableFromMarkdown},tt={mdxjs:T.mdxjs(),frontmatter:b.frontmatter(),directive:_.directive(),gfmTable:N.gfmTable};function nt({root:e,markdown:t,visitors:n,syntaxExtensions:r,mdastExtensions:a}){const o=C.fromMarkdown(t,{extensions:r,mdastExtensions:a});0===o.children.length&&o.children.push({type:"paragraph",children:[]}),rt({root:e,mdastRoot:o,visitors:n})}function rt({root:e,mdastRoot:t,visitors:n}){const r=new WeakMap;function a(e,t){if(!Xe(e))throw new Error("Attempting to visit children of a non-parent");e.children.forEach((n=>o(n,t,e)))}function o(e,t,o){const l=n.find((t=>"string"==typeof t.testNode?t.testNode===e.type:t.testNode(e)));if(!l)throw new Error(`no unist visitor found for ${e.type}`,{cause:e});l.visitNode({mdastNode:e,lexicalParent:t,actions:{visitChildren:a,addAndStepInto(n){t.append(n),Xe(e)&&a(e,n)},addFormatting(t){r.set(e,t|(r.get(o)??0))},getParentFormatting:()=>r.get(o)??0}})}o(t,e,null)}const at={ParagraphNode:u.ParagraphNode,LinkNode:w.LinkNode,HeadingNode:y.HeadingNode,QuoteNode:y.QuoteNode,ListNode:k.ListNode,ListItemNode:k.ListItemNode,HorizontalRuleNode:x.HorizontalRuleNode,ImageNode:Ee,SandpackNode:be,CodeBlockNode:ce,FrontmatterNode:me,AdmonitionNode:ae,JsxNode:ye,CodeNode:f.CodeNode,TableNode:Me};function ot(){const e=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0"))),t=crypto.getRandomValues(new Uint8Array(16));return t[6]=15&t[6]|64,t[8]=63&t[8]|128,[...t.entries()].map((([t,n])=>[4,6,8,10].includes(t)?`-${e[n]}`:e[n])).join("")}function lt(e,t){return e===t}class it{constructor(){t(this,"map",new Map)}getOrCreate(e){let t=this.map.get(e);return t||(t=new Set,this.map.set(e,t)),t}get(e){return this.map.get(e)}use(e,t){const n=this.get(e);void 0!==n&&t(n)}delete(e){return this.map.delete(e)}}class st{constructor(e=new Map){t(this,"map"),this.map=e}clone(){return new st(new Map(this.map))}increment(e){const t=this.map.get(e)??0;this.map.set(e,t+1)}decrement(e,t){let n=this.map.get(e);void 0!==n&&(n-=1,this.map.set(e,n),0===n&&t())}}const ct=Symbol("NO_VALUE");function dt(){const e=new it,t=new Map,n=new it,r=new Map,a=new Map,o={};function l(e=ct,t=!1){const n=ot();return e!==ct&&r.set(n,e),!1!==t&&a.set(n,!0===t?lt:t),{key:n,toString:()=>n}}function i({key:t},n){const r=e.getOrCreate(t);return r.add(n),()=>r.delete(n)}function s({key:e},n){return t.set(e,n),()=>t.delete(e)}function c(...e){const[t]=e.slice(-1),n=e.slice(0,-1);return 1===n.length?i(n[0],t):function(e,t){const n=l();return h({map:e=>(...t)=>{e(t)},sink:n,sources:e}),i(n,t)}(n,t)}function d(e){const t=[],r=new Set,a=new it,o=new st,l=new it;function i(e,s=0){o.increment(e),r.has(e)||(a.use(e,(e=>{s=Math.max(...Array.from(e).map((e=>t.indexOf(e))))+1})),n.use(e,(t=>{t.forEach((t=>{t.sources.has(e)?(l.getOrCreate(t.sink).add(t),i(t.sink,s)):a.getOrCreate(t.sink).add(e)}))})),r.add(e),t.splice(s,0,e))}return e.forEach((e=>i(e))),{participatingNodeKeys:t,pendingPulls:a,projections:l,refCount:o}}const u=new Map;function m(o){var l;const i=Object.keys(o),s=i.join(",");u.has(s)||u.set(s,d(i));const c=u.get(s),m=c.refCount.clone(),p=c.participatingNodeKeys.slice(),h=new Map(r);function g(e){n.use(e,(t=>{t.forEach((({sources:t,sink:n})=>{t.has(e)&&m.decrement(n,(()=>{p.splice(p.indexOf(n),1),g(n)}))}))}))}let E;for(;E=p.shift();){let n=!1;const i=e=>{a.has(E)&&a.get(E)(r.get(E),e)?n=!1:(n=!0,h.set(E,e),r.has(E)&&r.set(E,e))};if(Object.prototype.hasOwnProperty.call(o,E)?i(o[E]):c.projections.use(E,(e=>{e.forEach((e=>{const t=[...Array.from(e.sources),...Array.from(e.pulls)].map((e=>h.get(e)));e.map(i)(...t)}))})),n){const n=h.get(E);e.use(E,(e=>{e.forEach((e=>e(n)))})),null==(l=t.get(E))||l(n)}else g(E)}}function p(e){return new Set(e.map((e=>e.key)))}function h({sources:e,pulls:t=[],map:r,sink:{key:a}}){const o={map:r,pulls:p(t),sink:a,sources:p(e)};[...e,...t].forEach((({key:e})=>{n.getOrCreate(e).add(o)})),u.clear()}function g(...e){const t={};for(let n=0;n<e.length;n+=2){t[e[n].key]=e[n+1]}m(t)}function E(e){m(Object.entries(e).reduce(((e,[t,n])=>ie(e,(e=>e[o[t].key]=n))),{}))}return{combine:function(...e){const t=l();return h({map:e=>(...t)=>e(t),sink:t,sources:e}),t},connect:h,debug:function(){Object.entries(o).forEach((([e,t])=>{r.get(t.key)}))},derive:function(e,t){return ie(l(t,!0),(t=>{h({map:e=>t=>e(t),sink:t,sources:[e]})}))},getKeyValue:function(e){return r.get(o[e].key)},getValue:function(e){return r.get(e.key)},getKeyValues:function(e){return e.map((e=>r.get(o[e].key)))},label:function(e){Object.assign(o,e)},labels:o,link:function(e,t){h({map:e=>t=>e(t),sink:t,sources:[e]})},node:l,o:{delayWithMicrotask:function(){return e=>{const t=l();return c(e,(e=>queueMicrotask((()=>g(t,e))))),t}},debounceTime:function(e){return t=>{const n=l();let r,a;return c(t,(t=>{r=t,a&&clearTimeout(a),a=setTimeout((()=>{g(n,r)}),e)})),n}},filter:function(e){return t=>{const n=l();return h({map:t=>n=>e(n)&&t(n),sink:n,sources:[t]}),n}},map:function(e){return t=>{const n=l();return h({map:t=>n=>{t(e(n))},sink:n,sources:[t]}),n}},mapTo:function(e){return t=>{const n=l();return h({map:t=>()=>t(e),sink:n,sources:[t]}),n}},onNext:function(e){return t=>{const n=l();let r=ct;return c(t,(e=>r=e)),h({map:e=>t=>{r!==ct&&(e([r,t]),r=ct)},sink:n,sources:[e]}),n}},scan:function(e,t){return n=>{const r=l();return h({map:n=>r=>n(t=e(t,r)),sink:r,sources:[n]}),r}},throttleTime:function(e){return t=>{const n=l();let r,a;return c(t,(t=>{r=t,a||(a=setTimeout((()=>{a=void 0,g(n,r)}),e))})),n}},withLatestFrom:function(...e){return t=>{const n=l();return h({map:e=>(...t)=>e(t),pulls:e,sink:n,sources:[t]}),n}},once:function(){return e=>{const t=l();let n=!1;return h({map:e=>t=>{n||(n=!0,e(t))},sink:t,sources:[e]}),t}},passOnlyAfterNodeHasEmittedBefore:function(e,t){return n=>{const a=l();let o=0;return c(e,(()=>o=Date.now())),h({map:e=>n=>{Date.now()<o+r.get(t.key)&&e(n)},sink:a,sources:[n]}),a}}},pipe:function(e,...t){for(const n of t)e=n(e);return e},pub:g,pubIn:m,pubKey:function(e,t){E({[e]:t})},pubKeys:E,resetSingletonSubs:function(){t.clear()},singletonSub:s,singletonSubKey:function(e,t){return s(o[e],t)},spread:function(e,t){return t.map(((t,n)=>ie(l(t,!0),(t=>{h({map:e=>t=>{e(t[n])},sink:t,sources:[e]})}))))},sub:c,subKey:function(e,t){return c(o[e],t)},subKeys:function(e,t){return c(...e.map((e=>o[e])).concat(t))}}}const ut="undefined"!=typeof document?Q.useLayoutEffect:Q.useEffect,mt=m.createContext(void 0);function pt(e,t=[],n=ot()){return[{constructor:e,dependencies:t,id:n},{id:n}]}const ht=new Map([["number",k.INSERT_ORDERED_LIST_COMMAND],["bullet",k.INSERT_UNORDERED_LIST_COMMAND],["",k.REMOVE_LIST_COMMAND]]);const[gt,Et]=pt((e=>{const t=e.node(null,!0),n=e.node(""),r=e.node(H.createEmptyHistoryState()),a=e.derive(t,null),o=e.node(0,!0),l=e.node(null),i=e.node(null),s=e.node(null),c=e.node(),d=e.node(),m=e.node(),p=e.node(),h=e.node(),g=e.node(),E=e.node(),v=e.node(),f=e.node([]),w=e.node(!1,!0),C=e.node({type:"lexical"}),_=e.node(null),b=e.node(null),N=e.node(null),T=e.node([]),M=e.node([]);function A(){const t=u.$getSelection();u.$isRangeSelection(t)&&e.pubKeys({currentSelection:t,currentFormat:t.format})}return e.link(e.pipe(v,e.o.withLatestFrom(f),e.o.map((([e,t])=>[...t,e]))),f),e.sub(e.pipe(d,e.o.withLatestFrom(a)),(([e,t])=>{null==t||t.dispatchCommand(ht.get(e),void 0)})),e.sub(e.pipe(c,e.o.withLatestFrom(a)),(([e,t])=>{null==t||t.dispatchCommand(u.FORMAT_TEXT_COMMAND,e)})),e.sub(e.pipe(p,e.o.withLatestFrom(a)),(([,e])=>{null==e||e.dispatchCommand(x.INSERT_HORIZONTAL_RULE_COMMAND,void 0)})),e.sub(e.pipe(E,e.o.withLatestFrom(a)),(([e,t])=>{null==t||t.getEditorState().read((()=>{const n=u.$getSelection();if(u.$isRangeSelection(n)){null!==n.focus.getNode()&&t.update((()=>{const t=ve({altText:"",src:e,title:""});S.$insertNodeToNearestRoot(t)}))}}))})),e.sub(e.pipe(g,e.o.withLatestFrom(a)),(([,e])=>{null==e||e.update((()=>{const e=u.$getRoot().getFirstChild();if(!he(e)){const t=pe({yaml:'"": ""'});e?e.insertBefore(t):u.$getRoot().append(t)}}))})),e.sub(e.pipe(h,e.o.withLatestFrom(a)),(([,e])=>{null==e||e.getEditorState().read((()=>{const t=u.$getSelection();if(u.$isRangeSelection(t)){null!==t.focus.getNode()&&e.update((()=>{const e=He({type:"table",children:[{type:"tableRow",children:[{type:"tableCell",children:[]}]}]});S.$insertNodeToNearestRoot(e),setTimeout((()=>{e.select([0,0])}),50)}))}}))})),e.sub(e.pipe(m,e.o.withLatestFrom(a)),(([e,t])=>{if(t)switch(e){case"paragraph":(e=>{e.update((()=>{const e=u.$getSelection();(u.$isRangeSelection(e)||u.DEPRECATED_$isGridSelection(e))&&L.$setBlocksType(e,(()=>u.$createParagraphNode()))}))})(t);break;case"quote":(e=>{e.update((()=>{const e=u.$getSelection();(u.$isRangeSelection(e)||u.DEPRECATED_$isGridSelection(e))&&L.$setBlocksType(e,(()=>y.$createQuoteNode()))}))})(t);break;case"note":case"tip":case"danger":case"caution":case"info":((e,t)=>{e.update((()=>{const e=u.$getSelection();(u.$isRangeSelection(e)||u.DEPRECATED_$isGridSelection(e))&&L.$setBlocksType(e,(()=>oe(t)))}))})(t,e);break;default:((e,t)=>{e.update((()=>{const e=u.$getSelection();(u.$isRangeSelection(e)||u.DEPRECATED_$isGridSelection(e))&&L.$setBlocksType(e,(()=>y.$createHeadingNode(t)))}))})(t,e)}})),e.sub(e.pipe(l,e.o.withLatestFrom(a)),(([t,n])=>{if(!t||!n)return;const r=t.anchor.getNode();let a="root"===r.getKey()?r:S.$findMatchingParent(r,(e=>{const t=e.getParent();return null!==t&&u.$isRootOrShadowRoot(t)}));null===a&&(a=r.getTopLevelElementOrThrow());const o=a.getKey();if(null!==n.getElementByKey(o))if(k.$isListNode(a)){const t=S.$getNearestNodeOfType(r,k.ListNode),n=t?t.getListType():a.getListType();e.pubIn({[i.key]:n,[s.key]:""})}else{e.pub(i,null);const t=y.$isHeadingNode(a)?a.getTag():le(a)?a.getKind():a.getType();e.pubIn({[i.key]:null,[s.key]:t})}})),e.sub(t,(t=>{t&&t.registerCommand(u.SELECTION_CHANGE_COMMAND,((t,n)=>(e.pubIn({[a.key]:n,[w.key]:!0}),A(),!1)),u.COMMAND_PRIORITY_CRITICAL)})),e.pipe(e.combine(f,a),e.o.scan(((n,[r,a])=>(n.forEach((e=>e())),a?r.map((n=>n(a,e.getValue(t)))):[])),[])),e.pub(v,(e=>e.registerUpdateListener((({editorState:e})=>{e.read((()=>{A()}))})))),e.pub(v,(n=>n.registerCommand(u.BLUR_COMMAND,(n=>{var r;return!(null==(r=e.getValue(t).getRootElement())?void 0:r.contains(n.relatedTarget))&&e.pub(w,!1),!1}),u.COMMAND_PRIORITY_LOW))),{editor:t,activeEditor:a,currentFormat:o,currentSelection:l,currentListType:i,currentBlockType:s,applyFormat:c,applyListType:d,applyBlockType:m,insertHorizontalRule:p,insertFrontmatter:g,insertImage:E,insertTable:h,createEditorSubscription:v,editorSubscriptions:f,activeEditorType:C,inFocus:w,historyState:r,editorRootElementRef:_,markdownParseOptions:b,lexicalConvertOptions:N,lexicalNodes:T,imageAutocompleteSuggestions:M,markdownSource:n}}),[]),[vt,ft]=pt((e=>({jsxComponentDescriptors:e.node([])})),[]),[wt]=pt(((e,[{editor:t,markdownParseOptions:n,markdownSource:r},{}])=>{const a=e.node("editor"),o=e.node("");return e.sub(e.pipe(a,e.o.scan(((e,t)=>({current:e.next,next:t})),{current:"editor",next:"editor"}),e.o.withLatestFrom(t,r,n)),(([{current:e},t,n,r])=>{"markdown"===e&&(null==t||t.update((()=>{u.$getRoot().clear(),nt({root:u.$getRoot(),markdown:n,...r})})))})),{viewMode:a,headMarkdown:o}}),[Et,ft]),kt={defaultPreset:"react",presets:[{name:"react",meta:"live react",label:"React",sandpackTemplate:"react",sandpackTheme:"light",snippetFileName:"/App.js",snippetLanguage:"jsx",initialSnippetContent:'\nexport default function App() {\n return (\n <div className="App">\n <h1>Hello CodeSandbox</h1>\n <h2>Start editing to see some magic happen!</h2>\n </div>\n );\n}\n'}]},[xt]=pt(((e,[{activeEditor:t,activeEditorType:n,createEditorSubscription:r}])=>{const a=e.node(kt),o=e.node(),l=e.node();return e.pub(r,(t=>t.registerCommand(u.FOCUS_COMMAND,(()=>(e.pub(n,{type:"lexical"}),!1)),u.COMMAND_PRIORITY_LOW))),e.sub(e.pipe(o,e.o.withLatestFrom(t,a)),(([e,t,n])=>{null==t||t.getEditorState().read((()=>{const r=u.$getSelection();if(u.$isRangeSelection(r)){const a=r.focus.getNode(),o=e?n.presets.find((t=>t.meta===e)):n.presets.find((e=>e.name==n.defaultPreset));if(!o)throw new Error(`No sandpack preset found with ${e}`);null!==a&&t.update((()=>{const e=Ne({code:o.initialSnippetContent||"",language:o.snippetLanguage||"jsx",meta:o.meta});S.$insertNodeToNearestRoot(e),setTimeout((()=>e.select()),80)}))}}))})),e.sub(e.pipe(l,e.o.withLatestFrom(t)),(([,e])=>{null==e||e.getEditorState().read((()=>{const t=u.$getSelection();if(u.$isRangeSelection(t)){null!==t.focus.getNode()&&e.update((()=>{const e=de({code:"",language:"jsx",meta:""});S.$insertNodeToNearestRoot(e),setTimeout((()=>e.select()),80)}))}}))})),{insertSandpack:o,insertCodeBlock:l,sandpackConfig:a}}),[Et]);function yt(e){const t=u.$getSelection(),n=window.getSelection(),r=document.activeElement,a=e.getRootElement();if(null!==t&&null!==n&&null!==a&&a.contains(n.anchorNode)&&e.isEditable()){const e=n.getRangeAt(0);let t;if(n.anchorNode===a){let e=a;for(;null!=e.firstElementChild;)e=e.firstElementChild;t=e.getBoundingClientRect()}else t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX,width:t.width,height:t.height}}return r&&r.className,null}function Ct(e,t){return ie({markdown:""},(n=>{e.getEditorState().read((()=>{n.markdown=function({root:e,toMarkdownOptions:t,toMarkdownExtensions:n,visitors:r,jsxComponentDescriptors:a}){return v.toMarkdown(je({root:e,visitors:r,jsxComponentDescriptors:a}),{extensions:n,...t})}({root:u.$getRoot(),...t})}))})).markdown}function _t(e){const t=function(e){const t=e.anchor,n=e.focus,r=e.anchor.getNode(),a=e.focus.getNode();return r===a?r:e.isBackward()?L.$isAtNodeEnd(n)?r:a:L.$isAtNodeEnd(t)?r:a}(e),n=t.getParent();return w.$isLinkNode(n)?n:w.$isLinkNode(t)?t:null}const[bt,Nt]=pt(((e,[{activeEditor:t,currentSelection:n,createEditorSubscription:r}])=>{const a=e.node(!1),o=e.node(),l=e.node({type:"inactive"},!0),i=e.node(),s=e.node(),c=e.node(),d=e.node(),m=e.node(),p=e.node(),h=e.node([]);return e.sub(e.pipe(p,e.o.withLatestFrom(n,t),e.o.filter((([,e])=>u.$isRangeSelection(e)))),(([,t,n])=>{null==n||n.getEditorState().read((()=>{const r=_t(t),a=yt(n);r?e.pub(l,{type:"edit",initialUrl:r.getURL(),url:r.getURL(),linkNodeKey:r.getKey(),rectangle:a}):e.pub(l,{type:"edit",initialUrl:"",url:"",linkNodeKey:"",rectangle:a})}))})),e.sub(e.pipe(m,e.o.withLatestFrom(t)),(([,e])=>{null==e||e.dispatchCommand(w.TOGGLE_LINK_COMMAND,null)})),e.pub(r,(t=>t.registerCommand(u.KEY_ESCAPE_COMMAND,(()=>"preview"===e.getValue(l).type&&(e.pub(l,{type:"inactive"}),!0)),u.COMMAND_PRIORITY_LOW))),e.pub(r,(t=>t.registerCommand(u.KEY_MODIFIER_COMMAND,(t=>!("k"!==t.key||!t.metaKey)&&(e.pub(p,!0),!0)),u.COMMAND_PRIORITY_HIGH))),e.link(e.pipe(d,e.o.withLatestFrom(l),e.o.map((([,e])=>{if("preview"===e.type)return{type:"edit",initialUrl:e.url,url:e.url,linkNodeKey:e.linkNodeKey,rectangle:e.rectangle};throw new Error("Cannot switch to edit mode when not in preview mode")}))),l),e.sub(e.pipe(c,e.o.withLatestFrom(l,t)),(([,t,n])=>{if("edit"!==t.type)throw new Error("Cannot apply link edit when not in edit mode");{const r=t.url.trim();""!==r.trim()?(null==n||n.dispatchCommand(w.TOGGLE_LINK_COMMAND,r),e.pub(l,{type:"preview",linkNodeKey:t.linkNodeKey,rectangle:t.rectangle,url:r})):(""!==t.initialUrl&&(null==n||n.dispatchCommand(w.TOGGLE_LINK_COMMAND,null)),e.pub(l,{type:"inactive"}))}})),e.link(e.pipe(i,e.o.withLatestFrom(l),e.o.map((([e,t])=>{if("edit"===t.type)return{...t,url:e};throw new Error("Cannot update link url when not in edit mode")}))),l),e.link(e.pipe(s,e.o.withLatestFrom(l,t),e.o.map((([,e,t])=>{if("edit"===e.type)return null==t||t.focus(),""===e.initialUrl?{type:"inactive"}:{type:"preview",url:e.initialUrl,linkNodeKey:e.linkNodeKey,rectangle:e.rectangle};throw new Error("Cannot cancel edit when not in edit mode")}))),l),e.link(e.pipe(e.combine(n,o),e.o.withLatestFrom(t,l),e.o.map((([[e],t])=>{if(u.$isRangeSelection(e)&&t){const n=_t(e);return n?{type:"preview",url:n.getURL(),linkNodeKey:n.getKey(),rectangle:yt(t)}:{type:"inactive"}}return{type:"inactive"}}))),l),{dialogState:a,onWindowChange:o,linkDialogState:l,updateLinkUrl:i,switchFromPreviewToLinkEdit:d,cancelLinkEdit:s,removeLink:m,openLinkEditDialog:p,applyLinkChanges:c,linkAutocompleteSuggestions:h}}),[Et]),[Tt,St]=pt(((e,[{createEditorSubscription:t,lexicalConvertOptions:n,markdownSource:r},{jsxComponentDescriptors:a}])=>{const o=e.node();return e.pub(t,((t,l)=>{function i(){const t=e.getValue(a),i=e.getValue(n),s=Ct(l,{jsxComponentDescriptors:t,...i});e.pub(o,s),e.pub(r,s)}return i(),t.registerUpdateListener((({dirtyElements:e,dirtyLeaves:t,prevEditorState:n,tags:r})=>{0===e.size&&0===t.size||r.has("history-merge")||n.isEmpty()||i()}))})),{onChange:o}}),[Et,ft]),[Mt,Lt]=pt((e=>({toolbarComponents:e.node([])})),[]),{Component:Ht,usePublisher:At,useEmitterValues:Ot}=function(e,t,n){const r=Object.keys(t.required||{}),a=Object.keys(t.optional||{}),o=Object.keys(t.methods||{}),l=Object.keys(t.events||{}),i=mt;function s(e,n){const o={};for(const a of r){o[t.required[a]]=n[a]}for(const r of a){const e=n[r];if(void 0!==e){o[t.optional[r]]=e}}e.suppressFlushSync=!0,e.pubKeys(o),e.suppressFlushSync=!1}const c=m.forwardRef(((c,d)=>{const u=m.useMemo((()=>ie(e(),(e=>s(e,c)))),[]);var p;ut((()=>{s(u,c),u.resetSingletonSubs();for(const e of l)e in c&&u.singletonSubKey(t.events[e],c[e]);return()=>{u.resetSingletonSubs()}}),[c]),m.useImperativeHandle(d,(p=function(e){return o.reduce(((n,r)=>{const a=t.methods[r];return n[r]=t=>{e.pubKey(a,t)},n}),{})}(u),()=>p));const h=c.children;return m.createElement(i.Provider,{value:u},n?m.createElement(n,function(e,t){const n={},r={};let a=0;const o=e.length;for(;a<o;)r[e[a]]=1,a+=1;for(const l in t)Object.prototype.hasOwnProperty.call(r,l)||(n[l]=t[l]);return n}([...r,...a,...l],c),h):h)}));return c.displayName="Gurx Component",{Component:c,useEmitter:(e,t)=>{const n=m.useContext(i);ut((()=>n.subKey(e,t)),[t])},useEmitterValues:(...e)=>{const t=m.useContext(i),[n,r]=m.useState((()=>t.getKeyValues(e)));return ut((()=>null==t?void 0:t.subKeys(e,(n=>{const a=()=>{r(1===e.length?[n]:n)};t.suppressFlushSync,a()}))),[e]),n},usePubKeys:()=>m.useContext(i).pubKeys,usePublisher:e=>{const t=Q.useContext(i);return m.useCallback((n=>{t.pubKey(e,n)}),[e,t])}}}(function(...e){return()=>function(...e){const t=new Map,n=dt(),r=({id:a,constructor:o,dependencies:l})=>{if(t.has(a))return t.get(a);const i=o(n,l.map((t=>r(e.find((e=>e.id===t.id))))));return n.label(i),t.set(a,i),i};return e.forEach(r),n}(...e)}(gt,wt,xt,bt,vt,Tt,Mt),{required:{markdownSource:"markdownSource",headMarkdown:"headMarkdown",jsxComponentDescriptors:"jsxComponentDescriptors",sandpackConfig:"sandpackConfig",toolbarComponents:"toolbarComponents",markdownParseOptions:"markdownParseOptions",lexicalConvertOptions:"lexicalConvertOptions",lexicalNodes:"lexicalNodes"},optional:{editorRootElementRef:"editorRootElementRef",viewMode:"viewMode",linkAutocompleteSuggestions:"linkAutocompleteSuggestions",imageAutocompleteSuggestions:"imageAutocompleteSuggestions"},events:{onChange:"onChange"}},(({children:e})=>m.createElement("div",null,m.createElement(Vt,null),e))),Vt=()=>{const e=At("editor"),[t]=M.useLexicalComposerContext();return m.useEffect((()=>e(t)),[t,e]),null},Rt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4 9.55 18Z"}))),It=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M6.4 19 5 17.6l5.6-5.6L5 6.4 6.4 5l5.6 5.6L17.6 5 19 6.4 13.4 12l5.6 5.6-1.4 1.4-5.6-5.6L6.4 19Z"}))),Dt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M7 18V2h13v16H7Zm2-2h9V4H9v12Zm-6 6V6h2v14h11v2H3Z"}))),Pt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 19h1.4l8.625-8.625-1.4-1.4L5 17.6V19ZM19.3 8.925l-4.25-4.2L17.875 1.9 22.1 6.125l-2.8 2.8ZM3 21v-4.25l10.6-10.6 4.25 4.25L7.25 21H3Z"}))),Bt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m19.25 16.45-1.5-1.55a3.05 3.05 0 0 0 1.625-1.063A2.867 2.867 0 0 0 20 12c0-.833-.292-1.542-.875-2.125A2.893 2.893 0 0 0 17 9h-4V7h4c1.383 0 2.563.487 3.538 1.462C21.513 9.437 22 10.617 22 12c0 .95-.246 1.825-.737 2.625a4.79 4.79 0 0 1-2.013 1.825ZM15.85 13l-2-2H16v2h-.15Zm3.95 9.6L1.4 4.2l1.4-1.4 18.4 18.4-1.4 1.4ZM11 17H7c-1.383 0-2.562-.488-3.537-1.463C2.488 14.562 2 13.383 2 12c0-1.15.35-2.175 1.05-3.075.7-.9 1.6-1.492 2.7-1.775L7.6 9H7c-.833 0-1.542.292-2.125.875A2.893 2.893 0 0 0 4 12c0 .833.292 1.542.875 2.125A2.893 2.893 0 0 0 7 15h4v2Zm-3-4v-2h1.625l1.975 2H8Z"}))),$t=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 21V3h9v2H5v14h14v-7h2v9H3Zm6.7-5.3-1.4-1.4L17.6 5H14V3h7v7h-2V6.4l-9.3 9.3Z"}))),Zt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m12 15-5-5h10l-5 5Z"}))),Ut={editorRoot:"_editorRoot_1nlu3_43",editorWrapper:"_editorWrapper_1nlu3_121",nestedListItem:"_nestedListItem_1nlu3_125",toolbarRoot:"_toolbarRoot_1nlu3_129",toolbarModeSwitch:"_toolbarModeSwitch_1nlu3_150",toolbarToggleItem:"_toolbarToggleItem_1nlu3_159",toolbarGroupOfGroups:"_toolbarGroupOfGroups_1nlu3_169",toolbarToggleSingleGroup:"_toolbarToggleSingleGroup_1nlu3_173",toolbarButton:"_toolbarButton_1nlu3_187",toolbarNodeKindSelectContainer:"_toolbarNodeKindSelectContainer_1nlu3_216",toolbarButtonDropdownContainer:"_toolbarButtonDropdownContainer_1nlu3_217",toolbarNodeKindSelectTrigger:"_toolbarNodeKindSelectTrigger_1nlu3_230",toolbarButtonSelectTrigger:"_toolbarButtonSelectTrigger_1nlu3_231",toolbarNodeKindSelectItem:"_toolbarNodeKindSelectItem_1nlu3_264",toolbarNodeKindSelectDropdownArrow:"_toolbarNodeKindSelectDropdownArrow_1nlu3_287",contentEditable:"_contentEditable_1nlu3_291",sandpackWrapper:"_sandpackWrapper_1nlu3_299",frontmatterWrapper:"_frontmatterWrapper_1nlu3_303",frontmatterToggleButton:"_frontmatterToggleButton_1nlu3_313",frontmatterEditorTable:"_frontmatterEditorTable_1nlu3_321",iconButton:"_iconButton_1nlu3_339",frontmatterInput:"_frontmatterInput_1nlu3_345",primaryButton:"_primaryButton_1nlu3_360",linkDialogEditForm:"_linkDialogEditForm_1nlu3_370",linkDialogInputContainer:"_linkDialogInputContainer_1nlu3_376",linkDialogInputWrapper:"_linkDialogInputWrapper_1nlu3_382",linkDialogInput:"_linkDialogInput_1nlu3_376",linkDialogAutocompleteContainer:"_linkDialogAutocompleteContainer_1nlu3_412",linkDialogAnchor:"_linkDialogAnchor_1nlu3_457",linkDialogPopoverContent:"_linkDialogPopoverContent_1nlu3_471",tableColumnEditorPopoverContent:"_tableColumnEditorPopoverContent_1nlu3_471",dialogContent:"_dialogContent_1nlu3_471",linkDialogPreviewAnchor:"_linkDialogPreviewAnchor_1nlu3_485",tooltipContent:"_tooltipContent_1nlu3_507",actionButton:"_actionButton_1nlu3_519",primaryActionButton:"_primaryActionButton_1nlu3_525",tableEditor:"_tableEditor_1nlu3_534",toolCell:"_toolCell_1nlu3_545",tableColumnEditorTrigger:"_tableColumnEditorTrigger_1nlu3_562",tableRowEditorTrigger:"_tableRowEditorTrigger_1nlu3_562",addRowButton:"_addRowButton_1nlu3_562",addColumnButton:"_addColumnButton_1nlu3_562",tableColumnEditorToolbar:"_tableColumnEditorToolbar_1nlu3_596",toggleGroupRoot:"_toggleGroupRoot_1nlu3_608",tableToolsColumn:"_tableToolsColumn_1nlu3_625",leftAlignedCell:"_leftAlignedCell_1nlu3_633",rightAlignedCell:"_rightAlignedCell_1nlu3_637",centeredCell:"_centeredCell_1nlu3_641",dialogOverlay:"_dialogOverlay_1nlu3_669",overlayShow:"_overlayShow_1nlu3_1",contentShow:"_contentShow_1nlu3_1"};u.createCommand();const Ft=20;function Kt({initialUrl:e,onSubmit:t,onCancel:n,linkAutocompleteSuggestions:r}){const[a,o]=m.useState(r.slice(0,Ft)),{isOpen:l,getToggleButtonProps:i,getMenuProps:s,getInputProps:c,highlightedIndex:u,getItemProps:p,selectedItem:h}=V.useCombobox({initialInputValue:e,onInputValueChange({inputValue:e}){e=(null==e?void 0:e.toLowerCase())||"";const t=[];for(const n of r)if(n.toLowerCase().includes(e)&&(t.push(n),t.length>=Ft))break;o(t)},items:a,itemToString:e=>e??""}),g=m.useCallback((e=>{var n;"Escape"===e.key?null==(n=e.target.form)||n.reset():"Enter"!==e.key||l&&0!==a.length||(e.preventDefault(),t(e.target.value))}),[l,a,t]),E=c(),v={...E,onKeyDown:e=>{g(e),E.onKeyDown(e)}},f=l&&a.length>0;return m.createElement("form",{onSubmit:e=>{e.preventDefault(),t(h||"")},onReset:n,className:d(Ut.linkDialogEditForm)},m.createElement("div",{className:Ut.linkDialogInputContainer},m.createElement("div",{"data-visible-dropdown":f,className:Ut.linkDialogInputWrapper},m.createElement("input",{className:Ut.linkDialogInput,...v,autoFocus:!0,size:30,"data-editor-dialog":!0}),m.createElement("button",{"aria-label":"toggle menu",type:"button",...i()},m.createElement(Zt,null))),m.createElement("div",{className:Ut.linkDialogAutocompleteContainer},m.createElement("ul",{...s(),"data-visible":f},a.map(((e,t)=>m.createElement("li",{"data-selected":h===e,"data-highlighted":u===t,key:`${e}${t}`,...p({item:e,index:t})},e)))))),m.createElement(jt,{type:"submit",title:"Set URL","aria-label":"Set URL"},m.createElement(Rt,null)),m.createElement(jt,{type:"reset",title:"Cancel change","aria-label":"Cancel change"},m.createElement(It,null)))}function zt(){const[e]=Ot("editorRootElementRef"),t=At("onWindowChange"),[n,r,a]=Ot("linkDialogState","linkAutocompleteSuggestions","activeEditor"),o=At("updateLinkUrl"),l=At("cancelLinkEdit"),i=At("switchFromPreviewToLinkEdit"),s=At("removeLink"),c=At("applyLinkChanges");m.useEffect((()=>{const e=()=>{null==a||a.getEditorState().read((()=>{t(!0)}))};return window.addEventListener("resize",e),window.addEventListener("scroll",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e)}}),[a,t]);const[u,p]=m.useState(!1),h=null==n?void 0:n.rectangle,g=m.useCallback((e=>{o(e),c(!0)}),[c,o]),E="preview"===n.type&&n.url.startsWith("http");return m.createElement(X.Root,{open:"inactive"!==n.type},m.createElement(X.Anchor,{"data-visible":"edit"===n.type,className:Ut.linkDialogAnchor,style:{top:null==h?void 0:h.top,left:null==h?void 0:h.left,width:null==h?void 0:h.width,height:null==h?void 0:h.height}}),m.createElement(X.Portal,{container:null==e?void 0:e.current},m.createElement(X.Content,{className:d(Ut.linkDialogPopoverContent),sideOffset:5,onOpenAutoFocus:e=>e.preventDefault(),key:n.linkNodeKey},"edit"===n.type&&m.createElement(Kt,{initialUrl:n.url,onSubmit:g,onCancel:l.bind(null,!0),linkAutocompleteSuggestions:r}),"preview"===n.type&&m.createElement(m.Fragment,null,m.createElement("a",{className:Ut.linkDialogPreviewAnchor,href:n.url,...E?{target:"_blank",rel:"noreferrer"}:{},title:E?`Open ${n.url} in new window`:n.url},m.createElement("span",null,n.url),E&&m.createElement($t,null)),m.createElement(jt,{onClick:()=>i(!0),title:"Edit link URL","aria-label":"Edit link URL"},m.createElement(Pt,null)),m.createElement(ee.Provider,null,m.createElement(ee.Root,{open:u},m.createElement(ee.Trigger,{asChild:!0},m.createElement(jt,{title:"Copy to clipboard","aria-label":"Copy link URL",onClick:()=>{window.navigator.clipboard.writeText(n.url).then((()=>{p(!0),setTimeout((()=>p(!1)),1e3)}))}},u?m.createElement(Rt,null):m.createElement(Dt,null))),m.createElement(ee.Portal,{container:null==e?void 0:e.current},m.createElement(ee.Content,{className:d(Ut.tooltipContent),sideOffset:5},"Copied!",m.createElement(ee.Arrow,null))))),m.createElement(jt,{title:"Remove link","aria-label":"Remove link",onClick:()=>s(!0)},m.createElement(Bt,null))))))}const jt=m.forwardRef((({className:e,...t},n)=>m.createElement("button",{className:d(Ut.actionButton,e),ref:n,...t})));function qt(e){const t=u.$getSelection();if(!u.$isRangeSelection(t))return!1;const n=function(e){const t=e.getNodes();return 0===t.length?new Set([e.anchor.getNode().getParentOrThrow(),e.focus.getNode().getParentOrThrow()]):new Set(t.map((e=>u.$isElementNode(e)?e:e.getParentOrThrow())))}(t);let r=0;for(const a of n)if(k.$isListNode(a))r=Math.max(k.$getListDepth(a)+1,r);else if(k.$isListItemNode(a)){const e=a.getParent();if(1===(null==e?void 0:e.getChildren().length)){const t=null==e?void 0:e.getParent();if(k.$isListItemNode(t)&&1===t.getChildren().length)return!1}if(!k.$isListNode(e))throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");r=Math.max(k.$getListDepth(e)+1,r)}return r<=e}function Wt({maxDepth:e}){const[t]=M.useLexicalComposerContext();return m.useEffect((()=>t.registerCommand(u.INDENT_CONTENT_COMMAND,(()=>!qt(e??7)),u.COMMAND_PRIORITY_CRITICAL)),[t,e]),null}const Jt=()=>{return m.createElement(I.MarkdownShortcutPlugin,{transformers:(e=R.TRANSFORMERS,e.find((e=>e===R.CODE)).replace=(e,t,n)=>{const r=de({code:"",language:n?n[1]:"",meta:""});e.replace(r),setTimeout((()=>r.select()),80)},e)});var e};function Gt(e,t,n){const[r]=Ot("activeEditor"),a=At("activeEditorType"),o=m.useRef(null),l=m.useRef(!1),i=m.useRef(!1),s=m.useCallback((()=>{a({type:t,nodeKey:e})}),[e,a,t]),c=m.useCallback((t=>{var n,a,s,c;if("ArrowDown"===t.key){const t=null==(a=null==(n=null==o?void 0:o.current)?void 0:n.getCodemirror())?void 0:a.state;if(t){t.doc.length===t.selection.ranges[0].to&&(l.current?(null==r||r.update((()=>{var t,n;const r=u.$getNodeByKey(e);r.getNextSibling()?(null==(n=null==(t=null==o?void 0:o.current)?void 0:t.getCodemirror())||n.contentDOM.blur(),r.selectNext()):r.insertAfter(u.$createParagraphNode())})),l.current=!1):l.current=!0)}}else if("ArrowUp"===t.key){const t=null==(c=null==(s=null==o?void 0:o.current)?void 0:s.getCodemirror())?void 0:c.state;if(t){0===t.selection.ranges[0].from&&(i.current?(null==r||r.update((()=>{var t,n;const r=u.$getNodeByKey(e);r.getPreviousSibling()&&(null==(n=null==(t=null==o?void 0:o.current)?void 0:t.getCodemirror())||n.contentDOM.blur(),r.selectPrevious())})),i.current=!1):i.current=!0)}}else"Enter"===t.key&&t.stopPropagation()}),[r,e]);return m.useEffect((()=>{const e=o.current;return setTimeout((()=>{var t,n,r,a;null==(n=null==(t=null==e?void 0:e.getCodemirror())?void 0:t.contentDOM)||n.addEventListener("focus",s),null==(a=null==(r=null==e?void 0:e.getCodemirror())?void 0:r.contentDOM)||a.addEventListener("keydown",c)}),100),()=>{var t,n;null==(t=null==e?void 0:e.getCodemirror())||t.contentDOM.removeEventListener("focus",s),null==(n=null==e?void 0:e.getCodemirror())||n.contentDOM.removeEventListener("keydown",c)}}),[o,s,c,n]),o}const Yt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M10 17V7l5 5-5 5Z"}))),Qt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m12 15-5-5h10l-5 5Z"}))),Xt=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 17V6.5H4V5h4V4h4v1h4v1.5h-1V17H5Zm1.5-1.5h7v-9h-7v9ZM8 14h1.5V8H8v6Zm2.5 0H12V8h-1.5v6Z"}))),en=m.forwardRef((({className:e,autofocusIfEmpty:t,...n},r)=>(n.autoFocus=Boolean(!n.value&&t),m.createElement("input",{className:d(Ut.frontmatterInput,e),...n,ref:r})))),tn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m9.25 22-.4-3.2a3.79 3.79 0 0 1-.613-.3 8.266 8.266 0 0 1-.562-.375L4.7 19.375l-2.75-4.75 2.575-1.95a2.387 2.387 0 0 1-.025-.338v-.675c0-.108.008-.22.025-.337L1.95 9.375l2.75-4.75 2.975 1.25c.183-.133.375-.258.575-.375.2-.117.4-.217.6-.3l.4-3.2h5.5l.4 3.2c.217.083.42.183.612.3.192.117.38.242.563.375l2.975-1.25 2.75 4.75-2.575 1.95c.017.117.025.23.025.338v.675c0 .108-.017.22-.05.337l2.575 1.95-2.75 4.75-2.95-1.25a6.842 6.842 0 0 1-.575.375c-.2.117-.4.217-.6.3l-.4 3.2h-5.5Zm2.8-6.5c.967 0 1.792-.342 2.475-1.025A3.372 3.372 0 0 0 15.55 12c0-.967-.342-1.792-1.025-2.475A3.373 3.373 0 0 0 12.05 8.5c-.983 0-1.813.342-2.488 1.025A3.393 3.393 0 0 0 8.55 12c0 .967.337 1.792 1.012 2.475.676.683 1.505 1.025 2.488 1.025Zm0-2c-.417 0-.77-.146-1.063-.438A1.446 1.446 0 0 1 10.55 12c0-.417.146-.77.438-1.063a1.446 1.446 0 0 1 1.062-.437c.417 0 .77.146 1.063.438.291.291.437.645.437 1.062 0 .417-.146.77-.438 1.063a1.447 1.447 0 0 1-1.062.437ZM11 20h1.975l.35-2.65a5.61 5.61 0 0 0 1.438-.588c.441-.258.845-.57 1.212-.937l2.475 1.025.975-1.7-2.15-1.625c.083-.233.142-.48.175-.738a6.153 6.153 0 0 0 0-1.575 3.535 3.535 0 0 0-.175-.737l2.15-1.625-.975-1.7-2.475 1.05a5.556 5.556 0 0 0-1.213-.962 5.607 5.607 0 0 0-1.437-.588L13 4h-1.975l-.35 2.65c-.517.133-.996.33-1.438.587a6.015 6.015 0 0 0-1.212.938L5.55 7.15l-.975 1.7 2.15 1.6c-.083.25-.142.5-.175.75a6.122 6.122 0 0 0 0 1.575c.033.25.092.5.175.75l-2.15 1.625.975 1.7 2.475-1.05c.367.383.77.704 1.212.962.442.259.921.455 1.438.588L11 20Z"}))),nn=m.forwardRef(((e,t)=>m.createElement(X.Content,{...e,className:"",ref:t}))),rn=m.forwardRef(((e,t)=>m.createElement(X.Trigger,{...e,className:"",ref:t})));const an=({attributes:e,componentName:t,onSubmit:n})=>{const[r,a]=m.useState(!1),o=m.useCallback((e=>{n(e),a(!1)}),[n]);return m.createElement(X.Root,{open:r,onOpenChange:e=>a(e)},m.createElement(rn,null,m.createElement(tn,null)),m.createElement(X.Portal,null,m.createElement(nn,null,m.createElement(on,{attributes:e,componentName:t,onSubmit:o}))))},on=({attributes:e,componentName:t,onSubmit:n})=>{const[r]=Ot("jsxComponentDescriptors"),a=r.find((e=>e.name===t)),[o]=M.useLexicalComposerContext(),{register:l,handleSubmit:i}=B.useForm({defaultValues:e.reduce(((e,t)=>(e[t.name]=t.value,e)),{})});return m.createElement("form",{onSubmit:i((e=>{o.update((()=>{n(e)}))}))},m.createElement("table",null,m.createElement("thead",null,m.createElement("tr",null,m.createElement("th",null,"Attribute"),m.createElement("th",null,"Value"))),m.createElement("tbody",null,a.props.map((e=>m.createElement("tr",{key:e.name},m.createElement("td",null," ",e.name," "),m.createElement("td",null,m.createElement("input",{...l(e.name)}))))))),m.createElement("button",{type:"submit"},"Submit"))},ln=({onChange:e,snippetFileName:t})=>{const{sandpack:n}=D.useSandpack();return e(n.files[t].code),null};const sn=e=>{const t={type:"root",children:e.mdastChildren},n=U.raw(Z.toHast(t,{allowDangerousHtml:!0})),r=F.sanitize(n),a=K.toHtml(r);return m.createElement("span",{dangerouslySetInnerHTML:{__html:a||"&nbsp;"}})},cn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M6 14c-.55 0-1.02-.196-1.412-.588A1.926 1.926 0 0 1 4 12c0-.55.196-1.02.588-1.412A1.926 1.926 0 0 1 6 10c.55 0 1.02.196 1.412.588.392.391.588.862.588 1.412 0 .55-.196 1.02-.588 1.412A1.926 1.926 0 0 1 6 14Zm6 0c-.55 0-1.02-.196-1.412-.588A1.926 1.926 0 0 1 10 12c0-.55.196-1.02.588-1.412A1.926 1.926 0 0 1 12 10c.55 0 1.02.196 1.412.588.392.391.588.862.588 1.412 0 .55-.196 1.02-.588 1.412A1.926 1.926 0 0 1 12 14Zm6 0c-.55 0-1.02-.196-1.413-.588A1.926 1.926 0 0 1 16 12c0-.55.196-1.02.587-1.412A1.926 1.926 0 0 1 18 10c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412 0 .55-.196 1.02-.587 1.412A1.926 1.926 0 0 1 18 14Z"}))),dn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 17v-1.5h14V17H3Zm0-3.125v-1.5h10v1.5H3Zm0-3.125v-1.5h14v1.5H3Zm0-3.125v-1.5h10v1.5H3ZM3 4.5V3h14v1.5H3Z"}))),un=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 17v-1.5h14V17H3Zm3-3.125v-1.5h8v1.5H6ZM3 10.75v-1.5h14v1.5H3Zm3-3.125v-1.5h8v1.5H6ZM3 4.5V3h14v1.5H3Z"}))),mn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 17v-1.5h14V17H3Zm4-3.125v-1.5h10v1.5H7ZM3 10.75v-1.5h14v1.5H3Zm4-3.125v-1.5h10v1.5H7ZM3 4.5V3h14v1.5H3Z"}))),pn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 20h20v20H0z",transform:"rotate(-90 0 20)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M15.75 4.5H13v2.75h-1.5V4.5H8.75V3h2.75V.25H13V3h2.75v1.5ZM13 17H5V3h2.25v1.5H6.5v11h5V8.75H13V17Z"}))),hn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z",transform:"matrix(0 -1 -1 0 20 20)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M4.25 4.5H7v2.75h1.5V4.5h2.75V3H8.5V.25H7V3H4.25v1.5ZM7 17h8V3h-2.25v1.5h.75v11h-5V8.75H7V17Z"}))),gn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M6.5 17a1.45 1.45 0 0 1-1.06-.44A1.445 1.445 0 0 1 5 15.5v-10H4V4h4V3h4v1h4v1.5h-1v9.991c0 .423-.147.78-.44 1.072A1.45 1.45 0 0 1 13.5 17h-7Zm7-11.5h-7v10h7v-10ZM8 14h1.5V7H8v7Zm2.5 0H12V7h-1.5v7Z"}))),En=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z",transform:"matrix(-1 0 0 1 20 0)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M4.5 16.75V14h2.75v-1.5H4.5V9.75H3v2.75H.25V14H3v2.75h1.5ZM17 14V6H3v2.25h1.5V7.5h11v5H8.75V14H17Z"}))),vn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M20 20h20v20H20z",transform:"rotate(180 20 20)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M4.5 3.25V6h2.75v1.5H4.5v2.75H3V7.5H.25V6H3V3.25h1.5ZM17 6v8H3v-2.25h1.5v.75h11v-5H8.75V6H17Z"}))),fn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M20 20h20v20H20z",transform:"rotate(180 20 20)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M10.5 3.25V6h2.75v1.5H10.5v2.75H9V7.5H6.25V6H9V3.25h1.5ZM17 6v8H3V6h2.5v1.5h-1v5h11v-5H14V6h3Z"}))),wn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"currentColor",viewBox:"0 0 20 20",...e},Q.createElement("mask",{id:"a",width:20,height:20,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h20v20H0z",transform:"matrix(0 -1 -1 0 20 20)"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3.25 10.5H6v2.75h1.5V10.5h2.75V9H7.5V6.25H6V9H3.25v1.5ZM6 17h8V3H6v2.5h1.5v-1h5v11h-5V14H6v3Z"}))),kn=()=>{const[e]=Ot("historyState");return m.createElement(H.HistoryPlugin,{externalHistoryState:e})},xn={center:Ut.centeredCell,left:Ut.leftAlignedCell,right:Ut.rightAlignedCell},yn=({align:e,...t})=>{const[n,r]=t.activeCellTuple,a=n&&n[0]===t.colIndex&&n[1]===t.rowIndex,o=xn[e||"left"];return m.createElement("td",{className:o,"data-active":a,onClick:()=>{r([t.colIndex,t.rowIndex])}},a?m.createElement(Cn,{...t}):m.createElement(sn,{mdastChildren:t.contents}))},Cn=({activeCellTuple:e,parentEditor:t,lexicalTable:n,contents:o,colIndex:l,rowIndex:i})=>{const[c,d,p,h]=Ot("markdownParseOptions","lexicalConvertOptions","jsxComponentDescriptors","lexicalNodes"),[g]=m.useState((()=>{let r=!1;const a=u.createEditor({nodes:h,theme:we});function s(o){r||(r=!0,a.getEditorState().read((()=>{const e=je({root:u.$getRoot(),jsxComponentDescriptors:p,...d});t.update((()=>{n.updateCellContents(l,i,e.children[0].children)}))})),e[1](o))}return a.registerCommand(u.KEY_TAB_COMMAND,(e=>{e.preventDefault();return s(e.shiftKey?[l-1,i]:[l+1,i]),!0}),u.COMMAND_PRIORITY_CRITICAL),a.registerCommand(u.KEY_ENTER_COMMAND,(e=>{null==e||e.preventDefault();return s((null==e?void 0:e.shiftKey)?[l,i-1]:[l,i+1]),!0}),u.COMMAND_PRIORITY_CRITICAL),a.registerCommand(u.BLUR_COMMAND,(e=>{const t=e.relatedTarget;return void 0===(null==t?void 0:t.dataset.editorDialog)&&(s(null),!0)}),u.COMMAND_PRIORITY_CRITICAL),a.registerRootListener((e=>{e&&a.focus()})),a.update((()=>{rt({root:u.$getRoot(),mdastRoot:{type:"root",children:[{type:"paragraph",children:o}]},visitors:c.visitors})})),a}));return m.createElement($.LexicalNestedComposer,{initialEditor:g},m.createElement(s.RichTextPlugin,{contentEditable:m.createElement(r.ContentEditable,{autoFocus:!0}),placeholder:m.createElement("div",null),ErrorBoundary:a}),m.createElement(kn,null))},_n=({parentEditor:e,highlightedCoordinates:t,align:n,lexicalTable:r,colIndex:a,setActiveCellWithBoundaries:o})=>{const[l]=Ot("editorRootElementRef"),i=m.useCallback((t=>{e.update((()=>{r.insertColumnAt(t)})),o([t,0])}),[e,r,o]),s=m.useCallback((t=>{e.update((()=>{r.deleteColumnAt(t)}))}),[e,r]),c=m.useCallback(((t,n)=>{e.update((()=>{r.setColumnAlign(t,n)}))}),[e,r]);return m.createElement(X.Root,null,m.createElement(X.PopoverTrigger,{className:Ut.tableColumnEditorTrigger,"data-active":t[0]===a+1,title:"Column menu"},m.createElement(cn,null)),m.createElement(X.Portal,{container:null==l?void 0:l.current},m.createElement(X.PopoverContent,{className:d(Ut.tableColumnEditorPopoverContent),onOpenAutoFocus:e=>e.preventDefault(),sideOffset:5,side:"top"},m.createElement(te.Root,{className:Ut.tableColumnEditorToolbar},m.createElement(te.ToggleGroup,{className:Ut.toggleGroupRoot,onValueChange:e=>{c(a,e)},value:n||"left",type:"single","aria-label":"Text alignment"},m.createElement(te.ToggleItem,{value:"left",title:"Align left"},m.createElement(dn,null)),m.createElement(te.ToggleItem,{value:"center",title:"Align center"},m.createElement(un,null)),m.createElement(te.ToggleItem,{value:"right",title:"Align right"},m.createElement(mn,null))),m.createElement(te.Separator,null),m.createElement(te.Button,{onClick:i.bind(null,a),title:"Insert a column to the left of this one"},m.createElement(pn,null)),m.createElement(te.Button,{onClick:i.bind(null,a+1),title:"Insert a column to the right of this one"},m.createElement(hn,null)),m.createElement(te.Button,{onClick:s.bind(null,a),title:"Delete this column"},m.createElement(gn,null))))))},bn=({parentEditor:e,highlightedCoordinates:t,lexicalTable:n,rowIndex:r,setActiveCellWithBoundaries:a})=>{const[o]=Ot("editorRootElementRef"),l=m.useCallback((t=>{e.update((()=>{n.insertRowAt(t)})),a([0,t])}),[e,n,a]),i=m.useCallback((t=>{e.update((()=>{n.deleteRowAt(t)}))}),[e,n]);return m.createElement(X.Root,null,m.createElement(X.PopoverTrigger,{className:Ut.tableColumnEditorTrigger,"data-active":t[1]===r},m.createElement(cn,null)),m.createElement(X.Portal,{container:null==o?void 0:o.current},m.createElement(X.PopoverContent,{className:d(Ut.tableColumnEditorPopoverContent),onOpenAutoFocus:e=>e.preventDefault(),sideOffset:5,side:"bottom"},m.createElement(te.Root,{className:Ut.tableColumnEditorToolbar},m.createElement(te.Button,{onClick:l.bind(null,r),title:"Insert a row above this one"},m.createElement(En,null)),m.createElement(te.Button,{onClick:l.bind(null,r+1),title:"Insert a row below this one"},m.createElement(vn,null)),m.createElement(te.Button,{onClick:i.bind(null,r),title:"Delete this row"},m.createElement(gn,null))))))};function Nn({oldText:e,newText:t}){const n=W.formatLines(W.diffLines(e,t),{context:3});if(""===n.trim())return m.createElement("div",null,"No changes");const[r]=q.parseDiff(n,{nearbySequences:"zip"});return m.createElement(q.Diff,{viewType:"split",diffType:"modify",hunks:r.hunks||[]},(e=>e.map((e=>m.createElement(q.Hunk,{key:e.content,hunk:e})))))}function Tn(){const[e,t]=Ot("markdownSource","headMarkdown");return m.createElement(Nn,{oldText:t,newText:e})}const Sn=({children:e})=>{const[t]=Ot("viewMode");return m.createElement("div",null,m.createElement("div",{style:{display:"editor"===t?"block":"none"}},e),"diff"===t?m.createElement(Tn,null):null,"markdown"===t?m.createElement(Mn,null):null)},Mn=()=>{const[e]=Ot("markdownSource"),t=At("markdownSource"),n=m.useRef(null);return m.createElement("div",null,m.createElement(D.SandpackProvider,null,m.createElement(D.CodeEditor,{showLineNumbers:!0,additionalLanguages:[{name:"markdown",extensions:["md"],language:j.markdown()}],initMode:"lazy",filePath:"file.md",code:e,onCodeUpdate:t,ref:n})))},Ln=m.forwardRef((({children:e,className:t,...n},r)=>m.createElement(ne.Item,{...n,ref:r,className:d(t,Ut.toolbarNodeKindSelectItem)},m.createElement(ne.ItemText,null,e)))),Hn=({placeholder:e})=>m.createElement(ne.Trigger,{"aria-label":e,className:Ut.toolbarNodeKindSelectTrigger},m.createElement(ne.Value,{placeholder:e}),m.createElement(ne.Icon,{className:Ut.toolbarNodeKindSelectDropdownArrow},m.createElement(Zt,null))),An=({children:e,className:t=Ut.toolbarNodeKindSelectContainer})=>{const[n]=Ot("editorRootElementRef");return m.createElement(ne.Portal,{container:null==n?void 0:n.current},m.createElement(ne.Content,{className:t,onCloseAutoFocus:e=>e.preventDefault(),position:"popper"},m.createElement(ne.Viewport,null,e)))},On=({children:e,title:t,className:n})=>m.createElement(ne.Trigger,{className:d(Ut.toolbarButtonSelectTrigger,n),title:t},e,m.createElement(ne.Icon,{className:Ut.toolbarNodeKindSelectDropdownArrow},m.createElement(Zt,null)));function Vn(){const[e,t]=Ot("activeEditorType","activeEditor"),n=m.useMemo((()=>{let n;return t.getEditorState().read((()=>{const t=u.$getNodeByKey(e.nodeKey);n=t.getLanguage()})),n}),[t,e]);return m.createElement(ne.Root,{value:n,onValueChange:n=>{t.update((()=>{const t=u.$getNodeByKey(e.nodeKey);t.setLanguage(n),setTimeout((()=>{t.select()}),80)}))}},m.createElement(Hn,{placeholder:"Language"}),m.createElement(An,null,m.createElement(Ln,{value:"js"},"JavaScript"),m.createElement(Ln,{value:"ts"},"TypeScript"),m.createElement(Ln,{value:"css"},"CSS")))}const Rn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 21V6H4V4h5V3h6v1h5v2h-1v15H5Zm2-2h10V6H7v13Zm2-2h2V8H9v9Zm4 0h2V8h-2v9Z"}))),In=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m8 18-6-6 6-6 1.425 1.425-4.6 4.6L9.4 16.6 8 18Zm8 0-1.425-1.425 4.6-4.6L14.6 7.4 16 6l6 6-6 6Z"}))),Dn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"m5 15.95 6 3.475v-6.85L5 9.1v6.85Zm8 3.475 6-3.475V9.1l-6 3.475v6.85Zm-6.925-12L12 10.85l5.925-3.425L12 4 6.075 7.425ZM3 17.125V6.875L12 1.7l9 5.175v10.25L12 22.3l-9-5.175Z"}))),Pn=e=>Q.createElement("svg",{width:25,height:24,viewBox:"0 0 25 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Q.createElement("mask",{id:"mask0_318_257",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:0,y:0,width:25,height:24},Q.createElement("rect",{x:.929688,width:24,height:24,fill:"#D9D9D9"})),Q.createElement("g",{mask:"url(#mask0_318_257)"},Q.createElement("path",{d:"M12.4297 12H14.4297V10H16.4297V8H14.4297V6H12.4297V8H10.4297V10H12.4297V12ZM10.4297 16H16.4297V14H10.4297V16ZM5.92969 20V2H14.9297L20.9297 8V20H5.92969ZM7.92969 18H18.9297V9L13.9297 4H7.92969V18Z",fill:"currentColor"}))),Bn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M6.8 19V5h5.525c1.083 0 2.083.333 3 1 .917.667 1.375 1.592 1.375 2.775 0 .85-.192 1.504-.575 1.962-.383.459-.742.788-1.075.988.417.183.88.525 1.388 1.025.508.5.762 1.25.762 2.25 0 1.483-.542 2.521-1.625 3.113-1.083.591-2.1.887-3.05.887H6.8Zm3.025-2.8h2.6c.8 0 1.287-.204 1.462-.613.175-.408.263-.704.263-.887 0-.183-.088-.48-.263-.888-.175-.408-.687-.612-1.537-.612H9.825v3Zm0-5.7h2.325c.55 0 .95-.142 1.2-.425a1.4 1.4 0 0 0 .375-.95c0-.4-.142-.725-.425-.975-.283-.25-.65-.375-1.1-.375H9.825V10.5Z"}))),$n=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 19v-2.5h4l3-9H8V5h10v2.5h-3.5l-3 9H15V19H5Z"}))),Zn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M9 19v-2h12v2H9Zm0-6v-2h12v2H9Zm0-6V5h12v2H9ZM5 20a1.93 1.93 0 0 1-1.413-.587A1.928 1.928 0 0 1 3 18c0-.55.196-1.021.587-1.413A1.928 1.928 0 0 1 5 16c.55 0 1.02.196 1.412.587.392.392.588.863.588 1.413s-.196 1.021-.588 1.413A1.925 1.925 0 0 1 5 20Zm0-6c-.55 0-1.021-.196-1.413-.588A1.925 1.925 0 0 1 3 12c0-.55.196-1.021.587-1.413A1.928 1.928 0 0 1 5 10c.55 0 1.02.196 1.412.587.392.392.588.863.588 1.413s-.196 1.02-.588 1.412A1.923 1.923 0 0 1 5 14Zm0-6c-.55 0-1.021-.196-1.413-.588A1.925 1.925 0 0 1 3 6c0-.55.196-1.02.587-1.412A1.927 1.927 0 0 1 5 4c.55 0 1.02.196 1.412.588C6.804 4.979 7 5.45 7 6c0 .55-.196 1.02-.588 1.412A1.923 1.923 0 0 1 5 8Z"}))),Un=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 22v-1.5h2.5v-.75H4v-1.5h1.5v-.75H3V16h4v2.25L6 19l1 .75V22H3Zm0-7v-3.75h2.5v-.75H3V9h4v3.75H4.5v.75H7V15H3Zm1.5-7V3.5H3V2h3v6H4.5ZM9 19v-2h12v2H9Zm0-6v-2h12v2H9Zm0-6V5h12v2H9Z"}))),Fn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 21v-2h14v2H5Zm7-4c-1.683 0-2.992-.525-3.925-1.575-.933-1.05-1.4-2.442-1.4-4.175V3H9.25v8.4c0 .933.233 1.692.7 2.275.467.583 1.15.875 2.05.875.9 0 1.583-.292 2.05-.875.467-.583.7-1.342.7-2.275V3h2.575v8.25c0 1.733-.467 3.125-1.4 4.175C14.992 16.475 13.683 17 12 17Z"}))),Kn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 21v-6h2v4h4v2H3Zm12 0v-2h4v-4h2v6h-6Zm-6.4-5.4L5 12l3.6-3.6L10 9.825 7.825 12 10 14.175 8.6 15.6Zm6.8 0L14 14.175 16.175 12 14 9.825 15.4 8.4 19 12l-3.6 3.6ZM3 9V3h6v2H5v4H3Zm16 0V5h-4V3h6v6h-2Z"}))),zn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M5 7h4v2H5z"}),Q.createElement("path",{d:"M5 7h4v2H5zm0 7h4v2H5z"}),Q.createElement("path",{d:"M5 14h4v2H5zm5-7h4v2h-4z"}),Q.createElement("path",{d:"M10 7h4v2h-4zm0 7h4v2h-4z"}),Q.createElement("path",{d:"M10 14h4v2h-4zm5-7h4v2h-4z"}),Q.createElement("path",{d:"M15 7h4v2h-4zm0 7h4v2h-4z"}),Q.createElement("path",{d:"M15 14h4v2h-4z"}))),jn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M4 13v-2h16v2H4Z"}))),qn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M11 17H7c-1.383 0-2.562-.488-3.537-1.463C2.488 14.562 2 13.383 2 12s.488-2.563 1.463-3.538C4.438 7.487 5.617 7 7 7h4v2H7c-.833 0-1.542.292-2.125.875A2.893 2.893 0 0 0 4 12c0 .833.292 1.542.875 2.125A2.893 2.893 0 0 0 7 15h4v2Zm-3-4v-2h8v2H8Zm5 4v-2h4c.833 0 1.542-.292 2.125-.875A2.893 2.893 0 0 0 20 12c0-.833-.292-1.542-.875-2.125A2.893 2.893 0 0 0 17 9h-4V7h4c1.383 0 2.563.487 3.538 1.462C21.513 9.437 22 10.617 22 12s-.487 2.562-1.462 3.537C19.563 16.512 18.383 17 17 17h-4Z"}))),Wn=e=>Q.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Q.createElement("mask",{id:"mask0_46_56",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:0,y:0,width:24,height:24},Q.createElement("rect",{width:24,height:24,fill:"#D9D9D9"})),Q.createElement("g",{mask:"url(#mask0_46_56)"},Q.createElement("path",{d:"M19 19L14 14L15.4 12.575L18 15.175V5H20V15.175L22.6 12.575L24 14L19 19Z",fill:"currentColor"}),Q.createElement("path",{d:"M13 19H10.5V9L6.5 15L2.5 9V19H0V5H2.5L6.5 11L10.5 5H13V19Z",fill:"currentColor"}))),Jn=e=>Q.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Q.createElement("mask",{id:"mask0_318_249",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:0,y:0,width:24,height:24},Q.createElement("rect",{width:24,height:24,fill:"#D9D9D9"})),Q.createElement("g",{mask:"url(#mask0_318_249)"},Q.createElement("path",{d:"M5 21V19H19V21H5Z",fill:"currentColor"}),Q.createElement("path",{d:"M6.80005 17V3H12.325C13.4084 3 14.4084 3.33333 15.325 4C16.2417 4.66667 16.7001 5.59167 16.7001 6.775C16.7001 7.625 16.5084 8.279 16.125 8.737C15.7417 9.19567 15.3834 9.525 15.05 9.725C15.4667 9.90833 15.9294 10.25 16.438 10.75C16.946 11.25 17.2001 12 17.2001 13C17.2001 14.4833 16.6584 15.521 15.575 16.113C14.4917 16.7043 13.475 17 12.525 17H6.80005ZM9.82505 14.2H12.425C13.225 14.2 13.7124 13.9957 13.887 13.587C14.0624 13.179 14.15 12.8833 14.15 12.7C14.15 12.5167 14.0624 12.2207 13.887 11.812C13.7124 11.404 13.2 11.2 12.35 11.2H9.82505V14.2ZM9.82505 8.5H12.15C12.7 8.5 13.1 8.35833 13.35 8.075C13.6 7.79167 13.725 7.475 13.725 7.125C13.725 6.725 13.5834 6.4 13.3 6.15C13.0167 5.9 12.65 5.775 12.2 5.775H9.82505V8.5Z",fill:"currentColor"}))),Gn=e=>Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"currentColor",viewBox:"0 0 24 24",...e},Q.createElement("mask",{id:"a",width:24,height:24,x:0,y:0,maskUnits:"userSpaceOnUse",style:{maskType:"alpha"}},Q.createElement("path",{d:"M0 0h24v24H0z"})),Q.createElement("g",{mask:"url(#a)"},Q.createElement("path",{d:"M3 21V3h18v18H3ZM5 9h14V5H5v4Zm5.325 5h3.35v-3h-3.35v3Zm0 5h3.35v-3h-3.35v3ZM5 14h3.325v-3H5v3Zm10.675 0H19v-3h-3.325v3ZM5 19h3.325v-3H5v3Zm10.675 0H19v-3h-3.325v3Z"}),Q.createElement("path",{d:"M8.325 9h2V5h-2v4Zm5.35 0h2V5h-2v4Z"}))),Yn=()=>{const[e]=Ot("currentBlockType"),t=At("applyBlockType");return m.createElement(ne.Root,{value:e||"",onValueChange:t},m.createElement(Hn,{placeholder:"Block type"}),m.createElement(An,null,m.createElement(Ln,{value:"paragraph"},"Paragraph"),m.createElement(Ln,{value:"quote"},"Quote"),m.createElement(ne.Separator,null),m.createElement(Ln,{value:"h1"},"Heading 1"),m.createElement(Ln,{value:"h2"},"Heading 2"),m.createElement(Ln,{value:"h3"},"Heading 3"),m.createElement(Ln,{value:"h4"},"Heading 4"),m.createElement(Ln,{value:"h5"},"Heading 5"),m.createElement(Ln,{value:"h6"},"Heading 6"),m.createElement(ne.Separator,null),m.createElement(Ln,{value:"info"},"Info")))},Qn=e=>Q.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Q.createElement("mask",{id:"mask0_343_38",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:0,y:0,width:24,height:24},Q.createElement("rect",{width:24,height:24,fill:"#D9D9D9"})),Q.createElement("g",{mask:"url(#mask0_343_38)"},Q.createElement("path",{d:"M3 21V3H14V5H5V19H19V10H21V21H3ZM17 9V7H15V5H17V3H19V5H21V7H19V9H17ZM6 17H18L14.25 12L11.25 16L9 13L6 17Z",fill:"currentColor"}))),Xn=m.forwardRef(((e,t)=>{const[n,r]=Ot("editorRootElementRef","imageAutocompleteSuggestions"),[a,o]=m.useState(!1),l=At("insertImage"),i=m.useCallback((e=>{l(e),o(!1)}),[l]);return m.createElement(re.Root,{open:a,onOpenChange:o},m.createElement(re.Trigger,{asChild:!0},m.createElement(te.Button,{className:Ut.toolbarButton,...e,ref:t},m.createElement(Qn,null))),m.createElement(re.Portal,{container:n.current},m.createElement(re.Overlay,{className:Ut.dialogOverlay}),m.createElement(re.Content,{className:Ut.dialogContent},m.createElement(er,{initialUrl:"",onSubmit:i,imageAutocompleteSuggestions:r}))))}));u.createCommand();const er=({initialUrl:e,onSubmit:t,imageAutocompleteSuggestions:n})=>{const[r,a]=m.useState(n.slice(0,20)),{isOpen:o,getToggleButtonProps:l,getMenuProps:i,getInputProps:s,highlightedIndex:c,getItemProps:u,selectedItem:p}=V.useCombobox({initialInputValue:e,onInputValueChange({inputValue:e}){e=(null==e?void 0:e.toLowerCase())||"";const t=[];for(const r of n)if(r.toLowerCase().includes(e)&&(t.push(r),t.length>=20))break;a(t)},items:r,itemToString:e=>e??""}),h=m.useCallback((e=>{var n;"Escape"===e.key?null==(n=e.target.form)||n.reset():"Enter"!==e.key||o&&0!==r.length||(e.preventDefault(),t(e.target.value))}),[o,r,t]),g=s(),E={...g,onKeyDown:e=>{h(e),g.onKeyDown(e)}},v=o&&r.length>0;return m.createElement("form",{onSubmit:e=>{e.preventDefault(),t(p||"")},className:d(Ut.linkDialogEditForm)},m.createElement("div",{className:Ut.linkDialogInputContainer},m.createElement("div",{"data-visible-dropdown":v,className:Ut.linkDialogInputWrapper},m.createElement("input",{placeholder:"Paste or select an image url",className:Ut.linkDialogInput,...E,autoFocus:!0,size:30,"data-editor-dialog":!0}),m.createElement("button",{"aria-label":"toggle menu",type:"button",...l()},m.createElement(Zt,null))),m.createElement("div",{className:Ut.linkDialogAutocompleteContainer},m.createElement("ul",{...i(),"data-visible":v},r.map(((e,t)=>m.createElement("li",{"data-selected":p===e,"data-highlighted":c===t,key:`${e}${t}`,...u({item:e,index:t})},e)))))),m.createElement(tr,{type:"submit",title:"Insert image","aria-label":"Insert image",className:Ut.primaryActionButton},m.createElement(Rt,null)),m.createElement(re.Close,{className:Ut.actionButton},m.createElement(It,null)))},tr=m.forwardRef((({className:e,...t},n)=>m.createElement("button",{className:d(Ut.actionButton,e),ref:n,...t}))),nr=m.forwardRef((({className:e,...t},n)=>m.createElement(te.ToggleItem,{className:d(e,Ut.toolbarToggleItem),...t,ref:n}))),rr=m.forwardRef(((e,t)=>m.createElement(te.Button,{className:Ut.toolbarButton,...e,ref:t}))),ar=m.forwardRef((({children:e,className:t,...n},r)=>m.createElement(te.ToggleGroup,{...n,type:"single",ref:r,className:d(Ut.toolbarToggleSingleGroup,t)},e))),or=m.forwardRef((({on:e,children:t,...n},r)=>m.createElement(ar,{...n,value:e?"on":"off",ref:r},m.createElement(nr,{value:"on"},t)))),lr=({children:e})=>m.createElement("div",{className:Ut.toolbarGroupOfGroups},e),ir=te.ToolbarSeparator,sr=()=>{const[e]=Ot("currentFormat","currentListType"),t=At("applyFormat");return m.createElement(lr,null,m.createElement(or,{"aria-label":"Bold",on:0!=(1&e),onValueChange:t.bind(null,"bold")},m.createElement(Bn,null)),m.createElement(or,{"aria-label":"Italic",on:0!=(2&e),onValueChange:t.bind(null,"italic")},m.createElement($n,null)),m.createElement(or,{"aria-label":"Underline",on:0!=(8&e),onValueChange:t.bind(null,"underline")},m.createElement(Fn,{style:{transform:"translateY(2px)"}})))},cr=()=>{const[e]=Ot("currentListType"),t=At("applyListType");return m.createElement(lr,null,m.createElement(ar,{"aria-label":"List type",onValueChange:t,value:e||"",onFocus:e=>e.preventDefault()},m.createElement(nr,{value:"bullet","aria-label":"Bulleted list"},m.createElement(Zn,null)),m.createElement(nr,{value:"number","aria-label":"Numbered list"},m.createElement(Un,null))))},dr=()=>{const e=At("openLinkEditDialog");return m.createElement(rr,{onClick:e.bind(null,!0)},m.createElement(qn,null))},ur=()=>{const e=At("insertTable");return m.createElement(rr,{onClick:e.bind(null,!0)},m.createElement(Gn,null))},mr=()=>{const e=At("insertCodeBlock");return m.createElement(rr,{onClick:e.bind(null,!0)},m.createElement(Kn,null))},pr=()=>{const e=At("insertSandpack"),[t]=Ot("sandpackConfig");return m.createElement(m.Fragment,null,1===t.presets.length?m.createElement(rr,{onClick:e.bind(null,"")},m.createElement(Dn,null)):m.createElement(ne.Root,{value:"",onValueChange:e},m.createElement(On,{title:"Insert live code snippet"},m.createElement(Dn,null)),m.createElement(An,{className:Ut.toolbarButtonDropdownContainer},t.presets.map((e=>m.createElement(Ln,{key:e.name,value:e.meta},e.label))))))},hr=()=>{const e=At("insertFrontmatter");return m.createElement(rr,{onClick:e.bind(null,!0)},m.createElement(zn,null))},gr=()=>{const[e]=Ot("viewMode","activeEditorType"),t=At("viewMode");return m.createElement(ar,{"aria-label":"View Mode",onValueChange:e=>{""!==e&&t(e)},value:e,className:Ut.toolbarModeSwitch},m.createElement(nr,{value:"editor","aria-label":"Rich text",title:"Rich text"},m.createElement(Jn,null)),m.createElement(nr,{value:"diff","aria-label":"View diff",title:"Diff"},m.createElement(Pn,null)),m.createElement(nr,{value:"markdown","aria-label":"View Markdown",title:"Markdown"},m.createElement(Wn,null)))},Er={BlockTypeSelect:Yn,BoldItalicUnderlineButtons:sr,CodeBlockButton:mr,FrontmatterButton:hr,GroupGroup:lr,HorizontalRuleIcon:jn,LinkButton:dr,ListButtons:cr,SandpackButton:pr,TableButton:ur,ToggleItem:nr,ToggleSingleGroup:ar,ToggleSingleGroupWithItem:or,ToolbarButton:rr,ToolbarSeparator:ir,ImageButton:Xn},vr=()=>{const[e,t]=Ot("activeEditorType","viewMode");return m.createElement(te.Root,{className:Ut.toolbarRoot,"aria-label":"Formatting options"},"editor"===t&&("lexical"===e.type?m.createElement(kr,null):"codeblock"===e.type?m.createElement(fr,null):m.createElement(wr,null)),m.createElement(ir,null),m.createElement(gr,null))},fr=()=>{const[e,t]=Ot("activeEditor","activeEditorType");return m.createElement(m.Fragment,null,m.createElement(Vn,null),m.createElement(rr,{onClick:()=>{e.update((()=>{const e=u.$getNodeByKey(t.nodeKey);e.selectNext(),e.remove()}))}},m.createElement(Rn,null)))},wr=()=>{const[e,t]=Ot("activeEditor","activeEditorType");return m.createElement(m.Fragment,null,m.createElement(rr,{onClick:()=>{e.update((()=>{const e=u.$getNodeByKey(t.nodeKey);e.selectNext(),e.remove()}))}},m.createElement(Rn,null)))},kr=()=>{const[e]=Ot("toolbarComponents");return m.createElement(m.Fragment,null,e.map(((e,t)=>m.createElement(e,{key:t}))))},xr={FrontmatterEditor:({yaml:e,onChange:t})=>{const[n,r]=m.useState(!0),a=m.useMemo((()=>e?Object.entries(P.load(e)).map((([e,t])=>({key:e,value:t}))):[]),[e]),{register:o,control:l,watch:i}=B.useForm({defaultValues:{yamlConfig:a}}),{fields:s,append:c,remove:d}=B.useFieldArray({control:l,name:"yamlConfig"});return m.useEffect((()=>{const e=i((({yamlConfig:e})=>{const n=e.reduce(((e,{key:t,value:n})=>(t&&n&&(e[t]=n),e)),{});t(P.dump(n).trim())}));return()=>e.unsubscribe()}),[i,t]),m.createElement("div",{className:Ut.frontmatterWrapper,"data-expanded":n,"data-editor-type":"frontmatter"},m.createElement("button",{className:Ut.frontmatterToggleButton,onClick:e=>{e.preventDefault(),r((e=>!e))}},n?m.createElement(Qt,null):m.createElement(Yt,null),"Document frontmatter"),n&&m.createElement("form",null,m.createElement("table",{className:Ut.frontmatterEditorTable},m.createElement("colgroup",null,m.createElement("col",null),m.createElement("col",null),m.createElement("col",null)),m.createElement("thead",null,m.createElement("tr",null,m.createElement("th",null,"Key"),m.createElement("th",null,"Value"),m.createElement("th",null))),m.createElement("tbody",null,s.map(((e,t)=>m.createElement("tr",{key:e.id},m.createElement("td",null,m.createElement(en,{...o(`yamlConfig.${t}.key`,{required:!0}),autofocusIfEmpty:!0})),m.createElement("td",null,m.createElement(en,{...o(`yamlConfig.${t}.value`,{required:!0})})),m.createElement("td",null,m.createElement("button",{type:"button",onClick:()=>d(t),className:Ut.iconButton},m.createElement(Xt,null))))))),m.createElement("tfoot",null,m.createElement("tr",null,m.createElement("td",null,m.createElement("button",{className:Ut.primaryButton,type:"button",onClick:()=>{c({key:"",value:""})}},"Add new key")))))))},JsxEditor:function({kind:e,attributes:t,componentName:n,editor:o,onSubmit:l,theme:i}){return"flow"===e?m.createElement("div",null,m.createElement("div",null,n),m.createElement($.LexicalNestedComposer,{initialEditor:o,initialTheme:i},m.createElement(s.RichTextPlugin,{contentEditable:m.createElement(r.ContentEditable,null),placeholder:m.createElement("div",null,"Type here.."),ErrorBoundary:a}))):m.createElement("span",null,m.createElement("span",null,m.createElement(an,{attributes:t,componentName:n,onSubmit:l})),m.createElement("span",null,n,m.createElement($.LexicalNestedComposer,{initialEditor:o,initialTheme:i},m.createElement(s.RichTextPlugin,{contentEditable:m.createElement(r.ContentEditable,{style:{padding:5,border:"1px solid red"}}),placeholder:m.createElement("div",null,"Type here.."),ErrorBoundary:a}))))},SandpackEditor:({nodeKey:e,code:t,meta:n,onChange:r,focusEmitter:a})=>{const[o]=M.useLexicalComposerContext(),[l]=Ot("sandpackConfig"),i=Gt(e,"sandpack","jsx"),s=At("activeEditorType");m.useEffect((()=>{a.subscribe((()=>{var t,n;null==(n=null==(t=null==i?void 0:i.current)?void 0:t.getCodemirror())||n.focus(),s({type:"sandpack",nodeKey:e})}))}),[a,i,s,e]);const c=m.useCallback((e=>{o.update((()=>{r(e)}))}),[r,o]),d=function(e,t){return t.presets.find((t=>t.meta===e))||t.presets.find((e=>e.name===t.defaultPreset))}(n,l);if(!d)throw new Error(`No sandpack preset found for meta: ${n}`);return m.createElement(D.SandpackProvider,{template:d.sandpackTemplate,theme:d.sandpackTheme,files:{[d.snippetFileName]:t,...Object.entries(d.files||{}).reduce(((e,[t,n])=>({...e,[t]:{code:n,readOnly:!0}})),{})},customSetup:{dependencies:d.dependencies}},m.createElement(D.SandpackLayout,null,m.createElement(D.SandpackCodeEditor,{showLineNumbers:!0,showInlineErrors:!0,ref:i}),m.createElement(D.SandpackPreview,null)),m.createElement(ln,{onChange:c,snippetFileName:d.snippetFileName}))},CodeBlockEditor:({nodeKey:e,code:t,language:n,onChange:r,focusEmitter:a})=>{const[o]=Ot("activeEditor"),l=Gt(e,"codeblock",n),i=At("activeEditorType");m.useEffect((()=>{a.subscribe((()=>{var t,n;null==(n=null==(t=null==l?void 0:l.current)?void 0:t.getCodemirror())||n.focus(),i({type:"codeblock",nodeKey:e})}))}),[a,l,i,e]);const s=m.useCallback((e=>{null==o||o.update((()=>{r(e)}))}),[r,o]);return m.createElement("div",{className:Ut.sandpackWrapper},m.createElement(D.SandpackProvider,null,m.createElement(D.CodeEditor,{showLineNumbers:!0,initMode:"immediate",key:n,filePath:`file.${n||"txt"}`,code:t,onCodeUpdate:s,ref:l})))},TableEditor:({mdastNode:e,parentEditor:t,lexicalTable:n})=>{const[r,a]=m.useState(null),o=m.useCallback((e=>{const r=n.getColCount();if(null===e)return void a(null);let[o,l]=e;return o>r-1&&(o=0,l++),o<0&&(o=r-1,l-=1),l>n.getRowCount()-1?(a(null),void t.update((()=>{if(n.getLatest().getNextSibling())n.getLatest().selectNext();else{const e=u.$createParagraphNode();n.insertAfter(e),e.select()}}))):l<0?(a(null),void t.update((()=>{n.getLatest().selectPrevious()}))):void a([o,l])}),[n,t]);m.useEffect((()=>{n.focusEmitter.subscribe(o)}),[n,o]);const l=m.useCallback((()=>{t.update((()=>{n.addRowToBottom()})),o([0,n.getRowCount()])}),[t,n,o]),i=m.useCallback((()=>{t.update((()=>{n.addColumnToRight()})),o([n.getColCount(),0])}),[t,n,o]),[s,c]=m.useState([-1,-1]),d=m.useCallback((e=>{let t=e.target;for(;t&&!["TH","TD"].includes(t.tagName);){if(t===e.currentTarget)return;t=t.parentElement}if(null===t)return;const n=t.parentElement,r="TFOOT"===n.parentElement.tagName?-1:Array.from(n.children).indexOf(t),a="TH"===t.tagName?-1:Array.from(n.parentElement.children).indexOf(n);c([r,a])}),[]);return m.createElement("table",{className:Ut.tableEditor,onMouseOver:d,onMouseLeave:()=>c([-1,-1])},m.createElement("colgroup",null,m.createElement("col",null),Array.from({length:e.children[0].children.length},((t,n)=>{const r=(e.align||[])[n]||"left",a=xn[r];return m.createElement("col",{key:n,className:a})})),m.createElement("col",null)),m.createElement("thead",null,m.createElement("tr",null,m.createElement("th",{className:Ut.tableToolsColumn,"data-tool-cell":!0},m.createElement("button",{className:Ut.iconButton,title:"Delete table",onClick:()=>{t.update((()=>{n.selectNext(),n.remove()}))}},m.createElement(gn,null))),Array.from({length:e.children[0].children.length},((r,a)=>m.createElement("th",{key:a,"data-tool-cell":!0},m.createElement(_n,{setActiveCellWithBoundaries:o,parentEditor:t,colIndex:a,highlightedCoordinates:s,lexicalTable:n,align:(e.align||[])[a]})))),m.createElement("th",{className:Ut.tableToolsColumn}))),m.createElement("tbody",null,e.children.map(((a,l)=>m.createElement("tr",{key:l},m.createElement("td",{className:Ut.toolCell,"data-tool-cell":!0},m.createElement(bn,{setActiveCellWithBoundaries:o,parentEditor:t,rowIndex:l,highlightedCoordinates:s,lexicalTable:n})),a.children.map(((a,i)=>{var s;return m.createElement(yn,{align:null==(s=e.align)?void 0:s[i],key:i,contents:a.children,rowIndex:l,colIndex:i,lexicalTable:n,parentEditor:t,activeCellTuple:[r,o]})})),0===l&&m.createElement("th",{rowSpan:n.getRowCount(),"data-tool-cell":!0},m.createElement("button",{className:Ut.addColumnButton,onClick:i},m.createElement(wn,null))))))),m.createElement("tfoot",null,m.createElement("tr",null,m.createElement("th",null),m.createElement("th",{colSpan:n.getColCount()},m.createElement("button",{className:Ut.addRowButton,onClick:l},m.createElement(fn,null))),m.createElement("th",null))))}},yr=[sr,ir,()=>{const[e]=Ot("currentFormat","currentListType"),t=At("applyFormat");return m.createElement(lr,null,m.createElement(or,{"aria-label":"Inline code",on:0!=(16&e),onValueChange:t.bind(null,"code")},m.createElement(In,null)))},ir,cr,ir,Yn,ir,dr,Xn,ur,()=>{const e=At("insertHorizontalRule");return m.createElement(rr,{onClick:e.bind(null,!0)},m.createElement(jn,null))},hr,ir,mr,pr],Cr={defaultPreset:"react",presets:[{name:"react",meta:"live react",label:"React",sandpackTemplate:"react",sandpackTheme:"light",snippetFileName:"/App.js",snippetLanguage:"jsx",initialSnippetContent:'\nexport default function App() {\n return (\n <div className="App">\n <h1>Hello CodeSandbox</h1>\n <h2>Start editing to see some magic happen!</h2>\n </div>\n );\n}\n'.trim()}]},_r={markdownParse:{defaultVisitors:Qe,defaultSyntaxExtensions:tt,defaultMdastExtensions:et},lexicalConvert:{defaultVisitors:ze,defaultExtensions:Ge,defaultMarkdownOptions:Ye},defaultLexicalNodes:at},br=m.forwardRef((({markdown:e,headMarkdown:t,jsxComponentDescriptors:p=[],sandpackConfig:h=Cr,onChange:g,viewMode:E,linkAutocompleteSuggestions:v,imageAutoCompleteSuggestions:f,className:w,contentEditableClassName:k,toolbarComponents:x=yr,markdownParseOptions:{syntaxExtensions:y=Object.values(tt),mdastExtensions:C=Object.values(et),visitors:_=Object.values(Qe)}={},lexicalConvertOptions:{toMarkdownExtensions:b=Object.values(Ge),toMarkdownOptions:N=Ye,visitors:T=Object.values(ze)}={},lexicalNodes:S=Object.values(at)},M)=>{const L=m.useRef(null);return m.createElement("div",{className:d(Ut.editorRoot,Ut.editorWrapper,w),ref:L},m.createElement(n.LexicalComposer,{initialConfig:{editorState:()=>{nt({root:u.$getRoot(),visitors:_,mdastExtensions:C,markdown:e,syntaxExtensions:y})},namespace:"MDXEditor",theme:{...we,nodeDecoratorComponents:xr},nodes:S,onError:e=>console.error(e)}},m.createElement(Ht,{markdownSource:e,headMarkdown:t||e,jsxComponentDescriptors:p,sandpackConfig:h,onChange:g,viewMode:E,linkAutocompleteSuggestions:v,imageAutocompleteSuggestions:f,editorRootElementRef:L,toolbarComponents:x,markdownParseOptions:{visitors:_,mdastExtensions:C,syntaxExtensions:y},lexicalConvertOptions:{visitors:T,toMarkdownOptions:N,toMarkdownExtensions:b},lexicalNodes:S},m.createElement(vr,null),m.createElement(Sn,null,m.createElement(s.RichTextPlugin,{contentEditable:m.createElement(r.ContentEditable,{className:d(Ut.contentEditable,k)}),placeholder:m.createElement("div",null),ErrorBoundary:a})),m.createElement(l.LinkPlugin,null),m.createElement(o.HorizontalRulePlugin,null),m.createElement(i.ListPlugin,null),m.createElement(Wt,{maxDepth:7}),m.createElement(c.TabIndentationPlugin,null),m.createElement(zt,null),m.createElement(kn,null),m.createElement(Jt,null),m.createElement(Nr,{mdxRef:M}))))})),Nr=({mdxRef:e})=>{const[t]=Ot("markdownSource");return m.useImperativeHandle(e,(()=>({getMarkdown:()=>t})),[t]),null};Object.defineProperty(exports,"AdmonitionKind",{enumerable:!0,get:()=>u.AdmonitionKind}),exports.$createAdmonitionNode=oe,exports.$createCodeBlockNode=de,exports.$createFrontmatterNode=pe,exports.$createImageNode=ve,exports.$createJsxNode=Ce,exports.$createSandpackNode=Ne,exports.$createTableNode=He,exports.$isAdmonitionNode=le,exports.$isCodeBlockNode=ue,exports.$isFrontmatterNode=he,exports.$isImageNode=fe,exports.$isJsxNode=_e,exports.$isSandpackNode=Te,exports.$isTableNode=Le,exports.AdmonitionNode=ae,exports.CodeBlockNode=ce,exports.FrontmatterNode=me,exports.ImageNode=Ee,exports.JsxNode=ye,exports.MDXEditor=br,exports.SandpackNode=be,exports.TableNode=Me,exports.ToolbarComponents=Er,exports.defaultMdxOptionValues=_r;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,14 @@
1
+ /**
2
+ * The `@mdxeditor/editor` package exports the MDXEditor React component, along with some utilities and default option values that id the customization of the widget.
3
+ * In addition to that, the package exports the LexicalNodes used to represent the MDX AST, as well as the NodeDecorators used to render the nodes in the editor.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
1
8
  /// <reference types="react" />
2
9
 
3
10
  import { AdmonitionKind } from 'lexical';
11
+ import type { ComponentType } from 'react';
4
12
  import { ContainerDirective } from 'mdast-util-directive';
5
13
  import { DecoratorNode } from 'lexical';
6
14
  import type { DOMConversionMap } from 'lexical';
@@ -8,7 +16,7 @@ import type { DOMExportOutput } from 'lexical';
8
16
  import { EditorConfig } from 'lexical';
9
17
  import { EditorThemeClasses } from 'lexical';
10
18
  import { ElementNode } from 'lexical';
11
- import { fromMarkdown } from 'mdast-util-from-markdown';
19
+ import { FromMarkdownOptions } from 'mdast-util-from-markdown/lib';
12
20
  import { HeadingNode } from '@lexical/rich-text';
13
21
  import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
14
22
  import { Klass } from 'lexical';
@@ -26,6 +34,7 @@ import type { MdxJsxTextElement } from 'mdast-util-mdx-jsx';
26
34
  import { MdxJsxTextElement as MdxJsxTextElement_2 } from 'mdast-util-mdx';
27
35
  import { NodeKey } from 'lexical';
28
36
  import { ParagraphNode } from 'lexical';
37
+ import { ParseOptions } from 'mdast-util-from-markdown/lib';
29
38
  import { QuoteNode } from '@lexical/rich-text';
30
39
  import * as RadixToolbar from '@radix-ui/react-toolbar';
31
40
  import { RangeSelection } from 'lexical';
@@ -71,7 +80,6 @@ export declare type ActiveEditorType = LexicalEditorType | CodeBlockEditorType |
71
80
 
72
81
  export { AdmonitionKind }
73
82
 
74
- /** @noInheritDoc */
75
83
  export declare class AdmonitionNode extends ElementNode {
76
84
  __kind: AdmonitionKind;
77
85
  static getType(): string;
@@ -96,9 +104,6 @@ export declare type CodeBlockEditorType = {
96
104
  nodeKey: string;
97
105
  };
98
106
 
99
- /**
100
- * @noInheritDoc
101
- */
102
107
  export declare class CodeBlockNode extends DecoratorNode<JSX.Element> {
103
108
  __code: string;
104
109
  __meta: string;
@@ -121,7 +126,7 @@ export declare class CodeBlockNode extends DecoratorNode<JSX.Element> {
121
126
  setMeta(meta: string): void;
122
127
  setLanguage(language: string): void;
123
128
  select(): void;
124
- decorate(_editor: LexicalEditor, { theme: { nodeDecoratorComponents: { CodeBlockEditor }, }, }: ExtendedEditorConfig): JSX.Element;
129
+ decorate(_editor: LexicalEditor, { theme: { nodeDecoratorComponents: { CodeBlockEditor } } }: ExtendedEditorConfig): JSX.Element;
125
130
  }
126
131
 
127
132
  export declare interface CodeBlockPayload {
@@ -193,7 +198,7 @@ export declare interface ExportLexicalTreeOptions {
193
198
 
194
199
  export declare function exportLexicalTreeToMdast({ root, visitors, jsxComponentDescriptors }: ExportLexicalTreeOptions): Mdast.Root;
195
200
 
196
- export declare function exportMarkdownFromLexical({ root, toMarkdownOptions, toMarkdownExtensions, visitors, jsxComponentDescriptors, }: ExportMarkdownFromLexicalOptions): string;
201
+ export declare function exportMarkdownFromLexical({ root, toMarkdownOptions, toMarkdownExtensions, visitors, jsxComponentDescriptors }: ExportMarkdownFromLexicalOptions): string;
197
202
 
198
203
  export declare interface ExportMarkdownFromLexicalOptions extends ExportLexicalTreeOptions {
199
204
  toMarkdownExtensions: ToMarkdownOptions['extensions'];
@@ -206,16 +211,11 @@ declare type ExtendedEditorConfig = EditorConfig & {
206
211
  };
207
212
  };
208
213
 
209
- declare type FromMarkdownArgs = NonNullable<Parameters<typeof fromMarkdown>[1]>;
210
-
211
214
  export declare interface FrontmatterEditorProps {
212
215
  yaml: string;
213
216
  onChange: (yaml: string) => void;
214
217
  }
215
218
 
216
- /**
217
- * @noInheritDoc
218
- */
219
219
  export declare class FrontmatterNode extends DecoratorNode<JSX.Element> {
220
220
  __yaml: string;
221
221
  static getType(): string;
@@ -227,16 +227,13 @@ export declare class FrontmatterNode extends DecoratorNode<JSX.Element> {
227
227
  updateDOM(): false;
228
228
  getYaml(): string;
229
229
  setYaml(yaml: string): void;
230
- decorate(editor: LexicalEditor, { theme: { nodeDecoratorComponents: { FrontmatterEditor }, }, }: ExtendedEditorConfig): JSX.Element;
230
+ decorate(editor: LexicalEditor, { theme: { nodeDecoratorComponents: { FrontmatterEditor } } }: ExtendedEditorConfig): JSX.Element;
231
231
  }
232
232
 
233
233
  export declare interface FrontmatterPayload {
234
234
  yaml: string;
235
235
  }
236
236
 
237
- /**
238
- * @noInheritDoc
239
- */
240
237
  export declare class ImageNode extends DecoratorNode<JSX.Element> {
241
238
  __src: string;
242
239
  __altText: string;
@@ -297,9 +294,6 @@ export declare interface JsxEditorProps {
297
294
 
298
295
  export declare type JsxKind = 'text' | 'flow';
299
296
 
300
- /**
301
- * @noInheritDoc
302
- */
303
297
  export declare class JsxNode extends DecoratorNode<JSX.Element> {
304
298
  __kind: JsxKind;
305
299
  __name: string;
@@ -318,7 +312,7 @@ export declare class JsxNode extends DecoratorNode<JSX.Element> {
318
312
  getKind(): JsxKind;
319
313
  getAttributes(): MdxJsxAttribute[];
320
314
  updateAttributes(attributeValues: Record<string, string>): void;
321
- decorate(_parentEditor: LexicalEditor, { theme: { nodeDecoratorComponents: { JsxEditor }, }, }: ExtendedEditorConfig): JSX.Element;
315
+ decorate(_parentEditor: LexicalEditor, { theme: { nodeDecoratorComponents: { JsxEditor } } }: ExtendedEditorConfig): JSX.Element;
322
316
  }
323
317
 
324
318
  export declare interface JsxNodeConstructorParams extends JsxPayload {
@@ -367,8 +361,8 @@ export declare type LexicalVisitor = LexicalExportVisitor<LexicalNode, Mdast.Con
367
361
 
368
362
  export declare interface MarkdownParseOptions extends Omit<MdastTreeImportOptions, 'mdastRoot'> {
369
363
  markdown: string;
370
- syntaxExtensions: NonNullable<FromMarkdownArgs['extensions']>;
371
- mdastExtensions: NonNullable<FromMarkdownArgs['mdastExtensions']>;
364
+ syntaxExtensions: NonNullable<ParseOptions['extensions']>;
365
+ mdastExtensions: NonNullable<FromMarkdownOptions['mdastExtensions']>;
372
366
  }
373
367
 
374
368
  export declare const MdastAdmonitionVisitor: MdastImportVisitor<ContainerDirective>;
@@ -431,10 +425,26 @@ export declare interface MdastVisitParams<T extends Mdast.Content> {
431
425
  actions: MdastVisitActions;
432
426
  }
433
427
 
434
- export declare const MDXEditor: React_2.FC<MDXEditorProps>;
428
+ /**
429
+ * The MDXEditor React component
430
+ */
431
+ export declare const MDXEditor: React_2.ForwardRefExoticComponent<MDXEditorProps & React_2.RefAttributes<MDXEditorMethods>>;
432
+
433
+ /**
434
+ * The interface for the {@link MDXEditor} object reference.
435
+ *
436
+ * @example
437
+ * ```tsx
438
+ * const mdxEditorRef = React.useRef<MDXEditorMethods>(null)
439
+ * <MDXEditor ref={mdxEditorRef} />
440
+ * ```
441
+ */
442
+ export declare interface MDXEditorMethods {
443
+ getMarkdown: () => string;
444
+ }
435
445
 
436
446
  /**
437
- * MDXEditor is a rich text editor React Component for editing markdown.
447
+ * The properties of the {@link MDXEditor} react component
438
448
  */
439
449
  export declare interface MDXEditorProps {
440
450
  /**
@@ -466,7 +476,7 @@ export declare interface MDXEditorProps {
466
476
  /**
467
477
  * The set of components to be rendered in the toolbar.
468
478
  */
469
- toolbarComponents?: React_2.ComponentType[];
479
+ toolbarComponents?: ComponentType[];
470
480
  /**
471
481
  * The initial view mode for the editor. Defaults to `ViewMode.editor`.
472
482
  */
@@ -474,17 +484,9 @@ export declare interface MDXEditorProps {
474
484
  onChange?: (markdown: string) => void;
475
485
  className?: string;
476
486
  contentEditableClassName?: string;
477
- markdownParseOptions?: {
478
- syntaxExtensions?: MarkdownParseOptions['syntaxExtensions'];
479
- mdastExtensions?: MarkdownParseOptions['mdastExtensions'];
480
- visitors?: MarkdownParseOptions['visitors'];
481
- };
487
+ markdownParseOptions?: Partial<MarkdownParseOptions>;
482
488
  lexicalNodes?: Klass<LexicalNode>[];
483
- lexicalConvertOptions?: {
484
- extensions?: ExportMarkdownFromLexicalOptions['toMarkdownExtensions'];
485
- markdownOptions?: ExportMarkdownFromLexicalOptions['toMarkdownOptions'];
486
- visitors?: ExportMarkdownFromLexicalOptions['visitors'];
487
- };
489
+ lexicalConvertOptions?: Partial<ExportMarkdownFromLexicalOptions>;
488
490
  }
489
491
 
490
492
  declare interface NodeDecoratorComponents {
@@ -522,9 +524,6 @@ export declare type SandpackEditorType = {
522
524
  nodeKey: string;
523
525
  };
524
526
 
525
- /**
526
- * @noInheritDoc
527
- */
528
527
  export declare class SandpackNode extends DecoratorNode<JSX.Element> {
529
528
  __code: string;
530
529
  __meta: string;
@@ -547,7 +546,7 @@ export declare class SandpackNode extends DecoratorNode<JSX.Element> {
547
546
  setMeta(meta: string): void;
548
547
  setLanguage(language: string): void;
549
548
  select(): void;
550
- decorate(_parentEditor: LexicalEditor, { theme: { nodeDecoratorComponents: { SandpackEditor }, }, }: ExtendedEditorConfig): JSX.Element;
549
+ decorate(_parentEditor: LexicalEditor, { theme: { nodeDecoratorComponents: { SandpackEditor } } }: ExtendedEditorConfig): JSX.Element;
551
550
  }
552
551
 
553
552
  export declare interface SandpackPayload {
@@ -649,9 +648,6 @@ export declare interface TableEditorProps {
649
648
  mdastNode: Mdast.Table;
650
649
  }
651
650
 
652
- /**
653
- * @noInheritDoc
654
- */
655
651
  export declare class TableNode extends DecoratorNode<JSX.Element> {
656
652
  __mdastNode: Mdast.Table;
657
653
  focusEmitter: {
@@ -676,7 +672,7 @@ export declare class TableNode extends DecoratorNode<JSX.Element> {
676
672
  addRowToBottom(): void;
677
673
  addColumnToRight(): void;
678
674
  setColumnAlign(colIndex: number, align: Mdast.AlignType): void;
679
- decorate(parentEditor: LexicalEditor, { theme: { nodeDecoratorComponents: { TableEditor }, }, }: ExtendedEditorConfig): JSX.Element;
675
+ decorate(parentEditor: LexicalEditor, { theme: { nodeDecoratorComponents: { TableEditor } } }: ExtendedEditorConfig): JSX.Element;
680
676
  select(coords: [colIndex: number, rowIndex: number]): void;
681
677
  isInline(): false;
682
678
  }
package/dist/index.js CHANGED
@@ -2204,6 +2204,7 @@ function seedTable() {
2204
2204
  }
2205
2205
  const [EditorSystem, EditorSystemType] = system((r) => {
2206
2206
  const editor = r.node(null, true);
2207
+ const markdownSource = r.node("");
2207
2208
  const historyState = r.node(createEmptyHistoryState());
2208
2209
  const activeEditor = r.derive(editor, null);
2209
2210
  const currentFormat = r.node(0, true);
@@ -2423,59 +2424,10 @@ const [EditorSystem, EditorSystemType] = system((r) => {
2423
2424
  markdownParseOptions,
2424
2425
  lexicalConvertOptions,
2425
2426
  lexicalNodes,
2426
- imageAutocompleteSuggestions
2427
+ imageAutocompleteSuggestions,
2428
+ markdownSource
2427
2429
  };
2428
2430
  }, []);
2429
- function getSelectedNode(selection) {
2430
- const anchor = selection.anchor;
2431
- const focus = selection.focus;
2432
- const anchorNode = selection.anchor.getNode();
2433
- const focusNode = selection.focus.getNode();
2434
- if (anchorNode === focusNode) {
2435
- return anchorNode;
2436
- }
2437
- const isBackward = selection.isBackward();
2438
- if (isBackward) {
2439
- return $isAtNodeEnd(focus) ? anchorNode : focusNode;
2440
- } else {
2441
- return $isAtNodeEnd(anchor) ? anchorNode : focusNode;
2442
- }
2443
- }
2444
- function getSelectionRectangle(editor) {
2445
- const selection = $getSelection();
2446
- const nativeSelection = window.getSelection();
2447
- const activeElement = document.activeElement;
2448
- const rootElement = editor.getRootElement();
2449
- if (selection !== null && nativeSelection !== null && rootElement !== null && rootElement.contains(nativeSelection.anchorNode) && editor.isEditable()) {
2450
- const domRange = nativeSelection.getRangeAt(0);
2451
- let rect;
2452
- if (nativeSelection.anchorNode === rootElement) {
2453
- let inner = rootElement;
2454
- while (inner.firstElementChild != null) {
2455
- inner = inner.firstElementChild;
2456
- }
2457
- rect = inner.getBoundingClientRect();
2458
- } else {
2459
- rect = domRange.getBoundingClientRect();
2460
- }
2461
- return {
2462
- top: rect.top + window.scrollY,
2463
- left: rect.left + window.scrollX,
2464
- width: rect.width,
2465
- height: rect.height
2466
- };
2467
- } else if (!activeElement || activeElement.className !== "link-input") {
2468
- return null;
2469
- }
2470
- return null;
2471
- }
2472
- function getStateAsMarkdown(editor, exportParams) {
2473
- return tap({ markdown: "" }, (result) => {
2474
- editor.getEditorState().read(() => {
2475
- result.markdown = exportMarkdownFromLexical({ root: $getRoot(), ...exportParams });
2476
- });
2477
- }).markdown;
2478
- }
2479
2431
  const [JsxSystem, JsxSystemType] = system((r) => {
2480
2432
  const jsxComponentDescriptors = r.node([]);
2481
2433
  return {
@@ -2483,9 +2435,8 @@ const [JsxSystem, JsxSystemType] = system((r) => {
2483
2435
  };
2484
2436
  }, []);
2485
2437
  const [ViewModeSystem] = system(
2486
- (r, [{ editor, markdownParseOptions, lexicalConvertOptions }, { jsxComponentDescriptors }]) => {
2438
+ (r, [{ editor, markdownParseOptions, markdownSource }, {}]) => {
2487
2439
  const viewMode = r.node("editor");
2488
- const markdownSource = r.node("");
2489
2440
  const headMarkdown = r.node("");
2490
2441
  r.sub(
2491
2442
  r.pipe(
@@ -2499,19 +2450,15 @@ const [ViewModeSystem] = system(
2499
2450
  },
2500
2451
  { current: "editor", next: "editor" }
2501
2452
  ),
2502
- r.o.withLatestFrom(editor, markdownSource, jsxComponentDescriptors, markdownParseOptions, lexicalConvertOptions)
2453
+ r.o.withLatestFrom(editor, markdownSource, markdownParseOptions)
2503
2454
  ),
2504
- ([{ current }, editor2, markdownValue, jsxComponentDescriptors2, markdownParseOptions2, lexicalConvertOptions2]) => {
2505
- if (current === "editor") {
2506
- if (editor2) {
2507
- r.pub(markdownSource, getStateAsMarkdown(editor2, { jsxComponentDescriptors: jsxComponentDescriptors2, ...lexicalConvertOptions2 }));
2508
- }
2509
- } else if (current === "markdown") {
2455
+ ([{ current }, editor2, markdownSource2, markdownParseOptions2]) => {
2456
+ if (current === "markdown") {
2510
2457
  editor2 == null ? void 0 : editor2.update(() => {
2511
2458
  $getRoot().clear();
2512
2459
  importMarkdownToLexical({
2513
2460
  root: $getRoot(),
2514
- markdown: markdownValue,
2461
+ markdown: markdownSource2,
2515
2462
  ...markdownParseOptions2
2516
2463
  });
2517
2464
  });
@@ -2520,8 +2467,7 @@ const [ViewModeSystem] = system(
2520
2467
  );
2521
2468
  return {
2522
2469
  viewMode,
2523
- headMarkdown,
2524
- markdownSource
2470
+ headMarkdown
2525
2471
  };
2526
2472
  },
2527
2473
  [EditorSystemType, JsxSystemType]
@@ -2616,6 +2562,56 @@ const [SandpackSystem] = system(
2616
2562
  },
2617
2563
  [EditorSystemType]
2618
2564
  );
2565
+ function getSelectedNode(selection) {
2566
+ const anchor = selection.anchor;
2567
+ const focus = selection.focus;
2568
+ const anchorNode = selection.anchor.getNode();
2569
+ const focusNode = selection.focus.getNode();
2570
+ if (anchorNode === focusNode) {
2571
+ return anchorNode;
2572
+ }
2573
+ const isBackward = selection.isBackward();
2574
+ if (isBackward) {
2575
+ return $isAtNodeEnd(focus) ? anchorNode : focusNode;
2576
+ } else {
2577
+ return $isAtNodeEnd(anchor) ? anchorNode : focusNode;
2578
+ }
2579
+ }
2580
+ function getSelectionRectangle(editor) {
2581
+ const selection = $getSelection();
2582
+ const nativeSelection = window.getSelection();
2583
+ const activeElement = document.activeElement;
2584
+ const rootElement = editor.getRootElement();
2585
+ if (selection !== null && nativeSelection !== null && rootElement !== null && rootElement.contains(nativeSelection.anchorNode) && editor.isEditable()) {
2586
+ const domRange = nativeSelection.getRangeAt(0);
2587
+ let rect;
2588
+ if (nativeSelection.anchorNode === rootElement) {
2589
+ let inner = rootElement;
2590
+ while (inner.firstElementChild != null) {
2591
+ inner = inner.firstElementChild;
2592
+ }
2593
+ rect = inner.getBoundingClientRect();
2594
+ } else {
2595
+ rect = domRange.getBoundingClientRect();
2596
+ }
2597
+ return {
2598
+ top: rect.top + window.scrollY,
2599
+ left: rect.left + window.scrollX,
2600
+ width: rect.width,
2601
+ height: rect.height
2602
+ };
2603
+ } else if (!activeElement || activeElement.className !== "link-input") {
2604
+ return null;
2605
+ }
2606
+ return null;
2607
+ }
2608
+ function getStateAsMarkdown(editor, exportParams) {
2609
+ return tap({ markdown: "" }, (result) => {
2610
+ editor.getEditorState().read(() => {
2611
+ result.markdown = exportMarkdownFromLexical({ root: $getRoot(), ...exportParams });
2612
+ });
2613
+ }).markdown;
2614
+ }
2619
2615
  function getLinkNodeInSelection(selection) {
2620
2616
  const node = getSelectedNode(selection);
2621
2617
  const parent = node.getParent();
@@ -2828,16 +2824,22 @@ const [LinkDialogSystem, LinkDialogSystemType] = system(
2828
2824
  [EditorSystemType]
2829
2825
  );
2830
2826
  const [OnChangeSystem, OnChangeSystemType] = system(
2831
- (r, [{ createEditorSubscription, lexicalConvertOptions }, { jsxComponentDescriptors }]) => {
2827
+ (r, [{ createEditorSubscription, lexicalConvertOptions, markdownSource }, { jsxComponentDescriptors }]) => {
2832
2828
  const onChange = r.node();
2833
2829
  r.pub(createEditorSubscription, (activeEditor, rootEditor) => {
2830
+ function updateMarkdown() {
2831
+ const descriptors = r.getValue(jsxComponentDescriptors);
2832
+ const options = r.getValue(lexicalConvertOptions);
2833
+ const markdown2 = getStateAsMarkdown(rootEditor, { jsxComponentDescriptors: descriptors, ...options });
2834
+ r.pub(onChange, markdown2);
2835
+ r.pub(markdownSource, markdown2);
2836
+ }
2837
+ updateMarkdown();
2834
2838
  return activeEditor.registerUpdateListener(({ dirtyElements, dirtyLeaves, prevEditorState, tags }) => {
2835
2839
  if (dirtyElements.size === 0 && dirtyLeaves.size === 0 || tags.has("history-merge") || prevEditorState.isEmpty()) {
2836
2840
  return;
2837
2841
  }
2838
- const descriptors = r.getValue(jsxComponentDescriptors);
2839
- const options = r.getValue(lexicalConvertOptions);
2840
- r.pub(onChange, getStateAsMarkdown(rootEditor, { jsxComponentDescriptors: descriptors, ...options }));
2842
+ updateMarkdown();
2841
2843
  });
2842
2844
  });
2843
2845
  return {
@@ -4060,7 +4062,6 @@ const ImageButton = React__default.forwardRef((props, forwardedRef) => {
4060
4062
  const [editorRootElementRef, imageAutocompleteSuggestions] = useEmitterValues("editorRootElementRef", "imageAutocompleteSuggestions");
4061
4063
  const [open, setOpen] = React__default.useState(false);
4062
4064
  const insertImage = usePublisher("insertImage");
4063
- console.log(imageAutocompleteSuggestions);
4064
4065
  const onSubmit = React__default.useCallback(
4065
4066
  (url) => {
4066
4067
  insertImage(url);
@@ -4386,97 +4387,115 @@ const defaultMdxOptionValues = {
4386
4387
  },
4387
4388
  defaultLexicalNodes
4388
4389
  };
4389
- const MDXEditor = ({
4390
- markdown: markdown2,
4391
- headMarkdown,
4392
- jsxComponentDescriptors = [],
4393
- sandpackConfig = defaultSandpackConfig,
4394
- onChange,
4395
- viewMode,
4396
- linkAutocompleteSuggestions,
4397
- imageAutoCompleteSuggestions,
4398
- className,
4399
- contentEditableClassName,
4400
- toolbarComponents = defaultToolbarComponents,
4401
- markdownParseOptions: {
4402
- syntaxExtensions = Object.values(defaultSyntaxExtensions),
4403
- mdastExtensions = Object.values(defaultMdastExtensions),
4404
- visitors: importVisitors = Object.values(defaultMdastVisitors)
4405
- } = {},
4406
- lexicalConvertOptions: {
4407
- extensions: toMarkdownExtensions = Object.values(defaultExtensions),
4408
- markdownOptions: toMarkdownOptions = defaultToMarkdownOptions,
4409
- visitors: exportVisitors = Object.values(defaultLexicalVisitors)
4410
- } = {},
4411
- lexicalNodes = Object.values(defaultLexicalNodes)
4412
- }) => {
4413
- const editorRootElementRef = React__default.useRef(null);
4414
- return /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.editorRoot, styles.editorWrapper, className), ref: editorRootElementRef }, /* @__PURE__ */ React__default.createElement(
4415
- LexicalComposer,
4416
- {
4417
- initialConfig: {
4418
- editorState: () => {
4419
- importMarkdownToLexical({
4420
- root: $getRoot(),
4390
+ const MDXEditor = React__default.forwardRef(
4391
+ ({
4392
+ markdown: markdown2,
4393
+ headMarkdown,
4394
+ jsxComponentDescriptors = [],
4395
+ sandpackConfig = defaultSandpackConfig,
4396
+ onChange,
4397
+ viewMode,
4398
+ linkAutocompleteSuggestions,
4399
+ imageAutoCompleteSuggestions,
4400
+ className,
4401
+ contentEditableClassName,
4402
+ toolbarComponents = defaultToolbarComponents,
4403
+ markdownParseOptions: {
4404
+ syntaxExtensions = Object.values(defaultSyntaxExtensions),
4405
+ mdastExtensions = Object.values(defaultMdastExtensions),
4406
+ visitors: importVisitors = Object.values(defaultMdastVisitors)
4407
+ } = {},
4408
+ lexicalConvertOptions: {
4409
+ toMarkdownExtensions = Object.values(defaultExtensions),
4410
+ toMarkdownOptions = defaultToMarkdownOptions,
4411
+ visitors: exportVisitors = Object.values(defaultLexicalVisitors)
4412
+ } = {},
4413
+ lexicalNodes = Object.values(defaultLexicalNodes)
4414
+ }, ref) => {
4415
+ const editorRootElementRef = React__default.useRef(null);
4416
+ return /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.editorRoot, styles.editorWrapper, className), ref: editorRootElementRef }, /* @__PURE__ */ React__default.createElement(
4417
+ LexicalComposer,
4418
+ {
4419
+ initialConfig: {
4420
+ editorState: () => {
4421
+ importMarkdownToLexical({
4422
+ root: $getRoot(),
4423
+ visitors: importVisitors,
4424
+ mdastExtensions,
4425
+ markdown: markdown2,
4426
+ syntaxExtensions
4427
+ });
4428
+ },
4429
+ namespace: "MDXEditor",
4430
+ theme: {
4431
+ ...theme,
4432
+ nodeDecoratorComponents: defaultNodeDecorators
4433
+ },
4434
+ nodes: lexicalNodes,
4435
+ onError: (error) => console.error(error)
4436
+ }
4437
+ },
4438
+ /* @__PURE__ */ React__default.createElement(
4439
+ EditorSystemComponent,
4440
+ {
4441
+ markdownSource: markdown2,
4442
+ headMarkdown: headMarkdown || markdown2,
4443
+ jsxComponentDescriptors,
4444
+ sandpackConfig,
4445
+ onChange,
4446
+ viewMode,
4447
+ linkAutocompleteSuggestions,
4448
+ imageAutocompleteSuggestions: imageAutoCompleteSuggestions,
4449
+ editorRootElementRef,
4450
+ toolbarComponents,
4451
+ markdownParseOptions: {
4421
4452
  visitors: importVisitors,
4422
4453
  mdastExtensions,
4423
- markdown: markdown2,
4424
4454
  syntaxExtensions
4425
- });
4426
- },
4427
- namespace: "MDXEditor",
4428
- theme: {
4429
- ...theme,
4430
- nodeDecoratorComponents: defaultNodeDecorators
4431
- },
4432
- nodes: lexicalNodes,
4433
- onError: (error) => console.error(error)
4434
- }
4435
- },
4436
- /* @__PURE__ */ React__default.createElement(
4437
- EditorSystemComponent,
4438
- {
4439
- markdownSource: markdown2,
4440
- headMarkdown: headMarkdown || markdown2,
4441
- jsxComponentDescriptors,
4442
- sandpackConfig,
4443
- onChange,
4444
- viewMode,
4445
- linkAutocompleteSuggestions,
4446
- imageAutocompleteSuggestions: imageAutoCompleteSuggestions,
4447
- editorRootElementRef,
4448
- toolbarComponents,
4449
- markdownParseOptions: {
4450
- visitors: importVisitors,
4451
- mdastExtensions,
4452
- syntaxExtensions
4453
- },
4454
- lexicalConvertOptions: {
4455
- visitors: exportVisitors,
4456
- toMarkdownOptions,
4457
- toMarkdownExtensions
4455
+ },
4456
+ lexicalConvertOptions: {
4457
+ visitors: exportVisitors,
4458
+ toMarkdownOptions,
4459
+ toMarkdownExtensions
4460
+ },
4461
+ lexicalNodes
4458
4462
  },
4459
- lexicalNodes
4460
- },
4461
- /* @__PURE__ */ React__default.createElement(ToolbarPlugin, null),
4462
- /* @__PURE__ */ React__default.createElement(ViewModeToggler, null, /* @__PURE__ */ React__default.createElement(
4463
- RichTextPlugin,
4464
- {
4465
- contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { className: classNames(styles.contentEditable, contentEditableClassName) }),
4466
- placeholder: /* @__PURE__ */ React__default.createElement("div", null),
4467
- ErrorBoundary: LexicalErrorBoundary
4463
+ /* @__PURE__ */ React__default.createElement(ToolbarPlugin, null),
4464
+ /* @__PURE__ */ React__default.createElement(ViewModeToggler, null, /* @__PURE__ */ React__default.createElement(
4465
+ RichTextPlugin,
4466
+ {
4467
+ contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { className: classNames(styles.contentEditable, contentEditableClassName) }),
4468
+ placeholder: /* @__PURE__ */ React__default.createElement("div", null),
4469
+ ErrorBoundary: LexicalErrorBoundary
4470
+ }
4471
+ )),
4472
+ /* @__PURE__ */ React__default.createElement(LinkPlugin, null),
4473
+ /* @__PURE__ */ React__default.createElement(HorizontalRulePlugin, null),
4474
+ /* @__PURE__ */ React__default.createElement(ListPlugin, null),
4475
+ /* @__PURE__ */ React__default.createElement(ListMaxIndentLevelPlugin, { maxDepth: 7 }),
4476
+ /* @__PURE__ */ React__default.createElement(TabIndentationPlugin, null),
4477
+ /* @__PURE__ */ React__default.createElement(LinkDialogPlugin, null),
4478
+ /* @__PURE__ */ React__default.createElement(SharedHistoryPlugin, null),
4479
+ /* @__PURE__ */ React__default.createElement(PatchedMarkdownShortcutPlugin, null),
4480
+ /* @__PURE__ */ React__default.createElement(MDXMethods, { mdxRef: ref })
4481
+ )
4482
+ ));
4483
+ }
4484
+ );
4485
+ const MDXMethods = ({ mdxRef }) => {
4486
+ const [markdownSource] = useEmitterValues("markdownSource");
4487
+ React__default.useImperativeHandle(
4488
+ mdxRef,
4489
+ () => {
4490
+ return {
4491
+ getMarkdown: () => {
4492
+ return markdownSource;
4468
4493
  }
4469
- )),
4470
- /* @__PURE__ */ React__default.createElement(LinkPlugin, null),
4471
- /* @__PURE__ */ React__default.createElement(HorizontalRulePlugin, null),
4472
- /* @__PURE__ */ React__default.createElement(ListPlugin, null),
4473
- /* @__PURE__ */ React__default.createElement(ListMaxIndentLevelPlugin, { maxDepth: 7 }),
4474
- /* @__PURE__ */ React__default.createElement(TabIndentationPlugin, null),
4475
- /* @__PURE__ */ React__default.createElement(LinkDialogPlugin, null),
4476
- /* @__PURE__ */ React__default.createElement(SharedHistoryPlugin, null),
4477
- /* @__PURE__ */ React__default.createElement(PatchedMarkdownShortcutPlugin, null)
4478
- )
4479
- ));
4494
+ };
4495
+ },
4496
+ [markdownSource]
4497
+ );
4498
+ return null;
4480
4499
  };
4481
4500
  export {
4482
4501
  $createAdmonitionNode,
package/package.json CHANGED
@@ -21,8 +21,18 @@
21
21
  "main": "dist/index.cjs",
22
22
  "module": "dist/index.js",
23
23
  "types": "dist/index.d.ts",
24
- "version": "0.0.1",
24
+ "version": "0.1.1",
25
25
  "description": "React component for rich text markdown editing",
26
+ "scripts": {
27
+ "build": "vite build",
28
+ "build:docs:api": "./scripts/build_docs_api.sh",
29
+ "start": "LADLE=true ladle dev",
30
+ "dev": "LADLE=true ladle dev",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint src --ext .ts,.tsx",
33
+ "test": "vitest",
34
+ "semantic-release": "semantic-release"
35
+ },
26
36
  "files": [
27
37
  "dist"
28
38
  ],
@@ -90,6 +100,8 @@
90
100
  "@babel/preset-react": "^7.22.3",
91
101
  "@babel/preset-typescript": "^7.21.5",
92
102
  "@ladle/react": "^2.13.0",
103
+ "@microsoft/api-documenter": "^7.22.21",
104
+ "@microsoft/api-extractor": "^7.36.0",
93
105
  "@ngneat/falso": "^6.4.0",
94
106
  "@testing-library/jest-dom": "^5.16.5",
95
107
  "@testing-library/react": "^14.0.0",
@@ -133,7 +145,8 @@
133
145
  "vite": "^4.3.9",
134
146
  "vite-plugin-dts": "^2.3.0",
135
147
  "vite-plugin-svgr": "^3.2.0",
136
- "vitest": "^0.31.1"
148
+ "vitest": "^0.31.1",
149
+ "semantic-release": "^21.0.5"
137
150
  },
138
151
  "publishConfig": {
139
152
  "access": "public"
@@ -142,13 +155,24 @@
142
155
  "node": ">=16"
143
156
  },
144
157
  "packageManager": "pnpm@8.3.0",
145
- "scripts": {
146
- "build": "vite build",
147
- "build:docs:api": "./scripts/build_docs_api.sh",
148
- "start": "LADLE=true ladle dev",
149
- "dev": "LADLE=true ladle dev",
150
- "typecheck": "tsc --noEmit",
151
- "lint": "eslint src --ext .ts,.tsx",
152
- "test": "vitest"
158
+ "repository": {
159
+ "type": "git",
160
+ "url": "https://github.com/mdx-editor/editor.git"
161
+ },
162
+ "release": {
163
+ "branches": [
164
+ "+([0-9])?(.{+([0-9]),x}).x",
165
+ "main",
166
+ "next",
167
+ "next-major",
168
+ {
169
+ "name": "beta",
170
+ "prerelease": true
171
+ },
172
+ {
173
+ "name": "alpha",
174
+ "prerelease": true
175
+ }
176
+ ]
153
177
  }
154
- }
178
+ }