@frontify/fondue 12.0.0-beta.413 → 12.0.0-beta.414

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.
@@ -10,7 +10,7 @@ ${t2("Ctrl+.")}`),nodeType:V.getPluginType(e,l),clear:V.getPluginType(e,d0.MARK_
10
10
  ${t2("Ctrl+,")}`),nodeType:V.getPluginType(e,l),clear:V.getPluginType(e,d0.MARK_SUBSCRIPT),children:t.jsx(x0,{icon:t.jsx(Ne,{})})})}),Qm0="superscript-plugin",Wj=({attributes:e,children:l})=>t.jsx("sup",{...e,children:l});class Qj extends s0{constructor(l=d0.MARK_SUPERSCRIPT,c=Wj){super(l,c)}}class Em0 extends i0{constructor(l){super(Qm0,{button:Wm0,markupElement:new Qj,...l})}plugins(){return[d0.createSuperscriptPlugin({options:{hotkey:["mod+,","ctrl+,"]}})]}}const Ym0="underline-plugin",M3="tw-underline",Ej=({attributes:e,children:l})=>t.jsx("span",{...e,className:M3,children:l});class Yj extends s0{constructor(l=d0.MARK_UNDERLINE,c=Ej){super(l,c)}}const Km0=({editor:e,id:l})=>t.jsx(b0,{id:l,children:t.jsx(V1,{tooltip:F0(`Underline
11
11
  ${t2("Ctrl+U")}`),nodeType:V.getPluginType(e,l),children:t.jsx(x0,{icon:t.jsx(ke,{})})})}),$m0=[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}];class Kj extends i0{constructor(l){super(Ym0,{button:Km0,markupElement:new Yj,...l})}plugins(){return[d0.createUnderlinePlugin({deserializeHtml:{rules:[...$m0,{validNodeName:["SPAN"],validClassName:M3}]},options:{hotkey:["mod+u","ctrl+u"]}})]}}const Xm0=e=>!!e.match(/^(https?:\/\/|mailto:|tel:).+/),$j="text-style-plugin",Jm0=12,_m0=26,Rm0=124,ev0=e=>e.map((l,c)=>({group:l,buttonGroupWidth:l.reduce((r,s)=>s.id===$j?Rm0:_m0+r,Jm0),index:c})),tv0=(e,l)=>l.reduce((c,{group:r,buttonGroupWidth:s,index:i})=>{const d=Math.max(0,c.length-1);return c[d]=c[d]??[],(c[d]??[{actions:[],buttonGroupWidth:0}]).reduce((L,{buttonGroupWidth:w})=>L+w,0)+s<=e?c[d].push({group:r,buttonGroupWidth:s,index:i}):c.push([{group:r,buttonGroupWidth:s,index:i}]),c.filter(L=>L.length)},[]),lv0=({index:e,children:l})=>t.jsx("div",{"data-test-id":`toolbar-group-${e}`,className:"tw-flex tw-items-center tw-h-9 tw-p-2",children:l}),Xj=({toolbarButtons:e,editorId:l,toolbarWidth:c})=>{const r=V.useEditorRef(l),{editorWidth:s}=wj(),{position:i}=l2(),d=c||s||0,h=ev0(e.at(i)),L=tv0(d,h),w=he[i];return t.jsx(w.ToolbarWrapper,{editorWidth:s,toolbarWidth:c,toolbarButtonGroups:L,children:L.map((f,u)=>t.jsx("div",{className:"tw-divide-x tw-divide-line tw-flex tw-w-full",children:f.map(({group:m,index:C})=>t.jsx(lv0,{index:C,children:m.map((v,A)=>t.jsx(v.button,{editor:r,editorId:l,id:v.id},A.toString()))},C))},u))})},Jj="[data-floating-modal]",je=({children:e,minWidth:l,padding:c,"data-test-id":r="floating-modal"})=>t.jsx("div",{"data-test-id":r,className:"tw-bg-white tw-rounded tw-shadow tw-overflow-y-auto",style:{minWidth:l,padding:c},"data-floating-modal":!0,children:e}),A2="link-plugin",_j=(e,l)=>{const c=U.getAboveNode(e,{match:{type:o0.ELEMENT_LINK}});return Array.isArray(c)?l(c[0]):""},av0=e=>_j(e,l=>{var c,r;return((r=(c=l.chosenLink)==null?void 0:c.searchResult)==null?void 0:r.link)||""}),ov0=e=>_j(e,l=>l.url||""),nv0=e=>{var l,c;return e.url||((c=(l=e.chosenLink)==null?void 0:l.searchResult)==null?void 0:c.link)||""},cv0=({editButtonProps:e,unlinkButtonProps:l})=>{const{element:c}=o0.useLinkOpenButtonState(),{styles:r}=l2(),s=c?nv0(c):"";return t.jsx(je,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:t.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between",children:[t.jsx("span",{style:r[A2],className:"tw-pointer-events-none",children:s}),t.jsxs("span",{className:"tw-flex tw-gap-2",children:[t.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...e,children:t.jsx(Ce,{})}),t.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...l,children:t.jsx(e4,{})})]})]})})},rv0=({state:e,onTextChange:l,onUrlChange:c,onToggleTab:r,onCancel:s,onSave:i,isValidUrlOrEmpty:d,hasValues:h,testId:L,children:w})=>t.jsxs(je,{"data-test-id":L,minWidth:"400px",padding:"28px",children:[t.jsx(q5,{label:{children:"Text",htmlFor:"linkText",required:!0},children:t.jsx(W1,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:l})}),w,t.jsxs("div",{className:"tw-pt-5",children:[t.jsx(q5,{label:{children:"URL",htmlFor:"url",required:!0},children:t.jsx(W1,{id:"url",value:e.url,placeholder:"https://example.com",focusOnMount:!0,onChange:c})}),!d()&&t.jsx("div",{className:"tw-text-red-65 tw-mt-3",children:"Please enter a valid URL."})]}),t.jsx("div",{className:"tw-pt-5",children:t.jsx(x1,{value:"new-tab",label:"Open in new tab",state:e.newTab,onChange:r})}),t.jsx("div",{className:"tw-mt-3",children:t.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[t.jsx(H0,{onClick:s,size:L0.Medium,style:t0.Default,emphasis:m0.Default,children:"Cancel"}),t.jsx(H0,{onClick:i,size:L0.Medium,icon:t.jsx(o7,{}),disabled:!d()||!h,children:"Save"})]})})]}),sv0={url:"",text:"",newTab:A0.Unchecked},iv0=()=>{const[e,l]=o.useReducer((c,r)=>{const{type:s,payload:i}=r;switch(s){case"NEW_TAB":return{...c,newTab:A0.Checked};case"SAME_TAB":return{...c,newTab:A0.Unchecked};case"URL":case"TEXT":case"INIT":return{...c,...i};default:return c}},sv0);return[e,l]},dv0=()=>{const e=V.useEditorRef(),[l,c]=iv0();o.useEffect(()=>{const f=av0(e),u=ov0(e),m=o0.floatingLinkSelectors.newTab();c({type:"INIT",payload:{text:o0.floatingLinkSelectors.text(),newTab:m?A0.Checked:A0.Unchecked,url:f&&u===""?f:o0.floatingLinkSelectors.url()}})},[c,e]);const r=f=>{c({type:"TEXT",payload:{text:f}})},s=f=>{c({type:"URL",payload:{url:f}})},i=f=>{c(f?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{o0.floatingLinkActions.reset()},h=f=>{!w()||!L||(o0.floatingLinkActions.text(l.text),o0.floatingLinkActions.url(l.url),o0.floatingLinkActions.newTab(l.newTab===A0.Checked),o0.submitFloatingLink(e)&&(f==null||f.preventDefault()))},L=l.url!==""&&l.text!=="",w=()=>{const{isUrl:f}=V.getPluginOptions(e,o0.ELEMENT_LINK);return!l.url||f&&f(l.url)};return V.useHotkeys("enter",h,{enableOnFormTags:["INPUT"]},[]),{state:l,onTextChange:r,onUrlChange:s,onToggleTab:i,onCancel:d,onSave:h,hasValues:L,isValidUrlOrEmpty:w}},hv0=()=>t.jsx(rv0,{...dv0(),testId:"floating-link-insert"}),Rj={placement:"bottom-start",strategy:"absolute",middleware:[q0.offset(12),q0.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Lv0=()=>{const e=o0.useFloatingLinkInsertState({floatingOptions:Rj}),{props:l,ref:c,hidden:r}=o0.useFloatingLinkInsert(e),s=o0.useFloatingLinkEditState({floatingOptions:Rj}),{props:i,ref:d,editButtonProps:h,unlinkButtonProps:L}=o0.useFloatingLinkEdit(s);if(r)return null;const w=t.jsx(hv0,{}),f=s.isEditing?w:t.jsx(cv0,{editButtonProps:h,unlinkButtonProps:L});return t.jsxs(t.Fragment,{children:[e.isOpen&&!s.isOpen&&t.jsx("div",{ref:c,...l,style:{...l.style,zIndex:e2.floatingModal},children:w}),s.isOpen&&t.jsx("div",{ref:d,...i,style:{...i.style,zIndex:e2.floatingModal},children:f})]})},eP=o.forwardRef((e,l)=>{const c=V.useEditorRef(),r=o0.useLinkToolbarButtonState(),{props:s}=o0.useLinkToolbarButton(r);return t.jsx(c1,{onMouseDown:()=>{o2.focusEditor(c,c.selection??c.prevSelection??void 0)},ref:l,...s,...e,children:t.jsx(x0,{icon:t.jsx(x4,{})})})});eP.displayName="LinkToolbarButton";const wv0=({id:e,editorId:l})=>{const c=V.useEditorState(V.useEventPlateId(l)),r=!!d1.isRangeInSameBlock(c,{at:c.selection});return t.jsx(b0,{id:e,children:t.jsx(eP,{disabled:!r,tooltip:F0(r?`Link
12
12
  ${t2("Ctrl+K")}`:"Links can only be set for a single text block.")})})},fv0=e=>{var d,h;const{attributes:l,children:c}=e,{styles:r}=l2(),s=e.element.url||((h=(d=e.element.chosenLink)==null?void 0:d.searchResult)==null?void 0:h.link)||"",i=e.element.target||"_self";return t.jsx("a",{...l,href:s,target:i,style:r[A2],children:c})};class uv0 extends s0{constructor(l=o0.ELEMENT_LINK,c=fv0){super(l,c)}}const mv0=V.createPluginFactory({...o0.createLinkPlugin(),renderAfterEditable:Lv0,options:{isUrl:Xm0,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0}});class tP extends i0{constructor({styles:c=O0[A2],...r}={}){super(A2,{button:wv0,markupElement:new uv0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[mv0()]}}const Pe="tw-border-b tw-border-dashed tw-border-line-x-strong tw-pb-5",lP=`${Pe} tw-break-after-column tw-break-inside-avoid-column`,$0=e=>{const l=e.breakAfterColumn;return g([l==="active"&&lP,l==="inactive"&&Pe])},De="tw-w-auto tw-min-w-[10px]",Oe=e=>g([$0(e),e.align?He[e.align]:"tw-justify-start","tw-grid tw-grid-cols-[min-content_repeat(3,_auto)]"]),aP=({attributes:e,children:l,element:c})=>t.jsx("p",{className:Oe(c),...e,children:t.jsx("span",{className:De,children:l})});class oP extends s0{constructor(l=_.ELEMENT_LIC,c=aP){super(l,c)}}const z3="list-plugin",vv0=(e,{options:{validLiChildrenTypes:l,isSoftBreak:c}})=>{const{insertBreak:r,deleteBackward:s,deleteForward:i,deleteFragment:d}=e;return c?e.insertSoftBreak=()=>{_.insertBreakList(e)||r()}:e.insertBreak=()=>{_.insertBreakList(e)||r()},e.deleteBackward=h=>{_.deleteBackwardList(e,h)||s(h)},e.deleteForward=h=>{_.deleteForwardList(e,()=>{},h)||i(h)},e.deleteFragment=h=>{_.deleteFragmentList(e)||d(h)},e.insertFragment=_.insertFragmentList(e),e.normalizeNode=_.normalizeList(e,{validLiChildrenTypes:l}),e},e5="textStyle",nP=V.createPluginFactory({key:e5,isLeaf:!0});class Ze extends i0{constructor(c){super(z3,{leafMarkupElements:[new oP,new uP],...c});l0(this,"isSoftBreak");this.isSoftBreak=(c==null?void 0:c.isSoftBreak)??!1}plugins(){return[_.createListPlugin({withOverrides:vv0,options:{isSoftBreak:this.isSoftBreak}}),nP()]}}const gv0=e=>U.getAboveNode(e,{match:{type:_.ELEMENT_LI},mode:"lowest"})||U.someNode(e,{match:{type:r1},mode:"lowest"}),Cv0=({editor:e,type:l,children:c})=>{const r=e!=null&&e.selection?d1.getMark(e,e5)===l.id:U.someNode(e,{match:{type:l}});return t.jsx("button",{"data-test-id":"textstyle-option",type:"button",className:g(["tw-block tw-w-full tw-text-left tw-px-3 tw-py-2 tw-outline-none tw-cursor-pointer tw-truncate hover:tw-bg-box-neutral-hover hover:w-text-box-neutral-inverse-hover tw-max-h-20 tw-max-w-[15rem] tw-min-h-[2.25rem]",r?"tw-text-box-neutral-inverse tw-bg-box-neutral":"tw-text-text"]),onMouseDown:s=>{s.preventDefault(),s.stopPropagation(),!(!e||!e.selection)&&(d1.setMarks(e,{[e5]:l.id}),gv0(e)||V.toggleNodeType(e,{activeType:l.id,inactiveType:l.id}))},children:c})},Av0=({label:e,open:l,onClick:c},r)=>t.jsx("button",{ref:r,"data-test-id":"textstyle-dropdown-trigger",type:"button",className:"tw-cursor-pointer tw-h-8 tw-w-full",onClick:s=>{s.preventDefault(),s.stopPropagation(),c()},children:t.jsxs("div",{className:g(["tw-relative tw-inline-flex tw-flex-row tw-items-center tw-justify-between tw-overflow-hidden tw-text-text tw-rounded tw-gap-1 tw-px-2 hover:tw-text-box-selected-inverse hover:tw-bg-box-selected tw-h-6 tw-w-28",l&&"tw-text-box-selected-inverse tw-bg-box-selected"]),children:[t.jsx("span",{className:"tw-text-xs tw-truncate",children:e}),t.jsx("div",{className:g(["tw-transition-transform",l&&"tw-rotate-180"]),children:t.jsx(_3,{})})]})}),Iv0=o.forwardRef(Av0),Nv0=e=>Array.isArray(e.children)?(e.children.find(c=>U.isText(c))??{})[e5]:I1.ELEMENT_PARAGRAPH,Mv0=[_.ELEMENT_LI,_.ELEMENT_UL,_.ELEMENT_OL],zv0=e=>!e||!e.selection?[]:Array.from(U.getNodeEntries(e,{unhang:!0,at:e.selection,reverse:!0})).reduce((c,[r])=>{if(!U.isNode(r))return c;const s=r.type===_.ELEMENT_LIC||r.type===r1?Nv0(r):r.textStyle;return s&&!c.includes(s)&&!Mv0.includes(s)&&c.push(s),c},[]),Sv0=6,yv0=10,xv0={name:"vertical-positioning",phase:"read",fn:({state:e,name:l})=>{if(e.modifiersData[l]._skip)return;const{position:c,maxHeight:r}=c4(e.elements.reference,e.rects.popper.height,Sv0+yv0,0);c==="top"&&(e.placement="top-start"),e.styles.popper={maxHeight:`${r}px`},e.reset=!0,e.modifiersData[l]._skip=!0},enabled:!0},S3="Mixed";var q=(e=>(e.heading1="heading1",e.heading2="heading2",e.heading3="heading3",e.heading4="heading4",e.custom1="custom1",e.custom2="custom2",e.custom3="custom3",e.quote="quote",e.imageCaption="imageCaption",e.imageTitle="imageTitle",e.p="p",e))(q||{});const bv0=e=>{const[l,c]=o.useState(!1),[r,s]=o.useState(null),[i,d]=o.useState(null),h=V.useEditorState(e),L=zv0(h);let w=S3;L.length===1?w=L[0]:L.length===0&&(w="p");const f=o.useCallback(()=>{c(m=>!m)},[c]),u=a2.usePopper(r,i,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,6]}},{name:"flip",enabled:!1},xv0]});return o.useEffect(()=>{const m=C=>{if(l){const v=C.target;if(i&&i.contains(v)||r&&r.contains(v))return;c(!1)}};return document.addEventListener("pointerdown",m),()=>{document.removeEventListener("pointerdown",m)}},[l,i,c,r]),{state:{isOpen:l,toggle:f,editor:h},dropdownProps:{...u.attributes.popper,style:u.styles.popper},key:w,dropdownRef:d,triggerRef:s}},pv0=({editorId:e,textStyles:l=[]})=>{var u;const{state:{editor:c,toggle:r,isOpen:s},dropdownProps:i,triggerRef:d,dropdownRef:h,key:L}=bv0(e);let w=S3;const f=l.find(m=>{var C;return m.id===L&&((C=m.props)==null?void 0:C.label)});return f&&(w=((u=f.props)==null?void 0:u.label)||S3),t.jsxs(t.Fragment,{children:[t.jsx(Iv0,{label:w,open:s,onClick:r,ref:d}),s&&t.jsx("div",{style:{zIndex:e2.textStyleDropdown},className:"tw-divide-y tw-divide-line tw-bg-base tw-shadow-md tw-border tw-border-line tw-overflow-auto tw-min-h-[40px]",ref:h,...i,children:l.map(m=>{var C;return t.jsx(Cv0,{editor:c,type:m,children:t.jsx("span",{style:m.styles??{},children:(C=m.props)==null?void 0:C.label})},m.id)})})]})},kv0=({editorId:e,id:l,textStyles:c})=>t.jsx(b0,{id:l,children:t.jsx(pv0,{editorId:e,textStyles:c})}),Hv0=(e,l)=>c=>t.jsx(e,{...c,textStyles:l}),Vv0="textstyle-custom1-plugin";class Tv0 extends i0{constructor({styles:c=O0.custom1,...r}={}){super(q.custom1,{label:"Custom 1",markupElement:new Fv0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[Bv0(this.styles)]}}class Fv0 extends s0{constructor(l=Vv0,c=cP){super(l,c)}}const cP=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align;return t.jsx("p",{...l,className:g([s&&K0[s],$0(e)]),style:r,children:c})},Bv0=e=>V.createPluginFactory({key:q.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:q.custom1}]}})({component:l=>t.jsx(cP,{...l,styles:e})}),jv0="textstyle-custom2-plugin";class Pv0 extends i0{constructor({styles:c=O0.custom2,...r}={}){super(q.custom2,{label:"Custom 2",markupElement:new Dv0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[Ov0(this.styles)]}}class Dv0 extends s0{constructor(l=jv0,c=rP){super(l,c)}}const rP=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align;return t.jsx("p",{...l,className:g([s&&K0[s],$0(e)]),style:r,children:c})},Ov0=e=>V.createPluginFactory({key:q.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:q.custom2}]}})({component:l=>t.jsx(rP,{...l,styles:e})}),Zv0="textstyle-custom3-plugin";class Uv0 extends i0{constructor({styles:c=O0.custom3,...r}={}){super(q.custom3,{label:"Custom 3",markupElement:new qv0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[Gv0(this.styles)]}}class qv0 extends s0{constructor(l=Zv0,c=sP){super(l,c)}}const sP=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align;return t.jsx("p",{...l,className:g([s&&K0[s],$0(e)]),style:r,children:c})},Gv0=e=>V.createPluginFactory({key:q.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:q.custom3}]}})({component:l=>t.jsx(sP,{...l,styles:e})}),Wv0="textstyle-heading1-plugin";class Qv0 extends i0{constructor({styles:c=O0.heading1,...r}={}){super(q.heading1,{label:"Heading 1",markupElement:new Ev0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[Yv0(this.styles)]}}class Ev0 extends s0{constructor(l=Wv0,c=Ue){super(l,c)}}const Ue=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align;return t.jsx("h1",{...l,className:g([s&&K0[s],$0(e)]),style:r,children:c})},Yv0=e=>V.createPluginFactory({key:q.heading1,isElement:!0,component:Ue,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:l=>t.jsx(Ue,{...l,styles:e})}),Kv0="textstyle-heading2-plugin";class $v0 extends i0{constructor({styles:c=O0.heading2,...r}={}){super(q.heading2,{label:"Heading 2",markupElement:new Xv0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[Jv0(this.styles)]}}class Xv0 extends s0{constructor(l=Kv0,c=qe){super(l,c)}}const qe=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align;return t.jsx("h2",{...l,className:g([s&&K0[s],$0(e)]),style:r,children:c})},Jv0=e=>V.createPluginFactory({key:q.heading2,isElement:!0,component:qe,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:l=>t.jsx(qe,{...l,styles:e})}),_v0="textstyle-heading3-plugin";class Rv0 extends i0{constructor({styles:c=O0.heading3,...r}={}){super(q.heading3,{label:"Heading 3",markupElement:new eg0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[tg0(this.styles)]}}class eg0 extends s0{constructor(l=_v0,c=Ge){super(l,c)}}const Ge=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align;return t.jsx("h3",{...l,className:g([s&&K0[s],$0(e)]),style:r,children:c})},tg0=e=>V.createPluginFactory({key:q.heading3,isElement:!0,component:Ge,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:l=>t.jsx(Ge,{...l,styles:e})}),lg0="textstyle-heading4-plugin";class ag0 extends i0{constructor({styles:c=O0.heading4,...r}={}){super(q.heading4,{label:"Heading 4",markupElement:new og0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[ng0(this.styles)]}}class og0 extends s0{constructor(l=lg0,c=We){super(l,c)}}const We=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align;return t.jsx("h4",{...l,className:g([s&&K0[s],$0(e)]),style:r,children:c})},ng0=e=>V.createPluginFactory({key:q.heading4,isElement:!0,component:We,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:l=>t.jsx(We,{...l,styles:e})}),cg0="textstyle-imageCaption-plugin";class rg0 extends i0{constructor({styles:c=O0.imageCaption,...r}={}){super(q.imageCaption,{label:"Image Caption",markupElement:new sg0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[ig0(this.styles)]}}class sg0 extends s0{constructor(l=cg0,c=Qe){super(l,c)}}const Qe=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align;return t.jsx("p",{...l,className:g([s&&K0[s],$0(e)]),style:r,children:c})},ig0=e=>V.createPluginFactory({key:q.imageCaption,isElement:!0,component:Qe,deserializeHtml:{rules:[{validClassName:q.imageCaption}]}})({component:l=>t.jsx(Qe,{...l,styles:e})}),dg0="textstyle-imageTitle-plugin";class hg0 extends i0{constructor({styles:c=O0.imageTitle,...r}={}){super(q.imageTitle,{label:"Image Title",markupElement:new Lg0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[wg0(this.styles)]}}class Lg0 extends s0{constructor(l=dg0,c=Ee){super(l,c)}}const Ee=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align;return t.jsx("p",{...l,className:g([s&&K0[s],$0(e)]),style:r,children:c})},wg0=e=>V.createPluginFactory({key:q.imageTitle,isElement:!0,component:Ee,deserializeHtml:{rules:[{validClassName:q.imageTitle}]}})({component:l=>t.jsx(Ee,{...l,styles:e})});class iP extends i0{constructor({styles:c=O0.p,...r}={}){super(q.p,{markupElement:new hP,label:"Body Text",...r});l0(this,"styles",{});this.styles=c}plugins(){return[fg0(this.styles)]}}const dP="tw-m-0 tw-px-0 tw-py-0",y3=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align,i=g([s&&K0[s],dP,$0(e)]);return t.jsx("p",{...l,className:i,style:r,children:c})};class hP extends s0{constructor(l=q.p,c=y3){super(l,c)}}const fg0=e=>V.createPluginFactory({...I1.createParagraphPlugin(),key:q.p,isElement:!0,component:y3})({component:l=>t.jsx(y3,{...l,styles:e})}),ug0="textstyle-quote-plugin";class mg0 extends i0{constructor({styles:c=O0.quote,...r}={}){super(q.quote,{label:"Quote",markupElement:new vg0,...r});l0(this,"styles",{});this.styles=c}plugins(){return[LP(this.styles)]}}class vg0 extends s0{constructor(l=ug0,c=x3){super(l,c)}}const x3=({element:e,attributes:l,children:c,styles:r})=>{const s=e.align;return t.jsx("blockquote",{...l,className:g([s&&K0[s],$0(e)]),style:r,children:c})},LP=e=>V.createPluginFactory({key:q.quote,isElement:!0,component:x3,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:l=>t.jsx(x3,{...l,styles:e})});class wP extends i0{constructor({...c}){super($j,{button:Hv0(kv0,c.textStyles),...c});l0(this,"textStyles");this.textStyles=c.textStyles}plugins(){return this.textStyles.map(c=>c.plugins()).flat()}}const Ye="[&>p]:before:tw-flex [&>p]:before:tw-justify-end [&>p]:before:tw-w-[1.2em] !tw-no-underline !tw-list-item",fP=({attributes:e,children:l,element:c})=>{const{styles:r}=l2();return t.jsx("li",{style:Ke(c,r),...e,className:Ye,children:l})};class uP extends s0{constructor(l=_.ELEMENT_LI,c=fP){super(l,c)}}const Ke=(e,l)=>({...l[mP(e)??q.p],counterIncrement:"count"}),mP=e=>{let l;if(e.type==="a")l=e.children[0].textStyle;else if(e.children)for(const c of e.children){const r=mP(c);r&&(!l||r.startsWith(l))&&(l=r)}else l=e.textStyle;return l},gg0=["[&>li>p]:before:tw-content-[counter(count,decimal)_'._']","[&>li>p]:before:tw-content-[counter(count,_lower-alpha)_'._']","[&>li>p]:before:tw-content-[counter(count,lower-roman)_'._']"],Cg0=(e,l)=>{const c=o2.findNodePath(e,l);if(!c)return 0;const r=U.getNodeAncestors(e,c);return Array.from(r).filter(s=>s[0].type===_.ELEMENT_LI).length},$e=e=>`tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px] [&>li>p]:before:tw-pr-1 [&>li>p]:before:tw-tabular-nums ${gg0[e%3]}`,Xe={counterReset:"count"},vP=({attributes:e,children:l,element:c})=>{const r=V.useEditorRef(),s=Cg0(r,c);return t.jsx("ol",{className:$e(s),...e,style:Xe,children:l})};class gP extends s0{constructor(l=_.ELEMENT_OL,c=vP){super(l,c)}}const Je=o.forwardRef(({nodeType:e=_.ELEMENT_UL,tooltip:l,...c},r)=>{const s=_.useListToolbarButtonState({nodeType:e}),{props:i}=_.useListToolbarButton(s);return t.jsx(c1,{tooltip:l,ref:r,...i,...c})});Je.displayName="ListToolbarButton";const CP=({editor:e,id:l})=>t.jsx(b0,{id:l,children:t.jsx(Je,{tooltip:F0("Ordered list"),nodeType:V.getPluginType(e,l),children:t.jsx(x0,{icon:t.jsx(ge,{})})})});class AP extends Ze{constructor(l){super({id:z3,button:CP,markupElement:new gP,...l})}}const _e="[&>li>p]:before:tw-content-['•'] [&>li>p]:before:tw-px-2 tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px]",IP=({attributes:e,children:l})=>t.jsx("ul",{className:_e,...e,children:l});class NP extends s0{constructor(l=_.ELEMENT_UL,c=IP){super(l,c)}}const MP=({editor:e,id:l})=>t.jsx(b0,{id:l,children:t.jsx(Je,{tooltip:F0("Bullet list"),nodeType:V.getPluginType(e,l),children:t.jsx(x0,{icon:t.jsx(me,{})})})});class zP extends Ze{constructor(l){super({id:z3,button:MP,markupElement:new NP,...l})}}class Ag0{constructor(){l0(this,"toolbarButtons",{[N0.BOTTOM]:[],[N0.FLOATING]:[],[N0.TOP]:[]})}createGroupOfButtons(l){const c=[],r=[],s=[];for(const{markupElement:i,button:d,id:h,showIn:L}of l){if(!d)continue;const w={id:(i==null?void 0:i.getId())||h,button:d};L.includes(N0.BOTTOM)&&c.push(w),L.includes(N0.TOP)&&r.push(w),L.includes(N0.FLOATING)&&s.push(w)}c.length>0&&this.toolbarButtons[N0.BOTTOM].push(c),r.length>0&&this.toolbarButtons[N0.TOP].push(r),s.length>0&&this.toolbarButtons[N0.FLOATING].push(s)}at(l){return this.toolbarButtons[l]}}class SP{constructor(l){l0(this,"platePlugins",new Map);l0(this,"markupElements",{});l0(this,"inlineElements",[]);l0(this,"toolbarButtons",new Ag0);l0(this,"styles",{});this.props=l}setPlugin(...l){for(const c of l){const r=Array.isArray(c)?c:[c];for(const s of r)this.addElement(s.markupElement),this.addElement(s.markupInputElement),this.addLeafElements(s.leafMarkupElements),this.addPlugin(s),this.addInline(s.inline()),s.styles&&this.addStyles(s.styles,s.id),s.textStyles&&this.addTextStylesOfSubPlugins(s.textStyles);this.hasToolbar&&this.toolbarButtons.createGroupOfButtons(r)}return this}addTextStylesOfSubPlugins(l){for(const c of l)c.styles&&this.addStyles(c.styles,c.id)}addLeafElements(l){if(l===void 0)return;const c=Array.isArray(l)?l:[l];for(const r of c)this.addElement(r)}addElement(l){if(l===void 0)return;const c=l.getId(),r=l.getNode();r&&!this.markupElements[c]&&(this.markupElements[c]=r)}addPlugin(l){l.id&&!this.platePlugins.has(l.id)&&this.platePlugins.set(l.id,l.plugins())}addInline(l){l&&this.inlineElements.push(l)}addStyles(l,c){this.styles[c]=l}get elements(){return{...this.defaultElementsFromPlugins,...this.markupElements}}get defaultElementsFromPlugins(){const l={};for(const c of this.platePlugins.values())for(const r of c){const{key:s,component:i}=r;i&&(l[s]=i)}return l}get plugins(){const l=[];for(const c of this.platePlugins.values())l.push(...c);return l}get buttons(){return this.toolbarButtons}get inline(){return this.inlineElements}get hasToolbar(){var l;return!((l=this.props)!=null&&l.noToolbar)}get getStyles(){return this.styles}}const yP="reset-formatting-plugin",xP="reset-formatting",Ig0=e=>{!e||!e.selection||(d1.removeMark(e,{key:[d0.MARK_BOLD,d0.MARK_ITALIC,d0.MARK_CODE,d0.MARK_UNDERLINE,d0.MARK_STRIKETHROUGH]}),_.unwrapList(e,{}),U.setElements(e,{type:I1.ELEMENT_PARAGRAPH,align:void 0}))},Ng0=({id:e,...l})=>{const c=V.useEditorState(V.useEventPlateId(e));return t.jsx(c1,{tooltip:F0("Clear formatting"),onPointerDown:r=>{r.preventDefault(),Ig0(c)},...l,children:t.jsx(x0,{icon:t.jsx(fe,{})})})},Mg0=({id:e})=>t.jsx(b0,{id:e,children:t.jsx(Ng0,{id:e})}),bP=V.createPluginFactory({key:xP,isElement:!1});class pP extends i0{constructor(l){super(yP,{button:Mg0,...l})}plugins(){return[bP()]}}const zg0="autoformat-plugin";class Sg0 extends i0{constructor(l){super(zg0,{...l})}plugins(){return[h1.createAutoformatPlugin({options:{rules:[...h1.autoformatPunctuation,...h1.autoformatArrow,...h1.autoformatLegal,...h1.autoformatSubscriptNumbers,...h1.autoformatSubscriptSymbols,...h1.autoformatSuperscriptNumbers,...h1.autoformatSuperscriptSymbols,...h1.autoformatFraction,{mode:"mark",type:[d0.MARK_UNDERLINE],match:["_","_"],ignoreTrim:!0},{mode:"mark",type:[d0.MARK_BOLD],match:["**","**"],ignoreTrim:!0},{mode:"mark",type:[d0.MARK_ITALIC],match:["*","*"],ignoreTrim:!0},{mode:"mark",type:[d0.MARK_STRIKETHROUGH],match:["~~","~~"],ignoreTrim:!0},{mode:"mark",type:[d0.MARK_CODE],match:["`","`"],ignoreTrim:!0},{mode:"block",match:["# "],type:q.heading1},{mode:"block",match:["## "],type:q.heading2},{mode:"block",match:["### "],type:q.heading3},{mode:"block",match:["#### "],type:q.heading4},{mode:"block",type:_.ELEMENT_UL,match:["- "],preFormat:_.unwrapList,format:l=>_.toggleList(l,{type:_.ELEMENT_UL})},{mode:"block",type:_.ELEMENT_OL,match:["1. ","1) "],preFormat:_.unwrapList,format:l=>_.toggleList(l,{type:_.ELEMENT_OL})},{mode:"block",type:r1,match:["[] "]}]}})]}}const kP=e=>Array.from(U.getNodeEntries(e,{at:[],match:l=>!!l.breakAfterColumn})).length,t5=(e,{key:l=I2,value:c,at:r})=>{const s=i=>U.isBlock(e,i);c?U.setElements(e,{[l]:c},{mode:"lowest",match:s,at:r}):U.unsetNodes(e,l,{match:s,mode:"lowest",at:r})},yg0=(e,l,c)=>{t5(e,{at:l,value:c})},Re=(e,l)=>{const c=Array.from(U.getNodeEntries(e,{at:[],match:r=>!!r.breakAfterColumn}));for(const[r,[,s]]of c.entries())yg0(e,s,r<l-1?"active":"inactive")},HP=(e,l,c)=>{if(c.preventDefault(),c.stopPropagation(),!!(e!=null&&e.selection)&&U.someNode(e,{match:s=>!!s.breakAfterColumn}))t5(e,{value:void 0});else{const s=kP(e),i=Math.max(l-s-1,0);if(i===0)return;const d=Array.from(U.getNodeEntries(e,{at:e.selection,match:h=>U.isBlock(e,h),mode:"lowest"})).slice(-i);for(const h of d)t5(e,{value:"active",at:h[1]})}Re(e,l)},xg0=(e,{options:{hotkey:l}})=>c=>{var r;if(!c.defaultPrevented&&l&&V.isHotkey(l,c)){const s=e.plugins.find(d=>d.key===I2),i=((r=s==null?void 0:s.options)==null?void 0:r.columns)??1;HP(e,i,c)}},bg0=({id:e,...l})=>{var h,L;const c=V.useEditorState(V.useEventPlateId(e)),r=!!(c!=null&&c.selection)&&U.someNode(c,{match:w=>!!w.breakAfterColumn}),s=(L=(h=c==null?void 0:c.pluginsByKey.breakAfterColumn)==null?void 0:h.options)==null?void 0:L.columns,i=Number(s)||1,d=pg0(c,i,r);return t.jsx(c1,{disabled:!d,pressed:!r,tooltip:F0(d?`Column Break
13
- Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onPointerDown:w=>w.preventDefault(),onClick:w=>{HP(c,i,w)},...l,children:t.jsx(x0,{icon:t.jsx(g3,{})})})},pg0=(e,l,c)=>kP(e)+1<l||c,VP=({id:e})=>t.jsx(b0,{id:e,children:t.jsx(bg0,{children:t.jsx(x0,{icon:t.jsx(g3,{})})})}),kg0=(e,l)=>{const c=U.getStartPoint(e,l);setTimeout(()=>{U.select(e,{anchor:c,focus:c})})},Hg0=e=>{var c;const l=e.plugins.find(r=>r.key===I2);return((c=l==null?void 0:l.options)==null?void 0:c.columns)??1},Vg0=e=>{const{apply:l}=e,c=Hg0(e);e.apply=r=>{switch(r.type){case"split_node":r.properties={...r.properties,breakAfterColumn:void 0};break;case"merge_node":const s=U.getPointBefore(e,r.path);if(!s)break;const i=U.getParentNode(e,s.path);if(t5(e,{at:s,value:void 0}),Re(e,c),i!=null&&i[0].breakAfterColumn)return kg0(e,r.path),e;break}l(r)},setTimeout(()=>Re(e,c))},I2="breakAfterColumn",e6="normal";class Tg0 extends i0{constructor(c){super("break-after-plugin",{button:VP,...c});l0(this,"columns");l0(this,"gap");this.columns=(c==null?void 0:c.columns)??1,this.gap=(c==null?void 0:c.gap)??e6}plugins(){return[TP(this.columns,this.gap)]}}const TP=(e,l)=>V.createPluginFactory({key:I2,handlers:{onKeyDown:xg0},useHooks:Vg0,options:{columns:e,gap:l,hotkey:["shift+ctrl+enter"]}})(),FP=e=>V.createPlugins(e.plugins,{components:e.elements}),t6=(e,l)=>({plugins:FP(l),toolbar:c=>l.hasToolbar?t.jsx(Xj,{toolbarButtons:l.buttons,editorId:e,toolbarWidth:c}):null,inline:()=>t.jsx(t.Fragment,{children:l.inline.map((c,r)=>t.jsx(c,{},r))}),styles:()=>l.getStyles}),Fg0="mention-plugin",Bg0=e=>l=>l.text.toLowerCase().includes(e.toLowerCase()),l6=(e,l)=>`${e}:${l}`,a6=e=>{const l=new Map;for(const c of e){const r=l6(c.data.category,c.data.id),s=c.text;l.set(r,s)}return l},BP=(e,l,c)=>e.get(l)??c;var m1=(e=>(e.GROUP="group",e.ALL="all",e.USER="user",e))(m1||{});const o6=({attributes:e,element:l,nodeProps:c,children:r})=>t.jsx("span",{...e,dir:"auto","data-slate-value":l==null?void 0:l.value,"data-slate-key":l==null?void 0:l.key,"data-slate-category":l==null?void 0:l.category,contentEditable:!1,style:{lineHeight:"10px",padding:"1px",margin:"0 1px",fontWeight:"bold",verticalAlign:"baseline",display:"inline-block",borderRadius:"2px",backgroundColor:"rgb(227, 232, 246)",color:"rgb(130, 95, 255)"},...c,children:r}),jg0=({children:e,...l})=>t.jsxs(o6,{...l,children:[t.jsx("span",{style:{paddingRight:"3px",display:"inline-block",margin:"-1px 0"},children:t.jsx(v3,{})}),e]}),Pg0=({children:e,...l})=>t.jsxs(o6,{...l,children:["@",e]}),Dg0=({children:e,...l})=>t.jsx(o6,{...l,children:e}),Og0=({category:e,children:l,...c})=>{const r={[m1.USER]:Dg0,[m1.GROUP]:jg0,[m1.ALL]:Pg0},s=r[e]??r[m1.USER];return t.jsx(s,{...c,children:l})},n6=e=>l=>{const{element:c,children:r}=l,s=l6(c==null?void 0:c.category,String(c==null?void 0:c.id));return t.jsxs(Og0,{category:c==null?void 0:c.category,...l,children:[BP(e,s,String(c==null?void 0:c.id)),r]})};class jP extends s0{constructor(l=F1.ELEMENT_MENTION){super(l)}setNodeWithMentionable(l){return this.node=n6(a6(l)),this}}const Zg0=({image:e,category:l,text:c,id:r})=>{if(e)return t.jsx("img",{src:e,alt:`${r}-${l}-${c}`});switch(l){case m1.GROUP:return t.jsx(v3,{});case m1.ALL:return t.jsx(Me,{});default:return t.jsx(Ae,{})}},Ug0=({item:e})=>{const{data:{image:l,category:c},key:r,text:s}=e;return t.jsxs("div",{className:"tw-flex tw-items-center tw-w-full tw-min-h-[inherit]",children:[t.jsx("span",{className:"tw-flex tw-items-center tw-justify-center tw-rounded-full tw-mr-2.5 tw-bg-base-alt tw-border tw-border-line-weak tw-w-[22px] tw-h-[22px] tw-shrink-0 tw-overflow-hidden group-hover:tw-border-base group-aria-selected:tw-border-base",children:t.jsx(Zg0,{image:l,category:c,text:s,id:r})}),t.jsx("span",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis",children:s})]})};function qg0({pluginKey:e=F1.ELEMENT_MENTION,id:l=e,...c}){const r=V.useEditorRef(),{trigger:s}=V.getPluginOptions(r,e);return t.jsx(xj,{id:l,trigger:s,controlled:!0,onSelectItem:(i,d)=>F1.getMentionOnSelectItem({key:e})(r,d),onRenderItem:Ug0,...c})}const Gg0=e=>()=>t.jsx(qg0,{items:e,filter:Bg0}),Wg0={options:{trigger:"@",insertSpaceAfterMention:!0,createMentionNode:e=>({value:e.text,category:e.data.category,id:e.data.id})}},PP=o.forwardRef(({className:e,onClick:l,...c},r)=>{const{children:s,element:i}=c;return t.jsx(Q3.PlateElement,{ref:r,asChild:!0,"data-slate-value":i.value,className:g(["tw-inline-block tw-rounded-sm tw-shadow-none tw-font-bold tw-leading-[10px] tw-m-0 tw-py-0.5 tw-px-1.5 tw-text-[rgb(130,95,255)] tw-bg-[rgb(227,232,246)]",e]),onClick:E3.getHandler(l,i),...c,children:t.jsx("span",{children:s})})});PP.displayName="MentionInputElement";const Qg0=e=>t.jsx(PP,{...e});class Eg0 extends s0{constructor(l=F1.ELEMENT_MENTION_INPUT,c=Qg0){super(l,c)}}class Yg0 extends i0{constructor(l){super(Fg0,{markupElement:new jP().setNodeWithMentionable(l.mentionableItems),markupInputElement:new Eg0,...l})}inline(){var l;return Gg0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[W0.createComboboxPlugin(),F1.createMentionPlugin(Wg0)]}}const Kg0="blur-on-break-plugin",$g0=(e,{options:{onBreak:l=()=>{}}})=>c=>{V.Hotkeys.isSplitBlock(c)&&(c.stopPropagation(),c.preventDefault(),Tc(),typeof l=="function"&&l(e.children))},Xg0=V.createPluginFactory({key:"blurOnBreak",handlers:{onKeyDown:$g0}});class Jg0 extends i0{constructor(c){super(Kg0,{...c});l0(this,"onBreak");this.onBreak=c==null?void 0:c.onBreak}plugins(){return[Xg0({options:{onBreak:this.onBreak}})]}}const N2=new SP;N2.setPlugin(new pj).setPlugin(new wP({textStyles:[new iP]})).setPlugin([new Vj,new Dj,new Kj,new Uj,new tP,new Bj],[new Ij,new Aj,new Mj,new Nj,new zP,new Cj,new AP,new pP,new bj]);class l5{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=z1(),c=N2){const r=t6(l,c);return this.editor=V.createPlateEditor({id:l,plugins:r.plugins}),this}}l0(l5,"editor"),l0(l5,"editorId",z1());const _g0=e=>e[0].hasOwnProperty("type")?e:[{type:"p",children:e}],DP=[{type:I1.ELEMENT_PARAGRAPH,children:[{text:""}]}],a5=({editorId:e="parseRawValue",raw:l,plugins:c})=>{const r=l5.init(`${e}_parseRawValue`,c).getInstance();let s=DP;if(!l)return s;try{s=JSON.parse(l)}catch{const i=l.trim().replaceAll(/>\s+</g,"><"),d=V.deserializeHtml(r,{element:i});s=_g0(d)}return r.children=s,U.normalizeEditor(r,{force:!0}),r.children},Rg0=({children:e,apply:l})=>{for(const c of e)l({type:"remove_node",path:[0],node:c})},eC0=({value:e})=>{const l=V.useEditorRef();return o.useEffect(()=>{e&&(Rg0(l),U.insertNodes(l,e))},[l,e]),null},tC0=({hideExternalFloatingModals:e})=>{const l=V.useEditorRef(),c=o0.useFloatingLinkSelectors().isOpen(l.id),[r,s]=o.useState(!1),i=o.useCallback(()=>{c&&o0.floatingLinkActions.reset(),e&&e(l.id)},[c,e,l]),d=o.useCallback(()=>{l.collapse(),i()},[l,i]);return o.useEffect(()=>{if(!r)return;const h=L=>{const w=`[data-editor-id='${l.id}']`,f="[role='toolbar']",u="[data-is-underlay]",m=L.target,C=m.closest(u),v=m.closest(Jj),A=m.closest(w),N=m.closest(f);A&&!v||N?i():!A&&!N&&!C&&(d(),s(!1))};return document.addEventListener("pointerdown",h),document.addEventListener("focusin",h),()=>{document.removeEventListener("focusin",h),document.removeEventListener("pointerdown",h)}},[d,i,l.id,r]),o.useEffect(()=>{const h=document.querySelector(`[data-editor-id='${l.id}']`);if(!h)return;const L=()=>{s(!0)};return h.addEventListener("focusin",L),()=>{h.removeEventListener("focusin",L)}},[l.id]),null},lC0={position:"relative",height:"0"},aC0=({children:e,attributes:l})=>{const c={...l,style:{...l.style,...lC0}};return t.jsx("span",{...c,children:e})},OP=({id:e,value:l,placeholder:c="",readonly:r=!1,onTextChange:s,onBlur:i,padding:d=ie.None,position:h=N0.FLOATING,plugins:L=N2,updateValueOnChange:w=!1,onValueChanged:f,border:u=!0,toolbarWidth:m,hideExternalFloatingModals:C})=>{var x,y;const v=M0(e),{localValue:A,onChange:N,memoizedValue:I,config:M}=Ju0({editorId:v,initialValue:l,onTextChange:s,plugins:L,onValueChanged:f}),S=L.plugins.find(T=>T.key===I2),b=((x=S==null?void 0:S.options)==null?void 0:x.columns)??1,k=((y=S==null?void 0:S.options)==null?void 0:y.gap)??e6,p=o.useMemo(()=>({columns:b,columnGap:k,outline:"none"}),[b,k]),B=o.useCallback(()=>{i&&i(JSON.stringify(A.current))},[i,A]),z=o.useCallback(T=>{T.code==="Tab"&&Vc(T,!T.shiftKey)},[]),H={placeholder:c,renderPlaceholder:aC0,readOnly:r,onBlur:B,className:`${d}`,style:p,onKeyDown:z,scrollSelectionIntoView:F4};return t.jsx(dj,{styles:M.styles(),position:h,border:u,editorId:v,children:t.jsxs(V.Plate,{id:v,onChange:N,plugins:M.plugins,initialValue:I,children:[t.jsx(V.PlateContent,{...H}),!H.readOnly&&M.toolbar(m),M.inline(),w&&t.jsx(eC0,{value:a5({editorId:v,raw:l,plugins:L})}),h===N0.FLOATING&&t.jsx(tC0,{hideExternalFloatingModals:C})]})})};OP.displayName="FondueRichTextEditor";const ZP=e=>e.split("").reverse().join(""),M2=(e,l)=>{const c=e.trim(),r=c,s=`${l}${r}${ZP(l)}`;if(r.length===e.length)return s;const i=l+r+ZP(l);return e.replace(c,i)},oC0=(e,l)=>{const c=`
13
+ Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onPointerDown:w=>w.preventDefault(),onClick:w=>{HP(c,i,w)},...l,children:t.jsx(x0,{icon:t.jsx(g3,{})})})},pg0=(e,l,c)=>kP(e)+1<l||c,VP=({id:e})=>t.jsx(b0,{id:e,children:t.jsx(bg0,{children:t.jsx(x0,{icon:t.jsx(g3,{})})})}),kg0=(e,l)=>{const c=U.getStartPoint(e,l);setTimeout(()=>{U.select(e,{anchor:c,focus:c})})},Hg0=e=>{var c;const l=e.plugins.find(r=>r.key===I2);return((c=l==null?void 0:l.options)==null?void 0:c.columns)??1},Vg0=e=>{const{apply:l}=e,c=Hg0(e);e.apply=r=>{switch(r.type){case"split_node":r.properties={...r.properties,breakAfterColumn:void 0};break;case"merge_node":const s=U.getPointBefore(e,r.path);if(!s)break;const i=U.getParentNode(e,s.path);if(t5(e,{at:s,value:void 0}),Re(e,c),i!=null&&i[0].breakAfterColumn)return kg0(e,r.path),e;break}l(r)},setTimeout(()=>Re(e,c))},I2="breakAfterColumn",e6="normal";class Tg0 extends i0{constructor(c){super("break-after-plugin",{button:VP,...c});l0(this,"columns");l0(this,"gap");this.columns=(c==null?void 0:c.columns)??1,this.gap=(c==null?void 0:c.gap)??e6}plugins(){return[TP(this.columns,this.gap)]}}const TP=(e,l)=>V.createPluginFactory({key:I2,handlers:{onKeyDown:xg0},useHooks:Vg0,options:{columns:e,gap:l,hotkey:["shift+ctrl+enter"]}})(),FP=e=>V.createPlugins(e.plugins,{components:e.elements}),t6=(e,l)=>({plugins:FP(l),toolbar:c=>l.hasToolbar?t.jsx(Xj,{toolbarButtons:l.buttons,editorId:e,toolbarWidth:c}):null,inline:()=>t.jsx(t.Fragment,{children:l.inline.map((c,r)=>t.jsx(c,{},r))}),styles:()=>l.getStyles}),Fg0="mention-plugin",Bg0=e=>l=>l.text.toLowerCase().includes(e.toLowerCase()),l6=(e,l)=>`${e}:${l}`,a6=e=>{const l=new Map;for(const c of e){const r=l6(c.data.category,c.data.id),s=c.text;l.set(r,s)}return l},BP=(e,l,c)=>e.get(l)??c;var m1=(e=>(e.GROUP="group",e.ALL="all",e.USER="user",e))(m1||{});const o6=({attributes:e,element:l,nodeProps:c,children:r})=>t.jsx("span",{...e,dir:"auto","data-slate-value":l==null?void 0:l.value,"data-slate-key":l==null?void 0:l.key,"data-slate-category":l==null?void 0:l.category,contentEditable:!1,style:{lineHeight:"10px",padding:"1px",margin:"0 1px",fontWeight:"bold",verticalAlign:"baseline",display:"inline-block",borderRadius:"2px",backgroundColor:"rgb(227, 232, 246)",color:"rgb(130, 95, 255)"},...c,children:r}),jg0=({children:e,...l})=>t.jsxs(o6,{...l,children:[t.jsx("span",{style:{paddingRight:"3px",display:"inline-block",margin:"-1px 0"},children:t.jsx(v3,{})}),e]}),Pg0=({children:e,...l})=>t.jsxs(o6,{...l,children:["@",e]}),Dg0=({children:e,...l})=>t.jsx(o6,{...l,children:e}),Og0=({category:e,children:l,...c})=>{const r={[m1.USER]:Dg0,[m1.GROUP]:jg0,[m1.ALL]:Pg0},s=r[e]??r[m1.USER];return t.jsx(s,{...c,children:l})},n6=e=>l=>{const{element:c,children:r}=l,s=l6(c==null?void 0:c.category,String(c==null?void 0:c.id));return t.jsxs(Og0,{category:c==null?void 0:c.category,...l,children:[BP(e,s,String(c==null?void 0:c.id)),r]})};class jP extends s0{constructor(l=F1.ELEMENT_MENTION){super(l)}setNodeWithMentionable(l){return this.node=n6(a6(l)),this}}const Zg0=({image:e,category:l,text:c,id:r})=>{if(e)return t.jsx("img",{src:e,alt:`${r}-${l}-${c}`});switch(l){case m1.GROUP:return t.jsx(v3,{});case m1.ALL:return t.jsx(Me,{});default:return t.jsx(Ae,{})}},Ug0=({item:e})=>{const{data:{image:l,category:c},key:r,text:s}=e;return t.jsxs("div",{className:"tw-flex tw-items-center tw-w-full tw-min-h-[inherit]",children:[t.jsx("span",{className:"tw-flex tw-items-center tw-justify-center tw-rounded-full tw-mr-2.5 tw-bg-base-alt tw-border tw-border-line-weak tw-w-[22px] tw-h-[22px] tw-shrink-0 tw-overflow-hidden group-hover:tw-border-base group-aria-selected:tw-border-base",children:t.jsx(Zg0,{image:l,category:c,text:s,id:r})}),t.jsx("span",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis",children:s})]})};function qg0({pluginKey:e=F1.ELEMENT_MENTION,id:l=e,...c}){const r=V.useEditorRef(),{trigger:s}=V.getPluginOptions(r,e);return t.jsx(xj,{id:l,trigger:s,controlled:!0,onSelectItem:(i,d)=>F1.getMentionOnSelectItem({key:e})(r,d),onRenderItem:Ug0,...c})}const Gg0=e=>()=>t.jsx(qg0,{items:e,filter:Bg0}),Wg0={options:{trigger:"@",insertSpaceAfterMention:!0,createMentionNode:e=>({value:e.text,category:e.data.category,id:e.data.id})}},PP=o.forwardRef(({className:e,onClick:l,...c},r)=>{const{children:s,element:i}=c;return t.jsx(Q3.PlateElement,{ref:r,asChild:!0,"data-slate-value":i.value,className:g(["tw-inline-block tw-rounded-sm tw-shadow-none tw-font-bold tw-leading-[10px] tw-m-0 tw-py-0.5 tw-px-1.5 tw-text-[rgb(130,95,255)] tw-bg-[rgb(227,232,246)]",e]),onClick:E3.getHandler(l,i),...c,children:t.jsx("span",{children:s})})});PP.displayName="MentionInputElement";const Qg0=e=>t.jsx(PP,{...e});class Eg0 extends s0{constructor(l=F1.ELEMENT_MENTION_INPUT,c=Qg0){super(l,c)}}class Yg0 extends i0{constructor(l){super(Fg0,{markupElement:new jP().setNodeWithMentionable(l.mentionableItems),markupInputElement:new Eg0,...l})}inline(){var l;return Gg0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[W0.createComboboxPlugin(),F1.createMentionPlugin(Wg0)]}}const Kg0="blur-on-break-plugin",$g0=(e,{options:{onBreak:l=()=>{}}})=>c=>{V.Hotkeys.isSplitBlock(c)&&(c.stopPropagation(),c.preventDefault(),Tc(),typeof l=="function"&&l(e.children))},Xg0=V.createPluginFactory({key:"blurOnBreak",handlers:{onKeyDown:$g0}});class Jg0 extends i0{constructor(c){super(Kg0,{...c});l0(this,"onBreak");this.onBreak=c==null?void 0:c.onBreak}plugins(){return[Xg0({options:{onBreak:this.onBreak}})]}}const N2=new SP;N2.setPlugin(new pj).setPlugin(new wP({textStyles:[new iP]})).setPlugin([new Vj,new Dj,new Kj,new Uj,new tP,new Bj],[new Ij,new Aj,new Mj,new Nj,new zP,new Cj,new AP,new pP,new bj]);class l5{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=z1(),c=N2){const r=t6(l,c);return this.editor=V.createPlateEditor({id:l,plugins:r.plugins}),this}}l0(l5,"editor"),l0(l5,"editorId",z1());const _g0=e=>e[0].hasOwnProperty("type")?e:[{type:"p",children:e}],DP=[{type:I1.ELEMENT_PARAGRAPH,children:[{text:""}]}],a5=({editorId:e="parseRawValue",raw:l,plugins:c})=>{const r=l5.init(`${e}_parseRawValue`,c).getInstance();let s=DP;if(!l)return s;try{s=JSON.parse(l)}catch{const i=l.trim().replaceAll(/>\s+</g,"><"),d=V.deserializeHtml(r,{element:i});s=_g0(d)}return r.children=s,U.normalizeEditor(r,{force:!0}),r.children},Rg0=({children:e,apply:l})=>{for(const c of e)l({type:"remove_node",path:[0],node:c})},eC0=({value:e})=>{const l=V.useEditorRef();return o.useEffect(()=>{e&&(Rg0(l),U.insertNodes(l,e))},[l,e]),null},tC0=({hideExternalFloatingModals:e})=>{const l=V.useEditorRef(),c=o0.useFloatingLinkSelectors().isOpen(l.id),[r,s]=o.useState(!1),i=o.useCallback(()=>{c&&o0.floatingLinkActions.hide(),e&&e(l.id)},[c,e,l]),d=o.useCallback(()=>{l.collapse(),i()},[l,i]);return o.useEffect(()=>{if(!r)return;const h=L=>{const w=`[data-editor-id='${l.id}']`,f="[role='toolbar']",u="[data-is-underlay]",m=L.target,C=m.closest(u),v=m.closest(Jj),A=m.closest(w),N=m.closest(f);A&&!v||N?i():!A&&!N&&!C&&(d(),s(!1))};return document.addEventListener("pointerdown",h),document.addEventListener("focusin",h),()=>{document.removeEventListener("focusin",h),document.removeEventListener("pointerdown",h)}},[d,i,l.id,r]),o.useEffect(()=>{const h=document.querySelector(`[data-editor-id='${l.id}']`);if(!h)return;const L=()=>{s(!0)};return h.addEventListener("focusin",L),()=>{h.removeEventListener("focusin",L)}},[l.id]),null},lC0={position:"relative",height:"0"},aC0=({children:e,attributes:l})=>{const c={...l,style:{...l.style,...lC0}};return t.jsx("span",{...c,children:e})},OP=({id:e,value:l,placeholder:c="",readonly:r=!1,onTextChange:s,onBlur:i,padding:d=ie.None,position:h=N0.FLOATING,plugins:L=N2,updateValueOnChange:w=!1,onValueChanged:f,border:u=!0,toolbarWidth:m,hideExternalFloatingModals:C})=>{var x,y;const v=M0(e),{localValue:A,onChange:N,memoizedValue:I,config:M}=Ju0({editorId:v,initialValue:l,onTextChange:s,plugins:L,onValueChanged:f}),S=L.plugins.find(T=>T.key===I2),b=((x=S==null?void 0:S.options)==null?void 0:x.columns)??1,k=((y=S==null?void 0:S.options)==null?void 0:y.gap)??e6,p=o.useMemo(()=>({columns:b,columnGap:k,outline:"none"}),[b,k]),B=o.useCallback(()=>{i&&i(JSON.stringify(A.current))},[i,A]),z=o.useCallback(T=>{T.code==="Tab"&&Vc(T,!T.shiftKey)},[]),H={placeholder:c,renderPlaceholder:aC0,readOnly:r,onBlur:B,className:`${d}`,style:p,onKeyDown:z,scrollSelectionIntoView:F4};return t.jsx(dj,{styles:M.styles(),position:h,border:u,editorId:v,children:t.jsxs(V.Plate,{id:v,onChange:N,plugins:M.plugins,initialValue:I,children:[t.jsx(V.PlateContent,{...H}),!H.readOnly&&M.toolbar(m),M.inline(),w&&t.jsx(eC0,{value:a5({editorId:v,raw:l,plugins:L})}),h===N0.FLOATING&&t.jsx(tC0,{hideExternalFloatingModals:C})]})})};OP.displayName="FondueRichTextEditor";const ZP=e=>e.split("").reverse().join(""),M2=(e,l)=>{const c=e.trim(),r=c,s=`${l}${r}${ZP(l)}`;if(r.length===e.length)return s;const i=l+r+ZP(l);return e.replace(c,i)},oC0=(e,l)=>{const c=`
14
14
  `;return(l.strikethrough||l.bold||l.italic)&&new RegExp(c,"g").test(e)&&(e=e.replaceAll(c,`\\
15
15
  `)),e},nC0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=M2(e,"~~***"):l.bold&&l.italic?e=M2(e,"***"):(l.bold&&(e=M2(e,"**")),l.italic&&(e=M2(e,"_")),l.strikethrough&&(e=M2(e,"~~")),l.code&&(e=M2(e,"`"))),e=oC0(e,l),e),z2=e=>!("type"in e),cC0={paragraph:"paragraph",blockQuote:"block_quote",codeBlock:"code_block",link:"link",ulList:"ul_list",olList:"ol_list",listItem:"list_item",listItemChild:"lic",heading:{1:"heading_one",2:"heading_two",3:"heading_three",4:"heading_four",5:"heading_five",6:"heading_six"},emphasisMark:"italic",strongMark:"bold",deleteMark:"strikethrough",inlineCodeMark:"code",thematicBreak:"thematic_break",image:"image",mention:"mention"},b3={Blank:"_blank",Self:"_self"},UP="[\\d=a-z]+",qP=Object.values(m1).join("|"),rC0=`@\\[(${qP}):${UP}\\]`,GP=`@\\[(${qP}):(${UP})\\]`,sC0=new RegExp(rC0,"gi"),iC0=new RegExp(GP,"i"),WP="<br>",c6={nodeTypes:cC0,ignoreParagraphNewline:!1,listDepth:0,linkDestinationKey:"link"},QP=e=>{var l;return{...c6,...e,nodeTypes:{...c6.nodeTypes,...e==null?void 0:e.nodeTypes,heading:{...c6.nodeTypes.heading,...(l=e==null?void 0:e.nodeTypes)==null?void 0:l.heading}}}},r6=e=>/^(javascript:|data:text\/).+/i.test(e),dC0=e=>`@[${e.category}:${e.id}]`,hC0=e=>`${e}
16
16
  `,LC0=(e,l,c,r)=>{const s=c&&c.parentType===e.olList,i=c.children.length===1&&z2(c.children[0]);let d="";for(let h=0;r>h;h++)s?d+=" ":d+=" ";return`${d}${s?"1.":"-"} ${l}${i?`