@innoviatech/lexical-text-editor 3.0.3 → 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,{createContext as l,useContext as r,useRef as a,useEffect as c,cloneElement as s,useState as d,useCallback as u,useMemo as h}from"react";import{$isHeadingNode as p,$isQuoteNode as m,$createQuoteNode as g,$createHeadingNode as f,HeadingNode as b,QuoteNode as y}from"@lexical/rich-text";import{$isCodeNode as v,$createCodeNode as x,CodeHighlightNode as w,CodeNode as C}from"@lexical/code";import{RichTextPlugin as k}from"@lexical/react/LexicalRichTextPlugin";import{ContentEditable as N}from"@lexical/react/LexicalContentEditable";import{LexicalErrorBoundary as S}from"@lexical/react/LexicalErrorBoundary";import{$createRangeSelection as _,$findMatchingParent as L,INTERNAL_$isBlock as T,$isElementNode as E,$getSelection as A,$setSelection as F,$isRootOrShadowRoot as D,$hasAncestor as M,$isRangeSelection as z,$isTextNode as R,$isTokenOrSegmented as W,$getCharacterOffsets as O,$isLeafNode as I,$getPreviousSelection as H,$caretRangeFromSelection as U,$getRoot as P,$getNodeByKey as $,SELECTION_CHANGE_COMMAND as K,$createParagraphNode as B,KEY_TAB_COMMAND as J,OUTDENT_CONTENT_COMMAND as q,INDENT_CONTENT_COMMAND as V,COMMAND_PRIORITY_EDITOR as j,DecoratorNode as Q,$applyNodeReplacement as X,PASTE_COMMAND as Y,COMMAND_PRIORITY_LOW as G,$insertNodes as Z,CAN_REDO_COMMAND as ee,CAN_UNDO_COMMAND as te,REDO_COMMAND as ne,UNDO_COMMAND as oe,FORMAT_ELEMENT_COMMAND as ie,FORMAT_TEXT_COMMAND as le,KEY_DOWN_COMMAND as re,COMMAND_PRIORITY_HIGH as ae,KEY_ENTER_COMMAND as ce,isDOMDocumentNode as se,ArtificialNode__DO_NOT_USE as de,$createLineBreakNode as ue,$cloneWithProperties as he,getRegisteredNode as pe,isHTMLElement as me,isDocumentFragment as ge,$isBlockElementNode as fe,isBlockDomNode as be,isInlineDomNode as ye,TextNode as ve}from"lexical";import{HistoryPlugin as xe}from"@lexical/react/LexicalHistoryPlugin";import{ListPlugin as we}from"@lexical/react/LexicalListPlugin";import{REMOVE_LIST_COMMAND as Ce,INSERT_ORDERED_LIST_COMMAND as ke,INSERT_UNORDERED_LIST_COMMAND as Ne,ListNode as Se,$isListNode as _e,ListItemNode as Le}from"@lexical/list";import{INSERT_HORIZONTAL_RULE_COMMAND as Te,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 De,INSERT_TABLE_COMMAND as Me,$isTableCellNode as ze,TableCellHeaderStates as Re,$insertTableRowAtSelection as We,$deleteTableRowAtSelection as Oe,$insertTableColumnAtSelection as Ie,$deleteTableColumnAtSelection as He,TableNode as Ue,TableRowNode as Pe,TableCellNode as $e}from"@lexical/table";import{RxLetterCaseLowercase as Ke,RxLetterCaseUppercase as Be,RxLetterCaseCapitalize as Je}from"react-icons/rx";import{TbBold as qe,TbItalic as Ve,TbUnderline as je,TbSeparatorHorizontal as Qe,TbArrowsLeftRight as Xe}from"react-icons/tb";import{BsSuperscript as Ye,BsSubscript as Ge,BsChatSquareQuote as Ze,BsArrowCounterclockwise as et,BsArrowClockwise as tt,BsJustifyLeft as nt,BsTextCenter as ot,BsJustifyRight as it,BsJustify as lt,BsTextParagraph as rt,BsTypeH1 as at,BsTypeH2 as ct,BsTypeH3 as st,BsTypeH4 as dt,BsTypeH5 as ut,BsTypeH6 as ht,BsPencilSquare as pt,BsFonts as mt,BsListOl as gt,BsListUl as ft,BsTable as bt,BsFullscreenExit as yt,BsFullscreen as vt,BsThreeDots as xt,BsSun as wt,BsMoon as Ct}from"react-icons/bs";import{AiOutlineStrikethrough as kt,AiOutlineFontColors as Nt,AiOutlineBgColors as St}from"react-icons/ai";import{IoCodeSlashOutline as _t,IoChevronUp as Lt,IoChevronDown as Tt,IoClose as Et,IoImageOutline as At,IoSearchOutline as Ft,IoCodeOutline as Dt}from"react-icons/io5";import{PiHighlighterLight as Mt}from"react-icons/pi";import{RiEraserLine as zt,RiIndentIncrease as Rt,RiIndentDecrease as Wt}from"react-icons/ri";import{useLexicalComposerContext as Ot}from"@lexical/react/LexicalComposerContext";import{TOGGLE_LINK_COMMAND as It,$isLinkNode as Ht,LinkNode as Ut}from"@lexical/link";import{HiChevronDown as Pt}from"react-icons/hi2";import{createPortal as $t}from"react-dom";import{IoIosLink as Kt}from"react-icons/io";import{MdCheck as Bt,MdMonitor as Jt,MdWrapText as qt}from"react-icons/md";import{BiUnlink as Vt}from"react-icons/bi";import{SketchPicker as jt}from"react-color";import{LuMinus as Qt,LuPlus as Xt,LuUpload as Yt}from"react-icons/lu";import{FaYoutube as Gt}from"react-icons/fa";import{VscPreview as Zt}from"react-icons/vsc";import{LinkPlugin as en}from"@lexical/react/LexicalLinkPlugin";import{OnChangePlugin as tn}from"@lexical/react/LexicalOnChangePlugin";var nn,on;!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"}(nn||(nn={})),function(e){e.Normal="normal",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6"}(on||(on={}));const ln=[{id:nn.Lowercase,icon:e(Ke,{}),label:"Lowercase"},{id:nn.Uppercase,icon:e(Be,{}),label:"Uppercase"},{id:nn.Capitalize,icon:e(Je,{}),label:"Capitalize"},{id:nn.Superscript,icon:e(Ye,{}),label:"Superscript"},{id:nn.Subscript,icon:e(Ge,{}),label:"Subscript"}],rn=[{id:nn.Bold,icon:e(qe,{}),label:"Bold"},{id:nn.Italics,icon:e(Ve,{}),label:"Italics"},{id:nn.Underline,icon:e(je,{}),label:"Underline"},{id:nn.Strikethrough,icon:e(kt,{}),label:"Strikethrough"}],an=[{id:nn.Highlight,icon:e(Mt,{}),label:"Highlight"}],cn=[{id:nn.Quote,icon:e(Ze,{}),label:"Quote"},{id:nn.Code,icon:e(_t,{}),label:"Code"}],sn=[{id:nn.Undo,icon:e(et,{}),label:"Undo"},{id:nn.Redo,icon:e(tt,{}),label:"Redo"},{id:nn.ClearFormatting,icon:e(zt,{}),label:"Clear Formatting"}],dn=[{id:nn.Indent,icon:e(Rt,{}),label:"Indent"},{id:nn.Outdent,icon:e(Wt,{}),label:"Outdent"}],un=[{id:nn.HorizontalRule,icon:e(Qe,{}),label:"Horizontal Rule"}],hn=[{id:nn.LeftAlign,icon:e(nt,{}),label:"Left Align"},{id:nn.CenterAlign,icon:e(ot,{}),label:"Center Align"},{id:nn.RightAlign,icon:e(it,{}),label:"Right Align"},{id:nn.JustifyAlign,icon:e(lt,{}),label:"Justify Align"}],pn=[{id:"normal",label:"Normal",icon:e(rt,{})},{id:"h1",label:"Heading 1",icon:e(at,{})},{id:"h2",label:"Heading 2",icon:e(ct,{})},{id:"h3",label:"Heading 3",icon:e(st,{})},{id:"h4",label:"Heading 4",icon:e(dt,{})},{id:"h5",label:"Heading 5",icon:e(ut,{})},{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"}],gn=l(()=>{});function fn(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 bn=new Map;function yn(e){let t=bn.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),bn.set(e,t)),t}function vn(e,t){(z(e)?e.isCollapsed():R(e)||E(e))||fn(280);const n=yn(z(e)?e.style:R(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);z(e)||R(e)?e.setStyle(i):e.setTextStyle(i),bn.set(i,o)}function xn(e,t){if(z(e)&&e.isCollapsed()){vn(e,t);const n=e.anchor.getNode();E(n)&&n.isEmpty()&&vn(n,t)}!function(e){const t=A();if(!t)return;const n=new Map,o=e=>n.get(e.getKey())||[0,e.getTextContentSize()];if(z(t))for(const e of U(t).getTextSlices())e&&n.set(e.caret.origin.getKey(),e.getSliceIndices());const i=t.getNodes();for(const t of i){if(!R(t)||!t.canHaveFormat())continue;const[n,i]=o(t);i!==n&&(W(t)||0===n&&i===t.getTextContentSize()?e(t):e(t.splitText(n,i)[0===n?0:1]))}z(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=>{vn(e,t)})}function wn(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function Cn(e,t,n=wn){if(null===e)return;const o=e.getStartEndPoints(),i=new Map;let l=null;if(o){const[e,t]=o;l=_(),l.anchor.set(e.key,e.offset,e.type),l.focus.set(t.key,t.offset,t.type);const n=L(e.getNode(),T),r=L(t.getNode(),T);E(n)&&i.set(n.getKey(),n),E(r)&&i.set(r.getKey(),r)}for(const t of e.getNodes())if(E(t)&&T(t))i.set(t.getKey(),t);else if(null===o){const e=L(t,T);E(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(A())&&F(l)}function kn(e){return e.getNode().isAttached()}function Nn(e){let t=e;for(;null!==t&&!D(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function Sn(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];D(i)?(_n(e,c,c.length,t,n),c=[],a=i):null===a||null!==a&&M(i,a)?c.push(i):(_n(e,c,c.length,t,n),c=[i])}_n(e,c,c.length,t,n)}function _n(e,t,n,o,i=null){if(0===t.length)return;const l=t[0],r=new Map,a=[];let c=E(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(),D(c))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 i=n.getParent();if(null!==i&&i.isInline()&&(i=i.getParent()),null!==i&&I(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()),E(e)&&e.getChildrenKeys().forEach(e=>u.add(e))}),Nn(i)}}else if(d.has(n.getKey())){E(n)||fn(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(D(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(E(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=H();z(p)&&kn(p.anchor)&&kn(p.focus)?F(p.clone()):null!==h?h.selectEnd():e.dirty=!0}function Ln(e,t,n){const o=yn(e.getStyle());return null!==o&&o[t]||n}function Tn(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(z(e)&&e.isCollapsed()&&""!==e.style){const n=yn(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))&&R(l)){const e=Ln(l,t,n);if(null===o)o=e;else if(o!==e){o="";break}}}return null===o?n:o}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 Dn(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}function Mn({open:t,onOpenChange:n,children:o}){const l=a(null),r=a(null);return c(()=>{function e(e){l.current?.contains(e.target)||r.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===zn?s(e,{triggerRef:l}):e.type===Rn?s(e,{contentRef:r,triggerRef:l}):e:e)})}function zn({children:t,triggerRef:n}){return e("div",{className:"popover-trigger",ref:n,children:t})}function Rn({open:t,align:n="start",children:o,contentRef:l,triggerRef:r}){const s=a(null),[d,u]=i.useState(!1);return c(()=>{if(!t)return;const e=()=>{const e=s.current,t=r?.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(),a=e.offsetWidth,c=e.offsetHeight;let d=l.left;"center"===n?d=l.left+l.width/2-a/2:"end"===n&&(d=l.right-a),d=Math.max(8,Math.min(window.innerWidth-a-8,d));let h=l.bottom+4;h+c>window.innerHeight-8&&l.top>c+8&&(h=l.top-c-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,r]),t?$t(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=>{l.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 Wn({onAction:n,selectionMap:o}){const[i,l]=d(!1),r=a(null),c=a(null);return t(Mn,{open:i,onOpenChange:l,children:[e(zn,{triggerRef:r,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),children:[e("span",{children:"Aa"}),e(Pt,{className:"chevron "+(i?"rotated":"")})]})}),e(Rn,{open:i,align:"start",onClose:()=>l(!1),contentRef:c,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:ln.map(({id:i,label:r,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),l(!1)},style:{minWidth:130},children:[a,e("span",{className:"label",children:r})]},i))})})]})}function On(){return e("div",{className:"lexical-separator"})}function In({updateHeading:n,headingSelectionMap:o}){const i=pn.find(e=>o[e.id]),[l,r]=d(!1),c=a(null),s=a(null);return t(Mn,{open:l,onOpenChange:r,children:[e(zn,{triggerRef:c,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(l?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),style:{minWidth:132},children:[i?.icon,e("span",{children:i?.label}),e(Pt,{className:"chevron "+(l?"rotated":"")})]})}),e(Rn,{open:l,align:"start",onClose:()=>r(!1),contentRef:s,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:pn.map(({id:i,label:l,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),r(!1)},children:[a,e("span",{className:"label",children:l})]},i))})})]})}function Hn({linkUrl:n,setLinkUrl:o,onConfirm:i,onCancel:l,removeLink:r}){const[s,u]=d(!1),h=a(null),p=a(null);return c(()=>{"https://"===n&&u(!0)},[n]),c(()=>{s&&p.current?.focus()},[s]),c(()=>{const e=e=>{h.current&&!h.current.contains(e.target)&&l()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[l]),t("div",{ref:h,className:"lexical-text-editor-link link-editor-container",children:[e("div",{className:"link-editor-input-wrapper",children:s?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),l())}}):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:()=>{s?(i(n),u(!1)):u(!0)},children:s?e(Bt,{size:18}):e(pt,{size:14})}),e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onMouseDown:e=>e.preventDefault(),onClick:r,children:e(Vt,{size:14,style:{stroke:"black"}})})]})]})}function Un({onClose:n}){const[o]=Ot(),[i,l]=d(""),[r,s]=d(""),[u,h]=d(!1),[p,m]=d([]),[g,f]=d(0),b=a(null);c(()=>{b.current?.focus()},[]);const y=()=>{if(!i)return[];const e=u?i:i.toLowerCase(),t=[],n=P().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};c(()=>{const e=o.getEditorState().read(y);m(e),f(0)},[o,i,u]),c(()=>o.registerUpdateListener(({editorState:e})=>{const t=e.read(y);m(t),f(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];f(t),o.update(()=>{const e=$(n.key);R(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:b,className:"lexical-fr-input",placeholder:"Find",value:i,onChange:e=>l(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:r,onChange:e=>s(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(Lt,{})}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>v(1),disabled:!w,"aria-label":"Next match",children:e(Tt,{})}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{o.update(()=>{const e=y();if(0===e.length)return m([]),void f(0);const t=e[Math.min(g,e.length-1)],n=$(t.key);R(n)&&n.spliceText(t.start,i.length,r,!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=$(n.key);R(o)&&o.spliceText(n.start,i.length,r,!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 Pn({anchorRef:t,onClose:n,children:o}){const i=a(null);return c(()=>{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 $n({onAction:n,alignmentSelectionMap:o}){const i=hn.find(e=>o[e.id]),[l,r]=d(!1),c=a(null),s=a(null);return t(Mn,{open:l,onOpenChange:r,children:[e(zn,{triggerRef:c,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(l?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),style:{minWidth:146},children:[i?.icon,e("span",{children:i?.label}),e(Pt,{className:"chevron "+(l?"rotated":"")})]})}),e(Rn,{open:l,align:"start",onClose:()=>r(!1),contentRef:s,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:hn.map(({id:i,label:l,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),r(!1)},children:[a,e("span",{className:"label",children:l})]},i))})})]})}function Kn({color:n,onChange:o,icon:i}){const[l,r]=d(!1),s=a(null),u=a(null);c(()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&s.current&&!s.current.contains(e.target)&&r(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);return t("div",{className:"color-picker-wrapper",children:[e("button",{type:"button",ref:s,className:`size-10 lexical-btn ${l?"toolbarActive":"toolbar"} icon`,onClick:()=>r(e=>!e),children:i}),l&&$t(e("div",{ref:u,className:"lexical-color-popover "+(l?"open":""),"data-lte-popover-portal":"true",style:{top:s.current?.getBoundingClientRect().bottom,left:s.current?.getBoundingClientRect().left,position:"absolute"},onMouseDown:e=>{e.preventDefault(),(e=>{e.preventDefault()})(e)},children:e(jt,{color:n,onChangeComplete:e=>{o(e.hex)}})}),document.body)]})}function Bn(){const[o]=Ot(),[{color:i,bgColor:l},r]=d({color:"#000",bgColor:"#fff"}),a=()=>{const e=A();if(z(e)){const t=Tn(e,"color","#000"),n=Tn(e,"background","#fff");r({color:t,bgColor:n})}};c(()=>Fn(o.registerUpdateListener(({editorState:e})=>{e.read(()=>{a()})}),o.registerCommand(K,()=>(a(),!1),1)),[o]);const s=({property:e,color:t})=>{o.update(()=>{const n=A();n&&xn(n,{[e]:t})})};return t(n,{children:[e(Kn,{color:i,onChange:e=>{s({property:"color",color:e})},icon:e(Nt,{})}),e(Kn,{color:l,onChange:e=>{s({property:"background",color:e})},icon:e(St,{})})]})}function Jn({icon:n,tooltipLabel:o,currentValue:i,options:l,onSelect:r,minWidth:c=132}){const s=l.find(e=>""!==e.id&&e.id===i),[u,h]=d(!1),p=a(null),m=a(null);return t(Mn,{open:u,onOpenChange:h,children:[e(zn,{triggerRef:p,children:t("button",{type:"button","aria-label":o,className:"lexical-btn heading-trigger font-trigger "+(u?"toolbar-active":"toolbar"),style:{minWidth:c},onClick:()=>h(e=>!e),children:[n,e("span",{children:s?.label??"Default"}),e(Pt,{className:"chevron "+(u?"rotated":"")})]})}),e(Rn,{open:u,align:"start",onClose:()=>h(!1),contentRef:m,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:l.map(t=>e("button",{type:"button",className:"lexical-btn "+(""===t.id&&""===i||""!==t.id&&t.id===i?"toolbar-active":"toolbar"),onClick:()=>{r(t.id),h(!1)},children:e("span",{className:"label",children:t.label})},t.label))})})]})}En&&"InputEvent"in window&&!An&&new window.InputEvent("input");const qn=[{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]=Ot(),[n,o]=d(""),i=()=>{const e=A();if(z(e)){const t=Tn(e,"font-family","");o((e=>e.replace(/['"]/g,"").trim())(t))}};c(()=>Fn(t.registerUpdateListener(({editorState:e})=>{e.read(()=>{i()})}),t.registerCommand(K,()=>(i(),!1),1)),[t]);return e(Jn,{icon:e(mt,{}),tooltipLabel:"Font Family",currentValue:n,options:qn,onSelect:e=>{t.update(()=>{const t=A();z(t)&&xn(t,{"font-family":""===e?null:e})})}})}const jn=({content:n,direction:o="top",delay:i=400,children:l})=>{const[r,c]=d(!1),[s,u]=d(null),h=a(null),p=a(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})}c(!0)},i)},g=()=>{h.current&&clearTimeout(h.current),c(!1)};if(!s)return e("div",{ref:p,className:"Lexical-Tooltip-Wrapper",onMouseEnter:m,onMouseLeave:g,children:l});const f=s.left+s.width/2,b=s.top+s.height/2,y="bottom"===o?{top:s.bottom+10,left:f,bottom:"auto"}:"top"===o?{bottom:window.innerHeight-s.top+10,top:"auto",left:f}:"right"===o?{left:s.right+10,right:"auto",top:b}:{left:"auto",right:window.innerWidth-s.left+10,top:b};return t("div",{ref:p,className:"Lexical-Tooltip-Wrapper",onMouseEnter:m,onMouseLeave:g,children:[l,r&&$t(e("div",{className:`Lexical-Tooltip-Tip ${o}`,style:{position:"fixed",pointerEvents:"none",...y,zIndex:1e4},children:n}),document.body)]})};function Qn(){const[n]=Ot(),[o,i]=d(""),[l,r]=d(null),s=a(null),u=()=>{const e=A();if(z(e)){let t=Xn(Tn(e,"font-size",""));if(!t)try{const o=n.getElementByKey(e.anchor.getNode().getKey());o&&(t=window.getComputedStyle(o).fontSize||"")}catch{}i(Xn(t)),document.activeElement!==s.current&&r(null)}};c(()=>Fn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{u()})}),n.registerCommand(K,()=>(u(),!1),1)),[n]);const h=e=>{const t=Math.min(90,Math.max(6,e));n.update(()=>{const e=A();z(e)&&xn(e,{"font-size":`${t}px`})})},p=e=>{const t=l??o,n=Number.parseInt(t,10),i=Number.isNaN(n)?16:n;h(i+e)},m=()=>{const e=l;if(r(null),null===e)return;const t=Number.parseInt(e,10);if(Number.isNaN(t))return;t!==Number.parseInt(o,10)&&h(t)},g=Number.parseInt(o,10),f=Number.isNaN(g)?null:g;return t("div",{className:"lexical-stepper","aria-label":"Font Size",role:"group",children:[e(jn,{content:"Decrease font size",direction:"bottom",children:e("button",{type:"button","aria-label":"Decrease Font Size",className:"lexical-stepper-btn",disabled:null!==f&&f<=6,onClick:()=>p(-1),children:e(Qt,{})})}),e("input",{ref:s,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:l??(null!==f?String(f):""),onChange:e=>r(e.target.value.replace(/[^\d]/g,"")),onFocus:e=>e.currentTarget.select(),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),m(),e.currentTarget.blur()):"Escape"===e.key?(e.preventDefault(),r(null),e.currentTarget.blur()):"ArrowUp"!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),m(),p("ArrowUp"===e.key?1:-1)),e.stopPropagation()},onBlur:m}),e(jn,{content:"Increase font size",direction:"bottom",children:e("button",{type:"button","aria-label":"Increase Font Size",className:"lexical-stepper-btn",disabled:null!==f&&f>=90,onClick:()=>p(1),children:e(Xt,{})})})]})}const Xn=e=>e.trim();function Yn(){const[n]=Ot(),o=r(gn),[i,l]=d(!1),[s,u]=d(null),[h,p]=d(!1),m=a(null),g=a(null),f=()=>{const e=A();if(z(e)){const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow(),o=v(n);l(o),o&&u(n.getLanguage()??null)}};c(()=>Fn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{f()})}),n.registerCommand(K,()=>(f(),!1),1)),[n]);const b=mn.find(e=>e.id===s)?.label??"Plain Text";return t(Mn,{open:h,onOpenChange:p,children:[e(zn,{triggerRef:m,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>p(e=>!e),children:[e(_t,{}),e("span",{children:b}),e(Pt,{className:"chevron "+(h?"rotated":"")})]})}),e(Rn,{open:h,align:"start",onClose:()=>p(!1),contentRef:g,children:t("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[t("button",{type:"button",className:"lexical-btn "+(i?"toolbar-active":"toolbar"),onClick:()=>{n.update(()=>{if(!z(A())){const e=P().getFirstChild();E(e)&&e.select(0,0)}const e=A();if(!z(e))return;const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow();if(v(n))Cn(e,()=>B());else{const t=s??"javascript";Cn(e,()=>x(t))}}),o(),p(!1)},style:{minWidth:150},children:[e(_t,{}),e("span",{className:"label",children:i?"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:i})=>e("button",{type:"button",className:"lexical-btn "+(s===t?"toolbar-active":"toolbar"),onClick:()=>{var e;u(e=t),n.update(()=>{if(!z(A())){const e=P().getFirstChild();E(e)&&e.select(0,0)}const t=A();if(!z(t))return;const n=t.anchor.getNode(),o="root"===n.getKey()?n:n.getTopLevelElementOrThrow();v(o)?o.setLanguage(e):Cn(t,()=>x(e))}),o(),p(!1)},style:{minWidth:150},children:e("span",{className:"label",children:i})},t))})]})})]})}function Gn({blockType:o}){const[i]=Ot();c(()=>Fn(i.registerCommand(J,e=>{const t=A();if(!z(t))return!1;return!!Dn(t.anchor.getNode(),Se)&&(e.preventDefault(),i.dispatchCommand(e.shiftKey?q:V,void 0),!0)},j)),[i]);return t(n,{children:[e(jn,{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(Ce,void 0):i.dispatchCommand(ke,void 0)},children:e(gt,{})})}),e(jn,{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(Ce,void 0):i.dispatchCommand(Ne,void 0)},children:e(ft,{})})})]})}function Zn(){const[n]=Ot(),[o,i]=d(!1),[l,r]=d(!1),[s,u]=d(null),h=a(null),p=a(null),m=()=>{const e=A();if(z(e)){const t=De(e.anchor.getNode());i(!!t)}else i(!1)};c(()=>Fn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{m()})}),n.registerCommand(K,()=>(m(),!1),1)),[n]);const g=e=>{n.update(()=>{const t=A();z(t)&&e()}),r(!1)},f=s?`${s.rows} × ${s.cols}`:"Insert Table";return t(Mn,{open:l,onOpenChange:r,children:[e(zn,{triggerRef:h,children:t("button",{type:"button","aria-label":"Insert Table",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),children:[e(bt,{}),e(Pt,{className:"chevron "+(l?"rotated":"")})]})}),e(Rn,{open:l,align:"start",onClose:()=>r(!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,a=s&&i<=s.rows&&l<=s.cols;return e("div",{onMouseEnter:()=>u({rows:i,cols:l}),onClick:()=>{return e=i,t=l,n.update(()=>{if(!z(A())){const e=P().getFirstChild();E(e)&&e.select(0,0)}}),n.dispatchCommand(Me,{rows:String(e),columns:String(t),includeHeaders:!1}),void r(!1);var e,t},style:{width:18,height:18,borderRadius:3,border:"1px solid #d1d5db",backgroundColor:a?"#c7d2fe":"#fff",cursor:"pointer"}},o)})}),e("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:f})]}),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(()=>{We(!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(()=>{We(!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(()=>{Oe()}),style:{minWidth:160},children:e("span",{className:"label",children:"Delete row"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Ie(!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(()=>{Ie(!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(()=>{He()}),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=A();if(!z(e))return;const t=De(e.anchor.getNode());if(!t)return;const n=t.getParent();if(!n)return;const o=n.getChildren().filter(ze),i=o.some(e=>e.hasHeaderState(Re.ROW));for(const e of o)e.setHeaderStyles(i?Re.NO_STATUS:Re.ROW,Re.ROW)})},style:{minWidth:160},children:e("span",{className:"label",children:"Toggle header row"})})]})]})})]})}const eo=({src:n,altText:o,nodeKey:i,width:l,height:r,maxWidth:c,caption:s=""})=>{const[u]=Ot(),[h,p]=d(!1),[m,g]=d(s),f=a(null),b=a(null),y=a(null),v=a(null),x=e=>{if(!v.current||!b.current)return;const t=e.clientX-v.current.x,n=Math.min(c,Math.max(50,v.current.width+t)),o=n*b.current.ratio;b.current.width=n,b.current.height=o;const i=y.current?.querySelector("img");i&&(i.style.width=n+"px",i.style.height=o+"px")},w=()=>{if(!b.current)return;const{width:e,height:t}=b.current;u.update(()=>{const n=$(i);n&&"function"==typeof n.updateDimensions&&n.updateDimensions(e,t)}),b.current=null,v.current=null,window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",w)},C=()=>{p(!1),u.update(()=>{const e=$(i);e&&"function"==typeof e.setCaption&&e.setCaption(m)})},k=()=>{g(s),p(!0),setTimeout(()=>f.current?.focus(),0)};return t("div",{ref:y,style:{display:"inline-block",position:"relative",maxWidth:c},children:[e("img",{src:n,alt:o,width:"inherit"===l?void 0:l,height:"inherit"===r?void 0:r,style:{maxWidth:"100%",display:"block"}}),(s||h)&&e("div",{style:{textAlign:"center",marginTop:4},children:h?e("input",{ref:f,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:s})}),!s&&!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},b.current={width:n,height:i,ratio:o},window.addEventListener("mousemove",x),window.addEventListener("mouseup",w)},style:{position:"absolute",bottom:s||h?40:0,right:0,width:14,height:14,background:"white",border:"1px solid #999",cursor:"nwse-resize",borderRadius:2}})]})},to=e=>X(new oo(e)),no=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:to({src:t,altText:n,width:o??"inherit",height:i??"inherit"})}};class oo extends Q{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 oo({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:no,priority:1}),figure:()=>({conversion:e=>{const t=e.querySelector("img");if(!t)return null;const n=e.querySelector("figcaption"),o=n?.textContent||"",i=no(t);return i?.node instanceof oo&&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 oo({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(eo,{src:this.__src,altText:this.__altText,nodeKey:this.getKey(),width:this.__width,height:this.__height,maxWidth:this.__maxWidth,caption:this.__caption})}}function io({open:n,onClose:o,forPreview:i=!1,children:l}){const r=a(null);return c(()=>{if(!n)return;const e=e=>{r.current&&!r.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:r,className:"lte-dialog "+(i?"preview":""),children:[e("button",{type:"button",className:"lte-dialog-close",onClick:o,children:"×"}),l]})}):null}async function lo(e,{src:t,altText:n="",caption:o=""}){e.update(()=>{const e=to({src:t,altText:n,caption:o});Z([e])})}function ro({onImageUpload:n}){const[o]=Ot(),i=a(null),[l,r]=d(!1),[s,h]=d(""),[p,m]=d(""),[g,f]=d(""),[b,y]=d(),[v,x]=d(!1),w=u(async(e,t="",i="")=>{let l;l=n?await n(e):URL.createObjectURL(e),lo(o,{src:l,altText:t,caption:i})},[o,n]);return c(()=>{const e=o.registerCommand(Y,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},G);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(jn,{content:"Add Image",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${l?"toolbarActive":"toolbar"} icon`,onClick:()=>r(e=>!e),children:e(At,{size:18})})}),t(io,{open:l,onClose:()=>r(!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=>f(e.target.value)}),e("input",{className:"lte-input",placeholder:"Add image by URL",value:s,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(Yt,{size:20}),e("span",{children:"Upload Image"})]}),b&&e("div",{className:"lte-file-name",children:b.name})]}),e("div",{className:"lte-dialog-footer",children:e("button",{type:"button",className:"lte-primary-btn",disabled:!s&&!b||v,onClick:async()=>{if(!v){if(b){x(!0);try{await w(b,p,g)}catch(e){return console.error("Image upload failed:",e),void x(!1)}x(!1)}else{if(!s)return;lo(o,{src:s,altText:p,caption:g})}y(void 0),m(""),f(""),h(""),r(!1)}},children:v?"Uploading...":"Add Image"})})]})]})}const ao=({id:e,provider:t})=>new go({id:e,provider:t}),co="data-lexical-video",so="data-provider",uo="315px",ho="560px",po=(e,t)=>"drive"===t?`https://drive.google.com/file/d/${e}/preview`:`https://www.youtube-nocookie.com/embed/${e}`,mo=e=>{const t=e?.getAttribute(co),n=e?.getAttribute(so)??"youtube";if(!t)return null;return{node:ao({id:t,provider:n})}};class go 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 go({id:e.__id,provider:e.__provider,key:e.getKey()})}static importJSON(e){return ao({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:uo,width:ho,src:po(this.__id,this.__provider),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(co,this.__id),e.setAttribute(so,this.__provider),e.setAttribute("height",uo),e.setAttribute("width",ho),e.setAttribute("src",po(this.__id,this.__provider)),{element:e}}static importDOM(){return{iframe:()=>({conversion:mo,priority:0})}}}function fo(){const[n,o]=d(!1),[i,l]=d(!1),[r,a]=d(""),[s]=Ot();return c(()=>{n||(a(""),l(!1))},[n]),t("div",{className:"lexical-text-editor-dialog",children:[e(jn,{content:"Embed Video",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${n?"toolbarActive":"toolbar"} icon`,onClick:()=>o(!0),children:e(Gt,{size:18,color:"red"})})}),t(io,{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:r,onChange:e=>a(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:!r,onClick:()=>{if(!r)return;let e=null,t=null;const n=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(r);n&&11===n[2]?.length&&(e="youtube",t=n[2]);const i=/drive\.google\.com\/file\/d\/([a-zA-Z0-9_-]+)\//.exec(r);i&&i[1]&&(e="drive",t=i[1]),t&&e?(s.update(()=>{const n=ao({id:t,provider:e});Z([n])}),a(""),l(!1),o(!1)):l(!0)},children:"Embed"})})]})]})}function bo({value:t}){return e("div",{className:"lexical-text-editor-html-preview",dangerouslySetInnerHTML:{__html:t}})}function yo({value:n,triggerLabel:o="Preview"}){const[i,l]=d(!1);return t("div",{className:"lexical-text-editor-dialog",children:[e(jn,{content:o,direction:"bottom",children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),children:[e(Zt,{size:18}),e("span",{children:o})]})}),t(io,{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(bo,{value:n})]})]})]})}const vo=[{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"}],xo=vo.map(e=>e.id),wo=({value:o,onImageUpload:i,sourceView:l=!1,onToggleSourceView:r,fullscreen:s=!1,onToggleFullscreen:h,toolbarStyle:b="wrap"})=>{const y="normal"===b?"collapse":b,[v]=Ot(),[x,w]=d({[nn.Undo]:!0,[nn.Redo]:!0}),[C,k]=d(!1),[N,S]=d(!1),[_,L]=d(0),[T,F]=d(!1),D=u(()=>F(!1),[]),M=a(null),W=a(null),O=a(null),I=a({}),H=a({}),U=a(0),P=a(null),$=a(null),[J,j]=d({[nn.LeftAlign]:!0}),[Q,X]=d({[on.Normal]:!0}),[Y,G]=d("paragraph"),[Z,re]=d("https://");let ae=!0;const ce=()=>{if(ae){const e=v.getRootElement();e&&(e.scrollTop=0,ae=!1)}const e=A();if(z(e)){const t={[nn.Bold]:e.hasFormat("bold"),[nn.Italics]:e.hasFormat("italic"),[nn.Underline]:e.hasFormat("underline"),[nn.Uppercase]:e.hasFormat("uppercase"),[nn.Lowercase]:e.hasFormat("lowercase"),[nn.Capitalize]:e.hasFormat("capitalize"),[nn.Strikethrough]:e.hasFormat("strikethrough"),[nn.Superscript]:e.hasFormat("superscript"),[nn.Subscript]:e.hasFormat("subscript"),[nn.Code]:e.hasFormat("code"),[nn.Highlight]:e.hasFormat("highlight")};j(t);const n=e.anchor.getNode(),o="root"===n.getKey()?n:n.getTopLevelElementOrThrow(),i=o.getKey();if(!v.getElementByKey(i))return;if(_e(o)){const e=Dn(n,Se),t=e?e.getTag():o.getTag();G(t)}else if("paragraph"===o.getType()||p(o)){let e=null;p(o)&&(e=o.getTag());const t={[on.H1]:"h1"===e,[on.H2]:"h2"===e,[on.H3]:"h3"===e,[on.H4]:"h4"===e,[on.H5]:"h5"===e,[on.H6]:"h6"===e,[on.Normal]:"paragraph"===o.getType()};G(o.getType()),X(t)}else G(o.getType());const l=(E(n)?n:o).getFormat();j(e=>({...e,[nn.LeftAlign]:0===l||1===l,[nn.CenterAlign]:2===l,[nn.RightAlign]:3===l,[nn.JustifyAlign]:4===l})),"quote"===o.getType()?j(e=>({...e,[nn.Quote]:!0})):j(e=>({...e,[nn.Quote]:!1}));const r=e.anchor.getNode(),a=r.getParent();Ht(a)?(j(e=>({...e,[nn.Link]:!0})),re(a.getURL()),k(!0)):Ht(r)?(j(e=>({...e,[nn.Link]:!0})),re(r.getURL()),k(!0)):(j(e=>({...e,[nn.Link]:!1})),re("https://"),k(!1))}};c(()=>Fn(v.registerUpdateListener(({editorState:e})=>{e.read(()=>{ce()})}),v.registerCommand(K,()=>(ce(),!1),1),v.registerCommand(te,e=>(w(t=>({...t,undo:!e})),!1),1),v.registerCommand(ee,e=>(w(t=>({...t,redo:!e})),!1),1)),[]);const se="scrollbar"===y,de=u(()=>{if("collapse"!==y)return;const e=M.current;if(!e)return;const t=e.clientWidth;if(t<=0)return;const n=W.current?W.current.offsetWidth:0,o=xo.map(e=>{const t=I.current[e];return t&&"none"!==t.style.display&&(H.current[e]=t.offsetWidth),H.current[e]??0});O.current&&(U.current=O.current.offsetWidth);const i=U.current||40,l=e=>{const t=1+(e>0?1:0)+(xo.length-e);let l=n+6*Math.max(0,t-1)+(e>0?i:0);for(let t=0;t<xo.length-e;t++)l+=o[t];return l};let r=_;for(;r<xo.length&&l(r)>t;)r++;for(;r>0&&l(r-1)<=t;)r--;L(e=>e===r?e:r)},[_,y]);c(()=>{de()});const ue=a(()=>{});ue.current=de,c(()=>{if("undefined"==typeof ResizeObserver)return;const e=M.current;if(!e)return;const t=new ResizeObserver(()=>{ue.current(),be.current()});return t.observe(e),()=>t.disconnect()},[]),c(()=>{0===_&&F(!1)},[_]),c(()=>{"collapse"!==y&&L(0)},[y]);const he=u(()=>{if("scrollbar"!==y)return;const e=M.current,t=P.current,n=$.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)`},[b]),pe=u(e=>{e.stopPropagation(),e.preventDefault();const t=M.current,n=$.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)},[]),me=u(e=>{const t=M.current,n=P.current;if(!t||!n)return;const o=n.getBoundingClientRect(),i=(e.clientX-o.left)/o.width;t.scrollLeft=i*t.scrollWidth-t.clientWidth/2},[]),ge=a(null),fe=u(()=>{const e=ge.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{}}},[]);c(()=>{fe()}),c(()=>{he()});const be=a(()=>{});be.current=he,c(()=>{if("scrollbar"!==y)return;const e=M.current;if(!e)return;const t=()=>he();return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[y,he]);const ye=e=>{switch(e){case nn.Bold:v.dispatchCommand(le,"bold");break;case nn.Italics:v.dispatchCommand(le,"italic");break;case nn.Underline:v.dispatchCommand(le,"underline");break;case nn.Lowercase:v.dispatchCommand(le,"lowercase");break;case nn.Uppercase:v.dispatchCommand(le,"uppercase");break;case nn.Capitalize:v.dispatchCommand(le,"capitalize");break;case nn.Strikethrough:v.dispatchCommand(le,"strikethrough");break;case nn.Superscript:v.dispatchCommand(le,"superscript");break;case nn.Subscript:v.dispatchCommand(le,"subscript");break;case nn.Highlight:v.dispatchCommand(le,"highlight");break;case nn.Code:v.dispatchCommand(le,"code");break;case nn.Quote:v.update(()=>{const e=A();if(z(e)){const t=e.anchor.getNode().getParent();t&&m(t)?Cn(e,()=>B()):Sn(e,()=>g())}});break;case nn.Link:ve(),k(!0);break;case nn.LeftAlign:v.dispatchCommand(ie,"left");break;case nn.RightAlign:v.dispatchCommand(ie,"right");break;case nn.CenterAlign:v.dispatchCommand(ie,"center");break;case nn.JustifyAlign:v.dispatchCommand(ie,"justify");break;case nn.Undo:v.dispatchCommand(oe,void 0);break;case nn.Redo:v.dispatchCommand(ne,void 0);break;case nn.ClearFormatting:v.update(()=>{const e=A();if(!z(e))return;const t=e.getNodes().filter(R);for(const e of t)e.setFormat(0),e.setStyle("")});break;case nn.HorizontalRule:v.dispatchCommand(Te,void 0);break;case nn.Indent:v.dispatchCommand(V,void 0);break;case nn.Outdent:v.dispatchCommand(q,void 0)}},ve=u(()=>{v.update(()=>{const e=A();z(e)&&!e.isCollapsed()&&(C?v.dispatchCommand(It,null):""!==Z&&v.dispatchCommand(It,Z))})},[v,C,Z]),xe=u(()=>{re(""),v.dispatchCommand(It,null),k(!1)},[v]),we=e=>xo.indexOf(e)>=xo.length-_,Ce={headings:e(In,{updateHeading:e=>{v.update(()=>{const t=A();z(t)&&Sn(t,"normal"===e?()=>B():()=>f(e))})},headingSelectionMap:Q}),fontFamily:e(Vn,{}),fontSize:e(Qn,{}),textFormats:e(n,{children:rn.map(({id:t,label:n,icon:o})=>t===nn.Divider?e(On,{},t):e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:o})},t))}),dropdown:e(Wn,{onAction:ye,selectionMap:J}),color:t(n,{children:[e(Bn,{}),an.map(({id:t,label:n,icon:o})=>e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:o})},t))]}),quoteCode:e(n,{children:cn.map(({id:t,label:n,icon:o})=>e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:o})},t))}),codeBlock:e(Yn,{}),alignment:e($n,{onAction:ye,alignmentSelectionMap:J}),lists:e(Gn,{blockType:Y}),blockOptions:e(n,{children:dn.map(({id:t,label:n,icon:o})=>t===nn.Divider?e(On,{},t):e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:o})},t))}),table:e(Zn,{}),hline:e(n,{children:un.map(({id:t,label:n,icon:o})=>e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:o})},t))}),link:e(jn,{content:"Link",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[nn.Link]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(nn.Link),disabled:!!x[nn.Link],children:e(Kt,{})})}),image:e(ro,{onImageUpload:i}),video:e(fo,{}),utility:t(n,{children:[e(jn,{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(Ft,{})})}),e(jn,{content:"Source Code View",direction:"bottom",children:e("button",{type:"button","aria-label":"Source Code View",className:`size-10 lexical-btn ${l?"toolbarActive":"toolbar"} icon`,onClick:()=>r?.(),children:e(Dt,{})})}),e(jn,{content:s?"Exit Fullscreen":"Fullscreen",direction:"bottom",children:e("button",{type:"button","aria-label":s?"Exit Fullscreen":"Fullscreen",className:`size-10 lexical-btn ${s?"toolbarActive":"toolbar"} icon`,onClick:()=>h?.(),children:e(s?yt:vt,{})})})]}),preview:e(yo,{value:o})};return e(gn.Provider,{value:D,children:t("div",{ref:ge,className:"lexical-toolbar-wrapper",style:{position:"relative",padding:12,marginBottom:4,borderBottom:"1px solid #e5e7eb"},children:[t("div",{ref:M,className:"lte-toolbar-row "+(se?"useScroll":"collapse"===y?"lte-nowrap":"lte-wrap"),onMouseDown:e=>{"INPUT"!==e.target.tagName&&e.preventDefault()},children:[e("div",{ref:W,className:"lte-toolbar-primary",style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:sn.map(({id:t,label:n,icon:o})=>t===nn.Divider?e(On,{},t):e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),disabled:!!x[t],children:o})},n))}),vo.map(({id:n,sep:o})=>{const i=we(n);return t("div",{ref:e=>{I.current[n]=e},style:i?{display:"none"}:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[o?e(On,{}):null,i?null:Ce[n]]},n)}),_>0&&e(jn,{content:"More tools",direction:"bottom",children:e("button",{type:"button",ref:O,"aria-label":"More tools",className:`size-10 lexical-btn ${T?"toolbarActive":"toolbar"} icon`,onClick:()=>F(e=>!e),children:e(xt,{})})})]}),se&&e("div",{ref:P,className:"lte-custom-scrollbar",onPointerDown:me,"aria-hidden":"true",children:e("div",{ref:$,className:"lte-custom-scrollbar-thumb",onPointerDown:pe})}),C&&e(Hn,{linkUrl:Z,setLinkUrl:re,removeLink:xe,onConfirm:e=>{v.dispatchCommand(It,{url:e,target:"_blank"}),re(e),k(!1)},onCancel:()=>{re(""),k(!1)}}),T&&e(Pn,{anchorRef:O,onClose:()=>F(!1),children:vo.filter(({id:e})=>we(e)&&Ce[e]).map(({id:n,sep:o},i)=>t("div",{className:"lte-overflow-item",children:[o&&i>0?e(On,{}):null,Ce[n]]},n))}),N&&e(Un,{onClose:()=>S(!1)})]})})};function Co(){const[e]=Ot();return c(()=>{let t=!1;return Fn(e.registerCommand(ce,()=>{const e=A();if(!z(e))return!1;const n=e.anchor.getNode();return R(n)&&n.hasFormat("code")&&e.anchor.offset===n.getTextContentSize()&&(t=!0),!1},ae),e.registerCommand(re,t=>{if(t.ctrlKey||t.metaKey||t.altKey)return!1;const n=t.key;if(1!==n.length)return!1;const o=A();if(!z(o)||!o.isCollapsed())return!1;const i=o.anchor.getNode();if(!R(i)||i.hasFormat("code"))return!1;if(0!==o.anchor.offset)return!1;const l=i.getPreviousSibling();if(!R(l)||!l.hasFormat("code"))return!1;t.preventDefault();const r=l.getKey();return e.update(()=>{const e=$(r);if(!R(e)||!e.hasFormat("code"))return;e.setTextContent(e.getTextContent()+n);const t=e.getTextContentSize();e.select(t,t)}),!0},ae),e.registerUpdateListener(({editorState:n})=>{t&&(t=!1,n.read(()=>{const t=A();z(t)&&e.update(()=>{const e=A();if(!z(e))return;const t=e.anchor.getNode(),n=e=>R(e)&&0===e.getTextContentSize()&&e.hasFormat("code");if(R(t))if(n(t))t.setFormat(0);else{let e=t.getPreviousSibling();for(;e&&R(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)&&R(e)&&e.setFormat(0)}R(t)&&t.hasFormat("code")||e.hasFormat("code")&&e.setFormat(0)})}))}))},[e]),null}function ko(e,t){const n=se(t)?t.body.childNodes:t.childNodes;let o=[];const i=[];for(const t of n)if(!_o.has(t.nodeName)){const n=Lo(t,e,i,!1);null!==n&&(o=o.concat(n))}return function(e){for(const t of e)t.getNextSibling()instanceof de&&t.insertAfter(ue());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(i),o}function No(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=P().getChildren();for(let i=0;i<o.length;i++)So(e,o[i],n,t);return n.innerHTML}function So(e,t,n,o=null){let i=null===o||t.isSelected(o);const l=E(t)&&t.excludeFromCopy("html");let r=t;if(null!==o){let e=he(t);e=R(e)&&null!==o?function(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!W(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]=O(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=E(r)?r.getChildren():[],c=pe(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=So(e,l,h,o);!i&&E(t)&&r&&t.extractWithChild(l,o,"html")&&(i=!0)}if(i&&!l){if((me(d)||ge(d))&&d.append(h),n.append(d),u){const e=u.call(r,d);e&&(ge(d)?d.replaceChildren(e):d.replaceWith(e))}}else n.append(h);return i}const _o=new Set(["STYLE","SCRIPT"]);function Lo(e,t,n,o,i=new Map,l){let r=[];if(_o.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||!D(a))&&(null!=a&&fe(a)||o);for(let e=0;e<u.length;e++)h.push(...Lo(u[e],t,n,p,new Map(i),a));return null!=d&&(h=d(h)),be(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(fe(r))o&&!r.getFormat()&&r.setFormat(o),i.push(r);else if(l.push(r),e===t.length-1||e<t.length-1&&fe(t[e+1])){const e=n();e.setFormat(o),e.append(...l),i.push(e),l=[]}}return i}(e,h,p?()=>{const e=new de;return n.push(e),e}:B)),null==a?h.length>0?r=r.concat(h):be(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&(ye(e.nextSibling)&&ye(e.previousSibling))}(e)&&(r=r.concat(ue())):E(a)&&a.append(...h),r}function To({value:t,onChange:n}){const[o]=Ot(),[i,l]=d(!0);return c(()=>{t&&i&&(l(!1),o.update(()=>{if(No(o)!==t){P().clear();const e=(new DOMParser).parseFromString(t,"text/html"),n=ko(o,e);Z(n)}}))},[o,t,i]),c(()=>{l(!0)},[t]),e(tn,{onChange:e=>{e.read(()=>{n(No(o))})}})}function Eo({applyRef:n,onExit:o}){const[i]=Ot(),[l,r]=d(()=>i.getEditorState().read(()=>No(i))),s=a(l),u=e=>{e!==s.current&&(i.update(()=>{const t=P();if(t.clear(),t.selectEnd(),e){const t=(new DOMParser).parseFromString(e,"text/html"),n=ko(i,t);n.length>0&&Z(n)}}),s.current=e)};return c(()=>(n.current=()=>{u(l),o()},()=>{n.current=null}),[n,l,o,i]),t("div",{className:"lexical-source-view",children:[e("textarea",{className:"lexical-source-textarea",value:l,onChange:e=>r(e.target.value),"aria-label":"HTML source",spellCheck:!1}),t("div",{className:"lexical-source-actions",children:[e(jn,{content:"Apply HTML to the editor",direction:"top",children:t("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>u(l),children:[e(Bt,{size:16}),e("span",{className:"label",children:"Update"})]})}),e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{u(l),o()},children:"Done"})]})]})}function Ao({showWordCount:n=!0,showCharCount:o=!0,rightSlot:i}){const[l]=Ot(),[r,a]=d({words:0,chars:0});return c(()=>{const e=e=>{e.read(()=>{const e=P().getTextContent(),t=e.trim();a({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:[r.words," words"]}),o&&t("span",{children:[r.chars," characters"]}),i&&e("div",{className:"lexical-status-bar-right",children:i})]})}function Fo({theme:n,toolbarStyle:o,onThemeChange:i,onToolbarStyleChange:l}){const r="normal"===o?"collapse":o,a=[{value:"light",label:"Light theme",icon:e(wt,{})},{value:"dark",label:"Dark theme",icon:e(Ct,{})},{value:"system",label:"Follow system theme",icon:e(Jt,{})}],c=[{value:"wrap",label:"Toolbar: wrap to new lines",icon:e(qt,{})},{value:"collapse",label:'Toolbar: collapse into "..."',icon:e(xt,{})},{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(jn,{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(jn,{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 Do=({id:e})=>new Io({id:e}),Mo="data-lexical-youtube",zo="315px",Ro="560px",Wo=e=>`https://www.youtube-nocookie.com/embed/${e}`,Oo=e=>{const t=e?.getAttribute(Mo);if(!t)return null;return{node:Do({id:t})}};class Io extends Q{constructor({id:e,key:t}){super(t),this.__id=e}static getType(){return"youtube"}static clone(e){return new Io({id:e.__id,key:e.getKey()})}static importJSON(e){return Do({id:e.id})}exportJSON(){return{id:this.__id,type:"youtube",version:1}}decorate(){return e("iframe",{height:zo,width:Ro,src:Wo(this.__id),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(Mo,this.__id),e.setAttribute("height",zo),e.setAttribute("width",Ro),e.setAttribute("src",Wo(this.__id)),{element:e}}static importDOM(){return{iframe:()=>({conversion:Oo,priority:0})}}}class Ho extends ve{constructor(e,t){super(e,t)}static getType(){return"extended-text"}static clone(e){return new Ho(e.__text,e.__key)}static importDOM(){const e=ve.importDOM();return{...e,span:()=>({conversion:Uo(e?.span),priority:1}),div:()=>({conversion:Uo(e?.div),priority:1}),p:()=>({conversion:Uo(e?.p),priority:1}),b:()=>({conversion:Uo(e?.b),priority:1}),strong:()=>({conversion:Uo(e?.strong),priority:1}),i:()=>({conversion:Uo(e?.i),priority:1}),em:()=>({conversion:Uo(e?.em),priority:1}),u:()=>({conversion:Uo(e?.u),priority:1}),s:()=>({conversion:Uo(e?.s),priority:1}),strike:()=>({conversion:Uo(e?.strike),priority:1}),code:()=>({conversion:Uo(e?.code),priority:1})}}static importJSON(e){return function(e=""){return X(new Ho(e))}().updateFromJSON(e)}isSimpleText(){return"extended-text"===this.__type&&0===this.__mode}}function Uo(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(R(i)&&l.length>0){const e=l.join("; ");return i.setStyle(e)}return i}}}}const Po={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"}},$o=i.memo(function({name:n,value:i,onChange:l,placeholder:r,maxWidth:s=null,height:u=null,onImageUpload:p,showWordCount:m=!0,showCharCount:g=!0,theme:f="system",toolbarStyle:v="collapse",showDisplayControls:x=!0,onThemeChange:_,onToolbarStyleChange:L}){const[T,E]=d(!1),[A,F]=d(!1),D=a(null),[M,z]=d(!1),[R,W]=d(f),[O,I]=d("normal"===v?"collapse":v);c(()=>{W(f)},[f]),c(()=>{I("normal"===v?"collapse":v)},[v]),c(()=>{if("system"!==R||"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))},[R]);const H="dark"===R||"system"===R&&M;c(()=>{if(!A)return;const e=e=>{"Escape"===e.key&&F(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[A]);const U=h(()=>({namespace:n,theme:Po,onError:e=>{console.error("Lexical error:",e)},nodes:[Ho,{replace:ve,with:e=>new Ho(e.__text),withKlass:Ho},b,w,C,Se,Le,y,Ut,oo,Io,go,Ee,Ue,Pe,$e]}),[n]);return e("div",{className:`lexical-text-editor lexical-editor-container ${A?"lexical-fullscreen":""} ${H?"lexical-dark":""}`,style:{maxWidth:A?"none":s||"1090px"},children:t(o,{initialConfig:U,children:[e("div",{className:"lexical-toolbar-container",children:e(wo,{value:i,onImageUpload:p,sourceView:T,onToggleSourceView:()=>{E(e=>!e||(D.current?.(),!1))},fullscreen:A,onToggleFullscreen:()=>{F(e=>!e)},toolbarStyle:O})}),e("div",{className:"lexical-editor-inner",style:T?{display:"none"}:void 0,children:e(k,{contentEditable:e(N,{className:"lexical-content-editable",style:{height:u||"500px"}}),placeholder:e("div",{className:"lexical-placeholder",children:r||"Some Text"}),ErrorBoundary:S})}),T&&e(Eo,{applyRef:D,onExit:()=>E(!1)}),(m||g||x)&&e(Ao,{showWordCount:m,showCharCount:g,rightSlot:x?e(Fo,{theme:R,toolbarStyle:O,onThemeChange:e=>{W(e),_?.(e)},onToolbarStyleChange:e=>{I(e),L?.(e)}}):void 0}),e(xe,{}),e(we,{}),e(Fe,{}),e(Ae,{}),e(en,{}),e(Co,{}),e(To,{value:i,onChange:l})]})})});export{$o 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