forma-text
Version:
FormaText is a modern, feature-rich, and highly customizable React text editor with AI integration. It delivers a seamless and intuitive editing experience, supporting everything from simple text input to advanced rich content creation.
95 lines (93 loc) โข 109 kB
JavaScript
(function(a,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("react"),require("prop-types"),require("mammoth"),require("diff-match-patch"),require("lucide-react"),require("react-dom"),require("jwt-decode")):typeof define=="function"&&define.amd?define(["react","prop-types","mammoth","diff-match-patch","lucide-react","react-dom","jwt-decode"],o):(a=typeof globalThis<"u"?globalThis:a||self,a.FormaText=o(a.React,a.PropTypes,a.mammoth,a.diff_match_patch,a["lucide-react"],a.ReactDOM,a.jwt_decode))})(this,function(a,o,tr,Pe,i,Ot,rr){"use strict";var bt={exports:{}},He={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var zt;function or(){if(zt)return He;zt=1;var n=a,r=Symbol.for("react.element"),c=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,h=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,g={key:!0,ref:!0,__self:!0,__source:!0};function j(w,m,B){var k,N={},b=null,E=null;B!==void 0&&(b=""+B),m.key!==void 0&&(b=""+m.key),m.ref!==void 0&&(E=m.ref);for(k in m)s.call(m,k)&&!g.hasOwnProperty(k)&&(N[k]=m[k]);if(w&&w.defaultProps)for(k in m=w.defaultProps,m)N[k]===void 0&&(N[k]=m[k]);return{$$typeof:r,type:w,key:b,ref:E,props:N,_owner:h.current}}return He.Fragment=c,He.jsx=j,He.jsxs=j,He}var Me={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Lt;function nr(){return Lt||(Lt=1,process.env.NODE_ENV!=="production"&&function(){var n=a,r=Symbol.for("react.element"),c=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),j=Symbol.for("react.provider"),w=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),E=Symbol.for("react.offscreen"),O=Symbol.iterator,S="@@iterator";function Q(t){if(t===null||typeof t!="object")return null;var l=O&&t[O]||t[S];return typeof l=="function"?l:null}var M=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(t){{for(var l=arguments.length,v=new Array(l>1?l-1:0),y=1;y<l;y++)v[y-1]=arguments[y];f("error",t,v)}}function f(t,l,v){{var y=M.ReactDebugCurrentFrame,$=y.getStackAddendum();$!==""&&(l+="%s",v=v.concat([$]));var U=v.map(function(I){return String(I)});U.unshift("Warning: "+l),Function.prototype.apply.call(console[t],console,U)}}var A=!1,D=!1,W=!1,P=!1,ee=!1,C;C=Symbol.for("react.module.reference");function T(t){return!!(typeof t=="string"||typeof t=="function"||t===s||t===g||ee||t===h||t===B||t===k||P||t===E||A||D||W||typeof t=="object"&&t!==null&&(t.$$typeof===b||t.$$typeof===N||t.$$typeof===j||t.$$typeof===w||t.$$typeof===m||t.$$typeof===C||t.getModuleId!==void 0))}function X(t,l,v){var y=t.displayName;if(y)return y;var $=l.displayName||l.name||"";return $!==""?v+"("+$+")":v}function te(t){return t.displayName||"Context"}function K(t){if(t==null)return null;if(typeof t.tag=="number"&&p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case s:return"Fragment";case c:return"Portal";case g:return"Profiler";case h:return"StrictMode";case B:return"Suspense";case k:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case w:var l=t;return te(l)+".Consumer";case j:var v=t;return te(v._context)+".Provider";case m:return X(t,t.render,"ForwardRef");case N:var y=t.displayName||null;return y!==null?y:K(t.type)||"Memo";case b:{var $=t,U=$._payload,I=$._init;try{return K(I(U))}catch{return null}}}return null}var G=Object.assign,oe=0,je,Le,Ie,at,Fe,Be,Ae;function lt(){}lt.__reactDisabledLog=!0;function Ve(){{if(oe===0){je=console.log,Le=console.info,Ie=console.warn,at=console.error,Fe=console.group,Be=console.groupCollapsed,Ae=console.groupEnd;var t={configurable:!0,enumerable:!0,value:lt,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}oe++}}function Ye(){{if(oe--,oe===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:G({},t,{value:je}),info:G({},t,{value:Le}),warn:G({},t,{value:Ie}),error:G({},t,{value:at}),group:G({},t,{value:Fe}),groupCollapsed:G({},t,{value:Be}),groupEnd:G({},t,{value:Ae})})}oe<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var _e=M.ReactCurrentDispatcher,We;function Ce(t,l,v){{if(We===void 0)try{throw Error()}catch($){var y=$.stack.trim().match(/\n( *(at )?)/);We=y&&y[1]||""}return`
`+We+t}}var Ne=!1,Ee;{var ne=typeof WeakMap=="function"?WeakMap:Map;Ee=new ne}function we(t,l){if(!t||Ne)return"";{var v=Ee.get(t);if(v!==void 0)return v}var y;Ne=!0;var $=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var U;U=_e.current,_e.current=null,Ve();try{if(l){var I=function(){throw Error()};if(Object.defineProperty(I.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(I,[])}catch(se){y=se}Reflect.construct(t,[],I)}else{try{I.call()}catch(se){y=se}t.call(I.prototype)}}else{try{throw Error()}catch(se){y=se}t()}}catch(se){if(se&&y&&typeof se.stack=="string"){for(var z=se.stack.split(`
`),ie=y.stack.split(`
`),J=z.length-1,Z=ie.length-1;J>=1&&Z>=0&&z[J]!==ie[Z];)Z--;for(;J>=1&&Z>=0;J--,Z--)if(z[J]!==ie[Z]){if(J!==1||Z!==1)do if(J--,Z--,Z<0||z[J]!==ie[Z]){var ce=`
`+z[J].replace(" at new "," at ");return t.displayName&&ce.includes("<anonymous>")&&(ce=ce.replace("<anonymous>",t.displayName)),typeof t=="function"&&Ee.set(t,ce),ce}while(J>=1&&Z>=0);break}}}finally{Ne=!1,_e.current=U,Ye(),Error.prepareStackTrace=$}var De=t?t.displayName||t.name:"",Oe=De?Ce(De):"";return typeof t=="function"&&Ee.set(t,Oe),Oe}function Ke(t,l,v){return we(t,!1)}function Se(t){var l=t.prototype;return!!(l&&l.isReactComponent)}function ue(t,l,v){if(t==null)return"";if(typeof t=="function")return we(t,Se(t));if(typeof t=="string")return Ce(t);switch(t){case B:return Ce("Suspense");case k:return Ce("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case m:return Ke(t.render);case N:return ue(t.type,l,v);case b:{var y=t,$=y._payload,U=y._init;try{return ue(U($),l,v)}catch{}}}return""}var de=Object.prototype.hasOwnProperty,re={},xe=M.ReactDebugCurrentFrame;function ae(t){if(t){var l=t._owner,v=ue(t.type,t._source,l?l.type:null);xe.setExtraStackFrame(v)}else xe.setExtraStackFrame(null)}function vt(t,l,v,y,$){{var U=Function.call.bind(de);for(var I in t)if(U(t,I)){var z=void 0;try{if(typeof t[I]!="function"){var ie=Error((y||"React class")+": "+v+" type `"+I+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[I]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ie.name="Invariant Violation",ie}z=t[I](l,I,y,v,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(J){z=J}z&&!(z instanceof Error)&&(ae($),p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",y||"React class",v,I,typeof z),ae(null)),z instanceof Error&&!(z.message in re)&&(re[z.message]=!0,ae($),p("Failed %s type: %s",v,z.message),ae(null))}}}var ke=Array.isArray;function Ge(t){return ke(t)}function le(t){{var l=typeof Symbol=="function"&&Symbol.toStringTag,v=l&&t[Symbol.toStringTag]||t.constructor.name||"Object";return v}}function jt(t){try{return dt(t),!1}catch{return!0}}function dt(t){return""+t}function ct(t){if(jt(t))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",le(t)),dt(t)}var Te=M.ReactCurrentOwner,Ct={key:!0,ref:!0,__self:!0,__source:!0},ut,ft;function wt(t){if(de.call(t,"ref")){var l=Object.getOwnPropertyDescriptor(t,"ref").get;if(l&&l.isReactWarning)return!1}return t.ref!==void 0}function kt(t){if(de.call(t,"key")){var l=Object.getOwnPropertyDescriptor(t,"key").get;if(l&&l.isReactWarning)return!1}return t.key!==void 0}function yt(t,l){typeof t.ref=="string"&&Te.current}function Je(t,l){{var v=function(){ut||(ut=!0,p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",l))};v.isReactWarning=!0,Object.defineProperty(t,"key",{get:v,configurable:!0})}}function Ft(t,l){{var v=function(){ft||(ft=!0,p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",l))};v.isReactWarning=!0,Object.defineProperty(t,"ref",{get:v,configurable:!0})}}var Nt=function(t,l,v,y,$,U,I){var z={$$typeof:r,type:t,key:l,ref:v,props:I,_owner:U};return z._store={},Object.defineProperty(z._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(z,"_self",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.defineProperty(z,"_source",{configurable:!1,enumerable:!1,writable:!1,value:$}),Object.freeze&&(Object.freeze(z.props),Object.freeze(z)),z};function Et(t,l,v,y,$){{var U,I={},z=null,ie=null;v!==void 0&&(ct(v),z=""+v),kt(l)&&(ct(l.key),z=""+l.key),wt(l)&&(ie=l.ref,yt(l,$));for(U in l)de.call(l,U)&&!Ct.hasOwnProperty(U)&&(I[U]=l[U]);if(t&&t.defaultProps){var J=t.defaultProps;for(U in J)I[U]===void 0&&(I[U]=J[U])}if(z||ie){var Z=typeof t=="function"?t.displayName||t.name||"Unknown":t;z&&Je(I,Z),ie&&Ft(I,Z)}return Nt(t,z,ie,$,y,Te.current,I)}}var Xe=M.ReactCurrentOwner,mt=M.ReactDebugCurrentFrame;function ye(t){if(t){var l=t._owner,v=ue(t.type,t._source,l?l.type:null);mt.setExtraStackFrame(v)}else mt.setExtraStackFrame(null)}var u;u=!1;function d(t){return typeof t=="object"&&t!==null&&t.$$typeof===r}function x(){{if(Xe.current){var t=K(Xe.current.type);if(t)return`
Check the render method of \``+t+"`."}return""}}function L(t){return""}var F={};function _(t){{var l=x();if(!l){var v=typeof t=="string"?t:t.displayName||t.name;v&&(l=`
Check the top-level render call using <`+v+">.")}return l}}function V(t,l){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var v=_(l);if(F[v])return;F[v]=!0;var y="";t&&t._owner&&t._owner!==Xe.current&&(y=" It was passed a child from "+K(t._owner.type)+"."),ye(t),p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,y),ye(null)}}function Y(t,l){{if(typeof t!="object")return;if(Ge(t))for(var v=0;v<t.length;v++){var y=t[v];d(y)&&V(y,l)}else if(d(t))t._store&&(t._store.validated=!0);else if(t){var $=Q(t);if(typeof $=="function"&&$!==t.entries)for(var U=$.call(t),I;!(I=U.next()).done;)d(I.value)&&V(I.value,l)}}}function fe(t){{var l=t.type;if(l==null||typeof l=="string")return;var v;if(typeof l=="function")v=l.propTypes;else if(typeof l=="object"&&(l.$$typeof===m||l.$$typeof===N))v=l.propTypes;else return;if(v){var y=K(l);vt(v,t.props,"prop",y,t)}else if(l.PropTypes!==void 0&&!u){u=!0;var $=K(l);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",$||"Unknown")}typeof l.getDefaultProps=="function"&&!l.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ze(t){{for(var l=Object.keys(t.props),v=0;v<l.length;v++){var y=l[v];if(y!=="children"&&y!=="key"){ye(t),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",y),ye(null);break}}t.ref!==null&&(ye(t),p("Invalid attribute `ref` supplied to `React.Fragment`."),ye(null))}}var pt={};function $e(t,l,v,y,$,U){{var I=T(t);if(!I){var z="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(z+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ie=L();ie?z+=ie:z+=x();var J;t===null?J="null":Ge(t)?J="array":t!==void 0&&t.$$typeof===r?(J="<"+(K(t.type)||"Unknown")+" />",z=" Did you accidentally export a JSX literal instead of a component?"):J=typeof t,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",J,z)}var Z=Et(t,l,v,$,U);if(Z==null)return Z;if(I){var ce=l.children;if(ce!==void 0)if(y)if(Ge(ce)){for(var De=0;De<ce.length;De++)Y(ce[De],t);Object.freeze&&Object.freeze(ce)}else p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Y(ce,t)}if(de.call(l,"key")){var Oe=K(t),se=Object.keys(l).filter(function(Rr){return Rr!=="key"}),St=se.length>0?"{key: someKey, "+se.join(": ..., ")+": ...}":"{key: someKey}";if(!pt[Oe+St]){var qr=se.length>0?"{"+se.join(": ..., ")+": ...}":"{}";p(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,St,Oe,qr,Oe),pt[Oe+St]=!0}}return t===s?Ze(Z):fe(Z),Z}}function er(t,l,v){return $e(t,l,v,!0)}function Qe(t,l,v){return $e(t,l,v,!1)}var Hr=Qe,Mr=er;Me.Fragment=s,Me.jsx=Hr,Me.jsxs=Mr}()),Me}process.env.NODE_ENV==="production"?bt.exports=or():bt.exports=nr();var e=bt.exports;const q=a.memo(({onClick:n,title:r,command:c,activeStyles:s,disabled:h=!1,children:g})=>e.jsx(e.Fragment,{children:e.jsx("button",{type:"button",onClick:n,onMouseDown:j=>j.preventDefault(),className:`btn btn-outline-secondary ${s&&s.has(c)?"active":""}`,"data-bs-toggle":"tooltip","data-bs-placement":"bottom",disabled:h,children:g})}));q.propTypes={onClick:o.func.isRequired,title:o.string.isRequired,command:o.string,activeStyles:o.object,disabled:o.bool,children:o.node.isRequired},q.displayName="ToolbarButton";const ir=()=>e.jsx("style",{children:'.dropdown-menu{background-color:#fff;border:1px solid rgba(0,0,0,.15);border-radius:.375rem;box-shadow:0 .5rem 1rem rgba(0,0,0,.175);padding:.5rem}.dropdown-menu>*:not(div){display:block;width:100%;padding:.5rem 1rem;clear:both;font-weight:400;color:#212529;text-align:inherit;white-space:nowrap;background-color:transparent;border:0;text-decoration:none;border-radius:.25rem}.dropdown-menu>*:not(div):hover{background-color:#f8f9fa;color:#1e2125}.dropdown-menu div[class*="flex-wrap"] .btn{font-size:1.5rem;line-height:1;padding:.25rem;background-color:transparent;border:1px solid transparent;border-radius:.375rem;transition:background-color .15s ease-in-out}.dropdown-menu div[class*="flex-wrap"] .btn:hover{background-color:#e9ecef}'}),he=({title:n,icon:r,children:c,disabled:s=!1,selectedValue:h})=>{const[g,j]=a.useState(!1),w=a.useRef(null),m=a.useCallback(()=>{j(k=>!k)},[]);a.useEffect(()=>{const k=N=>{const b=document.querySelector(".dropdown-menu-portal");w.current&&!w.current.contains(N.target)&&(!b||!b.contains(N.target))&&j(!1)};return g&&document.addEventListener("mousedown",k),()=>{document.removeEventListener("mousedown",k)}},[g]);const B=()=>{const k=a.useRef(null),[N,b]=a.useState({opacity:0,position:"fixed"});return a.useEffect(()=>{if(w.current&&k.current){const E=w.current.getBoundingClientRect(),O=k.current.offsetWidth,S=k.current.offsetHeight,Q=window.innerWidth,M=window.innerHeight;let p=E.bottom+4,f=E.left;f+O>Q&&(f=E.right-O),p+S>M&&(p=E.top-S-4),b({position:"fixed",top:`${Math.max(5,p)}px`,left:`${Math.max(5,f)}px`,zIndex:2050,opacity:1})}},[]),e.jsx("div",{ref:k,className:"dropdown-menu dropdown-menu-portal show",style:N,onClick:E=>{E.target.closest("button")&&j(!1)},children:c})};return e.jsxs(e.Fragment,{children:[e.jsx(ir,{}),e.jsxs("div",{className:"btn-group",ref:w,children:[e.jsxs("button",{type:"button",onClick:m,onMouseDown:k=>k.preventDefault(),className:"btn btn-outline-secondary d-flex align-items-center gap-1 py-2 px-2","aria-haspopup":"true","aria-expanded":g,title:n,disabled:s,style:{minWidth:h?"110px":"auto"},children:[h?e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"13px",textAlign:"left",flexGrow:1},children:h}):r,e.jsx(i.ChevronDown,{size:14,style:{marginLeft:"auto"}})]}),g&&Ot.createPortal(e.jsx(B,{}),document.body)]})]})};he.propTypes={title:o.string.isRequired,icon:o.node,children:o.node.isRequired,disabled:o.bool,selectedValue:o.string};const sr=()=>e.jsx("style",{children:".color-swatch{width:24px;height:24px;border-radius:50%;border:1px solid rgba(0,0,0,.1);cursor:pointer;transition:transform .2s ease,box-shadow .2s ease}.color-swatch:hover{transform:scale(1.15);box-shadow:0 0 0 3px rgba(0,0,0,.1)}"}),ar=["#000000","#222222","#444444","#666666","#888888","#999999","#BBBBBB","#CCCCCC","#DDDDDD","#EEEEEE","#FFFFFF","#FF0000","#CC0000","#990000","#660000","#FF6666","#FF9900","#FF6600","#CC6600","#FFB84D","#FFFF00","#FFEE00","#CCCC00","#999900","#00FF00","#00CC00","#009900","#66FF66","#33CC33","#00FFFF","#00CCCC","#009999","#66FFFF","#0000FF","#0000CC","#000099","#6666FF","#3366FF","#9900FF","#6600CC","#9933FF","#CC99FF","#FF00FF","#CC00CC","#FF66FF","#FF99FF"],xt=({command:n,applyStyle:r,currentStyles:c})=>{const[s,h]=a.useState(n==="foreColor"?"#000000":"#ffff00"),g=n==="foreColor"?"Text Color":"Highlight Color";a.useEffect(()=>{if(c){const m=n==="foreColor"?c.foreColor:c.backColor;m&&h(m)}},[c,n]);const j=m=>{h(m),r(n,m)},w=e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[n==="foreColor"?e.jsx(i.Palette,{size:18}):e.jsx(i.Highlighter,{size:18}),e.jsx("div",{style:{width:"15px",height:"4px",backgroundColor:s,borderRadius:"2px",border:"1px solid #ced4da"}})]});return e.jsxs(e.Fragment,{children:[e.jsx(sr,{}),e.jsx(he,{title:g,icon:w,children:e.jsx("div",{className:"p-3 d-flex flex-wrap gap-1",style:{width:"160px"},children:ar.map(m=>e.jsx("button",{type:"button",className:"color-swatch",style:{backgroundColor:m},onClick:()=>j(m),"aria-label":m},m))})})]})};xt.propTypes={command:o.oneOf(["foreColor","backColor"]).isRequired,applyStyle:o.func.isRequired,currentStyles:o.object};const lr=["๐ป","๐ฅ๏ธ","๐ฑ๏ธ","โจ๏ธ","๐จ๏ธ","๐ฑ","๐ฒ","๐น๏ธ","๐งโ๐ป","๐จโ๐ป","๐ฉโ๐ป","๐ง","๐จ","โ๏ธ","๐งฐ","๐ก","๐","๐","๐พ","๐","๐","๐๏ธ","๐","๐","๐","๐","๐","๐","๐ก๏ธ","๐","โก","๐","๐งช","๐ก","๐ค","๐งฉ","๐งฌ","๐ ๏ธ","๐ง","๐","๐ฅ","๐ค"],It=({applyStyle:n})=>e.jsx(he,{title:"Insert Emoji",icon:e.jsx(i.Smile,{size:16}),children:e.jsx("div",{className:"p-2 d-flex flex-wrap gap-1",style:{maxHeight:"200px",width:"250px",overflowY:"auto"},children:lr.map(r=>e.jsx("button",{className:"btn btn-sm btn-light fs-5",onClick:()=>n("insertText",r),children:r},r))})});It.propTypes={applyStyle:o.func.isRequired};const At=["Arial","Georgia","Helvetica","Tahoma","Times New Roman","Verdana","Courier New"],dr={Small:"2",Normal:"3",Large:"5",Huge:"7"},cr={"Heading 1":"<h1>","Heading 2":"<h2>","Heading 3":"<h3>","Heading 4":"<h4>","Heading 5":"<h5>",Paragraph:"<p>"},qe={Single:"1",1.15:"1.15",1.5:"1.5",Double:"2"},ur={"13.3333px":"Small","16px":"Normal","24px":"Large","42.6667px":"Huge"},fr={h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",p:"Paragraph"},et="width: 100%; border-collapse: collapse; table-layout: fixed; margin: 0; padding: 0;",me="padding: 0; vertical-align: top;",tt="<style>@media screen and (max-width: 600px) { .responsive-cell { display: block !important; width: 100% !important; box-sizing: border-box !important; } }</style>",mr={"2 Columns (1:1)":`${tt}<table class="responsive-table" style="${et}"><tbody><tr><td class="responsive-cell" style="${me} width: 50%;"><p>C1</p></td><td class="responsive-cell" style="${me} width: 50%;"><p>C2</p></td></tr></tbody></table>`,"3 Columns (1:1:1)":`${tt}<table class="responsive-table" style="${et}"><tbody><tr><td class="responsive-cell" style="${me} width: 33.33%;"><p>C1</p></td><td class="responsive-cell" style="${me} width: 33.33%;"><p>C2</p></td><td class="responsive-cell" style="${me} width: 33.33%;"><p>C3</p></td></tr></tbody></table>`,"2 Columns (1:2)":`${tt}<table class="responsive-table" style="${et}"><tbody><tr><td class="responsive-cell" style="${me} width: 33.33%;"><p>C1</p></td><td class="responsive-cell" style="${me} width: 66.66%;"><p>C2</p></td></tr></tbody></table>`,"2 Columns (2:1)":`${tt}<table class="responsive-table" style="${et}"><tbody><tr><td class="responsive-cell" style="${me} width: 66.66%;"><p>C1</p></td><td class="responsive-cell" style="${me} width: 33.33%;"><p>C2</p></td></tr></tbody></table>`},_t=({currentStyles:n,applyStyle:r,applyLineHeight:c,activeStyles:s,onOpenLinkModal:h,onImageUpload:g,onDocxUpload:j,onVideoModalOpen:w,onTableModalOpen:m,onAiRefactor:B,content:k,isGenerating:N,isAiLoadingMinimized:b})=>{const E=a.useRef(null),O=a.useRef(null),S=a.useRef(null),[Q,M]=a.useState({headings:"Paragraph",fontFamily:"Arial",fontSize:"Normal",lineHeight:"Single"});a.useEffect(()=>{var f;if(n&&Object.keys(n).length>0){const A={};A.headings=fr[n.formatBlock]||"Paragraph",A.fontFamily=At.find(ee=>{var C;return(C=n.fontName)==null?void 0:C.toLowerCase().includes(ee.toLowerCase())})||"Arial",A.fontSize=((f=Object.entries(ur).find(([ee])=>{var C;return(C=n.fontSize)==null?void 0:C.includes(ee)}))==null?void 0:f[1])||"Normal";let D="Single";const W=n.lineHeight,P=n.fontSize;if(W&&W!=="normal")if(W.endsWith("px")&&(P!=null&&P.endsWith("px"))){const ee=parseFloat(W),C=parseFloat(P);if(C>0){const T=(ee/C).toFixed(2);D=Object.keys(qe).find(X=>parseFloat(qe[X]).toFixed(2)===T)||D}}else D=Object.keys(qe).find(ee=>qe[ee]===W)||D;else W==="normal"&&(D="1.15");A.lineHeight=D,M(ee=>({...ee,...A}))}},[n]);const p=(f,A)=>{M(D=>({...D,[f]:A}))};return a.useEffect(()=>{if(E.current&&typeof window.bootstrap<"u"){const A=[].slice.call(E.current.querySelectorAll('[data-bs-toggle="tooltip"]')).map(D=>new window.bootstrap.Tooltip(D));return()=>A.forEach(D=>D==null?void 0:D.dispose())}},[]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:E,className:"p-2 border-bottom d-flex flex-wrap align-items-center gap-2",children:[e.jsxs("div",{className:"btn-group",role:"group",children:[e.jsx(q,{title:"Undo (Ctrl+Z)",onClick:()=>r("undo"),children:e.jsx(i.Undo,{size:16})}),e.jsx(q,{title:"Redo (Ctrl+Y)",onClick:()=>r("redo"),children:e.jsx(i.Redo,{size:16})})]}),e.jsxs("div",{className:"btn-group",children:[e.jsx(he,{title:"Headings",selectedValue:Q.headings,children:Object.entries(cr).map(([f,A])=>e.jsxs("button",{className:"dropdown-item",onClick:()=>{r("formatBlock",A),p("headings",f)},children:[f," "]},f))}),e.jsx(he,{title:"Font Family",selectedValue:Q.fontFamily,children:At.map(f=>e.jsxs("button",{className:"dropdown-item",style:{fontFamily:f},onClick:()=>{r("fontName",f),p("fontFamily",f)},children:[" ",f]},f))}),e.jsx(he,{title:"Font Size",selectedValue:Q.fontSize,children:Object.entries(dr).map(([f,A])=>e.jsx("button",{className:"dropdown-item",onClick:()=>{r("fontSize",A),p("fontSize",f)},children:f},f))}),e.jsxs(he,{title:"Line Height",selectedValue:Q.lineHeight,children:[Object.entries(qe).map(([f,A])=>e.jsxs("button",{className:"dropdown-item",style:{fontSize:"14px"},onClick:()=>{c(A),p("lineHeight",f)},children:[f," "]},f)),e.jsx("button",{className:"dropdown-item text-danger border-top mt-2",style:{fontSize:"14px"},onClick:()=>{c("normal"),p("lineHeight","Single")},children:" Remove Height "})]})]}),e.jsxs("div",{className:"btn-group",children:[e.jsx(q,{title:"Bold (Ctrl+B)",command:"bold",activeStyles:s,onClick:()=>r("bold"),children:e.jsx(i.Bold,{size:14})}),e.jsx(q,{title:"Italic (Ctrl+I)",command:"italic",activeStyles:s,onClick:()=>r("italic"),children:e.jsx(i.Italic,{size:16})}),e.jsx(q,{title:"Underline (Ctrl+U)",command:"underline",activeStyles:s,onClick:()=>r("underline"),children:e.jsx(i.Underline,{size:16})}),e.jsx(q,{title:"Strikethrough",command:"strikeThrough",activeStyles:s,onClick:()=>r("strikeThrough"),children:e.jsx(i.Strikethrough,{size:16})}),e.jsx(q,{title:"Superscript",command:"superscript",activeStyles:s,onClick:()=>r("superscript"),children:e.jsx(i.Superscript,{size:16})}),e.jsx(q,{title:"Subscript",command:"subscript",activeStyles:s,onClick:()=>r("subscript"),children:e.jsx(i.Subscript,{size:16})}),e.jsx(It,{applyStyle:r})]}),e.jsxs("div",{className:"btn-group",children:[e.jsx(xt,{command:"foreColor",applyStyle:r,currentStyles:n}),e.jsx(xt,{command:"backColor",applyStyle:r,currentStyles:n})]}),e.jsxs("div",{className:"btn-group",children:[e.jsx(q,{title:"Align Left",command:"justifyLeft",activeStyles:s,onClick:()=>r("justifyLeft"),children:e.jsx(i.AlignLeft,{size:16})}),e.jsx(q,{title:"Align Center",command:"justifyCenter",activeStyles:s,onClick:()=>r("justifyCenter"),children:e.jsx(i.AlignCenter,{size:16})}),e.jsx(q,{title:"Align Right",command:"justifyRight",activeStyles:s,onClick:()=>r("justifyRight"),children:e.jsx(i.AlignRight,{size:16})})]}),e.jsxs("div",{className:"btn-group",children:[e.jsx(q,{title:"Ordered List",command:"insertOrderedList",activeStyles:s,onClick:()=>r("insertOrderedList"),children:e.jsx(i.ListOrdered,{size:16})}),e.jsx(q,{title:"Unordered List",command:"insertUnorderedList",activeStyles:s,onClick:()=>r("insertUnorderedList"),children:e.jsx(i.List,{size:16})}),e.jsx(q,{title:"Outdent",onClick:()=>r("outdent"),children:e.jsx(i.Outdent,{size:16})}),e.jsx(q,{title:"Indent",onClick:()=>r("indent"),children:e.jsx(i.Indent,{size:16})})]}),e.jsxs("div",{className:"btn-group",children:[e.jsx(q,{title:"Blockquote",onClick:()=>r("formatBlock","<blockquote>"),children:e.jsx(i.Quote,{size:16})}),e.jsx(q,{title:"Code Block",onClick:()=>r("formatBlock","<pre>"),children:e.jsx(i.Code,{size:16})}),e.jsx(q,{title:"Add/Edit Link (Ctrl+K)",onClick:h,children:e.jsx(i.Link,{size:16})}),e.jsx(q,{title:"Horizontal Line",onClick:()=>r("insertHorizontalRule"),children:e.jsx(i.Minus,{size:16})}),e.jsx(q,{title:"Clear Formatting",onClick:()=>r("removeFormat"),children:e.jsx(i.Eraser,{size:16})})]}),e.jsxs("div",{className:"btn-group",children:[e.jsx(q,{title:"Insert Image",onClick:()=>{var f;return(f=O.current)==null?void 0:f.click()},children:e.jsx(i.Image,{size:16})}),e.jsx(q,{title:"Insert Video",onClick:w,children:e.jsx(i.Video,{size:16})}),e.jsx(q,{title:"Insert Table",onClick:m,children:e.jsx(i.Table,{size:16})}),e.jsx(he,{title:"Insert Columns",icon:e.jsx(i.Columns,{size:16}),children:Object.entries(mr).map(([f,A])=>e.jsx("button",{className:"dropdown-item",style:{fontSize:"14px"},onClick:()=>r("insertHTML",A+"<p><br></p>"),children:f},f))}),e.jsx(q,{title:"Import from Word (.docx)",onClick:()=>{var f;return(f=S.current)==null?void 0:f.click()},children:e.jsx(i.FileUp,{size:16})})]}),e.jsx("div",{className:"btn-group",children:e.jsx(q,{title:"Improve with AI",onClick:B,disabled:!k||k===""||N,children:N&&!b?e.jsx("div",{className:"spinner-border spinner-border-sm",role:"status",children:e.jsx("span",{className:"visually-hidden",children:"Loading..."})}):e.jsx(i.Sparkles,{size:16})})})]}),e.jsx("input",{type:"file",accept:"image/*",ref:O,onChange:g,className:"d-none"}),e.jsx("input",{type:"file",accept:".docx",ref:S,onChange:j,className:"d-none"})]})};_t.propTypes={currentStyles:o.object,applyStyle:o.func.isRequired,applyLineHeight:o.func.isRequired,activeStyles:o.object.isRequired,onOpenLinkModal:o.func.isRequired,onImageUpload:o.func.isRequired,onDocxUpload:o.func.isRequired,onVideoModalOpen:o.func.isRequired,onTableModalOpen:o.func.isRequired,onAiRefactor:o.func.isRequired,content:o.string,isGenerating:o.bool.isRequired,isAiLoadingMinimized:o.bool.isRequired};const pr=()=>e.jsx("style",{children:'.forma-text-tooltip-container{position:relative;display:inline-block}.forma-text-tooltip{visibility:hidden;opacity:0;width:max-content;background-color:#63b1ff;color:#fff;text-align:center;border-radius:6px;padding:6px 12px;font-size:12px;font-weight:500;position:absolute;z-index:10;top:130%;left:50%;transform:translateX(-50%);transition:opacity .2s ease-in-out}.forma-text-tooltip::after{content:"";position:absolute;bottom:100%;left:50%;margin-left:-5px;border-width:5px;border-style:solid;border-color:transparent transparent #63b1ff transparent}.forma-text-tooltip-container:hover .forma-text-tooltip{visibility:visible;opacity:1}'}),R=a.memo(({onClick:n,title:r,command:c,activeStyles:s,disabled:h=!1,children:g,className:j=""})=>e.jsxs(e.Fragment,{children:[e.jsx(pr,{}),e.jsx("div",{className:"forma-text-tooltip-container",children:e.jsx("button",{type:"button",onClick:n,onMouseDown:w=>w.preventDefault(),className:`modern-toolbar-button ${s&&s.has(c)?"active":""} ${j}`,disabled:h,children:g})})]}));R.propTypes={onClick:o.func.isRequired,title:o.string.isRequired,command:o.string,activeStyles:o.object,disabled:o.bool,children:o.node.isRequired,className:o.string},R.displayName="ModernToolbarButton";const br=()=>e.jsx("style",{children:'.dropdown-menu{background-color:#fff;border:1px solid rgba(0,0,0,.15);border-radius:.375rem;box-shadow:0 .5rem 1rem rgba(0,0,0,.175);padding:.5rem}.dropdown-menu>*:not(div){display:block;width:100%;padding:.5rem 1rem;clear:both;font-weight:400;color:#212529;text-align:inherit;white-space:nowrap;background-color:transparent;border:0;text-decoration:none;border-radius:.25rem}.dropdown-menu>*:not(div):hover{background-color:#f8f9fa;color:#1e2125}.dropdown-menu div[class*="flex-wrap"] .btn{font-size:1.5rem;line-height:1;padding:.25rem;background-color:transparent;border:1px solid transparent;border-radius:.375rem;transition:background-color .15s ease-in-out}.dropdown-menu div[class*="flex-wrap"] .btn:hover{background-color:#007dfbff!important}.btn.forma-text-toolbar-button:hover{background-color:#e8f0fe!important;color:#1967d2!important}'}),ge=({title:n,icon:r,children:c,disabled:s=!1,selectedValue:h})=>{const[g,j]=a.useState(!1),w=a.useRef(null),m=a.useCallback(()=>{j(k=>!k)},[]);a.useEffect(()=>{const k=N=>{const b=document.querySelector(".dropdown-menu-portal");w.current&&!w.current.contains(N.target)&&(!b||!b.contains(N.target))&&j(!1)};return g&&document.addEventListener("mousedown",k),()=>{document.removeEventListener("mousedown",k)}},[g]);const B=()=>{const k=a.useRef(null),[N,b]=a.useState({opacity:0,position:"fixed"});return a.useEffect(()=>{if(w.current&&k.current){const E=w.current.getBoundingClientRect(),O=k.current.offsetWidth,S=k.current.offsetHeight,Q=window.innerWidth,M=window.innerHeight;let p=E.bottom+4,f=E.left;f+O>Q&&(f=E.right-O),p+S>M&&(p=E.top-S-4),b({position:"fixed",top:`${Math.max(5,p)}px`,left:`${Math.max(5,f)}px`,zIndex:2050,opacity:1})}},[]),e.jsx("div",{ref:k,className:"dropdown-menu dropdown-menu-portal show",style:N,onClick:E=>{E.target.closest("button")&&j(!1)},children:c})};return e.jsxs(e.Fragment,{children:[e.jsx(br,{}),e.jsxs("div",{className:"btn-group ",ref:w,children:[e.jsxs("button",{type:"button",onClick:m,onMouseDown:k=>k.preventDefault(),className:"btn d-flex align-items-center gap-1 py-2 px-2 forma-text-toolbar-button","aria-haspopup":"true","aria-expanded":g,title:n,disabled:s,style:{minWidth:h?"110px":"auto"},children:[h?e.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"13px",textAlign:"left",flexGrow:1},children:[e.jsx("span",{className:"me-2",children:r})," ",h]}):r,e.jsx(i.ChevronDown,{size:14})]}),g&&Ot.createPortal(e.jsx(B,{}),document.body)]})]})};ge.propTypes={title:o.string.isRequired,icon:o.node,children:o.node.isRequired,disabled:o.bool,selectedValue:o.string};const xr=["#000000","#222222","#444444","#666666","#888888","#999999","#BBBBBB","#CCCCCC","#DDDDDD","#EEEEEE","#FFFFFF","#FF0000","#CC0000","#990000","#660000","#FF6666","#FF9900","#FF6600","#CC6600","#FFB84D","#FFFF00","#FFEE00","#CCCC00","#999900","#00FF00","#00CC00","#009900","#66FF66","#33CC33","#00FFFF","#00CCCC","#009999","#66FFFF","#0000FF","#0000CC","#000099","#6666FF","#3366FF","#9900FF","#6600CC","#9933FF","#CC99FF","#FF00FF","#CC00CC","#FF66FF","#FF99FF"],ht=({command:n,applyStyle:r,currentStyles:c})=>{const[s,h]=a.useState(n==="foreColor"?"#000000":"#FFFF00"),g=n==="foreColor"?"Text Color":"Highlight Color";a.useEffect(()=>{if(c){const m=n==="foreColor"?c.foreColor:c.backColor;m&&h(m)}},[c,n]);const j=m=>{h(m),r(n,m)},w=n==="foreColor"?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e.jsx(i.Palette,{size:18}),e.jsx("div",{style:{width:"16px",height:"4px",backgroundColor:s,borderRadius:"2px",marginTop:"2px"}})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e.jsx(i.Highlighter,{size:18}),e.jsx("div",{style:{width:"16px",height:"4px",backgroundColor:s,borderRadius:"2px",marginTop:"2px"}})]});return e.jsx(ge,{title:g,icon:w,children:e.jsx("div",{className:"modern-color-picker",children:xr.map(m=>e.jsx("button",{type:"button",className:"modern-color-swatch",style:{backgroundColor:m},onClick:()=>j(m),"aria-label":m},m))})})};ht.propTypes={command:o.oneOf(["foreColor","backColor"]).isRequired,applyStyle:o.func.isRequired,currentStyles:o.object};const hr=["๐ป","๐ฅ๏ธ","๐ฑ๏ธ","โจ๏ธ","๐จ๏ธ","๐ฑ","๐ฒ","๐น๏ธ","๐งโ๐ป","๐จโ๐ป","๐ฉโ๐ป","๐ง","๐จ","โ๏ธ","๐งฐ","๐ก","๐","๐","๐พ","๐","๐","๐๏ธ","๐","๐","๐","๐","๐","๐","๐ก๏ธ","๐","โก","๐","๐งช","๐ก","๐ค","๐งฉ","๐งฌ","๐ ๏ธ","๐ง","๐","๐ฅ","๐ค"],Tt=({applyStyle:n})=>e.jsx(ge,{title:"Insert Emoji",icon:e.jsx(i.Smile,{size:18}),children:e.jsx("div",{className:"modern-emoji-picker",children:hr.map(r=>e.jsx("button",{type:"button",className:"modern-emoji",onClick:()=>n("insertText",r),children:r},r))})});Tt.propTypes={applyStyle:o.func.isRequired};const gr=()=>e.jsx("style",{children:".modern-toolbar{display:flex;flex-wrap:wrap;align-items:center;padding:8px;gap:4px;border-radius:12px;box-shadow:0 4px 12px rgba(0,0,0,.1);transition:background-color .3s ease,border-color .3s ease}.toolbar-group{display:flex;align-items:center;gap:4px}.toolbar-separator{width:1px;height:24px;margin:0 8px;transition:background-color .3s ease}.modern-toolbar-button{display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:8px;width:40px;height:36px;cursor:pointer;transition:background-color .2s ease,color .2s ease;position:relative}.modern-toolbar-button:disabled{opacity:.4;cursor:not-allowed}@keyframes pulse-glow{0%,100%{transform:scale(1);filter:drop-shadow(0 0 4px rgba(0,230,230,.7))}50%{transform:scale(1.15);filter:drop-shadow(0 0 10px rgba(128,255,255,1)) drop-shadow(0 0 20px rgba(128,255,255,.7))}}.modern-ai-button{border:1px solid rgba(0,230,230,.3);background:linear-gradient(45deg,#2a2a72,#009ffd);overflow:hidden}.modern-ai-button svg{color:#cceeff;animation:pulse-glow 2.5s infinite ease-in-out;transition:all .3s ease-in-out}.modern-ai-button:hover:not(:disabled) svg{animation-play-state:paused;transform:scale(1.2);color:#fff;filter:drop-shadow(0 0 6px #fff) drop-shadow(0 0 12px rgba(128,255,255,1))}.modern-ai-button .spinner{width:18px;height:18px;border:2px solid rgba(255,255,255,.3);border-top-color:#fff;border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.forma-text-dropdown{position:relative;display:inline-block}.forma-text-toolbar-button{color:#3c4043;border:1px solid transparent;border-radius:8px;padding:8px;font-size:14px;cursor:pointer;display:flex;align-items:center;gap:4px;transition:background-color .2s ease,border-color .2s ease;background:transparent}.forma-text-toolbar-button:hover{background-color:#bbe7fdff}.forma-text-toolbar-button:disabled{color:#adb5bd;cursor:not-allowed}.forma-text-toolbar-button.active{background-color:#e8f0fe;color:#1967d2}.forma-text-dropdown-menu{position:absolute;top:100%;margin-top:8px;border-radius:8px;padding:8px;z-index:1000;opacity:0;visibility:hidden;transform:translateY(-10px);transition:opacity .2s ease,transform .2s ease,visibility .2s;box-shadow:0 8px 24px rgba(0,0,0,.15);background-color:#fff;border:1px solid #e0e0e0;min-width:auto}.forma-text-dropdown-menu.show{opacity:1;visibility:visible;transform:translateY(0)}.forma-text-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:none;text-align:left;border-radius:6px;cursor:pointer;white-space:nowrap;transition:background-color .2s ease;font-size:15px;color:#3c4043}.forma-text-dropdown-item:hover{background-color:#34bbffff}.modern-dropdown{position:relative}.modern-dropdown-menu{position:absolute;top:100%;left:0;margin-top:8px;border-radius:8px;padding:8px;z-index:9999!important;opacity:0;visibility:hidden;transform:translateY(0);transition:opacity .2s ease,transform .2s ease,visibility .2s;box-shadow:0 8px 24px rgba(0,0,0,.15);background-color:#fff;border:1px solid #e0e0e0}.modern-dropdown-menu.show{opacity:1;visibility:visible;transform:translateY(0)}.modern-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:none;text-align:left;border-radius:6px;cursor:pointer;white-space:nowrap;transition:background-color .2s ease;font-size:16px;color:#3c4043}.modern-dropdown-item:hover{background-color:#f1f3f4}.modern-emoji:hover{background-color:#f1f3f4}.modern-color-picker{display:grid;grid-template-columns:repeat(auto-fit,minmax(24px,1fr));gap:6px;width:120px;padding:4px;max-height:200px;overflow-y:auto;overflow-x:hidden}.modern-color-swatch{width:24px;height:24px;border-radius:50%;border:1px solid rgba(0,0,0,.1);cursor:pointer;transition:transform .2s ease,box-shadow .2s ease}.modern-color-swatch:hover{transform:scale(1.15);box-shadow:0 0 0 3px rgba(0,0,0,.1)}.modern-emoji-picker{display:grid;grid-template-columns:repeat(2,1fr);max-height:200px;overflow-y:auto;overflow-x:hidden;padding:4px;width:120px}.modern-emoji{font-size:20px;background:none;border:none;padding:4px;border-radius:8px;cursor:pointer;transition:background-color .2s ease}.modern-color-picker::-webkit-scrollbar,.modern-emoji-picker::-webkit-scrollbar{width:8px}.modern-color-picker::-webkit-scrollbar-track,.modern-emoji-picker::-webkit-scrollbar-track{background:#f1f1f1;border-radius:10px}.modern-color-picker::-webkit-scrollbar-thumb,.modern-emoji-picker::-webkit-scrollbar-thumb{background:#ccc;border-radius:10px}.modern-color-picker::-webkit-scrollbar-thumb:hover,.modern-emoji-picker::-webkit-scrollbar-thumb:hover{background:#aaa}.modern-toolbar{background-color:#fff;border:1px solid #e0e0e0}.toolbar-separator{background-color:#e0e0e0}.modern-toolbar-button{background-color:transparent;color:#5f6368}.modern-toolbar-button:hover:not(:disabled){background-color:#f1f3f4}.modern-toolbar-button.active{background-color:#e8f0fe;color:#1967d2}.modern-toolbar-button:hover{color:#1967d2}"}),$t=["Arial","Georgia","Helvetica","Tahoma","Times New Roman","Verdana","Courier New"],vr={"Heading 1":"<h1>","Heading 2":"<h2>","Heading 3":"<h3>","Heading 4":"<h4>","Heading 5":"<h5>",Paragraph:"<p>"},Re={Single:"1",1.15:"1.15",1.5:"1.5",Double:"2"},jr={Small:"2",Normal:"3",Large:"5",Huge:"6"},Cr={"13px":"Small","16px":"Normal","24px":"Large","32px":"Huge"},wr={h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",p:"Paragraph"},rt="width: 100%; border-collapse: collapse; table-layout: fixed; margin: 0; padding: 0;",pe="padding: 0; vertical-align: top;",ot=`
<style>
@media screen and (max-width: 600px) {
.responsive-cell {
display: block !important;
width: 100% !important;
box-sizing: border-box !important;
}
}
</style>
`,kr={"2 Columns (1:1)":`
${ot}
<table class="responsive-table" style="${rt}">
<tbody>
<tr>
<td class="responsive-cell" style="${pe} width: 50%;">
<p>Column 1</p>
</td>
<td class="responsive-cell" style="${pe} width: 50%;">
<p>Column 2</p>
</td>
</tr>
</tbody>
</table>`,"3 Columns (1:1:1)":`
${ot}
<table class="responsive-table" style="${rt}">
<tbody>
<tr>
<td class="responsive-cell" style="${pe} width: 33.33%;">
<p>C1</p>
</td>
<td class="responsive-cell" style="${pe} width: 33.33%;">
<p>C2</p>
</td>
<td class="responsive-cell" style="${pe} width: 33.33%;">
<p>C3</p>
</td>
</tr>
</tbody>
</table>`,"2 Columns (1:2)":`
${ot}
<table class="responsive-table" style="${rt}">
<tbody>
<tr>
<td class="responsive-cell" style="${pe} width: 33.33%;">
<p>C1</p>
</td>
<td class="responsive-cell" style="${pe} width: 66.66%;">
<p>C2</p>
</td>
</tr>
</tbody>
</table>`,"2 Columns (2:1)":`
${ot}
<table class="responsive-table" style="${rt}">
<tbody>
<tr>
<td class="responsive-cell" style="${pe} width: 66.66%;">
<p>C1</p>
</td>
<td class="responsive-cell" style="${pe} width: 33.33%;">
<p>C2</p>
</td>
</tr>
</tbody>
</table>`},Dt=({currentStyles:n,applyStyle:r,applyLineHeight:c,activeStyles:s,onOpenLinkModal:h,onImageUpload:g,onDocxUpload:j,onVideoModalOpen:w,onTableModalOpen:m,onAiRefactor:B,content:k,isGenerating:N,isAiLoadingMinimized:b})=>{const E=a.useRef(null),O=a.useRef(null),[S,Q]=a.useState({headings:"Paragraph",fontFamily:"Arial",fontSize:"Normal",lineHeight:"Single"});a.useEffect(()=>{if(n&&Object.keys(n).length>0){const p={};p.headings=wr[n.formatBlock]||"Paragraph",p.fontFamily=$t.find(W=>{var P;return(P=n.fontName)==null?void 0:P.toLowerCase().includes(W.toLowerCase())})||"Arial",p.fontSize=Cr[n.fontSize]||"Normal";let f="Single";const A=n.lineHeight,D=n.fontSize;if(A&&A!=="normal")if(A.endsWith("px")&&D&&D.endsWith("px")){const W=parseFloat(A),P=parseFloat(D);if(P>0){const ee=(W/P).toFixed(2);f=Object.keys(Re).find(T=>parseFloat(Re[T]).toFixed(2)===ee)||f}}else f=Object.keys(Re).find(W=>Re[W]===A)||f;else A==="normal"&&(f="1.15");p.lineHeight=f,Q(W=>({...W,...p}))}},[n]);const M=(p,f)=>{Q(A=>({...A,[p]:f}))};return e.jsxs(e.Fragment,{children:[e.jsx(gr,{}),e.jsxs("div",{className:"modern-toolbar",children:[e.jsxs("div",{className:"toolbar-group",children:[e.jsx(R,{title:"Undo (Ctrl+Z)",onClick:()=>r("undo"),children:e.jsx(i.Undo,{size:18})}),e.jsx(R,{title:"Redo (Ctrl+Y)",onClick:()=>r("redo"),children:e.jsx(i.Redo,{size:18})})]}),e.jsx("div",{className:"toolbar-separator"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx(ge,{title:"Headings",icon:e.jsx(i.Pilcrow,{size:16}),selectedValue:S.headings,children:Object.entries(vr).map(([p,f])=>e.jsx("button",{className:"modern-dropdown-item",onClick:()=>{r("formatBlock",f),M("headings",p)},children:p},p))}),e.jsx(ge,{title:"Font Family",icon:e.jsx(i.Type,{size:16}),selectedValue:S.fontFamily,children:$t.map(p=>e.jsx("button",{className:"modern-dropdown-item",style:{fontFamily:p},onClick:()=>{r("fontName",p),M("fontFamily",p)},children:p},p))}),e.jsx(ge,{title:"Font Size",icon:e.jsx("span",{style:{fontSize:"17px"},children:"F"}),selectedValue:S.fontSize,children:Object.entries(jr).map(([p,f])=>e.jsx("button",{className:"modern-dropdown-item",onClick:()=>{r("fontSize",f),M("fontSize",p)},children:p},p))}),e.jsx(ge,{title:"Line Height",icon:e.jsx(i.ArrowDownUp,{size:16}),selectedValue:S.lineHeight,children:Object.entries(Re).map(([p,f])=>e.jsx("button",{className:"modern-dropdown-item",onClick:()=>{c(f),M("lineHeight",p)},children:p},p))})]}),e.jsx("div",{className:"toolbar-separator"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx(R,{title:"Bold (Ctrl+B)",command:"bold",activeStyles:s,onClick:()=>r("bold"),children:e.jsx(i.Bold,{size:18})}),e.jsx(R,{title:"Italic (Ctrl+I)",command:"italic",activeStyles:s,onClick:()=>r("italic"),children:e.jsx(i.Italic,{size:18})}),e.jsx(R,{title:"Underline (Ctrl+U)",command:"underline",activeStyles:s,onClick:()=>r("underline"),children:e.jsx(i.Underline,{size:18})}),e.jsx(R,{title:"Strikethrough",command:"strikeThrough",activeStyles:s,onClick:()=>r("strikeThrough"),children:e.jsx(i.Strikethrough,{size:18})}),e.jsx(R,{title:"Superscript",command:"superscript",activeStyles:s,onClick:()=>r("superscript"),children:e.jsx(i.Superscript,{size:18})}),e.jsx(R,{title:"Subscript",command:"subscript",activeStyles:s,onClick:()=>r("subscript"),children:e.jsx(i.Subscript,{size:18})}),e.jsx(Tt,{applyStyle:r})]}),e.jsx("div",{className:"toolbar-separator"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx(ht,{command:"foreColor",applyStyle:r}),e.jsx(ht,{command:"backColor",applyStyle:r})]}),e.jsx("div",{className:"toolbar-separator"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx(R,{title:"Align Left",command:"justifyLeft",activeStyles:s,onClick:()=>r("justifyLeft"),children:e.jsx(i.AlignLeft,{size:18})}),e.jsx(R,{title:"Align Center",command:"justifyCenter",activeStyles:s,onClick:()=>r("justifyCenter"),children:e.jsx(i.AlignCenter,{size:18})}),e.jsx(R,{title:"Align Right",command:"justifyRight",activeStyles:s,onClick:()=>r("justifyRight"),children:e.jsx(i.AlignRight,{size:18})})]}),e.jsx("div",{className:"toolbar-separator"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx(R,{title:"Ordered List",command:"insertOrderedList",activeStyles:s,onClick:()=>r("insertOrderedList"),children:e.jsx(i.ListOrdered,{size:18})}),e.jsx(R,{title:"Unordered List",command:"insertUnorderedList",activeStyles:s,onClick:()=>r("insertUnorderedList"),children:e.jsx(i.List,{size:18})}),e.jsx(R,{title:"Outdent",onClick:()=>r("outdent"),children:e.jsx(i.Outdent,{size:18})}),e.jsx(R,{title:"Indent",onClick:()=>r("indent"),children:e.jsx(i.Indent,{size:18})})]}),e.jsx("div",{className:"toolbar-separator"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx(R,{title:"Blockquote",onClick:()=>r("formatBlock","<blockquote>"),children:e.jsx(i.Quote,{size:18})}),e.jsx(R,{title:"Code Block",onClick:()=>r("formatBlock","<pre>"),children:e.jsx(i.Code,{size:18})}),e.jsx(R,{title:"Add/Edit Link (Ctrl+K)",onClick:h,children:e.jsx(i.Link,{size:18})}),e.jsx(R,{title:"Horizontal Line",onClick:()=>r("insertHorizontalRule"),children:e.jsx(i.Minus,{size:18})})]}),e.jsx("div",{className:"toolbar-separator"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx(R,{title:"Insert Image",onClick:()=>{var p;return(p=E.current)==null?void 0:p.click()},children:e.jsx(i.Image,{size:18})}),e.jsx(R,{title:"Insert Video",onClick:w,children:e.jsx(i.Video,{size:20})}),e.jsx(R,{title:"Insert Table",onClick:m,children:e.jsx(i.Table,{size:18})}),e.jsx(ge,{title:"Insert Columns",icon:e.jsx(i.Columns,{size:18}),children:Object.entries(kr).map(([p,f])=>e.jsx("button",{className:"modern-dropdown-item",onClick:()=>r("insertHTML",f+"<p><br></p>"),children:p},p))}),e.jsx(R,{title:"Import from Word (.docx)",onClick:()=>{var p;return(p=O.current)==null?void 0:p.click()},children:e.jsx(i.FileUp,{size:18})})]}),e.jsx("div",{className:"toolbar-separator"}),e.jsxs("div",{className:"toolbar-group",children:[e.jsx(R,{title:"Clear Formatting",onClick:()=>r("removeFormat"),children:e.jsx(i.Eraser,{size:18,style:{color:"red"}})}),e.jsx("div",{className:"toolbar-separator"}),e.jsx(R,{title:"Improve with AI",onClick:B,disabled:!k||k===""||N,className:"modern-ai-button mx-0 rounded-3",children:N&&!b?e.jsx("div",{className:"spinner"}):e.jsx(i.Sparkles,{size:20})})]})]}),e.jsx("input",{type:"file",accept:"image/*",ref:E,onChange:g,style:{display:"none"}}),e.jsx("input",{type:"file",accept:".docx",ref:O,onChange:j,style:{display:"none"}})]})};Dt.propTypes={currentStyles:o.object,applyStyle:o.func.isRequired,applyLineHeight:o.func.isRequired,activeStyles:o.object.isRequired,onOpenLinkModal:o.func.isRequired,onImageUpload:o.func.isRequired,onDocxUpload:o.func.isRequired,onVideoModalOpen:o.func.isRequired,onTableModalOpen:o.func.isRequired,onAiRefactor:o.func.isRequired,content:o.string,isGenerating:o.bool.isRequired,isAiLoadingMinimized:o.bool.isRequired};const H=a.memo(({onClick:n,title:r,cmd:c,active:s,disabled:h=!1,children:g,className:j=""})=>e.jsx("button",{type:"button",onClick:n,onMouseDown:w=>w.preventDefault(),className:`futuristic-button ${s&&s.has(c)?"active":""} ${j}`,title:r,disabled:h,children:e.jsx("span",{className:"button-content",children:g})}));H.propTypes={onClick:o.func.isRequired,title:o.string.isRequired,cmd:o.string,active:o.object,disabled:o.bool,children:o.node.isRequired,className:o.string},H.displayName="FuturisticToolbarButton";const ve=({title:n,icon:r,children:c,selectedValue:s})=>{const[h,g]=a.useState(!1),j=a.useRef(null),w=a.useRef(null);return a.useEffect(()=>{const m=B=>{j.current&&!j.current.contains(B.target)&&w.current&&!w.current.contains(B.target)&&g(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]),e.jsxs("div",{className:"futuristic-dropdown ps-2",ref:j,children:[e.jsx("button",{type:"button",title:n,onClick:()=>g(!h),onMouseDown:m=>m.preventDefault(),className:"futuristic-button","aria-expanded":h,style:{padding:"0 8px",minWidth:s?"110px":"auto"},children:e.jsxs("span",{className:"button-content",children:[s?e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"13px",textAlign:"left",flexGrow:1},children:s}):r,e.jsx(i.ChevronDown,{size:16,className:`chevron-icon ${h?"open":""}`})]})}),e.jsx("div",{ref:w,className:`futuristic-dropdown-menu ${h?"show":""}`,onClick:()=>g(!1),