@payloadcms/richtext-lexical 3.0.0-beta.111 → 3.0.0-beta.113

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.
@@ -31,7 +31,7 @@ ${e.map(ms).join(`
31
31
  `)}
32
32
  });
33
33
  });
34
- `},[t,e]),f=ue((_,E)=>{o(T=>{let I=e.length-1,S=e[I];if(S&&S.name===_){if(_==="type")return[...e.slice(0,I),{...S,value:S.value+E}];if(S.value===E)return[...e.slice(0,I),{...S,count:S.count+1}]}return[...T,{name:_,count:1,value:E}]})},[e,o]);ar(()=>{let _=T=>{if(!n)return;let I=T.key;fs(T)?f("selectAll",""):ur.has(I)?f("press",T.key):[...I].length>1?f("keydown",T.key):f("type",T.key)},E=T=>{if(!n)return;let I=T.key;!ur.has(I)&&[...I].length>1&&f("keyup",T.key)};return t.registerRootListener((T,I)=>{I!==null&&(I.removeEventListener("keydown",_),I.removeEventListener("keyup",E)),T!==null&&(T.addEventListener("keydown",_),T.addEventListener("keyup",E))})},[t,n,f]),ar(()=>{u.current&&u.current.scrollTo(0,u.current.scrollHeight)},[m]),Kt(()=>{if(e){let _=m();_!==null&&s(_),u.current&&u.current.scrollTo(0,u.current.scrollHeight)}},[m,e]),Kt(()=>t.registerUpdateListener(({dirtyElements:E,dirtyLeaves:T,editorState:I})=>{if(!n)return;let S=I._selection,x=a.current,N=c.current;if(x!==S){if(T.size===0&&E.size===0&&!N){let g=window.getSelection();if(g&&(g.anchorNode==null||g.focusNode==null))return}a.current=S}c.current=!1;let L=m();L!==null&&s(L)}),[t,m,n,f]),Kt(()=>n?t.registerUpdateListener(()=>{let E=t.getRootElement();E!==null&&i(E?.innerHTML)}):void 0,[t,n]);let p=ue(_=>{n||(_.update(()=>{let E=cs();E.clear();let T=as();E.append(ss().append(T)),T.select()}),o([])),r(E=>!E)},[n]),h=ue(()=>{if(!n)return;let _=window.getSelection();if(_===null||_.anchorNode==null||_.focusNode==null)return;let{anchorNode:E,anchorOffset:T,focusNode:I,focusOffset:S}=ps(_),x=d().getRootElement(),N;E!==null&&(N=cr(E,x));let L;I!==null&&(L=cr(I,x)),f("snapshot",{anchorNode:E,anchorOffset:T,anchorPath:N,focusNode:I,focusOffset:S,focusPath:L})},[f,n,d]),b=ue(()=>{us(m())},[m]),C=ue(()=>{ds("test.js",m())},[m]);return[de("button",{className:`editor-dev-button ${n?"active":""}`,id:"test-recorder-button",onClick:_=>{p(d()),_.preventDefault()},title:n?"Disable test recorder":"Enable test recorder",type:"button",children:n?"Disable test recorder":"Enable test recorder"}),n?Yt("div",{className:"test-recorder-output",children:[Yt("div",{className:"test-recorder-toolbar",children:[de("button",{className:"test-recorder-button",id:"test-recorder-button-snapshot",onClick:_=>{h(),_.preventDefault()},title:"Insert snapshot",type:"button",children:"Insert Snapshot"}),de("button",{className:"test-recorder-button",id:"test-recorder-button-copy",onClick:_=>{b(),_.preventDefault()},title:"Copy to clipboard",type:"button",children:"Copy"}),de("button",{className:"test-recorder-button",id:"test-recorder-button-download",onClick:_=>{C(),_.preventDefault()},title:"Download as a file",type:"button",children:"Download"})]}),de("pre",{id:"test-recorder",ref:u,children:l})]}):null]}var mr=()=>{let[t]=ls(),[e,o]=hs(t);return Yt(dr.Fragment,{children:[de("p",{children:"HI"}),e,o,de("p",{children:"DONE"})]})};var gs=y({plugins:[{Component:mr,position:"bottom"}]});import{c as Cs}from"react/compiler-runtime";import{jsx as xs}from"react/jsx-runtime";import{useLexicalComposerContext as bs}from"@lexical/react/LexicalComposerContext.js";import{TreeView as _s}from"@lexical/react/LexicalTreeView.js";import"react";var fr=()=>{let t=Cs(2),[e]=bs(),o;return t[0]!==e?(o=xs(_s,{editor:e,timeTravelButtonClassName:"debug-timetravel-button",timeTravelPanelButtonClassName:"debug-timetravel-panel-button",timeTravelPanelClassName:"debug-timetravel-panel",timeTravelPanelSliderClassName:"debug-timetravel-panel-slider",treeTypeButtonClassName:"debug-treetype-button",viewClassName:"tree-view-output"}),t[0]=e,t[1]=o):o=t[1],o};var Ts=y({plugins:[{Component:fr,position:"bottom"}]});import{$isRangeSelection as Es,FORMAT_TEXT_COMMAND as ws}from"lexical";import{jsx as pr}from"react/jsx-runtime";import"react";var hr=()=>pr("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:pr("path",{d:"M10.6772 15H6.27017V5.718H10.4172C12.6792 5.718 13.8492 6.602 13.8492 8.292C13.8492 9.098 13.1992 9.982 12.4712 10.216C13.3812 10.476 14.1742 11.256 14.1742 12.322C14.1742 14.09 12.9002 15 10.6772 15ZM8.46717 9.501H10.3262C11.3012 9.501 11.7042 9.046 11.7042 8.409C11.7042 7.72 11.2362 7.317 10.3392 7.317H8.46717V9.501ZM8.46717 11.061V13.401H10.4822C11.4702 13.401 11.9642 12.959 11.9642 12.218C11.9642 11.49 11.4702 11.061 10.4822 11.061H8.46717Z",fill:"currentColor"})});var U=t=>({type:"buttons",items:t,key:"format",order:40});var gr={type:"text-format",format:["bold","italic"],tag:"***"},Cr={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},xr={type:"text-format",format:["bold"],tag:"**"},br={type:"text-format",format:["bold"],intraword:!1,tag:"__"};var _r=[U([{ChildComponent:hr,isActive:({selection:t})=>Es(t)?t.hasFormat("bold"):!1,key:"bold",onSelect:({editor:t})=>{t.dispatchCommand(ws,"bold")},order:1}])],Ns=y(({featureProviderMap:t})=>{let e=[xr,br];return t.get("italic")&&e.push(Cr,gr),{markdownTransformers:e,toolbarFixed:{groups:_r},toolbarInline:{groups:_r}}});import{$isRangeSelection as Ls,FORMAT_TEXT_COMMAND as Is}from"lexical";import{jsx as Tr,jsxs as ks}from"react/jsx-runtime";import"react";var Er=()=>ks("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Tr("path",{d:"M7.76465 6L3.76465 10L7.76465 14",stroke:"currentColor"}),Tr("path",{d:"M12.2354 6L16.2354 10L12.2354 14",stroke:"currentColor"})]});var wr={type:"text-format",format:["code"],tag:"`"};var Nr=[U([{ChildComponent:Er,isActive:({selection:t})=>Ls(t)?t.hasFormat("code"):!1,key:"inlineCode",onSelect:({editor:t})=>{t.dispatchCommand(Is,"code")},order:7}])],Rs=y({markdownTransformers:[wr],toolbarFixed:{groups:Nr},toolbarInline:{groups:Nr}});import{$isRangeSelection as Ss,FORMAT_TEXT_COMMAND as ys}from"lexical";import{jsx as kr}from"react/jsx-runtime";import"react";var Lr=()=>kr("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:kr("path",{d:"M11.311 14.2969L11.0327 15H6.18408L6.4624 14.2969C7.54639 14.2969 7.70752 14.209 7.83936 13.8721L10.8423 6.45996C10.8716 6.38672 10.8862 6.32812 10.8862 6.26953C10.8862 6.09375 10.6519 6.03516 9.80225 6.03516L10.0952 5.33203H14.9438L14.6509 6.03516C13.5669 6.03516 13.4204 6.12305 13.2886 6.45996L10.2856 13.8721C10.2563 13.9453 10.2271 14.0039 10.2271 14.0625C10.2271 14.2383 10.4614 14.2969 11.311 14.2969Z",fill:"currentColor"})});var Ir={type:"text-format",format:["italic"],tag:"*"},Rr={type:"text-format",format:["italic"],intraword:!1,tag:"_"};var Sr=[U([{ChildComponent:Lr,isActive:({selection:t})=>Ss(t)?t.hasFormat("italic"):!1,key:"italic",onSelect:({editor:t})=>{t.dispatchCommand(ys,"italic")},order:2}])],Ms=y({markdownTransformers:[Ir,Rr],toolbarFixed:{groups:Sr},toolbarInline:{groups:Sr}});import{$isRangeSelection as As,FORMAT_TEXT_COMMAND as Fs}from"lexical";import{jsx as yr,jsxs as vs}from"react/jsx-runtime";import"react";var Mr=()=>vs("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[yr("path",{d:"M5.50756 12.76H7.42756C7.56256 14.215 8.82256 14.71 10.1576 14.71C11.4326 14.71 12.4226 14.14 12.4226 13.06C12.4226 12.28 11.9576 11.845 10.6676 11.605L8.70256 11.245C7.12756 10.96 5.85256 10.21 5.85256 8.335C5.85256 6.43 7.53256 5.11 9.87256 5.11C12.4226 5.11 13.9526 6.22 14.1626 8.23H12.2876C12.1526 7.18 11.2226 6.595 9.88756 6.595C8.59756 6.595 7.78756 7.27 7.78756 8.215C7.78756 9.1 8.34256 9.385 9.49756 9.61L11.5676 10.015C13.3226 10.345 14.3726 11.215 14.3726 12.94C14.3726 14.89 12.5876 16.18 10.2176 16.18C7.66756 16.18 5.70256 15.115 5.50756 12.76Z",fill:"currentColor"}),yr("path",{d:"M4.99756 11.44H15.0026V12.19H4.99756V11.44Z",fill:"currentColor"})]});var vr={type:"text-format",format:["strikethrough"],tag:"~~"};var Ar=[U([{ChildComponent:Mr,isActive:({selection:t})=>As(t)?t.hasFormat("strikethrough"):!1,key:"strikethrough",onSelect:({editor:t})=>{t.dispatchCommand(Fs,"strikethrough")},order:4}])],Ds=y({markdownTransformers:[vr],toolbarFixed:{groups:Ar},toolbarInline:{groups:Ar}});import{$isRangeSelection as Os,FORMAT_TEXT_COMMAND as Ps}from"lexical";import{jsx as Fr}from"react/jsx-runtime";import"react";var Dr=()=>Fr("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Fr("path",{d:"M10.167 15L7.45002 11.36L4.73302 15H2.91302L6.55302 10.177L3.23802 5.718H5.20102L7.54102 8.89L9.89402 5.718H11.714L8.43802 10.06L12.13 15H10.167ZM16.7768 13.258C16.7768 14.155 16.1398 14.532 15.2038 15C14.5538 15.325 14.2808 15.546 14.2418 15.78H16.7898V16.82H12.7208V16.339C12.7208 15.286 13.5918 14.675 14.3588 14.233C15.0868 13.83 15.4378 13.635 15.4378 13.232C15.4378 12.894 15.2038 12.686 14.8268 12.686C14.3848 12.686 14.1248 13.024 14.1118 13.427H12.7468C12.8248 12.426 13.5528 11.633 14.8398 11.633C15.9448 11.633 16.7768 12.257 16.7768 13.258Z",fill:"currentColor"})});var Or=[U([{ChildComponent:Dr,isActive:({selection:t})=>Os(t)?t.hasFormat("subscript"):!1,key:"subscript",onSelect:({editor:t})=>{t.dispatchCommand(Ps,"subscript")},order:5}])],$s=y({toolbarFixed:{groups:Or},toolbarInline:{groups:Or}});import{$isRangeSelection as Hs,FORMAT_TEXT_COMMAND as Bs}from"lexical";import{jsx as Pr}from"react/jsx-runtime";import"react";var $r=()=>Pr("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Pr("path",{d:"M10.167 15L7.45002 11.36L4.73302 15H2.91302L6.55302 10.177L3.23802 5.718H5.20102L7.54102 8.89L9.89402 5.718H11.714L8.43802 10.06L12.13 15H10.167ZM16.7768 7.252C16.7768 8.149 16.1398 8.526 15.2038 8.994C14.5538 9.319 14.2808 9.54 14.2418 9.774H16.7898V10.814H12.7208V10.333C12.7208 9.28 13.5918 8.669 14.3588 8.227C15.0868 7.824 15.4378 7.629 15.4378 7.226C15.4378 6.888 15.2038 6.68 14.8268 6.68C14.3848 6.68 14.1248 7.018 14.1118 7.421H12.7468C12.8248 6.42 13.5528 5.627 14.8398 5.627C15.9448 5.627 16.7768 6.251 16.7768 7.252Z",fill:"currentColor"})});var Hr=[U([{ChildComponent:$r,isActive:({selection:t})=>Hs(t)?t.hasFormat("superscript"):!1,key:"superscript",onSelect:({editor:t})=>{t.dispatchCommand(Bs,"superscript")},order:6}])],js=y({toolbarFixed:{groups:Hr},toolbarInline:{groups:Hr}});import{$isRangeSelection as Us,FORMAT_TEXT_COMMAND as Ws}from"lexical";import{jsx as Br,jsxs as Gs}from"react/jsx-runtime";import"react";var jr=()=>Gs("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Br("path",{d:"M13.9656 11.256C13.9656 13.791 12.5096 15.156 10.0006 15.156C7.50461 15.156 6.03561 13.791 6.03561 11.23V5.718H7.76461V11.243C7.76461 12.868 8.50561 13.778 10.0006 13.778C11.4956 13.778 12.2496 12.868 12.2496 11.243V5.718H13.9656V11.256Z",fill:"currentColor"}),Br("path",{d:"M5.09961 16.3H14.9016V16.95H5.09961V16.3Z",fill:"currentColor"})]});var Gr=[U([{ChildComponent:jr,isActive:({selection:t})=>Us(t)?t.hasFormat("underline"):!1,key:"underline",onSelect:({editor:t})=>{t.dispatchCommand(Ws,"underline")},order:3}])],Vs=y({toolbarFixed:{groups:Gr},toolbarInline:{groups:Gr}});import{$createHeadingNode as Ys,$isHeadingNode as on,HeadingNode as Xs}from"@lexical/rich-text";import{$setBlocksType as Js}from"@lexical/selection";import{$getSelection as qs,$isRangeSelection as Qs}from"lexical";import{jsx as Ur}from"react/jsx-runtime";import"react";var Wr=()=>Ur("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Ur("path",{d:"M4.639 13.5V7.074H6.196V9.648H9.076V7.074H10.642V13.5H9.076V10.836H6.196V13.5H4.639ZM11.5656 9.045V8.019C12.6636 8.019 13.1316 7.731 13.2846 7.065H14.4006V13.5H12.8436V9.045H11.5656Z",fill:"currentColor"})});import{jsx as Vr}from"react/jsx-runtime";import"react";var zr=()=>Vr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Vr("path",{d:"M4.139 13.5V7.074H5.696V9.648H8.576V7.074H10.142V13.5H8.576V10.836H5.696V13.5H4.139ZM15.9796 8.973C15.9796 10.116 15.1696 10.656 14.0356 11.232C13.2256 11.646 12.8206 11.943 12.7846 12.294H15.9886V13.5H11.0566V12.951C11.0566 11.601 12.1636 10.845 13.1176 10.287C14.0356 9.756 14.5126 9.486 14.5126 8.946C14.5126 8.46 14.2156 8.145 13.6306 8.145C13.0186 8.145 12.6586 8.613 12.6226 9.198H11.1196C11.2186 7.947 12.1006 6.966 13.6396 6.966C15.0346 6.966 15.9796 7.785 15.9796 8.973Z",fill:"currentColor"})});import{jsx as Kr}from"react/jsx-runtime";import"react";var Zr=()=>Kr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Kr("path",{d:"M4.139 13.5V7.074H5.696V9.648H8.576V7.074H10.142V13.5H8.576V10.836H5.696V13.5H4.139ZM16.1146 11.745C16.1146 12.744 15.2236 13.608 13.6126 13.608C12.0736 13.608 11.0926 12.762 10.9846 11.547H12.4696C12.5146 12.114 13.0006 12.456 13.6126 12.456C14.2876 12.456 14.6746 12.132 14.6746 11.619C14.6746 11.061 14.2426 10.836 13.6216 10.836H12.9826V9.738H13.6036C14.1526 9.738 14.5486 9.486 14.5486 8.937C14.5486 8.46 14.2156 8.127 13.6486 8.127C13.0366 8.127 12.6586 8.514 12.6226 9.045H11.1916C11.2726 7.929 12.1276 6.966 13.6666 6.966C15.1876 6.966 15.9706 7.848 15.9706 8.865C15.9706 9.603 15.5026 10.143 14.8186 10.269C15.6196 10.404 16.1146 10.971 16.1146 11.745Z",fill:"currentColor"})});import{jsx as Yr}from"react/jsx-runtime";import"react";var Xr=()=>Yr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Yr("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM15.1736 7.074V10.854H16.3706V12.033H15.1736V13.5H13.6796V12.033H10.5116V10.845L13.4996 7.074H15.1736ZM13.6796 8.46L11.8256 10.854H13.6796V8.46Z",fill:"currentColor"})});import{jsx as Jr}from"react/jsx-runtime";import"react";var qr=()=>Jr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Jr("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM13.1576 10.269C12.6896 10.269 12.3746 10.494 12.2216 10.737H10.8176L11.1956 7.074H15.2546V8.28H12.3206L12.1856 9.549C12.4016 9.351 12.8516 9.126 13.4636 9.126C14.7866 9.126 15.6596 10.053 15.6596 11.358C15.6596 12.609 14.7326 13.608 13.1756 13.608C11.5826 13.608 10.6556 12.753 10.5566 11.511H12.1136C12.1586 12.06 12.5456 12.465 13.1576 12.465C13.8236 12.465 14.1746 11.97 14.1746 11.376C14.1746 10.764 13.8416 10.269 13.1576 10.269Z",fill:"currentColor"})});import{jsx as Qr}from"react/jsx-runtime";import"react";var en=()=>Qr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Qr("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM13.3646 8.127C12.5456 8.127 12.0416 8.937 12.0416 9.999C12.3296 9.54 12.8246 9.207 13.5536 9.207C14.8586 9.207 15.8036 10.134 15.8036 11.376C15.8036 12.645 14.8226 13.608 13.3196 13.608C11.7266 13.608 10.6196 12.393 10.6196 10.395C10.6196 8.316 11.7716 6.966 13.4186 6.966C14.7056 6.966 15.5786 7.749 15.7316 8.829H14.3186C14.2016 8.415 13.9226 8.127 13.3646 8.127ZM13.3106 12.51C13.9586 12.51 14.3816 12.042 14.3816 11.385C14.3816 10.737 13.9586 10.278 13.3106 10.278C12.6536 10.278 12.2126 10.737 12.2126 11.385C12.2126 12.042 12.6536 12.51 13.3106 12.51Z",fill:"currentColor"})});import{$createHeadingNode as zs,$isHeadingNode as Ks,HeadingNode as Zs}from"@lexical/rich-text";var Xt=t=>(e,o,n)=>{let r=t(n);r&&(r.append(...o),e.replace(r),r.select(0,0))};var tn=t=>{let o=`^(${t.map(r=>Number(r.slice(1))).map(r=>`#{${r}}`).join("|")})\\s`,n=new RegExp(o);return{type:"element",dependencies:[Zs],export:(r,i)=>{if(!Ks(r))return null;let l=Number(r.getTag().slice(1));return"#".repeat(l)+" "+i(r)},regExp:n,replace:Xt(r=>{let i="h"+r[1].length;return zs(i)})}};var rn=t=>{let e=qs();Js(e,()=>Ys(t))},nn={h1:Wr,h2:zr,h3:Zr,h4:Xr,h5:qr,h6:en},ea=y(({props:t})=>{let{enabledHeadingSizes:e=["h1","h2","h3","h4","h5","h6"]}=t,o=[V(e.map((n,r)=>({ChildComponent:nn[n],isActive:({selection:i})=>{if(!Qs(i))return!1;for(let l of i.getNodes()){if(on(l)&&l.getTag()===n)continue;let s=l.getParent();if(!(on(s)&&s.getTag()===n))return!1}return!0},key:n,label:({i18n:i})=>i.t("lexical:heading:label",{headingLevel:n.charAt(1)}),onSelect:({editor:i})=>{i.update(()=>{rn(n)})},order:r+2})))];return{markdownTransformers:[tn(e)],nodes:[Xs],sanitizedClientFeatureProps:t,slashMenu:{groups:e?.length?[G(e.map(n=>({Icon:nn[n],key:`heading-${n.charAt(1)}`,keywords:["heading",n],label:({i18n:r})=>r.t("lexical:heading:label",{headingLevel:n.charAt(1)}),onSelect:({editor:r})=>{r.update(()=>{rn(n)})}})))]:[]},toolbarFixed:{groups:e?.length?o:[]},toolbarInline:{groups:e?.length?o:[]}}});import{$isNodeSelection as ca}from"lexical";import{jsx as ln}from"react/jsx-runtime";import"react";var Jt=()=>ln("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:ln("rect",{fill:"currentColor",height:"1",width:"12",x:"4",y:"9.5"})});import{jsx as sn,jsxs as ta}from"react/jsx-runtime";import"react";var an=()=>ta("svg",{fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[sn("path",{d:"M5 10h10",stroke:"currentColor"}),sn("path",{d:"M10 15V5",stroke:"currentColor"})]});var q=t=>({type:"dropdown",ChildComponent:an,items:t,key:"add",order:10});var cn={type:"element",dependencies:[Ye],export:(t,e)=>Je(t)?"---":null,regExp:/^---\s*$/,replace:t=>{let e=Xe();e&&t.replace(e)}};import{c as oa}from"react/compiler-runtime";import{useLexicalComposerContext as ra}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as na}from"@lexical/utils";import{$getSelection as ia,$isRangeSelection as la,COMMAND_PRIORITY_EDITOR as sa}from"lexical";import{useEffect as aa}from"react";var un=()=>{let t=oa(3),[e]=ra(),o,n;return t[0]!==e?(o=()=>e.registerCommand(Ie,r=>{let i=ia();if(!la(i))return!1;if(i.focus.getNode()!==null){let s=Xe();na(s)}return!0},sa),n=[e],t[0]=e,t[1]=o,t[2]=n):(o=t[1],n=t[2]),aa(o,n),null};var ua=y({markdownTransformers:[cn],nodes:[Ye],plugins:[{Component:un,position:"normal"}],slashMenu:{groups:[G([{Icon:Jt,key:"horizontalRule",keywords:["hr","horizontal rule","line","separator"],label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ie,void 0)}}])]},toolbarFixed:{groups:[q([{ChildComponent:Jt,isActive:({selection:t})=>{if(!ca(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return Je(e)},key:"horizontalRule",label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ie,void 0)}}])]}});import{INDENT_CONTENT_COMMAND as fa,OUTDENT_CONTENT_COMMAND as pa}from"lexical";import{jsx as st,jsxs as da}from"react/jsx-runtime";import"react";var dn=()=>da("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[st("path",{d:"M2.5 5H10.5",stroke:"currentColor",strokeWidth:"1.5"}),st("path",{d:"M2.5 10H10.5",stroke:"currentColor",strokeWidth:"1.5"}),st("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"}),st("path",{d:"M12.25 7.25L17.25 3.75V10.75L12.25 7.25Z",fill:"currentColor"})]});import{jsx as at,jsxs as ma}from"react/jsx-runtime";import"react";var mn=()=>ma("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[at("path",{d:"M17.5 5H9.5",stroke:"currentColor",strokeWidth:"1.5"}),at("path",{d:"M17.5 10H9.5",stroke:"currentColor",strokeWidth:"1.5"}),at("path",{d:"M17.5 15H2.5",stroke:"currentColor",strokeWidth:"1.5"}),at("path",{d:"M7.75 7.25L2.75 3.75V10.75L7.75 7.25Z",fill:"currentColor"})]});var fn=t=>({type:"buttons",items:t,key:"indent",order:35});var pn=[fn([{ChildComponent:dn,isActive:()=>!1,isEnabled:({selection:t})=>{if(!t||!t?.getNodes()?.length)return!1;for(let e of t.getNodes()){let o=e.getParentOrThrow();if("__indent"in e&&e.__indent>0||"__indent"in o&&o.__indent>0)return!0}return!1},key:"indentDecrease",label:({i18n:t})=>t.t("lexical:indent:decreaseLabel"),onSelect:({editor:t})=>{t.dispatchCommand(pa,void 0)},order:1},{ChildComponent:mn,isActive:()=>!1,key:"indentIncrease",label:({i18n:t})=>t.t("lexical:indent:increaseLabel"),onSelect:({editor:t})=>{t.dispatchCommand(fa,void 0)},order:2}])],ha=y({toolbarFixed:{groups:pn},toolbarInline:{groups:pn}});import{$findMatchingParent as kc}from"@lexical/utils";import{$getSelection as io,$isRangeSelection as Wn}from"lexical";import{jsx as hn}from"react/jsx-runtime";import"react";var gn=()=>hn("svg",{"aria-hidden":"true",className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:hn("path",{d:"M8.5 11.5L11.5 8.5M8.5 7L9.625 5.875C10.868 4.633 12.882 4.633 14.125 5.875C15.368 7.118 15.368 9.133 14.125 10.375L13 11.5M7 8.5L5.746 9.754C4.56 10.94 4.519 12.85 5.652 14.087C6.814 15.354 8.78 15.449 10.058 14.298L11.5 13",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})});import{$isAtNodeEnd as Cn}from"@lexical/selection";function he(t){let{anchor:e}=t,{focus:o}=t,n=t.anchor.getNode(),r=t.focus.getNode();return n===r?n:t.isBackward()?Cn(o)?n:r:Cn(e)?n:r}var qt=t=>({type:"buttons",items:t,key:"features",order:50});import{$createTextNode as La,$isTextNode as Ia}from"lexical";import{addClassNamesToElement as ga,isHTMLAnchorElement as Ca}from"@lexical/utils";import to from"bson-objectid";import{$applyNodeReplacement as xa,$createTextNode as xn,$getSelection as ba,$isElementNode as bn,$isRangeSelection as eo,createCommand as _a,ElementNode as Ta}from"lexical";var Ea=new Set(["http:","https:","mailto:","sms:","tel:"]),z=class t extends Ta{__fields;__id;constructor({id:e,fields:o={doc:null,linkType:"custom",newTab:!1,url:""},key:n}){super(n),this.__fields=o,this.__id=e}static clone(e){return new t({id:e.__id,fields:e.__fields,key:e.__key})}static getType(){return"link"}static importDOM(){return{a:e=>({conversion:wa,priority:1})}}static importJSON(e){e.version===1&&typeof e.fields?.doc?.value=="object"&&e.fields?.doc?.value?.id&&(e.fields.doc.value=e.fields.doc.value.id,e.version=2),e.version===2&&!e.id&&(e.id=new to.default().toHexString(),e.version=3);let o=Q({id:e.id,fields:e.fields});return o.setFormat(e.format),o.setIndent(e.indent),o.setDirection(e.direction),o}canBeEmpty(){return!1}canInsertTextAfter(){return!1}canInsertTextBefore(){return!1}createDOM(e){let o=document.createElement("a");return this.__fields?.linkType==="custom"&&(o.href=this.sanitizeUrl(this.__fields.url??"")),(this.__fields?.newTab??!1)&&(o.target="_blank"),this.__fields?.newTab===!0&&this.__fields?.linkType==="custom"&&(o.rel=Qt(o.rel,"add","noopener")),ga(o,e.theme.link),o}exportJSON(){let e={...super.exportJSON(),type:"link",fields:this.getFields(),version:3},o=this.getID();return o&&(e.id=o),e}extractWithChild(e,o,n){if(!eo(o))return!1;let r=o.anchor.getNode(),i=o.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&o.getTextContent().length>0}getFields(){return this.getLatest().__fields}getID(){return this.getLatest().__id}insertNewAfter(e,o=!0){let n=this.getParentOrThrow().insertNewAfter(e,o);if(bn(n)){let r=Q({fields:this.__fields});return n.append(r),r}return null}isInline(){return!0}sanitizeUrl(e){try{let o=new URL(e);if(!Ea.has(o.protocol))return"about:blank"}catch{return"https://"}return e}setFields(e){let o=this.getWritable();o.__fields=e}updateDOM(e,o,n){let r=this.__fields?.url,i=this.__fields?.newTab;return r!=null&&r!==e.__fields?.url&&this.__fields?.linkType==="custom"&&(o.href=r),this.__fields?.linkType==="internal"&&e.__fields?.linkType==="custom"&&o.removeAttribute("href"),o.rel==null&&(o.rel=""),i!==e.__fields?.newTab&&(i??!1?(o.target="_blank",this.__fields?.linkType==="custom"&&(o.rel=Qt(o.rel,"add","noopener"))):(o.removeAttribute("target"),o.rel=Qt(o.rel,"remove","noopener"))),!1}};function wa(t){let e=null;if(Ca(t)){let o=t.textContent;o!==null&&o!==""&&(e=Q({id:new to.default().toHexString(),fields:{doc:null,linkType:"custom",newTab:t.getAttribute("target")==="_blank",url:t.getAttribute("href")??""}}))}return{node:e}}function Q({id:t,fields:e}){return xa(new z({id:t??new to.default().toHexString(),fields:e}))}function j(t){return t instanceof z}var X=_a("TOGGLE_LINK_COMMAND");function _n(t){let e=ba();if(!eo(e)&&!t.selectedNodes?.length)return;let o=eo(e)?e.extract():t.selectedNodes;if(t===null)o?.forEach(n=>{let r=n.getParent();if(j(r)){let i=r.getChildren();for(let l=0;l<i.length;l+=1)r.insertBefore(i[l]);r.remove()}});else{if(o?.length===1){let i=o[0],l=j(i)?i:Na(i);if(l!==null){l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(xn(t.text)),l.getChildren().forEach(s=>{s!==l.getLastChild()&&s.remove()}));return}}let n=null,r=null;o?.forEach(i=>{let l=i.getParent();if(!(l===r||l===null||bn(i)&&!i.isInline())){if(j(l)){r=l,l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(xn(t.text)),l.getChildren().forEach(s=>{s!==l.getLastChild()&&s.remove()}));return}if(l.is(n)||(n=l,r=Q({fields:t.fields}),j(l)?i.getPreviousSibling()===null?l.insertBefore(r):l.insertAfter(r):i.insertBefore(r)),j(i)){if(i.is(r))return;if(r!==null){let s=i.getChildren();for(let a=0;a<s.length;a+=1)r.append(s[a])}i.remove();return}r!==null&&r.append(i)}})}}function Na(t){return ka(t,e=>j(e))}function ka(t,e){let o=t;for(;o!==null&&(o=o.getParent(),!(o===null||e(o))););return o}function Qt(t,e,o){let n,r=`${t}`;if(e==="add"){if(r.includes(o)){let i=new RegExp(o,"g");r=r.replace(i,"").trim()}r=r.trim(),n=r.length===0?`${o}`:`${r} ${o}`}else{let i=new RegExp(o,"g");n=r.replace(i,"").trim()}return n}var Tn={type:"text-match",dependencies:[z],export:(t,e,o)=>{if(!j(t))return null;let n=t,{url:r}=n.getFields(),i=`[${n.getTextContent()}](${r})`,l=n.getFirstChild();return n.getChildrenSize()===1&&Ia(l)?o(l,i):i},importRegExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)/,regExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)$/,replace:(t,e)=>{let[,o,n]=e,r=Q({fields:{doc:null,linkType:"custom",newTab:!1,url:n}}),i=La(o);i.setFormat(t.getFormat()),r.append(i),t.replace(r)},trigger:")"};import{$applyNodeReplacement as Ra,$isElementNode as Sa}from"lexical";var ee=class t extends z{static clone(e){return new t({id:"",fields:e.__fields,key:e.__key})}static getType(){return"autolink"}static importDOM(){return null}static importJSON(e){e.version===1&&typeof e.fields?.doc?.value=="object"&&e.fields?.doc?.value?.id&&(e.fields.doc.value=e.fields.doc.value.id,e.version=2);let o=Pe({fields:e.fields});return o.setFormat(e.format),o.setIndent(e.indent),o.setDirection(e.direction),o}exportJSON(){let e=super.exportJSON();return{type:"autolink",children:e.children,direction:e.direction,fields:e.fields,format:e.format,indent:e.indent,version:2}}insertNewAfter(e,o=!0){let n=this.getParentOrThrow().insertNewAfter(e,o);if(Sa(n)){let r=Pe({fields:this.__fields});return n.append(r),r}return null}};function Pe({fields:t}){return Ra(new ee({id:"",fields:t}))}function te(t){return t instanceof ee}import{c as ya}from"react/compiler-runtime";import{useLexicalComposerContext as Ma}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as va}from"@lexical/utils";import{$createTextNode as En,$getSelection as Aa,$isElementNode as Nn,$isLineBreakNode as kn,$isNodeSelection as Fa,$isRangeSelection as Da,$isTextNode as $e,TextNode as Oa}from"lexical";import{useEffect as Pa}from"react";function wn(t,e=o=>o){return o=>{let n=t.exec(o);return n===null?null:{index:n.index,length:n[0].length,text:n[0],url:e(n[0])}}}function Ln(t,e){for(let o=0;o<e.length;o++){let n=e[o](t);if(n!=null)return n}return null}var $a=/[.,;\s]/;function ut(t){return $a.test(t)}function In(t){return ut(t[t.length-1])}function ro(t){return ut(t[0])}function Ha(t,e){return e?/^\.[a-z]{2,}/i.test(t):/^\.[a-z0-9]+/i.test(t)}function Rn(t){let e=t.getPreviousSibling();return Nn(e)&&(e=e.getLastDescendant()),e===null||kn(e)||$e(e)&&In(e.getTextContent())}function Sn(t){let e=t.getNextSibling();return Nn(e)&&(e=e.getFirstDescendant()),e===null||kn(e)||$e(e)&&ro(e.getTextContent())}function Ba(t,e,o,n){return(t>0?ut(o[t-1]):Rn(n[0]))?e<o.length?ut(o[e]):Sn(n[n.length-1]):!1}function ja(t,e,o){let n=[],r=[],i=[],l=0,s=0,a=[...t];for(;a.length>0;){let c=a[0],d=c.getTextContent().length,m=s;s+d<=e?(n.push(c),l+=d):m>=o?i.push(c):r.push(c),s+=d,a.shift()}return[l,n,r,i]}function Ga(t,e,o,n){let r={linkType:"custom",url:n.url,...n.fields},i=Pe({fields:r});if(t.length===1){let l=t[0],s;e===0?[s,l]=l.splitText(o):[,s,l]=l.splitText(e,o);let a=En(n.text);return a.setFormat(s.getFormat()),a.setDetail(s.getDetail()),a.setStyle(s.getStyle()),i.append(a),s.replace(i),l}else if(t.length>1){let l=t[0],s=l.getTextContent().length,a;e===0?a=l:[,a]=l.splitText(e);let c=[],u;for(let p=1;p<t.length;p++){let h=t[p],C=h.getTextContent().length,v=s,M=s+C;if(v<o)if(M<=o)c.push(h);else{let[_,E]=h.splitText(o-v);c.push(_),u=E}s+=C}let d=Aa(),m=d?d.getNodes().find($e):void 0,f=En(a.getTextContent());return f.setFormat(a.getFormat()),f.setDetail(a.getDetail()),f.setStyle(a.getStyle()),i.append(f,...c),m&&m===a&&(Da(d)?f.select(d.anchor.offset,d.focus.offset):Fa(d)&&f.select(0,f.getTextContent().length)),a.replace(i),u}}function Ua(t,e,o){let n=[...t],r=n.map(a=>a.getTextContent()).join(""),i=r,l,s=0;for(;(l=Ln(i,e))!=null&&l!==null;){let a=l.index,c=l.length,u=a+c;if(Ba(s+a,s+u,r,n)){let[m,,f,p]=ja(n,s+a,s+u),h=s+a-m,b=s+u-m,C=Ga(f,h,b,l);n=C?[C,...p]:p,o(l.url,null),s=0}else s+=u;i=i.substring(u)}}function oo(t,e,o){let n=t.getChildren(),r=n.length;for(let a=0;a<r;a++){let c=n[a];if(!$e(c)||!c.isSimpleText()){ct(t),o(null,t.getFields()?.url??null);return}}let i=t.getTextContent(),l=Ln(i,e);if(l===null||l.text!==i){ct(t),o(null,t.getFields()?.url??null);return}if(!Rn(t)||!Sn(t)){ct(t),o(null,t.getFields()?.url??null);return}let s=t.getFields()?.url;if(s!==l?.url){let a=t.getFields();a.url=l?.url,t.setFields(a),o(l.url,s??null)}}function Wa(t,e,o){let n=t.getPreviousSibling(),r=t.getNextSibling(),i=t.getTextContent();if(te(n)){let l=n.getFields()?.url?n.getFields()?.url?.startsWith("mailto:"):!1;(!ro(i)||Ha(i,l))&&(n.append(t),oo(n,e,o),o(null,n.getFields()?.url??null))}te(r)&&!In(i)&&(ct(r),oo(r,e,o),o(null,r.getFields()?.url??null))}function ct(t){let e=t.getChildren(),o=e.length;for(let n=o-1;n>=0;n--)t.insertAfter(e[n]);return t.remove(),e.map(n=>n.getLatest())}function Va(t){let e=[t],o=t.getNextSibling();for(;o!==null&&$e(o)&&o.isSimpleText()&&(e.push(o),!/\s/.test(o.getTextContent()));)o=o.getNextSibling();return e}function za(t,e,o){let n=ya(5),r,i;n[0]!==t||n[1]!==o||n[2]!==e?(r=()=>{if(!t.hasNodes([ee]))throw new Error("LexicalAutoLinkPlugin: AutoLinkNode not registered on editor");let l=(s,a)=>{o?.(s,a)};return va(t.registerNodeTransform(Oa,s=>{let a=s.getParentOrThrow(),c=s.getPreviousSibling();if(te(a))oo(a,e,l);else if(!j(a)){if(s.isSimpleText()&&(ro(s.getTextContent())||!te(c))){let u=Va(s);Ua(u,e,l)}Wa(s,e,l)}}))},i=[t,e,o],n[0]=t,n[1]=o,n[2]=e,n[3]=r,n[4]=i):(r=n[3],i=n[4]),Pa(r,i)}var Ka=/((https?:\/\/(www\.)?)|(www\.))[-\w@:%.+~#=]{1,256}\.[a-zA-Z\d()]{1,6}\b([-\w()@:%+.~#?&/=]*)(?<![-.+():%])/,Za=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-z\-\d]+\.)+[a-z]{2,}))/i,Ya=[wn(Ka,t=>t.startsWith("http")?t:`https://${t}`),wn(Za,t=>`mailto:${t}`)],yn=()=>{let[t]=Ma();return za(t,Ya),null};import{jsx as Xa}from"react/jsx-runtime";import{ClickableLinkPlugin as Ja}from"@lexical/react/LexicalClickableLinkPlugin.js";import"react";var Mn=()=>Xa(Ja,{});import{jsx as fc}from"react/jsx-runtime";import"react";import{createPortal as pc}from"react-dom";import{jsx as le,jsxs as no}from"react/jsx-runtime";import{useLexicalComposerContext as Qa}from"@lexical/react/LexicalComposerContext.js";import{$findMatchingParent as vn,mergeRegister as An}from"@lexical/utils";import{getTranslation as ec}from"@payloadcms/translations";import{CloseMenuIcon as tc,EditIcon as oc,formatDrawerSlug as rc,useConfig as nc,useEditDepth as ic,useModal as lc,useTranslation as sc}from"@payloadcms/ui";import{$getSelection as Fn,$isLineBreakNode as ac,$isRangeSelection as Dn,COMMAND_PRIORITY_HIGH as cc,COMMAND_PRIORITY_LOW as On,KEY_ESCAPE_COMMAND as uc,SELECTION_CHANGE_COMMAND as dc}from"lexical";import Pn,{useCallback as $n,useEffect as ft,useRef as mc,useState as ge}from"react";function dt(t,e,o,n=10,r=5){let i=o.parentElement;if(t===null||i==null){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let l=e.getBoundingClientRect(),s=o.getBoundingClientRect(),a=i.getBoundingClientRect(),c=t.top-n,u=t.left-r;c<a.top&&(c+=l.height+t.height+n*2),u+l.width>a.right&&(u=a.right-l.width-r),c-=s.top,u-=s.left,e.style.opacity="1",e.style.transform=`translate(${u}px, ${c}px)`}import{createCommand as qa}from"lexical";var mt=qa("TOGGLE_LINK_WITH_MODAL_COMMAND");function Hn({anchorElem:t}){let[e]=Qa(),o=mc(null),[n,r]=ge(null),[i,l]=ge(null),{uuid:s}=H(),{config:a}=nc(),{i18n:c,t:u}=sc(),[d,m]=ge(),{closeModal:f,toggleModal:p}=lc(),h=ic(),[b,C]=ge(!1),[v,M]=ge([]),[_,E]=ge(!1),T=rc({slug:"lexical-rich-text-link-"+s,depth:h}),I=$n(()=>{C(!1),o&&o.current&&(o.current.style.opacity="0",o.current.style.transform="translate(-10000px, -10000px)"),E(!1),r(null),l(null),M([]),m(void 0)},[C,r,l,M]),S=$n(()=>{let x=Fn(),N;if(!Dn(x)||!x){I();return}let L=he(x);N=e.getElementByKey(L.getKey())?.getBoundingClientRect();let g=vn(L,j),w=x.getNodes().filter(B=>!ac(B)).find(B=>{let P=vn(B,j);return g&&!g.is(P)||P&&!P.is(g)});if(g==null||w){I();return}let k={...g.getFields(),id:g.getID(),text:g.getTextContent()};if(g.getFields()?.linkType==="custom")r(g.getFields()?.url??null),l(null);else{r(`/admin/collections/${g.getFields()?.doc?.relationTo}/${g.getFields()?.doc?.value}`);let B=a.collections.find(P=>P.slug===g.getFields()?.doc?.relationTo);if(!B)l(g.getFields()?.label?String(g.getFields()?.label):null),r(g.getFields()?.url?String(g.getFields()?.url):null);else{let P=u("fields:linkedTo",{label:ec(B.labels.singular,c)}).replace(/<[^>]*>?/g,"");l(P)}}m(k),C(!0),M(x?x?.getNodes():[]),te(g)?E(!0):E(!1);let R=o.current,A=window.getSelection(),{activeElement:O}=document;if(R===null)return;let D=e.getRootElement();return A!==null&&D!==null&&D.contains(A.anchorNode)?(N||(N=A.getRangeAt(0).getBoundingClientRect()),N!=null&&(N.y+=40,dt(N,R,t))):(O==null||O.className!=="link-input")&&(D!==null&&dt(null,R,t),r(null),l(null)),!0},[e,I,a.collections,u,c,t]);return ft(()=>An(e.registerCommand(mt,x=>(e.dispatchCommand(X,x),S(),p(T),!0),On)),[e,S,p,T]),ft(()=>{let x=t.parentElement,N=()=>{e.getEditorState().read(()=>{S()})};return window.addEventListener("resize",N),x?.addEventListener("scroll",N),()=>{window.removeEventListener("resize",N),x?.removeEventListener("scroll",N)}},[t.parentElement,e,S]),ft(()=>An(e.registerUpdateListener(({editorState:x})=>{x.read(()=>{S()})}),e.registerCommand(dc,()=>(S(),!0),On),e.registerCommand(uc,()=>b?(I(),!0):!1,cc)),[e,S,b,I]),ft(()=>{e.getEditorState().read(()=>{S()})},[e,S]),no(Pn.Fragment,{children:[le("div",{className:"link-editor",ref:o,children:no("div",{className:"link-input",children:[n&&n.length>0?le("a",{href:n,rel:"noopener noreferrer",target:"_blank",children:i!=null&&i.length>0?i:n}):i!=null&&i.length>0?le("span",{className:"link-input__label-pure",children:i}):null,e.isEditable()&&no(Pn.Fragment,{children:[le("button",{"aria-label":"Edit link",className:"link-edit",onClick:()=>{p(T)},onMouseDown:x=>{x.preventDefault()},tabIndex:0,type:"button",children:le(oc,{})}),!_&&le("button",{"aria-label":"Remove link",className:"link-trash",onClick:()=>{e.dispatchCommand(X,null)},onMouseDown:x=>{x.preventDefault()},tabIndex:0,type:"button",children:le(tc,{})})]})]})}),le(ce,{className:"lexical-link-edit-drawer",data:d,drawerSlug:T,drawerTitle:u("fields:editLink"),featureKey:"link",handleDrawerSubmit:(x,N)=>{f(T);let L=N,g={...L};delete g.text,e.update(()=>{let w=Fn(),k=null;if(Dn(w)?k=he(w).getParent():v.length&&(k=v[0].getParent()),k&&te(k)){let R=Q({fields:g});k.replace(R,!0)}}),e.dispatchCommand(X,{fields:g,selectedNodes:v,text:L.text})},schemaPathSuffix:"fields"})]})}var Bn=t=>{let{anchorElem:e=document.body}=t;return pc(fc(Hn,{anchorElem:e}),e)};import{c as Cc}from"react/compiler-runtime";import{useLexicalComposerContext as xc}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as bc}from"@lexical/utils";import{$getSelection as _c,$isElementNode as Tc,$isRangeSelection as Ec,COMMAND_PRIORITY_LOW as Gn,PASTE_COMMAND as wc}from"lexical";import{useEffect as Nc}from"react";var hc=/(?:[A-Za-z]{3,9}:(?:\/\/)?(?:[-;:&=+$,\w]+@)?[A-Za-z\d.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z\d.-]+)(?:\/[+~%/.\w-]*)?\??[-+=&;%@.\w]*#?\w*/,gc=/^[\w\-./]*(?:#\w[\w-]*)?$/;function jn(t){if(!t)return!1;if(t==="https://"||hc.test(t)||gc.test(t))return!0;try{return new URL(t),!0}catch{}return!1}var Un=()=>{let t=Cc(3),[e]=xc(),o,n;return t[0]!==e?(o=()=>{if(!e.hasNodes([z]))throw new Error("LinkPlugin: LinkNode not registered on editor");return bc(e.registerCommand(X,r=>(_n(r),!0),Gn),e.registerCommand(wc,r=>{let i=_c();if(!Ec(i)||i.isCollapsed()||!(r instanceof ClipboardEvent)||r.clipboardData==null)return!1;let l=r.clipboardData.getData("text");if(!jn(l))return!1;if(!i.getNodes().some(s=>Tc(s))){let s={doc:null,linkType:"custom",newTab:!1,url:l};return e.dispatchCommand(X,{fields:s,text:null}),r.preventDefault(),!0}return!1},Gn))},n=[e],t[0]=e,t[1]=o,t[2]=n):(o=t[1],n=t[2]),Nc(o,n),null};var Vn=[qt([{ChildComponent:gn,isActive:({selection:t})=>{if(Wn(t)){let e=he(t);return kc(e,j)!=null}return!1},isEnabled:({selection:t})=>!!(Wn(t)&&io()?.getTextContent()?.length),key:"link",label:({i18n:t})=>t.t("lexical:link:label"),onSelect:({editor:t,isActive:e})=>{if(e)t.dispatchCommand(X,null);else{let o,n=[];if(t.getEditorState().read(()=>{o=io()?.getTextContent(),n=io()?.getNodes()??[]}),!o?.length)return;let r={doc:null,linkType:"custom",newTab:!1,url:"https://"};t.dispatchCommand(mt,{fields:r,selectedNodes:n,text:o})}},order:1}])],Lc=y({markdownTransformers:[Tn],nodes:[z,ee],plugins:[{Component:Un,position:"normal"},{Component:yn,position:"normal"},{Component:Mn,position:"normal"},{Component:Bn,position:"floatingAnchorElem"}],toolbarFixed:{groups:Vn},toolbarInline:{groups:Vn}});import{$isListNode as ao,INSERT_CHECK_LIST_COMMAND as Jn,ListItemNode as $c,ListNode as Hc}from"@lexical/list";import{$isRangeSelection as Bc}from"lexical";import{jsx as zn,jsxs as Ic}from"react/jsx-runtime";import"react";var lo=()=>Ic("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[zn("rect",{height:"13",rx:"1.5",stroke:"currentColor",width:"13",x:"3.5",y:"3.5"}),zn("path",{d:"M7 10L9 12.5L13 7.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Rc}from"react/jsx-runtime";import{ListPlugin as Sc}from"@lexical/react/LexicalListPlugin.js";import"react";var Ce=()=>Rc(Sc,{});function xe(t){return{items:t,key:"lists",label:({i18n:e})=>e.t("lexical:general:slashMenuListGroupLabel")}}import{$isListNode as Ac,ListItemNode as Fc,ListNode as Dc}from"@lexical/list";import{$createListItemNode as yc,$createListNode as Mc,$isListItemNode as vc,$isListNode as so}from"@lexical/list";var Kn=4,be=t=>(e,o,n)=>{let r=e.getPreviousSibling(),i=e.getNextSibling(),l=yc(t==="check"?n[3]==="x":void 0);if(so(i)&&i.getListType()===t){let a=i.getFirstChild();a!==null?a.insertBefore(l):i.append(l),e.remove()}else if(so(r)&&r.getListType()===t)r.append(l),e.remove();else{let a=Mc(t,t==="number"?Number(n[2]):void 0);a.append(l),e.replace(a)}l.append(...o),l.select(0,0);let s=Math.floor(n[1].length/Kn);s&&l.setIndent(s)},me=(t,e,o)=>{let n=[],r=t.getChildren(),i=0;for(let l of r)if(vc(l)){if(l.getChildrenSize()===1){let u=l.getFirstChild();if(so(u)){n.push(me(u,e,o+1));continue}}let s=" ".repeat(o*Kn),a=t.getListType(),c=a==="number"?`${t.getStart()+i}. `:a==="check"?`- [${l.getChecked()?"x":" "}] `:"- ";n.push(s+c+e(l)),i++}return n.join(`
34
+ `},[t,e]),f=ue((_,E)=>{o(T=>{let I=e.length-1,S=e[I];if(S&&S.name===_){if(_==="type")return[...e.slice(0,I),{...S,value:S.value+E}];if(S.value===E)return[...e.slice(0,I),{...S,count:S.count+1}]}return[...T,{name:_,count:1,value:E}]})},[e,o]);ar(()=>{let _=T=>{if(!n)return;let I=T.key;fs(T)?f("selectAll",""):ur.has(I)?f("press",T.key):[...I].length>1?f("keydown",T.key):f("type",T.key)},E=T=>{if(!n)return;let I=T.key;!ur.has(I)&&[...I].length>1&&f("keyup",T.key)};return t.registerRootListener((T,I)=>{I!==null&&(I.removeEventListener("keydown",_),I.removeEventListener("keyup",E)),T!==null&&(T.addEventListener("keydown",_),T.addEventListener("keyup",E))})},[t,n,f]),ar(()=>{u.current&&u.current.scrollTo(0,u.current.scrollHeight)},[m]),Kt(()=>{if(e){let _=m();_!==null&&s(_),u.current&&u.current.scrollTo(0,u.current.scrollHeight)}},[m,e]),Kt(()=>t.registerUpdateListener(({dirtyElements:E,dirtyLeaves:T,editorState:I})=>{if(!n)return;let S=I._selection,x=a.current,N=c.current;if(x!==S){if(T.size===0&&E.size===0&&!N){let g=window.getSelection();if(g&&(g.anchorNode==null||g.focusNode==null))return}a.current=S}c.current=!1;let L=m();L!==null&&s(L)}),[t,m,n,f]),Kt(()=>n?t.registerUpdateListener(()=>{let E=t.getRootElement();E!==null&&i(E?.innerHTML)}):void 0,[t,n]);let p=ue(_=>{n||(_.update(()=>{let E=cs();E.clear();let T=as();E.append(ss().append(T)),T.select()}),o([])),r(E=>!E)},[n]),h=ue(()=>{if(!n)return;let _=window.getSelection();if(_===null||_.anchorNode==null||_.focusNode==null)return;let{anchorNode:E,anchorOffset:T,focusNode:I,focusOffset:S}=ps(_),x=d().getRootElement(),N;E!==null&&(N=cr(E,x));let L;I!==null&&(L=cr(I,x)),f("snapshot",{anchorNode:E,anchorOffset:T,anchorPath:N,focusNode:I,focusOffset:S,focusPath:L})},[f,n,d]),b=ue(()=>{us(m())},[m]),C=ue(()=>{ds("test.js",m())},[m]);return[de("button",{className:`editor-dev-button ${n?"active":""}`,id:"test-recorder-button",onClick:_=>{p(d()),_.preventDefault()},title:n?"Disable test recorder":"Enable test recorder",type:"button",children:n?"Disable test recorder":"Enable test recorder"}),n?Yt("div",{className:"test-recorder-output",children:[Yt("div",{className:"test-recorder-toolbar",children:[de("button",{className:"test-recorder-button",id:"test-recorder-button-snapshot",onClick:_=>{h(),_.preventDefault()},title:"Insert snapshot",type:"button",children:"Insert Snapshot"}),de("button",{className:"test-recorder-button",id:"test-recorder-button-copy",onClick:_=>{b(),_.preventDefault()},title:"Copy to clipboard",type:"button",children:"Copy"}),de("button",{className:"test-recorder-button",id:"test-recorder-button-download",onClick:_=>{C(),_.preventDefault()},title:"Download as a file",type:"button",children:"Download"})]}),de("pre",{id:"test-recorder",ref:u,children:l})]}):null]}var mr=()=>{let[t]=ls(),[e,o]=hs(t);return Yt(dr.Fragment,{children:[de("p",{children:"HI"}),e,o,de("p",{children:"DONE"})]})};var gs=y({plugins:[{Component:mr,position:"bottom"}]});import{c as Cs}from"react/compiler-runtime";import{jsx as xs}from"react/jsx-runtime";import{useLexicalComposerContext as bs}from"@lexical/react/LexicalComposerContext.js";import{TreeView as _s}from"@lexical/react/LexicalTreeView.js";import"react";var fr=()=>{let t=Cs(2),[e]=bs(),o;return t[0]!==e?(o=xs(_s,{editor:e,timeTravelButtonClassName:"debug-timetravel-button",timeTravelPanelButtonClassName:"debug-timetravel-panel-button",timeTravelPanelClassName:"debug-timetravel-panel",timeTravelPanelSliderClassName:"debug-timetravel-panel-slider",treeTypeButtonClassName:"debug-treetype-button",viewClassName:"tree-view-output"}),t[0]=e,t[1]=o):o=t[1],o};var Ts=y({plugins:[{Component:fr,position:"bottom"}]});import{$isRangeSelection as Es,FORMAT_TEXT_COMMAND as ws}from"lexical";import{jsx as pr}from"react/jsx-runtime";import"react";var hr=()=>pr("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:pr("path",{d:"M10.6772 15H6.27017V5.718H10.4172C12.6792 5.718 13.8492 6.602 13.8492 8.292C13.8492 9.098 13.1992 9.982 12.4712 10.216C13.3812 10.476 14.1742 11.256 14.1742 12.322C14.1742 14.09 12.9002 15 10.6772 15ZM8.46717 9.501H10.3262C11.3012 9.501 11.7042 9.046 11.7042 8.409C11.7042 7.72 11.2362 7.317 10.3392 7.317H8.46717V9.501ZM8.46717 11.061V13.401H10.4822C11.4702 13.401 11.9642 12.959 11.9642 12.218C11.9642 11.49 11.4702 11.061 10.4822 11.061H8.46717Z",fill:"currentColor"})});var U=t=>({type:"buttons",items:t,key:"format",order:40});var gr={type:"text-format",format:["bold","italic"],tag:"***"},Cr={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},xr={type:"text-format",format:["bold"],tag:"**"},br={type:"text-format",format:["bold"],intraword:!1,tag:"__"};var _r=[U([{ChildComponent:hr,isActive:({selection:t})=>Es(t)?t.hasFormat("bold"):!1,key:"bold",onSelect:({editor:t})=>{t.dispatchCommand(ws,"bold")},order:1}])],Ns=y(({featureProviderMap:t})=>{let e=[xr,br];return t.get("italic")&&e.push(Cr,gr),{markdownTransformers:e,toolbarFixed:{groups:_r},toolbarInline:{groups:_r}}});import{$isRangeSelection as Ls,FORMAT_TEXT_COMMAND as Is}from"lexical";import{jsx as Tr,jsxs as ks}from"react/jsx-runtime";import"react";var Er=()=>ks("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Tr("path",{d:"M7.76465 6L3.76465 10L7.76465 14",stroke:"currentColor"}),Tr("path",{d:"M12.2354 6L16.2354 10L12.2354 14",stroke:"currentColor"})]});var wr={type:"text-format",format:["code"],tag:"`"};var Nr=[U([{ChildComponent:Er,isActive:({selection:t})=>Ls(t)?t.hasFormat("code"):!1,key:"inlineCode",onSelect:({editor:t})=>{t.dispatchCommand(Is,"code")},order:7}])],Rs=y({markdownTransformers:[wr],toolbarFixed:{groups:Nr},toolbarInline:{groups:Nr}});import{$isRangeSelection as Ss,FORMAT_TEXT_COMMAND as ys}from"lexical";import{jsx as kr}from"react/jsx-runtime";import"react";var Lr=()=>kr("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:kr("path",{d:"M11.311 14.2969L11.0327 15H6.18408L6.4624 14.2969C7.54639 14.2969 7.70752 14.209 7.83936 13.8721L10.8423 6.45996C10.8716 6.38672 10.8862 6.32812 10.8862 6.26953C10.8862 6.09375 10.6519 6.03516 9.80225 6.03516L10.0952 5.33203H14.9438L14.6509 6.03516C13.5669 6.03516 13.4204 6.12305 13.2886 6.45996L10.2856 13.8721C10.2563 13.9453 10.2271 14.0039 10.2271 14.0625C10.2271 14.2383 10.4614 14.2969 11.311 14.2969Z",fill:"currentColor"})});var Ir={type:"text-format",format:["italic"],tag:"*"},Rr={type:"text-format",format:["italic"],intraword:!1,tag:"_"};var Sr=[U([{ChildComponent:Lr,isActive:({selection:t})=>Ss(t)?t.hasFormat("italic"):!1,key:"italic",onSelect:({editor:t})=>{t.dispatchCommand(ys,"italic")},order:2}])],Ms=y({markdownTransformers:[Ir,Rr],toolbarFixed:{groups:Sr},toolbarInline:{groups:Sr}});import{$isRangeSelection as As,FORMAT_TEXT_COMMAND as Fs}from"lexical";import{jsx as yr,jsxs as vs}from"react/jsx-runtime";import"react";var Mr=()=>vs("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[yr("path",{d:"M5.50756 12.76H7.42756C7.56256 14.215 8.82256 14.71 10.1576 14.71C11.4326 14.71 12.4226 14.14 12.4226 13.06C12.4226 12.28 11.9576 11.845 10.6676 11.605L8.70256 11.245C7.12756 10.96 5.85256 10.21 5.85256 8.335C5.85256 6.43 7.53256 5.11 9.87256 5.11C12.4226 5.11 13.9526 6.22 14.1626 8.23H12.2876C12.1526 7.18 11.2226 6.595 9.88756 6.595C8.59756 6.595 7.78756 7.27 7.78756 8.215C7.78756 9.1 8.34256 9.385 9.49756 9.61L11.5676 10.015C13.3226 10.345 14.3726 11.215 14.3726 12.94C14.3726 14.89 12.5876 16.18 10.2176 16.18C7.66756 16.18 5.70256 15.115 5.50756 12.76Z",fill:"currentColor"}),yr("path",{d:"M4.99756 11.44H15.0026V12.19H4.99756V11.44Z",fill:"currentColor"})]});var vr={type:"text-format",format:["strikethrough"],tag:"~~"};var Ar=[U([{ChildComponent:Mr,isActive:({selection:t})=>As(t)?t.hasFormat("strikethrough"):!1,key:"strikethrough",onSelect:({editor:t})=>{t.dispatchCommand(Fs,"strikethrough")},order:4}])],Ds=y({markdownTransformers:[vr],toolbarFixed:{groups:Ar},toolbarInline:{groups:Ar}});import{$isRangeSelection as Os,FORMAT_TEXT_COMMAND as Ps}from"lexical";import{jsx as Fr}from"react/jsx-runtime";import"react";var Dr=()=>Fr("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Fr("path",{d:"M10.167 15L7.45002 11.36L4.73302 15H2.91302L6.55302 10.177L3.23802 5.718H5.20102L7.54102 8.89L9.89402 5.718H11.714L8.43802 10.06L12.13 15H10.167ZM16.7768 13.258C16.7768 14.155 16.1398 14.532 15.2038 15C14.5538 15.325 14.2808 15.546 14.2418 15.78H16.7898V16.82H12.7208V16.339C12.7208 15.286 13.5918 14.675 14.3588 14.233C15.0868 13.83 15.4378 13.635 15.4378 13.232C15.4378 12.894 15.2038 12.686 14.8268 12.686C14.3848 12.686 14.1248 13.024 14.1118 13.427H12.7468C12.8248 12.426 13.5528 11.633 14.8398 11.633C15.9448 11.633 16.7768 12.257 16.7768 13.258Z",fill:"currentColor"})});var Or=[U([{ChildComponent:Dr,isActive:({selection:t})=>Os(t)?t.hasFormat("subscript"):!1,key:"subscript",onSelect:({editor:t})=>{t.dispatchCommand(Ps,"subscript")},order:5}])],$s=y({toolbarFixed:{groups:Or},toolbarInline:{groups:Or}});import{$isRangeSelection as Hs,FORMAT_TEXT_COMMAND as Bs}from"lexical";import{jsx as Pr}from"react/jsx-runtime";import"react";var $r=()=>Pr("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Pr("path",{d:"M10.167 15L7.45002 11.36L4.73302 15H2.91302L6.55302 10.177L3.23802 5.718H5.20102L7.54102 8.89L9.89402 5.718H11.714L8.43802 10.06L12.13 15H10.167ZM16.7768 7.252C16.7768 8.149 16.1398 8.526 15.2038 8.994C14.5538 9.319 14.2808 9.54 14.2418 9.774H16.7898V10.814H12.7208V10.333C12.7208 9.28 13.5918 8.669 14.3588 8.227C15.0868 7.824 15.4378 7.629 15.4378 7.226C15.4378 6.888 15.2038 6.68 14.8268 6.68C14.3848 6.68 14.1248 7.018 14.1118 7.421H12.7468C12.8248 6.42 13.5528 5.627 14.8398 5.627C15.9448 5.627 16.7768 6.251 16.7768 7.252Z",fill:"currentColor"})});var Hr=[U([{ChildComponent:$r,isActive:({selection:t})=>Hs(t)?t.hasFormat("superscript"):!1,key:"superscript",onSelect:({editor:t})=>{t.dispatchCommand(Bs,"superscript")},order:6}])],js=y({toolbarFixed:{groups:Hr},toolbarInline:{groups:Hr}});import{$isRangeSelection as Us,FORMAT_TEXT_COMMAND as Ws}from"lexical";import{jsx as Br,jsxs as Gs}from"react/jsx-runtime";import"react";var jr=()=>Gs("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Br("path",{d:"M13.9656 11.256C13.9656 13.791 12.5096 15.156 10.0006 15.156C7.50461 15.156 6.03561 13.791 6.03561 11.23V5.718H7.76461V11.243C7.76461 12.868 8.50561 13.778 10.0006 13.778C11.4956 13.778 12.2496 12.868 12.2496 11.243V5.718H13.9656V11.256Z",fill:"currentColor"}),Br("path",{d:"M5.09961 16.3H14.9016V16.95H5.09961V16.3Z",fill:"currentColor"})]});var Gr=[U([{ChildComponent:jr,isActive:({selection:t})=>Us(t)?t.hasFormat("underline"):!1,key:"underline",onSelect:({editor:t})=>{t.dispatchCommand(Ws,"underline")},order:3}])],Vs=y({toolbarFixed:{groups:Gr},toolbarInline:{groups:Gr}});import{$createHeadingNode as Ys,$isHeadingNode as on,HeadingNode as Xs}from"@lexical/rich-text";import{$setBlocksType as Js}from"@lexical/selection";import{$getSelection as qs,$isRangeSelection as Qs}from"lexical";import{jsx as Ur}from"react/jsx-runtime";import"react";var Wr=()=>Ur("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Ur("path",{d:"M4.639 13.5V7.074H6.196V9.648H9.076V7.074H10.642V13.5H9.076V10.836H6.196V13.5H4.639ZM11.5656 9.045V8.019C12.6636 8.019 13.1316 7.731 13.2846 7.065H14.4006V13.5H12.8436V9.045H11.5656Z",fill:"currentColor"})});import{jsx as Vr}from"react/jsx-runtime";import"react";var zr=()=>Vr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Vr("path",{d:"M4.139 13.5V7.074H5.696V9.648H8.576V7.074H10.142V13.5H8.576V10.836H5.696V13.5H4.139ZM15.9796 8.973C15.9796 10.116 15.1696 10.656 14.0356 11.232C13.2256 11.646 12.8206 11.943 12.7846 12.294H15.9886V13.5H11.0566V12.951C11.0566 11.601 12.1636 10.845 13.1176 10.287C14.0356 9.756 14.5126 9.486 14.5126 8.946C14.5126 8.46 14.2156 8.145 13.6306 8.145C13.0186 8.145 12.6586 8.613 12.6226 9.198H11.1196C11.2186 7.947 12.1006 6.966 13.6396 6.966C15.0346 6.966 15.9796 7.785 15.9796 8.973Z",fill:"currentColor"})});import{jsx as Kr}from"react/jsx-runtime";import"react";var Zr=()=>Kr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Kr("path",{d:"M4.139 13.5V7.074H5.696V9.648H8.576V7.074H10.142V13.5H8.576V10.836H5.696V13.5H4.139ZM16.1146 11.745C16.1146 12.744 15.2236 13.608 13.6126 13.608C12.0736 13.608 11.0926 12.762 10.9846 11.547H12.4696C12.5146 12.114 13.0006 12.456 13.6126 12.456C14.2876 12.456 14.6746 12.132 14.6746 11.619C14.6746 11.061 14.2426 10.836 13.6216 10.836H12.9826V9.738H13.6036C14.1526 9.738 14.5486 9.486 14.5486 8.937C14.5486 8.46 14.2156 8.127 13.6486 8.127C13.0366 8.127 12.6586 8.514 12.6226 9.045H11.1916C11.2726 7.929 12.1276 6.966 13.6666 6.966C15.1876 6.966 15.9706 7.848 15.9706 8.865C15.9706 9.603 15.5026 10.143 14.8186 10.269C15.6196 10.404 16.1146 10.971 16.1146 11.745Z",fill:"currentColor"})});import{jsx as Yr}from"react/jsx-runtime";import"react";var Xr=()=>Yr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Yr("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM15.1736 7.074V10.854H16.3706V12.033H15.1736V13.5H13.6796V12.033H10.5116V10.845L13.4996 7.074H15.1736ZM13.6796 8.46L11.8256 10.854H13.6796V8.46Z",fill:"currentColor"})});import{jsx as Jr}from"react/jsx-runtime";import"react";var qr=()=>Jr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Jr("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM13.1576 10.269C12.6896 10.269 12.3746 10.494 12.2216 10.737H10.8176L11.1956 7.074H15.2546V8.28H12.3206L12.1856 9.549C12.4016 9.351 12.8516 9.126 13.4636 9.126C14.7866 9.126 15.6596 10.053 15.6596 11.358C15.6596 12.609 14.7326 13.608 13.1756 13.608C11.5826 13.608 10.6556 12.753 10.5566 11.511H12.1136C12.1586 12.06 12.5456 12.465 13.1576 12.465C13.8236 12.465 14.1746 11.97 14.1746 11.376C14.1746 10.764 13.8416 10.269 13.1576 10.269Z",fill:"currentColor"})});import{jsx as Qr}from"react/jsx-runtime";import"react";var en=()=>Qr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Qr("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM13.3646 8.127C12.5456 8.127 12.0416 8.937 12.0416 9.999C12.3296 9.54 12.8246 9.207 13.5536 9.207C14.8586 9.207 15.8036 10.134 15.8036 11.376C15.8036 12.645 14.8226 13.608 13.3196 13.608C11.7266 13.608 10.6196 12.393 10.6196 10.395C10.6196 8.316 11.7716 6.966 13.4186 6.966C14.7056 6.966 15.5786 7.749 15.7316 8.829H14.3186C14.2016 8.415 13.9226 8.127 13.3646 8.127ZM13.3106 12.51C13.9586 12.51 14.3816 12.042 14.3816 11.385C14.3816 10.737 13.9586 10.278 13.3106 10.278C12.6536 10.278 12.2126 10.737 12.2126 11.385C12.2126 12.042 12.6536 12.51 13.3106 12.51Z",fill:"currentColor"})});import{$createHeadingNode as zs,$isHeadingNode as Ks,HeadingNode as Zs}from"@lexical/rich-text";var Xt=t=>(e,o,n)=>{let r=t(n);r&&(r.append(...o),e.replace(r),r.select(0,0))};var tn=t=>{let o=`^(${t.map(r=>Number(r.slice(1))).map(r=>`#{${r}}`).join("|")})\\s`,n=new RegExp(o);return{type:"element",dependencies:[Zs],export:(r,i)=>{if(!Ks(r))return null;let l=Number(r.getTag().slice(1));return"#".repeat(l)+" "+i(r)},regExp:n,replace:Xt(r=>{let i="h"+r[1].length;return zs(i)})}};var rn=t=>{let e=qs();Js(e,()=>Ys(t))},nn={h1:Wr,h2:zr,h3:Zr,h4:Xr,h5:qr,h6:en},ea=y(({props:t})=>{let{enabledHeadingSizes:e=["h1","h2","h3","h4","h5","h6"]}=t,o=[V(e.map((n,r)=>({ChildComponent:nn[n],isActive:({selection:i})=>{if(!Qs(i))return!1;for(let l of i.getNodes()){if(on(l)&&l.getTag()===n)continue;let s=l.getParent();if(!(on(s)&&s.getTag()===n))return!1}return!0},key:n,label:({i18n:i})=>i.t("lexical:heading:label",{headingLevel:n.charAt(1)}),onSelect:({editor:i})=>{i.update(()=>{rn(n)})},order:r+2})))];return{markdownTransformers:[tn(e)],nodes:[Xs],sanitizedClientFeatureProps:t,slashMenu:{groups:e?.length?[G(e.map(n=>({Icon:nn[n],key:`heading-${n.charAt(1)}`,keywords:["heading",n],label:({i18n:r})=>r.t("lexical:heading:label",{headingLevel:n.charAt(1)}),onSelect:({editor:r})=>{r.update(()=>{rn(n)})}})))]:[]},toolbarFixed:{groups:e?.length?o:[]},toolbarInline:{groups:e?.length?o:[]}}});import{$isNodeSelection as ca}from"lexical";import{jsx as ln}from"react/jsx-runtime";import"react";var Jt=()=>ln("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:ln("rect",{fill:"currentColor",height:"1",width:"12",x:"4",y:"9.5"})});import{jsx as sn,jsxs as ta}from"react/jsx-runtime";import"react";var an=()=>ta("svg",{fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[sn("path",{d:"M5 10h10",stroke:"currentColor"}),sn("path",{d:"M10 15V5",stroke:"currentColor"})]});var q=t=>({type:"dropdown",ChildComponent:an,items:t,key:"add",order:10});var cn={type:"element",dependencies:[Ye],export:(t,e)=>Je(t)?"---":null,regExp:/^---\s*$/,replace:t=>{let e=Xe();e&&t.replace(e)}};import{c as oa}from"react/compiler-runtime";import{useLexicalComposerContext as ra}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as na}from"@lexical/utils";import{$getSelection as ia,$isRangeSelection as la,COMMAND_PRIORITY_EDITOR as sa}from"lexical";import{useEffect as aa}from"react";var un=()=>{let t=oa(3),[e]=ra(),o,n;return t[0]!==e?(o=()=>e.registerCommand(Ie,r=>{let i=ia();if(!la(i))return!1;if(i.focus.getNode()!==null){let s=Xe();na(s)}return!0},sa),n=[e],t[0]=e,t[1]=o,t[2]=n):(o=t[1],n=t[2]),aa(o,n),null};var ua=y({markdownTransformers:[cn],nodes:[Ye],plugins:[{Component:un,position:"normal"}],slashMenu:{groups:[G([{Icon:Jt,key:"horizontalRule",keywords:["hr","horizontal rule","line","separator"],label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ie,void 0)}}])]},toolbarFixed:{groups:[q([{ChildComponent:Jt,isActive:({selection:t})=>{if(!ca(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return Je(e)},key:"horizontalRule",label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ie,void 0)}}])]}});import{INDENT_CONTENT_COMMAND as fa,OUTDENT_CONTENT_COMMAND as pa}from"lexical";import{jsx as st,jsxs as da}from"react/jsx-runtime";import"react";var dn=()=>da("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[st("path",{d:"M2.5 5H10.5",stroke:"currentColor",strokeWidth:"1.5"}),st("path",{d:"M2.5 10H10.5",stroke:"currentColor",strokeWidth:"1.5"}),st("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"}),st("path",{d:"M12.25 7.25L17.25 3.75V10.75L12.25 7.25Z",fill:"currentColor"})]});import{jsx as at,jsxs as ma}from"react/jsx-runtime";import"react";var mn=()=>ma("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[at("path",{d:"M17.5 5H9.5",stroke:"currentColor",strokeWidth:"1.5"}),at("path",{d:"M17.5 10H9.5",stroke:"currentColor",strokeWidth:"1.5"}),at("path",{d:"M17.5 15H2.5",stroke:"currentColor",strokeWidth:"1.5"}),at("path",{d:"M7.75 7.25L2.75 3.75V10.75L7.75 7.25Z",fill:"currentColor"})]});var fn=t=>({type:"buttons",items:t,key:"indent",order:35});var pn=[fn([{ChildComponent:dn,isActive:()=>!1,isEnabled:({selection:t})=>{if(!t||!t?.getNodes()?.length)return!1;for(let e of t.getNodes()){let o=e.getParentOrThrow();if("__indent"in e&&e.__indent>0||"__indent"in o&&o.__indent>0)return!0}return!1},key:"indentDecrease",label:({i18n:t})=>t.t("lexical:indent:decreaseLabel"),onSelect:({editor:t})=>{t.dispatchCommand(pa,void 0)},order:1},{ChildComponent:mn,isActive:()=>!1,key:"indentIncrease",label:({i18n:t})=>t.t("lexical:indent:increaseLabel"),onSelect:({editor:t})=>{t.dispatchCommand(fa,void 0)},order:2}])],ha=y({toolbarFixed:{groups:pn},toolbarInline:{groups:pn}});import{$findMatchingParent as kc}from"@lexical/utils";import{$getSelection as io,$isRangeSelection as Wn}from"lexical";import{jsx as hn}from"react/jsx-runtime";import"react";var gn=()=>hn("svg",{"aria-hidden":"true",className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:hn("path",{d:"M8.5 11.5L11.5 8.5M8.5 7L9.625 5.875C10.868 4.633 12.882 4.633 14.125 5.875C15.368 7.118 15.368 9.133 14.125 10.375L13 11.5M7 8.5L5.746 9.754C4.56 10.94 4.519 12.85 5.652 14.087C6.814 15.354 8.78 15.449 10.058 14.298L11.5 13",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})});import{$isAtNodeEnd as Cn}from"@lexical/selection";function he(t){let{anchor:e}=t,{focus:o}=t,n=t.anchor.getNode(),r=t.focus.getNode();return n===r?n:t.isBackward()?Cn(o)?n:r:Cn(e)?n:r}var qt=t=>({type:"buttons",items:t,key:"features",order:50});import{$createTextNode as La,$isTextNode as Ia}from"lexical";import{addClassNamesToElement as ga,isHTMLAnchorElement as Ca}from"@lexical/utils";import to from"bson-objectid";import{$applyNodeReplacement as xa,$createTextNode as xn,$getSelection as ba,$isElementNode as bn,$isRangeSelection as eo,createCommand as _a,ElementNode as Ta}from"lexical";var Ea=new Set(["http:","https:","mailto:","sms:","tel:"]),z=class t extends Ta{__fields;__id;constructor({id:e,fields:o={doc:null,linkType:"custom",newTab:!1,url:""},key:n}){super(n),this.__fields=o,this.__id=e}static clone(e){return new t({id:e.__id,fields:e.__fields,key:e.__key})}static getType(){return"link"}static importDOM(){return{a:e=>({conversion:wa,priority:1})}}static importJSON(e){e.version===1&&typeof e.fields?.doc?.value=="object"&&e.fields?.doc?.value?.id&&(e.fields.doc.value=e.fields.doc.value.id,e.version=2),e.version===2&&!e.id&&(e.id=new to.default().toHexString(),e.version=3);let o=Q({id:e.id,fields:e.fields});return o.setFormat(e.format),o.setIndent(e.indent),o.setDirection(e.direction),o}canBeEmpty(){return!1}canInsertTextAfter(){return!1}canInsertTextBefore(){return!1}createDOM(e){let o=document.createElement("a");return this.__fields?.linkType==="custom"&&(o.href=this.sanitizeUrl(this.__fields.url??"")),(this.__fields?.newTab??!1)&&(o.target="_blank"),this.__fields?.newTab===!0&&this.__fields?.linkType==="custom"&&(o.rel=Qt(o.rel,"add","noopener")),ga(o,e.theme.link),o}exportJSON(){let e={...super.exportJSON(),type:"link",fields:this.getFields(),version:3},o=this.getID();return o&&(e.id=o),e}extractWithChild(e,o,n){if(!eo(o))return!1;let r=o.anchor.getNode(),i=o.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&o.getTextContent().length>0}getFields(){return this.getLatest().__fields}getID(){return this.getLatest().__id}insertNewAfter(e,o=!0){let n=this.getParentOrThrow().insertNewAfter(e,o);if(bn(n)){let r=Q({fields:this.__fields});return n.append(r),r}return null}isInline(){return!0}sanitizeUrl(e){try{let o=new URL(e);if(!Ea.has(o.protocol))return"about:blank"}catch{return"https://"}return e}setFields(e){let o=this.getWritable();o.__fields=e}updateDOM(e,o,n){let r=this.__fields?.url,i=this.__fields?.newTab;return r!=null&&r!==e.__fields?.url&&this.__fields?.linkType==="custom"&&(o.href=r),this.__fields?.linkType==="internal"&&e.__fields?.linkType==="custom"&&o.removeAttribute("href"),o.rel==null&&(o.rel=""),i!==e.__fields?.newTab&&(i??!1?(o.target="_blank",this.__fields?.linkType==="custom"&&(o.rel=Qt(o.rel,"add","noopener"))):(o.removeAttribute("target"),o.rel=Qt(o.rel,"remove","noopener"))),!1}};function wa(t){let e=null;if(Ca(t)){let o=t.textContent;o!==null&&o!==""&&(e=Q({id:new to.default().toHexString(),fields:{doc:null,linkType:"custom",newTab:t.getAttribute("target")==="_blank",url:t.getAttribute("href")??""}}))}return{node:e}}function Q({id:t,fields:e}){return xa(new z({id:t??new to.default().toHexString(),fields:e}))}function j(t){return t instanceof z}var X=_a("TOGGLE_LINK_COMMAND");function _n(t){let e=ba();if(!eo(e)&&!t.selectedNodes?.length)return;let o=eo(e)?e.extract():t.selectedNodes;if(t===null)o?.forEach(n=>{let r=n.getParent();if(j(r)){let i=r.getChildren();for(let l=0;l<i.length;l+=1)r.insertBefore(i[l]);r.remove()}});else{if(o?.length===1){let i=o[0],l=j(i)?i:Na(i);if(l!==null){l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(xn(t.text)),l.getChildren().forEach(s=>{s!==l.getLastChild()&&s.remove()}));return}}let n=null,r=null;o?.forEach(i=>{let l=i.getParent();if(!(l===r||l===null||bn(i)&&!i.isInline())){if(j(l)){r=l,l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(xn(t.text)),l.getChildren().forEach(s=>{s!==l.getLastChild()&&s.remove()}));return}if(l.is(n)||(n=l,r=Q({fields:t.fields}),j(l)?i.getPreviousSibling()===null?l.insertBefore(r):l.insertAfter(r):i.insertBefore(r)),j(i)){if(i.is(r))return;if(r!==null){let s=i.getChildren();for(let a=0;a<s.length;a+=1)r.append(s[a])}i.remove();return}r!==null&&r.append(i)}})}}function Na(t){return ka(t,e=>j(e))}function ka(t,e){let o=t;for(;o!==null&&(o=o.getParent(),!(o===null||e(o))););return o}function Qt(t,e,o){let n,r=`${t}`;if(e==="add"){if(r.includes(o)){let i=new RegExp(o,"g");r=r.replace(i,"").trim()}r=r.trim(),n=r.length===0?`${o}`:`${r} ${o}`}else{let i=new RegExp(o,"g");n=r.replace(i,"").trim()}return n}var Tn={type:"text-match",dependencies:[z],export:(t,e,o)=>{if(!j(t))return null;let n=t,{url:r}=n.getFields(),i=`[${n.getTextContent()}](${r})`,l=n.getFirstChild();return n.getChildrenSize()===1&&Ia(l)?o(l,i):i},importRegExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)/,regExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)$/,replace:(t,e)=>{let[,o,n]=e,r=Q({fields:{doc:null,linkType:"custom",newTab:!1,url:n}}),i=La(o);i.setFormat(t.getFormat()),r.append(i),t.replace(r)},trigger:")"};import{$applyNodeReplacement as Ra,$isElementNode as Sa}from"lexical";var ee=class t extends z{static clone(e){return new t({id:"",fields:e.__fields,key:e.__key})}static getType(){return"autolink"}static importDOM(){return null}static importJSON(e){e.version===1&&typeof e.fields?.doc?.value=="object"&&e.fields?.doc?.value?.id&&(e.fields.doc.value=e.fields.doc.value.id,e.version=2);let o=Pe({fields:e.fields});return o.setFormat(e.format),o.setIndent(e.indent),o.setDirection(e.direction),o}exportJSON(){let e=super.exportJSON();return{type:"autolink",children:e.children,direction:e.direction,fields:e.fields,format:e.format,indent:e.indent,version:2}}insertNewAfter(e,o=!0){let n=this.getParentOrThrow().insertNewAfter(e,o);if(Sa(n)){let r=Pe({fields:this.__fields});return n.append(r),r}return null}};function Pe({fields:t}){return Ra(new ee({id:"",fields:t}))}function te(t){return t instanceof ee}import{c as ya}from"react/compiler-runtime";import{useLexicalComposerContext as Ma}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as va}from"@lexical/utils";import{$createTextNode as En,$getSelection as Aa,$isElementNode as Nn,$isLineBreakNode as kn,$isNodeSelection as Fa,$isRangeSelection as Da,$isTextNode as $e,TextNode as Oa}from"lexical";import{useEffect as Pa}from"react";function wn(t,e=o=>o){return o=>{let n=t.exec(o);return n===null?null:{index:n.index,length:n[0].length,text:n[0],url:e(n[0])}}}function Ln(t,e){for(let o=0;o<e.length;o++){let n=e[o](t);if(n!=null)return n}return null}var $a=/[.,;\s]/;function ut(t){return $a.test(t)}function In(t){return ut(t[t.length-1])}function ro(t){return ut(t[0])}function Ha(t,e){return e?/^\.[a-z]{2,}/i.test(t):/^\.[a-z0-9]+/i.test(t)}function Rn(t){let e=t.getPreviousSibling();return Nn(e)&&(e=e.getLastDescendant()),e===null||kn(e)||$e(e)&&In(e.getTextContent())}function Sn(t){let e=t.getNextSibling();return Nn(e)&&(e=e.getFirstDescendant()),e===null||kn(e)||$e(e)&&ro(e.getTextContent())}function Ba(t,e,o,n){return(t>0?ut(o[t-1]):Rn(n[0]))?e<o.length?ut(o[e]):Sn(n[n.length-1]):!1}function ja(t,e,o){let n=[],r=[],i=[],l=0,s=0,a=[...t];for(;a.length>0;){let c=a[0],d=c.getTextContent().length,m=s;s+d<=e?(n.push(c),l+=d):m>=o?i.push(c):r.push(c),s+=d,a.shift()}return[l,n,r,i]}function Ga(t,e,o,n){let r={linkType:"custom",url:n.url,...n.fields},i=Pe({fields:r});if(t.length===1){let l=t[0],s;e===0?[s,l]=l.splitText(o):[,s,l]=l.splitText(e,o);let a=En(n.text);return a.setFormat(s.getFormat()),a.setDetail(s.getDetail()),a.setStyle(s.getStyle()),i.append(a),s.replace(i),l}else if(t.length>1){let l=t[0],s=l.getTextContent().length,a;e===0?a=l:[,a]=l.splitText(e);let c=[],u;for(let p=1;p<t.length;p++){let h=t[p],C=h.getTextContent().length,v=s,M=s+C;if(v<o)if(M<=o)c.push(h);else{let[_,E]=h.splitText(o-v);c.push(_),u=E}s+=C}let d=Aa(),m=d?d.getNodes().find($e):void 0,f=En(a.getTextContent());return f.setFormat(a.getFormat()),f.setDetail(a.getDetail()),f.setStyle(a.getStyle()),i.append(f,...c),m&&m===a&&(Da(d)?f.select(d.anchor.offset,d.focus.offset):Fa(d)&&f.select(0,f.getTextContent().length)),a.replace(i),u}}function Ua(t,e,o){let n=[...t],r=n.map(a=>a.getTextContent()).join(""),i=r,l,s=0;for(;(l=Ln(i,e))!=null&&l!==null;){let a=l.index,c=l.length,u=a+c;if(Ba(s+a,s+u,r,n)){let[m,,f,p]=ja(n,s+a,s+u),h=s+a-m,b=s+u-m,C=Ga(f,h,b,l);n=C?[C,...p]:p,o(l.url,null),s=0}else s+=u;i=i.substring(u)}}function oo(t,e,o){let n=t.getChildren(),r=n.length;for(let a=0;a<r;a++){let c=n[a];if(!$e(c)||!c.isSimpleText()){ct(t),o(null,t.getFields()?.url??null);return}}let i=t.getTextContent(),l=Ln(i,e);if(l===null||l.text!==i){ct(t),o(null,t.getFields()?.url??null);return}if(!Rn(t)||!Sn(t)){ct(t),o(null,t.getFields()?.url??null);return}let s=t.getFields()?.url;if(s!==l?.url){let a=t.getFields();a.url=l?.url,t.setFields(a),o(l.url,s??null)}}function Wa(t,e,o){let n=t.getPreviousSibling(),r=t.getNextSibling(),i=t.getTextContent();if(te(n)){let l=n.getFields()?.url?n.getFields()?.url?.startsWith("mailto:"):!1;(!ro(i)||Ha(i,l))&&(n.append(t),oo(n,e,o),o(null,n.getFields()?.url??null))}te(r)&&!In(i)&&(ct(r),oo(r,e,o),o(null,r.getFields()?.url??null))}function ct(t){let e=t.getChildren(),o=e.length;for(let n=o-1;n>=0;n--)t.insertAfter(e[n]);return t.remove(),e.map(n=>n.getLatest())}function Va(t){let e=[t],o=t.getNextSibling();for(;o!==null&&$e(o)&&o.isSimpleText()&&(e.push(o),!/\s/.test(o.getTextContent()));)o=o.getNextSibling();return e}function za(t,e,o){let n=ya(5),r,i;n[0]!==t||n[1]!==o||n[2]!==e?(r=()=>{if(!t.hasNodes([ee]))throw new Error("LexicalAutoLinkPlugin: AutoLinkNode not registered on editor");let l=(s,a)=>{o?.(s,a)};return va(t.registerNodeTransform(Oa,s=>{let a=s.getParentOrThrow(),c=s.getPreviousSibling();if(te(a))oo(a,e,l);else if(!j(a)){if(s.isSimpleText()&&(ro(s.getTextContent())||!te(c))){let u=Va(s);Ua(u,e,l)}Wa(s,e,l)}}))},i=[t,e,o],n[0]=t,n[1]=o,n[2]=e,n[3]=r,n[4]=i):(r=n[3],i=n[4]),Pa(r,i)}var Ka=/((https?:\/\/(www\.)?)|(www\.))[-\w@:%.+~#=]{1,256}\.[a-zA-Z\d()]{1,6}\b([-\w()@:%+.~#?&/=]*)(?<![-.+():%])/,Za=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-z\-\d]+\.)+[a-z]{2,}))/i,Ya=[wn(Ka,t=>t.startsWith("http")?t:`https://${t}`),wn(Za,t=>`mailto:${t}`)],yn=()=>{let[t]=Ma();return za(t,Ya),null};import{jsx as Xa}from"react/jsx-runtime";import{ClickableLinkPlugin as Ja}from"@lexical/react/LexicalClickableLinkPlugin.js";import"react";var Mn=()=>Xa(Ja,{});import{jsx as fc}from"react/jsx-runtime";import"react";import{createPortal as pc}from"react-dom";import{jsx as le,jsxs as no}from"react/jsx-runtime";import{useLexicalComposerContext as Qa}from"@lexical/react/LexicalComposerContext.js";import{$findMatchingParent as vn,mergeRegister as An}from"@lexical/utils";import{getTranslation as ec}from"@payloadcms/translations";import{CloseMenuIcon as tc,EditIcon as oc,formatDrawerSlug as rc,useConfig as nc,useEditDepth as ic,useModal as lc,useTranslation as sc}from"@payloadcms/ui";import{$getSelection as Fn,$isLineBreakNode as ac,$isRangeSelection as Dn,COMMAND_PRIORITY_HIGH as cc,COMMAND_PRIORITY_LOW as On,KEY_ESCAPE_COMMAND as uc,SELECTION_CHANGE_COMMAND as dc}from"lexical";import Pn,{useCallback as $n,useEffect as ft,useRef as mc,useState as ge}from"react";function dt(t,e,o,n=10,r=5){let i=o.parentElement;if(t===null||i==null){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let l=e.getBoundingClientRect(),s=o.getBoundingClientRect(),a=i.getBoundingClientRect(),c=t.top-n,u=t.left-r;c<a.top&&(c+=l.height+t.height+n*2),u+l.width>a.right&&(u=a.right-l.width-r),c-=s.top,u-=s.left,e.style.opacity="1",e.style.transform=`translate(${u}px, ${c}px)`}import{createCommand as qa}from"lexical";var mt=qa("TOGGLE_LINK_WITH_MODAL_COMMAND");function Hn({anchorElem:t}){let[e]=Qa(),o=mc(null),[n,r]=ge(null),[i,l]=ge(null),{uuid:s}=H(),{config:a}=nc(),{i18n:c,t:u}=sc(),[d,m]=ge(),{closeModal:f,toggleModal:p}=lc(),h=ic(),[b,C]=ge(!1),[v,M]=ge([]),[_,E]=ge(!1),T=rc({slug:"lexical-rich-text-link-"+s,depth:h}),I=$n(()=>{C(!1),o&&o.current&&(o.current.style.opacity="0",o.current.style.transform="translate(-10000px, -10000px)"),E(!1),r(null),l(null),M([]),m(void 0)},[C,r,l,M]),S=$n(()=>{let x=Fn(),N;if(!Dn(x)||!x){I();return}let L=he(x);N=e.getElementByKey(L.getKey())?.getBoundingClientRect();let g=vn(L,j),w=x.getNodes().filter(B=>!ac(B)).find(B=>{let P=vn(B,j);return g&&!g.is(P)||P&&!P.is(g)});if(g==null||w){I();return}let k={...g.getFields(),id:g.getID(),text:g.getTextContent()};if(g.getFields()?.linkType==="custom")r(g.getFields()?.url??null),l(null);else{r(`${a.routes.admin==="/"?"":a.routes.admin}/collections/${g.getFields()?.doc?.relationTo}/${g.getFields()?.doc?.value}`);let B=a.collections.find(P=>P.slug===g.getFields()?.doc?.relationTo);if(!B)l(g.getFields()?.label?String(g.getFields()?.label):null),r(g.getFields()?.url?String(g.getFields()?.url):null);else{let P=u("fields:linkedTo",{label:ec(B.labels.singular,c)}).replace(/<[^>]*>?/g,"");l(P)}}m(k),C(!0),M(x?x?.getNodes():[]),te(g)?E(!0):E(!1);let R=o.current,A=window.getSelection(),{activeElement:O}=document;if(R===null)return;let D=e.getRootElement();return A!==null&&D!==null&&D.contains(A.anchorNode)?(N||(N=A.getRangeAt(0).getBoundingClientRect()),N!=null&&(N.y+=40,dt(N,R,t))):(O==null||O.className!=="link-input")&&(D!==null&&dt(null,R,t),r(null),l(null)),!0},[e,I,a.collections,u,c,t]);return ft(()=>An(e.registerCommand(mt,x=>(e.dispatchCommand(X,x),S(),p(T),!0),On)),[e,S,p,T]),ft(()=>{let x=t.parentElement,N=()=>{e.getEditorState().read(()=>{S()})};return window.addEventListener("resize",N),x?.addEventListener("scroll",N),()=>{window.removeEventListener("resize",N),x?.removeEventListener("scroll",N)}},[t.parentElement,e,S]),ft(()=>An(e.registerUpdateListener(({editorState:x})=>{x.read(()=>{S()})}),e.registerCommand(dc,()=>(S(),!0),On),e.registerCommand(uc,()=>b?(I(),!0):!1,cc)),[e,S,b,I]),ft(()=>{e.getEditorState().read(()=>{S()})},[e,S]),no(Pn.Fragment,{children:[le("div",{className:"link-editor",ref:o,children:no("div",{className:"link-input",children:[n&&n.length>0?le("a",{href:n,rel:"noopener noreferrer",target:"_blank",children:i!=null&&i.length>0?i:n}):i!=null&&i.length>0?le("span",{className:"link-input__label-pure",children:i}):null,e.isEditable()&&no(Pn.Fragment,{children:[le("button",{"aria-label":"Edit link",className:"link-edit",onClick:()=>{p(T)},onMouseDown:x=>{x.preventDefault()},tabIndex:0,type:"button",children:le(oc,{})}),!_&&le("button",{"aria-label":"Remove link",className:"link-trash",onClick:()=>{e.dispatchCommand(X,null)},onMouseDown:x=>{x.preventDefault()},tabIndex:0,type:"button",children:le(tc,{})})]})]})}),le(ce,{className:"lexical-link-edit-drawer",data:d,drawerSlug:T,drawerTitle:u("fields:editLink"),featureKey:"link",handleDrawerSubmit:(x,N)=>{f(T);let L=N,g={...L};delete g.text,e.update(()=>{let w=Fn(),k=null;if(Dn(w)?k=he(w).getParent():v.length&&(k=v[0].getParent()),k&&te(k)){let R=Q({fields:g});k.replace(R,!0)}}),e.dispatchCommand(X,{fields:g,selectedNodes:v,text:L.text})},schemaPathSuffix:"fields"})]})}var Bn=t=>{let{anchorElem:e=document.body}=t;return pc(fc(Hn,{anchorElem:e}),e)};import{c as Cc}from"react/compiler-runtime";import{useLexicalComposerContext as xc}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as bc}from"@lexical/utils";import{$getSelection as _c,$isElementNode as Tc,$isRangeSelection as Ec,COMMAND_PRIORITY_LOW as Gn,PASTE_COMMAND as wc}from"lexical";import{useEffect as Nc}from"react";var hc=/(?:[A-Za-z]{3,9}:(?:\/\/)?(?:[-;:&=+$,\w]+@)?[A-Za-z\d.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z\d.-]+)(?:\/[+~%/.\w-]*)?\??[-+=&;%@.\w]*#?\w*/,gc=/^[\w\-./]*(?:#\w[\w-]*)?$/;function jn(t){if(!t)return!1;if(t==="https://"||hc.test(t)||gc.test(t))return!0;try{return new URL(t),!0}catch{}return!1}var Un=()=>{let t=Cc(3),[e]=xc(),o,n;return t[0]!==e?(o=()=>{if(!e.hasNodes([z]))throw new Error("LinkPlugin: LinkNode not registered on editor");return bc(e.registerCommand(X,r=>(_n(r),!0),Gn),e.registerCommand(wc,r=>{let i=_c();if(!Ec(i)||i.isCollapsed()||!(r instanceof ClipboardEvent)||r.clipboardData==null)return!1;let l=r.clipboardData.getData("text");if(!jn(l))return!1;if(!i.getNodes().some(s=>Tc(s))){let s={doc:null,linkType:"custom",newTab:!1,url:l};return e.dispatchCommand(X,{fields:s,text:null}),r.preventDefault(),!0}return!1},Gn))},n=[e],t[0]=e,t[1]=o,t[2]=n):(o=t[1],n=t[2]),Nc(o,n),null};var Vn=[qt([{ChildComponent:gn,isActive:({selection:t})=>{if(Wn(t)){let e=he(t);return kc(e,j)!=null}return!1},isEnabled:({selection:t})=>!!(Wn(t)&&io()?.getTextContent()?.length),key:"link",label:({i18n:t})=>t.t("lexical:link:label"),onSelect:({editor:t,isActive:e})=>{if(e)t.dispatchCommand(X,null);else{let o,n=[];if(t.getEditorState().read(()=>{o=io()?.getTextContent(),n=io()?.getNodes()??[]}),!o?.length)return;let r={doc:null,linkType:"custom",newTab:!1,url:"https://"};t.dispatchCommand(mt,{fields:r,selectedNodes:n,text:o})}},order:1}])],Lc=y({markdownTransformers:[Tn],nodes:[z,ee],plugins:[{Component:Un,position:"normal"},{Component:yn,position:"normal"},{Component:Mn,position:"normal"},{Component:Bn,position:"floatingAnchorElem"}],toolbarFixed:{groups:Vn},toolbarInline:{groups:Vn}});import{$isListNode as ao,INSERT_CHECK_LIST_COMMAND as Jn,ListItemNode as $c,ListNode as Hc}from"@lexical/list";import{$isRangeSelection as Bc}from"lexical";import{jsx as zn,jsxs as Ic}from"react/jsx-runtime";import"react";var lo=()=>Ic("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[zn("rect",{height:"13",rx:"1.5",stroke:"currentColor",width:"13",x:"3.5",y:"3.5"}),zn("path",{d:"M7 10L9 12.5L13 7.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Rc}from"react/jsx-runtime";import{ListPlugin as Sc}from"@lexical/react/LexicalListPlugin.js";import"react";var Ce=()=>Rc(Sc,{});function xe(t){return{items:t,key:"lists",label:({i18n:e})=>e.t("lexical:general:slashMenuListGroupLabel")}}import{$isListNode as Ac,ListItemNode as Fc,ListNode as Dc}from"@lexical/list";import{$createListItemNode as yc,$createListNode as Mc,$isListItemNode as vc,$isListNode as so}from"@lexical/list";var Kn=4,be=t=>(e,o,n)=>{let r=e.getPreviousSibling(),i=e.getNextSibling(),l=yc(t==="check"?n[3]==="x":void 0);if(so(i)&&i.getListType()===t){let a=i.getFirstChild();a!==null?a.insertBefore(l):i.append(l),e.remove()}else if(so(r)&&r.getListType()===t)r.append(l),e.remove();else{let a=Mc(t,t==="number"?Number(n[2]):void 0);a.append(l),e.replace(a)}l.append(...o),l.select(0,0);let s=Math.floor(n[1].length/Kn);s&&l.setIndent(s)},me=(t,e,o)=>{let n=[],r=t.getChildren(),i=0;for(let l of r)if(vc(l)){if(l.getChildrenSize()===1){let u=l.getFirstChild();if(so(u)){n.push(me(u,e,o+1));continue}}let s=" ".repeat(o*Kn),a=t.getListType(),c=a==="number"?`${t.getStart()+i}. `:a==="check"?`- [${l.getChecked()?"x":" "}] `:"- ";n.push(s+c+e(l)),i++}return n.join(`
35
35
  `)};var Zn={type:"element",dependencies:[Dc,Fc],export:(t,e)=>Ac(t)?me(t,e,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:be("check")};import{jsx as Oc}from"react/jsx-runtime";import{CheckListPlugin as Pc}from"@lexical/react/LexicalCheckListPlugin.js";import"react";var Yn=()=>Oc(Pc,{});var Xn=[V([{ChildComponent:lo,isActive:({selection:t})=>{if(!Bc(t))return!1;for(let e of t.getNodes()){if(ao(e)&&e.getListType()==="check")continue;let o=e.getParent();if(ao(o)&&o.getListType()==="check")continue;let n=o?.getParent();if(!(ao(n)&&n.getListType()==="check"))return!1}return!0},key:"checklist",label:({i18n:t})=>t.t("lexical:checklist:label"),onSelect:({editor:t})=>{t.dispatchCommand(Jn,void 0)},order:12}])],jc=y(({featureProviderMap:t})=>{let e=[{Component:Yn,position:"normal"}];return!t.has("unorderedList")&&!t.has("orderedList")&&e.push({Component:Ce,position:"normal"}),{markdownTransformers:[Zn],nodes:t.has("unorderedList")||t.has("orderedList")?[]:[Hc,$c],plugins:e,slashMenu:{groups:[xe([{Icon:lo,key:"checklist",keywords:["check list","check","checklist","cl"],label:({i18n:o})=>o.t("lexical:checklist:label"),onSelect:({editor:o})=>{o.dispatchCommand(Jn,void 0)}}])]},toolbarFixed:{groups:Xn},toolbarInline:{groups:Xn}}});import{$isListNode as uo,INSERT_ORDERED_LIST_COMMAND as ei,ListItemNode as zc,ListNode as Kc}from"@lexical/list";import{$isRangeSelection as Zc}from"lexical";import{jsx as He,jsxs as Gc}from"react/jsx-runtime";import"react";var co=()=>Gc("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[He("path",{d:"M5.89284 12.479C5.89284 13.368 5.26284 13.788 4.38084 14.236C3.75084 14.558 3.43584 14.789 3.40784 15.062H5.89984V16H2.06384V15.573C2.06384 14.523 2.92484 13.935 3.66684 13.501C4.38084 13.088 4.75184 12.878 4.75184 12.458C4.75184 12.08 4.52084 11.835 4.06584 11.835C3.58984 11.835 3.30984 12.199 3.28184 12.654H2.11284C2.18984 11.681 2.87584 10.918 4.07284 10.918C5.15784 10.918 5.89284 11.555 5.89284 12.479Z",fill:"currentColor"}),He("path",{d:"M2.68608 4.535V3.737C3.54008 3.737 3.90408 3.513 4.02308 2.995H4.89108V8H3.68008L3.68008 4.535H2.68608Z",fill:"currentColor"}),He("path",{d:"M8 15L17 15",stroke:"currentColor",strokeWidth:"1.5"}),He("path",{d:"M8 10L17 10",stroke:"currentColor",strokeWidth:"1.5"}),He("path",{d:"M8 5L17 5",stroke:"currentColor",strokeWidth:"1.5"})]});import{$isListNode as Uc,ListItemNode as Wc,ListNode as Vc}from"@lexical/list";var qn={type:"element",dependencies:[Vc,Wc],export:(t,e)=>Uc(t)?me(t,e,0):null,regExp:/^(\s*)(\d+)\.\s/,replace:be("number")};var Qn=[V([{ChildComponent:co,isActive:({selection:t})=>{if(!Zc(t))return!1;for(let e of t.getNodes()){if(uo(e)&&e.getListType()==="number")continue;let o=e.getParent();if(uo(o)&&o.getListType()==="number")continue;let n=o?.getParent();if(!(uo(n)&&n.getListType()==="number"))return!1}return!0},key:"orderedList",label:({i18n:t})=>t.t("lexical:orderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(ei,void 0)},order:10}])],Yc=y(({featureProviderMap:t})=>({markdownTransformers:[qn],nodes:t.has("orderedList")?[]:[Kc,zc],plugins:t.has("orderedList")?[]:[{Component:Ce,position:"normal"}],slashMenu:{groups:[xe([{Icon:co,key:"orderedList",keywords:["ordered list","ol"],label:({i18n:e})=>e.t("lexical:orderedList:label"),onSelect:({editor:e})=>{e.dispatchCommand(ei,void 0)}}])]},toolbarFixed:{groups:Qn},toolbarInline:{groups:Qn}}));import{$isListNode as fo,INSERT_UNORDERED_LIST_COMMAND as ri,ListItemNode as eu,ListNode as tu}from"@lexical/list";import{$isRangeSelection as ou}from"lexical";import{jsx as _e,jsxs as Xc}from"react/jsx-runtime";import"react";var mo=()=>Xc("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[_e("circle",{cx:"4",cy:"5",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),_e("circle",{cx:"4",cy:"10",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),_e("circle",{cx:"4",cy:"15",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),_e("path",{d:"M17 5H7",stroke:"currentColor",strokeWidth:"1.5"}),_e("path",{d:"M17 10H7",stroke:"currentColor",strokeWidth:"1.5"}),_e("path",{d:"M17 15H7",stroke:"currentColor",strokeWidth:"1.5"})]});import{$isListNode as Jc,ListItemNode as qc,ListNode as Qc}from"@lexical/list";var ti={type:"element",dependencies:[Qc,qc],export:(t,e)=>Jc(t)?me(t,e,0):null,regExp:/^(\s*)[-*+]\s/,replace:be("bullet")};var oi=[V([{ChildComponent:mo,isActive:({selection:t})=>{if(!ou(t))return!1;for(let e of t.getNodes()){if(fo(e)&&e.getListType()==="bullet")continue;let o=e.getParent();if(fo(o)&&o.getListType()==="bullet")continue;let n=o?.getParent();if(!(fo(n)&&n.getListType()==="bullet"))return!1}return!0},key:"unorderedList",label:({i18n:t})=>t.t("lexical:unorderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(ri,void 0)},order:11}])],ru=y({markdownTransformers:[ti],nodes:[tu,eu],plugins:[{Component:Ce,position:"normal"}],slashMenu:{groups:[xe([{Icon:mo,key:"unorderedList",keywords:["unordered list","ul"],label:({i18n:t})=>t.t("lexical:unorderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(ri,void 0)}}])]},toolbarFixed:{groups:oi},toolbarInline:{groups:oi}});import{jsx as nu}from"react/jsx-runtime";import{addClassNamesToElement as iu}from"@lexical/utils";import{DecoratorNode as lu}from"lexical";import*as ni from"react";var su=ni.lazy(()=>import("./Component-MBLHTKDK.js").then(t=>({default:t.UnknownConvertedNodeComponent}))),Be=class t extends lu{__data;constructor({data:e,key:o}){super(o),this.__data=e}static clone(e){return new t({data:e.__data,key:e.__key})}static getType(){return"unknownConverted"}static importJSON(e){return au({data:e.data})}canInsertTextAfter(){return!0}canInsertTextBefore(){return!0}createDOM(e){let o=document.createElement("span");return iu(o,"unknownConverted"),o}decorate(){return nu(su,{data:this.__data})}exportJSON(){return{type:this.getType(),data:this.__data,version:1}}isInline(){return!0}updateDOM(e,o){return!1}};function au({data:t}){return new Be({data:t})}var cu=y(()=>({nodes:[Be]}));import{jsx as uu}from"react/jsx-runtime";import{addClassNamesToElement as du}from"@lexical/utils";import{DecoratorNode as mu}from"lexical";import*as ii from"react";var fu=ii.lazy(()=>import("./Component-DOSSWC76.js").then(t=>({default:t.UnknownConvertedNodeComponent}))),je=class t extends mu{__data;constructor({data:e,key:o}){super(o),this.__data=e}static clone(e){return new t({data:e.__data,key:e.__key})}static getType(){return"unknownConverted"}static importJSON(e){return pu({data:e.data})}canInsertTextAfter(){return!0}canInsertTextBefore(){return!0}createDOM(e){let o=document.createElement("span");return du(o,"unknownConverted"),o}decorate(){return uu(fu,{data:this.__data})}exportJSON(){return{type:this.getType(),data:this.__data,version:1}}isInline(){return!0}updateDOM(e,o){return!1}};function pu({data:t}){return new je({data:t})}var hu=y(()=>({nodes:[je]}));import{$setBlocksType as ai}from"@lexical/selection";import{$createParagraphNode as ci,$getSelection as ui,$isParagraphNode as li,$isRangeSelection as gu}from"lexical";var si=[V([{ChildComponent:Oe,isActive:({selection:t})=>{if(!gu(t))return!1;for(let e of t.getNodes())if(!li(e)&&!li(e.getParent()))return!1;return!0},key:"paragraph",label:({i18n:t})=>t.t("lexical:paragraph:label2"),onSelect:({editor:t})=>{t.update(()=>{let e=ui();ai(e,()=>ci())})},order:1}])],Cu=y({slashMenu:{groups:[G([{Icon:Oe,key:"paragraph",keywords:["normal","paragraph","p","text"],label:({i18n:t})=>t.t("lexical:paragraph:label"),onSelect:({editor:t})=>{t.update(()=>{let e=ui();ai(e,()=>ci())})}}])]},toolbarFixed:{groups:si},toolbarInline:{groups:si}});import{$isNodeSelection as Pu}from"lexical";import{jsx as Ge,jsxs as xu}from"react/jsx-runtime";import"react";var po=()=>xu("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Ge("g",{clipPath:"url(#clip0_4397_10817)",children:Ge("path",{d:"M7.75 12.25L15.25 4.75M15.25 4.75H11.5M15.25 4.75V8.5M13 11.5V13.75C13 14.5784 12.3284 15.25 11.5 15.25H6.25C5.42157 15.25 4.75 14.5784 4.75 13.75V8.5C4.75 7.67157 5.42157 7 6.25 7H8.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})}),Ge("defs",{children:Ge("clipPath",{id:"clip0_4397_10817",children:Ge("rect",{fill:"currentColor",height:"12",transform:"translate(4 4)",width:"12"})})})]});import{c as ku}from"react/compiler-runtime";import{jsx as Lu}from"react/jsx-runtime";import{useLexicalComposerContext as Iu}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Ru}from"@lexical/utils";import{useConfig as Su}from"@payloadcms/ui";import{$getPreviousSelection as yu,$getSelection as Mu,$isParagraphNode as hi,$isRangeSelection as vu,COMMAND_PRIORITY_EDITOR as Au,createCommand as Fu}from"lexical";import{useEffect as Du}from"react";import{c as bu}from"react/compiler-runtime";import{jsx as pt}from"react/jsx-runtime";import{useLexicalComposerContext as _u}from"@lexical/react/LexicalComposerContext.js";import{useListDrawer as Tu}from"@payloadcms/ui";import{$getNodeByKey as Eu,COMMAND_PRIORITY_EDITOR as wu}from"lexical";import{useEffect as di,useState as mi}from"react";var Nu=({editor:t,relationTo:e,replaceNodeKey:o,value:n})=>{o?t.update(()=>{let r=Eu(o);r&&r.replace(ye({relationTo:e,value:n}))}):t.dispatchCommand(ho,{relationTo:e,value:n})},fi=t=>{let e=bu(21),{enabledCollectionSlugs:o}=t,[n]=_u(),r;e[0]!==o?(r=()=>o?.[0],e[0]=o,e[1]=r):r=e[1];let[i,l]=mi(r),[s,a]=mi(null),c;e[2]!==o||e[3]!==i?(c={collectionSlugs:o,selectedCollection:i},e[2]=o,e[3]=i,e[4]=c):c=e[4];let[u,d,m]=Tu(c),{closeDrawer:f,isDrawerOpen:p,openDrawer:h}=m,b,C;e[5]!==n||e[6]!==h?(b=()=>n.registerCommand(Re,I=>(a(I?.replace?I?.replace.nodeKey:null),h(),!0),wu),C=[n,h],e[5]=n,e[6]=h,e[7]=b,e[8]=C):(b=e[7],C=e[8]),di(b,C);let v;e[9]!==n||e[10]!==s||e[11]!==f?(v=I=>{let{collectionSlug:S,docID:x}=I;Nu({editor:n,relationTo:S,replaceNodeKey:s,value:x}),f()},e[9]=n,e[10]=s,e[11]=f,e[12]=v):v=e[12];let M=v,_;e[13]!==o?(_=()=>{l(o?.[0])},e[13]=o,e[14]=_):_=e[14];let E;e[15]!==p||e[16]!==o?(E=[p,o],e[15]=p,e[16]=o,e[17]=E):E=e[17],di(_,E);let T;return e[18]!==M||e[19]!==u?(T=pt(u,{onSelect:M}),e[18]=M,e[19]=u,e[20]=T):T=e[20],T},pi=t=>(t?.enabledCollectionSlugs?.length??-1)>0?pt(fi,{...t}):pt(qe,{...t,children:pt(fi,{...t})});var ho=Fu("INSERT_RELATIONSHIP_COMMAND"),gi=t=>{let e=ku(10),{clientProps:o}=t,[n]=Iu(),{config:r}=Su(),{collections:i}=r,l=null;if(o?.enabledCollections)l=o?.enabledCollections;else if(o?.disabledCollections){let u;if(e[0]!==o||e[1]!==i){let d;e[3]!==o?(d=m=>{let{slug:f}=m;return!o?.disabledCollections?.includes(f)},e[3]=o,e[4]=d):d=e[4],u=i.filter(d).map(Ou),e[0]=o,e[1]=i,e[2]=u}else u=e[2];l=u}let s,a;e[5]!==n?(s=()=>{if(!n.hasNodes([Se]))throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");return n.registerCommand(ho,u=>{let d=Mu()||yu();if(vu(d)){let m=ye(u);Ru(m);let{focus:f}=d,p=f.getNode();hi(p)&&p.getTextContentSize()===0&&p.getParentOrThrow().getChildren().filter(h=>hi(h)).length>1&&p.remove()}return!0},Au)},a=[n],e[5]=n,e[6]=s,e[7]=a):(s=e[6],a=e[7]),Du(s,a);let c;return e[8]!==l?(c=Lu(pi,{enabledCollectionSlugs:l}),e[8]=l,e[9]=c):c=e[9],c};function Ou(t){let{slug:e}=t;return e}var $u=y({nodes:[Se],plugins:[{Component:gi,position:"normal"}],slashMenu:{groups:[G([{Icon:po,key:"relationship",keywords:["relationship","relation","rel"],label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(Re,{replace:!1})}}])]},toolbarFixed:{groups:[q([{ChildComponent:po,isActive:({selection:t})=>{if(!Pu(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return Pt(e)},key:"relationship",label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(Re,{replace:!1})}}])]}});import{c as qu}from"react/compiler-runtime";import{jsx as Z,jsxs as Qu}from"react/jsx-runtime";import{useLexicalComposerContext as ed}from"@lexical/react/LexicalComposerContext.js";import{useScrollInfo as td,useThrottledEffect as od,useTranslation as rd}from"@payloadcms/ui";import*as oe from"react";import{useMemo as nd}from"react";import{jsx as Hu}from"react/jsx-runtime";import{mergeRegister as Bu}from"@lexical/utils";import{$getSelection as ju}from"lexical";import{useCallback as Gu,useEffect as ht,useState as go}from"react";var Co="toolbar-popup__button",Ue=({children:t,editor:e,item:o})=>{let[n,r]=go(!0),[i,l]=go(!1),[s,a]=go(Co),c=H(),u=Gu(()=>{e.getEditorState().read(()=>{let d=ju();if(d){if(o.isActive){let m=o.isActive({editor:e,editorConfigContext:c,selection:d});i!==m&&l(m)}if(o.isEnabled){let m=o.isEnabled({editor:e,editorConfigContext:c,selection:d});n!==m&&r(m)}}})},[i,e,c,n,o]);return ht(()=>{u()},[u]),ht(()=>(document.addEventListener("mouseup",u),()=>{document.removeEventListener("mouseup",u)}),[u]),ht(()=>Bu(e.registerUpdateListener(()=>{u()})),[e,u]),ht(()=>{a([Co,n===!1?"disabled":"",i?"active":"",o?.key?`${Co}-`+o.key:""].filter(Boolean).join(" "))},[n,i,s,o.key]),Hu("button",{className:s,onClick:()=>{if(n!==!1)return e._updateTags=new Set([...e._updateTags,"toolbar"]),e.focus(()=>{o.onSelect?.({editor:e,isActive:i})}),!0},onMouseDown:d=>{d.preventDefault()},type:"button",children:t})};import{c as Ei}from"react/compiler-runtime";import{jsx as Ve,jsxs as Ku}from"react/jsx-runtime";import _o,{useEffect as Ti}from"react";import{mergeRegister as Zu}from"@lexical/utils";import{useTranslation as Yu}from"@payloadcms/ui";import{$getSelection as Xu}from"lexical";import{jsx as se,jsxs as Ci}from"react/jsx-runtime";import gt,{useCallback as Uu,useEffect as We,useMemo as Wu,useRef as bo,useState as Ct}from"react";import{createPortal as Vu}from"react-dom";var xo="toolbar-popup__dropdown-item",xi=gt.createContext(null);function bi({active:t,children:e,editor:o,enabled:n,item:r,title:i}){let[l,s]=Ct(xo);We(()=>{s([xo,n===!1?"disabled":"",t?"active":"",r?.key?`${xo}-${r.key}`:""].filter(Boolean).join(" "))},[n,t,l,r.key]);let a=bo(null),c=gt.useContext(xi);if(c===null)throw new Error("DropDownItem must be used within a DropDown");let{registerItem:u}=c;return We(()=>{a?.current!=null&&u(a)},[a,u]),se("button",{className:l,onClick:()=>{n!==!1&&(o._updateTags=new Set([...o._updateTags,"toolbar"]),o.focus(()=>{r.onSelect?.({editor:o,isActive:t})}))},onMouseDown:d=>{d.preventDefault()},ref:a,title:i,type:"button",children:e})}function zu({children:t,dropDownRef:e,itemsContainerClassNames:o,onClose:n}){let[r,i]=Ct(),[l,s]=Ct(),a=Uu(d=>{i(m=>m!=null?[...m,d]:[d])},[i]),c=d=>{if(r==null)return;let{key:m}=d;["ArrowDown","ArrowUp","Escape","Tab"].includes(m)&&d.preventDefault(),m==="Escape"||m==="Tab"?n():m==="ArrowUp"?s(f=>{if(f==null)return r[0];let p=r.indexOf(f)-1;return r[p===-1?r.length-1:p]}):m==="ArrowDown"&&s(f=>f==null?r[0]:r[r.indexOf(f)+1])},u=Wu(()=>({registerItem:a}),[a]);return We(()=>{r!=null&&l==null&&s(r[0]),l!=null&&l?.current!=null&&l.current.focus()},[r,l]),se(xi.Provider,{value:u,children:se("div",{className:(o??["toolbar-popup__dropdown-items"]).join(" "),onKeyDown:c,ref:e,children:t})})}function _i({buttonAriaLabel:t,buttonClassName:e,children:o,disabled:n=!1,Icon:r,itemsContainerClassNames:i,label:l,stopCloseOnClickSelf:s}){let a=bo(null),c=bo(null),[u,d]=Ct(!1),m=()=>{d(!1),c?.current!=null&&c.current.focus()};We(()=>{let p=c.current,h=a.current;if(u&&p!==null&&h!==null){let{left:b,top:C}=p.getBoundingClientRect(),v=window.scrollY||document.documentElement.scrollTop;h.style.top=`${C+v+p.offsetHeight+5}px`,h.style.left=`${Math.min(b-5,window.innerWidth-h.offsetWidth-20)}px`}},[a,c,u]),We(()=>{let p=c.current;if(p!==null&&u){let h=b=>{let{target:C}=b;s!=null&&a.current!=null&&a.current.contains(C)||p.contains(C)||d(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[a,c,u,s]);let f=Vu(se(zu,{dropDownRef:a,itemsContainerClassNames:i,onClose:m,children:o}),document.body);return Ci(gt.Fragment,{children:[Ci("button",{"aria-label":t,className:e+(u?" active":""),disabled:n,onClick:p=>{p.preventDefault(),d(!u)},onMouseDown:p=>{p.preventDefault()},ref:c,type:"button",children:[r&&se(r,{}),l&&se("span",{className:"toolbar-popup__dropdown-label",children:l}),se("i",{className:"toolbar-popup__dropdown-caret"})]}),u&&se(gt.Fragment,{children:f})]})}var To="toolbar-popup__dropdown",Ju=t=>{let e=Ei(19),{active:o,anchorElem:n,editor:r,enabled:i,item:l}=t,{i18n:s}=Yu(),{field:a}=H(),{richTextComponentMap:c}=a;if(l.Component){let f;return e[0]!==l||e[1]!==o||e[2]!==n||e[3]!==r||e[4]!==i?(f=l?.Component&&Ve(l.Component,{active:o,anchorElem:n,editor:r,enabled:i,item:l},l.key),e[0]=l,e[1]=o,e[2]=n,e[3]=r,e[4]=i,e[5]=f):f=e[5],f}let u=l.key;if(l.label){let f;e[6]!==l||e[7]!==s||e[8]!==c?(f=typeof l.label=="function"?l.label({i18n:s,richTextComponentMap:c}):l.label,e[6]=l,e[7]=s,e[8]=c,e[9]=f):f=e[9],u=f}u.length>25&&(u=u.substring(0,25)+"...");let d;e[10]!==l?(d=l?.ChildComponent&&Ve(l.ChildComponent,{}),e[10]=l,e[11]=d):d=e[11];let m;return e[12]!==u||e[13]!==d||e[14]!==o||e[15]!==r||e[16]!==i||e[17]!==l?(m=Ku(bi,{active:o,editor:r,enabled:i,item:l,children:[d,Ve("span",{className:"text",children:u})]},l.key),e[12]=u,e[13]=d,e[14]=o,e[15]=r,e[16]=i,e[17]=l,e[18]=m):m=e[18],m},fe=t=>{let e=Ei(42),{anchorElem:o,classNames:n,editor:r,group:i,Icon:l,itemsContainerClassNames:s,label:a,maxActiveItems:c,onActiveChange:u}=t,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];let[m,f]=_o.useState(d),p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[1]=p):p=e[1];let[h,b]=_o.useState(p),[C,v]=_o.useState(!0),M=H(),{items:_,key:E}=i,T;e[2]!==r||e[3]!==_||e[4]!==c||e[5]!==M||e[6]!==i||e[7]!==u?(T=()=>{r.getEditorState().read(()=>{let P=Xu();if(!P)return;let W=[],Po=[],yt=[];for(let ne of _)ne.isActive&&(!c||W.length<c)&&ne.isActive({editor:r,editorConfigContext:M,selection:P})&&(W.push(ne.key),Po.push(ne)),ne.isEnabled?ne.isEnabled({editor:r,editorConfigContext:M,selection:P})&&yt.push(ne.key):yt.push(ne.key);i.isEnabled&&v(i.isEnabled({editor:r,editorConfigContext:M,selection:P})),f(W),b(yt),u&&u({activeItems:Po})})},e[2]=r,e[3]=_,e[4]=c,e[5]=M,e[6]=i,e[7]=u,e[8]=T):T=e[8];let I=T,S,x;e[9]!==I?(S=()=>{I()},x=[I],e[9]=I,e[10]=S,e[11]=x):(S=e[10],x=e[11]),Ti(S,x);let N,L;e[12]!==r||e[13]!==I?(N=()=>Zu(r.registerUpdateListener(()=>{I()})),L=[r,I],e[12]=r,e[13]=I,e[14]=N,e[15]=L):(N=e[14],L=e[15]),Ti(N,L);let g=`${E} dropdown`,w=`${To}-${E}`,k;e[16]!==n?(k=n||[],e[16]=n,e[17]=k):k=e[17];let R;e[18]!==w||e[19]!==k?(R=[To,w,...k].filter(Boolean),e[18]=w,e[19]=k,e[20]=R):R=e[20];let A=R.join(" "),O=!C,D;e[21]!==s?(D=s||[],e[21]=s,e[22]=D):D=e[22];let B;if(e[23]!==D||e[24]!==_||e[25]!==m||e[26]!==o||e[27]!==r||e[28]!==h||e[29]!==g||e[30]!==A||e[31]!==O||e[32]!==l||e[33]!==a||e[34]!==E){let P;e[36]!==_||e[37]!==m||e[38]!==o||e[39]!==r||e[40]!==h?(P=_.length&&_.map(W=>Ve(Ju,{active:m.includes(W.key),anchorElem:o,editor:r,enabled:h.includes(W.key),item:W},W.key)),e[36]=_,e[37]=m,e[38]=o,e[39]=r,e[40]=h,e[41]=P):P=e[41],B=Ve(_i,{buttonAriaLabel:g,buttonClassName:A,disabled:O,Icon:l,itemsContainerClassNames:[`${To}-items`,...D],label:a,children:P},E),e[23]=D,e[24]=_,e[25]=m,e[26]=o,e[27]=r,e[28]=h,e[29]=g,e[30]=A,e[31]=O,e[32]=l,e[33]=a,e[34]=E,e[35]=B}else B=e[35];return B};function id({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&Z(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?Z(Ue,{editor:e,item:o,children:Z(o.ChildComponent,{})},o.key):null}function ld(t){let e=qu(25),{anchorElem:o,editor:n,editorConfig:r,group:i,index:l}=t,{i18n:s}=rd(),{field:a}=H(),{richTextComponentMap:c}=a,[u,d]=oe.useState(void 0),[m,f]=oe.useState(void 0),p,h;e[0]!==i?(p=()=>{i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0)},h=[i],e[0]=i,e[1]=p,e[2]=h):(p=e[1],h=e[2]),oe.useEffect(p,h);let b;e[3]!==i||e[4]!==s||e[5]!==c?(b=T=>{let{activeItems:I}=T;if(!I.length){i?.type==="dropdown"&&i.items.length&&i.ChildComponent?(f(()=>i.ChildComponent),d(void 0)):(f(void 0),d(void 0));return}let S=I[0],x=S.key;S.label&&(x=typeof S.label=="function"?S.label({i18n:s,richTextComponentMap:c}):S.label),x.length>25&&(x=x.substring(0,25)+"..."),d(x),f(()=>S.ChildComponent)},e[3]=i,e[4]=s,e[5]=c,e[6]=b):b=e[6];let C=b,v=`fixed-toolbar__group fixed-toolbar__group-${i.key}`,M;e[7]!==i||e[8]!==m||e[9]!==o||e[10]!==n||e[11]!==u||e[12]!==C?(M=i.type==="dropdown"&&i.items.length&&(m?Z(fe,{anchorElem:o,editor:n,group:i,Icon:m,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:u,maxActiveItems:1,onActiveChange:C}):Z(fe,{anchorElem:o,editor:n,group:i,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:u,maxActiveItems:1,onActiveChange:C})),e[7]=i,e[8]=m,e[9]=o,e[10]=n,e[11]=u,e[12]=C,e[13]=M):M=e[13];let _;e[14]!==i||e[15]!==o||e[16]!==n?(_=i.type==="buttons"&&i.items.length&&i.items.map(T=>Z(id,{anchorElem:o,editor:n,item:T},T.key)),e[14]=i,e[15]=o,e[16]=n,e[17]=_):_=e[17];let E;return e[18]!==r.features.toolbarFixed||e[19]!==l||e[20]!==M||e[21]!==_||e[22]!==v||e[23]!==i.key?(E=Qu("div",{className:v,children:[M,_,l<r.features.toolbarFixed?.groups.length-1&&Z("div",{className:"divider"})]},i.key),e[18]=r.features.toolbarFixed,e[19]=l,e[20]=M,e[21]=_,e[22]=v,e[23]=i.key,e[24]=E):E=e[24],E}function sd({anchorElem:t,clientProps:e,editor:o,editorConfig:n,parentWithFixedToolbar:r}){let i=oe.useRef(null),{y:l}=td(),s=nd(()=>{if(!r||e?.disableIfParentHasFixedToolbar)return null;let c=r.editorContainerRef.current.previousElementSibling;for(;c;){if(c.classList.contains("fixed-toolbar"))return c;c=c.previousElementSibling}return null},[e?.disableIfParentHasFixedToolbar,r]);return od(()=>{if(!s)return;let a=i.current;if(!a)return;let c=a.getBoundingClientRect(),u=s.getBoundingClientRect();if(!(c.bottom<u.top||c.top>u.bottom))a.className="fixed-toolbar fixed-toolbar--overlapping",s.className="fixed-toolbar fixed-toolbar--hide";else{if(!a.classList.contains("fixed-toolbar--overlapping"))return;a.className="fixed-toolbar",s.className="fixed-toolbar"}},50,[i,s,l]),Z("div",{className:"fixed-toolbar",onFocus:a=>{a.stopPropagation()},ref:i,children:o.isEditable()&&Z(oe.Fragment,{children:n?.features&&n.features?.toolbarFixed?.groups.map((a,c)=>Z(ld,{anchorElem:t,editor:o,editorConfig:n,group:a,index:c},a.key))})})}var wi=t=>{if(t.parentEditor?.editorConfig){if(t.parentEditor?.editorConfig.resolvedFeatureMap.has("toolbarFixed"))return t.parentEditor;if(t.parentEditor)return wi(t.parentEditor)}return!1},Ni=({anchorElem:t,clientProps:e})=>{let[o]=ed(),n=H(),{editorConfig:r}=n,i=e.applyToFocusedEditor&&n.focusedEditor?.editor||o,l=e.applyToFocusedEditor&&n.focusedEditor?.editorConfig||r,s=wi(n);return e?.disableIfParentHasFixedToolbar&&s||!l?.features?.toolbarFixed?.groups?.length?null:Z(sd,{anchorElem:t,editor:i,editorConfig:l,parentWithFixedToolbar:s})};var ad=y({plugins:[{Component:Ni,position:"aboveContainer"}]});import{c as cd}from"react/compiler-runtime";import{jsx as Y,jsxs as Ii}from"react/jsx-runtime";import{useLexicalComposerContext as ud}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Ri}from"@lexical/utils";import{$getSelection as Si,$isRangeSelection as ki,$isTextNode as dd,COMMAND_PRIORITY_LOW as md,SELECTION_CHANGE_COMMAND as fd}from"lexical";import{useCallback as ze,useEffect as Ke,useRef as Li,useState as pd}from"react";import*as Te from"react";import{createPortal as hd}from"react-dom";function Eo(t,e){let o=t.getRangeAt(0),n;if(t.anchorNode===e){let r=e;for(;r.firstElementChild!=null;)r=r.firstElementChild;n=r.getBoundingClientRect()}else n=o.getBoundingClientRect();return n}function xt(t){let{alwaysDisplayOnTop:e=!1,anchorElem:o,anchorFlippedOffset:n=0,floatingElem:r,horizontalOffset:i=32,horizontalPosition:l="left",specialHandlingForCaret:s=!1,targetRect:a,verticalGap:c=10}=t,u=o.parentElement;if(a===null||u==null){r.style.opacity="0",r.style.transform="translate(-10000px, -10000px)";return}let d=r.getBoundingClientRect(),m=o.getBoundingClientRect(),f=u.getBoundingClientRect(),p=a.top-d.height-c,h=a.left-i;l==="center"&&(h=a.left+a.width/2-d.width/2);let b=0;return!e&&p<f.top&&!s&&(b=d.height+a.height+c*2,p+=b),l==="center"?h+d.width>f.right?h=f.right-d.width-i:h<f.left&&(h=f.left+i):h+d.width>f.right&&(h=f.right-d.width-i),h-=m.left,r.style.opacity="1",s&&n!==0?(p-=m.bottom-n+d.height-3,r.style.transform=`translate(${h}px, ${p}px) rotate(180deg)`):(p-=m.top,r.style.transform=`translate(${h}px, ${p}px)`),b}function gd({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&Y(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?Y(Ue,{editor:e,item:o,children:Y(o.ChildComponent,{})},o.key):null}function Cd(t){let e=cd(22),{anchorElem:o,editor:n,group:r,index:i}=t,{editorConfig:l}=H(),[s,a]=Te.useState(),c,u;e[0]!==r?(c=()=>{r?.type==="dropdown"&&r.items.length&&r.ChildComponent?a(()=>r.ChildComponent):a(void 0)},u=[r],e[0]=r,e[1]=c,e[2]=u):(c=e[1],u=e[2]),Te.useEffect(c,u);let d;e[3]!==r?(d=C=>{let{activeItems:v}=C;if(!v.length){r?.type==="dropdown"&&r.items.length&&r.ChildComponent?a(()=>r.ChildComponent):a(void 0);return}let M=v[0];a(()=>M.ChildComponent)},e[3]=r,e[4]=d):d=e[4];let m=d,f=`inline-toolbar-popup__group inline-toolbar-popup__group-${r.key}`,p;e[5]!==r||e[6]!==s||e[7]!==o||e[8]!==n||e[9]!==m?(p=r.type==="dropdown"&&r.items.length&&(s?Y(fe,{anchorElem:o,editor:n,group:r,Icon:s,maxActiveItems:1,onActiveChange:m}):Y(fe,{anchorElem:o,editor:n,group:r,maxActiveItems:1,onActiveChange:m})),e[5]=r,e[6]=s,e[7]=o,e[8]=n,e[9]=m,e[10]=p):p=e[10];let h;e[11]!==r||e[12]!==o||e[13]!==n?(h=r.type==="buttons"&&r.items.length&&r.items.map(C=>Y(gd,{anchorElem:o,editor:n,item:C},C.key)),e[11]=r,e[12]=o,e[13]=n,e[14]=h):h=e[14];let b;return e[15]!==l.features.toolbarInline||e[16]!==i||e[17]!==p||e[18]!==h||e[19]!==f||e[20]!==r.key?(b=Ii("div",{className:f,children:[p,h,i<l.features.toolbarInline?.groups.length-1&&Y("div",{className:"divider"})]},r.key),e[15]=l.features.toolbarInline,e[16]=i,e[17]=p,e[18]=h,e[19]=f,e[20]=r.key,e[21]=b):b=e[21],b}function xd({anchorElem:t,editor:e}){let o=Li(null),n=Li(null),{editorConfig:r}=H(),i=ze(()=>{if(o?.current){let c=o.current.style.opacity==="0",u=o.current.style.pointerEvents==="none";c||(o.current.style.opacity="0"),u||(o.current.style.pointerEvents="none")}},[o]),l=ze(c=>{if(o?.current&&(c.buttons===1||c.buttons===3)){let u=o.current.style.opacity==="0",d=o.current.style.pointerEvents==="none";if(!u||!d){let m=c.clientX,f=c.clientY,p=document.elementFromPoint(m,f);o.current.contains(p)||i()}}},[i]),s=ze(()=>{o?.current&&(o.current.style.opacity!=="1"&&(o.current.style.opacity="1"),o.current.style.pointerEvents!=="auto"&&(o.current.style.pointerEvents="auto"))},[]);Ke(()=>(document.addEventListener("mousemove",l),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",s)}),[o,l,s]);let a=ze(()=>{let c=Si(),u=window.getSelection();if(o.current===null)return;let d=t.querySelector(":scope > .link-editor"),m=d!==null&&"style"in d&&d?.style?.opacity==="1",f=e.getRootElement();if(c!==null&&u!==null&&!u.isCollapsed&&f!==null&&f.contains(u.anchorNode)){let p=Eo(u,f),h=xt({alwaysDisplayOnTop:m,anchorElem:t,floatingElem:o.current,horizontalPosition:"center",targetRect:p});n.current&&xt({anchorElem:o.current,anchorFlippedOffset:h,floatingElem:n.current,horizontalOffset:5,horizontalPosition:"center",specialHandlingForCaret:!0,targetRect:p,verticalGap:8})}else i()},[e,i,t]);return Ke(()=>{let c=t.parentElement,u=()=>{e.getEditorState().read(()=>{a()})};return window.addEventListener("resize",u),c&&c.addEventListener("scroll",u),()=>{window.removeEventListener("resize",u),c&&c.removeEventListener("scroll",u)}},[e,a,t]),Ke(()=>(e.getEditorState().read(()=>{a()}),Ri(e.registerUpdateListener(({editorState:c})=>{c.read(()=>{a()})}),e.registerCommand(fd,()=>(a(),!1),md))),[e,a]),Ii("div",{className:"inline-toolbar-popup",ref:o,children:[Y("div",{className:"caret",ref:n}),e.isEditable()&&Y(Te.Fragment,{children:r?.features&&r.features?.toolbarInline?.groups.map((c,u)=>Y(Cd,{anchorElem:t,editor:e,group:c,index:u},c.key))})]})}function bd(t,e){let[o,n]=pd(!1),r=ze(()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let i=Si(),l=window.getSelection(),s=t.getRootElement();if(l!==null&&(!ki(i)||s===null||!s.contains(l.anchorNode))){n(!1);return}if(!ki(i))return;if(i.getTextContent()!==""){let c=i.getNodes(),u=!1;for(let d of c)if(dd(d)){n(!0),u=!0;break}u||n(!1)}else n(!1);let a=i.getTextContent().replace(/\n/g,"");if(!i.isCollapsed()&&a===""){n(!1);return}})},[t]);return Ke(()=>(document.addEventListener("selectionchange",r),document.addEventListener("mouseup",r),()=>{document.removeEventListener("selectionchange",r),document.removeEventListener("mouseup",r)}),[r]),Ke(()=>Ri(t.registerUpdateListener(()=>{r()}),t.registerRootListener(()=>{t.getRootElement()===null&&n(!1)})),[t,r]),o?hd(Y(xd,{anchorElem:e,editor:t}),e):null}var yi=({anchorElem:t})=>{let[e]=ud();return bd(e,t)};var _d=y({plugins:[{Component:yi,position:"floatingAnchorElem"}]});import{TableCellNode as Bm,TableNode as jm,TableRowNode as Gm}from"@lexical/table";import{jsx as Mi}from"react/jsx-runtime";import"react";var wo=()=>Mi("svg",{className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Mi("path",{clipRule:"evenodd",d:"M5.33333 4.5C4.8731 4.5 4.5 4.8731 4.5 5.33333V7.5H9.5V4.5H5.33333ZM5.33333 3.5C4.32081 3.5 3.5 4.32081 3.5 5.33333V14.6667C3.5 15.6792 4.32081 16.5 5.33333 16.5H14.6667C15.6792 16.5 16.5 15.6792 16.5 14.6667V5.33333C16.5 4.32081 15.6792 3.5 14.6667 3.5H5.33333ZM10.5 4.5V7.5H15.5V5.33333C15.5 4.8731 15.1269 4.5 14.6667 4.5H10.5ZM15.5 8.5H10.5V11.5H15.5V8.5ZM15.5 12.5H10.5V15.5H14.6667C15.1269 15.5 15.5 15.1269 15.5 14.6667V12.5ZM9.5 15.5V12.5H4.5V14.6667C4.5 15.1269 4.8731 15.5 5.33333 15.5H9.5ZM4.5 11.5H9.5V8.5H4.5V11.5Z",fill:"currentColor",fillRule:"evenodd"})});import{jsx as $,jsxs as re}from"react/jsx-runtime";import{useLexicalComposerContext as Di}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Ed}from"@lexical/react/useLexicalEditable";import{$deleteTableColumn__EXPERIMENTAL as wd,$deleteTableRow__EXPERIMENTAL as Nd,$getNodeTriplet as kd,$getTableCellNodeFromLexicalNode as Ld,$getTableColumnIndexFromTableCellNode as Id,$getTableNodeFromLexicalNodeOrThrow as Ze,$getTableRowIndexFromTableCellNode as Rd,$insertTableColumn__EXPERIMENTAL as Sd,$insertTableRow__EXPERIMENTAL as yd,$isTableCellNode as bt,$isTableRowNode as Ai,$isTableSelection as Tt,$unmergeCell as Md,getTableObserverFromTableElement as vd,TableCellHeaderStates as ae,TableCellNode as Ad}from"@lexical/table";import{useScrollInfo as Fd}from"@payloadcms/ui";import{$createParagraphNode as Dd,$getRoot as Od,$getSelection as Et,$isElementNode as Pd,$isParagraphNode as Oi,$isRangeSelection as Lo,$isTextNode as $d}from"lexical";import*as Io from"react";import{useCallback as J,useEffect as pe,useRef as _t,useState as Ee}from"react";import{createPortal as Pi}from"react-dom";import{jsx as No,jsxs as Td}from"react/jsx-runtime";import"react";var vi=()=>Td("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[No("path",{d:"M5 11C5.55228 11 6 10.5523 6 10C6 9.44772 5.55228 9 5 9C4.44772 9 4 9.44772 4 10C4 10.5523 4.44772 11 5 11Z",fill:"currentColor"}),No("path",{d:"M10 11C10.5523 11 11 10.5523 11 10C11 9.44772 10.5523 9 10 9C9.44772 9 9 9.44772 9 10C9 10.5523 9.44772 11 10 11Z",fill:"currentColor"}),No("path",{d:"M15 11C15.5523 11 16 10.5523 16 10C16 9.44772 15.5523 9 15 9C14.4477 9 14 9.44772 14 10C14 10.5523 14.4477 11 15 11Z",fill:"currentColor"})]});function ko(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function Hd(){let t=Et();if(Lo(t)&&!t.isCollapsed()||Tt(t)&&!t.anchor.is(t.focus)||!Lo(t)&&!Tt(t))return!1;let[e]=kd(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function Fi(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!Oi(e)||!e.isEmpty())}function Bd(t){let e=t.getLastDescendant();$d(e)?e.select():Pd(e)?e.selectEnd():e!==null&&e.selectNext()}function jd({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:n,tableCellNode:r}){let[i]=Di(),l=_t(null),[s,a]=Ee(r),[c,u]=Ee({columns:1,rows:1}),[d,m]=Ee(!1),[f,p]=Ee(!1),{y:h}=Fd();pe(()=>i.registerMutationListener(Ad,g=>{g.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{a(s.getLatest())})},{skipInitialization:!0}),[i,s]),pe(()=>{i.getEditorState().read(()=>{let g=Et();if(Tt(g)){let w=ko(g);u(ko(g)),m(w.columns>1||w.rows>1)}p(Hd())})},[i]),pe(()=>{let g=e.current,w=l.current,k=i.getRootElement();if(g!=null&&w!=null&&k!=null){let R=k.getBoundingClientRect(),A=g.getBoundingClientRect();w.style.opacity="1";let O=w.getBoundingClientRect(),D=5,B=A.right+D;if(B+O.width>window.innerWidth||B+O.width>R.right){let W=A.left-O.width-D;B=(W<0?D:W)+window.pageXOffset}w.style.left=`${B+window.pageXOffset}px`;let P=A.top;if(P+O.height>window.innerHeight){let W=A.bottom-O.height;P=(W<0?D:W)+window.pageYOffset}w.style.top=`${P}px`}},[e,l,i,h]),pe(()=>{function g(w){l.current!=null&&e.current!=null&&!l.current.contains(w.target)&&!e.current.contains(w.target)&&n(!1)}return window.addEventListener("click",g),()=>window.removeEventListener("click",g)},[n,e]);let b=J(()=>{i.update(()=>{if(s.isAttached()){let w=Ze(s),k=i.getElementByKey(w.getKey());if(!k)throw new Error("Expected to find tableElement in DOM");let R=vd(k);R!==null&&R.clearHighlight(),w.markDirty(),a(s.getLatest())}Od().selectStart()})},[i,s]),C=()=>{i.update(()=>{let g=Et();if(Tt(g)){let{columns:w,rows:k}=ko(g),R=g.getNodes(),A=null;for(let O=0;O<R.length;O++){let D=R[O];if(bt(D))if(A===null){D.setColSpan(w).setRowSpan(k),A=D;let B=Fi(D),P;B&&Oi(P=D.getFirstChild())&&P.remove()}else bt(A)&&(Fi(D)||A.append(...D.getChildren()),D.remove())}A!==null&&(A.getChildrenSize()===0&&A.append(Dd()),Bd(A)),o()}})},v=()=>{i.update(()=>{Md()})},M=J(g=>{i.update(()=>{yd(g),o()})},[i,o]),_=J(g=>{i.update(()=>{for(let w=0;w<c.columns;w++)Sd(g);o()})},[i,o,c.columns]),E=J(()=>{i.update(()=>{Nd(),o()})},[i,o]),T=J(()=>{i.update(()=>{Ze(s).remove(),b(),o()})},[i,s,b,o]),I=J(()=>{i.update(()=>{wd(),o()})},[i,o]),S=J(()=>{i.update(()=>{let g=Ze(s),w=Rd(s),k=g.getChildren();if(w>=k.length||w<0)throw new Error("Expected table cell to be inside of table row.");let R=k[w];if(!Ai(R))throw new Error("Expected table row");let A=s.getHeaderStyles()^ae.ROW;R.getChildren().forEach(O=>{if(!bt(O))throw new Error("Expected table cell");O.setHeaderStyles(A,ae.ROW)}),b(),o()})},[i,s,b,o]),x=J(()=>{i.update(()=>{let g=Ze(s),w=Id(s),k=g.getChildren(),R=Math.max(...k.map(O=>O.getChildren().length));if(w>=R||w<0)throw new Error("Expected table cell to be inside of table row.");let A=s.getHeaderStyles()^ae.COLUMN;for(let O=0;O<k.length;O++){let D=k[O];if(!Ai(D))throw new Error("Expected table row");let B=D.getChildren();if(w>=B.length)continue;let P=B[w];if(!bt(P))throw new Error("Expected table cell");P.setHeaderStyles(A,ae.COLUMN)}b(),o()})},[i,s,b,o]),N=J(()=>{i.update(()=>{if(s.isAttached()){let g=Ze(s);g&&g.setRowStriping(!g.getRowStriping())}b(),o()})},[i,s,b,o]),L=null;return t&&(d?L=$("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>C(),type:"button",children:"Merge cells"}):f&&(L=$("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>v(),type:"button",children:"Unmerge cells"}))),Pi(re("div",{className:"table-action-menu-dropdown",onClick:g=>{g.stopPropagation()},ref:l,children:[L?re(Io.Fragment,{children:[L,$("hr",{})]}):null,$("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>N(),type:"button",children:$("span",{className:"text",children:"Toggle Row Striping"})}),$("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>M(!1),type:"button",children:re("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),$("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>M(!0),type:"button",children:re("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),$("hr",{}),$("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>_(!1),type:"button",children:re("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),$("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>_(!0),type:"button",children:re("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),$("hr",{}),$("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>I(),type:"button",children:$("span",{className:"text",children:"Delete column"})}),$("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>E(),type:"button",children:$("span",{className:"text",children:"Delete row"})}),$("button",{className:"item","data-test-id":"table-delete",onClick:()=>T(),type:"button",children:$("span",{className:"text",children:"Delete table"})}),$("hr",{}),$("button",{className:"item",onClick:()=>S(),type:"button",children:re("span",{className:"text",children:[(s.__headerState&ae.ROW)===ae.ROW?"Remove":"Add"," ","row header"]})}),$("button",{className:"item","data-test-id":"table-column-header",onClick:()=>x(),type:"button",children:re("span",{className:"text",children:[(s.__headerState&ae.COLUMN)===ae.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function Gd({anchorElem:t,cellMerge:e}){let[o]=Di(),n=_t(null),r=_t(null),[i,l]=Ee(!1),[s,a]=Ee(null),c=J(()=>{let d=n.current,m=Et(),f=window.getSelection(),p=document.activeElement;if(m==null||d==null){a(null);return}let h=o.getRootElement();if(Lo(m)&&h!==null&&f!==null&&h.contains(f.anchorNode)){let b=Ld(m.anchor.getNode());if(b==null){a(null);return}if(o.getElementByKey(b.getKey())==null){a(null);return}a(b)}else p||a(null)},[o]);pe(()=>o.registerUpdateListener(()=>{o.getEditorState().read(()=>{c()})})),pe(()=>{let d=n.current;if(d!=null&&s!=null){let m=o.getElementByKey(s.getKey());if(m!=null){let f=m.getBoundingClientRect(),p=d.getBoundingClientRect(),h=t.getBoundingClientRect(),b=f.top-h.top+4,C=f.right-p.width-10-h.left;d.style.opacity="1",d.style.transform=`translate(${C}px, ${b}px)`}else d.style.opacity="0",d.style.transform="translate(-10000px, -10000px)"}},[n,s,o,t]);let u=_t(s);return pe(()=>{u.current!==s&&l(!1),u.current=s},[u,s]),$("div",{className:"table-cell-action-button-container",ref:n,children:s!=null&&re(Io.Fragment,{children:[$("button",{className:"table-cell-action-button",onClick:d=>{d.stopPropagation(),l(!i)},ref:r,type:"button",children:$(vi,{})}),i&&$(jd,{cellMerge:e,contextRef:r,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var $i=({anchorElem:t})=>{let e=Ed();return Pi(e?$(Gd,{anchorElem:t??document.body,cellMerge:!0}):null,t??document.body)};import{jsx as kt,jsxs as Ud}from"react/jsx-runtime";import{useLexicalComposerContext as Wd}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Vd}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as zd,$getTableNodeFromLexicalNodeOrThrow as Ro,$getTableRowIndexFromTableCellNode as Kd,$isTableCellNode as Hi,$isTableRowNode as Zd,getDOMCellFromTarget as Yd,TableNode as Xd}from"@lexical/table";import{calculateZoomLevel as Bi}from"@lexical/utils";import{$getNearestNodeFromDOMNode as So}from"lexical";import*as Ui from"react";import{useCallback as we,useEffect as ji,useMemo as Jd,useRef as wt,useState as Nt}from"react";import{createPortal as qd}from"react-dom";var Qd=33,Gi=92;function em({editor:t}){let e=wt(null),o=wt(null),n=wt(null),r=H(),i=wt(null),[l,s]=Nt(null),[a,c]=Nt(null),[u,d]=Nt(!1),[m,f]=Nt(null),p=we(()=>{c(null),e.current=null,f(null),i.current=null,n.current=null},[]),h=x=>(x.buttons&1)===1;ji(()=>t.registerNodeTransform(Xd,x=>{if(x.getColWidths())return x;let N=x.getColumnCount(),L=Gi;return x.setColWidths(Array(N).fill(L)),x}),[t]),ji(()=>{let x=w=>{setTimeout(()=>{let k=w.target;if(m){s({x:w.clientX,y:w.clientY});return}if(d(h(w)),!(o.current&&o.current.contains(k))&&e.current!==k){e.current=k;let R=Yd(k);R&&a!==R?t.update(()=>{let A=So(R.elem);if(!A)throw new Error("TableCellResizer: Table cell node not found.");let O=Ro(A),D=t.getElementByKey(O.getKey());if(!D)throw new Error("TableCellResizer: Table element not found.");e.current=k,n.current=D.getBoundingClientRect(),c(R)}):R==null&&p()}},0)},N=w=>{setTimeout(()=>{d(!0)},0)},L=w=>{setTimeout(()=>{d(!1)},0)},g=t.registerRootListener((w,k)=>{k?.removeEventListener("mousemove",x),k?.removeEventListener("mousedown",N),k?.removeEventListener("mouseup",L),w?.addEventListener("mousemove",x),w?.addEventListener("mousedown",N),w?.addEventListener("mouseup",L)});return()=>{g()}},[a,m,t,p]);let b=x=>x==="bottom",C=we(x=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=So(a.elem);if(!Hi(N))throw new Error("TableCellResizer: Table cell node not found.");let L=Ro(N),g=Kd(N)+N.getRowSpan()-1,w=L.getChildren();if(g>=w.length||g<0)throw new Error("Expected table cell to be inside of table row.");let k=w[g];if(!Zd(k))throw new Error("Expected table row");let R=k.getHeight();if(R===void 0){let O=k.getChildren();R=Math.min(...O.map(D=>v(D,t)??1/0))}let A=Math.max(R+x,Qd);k.setHeight(A)},{tag:"skip-scroll-into-view"})},[a,t]),v=(x,N)=>N.getElementByKey(x.getKey())?.clientHeight,M=(x,N)=>{for(let L=0;L<N.length;L++)for(let g=0;g<N[L].length;g++)if(N[L][g].cell===x)return g},_=we(x=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=So(a.elem);if(!Hi(N))throw new Error("TableCellResizer: Table cell node not found.");let L=Ro(N),[g]=zd(L,null,null),w=M(N,g);if(w===void 0)throw new Error("TableCellResizer: Table column not found.");let k=L.getColWidths();if(!k)return;let R=k[w];if(R===void 0)return;let A=[...k],O=Math.max(R+x,Gi);A[w]=O,L.setColWidths(A)},{tag:"skip-scroll-into-view"})},[a,t]),E=we(x=>{let N=L=>{if(L.preventDefault(),L.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");if(i.current){let{x:g,y:w}=i.current;if(a===null)return;let k=Bi(L.target);if(b(x)){let R=(L.clientY-w)/k;C(R)}else{let R=(L.clientX-g)/k;_(R)}p(),document.removeEventListener("mouseup",N)}};return N},[a,p,_,C]),T=we(x=>N=>{if(N.preventDefault(),N.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");i.current={x:N.clientX,y:N.clientY},s(i.current),f(x),document.addEventListener("mouseup",E(x))},[a,E]),S=we(()=>{if(a){let{height:x,left:N,top:L,width:g}=a.elem.getBoundingClientRect(),w=Bi(a.elem),k=10,R={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${k}px`,left:`${window.pageXOffset+N}px`,top:`${window.pageYOffset+L+x-k/2}px`,width:`${g}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${x}px`,left:`${window.pageXOffset+N+g-k/2}px`,top:`${window.pageYOffset+L}px`,width:`${k}px`}},A=n.current;return m&&l&&A&&(b(m)?(R[m].left=`${window.pageXOffset+A.left}px`,R[m].top=`${window.pageYOffset+l.y/w}px`,R[m].height="3px",R[m].width=`${A.width}px`):(R[m].top=`${window.pageYOffset+A.top}px`,R[m].left=`${window.pageXOffset+l.x/w}px`,R[m].width="3px",R[m].height=`${A.height}px`),R[m].backgroundColor="#adf"),R}return{bottom:null,left:null,right:null,top:null}},[a,m,l])();return kt("div",{ref:o,children:a!=null&&!u&&Ud(Ui.Fragment,{children:[kt("div",{className:`${r.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:T("right"),style:S.right||void 0}),kt("div",{className:`${r.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:T("bottom"),style:S.bottom||void 0})]})})}var Wi=()=>{let[t]=Wd(),e=Vd();return Jd(()=>e?qd(kt(em,{editor:t}),document.body):null,[t,e])};import{jsx as yo,jsxs as sm,Fragment as am}from"react/jsx-runtime";import{useLexicalComposerContext as cm}from"@lexical/react/LexicalComposerContext";import{$getTableColumnIndexFromTableCellNode as um,$getTableRowIndexFromTableCellNode as dm,$insertTableColumn__EXPERIMENTAL as mm,$insertTableRow__EXPERIMENTAL as fm,$isTableCellNode as pm,$isTableNode as Ki,TableNode as hm}from"@lexical/table";import{$findMatchingParent as gm,mergeRegister as Cm}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Zi}from"lexical";import{useEffect as Yi,useRef as Xi,useState as Lt}from"react";import"react";import{createPortal as xm}from"react-dom";import{useMemo as im,useRef as lm}from"react";var tm="Expected a function",om=Math.max,rm=Math.min;function nm(t,e,o){let n,r,i=0,l,s=!1,a=!1,c,u,d,m=!0;if(typeof t!="function")throw new TypeError(tm);e=e||0,typeof o=="object"&&(s=!!o.leading,a="maxWait"in o,c=a?om(o.maxWait||0,e):c,m="trailing"in o?!!o.trailing:m);function f(T){let I=n,S=l;return n=l=void 0,i=T,u=t.apply(S,I),u}function p(T){return i=T,d=setTimeout(C,e),s?f(T):u}function h(T){let I=T-r,S=T-i,x=e-I;return a?rm(x,c-S):x}function b(T){let I=T-r,S=T-i;return r===void 0||I>=e||I<0||a&&S>=c}function C(){let T=Date.now();if(b(T))return v(T);d=setTimeout(C,h(T))}function v(T){return d=void 0,m&&n?f(T):(n=l=void 0,u)}function M(){d!==void 0&&clearTimeout(d),i=0,n=r=l=d=void 0}function _(){return d===void 0?u:v(Date.now())}function E(){let T=Date.now(),I=b(T);if(n=arguments,l=this,r=T,I){if(d===void 0)return p(r);if(a)return clearTimeout(d),d=setTimeout(C,e),f(r)}return d===void 0&&(d=setTimeout(C,e)),u}return E.cancel=M,E.flush=_,E}var Vi=nm;function zi(t,e,o){let n=lm(null);return n.current=t,im(()=>Vi((...r)=>{n.current&&n.current(...r)},e,{maxWait:o}),[e,o])}var Ji=20;function bm({anchorElem:t}){let[e]=cm(),o=H(),[n,r]=Lt(!1),[i,l]=Lt(!1),[s,a]=Lt(!1),[c,u]=Lt({}),d=Xi(new Set),m=Xi(null),f=zi(h=>{let{isOutside:b,tableDOMNode:C}=_m(h,o.editorConfig?.lexical);if(b){r(!1),l(!1);return}if(!C)return;m.current=C;let v=null,M=null,_=null;if(e.update(()=>{let E=Zi(C);if(pm(E)){let T=gm(E,I=>Ki(I));if(!Ki(T))return;if(_=e.getElementByKey(T?.getKey()),_){let I=T.getChildrenSize(),S=T.getChildAtIndex(0)?.getChildrenSize(),x=dm(E),N=um(E);x===I-1?v=E:N===S-1&&(M=E)}}}),_){let{bottom:E,height:T,right:I,width:S,x,y:N}=_.getBoundingClientRect(),{left:L,y:g}=t.getBoundingClientRect();v?(l(!1),r(!0),u({height:Ji,left:x-L,top:E-g+5,width:S})):M&&(l(!0),r(!1),u({height:T,left:I-L+5,top:N-g,width:Ji}))}},50,250);Yi(()=>{if(s)return document.addEventListener("mousemove",f),()=>{r(!1),l(!1),document.removeEventListener("mousemove",f)}},[s,f]),Yi(()=>Cm(e.registerMutationListener(hm,h=>{e.getEditorState().read(()=>{for(let[b,C]of h)switch(C){case"created":d.current.add(b),a(d.current.size>0);break;case"destroyed":d.current.delete(b),a(d.current.size>0);break;default:break}})},{skipInitialization:!1})),[e]);let p=h=>{e.update(()=>{m.current&&(Zi(m.current)?.selectEnd(),h?(fm(),r(!1)):(mm(),l(!1)))})};return sm(am,{children:[n&&yo("button",{className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>p(!0),style:{...c}}),i&&yo("button",{className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>p(!1),style:{...c}})]})}function _m(t,e){let o=t.target;if(o&&o instanceof HTMLElement){let n=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(n||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:n}}else return{isOutside:!0,tableDOMNode:null}}function qi({anchorElem:t=document.body}){return xm(yo(bm,{anchorElem:t}),t)}import{c as Tm}from"react/compiler-runtime";import{jsx as Mo,jsxs as Em}from"react/jsx-runtime";import{useLexicalComposerContext as wm}from"@lexical/react/LexicalComposerContext";import{TablePlugin as Nm}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as km,TableNode as Lm}from"@lexical/table";import{mergeRegister as Im}from"@lexical/utils";import{formatDrawerSlug as Rm,useEditDepth as Sm,useModal as ym}from"@payloadcms/ui";import{$getSelection as Mm,$isRangeSelection as vm,COMMAND_PRIORITY_EDITOR as Am,createCommand as Fm}from"lexical";import{createContext as Dm,useContext as Om,useEffect as Pm,useMemo as $m,useState as Hm}from"react";import*as Qi from"react";var It=Fm("OPEN_EMBED_DRAWER_COMMAND"),el=Dm({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function tl({children:t}){let[e,o]=Hm({cellEditorConfig:null,cellEditorPlugins:null});return Mo(el.Provider,{value:$m(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(n,r)=>{o({cellEditorConfig:n,cellEditorPlugins:r})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var ol=()=>{let t=Tm(19),[e]=wm(),o=Om(el),{closeModal:n,toggleModal:r}=ym(),i=Sm(),{uuid:l}=H(),s="lexical-table-create-"+l,a;t[0]!==s||t[1]!==i?(a=Rm({slug:s,depth:i}),t[0]=s,t[1]=i,t[2]=a):a=t[2];let c=a,u;t[3]!==e||t[4]!==r||t[5]!==c?(u=()=>{if(!e.hasNodes([Lm]))throw new Error("TablePlugin: TableNode is not registered on editor");return Im(e.registerCommand(It,()=>{let p;return p=null,e.getEditorState().read(()=>{let h=Mm();vm(h)&&(p=h)}),p&&r(c),!0},Am))},t[3]=e,t[4]=r,t[5]=c,t[6]=u):u=t[6];let d;t[7]!==o||t[8]!==c||t[9]!==e||t[10]!==r?(d=[o,c,e,r],t[7]=o,t[8]=c,t[9]=e,t[10]=r,t[11]=d):d=t[11],Pm(u,d);let m;t[12]!==n||t[13]!==c||t[14]!==e?(m=(p,h)=>{n(c),!(!h.columns||!h.rows)&&e.dispatchCommand(km,{columns:String(h.columns),rows:String(h.rows)})},t[12]=n,t[13]=c,t[14]=e,t[15]=m):m=t[15];let f;return t[16]!==c||t[17]!==m?(f=Em(Qi.Fragment,{children:[Mo(ce,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:m,schemaPathSuffix:"fields"}),Mo(Nm,{hasCellBackgroundColor:!1,hasCellMerge:!0})]}),t[16]=c,t[17]=m,t[18]=f):f=t[18],f};var Um=y({nodes:[jm,Bm,Gm],plugins:[{Component:ol,position:"normal"},{Component:Wi,position:"normal"},{Component:$i,position:"floatingAnchorElem"},{Component:qi,position:"floatingAnchorElem"}],providers:[tl],slashMenu:{groups:[G([{Icon:wo,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(It,{})}}])]},toolbarFixed:{groups:[q([{ChildComponent:wo,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(It,{})}}])]}});import{$isNodeSelection as pf}from"lexical";import{jsx as vo,jsxs as Wm}from"react/jsx-runtime";import"react";var Ao=()=>Wm("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[vo("path",{d:"M14.6667 4H5.33333C4.59695 4 4 4.59695 4 5.33333V14.6667C4 15.403 4.59695 16 5.33333 16H14.6667C15.403 16 16 15.403 16 14.6667V5.33333C16 4.59695 15.403 4 14.6667 4Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),vo("path",{d:"M7.99984 9.33366C8.73622 9.33366 9.33317 8.73671 9.33317 8.00033C9.33317 7.26395 8.73622 6.66699 7.99984 6.66699C7.26346 6.66699 6.6665 7.26395 6.6665 8.00033C6.6665 8.73671 7.26346 9.33366 7.99984 9.33366Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),vo("path",{d:"M16 11.9995L13.9427 9.94214C13.6926 9.69218 13.3536 9.55176 13 9.55176C12.6464 9.55176 12.3074 9.69218 12.0573 9.94214L6 15.9995",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]});import{c as ef}from"react/compiler-runtime";import{jsx as tf}from"react/jsx-runtime";import{useLexicalComposerContext as of}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as rf,mergeRegister as nf}from"@lexical/utils";import{useConfig as lf}from"@payloadcms/ui";import{$getPreviousSelection as sf,$getSelection as af,$isParagraphNode as nl,$isRangeSelection as cf,COMMAND_PRIORITY_EDITOR as uf,createCommand as df}from"lexical";import{useEffect as mf}from"react";import{c as Vm}from"react/compiler-runtime";import{jsx as Fo}from"react/jsx-runtime";import{useLexicalComposerContext as zm}from"@lexical/react/LexicalComposerContext.js";import{useListDrawer as Km}from"@payloadcms/ui";import{$getNodeByKey as Zm,COMMAND_PRIORITY_EDITOR as Ym}from"lexical";import{useEffect as Xm,useState as Jm}from"react";var qm=({editor:t,relationTo:e,replaceNodeKey:o,value:n})=>{o?t.update(()=>{let r=Zm(o);r&&r.replace(Ae({data:{fields:null,relationTo:e,value:n}}))}):t.dispatchCommand(Do,{fields:null,relationTo:e,value:n})},Qm=t=>{let e=Vm(13),{enabledCollectionSlugs:o}=t,[n]=zm(),[r,i]=Jm(null),l;e[0]!==o?(l={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=l):l=e[1];let[s,a,c]=Km(l),{closeDrawer:u,openDrawer:d}=c,m,f;e[2]!==n||e[3]!==d?(m=()=>n.registerCommand(Me,C=>(i(C?.replace?C?.replace.nodeKey:null),d(),!0),Ym),f=[n,d],e[2]=n,e[3]=d,e[4]=m,e[5]=f):(m=e[4],f=e[5]),Xm(m,f);let p;e[6]!==n||e[7]!==r||e[8]!==u?(p=C=>{let{collectionSlug:v,docID:M}=C;qm({editor:n,relationTo:v,replaceNodeKey:r,value:M}),u()},e[6]=n,e[7]=r,e[8]=u,e[9]=p):p=e[9];let h=p,b;return e[10]!==h||e[11]!==s?(b=Fo(s,{onSelect:h}),e[10]=h,e[11]=s,e[12]=b):b=e[12],b},rl=t=>Fo(qe,{...t,uploads:!0,children:Fo(Qm,{...t})});var Do=df("INSERT_UPLOAD_COMMAND"),il=t=>{let e=ef(5),[o]=of(),{config:n}=lf(),{collections:r}=n,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([ve]))throw new Error("UploadPlugin: UploadNode not registered on editor");return nf(o.registerCommand(Do,a=>(o.update(()=>{let c=af()||sf();if(cf(c)){let u=Ae({data:{id:a.id,fields:a.fields,relationTo:a.relationTo,value:a.value}});rf(u);let{focus:d}=c,m=d.getNode();nl(m)&&m.getTextContentSize()===0&&m.getParentOrThrow().getChildren().filter(f=>nl(f)).length>1&&m.remove()}}),!0),uf))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),mf(i,l);let s;return e[3]!==r?(s=tf(rl,{enabledCollectionSlugs:r.map(ff)}),e[3]=r,e[4]=s):s=e[4],s};function ff(t){let{slug:e}=t;return e}var hf=y({nodes:[ve],plugins:[{Component:il,position:"normal"}],slashMenu:{groups:[G([{Icon:Ao,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Me,{replace:!1})}}])]},toolbarFixed:{groups:[q([{ChildComponent:Ao,isActive:({selection:t})=>{if(!pf(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return $t(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Me,{replace:!1})}}])]}});import{c as gf}from"react/compiler-runtime";import{jsx as Oo}from"react/jsx-runtime";import{ShimmerEffect as Cf}from"@payloadcms/ui";import{lazy as xf,Suspense as bf,useEffect as _f,useState as Tf}from"react";var Ef=xf(()=>import("./Field-ETCEVZLL.js").then(t=>({default:t.RichText}))),wf=t=>{let e=gf(11),{admin:o,field:n,lexicalEditorConfig:r}=t,i;e[0]!==o?(i=o===void 0?{}:o,e[0]=o,e[1]=i):i=e[1];let l=i,{richTextComponentMap:s}=n,[a,c]=Tf(null),u,d;e[2]!==a||e[3]!==s||e[4]!==r||e[5]!==l?(u=()=>{if(a)return;let f=s?.get("features"),p=[];for(let C of f)p.push(C.clientFeature(C.clientFeatureProps));let h=r||Fe,b=Qe({unSanitizedEditorConfig:{features:p,lexical:h}});c(De(b,h,l))},d=[r,s,l,a],e[2]=a,e[3]=s,e[4]=r,e[5]=l,e[6]=u,e[7]=d):(u=e[6],d=e[7]),_f(u,d);let m;return e[8]!==a||e[9]!==t?(m=Oo(bf,{fallback:Oo(Cf,{height:"35vh"}),children:a&&Oo(Ef,{...t,editorConfig:a})}),e[8]=a,e[9]=t,e[10]=m):m=e[10],m};function Nf(...t){return t.filter(Boolean).join(" ")}var Rt=new WeakMap;function ll(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function St(t,e){let o=Rt.get(t);if(o===void 0){let n=new Set,r=l=>{o!==void 0&&(o.start=ll(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let a=ll(l);for(let c of n)a!==null&&c([a[0]-s[0],a[1]-s[1]],l)};t.addEventListener("touchstart",r),t.addEventListener("touchend",i),o={handleTouchend:i,handleTouchstart:r,listeners:n,start:null},Rt.set(t,o)}return o.listeners.add(e),()=>{kf(t,e)}}function kf(t,e){let o=Rt.get(t);if(o===void 0)return;let{listeners:n}=o;n.delete(e),n.size===0&&(Rt.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function Lf(t,e){return St(t,(o,n)=>{let[r,i]=o;r<0&&-r>Math.abs(i)&&e(r,n)})}function If(t,e){return St(t,(o,n)=>{let[r,i]=o;r>0&&r>Math.abs(i)&&e(r,n)})}function Rf(t,e){return St(t,(o,n)=>{let[r,i]=o;i<0&&-i>Math.abs(r)&&e(r,n)})}function Sf(t,e){return St(t,(o,n)=>{let[r,i]=o;i>0&&i>Math.abs(r)&&e(r,n)})}var F={DOM_ELEMENT_TYPE:1,DOM_TEXT_TYPE:3,NO_DIRTY_NODES:0,HAS_DIRTY_NODES:1,FULL_RECONCILE:2,IS_NORMAL:0,IS_TOKEN:1,IS_SEGMENTED:2,IS_INERT:3,IS_BOLD:1,IS_ITALIC:2,IS_STRIKETHROUGH:4,IS_UNDERLINE:8,IS_CODE:16,IS_SUBSCRIPT:32,IS_SUPERSCRIPT:64,IS_HIGHLIGHT:128,IS_DIRECTIONLESS:1,IS_UNMERGEABLE:2,IS_ALIGN_LEFT:1,IS_ALIGN_CENTER:2,IS_ALIGN_RIGHT:3,IS_ALIGN_JUSTIFY:4,IS_ALIGN_START:5,IS_ALIGN_END:6},yf=F.IS_BOLD|F.IS_ITALIC|F.IS_STRIKETHROUGH|F.IS_UNDERLINE|F.IS_CODE|F.IS_SUBSCRIPT|F.IS_SUPERSCRIPT|F.IS_HIGHLIGHT,Mf="\xA0",vf=`
36
36
 
37
37
  `,sl="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",al="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",Af=new RegExp("^[^"+al+"]*["+sl+"]"),Ff=new RegExp("^[^"+sl+"]*["+al+"]"),Df={bold:F.IS_BOLD,code:F.IS_CODE,highlight:F.IS_HIGHLIGHT,italic:F.IS_ITALIC,strikethrough:F.IS_STRIKETHROUGH,subscript:F.IS_SUBSCRIPT,superscript:F.IS_SUPERSCRIPT,underline:F.IS_UNDERLINE},Of={directionless:F.IS_DIRECTIONLESS,unmergeable:F.IS_UNMERGEABLE},Pf={center:F.IS_ALIGN_CENTER,end:F.IS_ALIGN_END,justify:F.IS_ALIGN_JUSTIFY,left:F.IS_ALIGN_LEFT,right:F.IS_ALIGN_RIGHT,start:F.IS_ALIGN_START},$f={[F.IS_ALIGN_CENTER]:"center",[F.IS_ALIGN_END]:"end",[F.IS_ALIGN_JUSTIFY]:"justify",[F.IS_ALIGN_LEFT]:"left",[F.IS_ALIGN_RIGHT]:"right",[F.IS_ALIGN_START]:"start"},Hf={normal:F.IS_NORMAL,segmented:F.IS_SEGMENTED,token:F.IS_TOKEN},Bf={[F.IS_NORMAL]:"normal",[F.IS_SEGMENTED]:"segmented",[F.IS_TOKEN]:"token"};export{Pe as $createAutoLinkNode,vt as $createBlockNode,Dt as $createInlineBlockNode,Q as $createLinkNode,ye as $createRelationshipNode,Ae as $createUploadNode,te as $isAutoLinkNode,dl as $isBlockNode,Ot as $isInlineBlockNode,j as $isLinkNode,Pt as $isRelationshipNode,$t as $isUploadNode,Ml as AlignFeatureClient,ee as AutoLinkNode,Ne as BlockNode,Pl as BlockquoteFeatureClient,rs as BlocksFeatureClient,Ns as BoldFeatureClient,K as CAN_USE_DOM,jc as ChecklistFeatureClient,Of as DETAIL_TYPE_TO_DETAIL,vf as DOUBLE_LINE_BREAK,$f as ELEMENT_FORMAT_TO_TYPE,Pf as ELEMENT_TYPE_TO_FORMAT,hl as ENABLE_SLASH_MENU_COMMAND,ul as EditorConfigProvider,ce as FieldsDrawer,ad as FixedToolbarFeatureClient,ea as HeadingFeatureClient,ua as HorizontalRuleFeatureClient,yf as IS_ALL_FORMATTING,ha as IndentFeatureClient,Ft as InlineBlockNode,Rs as InlineCodeFeatureClient,_d as InlineToolbarFeatureClient,Ms as ItalicFeatureClient,Ff as LTR_REGEX,cu as LexicalPluginToLexicalFeatureClient,Lc as LinkFeatureClient,z as LinkNode,Mf as NON_BREAKING_SPACE,F as NodeFormat,Yc as OrderedListFeatureClient,Cu as ParagraphFeatureClient,fl as Point,Af as RTL_REGEX,gl as Rect,$u as RelationshipFeatureClient,Se as RelationshipNode,Ll as RichTextCell,wf as RichTextField,hu as SlateToLexicalFeatureClient,Ds as StrikethroughFeatureClient,$s as SubscriptFeatureClient,js as SuperscriptFeatureClient,Hf as TEXT_MODE_TO_TYPE,Df as TEXT_TYPE_TO_FORMAT,Bf as TEXT_TYPE_TO_MODE,X as TOGGLE_LINK_COMMAND,Um as TableFeatureClient,gs as TestRecorderFeatureClient,Ue as ToolbarButton,fe as ToolbarDropdown,Ts as TreeViewFeatureClient,Vs as UnderlineFeatureClient,ru as UnorderedListFeatureClient,hf as UploadFeatureClient,ve as UploadNode,Sf as addSwipeDownListener,Lf as addSwipeLeftListener,If as addSwipeRightListener,Rf as addSwipeUpListener,Xt as createBlockNode,y as createClientFeature,Fe as defaultEditorLexicalConfig,Eo as getDOMRangeRect,Mt as getEnabledNodes,he as getSelectedNode,ml as isHTMLElement,pl as isPoint,Nf as joinClasses,De as sanitizeClientEditorConfig,Ho as sanitizeClientFeatures,xt as setFloatingElemPosition,dt as setFloatingElemPositionForLinkEditor,G as slashMenuBasicGroupWithItems,q as toolbarAddDropdownGroupWithItems,qt as toolbarFeatureButtonsGroupWithItems,U as toolbarFormatGroupWithItems,V as toolbarTextDropdownGroupWithItems,H as useEditorConfigContext};