@innoviatech/lexical-text-editor 3.0.2 → 3.0.4

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/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{LexicalComposer as o}from"@lexical/react/LexicalComposer";import i,{useRef as l,useEffect as r,cloneElement as a,useState as c,useCallback as s,useMemo as d}from"react";import{$isHeadingNode as u,$isQuoteNode as h,$createQuoteNode as p,$createHeadingNode as m,HeadingNode as g,QuoteNode as b}from"@lexical/rich-text";import{$isCodeNode as f,$createCodeNode as y,CodeHighlightNode as v,CodeNode as x}from"@lexical/code";import{RichTextPlugin as w}from"@lexical/react/LexicalRichTextPlugin";import{ContentEditable as C}from"@lexical/react/LexicalContentEditable";import{LexicalErrorBoundary as k}from"@lexical/react/LexicalErrorBoundary";import{$createRangeSelection as N,$findMatchingParent as S,INTERNAL_$isBlock as _,$isElementNode as L,$getSelection as T,$setSelection as E,$isRootOrShadowRoot as A,$hasAncestor as M,$isRangeSelection as R,$isTextNode as D,$isTokenOrSegmented as z,$getCharacterOffsets as F,$isLeafNode as W,$getPreviousSelection as O,$caretRangeFromSelection as I,$getRoot as H,$getNodeByKey as U,SELECTION_CHANGE_COMMAND as $,$createParagraphNode as P,KEY_TAB_COMMAND as K,OUTDENT_CONTENT_COMMAND as B,INDENT_CONTENT_COMMAND as J,COMMAND_PRIORITY_EDITOR as q,DecoratorNode as V,$applyNodeReplacement as j,PASTE_COMMAND as Q,COMMAND_PRIORITY_LOW as X,$insertNodes as Y,CAN_REDO_COMMAND as G,CAN_UNDO_COMMAND as Z,REDO_COMMAND as ee,UNDO_COMMAND as te,FORMAT_ELEMENT_COMMAND as ne,FORMAT_TEXT_COMMAND as oe,isDOMDocumentNode as ie,ArtificialNode__DO_NOT_USE as le,$createLineBreakNode as re,$cloneWithProperties as ae,getRegisteredNode as ce,isHTMLElement as se,isDocumentFragment as de,$isBlockElementNode as ue,isBlockDomNode as he,isInlineDomNode as pe,TextNode as me}from"lexical";import{HistoryPlugin as ge}from"@lexical/react/LexicalHistoryPlugin";import{ListPlugin as be}from"@lexical/react/LexicalListPlugin";import{REMOVE_LIST_COMMAND as fe,INSERT_ORDERED_LIST_COMMAND as ye,INSERT_UNORDERED_LIST_COMMAND as ve,ListNode as xe,$isListNode as we,ListItemNode as Ce}from"@lexical/list";import{INSERT_HORIZONTAL_RULE_COMMAND as ke,HorizontalRuleNode as Ne}from"@lexical/react/LexicalHorizontalRuleNode";import{HorizontalRulePlugin as Se}from"@lexical/react/LexicalHorizontalRulePlugin";import{TablePlugin as _e}from"@lexical/react/LexicalTablePlugin";import{$findCellNode as Le,INSERT_TABLE_COMMAND as Te,$isTableCellNode as Ee,TableCellHeaderStates as Ae,$insertTableRowAtSelection as Me,$deleteTableRowAtSelection as Re,$insertTableColumnAtSelection as De,$deleteTableColumnAtSelection as ze,TableNode as Fe,TableRowNode as We,TableCellNode as Oe}from"@lexical/table";import{RxLetterCaseLowercase as Ie,RxLetterCaseUppercase as He,RxLetterCaseCapitalize as Ue}from"react-icons/rx";import{TbBold as $e,TbItalic as Pe,TbUnderline as Ke,TbSeparatorHorizontal as Be,TbArrowsLeftRight as Je}from"react-icons/tb";import{BsSuperscript as qe,BsSubscript as Ve,BsChatSquareQuote as je,BsArrowCounterclockwise as Qe,BsArrowClockwise as Xe,BsJustifyLeft as Ye,BsTextCenter as Ge,BsJustifyRight as Ze,BsJustify as et,BsTextParagraph as tt,BsTypeH1 as nt,BsTypeH2 as ot,BsTypeH3 as it,BsTypeH4 as lt,BsTypeH5 as rt,BsTypeH6 as at,BsPencilSquare as ct,BsListOl as st,BsListUl as dt,BsTable as ut,BsFullscreenExit as ht,BsFullscreen as pt,BsThreeDots as mt,BsSun as gt,BsMoon as bt}from"react-icons/bs";import{AiOutlineStrikethrough as ft,AiOutlineFontColors as yt,AiOutlineBgColors as vt}from"react-icons/ai";import{IoCodeSlashOutline as xt,IoChevronUp as wt,IoChevronDown as Ct,IoClose as kt,IoImageOutline as Nt,IoSearchOutline as St,IoCodeOutline as _t}from"react-icons/io5";import{PiHighlighterLight as Lt}from"react-icons/pi";import{RiEraserLine as Tt,RiIndentIncrease as Et,RiIndentDecrease as At,RiFontFamily as Mt}from"react-icons/ri";import{useLexicalComposerContext as Rt}from"@lexical/react/LexicalComposerContext";import{TOGGLE_LINK_COMMAND as Dt,$isLinkNode as zt,LinkNode as Ft}from"@lexical/link";import{HiChevronDown as Wt}from"react-icons/hi2";import{createPortal as Ot}from"react-dom";import{IoIosLink as It}from"react-icons/io";import{MdCheck as Ht,MdMonitor as Ut,MdWrapText as $t}from"react-icons/md";import{BiUnlink as Pt}from"react-icons/bi";import{SketchPicker as Kt}from"react-color";import{LuMinus as Bt,LuPlus as Jt,LuUpload as qt}from"react-icons/lu";import{FaYoutube as Vt}from"react-icons/fa";import{VscPreview as jt}from"react-icons/vsc";import{LinkPlugin as Qt}from"@lexical/react/LexicalLinkPlugin";import{OnChangePlugin as Xt}from"@lexical/react/LexicalOnChangePlugin";var Yt,Gt;!function(e){e.Bold="bold",e.Italics="italics",e.Underline="underline",e.Quote="quote",e.Lowercase="lowercase",e.Uppercase="uppercase",e.Capitalize="capitalize",e.Strikethrough="strikethrough",e.Superscript="superscript",e.Subscript="subscript",e.Highlight="highlight",e.Code="code",e.Link="link",e.LeftAlign="leftAlign",e.CenterAlign="centerAlign",e.RightAlign="rightAlign",e.JustifyAlign="justifyAlign",e.Divider="divider",e.Undo="undo",e.Redo="redo",e.ClearFormatting="clearFormatting",e.CodeBlock="codeBlock",e.HorizontalRule="horizontalRule",e.Indent="indent",e.Outdent="outdent",e.Table="table",e.FindReplace="findReplace",e.SourceView="sourceView",e.Fullscreen="fullscreen"}(Yt||(Yt={})),function(e){e.Normal="normal",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6"}(Gt||(Gt={}));const Zt=[{id:Yt.Lowercase,icon:e(Ie,{}),label:"Lowercase"},{id:Yt.Uppercase,icon:e(He,{}),label:"Uppercase"},{id:Yt.Capitalize,icon:e(Ue,{}),label:"Capitalize"},{id:Yt.Superscript,icon:e(qe,{}),label:"Superscript"},{id:Yt.Subscript,icon:e(Ve,{}),label:"Subscript"}],en=[{id:Yt.Bold,icon:e($e,{}),label:"Bold"},{id:Yt.Italics,icon:e(Pe,{}),label:"Italics"},{id:Yt.Underline,icon:e(Ke,{}),label:"Underline"},{id:Yt.Strikethrough,icon:e(ft,{}),label:"Strikethrough"}],tn=[{id:Yt.Highlight,icon:e(Lt,{}),label:"Highlight"}],nn=[{id:Yt.Quote,icon:e(je,{}),label:"Quote"},{id:Yt.Code,icon:e(xt,{}),label:"Code"}],on=[{id:Yt.Undo,icon:e(Qe,{}),label:"Undo"},{id:Yt.Redo,icon:e(Xe,{}),label:"Redo"},{id:Yt.ClearFormatting,icon:e(Tt,{}),label:"Clear Formatting"}],ln=[{id:Yt.Indent,icon:e(Et,{}),label:"Indent"},{id:Yt.Outdent,icon:e(At,{}),label:"Outdent"}],rn=[{id:Yt.HorizontalRule,icon:e(Be,{}),label:"Horizontal Rule"}],an=[{id:Yt.LeftAlign,icon:e(Ye,{}),label:"Left Align"},{id:Yt.CenterAlign,icon:e(Ge,{}),label:"Center Align"},{id:Yt.RightAlign,icon:e(Ze,{}),label:"Right Align"},{id:Yt.JustifyAlign,icon:e(et,{}),label:"Justify Align"}],cn=[{id:"normal",label:"Normal",icon:e(tt,{})},{id:"h1",label:"Heading 1",icon:e(nt,{})},{id:"h2",label:"Heading 2",icon:e(ot,{})},{id:"h3",label:"Heading 3",icon:e(it,{})},{id:"h4",label:"Heading 4",icon:e(lt,{})},{id:"h5",label:"Heading 5",icon:e(rt,{})},{id:"h6",label:"Heading 6",icon:e(at,{})}],sn=[{id:"plaintext",label:"Plain Text"},{id:"javascript",label:"JavaScript"},{id:"typescript",label:"TypeScript"},{id:"python",label:"Python"},{id:"java",label:"Java"},{id:"csharp",label:"C#"},{id:"cpp",label:"C++"},{id:"php",label:"PHP"},{id:"ruby",label:"Ruby"},{id:"go",label:"Go"},{id:"rust",label:"Rust"},{id:"swift",label:"Swift"},{id:"kotlin",label:"Kotlin"},{id:"html",label:"HTML"},{id:"css",label:"CSS"},{id:"sql",label:"SQL"},{id:"json",label:"JSON"},{id:"bash",label:"Bash"},{id:"markdown",label:"Markdown"},{id:"yaml",label:"YAML"},{id:"xml",label:"XML"}];function dn(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const un=new Map;function hn(e){let t=un.get(e);return void 0===t&&(t=function(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim())}return t}(e),un.set(e,t)),t}function pn(e,t){(R(e)?e.isCollapsed():D(e)||L(e))||dn(280);const n=hn(R(e)?e.style:D(e)?e.getStyle():e.getTextStyle()),o=Object.entries(t).reduce((t,[o,i])=>("function"==typeof i?t[o]=i(n[o],e):null===i?delete t[o]:t[o]=i,t),{...n}),i=function(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}(o);R(e)||D(e)?e.setStyle(i):e.setTextStyle(i),un.set(i,o)}function mn(e,t){if(R(e)&&e.isCollapsed()){pn(e,t);const n=e.anchor.getNode();L(n)&&n.isEmpty()&&pn(n,t)}!function(e){const t=T();if(!t)return;const n=new Map,o=e=>n.get(e.getKey())||[0,e.getTextContentSize()];if(R(t))for(const e of I(t).getTextSlices())e&&n.set(e.caret.origin.getKey(),e.getSliceIndices());const i=t.getNodes();for(const t of i){if(!D(t)||!t.canHaveFormat())continue;const[n,i]=o(t);i!==n&&(z(t)||0===n&&i===t.getTextContentSize()?e(t):e(t.splitText(n,i)[0===n?0:1]))}R(t)&&"text"===t.anchor.type&&"text"===t.focus.type&&t.anchor.key===t.focus.key&&function(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:i,type:l}=t;t.set(n.key,n.offset,n.type),n.set(o,i,l)}}(t)}(e=>{pn(e,t)})}function gn(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function bn(e,t,n=gn){if(null===e)return;const o=e.getStartEndPoints(),i=new Map;let l=null;if(o){const[e,t]=o;l=N(),l.anchor.set(e.key,e.offset,e.type),l.focus.set(t.key,t.offset,t.type);const n=S(e.getNode(),_),r=S(t.getNode(),_);L(n)&&i.set(n.getKey(),n),L(r)&&i.set(r.getKey(),r)}for(const t of e.getNodes())if(L(t)&&_(t))i.set(t.getKey(),t);else if(null===o){const e=S(t,_);L(e)&&i.set(e.getKey(),e)}for(const[e,o]of i){const i=t();n(o,i),o.replace(i,!0),l&&(e===l.anchor.key&&l.anchor.set(i.getKey(),l.anchor.offset,l.anchor.type),e===l.focus.key&&l.focus.set(i.getKey(),l.focus.offset,l.focus.type))}l&&e.is(T())&&E(l)}function fn(e){return e.getNode().isAttached()}function yn(e){let t=e;for(;null!==t&&!A(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function vn(e,t,n=null){const o=e.getStartEndPoints(),i=o?o[0]:null,l=e.getNodes(),r=l.length;if(null!==i&&(0===r||1===r&&"element"===i.type&&0===i.getNode().getChildrenSize())){const e="text"===i.type?i.getNode().getParentOrThrow():i.getNode(),o=e.getChildren();let l=t();return l.setFormat(e.getFormatType()),l.setIndent(e.getIndent()),o.forEach(e=>l.append(e)),n&&(l=n.append(l)),void e.replace(l)}let a=null,c=[];for(let o=0;o<r;o++){const i=l[o];A(i)?(xn(e,c,c.length,t,n),c=[],a=i):null===a||null!==a&&M(i,a)?c.push(i):(xn(e,c,c.length,t,n),c=[i])}xn(e,c,c.length,t,n)}function xn(e,t,n,o,i=null){if(0===t.length)return;const l=t[0],r=new Map,a=[];let c=L(l)?l:l.getParentOrThrow();c.isInline()&&(c=c.getParentOrThrow());let s=!1;for(;null!==c;){const e=c.getPreviousSibling();if(null!==e){c=e,s=!0;break}if(c=c.getParentOrThrow(),A(c))break}const d=new Set;for(let e=0;e<n;e++){const n=t[e];L(n)&&0===n.getChildrenSize()&&d.add(n.getKey())}const u=new Set;for(let e=0;e<n;e++){const n=t[e];let i=n.getParent();if(null!==i&&i.isInline()&&(i=i.getParent()),null!==i&&W(n)&&!u.has(n.getKey())){const e=i.getKey();if(void 0===r.get(e)){const t=o();t.setFormat(i.getFormatType()),t.setIndent(i.getIndent()),a.push(t),r.set(e,t),i.getChildren().forEach(e=>{t.append(e),u.add(e.getKey()),L(e)&&e.getChildrenKeys().forEach(e=>u.add(e))}),yn(i)}}else if(d.has(n.getKey())){L(n)||dn(179);const e=o();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),a.push(e),n.remove(!0)}}if(null!==i)for(let e=0;e<a.length;e++){const t=a[e];i.append(t)}let h=null;if(A(c))if(s)if(null!==i)c.insertAfter(i);else for(let e=a.length-1;e>=0;e--){const t=a[e];c.insertAfter(t)}else{const e=c.getFirstChild();if(L(e)&&(c=e),null===e)if(i)c.append(i);else for(let e=0;e<a.length;e++){const t=a[e];c.append(t),h=t}else if(null!==i)e.insertBefore(i);else for(let t=0;t<a.length;t++){const n=a[t];e.insertBefore(n),h=n}}else if(i)c.insertAfter(i);else for(let e=a.length-1;e>=0;e--){const t=a[e];c.insertAfter(t),h=t}const p=O();R(p)&&fn(p.anchor)&&fn(p.focus)?E(p.clone()):null!==h?h.selectEnd():e.dirty=!0}function wn(e,t,n){const o=hn(e.getStyle());return null!==o&&o[t]||n}function Cn(e,t,n=""){let o=null;const i=e.getNodes(),l=e.anchor,r=e.focus,a=e.isBackward(),c=a?r.offset:l.offset,s=a?r.getNode():l.getNode();if(R(e)&&e.isCollapsed()&&""!==e.style){const n=hn(e.style);if(null!==n&&t in n)return n[t]}for(let e=0;e<i.length;e++){const l=i[e];if((0===e||0!==c||!l.is(s))&&D(l)){const e=wn(l,t,n);if(null===o)o=e;else if(o!==e){o="";break}}}return null===o?n:o}const kn="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Nn=kn&&"documentMode"in document?document.documentMode:null;function Sn(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function _n(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}function Ln({open:t,onOpenChange:n,children:o}){const c=l(null),s=l(null);return r(()=>{function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||n(!1)}return t&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t,n]),e("div",{className:"popover-root",children:i.Children.map(o,e=>e&&"object"==typeof e?e.type===Tn?a(e,{triggerRef:c}):e.type===En?a(e,{contentRef:s,triggerRef:c}):e:e)})}function Tn({children:t,triggerRef:n}){return e("div",{className:"popover-trigger",ref:n,children:t})}function En({open:t,align:n="start",children:o,contentRef:a,triggerRef:c}){const s=l(null),[d,u]=i.useState(!1);return r(()=>{if(!t)return;const e=()=>{const e=s.current,t=c?.current;if(!e||!t)return;const o=t.closest(".lexical-text-editor"),i=!!o?.classList.contains("lexical-dark");e.classList.contains("lexical-dark")!==i&&e.classList.toggle("lexical-dark",i);const l=t.getBoundingClientRect(),r=e.offsetWidth,a=e.offsetHeight;let d=l.left;"center"===n?d=l.left+l.width/2-r/2:"end"===n&&(d=l.right-r),d=Math.max(8,Math.min(window.innerWidth-r-8,d));let h=l.bottom+4;h+a>window.innerHeight-8&&l.top>a+8&&(h=l.top-a-4),e.style.left=`${d}px`,e.style.top=`${h}px`,u(i)};return e(),requestAnimationFrame(e),window.addEventListener("resize",e),document.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),document.removeEventListener("scroll",e,!0)}},[t,n,c]),t?Ot(e("div",{ref:s,className:"lexical-text-editor"+(d?" lexical-dark":""),"data-lte-popover-portal":"true",onMouseDown:e=>e.preventDefault(),style:{position:"fixed",top:0,left:0,zIndex:9999,background:"transparent",border:"none",borderRadius:0,boxShadow:"none",padding:0,margin:0,height:"fit-content",maxWidth:"none"},children:e("div",{ref:e=>{a.current=e},className:"popover-content",style:{position:"static",top:"auto",left:"auto",borderRadius:6,border:"none",margin:0,width:"100%"},children:o})}),document.body):null}function An({onAction:n,selectionMap:o}){const[i,r]=c(!1),a=l(null),s=l(null);return t(Ln,{open:i,onOpenChange:r,children:[e(Tn,{triggerRef:a,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),children:[e("span",{children:"Aa"}),e(Wt,{className:"chevron "+(i?"rotated":"")})]})}),e(En,{open:i,align:"start",onClose:()=>r(!1),contentRef:s,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:Zt.map(({id:i,label:l,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),r(!1)},style:{minWidth:130},children:[a,e("span",{className:"label",children:l})]},i))})})]})}function Mn(){return e("div",{className:"lexical-separator"})}function Rn({updateHeading:n,headingSelectionMap:o}){const i=cn.find(e=>o[e.id]),[r,a]=c(!1),s=l(null),d=l(null);return t(Ln,{open:r,onOpenChange:a,children:[e(Tn,{triggerRef:s,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(r?"toolbar-active":"toolbar"),onClick:()=>a(e=>!e),style:{minWidth:132},children:[i?.icon,e("span",{children:i?.label}),e(Wt,{className:"chevron "+(r?"rotated":"")})]})}),e(En,{open:r,align:"start",onClose:()=>a(!1),contentRef:d,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:cn.map(({id:i,label:l,icon:r})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),a(!1)},children:[r,e("span",{className:"label",children:l})]},i))})})]})}function Dn({linkUrl:n,setLinkUrl:o,onConfirm:i,onCancel:a,removeLink:s}){const[d,u]=c(!1),h=l(null),p=l(null);return r(()=>{"https://"===n&&u(!0)},[n]),r(()=>{d&&p.current?.focus()},[d]),r(()=>{const e=e=>{h.current&&!h.current.contains(e.target)&&a()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a]),t("div",{ref:h,className:"lexical-text-editor-link link-editor-container",children:[e("div",{className:"link-editor-input-wrapper",children:d?e("input",{ref:p,className:"link-editor-input",value:n,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),i(n),u(!1)):"Escape"===e.key&&(e.preventDefault(),u(!1),a())}}):e("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"link-editor-url",children:n})}),t("div",{className:"link-editor-buttons",children:[e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{d?(i(n),u(!1)):u(!0)},children:d?e(Ht,{size:18}):e(ct,{size:14})}),e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onMouseDown:e=>e.preventDefault(),onClick:s,children:e(Pt,{size:14,style:{stroke:"black"}})})]})]})}function zn({onClose:n}){const[o]=Rt(),[i,a]=c(""),[s,d]=c(""),[u,h]=c(!1),[p,m]=c([]),[g,b]=c(0),f=l(null);r(()=>{f.current?.focus()},[]);const y=()=>{if(!i)return[];const e=u?i:i.toLowerCase(),t=[],n=H().getAllTextNodes();for(const o of n){const n=u?o.getTextContent():o.getTextContent().toLowerCase();let i=n.indexOf(e);for(;-1!==i;)t.push({key:o.getKey(),start:i}),i=n.indexOf(e,i+e.length)}return t};r(()=>{const e=o.getEditorState().read(y);m(e),b(0)},[o,i,u]),r(()=>o.registerUpdateListener(({editorState:e})=>{const t=e.read(y);m(t),b(e=>0===t.length?0:Math.min(e,t.length-1))}),[o,i,u]);const v=e=>{if(0===p.length)return;const t=(g+e+p.length)%p.length,n=p[t];b(t),o.update(()=>{const e=U(n.key);D(e)&&e.select(n.start,n.start+i.length)}),requestAnimationFrame(()=>{const e=o.getElementByKey(n.key);e?.scrollIntoView({block:"nearest"})})},x=i.length>0,w=p.length>0;return t("div",{className:"lexical-find-replace",onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),n())},children:[t("div",{className:"lexical-fr-row",children:[e("input",{ref:f,className:"lexical-fr-input",placeholder:"Find",value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),v(e.shiftKey?-1:1))}}),e("span",{className:"lexical-fr-count",children:w?`${g+1} of ${p.length}`:x?"0 results":""})]}),e("div",{className:"lexical-fr-row",children:e("input",{className:"lexical-fr-input",placeholder:"Replace with",value:s,onChange:e=>d(e.target.value)})}),t("div",{className:"lexical-fr-row",children:[t("label",{className:"lexical-fr-case",children:[e("input",{type:"checkbox",checked:u,onChange:e=>h(e.target.checked)}),e("span",{children:"Match case"})]}),e("span",{style:{flex:1}}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>v(-1),disabled:!w,"aria-label":"Previous match",children:e(wt,{})}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>v(1),disabled:!w,"aria-label":"Next match",children:e(Ct,{})}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{o.update(()=>{const e=y();if(0===e.length)return m([]),void b(0);const t=e[Math.min(g,e.length-1)],n=U(t.key);D(n)&&n.spliceText(t.start,i.length,s,!0)})},disabled:!w,children:"Replace"}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{o.update(()=>{const e=y();for(let t=e.length-1;t>=0;t--){const n=e[t],o=U(n.key);D(o)&&o.spliceText(n.start,i.length,s,!1)}})},disabled:!w,children:"Replace All"}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:n,"aria-label":"Close find and replace",children:e(kt,{})})]})]})}function Fn({anchorRef:t,onClose:n,children:o}){const i=l(null);return r(()=>{const e=e=>{const o=e.target;o instanceof HTMLElement&&o.closest("[data-lte-popover-portal]")||!i.current||i.current.contains(o)||t.current&&t.current.contains(o)||n()},o=e=>{"Escape"===e.key&&n()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",o)}},[t,n]),e("div",{ref:i,className:"lte-overflow-panel",onMouseDown:e=>e.preventDefault(),children:e("div",{className:"lte-overflow-grid",children:o})})}function Wn({onAction:n,alignmentSelectionMap:o}){const i=an.find(e=>o[e.id]),[r,a]=c(!1),s=l(null),d=l(null);return t(Ln,{open:r,onOpenChange:a,children:[e(Tn,{triggerRef:s,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(r?"toolbar-active":"toolbar"),onClick:()=>a(e=>!e),style:{minWidth:146},children:[i?.icon,e("span",{children:i?.label}),e(Wt,{className:"chevron "+(r?"rotated":"")})]})}),e(En,{open:r,align:"start",onClose:()=>a(!1),contentRef:d,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:an.map(({id:i,label:l,icon:r})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),a(!1)},children:[r,e("span",{className:"label",children:l})]},i))})})]})}function On({color:n,onChange:o,icon:i}){const[a,s]=c(!1),d=l(null),u=l(null);r(()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&d.current&&!d.current.contains(e.target)&&s(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);return t("div",{className:"color-picker-wrapper",children:[e("button",{type:"button",ref:d,className:`size-10 lexical-btn ${a?"toolbarActive":"toolbar"} icon`,onClick:()=>s(e=>!e),children:i}),a&&Ot(e("div",{ref:u,className:"lexical-color-popover "+(a?"open":""),"data-lte-popover-portal":"true",style:{top:d.current?.getBoundingClientRect().bottom,left:d.current?.getBoundingClientRect().left,position:"absolute"},onMouseDown:e=>{e.preventDefault(),(e=>{e.preventDefault()})(e)},children:e(Kt,{color:n,onChangeComplete:e=>{o(e.hex)}})}),document.body)]})}function In(){const[o]=Rt(),[{color:i,bgColor:l},a]=c({color:"#000",bgColor:"#fff"}),s=()=>{const e=T();if(R(e)){const t=Cn(e,"color","#000"),n=Cn(e,"background","#fff");a({color:t,bgColor:n})}};r(()=>Sn(o.registerUpdateListener(({editorState:e})=>{e.read(()=>{s()})}),o.registerCommand($,()=>(s(),!1),1)),[o]);const d=({property:e,color:t})=>{o.update(()=>{const n=T();n&&mn(n,{[e]:t})})};return t(n,{children:[e(On,{color:i,onChange:e=>{d({property:"color",color:e})},icon:e(yt,{})}),e(On,{color:l,onChange:e=>{d({property:"background",color:e})},icon:e(vt,{})})]})}function Hn({icon:n,tooltipLabel:o,currentValue:i,options:r,onSelect:a,minWidth:s=132}){const d=r.find(e=>""!==e.id&&e.id===i),[u,h]=c(!1),p=l(null),m=l(null);return t(Ln,{open:u,onOpenChange:h,children:[e(Tn,{triggerRef:p,children:t("button",{type:"button","aria-label":o,className:"lexical-btn heading-trigger font-trigger "+(u?"toolbar-active":"toolbar"),style:{minWidth:s},onClick:()=>h(e=>!e),children:[n,e("span",{children:d?.label??"Default"}),e(Wt,{className:"chevron "+(u?"rotated":"")})]})}),e(En,{open:u,align:"start",onClose:()=>h(!1),contentRef:m,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:r.map(t=>e("button",{type:"button",className:"lexical-btn "+(""===t.id&&""===i||""!==t.id&&t.id===i?"toolbar-active":"toolbar"),onClick:()=>{a(t.id),h(!1)},children:e("span",{className:"label",children:t.label})},t.label))})})]})}kn&&"InputEvent"in window&&!Nn&&new window.InputEvent("input");const Un=[{id:"",label:"Default"},{id:"Inter",label:"Inter"},{id:"System UI",label:"System"},{id:"serif",label:"Serif"},{id:"monospace",label:"Monospace"},{id:"cursive",label:"Cursive"},{id:"Georgia",label:"Georgia"},{id:"Courier New",label:"Courier"}];function $n(){const[t]=Rt(),[n,o]=c(""),i=()=>{const e=T();if(R(e)){const t=Cn(e,"font-family","");o((e=>e.replace(/['"]/g,"").trim())(t))}};r(()=>Sn(t.registerUpdateListener(({editorState:e})=>{e.read(()=>{i()})}),t.registerCommand($,()=>(i(),!1),1)),[t]);return e(Hn,{icon:e(Mt,{}),tooltipLabel:"Font Family",currentValue:n,options:Un,onSelect:e=>{t.update(()=>{const t=T();R(t)&&mn(t,{"font-family":""===e?null:e})})}})}const Pn=({content:n,direction:o="top",delay:i=400,children:r})=>{const[a,s]=c(!1),[d,u]=c(null),h=l(null),p=l(null),m=()=>{h.current=window.setTimeout(()=>{const e=p.current;if(e){const t=e.getBoundingClientRect();u({left:t.left,top:t.top,right:t.right,bottom:t.bottom,width:t.width,height:t.height})}s(!0)},i)},g=()=>{h.current&&clearTimeout(h.current),s(!1)};if(!d)return e("div",{ref:p,className:"Lexical-Tooltip-Wrapper",onMouseEnter:m,onMouseLeave:g,children:r});const b=d.left+d.width/2,f=d.top+d.height/2,y="bottom"===o?{top:d.bottom+10,left:b,bottom:"auto"}:"top"===o?{bottom:window.innerHeight-d.top+10,top:"auto",left:b}:"right"===o?{left:d.right+10,right:"auto",top:f}:{left:"auto",right:window.innerWidth-d.left+10,top:f};return t("div",{ref:p,className:"Lexical-Tooltip-Wrapper",onMouseEnter:m,onMouseLeave:g,children:[r,a&&Ot(e("div",{className:`Lexical-Tooltip-Tip ${o}`,style:{position:"fixed",pointerEvents:"none",...y,zIndex:1e4},children:n}),document.body)]})};function Kn(){const[n]=Rt(),[o,i]=c(""),l=()=>{const e=T();if(R(e)){let t=Bn(Cn(e,"font-size",""));if(!t)try{const o=n.getElementByKey(e.anchor.getNode().getKey());o&&(t=window.getComputedStyle(o).fontSize||"")}catch{}i(Bn(t))}};r(()=>Sn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{l()})}),n.registerCommand($,()=>(l(),!1),1)),[n]);const a=e=>{const t=Number.parseInt(o,10);(e=>{const t=Math.min(90,Math.max(6,e));n.update(()=>{const e=T();R(e)&&mn(e,{"font-size":`${t}px`})})})((Number.isNaN(t)?16:t)+e)},s=Number.parseInt(o,10),d=Number.isNaN(s)?null:s;return t("div",{className:"lexical-stepper","aria-label":"Font Size",role:"group",children:[e(Pn,{content:"Decrease font size",direction:"bottom",children:e("button",{type:"button","aria-label":"Decrease Font Size",className:"lexical-stepper-btn",disabled:null!==d&&d<=6,onClick:()=>a(-1),children:e(Bt,{})})}),e("span",{className:"lexical-stepper-value",children:d??"—"}),e(Pn,{content:"Increase font size",direction:"bottom",children:e("button",{type:"button","aria-label":"Increase Font Size",className:"lexical-stepper-btn",disabled:null!==d&&d>=90,onClick:()=>a(1),children:e(Jt,{})})})]})}const Bn=e=>e.trim();function Jn(){const[n]=Rt(),[o,i]=c(!1),[a,s]=c(null),[d,u]=c(!1),h=l(null),p=l(null),m=()=>{const e=T();if(R(e)){const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow(),o=f(n);i(o),o&&s(n.getLanguage()??null)}};r(()=>Sn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{m()})}),n.registerCommand($,()=>(m(),!1),1)),[n]);const g=sn.find(e=>e.id===a)?.label??"Plain Text";return t(Ln,{open:d,onOpenChange:u,children:[e(Tn,{triggerRef:h,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>u(e=>!e),children:[e(xt,{}),e("span",{children:g}),e(Wt,{className:"chevron "+(d?"rotated":"")})]})}),e(En,{open:d,align:"start",onClose:()=>u(!1),contentRef:p,children:t("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[t("button",{type:"button",className:"lexical-btn "+(o?"toolbar-active":"toolbar"),onClick:()=>{n.update(()=>{const e=T();if(!R(e))return;const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow();if(f(n))bn(e,()=>P());else{const t=a??"javascript";bn(e,()=>y(t))}}),u(!1)},style:{minWidth:150},children:[e(xt,{}),e("span",{className:"label",children:o?"Remove Code Block":"Code Block"})]}),e("div",{className:"w-full h-[1px] bg-gray-200 my-1"}),e("div",{style:{display:"flex",flexDirection:"column",gap:5,maxHeight:260,overflowY:"auto"},children:sn.map(({id:t,label:o})=>e("button",{type:"button",className:"lexical-btn "+(a===t?"toolbar-active":"toolbar"),onClick:()=>{var e;s(e=t),n.update(()=>{const t=T();if(!R(t))return;const n=t.anchor.getNode(),o="root"===n.getKey()?n:n.getTopLevelElementOrThrow();f(o)&&o.setLanguage(e)}),u(!1)},style:{minWidth:150},children:e("span",{className:"label",children:o})},t))})]})})]})}function qn({blockType:o}){const[i]=Rt();r(()=>Sn(i.registerCommand(K,e=>{const t=T();if(!R(t))return!1;return!!_n(t.anchor.getNode(),xe)&&(e.preventDefault(),i.dispatchCommand(e.shiftKey?B:J,void 0),!0)},q)),[i]);return t(n,{children:[e(Pn,{content:"Ordered list",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${"ol"===o?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ol"===o?i.dispatchCommand(fe,void 0):i.dispatchCommand(ye,void 0)},children:e(st,{})})}),e(Pn,{content:"Unordered list",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${"ul"===o?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ul"===o?i.dispatchCommand(fe,void 0):i.dispatchCommand(ve,void 0)},children:e(dt,{})})})]})}function Vn(){const[n]=Rt(),[o,i]=c(!1),[a,s]=c(!1),[d,u]=c(null),h=l(null),p=l(null),m=()=>{const e=T();if(R(e)){const t=Le(e.anchor.getNode());i(!!t)}else i(!1)};r(()=>Sn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{m()})}),n.registerCommand($,()=>(m(),!1),1)),[n]);const g=e=>{n.update(()=>{const t=T();R(t)&&e()}),s(!1)},b=d?`${d.rows} × ${d.cols}`:"Insert Table";return t(Ln,{open:a,onOpenChange:s,children:[e(Tn,{triggerRef:h,children:t("button",{type:"button","aria-label":"Insert Table",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>s(e=>!e),children:[e(ut,{}),e(Wt,{className:"chevron "+(a?"rotated":"")})]})}),e(En,{open:a,align:"start",onClose:()=>s(!1),contentRef:p,children:t("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t("div",{style:{width:"fit-content"},children:[e("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 18px)",gap:3},children:Array.from({length:25},(t,o)=>{const i=Math.floor(o/5)+1,l=o%5+1,r=d&&i<=d.rows&&l<=d.cols;return e("div",{onMouseEnter:()=>u({rows:i,cols:l}),onClick:()=>{return e=i,t=l,n.update(()=>{if(!R(T())){const e=H().getFirstChild();L(e)&&e.select(0,0)}}),n.dispatchCommand(Te,{rows:String(e),columns:String(t),includeHeaders:!1}),void s(!1);var e,t},style:{width:18,height:18,borderRadius:3,border:"1px solid #d1d5db",backgroundColor:r?"#c7d2fe":"#fff",cursor:"pointer"}},o)})}),e("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:b})]}),e("div",{className:"w-full h-[1px] bg-gray-200"}),t("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Me(!1)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert row above"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Me(!0)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert row below"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Re()}),style:{minWidth:160},children:e("span",{className:"label",children:"Delete row"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{De(!1)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert column left"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{De(!0)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert column right"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{ze()}),style:{minWidth:160},children:e("span",{className:"label",children:"Delete column"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>{g(()=>{const e=T();if(!R(e))return;const t=Le(e.anchor.getNode());if(!t)return;const n=t.getParent();if(!n)return;const o=n.getChildren().filter(Ee),i=o.some(e=>e.hasHeaderState(Ae.ROW));for(const e of o)e.setHeaderStyles(i?Ae.NO_STATUS:Ae.ROW,Ae.ROW)})},style:{minWidth:160},children:e("span",{className:"label",children:"Toggle header row"})})]})]})})]})}const jn=({src:n,altText:o,nodeKey:i,width:r,height:a,maxWidth:s,caption:d=""})=>{const[u]=Rt(),[h,p]=c(!1),[m,g]=c(d),b=l(null),f=l(null),y=l(null),v=l(null),x=e=>{if(!v.current||!f.current)return;const t=e.clientX-v.current.x,n=Math.min(s,Math.max(50,v.current.width+t)),o=n*f.current.ratio;f.current.width=n,f.current.height=o;const i=y.current?.querySelector("img");i&&(i.style.width=n+"px",i.style.height=o+"px")},w=()=>{if(!f.current)return;const{width:e,height:t}=f.current;u.update(()=>{const n=U(i);n&&"function"==typeof n.updateDimensions&&n.updateDimensions(e,t)}),f.current=null,v.current=null,window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",w)},C=()=>{p(!1),u.update(()=>{const e=U(i);e&&"function"==typeof e.setCaption&&e.setCaption(m)})},k=()=>{g(d),p(!0),setTimeout(()=>b.current?.focus(),0)};return t("div",{ref:y,style:{display:"inline-block",position:"relative",maxWidth:s},children:[e("img",{src:n,alt:o,width:"inherit"===r?void 0:r,height:"inherit"===a?void 0:a,style:{maxWidth:"100%",display:"block"}}),(d||h)&&e("div",{style:{textAlign:"center",marginTop:4},children:h?e("input",{ref:b,className:"lte-input",style:{width:"100%",textAlign:"center"},value:m,onChange:e=>g(e.target.value),onBlur:C,onKeyDown:e=>{"Enter"===e.key&&C()}}):e("span",{style:{fontSize:13,color:"#666",cursor:"text",display:"inline-block",minWidth:20,minHeight:18},onClick:k,children:d})}),!d&&!h&&e("div",{style:{textAlign:"center",marginTop:2},children:e("span",{style:{fontSize:12,color:"#999",cursor:"pointer"},onClick:k,children:"+ Add caption"})}),e("div",{onMouseDown:e=>{e.preventDefault(),e.stopPropagation();const t=y.current?.querySelector("img");if(!t)return;const n=t.getBoundingClientRect().width,o=t.naturalHeight/t.naturalWidth,i=n*o;v.current={x:e.clientX,y:e.clientY,width:n,height:i},f.current={width:n,height:i,ratio:o},window.addEventListener("mousemove",x),window.addEventListener("mouseup",w)},style:{position:"absolute",bottom:d||h?40:0,right:0,width:14,height:14,background:"white",border:"1px solid #999",cursor:"nwse-resize",borderRadius:2}})]})},Qn=e=>j(new Yn(e)),Xn=e=>{if(!(e instanceof HTMLImageElement))return null;const{src:t,alt:n}=e;let o,i;e.width&&(o=e.width),e.height&&(i=e.height);const l=e.style;if((!o||0===o)&&l.width){const e=parseInt(l.width,10);Number.isNaN(e)||(o=e)}if((!i||0===i)&&l.height){const e=parseInt(l.height,10);Number.isNaN(e)||(i=e)}return{node:Qn({src:t,altText:n,width:o??"inherit",height:i??"inherit"})}};class Yn extends V{constructor({src:e="",altText:t="",maxWidth:n=1080,width:o="inherit",height:i="inherit",caption:l="",key:r}={src:"",altText:""}){super(r),this.__src=e,this.__altText=t,this.__maxWidth=n,this.__width=o,this.__height=i,this.__caption=l}static getType(){return"image"}static clone(e){return new Yn({src:e.__src,altText:e.__altText,width:e.__width,height:e.__height,maxWidth:e.__maxWidth,caption:e.__caption,key:e.getKey()})}createDOM(){return document.createElement("span")}updateDOM(e){return e.__width!==this.__width||e.__height!==this.__height}exportDOM(){const e=document.createElement("img");if(e.src=this.__src,e.alt=this.__altText,"inherit"!==this.__width&&(e.width=this.__width??0),"inherit"!==this.__height&&(e.height=this.__height??0),this.__caption){const t=document.createElement("figure"),n=document.createElement("figcaption");return n.textContent=this.__caption,t.appendChild(e),t.appendChild(n),{element:t}}return{element:e}}static importDOM(){return{img:()=>({conversion:Xn,priority:1}),figure:()=>({conversion:e=>{const t=e.querySelector("img");if(!t)return null;const n=e.querySelector("figcaption"),o=n?.textContent||"",i=Xn(t);return i?.node instanceof Yn&&o&&(i.node.__caption=o),i},priority:1})}}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,maxWidth:this.__maxWidth,width:this.__width,height:this.__height,caption:this.__caption}}static importJSON(e){return new Yn({src:e.src,altText:e.altText,maxWidth:e.maxWidth,width:e.width,height:e.height,caption:e.caption})}updateDimensions(e,t){const n=this.getWritable();n.__width=e,n.__height=t}setCaption(e){this.getWritable().__caption=e}decorate(){return e(jn,{src:this.__src,altText:this.__altText,nodeKey:this.getKey(),width:this.__width,height:this.__height,maxWidth:this.__maxWidth,caption:this.__caption})}}function Gn({open:n,onClose:o,forPreview:i=!1,children:a}){const c=l(null);return r(()=>{if(!n)return;const e=e=>{c.current&&!c.current.contains(e.target)&&o()},t=e=>{"Escape"===e.key&&o()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[n,o]),n?e("div",{className:"lexical-text-editor-dialog lte-dialog-overlay",children:t("div",{ref:c,className:"lte-dialog "+(i?"preview":""),children:[e("button",{type:"button",className:"lte-dialog-close",onClick:o,children:"×"}),a]})}):null}async function Zn(e,{src:t,altText:n="",caption:o=""}){e.update(()=>{const e=Qn({src:t,altText:n,caption:o});Y([e])})}function eo({onImageUpload:n}){const[o]=Rt(),i=l(null),[a,d]=c(!1),[u,h]=c(""),[p,m]=c(""),[g,b]=c(""),[f,y]=c(),[v,x]=c(!1),w=s(async(e,t="",i="")=>{let l;l=n?await n(e):URL.createObjectURL(e),Zn(o,{src:l,altText:t,caption:i})},[o,n]);return r(()=>{const e=o.registerCommand(Q,e=>{if(e instanceof ClipboardEvent){const t=e.clipboardData?.items;if(!t)return!1;for(const n of t)if(n.type.startsWith("image/")){e.preventDefault();const t=n.getAsFile();return t&&w(t,"","").catch(console.error),!0}}return!1},X);return()=>e()},[o,w]),t("div",{className:"lexical-text-editor-dialog",children:[e("input",{type:"file",ref:i,accept:"image/*",className:"lte-hidden",onChange:e=>{const t=e.target.files?.[0];t&&y(t),e.target.value=""}}),e(Pn,{content:"Add Image",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${a?"toolbarActive":"toolbar"} icon`,onClick:()=>d(e=>!e),children:e(Nt,{size:18})})}),t(Gn,{open:a,onClose:()=>d(!1),children:[e("div",{className:"lte-dialog-header",children:"Add Image"}),t("div",{className:"lte-dialog-body",children:[e("input",{className:"lte-input",placeholder:"Alt text",value:p,onChange:e=>m(e.target.value)}),e("input",{className:"lte-input",placeholder:"Caption",value:g,onChange:e=>b(e.target.value)}),e("input",{className:"lte-input",placeholder:"Add image by URL",value:u,onChange:e=>h(e.target.value)}),e("div",{className:"lte-divider",children:e("span",{children:"or"})}),t("button",{type:"button",className:"lexical-btn heading-trigger toolbar-active",onClick:()=>i.current?.click(),style:{width:"fit-content",margin:"0 auto"},children:[e(qt,{size:20}),e("span",{children:"Upload Image"})]}),f&&e("div",{className:"lte-file-name",children:f.name})]}),e("div",{className:"lte-dialog-footer",children:e("button",{type:"button",className:"lte-primary-btn",disabled:!u&&!f||v,onClick:async()=>{if(!v){if(f){x(!0);try{await w(f,p,g)}catch(e){return console.error("Image upload failed:",e),void x(!1)}x(!1)}else{if(!u)return;Zn(o,{src:u,altText:p,caption:g})}y(void 0),m(""),b(""),h(""),d(!1)}},children:v?"Uploading...":"Add Image"})})]})]})}const to=({id:e,provider:t})=>new co({id:e,provider:t}),no="data-lexical-video",oo="data-provider",io="315px",lo="560px",ro=(e,t)=>"drive"===t?`https://drive.google.com/file/d/${e}/preview`:`https://www.youtube-nocookie.com/embed/${e}`,ao=e=>{const t=e?.getAttribute(no),n=e?.getAttribute(oo)??"youtube";if(!t)return null;return{node:to({id:t,provider:n})}};class co extends V{constructor({id:e,provider:t,key:n}){super(n),this.__id=e,this.__provider=t}static getType(){return"video"}static clone(e){return new co({id:e.__id,provider:e.__provider,key:e.getKey()})}static importJSON(e){return to({id:e.id,provider:e.provider})}exportJSON(){return{id:this.__id,provider:this.__provider,type:"video",version:1}}updateDOM(){return!1}decorate(){return e("iframe",{height:io,width:lo,src:ro(this.__id,this.__provider),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(no,this.__id),e.setAttribute(oo,this.__provider),e.setAttribute("height",io),e.setAttribute("width",lo),e.setAttribute("src",ro(this.__id,this.__provider)),{element:e}}static importDOM(){return{iframe:()=>({conversion:ao,priority:0})}}}function so(){const[n,o]=c(!1),[i,l]=c(!1),[a,s]=c(""),[d]=Rt();return r(()=>{n||(s(""),l(!1))},[n]),t("div",{className:"lexical-text-editor-dialog",children:[e(Pn,{content:"Embed Video",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${n?"toolbarActive":"toolbar"} icon`,onClick:()=>o(!0),children:e(Vt,{size:18,color:"red"})})}),t(Gn,{open:n,onClose:()=>o(!1),children:[e("div",{className:"lte-dialog-header",children:"Embed Video"}),t("div",{className:"lte-dialog-body",children:[e("input",{className:"lte-input",placeholder:"Add YouTube or Google Drive URL",value:a,onChange:e=>s(e.target.value)}),i&&e("p",{className:"lte-error-text",children:"It's not a valid YouTube or Google Drive URL"})]}),e("div",{className:"lte-dialog-footer",children:e("button",{type:"button",className:"lte-primary-btn",disabled:!a,onClick:()=>{if(!a)return;let e=null,t=null;const n=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(a);n&&11===n[2]?.length&&(e="youtube",t=n[2]);const i=/drive\.google\.com\/file\/d\/([a-zA-Z0-9_-]+)\//.exec(a);i&&i[1]&&(e="drive",t=i[1]),t&&e?(d.update(()=>{const n=to({id:t,provider:e});Y([n])}),s(""),l(!1),o(!1)):l(!0)},children:"Embed"})})]})]})}function uo({value:t}){return e("div",{className:"lexical-text-editor-html-preview",dangerouslySetInnerHTML:{__html:t}})}function ho({value:n,triggerLabel:o="Preview"}){const[i,l]=c(!1);return t("div",{className:"lexical-text-editor-dialog",children:[e(Pn,{content:o,direction:"bottom",children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),children:[e(jt,{size:18}),e("span",{children:o})]})}),t(Gn,{open:i,onClose:()=>l(!1),forPreview:!0,children:[e("div",{className:"lte-dialog-header",children:"Content Preview"}),t("div",{className:"lte-preview-container",children:[e("div",{className:"lte-preview-title",children:"CONTENT"}),e(uo,{value:n})]})]})]})}const po=[{id:"headings",sep:!0},{id:"fontFamily"},{id:"fontSize"},{id:"textFormats",sep:!0},{id:"dropdown",sep:!0},{id:"color",sep:!0},{id:"quoteCode",sep:!0},{id:"codeBlock"},{id:"alignment",sep:!0},{id:"lists",sep:!0},{id:"blockOptions"},{id:"table",sep:!0},{id:"hline"},{id:"link",sep:!0},{id:"image"},{id:"video"},{id:"utility",sep:!0},{id:"preview"}],mo=po.map(e=>e.id),go=({value:o,onImageUpload:i,sourceView:a=!1,onToggleSourceView:d,fullscreen:g=!1,onToggleFullscreen:b,toolbarStyle:f="wrap"})=>{const y="normal"===f?"collapse":f,[v]=Rt(),[x,w]=c({[Yt.Undo]:!0,[Yt.Redo]:!0}),[C,k]=c(!1),[N,S]=c(!1),[_,E]=c(0),[A,M]=c(!1),z=l(null),F=l(null),W=l(null),O=l({}),I=l({}),H=l(0),U=l(null),K=l(null),[q,V]=c({[Yt.LeftAlign]:!0}),[j,Q]=c({[Gt.Normal]:!0}),[X,Y]=c("paragraph"),[ie,le]=c("https://");let re=!0;const ae=()=>{if(re){const e=v.getRootElement();e&&(e.scrollTop=0,re=!1)}const e=T();if(R(e)){const t={[Yt.Bold]:e.hasFormat("bold"),[Yt.Italics]:e.hasFormat("italic"),[Yt.Underline]:e.hasFormat("underline"),[Yt.Uppercase]:e.hasFormat("uppercase"),[Yt.Lowercase]:e.hasFormat("lowercase"),[Yt.Capitalize]:e.hasFormat("capitalize"),[Yt.Strikethrough]:e.hasFormat("strikethrough"),[Yt.Superscript]:e.hasFormat("superscript"),[Yt.Subscript]:e.hasFormat("subscript"),[Yt.Code]:e.hasFormat("code"),[Yt.Highlight]:e.hasFormat("highlight")};V(t);const n=e.anchor.getNode(),o="root"===n.getKey()?n:n.getTopLevelElementOrThrow(),i=o.getKey();if(!v.getElementByKey(i))return;if(we(o)){const e=_n(n,xe),t=e?e.getTag():o.getTag();Y(t)}else if("paragraph"===o.getType()||u(o)){let e=null;u(o)&&(e=o.getTag());const t={[Gt.H1]:"h1"===e,[Gt.H2]:"h2"===e,[Gt.H3]:"h3"===e,[Gt.H4]:"h4"===e,[Gt.H5]:"h5"===e,[Gt.H6]:"h6"===e,[Gt.Normal]:"paragraph"===o.getType()};Y(o.getType()),Q(t)}else Y(o.getType());const l=(L(n)?n:o).getFormat();V(e=>({...e,[Yt.LeftAlign]:0===l||1===l,[Yt.CenterAlign]:2===l,[Yt.RightAlign]:3===l,[Yt.JustifyAlign]:4===l})),"quote"===o.getType()?V(e=>({...e,[Yt.Quote]:!0})):V(e=>({...e,[Yt.Quote]:!1}));const r=e.anchor.getNode(),a=r.getParent();zt(a)?(V(e=>({...e,[Yt.Link]:!0})),le(a.getURL()),k(!0)):zt(r)?(V(e=>({...e,[Yt.Link]:!0})),le(r.getURL()),k(!0)):(V(e=>({...e,[Yt.Link]:!1})),le("https://"),k(!1))}};r(()=>Sn(v.registerUpdateListener(({editorState:e})=>{e.read(()=>{ae()})}),v.registerCommand($,()=>(ae(),!1),1),v.registerCommand(Z,e=>(w(t=>({...t,undo:!e})),!1),1),v.registerCommand(G,e=>(w(t=>({...t,redo:!e})),!1),1)),[]);const ce="scrollbar"===y,se=s(()=>{if("collapse"!==y)return;const e=z.current;if(!e)return;const t=e.clientWidth;if(t<=0)return;const n=F.current?F.current.offsetWidth:0,o=mo.map(e=>{const t=O.current[e];return t&&"none"!==t.style.display&&(I.current[e]=t.offsetWidth),I.current[e]??0});W.current&&(H.current=W.current.offsetWidth);const i=H.current||40,l=e=>{const t=1+(e>0?1:0)+(mo.length-e);let l=n+6*Math.max(0,t-1)+(e>0?i:0);for(let t=0;t<mo.length-e;t++)l+=o[t];return l};let r=_;for(;r<mo.length&&l(r)>t;)r++;for(;r>0&&l(r-1)<=t;)r--;E(e=>e===r?e:r)},[_,y]);r(()=>{se()});const de=l(()=>{});de.current=se,r(()=>{if("undefined"==typeof ResizeObserver)return;const e=z.current;if(!e)return;const t=new ResizeObserver(()=>{de.current(),be.current()});return t.observe(e),()=>t.disconnect()},[]),r(()=>{0===_&&M(!1)},[_]),r(()=>{"collapse"!==y&&E(0)},[y]);const ue=s(()=>{if("scrollbar"!==y)return;const e=z.current,t=U.current,n=K.current;if(!e||!t||!n)return;const o=e.clientWidth;if(e.scrollWidth-o<=1)return void(t.style.display="none");t.style.display="flex";const i=Math.max(24,o/e.scrollWidth*o),l=e.scrollWidth-o,r=o-i,a=l>0?e.scrollLeft/l*r:0;n.style.width=`${i}px`,n.style.transform=`translateX(${a}px)`},[f]),he=s(e=>{e.stopPropagation(),e.preventDefault();const t=z.current,n=K.current;if(!t||!n)return;const o=e.clientX,i=t.scrollLeft,l=t.clientWidth,r=Math.max(24,l/t.scrollWidth*l),a=t.scrollWidth-l,c=l-r,s=e=>{const n=e.clientX-o;t.scrollLeft=c>0?i+n/c*a:0},d=()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",d)};document.addEventListener("pointermove",s),document.addEventListener("pointerup",d)},[]),pe=s(e=>{const t=z.current,n=U.current;if(!t||!n)return;const o=n.getBoundingClientRect(),i=(e.clientX-o.left)/o.width;t.scrollLeft=i*t.scrollWidth-t.clientWidth/2},[]),me=l(null),ge=s(()=>{const e=me.current;if(e)for(const t of e.querySelectorAll(".lte-toolbar-row svg:not(.chevron), .lte-overflow-panel svg:not(.chevron)")){if(t.closest(".lexical-stepper"))continue;const e=t;try{const t=e.viewBox?.baseVal;if(!t||!t.width)continue;let n=1/0,o=1/0,i=-1/0,l=-1/0;if(e.querySelectorAll("path, circle, rect, ellipse, polygon, polyline, line").forEach(e=>{const t=e.getBBox();(t.width||t.height)&&(n=Math.min(n,t.x),o=Math.min(o,t.y),i=Math.max(i,t.x+t.width),l=Math.max(l,t.y+t.height))}),i===-1/0)continue;const r=((i-n)/t.width+(l-o)/t.height)/2;if(!isFinite(r)||r<=0)continue;const a=Math.min(22,Math.max(17,15/r));parseFloat(e.style.width)!==a&&(e.style.width=`${a}px`,e.style.height=`${a}px`)}catch{}}},[]);r(()=>{ge()}),r(()=>{ue()});const be=l(()=>{});be.current=ue,r(()=>{if("scrollbar"!==y)return;const e=z.current;if(!e)return;const t=()=>ue();return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[y,ue]);const fe=e=>{switch(e){case Yt.Bold:v.dispatchCommand(oe,"bold");break;case Yt.Italics:v.dispatchCommand(oe,"italic");break;case Yt.Underline:v.dispatchCommand(oe,"underline");break;case Yt.Lowercase:v.dispatchCommand(oe,"lowercase");break;case Yt.Uppercase:v.dispatchCommand(oe,"uppercase");break;case Yt.Capitalize:v.dispatchCommand(oe,"capitalize");break;case Yt.Strikethrough:v.dispatchCommand(oe,"strikethrough");break;case Yt.Superscript:v.dispatchCommand(oe,"superscript");break;case Yt.Subscript:v.dispatchCommand(oe,"subscript");break;case Yt.Highlight:v.dispatchCommand(oe,"highlight");break;case Yt.Code:v.dispatchCommand(oe,"code");break;case Yt.Quote:v.update(()=>{const e=T();if(R(e)){const t=e.anchor.getNode().getParent();t&&h(t)?bn(e,()=>P()):vn(e,()=>p())}});break;case Yt.Link:ye(),k(!0);break;case Yt.LeftAlign:v.dispatchCommand(ne,"left");break;case Yt.RightAlign:v.dispatchCommand(ne,"right");break;case Yt.CenterAlign:v.dispatchCommand(ne,"center");break;case Yt.JustifyAlign:v.dispatchCommand(ne,"justify");break;case Yt.Undo:v.dispatchCommand(te,void 0);break;case Yt.Redo:v.dispatchCommand(ee,void 0);break;case Yt.ClearFormatting:v.update(()=>{const e=T();if(!R(e))return;const t=e.getNodes().filter(D);for(const e of t)e.setFormat(0),e.setStyle("")});break;case Yt.HorizontalRule:v.dispatchCommand(ke,void 0);break;case Yt.Indent:v.dispatchCommand(J,void 0);break;case Yt.Outdent:v.dispatchCommand(B,void 0)}},ye=s(()=>{v.update(()=>{const e=T();R(e)&&!e.isCollapsed()&&(C?v.dispatchCommand(Dt,null):""!==ie&&v.dispatchCommand(Dt,ie))})},[v,C,ie]),ve=s(()=>{le(""),v.dispatchCommand(Dt,null),k(!1)},[v]),Ce=e=>mo.indexOf(e)>=mo.length-_,Ne={headings:e(Rn,{updateHeading:e=>{v.update(()=>{const t=T();R(t)&&vn(t,"normal"===e?()=>P():()=>m(e))})},headingSelectionMap:j}),fontFamily:e($n,{}),fontSize:e(Kn,{}),textFormats:e(n,{children:en.map(({id:t,label:n,icon:o})=>t===Yt.Divider?e(Mn,{},t):e(Pn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${q[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>fe(t),children:o})},t))}),dropdown:e(An,{onAction:fe,selectionMap:q}),color:t(n,{children:[e(In,{}),tn.map(({id:t,label:n,icon:o})=>e(Pn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${q[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>fe(t),children:o})},t))]}),quoteCode:e(n,{children:nn.map(({id:t,label:n,icon:o})=>e(Pn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${q[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>fe(t),children:o})},t))}),codeBlock:e(Jn,{}),alignment:e(Wn,{onAction:fe,alignmentSelectionMap:q}),lists:e(qn,{blockType:X}),blockOptions:e(n,{children:ln.map(({id:t,label:n,icon:o})=>t===Yt.Divider?e(Mn,{},t):e(Pn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${q[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>fe(t),children:o})},t))}),table:e(Vn,{}),hline:e(n,{children:rn.map(({id:t,label:n,icon:o})=>e(Pn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${q[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>fe(t),children:o})},t))}),link:e(Pn,{content:"Link",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${q[Yt.Link]?"toolbarActive":"toolbar"} icon`,onClick:()=>fe(Yt.Link),disabled:!!x[Yt.Link],children:e(It,{})})}),image:e(eo,{onImageUpload:i}),video:e(so,{}),utility:t(n,{children:[e(Pn,{content:"Find & Replace",direction:"bottom",children:e("button",{type:"button","aria-label":"Find & Replace",className:`size-10 lexical-btn ${N?"toolbarActive":"toolbar"} icon`,onClick:()=>S(e=>!e),children:e(St,{})})}),e(Pn,{content:"Source Code View",direction:"bottom",children:e("button",{type:"button","aria-label":"Source Code View",className:`size-10 lexical-btn ${a?"toolbarActive":"toolbar"} icon`,onClick:()=>d?.(),children:e(_t,{})})}),e(Pn,{content:g?"Exit Fullscreen":"Fullscreen",direction:"bottom",children:e("button",{type:"button","aria-label":g?"Exit Fullscreen":"Fullscreen",className:`size-10 lexical-btn ${g?"toolbarActive":"toolbar"} icon`,onClick:()=>b?.(),children:e(g?ht:pt,{})})})]}),preview:e(ho,{value:o})};return t("div",{ref:me,className:"lexical-toolbar-wrapper",style:{position:"relative",padding:12,marginBottom:4,borderBottom:"1px solid #e5e7eb"},children:[t("div",{ref:z,className:"lte-toolbar-row "+(ce?"useScroll":"collapse"===y?"lte-nowrap":"lte-wrap"),onMouseDown:e=>e.preventDefault(),children:[e("div",{ref:F,className:"lte-toolbar-primary",style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:on.map(({id:t,label:n,icon:o})=>t===Yt.Divider?e(Mn,{},t):e(Pn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${q[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>fe(t),disabled:!!x[t],children:o})},n))}),po.map(({id:n,sep:o})=>{const i=Ce(n);return t("div",{ref:e=>{O.current[n]=e},style:i?{display:"none"}:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[o?e(Mn,{}):null,i?null:Ne[n]]},n)}),_>0&&e(Pn,{content:"More tools",direction:"bottom",children:e("button",{type:"button",ref:W,"aria-label":"More tools",className:`size-10 lexical-btn ${A?"toolbarActive":"toolbar"} icon`,onClick:()=>M(e=>!e),children:e(mt,{})})})]}),ce&&e("div",{ref:U,className:"lte-custom-scrollbar",onPointerDown:pe,"aria-hidden":"true",children:e("div",{ref:K,className:"lte-custom-scrollbar-thumb",onPointerDown:he})}),C&&e(Dn,{linkUrl:ie,setLinkUrl:le,removeLink:ve,onConfirm:e=>{v.dispatchCommand(Dt,{url:e,target:"_blank"}),le(e),k(!1)},onCancel:()=>{le(""),k(!1)}}),A&&e(Fn,{anchorRef:W,onClose:()=>M(!1),children:po.filter(({id:e})=>Ce(e)&&Ne[e]).map(({id:n,sep:o},i)=>t("div",{className:"lte-overflow-item",children:[o&&i>0?e(Mn,{}):null,Ne[n]]},n))}),N&&e(zn,{onClose:()=>S(!1)})]})};function bo(e,t){const n=ie(t)?t.body.childNodes:t.childNodes;let o=[];const i=[];for(const t of n)if(!vo.has(t.nodeName)){const n=xo(t,e,i,!1);null!==n&&(o=o.concat(n))}return function(e){for(const t of e)t.getNextSibling()instanceof le&&t.insertAfter(re());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(i),o}function fo(e,t){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const n=document.createElement("div"),o=H().getChildren();for(let i=0;i<o.length;i++)yo(e,o[i],n,t);return n.innerHTML}function yo(e,t,n,o=null){let i=null===o||t.isSelected(o);const l=L(t)&&t.excludeFromCopy("html");let r=t;if(null!==o){let e=ae(t);e=D(e)&&null!==o?function(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!z(t)&&null!==n){const[o,i]=n,l=e.isBackward(),r=o.getNode(),a=i.getNode(),c=t.is(r),s=t.is(a);if(c||s){const[n,o]=F(e),i=r.is(a),c=t.is(l?a:r),s=t.is(l?r:a);let d,u=0;i?(u=n>o?o:n,d=n>o?n:o):c?(u=l?o:n,d=void 0):s&&(u=0,d=l?n:o),t.__text=t.__text.slice(u,d)}}return t}(o,e):e,r=e}const a=L(r)?r.getChildren():[],c=ce(e,r.getType());let s;s=c&&void 0!==c.exportDOM?c.exportDOM(e,r):r.exportDOM(e);const{element:d,after:u}=s;if(!d)return!1;const h=document.createDocumentFragment();for(let n=0;n<a.length;n++){const l=a[n],r=yo(e,l,h,o);!i&&L(t)&&r&&t.extractWithChild(l,o,"html")&&(i=!0)}if(i&&!l){if((se(d)||de(d))&&d.append(h),n.append(d),u){const e=u.call(r,d);e&&(de(d)?d.replaceChildren(e):d.replaceWith(e))}}else n.append(h);return i}const vo=new Set(["STYLE","SCRIPT"]);function xo(e,t,n,o,i=new Map,l){let r=[];if(vo.has(e.nodeName))return r;let a=null;const c=function(e,t){const{nodeName:n}=e,o=t._htmlConversions.get(n.toLowerCase());let i=null;if(void 0!==o)for(const t of o){const n=t(e);null!==n&&(null===i||(i.priority||0)<=(n.priority||0))&&(i=n)}return null!==i?i.conversion:null}(e,t),s=c?c(e):null;let d=null;if(null!==s){d=s.after;const t=s.node;if(a=Array.isArray(t)?t[t.length-1]:t,null!==a){for(const[,e]of i)if(a=e(a,l),!a)break;a&&r.push(...Array.isArray(t)?t:[a])}null!=s.forChild&&i.set(e.nodeName,s.forChild)}const u=e.childNodes;let h=[];const p=(null==a||!A(a))&&(null!=a&&ue(a)||o);for(let e=0;e<u.length;e++)h.push(...xo(u[e],t,n,p,new Map(i),a));return null!=d&&(h=d(h)),he(e)&&(h=function(e,t,n){const o=e.style.textAlign,i=[];let l=[];for(let e=0;e<t.length;e++){const r=t[e];if(ue(r))o&&!r.getFormat()&&r.setFormat(o),i.push(r);else if(l.push(r),e===t.length-1||e<t.length-1&&ue(t[e+1])){const e=n();e.setFormat(o),e.append(...l),i.push(e),l=[]}}return i}(e,h,p?()=>{const e=new le;return n.push(e),e}:P)),null==a?h.length>0?r=r.concat(h):he(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&(pe(e.nextSibling)&&pe(e.previousSibling))}(e)&&(r=r.concat(re())):L(a)&&a.append(...h),r}function wo({value:t,onChange:n}){const[o]=Rt(),[i,l]=c(!0);return r(()=>{t&&i&&(l(!1),o.update(()=>{if(fo(o)!==t){H().clear();const e=(new DOMParser).parseFromString(t,"text/html"),n=bo(o,e);Y(n)}}))},[o,t,i]),r(()=>{l(!0)},[t]),e(Xt,{onChange:e=>{e.read(()=>{n(fo(o))})}})}function Co({applyRef:n,onExit:o}){const[i]=Rt(),[a,s]=c(()=>i.getEditorState().read(()=>fo(i))),d=l(a),u=e=>{e!==d.current&&(i.update(()=>{const t=H();if(t.clear(),t.selectEnd(),e){const t=(new DOMParser).parseFromString(e,"text/html"),n=bo(i,t);n.length>0&&Y(n)}}),d.current=e)};return r(()=>(n.current=()=>{u(a),o()},()=>{n.current=null}),[n,a,o,i]),t("div",{className:"lexical-source-view",children:[e("textarea",{className:"lexical-source-textarea",value:a,onChange:e=>s(e.target.value),"aria-label":"HTML source",spellCheck:!1}),t("div",{className:"lexical-source-actions",children:[e(Pn,{content:"Apply HTML to the editor",direction:"top",children:t("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>u(a),children:[e(Ht,{size:16}),e("span",{className:"label",children:"Update"})]})}),e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{u(a),o()},children:"Done"})]})]})}function ko({showWordCount:n=!0,showCharCount:o=!0,rightSlot:i}){const[l]=Rt(),[a,s]=c({words:0,chars:0});return r(()=>{const e=e=>{e.read(()=>{const e=H().getTextContent(),t=e.trim();s({words:t?t.split(/\s+/).length:0,chars:e.length})})};return e(l.getEditorState()),l.registerUpdateListener(({editorState:t})=>{e(t)})},[l]),t("div",{className:"lexical-status-bar",children:[n&&t("span",{children:[a.words," words"]}),o&&t("span",{children:[a.chars," characters"]}),i&&e("div",{className:"lexical-status-bar-right",children:i})]})}function No({theme:n,toolbarStyle:o,onThemeChange:i,onToolbarStyleChange:l}){const r="normal"===o?"collapse":o,a=[{value:"light",label:"Light theme",icon:e(gt,{})},{value:"dark",label:"Dark theme",icon:e(bt,{})},{value:"system",label:"Follow system theme",icon:e(Ut,{})}],c=[{value:"wrap",label:"Toolbar: wrap to new lines",icon:e($t,{})},{value:"collapse",label:'Toolbar: collapse into "..."',icon:e(mt,{})},{value:"scrollbar",label:"Toolbar: scroll in one row",icon:e(Je,{})}];return t("div",{className:"lexical-display-controls",role:"group","aria-label":"Display settings",children:[e("div",{className:"lte-mini-seg",role:"radiogroup","aria-label":"Theme",children:a.map(t=>e(Pn,{content:t.label,direction:"top",children:e("button",{type:"button",role:"radio","aria-checked":n===t.value,"aria-label":t.label,className:"lte-mini-btn btn "+(n===t.value?"active":""),onClick:()=>i?.(t.value),children:t.icon})},t.value))}),e("div",{className:"lte-mini-seg",role:"radiogroup","aria-label":"Toolbar style",children:c.map(t=>e(Pn,{content:t.label,direction:"top",children:e("button",{type:"button",role:"radio","aria-checked":r===t.value,"aria-label":t.label,className:"lte-mini-btn btn "+(r===t.value?"active":""),onClick:()=>l?.(t.value),children:t.icon})},t.value))})]})}const So=({id:e})=>new Mo({id:e}),_o="data-lexical-youtube",Lo="315px",To="560px",Eo=e=>`https://www.youtube-nocookie.com/embed/${e}`,Ao=e=>{const t=e?.getAttribute(_o);if(!t)return null;return{node:So({id:t})}};class Mo extends V{constructor({id:e,key:t}){super(t),this.__id=e}static getType(){return"youtube"}static clone(e){return new Mo({id:e.__id,key:e.getKey()})}static importJSON(e){return So({id:e.id})}exportJSON(){return{id:this.__id,type:"youtube",version:1}}decorate(){return e("iframe",{height:Lo,width:To,src:Eo(this.__id),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(_o,this.__id),e.setAttribute("height",Lo),e.setAttribute("width",To),e.setAttribute("src",Eo(this.__id)),{element:e}}static importDOM(){return{iframe:()=>({conversion:Ao,priority:0})}}}class Ro extends me{constructor(e,t){super(e,t)}static getType(){return"extended-text"}static clone(e){return new Ro(e.__text,e.__key)}static importDOM(){const e=me.importDOM();return{...e,span:()=>({conversion:Do(e?.span),priority:1}),div:()=>({conversion:Do(e?.div),priority:1}),p:()=>({conversion:Do(e?.p),priority:1}),b:()=>({conversion:Do(e?.b),priority:1}),strong:()=>({conversion:Do(e?.strong),priority:1}),i:()=>({conversion:Do(e?.i),priority:1}),em:()=>({conversion:Do(e?.em),priority:1}),u:()=>({conversion:Do(e?.u),priority:1}),s:()=>({conversion:Do(e?.s),priority:1}),strike:()=>({conversion:Do(e?.strike),priority:1}),code:()=>({conversion:Do(e?.code),priority:1})}}static importJSON(e){return function(e=""){return j(new Ro(e))}().updateFromJSON(e)}isSimpleText(){return"extended-text"===this.__type&&0===this.__mode}}function Do(e){return t=>{const n=e?.(t);if(!n)return null;const o=n.conversion(t);if(!o)return o;const i=t.style,l=[];i.backgroundColor&&l.push(`background-color: ${i.backgroundColor}`),i.color&&l.push(`color: ${i.color}`),i.fontFamily&&l.push(`font-family: ${i.fontFamily}`),i.fontWeight&&l.push(`font-weight: ${i.fontWeight}`),i.fontSize&&l.push(`font-size: ${i.fontSize}`),i.fontStyle&&l.push(`font-style: ${i.fontStyle}`),i.textDecoration&&l.push(`text-decoration: ${i.textDecoration}`),i.whiteSpace&&l.push(`white-space: ${i.whiteSpace}`),i.textAlign&&l.push(`text-align: ${i.textAlign}`);const r=t.getAttribute("style");if(r){r.split(";").filter(e=>e.trim()).forEach(e=>{const[t]=e.split(":").map(e=>e.trim());t&&!l.some(e=>e.startsWith(t))&&l.push(e.trim())})}return{...o,forChild:(e,t)=>{const n=o?.forChild??(e=>e),i=n(e,t);if(D(i)&&l.length>0){const e=l.join("; ");return i.setStyle(e)}return i}}}}const zo={text:{bold:"lexical-bold",underline:"lexical-underline",italic:"lexical-italic",strikethrough:"lexical-strikethrough",underlineStrikethrough:"lexical-underline-strikethrough",uppercase:"lexical-uppercase",lowercase:"lexical-lowercase",capitalize:"lexical-capitalize",code:"lexical-code"},paragraph:"lexical-paragraph",list:{ul:"lexical-list-ul",ol:"lexical-list-ol",listitem:"lexical-listitem"},quote:"lexical-quote",link:"lexical-link",code:"lexical-code-block",hr:"lexical-hr",indent:"lexical-indent",table:"lexical-table",tableRow:"lexical-table-row",tableCell:"lexical-table-cell",codeHighlight:{keyword:"lexical-code-token-keyword",string:"lexical-code-token-string",number:"lexical-code-token-number",comment:"lexical-code-token-comment",function:"lexical-code-token-function",operator:"lexical-code-token-operator",punctuation:"lexical-code-token-punctuation"}},Fo=i.memo(function({name:n,value:i,onChange:a,placeholder:s,maxWidth:u=null,height:h=null,onImageUpload:p,showWordCount:m=!0,showCharCount:f=!0,theme:y="system",toolbarStyle:N="collapse",showDisplayControls:S=!0,onThemeChange:_,onToolbarStyleChange:L}){const[T,E]=c(!1),[A,M]=c(!1),R=l(null),[D,z]=c(!1),[F,W]=c(y),[O,I]=c("normal"===N?"collapse":N);r(()=>{W(y)},[y]),r(()=>{I("normal"===N?"collapse":N)},[N]),r(()=>{if("system"!==F||"undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)");z(e.matches);const t=e=>z(e.matches);return e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))},[F]);const H="dark"===F||"system"===F&&D;r(()=>{if(!A)return;const e=e=>{"Escape"===e.key&&M(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[A]);const U=d(()=>({namespace:n,theme:zo,onError:e=>{console.error("Lexical error:",e)},nodes:[Ro,{replace:me,with:e=>new Ro(e.__text),withKlass:Ro},g,v,x,xe,Ce,b,Ft,Yn,Mo,co,Ne,Fe,We,Oe]}),[n]);return e("div",{className:`lexical-text-editor lexical-editor-container ${A?"lexical-fullscreen":""} ${H?"lexical-dark":""}`,style:{maxWidth:A?"none":u||"1090px"},children:t(o,{initialConfig:U,children:[e("div",{className:"lexical-toolbar-container",children:e(go,{value:i,onImageUpload:p,sourceView:T,onToggleSourceView:()=>{E(e=>!e||(R.current?.(),!1))},fullscreen:A,onToggleFullscreen:()=>{M(e=>!e)},toolbarStyle:O})}),e("div",{className:"lexical-editor-inner",style:T?{display:"none"}:void 0,children:e(w,{contentEditable:e(C,{className:"lexical-content-editable",style:{height:h||"500px"}}),placeholder:e("div",{className:"lexical-placeholder",children:s||"Some Text"}),ErrorBoundary:k})}),T&&e(Co,{applyRef:R,onExit:()=>E(!1)}),(m||f||S)&&e(ko,{showWordCount:m,showCharCount:f,rightSlot:S?e(No,{theme:F,toolbarStyle:O,onThemeChange:e=>{W(e),_?.(e)},onToolbarStyleChange:e=>{I(e),L?.(e)}}):void 0}),e(ge,{}),e(be,{}),e(_e,{}),e(Se,{}),e(Qt,{}),e(wo,{value:i,onChange:a})]})})});export{Fo as LexicalTextEditor};
1
+ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{LexicalComposer as i}from"@lexical/react/LexicalComposer";import o,{createContext as r,useContext as l,useRef as a,useEffect as s,cloneElement as c,useState as d,useCallback as u,useMemo as p}from"react";import{$isHeadingNode as h,$isQuoteNode as g,$createQuoteNode as m,$createHeadingNode as b,HeadingNode as f,QuoteNode as y}from"@lexical/rich-text";import{registerCodeHighlighting as v,$isCodeNode as x,$createCodeNode as w,CodeHighlightNode as k,CodeNode as C}from"@lexical/code";import{RichTextPlugin as N}from"@lexical/react/LexicalRichTextPlugin";import{ContentEditable as _}from"@lexical/react/LexicalContentEditable";import{LexicalErrorBoundary as S}from"@lexical/react/LexicalErrorBoundary";import{$createRangeSelection as T,$findMatchingParent as L,INTERNAL_$isBlock as z,$isElementNode as E,$getSelection as A,$setSelection as F,$isRootOrShadowRoot as $,$hasAncestor as R,$isRangeSelection as D,$isTextNode as M,$isTokenOrSegmented as O,$getCharacterOffsets as W,$isLeafNode as I,$getPreviousSelection as P,$caretRangeFromSelection as B,$getRoot as H,$getNodeByKey as U,SELECTION_CHANGE_COMMAND as K,$createParagraphNode as q,KEY_TAB_COMMAND as j,OUTDENT_CONTENT_COMMAND as J,INDENT_CONTENT_COMMAND as V,COMMAND_PRIORITY_EDITOR as Z,DecoratorNode as Q,$applyNodeReplacement as X,PASTE_COMMAND as G,COMMAND_PRIORITY_LOW as Y,$insertNodes as ee,CAN_REDO_COMMAND as te,CAN_UNDO_COMMAND as ne,REDO_COMMAND as ie,UNDO_COMMAND as oe,FORMAT_ELEMENT_COMMAND as re,FORMAT_TEXT_COMMAND as le,KEY_DOWN_COMMAND as ae,COMMAND_PRIORITY_HIGH as se,KEY_ENTER_COMMAND as ce,isDOMDocumentNode as de,ArtificialNode__DO_NOT_USE as ue,$createLineBreakNode as pe,$cloneWithProperties as he,getRegisteredNode as ge,isHTMLElement as me,isDocumentFragment as be,$isBlockElementNode as fe,isBlockDomNode as ye,isInlineDomNode as ve,TextNode as xe}from"lexical";import{HistoryPlugin as we}from"@lexical/react/LexicalHistoryPlugin";import{ListPlugin as ke}from"@lexical/react/LexicalListPlugin";import{REMOVE_LIST_COMMAND as Ce,INSERT_ORDERED_LIST_COMMAND as Ne,INSERT_UNORDERED_LIST_COMMAND as _e,ListNode as Se,$isListNode as Te,ListItemNode as Le}from"@lexical/list";import{INSERT_HORIZONTAL_RULE_COMMAND as ze,HorizontalRuleNode as Ee}from"@lexical/react/LexicalHorizontalRuleNode";import{HorizontalRulePlugin as Ae}from"@lexical/react/LexicalHorizontalRulePlugin";import{TablePlugin as Fe}from"@lexical/react/LexicalTablePlugin";import{$findCellNode as $e,INSERT_TABLE_COMMAND as Re,$isTableCellNode as De,TableCellHeaderStates as Me,$insertTableRowAtSelection as Oe,$deleteTableRowAtSelection as We,$insertTableColumnAtSelection as Ie,$deleteTableColumnAtSelection as Pe,TableNode as Be,TableRowNode as He,TableCellNode as Ue}from"@lexical/table";import{RxLetterCaseLowercase as Ke,RxLetterCaseUppercase as qe,RxLetterCaseCapitalize as je}from"react-icons/rx";import{TbBold as Je,TbItalic as Ve,TbUnderline as Ze,TbSeparatorHorizontal as Qe,TbArrowsLeftRight as Xe}from"react-icons/tb";import{BsSuperscript as Ge,BsSubscript as Ye,BsChatSquareQuote as et,BsArrowCounterclockwise as tt,BsArrowClockwise as nt,BsJustifyLeft as it,BsTextCenter as ot,BsJustifyRight as rt,BsJustify as lt,BsTextParagraph as at,BsTypeH1 as st,BsTypeH2 as ct,BsTypeH3 as dt,BsTypeH4 as ut,BsTypeH5 as pt,BsTypeH6 as ht,BsPencilSquare as gt,BsFonts as mt,BsListOl as bt,BsListUl as ft,BsTable as yt,BsFullscreenExit as vt,BsFullscreen as xt,BsThreeDots as wt,BsSun as kt,BsMoon as Ct}from"react-icons/bs";import{AiOutlineStrikethrough as Nt,AiOutlineFontColors as _t,AiOutlineBgColors as St}from"react-icons/ai";import{IoCodeSlashOutline as Tt,IoChevronUp as Lt,IoChevronDown as zt,IoClose as Et,IoImageOutline as At,IoSearchOutline as Ft,IoCodeOutline as $t}from"react-icons/io5";import{PiHighlighterLight as Rt}from"react-icons/pi";import{RiEraserLine as Dt,RiIndentIncrease as Mt,RiIndentDecrease as Ot}from"react-icons/ri";import{useLexicalComposerContext as Wt}from"@lexical/react/LexicalComposerContext";import{TOGGLE_LINK_COMMAND as It,$isLinkNode as Pt,LinkNode as Bt}from"@lexical/link";import{HiChevronDown as Ht}from"react-icons/hi2";import{createPortal as Ut}from"react-dom";import{IoIosLink as Kt}from"react-icons/io";import{MdCheck as qt,MdMonitor as jt,MdWrapText as Jt}from"react-icons/md";import{BiUnlink as Vt}from"react-icons/bi";import{SketchPicker as Zt}from"react-color";import{LuMinus as Qt,LuPlus as Xt,LuUpload as Gt}from"react-icons/lu";import{FaYoutube as Yt}from"react-icons/fa";import{VscPreview as en}from"react-icons/vsc";import{LinkPlugin as tn}from"@lexical/react/LexicalLinkPlugin";import{OnChangePlugin as nn}from"@lexical/react/LexicalOnChangePlugin";var on,rn;!function(e){e.Bold="bold",e.Italics="italics",e.Underline="underline",e.Quote="quote",e.Lowercase="lowercase",e.Uppercase="uppercase",e.Capitalize="capitalize",e.Strikethrough="strikethrough",e.Superscript="superscript",e.Subscript="subscript",e.Highlight="highlight",e.Code="code",e.Link="link",e.LeftAlign="leftAlign",e.CenterAlign="centerAlign",e.RightAlign="rightAlign",e.JustifyAlign="justifyAlign",e.Divider="divider",e.Undo="undo",e.Redo="redo",e.ClearFormatting="clearFormatting",e.CodeBlock="codeBlock",e.HorizontalRule="horizontalRule",e.Indent="indent",e.Outdent="outdent",e.Table="table",e.FindReplace="findReplace",e.SourceView="sourceView",e.Fullscreen="fullscreen"}(on||(on={})),function(e){e.Normal="normal",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6"}(rn||(rn={}));const ln=[{id:on.Lowercase,icon:e(Ke,{}),label:"Lowercase"},{id:on.Uppercase,icon:e(qe,{}),label:"Uppercase"},{id:on.Capitalize,icon:e(je,{}),label:"Capitalize"},{id:on.Superscript,icon:e(Ge,{}),label:"Superscript"},{id:on.Subscript,icon:e(Ye,{}),label:"Subscript"}],an=[{id:on.Bold,icon:e(Je,{}),label:"Bold"},{id:on.Italics,icon:e(Ve,{}),label:"Italics"},{id:on.Underline,icon:e(Ze,{}),label:"Underline"},{id:on.Strikethrough,icon:e(Nt,{}),label:"Strikethrough"}],sn=[{id:on.Highlight,icon:e(Rt,{}),label:"Highlight"}],cn=[{id:on.Quote,icon:e(et,{}),label:"Quote"},{id:on.Code,icon:e(Tt,{}),label:"Code"}],dn=[{id:on.Undo,icon:e(tt,{}),label:"Undo"},{id:on.Redo,icon:e(nt,{}),label:"Redo"},{id:on.ClearFormatting,icon:e(Dt,{}),label:"Clear Formatting"}],un=[{id:on.Indent,icon:e(Mt,{}),label:"Indent"},{id:on.Outdent,icon:e(Ot,{}),label:"Outdent"}],pn=[{id:on.HorizontalRule,icon:e(Qe,{}),label:"Horizontal Rule"}],hn=[{id:on.LeftAlign,icon:e(it,{}),label:"Left Align"},{id:on.CenterAlign,icon:e(ot,{}),label:"Center Align"},{id:on.RightAlign,icon:e(rt,{}),label:"Right Align"},{id:on.JustifyAlign,icon:e(lt,{}),label:"Justify Align"}],gn=[{id:"normal",label:"Normal",icon:e(at,{})},{id:"h1",label:"Heading 1",icon:e(st,{})},{id:"h2",label:"Heading 2",icon:e(ct,{})},{id:"h3",label:"Heading 3",icon:e(dt,{})},{id:"h4",label:"Heading 4",icon:e(ut,{})},{id:"h5",label:"Heading 5",icon:e(pt,{})},{id:"h6",label:"Heading 6",icon:e(ht,{})}],mn=[{id:"plaintext",label:"Plain Text"},{id:"javascript",label:"JavaScript"},{id:"typescript",label:"TypeScript"},{id:"python",label:"Python"},{id:"java",label:"Java"},{id:"csharp",label:"C#"},{id:"cpp",label:"C++"},{id:"php",label:"PHP"},{id:"ruby",label:"Ruby"},{id:"go",label:"Go"},{id:"rust",label:"Rust"},{id:"swift",label:"Swift"},{id:"kotlin",label:"Kotlin"},{id:"html",label:"HTML"},{id:"css",label:"CSS"},{id:"sql",label:"SQL"},{id:"json",label:"JSON"},{id:"bash",label:"Bash"},{id:"markdown",label:"Markdown"},{id:"yaml",label:"YAML"},{id:"xml",label:"XML"}],bn=r(()=>{});function fn(e,...t){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",e);for(const e of t)i.append("v",e);throw n.search=i.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const yn=new Map;function vn(e){let t=yn.get(e);return void 0===t&&(t=function(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,i]=e.split(/:([^]+)/);n&&i&&(t[n.trim()]=i.trim())}return t}(e),yn.set(e,t)),t}function xn(e,t){(D(e)?e.isCollapsed():M(e)||E(e))||fn(280);const n=vn(D(e)?e.style:M(e)?e.getStyle():e.getTextStyle()),i=Object.entries(t).reduce((t,[i,o])=>("function"==typeof o?t[i]=o(n[i],e):null===o?delete t[i]:t[i]=o,t),{...n}),o=function(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}(i);D(e)||M(e)?e.setStyle(o):e.setTextStyle(o),yn.set(o,i)}function wn(e,t){if(D(e)&&e.isCollapsed()){xn(e,t);const n=e.anchor.getNode();E(n)&&n.isEmpty()&&xn(n,t)}!function(e){const t=A();if(!t)return;const n=new Map,i=e=>n.get(e.getKey())||[0,e.getTextContentSize()];if(D(t))for(const e of B(t).getTextSlices())e&&n.set(e.caret.origin.getKey(),e.getSliceIndices());const o=t.getNodes();for(const t of o){if(!M(t)||!t.canHaveFormat())continue;const[n,o]=i(t);o!==n&&(O(t)||0===n&&o===t.getTextContentSize()?e(t):e(t.splitText(n,o)[0===n?0:1]))}D(t)&&"text"===t.anchor.type&&"text"===t.focus.type&&t.anchor.key===t.focus.key&&function(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:i,offset:o,type:r}=t;t.set(n.key,n.offset,n.type),n.set(i,o,r)}}(t)}(e=>{xn(e,t)})}function kn(e,t){const n=e.getFormatType(),i=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),i!==t.getIndent()&&t.setIndent(i)}function Cn(e,t,n=kn){if(null===e)return;const i=e.getStartEndPoints(),o=new Map;let r=null;if(i){const[e,t]=i;r=T(),r.anchor.set(e.key,e.offset,e.type),r.focus.set(t.key,t.offset,t.type);const n=L(e.getNode(),z),l=L(t.getNode(),z);E(n)&&o.set(n.getKey(),n),E(l)&&o.set(l.getKey(),l)}for(const t of e.getNodes())if(E(t)&&z(t))o.set(t.getKey(),t);else if(null===i){const e=L(t,z);E(e)&&o.set(e.getKey(),e)}for(const[e,i]of o){const o=t();n(i,o),i.replace(o,!0),r&&(e===r.anchor.key&&r.anchor.set(o.getKey(),r.anchor.offset,r.anchor.type),e===r.focus.key&&r.focus.set(o.getKey(),r.focus.offset,r.focus.type))}r&&e.is(A())&&F(r)}function Nn(e){return e.getNode().isAttached()}function _n(e){let t=e;for(;null!==t&&!$(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function Sn(e,t,n=null){const i=e.getStartEndPoints(),o=i?i[0]:null,r=e.getNodes(),l=r.length;if(null!==o&&(0===l||1===l&&"element"===o.type&&0===o.getNode().getChildrenSize())){const e="text"===o.type?o.getNode().getParentOrThrow():o.getNode(),i=e.getChildren();let r=t();return r.setFormat(e.getFormatType()),r.setIndent(e.getIndent()),i.forEach(e=>r.append(e)),n&&(r=n.append(r)),void e.replace(r)}let a=null,s=[];for(let i=0;i<l;i++){const o=r[i];$(o)?(Tn(e,s,s.length,t,n),s=[],a=o):null===a||null!==a&&R(o,a)?s.push(o):(Tn(e,s,s.length,t,n),s=[o])}Tn(e,s,s.length,t,n)}function Tn(e,t,n,i,o=null){if(0===t.length)return;const r=t[0],l=new Map,a=[];let s=E(r)?r:r.getParentOrThrow();s.isInline()&&(s=s.getParentOrThrow());let c=!1;for(;null!==s;){const e=s.getPreviousSibling();if(null!==e){s=e,c=!0;break}if(s=s.getParentOrThrow(),$(s))break}const d=new Set;for(let e=0;e<n;e++){const n=t[e];E(n)&&0===n.getChildrenSize()&&d.add(n.getKey())}const u=new Set;for(let e=0;e<n;e++){const n=t[e];let o=n.getParent();if(null!==o&&o.isInline()&&(o=o.getParent()),null!==o&&I(n)&&!u.has(n.getKey())){const e=o.getKey();if(void 0===l.get(e)){const t=i();t.setFormat(o.getFormatType()),t.setIndent(o.getIndent()),a.push(t),l.set(e,t),o.getChildren().forEach(e=>{t.append(e),u.add(e.getKey()),E(e)&&e.getChildrenKeys().forEach(e=>u.add(e))}),_n(o)}}else if(d.has(n.getKey())){E(n)||fn(179);const e=i();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),a.push(e),n.remove(!0)}}if(null!==o)for(let e=0;e<a.length;e++){const t=a[e];o.append(t)}let p=null;if($(s))if(c)if(null!==o)s.insertAfter(o);else for(let e=a.length-1;e>=0;e--){const t=a[e];s.insertAfter(t)}else{const e=s.getFirstChild();if(E(e)&&(s=e),null===e)if(o)s.append(o);else for(let e=0;e<a.length;e++){const t=a[e];s.append(t),p=t}else if(null!==o)e.insertBefore(o);else for(let t=0;t<a.length;t++){const n=a[t];e.insertBefore(n),p=n}}else if(o)s.insertAfter(o);else for(let e=a.length-1;e>=0;e--){const t=a[e];s.insertAfter(t),p=t}const h=P();D(h)&&Nn(h.anchor)&&Nn(h.focus)?F(h.clone()):null!==p?p.selectEnd():e.dirty=!0}function Ln(e,t,n){const i=vn(e.getStyle());return null!==i&&i[t]||n}function zn(e,t,n=""){let i=null;const o=e.getNodes(),r=e.anchor,l=e.focus,a=e.isBackward(),s=a?l.offset:r.offset,c=a?l.getNode():r.getNode();if(D(e)&&e.isCollapsed()&&""!==e.style){const n=vn(e.style);if(null!==n&&t in n)return n[t]}for(let e=0;e<o.length;e++){const r=o[e];if((0===e||0!==s||!r.is(c))&&M(r)){const e=Ln(r,t,n);if(null===i)i=e;else if(i!==e){i="";break}}}return null===i?n:i}const En="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,An=En&&"documentMode"in document?document.documentMode:null;function Fn(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function $n(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}function Rn({open:t,onOpenChange:n,children:i}){const r=a(null),l=a(null);return s(()=>{function e(e){r.current?.contains(e.target)||l.current?.contains(e.target)||n(!1)}return t&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t,n]),e("div",{className:"popover-root",children:o.Children.map(i,e=>e&&"object"==typeof e?e.type===Dn?c(e,{triggerRef:r}):e.type===Mn?c(e,{contentRef:l,triggerRef:r}):e:e)})}function Dn({children:t,triggerRef:n}){return e("div",{className:"popover-trigger",ref:n,children:t})}function Mn({open:t,align:n="start",children:i,contentRef:r,triggerRef:l}){const c=a(null),[d,u]=o.useState(!1);return s(()=>{if(!t)return;const e=()=>{const e=c.current,t=l?.current;if(!e||!t)return;const i=t.closest(".lexical-text-editor"),o=!!i?.classList.contains("lexical-dark");e.classList.contains("lexical-dark")!==o&&e.classList.toggle("lexical-dark",o);const r=t.getBoundingClientRect(),a=e.offsetWidth,s=e.offsetHeight;let d=r.left;"center"===n?d=r.left+r.width/2-a/2:"end"===n&&(d=r.right-a),d=Math.max(8,Math.min(window.innerWidth-a-8,d));let p=r.bottom+4;p+s>window.innerHeight-8&&r.top>s+8&&(p=r.top-s-4),e.style.left=`${d}px`,e.style.top=`${p}px`,u(o)};return e(),requestAnimationFrame(e),window.addEventListener("resize",e),document.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),document.removeEventListener("scroll",e,!0)}},[t,n,l]),t?Ut(e("div",{ref:c,className:"lexical-text-editor"+(d?" lexical-dark":""),"data-lte-popover-portal":"true",onMouseDown:e=>e.preventDefault(),style:{position:"fixed",top:0,left:0,zIndex:9999,background:"transparent",border:"none",borderRadius:0,boxShadow:"none",padding:0,margin:0,height:"fit-content",maxWidth:"none"},children:e("div",{ref:e=>{r.current=e},className:"popover-content",style:{position:"static",top:"auto",left:"auto",borderRadius:6,border:"none",margin:0,width:"100%"},children:i})}),document.body):null}function On({onAction:n,selectionMap:i}){const[o,r]=d(!1),l=a(null),s=a(null);return t(Rn,{open:o,onOpenChange:r,children:[e(Dn,{triggerRef:l,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),children:[e("span",{children:"Aa"}),e(Ht,{className:"chevron "+(o?"rotated":"")})]})}),e(Mn,{open:o,align:"start",onClose:()=>r(!1),contentRef:s,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:ln.map(({id:o,label:l,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(i[o]?"toolbar-active":"toolbar"),onClick:()=>{n(o),r(!1)},style:{minWidth:130},children:[a,e("span",{className:"label",children:l})]},o))})})]})}function Wn(){return e("div",{className:"lexical-separator"})}function In({updateHeading:n,headingSelectionMap:i}){const o=gn.find(e=>i[e.id]),[r,l]=d(!1),s=a(null),c=a(null);return t(Rn,{open:r,onOpenChange:l,children:[e(Dn,{triggerRef:s,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(r?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),style:{minWidth:132},children:[o?.icon,e("span",{children:o?.label}),e(Ht,{className:"chevron "+(r?"rotated":"")})]})}),e(Mn,{open:r,align:"start",onClose:()=>l(!1),contentRef:c,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:gn.map(({id:o,label:r,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(i[o]?"toolbar-active":"toolbar"),onClick:()=>{n(o),l(!1)},children:[a,e("span",{className:"label",children:r})]},o))})})]})}function Pn({linkUrl:n,setLinkUrl:i,onConfirm:o,onCancel:r,removeLink:l}){const[c,u]=d(!1),p=a(null),h=a(null);return s(()=>{"https://"===n&&u(!0)},[n]),s(()=>{c&&h.current?.focus()},[c]),s(()=>{const e=e=>{p.current&&!p.current.contains(e.target)&&r()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]),t("div",{ref:p,className:"lexical-text-editor-link link-editor-container",children:[e("div",{className:"link-editor-input-wrapper",children:c?e("input",{ref:h,className:"link-editor-input",value:n,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),o(n),u(!1)):"Escape"===e.key&&(e.preventDefault(),u(!1),r())}}):e("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"link-editor-url",children:n})}),t("div",{className:"link-editor-buttons",children:[e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{c?(o(n),u(!1)):u(!0)},children:c?e(qt,{size:18}):e(gt,{size:14})}),e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onMouseDown:e=>e.preventDefault(),onClick:l,children:e(Vt,{size:14,style:{stroke:"black"}})})]})]})}function Bn({onClose:n}){const[i]=Wt(),[o,r]=d(""),[l,c]=d(""),[u,p]=d(!1),[h,g]=d([]),[m,b]=d(0),f=a(null);s(()=>{f.current?.focus()},[]);const y=()=>{if(!o)return[];const e=u?o:o.toLowerCase(),t=[],n=H().getAllTextNodes();for(const i of n){const n=u?i.getTextContent():i.getTextContent().toLowerCase();let o=n.indexOf(e);for(;-1!==o;)t.push({key:i.getKey(),start:o}),o=n.indexOf(e,o+e.length)}return t};s(()=>{const e=i.getEditorState().read(y);g(e),b(0)},[i,o,u]),s(()=>i.registerUpdateListener(({editorState:e})=>{const t=e.read(y);g(t),b(e=>0===t.length?0:Math.min(e,t.length-1))}),[i,o,u]);const v=e=>{if(0===h.length)return;const t=(m+e+h.length)%h.length,n=h[t];b(t),i.update(()=>{const e=U(n.key);M(e)&&e.select(n.start,n.start+o.length)}),requestAnimationFrame(()=>{const e=i.getElementByKey(n.key);e?.scrollIntoView({block:"nearest"})})},x=o.length>0,w=h.length>0;return t("div",{className:"lexical-find-replace",onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),n())},children:[t("div",{className:"lexical-fr-row",children:[e("input",{ref:f,className:"lexical-fr-input",placeholder:"Find",value:o,onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),v(e.shiftKey?-1:1))}}),e("span",{className:"lexical-fr-count",children:w?`${m+1} of ${h.length}`:x?"0 results":""})]}),e("div",{className:"lexical-fr-row",children:e("input",{className:"lexical-fr-input",placeholder:"Replace with",value:l,onChange:e=>c(e.target.value)})}),t("div",{className:"lexical-fr-row",children:[t("label",{className:"lexical-fr-case",children:[e("input",{type:"checkbox",checked:u,onChange:e=>p(e.target.checked)}),e("span",{children:"Match case"})]}),e("span",{style:{flex:1}}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>v(-1),disabled:!w,"aria-label":"Previous match",children:e(Lt,{})}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>v(1),disabled:!w,"aria-label":"Next match",children:e(zt,{})}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{i.update(()=>{const e=y();if(0===e.length)return g([]),void b(0);const t=e[Math.min(m,e.length-1)],n=U(t.key);M(n)&&n.spliceText(t.start,o.length,l,!0)})},disabled:!w,children:"Replace"}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{i.update(()=>{const e=y();for(let t=e.length-1;t>=0;t--){const n=e[t],i=U(n.key);M(i)&&i.spliceText(n.start,o.length,l,!1)}})},disabled:!w,children:"Replace All"}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:n,"aria-label":"Close find and replace",children:e(Et,{})})]})]})}function Hn({anchorRef:t,onClose:n,children:i}){const o=a(null);return s(()=>{const e=e=>{const i=e.target;i instanceof HTMLElement&&i.closest("[data-lte-popover-portal]")||!o.current||o.current.contains(i)||t.current&&t.current.contains(i)||n()},i=e=>{"Escape"===e.key&&n()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",i)}},[t,n]),e("div",{ref:o,className:"lte-overflow-panel",onMouseDown:e=>e.preventDefault(),children:e("div",{className:"lte-overflow-grid",children:i})})}function Un({onAction:n,alignmentSelectionMap:i}){const o=hn.find(e=>i[e.id]),[r,l]=d(!1),s=a(null),c=a(null);return t(Rn,{open:r,onOpenChange:l,children:[e(Dn,{triggerRef:s,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(r?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),style:{minWidth:146},children:[o?.icon,e("span",{children:o?.label}),e(Ht,{className:"chevron "+(r?"rotated":"")})]})}),e(Mn,{open:r,align:"start",onClose:()=>l(!1),contentRef:c,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:hn.map(({id:o,label:r,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(i[o]?"toolbar-active":"toolbar"),onClick:()=>{n(o),l(!1)},children:[a,e("span",{className:"label",children:r})]},o))})})]})}function Kn({color:n,onChange:i,icon:o}){const[r,l]=d(!1),c=a(null),u=a(null);s(()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&c.current&&!c.current.contains(e.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);return t("div",{className:"color-picker-wrapper",children:[e("button",{type:"button",ref:c,className:`size-10 lexical-btn ${r?"toolbarActive":"toolbar"} icon`,onClick:()=>l(e=>!e),children:o}),r&&Ut(e("div",{ref:u,className:"lexical-color-popover "+(r?"open":""),"data-lte-popover-portal":"true",style:{top:c.current?.getBoundingClientRect().bottom,left:c.current?.getBoundingClientRect().left,position:"absolute"},onMouseDown:e=>{e.preventDefault(),(e=>{e.preventDefault()})(e)},children:e(Zt,{color:n,onChangeComplete:e=>{i(e.hex)}})}),document.body)]})}function qn(){const[i]=Wt(),[{color:o,bgColor:r},l]=d({color:"#000",bgColor:"#fff"}),a=()=>{const e=A();if(D(e)){const t=zn(e,"color","#000"),n=zn(e,"background","#fff");l({color:t,bgColor:n})}};s(()=>Fn(i.registerUpdateListener(({editorState:e})=>{e.read(()=>{a()})}),i.registerCommand(K,()=>(a(),!1),1)),[i]);const c=({property:e,color:t})=>{i.update(()=>{const n=A();n&&wn(n,{[e]:t})})};return t(n,{children:[e(Kn,{color:o,onChange:e=>{c({property:"color",color:e})},icon:e(_t,{})}),e(Kn,{color:r,onChange:e=>{c({property:"background",color:e})},icon:e(St,{})})]})}function jn({icon:n,tooltipLabel:i,currentValue:o,options:r,onSelect:l,minWidth:s=132}){const c=r.find(e=>""!==e.id&&e.id===o),[u,p]=d(!1),h=a(null),g=a(null);return t(Rn,{open:u,onOpenChange:p,children:[e(Dn,{triggerRef:h,children:t("button",{type:"button","aria-label":i,className:"lexical-btn heading-trigger font-trigger "+(u?"toolbar-active":"toolbar"),style:{minWidth:s},onClick:()=>p(e=>!e),children:[n,e("span",{children:c?.label??"Default"}),e(Ht,{className:"chevron "+(u?"rotated":"")})]})}),e(Mn,{open:u,align:"start",onClose:()=>p(!1),contentRef:g,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:r.map(t=>e("button",{type:"button",className:"lexical-btn "+(""===t.id&&""===o||""!==t.id&&t.id===o?"toolbar-active":"toolbar"),onClick:()=>{l(t.id),p(!1)},children:e("span",{className:"label",children:t.label})},t.label))})})]})}En&&"InputEvent"in window&&!An&&new window.InputEvent("input");const Jn=[{id:"",label:"Default"},{id:"Inter",label:"Inter"},{id:"System UI",label:"System"},{id:"serif",label:"Serif"},{id:"monospace",label:"Monospace"},{id:"cursive",label:"Cursive"},{id:"Georgia",label:"Georgia"},{id:"Courier New",label:"Courier"}];function Vn(){const[t]=Wt(),[n,i]=d(""),o=()=>{const e=A();if(D(e)){const t=zn(e,"font-family","");i((e=>e.replace(/['"]/g,"").trim())(t))}};s(()=>Fn(t.registerUpdateListener(({editorState:e})=>{e.read(()=>{o()})}),t.registerCommand(K,()=>(o(),!1),1)),[t]);return e(jn,{icon:e(mt,{}),tooltipLabel:"Font Family",currentValue:n,options:Jn,onSelect:e=>{t.update(()=>{const t=A();D(t)&&wn(t,{"font-family":""===e?null:e})})}})}const Zn=({content:n,direction:i="top",delay:o=400,children:r})=>{const[l,s]=d(!1),[c,u]=d(null),p=a(null),h=a(null),g=()=>{p.current=window.setTimeout(()=>{const e=h.current;if(e){const t=e.getBoundingClientRect();u({left:t.left,top:t.top,right:t.right,bottom:t.bottom,width:t.width,height:t.height})}s(!0)},o)},m=()=>{p.current&&clearTimeout(p.current),s(!1)};if(!c)return e("div",{ref:h,className:"Lexical-Tooltip-Wrapper",onMouseEnter:g,onMouseLeave:m,children:r});const b=c.left+c.width/2,f=c.top+c.height/2,y="bottom"===i?{top:c.bottom+10,left:b,bottom:"auto"}:"top"===i?{bottom:window.innerHeight-c.top+10,top:"auto",left:b}:"right"===i?{left:c.right+10,right:"auto",top:f}:{left:"auto",right:window.innerWidth-c.left+10,top:f};return t("div",{ref:h,className:"Lexical-Tooltip-Wrapper",onMouseEnter:g,onMouseLeave:m,children:[r,l&&Ut(e("div",{className:`Lexical-Tooltip-Tip ${i}`,style:{position:"fixed",pointerEvents:"none",...y,zIndex:1e4},children:n}),document.body)]})};function Qn(){const[n]=Wt(),[i,o]=d(""),[r,l]=d(null),c=a(null),u=()=>{const e=A();if(D(e)){let t=Xn(zn(e,"font-size",""));if(!t)try{const i=n.getElementByKey(e.anchor.getNode().getKey());i&&(t=window.getComputedStyle(i).fontSize||"")}catch{}o(Xn(t)),document.activeElement!==c.current&&l(null)}};s(()=>Fn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{u()})}),n.registerCommand(K,()=>(u(),!1),1)),[n]);const p=e=>{const t=Math.min(90,Math.max(6,e));n.update(()=>{const e=A();D(e)&&wn(e,{"font-size":`${t}px`})})},h=e=>{const t=r??i,n=Number.parseInt(t,10),o=Number.isNaN(n)?16:n;p(o+e)},g=()=>{const e=r;if(l(null),null===e)return;const t=Number.parseInt(e,10);if(Number.isNaN(t))return;t!==Number.parseInt(i,10)&&p(t)},m=Number.parseInt(i,10),b=Number.isNaN(m)?null:m;return t("div",{className:"lexical-stepper","aria-label":"Font Size",role:"group",children:[e(Zn,{content:"Decrease font size",direction:"bottom",children:e("button",{type:"button","aria-label":"Decrease Font Size",className:"lexical-stepper-btn",disabled:null!==b&&b<=6,onClick:()=>h(-1),children:e(Qt,{})})}),e("input",{ref:c,type:"text",inputMode:"numeric",className:"lexical-stepper-value lexical-stepper-input","aria-label":"Font size in pixels",placeholder:"—",title:"Click to type a size (6-90), then press Enter",value:r??(null!==b?String(b):""),onChange:e=>l(e.target.value.replace(/[^\d]/g,"")),onFocus:e=>e.currentTarget.select(),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),g(),e.currentTarget.blur()):"Escape"===e.key?(e.preventDefault(),l(null),e.currentTarget.blur()):"ArrowUp"!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),g(),h("ArrowUp"===e.key?1:-1)),e.stopPropagation()},onBlur:g}),e(Zn,{content:"Increase font size",direction:"bottom",children:e("button",{type:"button","aria-label":"Increase Font Size",className:"lexical-stepper-btn",disabled:null!==b&&b>=90,onClick:()=>h(1),children:e(Xt,{})})})]})}const Xn=e=>e.trim();!function(e){function t(e,t){return"___"+e.toUpperCase()+t+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,i,o,r){if(n.language===i){var l=n.tokenStack=[];n.code=n.code.replace(o,function(e){if("function"==typeof r&&!r(e))return e;for(var o,a=l.length;-1!==n.code.indexOf(o=t(i,a));)++a;return l[a]=e,o}),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,i){if(n.language===i&&n.tokenStack){n.grammar=e.languages[i];var o=0,r=Object.keys(n.tokenStack);!function l(a){for(var s=0;s<a.length&&!(o>=r.length);s++){var c=a[s];if("string"==typeof c||c.content&&"string"==typeof c.content){var d=r[o],u=n.tokenStack[d],p="string"==typeof c?c:c.content,h=t(i,d),g=p.indexOf(h);if(g>-1){++o;var m=p.substring(0,g),b=new e.Token(i,e.tokenize(u,n.grammar),"language-"+i,u),f=p.substring(g+h.length),y=[];m&&y.push.apply(y,l([m])),y.push(b),f&&y.push.apply(y,l([f])),"string"==typeof c?a.splice.apply(a,[s,1].concat(y)):c.content=y}}else c.content&&l(c.content)}return a}(n.tokens)}}}})}(Prism);var Gn;Gn||(Gn=1,function(e){function t(e,t){return e.replace(/<<(\d+)>>/g,function(e,n){return"(?:"+t[+n]+")"})}function n(e,n,i){return RegExp(t(e,n),"")}function i(e,t){for(var n=0;n<t;n++)e=e.replace(/<<self>>/g,function(){return"(?:"+e+")"});return e.replace(/<<self>>/g,"[^\\s\\S]")}var o="bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void",r="class enum interface record struct",l="add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)",a="abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield";function s(e){return"\\b(?:"+e.trim().replace(/ /g,"|")+")\\b"}var c=s(r),d=RegExp(s(o+" "+r+" "+l+" "+a)),u=s(r+" "+l+" "+a),p=s(o+" "+r+" "+a),h=i(/<(?:[^<>;=+\-*/%&|^]|<<self>>)*>/.source,2),g=i(/\((?:[^()]|<<self>>)*\)/.source,2),m=/@?\b[A-Za-z_]\w*\b/.source,b=t(/<<0>>(?:\s*<<1>>)?/.source,[m,h]),f=t(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source,[u,b]),y=/\[\s*(?:,\s*)*\]/.source,v=t(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source,[f,y]),x=t(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source,[h,g,y]),w=t(/\(<<0>>+(?:,<<0>>+)+\)/.source,[x]),k=t(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source,[w,f,y]),C={keyword:d,punctuation:/[<>()?,.:[\]]/},N=/'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source,_=/"(?:\\.|[^\\"\r\n])*"/.source,S=/@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;e.languages.csharp=e.languages.extend("clike",{string:[{pattern:n(/(^|[^$\\])<<0>>/.source,[S]),lookbehind:!0,greedy:!0},{pattern:n(/(^|[^@$\\])<<0>>/.source,[_]),lookbehind:!0,greedy:!0}],"class-name":[{pattern:n(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source,[f]),lookbehind:!0,inside:C},{pattern:n(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source,[m,k]),lookbehind:!0,inside:C},{pattern:n(/(\busing\s+)<<0>>(?=\s*=)/.source,[m]),lookbehind:!0},{pattern:n(/(\b<<0>>\s+)<<1>>/.source,[c,b]),lookbehind:!0,inside:C},{pattern:n(/(\bcatch\s*\(\s*)<<0>>/.source,[f]),lookbehind:!0,inside:C},{pattern:n(/(\bwhere\s+)<<0>>/.source,[m]),lookbehind:!0},{pattern:n(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source,[v]),lookbehind:!0,inside:C},{pattern:n(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source,[k,p,m]),inside:C}],keyword:d,number:/(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,operator:/>>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,punctuation:/\?\.?|::|[{}[\];(),.:]/}),e.languages.insertBefore("csharp","number",{range:{pattern:/\.\./,alias:"operator"}}),e.languages.insertBefore("csharp","punctuation",{"named-parameter":{pattern:n(/([(,]\s*)<<0>>(?=\s*:)/.source,[m]),lookbehind:!0,alias:"punctuation"}}),e.languages.insertBefore("csharp","class-name",{namespace:{pattern:n(/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source,[m]),lookbehind:!0,inside:{punctuation:/\./}},"type-expression":{pattern:n(/(\b(?:default|sizeof|typeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source,[g]),lookbehind:!0,alias:"class-name",inside:C},"return-type":{pattern:n(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source,[k,f]),inside:C,alias:"class-name"},"constructor-invocation":{pattern:n(/(\bnew\s+)<<0>>(?=\s*[[({])/.source,[k]),lookbehind:!0,inside:C,alias:"class-name"},"generic-method":{pattern:n(/<<0>>\s*<<1>>(?=\s*\()/.source,[m,h]),inside:{function:n(/^<<0>>/.source,[m]),generic:{pattern:RegExp(h),alias:"class-name",inside:C}}},"type-list":{pattern:n(/\b((?:<<0>>\s+<<1>>|record\s+<<1>>\s*<<5>>|where\s+<<2>>)\s*:\s*)(?:<<3>>|<<4>>|<<1>>\s*<<5>>|<<6>>)(?:\s*,\s*(?:<<3>>|<<4>>|<<6>>))*(?=\s*(?:where|[{;]|=>|$))/.source,[c,b,m,k,d.source,g,/\bnew\s*\(\s*\)/.source]),lookbehind:!0,inside:{"record-arguments":{pattern:n(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source,[b,g]),lookbehind:!0,greedy:!0,inside:e.languages.csharp},keyword:d,"class-name":{pattern:RegExp(k),greedy:!0,inside:C},punctuation:/[,()]/}},preprocessor:{pattern:/(^[\t ]*)#.*/m,lookbehind:!0,alias:"property",inside:{directive:{pattern:/(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,lookbehind:!0,alias:"keyword"}}}});var T=_+"|"+N,L=t(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source,[T]),z=i(t(/[^"'/()]|<<0>>|\(<<self>>*\)/.source,[L]),2),E=/\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source,A=t(/<<0>>(?:\s*\(<<1>>*\))?/.source,[f,z]);e.languages.insertBefore("csharp","class-name",{attribute:{pattern:n(/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source,[E,A]),lookbehind:!0,greedy:!0,inside:{target:{pattern:n(/^<<0>>(?=\s*:)/.source,[E]),alias:"keyword"},"attribute-arguments":{pattern:n(/\(<<0>>*\)/.source,[z]),inside:e.languages.csharp},"class-name":{pattern:RegExp(f),inside:{punctuation:/\./}},punctuation:/[:,]/}}});var F=/:[^}\r\n]+/.source,$=i(t(/[^"'/()]|<<0>>|\(<<self>>*\)/.source,[L]),2),R=t(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source,[$,F]),D=i(t(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source,[T]),2),M=t(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source,[D,F]);function O(t,i){return{interpolation:{pattern:n(/((?:^|[^{])(?:\{\{)*)<<0>>/.source,[t]),lookbehind:!0,inside:{"format-string":{pattern:n(/(^\{(?:(?![}:])<<0>>)*)<<1>>(?=\}$)/.source,[i,F]),lookbehind:!0,inside:{punctuation:/^:/}},punctuation:/^\{|\}$/,expression:{pattern:/[\s\S]+/,alias:"language-csharp",inside:e.languages.csharp}}},string:/[\s\S]+/}}e.languages.insertBefore("csharp","string",{"interpolation-string":[{pattern:n(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source,[R]),lookbehind:!0,greedy:!0,inside:O(R,$)},{pattern:n(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source,[M]),lookbehind:!0,greedy:!0,inside:O(M,D)}],char:{pattern:RegExp(N),greedy:!0}}),e.languages.dotnet=e.languages.cs=e.languages.csharp}(Prism));var Yn;Yn||(Yn=1,function(e){var t=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,n=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],i=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,o=/<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,r=/[{}\[\](),:;]/;e.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:t,variable:/\$+(?:\w+\b|(?=\{))/,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:n,function:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:i,operator:o,punctuation:r};var l={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:e.languages.php},a=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:l}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:l}}];e.languages.insertBefore("php","variable",{string:a,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:t,string:a,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:n,number:i,operator:o,punctuation:r}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),e.hooks.add("before-tokenize",function(t){/<\?/.test(t.code)&&e.languages["markup-templating"].buildPlaceholders(t,"php",/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g)}),e.hooks.add("after-tokenize",function(t){e.languages["markup-templating"].tokenizePlaceholders(t,"php")})}(Prism));var ei;function ti(){const[n]=Wt(),i=l(bn),[o,r]=d(!1),[c,u]=d(null),[p,h]=d(!1),g=a(null),m=a(null),b=()=>{const e=A();if(D(e)){const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow(),i=x(n);r(i),i&&u(n.getLanguage()??null)}};s(()=>Fn(v(n),n.registerUpdateListener(({editorState:e})=>{e.read(()=>{b()})}),n.registerCommand(K,()=>(b(),!1),1)),[n]);const f=mn.find(e=>e.id===c)?.label??"Plain Text";return t(Rn,{open:p,onOpenChange:h,children:[e(Dn,{triggerRef:g,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>h(e=>!e),children:[e(Tt,{}),e("span",{children:f}),e(Ht,{className:"chevron "+(p?"rotated":"")})]})}),e(Mn,{open:p,align:"start",onClose:()=>h(!1),contentRef:m,children:t("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[t("button",{type:"button",className:"lexical-btn "+(o?"toolbar-active":"toolbar"),onClick:()=>{n.update(()=>{if(!D(A())){const e=H().getFirstChild();E(e)&&e.select(0,0)}const e=A();if(!D(e))return;const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow();if(x(n))Cn(e,()=>q());else{const t=c??"javascript";Cn(e,()=>w(t))}}),i(),h(!1)},style:{minWidth:150},children:[e(Tt,{}),e("span",{className:"label",children:o?"Remove Code Block":"Code Block"})]}),e("div",{className:"w-full h-[1px] bg-gray-200 my-1"}),e("div",{style:{display:"flex",flexDirection:"column",gap:5,maxHeight:260,overflowY:"auto"},children:mn.map(({id:t,label:o})=>e("button",{type:"button",className:"lexical-btn "+(c===t?"toolbar-active":"toolbar"),onClick:()=>{var e;u(e=t),n.update(()=>{if(!D(A())){const e=H().getFirstChild();E(e)&&e.select(0,0)}const t=A();if(!D(t))return;const n=t.anchor.getNode(),i="root"===n.getKey()?n:n.getTopLevelElementOrThrow();x(i)?i.setLanguage(e):Cn(t,()=>w(e))}),i(),h(!1)},style:{minWidth:150},children:e("span",{className:"label",children:o})},t))})]})})]})}function ni({blockType:i}){const[o]=Wt();s(()=>Fn(o.registerCommand(j,e=>{const t=A();if(!D(t))return!1;return!!$n(t.anchor.getNode(),Se)&&(e.preventDefault(),o.dispatchCommand(e.shiftKey?J:V,void 0),!0)},Z)),[o]);return t(n,{children:[e(Zn,{content:"Ordered list",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${"ol"===i?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ol"===i?o.dispatchCommand(Ce,void 0):o.dispatchCommand(Ne,void 0)},children:e(bt,{})})}),e(Zn,{content:"Unordered list",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${"ul"===i?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ul"===i?o.dispatchCommand(Ce,void 0):o.dispatchCommand(_e,void 0)},children:e(ft,{})})})]})}ei||(ei=1,function(e){e.languages.ruby=e.languages.extend("clike",{comment:{pattern:/#.*|^=begin\s[\s\S]*?^=end/m,greedy:!0},"class-name":{pattern:/(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,operator:/\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,punctuation:/[(){}[\].,;]/}),e.languages.insertBefore("ruby","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}});var t={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:e.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"}}};delete e.languages.ruby.function;var n="(?:"+[/([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,/\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,/\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,/\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,/<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source].join("|")+")",i=/(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;e.languages.insertBefore("ruby","keyword",{"regex-literal":[{pattern:RegExp(/%r/.source+n+/[egimnosux]{0,6}/.source),greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:[{pattern:RegExp(/(^|[^:]):/.source+i),lookbehind:!0,greedy:!0},{pattern:RegExp(/([\r\n{(,][ \t]*)/.source+i+/(?=:(?!:))/.source),lookbehind:!0,greedy:!0}],"method-definition":{pattern:/(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,lookbehind:!0,inside:{function:/\b\w+$/,keyword:/^self\b/,"class-name":/^\w+/,punctuation:/\./}}}),e.languages.insertBefore("ruby","string",{"string-literal":[{pattern:RegExp(/%[qQiIwWs]?/.source+n),greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?/}},interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?'|'$/}},string:/[\s\S]+/}}],"command-literal":[{pattern:RegExp(/%x/.source+n),greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:"string"}}},{pattern:/`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:"string"}}}]}),delete e.languages.ruby.string,e.languages.insertBefore("ruby","number",{builtin:/\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,constant:/\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/}),e.languages.rb=e.languages.ruby}(Prism)),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"],function(e){e.languages.kotlin=e.languages.extend("clike",{keyword:{pattern:/(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,lookbehind:!0},function:[{pattern:/(?:`[^\r\n`]+`|\b\w+)(?=\s*\()/,greedy:!0},{pattern:/(\.)(?:`[^\r\n`]+`|\w+)(?=\s*\{)/,lookbehind:!0,greedy:!0}],number:/\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,operator:/\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/}),delete e.languages.kotlin["class-name"];var t={"interpolation-punctuation":{pattern:/^\$\{?|\}$/,alias:"punctuation"},expression:{pattern:/[\s\S]+/,inside:e.languages.kotlin}};e.languages.insertBefore("kotlin","string",{"string-literal":[{pattern:/"""(?:[^$]|\$(?:(?!\{)|\{[^{}]*\}))*?"""/,alias:"multiline",inside:{interpolation:{pattern:/\$(?:[a-z_]\w*|\{[^{}]*\})/i,inside:t},string:/[\s\S]+/}},{pattern:/"(?:[^"\\\r\n$]|\\.|\$(?:(?!\{)|\{[^{}]*\}))*"/,alias:"singleline",inside:{interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$(?:[a-z_]\w*|\{[^{}]*\})/i,lookbehind:!0,inside:t},string:/[\s\S]+/}}],char:{pattern:/'(?:[^'\\\r\n]|\\(?:.|u[a-fA-F0-9]{0,4}))'/,greedy:!0}}),delete e.languages.kotlin.string,e.languages.insertBefore("kotlin","keyword",{annotation:{pattern:/\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,alias:"builtin"}}),e.languages.insertBefore("kotlin","function",{label:{pattern:/\b\w+@|@\w+\b/,alias:"symbol"}}),e.languages.kt=e.languages.kotlin,e.languages.kts=e.languages.kotlin}(Prism);function ii(){const[n]=Wt(),[i,o]=d(!1),[r,l]=d(!1),[c,u]=d(null),p=a(null),h=a(null),g=()=>{const e=A();if(D(e)){const t=$e(e.anchor.getNode());o(!!t)}else o(!1)};s(()=>Fn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{g()})}),n.registerCommand(K,()=>(g(),!1),1)),[n]);const m=e=>{n.update(()=>{const t=A();D(t)&&e()}),l(!1)},b=c?`${c.rows} × ${c.cols}`:"Insert Table";return t(Rn,{open:r,onOpenChange:l,children:[e(Dn,{triggerRef:p,children:t("button",{type:"button","aria-label":"Insert Table",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),children:[e(yt,{}),e(Ht,{className:"chevron "+(r?"rotated":"")})]})}),e(Mn,{open:r,align:"start",onClose:()=>l(!1),contentRef:h,children:t("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t("div",{style:{width:"fit-content"},children:[e("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 18px)",gap:3},children:Array.from({length:25},(t,i)=>{const o=Math.floor(i/5)+1,r=i%5+1,a=c&&o<=c.rows&&r<=c.cols;return e("div",{onMouseEnter:()=>u({rows:o,cols:r}),onClick:()=>{return e=o,t=r,n.update(()=>{if(!D(A())){const e=H().getFirstChild();E(e)&&e.select(0,0)}}),n.dispatchCommand(Re,{rows:String(e),columns:String(t),includeHeaders:!1}),void l(!1);var e,t},style:{width:18,height:18,borderRadius:3,border:"1px solid #d1d5db",backgroundColor:a?"#c7d2fe":"#fff",cursor:"pointer"}},i)})}),e("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:b})]}),e("div",{className:"w-full h-[1px] bg-gray-200"}),t("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e("button",{type:"button",className:"lexical-btn toolbar",disabled:!i,onClick:()=>m(()=>{Oe(!1)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert row above"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!i,onClick:()=>m(()=>{Oe(!0)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert row below"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!i,onClick:()=>m(()=>{We()}),style:{minWidth:160},children:e("span",{className:"label",children:"Delete row"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!i,onClick:()=>m(()=>{Ie(!1)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert column left"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!i,onClick:()=>m(()=>{Ie(!0)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert column right"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!i,onClick:()=>m(()=>{Pe()}),style:{minWidth:160},children:e("span",{className:"label",children:"Delete column"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!i,onClick:()=>{m(()=>{const e=A();if(!D(e))return;const t=$e(e.anchor.getNode());if(!t)return;const n=t.getParent();if(!n)return;const i=n.getChildren().filter(De),o=i.some(e=>e.hasHeaderState(Me.ROW));for(const e of i)e.setHeaderStyles(o?Me.NO_STATUS:Me.ROW,Me.ROW)})},style:{minWidth:160},children:e("span",{className:"label",children:"Toggle header row"})})]})]})})]})}const oi=({src:n,altText:i,nodeKey:o,width:r,height:l,maxWidth:s,caption:c=""})=>{const[u]=Wt(),[p,h]=d(!1),[g,m]=d(c),b=a(null),f=a(null),y=a(null),v=a(null),x=e=>{if(!v.current||!f.current)return;const t=e.clientX-v.current.x,n=Math.min(s,Math.max(50,v.current.width+t)),i=n*f.current.ratio;f.current.width=n,f.current.height=i;const o=y.current?.querySelector("img");o&&(o.style.width=n+"px",o.style.height=i+"px")},w=()=>{if(!f.current)return;const{width:e,height:t}=f.current;u.update(()=>{const n=U(o);n&&"function"==typeof n.updateDimensions&&n.updateDimensions(e,t)}),f.current=null,v.current=null,window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",w)},k=()=>{h(!1),u.update(()=>{const e=U(o);e&&"function"==typeof e.setCaption&&e.setCaption(g)})},C=()=>{m(c),h(!0),setTimeout(()=>b.current?.focus(),0)};return t("div",{ref:y,style:{display:"inline-block",position:"relative",maxWidth:s},children:[e("img",{src:n,alt:i,width:"inherit"===r?void 0:r,height:"inherit"===l?void 0:l,style:{maxWidth:"100%",display:"block"}}),(c||p)&&e("div",{style:{textAlign:"center",marginTop:4},children:p?e("input",{ref:b,className:"lte-input",style:{width:"100%",textAlign:"center"},value:g,onChange:e=>m(e.target.value),onBlur:k,onKeyDown:e=>{"Enter"===e.key&&k()}}):e("span",{style:{fontSize:13,color:"#666",cursor:"text",display:"inline-block",minWidth:20,minHeight:18},onClick:C,children:c})}),!c&&!p&&e("div",{style:{textAlign:"center",marginTop:2},children:e("span",{style:{fontSize:12,color:"#999",cursor:"pointer"},onClick:C,children:"+ Add caption"})}),e("div",{onMouseDown:e=>{e.preventDefault(),e.stopPropagation();const t=y.current?.querySelector("img");if(!t)return;const n=t.getBoundingClientRect().width,i=t.naturalHeight/t.naturalWidth,o=n*i;v.current={x:e.clientX,y:e.clientY,width:n,height:o},f.current={width:n,height:o,ratio:i},window.addEventListener("mousemove",x),window.addEventListener("mouseup",w)},style:{position:"absolute",bottom:c||p?40:0,right:0,width:14,height:14,background:"white",border:"1px solid #999",cursor:"nwse-resize",borderRadius:2}})]})},ri=e=>X(new ai(e)),li=e=>{if(!(e instanceof HTMLImageElement))return null;const{src:t,alt:n}=e;let i,o;e.width&&(i=e.width),e.height&&(o=e.height);const r=e.style;if((!i||0===i)&&r.width){const e=parseInt(r.width,10);Number.isNaN(e)||(i=e)}if((!o||0===o)&&r.height){const e=parseInt(r.height,10);Number.isNaN(e)||(o=e)}return{node:ri({src:t,altText:n,width:i??"inherit",height:o??"inherit"})}};class ai extends Q{constructor({src:e="",altText:t="",maxWidth:n=1080,width:i="inherit",height:o="inherit",caption:r="",key:l}={src:"",altText:""}){super(l),this.__src=e,this.__altText=t,this.__maxWidth=n,this.__width=i,this.__height=o,this.__caption=r}static getType(){return"image"}static clone(e){return new ai({src:e.__src,altText:e.__altText,width:e.__width,height:e.__height,maxWidth:e.__maxWidth,caption:e.__caption,key:e.getKey()})}createDOM(){return document.createElement("span")}updateDOM(e){return e.__width!==this.__width||e.__height!==this.__height}exportDOM(){const e=document.createElement("img");if(e.src=this.__src,e.alt=this.__altText,"inherit"!==this.__width&&(e.width=this.__width??0),"inherit"!==this.__height&&(e.height=this.__height??0),this.__caption){const t=document.createElement("figure"),n=document.createElement("figcaption");return n.textContent=this.__caption,t.appendChild(e),t.appendChild(n),{element:t}}return{element:e}}static importDOM(){return{img:()=>({conversion:li,priority:1}),figure:()=>({conversion:e=>{const t=e.querySelector("img");if(!t)return null;const n=e.querySelector("figcaption"),i=n?.textContent||"",o=li(t);return o?.node instanceof ai&&i&&(o.node.__caption=i),o},priority:1})}}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,maxWidth:this.__maxWidth,width:this.__width,height:this.__height,caption:this.__caption}}static importJSON(e){return new ai({src:e.src,altText:e.altText,maxWidth:e.maxWidth,width:e.width,height:e.height,caption:e.caption})}updateDimensions(e,t){const n=this.getWritable();n.__width=e,n.__height=t}setCaption(e){this.getWritable().__caption=e}decorate(){return e(oi,{src:this.__src,altText:this.__altText,nodeKey:this.getKey(),width:this.__width,height:this.__height,maxWidth:this.__maxWidth,caption:this.__caption})}}function si({open:n,onClose:i,forPreview:o=!1,children:r}){const l=a(null);return s(()=>{if(!n)return;const e=e=>{l.current&&!l.current.contains(e.target)&&i()},t=e=>{"Escape"===e.key&&i()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[n,i]),n?e("div",{className:"lexical-text-editor-dialog lte-dialog-overlay",children:t("div",{ref:l,className:"lte-dialog "+(o?"preview":""),children:[e("button",{type:"button",className:"lte-dialog-close",onClick:i,children:"×"}),r]})}):null}async function ci(e,{src:t,altText:n="",caption:i=""}){e.update(()=>{const e=ri({src:t,altText:n,caption:i});ee([e])})}function di({onImageUpload:n}){const[i]=Wt(),o=a(null),[r,l]=d(!1),[c,p]=d(""),[h,g]=d(""),[m,b]=d(""),[f,y]=d(),[v,x]=d(!1),w=u(async(e,t="",o="")=>{let r;r=n?await n(e):URL.createObjectURL(e),ci(i,{src:r,altText:t,caption:o})},[i,n]);return s(()=>{const e=i.registerCommand(G,e=>{if(e instanceof ClipboardEvent){const t=e.clipboardData?.items;if(!t)return!1;for(const n of t)if(n.type.startsWith("image/")){e.preventDefault();const t=n.getAsFile();return t&&w(t,"","").catch(console.error),!0}}return!1},Y);return()=>e()},[i,w]),t("div",{className:"lexical-text-editor-dialog",children:[e("input",{type:"file",ref:o,accept:"image/*",className:"lte-hidden",onChange:e=>{const t=e.target.files?.[0];t&&y(t),e.target.value=""}}),e(Zn,{content:"Add Image",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${r?"toolbarActive":"toolbar"} icon`,onClick:()=>l(e=>!e),children:e(At,{size:18})})}),t(si,{open:r,onClose:()=>l(!1),children:[e("div",{className:"lte-dialog-header",children:"Add Image"}),t("div",{className:"lte-dialog-body",children:[e("input",{className:"lte-input",placeholder:"Alt text",value:h,onChange:e=>g(e.target.value)}),e("input",{className:"lte-input",placeholder:"Caption",value:m,onChange:e=>b(e.target.value)}),e("input",{className:"lte-input",placeholder:"Add image by URL",value:c,onChange:e=>p(e.target.value)}),e("div",{className:"lte-divider",children:e("span",{children:"or"})}),t("button",{type:"button",className:"lexical-btn heading-trigger toolbar-active",onClick:()=>o.current?.click(),style:{width:"fit-content",margin:"0 auto"},children:[e(Gt,{size:20}),e("span",{children:"Upload Image"})]}),f&&e("div",{className:"lte-file-name",children:f.name})]}),e("div",{className:"lte-dialog-footer",children:e("button",{type:"button",className:"lte-primary-btn",disabled:!c&&!f||v,onClick:async()=>{if(!v){if(f){x(!0);try{await w(f,h,m)}catch(e){return console.error("Image upload failed:",e),void x(!1)}x(!1)}else{if(!c)return;ci(i,{src:c,altText:h,caption:m})}y(void 0),g(""),b(""),p(""),l(!1)}},children:v?"Uploading...":"Add Image"})})]})]})}const ui=({id:e,provider:t})=>new yi({id:e,provider:t}),pi="data-lexical-video",hi="data-provider",gi="315px",mi="560px",bi=(e,t)=>"drive"===t?`https://drive.google.com/file/d/${e}/preview`:`https://www.youtube-nocookie.com/embed/${e}`,fi=e=>{const t=e?.getAttribute(pi),n=e?.getAttribute(hi)??"youtube";if(!t)return null;return{node:ui({id:t,provider:n})}};class yi extends Q{constructor({id:e,provider:t,key:n}){super(n),this.__id=e,this.__provider=t}static getType(){return"video"}static clone(e){return new yi({id:e.__id,provider:e.__provider,key:e.getKey()})}static importJSON(e){return ui({id:e.id,provider:e.provider})}exportJSON(){return{id:this.__id,provider:this.__provider,type:"video",version:1}}updateDOM(){return!1}decorate(){return e("iframe",{height:gi,width:mi,src:bi(this.__id,this.__provider),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(pi,this.__id),e.setAttribute(hi,this.__provider),e.setAttribute("height",gi),e.setAttribute("width",mi),e.setAttribute("src",bi(this.__id,this.__provider)),{element:e}}static importDOM(){return{iframe:()=>({conversion:fi,priority:0})}}}function vi(){const[n,i]=d(!1),[o,r]=d(!1),[l,a]=d(""),[c]=Wt();return s(()=>{n||(a(""),r(!1))},[n]),t("div",{className:"lexical-text-editor-dialog",children:[e(Zn,{content:"Embed Video",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${n?"toolbarActive":"toolbar"} icon`,onClick:()=>i(!0),children:e(Yt,{size:18,color:"red"})})}),t(si,{open:n,onClose:()=>i(!1),children:[e("div",{className:"lte-dialog-header",children:"Embed Video"}),t("div",{className:"lte-dialog-body",children:[e("input",{className:"lte-input",placeholder:"Add YouTube or Google Drive URL",value:l,onChange:e=>a(e.target.value)}),o&&e("p",{className:"lte-error-text",children:"It's not a valid YouTube or Google Drive URL"})]}),e("div",{className:"lte-dialog-footer",children:e("button",{type:"button",className:"lte-primary-btn",disabled:!l,onClick:()=>{if(!l)return;let e=null,t=null;const n=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(l);n&&11===n[2]?.length&&(e="youtube",t=n[2]);const o=/drive\.google\.com\/file\/d\/([a-zA-Z0-9_-]+)\//.exec(l);o&&o[1]&&(e="drive",t=o[1]),t&&e?(c.update(()=>{const n=ui({id:t,provider:e});ee([n])}),a(""),r(!1),i(!1)):r(!0)},children:"Embed"})})]})]})}function xi({value:t}){return e("div",{className:"lexical-text-editor-html-preview",dangerouslySetInnerHTML:{__html:t}})}function wi({value:n,triggerLabel:i="Preview"}){const[o,r]=d(!1);return t("div",{className:"lexical-text-editor-dialog",children:[e(Zn,{content:i,direction:"bottom",children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),children:[e(en,{size:18}),e("span",{children:i})]})}),t(si,{open:o,onClose:()=>r(!1),forPreview:!0,children:[e("div",{className:"lte-dialog-header",children:"Content Preview"}),t("div",{className:"lte-preview-container",children:[e("div",{className:"lte-preview-title",children:"CONTENT"}),e(xi,{value:n})]})]})]})}const ki=[{id:"headings",sep:!0},{id:"fontFamily"},{id:"fontSize"},{id:"textFormats",sep:!0},{id:"dropdown",sep:!0},{id:"color",sep:!0},{id:"quoteCode",sep:!0},{id:"codeBlock"},{id:"alignment",sep:!0},{id:"lists",sep:!0},{id:"blockOptions"},{id:"table",sep:!0},{id:"hline"},{id:"link",sep:!0},{id:"image"},{id:"video"},{id:"utility",sep:!0},{id:"preview"}],Ci=ki.map(e=>e.id),Ni=({value:i,onImageUpload:o,sourceView:r=!1,onToggleSourceView:l,fullscreen:c=!1,onToggleFullscreen:p,toolbarStyle:f="wrap"})=>{const y="normal"===f?"collapse":f,[v]=Wt(),[x,w]=d({[on.Undo]:!0,[on.Redo]:!0}),[k,C]=d(!1),[N,_]=d(!1),[S,T]=d(0),[L,z]=d(!1),F=u(()=>z(!1),[]),$=a(null),R=a(null),O=a(null),W=a({}),I=a({}),P=a(0),B=a(null),H=a(null),[U,j]=d({[on.LeftAlign]:!0}),[Z,Q]=d({[rn.Normal]:!0}),[X,G]=d("paragraph"),[Y,ee]=d("https://");let ae=!0;const se=()=>{if(ae){const e=v.getRootElement();e&&(e.scrollTop=0,ae=!1)}const e=A();if(D(e)){const t={[on.Bold]:e.hasFormat("bold"),[on.Italics]:e.hasFormat("italic"),[on.Underline]:e.hasFormat("underline"),[on.Uppercase]:e.hasFormat("uppercase"),[on.Lowercase]:e.hasFormat("lowercase"),[on.Capitalize]:e.hasFormat("capitalize"),[on.Strikethrough]:e.hasFormat("strikethrough"),[on.Superscript]:e.hasFormat("superscript"),[on.Subscript]:e.hasFormat("subscript"),[on.Code]:e.hasFormat("code"),[on.Highlight]:e.hasFormat("highlight")};j(t);const n=e.anchor.getNode(),i="root"===n.getKey()?n:n.getTopLevelElementOrThrow(),o=i.getKey();if(!v.getElementByKey(o))return;if(Te(i)){const e=$n(n,Se),t=e?e.getTag():i.getTag();G(t)}else if("paragraph"===i.getType()||h(i)){let e=null;h(i)&&(e=i.getTag());const t={[rn.H1]:"h1"===e,[rn.H2]:"h2"===e,[rn.H3]:"h3"===e,[rn.H4]:"h4"===e,[rn.H5]:"h5"===e,[rn.H6]:"h6"===e,[rn.Normal]:"paragraph"===i.getType()};G(i.getType()),Q(t)}else G(i.getType());const r=(E(n)?n:i).getFormat();j(e=>({...e,[on.LeftAlign]:0===r||1===r,[on.CenterAlign]:2===r,[on.RightAlign]:3===r,[on.JustifyAlign]:4===r})),"quote"===i.getType()?j(e=>({...e,[on.Quote]:!0})):j(e=>({...e,[on.Quote]:!1}));const l=e.anchor.getNode(),a=l.getParent();Pt(a)?(j(e=>({...e,[on.Link]:!0})),ee(a.getURL()),C(!0)):Pt(l)?(j(e=>({...e,[on.Link]:!0})),ee(l.getURL()),C(!0)):(j(e=>({...e,[on.Link]:!1})),ee("https://"),C(!1))}};s(()=>Fn(v.registerUpdateListener(({editorState:e})=>{e.read(()=>{se()})}),v.registerCommand(K,()=>(se(),!1),1),v.registerCommand(ne,e=>(w(t=>({...t,undo:!e})),!1),1),v.registerCommand(te,e=>(w(t=>({...t,redo:!e})),!1),1)),[]);const ce="scrollbar"===y,de=u(()=>{if("collapse"!==y)return;const e=$.current;if(!e)return;const t=e.clientWidth;if(t<=0)return;const n=R.current?R.current.offsetWidth:0,i=Ci.map(e=>{const t=W.current[e];return t&&"none"!==t.style.display&&(I.current[e]=t.offsetWidth),I.current[e]??0});O.current&&(P.current=O.current.offsetWidth);const o=P.current||40,r=e=>{const t=1+(e>0?1:0)+(Ci.length-e);let r=n+6*Math.max(0,t-1)+(e>0?o:0);for(let t=0;t<Ci.length-e;t++)r+=i[t];return r};let l=S;for(;l<Ci.length&&r(l)>t;)l++;for(;l>0&&r(l-1)<=t;)l--;T(e=>e===l?e:l)},[S,y]);s(()=>{de()});const ue=a(()=>{});ue.current=de,s(()=>{if("undefined"==typeof ResizeObserver)return;const e=$.current;if(!e)return;const t=new ResizeObserver(()=>{ue.current(),fe.current()});return t.observe(e),()=>t.disconnect()},[]),s(()=>{0===S&&z(!1)},[S]),s(()=>{"collapse"!==y&&T(0)},[y]);const pe=u(()=>{if("scrollbar"!==y)return;const e=$.current,t=B.current,n=H.current;if(!e||!t||!n)return;const i=e.clientWidth;if(e.scrollWidth-i<=1)return void(t.style.display="none");t.style.display="flex";const o=Math.max(24,i/e.scrollWidth*i),r=e.scrollWidth-i,l=i-o,a=r>0?e.scrollLeft/r*l:0;n.style.width=`${o}px`,n.style.transform=`translateX(${a}px)`},[f]),he=u(e=>{e.stopPropagation(),e.preventDefault();const t=$.current,n=H.current;if(!t||!n)return;const i=e.clientX,o=t.scrollLeft,r=t.clientWidth,l=Math.max(24,r/t.scrollWidth*r),a=t.scrollWidth-r,s=r-l,c=e=>{const n=e.clientX-i;t.scrollLeft=s>0?o+n/s*a:0},d=()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",d)};document.addEventListener("pointermove",c),document.addEventListener("pointerup",d)},[]),ge=u(e=>{const t=$.current,n=B.current;if(!t||!n)return;const i=n.getBoundingClientRect(),o=(e.clientX-i.left)/i.width;t.scrollLeft=o*t.scrollWidth-t.clientWidth/2},[]),me=a(null),be=u(()=>{const e=me.current;if(e)for(const t of e.querySelectorAll(".lte-toolbar-row svg:not(.chevron), .lte-overflow-panel svg:not(.chevron)")){if(t.closest(".lexical-stepper"))continue;const e=t;try{const t=e.viewBox?.baseVal;if(!t||!t.width)continue;let n=1/0,i=1/0,o=-1/0,r=-1/0;if(e.querySelectorAll("path, circle, rect, ellipse, polygon, polyline, line").forEach(e=>{const t=e.getBBox();(t.width||t.height)&&(n=Math.min(n,t.x),i=Math.min(i,t.y),o=Math.max(o,t.x+t.width),r=Math.max(r,t.y+t.height))}),o===-1/0)continue;const l=((o-n)/t.width+(r-i)/t.height)/2;if(!isFinite(l)||l<=0)continue;const a=Math.min(22,Math.max(17,15/l));parseFloat(e.style.width)!==a&&(e.style.width=`${a}px`,e.style.height=`${a}px`)}catch{}}},[]);s(()=>{be()}),s(()=>{pe()});const fe=a(()=>{});fe.current=pe,s(()=>{if("scrollbar"!==y)return;const e=$.current;if(!e)return;const t=()=>pe();return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[y,pe]);const ye=e=>{switch(e){case on.Bold:v.dispatchCommand(le,"bold");break;case on.Italics:v.dispatchCommand(le,"italic");break;case on.Underline:v.dispatchCommand(le,"underline");break;case on.Lowercase:v.dispatchCommand(le,"lowercase");break;case on.Uppercase:v.dispatchCommand(le,"uppercase");break;case on.Capitalize:v.dispatchCommand(le,"capitalize");break;case on.Strikethrough:v.dispatchCommand(le,"strikethrough");break;case on.Superscript:v.dispatchCommand(le,"superscript");break;case on.Subscript:v.dispatchCommand(le,"subscript");break;case on.Highlight:v.dispatchCommand(le,"highlight");break;case on.Code:v.dispatchCommand(le,"code");break;case on.Quote:v.update(()=>{const e=A();if(D(e)){const t=e.anchor.getNode().getParent();t&&g(t)?Cn(e,()=>q()):Sn(e,()=>m())}});break;case on.Link:ve(),C(!0);break;case on.LeftAlign:v.dispatchCommand(re,"left");break;case on.RightAlign:v.dispatchCommand(re,"right");break;case on.CenterAlign:v.dispatchCommand(re,"center");break;case on.JustifyAlign:v.dispatchCommand(re,"justify");break;case on.Undo:v.dispatchCommand(oe,void 0);break;case on.Redo:v.dispatchCommand(ie,void 0);break;case on.ClearFormatting:v.update(()=>{const e=A();if(!D(e))return;const t=e.getNodes().filter(M);for(const e of t)e.setFormat(0),e.setStyle("")});break;case on.HorizontalRule:v.dispatchCommand(ze,void 0);break;case on.Indent:v.dispatchCommand(V,void 0);break;case on.Outdent:v.dispatchCommand(J,void 0)}},ve=u(()=>{v.update(()=>{const e=A();D(e)&&!e.isCollapsed()&&(k?v.dispatchCommand(It,null):""!==Y&&v.dispatchCommand(It,Y))})},[v,k,Y]),xe=u(()=>{ee(""),v.dispatchCommand(It,null),C(!1)},[v]),we=e=>Ci.indexOf(e)>=Ci.length-S,ke={headings:e(In,{updateHeading:e=>{v.update(()=>{const t=A();D(t)&&Sn(t,"normal"===e?()=>q():()=>b(e))})},headingSelectionMap:Z}),fontFamily:e(Vn,{}),fontSize:e(Qn,{}),textFormats:e(n,{children:an.map(({id:t,label:n,icon:i})=>t===on.Divider?e(Wn,{},t):e(Zn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${U[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:i})},t))}),dropdown:e(On,{onAction:ye,selectionMap:U}),color:t(n,{children:[e(qn,{}),sn.map(({id:t,label:n,icon:i})=>e(Zn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${U[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:i})},t))]}),quoteCode:e(n,{children:cn.map(({id:t,label:n,icon:i})=>e(Zn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${U[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:i})},t))}),codeBlock:e(ti,{}),alignment:e(Un,{onAction:ye,alignmentSelectionMap:U}),lists:e(ni,{blockType:X}),blockOptions:e(n,{children:un.map(({id:t,label:n,icon:i})=>t===on.Divider?e(Wn,{},t):e(Zn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${U[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:i})},t))}),table:e(ii,{}),hline:e(n,{children:pn.map(({id:t,label:n,icon:i})=>e(Zn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${U[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:i})},t))}),link:e(Zn,{content:"Link",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${U[on.Link]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(on.Link),disabled:!!x[on.Link],children:e(Kt,{})})}),image:e(di,{onImageUpload:o}),video:e(vi,{}),utility:t(n,{children:[e(Zn,{content:"Find & Replace",direction:"bottom",children:e("button",{type:"button","aria-label":"Find & Replace",className:`size-10 lexical-btn ${N?"toolbarActive":"toolbar"} icon`,onClick:()=>_(e=>!e),children:e(Ft,{})})}),e(Zn,{content:"Source Code View",direction:"bottom",children:e("button",{type:"button","aria-label":"Source Code View",className:`size-10 lexical-btn ${r?"toolbarActive":"toolbar"} icon`,onClick:()=>l?.(),children:e($t,{})})}),e(Zn,{content:c?"Exit Fullscreen":"Fullscreen",direction:"bottom",children:e("button",{type:"button","aria-label":c?"Exit Fullscreen":"Fullscreen",className:`size-10 lexical-btn ${c?"toolbarActive":"toolbar"} icon`,onClick:()=>p?.(),children:e(c?vt:xt,{})})})]}),preview:e(wi,{value:i})};return e(bn.Provider,{value:F,children:t("div",{ref:me,className:"lexical-toolbar-wrapper",style:{position:"relative",padding:12,marginBottom:4,borderBottom:"1px solid #e5e7eb"},children:[t("div",{ref:$,className:"lte-toolbar-row "+(ce?"useScroll":"collapse"===y?"lte-nowrap":"lte-wrap"),onMouseDown:e=>{"INPUT"!==e.target.tagName&&e.preventDefault()},children:[e("div",{ref:R,className:"lte-toolbar-primary",style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:dn.map(({id:t,label:n,icon:i})=>t===on.Divider?e(Wn,{},t):e(Zn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${U[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),disabled:!!x[t],children:i})},n))}),ki.map(({id:n,sep:i})=>{const o=we(n);return t("div",{ref:e=>{W.current[n]=e},style:o?{display:"none"}:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[i?e(Wn,{}):null,o?null:ke[n]]},n)}),S>0&&e(Zn,{content:"More tools",direction:"bottom",children:e("button",{type:"button",ref:O,"aria-label":"More tools",className:`size-10 lexical-btn ${L?"toolbarActive":"toolbar"} icon`,onClick:()=>z(e=>!e),children:e(wt,{})})})]}),ce&&e("div",{ref:B,className:"lte-custom-scrollbar",onPointerDown:ge,"aria-hidden":"true",children:e("div",{ref:H,className:"lte-custom-scrollbar-thumb",onPointerDown:he})}),k&&e(Pn,{linkUrl:Y,setLinkUrl:ee,removeLink:xe,onConfirm:e=>{v.dispatchCommand(It,{url:e,target:"_blank"}),ee(e),C(!1)},onCancel:()=>{ee(""),C(!1)}}),L&&e(Hn,{anchorRef:O,onClose:()=>z(!1),children:ki.filter(({id:e})=>we(e)&&ke[e]).map(({id:n,sep:i},o)=>t("div",{className:"lte-overflow-item",children:[i&&o>0?e(Wn,{}):null,ke[n]]},n))}),N&&e(Bn,{onClose:()=>_(!1)})]})})};function _i(){const[e]=Wt();return s(()=>{let t=!1;return Fn(e.registerCommand(ce,()=>{const e=A();if(!D(e))return!1;const n=e.anchor.getNode();return M(n)&&n.hasFormat("code")&&e.anchor.offset===n.getTextContentSize()&&(t=!0),!1},se),e.registerCommand(ae,t=>{if(t.ctrlKey||t.metaKey||t.altKey)return!1;const n=t.key;if(1!==n.length)return!1;const i=A();if(!D(i)||!i.isCollapsed())return!1;const o=i.anchor.getNode();if(!M(o)||o.hasFormat("code"))return!1;if(0!==i.anchor.offset)return!1;const r=o.getPreviousSibling();if(!M(r)||!r.hasFormat("code"))return!1;t.preventDefault();const l=r.getKey();return e.update(()=>{const e=U(l);if(!M(e)||!e.hasFormat("code"))return;e.setTextContent(e.getTextContent()+n);const t=e.getTextContentSize();e.select(t,t)}),!0},se),e.registerUpdateListener(({editorState:n})=>{t&&(t=!1,n.read(()=>{const t=A();D(t)&&e.update(()=>{const e=A();if(!D(e))return;const t=e.anchor.getNode(),n=e=>M(e)&&0===e.getTextContentSize()&&e.hasFormat("code");if(M(t))if(n(t))t.setFormat(0);else{let e=t.getPreviousSibling();for(;e&&M(e)&&0===e.getTextContentSize();)e.hasFormat("code")&&e.setFormat(0),e=e.getPreviousSibling()}else if(E(t))if(0===t.getChildrenSize())e.hasFormat("code")&&e.setFormat(0);else{const e=t.getFirstChild();n(e)&&M(e)&&e.setFormat(0)}M(t)&&t.hasFormat("code")||e.hasFormat("code")&&e.setFormat(0)})}))}))},[e]),null}function Si(e,t){const n=de(t)?t.body.childNodes:t.childNodes;let i=[];const o=[];for(const t of n)if(!zi.has(t.nodeName)){const n=Ei(t,e,o,!1);null!==n&&(i=i.concat(n))}return function(e){for(const t of e)t.getNextSibling()instanceof ue&&t.insertAfter(pe());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(o),i}function Ti(e,t){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const n=document.createElement("div"),i=H().getChildren();for(let o=0;o<i.length;o++)Li(e,i[o],n,t);return n.innerHTML}function Li(e,t,n,i=null){let o=null===i||t.isSelected(i);const r=E(t)&&t.excludeFromCopy("html");let l=t;if(null!==i){let e=he(t);e=M(e)&&null!==i?function(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!O(t)&&null!==n){const[i,o]=n,r=e.isBackward(),l=i.getNode(),a=o.getNode(),s=t.is(l),c=t.is(a);if(s||c){const[n,i]=W(e),o=l.is(a),s=t.is(r?a:l),c=t.is(r?l:a);let d,u=0;o?(u=n>i?i:n,d=n>i?n:i):s?(u=r?i:n,d=void 0):c&&(u=0,d=r?n:i),t.__text=t.__text.slice(u,d)}}return t}(i,e):e,l=e}const a=E(l)?l.getChildren():[],s=ge(e,l.getType());let c;c=s&&void 0!==s.exportDOM?s.exportDOM(e,l):l.exportDOM(e);const{element:d,after:u}=c;if(!d)return!1;const p=document.createDocumentFragment();for(let n=0;n<a.length;n++){const r=a[n],l=Li(e,r,p,i);!o&&E(t)&&l&&t.extractWithChild(r,i,"html")&&(o=!0)}if(o&&!r){if((me(d)||be(d))&&d.append(p),n.append(d),u){const e=u.call(l,d);e&&(be(d)?d.replaceChildren(e):d.replaceWith(e))}}else n.append(p);return o}const zi=new Set(["STYLE","SCRIPT"]);function Ei(e,t,n,i,o=new Map,r){let l=[];if(zi.has(e.nodeName))return l;let a=null;const s=function(e,t){const{nodeName:n}=e,i=t._htmlConversions.get(n.toLowerCase());let o=null;if(void 0!==i)for(const t of i){const n=t(e);null!==n&&(null===o||(o.priority||0)<=(n.priority||0))&&(o=n)}return null!==o?o.conversion:null}(e,t),c=s?s(e):null;let d=null;if(null!==c){d=c.after;const t=c.node;if(a=Array.isArray(t)?t[t.length-1]:t,null!==a){for(const[,e]of o)if(a=e(a,r),!a)break;a&&l.push(...Array.isArray(t)?t:[a])}null!=c.forChild&&o.set(e.nodeName,c.forChild)}const u=e.childNodes;let p=[];const h=(null==a||!$(a))&&(null!=a&&fe(a)||i);for(let e=0;e<u.length;e++)p.push(...Ei(u[e],t,n,h,new Map(o),a));return null!=d&&(p=d(p)),ye(e)&&(p=function(e,t,n){const i=e.style.textAlign,o=[];let r=[];for(let e=0;e<t.length;e++){const l=t[e];if(fe(l))i&&!l.getFormat()&&l.setFormat(i),o.push(l);else if(r.push(l),e===t.length-1||e<t.length-1&&fe(t[e+1])){const e=n();e.setFormat(i),e.append(...r),o.push(e),r=[]}}return o}(e,p,h?()=>{const e=new ue;return n.push(e),e}:q)),null==a?p.length>0?l=l.concat(p):ye(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&(ve(e.nextSibling)&&ve(e.previousSibling))}(e)&&(l=l.concat(pe())):E(a)&&a.append(...p),l}function Ai({value:t,onChange:n}){const[i]=Wt(),[o,r]=d(!0);return s(()=>{t&&o&&(r(!1),i.update(()=>{if(Ti(i)!==t){H().clear();const e=(new DOMParser).parseFromString(t,"text/html"),n=Si(i,e);ee(n)}}))},[i,t,o]),s(()=>{r(!0)},[t]),e(nn,{onChange:e=>{e.read(()=>{n(Ti(i))})}})}function Fi({applyRef:n,onExit:i}){const[o]=Wt(),[r,l]=d(()=>o.getEditorState().read(()=>Ti(o))),c=a(r),u=e=>{e!==c.current&&(o.update(()=>{const t=H();if(t.clear(),t.selectEnd(),e){const t=(new DOMParser).parseFromString(e,"text/html"),n=Si(o,t);n.length>0&&ee(n)}}),c.current=e)};return s(()=>(n.current=()=>{u(r),i()},()=>{n.current=null}),[n,r,i,o]),t("div",{className:"lexical-source-view",children:[e("textarea",{className:"lexical-source-textarea",value:r,onChange:e=>l(e.target.value),"aria-label":"HTML source",spellCheck:!1}),t("div",{className:"lexical-source-actions",children:[e(Zn,{content:"Apply HTML to the editor",direction:"top",children:t("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>u(r),children:[e(qt,{size:16}),e("span",{className:"label",children:"Update"})]})}),e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{u(r),i()},children:"Done"})]})]})}function $i({showWordCount:n=!0,showCharCount:i=!0,rightSlot:o}){const[r]=Wt(),[l,a]=d({words:0,chars:0});return s(()=>{const e=e=>{e.read(()=>{const e=H().getTextContent(),t=e.trim();a({words:t?t.split(/\s+/).length:0,chars:e.length})})};return e(r.getEditorState()),r.registerUpdateListener(({editorState:t})=>{e(t)})},[r]),t("div",{className:"lexical-status-bar",children:[n&&t("span",{children:[l.words," words"]}),i&&t("span",{children:[l.chars," characters"]}),o&&e("div",{className:"lexical-status-bar-right",children:o})]})}function Ri({theme:n,toolbarStyle:i,onThemeChange:o,onToolbarStyleChange:r}){const l="normal"===i?"collapse":i,a=[{value:"light",label:"Light theme",icon:e(kt,{})},{value:"dark",label:"Dark theme",icon:e(Ct,{})},{value:"system",label:"Follow system theme",icon:e(jt,{})}],s=[{value:"wrap",label:"Toolbar: wrap to new lines",icon:e(Jt,{})},{value:"collapse",label:'Toolbar: collapse into "..."',icon:e(wt,{})},{value:"scrollbar",label:"Toolbar: scroll in one row",icon:e(Xe,{})}];return t("div",{className:"lexical-display-controls",role:"group","aria-label":"Display settings",children:[e("div",{className:"lte-mini-seg",role:"radiogroup","aria-label":"Theme",children:a.map(t=>e(Zn,{content:t.label,direction:"top",children:e("button",{type:"button",role:"radio","aria-checked":n===t.value,"aria-label":t.label,className:"lte-mini-btn btn "+(n===t.value?"active":""),onClick:()=>o?.(t.value),children:t.icon})},t.value))}),e("div",{className:"lte-mini-seg",role:"radiogroup","aria-label":"Toolbar style",children:s.map(t=>e(Zn,{content:t.label,direction:"top",children:e("button",{type:"button",role:"radio","aria-checked":l===t.value,"aria-label":t.label,className:"lte-mini-btn btn "+(l===t.value?"active":""),onClick:()=>r?.(t.value),children:t.icon})},t.value))})]})}const Di=({id:e})=>new Bi({id:e}),Mi="data-lexical-youtube",Oi="315px",Wi="560px",Ii=e=>`https://www.youtube-nocookie.com/embed/${e}`,Pi=e=>{const t=e?.getAttribute(Mi);if(!t)return null;return{node:Di({id:t})}};class Bi extends Q{constructor({id:e,key:t}){super(t),this.__id=e}static getType(){return"youtube"}static clone(e){return new Bi({id:e.__id,key:e.getKey()})}static importJSON(e){return Di({id:e.id})}exportJSON(){return{id:this.__id,type:"youtube",version:1}}decorate(){return e("iframe",{height:Oi,width:Wi,src:Ii(this.__id),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(Mi,this.__id),e.setAttribute("height",Oi),e.setAttribute("width",Wi),e.setAttribute("src",Ii(this.__id)),{element:e}}static importDOM(){return{iframe:()=>({conversion:Pi,priority:0})}}}class Hi extends xe{constructor(e,t){super(e,t)}static getType(){return"extended-text"}static clone(e){return new Hi(e.__text,e.__key)}static importDOM(){const e=xe.importDOM();return{...e,span:()=>({conversion:Ui(e?.span),priority:1}),div:()=>({conversion:Ui(e?.div),priority:1}),p:()=>({conversion:Ui(e?.p),priority:1}),b:()=>({conversion:Ui(e?.b),priority:1}),strong:()=>({conversion:Ui(e?.strong),priority:1}),i:()=>({conversion:Ui(e?.i),priority:1}),em:()=>({conversion:Ui(e?.em),priority:1}),u:()=>({conversion:Ui(e?.u),priority:1}),s:()=>({conversion:Ui(e?.s),priority:1}),strike:()=>({conversion:Ui(e?.strike),priority:1}),code:()=>({conversion:Ui(e?.code),priority:1})}}static importJSON(e){return function(e=""){return X(new Hi(e))}().updateFromJSON(e)}isSimpleText(){return"extended-text"===this.__type&&0===this.__mode}}function Ui(e){return t=>{const n=e?.(t);if(!n)return null;const i=n.conversion(t);if(!i)return i;const o=t.style,r=[];o.backgroundColor&&r.push(`background-color: ${o.backgroundColor}`),o.color&&r.push(`color: ${o.color}`),o.fontFamily&&r.push(`font-family: ${o.fontFamily}`),o.fontWeight&&r.push(`font-weight: ${o.fontWeight}`),o.fontSize&&r.push(`font-size: ${o.fontSize}`),o.fontStyle&&r.push(`font-style: ${o.fontStyle}`),o.textDecoration&&r.push(`text-decoration: ${o.textDecoration}`),o.whiteSpace&&r.push(`white-space: ${o.whiteSpace}`),o.textAlign&&r.push(`text-align: ${o.textAlign}`);const l=t.getAttribute("style");if(l){l.split(";").filter(e=>e.trim()).forEach(e=>{const[t]=e.split(":").map(e=>e.trim());t&&!r.some(e=>e.startsWith(t))&&r.push(e.trim())})}return{...i,forChild:(e,t)=>{const n=i?.forChild??(e=>e),o=n(e,t);if(M(o)&&r.length>0){const e=r.join("; ");return o.setStyle(e)}return o}}}}const Ki={text:{bold:"lexical-bold",underline:"lexical-underline",italic:"lexical-italic",strikethrough:"lexical-strikethrough",underlineStrikethrough:"lexical-underline-strikethrough",uppercase:"lexical-uppercase",lowercase:"lexical-lowercase",capitalize:"lexical-capitalize",code:"lexical-code"},paragraph:"lexical-paragraph",list:{ul:"lexical-list-ul",ol:"lexical-list-ol",listitem:"lexical-listitem"},quote:"lexical-quote",link:"lexical-link",code:"lexical-code-block",hr:"lexical-hr",indent:"lexical-indent",table:"lexical-table",tableRow:"lexical-table-row",tableCell:"lexical-table-cell",codeHighlight:{keyword:"lexical-code-token-keyword",string:"lexical-code-token-string",number:"lexical-code-token-number",comment:"lexical-code-token-comment",function:"lexical-code-token-function",operator:"lexical-code-token-operator",punctuation:"lexical-code-token-punctuation",boolean:"lexical-code-token-number",builtin:"lexical-code-token-keyword","class-name":"lexical-code-token-function",regex:"lexical-code-token-string",tag:"lexical-code-token-keyword","attr-name":"lexical-code-token-string"}},qi=o.memo(function({name:n,value:o,onChange:r,placeholder:l,maxWidth:c=null,height:u=null,onImageUpload:h,showWordCount:g=!0,showCharCount:m=!0,theme:b="system",toolbarStyle:v="collapse",showDisplayControls:x=!0,onThemeChange:w,onToolbarStyleChange:T}){const[L,z]=d(!1),[E,A]=d(!1),F=a(null),[$,R]=d(!1),[D,M]=d(b),[O,W]=d("normal"===v?"collapse":v);s(()=>{M(b)},[b]),s(()=>{W("normal"===v?"collapse":v)},[v]),s(()=>{if("system"!==D||"undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)");R(e.matches);const t=e=>R(e.matches);return e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))},[D]);const I="dark"===D||"system"===D&&$;s(()=>{if(!E)return;const e=e=>{"Escape"===e.key&&A(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[E]);const P=p(()=>({namespace:n,theme:Ki,onError:e=>{console.error("Lexical error:",e)},nodes:[Hi,{replace:xe,with:e=>new Hi(e.__text),withKlass:Hi},f,k,C,Se,Le,y,Bt,ai,Bi,yi,Ee,Be,He,Ue]}),[n]);return e("div",{className:`lexical-text-editor lexical-editor-container ${E?"lexical-fullscreen":""} ${I?"lexical-dark":""}`,style:{maxWidth:E?"none":c||"1090px"},children:t(i,{initialConfig:P,children:[e("div",{className:"lexical-toolbar-container",children:e(Ni,{value:o,onImageUpload:h,sourceView:L,onToggleSourceView:()=>{z(e=>!e||(F.current?.(),!1))},fullscreen:E,onToggleFullscreen:()=>{A(e=>!e)},toolbarStyle:O})}),e("div",{className:"lexical-editor-inner",style:L?{display:"none"}:void 0,children:e(N,{contentEditable:e(_,{className:"lexical-content-editable",style:{height:u||"500px"}}),placeholder:e("div",{className:"lexical-placeholder",children:l||"Some Text"}),ErrorBoundary:S})}),L&&e(Fi,{applyRef:F,onExit:()=>z(!1)}),(g||m||x)&&e($i,{showWordCount:g,showCharCount:m,rightSlot:x?e(Ri,{theme:D,toolbarStyle:O,onThemeChange:e=>{M(e),w?.(e)},onToolbarStyleChange:e=>{W(e),T?.(e)}}):void 0}),e(we,{}),e(ke,{}),e(Fe,{}),e(Ae,{}),e(tn,{}),e(_i,{}),e(Ai,{value:o,onChange:r})]})})});export{qi as LexicalTextEditor};
2
2
  //# sourceMappingURL=index.esm.js.map