@ryzeup/richtexteditor 1.0.32 â 1.0.33
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 +119 -119
- package/dist/index.js +2 -2
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var xt=Object.defineProperty,Rt=Object.defineProperties;var Nt=Object.getOwnPropertyDescriptors;var Pe=Object.getOwnPropertySymbols;var Mt=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable;var _e=(a,d,u)=>d in a?xt(a,d,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[d]=u,ee=(a,d)=>{for(var u in d||(d={}))Mt.call(d,u)&&_e(a,u,d[u]);if(Pe)for(var u of Pe(d))Tt.call(d,u)&&_e(a,u,d[u]);return a},te=(a,d)=>Rt(a,Nt(d));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),At=require("react-dom");function kt(a){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const u in a)if(u!=="default"){const h=Object.getOwnPropertyDescriptor(a,u);Object.defineProperty(d,u,h.get?h:{enumerable:!0,get:()=>a[u]})}}return d.default=a,Object.freeze(d)}const zt=kt(n);window.React=zt;var Ve={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},je=n.createContext&&n.createContext(Ve),Dt=["attr","size","title"];function Ot(a,d){if(a==null)return{};var u=Ht(a,d),h,v;if(Object.getOwnPropertySymbols){var L=Object.getOwnPropertySymbols(a);for(v=0;v<L.length;v++)h=L[v],!(d.indexOf(h)>=0)&&Object.prototype.propertyIsEnumerable.call(a,h)&&(u[h]=a[h])}return u}function Ht(a,d){if(a==null)return{};var u={};for(var h in a)if(Object.prototype.hasOwnProperty.call(a,h)){if(d.indexOf(h)>=0)continue;u[h]=a[h]}return u}function le(){return le=Object.assign?Object.assign.bind():function(a){for(var d=1;d<arguments.length;d++){var u=arguments[d];for(var h in u)Object.prototype.hasOwnProperty.call(u,h)&&(a[h]=u[h])}return a},le.apply(this,arguments)}function Fe(a,d){var u=Object.keys(a);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(a);d&&(h=h.filter(function(v){return Object.getOwnPropertyDescriptor(a,v).enumerable})),u.push.apply(u,h)}return u}function oe(a){for(var d=1;d<arguments.length;d++){var u=arguments[d]!=null?arguments[d]:{};d%2?Fe(Object(u),!0).forEach(function(h){Pt(a,h,u[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(u)):Fe(Object(u)).forEach(function(h){Object.defineProperty(a,h,Object.getOwnPropertyDescriptor(u,h))})}return a}function Pt(a,d,u){return d=_t(d),d in a?Object.defineProperty(a,d,{value:u,enumerable:!0,configurable:!0,writable:!0}):a[d]=u,a}function _t(a){var d=jt(a,"string");return typeof d=="symbol"?d:d+""}function jt(a,d){if(typeof a!="object"||!a)return a;var u=a[Symbol.toPrimitive];if(u!==void 0){var h=u.call(a,d);if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(a)}function Ue(a){return a&&a.map((d,u)=>n.createElement(d.tag,oe({key:u},d.attr),Ue(d.child)))}function k(a){return d=>n.createElement(Ft,le({attr:oe({},a.attr)},d),Ue(a.child))}function Ft(a){var d=u=>{var{attr:h,size:v,title:L}=a,H=Ot(a,Dt),z=v||u.size||"1em",E;return u.className&&(E=u.className),a.className&&(E=(E?E+" ":"")+a.className),n.createElement("svg",le({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,h,H,{className:E,style:oe(oe({color:a.color||u.color},u.style),a.style),height:z,width:z,xmlns:"http://www.w3.org/2000/svg"}),L&&n.createElement("title",null,L),a.children)};return je!==void 0?n.createElement(je.Consumer,null,u=>d(u)):d(Ve)}function It(a){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:[]}]})(a)}function qt(a){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:[]}]})(a)}function Bt(a){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:[]}]})(a)}function Vt(a){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:[]}]})(a)}function Ut(a){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:[]}]})(a)}function $t(a){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:[]}]})(a)}function Wt(a){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:[]}]})(a)}function Zt(a){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:[]}]})(a)}function Xt(a){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:[]}]})(a)}function Kt(a){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:[]}]})(a)}function Yt(a){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:[]}]})(a)}function Qt(a){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:[]}]})(a)}function Gt(a){return k({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM56.84,75.58a8,8,0,0,1,3.58-10.74l16-8A8,8,0,0,1,88,64v48a8,8,0,0,1-16,0V76.94l-4.42,2.22A8,8,0,0,1,56.84,75.58ZM92,180a8,8,0,0,1,0,16H68a8,8,0,0,1-6.4-12.8l21.67-28.89A3.92,3.92,0,0,0,84,152a4,4,0,0,0-7.77-1.33,8,8,0,0,1-15.09-5.34,20,20,0,1,1,35,18.53L84,180Zm100,4H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Z"},child:[]}]})(a)}function Jt(a){return k({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 18H9V20H2V18ZM2 11H11V13H2V11ZM2 4H22V6H2V4ZM20.674 13.0251L21.8301 12.634L22.8301 14.366L21.914 15.1711C21.9704 15.4386 22 15.7158 22 16C22 16.2842 21.9704 16.5614 21.914 16.8289L22.8301 17.634L21.8301 19.366L20.674 18.9749C20.2635 19.3441 19.7763 19.6295 19.2391 19.8044L19 21H17L16.7609 19.8044C16.2237 19.6295 15.7365 19.3441 15.326 18.9749L14.1699 19.366L13.1699 17.634L14.086 16.8289C14.0296 16.5614 14 16.2842 14 16C14 15.7158 14.0296 15.4386 14.086 15.1711L13.1699 14.366L14.1699 12.634L15.326 13.0251C15.7365 12.6559 16.2237 12.3705 16.7609 12.1956L17 11H19L19.2391 12.1956C19.7763 12.3705 20.2635 12.6559 20.674 13.0251ZM18 17C18.5523 17 19 16.5523 19 16C19 15.4477 18.5523 15 18 15C17.4477 15 17 15.4477 17 16C17 16.5523 17.4477 17 18 17Z"},child:[]}]})(a)}function en(a){return k({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]},{tag:"path",attr:{d:"M19.001 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M19.001 15.5v1.5"},child:[]},{tag:"path",attr:{d:"M19.001 21v1.5"},child:[]},{tag:"path",attr:{d:"M22.032 17.25l-1.299 .75"},child:[]},{tag:"path",attr:{d:"M17.27 20l-1.3 .75"},child:[]},{tag:"path",attr:{d:"M15.97 17.25l1.3 .75"},child:[]},{tag:"path",attr:{d:"M20.733 20l1.3 .75"},child:[]}]})(a)}function tn(a){return k({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]}]})(a)}function nn(a){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:[]}]})(a)}function rn(a){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:[]}]})(a)}const an=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],$e=({exec:a,saveSelection:d,handleFileChange:u,handleFontSizeChange:h,handleFontFamilyChange:v,insertEmoji:L,handleLink:H,removeFormatting:z,visibleActions:E,className:R,style:N})=>{var q,Z;const x=n.useRef(null),V=n.useRef(null),b=n.useRef(null),[T,_]=n.useState(!1),[j,O]=n.useState({x:0,y:0});n.useEffect(()=>{const g=w=>{!w.target.closest(".rte-emoji-popup")&&!w.target.closest("button[title='Emoji']")&&_(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const F=g=>{var $;g.preventDefault();const w=g.currentTarget.dataset.command;if(w)switch(w){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertStaticUnorderedList":case"insertOrderedList":case"insertStaticOrderedList":case"removeFormat":a(w);break;case"insertImage":{($=x.current)==null||$.click();break}default:console.warn("Unknown command:",w)}},W=g=>{a("foreColor",g.target.value)},U=g=>{a("backColor",g.target.value)},[S,D]=n.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}),I=n.useRef(null),P=n.useRef(null);return n.useEffect(()=>{const g=()=>{const w=window.getSelection();if(!w||!w.anchorNode)return;let $=w.anchorNode.nodeType===Node.ELEMENT_NODE?w.anchorNode:w.anchorNode.parentElement;if(!$)return;const Y=window.getComputedStyle($),ne=Y.fontFamily.replace(/['"]/g,"").split(",")[0],ce=parseInt(Y.fontSize,10);if(I.current){const Q=Array.from(I.current.options).some(re=>re.value===ne);I.current.value=Q?ne:""}P.current&&(P.current.value=String(ce))};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),n.useEffect(()=>{const g=()=>{D({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",g),()=>document.removeEventListener("selectionchange",g)},[]),n.createElement("div",{className:`rte-toolbar ${R||""}`,style:N},E.bold&&n.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:F,className:S.bold?"rte-active":""},n.createElement($t,null)),E.italic&&n.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:F,className:S.italic?"rte-active":""},n.createElement(Zt,null)),E.underline&&n.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:F,className:S.underline?"rte-active":""},n.createElement(Qt,null)),E.unorderedList&&n.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:F,title:"UnorderedList",className:S.unorderedList?"rte-active":""},n.createElement(Jt,null)),E.staticUnorderedList&&n.createElement("button",{"data-command":"insertStaticUnorderedList",onMouseDown:F,title:"StaticUnorderedList",className:S.unorderedList?"rte-active":""},n.createElement(Kt,null)),E.orderedList&&n.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:F,className:S.orderedList?"rte-active":"",style:{fontSize:"medium"}},n.createElement(Gt,null)),E.staticOrderedList&&n.createElement("button",{"data-command":"insertStaticOrderedList",title:"StaticOrderedList",onMouseDown:F,className:S.orderedList?"rte-active":""},n.createElement(Vt,null)),E.link&&n.createElement("button",{"data-command":"createLink",title:"Link",onClick:H,className:S.link?"rte-active":""},n.createElement(Xt,null)),E.removeFormat&&n.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),d(),z()},className:S.removeFormat?"rte-active":""},n.createElement(rn,null)),E.image&&n.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:F,className:S.image?"rte-active":""},n.createElement(Bt,null)),n.createElement("input",{type:"file",accept:"image/*",ref:x,style:{display:"none"},onChange:u}),E.emoji&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),d();const w=g.currentTarget.getBoundingClientRect();O({x:w.left,y:w.bottom+8}),_($=>!$)},className:S.emoji?"rte-active":""},n.createElement(Yt,null)),T&&At.createPortal(n.createElement("div",{className:"rte-emoji-popup",style:{top:j.y,left:j.x}},an.map((g,w)=>n.createElement("span",{key:w,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:$=>{$.preventDefault(),L(g),_(!1)}},g))),document.body)),E.color&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Text Color",onMouseDown:g=>{var w;g.preventDefault(),d(),(w=V.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((q=V.current)==null?void 0:q.value)||"#000",fontSize:"18px"},className:S.color?"rte-active":""},n.createElement(nn,null)),n.createElement("input",{ref:V,type:"color",defaultValue:"#000000",onChange:g=>{var w;W(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Highlight",onMouseDown:g=>{var w;g.preventDefault(),d(),(w=b.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((Z=b.current)==null?void 0:Z.value)||"#000",fontSize:"18px"},className:S.highlight?"rte-active":""},n.createElement(Wt,null)),n.createElement("input",{ref:b,type:"color",onChange:g=>{var w;U(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&n.createElement(n.Fragment,null,n.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyLeft"),className:S.alignLeft?"rte-active":""},n.createElement(Ut,null)),n.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyCenter"),className:S.alignCenter?"rte-active":""},n.createElement(It,null)),n.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyRight"),className:S.alignRight?"rte-active":""},n.createElement(qt,null))),E.table&&n.createElement("button",{title:"Insert Dynamic Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertTable"),className:S.table?"rte-active":"",style:{fontSize:"medium"}},n.createElement(en,null)),E.table&&n.createElement("button",{title:"Insert Static Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertStaticTable"),className:S.table?"rte-active":"",style:{fontSize:"medium"}},n.createElement(tn,null)),E.fontFamily&&n.createElement("select",{ref:I,className:"rte-dropdown",defaultValue:"",onMouseDown:()=>d(),onChange:v},n.createElement("option",{value:"",disabled:!0},"Font Family"),n.createElement("option",{value:"Arial"},"Arial"),n.createElement("option",{value:"Georgia"},"Georgia"),n.createElement("option",{value:"Times New Roman"},"Times New Roman"),n.createElement("option",{value:"Courier New"},"Courier New"),n.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&n.createElement("select",{ref:P,className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>d(),onChange:h},n.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(g,w)=>10+w).map(g=>n.createElement("option",{key:g,value:g},g,"px"))))},ln=({show:a,position:d,filtered:u,insertMention:h,onClose:v,query:L})=>{const H=n.useRef(null),[z,E]=n.useState(0);return n.useEffect(()=>{a&&E(0)},[a]),n.useEffect(()=>{const R=N=>{H.current&&!H.current.contains(N.target)&&v()};return a&&document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[a,v]),n.useEffect(()=>{if(!a)return;const R=N=>{if(!(!a||u.length===0)&&(N.key==="ArrowDown"&&(N.preventDefault(),E(x=>Math.min(x+1,u.length-1))),N.key==="ArrowUp"&&(N.preventDefault(),E(x=>Math.max(x-1,0))),N.key==="Enter")){N.preventDefault();const x=u[z];x&&h(x)}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[a,u,z]),n.useEffect(()=>{if(!H.current)return;const N=H.current.querySelectorAll("li")[z];N&&N.scrollIntoView({block:"nearest",behavior:"smooth"})},[z]),a?n.createElement("ul",{ref:H,className:"rte-popup",style:{top:d.y,left:d.x}},u.length>0?u.map(({name:R,value:N},x)=>{const V=R.toLowerCase(),b=L.toLowerCase(),T=V.indexOf(b);let _=R;if(T!==-1&&L.length>0){const j=T+L.length;_=R.substring(0,T)+`<span class="rte-highlight">${R.substring(T,j)}</span>`+R.substring(j)}return n.createElement("li",{key:N,onMouseDown:j=>{j.preventDefault(),h({name:R,value:N})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:x===z?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:_},onMouseEnter:()=>E(x)})}):n.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function me(a){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:[]}]}]}]})(a)}function ae(a){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:[]}]}]}]})(a)}const on=({visible:a,x:d,y:u,onAction:h,onClose:v})=>{if(!a)return null;const L={top:u,left:d};return n.createElement("div",{style:L,className:"rte-table-menu",onMouseLeave:v},n.createElement("button",{onClick:()=>h("insertRowAbove")},n.createElement(ae,null)," Insert row above"),n.createElement("button",{onClick:()=>h("insertRowBelow")},n.createElement(ae,null)," Insert row below"),n.createElement("button",{onClick:()=>h("insertColLeft")},n.createElement(ae,null)," Insert col left"),n.createElement("button",{onClick:()=>h("insertColRight")},n.createElement(ae,null)," Insert col right"),n.createElement("button",{onClick:()=>h("deleteRow")},n.createElement(me,null)," Delete row"),n.createElement("button",{onClick:()=>h("deleteCol")},n.createElement(me,null)," Delete column"),n.createElement("button",{onClick:()=>h("deleteTable")},n.createElement(me,null)," Delete table"))};function Ie(a){return k({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M885.9 490.3c3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-51.6-30.7-98.1-78.3-118.4a66.1 66.1 0 0 0-26.5-5.4H144c-17.7 0-32 14.3-32 32v364c0 17.7 14.3 32 32 32h129.3l85.8 310.8C372.9 889 418.9 924 470.9 924c29.7 0 57.4-11.8 77.9-33.4 20.5-21.5 31-49.7 29.5-79.4l-6-122.9h239.9c12.1 0 23.9-3.2 34.3-9.3 40.4-23.5 65.5-66.1 65.5-111 0-28.3-9.3-55.5-26.1-77.7zM184 456V172h81v284h-81zm627.2 160.4H496.8l9.6 198.4c.6 11.9-4.7 23.1-14.6 30.5-6.1 4.5-13.6 6.8-21.1 6.7a44.28 44.28 0 0 1-42.2-32.3L329 459.2V172h415.4a56.85 56.85 0 0 1 33.6 51.8c0 9.7-2.3 18.9-6.9 27.3l-13.9 25.4 21.9 19a56.76 56.76 0 0 1 19.6 43c0 9.7-2.3 18.9-6.9 27.3l-13.9 25.4 21.9 19a56.76 56.76 0 0 1 19.6 43c0 9.7-2.3 18.9-6.9 27.3l-14 25.5 21.9 19a56.76 56.76 0 0 1 19.6 43c0 19.1-11 37.5-28.8 48.4z"},child:[]}]})(a)}function qe(a){return k({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M885.9 533.7c16.8-22.2 26.1-49.4 26.1-77.7 0-44.9-25.1-87.4-65.5-111.1a67.67 67.67 0 0 0-34.3-9.3H572.4l6-122.9c1.4-29.7-9.1-57.9-29.5-79.4A106.62 106.62 0 0 0 471 99.9c-52 0-98 35-111.8 85.1l-85.9 311H144c-17.7 0-32 14.3-32 32v364c0 17.7 14.3 32 32 32h601.3c9.2 0 18.2-1.8 26.5-5.4 47.6-20.3 78.3-66.8 78.3-118.4 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7-.2-12.6-2-25.1-5.6-37.1zM184 852V568h81v284h-81zm636.4-353l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 16.5-7.2 32.2-19.6 43l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 16.5-7.2 32.2-19.6 43l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 22.4-13.2 42.6-33.6 51.8H329V564.8l99.5-360.5a44.1 44.1 0 0 1 42.2-32.3c7.6 0 15.1 2.2 21.1 6.7 9.9 7.4 15.2 18.6 14.6 30.5l-9.6 198.4h314.4C829 418.5 840 436.9 840 456c0 16.5-7.2 32.1-19.6 43z"},child:[]}]})(a)}const We=({html:a,className:d,style:u,attributes:h,setAttributes:v})=>{const[L,H]=n.useState("web"),z={web:{label:"Web",width:"100%",height:"100%"},galaxyS23:{label:"Galaxy S23",width:360,height:780},iphoneSE:{label:"iPhone SE (3rd Gen)",width:375,height:667},iphoneX:{label:"iPhone X / XS",width:375,height:812},pixel7a:{label:"Pixel 7a",width:390,height:844},iphone12:{label:"iPhone 12 / 13 / 14",width:390,height:844},iphone14:{label:"iPhone 14 Pro",width:393,height:852},pixel7:{label:"Pixel 7",width:412,height:915},iphone11:{label:"iPhone 11",width:414,height:896},iphone14ProMax:{label:"iPhone 14 Pro Max",width:430,height:932},pixel8Pro:{label:"Pixel 8 Pro",width:448,height:998},galaxyS24Ultra:{label:"Galaxy S24 Ultra",width:480,height:1040}},E=b=>{const T=b.target;if(T.tagName==="A"){b.preventDefault();const _=T.href;_&&window.open(_,"_blank","noopener,noreferrer")}},R=b=>b==="rgb(0, 0, 0)"||b==="rgba(0, 0, 0, 1)"||b==="#000"||b==="#000000"||b==="black",N=b=>{const T=document.createElement("div");T.innerHTML=b;const _=document.createTreeWalker(T,NodeFilter.SHOW_TEXT,null),j=[];for(;_.nextNode();){const O=_.currentNode;O.nodeValue&&/{{\s*[\s\S]*?\s*}}/.test(O.nodeValue)&&j.push(O)}return j.forEach(O=>{var P;const F=O.nodeValue||"",W=O.parentElement;if(!W)return;let U=W,S=!1;for(;U;){if(U.tagName==="FONT"&&U.getAttribute("color")){S=!0;break}const q=(P=U.style)==null?void 0:P.color;if(q&&!R(q)){S=!0;break}const Z=window.getComputedStyle(U);if(Z.color&&!R(Z.color)){S=!0;break}U=U.parentElement}const D=document.createDocumentFragment();let I=0;F.replace(/{{\s*([\s\S]*?)\s*}}/g,(q,Z,g)=>{if(g>I&&D.appendChild(document.createTextNode(F.slice(I,g))),S)D.appendChild(document.createTextNode(q));else{const w=document.createElement("span");w.style.color="blue",w.textContent=q,D.appendChild(w)}return I=g+q.length,q}),I<F.length&&D.appendChild(document.createTextNode(F.slice(I))),W.replaceChild(D,O)}),T.innerHTML=T.innerHTML.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""),T.innerHTML},x=()=>new Date().toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),V=()=>new Date().toLocaleString("en-US",{month:"short",day:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0});return n.createElement("div",{className:`rte-preview ${d||""}`,style:te(ee({},u),{position:"relative"}),onClick:E},n.createElement("div",{className:"rte-preview-device-picker"},n.createElement("select",{value:L,onChange:b=>H(b.target.value)},Object.entries(z).map(([b,T])=>n.createElement("option",{key:b,value:b},T.label)))),L==="web"&&n.createElement("div",{className:"rte-preview-web-wrapper"},n.createElement("div",{className:"rte-preview-card"},n.createElement("div",{className:"rte-preview-content",dangerouslySetInnerHTML:{__html:N(a)}}),n.createElement("div",{className:"rte-preview-meta"},"Data updated as on Dec 14, 2025"),n.createElement("div",{className:"rte-preview-footer"},n.createElement("div",{className:"rte-preview-actions"},n.createElement(qe,{className:"rte-preview-like"}),n.createElement(Ie,{className:"rte-preview-like"})),n.createElement("div",{className:"rte-preview-time"},"Dec 26, 2025 5:57 PM")))),L!=="web"&&n.createElement("div",{className:"rte-preview-mobile-overlay"},n.createElement("div",{className:"rte-preview-mobile-frame",style:{width:z[L].width,height:z[L].height}},n.createElement("div",{className:"rte-preview-mobile-header"},n.createElement("div",{className:"rte-preview-logo"},"A"),n.createElement("div",{className:"rte-preview-bell"},"đ",n.createElement("span",{className:"rte-preview-badge"},"99+"))),n.createElement("div",{className:"rte-preview-tabs-wrapper"},n.createElement("div",{className:"rte-preview-tabs"},n.createElement("div",{className:"rte-preview-tab rte-preview-tab-active"},"My Alerts"),n.createElement("div",{className:"rte-preview-tab"},"Reportees Alerts"))),n.createElement("div",{className:"rte-preview-mobile-body"},n.createElement("div",{className:"rte-preview-card"},n.createElement("div",{className:"rte-preview-content",dangerouslySetInnerHTML:{__html:N(a)}}),n.createElement("div",{className:"rte-preview-meta"},"Data updated as on ",x()),n.createElement("div",{className:"rte-preview-footer"},n.createElement("div",{className:"rte-preview-actions"},n.createElement(qe,{className:"rte-preview-like"}),n.createElement(Ie,{className:"rte-preview-like"})),n.createElement("div",{className:"rte-preview-time"},V())))))),n.createElement("div",null,n.createElement("h3",{style:{marginBottom:10}},"Enter Attribute Values"),n.createElement("div",{className:"rte-attr-list"},Object.keys(h).map(b=>n.createElement("div",{key:b,className:"rte-attr-row"},n.createElement("div",{className:"rte-attr-name"},`{{${b}}}`),n.createElement("span",null," : "),n.createElement("input",{className:"rte-attr-input",value:h[b]||"",onChange:T=>{const _=T.target.value;v(j=>te(ee({},j),{[b]:_}))},placeholder:"Enter value"}))))))},cn=({visible:a,linkData:d,onClose:u,onInsert:h})=>{const[v,L]=n.useState(""),[H,z]=n.useState(""),[E,R]=n.useState(""),[N,x]=n.useState("_self");if(n.useEffect(()=>{a?(L(d.url||""),z(d.text||""),R(d.title||""),x(d.target||"_self")):(L(""),z(""),R(""),x("_self"))},[a,d]),!a)return null;const V=()=>{h({url:v,text:H,title:E,target:N})};return n.createElement(n.Fragment,null,n.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),n.createElement("div",{className:"rte-link-modal"},n.createElement("h4",{className:"rte-link-modal__title"},v?"Edit Link":"Insert Link"),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:v,onChange:b=>L(b.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:H,onChange:b=>z(b.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:b=>R(b.target.value)}),n.createElement("select",{className:"rte-link-modal__select",value:N,onChange:b=>x(b.target.value)},n.createElement("option",{value:"_self"},"Same tab"),n.createElement("option",{value:"_blank"},"New tab")),n.createElement("div",{className:"rte-link-modal__actions"},n.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),n.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:V},"OK"))))};function Be(a){const d=new Map;return a.forEach(u=>{d.set(u.name,u.value)}),Array.from(d.entries()).map(([u,h])=>({name:u,value:h}))}const sn=({atSuggestions:a=[],showOutput:d=!1,showPreview:u=!1,toolbarConfig:h={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1,unorderedList:!1,orderedList:!1,staticUnorderedList:!1,staticOrderedList:!1},classNames:v={},styles:L={},handleGetHtml:H=()=>{},onChange:z=()=>{},value:E,onMentionSelect:R=()=>{},handleAddAttributes:N=()=>{}})=>{var Se,xe,Re,Ne,Me,Te,Ae,ke,ze,De,Oe,He;const x=n.useRef(null),[V,b]=n.useState(E!=null&&E.length?E:" "),[T,_]=n.useState(""),[j,O]=n.useState(!1),[F,W]=n.useState({x:0,y:0}),[U,S]=n.useState([]),D=n.useRef(null),I=n.useRef(null),[P,q]=n.useState({visible:!1,x:0,y:0}),[Z,g]=n.useState(!1),w=n.useRef(null),[$,Y]=n.useState({url:"",text:"",title:"",target:"_self"}),ne={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:(Se=h.unorderedList)!=null?Se:!0,orderedList:(xe=h.orderedList)!=null?xe:!0,staticUnorderedList:(Re=h.staticUnorderedList)!=null?Re:!0,staticOrderedList:(Ne=h.staticOrderedList)!=null?Ne:!0,align:!0,link:(Me=h.link)!=null?Me:!1,image:(Te=h.image)!=null?Te:!1,emoji:(Ae=h.emoji)!=null?Ae:!1,table:(ke=h.table)!=null?ke:!1,color:(ze=h.color)!=null?ze:!1,fontFamily:(De=h.fontFamily)!=null?De:!1,fontSize:(Oe=h.fontSize)!=null?Oe:!1,highlight:(He=h.fontSize)!=null?He:!1},[ce,Q]=n.useState(""),[re,ie]=n.useState([]),[he,fe]=n.useState({}),B=()=>x.current,M=()=>{const e=Ze(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;t||(r=`<div style="font-size: 12px;">${e}</div>`),r=r.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g,(o,y,f)=>{if(/list-type=["']static["']/.test(f)||o.includes("data-hidden-array-start")||o.includes("data-hidden-array-end"))return o;const m=`<${y}${f}>`,i='<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>',p='<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',C=`</${y}>`,A=o.replace(new RegExp(`^${m}`),"").replace(new RegExp(`${C}$`),"");return`${m}${i}${A}${p}${C}`}),_(r),H==null||H(r);const l=ht(e);z(l);const s=tt(),c=Be(s);JSON.stringify(c)!==JSON.stringify(re)&&(ie(c),R(c),bt(c))},Ze=()=>{const e=B();if(!e)return V;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(l=>l.remove()),t.querySelectorAll("table").forEach(l=>{l.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-table-selected , .rte-cell-highlight").forEach(l=>l.classList.remove(".rte-table-selected , .rte-cell-highlight"));let r=t.innerHTML;return r=Xe(r),r},Xe=e=>{const t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("tbody").forEach(r=>{r.getAttribute("table-type")==="static"||(r.innerHTML=`{{#arrayData}}${r.innerHTML}{{/arrayData}}`)}),t.innerHTML},X=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const r=e.getRangeAt(0);t.contains(r.startContainer)&&(D.current=r.cloneRange())},K=()=>{const e=window.getSelection();!e||!D.current||(e.removeAllRanges(),e.addRange(D.current))},ge=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(D.current=r.getRangeAt(0)),K(),document.execCommand(e,!1,t),M()};n.useEffect(()=>{const e=B();if(!e||!E)return;const t=Ke(E);e.innerHTML=t,M()},[]);const Ke=e=>e.replace(/(<table[\s\S]*?>[\s\S]*?<\/table>)/g,t=>t.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""));n.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),n.useEffect(()=>{N&&N(e=>{et(e)})},[]),n.useEffect(()=>{const e=B();if(!e)return;e.querySelectorAll("table").forEach(r=>{r.hasAttribute("data-has-resize-handle")||(ue(r),r.querySelectorAll("th, td").forEach(s=>G(s)))})},[]),n.useEffect(()=>{const e=()=>{requestAnimationFrame(()=>{St()})};return document.addEventListener("selectionchange",e),()=>{document.removeEventListener("selectionchange",e)}},[]),n.useEffect(()=>{const e=x.current;if(!e)return;const t=()=>{e.querySelectorAll("table.rte-table-selected").forEach(l=>{l.dataset.__rteSelected="true",l.classList.remove("rte-table-selected")})},r=()=>{e.querySelectorAll("table[data-__rte-selected]").forEach(l=>{l.classList.add("rte-table-selected"),l.removeAttribute("data-__rte-selected")})};return e.addEventListener("copy",t),document.addEventListener("mouseup",r),()=>{e.removeEventListener("copy",t),document.removeEventListener("mouseup",r)}},[]);const pe=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},ve=(e,t)=>{var m;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.getRangeAt(0),s=pe(l.startContainer);let c,o;const y=t==="insertStaticUnorderedList"||t==="insertStaticOrderedList";if(s){let i=s.querySelector(e);i||(i=document.createElement(e),i.style.margin="0",i.style.paddingLeft="20px",s.appendChild(i)),o=i,c=document.createElement("li"),c.textContent="â",o.appendChild(c)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const i=B();if(o=i==null?void 0:i.querySelector(`${e}:last-child`),!o)return;y&&o.setAttribute("list-type","static"),c=o.querySelector("li:last-child")}const f=document.createRange();f.setStart(c,0),f.collapse(!0),r.removeAllRanges(),r.addRange(f),(m=B())==null||m.focus(),M()},se=(e,t)=>{e==="insertOrderedList"||e==="insertStaticOrderedList"?ve("ol",e):e==="insertUnorderedList"||e==="insertStaticUnorderedList"?ve("ul",e):e.startsWith("justify")?ft(e):ge(e,t),e==="insertTable"&&we(),e==="insertStaticTable"&&we("insertStaticTable")},Ye=e=>{const t=document.createElement("span");t.textContent="â",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const r=t.getBoundingClientRect();t.remove(),W({x:r.left,y:r.bottom+window.scrollY}),S(a||[]),O(!0),I.current=e.cloneRange()},Qe=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let r=e.anchorOffset;if(!t)return null;let l=t;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=t.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const s=l.textContent||"",c=l===t?r:s.length,o=s.lastIndexOf("@",c-1);if(o!==-1){const y=document.createRange();return y.setStart(l,o),y.setEnd(l,c),y}}l=l.previousSibling}return null},Ge=e=>{var c;const t=window.getSelection();if(!t)return;const r=Qe();r?(t.removeAllRanges(),t.addRange(r)):I.current&&(t.removeAllRanges(),t.addRange(I.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.display="inline",l.setAttribute("data-mention",e.value||e.name||""),l.title=`{{${e.name}}}`;try{const o=t.rangeCount?t.getRangeAt(0):null;if(o)o.deleteContents(),o.insertNode(l);else{const m=document.createRange(),i=B();m.selectNodeContents(i),m.collapse(!1),m.insertNode(l)}const y=document.createTextNode("â");l.after(y);const f=document.createRange();f.setStartAfter(y),f.collapse(!0),t.removeAllRanges(),t.addRange(f)}catch(o){console.error("insertMention error:",o)}let s=Be([...re,e]);ie(s),R(s),O(!1),(c=B())==null||c.focus(),M()},Je=e=>{const t=B();if(!t)return;let r=null;D.current&&t.contains(D.current.startContainer)?r=D.current.cloneRange():(r=document.createRange(),r.selectNodeContents(t),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),s.title=`{{${e.name}}}`,r.insertNode(s);const c=document.createTextNode(" ");s.after(c);const o=document.createRange();o.setStartAfter(c),o.collapse(!0),l.removeAllRanges(),l.addRange(o),D.current=o.cloneRange(),t.focus()},et=e=>{e.forEach(t=>Je(t)),ie(t=>{const r=[...t,...e],l=Array.from(new Map(r.map(s=>[s.name,s])).values());return R(l),l}),M()},tt=()=>{const e=B();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),r=[];return t.forEach(l=>{const s=l.getAttribute("data-mention")||"",o=(l.textContent||"").match(/{{(.+?)}}/);o&&r.push({name:o[1],value:s})}),r},nt=e=>{var r,l,s;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),se(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const c=window.getSelection(),o=c!=null&&c.anchorNode?pe(c.anchorNode):null;if(!o)return;if(((r=o.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const f=o.parentElement,m=f==null?void 0:f.closest("li");if(m){f==null||f.removeChild(o);const i=document.createElement("p");i.innerHTML="<br />",(l=m.parentElement)==null||l.insertBefore(i,m.nextSibling);const p=document.createRange();p.setStart(i,0),p.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(p)}else{const i=o.closest("ul, ol");if(i){const p=document.createElement("p");p.innerHTML="<br />",(s=i.parentElement)==null||s.insertBefore(p,i.nextSibling),i.removeChild(o);const C=document.createRange();C.setStart(p,0),C.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(C)}}M()}}if(t==="backspace"||t==="delete"){const c=window.getSelection();if(!c||c.rangeCount===0)return;const o=c.getRangeAt(0);if(o.cloneContents().querySelector("table"))return;if(o.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},rt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(de(l))return;setTimeout(()=>{Ye(r.getRangeAt(0)),Q(""),S(a),O(!0)},0);return}if(j){setTimeout(()=>Ee(),0);return}},de=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},Ee=()=>{M();const e=window.getSelection();if(!e||!e.anchorNode)return;if(de(e.anchorNode)){O(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const r=t.match(/@([^\n]*)$/);if(!r){O(!1);return}const l=r[1].trim().toLowerCase();Q(l);const s=a.filter(c=>c.name.toLowerCase().includes(l));s.length>0?(S(s),O(!0)):O(!1)},at=e=>{var l;const t=(l=e.target.files)==null?void 0:l[0];if(!t)return;const r=new FileReader;r.onload=s=>{var C;const c=(C=s.target)==null?void 0:C.result;K();const o=window.getSelection();let y=o&&o.rangeCount?o.getRangeAt(0):null;const f=document.createElement("img");f.src=c,f.alt=t.name||"image",f.className="rte-inserted-image",f.contentEditable="true";const m=B();if(!y||!m){m==null||m.appendChild(f);const A=document.createTextNode(" ");m==null||m.appendChild(A);const J=document.createRange();J.setStartAfter(A),J.collapse(!0),o==null||o.removeAllRanges(),o==null||o.addRange(J),m==null||m.focus(),M(),e.target.value="";return}y.deleteContents(),y.insertNode(f);const i=document.createTextNode(" ");f.after(i);const p=document.createRange();p.setStartAfter(i),p.collapse(!0),o.removeAllRanges(),o.addRange(p),m.focus(),M(),e.target.value=""},r.readAsDataURL(t)},lt=e=>{var s;K();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),t.removeAllRanges(),t.addRange(r),(s=B())==null||s.focus(),M()},we=e=>{var i;wt(),K();const t=document.createElement("table");t.style.borderCollapse="collapse",t.style.width="310px",t.style.border="1px solid #ccc",t.style.margin="8px 0",t.style.position="relative",t.style.textAlign="center",v.table&&t.classList.add(v.table);const r=document.createElement("thead");v.thead&&r.classList.add(v.thead);const l=document.createElement("tbody");v.tbody&&l.classList.add(v.tbody),e==="insertStaticTable"&&l.setAttribute("table-type","static");const s=document.createElement("tr");v.tr&&s.classList.add(v.tr);const c=document.createElement("tr");v.tr&&c.classList.add(v.tr);for(let p=0;p<2;p++){const C=document.createElement("th");C.textContent="",C.style.border="1px solid #999",C.style.padding="4px",C.style.position="relative",C.style.backgroundColor="lightgray",C.style.height="20px",v.th&&C.classList.add(v.th);const A=document.createElement("td");A.textContent="",A.style.border="1px solid #999",A.style.padding="4px",A.style.position="relative",A.style.backgroundColor="#fff",A.style.minHeight="20px",A.style.height="20px",A.style.whiteSpace="normal",A.style.wordBreak="break-word",A.style.overflowWrap="anywhere",A.style.lineHeight="20px",A.style.minWidth="20px",v.td&&A.classList.add(v.td),G(C),G(A),s.appendChild(C),c.appendChild(A)}r.appendChild(s),l.appendChild(c),t.appendChild(r),t.appendChild(l),ue(t);const o=window.getSelection();if(!(o!=null&&o.rangeCount))return;const y=o.getRangeAt(0);y.collapse(!1),y.insertNode(t);const f=document.createElement("p");f.innerHTML="<br/>",t.after(f);const m=document.createRange();m.setStart(f,0),m.collapse(!0),o.removeAllRanges(),o.addRange(m),(i=B())==null||i.focus(),M()},ue=e=>{if(e.dataset.hasResizeHandle==="true")return;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.contentEditable="false",t.dataset.hasResizeHandle="true",t.classList.add("rte-resize-handle"),t.addEventListener("mousedown",r=>{r.preventDefault(),r.clientX,r.clientY;const l=e.getBoundingClientRect();l.width,l.height;const s=o=>{const y=Math.max(100,o.clientX-l.left),f=Math.max(20,o.clientY-l.top);e.style.width=`${y}px`,e.style.height=`${f}px`,M()},c=()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",c),M()};document.addEventListener("mousemove",s),document.addEventListener("mouseup",c)}),e.appendChild(t)},G=e=>{const t=document.createElement("div"),r=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",t.classList.add("rte-resize-handle"),Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),r.contentEditable="false",r.classList.add("rte-resize-handle"),ot(e,t,r),e.appendChild(t),e.appendChild(r)},ot=(e,t,r)=>{let l=0,s=0,c=0,o=0;t.addEventListener("mousedown",i=>{i.preventDefault(),l=i.clientX,c=e.offsetWidth,document.addEventListener("mousemove",y),document.addEventListener("mouseup",m)}),r.addEventListener("mousedown",i=>{i.preventDefault(),s=i.clientY,o=e.offsetHeight,document.addEventListener("mousemove",f),document.addEventListener("mouseup",m)});const y=i=>{const p=c+(i.clientX-l);e.style.width=`${Math.max(30,p)}px`,M()},f=i=>{const p=o+(i.clientY-s);e.style.height=`${Math.max(20,p)}px`,M()},m=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m),M()}},ct=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"),q({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},ye=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))};function be(){const e=x.current;e&&e.querySelectorAll("table.rte-table-selected").forEach(t=>t.classList.remove("rte-table-selected"))}const it=e=>{var c,o,y;if(!P.cell)return;const t=P.cell.closest("table"),r=P.cell.cellIndex,l=P.cell.parentElement.rowIndex,s=f=>{const m=f.tagName.toLowerCase(),i=document.createElement(m);return i.textContent="",i.style.cssText=f.style.cssText,G(i),i};switch(e){case"insertRowAbove":{const f=t.rows[l],m=t.insertRow(l);Array.from(f.cells).forEach(i=>{m.appendChild(s(i))});break}case"insertRowBelow":{const f=t.rows[l],m=t.insertRow(l+1);Array.from(f.cells).forEach(i=>{m.appendChild(s(i))});break}case"insertColLeft":{Array.from(t.rows).forEach(f=>{const m=f.cells[r];f.insertBefore(s(m),m)});break}case"insertColRight":{Array.from(t.rows).forEach(f=>{const m=f.cells[r];f.insertBefore(s(m),m.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(l);break;case"deleteCol":Array.from(t.rows).forEach(f=>{f.cells[r]&&f.deleteCell(r)});break;case"deleteTable":{const f=(c=P.cell)==null?void 0:c.closest("table");if(!f)break;f.remove();const m=document.createElement("p");m.innerHTML="<br />",(y=(o=P.cell)==null?void 0:o.parentElement)==null||y.after(m);break}}requestAnimationFrame(()=>M()),q(te(ee({},P),{visible:!1})),ye(),be()},st=()=>{X(),w.current=D.current,Y({url:"",text:"",title:"",target:"_self"}),g(!0)},dt=e=>{const t=window.getSelection();if(!t||!w.current)return;t.removeAllRanges(),t.addRange(w.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=t.getRangeAt(0);s.deleteContents(),s.insertNode(l);const c=document.createTextNode(" ");l.after(c);const o=document.createRange();o.setStartAfter(c),o.collapse(!0),t.removeAllRanges(),t.addRange(o),g(!1),M()},ut=e=>{const t=e.target;if(t.tagName==="A"){const r=t;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),w.current=l,Y({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),g(!0)}},mt=()=>{const e=B();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&D.current){const i=window.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(D.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);K(),document.execCommand("removeFormat",!1);const s=l.cloneContents(),c=document.createElement("div");c.appendChild(s);const o=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT,null),y=[];for(;o.nextNode();){const i=o.currentNode,p=i.tagName.toUpperCase(),C=i.getAttribute&&i.getAttribute("data-mention")!==null;p!=="A"&&!C&&y.push(i)}for(let i=y.length-1;i>=0;i--){const p=y[i],C=p.parentNode;if(C){for(;p.firstChild;)C.insertBefore(p.firstChild,p);C.removeChild(p)}}c.querySelectorAll("[style]").forEach(i=>i.removeAttribute("style")),l.deleteContents();const f=document.createDocumentFragment();for(;c.firstChild;)f.appendChild(c.firstChild);l.insertNode(f);const m=document.createRange();m.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),m.collapse(!0),r.removeAllRanges(),r.addRange(m),e.normalize(),M()},ht=e=>{var l;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=t,r.querySelectorAll("br").forEach(s=>{s.replaceWith(`
|
|
1
|
+
"use strict";var xt=Object.defineProperty,Rt=Object.defineProperties;var Nt=Object.getOwnPropertyDescriptors;var Pe=Object.getOwnPropertySymbols;var Mt=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable;var _e=(a,d,u)=>d in a?xt(a,d,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[d]=u,ee=(a,d)=>{for(var u in d||(d={}))Mt.call(d,u)&&_e(a,u,d[u]);if(Pe)for(var u of Pe(d))Tt.call(d,u)&&_e(a,u,d[u]);return a},te=(a,d)=>Rt(a,Nt(d));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),At=require("react-dom");function kt(a){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const u in a)if(u!=="default"){const h=Object.getOwnPropertyDescriptor(a,u);Object.defineProperty(d,u,h.get?h:{enumerable:!0,get:()=>a[u]})}}return d.default=a,Object.freeze(d)}const zt=kt(n);window.React=zt;var Ve={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},je=n.createContext&&n.createContext(Ve),Dt=["attr","size","title"];function Ht(a,d){if(a==null)return{};var u=Ot(a,d),h,v;if(Object.getOwnPropertySymbols){var S=Object.getOwnPropertySymbols(a);for(v=0;v<S.length;v++)h=S[v],!(d.indexOf(h)>=0)&&Object.prototype.propertyIsEnumerable.call(a,h)&&(u[h]=a[h])}return u}function Ot(a,d){if(a==null)return{};var u={};for(var h in a)if(Object.prototype.hasOwnProperty.call(a,h)){if(d.indexOf(h)>=0)continue;u[h]=a[h]}return u}function le(){return le=Object.assign?Object.assign.bind():function(a){for(var d=1;d<arguments.length;d++){var u=arguments[d];for(var h in u)Object.prototype.hasOwnProperty.call(u,h)&&(a[h]=u[h])}return a},le.apply(this,arguments)}function Fe(a,d){var u=Object.keys(a);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(a);d&&(h=h.filter(function(v){return Object.getOwnPropertyDescriptor(a,v).enumerable})),u.push.apply(u,h)}return u}function oe(a){for(var d=1;d<arguments.length;d++){var u=arguments[d]!=null?arguments[d]:{};d%2?Fe(Object(u),!0).forEach(function(h){Pt(a,h,u[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(u)):Fe(Object(u)).forEach(function(h){Object.defineProperty(a,h,Object.getOwnPropertyDescriptor(u,h))})}return a}function Pt(a,d,u){return d=_t(d),d in a?Object.defineProperty(a,d,{value:u,enumerable:!0,configurable:!0,writable:!0}):a[d]=u,a}function _t(a){var d=jt(a,"string");return typeof d=="symbol"?d:d+""}function jt(a,d){if(typeof a!="object"||!a)return a;var u=a[Symbol.toPrimitive];if(u!==void 0){var h=u.call(a,d);if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(a)}function Ue(a){return a&&a.map((d,u)=>n.createElement(d.tag,oe({key:u},d.attr),Ue(d.child)))}function k(a){return d=>n.createElement(Ft,le({attr:oe({},a.attr)},d),Ue(a.child))}function Ft(a){var d=u=>{var{attr:h,size:v,title:S}=a,O=Ht(a,Dt),z=v||u.size||"1em",E;return u.className&&(E=u.className),a.className&&(E=(E?E+" ":"")+a.className),n.createElement("svg",le({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,h,O,{className:E,style:oe(oe({color:a.color||u.color},u.style),a.style),height:z,width:z,xmlns:"http://www.w3.org/2000/svg"}),S&&n.createElement("title",null,S),a.children)};return je!==void 0?n.createElement(je.Consumer,null,u=>d(u)):d(Ve)}function It(a){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:[]}]})(a)}function qt(a){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:[]}]})(a)}function Bt(a){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:[]}]})(a)}function Vt(a){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:[]}]})(a)}function Ut(a){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:[]}]})(a)}function $t(a){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:[]}]})(a)}function Wt(a){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:[]}]})(a)}function Zt(a){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:[]}]})(a)}function Xt(a){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:[]}]})(a)}function Kt(a){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:[]}]})(a)}function Yt(a){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:[]}]})(a)}function Qt(a){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:[]}]})(a)}function Gt(a){return k({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM56.84,75.58a8,8,0,0,1,3.58-10.74l16-8A8,8,0,0,1,88,64v48a8,8,0,0,1-16,0V76.94l-4.42,2.22A8,8,0,0,1,56.84,75.58ZM92,180a8,8,0,0,1,0,16H68a8,8,0,0,1-6.4-12.8l21.67-28.89A3.92,3.92,0,0,0,84,152a4,4,0,0,0-7.77-1.33,8,8,0,0,1-15.09-5.34,20,20,0,1,1,35,18.53L84,180Zm100,4H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Z"},child:[]}]})(a)}function Jt(a){return k({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 18H9V20H2V18ZM2 11H11V13H2V11ZM2 4H22V6H2V4ZM20.674 13.0251L21.8301 12.634L22.8301 14.366L21.914 15.1711C21.9704 15.4386 22 15.7158 22 16C22 16.2842 21.9704 16.5614 21.914 16.8289L22.8301 17.634L21.8301 19.366L20.674 18.9749C20.2635 19.3441 19.7763 19.6295 19.2391 19.8044L19 21H17L16.7609 19.8044C16.2237 19.6295 15.7365 19.3441 15.326 18.9749L14.1699 19.366L13.1699 17.634L14.086 16.8289C14.0296 16.5614 14 16.2842 14 16C14 15.7158 14.0296 15.4386 14.086 15.1711L13.1699 14.366L14.1699 12.634L15.326 13.0251C15.7365 12.6559 16.2237 12.3705 16.7609 12.1956L17 11H19L19.2391 12.1956C19.7763 12.3705 20.2635 12.6559 20.674 13.0251ZM18 17C18.5523 17 19 16.5523 19 16C19 15.4477 18.5523 15 18 15C17.4477 15 17 15.4477 17 16C17 16.5523 17.4477 17 18 17Z"},child:[]}]})(a)}function en(a){return k({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]},{tag:"path",attr:{d:"M19.001 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M19.001 15.5v1.5"},child:[]},{tag:"path",attr:{d:"M19.001 21v1.5"},child:[]},{tag:"path",attr:{d:"M22.032 17.25l-1.299 .75"},child:[]},{tag:"path",attr:{d:"M17.27 20l-1.3 .75"},child:[]},{tag:"path",attr:{d:"M15.97 17.25l1.3 .75"},child:[]},{tag:"path",attr:{d:"M20.733 20l1.3 .75"},child:[]}]})(a)}function tn(a){return k({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]}]})(a)}function nn(a){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:[]}]})(a)}function rn(a){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:[]}]})(a)}const an=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],$e=({exec:a,saveSelection:d,handleFileChange:u,handleFontSizeChange:h,handleFontFamilyChange:v,insertEmoji:S,handleLink:O,removeFormatting:z,visibleActions:E,className:R,style:N})=>{var q,Z;const x=n.useRef(null),V=n.useRef(null),C=n.useRef(null),[T,_]=n.useState(!1),[j,H]=n.useState({x:0,y:0});n.useEffect(()=>{const g=y=>{!y.target.closest(".rte-emoji-popup")&&!y.target.closest("button[title='Emoji']")&&_(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const F=g=>{var $;g.preventDefault();const y=g.currentTarget.dataset.command;if(y)switch(y){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertStaticUnorderedList":case"insertOrderedList":case"insertStaticOrderedList":case"removeFormat":a(y);break;case"insertImage":{($=x.current)==null||$.click();break}default:console.warn("Unknown command:",y)}},W=g=>{a("foreColor",g.target.value)},U=g=>{a("backColor",g.target.value)},[L,D]=n.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}),I=n.useRef(null),P=n.useRef(null);return n.useEffect(()=>{const g=()=>{const y=window.getSelection();if(!y||!y.anchorNode)return;let $=y.anchorNode.nodeType===Node.ELEMENT_NODE?y.anchorNode:y.anchorNode.parentElement;if(!$)return;const Y=window.getComputedStyle($),ne=Y.fontFamily.replace(/['"]/g,"").split(",")[0],ie=parseInt(Y.fontSize,10);if(I.current){const Q=Array.from(I.current.options).some(re=>re.value===ne);I.current.value=Q?ne:""}P.current&&(P.current.value=String(ie))};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),n.useEffect(()=>{const g=()=>{D({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",g),()=>document.removeEventListener("selectionchange",g)},[]),n.createElement("div",{className:`rte-toolbar ${R||""}`,style:N},E.bold&&n.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:F,className:L.bold?"rte-active":""},n.createElement($t,null)),E.italic&&n.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:F,className:L.italic?"rte-active":""},n.createElement(Zt,null)),E.underline&&n.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:F,className:L.underline?"rte-active":""},n.createElement(Qt,null)),E.unorderedList&&n.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:F,title:"UnorderedList",className:L.unorderedList?"rte-active":""},n.createElement(Jt,null)),E.staticUnorderedList&&n.createElement("button",{"data-command":"insertStaticUnorderedList",onMouseDown:F,title:"StaticUnorderedList",className:L.unorderedList?"rte-active":""},n.createElement(Kt,null)),E.orderedList&&n.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:F,className:L.orderedList?"rte-active":"",style:{fontSize:"medium"}},n.createElement(Gt,null)),E.staticOrderedList&&n.createElement("button",{"data-command":"insertStaticOrderedList",title:"StaticOrderedList",onMouseDown:F,className:L.orderedList?"rte-active":""},n.createElement(Vt,null)),E.link&&n.createElement("button",{"data-command":"createLink",title:"Link",onClick:O,className:L.link?"rte-active":""},n.createElement(Xt,null)),E.removeFormat&&n.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),d(),z()},className:L.removeFormat?"rte-active":""},n.createElement(rn,null)),E.image&&n.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:F,className:L.image?"rte-active":""},n.createElement(Bt,null)),n.createElement("input",{type:"file",accept:"image/*",ref:x,style:{display:"none"},onChange:u}),E.emoji&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),d();const y=g.currentTarget.getBoundingClientRect();H({x:y.left,y:y.bottom+8}),_($=>!$)},className:L.emoji?"rte-active":""},n.createElement(Yt,null)),T&&At.createPortal(n.createElement("div",{className:"rte-emoji-popup",style:{top:j.y,left:j.x}},an.map((g,y)=>n.createElement("span",{key:y,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:$=>{$.preventDefault(),S(g),_(!1)}},g))),document.body)),E.color&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Text Color",onMouseDown:g=>{var y;g.preventDefault(),d(),(y=V.current)==null||y.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((q=V.current)==null?void 0:q.value)||"#000",fontSize:"18px"},className:L.color?"rte-active":""},n.createElement(nn,null)),n.createElement("input",{ref:V,type:"color",defaultValue:"#000000",onChange:g=>{var y;W(g),((y=g.target.parentElement)==null?void 0:y.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Highlight",onMouseDown:g=>{var y;g.preventDefault(),d(),(y=C.current)==null||y.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((Z=C.current)==null?void 0:Z.value)||"#000",fontSize:"18px"},className:L.highlight?"rte-active":""},n.createElement(Wt,null)),n.createElement("input",{ref:C,type:"color",onChange:g=>{var y;U(g),((y=g.target.parentElement)==null?void 0:y.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&n.createElement(n.Fragment,null,n.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyLeft"),className:L.alignLeft?"rte-active":""},n.createElement(Ut,null)),n.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyCenter"),className:L.alignCenter?"rte-active":""},n.createElement(It,null)),n.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyRight"),className:L.alignRight?"rte-active":""},n.createElement(qt,null))),E.table&&n.createElement("button",{title:"Insert Dynamic Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertTable"),className:L.table?"rte-active":"",style:{fontSize:"medium"}},n.createElement(en,null)),E.table&&n.createElement("button",{title:"Insert Static Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertStaticTable"),className:L.table?"rte-active":"",style:{fontSize:"medium"}},n.createElement(tn,null)),E.fontFamily&&n.createElement("select",{ref:I,className:"rte-dropdown",defaultValue:"",onMouseDown:()=>d(),onChange:v},n.createElement("option",{value:"",disabled:!0},"Font Family"),n.createElement("option",{value:"Arial"},"Arial"),n.createElement("option",{value:"Georgia"},"Georgia"),n.createElement("option",{value:"Times New Roman"},"Times New Roman"),n.createElement("option",{value:"Courier New"},"Courier New"),n.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&n.createElement("select",{ref:P,className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>d(),onChange:h},n.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(g,y)=>10+y).map(g=>n.createElement("option",{key:g,value:g},g,"px"))))},ln=({show:a,position:d,filtered:u,insertMention:h,onClose:v,query:S})=>{const O=n.useRef(null),[z,E]=n.useState(0);return n.useEffect(()=>{a&&E(0)},[a]),n.useEffect(()=>{const R=N=>{O.current&&!O.current.contains(N.target)&&v()};return a&&document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[a,v]),n.useEffect(()=>{if(!a)return;const R=N=>{if(!(!a||u.length===0)&&(N.key==="ArrowDown"&&(N.preventDefault(),E(x=>Math.min(x+1,u.length-1))),N.key==="ArrowUp"&&(N.preventDefault(),E(x=>Math.max(x-1,0))),N.key==="Enter")){N.preventDefault();const x=u[z];x&&h(x)}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[a,u,z]),n.useEffect(()=>{if(!O.current)return;const N=O.current.querySelectorAll("li")[z];N&&N.scrollIntoView({block:"nearest",behavior:"smooth"})},[z]),a?n.createElement("ul",{ref:O,className:"rte-popup",style:{top:d.y,left:d.x}},u.length>0?u.map(({name:R,value:N},x)=>{const V=R.toLowerCase(),C=S.toLowerCase(),T=V.indexOf(C);let _=R;if(T!==-1&&S.length>0){const j=T+S.length;_=R.substring(0,T)+`<span class="rte-highlight">${R.substring(T,j)}</span>`+R.substring(j)}return n.createElement("li",{key:N,onMouseDown:j=>{j.preventDefault(),h({name:R,value:N})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:x===z?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:_},onMouseEnter:()=>E(x)})}):n.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function me(a){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:[]}]}]}]})(a)}function ae(a){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:[]}]}]}]})(a)}const on=({visible:a,x:d,y:u,onAction:h,onClose:v})=>{if(!a)return null;const S={top:u,left:d};return n.createElement("div",{style:S,className:"rte-table-menu",onMouseLeave:v},n.createElement("button",{onClick:()=>h("insertRowAbove")},n.createElement(ae,null)," Insert row above"),n.createElement("button",{onClick:()=>h("insertRowBelow")},n.createElement(ae,null)," Insert row below"),n.createElement("button",{onClick:()=>h("insertColLeft")},n.createElement(ae,null)," Insert col left"),n.createElement("button",{onClick:()=>h("insertColRight")},n.createElement(ae,null)," Insert col right"),n.createElement("button",{onClick:()=>h("deleteRow")},n.createElement(me,null)," Delete row"),n.createElement("button",{onClick:()=>h("deleteCol")},n.createElement(me,null)," Delete column"),n.createElement("button",{onClick:()=>h("deleteTable")},n.createElement(me,null)," Delete table"))};function Ie(a){return k({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M885.9 490.3c3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-51.6-30.7-98.1-78.3-118.4a66.1 66.1 0 0 0-26.5-5.4H144c-17.7 0-32 14.3-32 32v364c0 17.7 14.3 32 32 32h129.3l85.8 310.8C372.9 889 418.9 924 470.9 924c29.7 0 57.4-11.8 77.9-33.4 20.5-21.5 31-49.7 29.5-79.4l-6-122.9h239.9c12.1 0 23.9-3.2 34.3-9.3 40.4-23.5 65.5-66.1 65.5-111 0-28.3-9.3-55.5-26.1-77.7zM184 456V172h81v284h-81zm627.2 160.4H496.8l9.6 198.4c.6 11.9-4.7 23.1-14.6 30.5-6.1 4.5-13.6 6.8-21.1 6.7a44.28 44.28 0 0 1-42.2-32.3L329 459.2V172h415.4a56.85 56.85 0 0 1 33.6 51.8c0 9.7-2.3 18.9-6.9 27.3l-13.9 25.4 21.9 19a56.76 56.76 0 0 1 19.6 43c0 9.7-2.3 18.9-6.9 27.3l-13.9 25.4 21.9 19a56.76 56.76 0 0 1 19.6 43c0 9.7-2.3 18.9-6.9 27.3l-14 25.5 21.9 19a56.76 56.76 0 0 1 19.6 43c0 19.1-11 37.5-28.8 48.4z"},child:[]}]})(a)}function qe(a){return k({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M885.9 533.7c16.8-22.2 26.1-49.4 26.1-77.7 0-44.9-25.1-87.4-65.5-111.1a67.67 67.67 0 0 0-34.3-9.3H572.4l6-122.9c1.4-29.7-9.1-57.9-29.5-79.4A106.62 106.62 0 0 0 471 99.9c-52 0-98 35-111.8 85.1l-85.9 311H144c-17.7 0-32 14.3-32 32v364c0 17.7 14.3 32 32 32h601.3c9.2 0 18.2-1.8 26.5-5.4 47.6-20.3 78.3-66.8 78.3-118.4 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7-.2-12.6-2-25.1-5.6-37.1zM184 852V568h81v284h-81zm636.4-353l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 16.5-7.2 32.2-19.6 43l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 16.5-7.2 32.2-19.6 43l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 22.4-13.2 42.6-33.6 51.8H329V564.8l99.5-360.5a44.1 44.1 0 0 1 42.2-32.3c7.6 0 15.1 2.2 21.1 6.7 9.9 7.4 15.2 18.6 14.6 30.5l-9.6 198.4h314.4C829 418.5 840 436.9 840 456c0 16.5-7.2 32.1-19.6 43z"},child:[]}]})(a)}const We=({html:a,className:d,style:u,attributes:h,setAttributes:v})=>{const[S,O]=n.useState("web"),z={web:{label:"Web",width:"100%",height:"100%"},galaxyS23:{label:"Galaxy S23",width:360,height:780},iphoneSE:{label:"iPhone SE (3rd Gen)",width:375,height:667},iphoneX:{label:"iPhone X / XS",width:375,height:812},pixel7a:{label:"Pixel 7a",width:390,height:844},iphone12:{label:"iPhone 12 / 13 / 14",width:390,height:844},iphone14:{label:"iPhone 14 Pro",width:393,height:852},pixel7:{label:"Pixel 7",width:412,height:915},iphone11:{label:"iPhone 11",width:414,height:896},iphone14ProMax:{label:"iPhone 14 Pro Max",width:430,height:932},pixel8Pro:{label:"Pixel 8 Pro",width:448,height:998},galaxyS24Ultra:{label:"Galaxy S24 Ultra",width:480,height:1040}},E=C=>{const T=C.target;if(T.tagName==="A"){C.preventDefault();const _=T.href;_&&window.open(_,"_blank","noopener,noreferrer")}},R=C=>C==="rgb(0, 0, 0)"||C==="rgba(0, 0, 0, 1)"||C==="#000"||C==="#000000"||C==="black",N=C=>{const T=document.createElement("div");T.innerHTML=C;const _=document.createTreeWalker(T,NodeFilter.SHOW_TEXT,null),j=[];for(;_.nextNode();){const H=_.currentNode;H.nodeValue&&/{{\s*[\s\S]*?\s*}}/.test(H.nodeValue)&&j.push(H)}return j.forEach(H=>{var P;const F=H.nodeValue||"",W=H.parentElement;if(!W)return;let U=W,L=!1;for(;U;){if(U.tagName==="FONT"&&U.getAttribute("color")){L=!0;break}const q=(P=U.style)==null?void 0:P.color;if(q&&!R(q)){L=!0;break}const Z=window.getComputedStyle(U);if(Z.color&&!R(Z.color)){L=!0;break}U=U.parentElement}const D=document.createDocumentFragment();let I=0;F.replace(/{{\s*([\s\S]*?)\s*}}/g,(q,Z,g)=>{if(g>I&&D.appendChild(document.createTextNode(F.slice(I,g))),L)D.appendChild(document.createTextNode(q));else{const y=document.createElement("span");y.style.color="blue",y.textContent=q,D.appendChild(y)}return I=g+q.length,q}),I<F.length&&D.appendChild(document.createTextNode(F.slice(I))),W.replaceChild(D,H)}),T.innerHTML=T.innerHTML.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""),T.innerHTML},x=()=>new Date().toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),V=()=>new Date().toLocaleString("en-US",{month:"short",day:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0});return n.createElement("div",{className:`rte-preview ${d||""}`,style:te(ee({},u),{position:"relative"}),onClick:E},n.createElement("div",{className:"rte-preview-device-picker"},n.createElement("select",{value:S,onChange:C=>O(C.target.value)},Object.entries(z).map(([C,T])=>n.createElement("option",{key:C,value:C},T.label)))),S==="web"&&n.createElement("div",{className:"rte-preview-web-wrapper"},n.createElement("div",{className:"rte-preview-card"},n.createElement("div",{className:"rte-preview-content",dangerouslySetInnerHTML:{__html:N(a)}}),n.createElement("div",{className:"rte-preview-meta"},"Data updated as on Dec 14, 2025"),n.createElement("div",{className:"rte-preview-footer"},n.createElement("div",{className:"rte-preview-actions"},n.createElement(qe,{className:"rte-preview-like"}),n.createElement(Ie,{className:"rte-preview-like"})),n.createElement("div",{className:"rte-preview-time"},"Dec 26, 2025 5:57 PM")))),S!=="web"&&n.createElement("div",{className:"rte-preview-mobile-overlay"},n.createElement("div",{className:"rte-preview-mobile-frame",style:{width:z[S].width,height:z[S].height}},n.createElement("div",{className:"rte-preview-mobile-header"},n.createElement("div",{className:"rte-preview-logo"},"A"),n.createElement("div",{className:"rte-preview-bell"},"đ",n.createElement("span",{className:"rte-preview-badge"},"99+"))),n.createElement("div",{className:"rte-preview-tabs-wrapper"},n.createElement("div",{className:"rte-preview-tabs"},n.createElement("div",{className:"rte-preview-tab rte-preview-tab-active"},"My Alerts"),n.createElement("div",{className:"rte-preview-tab"},"Reportees Alerts"))),n.createElement("div",{className:"rte-preview-mobile-body"},n.createElement("div",{className:"rte-preview-card"},n.createElement("div",{className:"rte-preview-content",dangerouslySetInnerHTML:{__html:N(a)}}),n.createElement("div",{className:"rte-preview-meta"},"Data updated as on ",x()),n.createElement("div",{className:"rte-preview-footer"},n.createElement("div",{className:"rte-preview-actions"},n.createElement(qe,{className:"rte-preview-like"}),n.createElement(Ie,{className:"rte-preview-like"})),n.createElement("div",{className:"rte-preview-time"},V())))))),n.createElement("div",null,n.createElement("h3",{style:{marginBottom:10}},"Enter Attribute Values"),n.createElement("div",{className:"rte-attr-list"},Object.keys(h).map(C=>n.createElement("div",{key:C,className:"rte-attr-row"},n.createElement("div",{className:"rte-attr-name"},`{{${C}}}`),n.createElement("span",null," : "),n.createElement("input",{className:"rte-attr-input",value:h[C]||"",onChange:T=>{const _=T.target.value;v(j=>te(ee({},j),{[C]:_}))},placeholder:"Enter value"}))))))},cn=({visible:a,linkData:d,onClose:u,onInsert:h})=>{const[v,S]=n.useState(""),[O,z]=n.useState(""),[E,R]=n.useState(""),[N,x]=n.useState("_self");if(n.useEffect(()=>{a?(S(d.url||""),z(d.text||""),R(d.title||""),x(d.target||"_self")):(S(""),z(""),R(""),x("_self"))},[a,d]),!a)return null;const V=()=>{h({url:v,text:O,title:E,target:N})};return n.createElement(n.Fragment,null,n.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),n.createElement("div",{className:"rte-link-modal"},n.createElement("h4",{className:"rte-link-modal__title"},v?"Edit Link":"Insert Link"),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:v,onChange:C=>S(C.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:O,onChange:C=>z(C.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:C=>R(C.target.value)}),n.createElement("select",{className:"rte-link-modal__select",value:N,onChange:C=>x(C.target.value)},n.createElement("option",{value:"_self"},"Same tab"),n.createElement("option",{value:"_blank"},"New tab")),n.createElement("div",{className:"rte-link-modal__actions"},n.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),n.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:V},"OK"))))};function Be(a){const d=new Map;return a.forEach(u=>{d.set(u.name,u.value)}),Array.from(d.entries()).map(([u,h])=>({name:u,value:h}))}const sn=({atSuggestions:a=[],showOutput:d=!1,showPreview:u=!1,toolbarConfig:h={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1,unorderedList:!1,orderedList:!1,staticUnorderedList:!1,staticOrderedList:!1},classNames:v={},styles:S={},handleGetHtml:O=()=>{},onChange:z=()=>{},value:E,onMentionSelect:R=()=>{},handleAddAttributes:N=()=>{}})=>{var Le,xe,Re,Ne,Me,Te,Ae,ke,ze,De,He,Oe;const x=n.useRef(null),[V,C]=n.useState(E!=null&&E.length?E:" "),[T,_]=n.useState(""),[j,H]=n.useState(!1),[F,W]=n.useState({x:0,y:0}),[U,L]=n.useState([]),D=n.useRef(null),I=n.useRef(null),[P,q]=n.useState({visible:!1,x:0,y:0}),[Z,g]=n.useState(!1),y=n.useRef(null),[$,Y]=n.useState({url:"",text:"",title:"",target:"_self"}),ne={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:(Le=h.unorderedList)!=null?Le:!0,orderedList:(xe=h.orderedList)!=null?xe:!0,staticUnorderedList:(Re=h.staticUnorderedList)!=null?Re:!0,staticOrderedList:(Ne=h.staticOrderedList)!=null?Ne:!0,align:!0,link:(Me=h.link)!=null?Me:!1,image:(Te=h.image)!=null?Te:!1,emoji:(Ae=h.emoji)!=null?Ae:!1,table:(ke=h.table)!=null?ke:!1,color:(ze=h.color)!=null?ze:!1,fontFamily:(De=h.fontFamily)!=null?De:!1,fontSize:(He=h.fontSize)!=null?He:!1,highlight:(Oe=h.fontSize)!=null?Oe:!1},[ie,Q]=n.useState(""),[re,ce]=n.useState([]),[he,fe]=n.useState({}),B=()=>x.current,M=()=>{const e=Ze(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;t||(r=`<div style="font-size: 12px;">${e}</div>`),r=r.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g,(o,w,f)=>{if(/list-type=["']static["']/.test(f)||o.includes("data-hidden-array-start")||o.includes("data-hidden-array-end"))return o;const m=`<${w}${f}>`,c='<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>',p='<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',b=`</${w}>`,A=o.replace(new RegExp(`^${m}`),"").replace(new RegExp(`${b}$`),"");return`${m}${c}${A}${p}${b}`}),_(r),O==null||O(r);const l=ht(e);z(l);const s=tt(),i=Be(s);JSON.stringify(i)!==JSON.stringify(re)&&(ce(i),R(i),bt(i))},Ze=()=>{const e=B();if(!e)return V;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(l=>l.remove()),t.querySelectorAll("table").forEach(l=>{l.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-table-selected , .rte-cell-highlight").forEach(l=>l.classList.remove(".rte-table-selected , .rte-cell-highlight"));let r=t.innerHTML;return r=Xe(r),r},Xe=e=>{const t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("tbody").forEach(r=>{r.getAttribute("table-type")==="static"||(r.innerHTML=`{{#arrayData}}${r.innerHTML}{{/arrayData}}`)}),t.innerHTML},X=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const r=e.getRangeAt(0);t.contains(r.startContainer)&&(D.current=r.cloneRange())},K=()=>{const e=window.getSelection();!e||!D.current||(e.removeAllRanges(),e.addRange(D.current))},ge=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(D.current=r.getRangeAt(0)),K(),document.execCommand(e,!1,t),M()};n.useEffect(()=>{const e=B();if(!e||!E)return;const t=Ke(E);e.innerHTML=t,M()},[]);const Ke=e=>e.replace(/(<table[\s\S]*?>[\s\S]*?<\/table>)/g,t=>t.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""));n.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),n.useEffect(()=>{N&&N(e=>{et(e)})},[]),n.useEffect(()=>{const e=B();if(!e)return;e.querySelectorAll("table").forEach(r=>{r.hasAttribute("data-has-resize-handle")||(ue(r),r.querySelectorAll("th, td").forEach(s=>G(s)))})},[]),n.useEffect(()=>{const e=()=>{requestAnimationFrame(()=>{Lt()})};return document.addEventListener("selectionchange",e),()=>{document.removeEventListener("selectionchange",e)}},[]),n.useEffect(()=>{const e=x.current;if(!e)return;const t=()=>{e.querySelectorAll("table.rte-table-selected").forEach(l=>{l.dataset.__rteSelected="true",l.classList.remove("rte-table-selected")})},r=()=>{e.querySelectorAll("table[data-__rte-selected]").forEach(l=>{l.classList.add("rte-table-selected"),l.removeAttribute("data-__rte-selected")})};return e.addEventListener("copy",t),document.addEventListener("mouseup",r),()=>{e.removeEventListener("copy",t),document.removeEventListener("mouseup",r)}},[]);const pe=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},ve=(e,t)=>{var m;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.getRangeAt(0),s=pe(l.startContainer);let i,o;const w=t==="insertStaticUnorderedList"||t==="insertStaticOrderedList";if(s){let c=s.querySelector(e);c||(c=document.createElement(e),c.style.margin="0",c.style.paddingLeft="20px",s.appendChild(c)),o=c,i=document.createElement("li"),i.textContent="â",o.appendChild(i)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const c=B();if(o=c==null?void 0:c.querySelector(`${e}:last-child`),!o)return;w&&o.setAttribute("list-type","static"),i=o.querySelector("li:last-child")}const f=document.createRange();f.setStart(i,0),f.collapse(!0),r.removeAllRanges(),r.addRange(f),(m=B())==null||m.focus(),M()},se=(e,t)=>{e==="insertOrderedList"||e==="insertStaticOrderedList"?ve("ol",e):e==="insertUnorderedList"||e==="insertStaticUnorderedList"?ve("ul",e):e.startsWith("justify")?ft(e):ge(e,t),e==="insertTable"&&ye(),e==="insertStaticTable"&&ye("insertStaticTable")},Ye=e=>{const t=document.createElement("span");t.textContent="â",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const r=t.getBoundingClientRect();t.remove(),W({x:r.left,y:r.bottom+window.scrollY}),L(a||[]),H(!0),I.current=e.cloneRange()},Qe=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let r=e.anchorOffset;if(!t)return null;let l=t;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=t.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const s=l.textContent||"",i=l===t?r:s.length,o=s.lastIndexOf("@",i-1);if(o!==-1){const w=document.createRange();return w.setStart(l,o),w.setEnd(l,i),w}}l=l.previousSibling}return null},Ge=e=>{var i;const t=window.getSelection();if(!t)return;const r=Qe();r?(t.removeAllRanges(),t.addRange(r)):I.current&&(t.removeAllRanges(),t.addRange(I.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.display="inline",l.setAttribute("data-mention",e.value||e.name||""),l.title=`{{${e.name}}}`;try{const o=t.rangeCount?t.getRangeAt(0):null;if(o)o.deleteContents(),o.insertNode(l);else{const m=document.createRange(),c=B();m.selectNodeContents(c),m.collapse(!1),m.insertNode(l)}const w=document.createTextNode("â");l.after(w);const f=document.createRange();f.setStartAfter(w),f.collapse(!0),t.removeAllRanges(),t.addRange(f)}catch(o){console.error("insertMention error:",o)}let s=Be([...re,e]);ce(s),R(s),H(!1),(i=B())==null||i.focus(),M()},Je=e=>{const t=B();if(!t)return;let r=null;D.current&&t.contains(D.current.startContainer)?r=D.current.cloneRange():(r=document.createRange(),r.selectNodeContents(t),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),s.title=`{{${e.name}}}`,r.insertNode(s);const i=document.createTextNode(" ");s.after(i);const o=document.createRange();o.setStartAfter(i),o.collapse(!0),l.removeAllRanges(),l.addRange(o),D.current=o.cloneRange(),t.focus()},et=e=>{e.forEach(t=>Je(t)),ce(t=>{const r=[...t,...e],l=Array.from(new Map(r.map(s=>[s.name,s])).values());return R(l),l}),M()},tt=()=>{const e=B();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),r=[];return t.forEach(l=>{const s=l.getAttribute("data-mention")||"",o=(l.textContent||"").match(/{{(.+?)}}/);o&&r.push({name:o[1],value:s})}),r},nt=e=>{var r,l,s;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),se(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const i=window.getSelection(),o=i!=null&&i.anchorNode?pe(i.anchorNode):null;if(!o)return;if(((r=o.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const f=o.parentElement,m=f==null?void 0:f.closest("li");if(m){f==null||f.removeChild(o);const c=document.createElement("p");c.innerHTML="<br />",(l=m.parentElement)==null||l.insertBefore(c,m.nextSibling);const p=document.createRange();p.setStart(c,0),p.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(p)}else{const c=o.closest("ul, ol");if(c){const p=document.createElement("p");p.innerHTML="<br />",(s=c.parentElement)==null||s.insertBefore(p,c.nextSibling),c.removeChild(o);const b=document.createRange();b.setStart(p,0),b.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(b)}}M()}}if(t==="backspace"||t==="delete"){const i=window.getSelection();if(!i||i.rangeCount===0)return;const o=i.getRangeAt(0);if(o.cloneContents().querySelector("table"))return;if(o.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},rt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(de(l))return;setTimeout(()=>{Ye(r.getRangeAt(0)),Q(""),L(a),H(!0)},0);return}if(j){setTimeout(()=>Ee(),0);return}},de=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},Ee=()=>{M();const e=window.getSelection();if(!e||!e.anchorNode)return;if(de(e.anchorNode)){H(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const r=t.match(/@([^\n]*)$/);if(!r){H(!1);return}const l=r[1].trim().toLowerCase();Q(l);const s=a.filter(i=>i.name.toLowerCase().includes(l));s.length>0?(L(s),H(!0)):H(!1)},at=e=>{var l;const t=(l=e.target.files)==null?void 0:l[0];if(!t)return;const r=new FileReader;r.onload=s=>{var b;const i=(b=s.target)==null?void 0:b.result;K();const o=window.getSelection();let w=o&&o.rangeCount?o.getRangeAt(0):null;const f=document.createElement("img");f.src=i,f.alt=t.name||"image",f.className="rte-inserted-image",f.contentEditable="true";const m=B();if(!w||!m){m==null||m.appendChild(f);const A=document.createTextNode(" ");m==null||m.appendChild(A);const J=document.createRange();J.setStartAfter(A),J.collapse(!0),o==null||o.removeAllRanges(),o==null||o.addRange(J),m==null||m.focus(),M(),e.target.value="";return}w.deleteContents(),w.insertNode(f);const c=document.createTextNode(" ");f.after(c);const p=document.createRange();p.setStartAfter(c),p.collapse(!0),o.removeAllRanges(),o.addRange(p),m.focus(),M(),e.target.value=""},r.readAsDataURL(t)},lt=e=>{var s;K();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),t.removeAllRanges(),t.addRange(r),(s=B())==null||s.focus(),M()},ye=e=>{var c;yt(),K();const t=document.createElement("table");t.style.borderCollapse="collapse",t.style.width="310px",t.style.border="1px solid #ccc",t.style.margin="8px 0",t.style.position="relative",t.style.textAlign="center",v.table&&t.classList.add(v.table);const r=document.createElement("thead");v.thead&&r.classList.add(v.thead);const l=document.createElement("tbody");v.tbody&&l.classList.add(v.tbody),e==="insertStaticTable"&&l.setAttribute("table-type","static");const s=document.createElement("tr");v.tr&&s.classList.add(v.tr);const i=document.createElement("tr");v.tr&&i.classList.add(v.tr);for(let p=0;p<2;p++){const b=document.createElement("th");b.textContent="",b.style.border="1px solid #999",b.style.padding="4px",b.style.position="relative",b.style.backgroundColor="lightgray",b.style.height="20px",b.style.whiteSpace="normal",b.style.wordBreak="break-word",b.style.overflowWrap="anywhere",b.style.lineHeight="20px",b.style.minWidth="20px",v.th&&b.classList.add(v.th);const A=document.createElement("td");A.textContent="",A.style.border="1px solid #999",A.style.padding="4px",A.style.position="relative",A.style.backgroundColor="#fff",A.style.minHeight="20px",A.style.height="20px",A.style.whiteSpace="normal",A.style.wordBreak="break-word",A.style.overflowWrap="anywhere",A.style.lineHeight="20px",A.style.minWidth="20px",v.td&&A.classList.add(v.td),G(b),G(A),s.appendChild(b),i.appendChild(A)}r.appendChild(s),l.appendChild(i),t.appendChild(r),t.appendChild(l),ue(t);const o=window.getSelection();if(!(o!=null&&o.rangeCount))return;const w=o.getRangeAt(0);w.collapse(!1),w.insertNode(t);const f=document.createElement("p");f.innerHTML="<br/>",t.after(f);const m=document.createRange();m.setStart(f,0),m.collapse(!0),o.removeAllRanges(),o.addRange(m),(c=B())==null||c.focus(),M()},ue=e=>{if(e.dataset.hasResizeHandle==="true")return;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.contentEditable="false",t.dataset.hasResizeHandle="true",t.classList.add("rte-resize-handle"),t.addEventListener("mousedown",r=>{r.preventDefault(),r.clientX,r.clientY;const l=e.getBoundingClientRect();l.width,l.height;const s=o=>{const w=Math.max(100,o.clientX-l.left),f=Math.max(20,o.clientY-l.top);e.style.width=`${w}px`,e.style.height=`${f}px`,M()},i=()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",i),M()};document.addEventListener("mousemove",s),document.addEventListener("mouseup",i)}),e.appendChild(t)},G=e=>{const t=document.createElement("div"),r=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",t.classList.add("rte-resize-handle"),Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),r.contentEditable="false",r.classList.add("rte-resize-handle"),ot(e,t,r),e.appendChild(t),e.appendChild(r)},ot=(e,t,r)=>{let l=0,s=0,i=0,o=0;t.addEventListener("mousedown",c=>{c.preventDefault(),l=c.clientX,i=e.offsetWidth,document.addEventListener("mousemove",w),document.addEventListener("mouseup",m)}),r.addEventListener("mousedown",c=>{c.preventDefault(),s=c.clientY,o=e.offsetHeight,document.addEventListener("mousemove",f),document.addEventListener("mouseup",m)});const w=c=>{const p=i+(c.clientX-l);e.style.width=`${Math.max(30,p)}px`,M()},f=c=>{const p=o+(c.clientY-s);e.style.height=`${Math.max(20,p)}px`,M()},m=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m),M()}},it=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"),q({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},we=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))};function be(){const e=x.current;e&&e.querySelectorAll("table.rte-table-selected").forEach(t=>t.classList.remove("rte-table-selected"))}const ct=e=>{var i,o,w;if(!P.cell)return;const t=P.cell.closest("table"),r=P.cell.cellIndex,l=P.cell.parentElement.rowIndex,s=f=>{const m=f.tagName.toLowerCase(),c=document.createElement(m);return c.textContent="",c.style.cssText=f.style.cssText,G(c),c};switch(e){case"insertRowAbove":{const f=t.rows[l],m=t.insertRow(l);Array.from(f.cells).forEach(c=>{m.appendChild(s(c))});break}case"insertRowBelow":{const f=t.rows[l],m=t.insertRow(l+1);Array.from(f.cells).forEach(c=>{m.appendChild(s(c))});break}case"insertColLeft":{Array.from(t.rows).forEach(f=>{const m=f.cells[r];f.insertBefore(s(m),m)});break}case"insertColRight":{Array.from(t.rows).forEach(f=>{const m=f.cells[r];f.insertBefore(s(m),m.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(l);break;case"deleteCol":Array.from(t.rows).forEach(f=>{f.cells[r]&&f.deleteCell(r)});break;case"deleteTable":{const f=(i=P.cell)==null?void 0:i.closest("table");if(!f)break;f.remove();const m=document.createElement("p");m.innerHTML="<br />",(w=(o=P.cell)==null?void 0:o.parentElement)==null||w.after(m);break}}requestAnimationFrame(()=>M()),q(te(ee({},P),{visible:!1})),we(),be()},st=()=>{X(),y.current=D.current,Y({url:"",text:"",title:"",target:"_self"}),g(!0)},dt=e=>{const t=window.getSelection();if(!t||!y.current)return;t.removeAllRanges(),t.addRange(y.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=t.getRangeAt(0);s.deleteContents(),s.insertNode(l);const i=document.createTextNode(" ");l.after(i);const o=document.createRange();o.setStartAfter(i),o.collapse(!0),t.removeAllRanges(),t.addRange(o),g(!1),M()},ut=e=>{const t=e.target;if(t.tagName==="A"){const r=t;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),y.current=l,Y({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),g(!0)}},mt=()=>{const e=B();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&D.current){const c=window.getSelection();c==null||c.removeAllRanges(),c==null||c.addRange(D.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);K(),document.execCommand("removeFormat",!1);const s=l.cloneContents(),i=document.createElement("div");i.appendChild(s);const o=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,null),w=[];for(;o.nextNode();){const c=o.currentNode,p=c.tagName.toUpperCase(),b=c.getAttribute&&c.getAttribute("data-mention")!==null;p!=="A"&&!b&&w.push(c)}for(let c=w.length-1;c>=0;c--){const p=w[c],b=p.parentNode;if(b){for(;p.firstChild;)b.insertBefore(p.firstChild,p);b.removeChild(p)}}i.querySelectorAll("[style]").forEach(c=>c.removeAttribute("style")),l.deleteContents();const f=document.createDocumentFragment();for(;i.firstChild;)f.appendChild(i.firstChild);l.insertNode(f);const m=document.createRange();m.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),m.collapse(!0),r.removeAllRanges(),r.addRange(m),e.normalize(),M()},ht=e=>{var l;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=t,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,`
|
|
5
5
|
|
|
6
|
-
`).trim())||""};function Ce(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let
|
|
6
|
+
`).trim())||""};function Ce(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let i=t.startContainer,o=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;const w=o==null?void 0:o.closest("td, th");return w?[w]:[]}const r=t.commonAncestorContainer,l=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;return Array.from(l.querySelectorAll("td, th")).filter(i=>{const o=document.createRange();return o.selectNodeContents(i),t.compareBoundaryPoints(Range.END_TO_START,o)<0&&t.compareBoundaryPoints(Range.START_TO_END,o)>0})}function ft(e){const t=Ce();if(t.length===0){ge(e);return}let r="left";e==="justifyCenter"&&(r="center"),e==="justifyRight"&&(r="right"),t.forEach(l=>{l.style.textAlign=r}),M()}const gt=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return!1;let t=e.anchorNode.nodeType===Node.ELEMENT_NODE?e.anchorNode:e.anchorNode.parentElement;for(;t;){if(t.tagName==="TABLE")return!0;t=t.parentElement}return!1},pt=e=>{if(gt()){e.preventDefault();const m=e.clipboardData.getData("text/plain");if(!m)return;const c=window.getSelection();if(!c||!c.rangeCount)return;const p=c.getRangeAt(0);p.deleteContents();const b=m.split(/\r?\n/);b.forEach((A,J)=>{p.insertNode(document.createTextNode(A)),J<b.length-1&&p.insertNode(document.createElement("br"))}),p.collapse(!1),c.removeAllRanges(),c.addRange(p),M();return}const t=e.clipboardData.getData("text/html")||"";if(!t)return;const r=document.createElement("div");if(r.innerHTML=t,r.querySelector("img")){e.preventDefault();return}e.preventDefault();const l=document.createElement("div");l.innerHTML=t;const s=m=>{m.hasAttribute("data-has-resize-handle")||(m.style.borderCollapse="collapse",m.style.width="100%",m.style.border="1px solid #ccc",m.style.margin="8px 0",m.style.position="relative",m.style.textAlign="center",m.querySelectorAll("th").forEach(c=>{const p=c;p.style.border="1px solid #999",p.style.padding="4px",p.style.position="relative",p.style.backgroundColor="lightgray",p.style.height="20px",p.style.whiteSpace="normal",p.style.wordBreak="break-word",p.style.overflowWrap="anywhere",p.style.lineHeight="20px",p.style.minWidth="20px"}),m.querySelectorAll("td").forEach(c=>{const p=c;p.style.border="1px solid #999",p.style.padding="4px",p.style.position="relative",p.style.backgroundColor="#fff",p.style.height="20px",p.style.minHeight="20px",p.style.whiteSpace="normal",p.style.wordBreak="break-word",p.style.overflowWrap="anywhere",p.style.lineHeight="20px",p.style.minWidth="20px"}))};l.querySelectorAll("table").forEach(m=>s(m));const i=window.getSelection();if(!i||!i.rangeCount)return;const o=i.getRangeAt(0);o.deleteContents();const w=document.createDocumentFragment();for(;l.firstChild;)w.appendChild(l.firstChild);o.insertNode(w),o.collapse(!1),i.removeAllRanges(),i.addRange(o);const f=x.current;f&&(f.querySelectorAll("table").forEach(m=>{const c=m;c.hasAttribute("data-has-resize-handle")||(ue(c),c.querySelectorAll("th, td").forEach(p=>{const b=p;b.dataset.hasResizeHandles||G(b)}))}),M())},vt=e=>{K();const t=window.getSelection();if(!t||!t.rangeCount)return;const r=Ce();if(r.length>0){r.forEach(o=>{o.style.fontSize=`${e}px`,o.style.lineHeight="1.2"}),M();return}const l=t.getRangeAt(0);if(l.collapsed)return;const s=document.createElement("span");s.style.fontSize=`${e}px`,s.appendChild(l.extractContents()),l.insertNode(s);const i=document.createRange();i.setStartAfter(s),i.collapse(!0),t.removeAllRanges(),t.addRange(i),M()},Et=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return null;const t=e.anchorNode;if(de(t)||t.nodeType!==Node.TEXT_NODE)return null;const r=t.textContent||"",l=e.anchorOffset,s=r.lastIndexOf("@",l-1);if(s===-1)return null;const i=r.substring(s+1,l);if(i.includes(" ")||i.includes("Â "))return null;const o=document.createRange();return o.setStart(t,s),o.setEnd(t,l),{range:o,query:i}},Se=()=>{const e=Et();if(!e)return;const{range:t,query:r}=e,l=document.createElement("span");l.textContent="â",t.insertNode(l);const s=l.getBoundingClientRect();l.remove(),W({x:s.left,y:s.bottom+window.scrollY}),Q(r.toLowerCase());const i=a.filter(o=>o.name.toLowerCase().includes(r.toLowerCase()));L(i),H(!0),I.current=t.cloneRange()};function yt(){const e=x.current;if(!e)return;const t=window.getSelection();if(!t||t.rangeCount>0&&e.contains(t.anchorNode))return;const r=document.createRange();r.selectNodeContents(e),r.collapse(!1),t.removeAllRanges(),t.addRange(r),D.current=r.cloneRange()}const wt=e=>{const t=e.target;if(!t||!(t.textContent||"").match(/{{([\s\S]+?)}}/)||!x.current)return;let i=t.firstChild;if((!i||i.nodeType!==Node.TEXT_NODE)&&(i=t.childNodes[0]),!i||i.nodeType!==Node.TEXT_NODE)return;const o=i.textContent||"",w=o.indexOf("{{"),f=o.indexOf("}}");if(w===-1||f===-1)return;const m=window.getSelection();if(!m)return;const c=document.createRange();c.setStart(i,w),c.setEnd(i,f+2),m.removeAllRanges(),m.addRange(c)},bt=e=>{fe(t=>{const r={};return e.forEach(l=>{var s;r[l.name]=(s=t[l.name])!=null?s:""}),r})},Ct=()=>{let e=T;return Object.entries(he).forEach(([t,r])=>{if(r.trim()){const l=new RegExp(`{{\\s*${t}\\s*}}`,"g");e=e.replace(l,r)}}),e};function St(e){const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const r=t.getRangeAt(0),l=document.createRange();return l.selectNode(e),r.compareBoundaryPoints(Range.START_TO_START,l)<=0&&r.compareBoundaryPoints(Range.END_TO_END,l)>=0}function Lt(){const e=x.current;if(!e)return;e.querySelectorAll("table").forEach(r=>{St(r)?r.classList.add("rte-table-selected"):r.classList.remove("rte-table-selected")})}return n.createElement("div",{className:`rte-wrapper ${(v==null?void 0:v.wrapper)||""}`,style:S.wrapper},n.createElement("div",{style:{flex:1}},n.createElement($e,{exec:se,saveSelection:X,handleFileChange:at,handleFontSizeChange:e=>vt(e.target.value),handleFontFamilyChange:e=>se("fontName",e.target.value),insertEmoji:lt,handleLink:st,removeFormatting:mt,visibleActions:ne,className:v.toolbar,style:S.toolbar}),n.createElement("div",{ref:x,id:"rte-editor-body",className:`rte-editor ${(v==null?void 0:v.editor)||""}`,style:S.editor,contentEditable:!0,suppressContentEditableWarning:!0,onPaste:pt,onKeyUp:()=>{X(),Se()},onMouseUp:X,onInput:()=>{Ee(),X()},onKeyDown:nt,onBeforeInput:rt,onContextMenu:it,onClick:e=>{ut(e),X(),Se()},onDoubleClick:wt}),n.createElement(ln,{show:j,position:F,filtered:U,insertMention:Ge,onClose:()=>H(!1),query:ie}),d&&n.createElement("div",{className:`rte-output ${(v==null?void 0:v.output)||""}`,style:S.output},n.createElement("h4",null,"Output HTML:"),n.createElement("p",null,T)),n.createElement(on,{visible:P.visible,x:P.x,y:P.y,onAction:ct,onClose:()=>{q(te(ee({},P),{visible:!1})),we(),be()}}),n.createElement(cn,{visible:Z,linkData:$,onClose:()=>g(!1),onInsert:dt})),u?n.createElement(We,{className:v.preview,style:S.preview,html:Ct(),attributes:he,setAttributes:fe}):null)};exports.RichTextEditor=sn;exports.RtePreview=We;exports.RteToolbar=$e;
|