@ryzeup/richtexteditor 1.0.19 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1076,7 +1076,7 @@ const Xt = ({
1076
1076
  var E;
1077
1077
  $();
1078
1078
  const e = document.createElement("table");
1079
- e.style.borderCollapse = "collapse", e.style.width = "100%", e.style.border = "1px solid #ccc", e.style.margin = "8px 0", e.style.position = "relative", f.table && e.classList.add(f.table);
1079
+ e.style.borderCollapse = "collapse", e.style.width = "100%", e.style.border = "1px solid #ccc", e.style.margin = "8px 0", e.style.position = "relative", e.style.textAlign = "center", f.table && e.classList.add(f.table);
1080
1080
  const t = document.createElement("thead");
1081
1081
  f.thead && t.classList.add(f.thead);
1082
1082
  const n = document.createElement("tbody");
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var st=Object.defineProperty,ut=Object.defineProperties;var dt=Object.getOwnPropertyDescriptors;var be=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var Ce=(a,c,u)=>c in a?st(a,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[c]=u,te=(a,c)=>{for(var u in c||(c={}))mt.call(c,u)&&Ce(a,u,c[u]);if(be)for(var u of be(c))ft.call(c,u)&&Ce(a,u,c[u]);return a},ne=(a,c)=>ut(a,dt(c));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),gt=require("react-dom");function ht(a){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const u in a)if(u!=="default"){const d=Object.getOwnPropertyDescriptor(a,u);Object.defineProperty(c,u,d.get?d:{enumerable:!0,get:()=>a[u]})}}return c.default=a,Object.freeze(c)}const pt=ht(r);window.React=pt;var Me={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Re=r.createContext&&r.createContext(Me),vt=["attr","size","title"];function yt(a,c){if(a==null)return{};var u=Et(a,c),d,g;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(a);for(g=0;g<w.length;g++)d=w[g],!(c.indexOf(d)>=0)&&Object.prototype.propertyIsEnumerable.call(a,d)&&(u[d]=a[d])}return u}function Et(a,c){if(a==null)return{};var u={};for(var d in a)if(Object.prototype.hasOwnProperty.call(a,d)){if(c.indexOf(d)>=0)continue;u[d]=a[d]}return u}function X(){return X=Object.assign?Object.assign.bind():function(a){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var d in u)Object.prototype.hasOwnProperty.call(u,d)&&(a[d]=u[d])}return a},X.apply(this,arguments)}function Se(a,c){var u=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);c&&(d=d.filter(function(g){return Object.getOwnPropertyDescriptor(a,g).enumerable})),u.push.apply(u,d)}return u}function Y(a){for(var c=1;c<arguments.length;c++){var u=arguments[c]!=null?arguments[c]:{};c%2?Se(Object(u),!0).forEach(function(d){wt(a,d,u[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(u)):Se(Object(u)).forEach(function(d){Object.defineProperty(a,d,Object.getOwnPropertyDescriptor(u,d))})}return a}function wt(a,c,u){return c=bt(c),c in a?Object.defineProperty(a,c,{value:u,enumerable:!0,configurable:!0,writable:!0}):a[c]=u,a}function bt(a){var c=Ct(a,"string");return typeof c=="symbol"?c:c+""}function Ct(a,c){if(typeof a!="object"||!a)return a;var u=a[Symbol.toPrimitive];if(u!==void 0){var d=u.call(a,c);if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(a)}function Ae(a){return a&&a.map((c,u)=>r.createElement(c.tag,Y({key:u},c.attr),Ae(c.child)))}function A(a){return c=>r.createElement(Rt,X({attr:Y({},a.attr)},c),Ae(a.child))}function Rt(a){var c=u=>{var{attr:d,size:g,title:w}=a,R=yt(a,vt),C=g||u.size||"1em",p;return u.className&&(p=u.className),a.className&&(p=(p?p+" ":"")+a.className),r.createElement("svg",X({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,d,R,{className:p,style:Y(Y({color:a.color||u.color},u.style),a.style),height:C,width:C,xmlns:"http://www.w3.org/2000/svg"}),w&&r.createElement("title",null,w),a.children)};return Re!==void 0?r.createElement(Re.Consumer,null,u=>c(u)):c(Me)}function St(a){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(a)}function xt(a){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(a)}function Lt(a){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(a)}function Mt(a){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(a)}function At(a){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function zt(a){return A({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(a)}function kt(a){return A({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(a)}function Nt(a){return A({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(a)}function Tt(a){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(a)}function Dt(a){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function Ot(a){return A({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(a)}function Ht(a){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(a)}function jt(a){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function _t(a){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(a)}function Pt(a){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(a)}const Ft=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],ze=({exec:a,saveSelection:c,handleFileChange:u,handleFontSizeChange:d,handleFontFamilyChange:g,insertEmoji:w,handleLink:R,removeFormatting:C,visibleActions:p,className:D,style:j})=>{var I,T;const z=r.useRef(null),H=r.useRef(null),x=r.useRef(null),[V,U]=r.useState(!1),[F,P]=r.useState({x:0,y:0});r.useEffect(()=>{const m=b=>{!b.target.closest(".rte-emoji-popup")&&!b.target.closest("button[title='Emoji']")&&U(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const _=m=>{var O;m.preventDefault();const b=m.currentTarget.dataset.command;if(b)switch(b){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":a(b);break;case"insertImage":{(O=z.current)==null||O.click();break}default:console.warn("Unknown command:",b)}},Z=m=>{a("foreColor",m.target.value)},Q=m=>{a("backColor",m.target.value)},[M,k]=r.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return r.useEffect(()=>{const m=()=>{k({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",m),()=>document.removeEventListener("selectionchange",m)},[]),r.createElement("div",{className:`rte-toolbar ${D||""}`,style:j},p.bold&&r.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:_,className:M.bold?"rte-active":""},r.createElement(zt,null)),p.italic&&r.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:_,className:M.italic?"rte-active":""},r.createElement(Nt,null)),p.underline&&r.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:_,className:M.underline?"rte-active":""},r.createElement(jt,null)),p.unorderedList&&r.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:_,title:"UnorderedList",className:M.unorderedList?"rte-active":""},r.createElement(Dt,null)),p.orderedList&&r.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:_,className:M.orderedList?"rte-active":""},r.createElement(Mt,null)),p.link&&r.createElement("button",{"data-command":"createLink",title:"Link",onClick:R,className:M.link?"rte-active":""},r.createElement(Tt,null)),p.removeFormat&&r.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:m=>{m.preventDefault(),c(),C()},className:M.removeFormat?"rte-active":""},r.createElement(Pt,null)),p.image&&r.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:_,className:M.image?"rte-active":""},r.createElement(Lt,null)),r.createElement("input",{type:"file",accept:"image/*",ref:z,style:{display:"none"},onChange:u}),p.emoji&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Emoji",onMouseDown:m=>{m.preventDefault(),c();const b=m.currentTarget.getBoundingClientRect();P({x:b.left,y:b.bottom+8}),U(O=>!O)},className:M.emoji?"rte-active":""},r.createElement(Ot,null)),V&&gt.createPortal(r.createElement("div",{className:"rte-emoji-popup",style:{top:F.y,left:F.x}},Ft.map((m,b)=>r.createElement("span",{key:b,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:O=>{O.preventDefault(),w(m),U(!1)}},m))),document.body)),p.color&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Text Color",onMouseDown:m=>{var b;m.preventDefault(),c(),(b=H.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((I=H.current)==null?void 0:I.value)||"#000",fontSize:"18px"},className:M.color?"rte-active":""},r.createElement(_t,null)),r.createElement("input",{ref:H,type:"color",defaultValue:"#000000",onChange:m=>{var b;Z(m),((b=m.target.parentElement)==null?void 0:b.querySelector("button")).style.color=m.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),p.highlight&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Highlight",onMouseDown:m=>{var b;m.preventDefault(),c(),(b=x.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((T=x.current)==null?void 0:T.value)||"#000",fontSize:"18px"},className:M.highlight?"rte-active":""},r.createElement(kt,null)),r.createElement("input",{ref:x,type:"color",onChange:m=>{var b;Q(m),((b=m.target.parentElement)==null?void 0:b.querySelector("button")).style.color=m.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),p.align&&r.createElement(r.Fragment,null,r.createElement("button",{title:"Align Left",onMouseDown:m=>m.preventDefault(),onClick:()=>a("justifyLeft"),className:M.alignLeft?"rte-active":""},r.createElement(At,null)),r.createElement("button",{title:"Align Center",onMouseDown:m=>m.preventDefault(),onClick:()=>a("justifyCenter"),className:M.alignCenter?"rte-active":""},r.createElement(St,null)),r.createElement("button",{title:"Align Right",onMouseDown:m=>m.preventDefault(),onClick:()=>a("justifyRight"),className:M.alignRight?"rte-active":""},r.createElement(xt,null))),p.table&&r.createElement("button",{title:"Insert Table",onMouseDown:m=>m.preventDefault(),onClick:()=>a("insertTable"),className:M.table?"rte-active":""},r.createElement(Ht,null)),p.fontFamily&&r.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:g},r.createElement("option",{value:"",disabled:!0},"Font Family"),r.createElement("option",{value:"Arial"},"Arial"),r.createElement("option",{value:"Georgia"},"Georgia"),r.createElement("option",{value:"Times New Roman"},"Times New Roman"),r.createElement("option",{value:"Courier New"},"Courier New"),r.createElement("option",{value:"Verdana"},"Verdana")),p.fontSize&&r.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:d},r.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(m,b)=>10+b).map(m=>r.createElement("option",{key:m,value:m},m,"px"))))},It=({show:a,position:c,filtered:u,insertMention:d,onClose:g,query:w})=>{const R=r.useRef(null);return r.useEffect(()=>{const C=p=>{R.current&&!R.current.contains(p.target)&&g()};return a&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[a,g]),a?r.createElement("ul",{ref:R,className:"rte-popup",style:{top:c.y,left:c.x}},u.length>0?u.map(({name:C,value:p})=>{const D=C.toLowerCase(),j=w.toLowerCase(),z=D.indexOf(j);let H=C;if(z!==-1&&w.length>0){const x=z+w.length;H=C.substring(0,z)+`<span class="rte-highlight">${C.substring(z,x)}</span>`+C.substring(x)}return r.createElement("li",{key:p,onMouseDown:x=>{x.preventDefault(),d({name:C,value:p})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:H},onMouseEnter:x=>x.currentTarget.style.background="#f0f0f0",onMouseLeave:x=>x.currentTarget.style.background="#fff"})}):r.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function xe(a){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(a)}function K(a){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(a)}const Bt=({visible:a,x:c,y:u,onAction:d,onClose:g})=>{if(!a)return null;const w={top:u,left:c};return r.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:g},r.createElement("button",{onClick:()=>d("insertRowAbove")},r.createElement(K,null)," Insert row above"),r.createElement("button",{onClick:()=>d("insertRowBelow")},r.createElement(K,null)," Insert row below"),r.createElement("button",{onClick:()=>d("insertColLeft")},r.createElement(K,null)," Insert col left"),r.createElement("button",{onClick:()=>d("insertColRight")},r.createElement(K,null)," Insert col right"),r.createElement("button",{onClick:()=>d("deleteRow")},r.createElement(xe,null)," Delete row"),r.createElement("button",{onClick:()=>d("deleteCol")},r.createElement(xe,null)," Delete column"))},ke=({html:a,className:c,style:u})=>{const d=w=>{const R=w.target;if(R.tagName==="A"){w.preventDefault();const C=R.href;C&&window.open(C,"_blank","noopener,noreferrer")}},g=w=>{let R=w.replace(/{{\s*(.*?)\s*}}/g,(C,p)=>`<span style="color: blue">${p}</span>`);return R=R.replace(/#arrayData/g,""),R=R.replace(/\/arrayData/g,""),R};return r.createElement("div",{className:`rte-preview ${c||""}`,style:u,onClick:d,dangerouslySetInnerHTML:{__html:g(a)}})},qt=({visible:a,linkData:c,onClose:u,onInsert:d})=>{const[g,w]=r.useState(""),[R,C]=r.useState(""),[p,D]=r.useState(""),[j,z]=r.useState("_self");if(r.useEffect(()=>{a?(w(c.url||""),C(c.text||""),D(c.title||""),z(c.target||"_self")):(w(""),C(""),D(""),z("_self"))},[a,c]),!a)return null;const H=()=>{d({url:g,text:R,title:p,target:j})};return r.createElement(r.Fragment,null,r.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),r.createElement("div",{className:"rte-link-modal"},r.createElement("h4",{className:"rte-link-modal__title"},g?"Edit Link":"Insert Link"),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:g,onChange:x=>w(x.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:R,onChange:x=>C(x.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:p,onChange:x=>D(x.target.value)}),r.createElement("select",{className:"rte-link-modal__select",value:j,onChange:x=>z(x.target.value)},r.createElement("option",{value:"_self"},"Same tab"),r.createElement("option",{value:"_blank"},"New tab")),r.createElement("div",{className:"rte-link-modal__actions"},r.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),r.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:H},"OK"))))};function Le(a){return Array.from(new Map(a.map(c=>[c.value,c])).values())}const Ut=({atSuggestions:a=[],showOutput:c=!1,showPreview:u=!1,toolbarConfig:d={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:g={},styles:w={},handleGetHtml:R=()=>{},onChange:C=()=>{},value:p,onMentionSelect:D=()=>{},handleAddAttributes:j=()=>{}})=>{var me,fe,ge,he,pe,ve,ye,Ee;const z=r.useRef(null),[H,x]=r.useState(p!=null&&p.length?p:" "),[V,U]=r.useState(""),[F,P]=r.useState(!1),[_,Z]=r.useState({x:0,y:0}),[Q,M]=r.useState([]),k=r.useRef(null),I=r.useRef(null),[T,m]=r.useState({visible:!1,x:0,y:0}),[b,O]=r.useState(!1),$=r.useRef(null),[Ne,re]=r.useState({url:"",text:"",title:"",target:"_self"}),Te={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(me=d.link)!=null?me:!1,image:(fe=d.image)!=null?fe:!1,emoji:(ge=d.emoji)!=null?ge:!1,table:(he=d.table)!=null?he:!1,color:(pe=d.color)!=null?pe:!1,fontFamily:(ve=d.fontFamily)!=null?ve:!1,fontSize:(ye=d.fontSize)!=null?ye:!1,highlight:(Ee=d.fontSize)!=null?Ee:!1},[De,ae]=r.useState(""),[oe,J]=r.useState([]),N=()=>z.current,L=()=>{const e=Oe(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let n=e;t||(n=`<div style="font-size:12px">${e}</div>`),U(n),R==null||R(n);const o=at(e);C(o);const s=Ve(),l=Le(s);JSON.stringify(l)!==JSON.stringify(oe)&&(J(l),D(l))},Oe=()=>{const e=N();if(!e)return H;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(o=>o.remove()),t.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let n=t.innerHTML;return n=He(n),n},He=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),B=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const n=e.getRangeAt(0);t.contains(n.startContainer)&&(k.current=n.cloneRange())},q=()=>{const e=window.getSelection();!e||!k.current||(e.removeAllRanges(),e.addRange(k.current))},le=(e,t)=>{const n=window.getSelection();n&&n.rangeCount>0&&(k.current=n.getRangeAt(0)),q(),document.execCommand(e,!1,t),L()};r.useEffect(()=>{const e=N();if(!e||!p)return;const t=je(p);e.innerHTML=t,L()},[]);const je=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");r.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),r.useEffect(()=>{j&&j(e=>{Ue(e)})},[]),r.useEffect(()=>{const e=N();if(!e)return;e.querySelectorAll("table").forEach(n=>{ue(n),n.querySelectorAll("th, td").forEach(s=>W(s))})},[]);const ce=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},_e=e=>{let t=0,n=e.parentElement;for(;n;)(n.tagName==="UL"||n.tagName==="OL")&&t++,n=n.parentElement;return t},Pe=e=>{const t=e.querySelector("li"),n=t?_e(t):1;if(e.querySelector("[data-hidden-array-start]"))return;const o=`{{#arrayData${n>1?n:""}}}`,s=`{{/arrayData${n>1?n:""}}}`,l=document.createElement("span");l.textContent=o,l.style.display="none",l.setAttribute("data-hidden-array-start","true"),e.insertBefore(l,e.firstChild);const i=document.createElement("span");i.textContent=s,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),e.appendChild(i)},ie=e=>{var v;const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=ce(n.startContainer);let s,l;if(o){let h=o.querySelector(e);h||(h=document.createElement(e),h.style.margin="0",h.style.paddingLeft="20px",o.appendChild(h)),l=h,s=document.createElement("li"),s.textContent="​",l.appendChild(s)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const h=N();if(l=h==null?void 0:h.querySelector(`${e}:last-child`),!l)return;s=l.querySelector("li:last-child")}Pe(l);const i=document.createRange();i.setStart(s,0),i.collapse(!0),t.removeAllRanges(),t.addRange(i),(v=N())==null||v.focus(),L()},G=(e,t)=>{e==="insertOrderedList"?ie("ol"):e==="insertUnorderedList"?ie("ul"):e.startsWith("justify")?lt(e):le(e,t),e==="insertTable"&&Ze()},Fe=e=>{const t=document.createElement("span");t.textContent="​",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const n=t.getBoundingClientRect();t.remove(),Z({x:n.left,y:n.bottom+window.scrollY}),M(a||[]),P(!0),I.current=e.cloneRange()},Ie=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let n=e.anchorOffset;if(!t)return null;let o=t;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[n]?o=o.childNodes[n]:o=t.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const s=o.textContent||"",l=o===t?n:s.length,i=s.lastIndexOf("@",l-1);if(i!==-1){const v=document.createRange();return v.setStart(o,i),v.setEnd(o,l),v}}o=o.previousSibling}return null},Be=e=>{var l;const t=window.getSelection();if(!t)return;const n=Ie();n?(t.removeAllRanges(),t.addRange(n)):I.current&&(t.removeAllRanges(),t.addRange(I.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",o.setAttribute("data-mention",e.value||e.name||"");try{const i=t.rangeCount?t.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(o);else{const E=document.createRange(),f=N();E.selectNodeContents(f),E.collapse(!1),E.insertNode(o)}const v=document.createTextNode(" ");o.after(v);const h=document.createRange();h.setStartAfter(v),h.collapse(!0),t.removeAllRanges(),t.addRange(h)}catch(i){console.error("insertMention error:",i)}let s=Le([...oe,e]);J(s),D(s),P(!1),(l=N())==null||l.focus(),L()},qe=e=>{const t=N();if(!t)return;let n=null;k.current&&t.contains(k.current.startContainer)?n=k.current.cloneRange():(n=document.createRange(),n.selectNodeContents(t),n.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(n);const s=document.createElement("span");s.textContent=`{{${e.name}}}`,s.style.display="inline",s.setAttribute("data-mention",e.value||e.name),n.insertNode(s);const l=document.createTextNode(" ");s.after(l);const i=document.createRange();i.setStartAfter(l),i.collapse(!0),o.removeAllRanges(),o.addRange(i),k.current=i.cloneRange(),t.focus()},Ue=e=>{e.forEach(t=>qe(t)),J(t=>{const n=[...t,...e],o=Array.from(new Map(n.map(s=>[s.name,s])).values());return D(o),o}),L()},Ve=()=>{const e=N();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),n=[];return t.forEach(o=>{const s=o.getAttribute("data-mention")||"",i=(o.textContent||"").match(/{{(.+?)}}/);i&&n.push({name:i[1],value:s})}),n},$e=e=>{var n,o,s;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),G(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const l=window.getSelection(),i=l!=null&&l.anchorNode?ce(l.anchorNode):null;if(!i)return;if(((n=i.textContent)==null?void 0:n.replace(/\u200B/g,"").trim())===""){e.preventDefault();const h=i.parentElement,E=h==null?void 0:h.closest("li");if(E){h==null||h.removeChild(i);const f=document.createElement("p");f.innerHTML="<br />",(o=E.parentElement)==null||o.insertBefore(f,E.nextSibling);const y=document.createRange();y.setStart(f,0),y.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(y)}else{const f=i.closest("ul, ol");if(f){const y=document.createElement("p");y.innerHTML="<br />",(s=f.parentElement)==null||s.insertBefore(y,f.nextSibling),f.removeChild(i);const S=document.createRange();S.setStart(y,0),S.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(S)}}L()}}},We=e=>{if(e.data==="@"){const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.anchorNode;if(Ke(o))return;setTimeout(()=>{Fe(n.getRangeAt(0)),ae(""),M(a),P(!0)},0);return}if(F){setTimeout(()=>se(),0);return}},Ke=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},se=()=>{if(L(),!F)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const n=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!n){P(!1);return}const o=n[1].toLowerCase();ae(o);const s=a.filter(l=>l.name.toLowerCase().includes(o));M(s)},Xe=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const n=new FileReader;n.onload=s=>{var S;const l=(S=s.target)==null?void 0:S.result;q();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const h=document.createElement("img");h.src=l,h.alt=t.name||"image",h.className="rte-inserted-image",h.contentEditable="true";const E=N();if(!v||!E){E==null||E.appendChild(h);const we=document.createTextNode(" ");E==null||E.appendChild(we);const ee=document.createRange();ee.setStartAfter(we),ee.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(ee),E==null||E.focus(),L(),e.target.value="";return}v.deleteContents(),v.insertNode(h);const f=document.createTextNode(" ");h.after(f);const y=document.createRange();y.setStartAfter(f),y.collapse(!0),i.removeAllRanges(),i.addRange(y),E.focus(),L(),e.target.value=""},n.readAsDataURL(t)},Ye=e=>{var s;q();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=document.createTextNode(e);n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),(s=N())==null||s.focus(),L()},Ze=()=>{var E;q();const e=document.createElement("table");e.style.borderCollapse="collapse",e.style.width="100%",e.style.border="1px solid #ccc",e.style.margin="8px 0",e.style.position="relative",g.table&&e.classList.add(g.table);const t=document.createElement("thead");g.thead&&t.classList.add(g.thead);const n=document.createElement("tbody");g.tbody&&n.classList.add(g.tbody);const o=document.createElement("tr");g.tr&&o.classList.add(g.tr);const s=document.createElement("tr");g.tr&&s.classList.add(g.tr);for(let f=0;f<2;f++){const y=document.createElement("th");y.textContent=`Header ${f+1}`,y.style.border="1px solid #999",y.style.padding="4px",y.style.position="relative",y.style.backgroundColor="lightgray",g.th&&y.classList.add(g.th);const S=document.createElement("td");S.textContent=`Row 1 Col ${f+1}`,S.style.border="1px solid #999",S.style.padding="4px",S.style.position="relative",S.style.backgroundColor="#fff",g.td&&S.classList.add(g.td),W(y),W(S),o.appendChild(y),s.appendChild(S)}t.appendChild(o),n.appendChild(s),e.appendChild(t),e.appendChild(n),ue(e);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;const i=l.getRangeAt(0);i.collapse(!1),i.insertNode(e);const v=document.createElement("p");v.innerHTML="<br/>",e.after(v);const h=document.createRange();h.setStart(v,0),h.collapse(!0),l.removeAllRanges(),l.addRange(h),(E=N())==null||E.focus(),L()},ue=e=>{const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),t.style.userSelect="none",t.contentEditable="false";let n=0,o=0,s=0,l=0;t.addEventListener("mousedown",i=>{i.preventDefault(),n=i.clientX,o=i.clientY;const v=e.getBoundingClientRect();s=v.width,l=v.height;const h=f=>{const y=Math.max(100,s+(f.clientX-n)),S=Math.max(60,l+(f.clientY-o));e.style.width=`${y}px`,e.style.height=`${S}px`,L()},E=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",E),L()};document.addEventListener("mousemove",h),document.addEventListener("mouseup",E)}),e.appendChild(t)},W=e=>{const t=document.createElement("div"),n=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",Object.assign(n.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),n.contentEditable="false",Qe(e,t,n),e.appendChild(t),e.appendChild(n)},Qe=(e,t,n)=>{let o=0,s=0,l=0,i=0;t.addEventListener("mousedown",f=>{f.preventDefault(),o=f.clientX,l=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",E)}),n.addEventListener("mousedown",f=>{f.preventDefault(),s=f.clientY,i=e.offsetHeight,document.addEventListener("mousemove",h),document.addEventListener("mouseup",E)});const v=f=>{const y=l+(f.clientX-o);e.style.width=`${Math.max(30,y)}px`,L()},h=f=>{const y=i+(f.clientY-s);e.style.height=`${Math.max(20,y)}px`,L()},E=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",E),L()}},Je=e=>{const n=e.target.closest("td, th");n&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),n.classList.add("rte-cell-highlight"),m({visible:!0,x:e.clientX,y:e.clientY,cell:n}))},de=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Ge=e=>{if(!T.cell)return;const t=T.cell.closest("table"),n=T.cell.cellIndex,o=T.cell.parentElement.rowIndex,s=l=>{const i=l.tagName.toLowerCase(),v=document.createElement(i);return v.textContent=l.textContent||"",v.style.cssText=l.style.cssText,W(v),v};switch(e){case"insertRowAbove":{const l=t.rows[o],i=t.insertRow(o);Array.from(l.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertRowBelow":{const l=t.rows[o],i=t.insertRow(o+1);Array.from(l.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertColLeft":{Array.from(t.rows).forEach(l=>{const i=l.cells[n];l.insertBefore(s(i),i)});break}case"insertColRight":{Array.from(t.rows).forEach(l=>{const i=l.cells[n];l.insertBefore(s(i),i.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(l=>{l.cells[n]&&l.deleteCell(n)});break}L(),m(ne(te({},T),{visible:!1})),de()},et=()=>{B(),$.current=k.current,re({url:"",text:"",title:"",target:"_self"}),O(!0)},tt=e=>{const t=window.getSelection();if(!t||!$.current)return;t.removeAllRanges(),t.addRange($.current);let n=e.url.trim();/^https?:\/\//i.test(n)||(n="https://"+n);const o=document.createElement("a");o.href=n,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||n,o.title=e.title,o.target=e.target,o.contentEditable="true";const s=t.getRangeAt(0);s.deleteContents(),s.insertNode(o);const l=document.createTextNode(" ");o.after(l);const i=document.createRange();i.setStartAfter(l),i.collapse(!0),t.removeAllRanges(),t.addRange(i),O(!1),L()},nt=e=>{const t=e.target;if(t.tagName==="A"){const n=t;if(e.ctrlKey||e.metaKey){window.open(n.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(n),$.current=o,re({url:n.href,text:n.textContent||n.href,title:n.title,target:n.target}),O(!0)}},rt=()=>{const e=N();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&k.current){const f=window.getSelection();f==null||f.removeAllRanges(),f==null||f.addRange(k.current)}const n=window.getSelection();if(!n||n.rangeCount===0)return;const o=n.getRangeAt(0);q(),document.execCommand("removeFormat",!1);const s=o.cloneContents(),l=document.createElement("div");l.appendChild(s);const i=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const f=i.currentNode,y=f.tagName.toUpperCase(),S=f.getAttribute&&f.getAttribute("data-mention")!==null;y!=="A"&&!S&&v.push(f)}for(let f=v.length-1;f>=0;f--){const y=v[f],S=y.parentNode;if(S){for(;y.firstChild;)S.insertBefore(y.firstChild,y);S.removeChild(y)}}l.querySelectorAll("[style]").forEach(f=>f.removeAttribute("style")),o.deleteContents();const h=document.createDocumentFragment();for(;l.firstChild;)h.appendChild(l.firstChild);o.insertNode(h);const E=document.createRange();E.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),E.collapse(!0),n.removeAllRanges(),n.addRange(E),e.normalize(),L()},at=e=>{var o;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const n=document.createElement("div");return n.innerHTML=t,n.querySelectorAll("br").forEach(s=>{s.replaceWith(`
1
+ "use strict";var st=Object.defineProperty,ut=Object.defineProperties;var dt=Object.getOwnPropertyDescriptors;var be=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var Ce=(a,c,u)=>c in a?st(a,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[c]=u,te=(a,c)=>{for(var u in c||(c={}))mt.call(c,u)&&Ce(a,u,c[u]);if(be)for(var u of be(c))ft.call(c,u)&&Ce(a,u,c[u]);return a},ne=(a,c)=>ut(a,dt(c));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),gt=require("react-dom");function ht(a){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const u in a)if(u!=="default"){const d=Object.getOwnPropertyDescriptor(a,u);Object.defineProperty(c,u,d.get?d:{enumerable:!0,get:()=>a[u]})}}return c.default=a,Object.freeze(c)}const pt=ht(r);window.React=pt;var Me={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Re=r.createContext&&r.createContext(Me),vt=["attr","size","title"];function yt(a,c){if(a==null)return{};var u=Et(a,c),d,g;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(a);for(g=0;g<w.length;g++)d=w[g],!(c.indexOf(d)>=0)&&Object.prototype.propertyIsEnumerable.call(a,d)&&(u[d]=a[d])}return u}function Et(a,c){if(a==null)return{};var u={};for(var d in a)if(Object.prototype.hasOwnProperty.call(a,d)){if(c.indexOf(d)>=0)continue;u[d]=a[d]}return u}function X(){return X=Object.assign?Object.assign.bind():function(a){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var d in u)Object.prototype.hasOwnProperty.call(u,d)&&(a[d]=u[d])}return a},X.apply(this,arguments)}function Se(a,c){var u=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);c&&(d=d.filter(function(g){return Object.getOwnPropertyDescriptor(a,g).enumerable})),u.push.apply(u,d)}return u}function Y(a){for(var c=1;c<arguments.length;c++){var u=arguments[c]!=null?arguments[c]:{};c%2?Se(Object(u),!0).forEach(function(d){wt(a,d,u[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(u)):Se(Object(u)).forEach(function(d){Object.defineProperty(a,d,Object.getOwnPropertyDescriptor(u,d))})}return a}function wt(a,c,u){return c=bt(c),c in a?Object.defineProperty(a,c,{value:u,enumerable:!0,configurable:!0,writable:!0}):a[c]=u,a}function bt(a){var c=Ct(a,"string");return typeof c=="symbol"?c:c+""}function Ct(a,c){if(typeof a!="object"||!a)return a;var u=a[Symbol.toPrimitive];if(u!==void 0){var d=u.call(a,c);if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(a)}function Ae(a){return a&&a.map((c,u)=>r.createElement(c.tag,Y({key:u},c.attr),Ae(c.child)))}function A(a){return c=>r.createElement(Rt,X({attr:Y({},a.attr)},c),Ae(a.child))}function Rt(a){var c=u=>{var{attr:d,size:g,title:w}=a,R=yt(a,vt),C=g||u.size||"1em",p;return u.className&&(p=u.className),a.className&&(p=(p?p+" ":"")+a.className),r.createElement("svg",X({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,d,R,{className:p,style:Y(Y({color:a.color||u.color},u.style),a.style),height:C,width:C,xmlns:"http://www.w3.org/2000/svg"}),w&&r.createElement("title",null,w),a.children)};return Re!==void 0?r.createElement(Re.Consumer,null,u=>c(u)):c(Me)}function St(a){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(a)}function xt(a){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(a)}function Lt(a){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(a)}function Mt(a){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(a)}function At(a){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function zt(a){return A({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(a)}function kt(a){return A({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(a)}function Nt(a){return A({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(a)}function Tt(a){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(a)}function Dt(a){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function Ot(a){return A({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(a)}function Ht(a){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(a)}function jt(a){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function _t(a){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(a)}function Pt(a){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(a)}const Ft=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],ze=({exec:a,saveSelection:c,handleFileChange:u,handleFontSizeChange:d,handleFontFamilyChange:g,insertEmoji:w,handleLink:R,removeFormatting:C,visibleActions:p,className:D,style:j})=>{var I,T;const z=r.useRef(null),H=r.useRef(null),x=r.useRef(null),[V,U]=r.useState(!1),[F,P]=r.useState({x:0,y:0});r.useEffect(()=>{const m=b=>{!b.target.closest(".rte-emoji-popup")&&!b.target.closest("button[title='Emoji']")&&U(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const _=m=>{var O;m.preventDefault();const b=m.currentTarget.dataset.command;if(b)switch(b){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":a(b);break;case"insertImage":{(O=z.current)==null||O.click();break}default:console.warn("Unknown command:",b)}},Z=m=>{a("foreColor",m.target.value)},Q=m=>{a("backColor",m.target.value)},[M,k]=r.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return r.useEffect(()=>{const m=()=>{k({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",m),()=>document.removeEventListener("selectionchange",m)},[]),r.createElement("div",{className:`rte-toolbar ${D||""}`,style:j},p.bold&&r.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:_,className:M.bold?"rte-active":""},r.createElement(zt,null)),p.italic&&r.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:_,className:M.italic?"rte-active":""},r.createElement(Nt,null)),p.underline&&r.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:_,className:M.underline?"rte-active":""},r.createElement(jt,null)),p.unorderedList&&r.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:_,title:"UnorderedList",className:M.unorderedList?"rte-active":""},r.createElement(Dt,null)),p.orderedList&&r.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:_,className:M.orderedList?"rte-active":""},r.createElement(Mt,null)),p.link&&r.createElement("button",{"data-command":"createLink",title:"Link",onClick:R,className:M.link?"rte-active":""},r.createElement(Tt,null)),p.removeFormat&&r.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:m=>{m.preventDefault(),c(),C()},className:M.removeFormat?"rte-active":""},r.createElement(Pt,null)),p.image&&r.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:_,className:M.image?"rte-active":""},r.createElement(Lt,null)),r.createElement("input",{type:"file",accept:"image/*",ref:z,style:{display:"none"},onChange:u}),p.emoji&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Emoji",onMouseDown:m=>{m.preventDefault(),c();const b=m.currentTarget.getBoundingClientRect();P({x:b.left,y:b.bottom+8}),U(O=>!O)},className:M.emoji?"rte-active":""},r.createElement(Ot,null)),V&&gt.createPortal(r.createElement("div",{className:"rte-emoji-popup",style:{top:F.y,left:F.x}},Ft.map((m,b)=>r.createElement("span",{key:b,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:O=>{O.preventDefault(),w(m),U(!1)}},m))),document.body)),p.color&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Text Color",onMouseDown:m=>{var b;m.preventDefault(),c(),(b=H.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((I=H.current)==null?void 0:I.value)||"#000",fontSize:"18px"},className:M.color?"rte-active":""},r.createElement(_t,null)),r.createElement("input",{ref:H,type:"color",defaultValue:"#000000",onChange:m=>{var b;Z(m),((b=m.target.parentElement)==null?void 0:b.querySelector("button")).style.color=m.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),p.highlight&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Highlight",onMouseDown:m=>{var b;m.preventDefault(),c(),(b=x.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((T=x.current)==null?void 0:T.value)||"#000",fontSize:"18px"},className:M.highlight?"rte-active":""},r.createElement(kt,null)),r.createElement("input",{ref:x,type:"color",onChange:m=>{var b;Q(m),((b=m.target.parentElement)==null?void 0:b.querySelector("button")).style.color=m.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),p.align&&r.createElement(r.Fragment,null,r.createElement("button",{title:"Align Left",onMouseDown:m=>m.preventDefault(),onClick:()=>a("justifyLeft"),className:M.alignLeft?"rte-active":""},r.createElement(At,null)),r.createElement("button",{title:"Align Center",onMouseDown:m=>m.preventDefault(),onClick:()=>a("justifyCenter"),className:M.alignCenter?"rte-active":""},r.createElement(St,null)),r.createElement("button",{title:"Align Right",onMouseDown:m=>m.preventDefault(),onClick:()=>a("justifyRight"),className:M.alignRight?"rte-active":""},r.createElement(xt,null))),p.table&&r.createElement("button",{title:"Insert Table",onMouseDown:m=>m.preventDefault(),onClick:()=>a("insertTable"),className:M.table?"rte-active":""},r.createElement(Ht,null)),p.fontFamily&&r.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:g},r.createElement("option",{value:"",disabled:!0},"Font Family"),r.createElement("option",{value:"Arial"},"Arial"),r.createElement("option",{value:"Georgia"},"Georgia"),r.createElement("option",{value:"Times New Roman"},"Times New Roman"),r.createElement("option",{value:"Courier New"},"Courier New"),r.createElement("option",{value:"Verdana"},"Verdana")),p.fontSize&&r.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:d},r.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(m,b)=>10+b).map(m=>r.createElement("option",{key:m,value:m},m,"px"))))},It=({show:a,position:c,filtered:u,insertMention:d,onClose:g,query:w})=>{const R=r.useRef(null);return r.useEffect(()=>{const C=p=>{R.current&&!R.current.contains(p.target)&&g()};return a&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[a,g]),a?r.createElement("ul",{ref:R,className:"rte-popup",style:{top:c.y,left:c.x}},u.length>0?u.map(({name:C,value:p})=>{const D=C.toLowerCase(),j=w.toLowerCase(),z=D.indexOf(j);let H=C;if(z!==-1&&w.length>0){const x=z+w.length;H=C.substring(0,z)+`<span class="rte-highlight">${C.substring(z,x)}</span>`+C.substring(x)}return r.createElement("li",{key:p,onMouseDown:x=>{x.preventDefault(),d({name:C,value:p})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:H},onMouseEnter:x=>x.currentTarget.style.background="#f0f0f0",onMouseLeave:x=>x.currentTarget.style.background="#fff"})}):r.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function xe(a){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(a)}function K(a){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(a)}const Bt=({visible:a,x:c,y:u,onAction:d,onClose:g})=>{if(!a)return null;const w={top:u,left:c};return r.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:g},r.createElement("button",{onClick:()=>d("insertRowAbove")},r.createElement(K,null)," Insert row above"),r.createElement("button",{onClick:()=>d("insertRowBelow")},r.createElement(K,null)," Insert row below"),r.createElement("button",{onClick:()=>d("insertColLeft")},r.createElement(K,null)," Insert col left"),r.createElement("button",{onClick:()=>d("insertColRight")},r.createElement(K,null)," Insert col right"),r.createElement("button",{onClick:()=>d("deleteRow")},r.createElement(xe,null)," Delete row"),r.createElement("button",{onClick:()=>d("deleteCol")},r.createElement(xe,null)," Delete column"))},ke=({html:a,className:c,style:u})=>{const d=w=>{const R=w.target;if(R.tagName==="A"){w.preventDefault();const C=R.href;C&&window.open(C,"_blank","noopener,noreferrer")}},g=w=>{let R=w.replace(/{{\s*(.*?)\s*}}/g,(C,p)=>`<span style="color: blue">${p}</span>`);return R=R.replace(/#arrayData/g,""),R=R.replace(/\/arrayData/g,""),R};return r.createElement("div",{className:`rte-preview ${c||""}`,style:u,onClick:d,dangerouslySetInnerHTML:{__html:g(a)}})},qt=({visible:a,linkData:c,onClose:u,onInsert:d})=>{const[g,w]=r.useState(""),[R,C]=r.useState(""),[p,D]=r.useState(""),[j,z]=r.useState("_self");if(r.useEffect(()=>{a?(w(c.url||""),C(c.text||""),D(c.title||""),z(c.target||"_self")):(w(""),C(""),D(""),z("_self"))},[a,c]),!a)return null;const H=()=>{d({url:g,text:R,title:p,target:j})};return r.createElement(r.Fragment,null,r.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),r.createElement("div",{className:"rte-link-modal"},r.createElement("h4",{className:"rte-link-modal__title"},g?"Edit Link":"Insert Link"),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:g,onChange:x=>w(x.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:R,onChange:x=>C(x.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:p,onChange:x=>D(x.target.value)}),r.createElement("select",{className:"rte-link-modal__select",value:j,onChange:x=>z(x.target.value)},r.createElement("option",{value:"_self"},"Same tab"),r.createElement("option",{value:"_blank"},"New tab")),r.createElement("div",{className:"rte-link-modal__actions"},r.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),r.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:H},"OK"))))};function Le(a){return Array.from(new Map(a.map(c=>[c.value,c])).values())}const Ut=({atSuggestions:a=[],showOutput:c=!1,showPreview:u=!1,toolbarConfig:d={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:g={},styles:w={},handleGetHtml:R=()=>{},onChange:C=()=>{},value:p,onMentionSelect:D=()=>{},handleAddAttributes:j=()=>{}})=>{var me,fe,ge,he,pe,ve,ye,Ee;const z=r.useRef(null),[H,x]=r.useState(p!=null&&p.length?p:" "),[V,U]=r.useState(""),[F,P]=r.useState(!1),[_,Z]=r.useState({x:0,y:0}),[Q,M]=r.useState([]),k=r.useRef(null),I=r.useRef(null),[T,m]=r.useState({visible:!1,x:0,y:0}),[b,O]=r.useState(!1),$=r.useRef(null),[Ne,re]=r.useState({url:"",text:"",title:"",target:"_self"}),Te={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(me=d.link)!=null?me:!1,image:(fe=d.image)!=null?fe:!1,emoji:(ge=d.emoji)!=null?ge:!1,table:(he=d.table)!=null?he:!1,color:(pe=d.color)!=null?pe:!1,fontFamily:(ve=d.fontFamily)!=null?ve:!1,fontSize:(ye=d.fontSize)!=null?ye:!1,highlight:(Ee=d.fontSize)!=null?Ee:!1},[De,ae]=r.useState(""),[oe,J]=r.useState([]),N=()=>z.current,L=()=>{const e=Oe(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let n=e;t||(n=`<div style="font-size:12px">${e}</div>`),U(n),R==null||R(n);const o=at(e);C(o);const s=Ve(),l=Le(s);JSON.stringify(l)!==JSON.stringify(oe)&&(J(l),D(l))},Oe=()=>{const e=N();if(!e)return H;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(o=>o.remove()),t.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let n=t.innerHTML;return n=He(n),n},He=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),B=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const n=e.getRangeAt(0);t.contains(n.startContainer)&&(k.current=n.cloneRange())},q=()=>{const e=window.getSelection();!e||!k.current||(e.removeAllRanges(),e.addRange(k.current))},le=(e,t)=>{const n=window.getSelection();n&&n.rangeCount>0&&(k.current=n.getRangeAt(0)),q(),document.execCommand(e,!1,t),L()};r.useEffect(()=>{const e=N();if(!e||!p)return;const t=je(p);e.innerHTML=t,L()},[]);const je=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");r.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),r.useEffect(()=>{j&&j(e=>{Ue(e)})},[]),r.useEffect(()=>{const e=N();if(!e)return;e.querySelectorAll("table").forEach(n=>{ue(n),n.querySelectorAll("th, td").forEach(s=>W(s))})},[]);const ce=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},_e=e=>{let t=0,n=e.parentElement;for(;n;)(n.tagName==="UL"||n.tagName==="OL")&&t++,n=n.parentElement;return t},Pe=e=>{const t=e.querySelector("li"),n=t?_e(t):1;if(e.querySelector("[data-hidden-array-start]"))return;const o=`{{#arrayData${n>1?n:""}}}`,s=`{{/arrayData${n>1?n:""}}}`,l=document.createElement("span");l.textContent=o,l.style.display="none",l.setAttribute("data-hidden-array-start","true"),e.insertBefore(l,e.firstChild);const i=document.createElement("span");i.textContent=s,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),e.appendChild(i)},ie=e=>{var v;const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=ce(n.startContainer);let s,l;if(o){let h=o.querySelector(e);h||(h=document.createElement(e),h.style.margin="0",h.style.paddingLeft="20px",o.appendChild(h)),l=h,s=document.createElement("li"),s.textContent="​",l.appendChild(s)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const h=N();if(l=h==null?void 0:h.querySelector(`${e}:last-child`),!l)return;s=l.querySelector("li:last-child")}Pe(l);const i=document.createRange();i.setStart(s,0),i.collapse(!0),t.removeAllRanges(),t.addRange(i),(v=N())==null||v.focus(),L()},G=(e,t)=>{e==="insertOrderedList"?ie("ol"):e==="insertUnorderedList"?ie("ul"):e.startsWith("justify")?lt(e):le(e,t),e==="insertTable"&&Ze()},Fe=e=>{const t=document.createElement("span");t.textContent="​",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const n=t.getBoundingClientRect();t.remove(),Z({x:n.left,y:n.bottom+window.scrollY}),M(a||[]),P(!0),I.current=e.cloneRange()},Ie=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let n=e.anchorOffset;if(!t)return null;let o=t;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[n]?o=o.childNodes[n]:o=t.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const s=o.textContent||"",l=o===t?n:s.length,i=s.lastIndexOf("@",l-1);if(i!==-1){const v=document.createRange();return v.setStart(o,i),v.setEnd(o,l),v}}o=o.previousSibling}return null},Be=e=>{var l;const t=window.getSelection();if(!t)return;const n=Ie();n?(t.removeAllRanges(),t.addRange(n)):I.current&&(t.removeAllRanges(),t.addRange(I.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",o.setAttribute("data-mention",e.value||e.name||"");try{const i=t.rangeCount?t.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(o);else{const E=document.createRange(),f=N();E.selectNodeContents(f),E.collapse(!1),E.insertNode(o)}const v=document.createTextNode(" ");o.after(v);const h=document.createRange();h.setStartAfter(v),h.collapse(!0),t.removeAllRanges(),t.addRange(h)}catch(i){console.error("insertMention error:",i)}let s=Le([...oe,e]);J(s),D(s),P(!1),(l=N())==null||l.focus(),L()},qe=e=>{const t=N();if(!t)return;let n=null;k.current&&t.contains(k.current.startContainer)?n=k.current.cloneRange():(n=document.createRange(),n.selectNodeContents(t),n.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(n);const s=document.createElement("span");s.textContent=`{{${e.name}}}`,s.style.display="inline",s.setAttribute("data-mention",e.value||e.name),n.insertNode(s);const l=document.createTextNode(" ");s.after(l);const i=document.createRange();i.setStartAfter(l),i.collapse(!0),o.removeAllRanges(),o.addRange(i),k.current=i.cloneRange(),t.focus()},Ue=e=>{e.forEach(t=>qe(t)),J(t=>{const n=[...t,...e],o=Array.from(new Map(n.map(s=>[s.name,s])).values());return D(o),o}),L()},Ve=()=>{const e=N();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),n=[];return t.forEach(o=>{const s=o.getAttribute("data-mention")||"",i=(o.textContent||"").match(/{{(.+?)}}/);i&&n.push({name:i[1],value:s})}),n},$e=e=>{var n,o,s;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),G(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const l=window.getSelection(),i=l!=null&&l.anchorNode?ce(l.anchorNode):null;if(!i)return;if(((n=i.textContent)==null?void 0:n.replace(/\u200B/g,"").trim())===""){e.preventDefault();const h=i.parentElement,E=h==null?void 0:h.closest("li");if(E){h==null||h.removeChild(i);const f=document.createElement("p");f.innerHTML="<br />",(o=E.parentElement)==null||o.insertBefore(f,E.nextSibling);const y=document.createRange();y.setStart(f,0),y.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(y)}else{const f=i.closest("ul, ol");if(f){const y=document.createElement("p");y.innerHTML="<br />",(s=f.parentElement)==null||s.insertBefore(y,f.nextSibling),f.removeChild(i);const S=document.createRange();S.setStart(y,0),S.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(S)}}L()}}},We=e=>{if(e.data==="@"){const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.anchorNode;if(Ke(o))return;setTimeout(()=>{Fe(n.getRangeAt(0)),ae(""),M(a),P(!0)},0);return}if(F){setTimeout(()=>se(),0);return}},Ke=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},se=()=>{if(L(),!F)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const n=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!n){P(!1);return}const o=n[1].toLowerCase();ae(o);const s=a.filter(l=>l.name.toLowerCase().includes(o));M(s)},Xe=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const n=new FileReader;n.onload=s=>{var S;const l=(S=s.target)==null?void 0:S.result;q();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const h=document.createElement("img");h.src=l,h.alt=t.name||"image",h.className="rte-inserted-image",h.contentEditable="true";const E=N();if(!v||!E){E==null||E.appendChild(h);const we=document.createTextNode(" ");E==null||E.appendChild(we);const ee=document.createRange();ee.setStartAfter(we),ee.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(ee),E==null||E.focus(),L(),e.target.value="";return}v.deleteContents(),v.insertNode(h);const f=document.createTextNode(" ");h.after(f);const y=document.createRange();y.setStartAfter(f),y.collapse(!0),i.removeAllRanges(),i.addRange(y),E.focus(),L(),e.target.value=""},n.readAsDataURL(t)},Ye=e=>{var s;q();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=document.createTextNode(e);n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),(s=N())==null||s.focus(),L()},Ze=()=>{var E;q();const e=document.createElement("table");e.style.borderCollapse="collapse",e.style.width="100%",e.style.border="1px solid #ccc",e.style.margin="8px 0",e.style.position="relative",e.style.textAlign="center",g.table&&e.classList.add(g.table);const t=document.createElement("thead");g.thead&&t.classList.add(g.thead);const n=document.createElement("tbody");g.tbody&&n.classList.add(g.tbody);const o=document.createElement("tr");g.tr&&o.classList.add(g.tr);const s=document.createElement("tr");g.tr&&s.classList.add(g.tr);for(let f=0;f<2;f++){const y=document.createElement("th");y.textContent=`Header ${f+1}`,y.style.border="1px solid #999",y.style.padding="4px",y.style.position="relative",y.style.backgroundColor="lightgray",g.th&&y.classList.add(g.th);const S=document.createElement("td");S.textContent=`Row 1 Col ${f+1}`,S.style.border="1px solid #999",S.style.padding="4px",S.style.position="relative",S.style.backgroundColor="#fff",g.td&&S.classList.add(g.td),W(y),W(S),o.appendChild(y),s.appendChild(S)}t.appendChild(o),n.appendChild(s),e.appendChild(t),e.appendChild(n),ue(e);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;const i=l.getRangeAt(0);i.collapse(!1),i.insertNode(e);const v=document.createElement("p");v.innerHTML="<br/>",e.after(v);const h=document.createRange();h.setStart(v,0),h.collapse(!0),l.removeAllRanges(),l.addRange(h),(E=N())==null||E.focus(),L()},ue=e=>{const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),t.style.userSelect="none",t.contentEditable="false";let n=0,o=0,s=0,l=0;t.addEventListener("mousedown",i=>{i.preventDefault(),n=i.clientX,o=i.clientY;const v=e.getBoundingClientRect();s=v.width,l=v.height;const h=f=>{const y=Math.max(100,s+(f.clientX-n)),S=Math.max(60,l+(f.clientY-o));e.style.width=`${y}px`,e.style.height=`${S}px`,L()},E=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",E),L()};document.addEventListener("mousemove",h),document.addEventListener("mouseup",E)}),e.appendChild(t)},W=e=>{const t=document.createElement("div"),n=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",Object.assign(n.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),n.contentEditable="false",Qe(e,t,n),e.appendChild(t),e.appendChild(n)},Qe=(e,t,n)=>{let o=0,s=0,l=0,i=0;t.addEventListener("mousedown",f=>{f.preventDefault(),o=f.clientX,l=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",E)}),n.addEventListener("mousedown",f=>{f.preventDefault(),s=f.clientY,i=e.offsetHeight,document.addEventListener("mousemove",h),document.addEventListener("mouseup",E)});const v=f=>{const y=l+(f.clientX-o);e.style.width=`${Math.max(30,y)}px`,L()},h=f=>{const y=i+(f.clientY-s);e.style.height=`${Math.max(20,y)}px`,L()},E=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",E),L()}},Je=e=>{const n=e.target.closest("td, th");n&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),n.classList.add("rte-cell-highlight"),m({visible:!0,x:e.clientX,y:e.clientY,cell:n}))},de=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Ge=e=>{if(!T.cell)return;const t=T.cell.closest("table"),n=T.cell.cellIndex,o=T.cell.parentElement.rowIndex,s=l=>{const i=l.tagName.toLowerCase(),v=document.createElement(i);return v.textContent=l.textContent||"",v.style.cssText=l.style.cssText,W(v),v};switch(e){case"insertRowAbove":{const l=t.rows[o],i=t.insertRow(o);Array.from(l.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertRowBelow":{const l=t.rows[o],i=t.insertRow(o+1);Array.from(l.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertColLeft":{Array.from(t.rows).forEach(l=>{const i=l.cells[n];l.insertBefore(s(i),i)});break}case"insertColRight":{Array.from(t.rows).forEach(l=>{const i=l.cells[n];l.insertBefore(s(i),i.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(l=>{l.cells[n]&&l.deleteCell(n)});break}L(),m(ne(te({},T),{visible:!1})),de()},et=()=>{B(),$.current=k.current,re({url:"",text:"",title:"",target:"_self"}),O(!0)},tt=e=>{const t=window.getSelection();if(!t||!$.current)return;t.removeAllRanges(),t.addRange($.current);let n=e.url.trim();/^https?:\/\//i.test(n)||(n="https://"+n);const o=document.createElement("a");o.href=n,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||n,o.title=e.title,o.target=e.target,o.contentEditable="true";const s=t.getRangeAt(0);s.deleteContents(),s.insertNode(o);const l=document.createTextNode(" ");o.after(l);const i=document.createRange();i.setStartAfter(l),i.collapse(!0),t.removeAllRanges(),t.addRange(i),O(!1),L()},nt=e=>{const t=e.target;if(t.tagName==="A"){const n=t;if(e.ctrlKey||e.metaKey){window.open(n.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(n),$.current=o,re({url:n.href,text:n.textContent||n.href,title:n.title,target:n.target}),O(!0)}},rt=()=>{const e=N();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&k.current){const f=window.getSelection();f==null||f.removeAllRanges(),f==null||f.addRange(k.current)}const n=window.getSelection();if(!n||n.rangeCount===0)return;const o=n.getRangeAt(0);q(),document.execCommand("removeFormat",!1);const s=o.cloneContents(),l=document.createElement("div");l.appendChild(s);const i=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const f=i.currentNode,y=f.tagName.toUpperCase(),S=f.getAttribute&&f.getAttribute("data-mention")!==null;y!=="A"&&!S&&v.push(f)}for(let f=v.length-1;f>=0;f--){const y=v[f],S=y.parentNode;if(S){for(;y.firstChild;)S.insertBefore(y.firstChild,y);S.removeChild(y)}}l.querySelectorAll("[style]").forEach(f=>f.removeAttribute("style")),o.deleteContents();const h=document.createDocumentFragment();for(;l.firstChild;)h.appendChild(l.firstChild);o.insertNode(h);const E=document.createRange();E.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),E.collapse(!0),n.removeAllRanges(),n.addRange(E),e.normalize(),L()},at=e=>{var o;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const n=document.createElement("div");return n.innerHTML=t,n.querySelectorAll("br").forEach(s=>{s.replaceWith(`
2
2
  `)}),n.querySelectorAll("p, div, tr").forEach(s=>{s.insertAdjacentText("afterend",`
3
3
  `)}),n.querySelectorAll("table").forEach(s=>{s.insertAdjacentText("afterend",`
4
4
  `)}),((o=n.textContent)==null?void 0:o.replace(/\n{3,}/g,`
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(A,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],t):(A=typeof globalThis!="undefined"?globalThis:A||self,t(A.RichTextEditor={},A.React,A.ReactDOM))})(this,(function(A,t,O){"use strict";var Bt=Object.defineProperty,qt=Object.defineProperties;var Rt=Object.getOwnPropertyDescriptors;var Ne=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var De=(A,t,O)=>t in A?Bt(A,t,{enumerable:!0,configurable:!0,writable:!0,value:O}):A[t]=O,re=(A,t)=>{for(var O in t||(t={}))Ut.call(t,O)&&De(A,O,t[O]);if(Ne)for(var O of Ne(t))Vt.call(t,O)&&De(A,O,t[O]);return A},oe=(A,t)=>qt(A,Rt(t));function Oe(o){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const d in o)if(d!=="default"){const u=Object.getOwnPropertyDescriptor(o,d);Object.defineProperty(c,d,u.get?u:{enumerable:!0,get:()=>o[d]})}}return c.default=o,Object.freeze(c)}const je=Oe(t);window.React=je;var le={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ae=t.createContext&&t.createContext(le),He=["attr","size","title"];function _e(o,c){if(o==null)return{};var d=Pe(o,c),u,g;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(o);for(g=0;g<w.length;g++)u=w[g],!(c.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(o,u)&&(d[u]=o[u])}return d}function Pe(o,c){if(o==null)return{};var d={};for(var u in o)if(Object.prototype.hasOwnProperty.call(o,u)){if(c.indexOf(u)>=0)continue;d[u]=o[u]}return d}function W(){return W=Object.assign?Object.assign.bind():function(o){for(var c=1;c<arguments.length;c++){var d=arguments[c];for(var u in d)Object.prototype.hasOwnProperty.call(d,u)&&(o[u]=d[u])}return o},W.apply(this,arguments)}function ie(o,c){var d=Object.keys(o);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(o);c&&(u=u.filter(function(g){return Object.getOwnPropertyDescriptor(o,g).enumerable})),d.push.apply(d,u)}return d}function K(o){for(var c=1;c<arguments.length;c++){var d=arguments[c]!=null?arguments[c]:{};c%2?ie(Object(d),!0).forEach(function(u){Fe(o,u,d[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(d)):ie(Object(d)).forEach(function(u){Object.defineProperty(o,u,Object.getOwnPropertyDescriptor(d,u))})}return o}function Fe(o,c,d){return c=Ie(c),c in o?Object.defineProperty(o,c,{value:d,enumerable:!0,configurable:!0,writable:!0}):o[c]=d,o}function Ie(o){var c=Be(o,"string");return typeof c=="symbol"?c:c+""}function Be(o,c){if(typeof o!="object"||!o)return o;var d=o[Symbol.toPrimitive];if(d!==void 0){var u=d.call(o,c);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(o)}function se(o){return o&&o.map((c,d)=>t.createElement(c.tag,K({key:d},c.attr),se(c.child)))}function k(o){return c=>t.createElement(qe,W({attr:K({},o.attr)},c),se(o.child))}function qe(o){var c=d=>{var{attr:u,size:g,title:w}=o,S=_e(o,He),C=g||d.size||"1em",p;return d.className&&(p=d.className),o.className&&(p=(p?p+" ":"")+o.className),t.createElement("svg",W({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},d.attr,u,S,{className:p,style:K(K({color:o.color||d.color},d.style),o.style),height:C,width:C,xmlns:"http://www.w3.org/2000/svg"}),w&&t.createElement("title",null,w),o.children)};return ae!==void 0?t.createElement(ae.Consumer,null,d=>c(d)):c(le)}function Re(o){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(o)}function Ue(o){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(o)}function Ve(o){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(o)}function $e(o){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(o)}function We(o){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function Ke(o){return k({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(o)}function Xe(o){return k({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(o)}function Ye(o){return k({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(o)}function Ze(o){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(o)}function Qe(o){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function Je(o){return k({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(o)}function Ge(o){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(o)}function et(o){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function tt(o){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(o)}function nt(o){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(o)}const rt=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],ce=({exec:o,saveSelection:c,handleFileChange:d,handleFontSizeChange:u,handleFontFamilyChange:g,insertEmoji:w,handleLink:S,removeFormatting:C,visibleActions:p,className:H,style:F})=>{var R,j;const T=t.useRef(null),P=t.useRef(null),L=t.useRef(null),[Y,$]=t.useState(!1),[q,B]=t.useState({x:0,y:0});t.useEffect(()=>{const m=b=>{!b.target.closest(".rte-emoji-popup")&&!b.target.closest("button[title='Emoji']")&&$(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const I=m=>{var _;m.preventDefault();const b=m.currentTarget.dataset.command;if(b)switch(b){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":o(b);break;case"insertImage":{(_=T.current)==null||_.click();break}default:console.warn("Unknown command:",b)}},J=m=>{o("foreColor",m.target.value)},G=m=>{o("backColor",m.target.value)},[z,N]=t.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return t.useEffect(()=>{const m=()=>{N({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",m),()=>document.removeEventListener("selectionchange",m)},[]),t.createElement("div",{className:`rte-toolbar ${H||""}`,style:F},p.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:I,className:z.bold?"rte-active":""},t.createElement(Ke,null)),p.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:I,className:z.italic?"rte-active":""},t.createElement(Ye,null)),p.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:I,className:z.underline?"rte-active":""},t.createElement(et,null)),p.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:I,title:"UnorderedList",className:z.unorderedList?"rte-active":""},t.createElement(Qe,null)),p.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:I,className:z.orderedList?"rte-active":""},t.createElement($e,null)),p.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:S,className:z.link?"rte-active":""},t.createElement(Ze,null)),p.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:m=>{m.preventDefault(),c(),C()},className:z.removeFormat?"rte-active":""},t.createElement(nt,null)),p.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:I,className:z.image?"rte-active":""},t.createElement(Ve,null)),t.createElement("input",{type:"file",accept:"image/*",ref:T,style:{display:"none"},onChange:d}),p.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:m=>{m.preventDefault(),c();const b=m.currentTarget.getBoundingClientRect();B({x:b.left,y:b.bottom+8}),$(_=>!_)},className:z.emoji?"rte-active":""},t.createElement(Je,null)),Y&&O.createPortal(t.createElement("div",{className:"rte-emoji-popup",style:{top:q.y,left:q.x}},rt.map((m,b)=>t.createElement("span",{key:b,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:_=>{_.preventDefault(),w(m),$(!1)}},m))),document.body)),p.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:m=>{var b;m.preventDefault(),c(),(b=P.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((R=P.current)==null?void 0:R.value)||"#000",fontSize:"18px"},className:z.color?"rte-active":""},t.createElement(tt,null)),t.createElement("input",{ref:P,type:"color",defaultValue:"#000000",onChange:m=>{var b;J(m),((b=m.target.parentElement)==null?void 0:b.querySelector("button")).style.color=m.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),p.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:m=>{var b;m.preventDefault(),c(),(b=L.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((j=L.current)==null?void 0:j.value)||"#000",fontSize:"18px"},className:z.highlight?"rte-active":""},t.createElement(Xe,null)),t.createElement("input",{ref:L,type:"color",onChange:m=>{var b;G(m),((b=m.target.parentElement)==null?void 0:b.querySelector("button")).style.color=m.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),p.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:m=>m.preventDefault(),onClick:()=>o("justifyLeft"),className:z.alignLeft?"rte-active":""},t.createElement(We,null)),t.createElement("button",{title:"Align Center",onMouseDown:m=>m.preventDefault(),onClick:()=>o("justifyCenter"),className:z.alignCenter?"rte-active":""},t.createElement(Re,null)),t.createElement("button",{title:"Align Right",onMouseDown:m=>m.preventDefault(),onClick:()=>o("justifyRight"),className:z.alignRight?"rte-active":""},t.createElement(Ue,null))),p.table&&t.createElement("button",{title:"Insert Table",onMouseDown:m=>m.preventDefault(),onClick:()=>o("insertTable"),className:z.table?"rte-active":""},t.createElement(Ge,null)),p.fontFamily&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:g},t.createElement("option",{value:"",disabled:!0},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Times New Roman"},"Times New Roman"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Verdana"},"Verdana")),p.fontSize&&t.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:u},t.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(m,b)=>10+b).map(m=>t.createElement("option",{key:m,value:m},m,"px"))))},ot=({show:o,position:c,filtered:d,insertMention:u,onClose:g,query:w})=>{const S=t.useRef(null);return t.useEffect(()=>{const C=p=>{S.current&&!S.current.contains(p.target)&&g()};return o&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[o,g]),o?t.createElement("ul",{ref:S,className:"rte-popup",style:{top:c.y,left:c.x}},d.length>0?d.map(({name:C,value:p})=>{const H=C.toLowerCase(),F=w.toLowerCase(),T=H.indexOf(F);let P=C;if(T!==-1&&w.length>0){const L=T+w.length;P=C.substring(0,T)+`<span class="rte-highlight">${C.substring(T,L)}</span>`+C.substring(L)}return t.createElement("li",{key:p,onMouseDown:L=>{L.preventDefault(),u({name:C,value:p})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:P},onMouseEnter:L=>L.currentTarget.style.background="#f0f0f0",onMouseLeave:L=>L.currentTarget.style.background="#fff"})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ue(o){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(o)}function X(o){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(o)}const lt=({visible:o,x:c,y:d,onAction:u,onClose:g})=>{if(!o)return null;const w={top:d,left:c};return t.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:g},t.createElement("button",{onClick:()=>u("insertRowAbove")},t.createElement(X,null)," Insert row above"),t.createElement("button",{onClick:()=>u("insertRowBelow")},t.createElement(X,null)," Insert row below"),t.createElement("button",{onClick:()=>u("insertColLeft")},t.createElement(X,null)," Insert col left"),t.createElement("button",{onClick:()=>u("insertColRight")},t.createElement(X,null)," Insert col right"),t.createElement("button",{onClick:()=>u("deleteRow")},t.createElement(ue,null)," Delete row"),t.createElement("button",{onClick:()=>u("deleteCol")},t.createElement(ue,null)," Delete column"))},de=({html:o,className:c,style:d})=>{const u=w=>{const S=w.target;if(S.tagName==="A"){w.preventDefault();const C=S.href;C&&window.open(C,"_blank","noopener,noreferrer")}},g=w=>{let S=w.replace(/{{\s*(.*?)\s*}}/g,(C,p)=>`<span style="color: blue">${p}</span>`);return S=S.replace(/#arrayData/g,""),S=S.replace(/\/arrayData/g,""),S};return t.createElement("div",{className:`rte-preview ${c||""}`,style:d,onClick:u,dangerouslySetInnerHTML:{__html:g(o)}})},at=({visible:o,linkData:c,onClose:d,onInsert:u})=>{const[g,w]=t.useState(""),[S,C]=t.useState(""),[p,H]=t.useState(""),[F,T]=t.useState("_self");if(t.useEffect(()=>{o?(w(c.url||""),C(c.text||""),H(c.title||""),T(c.target||"_self")):(w(""),C(""),H(""),T("_self"))},[o,c]),!o)return null;const P=()=>{u({url:g,text:S,title:p,target:F})};return t.createElement(t.Fragment,null,t.createElement("div",{className:"rte-link-modal-overlay",onClick:d}),t.createElement("div",{className:"rte-link-modal"},t.createElement("h4",{className:"rte-link-modal__title"},g?"Edit Link":"Insert Link"),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:g,onChange:L=>w(L.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:S,onChange:L=>C(L.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:p,onChange:L=>H(L.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:F,onChange:L=>T(L.target.value)},t.createElement("option",{value:"_self"},"Same tab"),t.createElement("option",{value:"_blank"},"New tab")),t.createElement("div",{className:"rte-link-modal__actions"},t.createElement("button",{className:"rte-link-modal__btn",onClick:d},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:P},"OK"))))};function me(o){return Array.from(new Map(o.map(c=>[c.value,c])).values())}const it=({atSuggestions:o=[],showOutput:c=!1,showPreview:d=!1,toolbarConfig:u={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:g={},styles:w={},handleGetHtml:S=()=>{},onChange:C=()=>{},value:p,onMentionSelect:H=()=>{},handleAddAttributes:F=()=>{}})=>{var Ce,Se,xe,Le,Me,Ae,ze,ke;const T=t.useRef(null),[P,L]=t.useState(p!=null&&p.length?p:" "),[Y,$]=t.useState(""),[q,B]=t.useState(!1),[I,J]=t.useState({x:0,y:0}),[G,z]=t.useState([]),N=t.useRef(null),R=t.useRef(null),[j,m]=t.useState({visible:!1,x:0,y:0}),[b,_]=t.useState(!1),Z=t.useRef(null),[st,fe]=t.useState({url:"",text:"",title:"",target:"_self"}),ct={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(Ce=u.link)!=null?Ce:!1,image:(Se=u.image)!=null?Se:!1,emoji:(xe=u.emoji)!=null?xe:!1,table:(Le=u.table)!=null?Le:!1,color:(Me=u.color)!=null?Me:!1,fontFamily:(Ae=u.fontFamily)!=null?Ae:!1,fontSize:(ze=u.fontSize)!=null?ze:!1,highlight:(ke=u.fontSize)!=null?ke:!1},[ut,ge]=t.useState(""),[he,ee]=t.useState([]),D=()=>T.current,M=()=>{const e=dt(),n=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;n||(r=`<div style="font-size:12px">${e}</div>`),$(r),S==null||S(r);const l=Ht(e);C(l);const s=bt(),a=me(s);JSON.stringify(a)!==JSON.stringify(he)&&(ee(a),H(a))},dt=()=>{const e=D();if(!e)return P;const n=e.cloneNode(!0);n.querySelectorAll("table div").forEach(l=>l.remove()),n.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight"));let r=n.innerHTML;return r=mt(r),r},mt=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),U=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=document.getElementById("rte-editor-body");if(!n)return;const r=e.getRangeAt(0);n.contains(r.startContainer)&&(N.current=r.cloneRange())},V=()=>{const e=window.getSelection();!e||!N.current||(e.removeAllRanges(),e.addRange(N.current))},pe=(e,n)=>{const r=window.getSelection();r&&r.rangeCount>0&&(N.current=r.getRangeAt(0)),V(),document.execCommand(e,!1,n),M()};t.useEffect(()=>{const e=D();if(!e||!p)return;const n=ft(p);e.innerHTML=n,M()},[]);const ft=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),t.useEffect(()=>{F&&F(e=>{wt(e)})},[]),t.useEffect(()=>{const e=D();if(!e)return;e.querySelectorAll("table").forEach(r=>{we(r),r.querySelectorAll("th, td").forEach(s=>Q(s))})},[]);const ve=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},gt=e=>{let n=0,r=e.parentElement;for(;r;)(r.tagName==="UL"||r.tagName==="OL")&&n++,r=r.parentElement;return n},ht=e=>{const n=e.querySelector("li"),r=n?gt(n):1;if(e.querySelector("[data-hidden-array-start]"))return;const l=`{{#arrayData${r>1?r:""}}}`,s=`{{/arrayData${r>1?r:""}}}`,a=document.createElement("span");a.textContent=l,a.style.display="none",a.setAttribute("data-hidden-array-start","true"),e.insertBefore(a,e.firstChild);const i=document.createElement("span");i.textContent=s,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),e.appendChild(i)},ye=e=>{var v;const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const r=n.getRangeAt(0),l=ve(r.startContainer);let s,a;if(l){let h=l.querySelector(e);h||(h=document.createElement(e),h.style.margin="0",h.style.paddingLeft="20px",l.appendChild(h)),a=h,s=document.createElement("li"),s.textContent="​",a.appendChild(s)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const h=D();if(a=h==null?void 0:h.querySelector(`${e}:last-child`),!a)return;s=a.querySelector("li:last-child")}ht(a);const i=document.createRange();i.setStart(s,0),i.collapse(!0),n.removeAllRanges(),n.addRange(i),(v=D())==null||v.focus(),M()},te=(e,n)=>{e==="insertOrderedList"?ye("ol"):e==="insertUnorderedList"?ye("ul"):e.startsWith("justify")?Pt(e):pe(e,n),e==="insertTable"&&At()},pt=e=>{const n=document.createElement("span");n.textContent="​",e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=n.getBoundingClientRect();n.remove(),J({x:r.left,y:r.bottom+window.scrollY}),z(o||[]),B(!0),R.current=e.cloneRange()},vt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.anchorNode;let r=e.anchorOffset;if(!n)return null;let l=n;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=n.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const s=l.textContent||"",a=l===n?r:s.length,i=s.lastIndexOf("@",a-1);if(i!==-1){const v=document.createRange();return v.setStart(l,i),v.setEnd(l,a),v}}l=l.previousSibling}return null},yt=e=>{var a;const n=window.getSelection();if(!n)return;const r=vt();r?(n.removeAllRanges(),n.addRange(r)):R.current&&(n.removeAllRanges(),n.addRange(R.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.display="inline",l.setAttribute("data-mention",e.value||e.name||"");try{const i=n.rangeCount?n.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(l);else{const E=document.createRange(),f=D();E.selectNodeContents(f),E.collapse(!1),E.insertNode(l)}const v=document.createTextNode(" ");l.after(v);const h=document.createRange();h.setStartAfter(v),h.collapse(!0),n.removeAllRanges(),n.addRange(h)}catch(i){console.error("insertMention error:",i)}let s=me([...he,e]);ee(s),H(s),B(!1),(a=D())==null||a.focus(),M()},Et=e=>{const n=D();if(!n)return;let r=null;N.current&&n.contains(N.current.startContainer)?r=N.current.cloneRange():(r=document.createRange(),r.selectNodeContents(n),r.collapse(!1));const l=window.getSelection();if(!l)return;l.removeAllRanges(),l.addRange(r);const s=document.createElement("span");s.textContent=`{{${e.name}}}`,s.style.display="inline",s.setAttribute("data-mention",e.value||e.name),r.insertNode(s);const a=document.createTextNode(" ");s.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),l.removeAllRanges(),l.addRange(i),N.current=i.cloneRange(),n.focus()},wt=e=>{e.forEach(n=>Et(n)),ee(n=>{const r=[...n,...e],l=Array.from(new Map(r.map(s=>[s.name,s])).values());return H(l),l}),M()},bt=()=>{const e=D();if(!e)return[];const n=e.querySelectorAll("span[data-mention]"),r=[];return n.forEach(l=>{const s=l.getAttribute("data-mention")||"",i=(l.textContent||"").match(/{{(.+?)}}/);i&&r.push({name:i[1],value:s})}),r},Ct=e=>{var r,l,s;const n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(n)&&(e.preventDefault(),te(n==="b"?"bold":n==="i"?"italic":n==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const a=window.getSelection(),i=a!=null&&a.anchorNode?ve(a.anchorNode):null;if(!i)return;if(((r=i.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const h=i.parentElement,E=h==null?void 0:h.closest("li");if(E){h==null||h.removeChild(i);const f=document.createElement("p");f.innerHTML="<br />",(l=E.parentElement)==null||l.insertBefore(f,E.nextSibling);const y=document.createRange();y.setStart(f,0),y.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(y)}else{const f=i.closest("ul, ol");if(f){const y=document.createElement("p");y.innerHTML="<br />",(s=f.parentElement)==null||s.insertBefore(y,f.nextSibling),f.removeChild(i);const x=document.createRange();x.setStart(y,0),x.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(x)}}M()}}},St=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(xt(l))return;setTimeout(()=>{pt(r.getRangeAt(0)),ge(""),z(o),B(!0)},0);return}if(q){setTimeout(()=>Ee(),0);return}},xt=e=>{if(!e)return!1;let n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;n;){if(n.tagName==="TH")return!0;n=n.parentElement}return!1},Ee=()=>{if(M(),!q)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const r=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!r){B(!1);return}const l=r[1].toLowerCase();ge(l);const s=o.filter(a=>a.name.toLowerCase().includes(l));z(s)},Lt=e=>{var l;const n=(l=e.target.files)==null?void 0:l[0];if(!n)return;const r=new FileReader;r.onload=s=>{var x;const a=(x=s.target)==null?void 0:x.result;V();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const h=document.createElement("img");h.src=a,h.alt=n.name||"image",h.className="rte-inserted-image",h.contentEditable="true";const E=D();if(!v||!E){E==null||E.appendChild(h);const Te=document.createTextNode(" ");E==null||E.appendChild(Te);const ne=document.createRange();ne.setStartAfter(Te),ne.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(ne),E==null||E.focus(),M(),e.target.value="";return}v.deleteContents(),v.insertNode(h);const f=document.createTextNode(" ");h.after(f);const y=document.createRange();y.setStartAfter(f),y.collapse(!0),i.removeAllRanges(),i.addRange(y),E.focus(),M(),e.target.value=""},r.readAsDataURL(n)},Mt=e=>{var s;V();const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const r=n.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),n.removeAllRanges(),n.addRange(r),(s=D())==null||s.focus(),M()},At=()=>{var E;V();const e=document.createElement("table");e.style.borderCollapse="collapse",e.style.width="100%",e.style.border="1px solid #ccc",e.style.margin="8px 0",e.style.position="relative",g.table&&e.classList.add(g.table);const n=document.createElement("thead");g.thead&&n.classList.add(g.thead);const r=document.createElement("tbody");g.tbody&&r.classList.add(g.tbody);const l=document.createElement("tr");g.tr&&l.classList.add(g.tr);const s=document.createElement("tr");g.tr&&s.classList.add(g.tr);for(let f=0;f<2;f++){const y=document.createElement("th");y.textContent=`Header ${f+1}`,y.style.border="1px solid #999",y.style.padding="4px",y.style.position="relative",y.style.backgroundColor="lightgray",g.th&&y.classList.add(g.th);const x=document.createElement("td");x.textContent=`Row 1 Col ${f+1}`,x.style.border="1px solid #999",x.style.padding="4px",x.style.position="relative",x.style.backgroundColor="#fff",g.td&&x.classList.add(g.td),Q(y),Q(x),l.appendChild(y),s.appendChild(x)}n.appendChild(l),r.appendChild(s),e.appendChild(n),e.appendChild(r),we(e);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;const i=a.getRangeAt(0);i.collapse(!1),i.insertNode(e);const v=document.createElement("p");v.innerHTML="<br/>",e.after(v);const h=document.createRange();h.setStart(v,0),h.collapse(!0),a.removeAllRanges(),a.addRange(h),(E=D())==null||E.focus(),M()},we=e=>{const n=document.createElement("div");Object.assign(n.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),n.style.userSelect="none",n.contentEditable="false";let r=0,l=0,s=0,a=0;n.addEventListener("mousedown",i=>{i.preventDefault(),r=i.clientX,l=i.clientY;const v=e.getBoundingClientRect();s=v.width,a=v.height;const h=f=>{const y=Math.max(100,s+(f.clientX-r)),x=Math.max(60,a+(f.clientY-l));e.style.width=`${y}px`,e.style.height=`${x}px`,M()},E=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",E),M()};document.addEventListener("mousemove",h),document.addEventListener("mouseup",E)}),e.appendChild(n)},Q=e=>{const n=document.createElement("div"),r=document.createElement("div");Object.assign(n.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),n.contentEditable="false",Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),r.contentEditable="false",zt(e,n,r),e.appendChild(n),e.appendChild(r)},zt=(e,n,r)=>{let l=0,s=0,a=0,i=0;n.addEventListener("mousedown",f=>{f.preventDefault(),l=f.clientX,a=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",E)}),r.addEventListener("mousedown",f=>{f.preventDefault(),s=f.clientY,i=e.offsetHeight,document.addEventListener("mousemove",h),document.addEventListener("mouseup",E)});const v=f=>{const y=a+(f.clientX-l);e.style.width=`${Math.max(30,y)}px`,M()},h=f=>{const y=i+(f.clientY-s);e.style.height=`${Math.max(20,y)}px`,M()},E=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",E),M()}},kt=e=>{const r=e.target.closest("td, th");r&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight")),r.classList.add("rte-cell-highlight"),m({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},be=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Tt=e=>{if(!j.cell)return;const n=j.cell.closest("table"),r=j.cell.cellIndex,l=j.cell.parentElement.rowIndex,s=a=>{const i=a.tagName.toLowerCase(),v=document.createElement(i);return v.textContent=a.textContent||"",v.style.cssText=a.style.cssText,Q(v),v};switch(e){case"insertRowAbove":{const a=n.rows[l],i=n.insertRow(l);Array.from(a.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertRowBelow":{const a=n.rows[l],i=n.insertRow(l+1);Array.from(a.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertColLeft":{Array.from(n.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(s(i),i)});break}case"insertColRight":{Array.from(n.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(s(i),i.nextSibling)});break}case"deleteRow":n.rows.length>1&&n.deleteRow(l);break;case"deleteCol":Array.from(n.rows).forEach(a=>{a.cells[r]&&a.deleteCell(r)});break}M(),m(oe(re({},j),{visible:!1})),be()},Nt=()=>{U(),Z.current=N.current,fe({url:"",text:"",title:"",target:"_self"}),_(!0)},Dt=e=>{const n=window.getSelection();if(!n||!Z.current)return;n.removeAllRanges(),n.addRange(Z.current);let r=e.url.trim();/^https?:\/\//i.test(r)||(r="https://"+r);const l=document.createElement("a");l.href=r,l.style.cursor="pointer",l.style.outline="none",l.textContent=e.text||r,l.title=e.title,l.target=e.target,l.contentEditable="true";const s=n.getRangeAt(0);s.deleteContents(),s.insertNode(l);const a=document.createTextNode(" ");l.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),n.removeAllRanges(),n.addRange(i),_(!1),M()},Ot=e=>{const n=e.target;if(n.tagName==="A"){const r=n;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),Z.current=l,fe({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),_(!0)}},jt=()=>{const e=D();if(!e)return;const n=window.getSelection();if((!n||n.rangeCount===0)&&N.current){const f=window.getSelection();f==null||f.removeAllRanges(),f==null||f.addRange(N.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);V(),document.execCommand("removeFormat",!1);const s=l.cloneContents(),a=document.createElement("div");a.appendChild(s);const i=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const f=i.currentNode,y=f.tagName.toUpperCase(),x=f.getAttribute&&f.getAttribute("data-mention")!==null;y!=="A"&&!x&&v.push(f)}for(let f=v.length-1;f>=0;f--){const y=v[f],x=y.parentNode;if(x){for(;y.firstChild;)x.insertBefore(y.firstChild,y);x.removeChild(y)}}a.querySelectorAll("[style]").forEach(f=>f.removeAttribute("style")),l.deleteContents();const h=document.createDocumentFragment();for(;a.firstChild;)h.appendChild(a.firstChild);l.insertNode(h);const E=document.createRange();E.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),E.collapse(!0),r.removeAllRanges(),r.addRange(E),e.normalize(),M()},Ht=e=>{var l;let n=e;n=n.replace(/{{#arrayData\d*}}/g,""),n=n.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=n,r.querySelectorAll("br").forEach(s=>{s.replaceWith(`
1
+ (function(A,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],t):(A=typeof globalThis!="undefined"?globalThis:A||self,t(A.RichTextEditor={},A.React,A.ReactDOM))})(this,(function(A,t,O){"use strict";var Bt=Object.defineProperty,qt=Object.defineProperties;var Rt=Object.getOwnPropertyDescriptors;var Ne=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var De=(A,t,O)=>t in A?Bt(A,t,{enumerable:!0,configurable:!0,writable:!0,value:O}):A[t]=O,re=(A,t)=>{for(var O in t||(t={}))Ut.call(t,O)&&De(A,O,t[O]);if(Ne)for(var O of Ne(t))Vt.call(t,O)&&De(A,O,t[O]);return A},oe=(A,t)=>qt(A,Rt(t));function Oe(o){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const d in o)if(d!=="default"){const u=Object.getOwnPropertyDescriptor(o,d);Object.defineProperty(c,d,u.get?u:{enumerable:!0,get:()=>o[d]})}}return c.default=o,Object.freeze(c)}const je=Oe(t);window.React=je;var le={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ae=t.createContext&&t.createContext(le),He=["attr","size","title"];function _e(o,c){if(o==null)return{};var d=Pe(o,c),u,g;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(o);for(g=0;g<w.length;g++)u=w[g],!(c.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(o,u)&&(d[u]=o[u])}return d}function Pe(o,c){if(o==null)return{};var d={};for(var u in o)if(Object.prototype.hasOwnProperty.call(o,u)){if(c.indexOf(u)>=0)continue;d[u]=o[u]}return d}function W(){return W=Object.assign?Object.assign.bind():function(o){for(var c=1;c<arguments.length;c++){var d=arguments[c];for(var u in d)Object.prototype.hasOwnProperty.call(d,u)&&(o[u]=d[u])}return o},W.apply(this,arguments)}function ie(o,c){var d=Object.keys(o);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(o);c&&(u=u.filter(function(g){return Object.getOwnPropertyDescriptor(o,g).enumerable})),d.push.apply(d,u)}return d}function K(o){for(var c=1;c<arguments.length;c++){var d=arguments[c]!=null?arguments[c]:{};c%2?ie(Object(d),!0).forEach(function(u){Fe(o,u,d[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(d)):ie(Object(d)).forEach(function(u){Object.defineProperty(o,u,Object.getOwnPropertyDescriptor(d,u))})}return o}function Fe(o,c,d){return c=Ie(c),c in o?Object.defineProperty(o,c,{value:d,enumerable:!0,configurable:!0,writable:!0}):o[c]=d,o}function Ie(o){var c=Be(o,"string");return typeof c=="symbol"?c:c+""}function Be(o,c){if(typeof o!="object"||!o)return o;var d=o[Symbol.toPrimitive];if(d!==void 0){var u=d.call(o,c);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(o)}function se(o){return o&&o.map((c,d)=>t.createElement(c.tag,K({key:d},c.attr),se(c.child)))}function k(o){return c=>t.createElement(qe,W({attr:K({},o.attr)},c),se(o.child))}function qe(o){var c=d=>{var{attr:u,size:g,title:w}=o,S=_e(o,He),C=g||d.size||"1em",p;return d.className&&(p=d.className),o.className&&(p=(p?p+" ":"")+o.className),t.createElement("svg",W({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},d.attr,u,S,{className:p,style:K(K({color:o.color||d.color},d.style),o.style),height:C,width:C,xmlns:"http://www.w3.org/2000/svg"}),w&&t.createElement("title",null,w),o.children)};return ae!==void 0?t.createElement(ae.Consumer,null,d=>c(d)):c(le)}function Re(o){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(o)}function Ue(o){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(o)}function Ve(o){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(o)}function $e(o){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(o)}function We(o){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function Ke(o){return k({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(o)}function Xe(o){return k({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(o)}function Ye(o){return k({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(o)}function Ze(o){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(o)}function Qe(o){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function Je(o){return k({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(o)}function Ge(o){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(o)}function et(o){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function tt(o){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(o)}function nt(o){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(o)}const rt=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],ce=({exec:o,saveSelection:c,handleFileChange:d,handleFontSizeChange:u,handleFontFamilyChange:g,insertEmoji:w,handleLink:S,removeFormatting:C,visibleActions:p,className:H,style:F})=>{var R,j;const T=t.useRef(null),P=t.useRef(null),L=t.useRef(null),[Y,$]=t.useState(!1),[q,B]=t.useState({x:0,y:0});t.useEffect(()=>{const m=b=>{!b.target.closest(".rte-emoji-popup")&&!b.target.closest("button[title='Emoji']")&&$(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const I=m=>{var _;m.preventDefault();const b=m.currentTarget.dataset.command;if(b)switch(b){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":o(b);break;case"insertImage":{(_=T.current)==null||_.click();break}default:console.warn("Unknown command:",b)}},J=m=>{o("foreColor",m.target.value)},G=m=>{o("backColor",m.target.value)},[z,N]=t.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return t.useEffect(()=>{const m=()=>{N({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",m),()=>document.removeEventListener("selectionchange",m)},[]),t.createElement("div",{className:`rte-toolbar ${H||""}`,style:F},p.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:I,className:z.bold?"rte-active":""},t.createElement(Ke,null)),p.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:I,className:z.italic?"rte-active":""},t.createElement(Ye,null)),p.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:I,className:z.underline?"rte-active":""},t.createElement(et,null)),p.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:I,title:"UnorderedList",className:z.unorderedList?"rte-active":""},t.createElement(Qe,null)),p.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:I,className:z.orderedList?"rte-active":""},t.createElement($e,null)),p.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:S,className:z.link?"rte-active":""},t.createElement(Ze,null)),p.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:m=>{m.preventDefault(),c(),C()},className:z.removeFormat?"rte-active":""},t.createElement(nt,null)),p.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:I,className:z.image?"rte-active":""},t.createElement(Ve,null)),t.createElement("input",{type:"file",accept:"image/*",ref:T,style:{display:"none"},onChange:d}),p.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:m=>{m.preventDefault(),c();const b=m.currentTarget.getBoundingClientRect();B({x:b.left,y:b.bottom+8}),$(_=>!_)},className:z.emoji?"rte-active":""},t.createElement(Je,null)),Y&&O.createPortal(t.createElement("div",{className:"rte-emoji-popup",style:{top:q.y,left:q.x}},rt.map((m,b)=>t.createElement("span",{key:b,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:_=>{_.preventDefault(),w(m),$(!1)}},m))),document.body)),p.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:m=>{var b;m.preventDefault(),c(),(b=P.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((R=P.current)==null?void 0:R.value)||"#000",fontSize:"18px"},className:z.color?"rte-active":""},t.createElement(tt,null)),t.createElement("input",{ref:P,type:"color",defaultValue:"#000000",onChange:m=>{var b;J(m),((b=m.target.parentElement)==null?void 0:b.querySelector("button")).style.color=m.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),p.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:m=>{var b;m.preventDefault(),c(),(b=L.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((j=L.current)==null?void 0:j.value)||"#000",fontSize:"18px"},className:z.highlight?"rte-active":""},t.createElement(Xe,null)),t.createElement("input",{ref:L,type:"color",onChange:m=>{var b;G(m),((b=m.target.parentElement)==null?void 0:b.querySelector("button")).style.color=m.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),p.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:m=>m.preventDefault(),onClick:()=>o("justifyLeft"),className:z.alignLeft?"rte-active":""},t.createElement(We,null)),t.createElement("button",{title:"Align Center",onMouseDown:m=>m.preventDefault(),onClick:()=>o("justifyCenter"),className:z.alignCenter?"rte-active":""},t.createElement(Re,null)),t.createElement("button",{title:"Align Right",onMouseDown:m=>m.preventDefault(),onClick:()=>o("justifyRight"),className:z.alignRight?"rte-active":""},t.createElement(Ue,null))),p.table&&t.createElement("button",{title:"Insert Table",onMouseDown:m=>m.preventDefault(),onClick:()=>o("insertTable"),className:z.table?"rte-active":""},t.createElement(Ge,null)),p.fontFamily&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:g},t.createElement("option",{value:"",disabled:!0},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Times New Roman"},"Times New Roman"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Verdana"},"Verdana")),p.fontSize&&t.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:u},t.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(m,b)=>10+b).map(m=>t.createElement("option",{key:m,value:m},m,"px"))))},ot=({show:o,position:c,filtered:d,insertMention:u,onClose:g,query:w})=>{const S=t.useRef(null);return t.useEffect(()=>{const C=p=>{S.current&&!S.current.contains(p.target)&&g()};return o&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[o,g]),o?t.createElement("ul",{ref:S,className:"rte-popup",style:{top:c.y,left:c.x}},d.length>0?d.map(({name:C,value:p})=>{const H=C.toLowerCase(),F=w.toLowerCase(),T=H.indexOf(F);let P=C;if(T!==-1&&w.length>0){const L=T+w.length;P=C.substring(0,T)+`<span class="rte-highlight">${C.substring(T,L)}</span>`+C.substring(L)}return t.createElement("li",{key:p,onMouseDown:L=>{L.preventDefault(),u({name:C,value:p})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:P},onMouseEnter:L=>L.currentTarget.style.background="#f0f0f0",onMouseLeave:L=>L.currentTarget.style.background="#fff"})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ue(o){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(o)}function X(o){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(o)}const lt=({visible:o,x:c,y:d,onAction:u,onClose:g})=>{if(!o)return null;const w={top:d,left:c};return t.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:g},t.createElement("button",{onClick:()=>u("insertRowAbove")},t.createElement(X,null)," Insert row above"),t.createElement("button",{onClick:()=>u("insertRowBelow")},t.createElement(X,null)," Insert row below"),t.createElement("button",{onClick:()=>u("insertColLeft")},t.createElement(X,null)," Insert col left"),t.createElement("button",{onClick:()=>u("insertColRight")},t.createElement(X,null)," Insert col right"),t.createElement("button",{onClick:()=>u("deleteRow")},t.createElement(ue,null)," Delete row"),t.createElement("button",{onClick:()=>u("deleteCol")},t.createElement(ue,null)," Delete column"))},de=({html:o,className:c,style:d})=>{const u=w=>{const S=w.target;if(S.tagName==="A"){w.preventDefault();const C=S.href;C&&window.open(C,"_blank","noopener,noreferrer")}},g=w=>{let S=w.replace(/{{\s*(.*?)\s*}}/g,(C,p)=>`<span style="color: blue">${p}</span>`);return S=S.replace(/#arrayData/g,""),S=S.replace(/\/arrayData/g,""),S};return t.createElement("div",{className:`rte-preview ${c||""}`,style:d,onClick:u,dangerouslySetInnerHTML:{__html:g(o)}})},at=({visible:o,linkData:c,onClose:d,onInsert:u})=>{const[g,w]=t.useState(""),[S,C]=t.useState(""),[p,H]=t.useState(""),[F,T]=t.useState("_self");if(t.useEffect(()=>{o?(w(c.url||""),C(c.text||""),H(c.title||""),T(c.target||"_self")):(w(""),C(""),H(""),T("_self"))},[o,c]),!o)return null;const P=()=>{u({url:g,text:S,title:p,target:F})};return t.createElement(t.Fragment,null,t.createElement("div",{className:"rte-link-modal-overlay",onClick:d}),t.createElement("div",{className:"rte-link-modal"},t.createElement("h4",{className:"rte-link-modal__title"},g?"Edit Link":"Insert Link"),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:g,onChange:L=>w(L.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:S,onChange:L=>C(L.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:p,onChange:L=>H(L.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:F,onChange:L=>T(L.target.value)},t.createElement("option",{value:"_self"},"Same tab"),t.createElement("option",{value:"_blank"},"New tab")),t.createElement("div",{className:"rte-link-modal__actions"},t.createElement("button",{className:"rte-link-modal__btn",onClick:d},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:P},"OK"))))};function me(o){return Array.from(new Map(o.map(c=>[c.value,c])).values())}const it=({atSuggestions:o=[],showOutput:c=!1,showPreview:d=!1,toolbarConfig:u={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:g={},styles:w={},handleGetHtml:S=()=>{},onChange:C=()=>{},value:p,onMentionSelect:H=()=>{},handleAddAttributes:F=()=>{}})=>{var Ce,Se,xe,Le,Me,Ae,ze,ke;const T=t.useRef(null),[P,L]=t.useState(p!=null&&p.length?p:" "),[Y,$]=t.useState(""),[q,B]=t.useState(!1),[I,J]=t.useState({x:0,y:0}),[G,z]=t.useState([]),N=t.useRef(null),R=t.useRef(null),[j,m]=t.useState({visible:!1,x:0,y:0}),[b,_]=t.useState(!1),Z=t.useRef(null),[st,fe]=t.useState({url:"",text:"",title:"",target:"_self"}),ct={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(Ce=u.link)!=null?Ce:!1,image:(Se=u.image)!=null?Se:!1,emoji:(xe=u.emoji)!=null?xe:!1,table:(Le=u.table)!=null?Le:!1,color:(Me=u.color)!=null?Me:!1,fontFamily:(Ae=u.fontFamily)!=null?Ae:!1,fontSize:(ze=u.fontSize)!=null?ze:!1,highlight:(ke=u.fontSize)!=null?ke:!1},[ut,ge]=t.useState(""),[he,ee]=t.useState([]),D=()=>T.current,M=()=>{const e=dt(),n=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;n||(r=`<div style="font-size:12px">${e}</div>`),$(r),S==null||S(r);const l=Ht(e);C(l);const s=bt(),a=me(s);JSON.stringify(a)!==JSON.stringify(he)&&(ee(a),H(a))},dt=()=>{const e=D();if(!e)return P;const n=e.cloneNode(!0);n.querySelectorAll("table div").forEach(l=>l.remove()),n.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight"));let r=n.innerHTML;return r=mt(r),r},mt=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),U=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=document.getElementById("rte-editor-body");if(!n)return;const r=e.getRangeAt(0);n.contains(r.startContainer)&&(N.current=r.cloneRange())},V=()=>{const e=window.getSelection();!e||!N.current||(e.removeAllRanges(),e.addRange(N.current))},pe=(e,n)=>{const r=window.getSelection();r&&r.rangeCount>0&&(N.current=r.getRangeAt(0)),V(),document.execCommand(e,!1,n),M()};t.useEffect(()=>{const e=D();if(!e||!p)return;const n=ft(p);e.innerHTML=n,M()},[]);const ft=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),t.useEffect(()=>{F&&F(e=>{wt(e)})},[]),t.useEffect(()=>{const e=D();if(!e)return;e.querySelectorAll("table").forEach(r=>{we(r),r.querySelectorAll("th, td").forEach(s=>Q(s))})},[]);const ve=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},gt=e=>{let n=0,r=e.parentElement;for(;r;)(r.tagName==="UL"||r.tagName==="OL")&&n++,r=r.parentElement;return n},ht=e=>{const n=e.querySelector("li"),r=n?gt(n):1;if(e.querySelector("[data-hidden-array-start]"))return;const l=`{{#arrayData${r>1?r:""}}}`,s=`{{/arrayData${r>1?r:""}}}`,a=document.createElement("span");a.textContent=l,a.style.display="none",a.setAttribute("data-hidden-array-start","true"),e.insertBefore(a,e.firstChild);const i=document.createElement("span");i.textContent=s,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),e.appendChild(i)},ye=e=>{var v;const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const r=n.getRangeAt(0),l=ve(r.startContainer);let s,a;if(l){let h=l.querySelector(e);h||(h=document.createElement(e),h.style.margin="0",h.style.paddingLeft="20px",l.appendChild(h)),a=h,s=document.createElement("li"),s.textContent="​",a.appendChild(s)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const h=D();if(a=h==null?void 0:h.querySelector(`${e}:last-child`),!a)return;s=a.querySelector("li:last-child")}ht(a);const i=document.createRange();i.setStart(s,0),i.collapse(!0),n.removeAllRanges(),n.addRange(i),(v=D())==null||v.focus(),M()},te=(e,n)=>{e==="insertOrderedList"?ye("ol"):e==="insertUnorderedList"?ye("ul"):e.startsWith("justify")?Pt(e):pe(e,n),e==="insertTable"&&At()},pt=e=>{const n=document.createElement("span");n.textContent="​",e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=n.getBoundingClientRect();n.remove(),J({x:r.left,y:r.bottom+window.scrollY}),z(o||[]),B(!0),R.current=e.cloneRange()},vt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.anchorNode;let r=e.anchorOffset;if(!n)return null;let l=n;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=n.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const s=l.textContent||"",a=l===n?r:s.length,i=s.lastIndexOf("@",a-1);if(i!==-1){const v=document.createRange();return v.setStart(l,i),v.setEnd(l,a),v}}l=l.previousSibling}return null},yt=e=>{var a;const n=window.getSelection();if(!n)return;const r=vt();r?(n.removeAllRanges(),n.addRange(r)):R.current&&(n.removeAllRanges(),n.addRange(R.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.display="inline",l.setAttribute("data-mention",e.value||e.name||"");try{const i=n.rangeCount?n.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(l);else{const E=document.createRange(),f=D();E.selectNodeContents(f),E.collapse(!1),E.insertNode(l)}const v=document.createTextNode(" ");l.after(v);const h=document.createRange();h.setStartAfter(v),h.collapse(!0),n.removeAllRanges(),n.addRange(h)}catch(i){console.error("insertMention error:",i)}let s=me([...he,e]);ee(s),H(s),B(!1),(a=D())==null||a.focus(),M()},Et=e=>{const n=D();if(!n)return;let r=null;N.current&&n.contains(N.current.startContainer)?r=N.current.cloneRange():(r=document.createRange(),r.selectNodeContents(n),r.collapse(!1));const l=window.getSelection();if(!l)return;l.removeAllRanges(),l.addRange(r);const s=document.createElement("span");s.textContent=`{{${e.name}}}`,s.style.display="inline",s.setAttribute("data-mention",e.value||e.name),r.insertNode(s);const a=document.createTextNode(" ");s.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),l.removeAllRanges(),l.addRange(i),N.current=i.cloneRange(),n.focus()},wt=e=>{e.forEach(n=>Et(n)),ee(n=>{const r=[...n,...e],l=Array.from(new Map(r.map(s=>[s.name,s])).values());return H(l),l}),M()},bt=()=>{const e=D();if(!e)return[];const n=e.querySelectorAll("span[data-mention]"),r=[];return n.forEach(l=>{const s=l.getAttribute("data-mention")||"",i=(l.textContent||"").match(/{{(.+?)}}/);i&&r.push({name:i[1],value:s})}),r},Ct=e=>{var r,l,s;const n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(n)&&(e.preventDefault(),te(n==="b"?"bold":n==="i"?"italic":n==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const a=window.getSelection(),i=a!=null&&a.anchorNode?ve(a.anchorNode):null;if(!i)return;if(((r=i.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const h=i.parentElement,E=h==null?void 0:h.closest("li");if(E){h==null||h.removeChild(i);const f=document.createElement("p");f.innerHTML="<br />",(l=E.parentElement)==null||l.insertBefore(f,E.nextSibling);const y=document.createRange();y.setStart(f,0),y.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(y)}else{const f=i.closest("ul, ol");if(f){const y=document.createElement("p");y.innerHTML="<br />",(s=f.parentElement)==null||s.insertBefore(y,f.nextSibling),f.removeChild(i);const x=document.createRange();x.setStart(y,0),x.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(x)}}M()}}},St=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(xt(l))return;setTimeout(()=>{pt(r.getRangeAt(0)),ge(""),z(o),B(!0)},0);return}if(q){setTimeout(()=>Ee(),0);return}},xt=e=>{if(!e)return!1;let n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;n;){if(n.tagName==="TH")return!0;n=n.parentElement}return!1},Ee=()=>{if(M(),!q)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const r=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!r){B(!1);return}const l=r[1].toLowerCase();ge(l);const s=o.filter(a=>a.name.toLowerCase().includes(l));z(s)},Lt=e=>{var l;const n=(l=e.target.files)==null?void 0:l[0];if(!n)return;const r=new FileReader;r.onload=s=>{var x;const a=(x=s.target)==null?void 0:x.result;V();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const h=document.createElement("img");h.src=a,h.alt=n.name||"image",h.className="rte-inserted-image",h.contentEditable="true";const E=D();if(!v||!E){E==null||E.appendChild(h);const Te=document.createTextNode(" ");E==null||E.appendChild(Te);const ne=document.createRange();ne.setStartAfter(Te),ne.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(ne),E==null||E.focus(),M(),e.target.value="";return}v.deleteContents(),v.insertNode(h);const f=document.createTextNode(" ");h.after(f);const y=document.createRange();y.setStartAfter(f),y.collapse(!0),i.removeAllRanges(),i.addRange(y),E.focus(),M(),e.target.value=""},r.readAsDataURL(n)},Mt=e=>{var s;V();const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const r=n.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),n.removeAllRanges(),n.addRange(r),(s=D())==null||s.focus(),M()},At=()=>{var E;V();const e=document.createElement("table");e.style.borderCollapse="collapse",e.style.width="100%",e.style.border="1px solid #ccc",e.style.margin="8px 0",e.style.position="relative",e.style.textAlign="center",g.table&&e.classList.add(g.table);const n=document.createElement("thead");g.thead&&n.classList.add(g.thead);const r=document.createElement("tbody");g.tbody&&r.classList.add(g.tbody);const l=document.createElement("tr");g.tr&&l.classList.add(g.tr);const s=document.createElement("tr");g.tr&&s.classList.add(g.tr);for(let f=0;f<2;f++){const y=document.createElement("th");y.textContent=`Header ${f+1}`,y.style.border="1px solid #999",y.style.padding="4px",y.style.position="relative",y.style.backgroundColor="lightgray",g.th&&y.classList.add(g.th);const x=document.createElement("td");x.textContent=`Row 1 Col ${f+1}`,x.style.border="1px solid #999",x.style.padding="4px",x.style.position="relative",x.style.backgroundColor="#fff",g.td&&x.classList.add(g.td),Q(y),Q(x),l.appendChild(y),s.appendChild(x)}n.appendChild(l),r.appendChild(s),e.appendChild(n),e.appendChild(r),we(e);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;const i=a.getRangeAt(0);i.collapse(!1),i.insertNode(e);const v=document.createElement("p");v.innerHTML="<br/>",e.after(v);const h=document.createRange();h.setStart(v,0),h.collapse(!0),a.removeAllRanges(),a.addRange(h),(E=D())==null||E.focus(),M()},we=e=>{const n=document.createElement("div");Object.assign(n.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),n.style.userSelect="none",n.contentEditable="false";let r=0,l=0,s=0,a=0;n.addEventListener("mousedown",i=>{i.preventDefault(),r=i.clientX,l=i.clientY;const v=e.getBoundingClientRect();s=v.width,a=v.height;const h=f=>{const y=Math.max(100,s+(f.clientX-r)),x=Math.max(60,a+(f.clientY-l));e.style.width=`${y}px`,e.style.height=`${x}px`,M()},E=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",E),M()};document.addEventListener("mousemove",h),document.addEventListener("mouseup",E)}),e.appendChild(n)},Q=e=>{const n=document.createElement("div"),r=document.createElement("div");Object.assign(n.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),n.contentEditable="false",Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),r.contentEditable="false",zt(e,n,r),e.appendChild(n),e.appendChild(r)},zt=(e,n,r)=>{let l=0,s=0,a=0,i=0;n.addEventListener("mousedown",f=>{f.preventDefault(),l=f.clientX,a=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",E)}),r.addEventListener("mousedown",f=>{f.preventDefault(),s=f.clientY,i=e.offsetHeight,document.addEventListener("mousemove",h),document.addEventListener("mouseup",E)});const v=f=>{const y=a+(f.clientX-l);e.style.width=`${Math.max(30,y)}px`,M()},h=f=>{const y=i+(f.clientY-s);e.style.height=`${Math.max(20,y)}px`,M()},E=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",E),M()}},kt=e=>{const r=e.target.closest("td, th");r&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight")),r.classList.add("rte-cell-highlight"),m({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},be=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Tt=e=>{if(!j.cell)return;const n=j.cell.closest("table"),r=j.cell.cellIndex,l=j.cell.parentElement.rowIndex,s=a=>{const i=a.tagName.toLowerCase(),v=document.createElement(i);return v.textContent=a.textContent||"",v.style.cssText=a.style.cssText,Q(v),v};switch(e){case"insertRowAbove":{const a=n.rows[l],i=n.insertRow(l);Array.from(a.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertRowBelow":{const a=n.rows[l],i=n.insertRow(l+1);Array.from(a.cells).forEach(v=>{i.appendChild(s(v))});break}case"insertColLeft":{Array.from(n.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(s(i),i)});break}case"insertColRight":{Array.from(n.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(s(i),i.nextSibling)});break}case"deleteRow":n.rows.length>1&&n.deleteRow(l);break;case"deleteCol":Array.from(n.rows).forEach(a=>{a.cells[r]&&a.deleteCell(r)});break}M(),m(oe(re({},j),{visible:!1})),be()},Nt=()=>{U(),Z.current=N.current,fe({url:"",text:"",title:"",target:"_self"}),_(!0)},Dt=e=>{const n=window.getSelection();if(!n||!Z.current)return;n.removeAllRanges(),n.addRange(Z.current);let r=e.url.trim();/^https?:\/\//i.test(r)||(r="https://"+r);const l=document.createElement("a");l.href=r,l.style.cursor="pointer",l.style.outline="none",l.textContent=e.text||r,l.title=e.title,l.target=e.target,l.contentEditable="true";const s=n.getRangeAt(0);s.deleteContents(),s.insertNode(l);const a=document.createTextNode(" ");l.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),n.removeAllRanges(),n.addRange(i),_(!1),M()},Ot=e=>{const n=e.target;if(n.tagName==="A"){const r=n;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),Z.current=l,fe({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),_(!0)}},jt=()=>{const e=D();if(!e)return;const n=window.getSelection();if((!n||n.rangeCount===0)&&N.current){const f=window.getSelection();f==null||f.removeAllRanges(),f==null||f.addRange(N.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);V(),document.execCommand("removeFormat",!1);const s=l.cloneContents(),a=document.createElement("div");a.appendChild(s);const i=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const f=i.currentNode,y=f.tagName.toUpperCase(),x=f.getAttribute&&f.getAttribute("data-mention")!==null;y!=="A"&&!x&&v.push(f)}for(let f=v.length-1;f>=0;f--){const y=v[f],x=y.parentNode;if(x){for(;y.firstChild;)x.insertBefore(y.firstChild,y);x.removeChild(y)}}a.querySelectorAll("[style]").forEach(f=>f.removeAttribute("style")),l.deleteContents();const h=document.createDocumentFragment();for(;a.firstChild;)h.appendChild(a.firstChild);l.insertNode(h);const E=document.createRange();E.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),E.collapse(!0),r.removeAllRanges(),r.addRange(E),e.normalize(),M()},Ht=e=>{var l;let n=e;n=n.replace(/{{#arrayData\d*}}/g,""),n=n.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=n,r.querySelectorAll("br").forEach(s=>{s.replaceWith(`
2
2
  `)}),r.querySelectorAll("p, div, tr").forEach(s=>{s.insertAdjacentText("afterend",`
3
3
  `)}),r.querySelectorAll("table").forEach(s=>{s.insertAdjacentText("afterend",`
4
4
  `)}),((l=r.textContent)==null?void 0:l.replace(/\n{3,}/g,`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryzeup/richtexteditor",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "A React Rich Text Editor component",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",