fable-editor 1.0.0 → 1.0.2

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react");var vt={exports:{}},G={};/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react");var yt={exports:{}},G={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var jt;function He(){if(jt)return G;jt=1;var m=O,t=Symbol.for("react.element"),e=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function l(o,a,c){var d,u={},v=null,b=null;c!==void 0&&(v=""+c),a.key!==void 0&&(v=""+a.key),a.ref!==void 0&&(b=a.ref);for(d in a)i.call(a,d)&&!r.hasOwnProperty(d)&&(u[d]=a[d]);if(o&&o.defaultProps)for(d in a=o.defaultProps,a)u[d]===void 0&&(u[d]=a[d]);return{$$typeof:t,type:o,key:v,ref:b,props:u,_owner:s.current}}return G.Fragment=e,G.jsx=l,G.jsxs=l,G}var K={};/**
9
+ */var zt;function qe(){if(zt)return G;zt=1;var m=O,t=Symbol.for("react.element"),e=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function l(o,a,c){var d,u={},v=null,b=null;c!==void 0&&(v=""+c),a.key!==void 0&&(v=""+a.key),a.ref!==void 0&&(b=a.ref);for(d in a)i.call(a,d)&&!r.hasOwnProperty(d)&&(u[d]=a[d]);if(o&&o.defaultProps)for(d in a=o.defaultProps,a)u[d]===void 0&&(u[d]=a[d]);return{$$typeof:t,type:o,key:v,ref:b,props:u,_owner:s.current}}return G.Fragment=e,G.jsx=l,G.jsxs=l,G}var K={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,28 +14,28 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var zt;function qe(){return zt||(zt=1,process.env.NODE_ENV!=="production"&&function(){var m=O,t=Symbol.for("react.element"),e=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),f=Symbol.iterator,w="@@iterator";function E(n){if(n===null||typeof n!="object")return null;var p=f&&n[f]||n[w];return typeof p=="function"?p:null}var q=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function M(n){{for(var p=arguments.length,g=new Array(p>1?p-1:0),C=1;C<p;C++)g[C-1]=arguments[C];D("error",n,g)}}function D(n,p,g){{var C=q.ReactDebugCurrentFrame,S=C.getStackAddendum();S!==""&&(p+="%s",g=g.concat([S]));var k=g.map(function(T){return String(T)});k.unshift("Warning: "+p),Function.prototype.apply.call(console[n],console,k)}}var I=!1,_=!1,F=!1,Y=!1,Kt=!1,bt;bt=Symbol.for("react.module.reference");function Jt(n){return!!(typeof n=="string"||typeof n=="function"||n===i||n===r||Kt||n===s||n===c||n===d||Y||n===b||I||_||F||typeof n=="object"&&n!==null&&(n.$$typeof===v||n.$$typeof===u||n.$$typeof===l||n.$$typeof===o||n.$$typeof===a||n.$$typeof===bt||n.getModuleId!==void 0))}function te(n,p,g){var C=n.displayName;if(C)return C;var S=p.displayName||p.name||"";return S!==""?g+"("+S+")":g}function yt(n){return n.displayName||"Context"}function $(n){if(n==null)return null;if(typeof n.tag=="number"&&M("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case i:return"Fragment";case e:return"Portal";case r:return"Profiler";case s:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case o:var p=n;return yt(p)+".Consumer";case l:var g=n;return yt(g._context)+".Provider";case a:return te(n,n.render,"ForwardRef");case u:var C=n.displayName||null;return C!==null?C:$(n.type)||"Memo";case v:{var S=n,k=S._payload,T=S._init;try{return $(T(k))}catch{return null}}}return null}var j=Object.assign,Q=0,wt,Ct,xt,Tt,Et,St,Mt;function kt(){}kt.__reactDisabledLog=!0;function ee(){{if(Q===0){wt=console.log,Ct=console.info,xt=console.warn,Tt=console.error,Et=console.group,St=console.groupCollapsed,Mt=console.groupEnd;var n={configurable:!0,enumerable:!0,value:kt,writable:!0};Object.defineProperties(console,{info:n,log:n,warn:n,error:n,group:n,groupCollapsed:n,groupEnd:n})}Q++}}function ie(){{if(Q--,Q===0){var n={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},n,{value:wt}),info:j({},n,{value:Ct}),warn:j({},n,{value:xt}),error:j({},n,{value:Tt}),group:j({},n,{value:Et}),groupCollapsed:j({},n,{value:St}),groupEnd:j({},n,{value:Mt})})}Q<0&&M("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var at=q.ReactCurrentDispatcher,ct;function J(n,p,g){{if(ct===void 0)try{throw Error()}catch(S){var C=S.stack.trim().match(/\n( *(at )?)/);ct=C&&C[1]||""}return`
18
- `+ct+n}}var ht=!1,tt;{var se=typeof WeakMap=="function"?WeakMap:Map;tt=new se}function Ht(n,p){if(!n||ht)return"";{var g=tt.get(n);if(g!==void 0)return g}var C;ht=!0;var S=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var k;k=at.current,at.current=null,ee();try{if(p){var T=function(){throw Error()};if(Object.defineProperty(T.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(T,[])}catch(N){C=N}Reflect.construct(n,[],T)}else{try{T.call()}catch(N){C=N}n.call(T.prototype)}}else{try{throw Error()}catch(N){C=N}n()}}catch(N){if(N&&C&&typeof N.stack=="string"){for(var x=N.stack.split(`
19
- `),P=C.stack.split(`
20
- `),L=x.length-1,A=P.length-1;L>=1&&A>=0&&x[L]!==P[A];)A--;for(;L>=1&&A>=0;L--,A--)if(x[L]!==P[A]){if(L!==1||A!==1)do if(L--,A--,A<0||x[L]!==P[A]){var B=`
21
- `+x[L].replace(" at new "," at ");return n.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",n.displayName)),typeof n=="function"&&tt.set(n,B),B}while(L>=1&&A>=0);break}}}finally{ht=!1,at.current=k,ie(),Error.prepareStackTrace=S}var X=n?n.displayName||n.name:"",z=X?J(X):"";return typeof n=="function"&&tt.set(n,z),z}function re(n,p,g){return Ht(n,!1)}function ne(n){var p=n.prototype;return!!(p&&p.isReactComponent)}function et(n,p,g){if(n==null)return"";if(typeof n=="function")return Ht(n,ne(n));if(typeof n=="string")return J(n);switch(n){case c:return J("Suspense");case d:return J("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case a:return re(n.render);case u:return et(n.type,p,g);case v:{var C=n,S=C._payload,k=C._init;try{return et(k(S),p,g)}catch{}}}return""}var V=Object.prototype.hasOwnProperty,qt={},Lt=q.ReactDebugCurrentFrame;function it(n){if(n){var p=n._owner,g=et(n.type,n._source,p?p.type:null);Lt.setExtraStackFrame(g)}else Lt.setExtraStackFrame(null)}function le(n,p,g,C,S){{var k=Function.call.bind(V);for(var T in n)if(k(n,T)){var x=void 0;try{if(typeof n[T]!="function"){var P=Error((C||"React class")+": "+g+" type `"+T+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[T]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw P.name="Invariant Violation",P}x=n[T](p,T,C,g,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(L){x=L}x&&!(x instanceof Error)&&(it(S),M("%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).",C||"React class",g,T,typeof x),it(null)),x instanceof Error&&!(x.message in qt)&&(qt[x.message]=!0,it(S),M("Failed %s type: %s",g,x.message),it(null))}}}var oe=Array.isArray;function dt(n){return oe(n)}function ae(n){{var p=typeof Symbol=="function"&&Symbol.toStringTag,g=p&&n[Symbol.toStringTag]||n.constructor.name||"Object";return g}}function ce(n){try{return It(n),!1}catch{return!0}}function It(n){return""+n}function At(n){if(ce(n))return M("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ae(n)),It(n)}var Rt=q.ReactCurrentOwner,he={key:!0,ref:!0,__self:!0,__source:!0},Zt,Dt;function de(n){if(V.call(n,"ref")){var p=Object.getOwnPropertyDescriptor(n,"ref").get;if(p&&p.isReactWarning)return!1}return n.ref!==void 0}function ue(n){if(V.call(n,"key")){var p=Object.getOwnPropertyDescriptor(n,"key").get;if(p&&p.isReactWarning)return!1}return n.key!==void 0}function pe(n,p){typeof n.ref=="string"&&Rt.current}function me(n,p){{var g=function(){Zt||(Zt=!0,M("%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)",p))};g.isReactWarning=!0,Object.defineProperty(n,"key",{get:g,configurable:!0})}}function fe(n,p){{var g=function(){Dt||(Dt=!0,M("%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)",p))};g.isReactWarning=!0,Object.defineProperty(n,"ref",{get:g,configurable:!0})}}var ge=function(n,p,g,C,S,k,T){var x={$$typeof:t,type:n,key:p,ref:g,props:T,_owner:k};return x._store={},Object.defineProperty(x._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(x,"_self",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.defineProperty(x,"_source",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.freeze&&(Object.freeze(x.props),Object.freeze(x)),x};function ve(n,p,g,C,S){{var k,T={},x=null,P=null;g!==void 0&&(At(g),x=""+g),ue(p)&&(At(p.key),x=""+p.key),de(p)&&(P=p.ref,pe(p,S));for(k in p)V.call(p,k)&&!he.hasOwnProperty(k)&&(T[k]=p[k]);if(n&&n.defaultProps){var L=n.defaultProps;for(k in L)T[k]===void 0&&(T[k]=L[k])}if(x||P){var A=typeof n=="function"?n.displayName||n.name||"Unknown":n;x&&me(T,A),P&&fe(T,A)}return ge(n,x,P,S,C,Rt.current,T)}}var ut=q.ReactCurrentOwner,Pt=q.ReactDebugCurrentFrame;function U(n){if(n){var p=n._owner,g=et(n.type,n._source,p?p.type:null);Pt.setExtraStackFrame(g)}else Pt.setExtraStackFrame(null)}var pt;pt=!1;function mt(n){return typeof n=="object"&&n!==null&&n.$$typeof===t}function Nt(){{if(ut.current){var n=$(ut.current.type);if(n)return`
17
+ */var Ut;function Ae(){return Ut||(Ut=1,process.env.NODE_ENV!=="production"&&function(){var m=O,t=Symbol.for("react.element"),e=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),f=Symbol.iterator,w="@@iterator";function E(n){if(n===null||typeof n!="object")return null;var p=f&&n[f]||n[w];return typeof p=="function"?p:null}var q=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function M(n){{for(var p=arguments.length,g=new Array(p>1?p-1:0),x=1;x<p;x++)g[x-1]=arguments[x];P("error",n,g)}}function P(n,p,g){{var x=q.ReactDebugCurrentFrame,S=x.getStackAddendum();S!==""&&(p+="%s",g=g.concat([S]));var k=g.map(function(T){return String(T)});k.unshift("Warning: "+p),Function.prototype.apply.call(console[n],console,k)}}var I=!1,$=!1,F=!1,Y=!1,te=!1,wt;wt=Symbol.for("react.module.reference");function ee(n){return!!(typeof n=="string"||typeof n=="function"||n===i||n===r||te||n===s||n===c||n===d||Y||n===b||I||$||F||typeof n=="object"&&n!==null&&(n.$$typeof===v||n.$$typeof===u||n.$$typeof===l||n.$$typeof===o||n.$$typeof===a||n.$$typeof===wt||n.getModuleId!==void 0))}function ie(n,p,g){var x=n.displayName;if(x)return x;var S=p.displayName||p.name||"";return S!==""?g+"("+S+")":g}function xt(n){return n.displayName||"Context"}function _(n){if(n==null)return null;if(typeof n.tag=="number"&&M("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case i:return"Fragment";case e:return"Portal";case r:return"Profiler";case s:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case o:var p=n;return xt(p)+".Consumer";case l:var g=n;return xt(g._context)+".Provider";case a:return ie(n,n.render,"ForwardRef");case u:var x=n.displayName||null;return x!==null?x:_(n.type)||"Memo";case v:{var S=n,k=S._payload,T=S._init;try{return _(T(k))}catch{return null}}}return null}var j=Object.assign,Q=0,Ct,Tt,Et,St,Mt,kt,Ht;function Lt(){}Lt.__reactDisabledLog=!0;function se(){{if(Q===0){Ct=console.log,Tt=console.info,Et=console.warn,St=console.error,Mt=console.group,kt=console.groupCollapsed,Ht=console.groupEnd;var n={configurable:!0,enumerable:!0,value:Lt,writable:!0};Object.defineProperties(console,{info:n,log:n,warn:n,error:n,group:n,groupCollapsed:n,groupEnd:n})}Q++}}function re(){{if(Q--,Q===0){var n={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},n,{value:Ct}),info:j({},n,{value:Tt}),warn:j({},n,{value:Et}),error:j({},n,{value:St}),group:j({},n,{value:Mt}),groupCollapsed:j({},n,{value:kt}),groupEnd:j({},n,{value:Ht})})}Q<0&&M("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var at=q.ReactCurrentDispatcher,ct;function J(n,p,g){{if(ct===void 0)try{throw Error()}catch(S){var x=S.stack.trim().match(/\n( *(at )?)/);ct=x&&x[1]||""}return`
18
+ `+ct+n}}var ht=!1,tt;{var ne=typeof WeakMap=="function"?WeakMap:Map;tt=new ne}function qt(n,p){if(!n||ht)return"";{var g=tt.get(n);if(g!==void 0)return g}var x;ht=!0;var S=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var k;k=at.current,at.current=null,se();try{if(p){var T=function(){throw Error()};if(Object.defineProperty(T.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(T,[])}catch(N){x=N}Reflect.construct(n,[],T)}else{try{T.call()}catch(N){x=N}n.call(T.prototype)}}else{try{throw Error()}catch(N){x=N}n()}}catch(N){if(N&&x&&typeof N.stack=="string"){for(var C=N.stack.split(`
19
+ `),D=x.stack.split(`
20
+ `),A=C.length-1,R=D.length-1;A>=1&&R>=0&&C[A]!==D[R];)R--;for(;A>=1&&R>=0;A--,R--)if(C[A]!==D[R]){if(A!==1||R!==1)do if(A--,R--,R<0||C[A]!==D[R]){var B=`
21
+ `+C[A].replace(" at new "," at ");return n.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",n.displayName)),typeof n=="function"&&tt.set(n,B),B}while(A>=1&&R>=0);break}}}finally{ht=!1,at.current=k,re(),Error.prepareStackTrace=S}var X=n?n.displayName||n.name:"",W=X?J(X):"";return typeof n=="function"&&tt.set(n,W),W}function le(n,p,g){return qt(n,!1)}function oe(n){var p=n.prototype;return!!(p&&p.isReactComponent)}function et(n,p,g){if(n==null)return"";if(typeof n=="function")return qt(n,oe(n));if(typeof n=="string")return J(n);switch(n){case c:return J("Suspense");case d:return J("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case a:return le(n.render);case u:return et(n.type,p,g);case v:{var x=n,S=x._payload,k=x._init;try{return et(k(S),p,g)}catch{}}}return""}var V=Object.prototype.hasOwnProperty,At={},It=q.ReactDebugCurrentFrame;function it(n){if(n){var p=n._owner,g=et(n.type,n._source,p?p.type:null);It.setExtraStackFrame(g)}else It.setExtraStackFrame(null)}function ae(n,p,g,x,S){{var k=Function.call.bind(V);for(var T in n)if(k(n,T)){var C=void 0;try{if(typeof n[T]!="function"){var D=Error((x||"React class")+": "+g+" type `"+T+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[T]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw D.name="Invariant Violation",D}C=n[T](p,T,x,g,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(A){C=A}C&&!(C instanceof Error)&&(it(S),M("%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).",x||"React class",g,T,typeof C),it(null)),C instanceof Error&&!(C.message in At)&&(At[C.message]=!0,it(S),M("Failed %s type: %s",g,C.message),it(null))}}}var ce=Array.isArray;function dt(n){return ce(n)}function he(n){{var p=typeof Symbol=="function"&&Symbol.toStringTag,g=p&&n[Symbol.toStringTag]||n.constructor.name||"Object";return g}}function de(n){try{return Rt(n),!1}catch{return!0}}function Rt(n){return""+n}function Zt(n){if(de(n))return M("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",he(n)),Rt(n)}var Pt=q.ReactCurrentOwner,ue={key:!0,ref:!0,__self:!0,__source:!0},Dt,Nt;function pe(n){if(V.call(n,"ref")){var p=Object.getOwnPropertyDescriptor(n,"ref").get;if(p&&p.isReactWarning)return!1}return n.ref!==void 0}function me(n){if(V.call(n,"key")){var p=Object.getOwnPropertyDescriptor(n,"key").get;if(p&&p.isReactWarning)return!1}return n.key!==void 0}function fe(n,p){typeof n.ref=="string"&&Pt.current}function ge(n,p){{var g=function(){Dt||(Dt=!0,M("%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)",p))};g.isReactWarning=!0,Object.defineProperty(n,"key",{get:g,configurable:!0})}}function ve(n,p){{var g=function(){Nt||(Nt=!0,M("%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)",p))};g.isReactWarning=!0,Object.defineProperty(n,"ref",{get:g,configurable:!0})}}var be=function(n,p,g,x,S,k,T){var C={$$typeof:t,type:n,key:p,ref:g,props:T,_owner:k};return C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(C,"_self",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.defineProperty(C,"_source",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C};function ye(n,p,g,x,S){{var k,T={},C=null,D=null;g!==void 0&&(Zt(g),C=""+g),me(p)&&(Zt(p.key),C=""+p.key),pe(p)&&(D=p.ref,fe(p,S));for(k in p)V.call(p,k)&&!ue.hasOwnProperty(k)&&(T[k]=p[k]);if(n&&n.defaultProps){var A=n.defaultProps;for(k in A)T[k]===void 0&&(T[k]=A[k])}if(C||D){var R=typeof n=="function"?n.displayName||n.name||"Unknown":n;C&&ge(T,R),D&&ve(T,R)}return be(n,C,D,S,x,Pt.current,T)}}var ut=q.ReactCurrentOwner,Ot=q.ReactDebugCurrentFrame;function U(n){if(n){var p=n._owner,g=et(n.type,n._source,p?p.type:null);Ot.setExtraStackFrame(g)}else Ot.setExtraStackFrame(null)}var pt;pt=!1;function mt(n){return typeof n=="object"&&n!==null&&n.$$typeof===t}function Bt(){{if(ut.current){var n=_(ut.current.type);if(n)return`
22
22
 
23
- Check the render method of \``+n+"`."}return""}}function be(n){return""}var Ot={};function ye(n){{var p=Nt();if(!p){var g=typeof n=="string"?n:n.displayName||n.name;g&&(p=`
23
+ Check the render method of \``+n+"`."}return""}}function we(n){return""}var Ft={};function xe(n){{var p=Bt();if(!p){var g=typeof n=="string"?n:n.displayName||n.name;g&&(p=`
24
24
 
25
- Check the top-level render call using <`+g+">.")}return p}}function Bt(n,p){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var g=ye(p);if(Ot[g])return;Ot[g]=!0;var C="";n&&n._owner&&n._owner!==ut.current&&(C=" It was passed a child from "+$(n._owner.type)+"."),U(n),M('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,C),U(null)}}function Ft(n,p){{if(typeof n!="object")return;if(dt(n))for(var g=0;g<n.length;g++){var C=n[g];mt(C)&&Bt(C,p)}else if(mt(n))n._store&&(n._store.validated=!0);else if(n){var S=E(n);if(typeof S=="function"&&S!==n.entries)for(var k=S.call(n),T;!(T=k.next()).done;)mt(T.value)&&Bt(T.value,p)}}}function we(n){{var p=n.type;if(p==null||typeof p=="string")return;var g;if(typeof p=="function")g=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===a||p.$$typeof===u))g=p.propTypes;else return;if(g){var C=$(p);le(g,n.props,"prop",C,n)}else if(p.PropTypes!==void 0&&!pt){pt=!0;var S=$(p);M("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",S||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&M("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ce(n){{for(var p=Object.keys(n.props),g=0;g<p.length;g++){var C=p[g];if(C!=="children"&&C!=="key"){U(n),M("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",C),U(null);break}}n.ref!==null&&(U(n),M("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}var _t={};function $t(n,p,g,C,S,k){{var T=Jt(n);if(!T){var x="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(x+=" 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 P=be();P?x+=P:x+=Nt();var L;n===null?L="null":dt(n)?L="array":n!==void 0&&n.$$typeof===t?(L="<"+($(n.type)||"Unknown")+" />",x=" Did you accidentally export a JSX literal instead of a component?"):L=typeof n,M("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",L,x)}var A=ve(n,p,g,S,k);if(A==null)return A;if(T){var B=p.children;if(B!==void 0)if(C)if(dt(B)){for(var X=0;X<B.length;X++)Ft(B[X],n);Object.freeze&&Object.freeze(B)}else M("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 Ft(B,n)}if(V.call(p,"key")){var z=$(n),N=Object.keys(p).filter(function(ke){return ke!=="key"}),ft=N.length>0?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}";if(!_t[z+ft]){var Me=N.length>0?"{"+N.join(": ..., ")+": ...}":"{}";M(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+g+">.")}return p}}function $t(n,p){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var g=xe(p);if(Ft[g])return;Ft[g]=!0;var x="";n&&n._owner&&n._owner!==ut.current&&(x=" It was passed a child from "+_(n._owner.type)+"."),U(n),M('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,x),U(null)}}function _t(n,p){{if(typeof n!="object")return;if(dt(n))for(var g=0;g<n.length;g++){var x=n[g];mt(x)&&$t(x,p)}else if(mt(n))n._store&&(n._store.validated=!0);else if(n){var S=E(n);if(typeof S=="function"&&S!==n.entries)for(var k=S.call(n),T;!(T=k.next()).done;)mt(T.value)&&$t(T.value,p)}}}function Ce(n){{var p=n.type;if(p==null||typeof p=="string")return;var g;if(typeof p=="function")g=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===a||p.$$typeof===u))g=p.propTypes;else return;if(g){var x=_(p);ae(g,n.props,"prop",x,n)}else if(p.PropTypes!==void 0&&!pt){pt=!0;var S=_(p);M("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",S||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&M("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Te(n){{for(var p=Object.keys(n.props),g=0;g<p.length;g++){var x=p[g];if(x!=="children"&&x!=="key"){U(n),M("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",x),U(null);break}}n.ref!==null&&(U(n),M("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}var jt={};function Wt(n,p,g,x,S,k){{var T=ee(n);if(!T){var C="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(C+=" 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 D=we();D?C+=D:C+=Bt();var A;n===null?A="null":dt(n)?A="array":n!==void 0&&n.$$typeof===t?(A="<"+(_(n.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):A=typeof n,M("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",A,C)}var R=ye(n,p,g,S,k);if(R==null)return R;if(T){var B=p.children;if(B!==void 0)if(x)if(dt(B)){for(var X=0;X<B.length;X++)_t(B[X],n);Object.freeze&&Object.freeze(B)}else M("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 _t(B,n)}if(V.call(p,"key")){var W=_(n),N=Object.keys(p).filter(function(Le){return Le!=="key"}),ft=N.length>0?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}";if(!jt[W+ft]){var He=N.length>0?"{"+N.join(": ..., ")+": ...}":"{}";M(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,ft,z,Me,z),_t[z+ft]=!0}}return n===i?Ce(A):we(A),A}}function xe(n,p,g){return $t(n,p,g,!0)}function Te(n,p,g){return $t(n,p,g,!1)}var Ee=Te,Se=xe;K.Fragment=i,K.jsx=Ee,K.jsxs=Se}()),K}process.env.NODE_ENV==="production"?vt.exports=He():vt.exports=qe();var Le=vt.exports;const Ie={en:{dir:"ltr",file:"File",edit:"Edit",view:"View",insert:"Insert",format:"Format",tools:"Tools",table:"Table",help:"Help",newdoc:"New document",preview:"Preview",print:"Print…",undo:"Undo",redo:"Redo",cut:"Cut",copy:"Copy",paste:"Paste",selectall:"Select all",fullscreen:"Fullscreen",sourcecode:"Source code",wordcount:"Word count",image:"Image…",inserttable:"Table",hr:"Horizontal line",charmap:"Special character…",datetime:"Date/time",pagebreak:"Page break",nbsp:"Nonbreaking space",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",superscript:"Superscript",subscript:"Subscript",clearformat:"Clear formatting",rowabove:"Insert row before",rowbelow:"Insert row after",delrow:"Delete row",colbefore:"Insert column before",colafter:"Insert column after",delcol:"Delete column",deltable:"Delete table",ltr:"Left to right",rtl:"Right to left",alignleft:"Align left",aligncenter:"Align center",alignright:"Align right",alignjustify:"Justify",numlist:"Numbered list",bullist:"Bullet list",forecolor:"Text color",backcolor:"Background color",removeformat:"Clear formatting",outdent:"Decrease indent",indent:"Increase indent",fontfamily:"Font family",fontsize:"Font size",blocks:"Blocks",quickimage:"Insert image",quicktable:"Insert table",more:"More…",para:"Paragraph",heading:"Heading",pre:"Preformatted",removecolor:"Remove color",currentcolor:"Current color",statushelp:"Press Alt+0 for help",words:"words",helpttl:"Help",shortcuts:"Handy shortcuts",close:"Close",save:"Save",cancel:"Cancel",srcttl:"Source code",wcttl:"Word count",wcwords:"Words",wcchars:"Characters",pastehint:"Use Ctrl+V / ⌘V to paste",liststyles_ol:["Default","Lower alpha","Lower roman","Upper alpha","Upper roman"],liststyles_ul:["Default","Circle","Square"],previewttl:"Preview",tablepropsttl:"Table properties",tblwidth:"Width",tblcellspacing:"Cell spacing",tblcellpadding:"Cell padding",tblborder:"Border width",tblalign:"Alignment",alignnone:"None",quote:"Blockquote",link:"Link…",linkttl:"Insert/edit link",linkurl:"URL",unlink:"Remove link",lineheight:"Line height",wordspacing:"Word spacing",changecase:"Change case",lowercase:"Lowercase",uppercase:"Uppercase",capitalize:"Capitalize Each Word",customcolor:"Custom color…",normal:"Normal",revhistory:"Revision history",revempty:"No revisions yet",restore:"Restore",currentver:"Current version",importword:"Import from Word…",importfail:"Could not import this file. Please choose a valid .docx document.",restoredraft:"Restore last draft",draftempty:"No saved draft found",deleteimg:"Delete image",rotateleft:"Rotate left",rotateright:"Rotate right",fliphorizontal:"Flip horizontal",flipvertical:"Flip vertical",cell:"Cell",row:"Row",column:"Column",cellprops:"Cell properties…",rowprops:"Row properties…",colprops:"Column properties…",tblheight:"Height",valign:"Vertical align",valigntop:"Top",valignmiddle:"Middle",valignbottom:"Bottom",fill:"Fill",nocell:"Click inside a table cell first",uploadimg:"Upload from computer",imagelink:"Insert from URL",imageurlph:"Paste image URL…",insertimg:"Insert",dropimage:"Drop image here",uploading:"Uploading…",uploadfailed:"Upload failed — click to retry"},ar:{dir:"rtl",file:"ملف",edit:"تحرير",view:"عرض",insert:"إدراج",format:"التنسيق",tools:"الأدوات",table:"جدول",help:"تعليمات",newdoc:"مستند جديد",preview:"معاينة",print:"طباعة…",undo:"تراجع",redo:"إعادة",cut:"قص",copy:"نسخ",paste:"لصق",selectall:"تحديد الكل",fullscreen:"ملء الشاشة",sourcecode:"الكود المصدري",wordcount:"عدد الكلمات",image:"صورة…",inserttable:"جدول",hr:"خط أفقي",charmap:"رمز خاص…",datetime:"التاريخ/الوقت",pagebreak:"فاصل الصفحة",nbsp:"مسافة غير فاصلة",bold:"غامق",italic:"مائل",underline:"تسطير",strikethrough:"يتوسطه خط",superscript:"نص مرتفع",subscript:"نص منخفض",clearformat:"مسح التنسيق",rowabove:"إدراج صف قبل",rowbelow:"إدراج صف بعد",delrow:"حذف الصف",colbefore:"إدراج عمود قبل",colafter:"إدراج عمود بعد",delcol:"حذف العمود",deltable:"حذف الجدول",ltr:"من اليسار إلى اليمين",rtl:"من اليمين إلى اليسار",alignleft:"محاذاة لليسار",aligncenter:"توسيط",alignright:"محاذاة لليمين",alignjustify:"ضبط",numlist:"قائمة رقمية",bullist:"قائمة نقطية",forecolor:"لون النص",backcolor:"لون الخلفية",removeformat:"مسح التنسيق",outdent:"إنقاص المسافة البادئة",indent:"زيادة المسافة البادئة",fontfamily:"عائلة الخط",fontsize:"حجم الخط",blocks:"الفقرات",quickimage:"إدراج صورة",quicktable:"إدراج جدول",more:"المزيد…",para:"الفقرة",heading:"العنوان",pre:"منسق مسبقاً",removecolor:"إزالة اللون",currentcolor:"اللون الحالي",statushelp:"اضغط على Alt+0 للحصول على مساعدة",words:"الكلمات",helpttl:"تعليمات",shortcuts:"اختصارات مفيدة",close:"إغلاق",save:"حفظ",cancel:"إلغاء",srcttl:"الكود المصدري",wcttl:"عدد الكلمات",wcwords:"الكلمات",wcchars:"الأحرف",pastehint:"استخدم Ctrl+V / ⌘V للصق",liststyles_ol:["افتراضي","أبجدي صغير","روماني صغير","أبجدي كبير","روماني كبير"],liststyles_ul:["افتراضي","دائرة","مربع"],previewttl:"معاينة",tablepropsttl:"خصائص الجدول",tblwidth:"العرض",tblcellspacing:"تباعد الخلايا",tblcellpadding:"حشو الخلايا",tblborder:"عرض الحدود",tblalign:"المحاذاة",alignnone:"بدون",quote:"اقتباس",link:"رابط…",linkttl:"إدراج/تعديل رابط",linkurl:"الرابط",unlink:"إزالة الرابط",lineheight:"تباعد الأسطر",wordspacing:"تباعد الكلمات",changecase:"تغيير حالة الأحرف",lowercase:"أحرف صغيرة",uppercase:"أحرف كبيرة",capitalize:"تكبير أول حرف",customcolor:"لون مخصص…",normal:"عادي",revhistory:"سجل المراجعات",revempty:"لا توجد مراجعات بعد",restore:"استعادة",currentver:"النسخة الحالية",importword:"استيراد من Word…",importfail:"تعذر استيراد هذا الملف. الرجاء اختيار مستند ‎.docx صالح.",restoredraft:"استعادة آخر مسودة",draftempty:"لا توجد مسودة محفوظة",deleteimg:"حذف الصورة",rotateleft:"تدوير لليسار",rotateright:"تدوير لليمين",fliphorizontal:"قلب أفقي",flipvertical:"قلب رأسي",cell:"خلية",row:"صف",column:"عمود",cellprops:"خصائص الخلية…",rowprops:"خصائص الصف…",colprops:"خصائص العمود…",tblheight:"الارتفاع",valign:"محاذاة عمودية",valigntop:"أعلى",valignmiddle:"وسط",valignbottom:"أسفل",fill:"تعبئة",nocell:"انقر داخل خلية جدول أولاً",uploadimg:"رفع من الجهاز",imagelink:"إدراج من رابط",imageurlph:"الصق رابط الصورة…",insertimg:"إدراج",dropimage:"أسقط الصورة هنا",uploading:"جارٍ الرفع…",uploadfailed:"فشل الرفع — انقر لإعادة المحاولة"}};function gt(m){return Ie[m]}const Ae="undo redo | preview print | importword revhistory | fontfamily fontsize | fontsizeincrease fontsizedecrease | bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | link blockquote changecase lineheight wordspacing | removeformat | blocks | ltr rtl | quickimage quicktable charmap | fullscreen sourcecode",Re="file edit view insert format tools table help",Ze=[["Andale Mono","andale mono,times"],["Arial","arial,helvetica,sans-serif"],["Arial Black","arial black,avant garde"],["Book Antiqua","book antiqua,palatino"],["Comic Sans MS","comic sans ms,sans-serif"],["Courier New","courier new,courier"],["Georgia","georgia,palatino"],["Helvetica","helvetica"],["Impact","impact,chicago"],["Oswald","oswald"],["Sakkal Majalla","sakkal majalla"],["Symbol","symbol"],["Tahoma","tahoma,arial,helvetica,sans-serif"],["Terminal","terminal,monaco"],["Times New Roman","times new roman,times"],["Trebuchet MS","trebuchet ms,geneva"],["Verdana","verdana,geneva"],["Webdings","webdings"],["Wingdings","wingdings,zapf dingbats"]],De=["8px","9px","10px","11px","12px","14px","16px","18px","20px","24px","28px","32px","36px","48px","72px","96px"],Pe=1,Ne=100,Oe=["1","1.15","1.4","1.5","1.75","2","2.5","3"],Be=["1px","2px","4px","6px","8px","12px"],Wt=[["p","para"],["h1","heading1"],["h2","heading2"],["h3","heading3"],["h4","heading4"],["h5","heading5"],["h6","heading6"],["pre","pre"]],Fe=["#F76707","#4263EB","#CC5DE8"],_e=["#BFEDD2","#FBEEB8","#F8CAC6","#ECCAFA","#C2E0F4","#2DC26B","#F1C40F","#E03E2D","#B96AD9","#3598DB","#169179","#E67E23","#BA372A","#843FA1","#236FA1","#ECF0F1","#CED4D9","#95A5A6","#7E8C8D","#34495E","#000000","#FFFFFF"],$e=["©","®","™","§","¶","†","‡","•","…","′","″","‰","°","±","×","÷","≈","≠","≤","≥","∞","µ","√","∑","€","£","¥","¢","←","→","↑","↓","«","»","“","”","‘","’","–","—","؟","،","؛","٪","٭","ـ","٠","١"],R=(m,t)=>`<svg viewBox="${t||"0 0 24 24"}">${m}</svg>`,y=m=>R(`<path class="f" d="${m}"/>`,"0 -960 960 960"),st=(m,t=7.5)=>R('<path d="M10 6h10M10 12h10M10 18h10"/>'+m.map((e,i)=>`<text x="2.5" y="${8.4+i*6}" font-size="${t}" stroke="none" fill="#222f3e" font-family="Arial">${e}</text>`).join("")),h={bold:y("M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"),italic:y("M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"),underline:y("M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"),strikethrough:y("M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z"),undo:y("M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"),redo:y("M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"),ltr:y("M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm0-280v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80ZM680-80l-56-56 64-64H120v-80h568l-64-64 56-56 160 160L680-80Z"),rtl:y("M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm-88 160 64 64-56 56-160-160 160-160 56 56-64 64h568v80H272Zm88-440v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Z"),alignleft:y("M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"),aligncenter:y("M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"),alignright:y("M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"),alignjustify:y("M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"),fullscreen:y("M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z"),clearformatic:y("m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"),numlist:y("M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"),bullist:y("M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z"),chev:R('<path d="M2 3.5 6 7.5 10 3.5"/>',"0 0 12 11"),backcolor:y("M440-80q-33 0-56.5-23.5T360-160v-160H240q-33 0-56.5-23.5T160-400v-280q0-66 47-113t113-47h480v440q0 33-23.5 56.5T720-320H600v160q0 33-23.5 56.5T520-80h-80ZM240-560h480v-200h-40v160h-80v-160h-40v80h-80v-80H320q-33 0-56.5 23.5T240-680v120Zm0 160h480v-80H240v80Zm0 0v-80 80Z"),outdent:y("M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"),indent:y("M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"),image:y("M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"),uploadic:y("M440-200v-326L336-422l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-80q-33 0-56.5-23.5T160-160v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-80H240Z"),tableic:y("M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm240-240H200v160h240v-160Zm80 0v160h240v-160H520Zm-80-80v-160H200v160h240Zm80 0h240v-160H520v160ZM200-680h560v-80H200v80Z"),hric:R('<path d="M4 12h16"/>'),charic:y("M120-120v-120h200q-84-45-132-125t-48-175q0-142 99-241t241-99q142 0 241 99t99 241q0 95-48 175T640-240h200v120H520v-204q78-14 129-75t51-141q0-92-64-156t-156-64q-92 0-156 64t-64 156q0 80 51 141t129 75v204H120Z"),dateic:R('<rect x="4" y="6" width="16" height="14" rx="1.5"/><path d="M4 10h16M8 4v4M16 4v4"/>'),pbic:y("M240-80q-33 0-56.5-23.5T160-160v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-80H240Zm-80-440v-280q0-33 23.5-56.5T240-880h320l240 240v120h-80v-80H520v-200H240v280h-80Zm200 160v-80h240v80H360Zm320 0v-80h240v80H680Zm-640 0v-80h240v80H40Zm440-160Zm0 240Z"),nbspic:R('<path d="M6 12v4h12v-4"/>'),srcic:y("M240-280 40-480l200-200 56 56-143 144 143 144-56 56Zm178 132-76-24 200-640 76 24-200 640Zm302-132-56-56 143-144-143-144 56-56 200 200-200 200Z"),prevw:y("M607.5-372.5Q660-425 660-500t-52.5-127.5Q555-680 480-680t-127.5 52.5Q300-575 300-500t52.5 127.5Q405-320 480-320t127.5-52.5Zm-204-51Q372-455 372-500t31.5-76.5Q435-608 480-608t76.5 31.5Q588-545 588-500t-31.5 76.5Q525-392 480-392t-76.5-31.5ZM214-281.5Q94-363 40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200q-146 0-266-81.5ZM480-500Zm207.5 160.5Q782-399 832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280q113 0 207.5-59.5Z"),printic:y("M640-640v-120H320v120h-80v-200h480v200h-80Zm-480 80h640-640Zm560 100q17 0 28.5-11.5T760-500q0-17-11.5-28.5T720-540q-17 0-28.5 11.5T680-500q0 17 11.5 28.5T720-460Zm-80 260v-160H320v160h320Zm80 80H240v-160H80v-240q0-51 35-85.5t85-34.5h560q51 0 85.5 34.5T880-520v240H720v160Zm80-240v-160q0-17-11.5-28.5T760-560H200q-17 0-28.5 11.5T160-520v160h80v-80h480v80h80Z"),cutic:y("M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-520l-80-80 240-240h120v40L600-520ZM296.5-663.5Q320-687 320-720t-23.5-56.5Q273-800 240-800t-56.5 23.5Q160-753 160-720t23.5 56.5Q207-640 240-640t56.5-23.5ZM494-466q6-6 6-14t-6-14q-6-6-14-6t-14 6q-6 6-6 14t6 14q6 6 14 6t14-6ZM296.5-183.5Q320-207 320-240t-23.5-56.5Q273-320 240-320t-56.5 23.5Q160-273 160-240t23.5 56.5Q207-160 240-160t56.5-23.5Z"),copyic:y("M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"),pasteic:y("M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm308.5-571.5Q520-783 520-800t-11.5-28.5Q497-840 480-840t-28.5 11.5Q440-817 440-800t11.5 28.5Q463-760 480-760t28.5-11.5Z"),selall:y("M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T200-840v80Zm80 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z"),superscriptic:y("M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"),subscriptic:y("M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"),newic:R('<path d="M6 3h8l5 5v13H6z"/><path d="M14 3v5h5"/>'),helpic:R('<circle cx="12" cy="12" r="8.5"/><path d="M9.6 9.6a2.5 2.5 0 1 1 3.4 2.6c-.8.3-1 .9-1 1.8"/><circle class="f" cx="12" cy="16.6" r="1.1"/>'),wcic:R('<path d="M4 6h16M4 10h16M4 14h9"/><path d="M15 17.5l2 2 3.6-4"/>'),rowbefore:y("M200-160h560v-240H200v240Zm640 80H120v-720h160v80h-80v240h560v-240h-80v-80h160v720ZM480-480Zm0 80v-80 80Zm0 0Zm-40-240v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),rowafter:y("M200-560h560v-240H200v240Zm-80 400v-720h720v720H680v-80h80v-240H200v240h80v80H120Zm360-320Zm0-80v80-80Zm0 0ZM440-80v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),rowdelete:y("M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200ZM200-200h560v-560H200ZM200-400v-160h560v160H200ZM330-580l250 250 50-50-250-250ZM330-380l250-250 50 50-250 250Z"),colbefore:y("M800-200v-560H560v560h240Zm-640 80v-160h80v80h240v-560H240v80h-80v-160h720v720H160Zm320-360Zm80 0h-80 80Zm0 0ZM160-360v-80H80v-80h80v-80h80v80h80v80h-80v80h-80Z"),colafter:y("M160-760v560h240v-560H160ZM80-120v-720h720v160h-80v-80H480v560h240v-80h80v160H80Zm400-360Zm-80 0h80-80Zm0 0Zm320 120v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),coldelete:y("M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200ZM200-200h560v-560H200ZM400-200v-560h160v560H400ZM330-580l250 250 50-50-250-250ZM330-380l250-250 50 50-250 250Z"),tabledelete:R('<rect x="4" y="5" width="16" height="14" rx="1.5"/><path d="M4 10h16M4 14.5h16M9.5 5v14M14.5 5v14"/><path d="M6.5 6.5l11 11M17.5 6.5l-11 11" stroke-width="2.1"/>'),quote:y("m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92ZM362.5-517.5Q380-535 380-560t-17.5-42.5Q345-620 320-620t-42.5 17.5Q260-585 260-560t17.5 42.5Q295-500 320-500t42.5-17.5Zm360 0Q740-535 740-560t-17.5-42.5Q705-620 680-620t-42.5 17.5Q620-585 620-560t17.5 42.5Q655-500 680-500t42.5-17.5ZM680-560Zm-360 0Z"),link:y("M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"),lineheight:y("M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z"),wordspacing:y("M320-80 160-240l160-160 57 56-64 64h334l-63-64 56-56 160 160L640-80l-57-56 64-64H313l63 64-56 56ZM200-480v-400h80v400h-80Zm240 0v-400h80v400h-80Zm240 0v-400h80v400h-80Z"),caseic:y("m131-252 165-440h79l165 440h-76l-39-112H247l-40 112h-76Zm139-176h131l-64-182h-4l-63 182Zm395 186q-51 0-81-27.5T554-342q0-44 34.5-72.5T677-443q23 0 45 4t38 11v-12q0-29-20.5-47T685-505q-23 0-42 9.5T610-468l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T689-393q-32 0-50 14t-18 37q0 20 16 33t40 13Z"),uppercaseic:y("M660-240v-248l-64 64-56-56 160-160 160 160-56 56-64-64v248h-80Zm-540 0 165-440h79l165 440h-76l-39-113H236l-40 113h-76Zm139-177h131l-65-182h-4l-62 182Z"),lowercaseic:y("M300-240q-51 0-81-27.5T189-340q0-44 34.5-72.5T312-441q23 0 45 4t38 11v-12q0-29-20.5-47T320-503q-23 0-42 9.5T245-466l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T324-391q-32 0-50 14t-18 37q0 20 16 33t40 13Zm388 54L540-400l56-56 64 64v-248h80v248l64-64 56 56-160 160Z"),capitalizeic:y("M344-250v-366H224v-64h308v64H412v366h-68Zm344 10q-44 0-69-25.5T594-336v-162h-54v-58h54v-87h66v87h74v58h-74v148q0 23 10.5 36t28.5 13q9 0 18.5-3.5T736-314v65q-10 5-22 7t-26 2Z"),fontsizeup:y("m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm504 104v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z"),fontsizedown:y("m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm384-16v-80h320v80H600Z"),historyic:y("M480-120q-138 0-240.5-91.5T122-440h82q14 104 92.5 172T480-200q117 0 198.5-81.5T760-480q0-117-81.5-198.5T480-760q-69 0-129 32t-101 88h110v80H120v-240h80v94q51-64 124.5-99T480-840q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-480q0 75-28.5 140.5t-77 114q-48.5 48.5-114 77T480-120Zm112-192L440-464v-216h80v184l128 128-56 56Z"),wordic:R('<path d="M6 3h8l5 5v13H6z"/><path d="M14 3v5h5"/><text x="8" y="17" font-size="8.5" stroke="none" fill="#222f3e" font-family="Arial" font-weight="bold">W</text>'),draftic:y("M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z"),trash:R('<path d="M5 7h14M10 7V5h4v2M7.5 7l1 13h7l1-13"/>'),rotateleft:R('<polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>'),rotateright:R('<polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>'),fliphorizontal:R('<path d="M12 3v18"/><path d="M7 8l-4 4 4 4"/><path d="M17 8l4 4-4 4"/>'),flipvertical:R('<path d="M3 12h18"/><path d="M8 7l4-4 4 4"/><path d="M8 17l4 4 4-4"/>'),check:R('<path d="M5 12.5 9.5 17 19 7"/>'),palette:R('<path d="M12 3a9 9 0 1 0 0 18h1.2a2 2 0 0 0 2-2 2 2 0 0 1 2-2H18a3 3 0 0 0 3-3c0-6.1-4.5-11-9-11z"/><circle class="f" cx="7.8" cy="10.2" r="1.3"/><circle class="f" cx="11.6" cy="7.3" r="1.3"/><circle class="f" cx="15.8" cy="9.6" r="1.3"/><circle class="f" cx="9" cy="14.8" r="1.3"/>'),ul_circle:y("M280-600v-80h560v80H280Zm0 160v-80h560v80H280Zm0 160v-80h560v80H280ZM160-600q-17 0-28.5-11.5T120-640q0-17 11.5-28.5T160-680q17 0 28.5 11.5T200-640q0 17-11.5 28.5T160-600Zm0 160q-17 0-28.5-11.5T120-480q0-17 11.5-28.5T160-520q17 0 28.5 11.5T200-480q0 17-11.5 28.5T160-440Zm0 160q-17 0-28.5-11.5T120-320q0-17 11.5-28.5T160-360q17 0 28.5 11.5T200-320q0 17-11.5 28.5T160-280Z"),ul_square:y("M80-160v-160h160v160H80Zm240 0v-160h560v160H320ZM80-400v-160h160v160H80Zm240 0v-160h560v160H320ZM80-640v-160h160v160H80Zm240 0v-160h560v160H320Z"),ol_alpha:st(["a","b","c"]),ol_roman:st(["i","ii","iii"],6.5),ol_alphau:st(["A","B","C"]),ol_romanu:st(["I","II","III"],6.5)},je=new Set(["p","div","span","br","hr","a","b","strong","i","em","u","s","strike","sub","sup","h1","h2","h3","h4","h5","h6","blockquote","pre","code","ul","ol","li","table","thead","tbody","tfoot","tr","td","th","caption","colgroup","col","img","figure","figcaption","mark"]),ze=new Set(["text-align","direction","unicode-bidi","font-weight","font-style","text-decoration","text-decoration-line","color","background-color","background","background-image","background-position","background-repeat","background-size","font-size","font-family","line-height","letter-spacing","vertical-align","text-indent","margin","margin-top","margin-bottom","margin-left","margin-right","margin-inline-start","margin-inline-end","padding","padding-top","padding-bottom","padding-left","padding-right","width","height","min-width","max-width","min-height","max-height","border","border-top","border-right","border-bottom","border-left","border-color","border-style","border-width","border-radius","border-collapse","border-spacing","table-layout","float","display","box-sizing","list-style-type","white-space"]),Ut={"*":["dir","lang","colspan","rowspan"],a:["href","target","rel","title"],img:["src","alt","width","height","title"],col:["span","width"],td:["width","valign"],th:["width","valign"],table:["width","cellpadding","cellspacing"]};function ot(m){const t={},e=m.getAttribute&&m.getAttribute("style");return e&&e.split(";").forEach(i=>{const s=i.indexOf(":");s<1||(t[i.slice(0,s).trim().toLowerCase()]=i.slice(s+1).trim())}),t}function We(m){return m.replace(/<!--\[if !supportLists\]-->([\s\S]*?)<!--\[endif\]-->/gi,"$1").replace(/<!--\[if !supportLists\]>([\s\S]*?)<!\[endif\]-->/gi,"$1").replace(/<!\[if !supportLists\]>([\s\S]*?)<!\[endif\]>/gi,"$1").replace(/<!--\[if [\s\S]*?<!\[endif\]-->/gi,"").replace(/<!--[\s\S]*?-->/g,"").replace(/<(script|style|xml|title)[\s\S]*?<\/\1>/gi,"").replace(/<\/?(meta|link)[^>]*>/gi,"").replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<\/?(o|v|w|m|st1):[^>]*>/gi,"")}function Ue(m){return/^[0-9]+[\.\)،]/.test(m)?{ordered:!0}:/^[٠-٩۰-۹]+/.test(m)?{ordered:!0,style:"arabic-indic"}:/^[ivxlc]{2,}[\.\)]/.test(m)?{ordered:!0,style:"lower-roman"}:/^[IVXLC]{2,}[\.\)]/.test(m)?{ordered:!0,style:"upper-roman"}:/^[a-z][\.\)]/.test(m)?{ordered:!0,style:"lower-alpha"}:/^[A-Z][\.\)]/.test(m)?{ordered:!0,style:"upper-alpha"}:/^[ء-ي][\.\)،-]/.test(m)?{ordered:!0,style:"arabic-indic"}:{ordered:!1}}function Xe(m){const t=s=>{const r=(s.getAttribute("style")||"")+" "+(s.className||"");return/mso-list\s*:(?!\s*ignore)/i.test(r)||/MsoListParagraph/i.test(r)},e=[];let i=null;Array.from(m.body.querySelectorAll("p")).forEach(s=>{if(!t(s)){i=null;return}const r=s.previousElementSibling;i&&r&&i[i.length-1]===r?i.push(s):(i=[s],e.push(i))}),e.forEach(s=>{const r=[],l=s[0];s.forEach(o=>{var q,M,D;const c=+(((q=(o.getAttribute("style")||"").match(/level(\d+)/i))==null?void 0:q[1])||1),d=Array.from(o.querySelectorAll("span")).find(I=>/mso-list\s*:\s*ignore/i.test(I.getAttribute("style")||"")),u=d?((M=d.textContent)==null?void 0:M.trim())||"":(((D=o.textContent)==null?void 0:D.trim().match(/^\S{1,4}/))||[""])[0],{ordered:v,style:b}=Ue(u);for(d&&d.remove();r.length&&r[r.length-1].level>c;)r.pop();if(!r.length||r[r.length-1].level<c){const I=m.createElement(v?"ol":"ul");if(v&&b&&(I.style.listStyleType=b),r.length){const _=r[r.length-1].list;(_.lastElementChild||_).appendChild(I)}else l.parentNode.insertBefore(I,l);r.push({list:I,level:c})}const f=m.createElement("li"),w=ot(o),E=["text-align","direction","unicode-bidi","color","font-size","font-family","background-color"].filter(I=>w[I]).map(I=>I+":"+w[I]).join(";");for(E&&f.setAttribute("style",E),o.getAttribute("dir")&&f.setAttribute("dir",o.getAttribute("dir"));o.firstChild;)f.appendChild(o.firstChild);r[r.length-1].list.appendChild(f),o.remove()})})}function Ye(m){m.querySelectorAll('b[id^="docs-internal-guid"]').forEach(t=>{for(;t.firstChild;)t.parentNode.insertBefore(t.firstChild,t);t.remove()})}function Qe(m){m.querySelectorAll("table").forEach(t=>{const e=t;ot(e)["border-collapse"]||(e.style.borderCollapse="collapse")}),m.querySelectorAll("[align]").forEach(t=>{const e=t,i=e.getAttribute("align").toLowerCase();e.tagName.toLowerCase()==="table"?i==="center"?(e.style.marginLeft=e.style.marginLeft||"auto",e.style.marginRight=e.style.marginRight||"auto"):i==="right"?e.style.marginLeft=e.style.marginLeft||"auto":i==="left"&&(e.style.marginRight=e.style.marginRight||"auto"):["left","right","center","justify"].includes(i)&&(e.style.textAlign=e.style.textAlign||i,Array.from(e.children).forEach(s=>{if(s.tagName.toLowerCase()!=="table")return;const r=s;i==="center"?(r.style.marginLeft=r.style.marginLeft||"auto",r.style.marginRight=r.style.marginRight||"auto"):i==="right"?r.style.marginLeft=r.style.marginLeft||"auto":i==="left"&&(r.style.marginRight=r.style.marginRight||"auto")})),e.removeAttribute("align")}),m.querySelectorAll("center table").forEach(t=>{const e=t;e.style.marginLeft=e.style.marginLeft||"auto",e.style.marginRight=e.style.marginRight||"auto"}),m.querySelectorAll("[bgcolor]").forEach(t=>{const e=t;e.style.backgroundColor=e.style.backgroundColor||e.getAttribute("bgcolor"),e.removeAttribute("bgcolor")})}function nt(m,t){Array.from(m.childNodes).forEach(e=>{if(e.nodeType===Node.COMMENT_NODE){e.remove();return}if(e.nodeType!==Node.ELEMENT_NODE)return;const i=e,s=i.tagName.toLowerCase();if(!je.has(s)){if(s==="font"){const a=t.createElement("span");i.getAttribute("style")&&a.setAttribute("style",i.getAttribute("style")),i.getAttribute("color")&&(a.style.color=i.getAttribute("color")),i.getAttribute("face")&&(a.style.fontFamily=i.getAttribute("face"));const c=i.getAttribute("size");if(c&&!a.style.fontSize){const d={1:"8pt",2:"10pt",3:"12pt",4:"14pt",5:"18pt",6:"24pt",7:"36pt"};d[c]&&(a.style.fontSize=d[c])}for(;i.firstChild;)a.appendChild(i.firstChild);i.replaceWith(a),nt(a,t);return}for(nt(i,t);i.firstChild;)i.parentNode.insertBefore(i.firstChild,i);i.remove();return}const r=new Set([...Ut["*"]||[],...Ut[s]||[]]);if(Array.from(i.attributes).forEach(a=>{const c=a.name.toLowerCase();c!=="style"&&!r.has(c)&&i.removeAttribute(a.name)}),s==="a"){const a=i.getAttribute("href")||"";/^(https?:|mailto:|tel:|#)/i.test(a)||i.removeAttribute("href")}if(s==="img"){const a=i.getAttribute("src")||"";if(!/^(https?:|data:image\/|blob:)/i.test(a)){const c=t.createElement("span");c.textContent="[local image — paste it separately]",c.setAttribute("style","color:#a33;font-style:italic;font-size:12px"),i.replaceWith(c);return}}const l=ot(i),o=[];for(const[a,c]of Object.entries(l))ze.has(a)&&(/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(c)||a==="font-weight"&&/^(400|normal)$/i.test(c)||a==="font-style"&&/^normal$/i.test(c)||a==="text-decoration"&&/^none$/i.test(c)||o.push(a+":"+c));if(o.length?i.setAttribute("style",o.join(";")):i.removeAttribute("style"),i.removeAttribute("class"),nt(i,t),s==="span"&&!i.attributes.length){for(;i.firstChild;)i.parentNode.insertBefore(i.firstChild,i);i.remove()}})}function Ve(m){const t=[],e=/<style[^>]*>([\s\S]*?)<\/style>/gi;let i;for(;i=e.exec(m);){let s=i[1].replace(/<!--|-->/g,"").replace(/\/\*[\s\S]*?\*\//g,"");s=s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi,""),s=s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g,"");let r;const l=/([^{}]+)\{([^}]*)\}/g;for(;r=l.exec(s);){const o=r[2].split(";").map(a=>{const c=a.indexOf(":");return c<1?null:[a.slice(0,c).trim().toLowerCase(),a.slice(c+1).trim()]}).filter(a=>!!a&&!!a[1]);o.length&&r[1].split(",").map(a=>a.trim()).filter(a=>a&&!a.startsWith("@")).forEach(a=>t.push({sel:a,decls:o}))}}return t}function Ge(m,t){if(!t.length)return;const e=new Map;t.forEach(({sel:i,decls:s})=>{let r;try{r=m.querySelectorAll(i)}catch{return}r.forEach(l=>{let o=e.get(l);o||(o={},e.set(l,o)),s.forEach(([a,c])=>{o[a]=c})})}),e.forEach((i,s)=>{const r=ot(s),l=s.hasAttribute("dir"),o=s.hasAttribute("align"),a=Object.entries(i).filter(([u])=>!(u in r||(u==="direction"||u==="unicode-bidi")&&l||u==="text-align"&&(o||l)||(u==="background"||u==="background-color")&&s.hasAttribute("bgcolor")));if(!a.length)return;const c=a.map(([u,v])=>u+":"+v).join(";"),d=s.getAttribute("style");s.setAttribute("style",d?c+";"+d:c)})}function Vt(m){return m.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g,t=>t.normalize("NFKC"))}function Ke(m){const t=m.createTreeWalker(m.body,NodeFilter.SHOW_TEXT,null);let e;for(;e=t.nextNode();)/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue||"")&&(e.nodeValue=Vt(e.nodeValue||""))}function Je(m,t="ltr"){const e=Ve(m),i=new DOMParser().parseFromString(We(m),"text/html");Ge(i,e),/class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML)&&Xe(i),Ye(i),Qe(i),nt(i.body,i),Ke(i);const s=r=>{var l;return r&&r.tagName==="P"&&!((l=r.textContent)!=null&&l.trim())&&!r.querySelector("img,table")};for(;s(i.body.firstElementChild);)i.body.firstElementChild.remove();for(;s(i.body.lastElementChild);)i.body.lastElementChild.remove();return i.body.innerHTML.trim()}function ti(m){const t=Vt(m).replace(/\r/g,""),e=i=>i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return/\n/.test(t)?t.split(/\n{2,}/).map(i=>`<p dir="auto">${e(i).replace(/\n/g,"<br>")||"<br>"}</p>`).join(""):e(t)}function ei(m){const t=new DataView(m),e=new Map;let i=-1;for(let o=m.byteLength-22;o>=Math.max(0,m.byteLength-22-65535);o--)if(t.getUint32(o,!0)===101010256){i=o;break}if(i<0)throw new Error("EOCD not found");const s=t.getUint16(i+10,!0);let r=t.getUint32(i+16,!0);const l=new TextDecoder;for(let o=0;o<s&&t.getUint32(r,!0)===33639248;o++){const a=t.getUint16(r+10,!0),c=t.getUint32(r+20,!0),d=t.getUint16(r+28,!0),u=t.getUint16(r+30,!0),v=t.getUint16(r+32,!0),b=t.getUint32(r+42,!0),f=l.decode(new Uint8Array(m,r+46,d));e.set(f,{name:f,method:a,compSize:c,localOffset:b}),r+=46+d+u+v}return e}async function Xt(m,t){const e=new DataView(m,t.localOffset);if(e.getUint32(0,!0)!==67324752)throw new Error("Bad local header");const i=e.getUint16(26,!0),s=e.getUint16(28,!0),r=t.localOffset+30+i+s,l=new Uint8Array(m.slice(r,r+t.compSize));if(t.method===0)return l;if(t.method!==8)throw new Error("Unsupported compression method "+t.method);const o=new Blob([l]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(o).arrayBuffer())}const Yt=m=>m.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),lt=(m,t)=>Array.from(m.children).filter(e=>e.localName===t),Z=(m,...t)=>{let e=m;for(const i of t){if(!e)return null;e=Array.from(e.children).find(s=>s.localName===i)||null}return e},H=(m,t="val")=>{if(!m)return"";for(const e of Array.from(m.attributes))if(e.localName===t)return e.value;return""},rt=(m,t)=>{const e=m?Z(m,t):null;if(!e)return!1;const i=H(e);return i!=="false"&&i!=="0"},Qt={yellow:"#FFFF00",green:"#00FF00",cyan:"#00FFFF",magenta:"#FF00FF",blue:"#0000FF",red:"#FF0000",darkBlue:"#00008B",darkCyan:"#008B8B",darkGreen:"#006400",darkMagenta:"#8B008B",darkRed:"#8B0000",darkYellow:"#808000",darkGray:"#A9A9A9",lightGray:"#D3D3D3",black:"#000000",white:"#FFFFFF"},ii={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",webp:"image/webp"};function si(m){let t="";for(let e=0;e<m.length;e+=32768)t+=String.fromCharCode(...m.subarray(e,e+32768));return btoa(t)}class ri{constructor(t,e,i){this.rels=t,this.images=e,this.numFmt=i}convertBody(t){let e="",i=[];const s=r=>{for(;i.length>r;)e+=`</${i.pop()}>`};for(const r of Array.from(t.children))if(r.localName==="p"){const l=this.paraList(r);if(l){const o=l.ilvl+1;for(;i.length>o;)e+=`</${i.pop()}>`;for(i.length===o&&i[o-1]!==l.type&&(e+=`</${i.pop()}>`);i.length<o;)e+=`<${l.type}>`,i.push(l.type);e+=`<li>${this.runsOf(r)||"<br>"}</li>`;continue}s(0),e+=this.convertPara(r)}else r.localName==="tbl"?(s(0),e+=this.convertTable(r)):r.localName;return s(0),e||"<p><br></p>"}paraList(t){const e=Z(t,"pPr","numPr");if(!e)return null;const i=H(Z(e,"numId"));if(!i||i==="0")return null;const s=parseInt(H(Z(e,"ilvl"))||"0",10)||0;return{type:this.numFmt.get(i)||"ul",ilvl:Math.min(s,8)}}convertPara(t){const e=Z(t,"pPr"),i=H(Z(t,"pPr","pStyle"));let s="p";const r=/^Heading([1-6])$/i.exec(i);r?s="h"+r[1]:/^Title$/i.test(i)&&(s="h1");const l=[],o=H(Z(t,"pPr","jc"));o==="center"?l.push("text-align:center"):o==="right"||o==="end"?l.push("text-align:right"):(o==="both"||o==="distribute")&&l.push("text-align:justify"),e&&Z(e,"bidi")&&l.push("direction:rtl");const a=this.runsOf(t),c=l.length?` style="${l.join(";")}"`:"";return`<${s}${c}>${a||"<br>"}</${s}>`}runsOf(t){let e="";for(const i of Array.from(t.children))if(i.localName==="r")e+=this.convertRun(i);else if(i.localName==="hyperlink"){let s=this.rels.get(H(i,"id"))||"";const r=H(i,"anchor");!s&&r&&(s="#"+r);const l=this.runsOf(i);e+=s?`<a href="${Yt(s)}">${l}</a>`:l}else(i.localName==="smartTag"||i.localName==="ins")&&(e+=this.runsOf(i));return e}convertRun(t){const e=Z(t,"rPr");let i="";for(const u of Array.from(t.children))u.localName==="t"?i+=Yt(u.textContent||""):u.localName==="br"||u.localName==="cr"?i+="<br>":u.localName==="tab"?i+="&emsp;":(u.localName==="drawing"||u.localName==="pict"||u.localName==="object")&&(i+=this.convertImage(u));if(!i)return"";const s=[],r=H(e?Z(e,"color"):null);r&&r!=="auto"&&s.push("color:#"+r);const l=H(e?Z(e,"highlight"):null);l&&Qt[l]&&s.push("background-color:"+Qt[l]);const o=parseFloat(H(e?Z(e,"sz"):null));o&&s.push("font-size:"+Math.round(o/2*(4/3))+"px");const a=e?Z(e,"rFonts"):null,c=H(a,"ascii")||H(a,"cs");c&&s.push(`font-family:'${c}'`),s.length&&(i=`<span style="${s.join(";")}">${i}</span>`),rt(e,"b")&&(i=`<strong>${i}</strong>`),rt(e,"i")&&(i=`<em>${i}</em>`),rt(e,"u")&&H(Z(e,"u"))!=="none"&&(i=`<u>${i}</u>`),rt(e,"strike")&&(i=`<s>${i}</s>`);const d=H(e?Z(e,"vertAlign"):null);return d==="superscript"?i=`<sup>${i}</sup>`:d==="subscript"&&(i=`<sub>${i}</sub>`),i}convertImage(t){let e="",i=0;const s=o=>{if(o.localName==="blip"&&(e=e||H(o,"embed")||H(o,"link")),o.localName==="imagedata"&&(e=e||H(o,"id")),o.localName==="extent"){const a=parseFloat(o.getAttribute("cx")||"0");a&&(i=Math.round(a/9525))}for(const a of Array.from(o.children))s(a)};if(s(t),!e)return"";const r=this.images.get(e);if(!r)return"";const l=i?` width="${i}"`:"";return`<img src="${r}" alt=""${l}>`}convertTable(t){let e='<table style="border-collapse:collapse;width:100%"><tbody>';for(const i of lt(t,"tr")){e+="<tr>";for(const s of lt(i,"tc")){const r=parseInt(H(Z(s,"tcPr","gridSpan"))||"1",10)||1,l=r>1?` colspan="${r}"`:"";let o="";for(const a of Array.from(s.children))a.localName==="p"?o+=this.convertPara(a):a.localName==="tbl"&&(o+=this.convertTable(a));e+=`<td style="border:1px solid #b9c2cc"${l}>${o||"<br>"}</td>`}e+="</tr>"}return e+"</tbody></table>"}}async function ni(m){const t=m instanceof ArrayBuffer?m:await m.arrayBuffer(),e=ei(t),i=new TextDecoder,s=async f=>{const w=e.get(f);return w?new DOMParser().parseFromString(i.decode(await Xt(t,w)),"application/xml"):null},r=await s("word/document.xml"),l=r==null?void 0:r.getElementsByTagName("*");let o=null;if(l){for(const f of Array.from(l))if(f.localName==="body"){o=f;break}}if(!o)throw new Error("word/document.xml missing or invalid");const a=new Map,c=new Map,d=await s("word/_rels/document.xml.rels");if(d)for(const f of Array.from(d.getElementsByTagName("*"))){if(f.localName!=="Relationship")continue;const w=f.getAttribute("Id")||"",E=f.getAttribute("Target")||"",q=f.getAttribute("Type")||"";/hyperlink/i.test(q)?a.set(w,E):/image/i.test(q)&&c.set(w,E)}const u=new Map;for(const[f,w]of c){const E=w.startsWith("/")?w.slice(1):"word/"+w.replace(/^\.\//,""),q=e.get(E);if(!q)continue;const M=(E.split(".").pop()||"").toLowerCase(),D=ii[M];if(D)try{u.set(f,`data:${D};base64,${si(await Xt(t,q))}`)}catch{}}const v=new Map,b=await s("word/numbering.xml");if(b){const f=new Map,w=Array.from(b.getElementsByTagName("*"));for(const E of w){if(E.localName!=="abstractNum")continue;const q=H(E,"abstractNumId"),M=lt(E,"lvl").find(I=>H(I,"ilvl")==="0")||lt(E,"lvl")[0],D=M?H(Z(M,"numFmt")):"";f.set(q,D==="bullet"?"ul":"ol")}for(const E of w){if(E.localName!=="num")continue;const q=H(E,"numId"),M=H(Z(E,"abstractNumId"));v.set(q,f.get(M)||"ul")}}return new ri(a,u,v).convertBody(o)}const li=["nw","ne","sw","se"];var W;let oi=(W=class{constructor(t){this.lang="en",this.contentClass="fable-content-"+W.instanceCounter++,this.contentStyleEl=null,this.savedRange=null,this.foreColor="#000000",this.backColor="#FACC15",this.openPop=null,this.openSubEl=null,this.popAnchor=null,this.dlgOvl=null,this.tblActive=null,this.tblCorner=null,this.tblColBars=[],this.tblCtx=null,this.tblCellMark=null,this.tblOpMark=null,this.tblOpMarkKind=null,this.imgActive=null,this.imgHandles=[],this.imgCtx=null,this.imgHideTimer=null,this.phActive=null,this.phCtx=null,this.phUploadTarget=null,this.selCtx=null,this.revisions=[],this.revTimer=null,this.draftTimer=null,this.draftStorageKey="",this.listeners=[],this.isDestroyed=!1,this.options={target:t.target,language:t.language||"en",height:t.height??302,initialContent:t.initialContent??"<p><br></p>",onChange:t.onChange||(()=>{}),onReady:t.onReady||(()=>{}),menubar:t.menubar??!0,toolbar:t.toolbar??!0,statusbar:t.statusbar??!0,readonly:t.readonly??!1,draftKey:t.draftKey??(typeof location<"u"?location.pathname:"default"),fontFamilyFormats:t.fontFamilyFormats??Ze,imageFileTypes:t.imageFileTypes??["image/jpeg","image/jpg","image/png","image/gif","image/bmp","image/webp"]},this.imageUploadHandler=t.imageUploadHandler,this.onImageUploadError=t.onImageUploadError,this.contentStyle=t.contentStyle,this.lang=this.options.language,this.draftStorageKey="tmclone-draft:"+this.options.draftKey,this.initDOM(),this.bindEvents(),this.initUI(),this.recordRevision(),this.options.onReady(this)}t(t){const e=gt(this.lang)[t];return typeof e=="string"?e:e.join(",")}tArr(t){return gt(this.lang)[t]}dir(){return gt(this.lang).dir}initDOM(){const t=this.options.target;t.innerHTML="",t.classList.add("tox-root"),this.shell=document.createElement("div"),this.shell.className="tox",this.menubar=document.createElement("div"),this.menubar.className="mnb",this.toolbar=document.createElement("div"),this.toolbar.className="tbr",this.ed=document.createElement("div"),this.ed.className="earea "+this.contentClass,this.ed.setAttribute("contenteditable",(!this.options.readonly).toString()),this.ed.spellcheck=!0,this.ed.innerHTML=this.options.initialContent,this.ed.style.height=this.options.height+"px",this.statusbar=document.createElement("div"),this.statusbar.className="sbar",this.statusbar.innerHTML=`
30
+ <%s key={someKey} {...props} />`,ft,W,He,W),jt[W+ft]=!0}}return n===i?Te(R):Ce(R),R}}function Ee(n,p,g){return Wt(n,p,g,!0)}function Se(n,p,g){return Wt(n,p,g,!1)}var Me=Se,ke=Ee;K.Fragment=i,K.jsx=Me,K.jsxs=ke}()),K}process.env.NODE_ENV==="production"?yt.exports=qe():yt.exports=Ae();var Ie=yt.exports;const Re={en:{dir:"ltr",file:"File",edit:"Edit",view:"View",insert:"Insert",format:"Format",tools:"Tools",table:"Table",help:"Help",newdoc:"New document",preview:"Preview",print:"Print…",undo:"Undo",redo:"Redo",cut:"Cut",copy:"Copy",paste:"Paste",selectall:"Select all",fullscreen:"Fullscreen",sourcecode:"Source code",wordcount:"Word count",image:"Image…",inserttable:"Table",hr:"Horizontal line",charmap:"Special character…",datetime:"Date/time",pagebreak:"Page break",nbsp:"Nonbreaking space",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",superscript:"Superscript",subscript:"Subscript",clearformat:"Clear formatting",rowabove:"Insert row before",rowbelow:"Insert row after",delrow:"Delete row",colbefore:"Insert column before",colafter:"Insert column after",delcol:"Delete column",deltable:"Delete table",ltr:"Left to right",rtl:"Right to left",alignleft:"Align left",aligncenter:"Align center",alignright:"Align right",alignjustify:"Justify",numlist:"Numbered list",bullist:"Bullet list",forecolor:"Text color",backcolor:"Background color",removeformat:"Clear formatting",outdent:"Decrease indent",indent:"Increase indent",fontfamily:"Font family",fontsize:"Font size",blocks:"Blocks",quickimage:"Insert image",quicktable:"Insert table",more:"More…",para:"Paragraph",heading:"Heading",pre:"Preformatted",removecolor:"Remove color",currentcolor:"Current color",statushelp:"Press Alt+0 for help",words:"words",helpttl:"Help",shortcuts:"Handy shortcuts",close:"Close",save:"Save",cancel:"Cancel",srcttl:"Source code",wcttl:"Word count",wcwords:"Words",wcchars:"Characters",pastehint:"Use Ctrl+V / ⌘V to paste",liststyles_ol:["Default","Lower alpha","Lower roman","Upper alpha","Upper roman"],liststyles_ul:["Default","Circle","Square"],previewttl:"Preview",tablepropsttl:"Table properties",tblwidth:"Width",tblcellspacing:"Cell spacing",tblcellpadding:"Cell padding",tblborder:"Border width",tblalign:"Alignment",alignnone:"None",quote:"Blockquote",link:"Link…",linkttl:"Insert/edit link",linkurl:"URL",unlink:"Remove link",lineheight:"Line height",wordspacing:"Word spacing",changecase:"Change case",lowercase:"Lowercase",uppercase:"Uppercase",capitalize:"Capitalize Each Word",customcolor:"Custom color…",normal:"Normal",revhistory:"Revision history",revempty:"No revisions yet",restore:"Restore",currentver:"Current version",importword:"Import from Word…",importfail:"Could not import this file. Please choose a valid .docx document.",restoredraft:"Restore last draft",draftempty:"No saved draft found",deleteimg:"Delete image",rotateleft:"Rotate left",rotateright:"Rotate right",fliphorizontal:"Flip horizontal",flipvertical:"Flip vertical",cell:"Cell",row:"Row",column:"Column",cellprops:"Cell properties…",rowprops:"Row properties…",colprops:"Column properties…",tblheight:"Height",valign:"Vertical align",valigntop:"Top",valignmiddle:"Middle",valignbottom:"Bottom",fill:"Fill",nocell:"Click inside a table cell first",uploadimg:"Upload from computer",imagelink:"Insert from URL",imageurlph:"Paste image URL…",insertimg:"Insert",dropimage:"Drop image here",uploading:"Uploading…",uploadfailed:"Upload failed — click to retry",template:"Templates",tplimgleft:"Image left, text right",tplimgright:"Image right, text left",tplimgtop:"Image top, text below",tplimgcenter:"Text top, image center",deltemplate:"Delete template"},ar:{dir:"rtl",file:"ملف",edit:"تحرير",view:"عرض",insert:"إدراج",format:"التنسيق",tools:"الأدوات",table:"جدول",help:"تعليمات",newdoc:"مستند جديد",preview:"معاينة",print:"طباعة…",undo:"تراجع",redo:"إعادة",cut:"قص",copy:"نسخ",paste:"لصق",selectall:"تحديد الكل",fullscreen:"ملء الشاشة",sourcecode:"الكود المصدري",wordcount:"عدد الكلمات",image:"صورة…",inserttable:"جدول",hr:"خط أفقي",charmap:"رمز خاص…",datetime:"التاريخ/الوقت",pagebreak:"فاصل الصفحة",nbsp:"مسافة غير فاصلة",bold:"غامق",italic:"مائل",underline:"تسطير",strikethrough:"يتوسطه خط",superscript:"نص مرتفع",subscript:"نص منخفض",clearformat:"مسح التنسيق",rowabove:"إدراج صف قبل",rowbelow:"إدراج صف بعد",delrow:"حذف الصف",colbefore:"إدراج عمود قبل",colafter:"إدراج عمود بعد",delcol:"حذف العمود",deltable:"حذف الجدول",ltr:"من اليسار إلى اليمين",rtl:"من اليمين إلى اليسار",alignleft:"محاذاة لليسار",aligncenter:"توسيط",alignright:"محاذاة لليمين",alignjustify:"ضبط",numlist:"قائمة رقمية",bullist:"قائمة نقطية",forecolor:"لون النص",backcolor:"لون الخلفية",removeformat:"مسح التنسيق",outdent:"إنقاص المسافة البادئة",indent:"زيادة المسافة البادئة",fontfamily:"عائلة الخط",fontsize:"حجم الخط",blocks:"الفقرات",quickimage:"إدراج صورة",quicktable:"إدراج جدول",more:"المزيد…",para:"الفقرة",heading:"العنوان",pre:"منسق مسبقاً",removecolor:"إزالة اللون",currentcolor:"اللون الحالي",statushelp:"اضغط على Alt+0 للحصول على مساعدة",words:"الكلمات",helpttl:"تعليمات",shortcuts:"اختصارات مفيدة",close:"إغلاق",save:"حفظ",cancel:"إلغاء",srcttl:"الكود المصدري",wcttl:"عدد الكلمات",wcwords:"الكلمات",wcchars:"الأحرف",pastehint:"استخدم Ctrl+V / ⌘V للصق",liststyles_ol:["افتراضي","أبجدي صغير","روماني صغير","أبجدي كبير","روماني كبير"],liststyles_ul:["افتراضي","دائرة","مربع"],previewttl:"معاينة",tablepropsttl:"خصائص الجدول",tblwidth:"العرض",tblcellspacing:"تباعد الخلايا",tblcellpadding:"حشو الخلايا",tblborder:"عرض الحدود",tblalign:"المحاذاة",alignnone:"بدون",quote:"اقتباس",link:"رابط…",linkttl:"إدراج/تعديل رابط",linkurl:"الرابط",unlink:"إزالة الرابط",lineheight:"تباعد الأسطر",wordspacing:"تباعد الكلمات",changecase:"تغيير حالة الأحرف",lowercase:"أحرف صغيرة",uppercase:"أحرف كبيرة",capitalize:"تكبير أول حرف",customcolor:"لون مخصص…",normal:"عادي",revhistory:"سجل المراجعات",revempty:"لا توجد مراجعات بعد",restore:"استعادة",currentver:"النسخة الحالية",importword:"استيراد من Word…",importfail:"تعذر استيراد هذا الملف. الرجاء اختيار مستند ‎.docx صالح.",restoredraft:"استعادة آخر مسودة",draftempty:"لا توجد مسودة محفوظة",deleteimg:"حذف الصورة",rotateleft:"تدوير لليسار",rotateright:"تدوير لليمين",fliphorizontal:"قلب أفقي",flipvertical:"قلب رأسي",cell:"خلية",row:"صف",column:"عمود",cellprops:"خصائص الخلية…",rowprops:"خصائص الصف…",colprops:"خصائص العمود…",tblheight:"الارتفاع",valign:"محاذاة عمودية",valigntop:"أعلى",valignmiddle:"وسط",valignbottom:"أسفل",fill:"تعبئة",nocell:"انقر داخل خلية جدول أولاً",uploadimg:"رفع من الجهاز",imagelink:"إدراج من رابط",imageurlph:"الصق رابط الصورة…",insertimg:"إدراج",dropimage:"أسقط الصورة هنا",uploading:"جارٍ الرفع…",uploadfailed:"فشل الرفع — انقر لإعادة المحاولة",template:"قوالب",tplimgleft:"صورة يسار، نص يمين",tplimgright:"صورة يمين، نص يسار",tplimgtop:"صورة أعلى، نص أسفل",tplimgcenter:"نص أعلى، صورة وسط",deltemplate:"حذف القالب"}};function gt(m){return Re[m]}const Ze="undo redo | preview print | importword revhistory | fontfamily fontsize | fontsizeincrease fontsizedecrease | bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | link blockquote changecase lineheight wordspacing | removeformat | blocks | ltr rtl | quickimage quicktable template charmap | fullscreen sourcecode",Pe="file edit view insert format tools table help",De=[["Andale Mono","andale mono,times"],["Arial","arial,helvetica,sans-serif"],["Arial Black","arial black,avant garde"],["Book Antiqua","book antiqua,palatino"],["Comic Sans MS","comic sans ms,sans-serif"],["Courier New","courier new,courier"],["Georgia","georgia,palatino"],["Helvetica","helvetica"],["Impact","impact,chicago"],["Oswald","oswald"],["Sakkal Majalla","sakkal majalla"],["Symbol","symbol"],["Tahoma","tahoma,arial,helvetica,sans-serif"],["Terminal","terminal,monaco"],["Times New Roman","times new roman,times"],["Trebuchet MS","trebuchet ms,geneva"],["Verdana","verdana,geneva"],["Webdings","webdings"],["Wingdings","wingdings,zapf dingbats"]],Ne=["8px","9px","10px","11px","12px","14px","16px","18px","20px","24px","28px","32px","36px","48px","72px","96px"],Oe=1,Be=100,Fe=["1","1.15","1.4","1.5","1.75","2","2.5","3"],$e=["1px","2px","4px","6px","8px","12px"],Xt=[["p","para"],["h1","heading1"],["h2","heading2"],["h3","heading3"],["h4","heading4"],["h5","heading5"],["h6","heading6"],["pre","pre"]],_e=["#F76707","#4263EB","#CC5DE8"],je=["#BFEDD2","#FBEEB8","#F8CAC6","#ECCAFA","#C2E0F4","#2DC26B","#F1C40F","#E03E2D","#B96AD9","#3598DB","#169179","#E67E23","#BA372A","#843FA1","#236FA1","#ECF0F1","#CED4D9","#95A5A6","#7E8C8D","#34495E","#000000","#FFFFFF"],We=["©","®","™","§","¶","†","‡","•","…","′","″","‰","°","±","×","÷","≈","≠","≤","≥","∞","µ","√","∑","€","£","¥","¢","←","→","↑","↓","«","»","“","”","‘","’","–","—","؟","،","؛","٪","٭","ـ","٠","١"],L=(m,t)=>`<svg viewBox="${t||"0 0 24 24"}">${m}</svg>`,y=m=>L(`<path class="f" d="${m}"/>`,"0 -960 960 960"),st=(m,t=7.5)=>L('<path d="M10 6h10M10 12h10M10 18h10"/>'+m.map((e,i)=>`<text x="2.5" y="${8.4+i*6}" font-size="${t}" stroke="none" fill="#222f3e" font-family="Arial">${e}</text>`).join("")),h={bold:y("M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"),italic:y("M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"),underline:y("M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"),strikethrough:y("M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z"),undo:y("M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"),redo:y("M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"),ltr:y("M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm0-280v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80ZM680-80l-56-56 64-64H120v-80h568l-64-64 56-56 160 160L680-80Z"),rtl:y("M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm-88 160 64 64-56 56-160-160 160-160 56 56-64 64h568v80H272Zm88-440v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Z"),alignleft:y("M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"),aligncenter:y("M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"),alignright:y("M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"),alignjustify:y("M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"),fullscreen:y("M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z"),clearformatic:y("m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"),numlist:y("M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"),bullist:y("M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z"),chev:L('<path d="M2 3.5 6 7.5 10 3.5"/>',"0 0 12 11"),backcolor:y("M440-80q-33 0-56.5-23.5T360-160v-160H240q-33 0-56.5-23.5T160-400v-280q0-66 47-113t113-47h480v440q0 33-23.5 56.5T720-320H600v160q0 33-23.5 56.5T520-80h-80ZM240-560h480v-200h-40v160h-80v-160h-40v80h-80v-80H320q-33 0-56.5 23.5T240-680v120Zm0 160h480v-80H240v80Zm0 0v-80 80Z"),outdent:y("M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"),indent:y("M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"),image:y("M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"),uploadic:y("M440-200v-326L336-422l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-80q-33 0-56.5-23.5T160-160v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-80H240Z"),tableic:y("M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm240-240H200v160h240v-160Zm80 0v160h240v-160H520Zm-80-80v-160H200v160h240Zm80 0h240v-160H520v160ZM200-680h560v-80H200v80Z"),hric:L('<path d="M4 12h16"/>'),charic:y("M120-120v-120h200q-84-45-132-125t-48-175q0-142 99-241t241-99q142 0 241 99t99 241q0 95-48 175T640-240h200v120H520v-204q78-14 129-75t51-141q0-92-64-156t-156-64q-92 0-156 64t-64 156q0 80 51 141t129 75v204H120Z"),dateic:L('<rect x="4" y="6" width="16" height="14" rx="1.5"/><path d="M4 10h16M8 4v4M16 4v4"/>'),pbic:y("M240-80q-33 0-56.5-23.5T160-160v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-80H240Zm-80-440v-280q0-33 23.5-56.5T240-880h320l240 240v120h-80v-80H520v-200H240v280h-80Zm200 160v-80h240v80H360Zm320 0v-80h240v80H680Zm-640 0v-80h240v80H40Zm440-160Zm0 240Z"),nbspic:L('<path d="M6 12v4h12v-4"/>'),srcic:y("M240-280 40-480l200-200 56 56-143 144 143 144-56 56Zm178 132-76-24 200-640 76 24-200 640Zm302-132-56-56 143-144-143-144 56-56 200 200-200 200Z"),prevw:y("M607.5-372.5Q660-425 660-500t-52.5-127.5Q555-680 480-680t-127.5 52.5Q300-575 300-500t52.5 127.5Q405-320 480-320t127.5-52.5Zm-204-51Q372-455 372-500t31.5-76.5Q435-608 480-608t76.5 31.5Q588-545 588-500t-31.5 76.5Q525-392 480-392t-76.5-31.5ZM214-281.5Q94-363 40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200q-146 0-266-81.5ZM480-500Zm207.5 160.5Q782-399 832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280q113 0 207.5-59.5Z"),printic:y("M640-640v-120H320v120h-80v-200h480v200h-80Zm-480 80h640-640Zm560 100q17 0 28.5-11.5T760-500q0-17-11.5-28.5T720-540q-17 0-28.5 11.5T680-500q0 17 11.5 28.5T720-460Zm-80 260v-160H320v160h320Zm80 80H240v-160H80v-240q0-51 35-85.5t85-34.5h560q51 0 85.5 34.5T880-520v240H720v160Zm80-240v-160q0-17-11.5-28.5T760-560H200q-17 0-28.5 11.5T160-520v160h80v-80h480v80h80Z"),cutic:y("M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-520l-80-80 240-240h120v40L600-520ZM296.5-663.5Q320-687 320-720t-23.5-56.5Q273-800 240-800t-56.5 23.5Q160-753 160-720t23.5 56.5Q207-640 240-640t56.5-23.5ZM494-466q6-6 6-14t-6-14q-6-6-14-6t-14 6q-6 6-6 14t6 14q6 6 14 6t14-6ZM296.5-183.5Q320-207 320-240t-23.5-56.5Q273-320 240-320t-56.5 23.5Q160-273 160-240t23.5 56.5Q207-160 240-160t56.5-23.5Z"),copyic:y("M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"),pasteic:y("M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm308.5-571.5Q520-783 520-800t-11.5-28.5Q497-840 480-840t-28.5 11.5Q440-817 440-800t11.5 28.5Q463-760 480-760t28.5-11.5Z"),selall:y("M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T200-840v80Zm80 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z"),superscriptic:y("M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"),subscriptic:y("M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"),newic:L('<path d="M6 3h8l5 5v13H6z"/><path d="M14 3v5h5"/>'),helpic:L('<circle cx="12" cy="12" r="8.5"/><path d="M9.6 9.6a2.5 2.5 0 1 1 3.4 2.6c-.8.3-1 .9-1 1.8"/><circle class="f" cx="12" cy="16.6" r="1.1"/>'),wcic:L('<path d="M4 6h16M4 10h16M4 14h9"/><path d="M15 17.5l2 2 3.6-4"/>'),rowbefore:y("M200-160h560v-240H200v240Zm640 80H120v-720h160v80h-80v240h560v-240h-80v-80h160v720ZM480-480Zm0 80v-80 80Zm0 0Zm-40-240v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),rowafter:y("M200-560h560v-240H200v240Zm-80 400v-720h720v720H680v-80h80v-240H200v240h80v80H120Zm360-320Zm0-80v80-80Zm0 0ZM440-80v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),rowdelete:y("M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200ZM200-200h560v-560H200ZM200-400v-160h560v160H200ZM330-580l250 250 50-50-250-250ZM330-380l250-250 50 50-250 250Z"),colbefore:y("M800-200v-560H560v560h240Zm-640 80v-160h80v80h240v-560H240v80h-80v-160h720v720H160Zm320-360Zm80 0h-80 80Zm0 0ZM160-360v-80H80v-80h80v-80h80v80h80v80h-80v80h-80Z"),colafter:y("M160-760v560h240v-560H160ZM80-120v-720h720v160h-80v-80H480v560h240v-80h80v160H80Zm400-360Zm-80 0h80-80Zm0 0Zm320 120v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),coldelete:y("M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200ZM200-200h560v-560H200ZM400-200v-560h160v560H400ZM330-580l250 250 50-50-250-250ZM330-380l250-250 50 50-250 250Z"),quote:y("m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92ZM362.5-517.5Q380-535 380-560t-17.5-42.5Q345-620 320-620t-42.5 17.5Q260-585 260-560t17.5 42.5Q295-500 320-500t42.5-17.5Zm360 0Q740-535 740-560t-17.5-42.5Q705-620 680-620t-42.5 17.5Q620-585 620-560t17.5 42.5Q655-500 680-500t42.5-17.5ZM680-560Zm-360 0Z"),link:y("M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"),lineheight:y("M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z"),wordspacing:y("M320-80 160-240l160-160 57 56-64 64h334l-63-64 56-56 160 160L640-80l-57-56 64-64H313l63 64-56 56ZM200-480v-400h80v400h-80Zm240 0v-400h80v400h-80Zm240 0v-400h80v400h-80Z"),caseic:y("m131-252 165-440h79l165 440h-76l-39-112H247l-40 112h-76Zm139-176h131l-64-182h-4l-63 182Zm395 186q-51 0-81-27.5T554-342q0-44 34.5-72.5T677-443q23 0 45 4t38 11v-12q0-29-20.5-47T685-505q-23 0-42 9.5T610-468l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T689-393q-32 0-50 14t-18 37q0 20 16 33t40 13Z"),uppercaseic:y("M660-240v-248l-64 64-56-56 160-160 160 160-56 56-64-64v248h-80Zm-540 0 165-440h79l165 440h-76l-39-113H236l-40 113h-76Zm139-177h131l-65-182h-4l-62 182Z"),lowercaseic:y("M300-240q-51 0-81-27.5T189-340q0-44 34.5-72.5T312-441q23 0 45 4t38 11v-12q0-29-20.5-47T320-503q-23 0-42 9.5T245-466l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T324-391q-32 0-50 14t-18 37q0 20 16 33t40 13Zm388 54L540-400l56-56 64 64v-248h80v248l64-64 56 56-160 160Z"),capitalizeic:y("M344-250v-366H224v-64h308v64H412v366h-68Zm344 10q-44 0-69-25.5T594-336v-162h-54v-58h54v-87h66v87h74v58h-74v148q0 23 10.5 36t28.5 13q9 0 18.5-3.5T736-314v65q-10 5-22 7t-26 2Z"),fontsizeup:y("m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm504 104v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z"),fontsizedown:y("m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm384-16v-80h320v80H600Z"),historyic:y("M480-120q-138 0-240.5-91.5T122-440h82q14 104 92.5 172T480-200q117 0 198.5-81.5T760-480q0-117-81.5-198.5T480-760q-69 0-129 32t-101 88h110v80H120v-240h80v94q51-64 124.5-99T480-840q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-480q0 75-28.5 140.5t-77 114q-48.5 48.5-114 77T480-120Zm112-192L440-464v-216h80v184l128 128-56 56Z"),wordic:L('<path d="M6 3h8l5 5v13H6z"/><path d="M14 3v5h5"/><text x="8" y="17" font-size="8.5" stroke="none" fill="#222f3e" font-family="Arial" font-weight="bold">W</text>'),draftic:y("M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z"),trash:L('<path d="M5 7h14M10 7V5h4v2M7.5 7l1 13h7l1-13"/>'),templateic:L('<rect x="4" y="4" width="16" height="16" rx="1.5"/><rect x="6.5" y="6.5" width="5" height="5" rx=".5"/><path d="M14 7.5h3.5M14 10h3.5M6.5 14h11M6.5 17h11"/>'),tplleft:L('<rect x="3" y="5" width="8" height="8" rx=".8"/><path d="M13.5 6.5H21M13.5 9.5H21M13.5 12.5H21M3 15.5h18M3 18.5h18"/>'),tplright:L('<rect x="13" y="5" width="8" height="8" rx=".8"/><path d="M3 6.5h7.5M3 9.5h7.5M3 12.5h7.5M3 15.5h18M3 18.5h18"/>'),tpltop:L('<rect x="5" y="3" width="14" height="9" rx=".8"/><path d="M3 15h18M3 18h18M3 21h12"/>'),tplcenter:L('<path d="M3 4h18M3 7h18M3 10h12"/><rect x="5" y="12.5" width="14" height="9" rx=".8"/>'),rotateleft:L('<polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>'),rotateright:L('<polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>'),fliphorizontal:L('<path d="M12 3v18"/><path d="M7 8l-4 4 4 4"/><path d="M17 8l4 4-4 4"/>'),flipvertical:L('<path d="M3 12h18"/><path d="M8 7l4-4 4 4"/><path d="M8 17l4 4 4-4"/>'),check:L('<path d="M5 12.5 9.5 17 19 7"/>'),palette:L('<path d="M12 3a9 9 0 1 0 0 18h1.2a2 2 0 0 0 2-2 2 2 0 0 1 2-2H18a3 3 0 0 0 3-3c0-6.1-4.5-11-9-11z"/><circle class="f" cx="7.8" cy="10.2" r="1.3"/><circle class="f" cx="11.6" cy="7.3" r="1.3"/><circle class="f" cx="15.8" cy="9.6" r="1.3"/><circle class="f" cx="9" cy="14.8" r="1.3"/>'),ul_circle:y("M280-600v-80h560v80H280Zm0 160v-80h560v80H280Zm0 160v-80h560v80H280ZM160-600q-17 0-28.5-11.5T120-640q0-17 11.5-28.5T160-680q17 0 28.5 11.5T200-640q0 17-11.5 28.5T160-600Zm0 160q-17 0-28.5-11.5T120-480q0-17 11.5-28.5T160-520q17 0 28.5 11.5T200-480q0 17-11.5 28.5T160-440Zm0 160q-17 0-28.5-11.5T120-320q0-17 11.5-28.5T160-360q17 0 28.5 11.5T200-320q0 17-11.5 28.5T160-280Z"),ul_square:y("M80-160v-160h160v160H80Zm240 0v-160h560v160H320ZM80-400v-160h160v160H80Zm240 0v-160h560v160H320ZM80-640v-160h160v160H80Zm240 0v-160h560v160H320Z"),ol_alpha:st(["a","b","c"]),ol_roman:st(["i","ii","iii"],6.5),ol_alphau:st(["A","B","C"]),ol_romanu:st(["I","II","III"],6.5)},ze=new Set(["p","div","span","br","hr","a","b","strong","i","em","u","s","strike","sub","sup","h1","h2","h3","h4","h5","h6","blockquote","pre","code","ul","ol","li","table","thead","tbody","tfoot","tr","td","th","caption","colgroup","col","img","figure","figcaption","mark"]),Ue=new Set(["text-align","direction","unicode-bidi","font-weight","font-style","text-decoration","text-decoration-line","color","background-color","background","background-image","background-position","background-repeat","background-size","font-size","font-family","line-height","letter-spacing","vertical-align","text-indent","margin","margin-top","margin-bottom","margin-left","margin-right","margin-inline-start","margin-inline-end","padding","padding-top","padding-bottom","padding-left","padding-right","width","height","min-width","max-width","min-height","max-height","border","border-top","border-right","border-bottom","border-left","border-color","border-style","border-width","border-radius","border-collapse","border-spacing","table-layout","float","display","box-sizing","list-style-type","white-space"]),Yt={"*":["dir","lang","colspan","rowspan"],a:["href","target","rel","title"],img:["src","alt","width","height","title"],col:["span","width"],td:["width","valign"],th:["width","valign"],table:["width","cellpadding","cellspacing"]};function ot(m){const t={},e=m.getAttribute&&m.getAttribute("style");return e&&e.split(";").forEach(i=>{const s=i.indexOf(":");s<1||(t[i.slice(0,s).trim().toLowerCase()]=i.slice(s+1).trim())}),t}function Xe(m){return m.replace(/<!--\[if !supportLists\]-->([\s\S]*?)<!--\[endif\]-->/gi,"$1").replace(/<!--\[if !supportLists\]>([\s\S]*?)<!\[endif\]-->/gi,"$1").replace(/<!\[if !supportLists\]>([\s\S]*?)<!\[endif\]>/gi,"$1").replace(/<!--\[if [\s\S]*?<!\[endif\]-->/gi,"").replace(/<!--[\s\S]*?-->/g,"").replace(/<(script|style|xml|title)[\s\S]*?<\/\1>/gi,"").replace(/<\/?(meta|link)[^>]*>/gi,"").replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<\/?(o|v|w|m|st1):[^>]*>/gi,"")}function Ye(m){return/^[0-9]+[\.\)،]/.test(m)?{ordered:!0}:/^[٠-٩۰-۹]+/.test(m)?{ordered:!0,style:"arabic-indic"}:/^[ivxlc]{2,}[\.\)]/.test(m)?{ordered:!0,style:"lower-roman"}:/^[IVXLC]{2,}[\.\)]/.test(m)?{ordered:!0,style:"upper-roman"}:/^[a-z][\.\)]/.test(m)?{ordered:!0,style:"lower-alpha"}:/^[A-Z][\.\)]/.test(m)?{ordered:!0,style:"upper-alpha"}:/^[ء-ي][\.\)،-]/.test(m)?{ordered:!0,style:"arabic-indic"}:{ordered:!1}}function Qe(m){const t=s=>{const r=(s.getAttribute("style")||"")+" "+(s.className||"");return/mso-list\s*:(?!\s*ignore)/i.test(r)||/MsoListParagraph/i.test(r)},e=[];let i=null;Array.from(m.body.querySelectorAll("p")).forEach(s=>{if(!t(s)){i=null;return}const r=s.previousElementSibling;i&&r&&i[i.length-1]===r?i.push(s):(i=[s],e.push(i))}),e.forEach(s=>{const r=[],l=s[0];s.forEach(o=>{var q,M,P;const c=+(((q=(o.getAttribute("style")||"").match(/level(\d+)/i))==null?void 0:q[1])||1),d=Array.from(o.querySelectorAll("span")).find(I=>/mso-list\s*:\s*ignore/i.test(I.getAttribute("style")||"")),u=d?((M=d.textContent)==null?void 0:M.trim())||"":(((P=o.textContent)==null?void 0:P.trim().match(/^\S{1,4}/))||[""])[0],{ordered:v,style:b}=Ye(u);for(d&&d.remove();r.length&&r[r.length-1].level>c;)r.pop();if(!r.length||r[r.length-1].level<c){const I=m.createElement(v?"ol":"ul");if(v&&b&&(I.style.listStyleType=b),r.length){const $=r[r.length-1].list;($.lastElementChild||$).appendChild(I)}else l.parentNode.insertBefore(I,l);r.push({list:I,level:c})}const f=m.createElement("li"),w=ot(o),E=["text-align","direction","unicode-bidi","color","font-size","font-family","background-color"].filter(I=>w[I]).map(I=>I+":"+w[I]).join(";");for(E&&f.setAttribute("style",E),o.getAttribute("dir")&&f.setAttribute("dir",o.getAttribute("dir"));o.firstChild;)f.appendChild(o.firstChild);r[r.length-1].list.appendChild(f),o.remove()})})}function Ve(m){m.querySelectorAll('b[id^="docs-internal-guid"]').forEach(t=>{for(;t.firstChild;)t.parentNode.insertBefore(t.firstChild,t);t.remove()})}function Ge(m){m.querySelectorAll("table").forEach(t=>{const e=t;ot(e)["border-collapse"]||(e.style.borderCollapse="collapse")}),m.querySelectorAll("[align]").forEach(t=>{const e=t,i=e.getAttribute("align").toLowerCase();e.tagName.toLowerCase()==="table"?i==="center"?(e.style.marginLeft=e.style.marginLeft||"auto",e.style.marginRight=e.style.marginRight||"auto"):i==="right"?e.style.marginLeft=e.style.marginLeft||"auto":i==="left"&&(e.style.marginRight=e.style.marginRight||"auto"):["left","right","center","justify"].includes(i)&&(e.style.textAlign=e.style.textAlign||i,Array.from(e.children).forEach(s=>{if(s.tagName.toLowerCase()!=="table")return;const r=s;i==="center"?(r.style.marginLeft=r.style.marginLeft||"auto",r.style.marginRight=r.style.marginRight||"auto"):i==="right"?r.style.marginLeft=r.style.marginLeft||"auto":i==="left"&&(r.style.marginRight=r.style.marginRight||"auto")})),e.removeAttribute("align")}),m.querySelectorAll("center table").forEach(t=>{const e=t;e.style.marginLeft=e.style.marginLeft||"auto",e.style.marginRight=e.style.marginRight||"auto"}),m.querySelectorAll("[bgcolor]").forEach(t=>{const e=t;e.style.backgroundColor=e.style.backgroundColor||e.getAttribute("bgcolor"),e.removeAttribute("bgcolor")})}function nt(m,t){Array.from(m.childNodes).forEach(e=>{if(e.nodeType===Node.COMMENT_NODE){e.remove();return}if(e.nodeType!==Node.ELEMENT_NODE)return;const i=e,s=i.tagName.toLowerCase();if(!ze.has(s)){if(s==="font"){const a=t.createElement("span");i.getAttribute("style")&&a.setAttribute("style",i.getAttribute("style")),i.getAttribute("color")&&(a.style.color=i.getAttribute("color")),i.getAttribute("face")&&(a.style.fontFamily=i.getAttribute("face"));const c=i.getAttribute("size");if(c&&!a.style.fontSize){const d={1:"8pt",2:"10pt",3:"12pt",4:"14pt",5:"18pt",6:"24pt",7:"36pt"};d[c]&&(a.style.fontSize=d[c])}for(;i.firstChild;)a.appendChild(i.firstChild);i.replaceWith(a),nt(a,t);return}for(nt(i,t);i.firstChild;)i.parentNode.insertBefore(i.firstChild,i);i.remove();return}const r=new Set([...Yt["*"]||[],...Yt[s]||[]]);if(Array.from(i.attributes).forEach(a=>{const c=a.name.toLowerCase();c!=="style"&&!r.has(c)&&i.removeAttribute(a.name)}),s==="a"){const a=i.getAttribute("href")||"";/^(https?:|mailto:|tel:|#)/i.test(a)||i.removeAttribute("href")}if(s==="img"){const a=i.getAttribute("src")||"";if(!/^(https?:|data:image\/|blob:)/i.test(a)){const c=t.createElement("span");c.textContent="[local image — paste it separately]",c.setAttribute("style","color:#a33;font-style:italic;font-size:12px"),i.replaceWith(c);return}}const l=ot(i),o=[];for(const[a,c]of Object.entries(l))Ue.has(a)&&(/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(c)||a==="font-weight"&&/^(400|normal)$/i.test(c)||a==="font-style"&&/^normal$/i.test(c)||a==="text-decoration"&&/^none$/i.test(c)||o.push(a+":"+c));if(o.length?i.setAttribute("style",o.join(";")):i.removeAttribute("style"),i.removeAttribute("class"),nt(i,t),s==="span"&&!i.attributes.length){for(;i.firstChild;)i.parentNode.insertBefore(i.firstChild,i);i.remove()}})}function Ke(m){const t=[],e=/<style[^>]*>([\s\S]*?)<\/style>/gi;let i;for(;i=e.exec(m);){let s=i[1].replace(/<!--|-->/g,"").replace(/\/\*[\s\S]*?\*\//g,"");s=s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi,""),s=s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g,"");let r;const l=/([^{}]+)\{([^}]*)\}/g;for(;r=l.exec(s);){const o=r[2].split(";").map(a=>{const c=a.indexOf(":");return c<1?null:[a.slice(0,c).trim().toLowerCase(),a.slice(c+1).trim()]}).filter(a=>!!a&&!!a[1]);o.length&&r[1].split(",").map(a=>a.trim()).filter(a=>a&&!a.startsWith("@")).forEach(a=>t.push({sel:a,decls:o}))}}return t}function Je(m,t){if(!t.length)return;const e=new Map;t.forEach(({sel:i,decls:s})=>{let r;try{r=m.querySelectorAll(i)}catch{return}r.forEach(l=>{let o=e.get(l);o||(o={},e.set(l,o)),s.forEach(([a,c])=>{o[a]=c})})}),e.forEach((i,s)=>{const r=ot(s),l=s.hasAttribute("dir"),o=s.hasAttribute("align"),a=Object.entries(i).filter(([u])=>!(u in r||(u==="direction"||u==="unicode-bidi")&&l||u==="text-align"&&(o||l)||(u==="background"||u==="background-color")&&s.hasAttribute("bgcolor")));if(!a.length)return;const c=a.map(([u,v])=>u+":"+v).join(";"),d=s.getAttribute("style");s.setAttribute("style",d?c+";"+d:c)})}function Kt(m){return m.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g,t=>t.normalize("NFKC"))}function ti(m){const t=m.createTreeWalker(m.body,NodeFilter.SHOW_TEXT,null);let e;for(;e=t.nextNode();)/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue||"")&&(e.nodeValue=Kt(e.nodeValue||""))}function ei(m,t="ltr"){const e=Ke(m),i=new DOMParser().parseFromString(Xe(m),"text/html");Je(i,e),/class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML)&&Qe(i),Ve(i),Ge(i),nt(i.body,i),ti(i);const s=r=>{var l;return r&&r.tagName==="P"&&!((l=r.textContent)!=null&&l.trim())&&!r.querySelector("img,table")};for(;s(i.body.firstElementChild);)i.body.firstElementChild.remove();for(;s(i.body.lastElementChild);)i.body.lastElementChild.remove();return i.body.innerHTML.trim()}function ii(m){const t=Kt(m).replace(/\r/g,""),e=i=>i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return/\n/.test(t)?t.split(/\n{2,}/).map(i=>`<p dir="auto">${e(i).replace(/\n/g,"<br>")||"<br>"}</p>`).join(""):e(t)}function si(m){const t=new DataView(m),e=new Map;let i=-1;for(let o=m.byteLength-22;o>=Math.max(0,m.byteLength-22-65535);o--)if(t.getUint32(o,!0)===101010256){i=o;break}if(i<0)throw new Error("EOCD not found");const s=t.getUint16(i+10,!0);let r=t.getUint32(i+16,!0);const l=new TextDecoder;for(let o=0;o<s&&t.getUint32(r,!0)===33639248;o++){const a=t.getUint16(r+10,!0),c=t.getUint32(r+20,!0),d=t.getUint16(r+28,!0),u=t.getUint16(r+30,!0),v=t.getUint16(r+32,!0),b=t.getUint32(r+42,!0),f=l.decode(new Uint8Array(m,r+46,d));e.set(f,{name:f,method:a,compSize:c,localOffset:b}),r+=46+d+u+v}return e}async function Qt(m,t){const e=new DataView(m,t.localOffset);if(e.getUint32(0,!0)!==67324752)throw new Error("Bad local header");const i=e.getUint16(26,!0),s=e.getUint16(28,!0),r=t.localOffset+30+i+s,l=new Uint8Array(m.slice(r,r+t.compSize));if(t.method===0)return l;if(t.method!==8)throw new Error("Unsupported compression method "+t.method);const o=new Blob([l]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(o).arrayBuffer())}const Vt=m=>m.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),lt=(m,t)=>Array.from(m.children).filter(e=>e.localName===t),Z=(m,...t)=>{let e=m;for(const i of t){if(!e)return null;e=Array.from(e.children).find(s=>s.localName===i)||null}return e},H=(m,t="val")=>{if(!m)return"";for(const e of Array.from(m.attributes))if(e.localName===t)return e.value;return""},rt=(m,t)=>{const e=m?Z(m,t):null;if(!e)return!1;const i=H(e);return i!=="false"&&i!=="0"},Gt={yellow:"#FFFF00",green:"#00FF00",cyan:"#00FFFF",magenta:"#FF00FF",blue:"#0000FF",red:"#FF0000",darkBlue:"#00008B",darkCyan:"#008B8B",darkGreen:"#006400",darkMagenta:"#8B008B",darkRed:"#8B0000",darkYellow:"#808000",darkGray:"#A9A9A9",lightGray:"#D3D3D3",black:"#000000",white:"#FFFFFF"},ri={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",webp:"image/webp"};function ni(m){let t="";for(let e=0;e<m.length;e+=32768)t+=String.fromCharCode(...m.subarray(e,e+32768));return btoa(t)}class li{constructor(t,e,i){this.rels=t,this.images=e,this.numFmt=i}convertBody(t){let e="",i=[];const s=r=>{for(;i.length>r;)e+=`</${i.pop()}>`};for(const r of Array.from(t.children))if(r.localName==="p"){const l=this.paraList(r);if(l){const o=l.ilvl+1;for(;i.length>o;)e+=`</${i.pop()}>`;for(i.length===o&&i[o-1]!==l.type&&(e+=`</${i.pop()}>`);i.length<o;)e+=`<${l.type}>`,i.push(l.type);e+=`<li>${this.runsOf(r)||"<br>"}</li>`;continue}s(0),e+=this.convertPara(r)}else r.localName==="tbl"?(s(0),e+=this.convertTable(r)):r.localName;return s(0),e||"<p><br></p>"}paraList(t){const e=Z(t,"pPr","numPr");if(!e)return null;const i=H(Z(e,"numId"));if(!i||i==="0")return null;const s=parseInt(H(Z(e,"ilvl"))||"0",10)||0;return{type:this.numFmt.get(i)||"ul",ilvl:Math.min(s,8)}}convertPara(t){const e=Z(t,"pPr"),i=H(Z(t,"pPr","pStyle"));let s="p";const r=/^Heading([1-6])$/i.exec(i);r?s="h"+r[1]:/^Title$/i.test(i)&&(s="h1");const l=[],o=H(Z(t,"pPr","jc"));o==="center"?l.push("text-align:center"):o==="right"||o==="end"?l.push("text-align:right"):(o==="both"||o==="distribute")&&l.push("text-align:justify"),e&&Z(e,"bidi")&&l.push("direction:rtl");const a=this.runsOf(t),c=l.length?` style="${l.join(";")}"`:"";return`<${s}${c}>${a||"<br>"}</${s}>`}runsOf(t){let e="";for(const i of Array.from(t.children))if(i.localName==="r")e+=this.convertRun(i);else if(i.localName==="hyperlink"){let s=this.rels.get(H(i,"id"))||"";const r=H(i,"anchor");!s&&r&&(s="#"+r);const l=this.runsOf(i);e+=s?`<a href="${Vt(s)}">${l}</a>`:l}else(i.localName==="smartTag"||i.localName==="ins")&&(e+=this.runsOf(i));return e}convertRun(t){const e=Z(t,"rPr");let i="";for(const u of Array.from(t.children))u.localName==="t"?i+=Vt(u.textContent||""):u.localName==="br"||u.localName==="cr"?i+="<br>":u.localName==="tab"?i+="&emsp;":(u.localName==="drawing"||u.localName==="pict"||u.localName==="object")&&(i+=this.convertImage(u));if(!i)return"";const s=[],r=H(e?Z(e,"color"):null);r&&r!=="auto"&&s.push("color:#"+r);const l=H(e?Z(e,"highlight"):null);l&&Gt[l]&&s.push("background-color:"+Gt[l]);const o=parseFloat(H(e?Z(e,"sz"):null));o&&s.push("font-size:"+Math.round(o/2*(4/3))+"px");const a=e?Z(e,"rFonts"):null,c=H(a,"ascii")||H(a,"cs");c&&s.push(`font-family:'${c}'`),s.length&&(i=`<span style="${s.join(";")}">${i}</span>`),rt(e,"b")&&(i=`<strong>${i}</strong>`),rt(e,"i")&&(i=`<em>${i}</em>`),rt(e,"u")&&H(Z(e,"u"))!=="none"&&(i=`<u>${i}</u>`),rt(e,"strike")&&(i=`<s>${i}</s>`);const d=H(e?Z(e,"vertAlign"):null);return d==="superscript"?i=`<sup>${i}</sup>`:d==="subscript"&&(i=`<sub>${i}</sub>`),i}convertImage(t){let e="",i=0;const s=o=>{if(o.localName==="blip"&&(e=e||H(o,"embed")||H(o,"link")),o.localName==="imagedata"&&(e=e||H(o,"id")),o.localName==="extent"){const a=parseFloat(o.getAttribute("cx")||"0");a&&(i=Math.round(a/9525))}for(const a of Array.from(o.children))s(a)};if(s(t),!e)return"";const r=this.images.get(e);if(!r)return"";const l=i?` width="${i}"`:"";return`<img src="${r}" alt=""${l}>`}convertTable(t){let e='<table style="border-collapse:collapse;width:100%"><tbody>';for(const i of lt(t,"tr")){e+="<tr>";for(const s of lt(i,"tc")){const r=parseInt(H(Z(s,"tcPr","gridSpan"))||"1",10)||1,l=r>1?` colspan="${r}"`:"";let o="";for(const a of Array.from(s.children))a.localName==="p"?o+=this.convertPara(a):a.localName==="tbl"&&(o+=this.convertTable(a));e+=`<td style="border:1px solid #b9c2cc"${l}>${o||"<br>"}</td>`}e+="</tr>"}return e+"</tbody></table>"}}async function oi(m){const t=m instanceof ArrayBuffer?m:await m.arrayBuffer(),e=si(t),i=new TextDecoder,s=async f=>{const w=e.get(f);return w?new DOMParser().parseFromString(i.decode(await Qt(t,w)),"application/xml"):null},r=await s("word/document.xml"),l=r==null?void 0:r.getElementsByTagName("*");let o=null;if(l){for(const f of Array.from(l))if(f.localName==="body"){o=f;break}}if(!o)throw new Error("word/document.xml missing or invalid");const a=new Map,c=new Map,d=await s("word/_rels/document.xml.rels");if(d)for(const f of Array.from(d.getElementsByTagName("*"))){if(f.localName!=="Relationship")continue;const w=f.getAttribute("Id")||"",E=f.getAttribute("Target")||"",q=f.getAttribute("Type")||"";/hyperlink/i.test(q)?a.set(w,E):/image/i.test(q)&&c.set(w,E)}const u=new Map;for(const[f,w]of c){const E=w.startsWith("/")?w.slice(1):"word/"+w.replace(/^\.\//,""),q=e.get(E);if(!q)continue;const M=(E.split(".").pop()||"").toLowerCase(),P=ri[M];if(P)try{u.set(f,`data:${P};base64,${ni(await Qt(t,q))}`)}catch{}}const v=new Map,b=await s("word/numbering.xml");if(b){const f=new Map,w=Array.from(b.getElementsByTagName("*"));for(const E of w){if(E.localName!=="abstractNum")continue;const q=H(E,"abstractNumId"),M=lt(E,"lvl").find(I=>H(I,"ilvl")==="0")||lt(E,"lvl")[0],P=M?H(Z(M,"numFmt")):"";f.set(q,P==="bullet"?"ul":"ol")}for(const E of w){if(E.localName!=="num")continue;const q=H(E,"numId"),M=H(Z(E,"abstractNumId"));v.set(q,f.get(M)||"ul")}}return new li(a,u,v).convertBody(o)}const ai=["nw","ne","sw","se"],vt=["img-left","img-right","img-top","img-center"],bt={"img-left":"tplimgleft","img-right":"tplimgright","img-top":"tplimgtop","img-center":"tplimgcenter"},ci={"img-left":h.tplleft,"img-right":h.tplright,"img-top":h.tpltop,"img-center":h.tplcenter};var z;let hi=(z=class{constructor(t){this.lang="en",this.contentClass="fable-content-"+z.instanceCounter++,this.contentStyleEl=null,this.savedRange=null,this.foreColor="#000000",this.backColor="#FACC15",this.openPop=null,this.openSubEl=null,this.popAnchor=null,this.dlgOvl=null,this.tblActive=null,this.tblCorner=null,this.tblColBars=[],this.tblCtx=null,this.tblCellMark=null,this.tblOpMark=null,this.tblOpMarkKind=null,this.imgActive=null,this.imgHandles=[],this.imgCtx=null,this.imgHideTimer=null,this.phActive=null,this.phCtx=null,this.phUploadTarget=null,this.selCtx=null,this.tplActive=null,this.tplCtx=null,this.revisions=[],this.revTimer=null,this.draftTimer=null,this.draftStorageKey="",this.listeners=[],this.isDestroyed=!1,this.options={target:t.target,language:t.language||"en",height:t.height??302,initialContent:t.initialContent??"<p><br></p>",onChange:t.onChange||(()=>{}),onReady:t.onReady||(()=>{}),menubar:t.menubar??!0,toolbar:t.toolbar??!0,statusbar:t.statusbar??!0,readonly:t.readonly??!1,draftKey:t.draftKey??(typeof location<"u"?location.pathname:"default"),fontFamilyFormats:t.fontFamilyFormats??De,imageFileTypes:t.imageFileTypes??["image/jpeg","image/jpg","image/png","image/gif","image/bmp","image/webp"]},this.imageUploadHandler=t.imageUploadHandler,this.onImageUploadError=t.onImageUploadError,this.contentStyle=t.contentStyle,this.lang=this.options.language,this.draftStorageKey="tmclone-draft:"+this.options.draftKey,this.initDOM(),this.bindEvents(),this.initUI(),this.recordRevision(),this.options.onReady(this)}t(t){const e=gt(this.lang)[t];return typeof e=="string"?e:e.join(",")}tArr(t){return gt(this.lang)[t]}dir(){return gt(this.lang).dir}initDOM(){const t=this.options.target;t.innerHTML="",t.classList.add("tox-root"),this.shell=document.createElement("div"),this.shell.className="tox",this.menubar=document.createElement("div"),this.menubar.className="mnb",this.toolbar=document.createElement("div"),this.toolbar.className="tbr",this.ed=document.createElement("div"),this.ed.className="earea "+this.contentClass,this.ed.setAttribute("contenteditable",(!this.options.readonly).toString()),this.ed.spellcheck=!0,this.ed.innerHTML=this.options.initialContent,this.ed.style.height=this.options.height+"px",this.statusbar=document.createElement("div"),this.statusbar.className="sbar",this.statusbar.innerHTML=`
31
31
  <span class="mid"></span>
32
32
  <span class="words"></span>
33
33
  <span class="grip">
34
34
  <svg viewBox="0 0 12 12"><path d="M11 1 1 11M11 6 6 11M11 11h0"/></svg>
35
35
  </span>
36
- `,this.sbHelp=this.statusbar.querySelector(".mid"),this.sbWords=this.statusbar.querySelector(".words");const e=this.statusbar.querySelector(".grip");this.bindGrip(e),this.shell.appendChild(this.menubar),this.shell.appendChild(this.toolbar),this.shell.appendChild(this.ed),this.shell.appendChild(this.statusbar),this.contentStyle&&(this.contentStyleEl=document.createElement("style"),this.contentStyleEl.textContent=this.scopeContentStyle(this.contentStyle),this.shell.appendChild(this.contentStyleEl)),t.appendChild(this.shell),this.options.statusbar||(this.statusbar.style.display="none"),this.imgInput=document.createElement("input"),this.imgInput.type="file",this.imgInput.accept=this.options.imageFileTypes.join(","),this.imgInput.style.display="none",t.appendChild(this.imgInput),this.docInput=document.createElement("input"),this.docInput.type="file",this.docInput.accept=".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",this.docInput.style.display="none",t.appendChild(this.docInput)}scopeContentStyle(t){return t.replace(/\bbody\b/g,"."+this.contentClass)}bindGrip(t){let e=0,i=0;const s=r=>{e=r.clientY,i=this.ed.offsetHeight,r.preventDefault();const l=a=>{this.ed.style.height=Math.max(120,i+a.clientY-e)+"px"},o=()=>{window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",l),window.addEventListener("mouseup",o)};t.addEventListener("mousedown",s),this.listeners.push(()=>t.removeEventListener("mousedown",s))}bindEvents(){this.onDoc("mousedown",t=>{this.openPop&&!this.openPop.contains(t.target)&&!this.popAnchor.contains(t.target)&&!(this.openSubEl&&this.openSubEl.contains(t.target))&&this.closePop()}),this.onDoc("keydown",t=>{t.key==="Escape"&&(this.closePop(),this.closeDlg())}),this.onDoc("selectionchange",()=>{const t=window.getSelection();t&&this.ed.contains(t.anchorNode)?(this.saveSel(),this.refreshState(),this.updateSelToolbar(t),this.positionCellMarker()):this.clearSelToolbar()}),this.on(this.ed,"input",()=>{this.refreshState(),this.onChange(),this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx()}),this.on(this.ed,"keydown",t=>{t.altKey&&t.key==="0"&&(t.preventDefault(),this.helpDlg())}),this.on(this.ed,"paste",t=>this.handlePaste(t)),this.on(this.ed,"drop",t=>{var s,r,l;t.preventDefault();const e=(r=(s=t.target).closest)==null?void 0:r.call(s,".img-ph");if(!e||!this.ed.contains(e)||this.options.readonly)return;const i=Array.from(((l=t.dataTransfer)==null?void 0:l.files)||[]).find(o=>o.type.startsWith("image/"));i&&this.readImageFileInto(i,e)}),this.on(this.ed,"dragover",t=>t.preventDefault()),this.on(this.ed,"mousedown",t=>{var l,o,a;const e=t.target,i=(l=e.closest)==null?void 0:l.call(e,"table");i&&this.ed.contains(i)?this.selectTableForResize(i):this.clearTableHandles();const s=(o=e.closest)==null?void 0:o.call(e,".img-ph");s&&this.ed.contains(s)&&!this.options.readonly?(t.preventDefault(),this.selectImgPlaceholder(s)):this.clearImgPlaceholderSel();const r=(a=e.closest)==null?void 0:a.call(e,"img");r&&this.ed.contains(r)&&!this.options.readonly?(t.preventDefault(),this.selectImage(r)):this.clearImageHandles()}),this.on(this.ed,"mouseover",t=>{var i,s;if(this.options.readonly)return;const e=(s=(i=t.target).closest)==null?void 0:s.call(i,"img");e&&this.ed.contains(e)&&(this.cancelImgHide(),this.selectImage(e))}),this.on(this.ed,"mouseout",t=>{var s,r,l,o;const e=(r=(s=t.target).closest)==null?void 0:r.call(s,"img");if(!e)return;const i=t.relatedTarget;i&&((l=this.imgCtx)!=null&&l.contains(i)||this.imgHandles.some(a=>a.contains(i))||((o=i.closest)==null?void 0:o.call(i,"img"))===e)||this.scheduleImgHide()}),this.on(this.ed,"scroll",()=>{this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx()}),this.onWin("scroll",()=>{this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.repositionSelToolbar()},!0),this.onWin("resize",()=>{this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.repositionSelToolbar()}),this.on(this.imgInput,"change",()=>{var s;const t=(s=this.imgInput.files)==null?void 0:s[0];if(!t)return;const e=this.phUploadTarget;if(this.phUploadTarget=null,e&&this.ed.contains(e)){this.readImageFileInto(t,e);return}const i=new FileReader;i.onload=()=>{this.restoreSel(),document.execCommand("insertHTML",!1,`<img src="${i.result}" title="${t.name.replace(/"/g,"")}" alt="">`),this.onChange()},i.readAsDataURL(t)}),this.on(this.docInput,"change",()=>{var e;const t=(e=this.docInput.files)==null?void 0:e[0];t&&this.importWordFile(t).catch(()=>alert(this.t("importfail")))}),this.onDoc("mousedown",t=>{this.ed.contains(t.target)||t.target===this.tblCorner||this.tblColBars.includes(t.target)||this.tblCtx&&this.tblCtx.contains(t.target)||this.imgHandles.includes(t.target)||this.imgCtx&&this.imgCtx.contains(t.target)||this.phCtx&&this.phCtx.contains(t.target)||this.selCtx&&this.selCtx.contains(t.target)||this.openPop&&this.openPop.contains(t.target)||this.openSubEl&&this.openSubEl.contains(t.target)||(this.clearTableHandles(),this.clearImageHandles(),this.clearImgPlaceholderSel(),this.clearSelToolbar())})}on(t,e,i){t.addEventListener(e,i),this.listeners.push(()=>t.removeEventListener(e,i))}onDoc(t,e){document.addEventListener(t,e),this.listeners.push(()=>document.removeEventListener(t,e))}onWin(t,e,i){window.addEventListener(t,e,i),this.listeners.push(()=>window.removeEventListener(t,e,i))}getContent(){return this.ed.innerHTML}setContent(t){this.ed.innerHTML=t||"<p><br></p>",this.refreshState(),this.clearTableHandles(),this.clearImageHandles(),this.clearImgPlaceholderSel(),this.clearSelToolbar(),this.onChange()}insertContent(t){this.restoreSel(),document.execCommand("insertHTML",!1,t),this.saveSel(),this.refreshState(),this.onChange()}setLanguage(t){this.lang=t,this.initUI()}focus(){this.ed.focus()}async importWordFile(t){const e=await ni(t);this.recordRevision(),this.setContent(e),this.recordRevision()}restoreDraft(){let t=null;try{t=localStorage.getItem(this.draftStorageKey)}catch{}if(!t)return!1;try{const e=JSON.parse(t);return e.html?(this.recordRevision(),this.setContent(e.html),!0):!1}catch{return!1}}getRevisions(){return this.revisions.slice()}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.revTimer!=null&&window.clearTimeout(this.revTimer),this.draftTimer!=null&&window.clearTimeout(this.draftTimer),this.closePop(),this.closeDlg(),this.clearTableHandles(),this.clearImageHandles(),this.clearImgPlaceholderSel(),this.clearSelToolbar(),this.listeners.forEach(t=>t()),this.listeners=[],this.shell&&this.shell.parentNode&&this.shell.parentNode.removeChild(this.shell),this.imgInput&&this.imgInput.parentNode&&this.imgInput.parentNode.removeChild(this.imgInput),this.docInput&&this.docInput.parentNode&&this.docInput.parentNode.removeChild(this.docInput),this.contentStyleEl=null)}saveSel(){const t=window.getSelection();t&&t.rangeCount&&this.ed.contains(t.anchorNode)&&(this.savedRange=t.getRangeAt(0).cloneRange())}restoreSel(){if(!this.savedRange){this.ed.focus();return}this.ed.focus();const t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(this.savedRange))}exec(t,e){this.restoreSel(),document.execCommand("styleWithCSS",!1,t!=="fontSize"?"true":"false"),document.execCommand(t,!1,e??void 0),this.saveSel(),this.refreshState(),this.onChange()}closestBlock(t){for(;t&&t!==this.ed;){if(t.nodeType===1&&/^(P|DIV|H[1-6]|LI|PRE|BLOCKQUOTE|TD|TH)$/i.test(t.tagName))return t;t=t.parentNode}return null}selectedBlocks(){const t=window.getSelection();if(!t||!t.rangeCount||!this.ed.contains(t.anchorNode))return[];const e=t.getRangeAt(0),i=Array.from(this.ed.querySelectorAll("p,h1,h2,h3,h4,h5,h6,li,pre,blockquote,td,th")).filter(s=>e.intersectsNode(s));if(!i.length){const s=this.closestBlock(t.anchorNode);if(s)return[s]}return i}onChange(){this.options.onChange(this.ed.innerHTML),this.scheduleRevision(),this.scheduleDraftSave()}recordRevision(){const t=this.ed.innerHTML,e=this.revisions[this.revisions.length-1];e&&e.html===t||(this.revisions.push({time:Date.now(),html:t}),this.revisions.length>30&&this.revisions.shift())}scheduleRevision(){this.revTimer!=null&&window.clearTimeout(this.revTimer),this.revTimer=window.setTimeout(()=>{this.revTimer=null,this.recordRevision()},1500)}scheduleDraftSave(){this.draftTimer!=null&&window.clearTimeout(this.draftTimer),this.draftTimer=window.setTimeout(()=>{this.draftTimer=null;try{localStorage.setItem(this.draftStorageKey,JSON.stringify({time:Date.now(),html:this.ed.innerHTML}))}catch{}},800)}revisionDlg(){this.recordRevision(),this.dialog(this.t("revhistory"),t=>{if(!this.revisions.length){t.innerHTML=`<p style="color:#556">${this.t("revempty")}</p>`;return}const e=document.createElement("div");e.className="revwrap";const i=document.createElement("div");i.className="revlist";const s=document.createElement("div");s.className="revprev";const r=document.createElement("button");r.type="button",r.className="revrestore",r.textContent=this.t("restore");let l=this.revisions.length-1;const o=new Intl.DateTimeFormat(this.lang==="ar"?"ar-AE":"en-GB",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),a={},c=d=>{l=d,this.revisions.forEach((u,v)=>{var b;return(b=a[v])==null?void 0:b.classList.toggle("on",v===d)}),s.innerHTML=this.revisions[d].html,r.disabled=d===this.revisions.length-1};for(let d=this.revisions.length-1;d>=0;d--){const u=this.revisions[d],v=document.createElement("button");v.type="button";const b=(new DOMParser().parseFromString(u.html,"text/html").body.textContent||"").trim(),f=b?b.split(/\s+/).length:0,w=d===this.revisions.length-1;v.innerHTML=`<span>${w?this.t("currentver"):o.format(new Date(u.time))}</span><span class="wc">${f} ${this.t("words")}</span>`,v.addEventListener("click",()=>c(d)),a[d]=v,i.appendChild(v)}i.append(r),r.addEventListener("click",()=>{const d=this.revisions[l];d&&(this.recordRevision(),this.setContent(d.html),this.recordRevision(),this.closeDlg())}),e.append(i,s),t.appendChild(e),c(l)})}closeSub(){var t;(t=this.openSubEl)==null||t.remove(),this.openSubEl=null}closePop(){var t;this.closeSub(),this.openPop&&(this.openPop.remove(),this.openPop=null,(t=this.popAnchor)==null||t.classList.remove("open"),this.popAnchor=null,this.setOpTarget(null))}openSubFor(t,e){this.closeSub();const i=document.createElement("div");i.className="pop sub",i.dir=this.dir(),t.subBuild?t.subBuild(i):t.sub&&this.menuItems(i,t.sub),i.addEventListener("mousedown",a=>{a.target.tagName!=="INPUT"&&a.preventDefault()}),document.body.appendChild(i);const s=e.getBoundingClientRect();let l=this.dir()==="rtl"?s.left-i.offsetWidth+2:s.right-2;l=Math.max(8,Math.min(l+scrollX,scrollX+innerWidth-i.offsetWidth-8));let o=s.top+scrollY-6;o=Math.max(8+scrollY,Math.min(o,scrollY+innerHeight-i.offsetHeight-8)),i.style.left=l+"px",i.style.top=o+"px",this.openSubEl=i}popup(t,e){if(this.openPop&&this.popAnchor===t){this.closePop();return}this.closePop();const i=document.createElement("div");i.className="pop",i.dir=this.dir(),e(i),document.body.appendChild(i);const s=t.getBoundingClientRect();i.style.minWidth=Math.max(160,Math.round(s.width))+"px",i.style.top=s.bottom+scrollY+2+"px";let l=this.dir()==="rtl"?s.right-i.offsetWidth:s.left;l=Math.max(8,Math.min(l+scrollX,scrollX+innerWidth-i.offsetWidth-8)),i.style.left=l+"px",i.addEventListener("mousedown",o=>{o.target.tagName!=="INPUT"&&o.preventDefault()}),this.openPop=i,this.popAnchor=t,t.classList.add("open")}menuItems(t,e){e.forEach(i=>{if(i==="|"){t.insertAdjacentHTML("beforeend",'<div class="sep"></div>');return}const s=!!(i.sub||i.subBuild),r=document.createElement("button");r.className="mi"+(i.on?" on":""),r.innerHTML=`<span class="ic">${i.icon||""}</span><span class="prev" ${i.previewStyle?`style="${i.previewStyle}"`:""}>${i.label}</span>${i.shortcut?`<span class="sc">${i.shortcut}</span>`:""}${s?`<span class="subarrow">${h.chev}</span>`:""}`,r.addEventListener("click",()=>{i.action&&(this.closePop(),i.action())}),r.addEventListener("mouseenter",()=>{var l;s?this.openSubFor(i,r):this.openSubEl&&t!==this.openSubEl&&this.closeSub(),(l=i.hover)==null||l.call(i,!0)}),r.addEventListener("mouseleave",()=>{var l;return(l=i.hover)==null?void 0:l.call(i,!1)}),t.appendChild(r)})}tbtn(t,e,i,s){const r=document.createElement("button");return r.className="tbtn",r.type="button",r.title=e,r.innerHTML=t,s&&(r.dataset.id=s),r.addEventListener("mousedown",l=>l.preventDefault()),r.addEventListener("click",i),r}stepBtn(t){const e=t>0?"+":"−",i=t>0?h.fontsizeup:h.fontsizedown,s=this.tbtn(i,this.t("fontsize")+" "+e,()=>this.stepFontSize(t));return s.addEventListener("mousedown",()=>this.saveSel()),s}menuTbtn(t,e,i,s){const r=this.tbtn(t,e,()=>i(r),s);return r.classList.add("hasmenu"),r.insertAdjacentHTML("beforeend",h.chev),r.addEventListener("mousedown",()=>this.saveSel()),r}colorChips(){const t=s=>{const r=document.createElement("button");return r.type="button",r.className="cchip",r.title=s,r.addEventListener("mousedown",l=>{l.preventDefault(),this.saveSel()}),r},e=Fe.map(s=>{const r=t(this.t("forecolor"));return r.style.background=s,r.addEventListener("click",()=>this.applyColor("fore",s)),r}),i=t(this.t("forecolor"));return i.classList.add("more"),i.dataset.cb="fore",i.innerHTML=h.chev,i.addEventListener("click",()=>this.colorMenu(i,"fore")),[...e,i]}group(...t){const e=document.createElement("div");return e.className="tgrp",t.forEach(i=>{i.classList.add("gbtn"),e.appendChild(i)}),e}tsel(t,e,i,s){const r=document.createElement("button");return r.className="tsel "+t,r.type="button",r.dataset.id=e,r.innerHTML=`<span class="lbl empty">${i||""}</span>${h.chev}`,r.addEventListener("mousedown",l=>{l.preventDefault(),this.saveSel()}),r.addEventListener("click",()=>s(r)),r}setListStyle(t,e){var r,l;this.restoreSel();const i=window.getSelection();if(!i)return;let s=(r=this.closestBlock(i.anchorNode))==null?void 0:r.closest(t);s||(this.exec(t==="ol"?"insertOrderedList":"insertUnorderedList"),s=(l=this.closestBlock(i.anchorNode))==null?void 0:l.closest(t)),s&&(s.style.listStyleType=e),this.saveSel(),this.onChange()}listMenu(t,e){var c;const i=e==="ol"?"insertOrderedList":"insertUnorderedList",s=e==="ol"?[["lower-alpha",h.ol_alpha],["lower-roman",h.ol_roman],["upper-alpha",h.ol_alphau],["upper-roman",h.ol_romanu]]:[["circle",h.ul_circle],["square",h.ul_square]],r=this.tArr(e==="ol"?"liststyles_ol":"liststyles_ul").slice(1),l=window.getSelection(),o=l?(c=this.closestBlock(l.anchorNode))==null?void 0:c.closest(e):null,a=o?o.style.listStyleType:"";this.popup(t,d=>{this.menuItems(d,[{label:this.t(e==="ol"?"numlist":"bullist"),icon:e==="ol"?h.numlist:h.bullist,on:document.queryCommandState(i),action:()=>this.exec(i)}]),d.insertAdjacentHTML("beforeend",'<div class="sep"></div>');const u=document.createElement("div");u.className="mi-grid",s.forEach(([v,b],f)=>{const w=document.createElement("button");w.className="mi"+(a===v?" on":""),w.innerHTML=`<span class="ic">${b}</span><span class="prev">${r[f]}</span>`,w.addEventListener("click",()=>{this.closePop(),this.setListStyle(e,v)}),u.appendChild(w)}),d.appendChild(u)})}colorMenu(t,e){this.popup(t,i=>{const s=document.createElement("div");s.className="cpal",_e.forEach(u=>{const v=document.createElement("button");v.style.background=u,v.title=u,v.addEventListener("click",()=>{this.closePop(),this.applyColor(e,u)}),s.appendChild(v)}),i.appendChild(s),i.insertAdjacentHTML("beforeend",'<div class="sep"></div>');const r=document.createElement("div");r.className="cfoot";const l=document.createElement("div");l.className="cswatch cur",l.title=this.t("currentcolor");const o=e==="fore"?this.foreColor:this.backColor;l.style.background=/^#[0-9a-f]{6}$/i.test(o)?o:"#000000",l.innerHTML=h.check;const a=document.createElement("button");a.type="button",a.className="cswatch nocolor",a.title=this.t("removecolor"),a.addEventListener("click",()=>{this.closePop(),this.applyColor(e,null)});const c=document.createElement("label");c.className="cswatch cwheel",c.title=this.t("customcolor"),c.innerHTML=h.palette;const d=document.createElement("input");d.type="color",d.value=/^#[0-9a-f]{6}$/i.test(o)?o:"#000000",d.addEventListener("change",()=>{this.closePop(),this.applyColor(e,d.value)}),c.appendChild(d),r.append(l,a,c),i.appendChild(r)})}applyColor(t,e){t==="fore"?(this.foreColor=e||"#000000",this.exec("foreColor",e||"#000000")):(this.backColor=e||"transparent",this.exec("hiliteColor",e||"transparent")),this.syncColorSwatches(this.toolbar),this.selCtx&&this.syncColorSwatches(this.selCtx)}syncColorSwatches(t){t.querySelectorAll("[data-cb=fore]").forEach(e=>e.style.background=this.foreColor),t.querySelectorAll("[data-cb=back]").forEach(e=>e.style.background=this.backColor)}fontMenu(t){this.popup(t,e=>{this.menuItems(e,this.options.fontFamilyFormats.map(([i,s])=>({label:i,previewStyle:`font-family:${s}`,on:this.currentFont()===i,action:()=>this.exec("fontName",s)})))})}sizeMenu(t){this.popup(t,e=>{this.menuItems(e,De.map(i=>({label:i,on:this.currentSize()===i,action:()=>this.applyFontSize(i)})))})}ensureSizeTarget(){const t=window.getSelection();if(!t)return;if(!t.rangeCount){const l=document.createRange();l.selectNodeContents(this.ed),l.collapse(!0),t.addRange(l)}if(!t.isCollapsed)return;const e=t.getRangeAt(0),i=e.startContainer;if(i.nodeType===3){const l=i.data;let o=e.startOffset,a=e.startOffset;for(;o>0&&/\S/.test(l[o-1]);)o--;for(;a<l.length&&/\S/.test(l[a]);)a++;if(a>o){const c=document.createRange();c.setStart(i,o),c.setEnd(i,a),t.removeAllRanges(),t.addRange(c),this.savedRange=c.cloneRange();return}}const s=document.createTextNode("​");e.insertNode(s);const r=document.createRange();r.setStart(s,0),r.setEnd(s,1),t.removeAllRanges(),t.addRange(r),this.savedRange=r.cloneRange()}applyFontSize(t){this.restoreSel(),this.ensureSizeTarget(),document.execCommand("styleWithCSS",!1,"false"),document.execCommand("fontSize",!1,"7");const e=[];if(this.ed.querySelectorAll('font[size="7"]').forEach(i=>{const s=document.createElement("span");for(s.style.fontSize=t;i.firstChild;)s.appendChild(i.firstChild);i.replaceWith(s),e.push(s)}),e.length){const i=document.createRange();i.setStart(e[0],0),i.setEnd(e[e.length-1],e[e.length-1].childNodes.length);const s=window.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}this.saveSel(),this.refreshState(),this.onChange()}stepFontSize(t){const e=parseInt(this.currentSize(),10)||14,i=Math.min(Ne,Math.max(Pe,e+t));i!==e&&this.applyFontSize(i+"px")}transformCase(t){this.restoreSel();const e=window.getSelection();if(!e||!e.rangeCount||e.isCollapsed)return;const i=e.getRangeAt(0),s=document.createTreeWalker(this.ed,NodeFilter.SHOW_TEXT),r=[];let l;for(;l=s.nextNode();)i.intersectsNode(l)&&r.push(l);r.forEach(o=>{const a=o===i.startContainer?i.startOffset:0,c=o===i.endContainer?i.endOffset:o.data.length;if(c<=a)return;const d=o.data.slice(a,c);let u=d;t==="lower"?u=d.toLowerCase():t==="upper"?u=d.toUpperCase():u=d.replace(/(^|\s)(\S)/g,(v,b,f)=>b+f.toUpperCase()),o.replaceData(a,c-a,u)}),this.saveSel(),this.refreshState(),this.onChange()}caseMenu(t){this.popup(t,e=>{this.menuItems(e,[{label:this.t("lowercase"),icon:h.lowercaseic,action:()=>this.transformCase("lower")},{label:this.t("uppercase"),icon:h.uppercaseic,action:()=>this.transformCase("upper")},{label:this.t("capitalize"),icon:h.capitalizeic,action:()=>this.transformCase("capitalize")}])})}applyBlockStyle(t,e){this.restoreSel(),this.selectedBlocks().forEach(s=>{e?s.style[t]=e:s.style.removeProperty(t==="lineHeight"?"line-height":"word-spacing")}),this.saveSel(),this.onChange()}currentBlockStyle(t){const e=window.getSelection(),i=e?this.closestBlock(e.anchorNode):null;return i&&i.style[t]||""}lineHeightMenu(t){const e=this.currentBlockStyle("lineHeight");this.popup(t,i=>{this.menuItems(i,[{label:this.t("normal"),on:!e,action:()=>this.applyBlockStyle("lineHeight","")},...Oe.map(s=>({label:s,on:e===s,action:()=>this.applyBlockStyle("lineHeight",s)}))])})}wordSpacingMenu(t){const e=this.currentBlockStyle("wordSpacing");this.popup(t,i=>{this.menuItems(i,[{label:this.t("normal"),on:!e,action:()=>this.applyBlockStyle("wordSpacing","")},...Be.map(s=>({label:s,on:e===s,action:()=>this.applyBlockStyle("wordSpacing",s)}))])})}closestAnchor(){const t=window.getSelection();let e=t&&this.ed.contains(t.anchorNode)?t.anchorNode:null;for(;e&&e!==this.ed;){if(e.nodeType===1&&e.tagName==="A")return e;e=e.parentNode}return null}linkDlg(){this.saveSel();const t=this.closestAnchor();let e;const i=[];t&&i.push({label:this.t("unlink"),action:()=>{const s=document.createRange();s.selectNodeContents(t);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(s)),document.execCommand("unlink"),this.closeDlg(),this.onChange()}}),i.push({label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{const s=e.value.trim();if(this.closeDlg(),!s)return;if(t){t.setAttribute("href",s),this.onChange();return}this.restoreSel();const r=window.getSelection();!r||r.isCollapsed?document.execCommand("insertHTML",!1,`<a href="${s.replace(/"/g,"&quot;")}">${s.replace(/&/g,"&amp;").replace(/</g,"&lt;")}</a>`):(document.execCommand("styleWithCSS",!1,"false"),document.execCommand("createLink",!1,s)),this.saveSel(),this.onChange()}}),this.dialog(this.t("linkttl"),s=>{const r=document.createElement("div");r.style.cssText="display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";const l=document.createElement("span");l.style.cssText="width:60px;color:#556;flex:none",l.textContent=this.t("linkurl"),e=document.createElement("input"),e.type="url",e.placeholder="https://",e.style.cssText="flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit",e.value=(t==null?void 0:t.getAttribute("href"))||"",r.append(l,e),s.appendChild(r),setTimeout(()=>e.focus(),0)},i)}blocksMenu(t){this.popup(t,e=>{this.menuItems(e,Wt.map(([i,s])=>({label:this.blockLabel(i),previewStyle:i.startsWith("h")?`font-weight:700;font-size:${22-2*+i[1]}px`:i==="pre"?"font-family:monospace":"",on:this.currentBlock()===i,action:()=>this.exec("formatBlock","<"+i+">")})))})}blockLabel(t){return t==="p"?this.t("para"):t==="pre"?this.t("pre"):this.t("heading")+" "+t[1]}tableGrid(t,e){this.popup(t,i=>this.buildTableGridInto(i,e))}buildTableGridInto(t,e){{const i=document.createElement("div");i.className="tgridwrap";const s=document.createElement("div");s.className="tgrid";const r=document.createElement("div");r.className="tgridlbl",r.textContent="1 × 1";const l=[];for(let o=0;o<8;o++)for(let a=0;a<10;a++){const c=document.createElement("span");c.dataset.r=String(o),c.dataset.c=String(a),c.addEventListener("mouseenter",()=>{l.forEach(d=>d.classList.toggle("hot",+d.dataset.r<=o&&+d.dataset.c<=a)),r.textContent=a+1+" × "+(o+1)}),c.addEventListener("click",()=>{this.closePop(),this.insertTable(o+1,a+1),e==null||e()}),l.push(c),s.appendChild(c)}i.append(s,r),t.appendChild(i)}}insertTable(t,e){this.restoreSel();let i='<table style="border-collapse:collapse;width:100%;table-layout:fixed"><tbody>';for(let s=0;s<t;s++){i+="<tr>";for(let r=0;r<e;r++)i+='<td style="border:1px solid #b9c2cc"><br></td>';i+="</tr>"}i+="</tbody></table><p><br></p>",document.execCommand("insertHTML",!1,i),this.saveSel(),this.onChange()}setDir(t){this.restoreSel();const e=this.selectedBlocks();e.length?e.forEach(i=>i.setAttribute("dir",t)):this.ed.setAttribute("dir",t),this.saveSel(),this.refreshState(),this.onChange()}parseToolbarString(t){return t.split("|").map(e=>e.trim().split(/\s+/).filter(Boolean)).filter(e=>e.length>0)}buildToolbarRegistry(){const t=this.tbtn(h.tableic,this.t("quicktable"),()=>this.tableGrid(t));return{undo:()=>this.tbtn(h.undo,this.t("undo"),()=>this.exec("undo")),redo:()=>this.tbtn(h.redo,this.t("redo"),()=>this.exec("redo")),preview:()=>this.tbtn(h.prevw,this.t("preview"),()=>this.previewDlg()),print:()=>this.tbtn(h.printic,this.t("print"),()=>this.printDoc()),importword:()=>this.tbtn(h.wordic,this.t("importword"),()=>this.pickWordDoc()),revhistory:()=>this.tbtn(h.historyic,this.t("revhistory"),()=>this.revisionDlg()),fontfamily:()=>this.tsel("w-font","fontsel","",e=>this.fontMenu(e)),fontsize:()=>this.tsel("w-size","sizesel","",e=>this.sizeMenu(e)),fontsizeincrease:()=>this.stepBtn(1),fontsizedecrease:()=>this.stepBtn(-1),bold:()=>this.tbtn(h.bold,this.t("bold"),()=>this.exec("bold"),"bold"),italic:()=>this.tbtn(h.italic,this.t("italic"),()=>this.exec("italic"),"italic"),underline:()=>this.tbtn(h.underline,this.t("underline"),()=>this.exec("underline"),"underline"),strikethrough:()=>this.tbtn(h.strikethrough,this.t("strikethrough"),()=>this.exec("strikeThrough"),"strikeThrough"),forecolor:()=>this.colorChips(),backcolor:()=>this.menuTbtn(h.backcolor+'<span class="colorbar" data-cb="back"></span>',this.t("backcolor"),e=>this.colorMenu(e,"back")),alignleft:()=>this.tbtn(h.alignleft,this.t("alignleft"),()=>this.exec("justifyLeft"),"justifyLeft"),aligncenter:()=>this.tbtn(h.aligncenter,this.t("aligncenter"),()=>this.exec("justifyCenter"),"justifyCenter"),alignright:()=>this.tbtn(h.alignright,this.t("alignright"),()=>this.exec("justifyRight"),"justifyRight"),alignjustify:()=>this.tbtn(h.alignjustify,this.t("alignjustify"),()=>this.exec("justifyFull"),"justifyFull"),bullist:()=>this.menuTbtn(h.bullist,this.t("bullist"),e=>this.listMenu(e,"ul"),"insertUnorderedList"),numlist:()=>this.menuTbtn(h.numlist,this.t("numlist"),e=>this.listMenu(e,"ol"),"insertOrderedList"),outdent:()=>this.tbtn(h.outdent,this.t("outdent"),()=>this.exec("outdent")),indent:()=>this.tbtn(h.indent,this.t("indent"),()=>this.exec("indent")),link:()=>this.tbtn(h.link,this.t("linkttl"),()=>this.linkDlg()),blockquote:()=>this.tbtn(h.quote,this.t("quote"),()=>this.toggleBlock("blockquote"),"blockquote"),changecase:()=>this.menuTbtn(h.caseic,this.t("changecase"),e=>this.caseMenu(e)),lineheight:()=>this.menuTbtn(h.lineheight,this.t("lineheight"),e=>this.lineHeightMenu(e)),wordspacing:()=>this.menuTbtn(h.wordspacing,this.t("wordspacing"),e=>this.wordSpacingMenu(e)),removeformat:()=>this.tbtn(h.clearformatic,this.t("removeformat"),()=>this.exec("removeFormat")),blocks:()=>this.tsel("w-block","blocksel",this.t("para"),e=>this.blocksMenu(e)),ltr:()=>this.tbtn(h.ltr,this.t("ltr"),()=>this.setDir("ltr"),"ltr"),rtl:()=>this.tbtn(h.rtl,this.t("rtl"),()=>this.setDir("rtl"),"rtl"),quickimage:()=>this.tbtn(h.image,this.t("quickimage"),()=>this.insertImagePlaceholder()),quicktable:()=>t,charmap:()=>this.tbtn(h.charic,this.t("charmap"),()=>this.charMap()),fullscreen:()=>this.tbtn(h.fullscreen,this.t("fullscreen"),()=>this.toggleFullscreen(),"fullscreen"),sourcecode:()=>this.tbtn(h.srcic,this.t("sourcecode"),()=>this.sourceDlg())}}buildToolbar(){this.toolbar.innerHTML="";const t=this.options.toolbar===!0?Ae:this.options.toolbar,e=this.buildToolbarRegistry();this.parseToolbarString(t).forEach(i=>{const s=[];i.forEach(r=>{const l=e[r];if(!l){console.warn(`FableEditor: unknown toolbar item "${r}"`);return}const o=l();Array.isArray(o)?s.push(...o):s.push(o)}),s.length&&this.toolbar.appendChild(this.group(...s))}),this.syncColorSwatches(this.toolbar)}mItem(t,e,i,s){return{label:this.t(t),icon:e,action:i,shortcut:s}}buildMenubar(){this.menubar.innerHTML="";const t={file:[this.mItem("newdoc",h.newic,()=>{this.recordRevision(),this.ed.innerHTML="<p><br></p>",this.onChange()}),"|",this.mItem("importword",h.wordic,()=>this.pickWordDoc()),this.mItem("restoredraft",h.draftic,()=>{this.restoreDraft()||alert(this.t("draftempty"))}),this.mItem("revhistory",h.historyic,()=>this.revisionDlg()),"|",this.mItem("preview",h.prevw,()=>this.previewDlg()),this.mItem("print",h.printic,()=>this.printDoc(),"Ctrl+P")],edit:[this.mItem("undo",h.undo,()=>this.exec("undo"),"Ctrl+Z"),this.mItem("redo",h.redo,()=>this.exec("redo"),"Ctrl+Y"),"|",this.mItem("cut",h.cutic,()=>this.exec("cut"),"Ctrl+X"),this.mItem("copy",h.copyic,()=>this.exec("copy"),"Ctrl+C"),this.mItem("paste",h.pasteic,()=>alert(this.t("pastehint")),"Ctrl+V"),"|",this.mItem("selectall",h.selall,()=>this.exec("selectAll"),"Ctrl+A")],view:[this.mItem("fullscreen",h.fullscreen,()=>this.toggleFullscreen()),this.mItem("preview",h.prevw,()=>this.previewDlg()),this.mItem("sourcecode",h.srcic,()=>this.sourceDlg())],insert:[this.mItem("link",h.link,()=>this.linkDlg()),this.mItem("image",h.image,()=>this.insertImagePlaceholder()),{label:this.t("inserttable"),icon:h.tableic,action:()=>this.tableGrid(this.menubar.querySelector('[data-menu-key="table"]')||this.menubar)},this.mItem("hr",h.hric,()=>this.exec("insertHorizontalRule")),"|",this.mItem("charmap",h.charic,()=>this.charMap()),this.mItem("datetime",h.dateic,()=>this.exec("insertText",new Date().toLocaleString(this.lang==="ar"?"ar-AE":"en-GB"))),"|",{label:this.t("pagebreak"),icon:h.pbic,action:()=>{this.restoreSel(),document.execCommand("insertHTML",!1,'<hr class="pagebreak"><p><br></p>'),this.onChange()}},this.mItem("nbsp",h.nbspic,()=>this.exec("insertText"," "))],format:[this.mItem("bold",h.bold,()=>this.exec("bold"),"Ctrl+B"),this.mItem("italic",h.italic,()=>this.exec("italic"),"Ctrl+I"),this.mItem("underline",h.underline,()=>this.exec("underline"),"Ctrl+U"),this.mItem("strikethrough",h.strikethrough,()=>this.exec("strikeThrough")),this.mItem("superscript",h.superscriptic,()=>this.exec("superscript")),this.mItem("subscript",h.subscriptic,()=>this.exec("subscript")),"|",this.mItem("lowercase",h.lowercaseic,()=>this.transformCase("lower")),this.mItem("uppercase",h.uppercaseic,()=>this.transformCase("upper")),this.mItem("capitalize",h.capitalizeic,()=>this.transformCase("capitalize")),"|",this.mItem("clearformat",h.clearformatic,()=>this.exec("removeFormat"))],tools:[this.mItem("sourcecode",h.srcic,()=>this.sourceDlg()),this.mItem("wordcount",h.wcic,()=>this.wordCountDlg())],table:[{label:this.t("inserttable"),icon:h.tableic,subBuild:s=>this.buildTableGridInto(s)},"|",{label:this.t("cell"),sub:[{label:this.t("cellprops"),icon:h.tableic,action:()=>this.cellPropsDlg()}]},{label:this.t("row"),sub:[{label:this.t("rowabove"),icon:h.rowbefore,action:()=>this.tableOp("rowabove"),hover:s=>this.setOpTarget(s?"row":null)},{label:this.t("rowbelow"),icon:h.rowafter,action:()=>this.tableOp("rowbelow"),hover:s=>this.setOpTarget(s?"row":null)},{label:this.t("delrow"),icon:h.rowdelete,action:()=>this.tableOp("delrow"),hover:s=>this.setOpTarget(s?"row":null)},"|",{label:this.t("rowprops"),icon:h.tableic,action:()=>this.rowPropsDlg(),hover:s=>this.setOpTarget(s?"row":null)}]},{label:this.t("column"),sub:[{label:this.t("colbefore"),icon:h.colbefore,action:()=>this.tableOp("colbefore"),hover:s=>this.setOpTarget(s?"col":null)},{label:this.t("colafter"),icon:h.colafter,action:()=>this.tableOp("colafter"),hover:s=>this.setOpTarget(s?"col":null)},{label:this.t("delcol"),icon:h.coldelete,action:()=>this.tableOp("delcol"),hover:s=>this.setOpTarget(s?"col":null)},"|",{label:this.t("colprops"),icon:h.tableic,action:()=>this.colPropsDlg(),hover:s=>this.setOpTarget(s?"col":null)}]},"|",{label:this.t("tablepropsttl"),icon:h.tableic,action:()=>{const s=this.currentCell();if(!s){alert(this.t("nocell"));return}this.tblActive=s.closest("table"),this.tablePropsDlg()}},{label:this.t("deltable"),icon:h.tabledelete,action:()=>this.tableOp("deltable")}],help:[this.mItem("helpttl",h.helpic,()=>this.helpDlg(),"Alt+0")]},e=this.options.menubar===!0?Re:this.options.menubar,i=new Set;e.split(/\s+/).filter(Boolean).forEach(s=>{if(i.has(s))return;if(i.add(s),!t[s]){console.warn(`FableEditor: unknown menubar item "${s}"`);return}const r=document.createElement("button");r.type="button",r.textContent=this.t(s),r.dataset.menuKey=s,r.addEventListener("mousedown",l=>{l.preventDefault(),this.saveSel()}),r.addEventListener("click",()=>this.popup(r,l=>this.menuItems(l,t[s]))),this.menubar.appendChild(r)})}tableOp(t){var a,c,d;this.restoreSel();const e=window.getSelection();if(!e)return;const i=((a=this.closestBlock(e.anchorNode))==null?void 0:a.closest("td,th"))||(e.anchorNode&&e.anchorNode.nodeType===1?(d=(c=e.anchorNode).closest)==null?void 0:d.call(c,"td,th"):null);if(!i)return;const s=i.parentElement,r=i.closest("table"),l=Array.from(s.children).indexOf(i),o=()=>{const u=s.cloneNode(!1);return Array.from(s.children).forEach(v=>{const b=document.createElement("td"),f=v.getAttribute("style");f&&b.setAttribute("style",f),b.style.removeProperty("background-color"),b.innerHTML="<br>",u.appendChild(b)}),u};if(t==="rowabove"&&s.before(o()),t==="rowbelow"&&s.after(o()),t==="delrow"){const u=s.parentElement;s.remove(),u.querySelector("tr")||r.remove()}(t==="colbefore"||t==="colafter")&&r.querySelectorAll("tr").forEach(u=>{const v=u.children[Math.min(l,u.children.length-1)],b=document.createElement("td"),f=v.getAttribute("style");f&&b.setAttribute("style",f),b.style.removeProperty("width"),b.style.removeProperty("background-color"),b.innerHTML="<br>",t==="colbefore"?v.before(b):v.after(b)}),t==="delcol"&&(r.querySelectorAll("tr").forEach(u=>{var v;return(v=u.children[l])==null?void 0:v.remove()}),r.querySelector("td,th")||r.remove()),t==="deltable"&&r.remove(),this.onChange(),this.positionTableHandles()}applyTableProps(t,e){e.width?t.style.width=/^\d+$/.test(e.width)?e.width+"px":e.width:t.style.removeProperty("width");const i=Array.from(t.querySelectorAll("td,th"));e.cellpadding!==""?i.forEach(s=>s.style.padding=e.cellpadding+"px"):i.forEach(s=>s.style.removeProperty("padding")),e.cellspacing!==""?(t.style.borderCollapse="separate",t.style.borderSpacing=e.cellspacing+"px"):(t.style.borderCollapse="collapse",t.style.removeProperty("border-spacing")),e.border!==""&&+e.border>0?(t.style.border=e.border+"px solid #b9c2cc",i.forEach(s=>s.style.border=e.border+"px solid #b9c2cc")):(t.style.removeProperty("border"),i.forEach(s=>s.style.removeProperty("border"))),t.style.removeProperty("margin-left"),t.style.removeProperty("margin-right"),e.align==="center"?(t.style.marginLeft="auto",t.style.marginRight="auto"):e.align==="right"?(t.style.marginLeft="auto",t.style.marginRight="0"):e.align==="left"&&(t.style.marginLeft="0",t.style.marginRight="auto")}tablePropsDlg(){const t=this.tblActive;if(!t)return;let e,i,s,r,l;const o="display:flex;align-items:center;gap:10px;margin:10px 0",a="width:120px;color:#556;flex:none",c="flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit",d=t.querySelector("td,th"),u=t.style.width||"",v=d&&d.style.padding?parseFloat(d.style.padding):"",b=t.style.borderSpacing?parseFloat(t.style.borderSpacing):"",f=t.style.borderWidth?parseFloat(t.style.borderWidth):"",w=t.style.marginLeft,E=t.style.marginRight,q=w==="auto"&&E==="auto"?"center":w==="auto"?"right":E==="auto"&&w==="0"?"left":"";this.dialog(this.t("tablepropsttl"),M=>{const D=(I,_)=>{const F=document.createElement("div");F.style.cssText=o;const Y=document.createElement("span");Y.style.cssText=a,Y.textContent=this.t(I),F.append(Y,_),M.appendChild(F)};e=document.createElement("input"),e.type="text",e.style.cssText=c,e.placeholder="e.g. 600px or 100%",e.value=u,D("tblwidth",e),i=document.createElement("input"),i.type="number",i.min="0",i.style.cssText=c,i.value=String(v),D("tblcellpadding",i),s=document.createElement("input"),s.type="number",s.min="0",s.style.cssText=c,s.value=String(b),D("tblcellspacing",s),r=document.createElement("input"),r.type="number",r.min="0",r.style.cssText=c,r.value=String(f),D("tblborder",r),l=document.createElement("select"),l.style.cssText=c,[["","alignnone"],["left","alignleft"],["center","aligncenter"],["right","alignright"]].forEach(([I,_])=>{const F=document.createElement("option");F.value=I,F.textContent=this.t(_),I===q&&(F.selected=!0),l.appendChild(F)}),D("tblalign",l)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{this.applyTableProps(t,{width:e.value.trim(),cellpadding:i.value.trim(),cellspacing:s.value.trim(),border:r.value.trim(),align:l.value}),this.closeDlg(),this.onChange(),this.positionTableHandles()}}])}currentCell(){let t=this.savedRange?this.savedRange.startContainer:null;if(!t||!this.ed.contains(t)){const e=window.getSelection();t=e&&this.ed.contains(e.anchorNode)?e.anchorNode:null}for(;t&&t!==this.ed;){if(t.nodeType===1&&/^(TD|TH)$/.test(t.tagName))return t;t=t.parentNode}return null}toHexColor(t){if(/^#[0-9a-fA-F]{6}$/.test(t))return t;const e=/rgba?\((\d+)[,\s]+(\d+)[,\s]+(\d+)/.exec(t);return e?"#"+[e[1],e[2],e[3]].map(i=>(+i).toString(16).padStart(2,"0")).join(""):""}formRow(t,e,i){const s=document.createElement("div");s.style.cssText="display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";const r=document.createElement("span");r.style.cssText="width:120px;color:#556;flex:none",r.textContent=e,s.append(r,i),t.appendChild(s)}formInput(t,e=""){const i=document.createElement("input");return i.type="text",i.style.cssText="flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;min-width:0",i.value=t,i.placeholder=e,i}formSelect(t,e){const i=document.createElement("select");return i.style.cssText="flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;background:#fff",t.forEach(([s,r])=>{const l=document.createElement("option");l.value=s,l.textContent=r,s===e&&(l.selected=!0),i.appendChild(l)}),i}formBg(t){const e=document.createElement("div");e.style.cssText="flex:1;display:flex;align-items:center;gap:8px";const i=this.toHexColor(t),s=document.createElement("input");s.type="color",s.value=i||"#ffffff",s.style.cssText="width:36px;height:29px;border:1px solid #cfd6df;border-radius:4px;padding:1px;background:none;cursor:pointer";const r=document.createElement("label");r.style.cssText="display:flex;align-items:center;gap:6px;cursor:pointer;color:#556";const l=document.createElement("input");return l.type="checkbox",l.checked=!!i,r.append(l,document.createTextNode(this.t("fill"))),s.addEventListener("input",()=>l.checked=!0),e.append(s,r),{wrap:e,color:s,fill:l}}setOrClear(t,e,i){i?t.style.setProperty(e,/^(width|height)$/.test(e)&&/^\d+$/.test(i)?i+"px":i):t.style.removeProperty(e)}cellPropsDlg(){const t=this.currentCell();if(!t){alert(this.t("nocell"));return}let e,i,s,r,l;this.dialog(this.t("cellprops").replace("…",""),o=>{e=this.formInput(t.style.width,"e.g. 120px / 25%"),this.formRow(o,this.t("tblwidth"),e),i=this.formInput(t.style.height,"e.g. 40px"),this.formRow(o,this.t("tblheight"),i),s=this.formSelect([["",this.t("alignnone")],["left",this.t("alignleft")],["center",this.t("aligncenter")],["right",this.t("alignright")]],t.style.textAlign||""),this.formRow(o,this.t("tblalign"),s),r=this.formSelect([["",this.t("alignnone")],["top",this.t("valigntop")],["middle",this.t("valignmiddle")],["bottom",this.t("valignbottom")]],t.style.verticalAlign||""),this.formRow(o,this.t("valign"),r),l=this.formBg(t.style.backgroundColor||""),this.formRow(o,this.t("backcolor"),l.wrap)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{this.setOrClear(t,"width",e.value.trim()),this.setOrClear(t,"height",i.value.trim()),this.setOrClear(t,"text-align",s.value),this.setOrClear(t,"vertical-align",r.value),this.setOrClear(t,"background-color",l.fill.checked?l.color.value:""),this.closeDlg(),this.onChange(),this.positionTableHandles()}}])}rowPropsDlg(){const t=this.currentCell();if(!t){alert(this.t("nocell"));return}const e=t.parentElement;let i,s;this.dialog(this.t("rowprops").replace("…",""),r=>{i=this.formInput(e.style.height,"e.g. 40px"),this.formRow(r,this.t("tblheight"),i),s=this.formBg(e.style.backgroundColor||""),this.formRow(r,this.t("backcolor"),s.wrap)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{this.setOrClear(e,"height",i.value.trim()),this.setOrClear(e,"background-color",s.fill.checked?s.color.value:""),this.closeDlg(),this.onChange(),this.positionTableHandles()}}])}colPropsDlg(){const t=this.currentCell();if(!t){alert(this.t("nocell"));return}const e=t.parentElement,i=t.closest("table"),s=Array.from(e.children).indexOf(t),r=Array.from(i.rows).map(a=>a.cells[s]).filter(Boolean);let l,o;this.dialog(this.t("colprops").replace("…",""),a=>{l=this.formInput(t.style.width,"e.g. 120px / 25%"),this.formRow(a,this.t("tblwidth"),l),o=this.formBg(t.style.backgroundColor||""),this.formRow(a,this.t("backcolor"),o.wrap)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{r.forEach(a=>{this.setOrClear(a,"width",l.value.trim()),this.setOrClear(a,"background-color",o.fill.checked?o.color.value:"")}),this.closeDlg(),this.onChange(),this.positionTableHandles()}}])}closeDlg(){this.dlgOvl&&(this.dlgOvl.remove(),this.dlgOvl=null)}dialog(t,e,i){this.closeDlg(),this.closePop(),this.dlgOvl=document.createElement("div"),this.dlgOvl.className="ovl";const s=document.createElement("div");s.className="dlg",s.dir=this.dir(),s.innerHTML=`<header><span>${t}</span><button type="button">×</button></header>
36
+ `,this.sbHelp=this.statusbar.querySelector(".mid"),this.sbWords=this.statusbar.querySelector(".words");const e=this.statusbar.querySelector(".grip");this.bindGrip(e),this.shell.appendChild(this.menubar),this.shell.appendChild(this.toolbar),this.shell.appendChild(this.ed),this.shell.appendChild(this.statusbar),this.contentStyle&&(this.contentStyleEl=document.createElement("style"),this.contentStyleEl.textContent=this.scopeContentStyle(this.contentStyle),this.shell.appendChild(this.contentStyleEl)),t.appendChild(this.shell),this.options.statusbar||(this.statusbar.style.display="none"),this.imgInput=document.createElement("input"),this.imgInput.type="file",this.imgInput.accept=this.options.imageFileTypes.join(","),this.imgInput.style.display="none",t.appendChild(this.imgInput),this.docInput=document.createElement("input"),this.docInput.type="file",this.docInput.accept=".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",this.docInput.style.display="none",t.appendChild(this.docInput)}scopeContentStyle(t){return t.replace(/\bbody\b/g,"."+this.contentClass)}bindGrip(t){let e=0,i=0;const s=r=>{e=r.clientY,i=this.ed.offsetHeight,r.preventDefault();const l=a=>{this.ed.style.height=Math.max(120,i+a.clientY-e)+"px"},o=()=>{window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",l),window.addEventListener("mouseup",o)};t.addEventListener("mousedown",s),this.listeners.push(()=>t.removeEventListener("mousedown",s))}bindEvents(){this.onDoc("mousedown",t=>{this.openPop&&!this.openPop.contains(t.target)&&!this.popAnchor.contains(t.target)&&!(this.openSubEl&&this.openSubEl.contains(t.target))&&this.closePop()}),this.onDoc("keydown",t=>{t.key==="Escape"&&(this.closePop(),this.closeDlg())}),this.onDoc("selectionchange",()=>{const t=window.getSelection();t&&this.ed.contains(t.anchorNode)?(this.saveSel(),this.refreshState(),this.updateSelToolbar(t),this.positionCellMarker()):this.clearSelToolbar()}),this.on(this.ed,"input",()=>{this.refreshState(),this.onChange(),this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.positionTplCtx()}),this.on(this.ed,"keydown",t=>{t.altKey&&t.key==="0"&&(t.preventDefault(),this.helpDlg()),(t.key==="Delete"||t.key==="Backspace")&&this.phActive&&(t.preventDefault(),this.removeImgPlaceholder())}),this.on(this.ed,"paste",t=>this.handlePaste(t)),this.on(this.ed,"drop",t=>{var s,r,l;t.preventDefault();const e=(r=(s=t.target).closest)==null?void 0:r.call(s,".img-ph");if(!e||!this.ed.contains(e)||this.options.readonly)return;const i=Array.from(((l=t.dataTransfer)==null?void 0:l.files)||[]).find(o=>o.type.startsWith("image/"));i&&this.readImageFileInto(i,e)}),this.on(this.ed,"dragover",t=>t.preventDefault()),this.on(this.ed,"mousedown",t=>{var o,a,c,d;const e=t.target,i=(o=e.closest)==null?void 0:o.call(e,"table");i&&this.ed.contains(i)?this.selectTableForResize(i):this.clearTableHandles();const s=(a=e.closest)==null?void 0:a.call(e,".img-ph");s&&this.ed.contains(s)&&!this.options.readonly?(t.preventDefault(),this.ed.focus(),this.selectImgPlaceholder(s)):this.clearImgPlaceholderSel();const r=(c=e.closest)==null?void 0:c.call(e,".tpl");r&&this.ed.contains(r)&&!this.options.readonly?this.selectTemplate(r):this.clearTplSel();const l=(d=e.closest)==null?void 0:d.call(e,"img");l&&this.ed.contains(l)&&!this.options.readonly?(t.preventDefault(),this.selectImage(l)):this.clearImageHandles()}),this.on(this.ed,"mouseover",t=>{var i,s;if(this.options.readonly)return;const e=(s=(i=t.target).closest)==null?void 0:s.call(i,"img");e&&this.ed.contains(e)&&(this.cancelImgHide(),this.selectImage(e))}),this.on(this.ed,"mouseout",t=>{var s,r,l,o;const e=(r=(s=t.target).closest)==null?void 0:r.call(s,"img");if(!e)return;const i=t.relatedTarget;i&&((l=this.imgCtx)!=null&&l.contains(i)||this.imgHandles.some(a=>a.contains(i))||((o=i.closest)==null?void 0:o.call(i,"img"))===e)||this.scheduleImgHide()}),this.on(this.ed,"scroll",()=>{this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.positionTplCtx()}),this.onWin("scroll",()=>{this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.positionTplCtx(),this.repositionSelToolbar()},!0),this.onWin("resize",()=>{this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.positionTplCtx(),this.repositionSelToolbar()}),this.on(this.imgInput,"change",()=>{var s;const t=(s=this.imgInput.files)==null?void 0:s[0];if(!t)return;const e=this.phUploadTarget;if(this.phUploadTarget=null,e&&this.ed.contains(e)){this.readImageFileInto(t,e);return}const i=new FileReader;i.onload=()=>{this.restoreSel(),document.execCommand("insertHTML",!1,`<img src="${i.result}" title="${t.name.replace(/"/g,"")}" alt="">`),this.onChange()},i.readAsDataURL(t)}),this.on(this.docInput,"change",()=>{var e;const t=(e=this.docInput.files)==null?void 0:e[0];t&&this.importWordFile(t).catch(()=>alert(this.t("importfail")))}),this.onDoc("mousedown",t=>{this.ed.contains(t.target)||t.target===this.tblCorner||this.tblColBars.includes(t.target)||this.tblCtx&&this.tblCtx.contains(t.target)||this.imgHandles.includes(t.target)||this.imgCtx&&this.imgCtx.contains(t.target)||this.phCtx&&this.phCtx.contains(t.target)||this.tplCtx&&this.tplCtx.contains(t.target)||this.selCtx&&this.selCtx.contains(t.target)||this.openPop&&this.openPop.contains(t.target)||this.openSubEl&&this.openSubEl.contains(t.target)||(this.clearTableHandles(),this.clearImageHandles(),this.clearImgPlaceholderSel(),this.clearTplSel(),this.clearSelToolbar())})}on(t,e,i){t.addEventListener(e,i),this.listeners.push(()=>t.removeEventListener(e,i))}onDoc(t,e){document.addEventListener(t,e),this.listeners.push(()=>document.removeEventListener(t,e))}onWin(t,e,i){window.addEventListener(t,e,i),this.listeners.push(()=>window.removeEventListener(t,e,i))}getContent(){return this.ed.innerHTML}setContent(t){this.ed.innerHTML=t||"<p><br></p>",this.refreshState(),this.clearTableHandles(),this.clearImageHandles(),this.clearImgPlaceholderSel(),this.clearTplSel(),this.clearSelToolbar(),this.onChange()}insertContent(t){this.restoreSel(),document.execCommand("insertHTML",!1,t),this.saveSel(),this.refreshState(),this.onChange()}setLanguage(t){this.lang=t,this.initUI()}focus(){this.ed.focus()}async importWordFile(t){const e=await oi(t);this.recordRevision(),this.setContent(e),this.recordRevision()}restoreDraft(){let t=null;try{t=localStorage.getItem(this.draftStorageKey)}catch{}if(!t)return!1;try{const e=JSON.parse(t);return e.html?(this.recordRevision(),this.setContent(e.html),!0):!1}catch{return!1}}getRevisions(){return this.revisions.slice()}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.revTimer!=null&&window.clearTimeout(this.revTimer),this.draftTimer!=null&&window.clearTimeout(this.draftTimer),this.closePop(),this.closeDlg(),this.clearTableHandles(),this.clearImageHandles(),this.clearImgPlaceholderSel(),this.clearTplSel(),this.clearSelToolbar(),this.listeners.forEach(t=>t()),this.listeners=[],this.shell&&this.shell.parentNode&&this.shell.parentNode.removeChild(this.shell),this.imgInput&&this.imgInput.parentNode&&this.imgInput.parentNode.removeChild(this.imgInput),this.docInput&&this.docInput.parentNode&&this.docInput.parentNode.removeChild(this.docInput),this.contentStyleEl=null)}saveSel(){const t=window.getSelection();t&&t.rangeCount&&this.ed.contains(t.anchorNode)&&(this.savedRange=t.getRangeAt(0).cloneRange())}restoreSel(){if(!this.savedRange){this.ed.focus();return}this.ed.focus();const t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(this.savedRange))}exec(t,e){this.restoreSel(),document.execCommand("styleWithCSS",!1,t!=="fontSize"?"true":"false"),document.execCommand(t,!1,e??void 0),this.saveSel(),this.refreshState(),this.onChange()}closestBlock(t){for(;t&&t!==this.ed;){if(t.nodeType===1&&/^(P|DIV|H[1-6]|LI|PRE|BLOCKQUOTE|TD|TH)$/i.test(t.tagName))return t;t=t.parentNode}return null}selectedBlocks(){const t=window.getSelection();if(!t||!t.rangeCount||!this.ed.contains(t.anchorNode))return[];const e=t.getRangeAt(0),i=Array.from(this.ed.querySelectorAll("p,h1,h2,h3,h4,h5,h6,li,pre,blockquote,td,th")).filter(s=>e.intersectsNode(s));if(!i.length){const s=this.closestBlock(t.anchorNode);if(s)return[s]}return i}onChange(){this.options.onChange(this.ed.innerHTML),this.scheduleRevision(),this.scheduleDraftSave()}recordRevision(){const t=this.ed.innerHTML,e=this.revisions[this.revisions.length-1];e&&e.html===t||(this.revisions.push({time:Date.now(),html:t}),this.revisions.length>30&&this.revisions.shift())}scheduleRevision(){this.revTimer!=null&&window.clearTimeout(this.revTimer),this.revTimer=window.setTimeout(()=>{this.revTimer=null,this.recordRevision()},1500)}scheduleDraftSave(){this.draftTimer!=null&&window.clearTimeout(this.draftTimer),this.draftTimer=window.setTimeout(()=>{this.draftTimer=null;try{localStorage.setItem(this.draftStorageKey,JSON.stringify({time:Date.now(),html:this.ed.innerHTML}))}catch{}},800)}revisionDlg(){this.recordRevision(),this.dialog(this.t("revhistory"),t=>{if(!this.revisions.length){t.innerHTML=`<p style="color:#556">${this.t("revempty")}</p>`;return}const e=document.createElement("div");e.className="revwrap";const i=document.createElement("div");i.className="revlist";const s=document.createElement("div");s.className="revprev";const r=document.createElement("button");r.type="button",r.className="revrestore",r.textContent=this.t("restore");let l=this.revisions.length-1;const o=new Intl.DateTimeFormat(this.lang==="ar"?"ar-AE":"en-GB",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),a={},c=d=>{l=d,this.revisions.forEach((u,v)=>{var b;return(b=a[v])==null?void 0:b.classList.toggle("on",v===d)}),s.innerHTML=this.revisions[d].html,r.disabled=d===this.revisions.length-1};for(let d=this.revisions.length-1;d>=0;d--){const u=this.revisions[d],v=document.createElement("button");v.type="button";const b=(new DOMParser().parseFromString(u.html,"text/html").body.textContent||"").trim(),f=b?b.split(/\s+/).length:0,w=d===this.revisions.length-1;v.innerHTML=`<span>${w?this.t("currentver"):o.format(new Date(u.time))}</span><span class="wc">${f} ${this.t("words")}</span>`,v.addEventListener("click",()=>c(d)),a[d]=v,i.appendChild(v)}i.append(r),r.addEventListener("click",()=>{const d=this.revisions[l];d&&(this.recordRevision(),this.setContent(d.html),this.recordRevision(),this.closeDlg())}),e.append(i,s),t.appendChild(e),c(l)})}closeSub(){var t;(t=this.openSubEl)==null||t.remove(),this.openSubEl=null}closePop(){var t;this.closeSub(),this.openPop&&(this.openPop.remove(),this.openPop=null,(t=this.popAnchor)==null||t.classList.remove("open"),this.popAnchor=null,this.setOpTarget(null))}openSubFor(t,e){this.closeSub();const i=document.createElement("div");i.className="pop sub",i.dir=this.dir(),t.subBuild?t.subBuild(i):t.sub&&this.menuItems(i,t.sub),i.addEventListener("mousedown",a=>{a.target.tagName!=="INPUT"&&a.preventDefault()}),document.body.appendChild(i);const s=e.getBoundingClientRect();let l=this.dir()==="rtl"?s.left-i.offsetWidth+2:s.right-2;l=Math.max(8,Math.min(l+scrollX,scrollX+innerWidth-i.offsetWidth-8));let o=s.top+scrollY-6;o=Math.max(8+scrollY,Math.min(o,scrollY+innerHeight-i.offsetHeight-8)),i.style.left=l+"px",i.style.top=o+"px",this.openSubEl=i}popup(t,e){if(this.openPop&&this.popAnchor===t){this.closePop();return}this.closePop();const i=document.createElement("div");i.className="pop",i.dir=this.dir(),e(i),document.body.appendChild(i);const s=t.getBoundingClientRect();i.style.minWidth=Math.max(160,Math.round(s.width))+"px",i.style.top=s.bottom+scrollY+2+"px";let l=this.dir()==="rtl"?s.right-i.offsetWidth:s.left;l=Math.max(8,Math.min(l+scrollX,scrollX+innerWidth-i.offsetWidth-8)),i.style.left=l+"px",i.addEventListener("mousedown",o=>{o.target.tagName!=="INPUT"&&o.preventDefault()}),this.openPop=i,this.popAnchor=t,t.classList.add("open")}menuItems(t,e){e.forEach(i=>{if(i==="|"){t.insertAdjacentHTML("beforeend",'<div class="sep"></div>');return}const s=!!(i.sub||i.subBuild),r=document.createElement("button");r.className="mi"+(i.on?" on":""),r.innerHTML=`<span class="ic">${i.icon||""}</span><span class="prev" ${i.previewStyle?`style="${i.previewStyle}"`:""}>${i.label}</span>${i.shortcut?`<span class="sc">${i.shortcut}</span>`:""}${s?`<span class="subarrow">${h.chev}</span>`:""}`,r.addEventListener("click",()=>{i.action&&(this.closePop(),i.action())}),r.addEventListener("mouseenter",()=>{var l;s?this.openSubFor(i,r):this.openSubEl&&t!==this.openSubEl&&this.closeSub(),(l=i.hover)==null||l.call(i,!0)}),r.addEventListener("mouseleave",()=>{var l;return(l=i.hover)==null?void 0:l.call(i,!1)}),t.appendChild(r)})}tbtn(t,e,i,s){const r=document.createElement("button");return r.className="tbtn",r.type="button",r.title=e,r.innerHTML=t,s&&(r.dataset.id=s),r.addEventListener("mousedown",l=>l.preventDefault()),r.addEventListener("click",i),r}stepBtn(t){const e=t>0?"+":"−",i=t>0?h.fontsizeup:h.fontsizedown,s=this.tbtn(i,this.t("fontsize")+" "+e,()=>this.stepFontSize(t));return s.addEventListener("mousedown",()=>this.saveSel()),s}menuTbtn(t,e,i,s){const r=this.tbtn(t,e,()=>i(r),s);return r.classList.add("hasmenu"),r.insertAdjacentHTML("beforeend",h.chev),r.addEventListener("mousedown",()=>this.saveSel()),r}colorChips(){const t=s=>{const r=document.createElement("button");return r.type="button",r.className="cchip",r.title=s,r.addEventListener("mousedown",l=>{l.preventDefault(),this.saveSel()}),r},e=_e.map(s=>{const r=t(this.t("forecolor"));return r.style.background=s,r.addEventListener("click",()=>this.applyColor("fore",s)),r}),i=t(this.t("forecolor"));return i.classList.add("more"),i.dataset.cb="fore",i.innerHTML=h.chev,i.addEventListener("click",()=>this.colorMenu(i,"fore")),[...e,i]}group(...t){const e=document.createElement("div");return e.className="tgrp",t.forEach(i=>{i.classList.add("gbtn"),e.appendChild(i)}),e}tsel(t,e,i,s){const r=document.createElement("button");return r.className="tsel "+t,r.type="button",r.dataset.id=e,r.innerHTML=`<span class="lbl empty">${i||""}</span>${h.chev}`,r.addEventListener("mousedown",l=>{l.preventDefault(),this.saveSel()}),r.addEventListener("click",()=>s(r)),r}setListStyle(t,e){var r,l;this.restoreSel();const i=window.getSelection();if(!i)return;let s=(r=this.closestBlock(i.anchorNode))==null?void 0:r.closest(t);s||(this.exec(t==="ol"?"insertOrderedList":"insertUnorderedList"),s=(l=this.closestBlock(i.anchorNode))==null?void 0:l.closest(t)),s&&(s.style.listStyleType=e),this.saveSel(),this.onChange()}listMenu(t,e){var c;const i=e==="ol"?"insertOrderedList":"insertUnorderedList",s=e==="ol"?[["lower-alpha",h.ol_alpha],["lower-roman",h.ol_roman],["upper-alpha",h.ol_alphau],["upper-roman",h.ol_romanu]]:[["circle",h.ul_circle],["square",h.ul_square]],r=this.tArr(e==="ol"?"liststyles_ol":"liststyles_ul").slice(1),l=window.getSelection(),o=l?(c=this.closestBlock(l.anchorNode))==null?void 0:c.closest(e):null,a=o?o.style.listStyleType:"";this.popup(t,d=>{this.menuItems(d,[{label:this.t(e==="ol"?"numlist":"bullist"),icon:e==="ol"?h.numlist:h.bullist,on:document.queryCommandState(i),action:()=>this.exec(i)}]),d.insertAdjacentHTML("beforeend",'<div class="sep"></div>');const u=document.createElement("div");u.className="mi-grid",s.forEach(([v,b],f)=>{const w=document.createElement("button");w.className="mi"+(a===v?" on":""),w.innerHTML=`<span class="ic">${b}</span><span class="prev">${r[f]}</span>`,w.addEventListener("click",()=>{this.closePop(),this.setListStyle(e,v)}),u.appendChild(w)}),d.appendChild(u)})}colorMenu(t,e){this.popup(t,i=>{const s=document.createElement("div");s.className="cpal",je.forEach(u=>{const v=document.createElement("button");v.style.background=u,v.title=u,v.addEventListener("click",()=>{this.closePop(),this.applyColor(e,u)}),s.appendChild(v)}),i.appendChild(s),i.insertAdjacentHTML("beforeend",'<div class="sep"></div>');const r=document.createElement("div");r.className="cfoot";const l=document.createElement("div");l.className="cswatch cur",l.title=this.t("currentcolor");const o=e==="fore"?this.foreColor:this.backColor;l.style.background=/^#[0-9a-f]{6}$/i.test(o)?o:"#000000",l.innerHTML=h.check;const a=document.createElement("button");a.type="button",a.className="cswatch nocolor",a.title=this.t("removecolor"),a.addEventListener("click",()=>{this.closePop(),this.applyColor(e,null)});const c=document.createElement("label");c.className="cswatch cwheel",c.title=this.t("customcolor"),c.innerHTML=h.palette;const d=document.createElement("input");d.type="color",d.value=/^#[0-9a-f]{6}$/i.test(o)?o:"#000000",d.addEventListener("change",()=>{this.closePop(),this.applyColor(e,d.value)}),c.appendChild(d),r.append(l,a,c),i.appendChild(r)})}applyColor(t,e){t==="fore"?(this.foreColor=e||"#000000",this.exec("foreColor",e||"#000000")):(this.backColor=e||"transparent",this.exec("hiliteColor",e||"transparent")),this.syncColorSwatches(this.toolbar),this.selCtx&&this.syncColorSwatches(this.selCtx)}syncColorSwatches(t){t.querySelectorAll("[data-cb=fore]").forEach(e=>e.style.background=this.foreColor),t.querySelectorAll("[data-cb=back]").forEach(e=>e.style.background=this.backColor)}fontMenu(t){this.popup(t,e=>{this.menuItems(e,this.options.fontFamilyFormats.map(([i,s])=>({label:i,previewStyle:`font-family:${s}`,on:this.currentFont()===i,action:()=>this.exec("fontName",s)})))})}sizeMenu(t){this.popup(t,e=>{this.menuItems(e,Ne.map(i=>({label:i,on:this.currentSize()===i,action:()=>this.applyFontSize(i)})))})}ensureSizeTarget(){const t=window.getSelection();if(!t)return;if(!t.rangeCount){const l=document.createRange();l.selectNodeContents(this.ed),l.collapse(!0),t.addRange(l)}if(!t.isCollapsed)return;const e=t.getRangeAt(0),i=e.startContainer;if(i.nodeType===3){const l=i.data;let o=e.startOffset,a=e.startOffset;for(;o>0&&/\S/.test(l[o-1]);)o--;for(;a<l.length&&/\S/.test(l[a]);)a++;if(a>o){const c=document.createRange();c.setStart(i,o),c.setEnd(i,a),t.removeAllRanges(),t.addRange(c),this.savedRange=c.cloneRange();return}}const s=document.createTextNode("​");e.insertNode(s);const r=document.createRange();r.setStart(s,0),r.setEnd(s,1),t.removeAllRanges(),t.addRange(r),this.savedRange=r.cloneRange()}applyFontSize(t){this.restoreSel(),this.ensureSizeTarget(),document.execCommand("styleWithCSS",!1,"false"),document.execCommand("fontSize",!1,"7");const e=[];if(this.ed.querySelectorAll('font[size="7"]').forEach(i=>{const s=document.createElement("span");for(s.style.fontSize=t;i.firstChild;)s.appendChild(i.firstChild);i.replaceWith(s),e.push(s)}),e.length){const i=document.createRange();i.setStart(e[0],0),i.setEnd(e[e.length-1],e[e.length-1].childNodes.length);const s=window.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}this.saveSel(),this.refreshState(),this.onChange()}stepFontSize(t){const e=parseInt(this.currentSize(),10)||14,i=Math.min(Be,Math.max(Oe,e+t));i!==e&&this.applyFontSize(i+"px")}transformCase(t){this.restoreSel();const e=window.getSelection();if(!e||!e.rangeCount||e.isCollapsed)return;const i=e.getRangeAt(0),s=document.createTreeWalker(this.ed,NodeFilter.SHOW_TEXT),r=[];let l;for(;l=s.nextNode();)i.intersectsNode(l)&&r.push(l);r.forEach(o=>{const a=o===i.startContainer?i.startOffset:0,c=o===i.endContainer?i.endOffset:o.data.length;if(c<=a)return;const d=o.data.slice(a,c);let u=d;t==="lower"?u=d.toLowerCase():t==="upper"?u=d.toUpperCase():u=d.replace(/(^|\s)(\S)/g,(v,b,f)=>b+f.toUpperCase()),o.replaceData(a,c-a,u)}),this.saveSel(),this.refreshState(),this.onChange()}caseMenu(t){this.popup(t,e=>{this.menuItems(e,[{label:this.t("lowercase"),icon:h.lowercaseic,action:()=>this.transformCase("lower")},{label:this.t("uppercase"),icon:h.uppercaseic,action:()=>this.transformCase("upper")},{label:this.t("capitalize"),icon:h.capitalizeic,action:()=>this.transformCase("capitalize")}])})}applyBlockStyle(t,e){this.restoreSel(),this.selectedBlocks().forEach(s=>{e?s.style[t]=e:s.style.removeProperty(t==="lineHeight"?"line-height":"word-spacing")}),this.saveSel(),this.onChange()}currentBlockStyle(t){const e=window.getSelection(),i=e?this.closestBlock(e.anchorNode):null;return i&&i.style[t]||""}lineHeightMenu(t){const e=this.currentBlockStyle("lineHeight");this.popup(t,i=>{this.menuItems(i,[{label:this.t("normal"),on:!e,action:()=>this.applyBlockStyle("lineHeight","")},...Fe.map(s=>({label:s,on:e===s,action:()=>this.applyBlockStyle("lineHeight",s)}))])})}wordSpacingMenu(t){const e=this.currentBlockStyle("wordSpacing");this.popup(t,i=>{this.menuItems(i,[{label:this.t("normal"),on:!e,action:()=>this.applyBlockStyle("wordSpacing","")},...$e.map(s=>({label:s,on:e===s,action:()=>this.applyBlockStyle("wordSpacing",s)}))])})}closestAnchor(){const t=window.getSelection();let e=t&&this.ed.contains(t.anchorNode)?t.anchorNode:null;for(;e&&e!==this.ed;){if(e.nodeType===1&&e.tagName==="A")return e;e=e.parentNode}return null}linkDlg(){this.saveSel();const t=this.closestAnchor();let e;const i=[];t&&i.push({label:this.t("unlink"),action:()=>{const s=document.createRange();s.selectNodeContents(t);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(s)),document.execCommand("unlink"),this.closeDlg(),this.onChange()}}),i.push({label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{const s=e.value.trim();if(this.closeDlg(),!s)return;if(t){t.setAttribute("href",s),this.onChange();return}this.restoreSel();const r=window.getSelection();!r||r.isCollapsed?document.execCommand("insertHTML",!1,`<a href="${s.replace(/"/g,"&quot;")}">${s.replace(/&/g,"&amp;").replace(/</g,"&lt;")}</a>`):(document.execCommand("styleWithCSS",!1,"false"),document.execCommand("createLink",!1,s)),this.saveSel(),this.onChange()}}),this.dialog(this.t("linkttl"),s=>{const r=document.createElement("div");r.style.cssText="display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";const l=document.createElement("span");l.style.cssText="width:60px;color:#556;flex:none",l.textContent=this.t("linkurl"),e=document.createElement("input"),e.type="url",e.placeholder="https://",e.style.cssText="flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit",e.value=(t==null?void 0:t.getAttribute("href"))||"",r.append(l,e),s.appendChild(r),setTimeout(()=>e.focus(),0)},i)}blocksMenu(t){this.popup(t,e=>{this.menuItems(e,Xt.map(([i,s])=>({label:this.blockLabel(i),previewStyle:i.startsWith("h")?`font-weight:700;font-size:${22-2*+i[1]}px`:i==="pre"?"font-family:monospace":"",on:this.currentBlock()===i,action:()=>this.exec("formatBlock","<"+i+">")})))})}blockLabel(t){return t==="p"?this.t("para"):t==="pre"?this.t("pre"):this.t("heading")+" "+t[1]}tableGrid(t,e){this.popup(t,i=>this.buildTableGridInto(i,e))}buildTableGridInto(t,e){{const i=document.createElement("div");i.className="tgridwrap";const s=document.createElement("div");s.className="tgrid";const r=document.createElement("div");r.className="tgridlbl",r.textContent="1 × 1";const l=[];for(let o=0;o<8;o++)for(let a=0;a<10;a++){const c=document.createElement("span");c.dataset.r=String(o),c.dataset.c=String(a),c.addEventListener("mouseenter",()=>{l.forEach(d=>d.classList.toggle("hot",+d.dataset.r<=o&&+d.dataset.c<=a)),r.textContent=a+1+" × "+(o+1)}),c.addEventListener("click",()=>{this.closePop(),this.insertTable(o+1,a+1),e==null||e()}),l.push(c),s.appendChild(c)}i.append(s,r),t.appendChild(i)}}insertTable(t,e){this.restoreSel();let i='<table style="border-collapse:collapse;width:100%;table-layout:fixed"><tbody>';for(let s=0;s<t;s++){i+="<tr>";for(let r=0;r<e;r++)i+='<td style="border:1px solid #b9c2cc"><br></td>';i+="</tr>"}i+="</tbody></table><p><br></p>",document.execCommand("insertHTML",!1,i),this.saveSel(),this.onChange()}setDir(t){this.restoreSel();const e=this.selectedBlocks();e.length?e.forEach(i=>i.setAttribute("dir",t)):this.ed.setAttribute("dir",t),this.saveSel(),this.refreshState(),this.onChange()}parseToolbarString(t){return t.split("|").map(e=>e.trim().split(/\s+/).filter(Boolean)).filter(e=>e.length>0)}buildToolbarRegistry(){const t=this.tbtn(h.tableic,this.t("quicktable"),()=>this.tableGrid(t));return{undo:()=>this.tbtn(h.undo,this.t("undo"),()=>this.exec("undo")),redo:()=>this.tbtn(h.redo,this.t("redo"),()=>this.exec("redo")),preview:()=>this.tbtn(h.prevw,this.t("preview"),()=>this.previewDlg()),print:()=>this.tbtn(h.printic,this.t("print"),()=>this.printDoc()),importword:()=>this.tbtn(h.wordic,this.t("importword"),()=>this.pickWordDoc()),revhistory:()=>this.tbtn(h.historyic,this.t("revhistory"),()=>this.revisionDlg()),fontfamily:()=>this.tsel("w-font","fontsel","",e=>this.fontMenu(e)),fontsize:()=>this.tsel("w-size","sizesel","",e=>this.sizeMenu(e)),fontsizeincrease:()=>this.stepBtn(1),fontsizedecrease:()=>this.stepBtn(-1),bold:()=>this.tbtn(h.bold,this.t("bold"),()=>this.exec("bold"),"bold"),italic:()=>this.tbtn(h.italic,this.t("italic"),()=>this.exec("italic"),"italic"),underline:()=>this.tbtn(h.underline,this.t("underline"),()=>this.exec("underline"),"underline"),strikethrough:()=>this.tbtn(h.strikethrough,this.t("strikethrough"),()=>this.exec("strikeThrough"),"strikeThrough"),forecolor:()=>this.colorChips(),backcolor:()=>this.menuTbtn(h.backcolor+'<span class="colorbar" data-cb="back"></span>',this.t("backcolor"),e=>this.colorMenu(e,"back")),alignleft:()=>this.tbtn(h.alignleft,this.t("alignleft"),()=>this.exec("justifyLeft"),"justifyLeft"),aligncenter:()=>this.tbtn(h.aligncenter,this.t("aligncenter"),()=>this.exec("justifyCenter"),"justifyCenter"),alignright:()=>this.tbtn(h.alignright,this.t("alignright"),()=>this.exec("justifyRight"),"justifyRight"),alignjustify:()=>this.tbtn(h.alignjustify,this.t("alignjustify"),()=>this.exec("justifyFull"),"justifyFull"),bullist:()=>this.menuTbtn(h.bullist,this.t("bullist"),e=>this.listMenu(e,"ul"),"insertUnorderedList"),numlist:()=>this.menuTbtn(h.numlist,this.t("numlist"),e=>this.listMenu(e,"ol"),"insertOrderedList"),outdent:()=>this.tbtn(h.outdent,this.t("outdent"),()=>this.exec("outdent")),indent:()=>this.tbtn(h.indent,this.t("indent"),()=>this.exec("indent")),link:()=>this.tbtn(h.link,this.t("linkttl"),()=>this.linkDlg()),blockquote:()=>this.tbtn(h.quote,this.t("quote"),()=>this.toggleBlock("blockquote"),"blockquote"),changecase:()=>this.menuTbtn(h.caseic,this.t("changecase"),e=>this.caseMenu(e)),lineheight:()=>this.menuTbtn(h.lineheight,this.t("lineheight"),e=>this.lineHeightMenu(e)),wordspacing:()=>this.menuTbtn(h.wordspacing,this.t("wordspacing"),e=>this.wordSpacingMenu(e)),removeformat:()=>this.tbtn(h.clearformatic,this.t("removeformat"),()=>this.exec("removeFormat")),blocks:()=>this.tsel("w-block","blocksel",this.t("para"),e=>this.blocksMenu(e)),ltr:()=>this.tbtn(h.ltr,this.t("ltr"),()=>this.setDir("ltr"),"ltr"),rtl:()=>this.tbtn(h.rtl,this.t("rtl"),()=>this.setDir("rtl"),"rtl"),quickimage:()=>this.tbtn(h.image,this.t("quickimage"),()=>this.insertImagePlaceholder()),quicktable:()=>t,template:()=>this.menuTbtn(h.templateic,this.t("template"),e=>this.templateMenu(e)),charmap:()=>this.tbtn(h.charic,this.t("charmap"),()=>this.charMap()),fullscreen:()=>this.tbtn(h.fullscreen,this.t("fullscreen"),()=>this.toggleFullscreen(),"fullscreen"),sourcecode:()=>this.tbtn(h.srcic,this.t("sourcecode"),()=>this.sourceDlg())}}buildToolbar(){this.toolbar.innerHTML="";const t=this.options.toolbar===!0?Ze:this.options.toolbar,e=this.buildToolbarRegistry();this.parseToolbarString(t).forEach(i=>{const s=[];i.forEach(r=>{const l=e[r];if(!l){console.warn(`FableEditor: unknown toolbar item "${r}"`);return}const o=l();Array.isArray(o)?s.push(...o):s.push(o)}),s.length&&this.toolbar.appendChild(this.group(...s))}),this.syncColorSwatches(this.toolbar)}mItem(t,e,i,s){return{label:this.t(t),icon:e,action:i,shortcut:s}}buildMenubar(){this.menubar.innerHTML="";const t={file:[this.mItem("newdoc",h.newic,()=>{this.recordRevision(),this.ed.innerHTML="<p><br></p>",this.onChange()}),"|",this.mItem("importword",h.wordic,()=>this.pickWordDoc()),this.mItem("restoredraft",h.draftic,()=>{this.restoreDraft()||alert(this.t("draftempty"))}),this.mItem("revhistory",h.historyic,()=>this.revisionDlg()),"|",this.mItem("preview",h.prevw,()=>this.previewDlg()),this.mItem("print",h.printic,()=>this.printDoc(),"Ctrl+P")],edit:[this.mItem("undo",h.undo,()=>this.exec("undo"),"Ctrl+Z"),this.mItem("redo",h.redo,()=>this.exec("redo"),"Ctrl+Y"),"|",this.mItem("cut",h.cutic,()=>this.exec("cut"),"Ctrl+X"),this.mItem("copy",h.copyic,()=>this.exec("copy"),"Ctrl+C"),this.mItem("paste",h.pasteic,()=>alert(this.t("pastehint")),"Ctrl+V"),"|",this.mItem("selectall",h.selall,()=>this.exec("selectAll"),"Ctrl+A")],view:[this.mItem("fullscreen",h.fullscreen,()=>this.toggleFullscreen()),this.mItem("preview",h.prevw,()=>this.previewDlg()),this.mItem("sourcecode",h.srcic,()=>this.sourceDlg())],insert:[this.mItem("link",h.link,()=>this.linkDlg()),this.mItem("image",h.image,()=>this.insertImagePlaceholder()),{label:this.t("inserttable"),icon:h.tableic,action:()=>this.tableGrid(this.menubar.querySelector('[data-menu-key="table"]')||this.menubar)},{label:this.t("template"),icon:h.templateic,subBuild:s=>this.buildTemplatePickInto(s)},this.mItem("hr",h.hric,()=>this.exec("insertHorizontalRule")),"|",this.mItem("charmap",h.charic,()=>this.charMap()),this.mItem("datetime",h.dateic,()=>this.exec("insertText",new Date().toLocaleString(this.lang==="ar"?"ar-AE":"en-GB"))),"|",{label:this.t("pagebreak"),icon:h.pbic,action:()=>{this.restoreSel(),document.execCommand("insertHTML",!1,'<hr class="pagebreak"><p><br></p>'),this.onChange()}},this.mItem("nbsp",h.nbspic,()=>this.exec("insertText"," "))],format:[this.mItem("bold",h.bold,()=>this.exec("bold"),"Ctrl+B"),this.mItem("italic",h.italic,()=>this.exec("italic"),"Ctrl+I"),this.mItem("underline",h.underline,()=>this.exec("underline"),"Ctrl+U"),this.mItem("strikethrough",h.strikethrough,()=>this.exec("strikeThrough")),this.mItem("superscript",h.superscriptic,()=>this.exec("superscript")),this.mItem("subscript",h.subscriptic,()=>this.exec("subscript")),"|",this.mItem("lowercase",h.lowercaseic,()=>this.transformCase("lower")),this.mItem("uppercase",h.uppercaseic,()=>this.transformCase("upper")),this.mItem("capitalize",h.capitalizeic,()=>this.transformCase("capitalize")),"|",this.mItem("clearformat",h.clearformatic,()=>this.exec("removeFormat"))],tools:[this.mItem("sourcecode",h.srcic,()=>this.sourceDlg()),this.mItem("wordcount",h.wcic,()=>this.wordCountDlg())],table:[{label:this.t("inserttable"),icon:h.tableic,subBuild:s=>this.buildTableGridInto(s)},"|",{label:this.t("cell"),sub:[{label:this.t("cellprops"),icon:h.tableic,action:()=>this.cellPropsDlg()}]},{label:this.t("row"),sub:[{label:this.t("rowabove"),icon:h.rowbefore,action:()=>this.tableOp("rowabove"),hover:s=>this.setOpTarget(s?"row":null)},{label:this.t("rowbelow"),icon:h.rowafter,action:()=>this.tableOp("rowbelow"),hover:s=>this.setOpTarget(s?"row":null)},{label:this.t("delrow"),icon:h.rowdelete,action:()=>this.tableOp("delrow"),hover:s=>this.setOpTarget(s?"row":null)},"|",{label:this.t("rowprops"),icon:h.tableic,action:()=>this.rowPropsDlg(),hover:s=>this.setOpTarget(s?"row":null)}]},{label:this.t("column"),sub:[{label:this.t("colbefore"),icon:h.colbefore,action:()=>this.tableOp("colbefore"),hover:s=>this.setOpTarget(s?"col":null)},{label:this.t("colafter"),icon:h.colafter,action:()=>this.tableOp("colafter"),hover:s=>this.setOpTarget(s?"col":null)},{label:this.t("delcol"),icon:h.coldelete,action:()=>this.tableOp("delcol"),hover:s=>this.setOpTarget(s?"col":null)},"|",{label:this.t("colprops"),icon:h.tableic,action:()=>this.colPropsDlg(),hover:s=>this.setOpTarget(s?"col":null)}]},"|",{label:this.t("tablepropsttl"),icon:h.tableic,action:()=>{const s=this.currentCell();if(!s){alert(this.t("nocell"));return}this.tblActive=s.closest("table"),this.tablePropsDlg()}},{label:this.t("deltable"),icon:h.trash,action:()=>this.tableOp("deltable")}],help:[this.mItem("helpttl",h.helpic,()=>this.helpDlg(),"Alt+0")]},e=this.options.menubar===!0?Pe:this.options.menubar,i=new Set;e.split(/\s+/).filter(Boolean).forEach(s=>{if(i.has(s))return;if(i.add(s),!t[s]){console.warn(`FableEditor: unknown menubar item "${s}"`);return}const r=document.createElement("button");r.type="button",r.textContent=this.t(s),r.dataset.menuKey=s,r.addEventListener("mousedown",l=>{l.preventDefault(),this.saveSel()}),r.addEventListener("click",()=>this.popup(r,l=>this.menuItems(l,t[s]))),this.menubar.appendChild(r)})}tableOp(t){var a,c,d;this.restoreSel();const e=window.getSelection();if(!e)return;const i=((a=this.closestBlock(e.anchorNode))==null?void 0:a.closest("td,th"))||(e.anchorNode&&e.anchorNode.nodeType===1?(d=(c=e.anchorNode).closest)==null?void 0:d.call(c,"td,th"):null);if(!i)return;const s=i.parentElement,r=i.closest("table"),l=Array.from(s.children).indexOf(i),o=()=>{const u=s.cloneNode(!1);return Array.from(s.children).forEach(v=>{const b=document.createElement("td"),f=v.getAttribute("style");f&&b.setAttribute("style",f),b.style.removeProperty("background-color"),b.innerHTML="<br>",u.appendChild(b)}),u};if(t==="rowabove"&&s.before(o()),t==="rowbelow"&&s.after(o()),t==="delrow"){const u=s.parentElement;s.remove(),u.querySelector("tr")||r.remove()}(t==="colbefore"||t==="colafter")&&r.querySelectorAll("tr").forEach(u=>{const v=u.children[Math.min(l,u.children.length-1)],b=document.createElement("td"),f=v.getAttribute("style");f&&b.setAttribute("style",f),b.style.removeProperty("width"),b.style.removeProperty("background-color"),b.innerHTML="<br>",t==="colbefore"?v.before(b):v.after(b)}),t==="delcol"&&(r.querySelectorAll("tr").forEach(u=>{var v;return(v=u.children[l])==null?void 0:v.remove()}),r.querySelector("td,th")||r.remove()),t==="deltable"&&r.remove(),this.onChange(),this.positionTableHandles()}applyTableProps(t,e){e.width?t.style.width=/^\d+$/.test(e.width)?e.width+"px":e.width:t.style.removeProperty("width");const i=Array.from(t.querySelectorAll("td,th"));e.cellpadding!==""?i.forEach(s=>s.style.padding=e.cellpadding+"px"):i.forEach(s=>s.style.removeProperty("padding")),e.cellspacing!==""?(t.style.borderCollapse="separate",t.style.borderSpacing=e.cellspacing+"px"):(t.style.borderCollapse="collapse",t.style.removeProperty("border-spacing")),e.border!==""&&+e.border>0?(t.style.border=e.border+"px solid #b9c2cc",i.forEach(s=>s.style.border=e.border+"px solid #b9c2cc")):(t.style.removeProperty("border"),i.forEach(s=>s.style.removeProperty("border"))),t.style.removeProperty("margin-left"),t.style.removeProperty("margin-right"),e.align==="center"?(t.style.marginLeft="auto",t.style.marginRight="auto"):e.align==="right"?(t.style.marginLeft="auto",t.style.marginRight="0"):e.align==="left"&&(t.style.marginLeft="0",t.style.marginRight="auto")}tablePropsDlg(){const t=this.tblActive;if(!t)return;let e,i,s,r,l;const o="display:flex;align-items:center;gap:10px;margin:10px 0",a="width:120px;color:#556;flex:none",c="flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit",d=t.querySelector("td,th"),u=t.style.width||"",v=d&&d.style.padding?parseFloat(d.style.padding):"",b=t.style.borderSpacing?parseFloat(t.style.borderSpacing):"",f=t.style.borderWidth?parseFloat(t.style.borderWidth):"",w=t.style.marginLeft,E=t.style.marginRight,q=w==="auto"&&E==="auto"?"center":w==="auto"?"right":E==="auto"&&w==="0"?"left":"";this.dialog(this.t("tablepropsttl"),M=>{const P=(I,$)=>{const F=document.createElement("div");F.style.cssText=o;const Y=document.createElement("span");Y.style.cssText=a,Y.textContent=this.t(I),F.append(Y,$),M.appendChild(F)};e=document.createElement("input"),e.type="text",e.style.cssText=c,e.placeholder="e.g. 600px or 100%",e.value=u,P("tblwidth",e),i=document.createElement("input"),i.type="number",i.min="0",i.style.cssText=c,i.value=String(v),P("tblcellpadding",i),s=document.createElement("input"),s.type="number",s.min="0",s.style.cssText=c,s.value=String(b),P("tblcellspacing",s),r=document.createElement("input"),r.type="number",r.min="0",r.style.cssText=c,r.value=String(f),P("tblborder",r),l=document.createElement("select"),l.style.cssText=c,[["","alignnone"],["left","alignleft"],["center","aligncenter"],["right","alignright"]].forEach(([I,$])=>{const F=document.createElement("option");F.value=I,F.textContent=this.t($),I===q&&(F.selected=!0),l.appendChild(F)}),P("tblalign",l)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{this.applyTableProps(t,{width:e.value.trim(),cellpadding:i.value.trim(),cellspacing:s.value.trim(),border:r.value.trim(),align:l.value}),this.closeDlg(),this.onChange(),this.positionTableHandles()}}])}currentCell(){let t=this.savedRange?this.savedRange.startContainer:null;if(!t||!this.ed.contains(t)){const e=window.getSelection();t=e&&this.ed.contains(e.anchorNode)?e.anchorNode:null}for(;t&&t!==this.ed;){if(t.nodeType===1&&/^(TD|TH)$/.test(t.tagName))return t;t=t.parentNode}return null}toHexColor(t){if(/^#[0-9a-fA-F]{6}$/.test(t))return t;const e=/rgba?\((\d+)[,\s]+(\d+)[,\s]+(\d+)/.exec(t);return e?"#"+[e[1],e[2],e[3]].map(i=>(+i).toString(16).padStart(2,"0")).join(""):""}formRow(t,e,i){const s=document.createElement("div");s.style.cssText="display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";const r=document.createElement("span");r.style.cssText="width:120px;color:#556;flex:none",r.textContent=e,s.append(r,i),t.appendChild(s)}formInput(t,e=""){const i=document.createElement("input");return i.type="text",i.style.cssText="flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;min-width:0",i.value=t,i.placeholder=e,i}formSelect(t,e){const i=document.createElement("select");return i.style.cssText="flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;background:#fff",t.forEach(([s,r])=>{const l=document.createElement("option");l.value=s,l.textContent=r,s===e&&(l.selected=!0),i.appendChild(l)}),i}formBg(t){const e=document.createElement("div");e.style.cssText="flex:1;display:flex;align-items:center;gap:8px";const i=this.toHexColor(t),s=document.createElement("input");s.type="color",s.value=i||"#ffffff",s.style.cssText="width:36px;height:29px;border:1px solid #cfd6df;border-radius:4px;padding:1px;background:none;cursor:pointer";const r=document.createElement("label");r.style.cssText="display:flex;align-items:center;gap:6px;cursor:pointer;color:#556";const l=document.createElement("input");return l.type="checkbox",l.checked=!!i,r.append(l,document.createTextNode(this.t("fill"))),s.addEventListener("input",()=>l.checked=!0),e.append(s,r),{wrap:e,color:s,fill:l}}setOrClear(t,e,i){i?t.style.setProperty(e,/^(width|height)$/.test(e)&&/^\d+$/.test(i)?i+"px":i):t.style.removeProperty(e)}cellPropsDlg(){const t=this.currentCell();if(!t){alert(this.t("nocell"));return}let e,i,s,r,l;this.dialog(this.t("cellprops").replace("…",""),o=>{e=this.formInput(t.style.width,"e.g. 120px / 25%"),this.formRow(o,this.t("tblwidth"),e),i=this.formInput(t.style.height,"e.g. 40px"),this.formRow(o,this.t("tblheight"),i),s=this.formSelect([["",this.t("alignnone")],["left",this.t("alignleft")],["center",this.t("aligncenter")],["right",this.t("alignright")]],t.style.textAlign||""),this.formRow(o,this.t("tblalign"),s),r=this.formSelect([["",this.t("alignnone")],["top",this.t("valigntop")],["middle",this.t("valignmiddle")],["bottom",this.t("valignbottom")]],t.style.verticalAlign||""),this.formRow(o,this.t("valign"),r),l=this.formBg(t.style.backgroundColor||""),this.formRow(o,this.t("backcolor"),l.wrap)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{this.setOrClear(t,"width",e.value.trim()),this.setOrClear(t,"height",i.value.trim()),this.setOrClear(t,"text-align",s.value),this.setOrClear(t,"vertical-align",r.value),this.setOrClear(t,"background-color",l.fill.checked?l.color.value:""),this.closeDlg(),this.onChange(),this.positionTableHandles()}}])}rowPropsDlg(){const t=this.currentCell();if(!t){alert(this.t("nocell"));return}const e=t.parentElement;let i,s;this.dialog(this.t("rowprops").replace("…",""),r=>{i=this.formInput(e.style.height,"e.g. 40px"),this.formRow(r,this.t("tblheight"),i),s=this.formBg(e.style.backgroundColor||""),this.formRow(r,this.t("backcolor"),s.wrap)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{this.setOrClear(e,"height",i.value.trim()),this.setOrClear(e,"background-color",s.fill.checked?s.color.value:""),this.closeDlg(),this.onChange(),this.positionTableHandles()}}])}colPropsDlg(){const t=this.currentCell();if(!t){alert(this.t("nocell"));return}const e=t.parentElement,i=t.closest("table"),s=Array.from(e.children).indexOf(t),r=Array.from(i.rows).map(a=>a.cells[s]).filter(Boolean);let l,o;this.dialog(this.t("colprops").replace("…",""),a=>{l=this.formInput(t.style.width,"e.g. 120px / 25%"),this.formRow(a,this.t("tblwidth"),l),o=this.formBg(t.style.backgroundColor||""),this.formRow(a,this.t("backcolor"),o.wrap)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{r.forEach(a=>{this.setOrClear(a,"width",l.value.trim()),this.setOrClear(a,"background-color",o.fill.checked?o.color.value:"")}),this.closeDlg(),this.onChange(),this.positionTableHandles()}}])}closeDlg(){this.dlgOvl&&(this.dlgOvl.remove(),this.dlgOvl=null)}dialog(t,e,i){this.closeDlg(),this.closePop(),this.dlgOvl=document.createElement("div"),this.dlgOvl.className="ovl";const s=document.createElement("div");s.className="dlg",s.dir=this.dir(),s.innerHTML=`<header><span>${t}</span><button type="button">×</button></header>
37
37
  <div class="body"></div><footer></footer>`,s.querySelector("header button").onclick=()=>this.closeDlg(),e(s.querySelector(".body")),(i||[{label:this.t("close"),primary:!0,action:()=>this.closeDlg()}]).forEach(r=>{const l=document.createElement("button");l.type="button",l.textContent=r.label,r.primary&&(l.className="pri"),l.onclick=r.action,s.querySelector("footer").appendChild(l)}),this.dlgOvl.appendChild(s),this.dlgOvl.addEventListener("mousedown",r=>{r.target===this.dlgOvl&&this.closeDlg()}),document.body.appendChild(this.dlgOvl)}sourceDlg(){let t;this.dialog(this.t("srcttl"),e=>{t=document.createElement("textarea"),t.value=this.ed.innerHTML.replace(/></g,`>
38
38
  <`),e.appendChild(t)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{this.ed.innerHTML=t.value,this.closeDlg(),this.onChange()}}])}helpDlg(){this.dialog(this.t("helpttl"),t=>{const e=[["Ctrl+B",this.t("bold")],["Ctrl+I",this.t("italic")],["Ctrl+U",this.t("underline")],["Ctrl+Z",this.t("undo")],["Ctrl+Y",this.t("redo")],["Ctrl+A",this.t("selectall")],["Alt+0",this.t("helpttl")]];t.innerHTML=`<p style="color:#556">${this.t("shortcuts")}</p>
39
39
  <table class="kbd">${e.map(i=>`<tr><td>${i[1]}</td><td><kbd>${i[0]}</kbd></td></tr>`).join("")}</table>`})}wordCountDlg(){this.dialog(this.t("wcttl"),t=>{var e;t.innerHTML=`<table class="kbd">
40
40
  <tr><td>${this.t("wcwords")}</td><td>${this.countWords()}</td></tr>
41
- <tr><td>${this.t("wcchars")}</td><td>${((e=this.ed.textContent)==null?void 0:e.replace(/\s/g,"").length)??0}</td></tr></table>`})}previewDlg(){this.dialog(this.t("previewttl"),t=>{const e=document.createElement("div");e.style.cssText="width:640px;max-width:78vw;max-height:52vh;overflow:auto;border:1px solid #e3e3e3;border-radius:6px;padding:14px;font-family:Helvetica,Arial,sans-serif;font-size:14px",e.innerHTML=this.ed.innerHTML,t.appendChild(e)})}charMap(){this.dialog(this.t("charmap").replace("…",""),t=>{const e=document.createElement("div");e.className="chgrid",$e.forEach(i=>{const s=document.createElement("button");s.textContent=i,s.onclick=()=>{this.closeDlg(),this.exec("insertText",i)},e.appendChild(s)}),t.appendChild(e)})}printDoc(){const t=window.open("","_blank");t&&(t.document.write(`<html dir="${this.dir()}"><body style="font-family:Helvetica,Arial,sans-serif;font-size:14px">${this.ed.innerHTML}</body></html>`),t.document.close(),t.focus(),t.print())}pickImage(){this.imgInput.value="",this.imgInput.click()}insertImagePlaceholder(){this.restoreSel();const t="img-ph-"+Date.now().toString(36)+Math.random().toString(36).slice(2,6);document.execCommand("insertHTML",!1,`<div class="img-ph" id="${t}" contenteditable="false">${h.image}<span>${this.t("dropimage")}</span></div>`);const e=this.ed.querySelector("#"+t);e&&(e.removeAttribute("id"),this.selectImgPlaceholder(e)),this.onChange()}clearImgPlaceholderSel(){var t,e;(t=this.phCtx)==null||t.remove(),this.phCtx=null,(e=this.phActive)==null||e.classList.remove("active"),this.phActive=null}selectImgPlaceholder(t){this.phActive!==t&&(this.clearImgPlaceholderSel(),this.phActive=t,t.classList.add("active"),this.phCtx=document.createElement("div"),this.phCtx.className="imgctx img-ph-ctx",this.phCtx.dir=this.dir(),document.body.appendChild(this.phCtx),this.renderPhCtxButtons())}renderPhCtxButtons(){const t=this.phCtx;t&&(t.innerHTML="",t.append(this.ctxBtn(h.uploadic,this.t("uploadimg"),()=>{this.phUploadTarget=this.phActive,this.pickImage()}),this.ctxBtn(h.link,this.t("imagelink"),()=>this.renderPhCtxUrlInput())),this.positionImgPhCtx())}renderPhCtxUrlInput(){const t=this.phCtx;if(!t)return;t.innerHTML="";const e=document.createElement("input");e.type="url",e.className="urlinp",e.placeholder=this.t("imageurlph");const i=document.createElement("button");i.type="button",i.className="txtbtn",i.textContent=this.t("insertimg");const s=()=>{const r=e.value.trim(),l=this.phActive;if(!l)return;if(!/^(https?:|data:image\/|blob:)/i.test(r)){e.classList.add("err"),e.focus();return}i.disabled=!0,e.disabled=!0;const o=new Image;o.onload=()=>this.replacePlaceholderWithImage(l,r,""),o.onerror=()=>{i.disabled=!1,e.disabled=!1,e.classList.add("err"),e.focus()},o.src=r};i.addEventListener("click",s),e.addEventListener("input",()=>e.classList.remove("err")),e.addEventListener("keydown",r=>{r.key==="Enter"?(r.preventDefault(),s()):r.key==="Escape"&&(r.stopPropagation(),this.renderPhCtxButtons())}),t.append(e,i),this.positionImgPhCtx(),e.focus()}readImageFileInto(t,e){if(e.classList.contains("uploading"))return;if(this.imageUploadHandler){this.uploadImageFile(t,e);return}const i=new FileReader;i.onload=()=>{this.ed.contains(e)&&this.replacePlaceholderWithImage(e,i.result,t.name.replace(/"/g,""))},i.readAsDataURL(t)}uploadImageFile(t,e){const i=t.name.replace(/"/g,"");e.classList.remove("upload-error"),e.classList.add("uploading");const s=e.querySelector("span");s&&(s.textContent=this.t("uploading")),this.imageUploadHandler(t).then(r=>{this.ed.contains(e)&&this.replacePlaceholderWithImage(e,r,i)}).catch(r=>{var l;this.ed.contains(e)&&(e.classList.remove("uploading"),e.classList.add("upload-error"),s&&(s.textContent=this.t("uploadfailed")),(l=this.onImageUploadError)==null||l.call(this,r,t))})}replacePlaceholderWithImage(t,e,i){const s=document.createElement("img");s.src=e,s.alt="",i&&(s.title=i),t.replaceWith(s),this.phActive===t&&this.clearImgPlaceholderSel(),this.refreshState(),this.onChange()}positionImgPhCtx(){if(this.phActive&&!document.body.contains(this.phActive)){this.clearImgPlaceholderSel();return}if(!this.phActive||!this.phCtx)return;const t=this.phActive.getBoundingClientRect(),e=this.phCtx.offsetWidth,i=this.phCtx.offsetHeight;let s=t.left+scrollX+(t.width-e)/2;s=Math.max(8+scrollX,Math.min(s,scrollX+innerWidth-e-8));let r=t.bottom+scrollY+8;t.bottom+8+i>innerHeight-4&&(r=Math.max(this.ctxMinTop(),t.top+scrollY-i-8)),this.phCtx.style.left=s+"px",this.phCtx.style.top=r+"px"}pickWordDoc(){this.docInput.value="",this.docInput.click()}toggleFullscreen(){this.shell.classList.toggle("fullscreen");const t=this.toolbar.querySelector("[data-id=fullscreen]");t==null||t.classList.toggle("on",this.shell.classList.contains("fullscreen")),this.positionTableHandles()}clearTableHandles(){var t,e,i,s,r;(t=this.tblCorner)==null||t.remove(),this.tblCorner=null,this.tblColBars.forEach(l=>l.remove()),this.tblColBars=[],(e=this.tblCtx)==null||e.remove(),this.tblCtx=null,(i=this.tblCellMark)==null||i.remove(),this.tblCellMark=null,(s=this.tblOpMark)==null||s.remove(),this.tblOpMark=null,this.tblOpMarkKind=null,(r=this.tblActive)==null||r.classList.remove("tbl-selected"),this.tblActive=null}positionCellMarker(){if(!this.tblCellMark)return;const t=this.currentCell();if(!t||!this.tblActive||t.closest("table")!==this.tblActive){this.tblCellMark.style.display="none";return}const e=t.getBoundingClientRect();this.tblCellMark.style.display="block",this.tblCellMark.style.left=e.left+scrollX+"px",this.tblCellMark.style.top=e.top+scrollY+"px",this.tblCellMark.style.width=e.width+"px",this.tblCellMark.style.height=e.height+"px"}setOpTarget(t){this.tblOpMarkKind=t,this.positionOpMark()}positionOpMark(){var d;const t=this.tblOpMarkKind,e=t?this.currentCell():null;if(!t||!e||!this.tblActive||e.closest("table")!==this.tblActive){(d=this.tblOpMark)==null||d.remove(),this.tblOpMark=null;return}this.tblOpMark||(this.tblOpMark=document.createElement("div"),this.tblOpMark.className="tbl-opmark",document.body.appendChild(this.tblOpMark));const i=this.tblActive.getBoundingClientRect(),s=e.getBoundingClientRect(),r=e.parentElement.getBoundingClientRect(),l=t==="row"?r.left:s.left,o=t==="row"?r.top:i.top,a=t==="row"?r.width:s.width,c=t==="row"?r.height:i.height;this.tblOpMark.style.left=l+scrollX+"px",this.tblOpMark.style.top=o+scrollY+"px",this.tblOpMark.style.width=a+"px",this.tblOpMark.style.height=c+"px"}ctxMinTop(){return Math.max(scrollY+4,this.ed.getBoundingClientRect().top+scrollY-2)}ctxBtn(t,e,i,s){const r=document.createElement("button");return r.type="button",r.title=e,r.innerHTML=t,s&&(r.dataset.id=s),r.addEventListener("mousedown",l=>l.preventDefault()),r.addEventListener("click",i),r}ctxSep(){const t=document.createElement("div");return t.className="sep",t}buildTableCtxToolbar(){const t=document.createElement("div");t.className="tblctx",t.dir=this.dir();const e=(i,s)=>(i.addEventListener("mouseenter",()=>this.setOpTarget(s)),i.addEventListener("mouseleave",()=>this.setOpTarget(null)),i);return t.append(e(this.ctxBtn(h.rowbefore,this.t("rowabove"),()=>this.tableOp("rowabove")),"row"),e(this.ctxBtn(h.rowafter,this.t("rowbelow"),()=>this.tableOp("rowbelow")),"row"),e(this.ctxBtn(h.rowdelete,this.t("delrow"),()=>this.tableOp("delrow")),"row"),this.ctxSep(),e(this.ctxBtn(h.colbefore,this.t("colbefore"),()=>this.tableOp("colbefore")),"col"),e(this.ctxBtn(h.colafter,this.t("colafter"),()=>this.tableOp("colafter")),"col"),e(this.ctxBtn(h.coldelete,this.t("delcol"),()=>this.tableOp("delcol")),"col"),this.ctxSep(),this.ctxBtn(h.tabledelete,this.t("deltable"),()=>this.tableOp("deltable")),this.ctxBtn(h.tableic,this.t("tablepropsttl"),()=>this.tablePropsDlg())),document.body.appendChild(t),t}positionTableHandles(){if(!this.tblActive||!document.body.contains(this.tblActive)){this.clearTableHandles();return}const t=this.ed.getAttribute("dir")==="rtl",e=this.tblActive.getBoundingClientRect(),i=e.top+scrollY,s=e.left+scrollX,r=e.right+scrollX,l=e.bottom+scrollY;if(this.tblCorner&&(this.tblCorner.style.top=l-5+"px",this.tblCorner.style.left=(t?s-5:r-5)+"px",this.tblCorner.style.cursor=t?"nesw-resize":"nwse-resize"),this.tblCtx){const a=this.tblCtx.offsetWidth,c=this.tblCtx.offsetHeight;let d=s+(r-s)/2-a/2;d=Math.max(8+scrollX,Math.min(d,scrollX+innerWidth-a-8));let u=i-c-8;u<this.ctxMinTop()&&(u=l+8),this.tblCtx.style.left=d+"px",this.tblCtx.style.top=u+"px"}this.tblColBars.forEach(a=>a.remove()),this.tblColBars=[];const o=this.tblActive.rows[0];if(o)for(let a=0;a<o.cells.length-1;a++){const c=o.cells[a].getBoundingClientRect(),d=(t?c.left:c.right)+scrollX,u=document.createElement("div");u.className="tbl-colbar",u.style.top=i+"px",u.style.left=d+"px",u.style.height=l-i+"px",document.body.appendChild(u),u.addEventListener("mousedown",v=>this.startColBarDrag(v,a)),this.tblColBars.push(u)}this.positionCellMarker(),this.positionOpMark()}selectTableForResize(t){this.tblActive!==t&&(this.clearTableHandles(),this.tblActive=t,t.classList.add("tbl-selected"),this.tblCorner=document.createElement("div"),this.tblCorner.className="tbl-handle",document.body.appendChild(this.tblCorner),this.tblCorner.addEventListener("mousedown",e=>this.startTableCornerDrag(e)),this.tblCellMark=document.createElement("div"),this.tblCellMark.className="tbl-cellmark",this.tblCellMark.style.display="none",document.body.appendChild(this.tblCellMark),this.tblCtx=this.buildTableCtxToolbar(),this.positionTableHandles())}withNoTextSelect(t){const e=document.body.style.userSelect;document.body.style.userSelect="none",t(()=>{document.body.style.userSelect=e})}startTableCornerDrag(t){t.preventDefault();const e=this.tblActive;if(!e)return;const i=this.ed.getAttribute("dir")==="rtl",s=t.clientX,r=e.getBoundingClientRect().width;e.style.tableLayout=e.style.tableLayout||"fixed",this.withNoTextSelect(l=>{const o=c=>{const d=i?-(c.clientX-s):c.clientX-s;e.style.width=Math.max(60,Math.round(r+d))+"px",this.positionTableHandles()},a=()=>{window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a),l(),this.onChange()};window.addEventListener("mousemove",o),window.addEventListener("mouseup",a)})}startColBarDrag(t,e){t.preventDefault(),t.stopPropagation();const i=this.tblActive;if(!i)return;const s=this.ed.getAttribute("dir")==="rtl",r=Array.from(i.rows),l=r.map(u=>u.cells[e]).filter(Boolean),o=r.map(u=>u.cells[e+1]).filter(Boolean);if(!l.length||!o.length)return;const a=t.clientX,c=l[0].getBoundingClientRect().width,d=o[0].getBoundingClientRect().width;i.style.tableLayout="fixed",this.withNoTextSelect(u=>{const v=f=>{const w=(s?-1:1)*(f.clientX-a);l.forEach(E=>E.style.width=Math.max(24,Math.round(c+w))+"px"),o.forEach(E=>E.style.width=Math.max(24,Math.round(d-w))+"px"),this.positionTableHandles()},b=()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b),u(),this.onChange()};window.addEventListener("mousemove",v),window.addEventListener("mouseup",b)})}cancelImgHide(){this.imgHideTimer!=null&&(window.clearTimeout(this.imgHideTimer),this.imgHideTimer=null)}scheduleImgHide(){this.cancelImgHide(),this.imgHideTimer=window.setTimeout(()=>this.clearImageHandles(),250)}clearImageHandles(){var t,e;this.cancelImgHide(),this.imgHandles.forEach(i=>i.remove()),this.imgHandles=[],(t=this.imgCtx)==null||t.remove(),this.imgCtx=null,(e=this.imgActive)==null||e.classList.remove("img-selected"),this.imgActive=null}selectImage(t){this.imgActive!==t&&(this.clearImageHandles(),this.imgActive=t,t.classList.add("img-selected"),this.imgHandles=li.map(e=>{const i=document.createElement("div");return i.className="img-handle img-handle-"+e,i.dataset.corner=e,i.addEventListener("mousedown",s=>this.startImageResizeDrag(s,e)),i.addEventListener("mouseenter",()=>this.cancelImgHide()),i.addEventListener("mouseleave",()=>this.scheduleImgHide()),document.body.appendChild(i),i}),this.imgCtx=this.buildImageCtxToolbar(t),this.positionImageHandles())}buildImageCtxToolbar(t){const e=document.createElement("div");e.className="imgctx",e.dir=this.dir();const i=()=>{var d;const c=this.buildImageCtxToolbar(t);(d=this.imgCtx)==null||d.replaceWith(c),this.imgCtx=c,this.positionImageHandles()},s=c=>{this.setImageAlign(t,c),i()},r=t.style.float==="left",l=t.style.float==="right",o=!r&&!l&&t.style.marginLeft==="auto"&&t.style.marginRight==="auto",a=(c,d,u,v)=>{const b=this.ctxBtn(c,d,v);return b.classList.toggle("on",u),b};return e.append(a(h.alignleft,this.t("alignleft"),r,()=>s("left")),a(h.aligncenter,this.t("aligncenter"),o,()=>s("center")),a(h.alignright,this.t("alignright"),l,()=>s("right")),this.ctxSep(),a(h.rotateleft,this.t("rotateleft"),!1,()=>{this.rotateImage(t,-90),i()}),a(h.rotateright,this.t("rotateright"),!1,()=>{this.rotateImage(t,90),i()}),this.ctxSep(),a(h.fliphorizontal,this.t("fliphorizontal"),t.dataset.flipx==="1",()=>{this.flipImage(t,"x"),i()}),a(h.flipvertical,this.t("flipvertical"),t.dataset.flipy==="1",()=>{this.flipImage(t,"y"),i()}),this.ctxSep(),a(h.trash,this.t("deleteimg"),!1,()=>{t.remove(),this.clearImageHandles(),this.onChange()})),e.addEventListener("mousedown",c=>c.preventDefault()),e.addEventListener("mouseenter",()=>this.cancelImgHide()),e.addEventListener("mouseleave",()=>this.scheduleImgHide()),document.body.appendChild(e),e}setImageAlign(t,e){t.style.float="",t.style.display="",t.style.marginLeft="",t.style.marginRight="",t.style.marginBottom="",e==="left"?(t.style.float="left",t.style.marginInlineEnd="1em",t.style.marginBottom="0.5em"):e==="right"?(t.style.float="right",t.style.marginInlineStart="1em",t.style.marginBottom="0.5em"):(t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="auto"),this.onChange()}applyImgTransform(t){const e=parseInt(t.dataset.rotate||"0",10),i=t.dataset.flipx==="1"?-1:1,s=t.dataset.flipy==="1"?-1:1;t.style.transform=e||i<0||s<0?`rotate(${e}deg) scale(${i}, ${s})`:""}rotateImage(t,e){const i=((parseInt(t.dataset.rotate||"0",10)+e)%360+360)%360;t.dataset.rotate=String(i),this.applyImgTransform(t),this.positionImageHandles(),this.onChange()}flipImage(t,e){const i=e==="x"?"flipx":"flipy";t.dataset[i]=t.dataset[i]==="1"?"":"1",this.applyImgTransform(t),this.positionImageHandles(),this.onChange()}positionImageHandles(){if(!this.imgActive||!document.body.contains(this.imgActive)){this.clearImageHandles();return}const t=this.imgActive.getBoundingClientRect(),e=t.top+scrollY,i=t.left+scrollX,s=t.right+scrollX,r=t.bottom+scrollY,l={nw:[i,e],ne:[s,e],sw:[i,r],se:[s,r]};if(this.imgHandles.forEach(o=>{const[a,c]=l[o.dataset.corner];o.style.left=a-5+"px",o.style.top=c-5+"px"}),this.imgCtx){const o=this.imgCtx.offsetWidth,a=this.imgCtx.offsetHeight;let c=i+(s-i)/2-o/2;c=Math.max(8+scrollX,Math.min(c,scrollX+innerWidth-o-8));let d=e-a-8;d<this.ctxMinTop()&&(d=r+8),this.imgCtx.style.left=c+"px",this.imgCtx.style.top=d+"px"}}startImageResizeDrag(t,e){t.preventDefault();const i=this.imgActive;if(!i)return;this.cancelImgHide();const s=t.clientX,r=i.getBoundingClientRect().width,l=e==="nw"||e==="sw"?-1:1;this.withNoTextSelect(o=>{const a=d=>{i.style.width=Math.max(24,Math.round(r+l*(d.clientX-s)))+"px",i.style.height="auto",this.positionImageHandles()},c=()=>{window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",c),o(),this.onChange()};window.addEventListener("mousemove",a),window.addEventListener("mouseup",c)})}toggleBlock(t){this.exec("formatBlock",this.currentBlock()===t?"<p>":"<"+t+">")}clearSelToolbar(){var t;(t=this.selCtx)==null||t.remove(),this.selCtx=null}updateSelToolbar(t){if(this.options.readonly||t.isCollapsed||!t.rangeCount){this.clearSelToolbar();return}const e=t.getRangeAt(0),i=e.getBoundingClientRect();if(!i.width&&!i.height){this.clearSelToolbar();return}this.selCtx||(this.selCtx=this.buildSelToolbar()),this.positionSelToolbar(e)}buildSelToolbar(){var o;const t=document.createElement("div");t.className="selctx",t.dir=this.dir();const e=this.ctxBtn('<b style="font:600 15px/1 Georgia,serif">A</b><span class="colorbar" data-cb="fore"></span>',this.t("forecolor"),()=>this.colorMenu(e,"fore")),i=this.ctxBtn(h.backcolor,this.t("backcolor"),()=>this.colorMenu(i,"back"));(o=i.querySelector("svg"))==null||o.insertAdjacentHTML("afterend",'<span class="colorbar" data-cb="back"></span>');const s=this.ctxBtn(h.caseic,this.t("changecase"),()=>this.caseMenu(s)),r=this.ctxBtn(h.lineheight,this.t("lineheight"),()=>this.lineHeightMenu(r)),l=this.ctxBtn(h.wordspacing,this.t("wordspacing"),()=>this.wordSpacingMenu(l));return t.append(this.ctxBtn(h.bold,this.t("bold"),()=>this.exec("bold"),"bold"),this.ctxBtn(h.italic,this.t("italic"),()=>this.exec("italic"),"italic"),e,i,this.ctxSep(),this.ctxBtn(h.quote,this.t("quote"),()=>this.toggleBlock("blockquote"),"blockquote"),this.ctxBtn('<b style="font:700 12px/1 Arial,sans-serif">H2</b>',this.blockLabel("h2"),()=>this.toggleBlock("h2"),"h2"),this.ctxBtn('<b style="font:700 12px/1 Arial,sans-serif">H3</b>',this.blockLabel("h3"),()=>this.toggleBlock("h3"),"h3"),this.ctxSep(),this.ctxBtn(h.link,this.t("linkttl"),()=>this.linkDlg()),s,r,l),t.addEventListener("mousedown",a=>a.preventDefault()),document.body.appendChild(t),this.syncColorSwatches(t),t}positionSelToolbar(t){if(!this.selCtx)return;const e=t.getBoundingClientRect(),i=e.top+scrollY,s=e.left+scrollX,r=e.right+scrollX,l=e.bottom+scrollY,o=this.selCtx.offsetWidth,a=this.selCtx.offsetHeight;let c=s+(r-s)/2-o/2;c=Math.max(8+scrollX,Math.min(c,scrollX+innerWidth-o-8));let d=i-a-8;d<this.ctxMinTop()&&(d=l+8),this.selCtx.style.left=c+"px",this.selCtx.style.top=d+"px"}repositionSelToolbar(){if(!this.selCtx)return;const t=window.getSelection();t&&t.rangeCount&&!t.isCollapsed&&this.ed.contains(t.anchorNode)&&this.positionSelToolbar(t.getRangeAt(0))}currentBlock(){const t=window.getSelection();if(!t||!t.anchorNode||!this.ed.contains(t.anchorNode))return"p";const e=this.closestBlock(t.anchorNode);return e?e.tagName.toLowerCase().replace("div","p"):"p"}fontRefEl(){const t=window.getSelection();return t&&t.anchorNode&&this.ed.contains(t.anchorNode)?t.anchorNode.nodeType===1?t.anchorNode:t.anchorNode.parentElement:this.ed}currentFont(){const t=getComputedStyle(this.fontRefEl()).fontFamily.toLowerCase(),e=this.options.fontFamilyFormats.find(([i,s])=>t.includes(s.split(",")[0].toLowerCase()));return e?e[0]:""}currentSize(){const t=Math.round(parseFloat(getComputedStyle(this.fontRefEl()).fontSize));return t>0?t+"px":""}refreshState(){var a,c,d;const t=window.getSelection(),e=t?this.ed.contains(t.anchorNode):!1,i=this.currentBlock();[this.toolbar,this.selCtx].filter(Boolean).forEach(u=>{["bold","italic","underline","strikeThrough","justifyLeft","justifyCenter","justifyRight","justifyFull","insertOrderedList","insertUnorderedList"].forEach(v=>{const b=u.querySelector(`[data-id=${v}]`);b&&b.classList.toggle("on",e&&document.queryCommandState(v))}),["h2","h3","blockquote"].forEach(v=>{const b=u.querySelector(`[data-id=${v}]`);b&&b.classList.toggle("on",e&&i===v)})});const r=t?this.closestBlock(t.anchorNode):null,l=((a=r==null?void 0:r.closest("[dir]"))==null?void 0:a.getAttribute("dir"))||this.ed.getAttribute("dir")||this.dir();(c=this.toolbar.querySelector("[data-id=ltr]"))==null||c.classList.toggle("on",e&&l==="ltr"),(d=this.toolbar.querySelector("[data-id=rtl]"))==null||d.classList.toggle("on",e&&l==="rtl");const o=(u,v,b)=>{const f=this.toolbar.querySelector(`[data-id=${u}] .lbl`);f&&(f.textContent=v||b||"",f.classList.toggle("empty",!v))};o("fontsel",this.currentFont()),o("sizesel",this.currentSize().replace("px","")),e&&o("blocksel",Wt.some(u=>u[0]===i)?this.blockLabel(i):this.t("para")),this.sbWords.textContent=this.countWords()+" "+this.t("words")}countWords(){const t=(this.ed.textContent||"").trim();return t?t.split(/\s+/).length:0}handlePaste(t){const e=t.clipboardData;if(!e)return;t.preventDefault();const i=e.getData("text/html"),s=Array.from(e.items).find(r=>r.type.startsWith("image/"));if(s&&!i){const r=new FileReader;r.onload=()=>{document.execCommand("insertHTML",!1,`<img src="${r.result}" alt="">`),this.onChange()},r.readAsDataURL(s.getAsFile());return}i?document.execCommand("insertHTML",!1,Je(i,this.dir())):document.execCommand("insertHTML",!1,ti(e.getData("text/plain"))),this.onChange()}initUI(){this.closePop(),this.closeDlg(),this.clearTableHandles(),this.clearImgPlaceholderSel(),this.shell.dir=this.dir(),this.ed.dir=this.dir(),this.options.menubar?this.buildMenubar():this.menubar.style.display="none",this.options.toolbar?this.buildToolbar():this.toolbar.style.display="none",this.sbHelp.textContent=this.t("statushelp"),this.refreshState()}},W.instanceCounter=0,W);const Gt=O.forwardRef(({value:m,defaultValue:t,onChange:e,onReady:i,className:s,style:r,...l},o)=>{const a=O.useRef(null),c=O.useRef(null),d=O.useRef(!1),u=O.useRef(m??t),v=O.useRef(e),b=O.useRef(i);return v.current=e,b.current=i,O.useImperativeHandle(o,()=>({getContent:()=>{var f;return((f=c.current)==null?void 0:f.getContent())??""},setContent:f=>{var w;return(w=c.current)==null?void 0:w.setContent(f)},insertContent:f=>{var w;return(w=c.current)==null?void 0:w.insertContent(f)},setLanguage:f=>{var w;return(w=c.current)==null?void 0:w.setLanguage(f)},focus:()=>{var f;return(f=c.current)==null?void 0:f.focus()},destroy:()=>{var f;return(f=c.current)==null?void 0:f.destroy()},importWordFile:f=>{var w;return((w=c.current)==null?void 0:w.importWordFile(f))??Promise.resolve()},restoreDraft:()=>{var f;return((f=c.current)==null?void 0:f.restoreDraft())??!1},getRevisions:()=>{var f;return((f=c.current)==null?void 0:f.getRevisions())??[]}})),O.useEffect(()=>{if(!a.current)return;const f=new oi({target:a.current,initialContent:u.current,onChange:w=>{var E;d.current=!0,u.current=w,(E=v.current)==null||E.call(v,w)},onReady:w=>{var E;return(E=b.current)==null?void 0:E.call(b,w)},...l});return c.current=f,()=>{f.destroy(),c.current=null}},[]),O.useEffect(()=>{var f;if(m!==void 0&&m!==u.current){if(d.current){d.current=!1;return}u.current=m,(f=c.current)==null||f.setContent(m)}},[m]),O.useEffect(()=>{var f;l.language&&((f=c.current)==null||f.setLanguage(l.language))},[l.language]),Le.jsx("div",{ref:a,className:s,style:r})});Gt.displayName="FableEditor";exports.FableEditor=Gt;
41
+ <tr><td>${this.t("wcchars")}</td><td>${((e=this.ed.textContent)==null?void 0:e.replace(/\s/g,"").length)??0}</td></tr></table>`})}previewDlg(){this.dialog(this.t("previewttl"),t=>{const e=document.createElement("div");e.style.cssText="width:640px;max-width:78vw;max-height:52vh;overflow:auto;border:1px solid #e3e3e3;border-radius:6px;padding:14px;font-family:Helvetica,Arial,sans-serif;font-size:14px",e.innerHTML=this.ed.innerHTML,t.appendChild(e)})}charMap(){this.dialog(this.t("charmap").replace("…",""),t=>{const e=document.createElement("div");e.className="chgrid",We.forEach(i=>{const s=document.createElement("button");s.textContent=i,s.onclick=()=>{this.closeDlg(),this.exec("insertText",i)},e.appendChild(s)}),t.appendChild(e)})}printDoc(){const t=window.open("","_blank");t&&(t.document.write(`<html dir="${this.dir()}"><body style="font-family:Helvetica,Arial,sans-serif;font-size:14px">${this.ed.innerHTML}</body></html>`),t.document.close(),t.focus(),t.print())}pickImage(){this.imgInput.value="",this.imgInput.click()}imgPhHTML(t){return`<div class="img-ph"${t?` id="${t}"`:""} contenteditable="false">${h.image}<span>${this.t("dropimage")}</span></div>`}insertImagePlaceholder(){this.restoreSel();const t="img-ph-"+Date.now().toString(36)+Math.random().toString(36).slice(2,6);document.execCommand("insertHTML",!1,this.imgPhHTML(t));const e=this.ed.querySelector("#"+t);e&&(e.removeAttribute("id"),this.selectImgPlaceholder(e)),this.onChange()}clearImgPlaceholderSel(){var t,e;(t=this.phCtx)==null||t.remove(),this.phCtx=null,(e=this.phActive)==null||e.classList.remove("active"),this.phActive=null}removeImgPlaceholder(){const t=this.phActive;t&&(this.clearImgPlaceholderSel(),(t.closest(".tpl-media")||t).remove(),this.refreshState(),this.onChange())}selectImgPlaceholder(t){this.phActive!==t&&(this.clearImgPlaceholderSel(),this.phActive=t,t.classList.add("active"),this.phCtx=document.createElement("div"),this.phCtx.className="imgctx img-ph-ctx",this.phCtx.dir=this.dir(),document.body.appendChild(this.phCtx),this.renderPhCtxButtons())}renderPhCtxButtons(){const t=this.phCtx;t&&(t.innerHTML="",t.append(this.ctxBtn(h.uploadic,this.t("uploadimg"),()=>{this.phUploadTarget=this.phActive,this.pickImage()}),this.ctxBtn(h.link,this.t("imagelink"),()=>this.renderPhCtxUrlInput()),this.ctxSep(),this.ctxBtn(h.trash,this.t("deleteimg"),()=>this.removeImgPlaceholder())),this.positionImgPhCtx())}renderPhCtxUrlInput(){const t=this.phCtx;if(!t)return;t.innerHTML="";const e=document.createElement("input");e.type="url",e.className="urlinp",e.placeholder=this.t("imageurlph");const i=document.createElement("button");i.type="button",i.className="txtbtn",i.textContent=this.t("insertimg");const s=()=>{const r=e.value.trim(),l=this.phActive;if(!l)return;if(!/^(https?:|data:image\/|blob:)/i.test(r)){e.classList.add("err"),e.focus();return}i.disabled=!0,e.disabled=!0;const o=new Image;o.onload=()=>this.replacePlaceholderWithImage(l,r,""),o.onerror=()=>{i.disabled=!1,e.disabled=!1,e.classList.add("err"),e.focus()},o.src=r};i.addEventListener("click",s),e.addEventListener("input",()=>e.classList.remove("err")),e.addEventListener("keydown",r=>{r.key==="Enter"?(r.preventDefault(),s()):r.key==="Escape"&&(r.stopPropagation(),this.renderPhCtxButtons())}),t.append(e,i),this.positionImgPhCtx(),e.focus()}readImageFileInto(t,e){if(e.classList.contains("uploading"))return;if(this.imageUploadHandler){this.uploadImageFile(t,e);return}const i=new FileReader;i.onload=()=>{this.ed.contains(e)&&this.replacePlaceholderWithImage(e,i.result,t.name.replace(/"/g,""))},i.readAsDataURL(t)}uploadImageFile(t,e){const i=t.name.replace(/"/g,"");e.classList.remove("upload-error"),e.classList.add("uploading");const s=e.querySelector("span");s&&(s.textContent=this.t("uploading")),this.imageUploadHandler(t).then(r=>{this.ed.contains(e)&&this.replacePlaceholderWithImage(e,r,i)}).catch(r=>{var l;this.ed.contains(e)&&(e.classList.remove("uploading"),e.classList.add("upload-error"),s&&(s.textContent=this.t("uploadfailed")),(l=this.onImageUploadError)==null||l.call(this,r,t))})}replacePlaceholderWithImage(t,e,i){const s=document.createElement("img");s.src=e,s.alt="",i&&(s.title=i),t.replaceWith(s),this.phActive===t&&this.clearImgPlaceholderSel(),this.refreshState(),this.onChange()}positionImgPhCtx(){if(this.phActive&&!document.body.contains(this.phActive)){this.clearImgPlaceholderSel();return}if(!this.phActive||!this.phCtx)return;const t=this.phActive.getBoundingClientRect(),e=this.phCtx.offsetWidth,i=this.phCtx.offsetHeight;let s=t.left+scrollX+(t.width-e)/2;s=Math.max(8+scrollX,Math.min(s,scrollX+innerWidth-e-8));let r=t.bottom+scrollY+8;t.bottom+8+i>innerHeight-4&&(r=Math.max(this.ctxMinTop(),t.top+scrollY-i-8)),this.phCtx.style.left=s+"px",this.phCtx.style.top=r+"px"}templateMenu(t){this.popup(t,e=>this.buildTemplatePickInto(e))}tplPreviewHTML(t){const e='<span class="pv-img"></span>',i='<span class="pv-h"></span>',s=a=>`<span class="pv-l" style="width:${a}%"></span>`,r=a=>`<span class="pv-col">${a}</span>`,l=a=>`<span class="pv-row">${a}</span>`,o=r(i+s(100)+s(88));return t==="img-left"?`<span class="pv">${l(e+o)}${s(100)}${s(72)}</span>`:t==="img-right"?`<span class="pv">${l(o+e)}${s(100)}${s(72)}</span>`:t==="img-top"?`<span class="pv pv-c">${e}${i}${s(100)}${s(72)}</span>`:`<span class="pv pv-c">${i}${s(100)}${s(72)}${e}</span>`}buildTemplatePickInto(t,e){const i=document.createElement("div");i.className="tplpick",vt.forEach(s=>{const r=document.createElement("button");r.type="button",r.className="tpltile",r.title=this.t(bt[s]),r.innerHTML=this.tplPreviewHTML(s)+`<span class="tpllbl">${this.t(bt[s])}</span>`,r.addEventListener("click",()=>{this.closePop(),this.insertTemplate(s),e==null||e()}),i.appendChild(r)}),t.appendChild(i)}insertTemplate(t){this.restoreSel();const e=`<div class="tpl-media" contenteditable="false">${this.imgPhHTML()}</div>`,i=`<div class="tpl-text"><h2>${this.t("heading")}</h2><p>${this.t("para")}</p></div>`,s=t==="img-center"?i+e:e+i;document.execCommand("insertHTML",!1,`<div class="tpl tpl-${t}">${s}</div><p><br></p>`),this.saveSel(),this.onChange()}clearTplSel(){var t,e;(t=this.tplCtx)==null||t.remove(),this.tplCtx=null,(e=this.tplActive)==null||e.classList.remove("tpl-selected"),this.tplActive=null}selectTemplate(t){this.tplActive!==t&&(this.clearTplSel(),this.tplActive=t,t.classList.add("tpl-selected"),this.tplCtx=document.createElement("div"),this.tplCtx.className="imgctx tplctx",this.tplCtx.dir=this.dir(),document.body.appendChild(this.tplCtx),this.renderTplCtxButtons())}renderTplCtxButtons(){const t=this.tplCtx,e=this.tplActive;!t||!e||(t.innerHTML="",vt.forEach(i=>{const s=this.ctxBtn(ci[i],this.t(bt[i]),()=>this.setTplLayout(i));s.classList.toggle("on",e.classList.contains("tpl-"+i)),t.appendChild(s)}),t.append(this.ctxSep(),this.ctxBtn(h.trash,this.t("deltemplate"),()=>this.removeTemplate())),this.positionTplCtx())}setTplLayout(t){const e=this.tplActive;if(!e)return;vt.forEach(r=>e.classList.remove("tpl-"+r)),e.classList.add("tpl-"+t);const i=e.querySelector(":scope > .tpl-media"),s=e.querySelector(":scope > .tpl-text");i&&s&&(t==="img-center"?e.appendChild(i):e.insertBefore(i,s)),this.renderTplCtxButtons(),this.positionImgPhCtx(),this.positionImageHandles(),this.onChange()}removeTemplate(){const t=this.tplActive;t&&(this.clearTplSel(),this.phActive&&t.contains(this.phActive)&&this.clearImgPlaceholderSel(),this.imgActive&&t.contains(this.imgActive)&&this.clearImageHandles(),t.remove(),this.refreshState(),this.onChange())}positionTplCtx(){if(this.tplActive&&!document.body.contains(this.tplActive)){this.clearTplSel();return}if(!this.tplActive||!this.tplCtx)return;const t=this.tplActive.getBoundingClientRect(),e=this.tplCtx.offsetWidth,i=this.tplCtx.offsetHeight;let s=t.left+scrollX+(t.width-e)/2;s=Math.max(8+scrollX,Math.min(s,scrollX+innerWidth-e-8));let r=t.top+scrollY-i-8;r<this.ctxMinTop()&&(r=t.bottom+scrollY+8),this.tplCtx.style.left=s+"px",this.tplCtx.style.top=r+"px"}pickWordDoc(){this.docInput.value="",this.docInput.click()}toggleFullscreen(){this.shell.classList.toggle("fullscreen");const t=this.toolbar.querySelector("[data-id=fullscreen]");t==null||t.classList.toggle("on",this.shell.classList.contains("fullscreen")),this.positionTableHandles()}clearTableHandles(){var t,e,i,s,r;(t=this.tblCorner)==null||t.remove(),this.tblCorner=null,this.tblColBars.forEach(l=>l.remove()),this.tblColBars=[],(e=this.tblCtx)==null||e.remove(),this.tblCtx=null,(i=this.tblCellMark)==null||i.remove(),this.tblCellMark=null,(s=this.tblOpMark)==null||s.remove(),this.tblOpMark=null,this.tblOpMarkKind=null,(r=this.tblActive)==null||r.classList.remove("tbl-selected"),this.tblActive=null}positionCellMarker(){if(!this.tblCellMark)return;const t=this.currentCell();if(!t||!this.tblActive||t.closest("table")!==this.tblActive){this.tblCellMark.style.display="none";return}const e=t.getBoundingClientRect();this.tblCellMark.style.display="block",this.tblCellMark.style.left=e.left+scrollX+"px",this.tblCellMark.style.top=e.top+scrollY+"px",this.tblCellMark.style.width=e.width+"px",this.tblCellMark.style.height=e.height+"px"}setOpTarget(t){this.tblOpMarkKind=t,this.positionOpMark()}positionOpMark(){var d;const t=this.tblOpMarkKind,e=t?this.currentCell():null;if(!t||!e||!this.tblActive||e.closest("table")!==this.tblActive){(d=this.tblOpMark)==null||d.remove(),this.tblOpMark=null;return}this.tblOpMark||(this.tblOpMark=document.createElement("div"),this.tblOpMark.className="tbl-opmark",document.body.appendChild(this.tblOpMark));const i=this.tblActive.getBoundingClientRect(),s=e.getBoundingClientRect(),r=e.parentElement.getBoundingClientRect(),l=t==="row"?r.left:s.left,o=t==="row"?r.top:i.top,a=t==="row"?r.width:s.width,c=t==="row"?r.height:i.height;this.tblOpMark.style.left=l+scrollX+"px",this.tblOpMark.style.top=o+scrollY+"px",this.tblOpMark.style.width=a+"px",this.tblOpMark.style.height=c+"px"}ctxMinTop(){return Math.max(scrollY+4,this.ed.getBoundingClientRect().top+scrollY-2)}ctxBtn(t,e,i,s){const r=document.createElement("button");return r.type="button",r.title=e,r.innerHTML=t,s&&(r.dataset.id=s),r.addEventListener("mousedown",l=>l.preventDefault()),r.addEventListener("click",i),r}ctxSep(){const t=document.createElement("div");return t.className="sep",t}buildTableCtxToolbar(){const t=document.createElement("div");t.className="tblctx",t.dir=this.dir();const e=(i,s)=>(i.addEventListener("mouseenter",()=>this.setOpTarget(s)),i.addEventListener("mouseleave",()=>this.setOpTarget(null)),i);return t.append(e(this.ctxBtn(h.rowbefore,this.t("rowabove"),()=>this.tableOp("rowabove")),"row"),e(this.ctxBtn(h.rowafter,this.t("rowbelow"),()=>this.tableOp("rowbelow")),"row"),e(this.ctxBtn(h.rowdelete,this.t("delrow"),()=>this.tableOp("delrow")),"row"),this.ctxSep(),e(this.ctxBtn(h.colbefore,this.t("colbefore"),()=>this.tableOp("colbefore")),"col"),e(this.ctxBtn(h.colafter,this.t("colafter"),()=>this.tableOp("colafter")),"col"),e(this.ctxBtn(h.coldelete,this.t("delcol"),()=>this.tableOp("delcol")),"col"),this.ctxSep(),this.ctxBtn(h.trash,this.t("deltable"),()=>this.tableOp("deltable")),this.ctxBtn(h.tableic,this.t("tablepropsttl"),()=>this.tablePropsDlg())),document.body.appendChild(t),t}positionTableHandles(){if(!this.tblActive||!document.body.contains(this.tblActive)){this.clearTableHandles();return}const t=this.ed.getAttribute("dir")==="rtl",e=this.tblActive.getBoundingClientRect(),i=e.top+scrollY,s=e.left+scrollX,r=e.right+scrollX,l=e.bottom+scrollY;if(this.tblCorner&&(this.tblCorner.style.top=l-5+"px",this.tblCorner.style.left=(t?s-5:r-5)+"px",this.tblCorner.style.cursor=t?"nesw-resize":"nwse-resize"),this.tblCtx){const a=this.tblCtx.offsetWidth,c=this.tblCtx.offsetHeight;let d=s+(r-s)/2-a/2;d=Math.max(8+scrollX,Math.min(d,scrollX+innerWidth-a-8));let u=i-c-8;u<this.ctxMinTop()&&(u=l+8),this.tblCtx.style.left=d+"px",this.tblCtx.style.top=u+"px"}this.tblColBars.forEach(a=>a.remove()),this.tblColBars=[];const o=this.tblActive.rows[0];if(o)for(let a=0;a<o.cells.length-1;a++){const c=o.cells[a].getBoundingClientRect(),d=(t?c.left:c.right)+scrollX,u=document.createElement("div");u.className="tbl-colbar",u.style.top=i+"px",u.style.left=d+"px",u.style.height=l-i+"px",document.body.appendChild(u),u.addEventListener("mousedown",v=>this.startColBarDrag(v,a)),this.tblColBars.push(u)}this.positionCellMarker(),this.positionOpMark()}selectTableForResize(t){this.tblActive!==t&&(this.clearTableHandles(),this.tblActive=t,t.classList.add("tbl-selected"),this.tblCorner=document.createElement("div"),this.tblCorner.className="tbl-handle",document.body.appendChild(this.tblCorner),this.tblCorner.addEventListener("mousedown",e=>this.startTableCornerDrag(e)),this.tblCellMark=document.createElement("div"),this.tblCellMark.className="tbl-cellmark",this.tblCellMark.style.display="none",document.body.appendChild(this.tblCellMark),this.tblCtx=this.buildTableCtxToolbar(),this.positionTableHandles())}withNoTextSelect(t){const e=document.body.style.userSelect;document.body.style.userSelect="none",t(()=>{document.body.style.userSelect=e})}startTableCornerDrag(t){t.preventDefault();const e=this.tblActive;if(!e)return;const i=this.ed.getAttribute("dir")==="rtl",s=t.clientX,r=e.getBoundingClientRect().width;e.style.tableLayout=e.style.tableLayout||"fixed",this.withNoTextSelect(l=>{const o=c=>{const d=i?-(c.clientX-s):c.clientX-s;e.style.width=Math.max(60,Math.round(r+d))+"px",this.positionTableHandles()},a=()=>{window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a),l(),this.onChange()};window.addEventListener("mousemove",o),window.addEventListener("mouseup",a)})}startColBarDrag(t,e){t.preventDefault(),t.stopPropagation();const i=this.tblActive;if(!i)return;const s=this.ed.getAttribute("dir")==="rtl",r=Array.from(i.rows),l=r.map(u=>u.cells[e]).filter(Boolean),o=r.map(u=>u.cells[e+1]).filter(Boolean);if(!l.length||!o.length)return;const a=t.clientX,c=l[0].getBoundingClientRect().width,d=o[0].getBoundingClientRect().width;i.style.tableLayout="fixed",this.withNoTextSelect(u=>{const v=f=>{const w=(s?-1:1)*(f.clientX-a);l.forEach(E=>E.style.width=Math.max(24,Math.round(c+w))+"px"),o.forEach(E=>E.style.width=Math.max(24,Math.round(d-w))+"px"),this.positionTableHandles()},b=()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b),u(),this.onChange()};window.addEventListener("mousemove",v),window.addEventListener("mouseup",b)})}cancelImgHide(){this.imgHideTimer!=null&&(window.clearTimeout(this.imgHideTimer),this.imgHideTimer=null)}scheduleImgHide(){this.cancelImgHide(),this.imgHideTimer=window.setTimeout(()=>this.clearImageHandles(),250)}clearImageHandles(){var t,e;this.cancelImgHide(),this.imgHandles.forEach(i=>i.remove()),this.imgHandles=[],(t=this.imgCtx)==null||t.remove(),this.imgCtx=null,(e=this.imgActive)==null||e.classList.remove("img-selected"),this.imgActive=null}selectImage(t){this.imgActive!==t&&(this.clearImageHandles(),this.imgActive=t,t.classList.add("img-selected"),this.imgHandles=ai.map(e=>{const i=document.createElement("div");return i.className="img-handle img-handle-"+e,i.dataset.corner=e,i.addEventListener("mousedown",s=>this.startImageResizeDrag(s,e)),i.addEventListener("mouseenter",()=>this.cancelImgHide()),i.addEventListener("mouseleave",()=>this.scheduleImgHide()),document.body.appendChild(i),i}),this.imgCtx=this.buildImageCtxToolbar(t),this.positionImageHandles())}buildImageCtxToolbar(t){const e=document.createElement("div");e.className="imgctx",e.dir=this.dir();const i=()=>{var d;const c=this.buildImageCtxToolbar(t);(d=this.imgCtx)==null||d.replaceWith(c),this.imgCtx=c,this.positionImageHandles()},s=c=>{this.setImageAlign(t,c),i()},r=t.style.float==="left",l=t.style.float==="right",o=!r&&!l&&t.style.marginLeft==="auto"&&t.style.marginRight==="auto",a=(c,d,u,v)=>{const b=this.ctxBtn(c,d,v);return b.classList.toggle("on",u),b};return e.append(a(h.alignleft,this.t("alignleft"),r,()=>s("left")),a(h.aligncenter,this.t("aligncenter"),o,()=>s("center")),a(h.alignright,this.t("alignright"),l,()=>s("right")),this.ctxSep(),a(h.rotateleft,this.t("rotateleft"),!1,()=>{this.rotateImage(t,-90),i()}),a(h.rotateright,this.t("rotateright"),!1,()=>{this.rotateImage(t,90),i()}),this.ctxSep(),a(h.fliphorizontal,this.t("fliphorizontal"),t.dataset.flipx==="1",()=>{this.flipImage(t,"x"),i()}),a(h.flipvertical,this.t("flipvertical"),t.dataset.flipy==="1",()=>{this.flipImage(t,"y"),i()}),this.ctxSep(),a(h.trash,this.t("deleteimg"),!1,()=>{const c=t.closest(".tpl-media");c&&this.ed.contains(c)?t.outerHTML=this.imgPhHTML():t.remove(),this.clearImageHandles(),this.onChange()})),e.addEventListener("mousedown",c=>c.preventDefault()),e.addEventListener("mouseenter",()=>this.cancelImgHide()),e.addEventListener("mouseleave",()=>this.scheduleImgHide()),document.body.appendChild(e),e}setImageAlign(t,e){t.style.float="",t.style.display="",t.style.marginLeft="",t.style.marginRight="",t.style.marginBottom="",e==="left"?(t.style.float="left",t.style.marginInlineEnd="1em",t.style.marginBottom="0.5em"):e==="right"?(t.style.float="right",t.style.marginInlineStart="1em",t.style.marginBottom="0.5em"):(t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="auto"),this.onChange()}applyImgTransform(t){const e=parseInt(t.dataset.rotate||"0",10),i=t.dataset.flipx==="1"?-1:1,s=t.dataset.flipy==="1"?-1:1;t.style.transform=e||i<0||s<0?`rotate(${e}deg) scale(${i}, ${s})`:""}rotateImage(t,e){const i=((parseInt(t.dataset.rotate||"0",10)+e)%360+360)%360;t.dataset.rotate=String(i),this.applyImgTransform(t),this.positionImageHandles(),this.onChange()}flipImage(t,e){const i=e==="x"?"flipx":"flipy";t.dataset[i]=t.dataset[i]==="1"?"":"1",this.applyImgTransform(t),this.positionImageHandles(),this.onChange()}positionImageHandles(){if(!this.imgActive||!document.body.contains(this.imgActive)){this.clearImageHandles();return}const t=this.imgActive.getBoundingClientRect(),e=t.top+scrollY,i=t.left+scrollX,s=t.right+scrollX,r=t.bottom+scrollY,l={nw:[i,e],ne:[s,e],sw:[i,r],se:[s,r]};if(this.imgHandles.forEach(o=>{const[a,c]=l[o.dataset.corner];o.style.left=a-5+"px",o.style.top=c-5+"px"}),this.imgCtx){const o=this.imgCtx.offsetWidth,a=this.imgCtx.offsetHeight;let c=i+(s-i)/2-o/2;c=Math.max(8+scrollX,Math.min(c,scrollX+innerWidth-o-8));let d=e-a-8;d<this.ctxMinTop()&&(d=r+8),this.imgCtx.style.left=c+"px",this.imgCtx.style.top=d+"px"}}startImageResizeDrag(t,e){t.preventDefault();const i=this.imgActive;if(!i)return;this.cancelImgHide();const s=t.clientX,r=i.getBoundingClientRect().width,l=e==="nw"||e==="sw"?-1:1;this.withNoTextSelect(o=>{const a=d=>{i.style.width=Math.max(24,Math.round(r+l*(d.clientX-s)))+"px",i.style.height="auto",this.positionImageHandles()},c=()=>{window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",c),o(),this.onChange()};window.addEventListener("mousemove",a),window.addEventListener("mouseup",c)})}toggleBlock(t){this.exec("formatBlock",this.currentBlock()===t?"<p>":"<"+t+">")}clearSelToolbar(){var t;(t=this.selCtx)==null||t.remove(),this.selCtx=null}updateSelToolbar(t){if(this.options.readonly||t.isCollapsed||!t.rangeCount){this.clearSelToolbar();return}const e=t.getRangeAt(0),i=e.getBoundingClientRect();if(!i.width&&!i.height){this.clearSelToolbar();return}this.selCtx||(this.selCtx=this.buildSelToolbar()),this.positionSelToolbar(e)}buildSelToolbar(){var o;const t=document.createElement("div");t.className="selctx",t.dir=this.dir();const e=this.ctxBtn('<b style="font:600 15px/1 Georgia,serif">A</b><span class="colorbar" data-cb="fore"></span>',this.t("forecolor"),()=>this.colorMenu(e,"fore")),i=this.ctxBtn(h.backcolor,this.t("backcolor"),()=>this.colorMenu(i,"back"));(o=i.querySelector("svg"))==null||o.insertAdjacentHTML("afterend",'<span class="colorbar" data-cb="back"></span>');const s=this.ctxBtn(h.caseic,this.t("changecase"),()=>this.caseMenu(s)),r=this.ctxBtn(h.lineheight,this.t("lineheight"),()=>this.lineHeightMenu(r)),l=this.ctxBtn(h.wordspacing,this.t("wordspacing"),()=>this.wordSpacingMenu(l));return t.append(this.ctxBtn(h.bold,this.t("bold"),()=>this.exec("bold"),"bold"),this.ctxBtn(h.italic,this.t("italic"),()=>this.exec("italic"),"italic"),e,i,this.ctxSep(),this.ctxBtn(h.quote,this.t("quote"),()=>this.toggleBlock("blockquote"),"blockquote"),this.ctxBtn('<b style="font:700 12px/1 Arial,sans-serif">H2</b>',this.blockLabel("h2"),()=>this.toggleBlock("h2"),"h2"),this.ctxBtn('<b style="font:700 12px/1 Arial,sans-serif">H3</b>',this.blockLabel("h3"),()=>this.toggleBlock("h3"),"h3"),this.ctxSep(),this.ctxBtn(h.link,this.t("linkttl"),()=>this.linkDlg()),s,r,l),t.addEventListener("mousedown",a=>a.preventDefault()),document.body.appendChild(t),this.syncColorSwatches(t),t}positionSelToolbar(t){if(!this.selCtx)return;const e=t.getBoundingClientRect(),i=e.top+scrollY,s=e.left+scrollX,r=e.right+scrollX,l=e.bottom+scrollY,o=this.selCtx.offsetWidth,a=this.selCtx.offsetHeight;let c=s+(r-s)/2-o/2;c=Math.max(8+scrollX,Math.min(c,scrollX+innerWidth-o-8));let d=i-a-8;d<this.ctxMinTop()&&(d=l+8),this.selCtx.style.left=c+"px",this.selCtx.style.top=d+"px"}repositionSelToolbar(){if(!this.selCtx)return;const t=window.getSelection();t&&t.rangeCount&&!t.isCollapsed&&this.ed.contains(t.anchorNode)&&this.positionSelToolbar(t.getRangeAt(0))}currentBlock(){const t=window.getSelection();if(!t||!t.anchorNode||!this.ed.contains(t.anchorNode))return"p";const e=this.closestBlock(t.anchorNode);return e?e.tagName.toLowerCase().replace("div","p"):"p"}fontRefEl(){const t=window.getSelection();return t&&t.anchorNode&&this.ed.contains(t.anchorNode)?t.anchorNode.nodeType===1?t.anchorNode:t.anchorNode.parentElement:this.ed}currentFont(){const t=getComputedStyle(this.fontRefEl()).fontFamily.toLowerCase(),e=this.options.fontFamilyFormats.find(([i,s])=>t.includes(s.split(",")[0].toLowerCase()));return e?e[0]:""}currentSize(){const t=Math.round(parseFloat(getComputedStyle(this.fontRefEl()).fontSize));return t>0?t+"px":""}refreshState(){var a,c,d;const t=window.getSelection(),e=t?this.ed.contains(t.anchorNode):!1,i=this.currentBlock();[this.toolbar,this.selCtx].filter(Boolean).forEach(u=>{["bold","italic","underline","strikeThrough","justifyLeft","justifyCenter","justifyRight","justifyFull","insertOrderedList","insertUnorderedList"].forEach(v=>{const b=u.querySelector(`[data-id=${v}]`);b&&b.classList.toggle("on",e&&document.queryCommandState(v))}),["h2","h3","blockquote"].forEach(v=>{const b=u.querySelector(`[data-id=${v}]`);b&&b.classList.toggle("on",e&&i===v)})});const r=t?this.closestBlock(t.anchorNode):null,l=((a=r==null?void 0:r.closest("[dir]"))==null?void 0:a.getAttribute("dir"))||this.ed.getAttribute("dir")||this.dir();(c=this.toolbar.querySelector("[data-id=ltr]"))==null||c.classList.toggle("on",e&&l==="ltr"),(d=this.toolbar.querySelector("[data-id=rtl]"))==null||d.classList.toggle("on",e&&l==="rtl");const o=(u,v,b)=>{const f=this.toolbar.querySelector(`[data-id=${u}] .lbl`);f&&(f.textContent=v||b||"",f.classList.toggle("empty",!v))};o("fontsel",this.currentFont()),o("sizesel",this.currentSize().replace("px","")),e&&o("blocksel",Xt.some(u=>u[0]===i)?this.blockLabel(i):this.t("para")),this.sbWords.textContent=this.countWords()+" "+this.t("words")}countWords(){const t=(this.ed.textContent||"").trim();return t?t.split(/\s+/).length:0}handlePaste(t){const e=t.clipboardData;if(!e)return;t.preventDefault();const i=e.getData("text/html"),s=Array.from(e.items).find(r=>r.type.startsWith("image/"));if(s&&!i){const r=new FileReader;r.onload=()=>{document.execCommand("insertHTML",!1,`<img src="${r.result}" alt="">`),this.onChange()},r.readAsDataURL(s.getAsFile());return}i?document.execCommand("insertHTML",!1,ei(i,this.dir())):document.execCommand("insertHTML",!1,ii(e.getData("text/plain"))),this.onChange()}initUI(){this.closePop(),this.closeDlg(),this.clearTableHandles(),this.clearImgPlaceholderSel(),this.shell.dir=this.dir(),this.ed.dir=this.dir(),this.options.menubar?this.buildMenubar():this.menubar.style.display="none",this.options.toolbar?this.buildToolbar():this.toolbar.style.display="none",this.sbHelp.textContent=this.t("statushelp"),this.refreshState()}},z.instanceCounter=0,z);const Jt=O.forwardRef(({value:m,defaultValue:t,onChange:e,onReady:i,className:s,style:r,...l},o)=>{const a=O.useRef(null),c=O.useRef(null),d=O.useRef(!1),u=O.useRef(m??t),v=O.useRef(e),b=O.useRef(i);return v.current=e,b.current=i,O.useImperativeHandle(o,()=>({getContent:()=>{var f;return((f=c.current)==null?void 0:f.getContent())??""},setContent:f=>{var w;return(w=c.current)==null?void 0:w.setContent(f)},insertContent:f=>{var w;return(w=c.current)==null?void 0:w.insertContent(f)},setLanguage:f=>{var w;return(w=c.current)==null?void 0:w.setLanguage(f)},focus:()=>{var f;return(f=c.current)==null?void 0:f.focus()},destroy:()=>{var f;return(f=c.current)==null?void 0:f.destroy()},importWordFile:f=>{var w;return((w=c.current)==null?void 0:w.importWordFile(f))??Promise.resolve()},restoreDraft:()=>{var f;return((f=c.current)==null?void 0:f.restoreDraft())??!1},getRevisions:()=>{var f;return((f=c.current)==null?void 0:f.getRevisions())??[]}})),O.useEffect(()=>{if(!a.current)return;const f=new hi({target:a.current,initialContent:u.current,onChange:w=>{var E;d.current=!0,u.current=w,(E=v.current)==null||E.call(v,w)},onReady:w=>{var E;return(E=b.current)==null?void 0:E.call(b,w)},...l});return c.current=f,()=>{f.destroy(),c.current=null}},[]),O.useEffect(()=>{var f;if(m!==void 0&&m!==u.current){if(d.current){d.current=!1;return}u.current=m,(f=c.current)==null||f.setContent(m)}},[m]),O.useEffect(()=>{var f;l.language&&((f=c.current)==null||f.setLanguage(l.language))},[l.language]),Ie.jsx("div",{ref:a,className:s,style:r})});Jt.displayName="FableEditor";exports.FableEditor=Jt;