fable-editor 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular/esm2022/core/editor.mjs +47 -13
- package/dist/angular/fesm2022/fable-editor.mjs +46 -12
- package/dist/angular/fesm2022/fable-editor.mjs.map +1 -1
- package/dist/core/editor.d.ts.map +1 -1
- package/dist/core/index.cjs +4 -4
- package/dist/core/index.mjs +448 -446
- package/dist/react/index.cjs +8 -8
- package/dist/react/index.mjs +639 -637
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -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 Qt;function Xe(){if(Qt)return J;Qt=1;var
|
|
9
|
+
*/var Qt;function Xe(){if(Qt)return J;Qt=1;var u=N,t=Symbol.for("react.element"),e=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n={key:!0,ref:!0,__self:!0,__source:!0};function r(o,l,a){var d,p={},m=null,v=null;a!==void 0&&(m=""+a),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(v=l.ref);for(d in l)i.call(l,d)&&!n.hasOwnProperty(d)&&(p[d]=l[d]);if(o&&o.defaultProps)for(d in l=o.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:t,type:o,key:m,ref:v,props:p,_owner:s.current}}return J.Fragment=e,J.jsx=r,J.jsxs=r,J}var tt={};/**
|
|
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 Jt;function Ye(){return Jt||(Jt=1,process.env.NODE_ENV!=="production"&&function(){var
|
|
17
|
+
*/var Jt;function Ye(){return Jt||(Jt=1,process.env.NODE_ENV!=="production"&&function(){var u=N,t=Symbol.for("react.element"),e=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),a=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),b=Symbol.iterator,f="@@iterator";function y(c){if(c===null||typeof c!="object")return null;var g=b&&c[b]||c[f];return typeof g=="function"?g:null}var C=u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function E(c){{for(var g=arguments.length,x=new Array(g>1?g-1:0),T=1;T<g;T++)x[T-1]=arguments[T];I("error",c,x)}}function I(c,g,x){{var T=C.ReactDebugCurrentFrame,k=T.getStackAddendum();k!==""&&(g+="%s",x=x.concat([k]));var H=x.map(function(M){return String(M)});H.unshift("Warning: "+g),Function.prototype.apply.call(console[c],console,H)}}var A=!1,j=!1,Z=!1,_=!1,et=!1,Lt;Lt=Symbol.for("react.module.reference");function ye(c){return!!(typeof c=="string"||typeof c=="function"||c===i||c===n||et||c===s||c===a||c===d||_||c===v||A||j||Z||typeof c=="object"&&c!==null&&(c.$$typeof===m||c.$$typeof===p||c.$$typeof===r||c.$$typeof===o||c.$$typeof===l||c.$$typeof===Lt||c.getModuleId!==void 0))}function xe(c,g,x){var T=c.displayName;if(T)return T;var k=g.displayName||g.name||"";return k!==""?x+"("+k+")":x}function kt(c){return c.displayName||"Context"}function U(c){if(c==null)return null;if(typeof c.tag=="number"&&E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case i:return"Fragment";case e:return"Portal";case n:return"Profiler";case s:return"StrictMode";case a:return"Suspense";case d:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case o:var g=c;return kt(g)+".Consumer";case r:var x=c;return kt(x._context)+".Provider";case l:return xe(c,c.render,"ForwardRef");case p:var T=c.displayName||null;return T!==null?T:U(c.type)||"Memo";case m:{var k=c,H=k._payload,M=k._init;try{return U(M(H))}catch{return null}}}return null}var V=Object.assign,K=0,At,Ht,It,qt,Rt,Pt,Bt;function Dt(){}Dt.__reactDisabledLog=!0;function Ce(){{if(K===0){At=console.log,Ht=console.info,It=console.warn,qt=console.error,Rt=console.group,Pt=console.groupCollapsed,Bt=console.groupEnd;var c={configurable:!0,enumerable:!0,value:Dt,writable:!0};Object.defineProperties(console,{info:c,log:c,warn:c,error:c,group:c,groupCollapsed:c,groupEnd:c})}K++}}function we(){{if(K--,K===0){var c={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:V({},c,{value:At}),info:V({},c,{value:Ht}),warn:V({},c,{value:It}),error:V({},c,{value:qt}),group:V({},c,{value:Rt}),groupCollapsed:V({},c,{value:Pt}),groupEnd:V({},c,{value:Bt})})}K<0&&E("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var pt=C.ReactCurrentDispatcher,mt;function it(c,g,x){{if(mt===void 0)try{throw Error()}catch(k){var T=k.stack.trim().match(/\n( *(at )?)/);mt=T&&T[1]||""}return`
|
|
18
18
|
`+mt+c}}var ft=!1,st;{var Te=typeof WeakMap=="function"?WeakMap:Map;st=new Te}function Nt(c,g){if(!c||ft)return"";{var x=st.get(c);if(x!==void 0)return x}var T;ft=!0;var k=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var H;H=pt.current,pt.current=null,Ce();try{if(g){var M=function(){throw Error()};if(Object.defineProperty(M.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(M,[])}catch(O){T=O}Reflect.construct(c,[],M)}else{try{M.call()}catch(O){T=O}c.call(M.prototype)}}else{try{throw Error()}catch(O){T=O}c()}}catch(O){if(O&&T&&typeof O.stack=="string"){for(var S=O.stack.split(`
|
|
19
19
|
`),D=T.stack.split(`
|
|
20
20
|
`),R=S.length-1,P=D.length-1;R>=1&&P>=0&&S[R]!==D[P];)P--;for(;R>=1&&P>=0;R--,P--)if(S[R]!==D[P]){if(R!==1||P!==1)do if(R--,P--,P<0||S[R]!==D[P]){var $=`
|
|
21
|
-
`+S[R].replace(" at new "," at ");return c.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",c.displayName)),typeof c=="function"&&st.set(c,$),$}while(R>=1&&P>=0);break}}}finally{ft=!1,pt.current=H,we(),Error.prepareStackTrace=k}var G=c?c.displayName||c.name:"",z=G?it(G):"";return typeof c=="function"&&st.set(c,z),z}function Ee(c,g,x){return Nt(c,!1)}function Se(c){var g=c.prototype;return!!(g&&g.isReactComponent)}function nt(c,g,x){if(c==null)return"";if(typeof c=="function")return Nt(c,Se(c));if(typeof c=="string")return it(c);switch(c){case a:return it("Suspense");case
|
|
21
|
+
`+S[R].replace(" at new "," at ");return c.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",c.displayName)),typeof c=="function"&&st.set(c,$),$}while(R>=1&&P>=0);break}}}finally{ft=!1,pt.current=H,we(),Error.prepareStackTrace=k}var G=c?c.displayName||c.name:"",z=G?it(G):"";return typeof c=="function"&&st.set(c,z),z}function Ee(c,g,x){return Nt(c,!1)}function Se(c){var g=c.prototype;return!!(g&&g.isReactComponent)}function nt(c,g,x){if(c==null)return"";if(typeof c=="function")return Nt(c,Se(c));if(typeof c=="string")return it(c);switch(c){case a:return it("Suspense");case d:return it("SuspenseList")}if(typeof c=="object")switch(c.$$typeof){case l:return Ee(c.render);case p:return nt(c.type,g,x);case m:{var T=c,k=T._payload,H=T._init;try{return nt(H(k),g,x)}catch{}}}return""}var Q=Object.prototype.hasOwnProperty,Ot={},Ft=C.ReactDebugCurrentFrame;function rt(c){if(c){var g=c._owner,x=nt(c.type,c._source,g?g.type:null);Ft.setExtraStackFrame(x)}else Ft.setExtraStackFrame(null)}function Me(c,g,x,T,k){{var H=Function.call.bind(Q);for(var M in c)if(H(c,M)){var S=void 0;try{if(typeof c[M]!="function"){var D=Error((T||"React class")+": "+x+" type `"+M+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof c[M]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw D.name="Invariant Violation",D}S=c[M](g,M,T,x,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(R){S=R}S&&!(S instanceof Error)&&(rt(k),E("%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).",T||"React class",x,M,typeof S),rt(null)),S instanceof Error&&!(S.message in Ot)&&(Ot[S.message]=!0,rt(k),E("Failed %s type: %s",x,S.message),rt(null))}}}var Le=Array.isArray;function gt(c){return Le(c)}function ke(c){{var g=typeof Symbol=="function"&&Symbol.toStringTag,x=g&&c[Symbol.toStringTag]||c.constructor.name||"Object";return x}}function Ae(c){try{return Zt(c),!1}catch{return!0}}function Zt(c){return""+c}function _t(c){if(Ae(c))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ke(c)),Zt(c)}var $t=C.ReactCurrentOwner,He={key:!0,ref:!0,__self:!0,__source:!0},jt,Wt;function Ie(c){if(Q.call(c,"ref")){var g=Object.getOwnPropertyDescriptor(c,"ref").get;if(g&&g.isReactWarning)return!1}return c.ref!==void 0}function qe(c){if(Q.call(c,"key")){var g=Object.getOwnPropertyDescriptor(c,"key").get;if(g&&g.isReactWarning)return!1}return c.key!==void 0}function Re(c,g){typeof c.ref=="string"&&$t.current}function Pe(c,g){{var x=function(){jt||(jt=!0,E("%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)",g))};x.isReactWarning=!0,Object.defineProperty(c,"key",{get:x,configurable:!0})}}function Be(c,g){{var x=function(){Wt||(Wt=!0,E("%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)",g))};x.isReactWarning=!0,Object.defineProperty(c,"ref",{get:x,configurable:!0})}}var De=function(c,g,x,T,k,H,M){var S={$$typeof:t,type:c,key:g,ref:x,props:M,_owner:H};return S._store={},Object.defineProperty(S._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(S,"_self",{configurable:!1,enumerable:!1,writable:!1,value:T}),Object.defineProperty(S,"_source",{configurable:!1,enumerable:!1,writable:!1,value:k}),Object.freeze&&(Object.freeze(S.props),Object.freeze(S)),S};function Ne(c,g,x,T,k){{var H,M={},S=null,D=null;x!==void 0&&(_t(x),S=""+x),qe(g)&&(_t(g.key),S=""+g.key),Ie(g)&&(D=g.ref,Re(g,k));for(H in g)Q.call(g,H)&&!He.hasOwnProperty(H)&&(M[H]=g[H]);if(c&&c.defaultProps){var R=c.defaultProps;for(H in R)M[H]===void 0&&(M[H]=R[H])}if(S||D){var P=typeof c=="function"?c.displayName||c.name||"Unknown":c;S&&Pe(M,P),D&&Be(M,P)}return De(c,S,D,k,T,$t.current,M)}}var vt=C.ReactCurrentOwner,Ut=C.ReactDebugCurrentFrame;function Y(c){if(c){var g=c._owner,x=nt(c.type,c._source,g?g.type:null);Ut.setExtraStackFrame(x)}else Ut.setExtraStackFrame(null)}var bt;bt=!1;function yt(c){return typeof c=="object"&&c!==null&&c.$$typeof===t}function Vt(){{if(vt.current){var c=U(vt.current.type);if(c)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+c+"`."}return""}}function Oe(c){return""}var zt={};function Fe(c){{var g=Vt();if(!g){var x=typeof c=="string"?c:c.displayName||c.name;x&&(g=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+x+">.")}return g}}function Xt(c,g){{if(!c._store||c._store.validated||c.key!=null)return;c._store.validated=!0;var x=Fe(g);if(zt[x])return;zt[x]=!0;var T="";c&&c._owner&&c._owner!==vt.current&&(T=" It was passed a child from "+U(c._owner.type)+"."),Y(c),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',x,T),Y(null)}}function Yt(c,g){{if(typeof c!="object")return;if(gt(c))for(var x=0;x<c.length;x++){var T=c[x];yt(T)&&Xt(T,g)}else if(yt(c))c._store&&(c._store.validated=!0);else if(c){var k=y(c);if(typeof k=="function"&&k!==c.entries)for(var H=k.call(c),M;!(M=H.next()).done;)yt(M.value)&&Xt(M.value,g)}}}function Ze(c){{var g=c.type;if(g==null||typeof g=="string")return;var x;if(typeof g=="function")x=g.propTypes;else if(typeof g=="object"&&(g.$$typeof===
|
|
25
|
+
Check the top-level render call using <`+x+">.")}return g}}function Xt(c,g){{if(!c._store||c._store.validated||c.key!=null)return;c._store.validated=!0;var x=Fe(g);if(zt[x])return;zt[x]=!0;var T="";c&&c._owner&&c._owner!==vt.current&&(T=" It was passed a child from "+U(c._owner.type)+"."),Y(c),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',x,T),Y(null)}}function Yt(c,g){{if(typeof c!="object")return;if(gt(c))for(var x=0;x<c.length;x++){var T=c[x];yt(T)&&Xt(T,g)}else if(yt(c))c._store&&(c._store.validated=!0);else if(c){var k=y(c);if(typeof k=="function"&&k!==c.entries)for(var H=k.call(c),M;!(M=H.next()).done;)yt(M.value)&&Xt(M.value,g)}}}function Ze(c){{var g=c.type;if(g==null||typeof g=="string")return;var x;if(typeof g=="function")x=g.propTypes;else if(typeof g=="object"&&(g.$$typeof===l||g.$$typeof===p))x=g.propTypes;else return;if(x){var T=U(g);Me(x,c.props,"prop",T,c)}else if(g.PropTypes!==void 0&&!bt){bt=!0;var k=U(g);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k||"Unknown")}typeof g.getDefaultProps=="function"&&!g.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function _e(c){{for(var g=Object.keys(c.props),x=0;x<g.length;x++){var T=g[x];if(T!=="children"&&T!=="key"){Y(c),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",T),Y(null);break}}c.ref!==null&&(Y(c),E("Invalid attribute `ref` supplied to `React.Fragment`."),Y(null))}}var Gt={};function Kt(c,g,x,T,k,H){{var M=ye(c);if(!M){var S="";(c===void 0||typeof c=="object"&&c!==null&&Object.keys(c).length===0)&&(S+=" 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=Oe();D?S+=D:S+=Vt();var R;c===null?R="null":gt(c)?R="array":c!==void 0&&c.$$typeof===t?(R="<"+(U(c.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):R=typeof c,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",R,S)}var P=Ne(c,g,x,k,H);if(P==null)return P;if(M){var $=g.children;if($!==void 0)if(T)if(gt($)){for(var G=0;G<$.length;G++)Yt($[G],c);Object.freeze&&Object.freeze($)}else E("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 Yt($,c)}if(Q.call(g,"key")){var z=U(c),O=Object.keys(g).filter(function(ze){return ze!=="key"}),xt=O.length>0?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}";if(!Gt[z+xt]){var Ve=O.length>0?"{"+O.join(": ..., ")+": ...}":"{}";E(`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} />`,xt,z,Ve,z),Gt[z+xt]=!0}}return c===i?_e(P):Ze(P),P}}function $e(c,g,x){return Kt(c,g,x,!0)}function je(c,g,x){return Kt(c,g,x,!1)}var We=je,Ue=$e;tt.Fragment=i,tt.jsx=We,tt.jsxs=Ue}()),tt}process.env.NODE_ENV==="production"?St.exports=Xe():St.exports=Ye();var Ge=St.exports;const Ke={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",moverowup:"Move row up",moverowdown:"Move row down",colbefore:"Insert column before",colafter:"Insert column after",delcol:"Delete column",movecolleft:"Move column left",movecolright:"Move column right",cellbg:"Cell background",deltable:"Delete table",ltr:"Left to right",rtl:"Right to left",alignleft:"Align left",aligncenter:"Align center",alignright:"Align right",alignjustify:"Justify",align:"Align",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",tblalignleft:"Align table left",tblaligncenter:"Center table",tblalignright:"Align table right",alignnone:"None",quote:"Blockquote",link:"Link…",linkttl:"Insert/edit link",linkurl:"URL",unlink:"Remove link",lineheight:"Line height",wordspacing:"Word spacing",letterspacing:"Letter 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",video:"Video",quickvideo:"Insert video",deletevideo:"Delete video",uploadvideo:"Upload from computer",videolink:"Insert from URL",videourlph:"Paste video URL…",insertvideo:"Insert",dropvideo:"Drop video here",videodlgttl:"Insert/edit video",vidgeneral:"General",vidembed:"Embed",vidadvanced:"Advanced",vidsource:"Source",vidembedhint:"Paste your embed code below:",vidaltsource:"Alternative source URL",vidposter:"Media poster (Image URL)",emoji:"Emojis…",code:"Inline code",codesample:"Code sample…",codedlgttl:"Insert/edit code sample",codelang:"Language",editcode:"Edit code sample",deletecode:"Delete code sample",copycode:"Copy code",chcat_currency:"Currency",chcat_text:"Text & punctuation",chcat_math:"Mathematical",chcat_arrows:"Arrows",chcat_symbols:"Symbols",chcat_latin:"Extended Latin",chcat_arabic:"Arabic",emcat_smileys:"Smileys & emotion",emcat_people:"People & body",emcat_animals:"Animals & nature",emcat_food:"Food & drink",emcat_travel:"Travel & places",emcat_activities:"Activities",emcat_objects:"Objects",emcat_symbols:"Symbols",emcat_flags:"Flags"},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:"حذف الصف",moverowup:"نقل الصف لأعلى",moverowdown:"نقل الصف لأسفل",colbefore:"إدراج عمود قبل",colafter:"إدراج عمود بعد",delcol:"حذف العمود",movecolleft:"نقل العمود لليسار",movecolright:"نقل العمود لليمين",cellbg:"خلفية الخلية",deltable:"حذف الجدول",ltr:"من اليسار إلى اليمين",rtl:"من اليمين إلى اليسار",alignleft:"محاذاة لليسار",aligncenter:"توسيط",alignright:"محاذاة لليمين",alignjustify:"ضبط",align:"محاذاة",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:"المحاذاة",tblalignleft:"محاذاة الجدول لليسار",tblaligncenter:"توسيط الجدول",tblalignright:"محاذاة الجدول لليمين",alignnone:"بدون",quote:"اقتباس",link:"رابط…",linkttl:"إدراج/تعديل رابط",linkurl:"الرابط",unlink:"إزالة الرابط",lineheight:"تباعد الأسطر",wordspacing:"تباعد الكلمات",letterspacing:"تباعد الأحرف",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:"حذف القالب",video:"فيديو",quickvideo:"إدراج فيديو",deletevideo:"حذف الفيديو",uploadvideo:"رفع من الجهاز",videolink:"إدراج من رابط",videourlph:"الصق رابط الفيديو…",insertvideo:"إدراج",dropvideo:"أسقط الفيديو هنا",videodlgttl:"إدراج/تعديل فيديو",vidgeneral:"عام",vidembed:"تضمين",vidadvanced:"متقدم",vidsource:"المصدر",vidembedhint:"الصق كود التضمين أدناه:",vidaltsource:"رابط مصدر بديل",vidposter:"صورة الغلاف (رابط الصورة)",emoji:"رموز تعبيرية…",code:"كود مضمّن",codesample:"عينة كود…",codedlgttl:"إدراج/تعديل عينة كود",codelang:"اللغة",editcode:"تعديل عينة الكود",deletecode:"حذف عينة الكود",copycode:"نسخ الكود",chcat_currency:"عملات",chcat_text:"نص وعلامات ترقيم",chcat_math:"رموز رياضية",chcat_arrows:"أسهم",chcat_symbols:"رموز",chcat_latin:"لاتينية موسعة",chcat_arabic:"عربية",emcat_smileys:"وجوه ومشاعر",emcat_people:"أشخاص وإيماءات",emcat_animals:"حيوانات وطبيعة",emcat_food:"طعام وشراب",emcat_travel:"سفر وأماكن",emcat_activities:"أنشطة",emcat_objects:"أشياء",emcat_symbols:"رموز",emcat_flags:"أعلام"}};function Ct(d){return Ke[d]}const Qe="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 code changecase lineheight wordspacing letterspacing | removeformat | blocks | ltr rtl | quickimage quickvideo quicktable codesample template charmap emoji | fullscreen sourcecode",Je="file edit view insert format tools table help",ti=[["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"]],ei=["8px","9px","10px","11px","12px","14px","16px","18px","20px","24px","28px","32px","36px","48px","72px","96px"],ii=1,si=100,te=["1","1.15","1.4","1.5","1.75","2","2.5","3"],ee=["1px","2px","4px","6px","8px","12px"],ie=["0.5px","1px","1.5px","2px","3px","4px"],se=[["plain","Plain text"],["html","HTML/XML"],["css","CSS"],["javascript","JavaScript"],["typescript","TypeScript"],["json","JSON"],["python","Python"],["java","Java"],["csharp","C#"],["cpp","C/C++"],["php","PHP"],["ruby","Ruby"],["go","Go"],["rust","Rust"],["sql","SQL"],["bash","Bash/Shell"]],ne=[["p","para"],["h1","heading1"],["h2","heading2"],["h3","heading3"],["h4","heading4"],["h5","heading5"],["h6","heading6"],["pre","pre"]],ni=["#F76707","#4263EB","#CC5DE8"],ri=["#FFFFFF","#F4F4F4","#E8EAED","#DADCE0","#000000","#F28B82","#FBBC04","#FFF475","#CCFF90","#A7FFEB","#CBF0F8","#AECBFA","#D7AEFB","#FDCFE8","#E6C9A8","#EA4335","#FB8C00","#FDD835","#34A853","#00ACC1","#4285F4","#5E35B1","#8E24AA","#C2185B","#6D4C41"],li=[{key:"chcat_currency",chars:["€","£","¥","¢","$","₹","₽","₩","₺","₴","₦","฿","₫","₪","﷼","¤","₡","₱","₲","₵","₭","₮","₸","₼","₾","₿"]},{key:"chcat_text",chars:["§","¶","†","‡","•","…","′","″","‰","‱","–","—","―","¡","¿","·","‹","›","«","»","“","”","‘","’","„","‚","¦","ª","º","‽","※","❝","❞","❮","❯"]},{key:"chcat_math",chars:["°","±","×","÷","≈","≠","≤","≥","∞","µ","√","∑","∫","∂","∆","∏","π","Ω","α","β","γ","δ","ε","θ","λ","σ","φ","ψ","ω","∈","∉","∪","∩","⊂","⊃","⊆","⊇","∀","∃","∅","∝","∴","∵","¬","∧","∨","½","⅓","¼","¾","⅔","⅛","⅜","⅝","⅞","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","⁰","₁","₂","₃","₄","₅","₆","₇","₈","₉","₀"]},{key:"chcat_arrows",chars:["←","→","↑","↓","↔","↕","⇐","⇒","⇑","⇓","⇔","↖","↗","↘","↙","↩","↪","↺","↻","⤴","⤵","➜","➝","➞","➟","⇦","⇨","⇧","⇩"]},{key:"chcat_symbols",chars:["©","®","™","℠","№","℮","✓","✔","✗","✘","★","☆","✦","✪","♠","♣","♥","♦","♪","♫","♬","☀","☁","☂","☃","☾","☹","☺","☻","✉","✂","✎","✏","☎","☏","⌛","⌚","☞","☜","☝","☟"]},{key:"chcat_latin",chars:["À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ø","ù","ú","û","ü","ý","þ","ÿ","Œ","œ","Š","š","Ž","ž","Ł","ł"]},{key:"chcat_arabic",chars:["؟","،","؛","٪","٭","ـ","٠","١","٢","٣","٤","٥","٦","٧","٨","٩","﴾","﴿","۞","؎","ء","آ","أ","ؤ","إ","ئ","ى","ة"]}],oi=[{key:"emcat_smileys",chars:["😀","😃","😄","😁","😆","😅","😂","🤣","😊","😇","🙂","🙃","😉","😌","😍","🥰","😘","😋","😛","😜","🤪","🤨","🧐","🤓","😎","🥳","😏","😒","😞","😔","😟","😕","🙁","😣","😫","😩","🥺","😢","😭","😤","😠","😡","🤯","😳","🥵","🥶","😱","😨","😥","🤗","🤔","🤭","🤫","😐","😑","😬","🙄","😯","😴","😪","😷","🤒","🤕","🤢","🤧","😈","💀","👻","👽","🤖","💩","😺","😸","😹","😻","🙀"]},{key:"emcat_people",chars:["👋","🤚","✋","🖖","👌","🤏","✌","🤞","🤟","🤘","🤙","👈","👉","👆","👇","☝","👍","👎","✊","👊","👏","🙌","👐","🤲","🤝","🙏","💪","✍","💅","🤳","👂","👃","👀","👁","🧠","👶","🧒","👦","👧","🧑","👨","👩","🧓","👴","👵","👮","👷","💂","🕵","👸","🤴","👰","🤵","🤰","👼","🎅","🦸","🦹","🧙","🧚","🧛","🧟","💃","🕺","🚶","🏃","🧘"]},{key:"emcat_animals",chars:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🐔","🐧","🐦","🐤","🦆","🦅","🦉","🐺","🐗","🐴","🦄","🐝","🐛","🦋","🐌","🐞","🐢","🐍","🦎","🦖","🐙","🦑","🦀","🐠","🐟","🐬","🐳","🦈","🐊","🐅","🦓","🦍","🐘","🦏","🐪","🦒","🦘","🐄","🐎","🐖","🐑","🐐","🦌","🐕","🐈","🐓","🦃","🦚","🦜","🦢","🕊","🐇","🦔","🌵","🌲","🌴","🌱","🌿","☘","🍀","🍁","🌸","🌺","🌻","🌹","🌷","💐"]},{key:"emcat_food",chars:["🍏","🍎","🍐","🍊","🍋","🍌","🍉","🍇","🍓","🍈","🍒","🍑","🥭","🍍","🥥","🥝","🍅","🍆","🥑","🥦","🥒","🌶","🌽","🥕","🥔","🥐","🍞","🥖","🥨","🧀","🥚","🍳","🥞","🥓","🥩","🍗","🍖","🌭","🍔","🍟","🍕","🥪","🌮","🌯","🥗","🍝","🍜","🍲","🍛","🍣","🍱","🥟","🍤","🍚","🍧","🍨","🍦","🥧","🧁","🍰","🎂","🍮","🍭","🍬","🍫","🍿","🍩","🍪","🥜","🍯","🥛","☕","🍵","🥤","🍺","🥂","🍷","🍸","🍹"]},{key:"emcat_travel",chars:["🚗","🚕","🚙","🚌","🏎","🚓","🚑","🚒","🚚","🚜","🛵","🏍","🚲","🛴","🚔","🚃","🚄","🚅","🚂","🚆","🚇","🚉","✈","🛫","🛬","💺","🚁","🚀","🛸","🚢","⛵","🚤","⚓","⛽","🚧","🗺","🗿","🗽","🗼","🏰","🏯","🎡","🎢","🎠","⛲","🏖","🏝","🌋","⛰","🏔","🗻","🏕","⛺","🏠","🏡","🏢","🏬","🏥","🏦","🏨","🏪","🏫","💒","⛪","🕌","🕍","🕋","⛩","🌅","🌄","🌇","🌆","🌃","🌉","🌌","🌠"]},{key:"emcat_activities",chars:["⚽","🏀","🏈","⚾","🎾","🏐","🏉","🎱","🏓","🏸","🏒","🏑","🏏","⛳","🏹","🎣","🥊","🥋","⛸","🎿","⛷","🏂","🏋","🤸","⛹","🤺","🏇","🧗","🏄","🏊","🚣","🚵","🚴","🏆","🥇","🥈","🥉","🏅","🎖","🎫","🎪","🤹","🎭","🎨","🎬","🎤","🎧","🎼","🎹","🥁","🎷","🎺","🎸","🎻","🎲","🎯","🎳","🎮","🎰","🧩"]},{key:"emcat_objects",chars:["⌚","📱","💻","⌨","🖥","🖨","🖱","🕹","💽","💾","💿","📀","📷","📸","📹","🎥","📞","☎","📺","📻","🎙","⏱","⏰","⌛","⏳","📡","🔋","🔌","💡","🔦","🕯","💸","💵","💰","💳","💎","⚖","🔧","🔨","⚒","🛠","⛏","🔩","⚙","🧲","🔫","💣","🔪","🛡","🔮","🧿","🔭","🔬","💊","💉","🌡","🧬","🧪","🧹","🧺","🛁","🔑","🗝","🚪","🛋","🛏","🧸","🖼","🛍","🛒","🎁","🎈","🎀","🎊","🎉","✉","📩","📦","📜","📄","📊","📈","📉","📅","📋","📁","📰","📓","📚","📖","🔖","🔗","📎","📐","📏","📌","📍","✂","🖊","✒","🖌","🖍","📝","✏","🔍","🔒","🔓"]},{key:"emcat_symbols",chars:["❤","🧡","💛","💚","💙","💜","🖤","💔","❣","💕","💞","💓","💗","💖","💘","💝","☮","✝","☪","🕉","☸","✡","☯","♈","♉","♊","♋","♌","♍","♎","♏","♐","♑","♒","♓","⚛","❌","⭕","🛑","⛔","🚫","💯","💢","⚠","🚸","🔱","⚜","🔰","♻","✅","❇","✳","❎","🌐","💠","🌀","💤","🏧","♿","🚭","❗","❕","❓","❔","‼","⁉","💲","🔅","🔆","〽","ℹ","🆗","🆕","🆓","🆒","🆙","🈯","🈚"]},{key:"emcat_flags",chars:["🏁","🚩","🎌","🏴","🏳","🇦🇪","🇸🇦","🇶🇦","🇰🇼","🇧🇭","🇴🇲","🇪🇬","🇯🇴","🇱🇧","🇮🇳","🇵🇰","🇺🇸","🇬🇧","🇨🇦","🇦🇺","🇫🇷","🇩🇪","🇮🇹","🇪🇸","🇵🇹","🇳🇱","🇧🇪","🇨🇭","🇸🇪","🇳🇴","🇩🇰","🇫🇮","🇮🇪","🇬🇷","🇹🇷","🇷🇺","🇺🇦","🇵🇱","🇯🇵","🇰🇷","🇨🇳","🇸🇬","🇲🇾","🇮🇩","🇹🇭","🇵🇭","🇻🇳","🇧🇷","🇦🇷","🇲🇽","🇿🇦","🇳🇬","🇰🇪","🇲🇦"]}],L=(d,t)=>`<svg viewBox="${t||"0 0 24 24"}">${d}</svg>`,w=d=>L(`<path class="f" d="${d}"/>`,"0 -960 960 960"),lt=(d,t=7.5)=>L('<path d="M10 6h10M10 12h10M10 18h10"/>'+d.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:w("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:w("M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"),underline:w("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:w("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:w("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:w("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:w("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:w("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:w("M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"),aligncenter:w("M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"),alignright:w("M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"),alignjustify:w("M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"),fullscreen:w("M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z"),clearformatic:w("m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"),numlist:w("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:w("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:w("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:w("M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"),indent:w("M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"),more:L('<circle class="f" cx="5" cy="12" r="1.7"/><circle class="f" cx="12" cy="12" r="1.7"/><circle class="f" cx="19" cy="12" r="1.7"/>'),image:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("M200-160h560v-240H200v240Zm640 80H120v-720h160v80h-80v240h560v-240h-80v-80h160v720ZM480-480Zm0 80v-80 80Zm0 0Zm-40-240v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),rowafter:w("M200-560h560v-240H200v240Zm-80 400v-720h720v720H680v-80h80v-240H200v240h80v80H120Zm360-320Zm0-80v80-80Zm0 0ZM440-80v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),rowdelete:w("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:w("M800-200v-560H560v560h240Zm-640 80v-160h80v80h240v-560H240v80h-80v-160h720v720H160Zm320-360Zm80 0h-80 80Zm0 0ZM160-360v-80H80v-80h80v-80h80v80h80v80h-80v80h-80Z"),colafter:w("M160-760v560h240v-560H160ZM80-120v-720h720v160h-80v-80H480v560h240v-80h80v160H80Zm400-360Zm-80 0h80-80Zm0 0Zm320 120v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),coldelete:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm504 104v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z"),fontsizedown:w("m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm384-16v-80h320v80H600Z"),historyic:w("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:w("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:w("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:w("M80-160v-160h160v160H80Zm240 0v-160h560v160H320ZM80-400v-160h160v160H80Zm240 0v-160h560v160H320ZM80-640v-160h160v160H80Zm240 0v-160h560v160H320Z"),ol_alpha:lt(["a","b","c"]),ol_roman:lt(["i","ii","iii"],6.5),ol_alphau:lt(["A","B","C"]),ol_romanu:lt(["I","II","III"],6.5),video:L('<rect x="3" y="6" width="13" height="12" rx="1.5"/><path d="M16 10l5-3v10l-5-3z"/>'),editic:L('<path d="M4 20l1-4.5L15.5 5 19 8.5 8.5 19 4 20z"/><path d="M13.5 6.5l4 4"/>'),letterspacing:L('<text x="2.5" y="13" font-size="12" stroke="none" fill="#222f3e" font-family="Arial" font-weight="bold">A</text><text x="13" y="13" font-size="12" stroke="none" fill="#222f3e" font-family="Arial" font-weight="bold">B</text><path d="M7 18.5h10"/><path class="f" d="M7.5 18.5 4.5 16.6v3.8z"/><path class="f" d="M16.5 18.5l3-1.9v3.8z"/>'),emojiic:L('<circle cx="12" cy="12" r="8.5"/><path d="M8.6 14.3a4.6 4.6 0 0 0 6.8 0"/><path d="M9.2 9.6v.7M14.8 9.6v.7"/>'),inlinecodeic:L('<path d="M8.5 8 4.5 12l4 4M15.5 8l4 4-4 4"/><path d="M13 6l-2 12"/>'),moverowup:L('<rect x="4" y="15.5" width="16" height="5" rx="1"/><path d="M12 12.5V4M8.5 7.5 12 4l3.5 3.5"/>'),moverowdown:L('<rect x="4" y="3.5" width="16" height="5" rx="1"/><path d="M12 11.5V20M8.5 16.5 12 20l3.5-3.5"/>'),movecolleft:L('<rect x="15.5" y="4" width="5" height="16" rx="1"/><path d="M12.5 12H4M7.5 8.5 4 12l3.5 3.5"/>'),movecolright:L('<rect x="3.5" y="4" width="5" height="16" rx="1"/><path d="M11.5 12H20M16.5 8.5 20 12l-3.5 3.5"/>'),codesampleic:L('<rect x="3.5" y="4" width="17" height="16" rx="2"/><path d="M3.5 8.5h17"/><path d="M9.5 12 7 14.25l2.5 2.25M14.5 12l2.5 2.25-2.5 2.25"/>')},ai=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"]),ci=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"]),re={"*":["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 ut(d){const t={},e=d.getAttribute&&d.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 hi(d){return d.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 di(d){return/^[0-9]+[\.\)،]/.test(d)?{ordered:!0}:/^[٠-٩۰-۹]+/.test(d)?{ordered:!0,style:"arabic-indic"}:/^[ivxlc]{2,}[\.\)]/.test(d)?{ordered:!0,style:"lower-roman"}:/^[IVXLC]{2,}[\.\)]/.test(d)?{ordered:!0,style:"upper-roman"}:/^[a-z][\.\)]/.test(d)?{ordered:!0,style:"lower-alpha"}:/^[A-Z][\.\)]/.test(d)?{ordered:!0,style:"upper-alpha"}:/^[ء-ي][\.\)،-]/.test(d)?{ordered:!0,style:"arabic-indic"}:{ordered:!1}}function ui(d){const t=s=>{const n=(s.getAttribute("style")||"")+" "+(s.className||"");return/mso-list\s*:(?!\s*ignore)/i.test(n)||/MsoListParagraph/i.test(n)},e=[];let i=null;Array.from(d.body.querySelectorAll("p")).forEach(s=>{if(!t(s)){i=null;return}const n=s.previousElementSibling;i&&n&&i[i.length-1]===n?i.push(s):(i=[s],e.push(i))}),e.forEach(s=>{const n=[],l=s[0];s.forEach(r=>{var C,E,I;const a=+(((C=(r.getAttribute("style")||"").match(/level(\d+)/i))==null?void 0:C[1])||1),u=Array.from(r.querySelectorAll("span")).find(A=>/mso-list\s*:\s*ignore/i.test(A.getAttribute("style")||"")),p=u?((E=u.textContent)==null?void 0:E.trim())||"":(((I=r.textContent)==null?void 0:I.trim().match(/^\S{1,4}/))||[""])[0],{ordered:m,style:v}=di(p);for(u&&u.remove();n.length&&n[n.length-1].level>a;)n.pop();if(!n.length||n[n.length-1].level<a){const A=d.createElement(m?"ol":"ul");if(m&&v&&(A.style.listStyleType=v),n.length){const j=n[n.length-1].list;(j.lastElementChild||j).appendChild(A)}else l.parentNode.insertBefore(A,l);n.push({list:A,level:a})}const b=d.createElement("li"),f=ut(r),y=["text-align","direction","unicode-bidi","color","font-size","font-family","background-color"].filter(A=>f[A]).map(A=>A+":"+f[A]).join(";");for(y&&b.setAttribute("style",y),r.getAttribute("dir")&&b.setAttribute("dir",r.getAttribute("dir"));r.firstChild;)b.appendChild(r.firstChild);n[n.length-1].list.appendChild(b),r.remove()})})}function pi(d){d.querySelectorAll('b[id^="docs-internal-guid"]').forEach(t=>{for(;t.firstChild;)t.parentNode.insertBefore(t.firstChild,t);t.remove()})}function mi(d){d.querySelectorAll("table").forEach(t=>{const e=t;ut(e)["border-collapse"]||(e.style.borderCollapse="collapse")}),d.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 n=s;i==="center"?(n.style.marginLeft=n.style.marginLeft||"auto",n.style.marginRight=n.style.marginRight||"auto"):i==="right"?n.style.marginLeft=n.style.marginLeft||"auto":i==="left"&&(n.style.marginRight=n.style.marginRight||"auto")})),e.removeAttribute("align")}),d.querySelectorAll("center table").forEach(t=>{const e=t;e.style.marginLeft=e.style.marginLeft||"auto",e.style.marginRight=e.style.marginRight||"auto"}),d.querySelectorAll("[bgcolor]").forEach(t=>{const e=t;e.style.backgroundColor=e.style.backgroundColor||e.getAttribute("bgcolor"),e.removeAttribute("bgcolor")})}function ht(d,t){Array.from(d.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(!ai.has(s)){if(s==="font"){const o=t.createElement("span");i.getAttribute("style")&&o.setAttribute("style",i.getAttribute("style")),i.getAttribute("color")&&(o.style.color=i.getAttribute("color")),i.getAttribute("face")&&(o.style.fontFamily=i.getAttribute("face"));const a=i.getAttribute("size");if(a&&!o.style.fontSize){const u={1:"8pt",2:"10pt",3:"12pt",4:"14pt",5:"18pt",6:"24pt",7:"36pt"};u[a]&&(o.style.fontSize=u[a])}for(;i.firstChild;)o.appendChild(i.firstChild);i.replaceWith(o),ht(o,t);return}for(ht(i,t);i.firstChild;)i.parentNode.insertBefore(i.firstChild,i);i.remove();return}const n=new Set([...re["*"]||[],...re[s]||[]]);if(Array.from(i.attributes).forEach(o=>{const a=o.name.toLowerCase();a!=="style"&&!n.has(a)&&i.removeAttribute(o.name)}),s==="a"){const o=i.getAttribute("href")||"";/^(https?:|mailto:|tel:|#)/i.test(o)||i.removeAttribute("href")}if(s==="img"){const o=i.getAttribute("src")||"";if(!/^(https?:|data:image\/|blob:)/i.test(o)){const a=t.createElement("span");a.textContent="[local image — paste it separately]",a.setAttribute("style","color:#a33;font-style:italic;font-size:12px"),i.replaceWith(a);return}}const l=ut(i),r=[];for(const[o,a]of Object.entries(l))ci.has(o)&&(/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(a)||o==="font-weight"&&/^(400|normal)$/i.test(a)||o==="font-style"&&/^normal$/i.test(a)||o==="text-decoration"&&/^none$/i.test(a)||r.push(o+":"+a));if(r.length?i.setAttribute("style",r.join(";")):i.removeAttribute("style"),i.removeAttribute("class"),ht(i,t),s==="span"&&!i.attributes.length){for(;i.firstChild;)i.parentNode.insertBefore(i.firstChild,i);i.remove()}})}function fi(d){const t=[],e=/<style[^>]*>([\s\S]*?)<\/style>/gi;let i;for(;i=e.exec(d);){let s=i[1].replace(/<!--|-->/g,"").replace(/\/\*[\s\S]*?\*\//g,"");s=s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi,""),s=s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g,"");let n;const l=/([^{}]+)\{([^}]*)\}/g;for(;n=l.exec(s);){const r=n[2].split(";").map(o=>{const a=o.indexOf(":");return a<1?null:[o.slice(0,a).trim().toLowerCase(),o.slice(a+1).trim()]}).filter(o=>!!o&&!!o[1]);r.length&&n[1].split(",").map(o=>o.trim()).filter(o=>o&&!o.startsWith("@")).forEach(o=>t.push({sel:o,decls:r}))}}return t}function gi(d,t){if(!t.length)return;const e=new Map;t.forEach(({sel:i,decls:s})=>{let n;try{n=d.querySelectorAll(i)}catch{return}n.forEach(l=>{let r=e.get(l);r||(r={},e.set(l,r)),s.forEach(([o,a])=>{r[o]=a})})}),e.forEach((i,s)=>{const n=ut(s),l=s.hasAttribute("dir"),r=s.hasAttribute("align"),o=Object.entries(i).filter(([p])=>!(p in n||(p==="direction"||p==="unicode-bidi")&&l||p==="text-align"&&(r||l)||(p==="background"||p==="background-color")&&s.hasAttribute("bgcolor")));if(!o.length)return;const a=o.map(([p,m])=>p+":"+m).join(";"),u=s.getAttribute("style");s.setAttribute("style",u?a+";"+u:a)})}function pe(d){return d.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g,t=>t.normalize("NFKC"))}function vi(d){const t=d.createTreeWalker(d.body,NodeFilter.SHOW_TEXT,null);let e;for(;e=t.nextNode();)/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue||"")&&(e.nodeValue=pe(e.nodeValue||""))}function bi(d,t="ltr"){const e=fi(d),i=new DOMParser().parseFromString(hi(d),"text/html");gi(i,e),/class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML)&&ui(i),pi(i),mi(i),ht(i.body,i),vi(i);const s=n=>{var l;return n&&n.tagName==="P"&&!((l=n.textContent)!=null&&l.trim())&&!n.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 yi(d){const t=pe(d).replace(/\r/g,""),e=i=>i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return/\n/.test(t)?t.split(/\n{2,}/).map(i=>`<p dir="auto">${e(i).replace(/\n/g,"<br>")||"<br>"}</p>`).join(""):e(t)}const xi=10*1024*1024,me=/^(https?:|data:image\/|blob:)/i;function le(d,t){const e=[],i="{\\"+t;let s=0;for(;(s=d.indexOf(i,s))!==-1;){const n=d[s+i.length];if(n&&/[a-z0-9]/i.test(n)){s+=i.length;continue}let l=0,r=s;for(;r<d.length;r++){const o=d[r];if(o==="\\"){r++;continue}if(o==="{")l++;else if(o==="}"&&(l--,!l))break}e.push({start:s,end:r+1,body:d.slice(s+i.length,r)}),s=r+1}return e}function Ci(d){const t=new Uint8Array(d.length/2);for(let e=0;e<t.length;e++)t[e]=parseInt(d.substr(e*2,2),16);return t}function wt(d){let t="";for(let e=0;e<d.length;e++)t+=String.fromCharCode(d[e]);return btoa(t)}function oe(d,t){t:for(let e=0;e+t.length<=d.length;e++){for(let i=0;i<t.length;i++)if(d[e+i]!==t[i])continue t;return e}return-1}const wi=[137,80,78,71],Ti=[255,216,255];function Ei(d){let t=null;if(/\\pngblip/.test(d)?t="image/png":/\\jpegblip/.test(d)?t="image/jpeg":(/\\wmetafile\d*/.test(d)||/\\emfblip/.test(d))&&(t="metafile"),!t)return null;let e=d.replace(/\{[^{}]*\}/g," ").replace(/\\[a-z]+-?\d*\s?/gi," ").replace(/[^0-9a-fA-F]/g,"");if(e.length%2&&(e=e.slice(0,-1)),!e)return null;const i=Ci(e);if(t==="metafile"){const s=oe(i,wi);if(s>=0)return"data:image/png;base64,"+wt(i.slice(s));const n=oe(i,Ti);return n>=0?"data:image/jpeg;base64,"+wt(i.slice(n)):null}return"data:"+t+";base64,"+wt(i)}function Si(d){if(!d||d.indexOf("\\pict")===-1)return[];let t=d;le(d,"nonshppict").reverse().forEach(i=>{t=t.slice(0,i.start)+t.slice(i.end)});let e=xi;return le(t,"pict").map(i=>{if(e<=0)return null;const s=Ei(i.body);return s&&(e-=s.length*.75),s})}function ae(d){const t=d.match(/^\s*(-?[\d.]+)\s*(pt|px|in|cm|mm)?\s*$/i);if(!t)return null;const e=parseFloat(t[1]);if(!isFinite(e)||e<=0)return null;const i=(t[2]||"px").toLowerCase(),s=i==="pt"?e*4/3:i==="in"?e*96:i==="cm"?e*96/2.54:i==="mm"?e*96/25.4:e;return Math.round(s)}function Mi(d,t){const e=d.match(new RegExp("\\s"+t+`\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));return e?e[1]??e[2]??e[3]??"":""}function Li(d){if(!/<v:imagedata\b/i.test(d))return d;const t=(i,s)=>{const n=Mi(i,"src");if(!n)return null;const l=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`<img\\b[^>]*\\bsrc\\s*=\\s*["']?`+l,"i").test(d))return null;const r=(s.match(/<v:shape\b[^>]*\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/i)||[]).slice(1).find(Boolean)||"",o=ae((r.match(/(?:^|;)\s*width\s*:\s*([^;]+)/i)||[])[1]||""),a=ae((r.match(/(?:^|;)\s*height\s*:\s*([^;]+)/i)||[])[1]||"");return'<img src="'+n.replace(/"/g,""")+'"'+(o?' width="'+o+'"':"")+(a?' height="'+a+'"':"")+">"};let e=d.replace(/<!--\[if [^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi,(i,s)=>{const n=s.match(/<v:imagedata\b[^>]*>/i);return n&&t(n[0],s)||i});return e=e.replace(/<v:shape\b[^>]*>[\s\S]*?<\/v:shape\s*>/gi,i=>{const s=i.match(/<v:imagedata\b[^>]*>/i);return s&&t(s[0],i)||i}),e.replace(/<v:imagedata\b[^>]*>/gi,i=>t(i,"")||i)}function fe(d,t){if(!d||!t.length)return{html:d,injected:[]};const e=[];let i=0;return{html:Li(d).replace(/<img\b[^>]*>/gi,n=>{const l=(n.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i)||[])[1]||"";if(me.test(l))return n;const r=t[i++];return r?(e.push(r),/\ssrc\s*=\s*["']/i.test(n)?n.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i,'$1"'+r+'"'):n.replace(/(\ssrc\s*=\s*)[^\s>]+/i,'$1"'+r+'"')):n}),injected:e}}function ki(d,t){return!d||!t?{html:d,injected:[]}:fe(d,Si(t))}function Ai(d){const t=d.match(/<img\b[^>]*>/gi);return t?t.filter(e=>{const i=(e.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i)||[])[1]||"";return!me.test(i)}).length:0}function Hi(d,t){const e=d.match(/^data:([^;,]+);base64,(.*)$/);if(!e)return null;const i=(e[1].split("/")[1]||"png").replace(/[^a-z0-9]/gi,"")||"png";try{const s=atob(e[2]),n=new Uint8Array(s.length);for(let l=0;l<s.length;l++)n[l]=s.charCodeAt(l);return new File([n],t+"."+(i==="jpeg"?"jpg":i),{type:e[1]})}catch{return null}}function Ii(d){const t=new DataView(d),e=new Map;let i=-1;for(let r=d.byteLength-22;r>=Math.max(0,d.byteLength-22-65535);r--)if(t.getUint32(r,!0)===101010256){i=r;break}if(i<0)throw new Error("EOCD not found");const s=t.getUint16(i+10,!0);let n=t.getUint32(i+16,!0);const l=new TextDecoder;for(let r=0;r<s&&t.getUint32(n,!0)===33639248;r++){const o=t.getUint16(n+10,!0),a=t.getUint32(n+20,!0),u=t.getUint16(n+28,!0),p=t.getUint16(n+30,!0),m=t.getUint16(n+32,!0),v=t.getUint32(n+42,!0),b=l.decode(new Uint8Array(d,n+46,u));e.set(b,{name:b,method:o,compSize:a,localOffset:v}),n+=46+u+p+m}return e}async function ce(d,t){const e=new DataView(d,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),n=t.localOffset+30+i+s,l=new Uint8Array(d.slice(n,n+t.compSize));if(t.method===0)return l;if(t.method!==8)throw new Error("Unsupported compression method "+t.method);const r=new Blob([l]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(r).arrayBuffer())}const he=d=>d.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),dt=(d,t)=>Array.from(d.children).filter(e=>e.localName===t),B=(d,...t)=>{let e=d;for(const i of t){if(!e)return null;e=Array.from(e.children).find(s=>s.localName===i)||null}return e},q=(d,t="val")=>{if(!d)return"";for(const e of Array.from(d.attributes))if(e.localName===t)return e.value;return""},ot=(d,t)=>{const e=d?B(d,t):null;if(!e)return!1;const i=q(e);return i!=="false"&&i!=="0"},de={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"},qi={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",webp:"image/webp"};function Ri(d){let t="";for(let e=0;e<d.length;e+=32768)t+=String.fromCharCode(...d.subarray(e,e+32768));return btoa(t)}class Pi{constructor(t,e,i){this.rels=t,this.images=e,this.numFmt=i}convertBody(t){let e="",i=[];const s=n=>{for(;i.length>n;)e+=`</${i.pop()}>`};for(const n of Array.from(t.children))if(n.localName==="p"){const l=this.paraList(n);if(l){const r=l.ilvl+1;for(;i.length>r;)e+=`</${i.pop()}>`;for(i.length===r&&i[r-1]!==l.type&&(e+=`</${i.pop()}>`);i.length<r;)e+=`<${l.type}>`,i.push(l.type);e+=`<li>${this.runsOf(n)||"<br>"}</li>`;continue}s(0),e+=this.convertPara(n)}else n.localName==="tbl"?(s(0),e+=this.convertTable(n)):n.localName;return s(0),e||"<p><br></p>"}paraList(t){const e=B(t,"pPr","numPr");if(!e)return null;const i=q(B(e,"numId"));if(!i||i==="0")return null;const s=parseInt(q(B(e,"ilvl"))||"0",10)||0;return{type:this.numFmt.get(i)||"ul",ilvl:Math.min(s,8)}}convertPara(t){const e=B(t,"pPr"),i=q(B(t,"pPr","pStyle"));let s="p";const n=/^Heading([1-6])$/i.exec(i);n?s="h"+n[1]:/^Title$/i.test(i)&&(s="h1");const l=[],r=q(B(t,"pPr","jc"));r==="center"?l.push("text-align:center"):r==="right"||r==="end"?l.push("text-align:right"):(r==="both"||r==="distribute")&&l.push("text-align:justify"),e&&B(e,"bidi")&&l.push("direction:rtl");const o=this.runsOf(t),a=l.length?` style="${l.join(";")}"`:"";return`<${s}${a}>${o||"<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(q(i,"id"))||"";const n=q(i,"anchor");!s&&n&&(s="#"+n);const l=this.runsOf(i);e+=s?`<a href="${he(s)}">${l}</a>`:l}else(i.localName==="smartTag"||i.localName==="ins")&&(e+=this.runsOf(i));return e}convertRun(t){const e=B(t,"rPr");let i="";for(const p of Array.from(t.children))p.localName==="t"?i+=he(p.textContent||""):p.localName==="br"||p.localName==="cr"?i+="<br>":p.localName==="tab"?i+=" ":(p.localName==="drawing"||p.localName==="pict"||p.localName==="object")&&(i+=this.convertImage(p));if(!i)return"";const s=[],n=q(e?B(e,"color"):null);n&&n!=="auto"&&s.push("color:#"+n);const l=q(e?B(e,"highlight"):null);l&&de[l]&&s.push("background-color:"+de[l]);const r=parseFloat(q(e?B(e,"sz"):null));r&&s.push("font-size:"+Math.round(r/2*(4/3))+"px");const o=e?B(e,"rFonts"):null,a=q(o,"ascii")||q(o,"cs");a&&s.push(`font-family:'${a}'`),s.length&&(i=`<span style="${s.join(";")}">${i}</span>`),ot(e,"b")&&(i=`<strong>${i}</strong>`),ot(e,"i")&&(i=`<em>${i}</em>`),ot(e,"u")&&q(B(e,"u"))!=="none"&&(i=`<u>${i}</u>`),ot(e,"strike")&&(i=`<s>${i}</s>`);const u=q(e?B(e,"vertAlign"):null);return u==="superscript"?i=`<sup>${i}</sup>`:u==="subscript"&&(i=`<sub>${i}</sub>`),i}convertImage(t){let e="",i=0;const s=r=>{if(r.localName==="blip"&&(e=e||q(r,"embed")||q(r,"link")),r.localName==="imagedata"&&(e=e||q(r,"id")),r.localName==="extent"){const o=parseFloat(r.getAttribute("cx")||"0");o&&(i=Math.round(o/9525))}for(const o of Array.from(r.children))s(o)};if(s(t),!e)return"";const n=this.images.get(e);if(!n)return"";const l=i?` width="${i}"`:"";return`<img src="${n}" alt=""${l}>`}convertTable(t){let e='<table style="border-collapse:collapse;width:100%"><tbody>';for(const i of dt(t,"tr")){e+="<tr>";for(const s of dt(i,"tc")){const n=parseInt(q(B(s,"tcPr","gridSpan"))||"1",10)||1,l=n>1?` colspan="${n}"`:"";let r="";for(const o of Array.from(s.children))o.localName==="p"?r+=this.convertPara(o):o.localName==="tbl"&&(r+=this.convertTable(o));e+=`<td style="border:1px solid #b9c2cc"${l}>${r||"<br>"}</td>`}e+="</tr>"}return e+"</tbody></table>"}}async function Bi(d){const t=d instanceof ArrayBuffer?d:await d.arrayBuffer(),e=Ii(t),i=new TextDecoder,s=async b=>{const f=e.get(b);return f?new DOMParser().parseFromString(i.decode(await ce(t,f)),"application/xml"):null},n=await s("word/document.xml"),l=n==null?void 0:n.getElementsByTagName("*");let r=null;if(l){for(const b of Array.from(l))if(b.localName==="body"){r=b;break}}if(!r)throw new Error("word/document.xml missing or invalid");const o=new Map,a=new Map,u=await s("word/_rels/document.xml.rels");if(u)for(const b of Array.from(u.getElementsByTagName("*"))){if(b.localName!=="Relationship")continue;const f=b.getAttribute("Id")||"",y=b.getAttribute("Target")||"",C=b.getAttribute("Type")||"";/hyperlink/i.test(C)?o.set(f,y):/image/i.test(C)&&a.set(f,y)}const p=new Map;for(const[b,f]of a){const y=f.startsWith("/")?f.slice(1):"word/"+f.replace(/^\.\//,""),C=e.get(y);if(!C)continue;const E=(y.split(".").pop()||"").toLowerCase(),I=qi[E];if(I)try{p.set(b,`data:${I};base64,${Ri(await ce(t,C))}`)}catch{}}const m=new Map,v=await s("word/numbering.xml");if(v){const b=new Map,f=Array.from(v.getElementsByTagName("*"));for(const y of f){if(y.localName!=="abstractNum")continue;const C=q(y,"abstractNumId"),E=dt(y,"lvl").find(A=>q(A,"ilvl")==="0")||dt(y,"lvl")[0],I=E?q(B(E,"numFmt")):"";b.set(C,I==="bullet"?"ul":"ol")}for(const y of f){if(y.localName!=="num")continue;const C=q(y,"numId"),E=q(B(y,"abstractNumId"));m.set(C,b.get(E)||"ul")}}return new Pi(o,p,m).convertBody(r)}const Di=["nw","ne","sw","se"],Tt=["img-left","img-right","img-top","img-center"],Et={"img-left":"tplimgleft","img-right":"tplimgright","img-top":"tplimgtop","img-center":"tplimgcenter"},Ni={"img-left":h.tplleft,"img-right":h.tplright,"img-top":h.tpltop,"img-center":h.tplcenter},Oi=".tox,.pop,.tblctx,.imgctx,.selctx,.dlg";let F=null,X=null,Mt=0,ue=!1;function at(){clearTimeout(Mt),X=null,F&&F.classList.remove("show")}function Fi(d){const t=d.dataset.tip;if(!t)return;X=d,clearTimeout(Mt);const e=F&&F.classList.contains("show")?60:350;Mt=window.setTimeout(()=>{if(X!==d||!document.contains(d))return;F||(F=document.createElement("div"),F.className="etip",document.body.appendChild(F)),F.textContent=t,F.classList.add("show");const i=d.getBoundingClientRect(),s=F.offsetWidth,n=F.offsetHeight;let l=i.left+i.width/2-s/2;l=Math.max(6,Math.min(l,innerWidth-s-6));let r=i.bottom+7;r+n>innerHeight-6&&(r=i.top-n-7),F.style.left=l+"px",F.style.top=r+"px"},e)}function Zi(){ue||(ue=!0,document.addEventListener("mouseover",d=>{const t=d.target,e=t.closest?t.closest("[title],[data-tip]"):null;if(!e||!e.closest(Oi)||e.closest(".earea")){e!==X&&at();return}const i=e.getAttribute("title");i&&(e.dataset.tip=i,e.removeAttribute("title"),e.getAttribute("aria-label")||e.setAttribute("aria-label",i)),e!==X&&Fi(e)}),document.addEventListener("mouseout",d=>{X&&!X.contains(d.relatedTarget)&&at()}),document.addEventListener("mousedown",at,!0),addEventListener("scroll",at,!0))}const _i=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u0780-\u07BF\u08A0-\u08FF\uFB1D-\uFB4F\uFB50-\uFDFF\uFE70-\uFEFF]/,$i=new RegExp("\\p{L}","u"),ji="p,div,li,td,th,blockquote,h1,h2,h3,h4,h5,h6,pre,figcaption";function Wi(d){for(const t of d){if(_i.test(t))return"rtl";if($i.test(t))return"ltr"}return null}const ct=["top","right","bottom","left"],Ui=/^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/i,Vi=/^(thin|medium|thick|[+-]?(\d+\.?\d*|\.\d+)(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?)$/i,zi=/^[+-]?0*(\.0*)?(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?$/i,Xi=/^border-(collapse|spacing|radius|image|block|inline|start|end)/i,Yi=/^border(?:-(top|right|bottom|left))?(?:-(width|style|color))?$/,Gi=/^(inherit|initial|unset|revert|revert-layer)$/i;function ge(d){const t=[];let e=0,i="";for(const s of d)s==="("?e++:s===")"&&e--,e===0&&/\s/.test(s)?(i&&t.push(i),i=""):i+=s;return i&&t.push(i),t}function Ki(d){const[t,e=t,i=t,s=e]=d;return[t,e,i,s]}function Qi(d){const t={width:"medium",style:"none",color:""};return ge(d).forEach(e=>{Ui.test(e)?t.style=e.toLowerCase():Vi.test(e)?t.width=e:t.color=e}),t}function Ji(d){return!d||/^currentcolor$/i.test(d)?"":/^windowtext$/i.test(d)?"#000000":d}function ts(d){if(d.width===null&&d.style===null&&d.color===null)return"";const t=d.style??"solid";return t==="none"||t==="hidden"||d.width&&zi.test(d.width)?"none":[d.width&&d.width!=="medium"?d.width:"",t,Ji(d.color||"")].filter(Boolean).join(" ")}function es(d){d.querySelectorAll("table,td,th").forEach(t=>{const e=t.getAttribute("style")||"";if(!/border/i.test(e))return;const i={top:{width:null,style:null,color:null},right:{width:null,style:null,color:null},bottom:{width:null,style:null,color:null},left:{width:null,style:null,color:null}},s=[];let n=!1,l=!1;if(e.split(";").forEach(a=>{const u=a.indexOf(":");if(u<1){a.trim()&&s.push(a.trim());return}const p=a.slice(0,u).trim().toLowerCase(),m=a.slice(u+1).trim(),v=Yi.exec(p);if(!v||Xi.test(p)){s.push(p+":"+m);return}if(Gi.test(m)){l=!0;return}n=!0;const b=v[1],f=v[2];if(f)if(b)i[b][f]=m;else{const y=Ki(ge(m));ct.forEach((C,E)=>{i[C][f]=y[E]})}else{const y=Qi(m);(b?[b]:ct.slice()).forEach(C=>{i[C]={...y}})}}),l||!n)return;const r=ct.map(a=>ts(i[a])),o=s.slice();r.every(a=>a&&a===r[0])?o.push("border:"+r[0]):ct.forEach((a,u)=>r[u]&&o.push(`border-${a}:`+r[u])),t.setAttribute("style",o.join(";"))})}function ve(d){let t="";return d.childNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE)t+=e.nodeValue||"";else if(e.nodeType===Node.ELEMENT_NODE){const i=e,s=(i.getAttribute("dir")||"").toLowerCase();if(s==="rtl"||s==="ltr")return;t+=ve(i)}}),t}var W;let is=(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.subStack=[],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.vidActive=null,this.vidCtx=null,this.vidHideTimer=null,this.vphActive=null,this.vphCtx=null,this.vphUploadTarget=null,this.selCtx=null,this.tbrMore=null,this.tbrExpanded=!1,this.codeActive=null,this.codeCtx=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??ti,imageFileTypes:t.imageFileTypes??["image/jpeg","image/jpg","image/png","image/gif","image/bmp","image/webp"],videoFileTypes:t.videoFileTypes??["video/mp4","video/webm","video/ogg"]},this.imageUploadHandler=t.imageUploadHandler,this.onImageUploadError=t.onImageUploadError,this.videoUploadHandler=t.videoUploadHandler,this.onVideoUploadError=t.onVideoUploadError,this.contentStyle=t.contentStyle,this.applyTheme(t),this.lang=this.options.language,this.draftStorageKey="tmclone-draft:"+this.options.draftKey,this.initDOM(),this.bindEvents(),this.initUI(),this.recordRevision(),this.stampExistingImages(),this.options.onReady(this)}t(t){const e=Ct(this.lang)[t];return typeof e=="string"?e:e.join(",")}tArr(t){return Ct(this.lang)[t]}dir(){return Ct(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} />`,xt,z,Ve,z),Gt[z+xt]=!0}}return c===i?_e(P):Ze(P),P}}function $e(c,g,x){return Kt(c,g,x,!0)}function je(c,g,x){return Kt(c,g,x,!1)}var We=je,Ue=$e;tt.Fragment=i,tt.jsx=We,tt.jsxs=Ue}()),tt}process.env.NODE_ENV==="production"?St.exports=Xe():St.exports=Ye();var Ge=St.exports;const Ke={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",moverowup:"Move row up",moverowdown:"Move row down",colbefore:"Insert column before",colafter:"Insert column after",delcol:"Delete column",movecolleft:"Move column left",movecolright:"Move column right",cellbg:"Cell background",deltable:"Delete table",ltr:"Left to right",rtl:"Right to left",alignleft:"Align left",aligncenter:"Align center",alignright:"Align right",alignjustify:"Justify",align:"Align",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",tblalignleft:"Align table left",tblaligncenter:"Center table",tblalignright:"Align table right",alignnone:"None",quote:"Blockquote",link:"Link…",linkttl:"Insert/edit link",linkurl:"URL",unlink:"Remove link",lineheight:"Line height",wordspacing:"Word spacing",letterspacing:"Letter 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",video:"Video",quickvideo:"Insert video",deletevideo:"Delete video",uploadvideo:"Upload from computer",videolink:"Insert from URL",videourlph:"Paste video URL…",insertvideo:"Insert",dropvideo:"Drop video here",videodlgttl:"Insert/edit video",vidgeneral:"General",vidembed:"Embed",vidadvanced:"Advanced",vidsource:"Source",vidembedhint:"Paste your embed code below:",vidaltsource:"Alternative source URL",vidposter:"Media poster (Image URL)",emoji:"Emojis…",code:"Inline code",codesample:"Code sample…",codedlgttl:"Insert/edit code sample",codelang:"Language",editcode:"Edit code sample",deletecode:"Delete code sample",copycode:"Copy code",chcat_currency:"Currency",chcat_text:"Text & punctuation",chcat_math:"Mathematical",chcat_arrows:"Arrows",chcat_symbols:"Symbols",chcat_latin:"Extended Latin",chcat_arabic:"Arabic",emcat_smileys:"Smileys & emotion",emcat_people:"People & body",emcat_animals:"Animals & nature",emcat_food:"Food & drink",emcat_travel:"Travel & places",emcat_activities:"Activities",emcat_objects:"Objects",emcat_symbols:"Symbols",emcat_flags:"Flags"},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:"حذف الصف",moverowup:"نقل الصف لأعلى",moverowdown:"نقل الصف لأسفل",colbefore:"إدراج عمود قبل",colafter:"إدراج عمود بعد",delcol:"حذف العمود",movecolleft:"نقل العمود لليسار",movecolright:"نقل العمود لليمين",cellbg:"خلفية الخلية",deltable:"حذف الجدول",ltr:"من اليسار إلى اليمين",rtl:"من اليمين إلى اليسار",alignleft:"محاذاة لليسار",aligncenter:"توسيط",alignright:"محاذاة لليمين",alignjustify:"ضبط",align:"محاذاة",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:"المحاذاة",tblalignleft:"محاذاة الجدول لليسار",tblaligncenter:"توسيط الجدول",tblalignright:"محاذاة الجدول لليمين",alignnone:"بدون",quote:"اقتباس",link:"رابط…",linkttl:"إدراج/تعديل رابط",linkurl:"الرابط",unlink:"إزالة الرابط",lineheight:"تباعد الأسطر",wordspacing:"تباعد الكلمات",letterspacing:"تباعد الأحرف",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:"حذف القالب",video:"فيديو",quickvideo:"إدراج فيديو",deletevideo:"حذف الفيديو",uploadvideo:"رفع من الجهاز",videolink:"إدراج من رابط",videourlph:"الصق رابط الفيديو…",insertvideo:"إدراج",dropvideo:"أسقط الفيديو هنا",videodlgttl:"إدراج/تعديل فيديو",vidgeneral:"عام",vidembed:"تضمين",vidadvanced:"متقدم",vidsource:"المصدر",vidembedhint:"الصق كود التضمين أدناه:",vidaltsource:"رابط مصدر بديل",vidposter:"صورة الغلاف (رابط الصورة)",emoji:"رموز تعبيرية…",code:"كود مضمّن",codesample:"عينة كود…",codedlgttl:"إدراج/تعديل عينة كود",codelang:"اللغة",editcode:"تعديل عينة الكود",deletecode:"حذف عينة الكود",copycode:"نسخ الكود",chcat_currency:"عملات",chcat_text:"نص وعلامات ترقيم",chcat_math:"رموز رياضية",chcat_arrows:"أسهم",chcat_symbols:"رموز",chcat_latin:"لاتينية موسعة",chcat_arabic:"عربية",emcat_smileys:"وجوه ومشاعر",emcat_people:"أشخاص وإيماءات",emcat_animals:"حيوانات وطبيعة",emcat_food:"طعام وشراب",emcat_travel:"سفر وأماكن",emcat_activities:"أنشطة",emcat_objects:"أشياء",emcat_symbols:"رموز",emcat_flags:"أعلام"}};function Ct(u){return Ke[u]}const Qe="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 code changecase lineheight wordspacing letterspacing | removeformat | blocks | ltr rtl | quickimage quickvideo quicktable codesample template charmap emoji | fullscreen sourcecode",Je="file edit view insert format tools table help",ti=[["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"]],ei=["8px","9px","10px","11px","12px","14px","16px","18px","20px","24px","28px","32px","36px","48px","72px","96px"],ii=1,si=100,te=["1","1.15","1.4","1.5","1.75","2","2.5","3"],ee=["1px","2px","4px","6px","8px","12px"],ie=["0.5px","1px","1.5px","2px","3px","4px"],se=[["plain","Plain text"],["html","HTML/XML"],["css","CSS"],["javascript","JavaScript"],["typescript","TypeScript"],["json","JSON"],["python","Python"],["java","Java"],["csharp","C#"],["cpp","C/C++"],["php","PHP"],["ruby","Ruby"],["go","Go"],["rust","Rust"],["sql","SQL"],["bash","Bash/Shell"]],ne=[["p","para"],["h1","heading1"],["h2","heading2"],["h3","heading3"],["h4","heading4"],["h5","heading5"],["h6","heading6"],["pre","pre"]],ni=["#F76707","#4263EB","#CC5DE8"],ri=["#FFFFFF","#F4F4F4","#E8EAED","#DADCE0","#000000","#F28B82","#FBBC04","#FFF475","#CCFF90","#A7FFEB","#CBF0F8","#AECBFA","#D7AEFB","#FDCFE8","#E6C9A8","#EA4335","#FB8C00","#FDD835","#34A853","#00ACC1","#4285F4","#5E35B1","#8E24AA","#C2185B","#6D4C41"],li=[{key:"chcat_currency",chars:["€","£","¥","¢","$","₹","₽","₩","₺","₴","₦","฿","₫","₪","﷼","¤","₡","₱","₲","₵","₭","₮","₸","₼","₾","₿"]},{key:"chcat_text",chars:["§","¶","†","‡","•","…","′","″","‰","‱","–","—","―","¡","¿","·","‹","›","«","»","“","”","‘","’","„","‚","¦","ª","º","‽","※","❝","❞","❮","❯"]},{key:"chcat_math",chars:["°","±","×","÷","≈","≠","≤","≥","∞","µ","√","∑","∫","∂","∆","∏","π","Ω","α","β","γ","δ","ε","θ","λ","σ","φ","ψ","ω","∈","∉","∪","∩","⊂","⊃","⊆","⊇","∀","∃","∅","∝","∴","∵","¬","∧","∨","½","⅓","¼","¾","⅔","⅛","⅜","⅝","⅞","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","⁰","₁","₂","₃","₄","₅","₆","₇","₈","₉","₀"]},{key:"chcat_arrows",chars:["←","→","↑","↓","↔","↕","⇐","⇒","⇑","⇓","⇔","↖","↗","↘","↙","↩","↪","↺","↻","⤴","⤵","➜","➝","➞","➟","⇦","⇨","⇧","⇩"]},{key:"chcat_symbols",chars:["©","®","™","℠","№","℮","✓","✔","✗","✘","★","☆","✦","✪","♠","♣","♥","♦","♪","♫","♬","☀","☁","☂","☃","☾","☹","☺","☻","✉","✂","✎","✏","☎","☏","⌛","⌚","☞","☜","☝","☟"]},{key:"chcat_latin",chars:["À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ø","ù","ú","û","ü","ý","þ","ÿ","Œ","œ","Š","š","Ž","ž","Ł","ł"]},{key:"chcat_arabic",chars:["؟","،","؛","٪","٭","ـ","٠","١","٢","٣","٤","٥","٦","٧","٨","٩","﴾","﴿","۞","؎","ء","آ","أ","ؤ","إ","ئ","ى","ة"]}],oi=[{key:"emcat_smileys",chars:["😀","😃","😄","😁","😆","😅","😂","🤣","😊","😇","🙂","🙃","😉","😌","😍","🥰","😘","😋","😛","😜","🤪","🤨","🧐","🤓","😎","🥳","😏","😒","😞","😔","😟","😕","🙁","😣","😫","😩","🥺","😢","😭","😤","😠","😡","🤯","😳","🥵","🥶","😱","😨","😥","🤗","🤔","🤭","🤫","😐","😑","😬","🙄","😯","😴","😪","😷","🤒","🤕","🤢","🤧","😈","💀","👻","👽","🤖","💩","😺","😸","😹","😻","🙀"]},{key:"emcat_people",chars:["👋","🤚","✋","🖖","👌","🤏","✌","🤞","🤟","🤘","🤙","👈","👉","👆","👇","☝","👍","👎","✊","👊","👏","🙌","👐","🤲","🤝","🙏","💪","✍","💅","🤳","👂","👃","👀","👁","🧠","👶","🧒","👦","👧","🧑","👨","👩","🧓","👴","👵","👮","👷","💂","🕵","👸","🤴","👰","🤵","🤰","👼","🎅","🦸","🦹","🧙","🧚","🧛","🧟","💃","🕺","🚶","🏃","🧘"]},{key:"emcat_animals",chars:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🐔","🐧","🐦","🐤","🦆","🦅","🦉","🐺","🐗","🐴","🦄","🐝","🐛","🦋","🐌","🐞","🐢","🐍","🦎","🦖","🐙","🦑","🦀","🐠","🐟","🐬","🐳","🦈","🐊","🐅","🦓","🦍","🐘","🦏","🐪","🦒","🦘","🐄","🐎","🐖","🐑","🐐","🦌","🐕","🐈","🐓","🦃","🦚","🦜","🦢","🕊","🐇","🦔","🌵","🌲","🌴","🌱","🌿","☘","🍀","🍁","🌸","🌺","🌻","🌹","🌷","💐"]},{key:"emcat_food",chars:["🍏","🍎","🍐","🍊","🍋","🍌","🍉","🍇","🍓","🍈","🍒","🍑","🥭","🍍","🥥","🥝","🍅","🍆","🥑","🥦","🥒","🌶","🌽","🥕","🥔","🥐","🍞","🥖","🥨","🧀","🥚","🍳","🥞","🥓","🥩","🍗","🍖","🌭","🍔","🍟","🍕","🥪","🌮","🌯","🥗","🍝","🍜","🍲","🍛","🍣","🍱","🥟","🍤","🍚","🍧","🍨","🍦","🥧","🧁","🍰","🎂","🍮","🍭","🍬","🍫","🍿","🍩","🍪","🥜","🍯","🥛","☕","🍵","🥤","🍺","🥂","🍷","🍸","🍹"]},{key:"emcat_travel",chars:["🚗","🚕","🚙","🚌","🏎","🚓","🚑","🚒","🚚","🚜","🛵","🏍","🚲","🛴","🚔","🚃","🚄","🚅","🚂","🚆","🚇","🚉","✈","🛫","🛬","💺","🚁","🚀","🛸","🚢","⛵","🚤","⚓","⛽","🚧","🗺","🗿","🗽","🗼","🏰","🏯","🎡","🎢","🎠","⛲","🏖","🏝","🌋","⛰","🏔","🗻","🏕","⛺","🏠","🏡","🏢","🏬","🏥","🏦","🏨","🏪","🏫","💒","⛪","🕌","🕍","🕋","⛩","🌅","🌄","🌇","🌆","🌃","🌉","🌌","🌠"]},{key:"emcat_activities",chars:["⚽","🏀","🏈","⚾","🎾","🏐","🏉","🎱","🏓","🏸","🏒","🏑","🏏","⛳","🏹","🎣","🥊","🥋","⛸","🎿","⛷","🏂","🏋","🤸","⛹","🤺","🏇","🧗","🏄","🏊","🚣","🚵","🚴","🏆","🥇","🥈","🥉","🏅","🎖","🎫","🎪","🤹","🎭","🎨","🎬","🎤","🎧","🎼","🎹","🥁","🎷","🎺","🎸","🎻","🎲","🎯","🎳","🎮","🎰","🧩"]},{key:"emcat_objects",chars:["⌚","📱","💻","⌨","🖥","🖨","🖱","🕹","💽","💾","💿","📀","📷","📸","📹","🎥","📞","☎","📺","📻","🎙","⏱","⏰","⌛","⏳","📡","🔋","🔌","💡","🔦","🕯","💸","💵","💰","💳","💎","⚖","🔧","🔨","⚒","🛠","⛏","🔩","⚙","🧲","🔫","💣","🔪","🛡","🔮","🧿","🔭","🔬","💊","💉","🌡","🧬","🧪","🧹","🧺","🛁","🔑","🗝","🚪","🛋","🛏","🧸","🖼","🛍","🛒","🎁","🎈","🎀","🎊","🎉","✉","📩","📦","📜","📄","📊","📈","📉","📅","📋","📁","📰","📓","📚","📖","🔖","🔗","📎","📐","📏","📌","📍","✂","🖊","✒","🖌","🖍","📝","✏","🔍","🔒","🔓"]},{key:"emcat_symbols",chars:["❤","🧡","💛","💚","💙","💜","🖤","💔","❣","💕","💞","💓","💗","💖","💘","💝","☮","✝","☪","🕉","☸","✡","☯","♈","♉","♊","♋","♌","♍","♎","♏","♐","♑","♒","♓","⚛","❌","⭕","🛑","⛔","🚫","💯","💢","⚠","🚸","🔱","⚜","🔰","♻","✅","❇","✳","❎","🌐","💠","🌀","💤","🏧","♿","🚭","❗","❕","❓","❔","‼","⁉","💲","🔅","🔆","〽","ℹ","🆗","🆕","🆓","🆒","🆙","🈯","🈚"]},{key:"emcat_flags",chars:["🏁","🚩","🎌","🏴","🏳","🇦🇪","🇸🇦","🇶🇦","🇰🇼","🇧🇭","🇴🇲","🇪🇬","🇯🇴","🇱🇧","🇮🇳","🇵🇰","🇺🇸","🇬🇧","🇨🇦","🇦🇺","🇫🇷","🇩🇪","🇮🇹","🇪🇸","🇵🇹","🇳🇱","🇧🇪","🇨🇭","🇸🇪","🇳🇴","🇩🇰","🇫🇮","🇮🇪","🇬🇷","🇹🇷","🇷🇺","🇺🇦","🇵🇱","🇯🇵","🇰🇷","🇨🇳","🇸🇬","🇲🇾","🇮🇩","🇹🇭","🇵🇭","🇻🇳","🇧🇷","🇦🇷","🇲🇽","🇿🇦","🇳🇬","🇰🇪","🇲🇦"]}],L=(u,t)=>`<svg viewBox="${t||"0 0 24 24"}">${u}</svg>`,w=u=>L(`<path class="f" d="${u}"/>`,"0 -960 960 960"),lt=(u,t=7.5)=>L('<path d="M10 6h10M10 12h10M10 18h10"/>'+u.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:w("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:w("M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"),underline:w("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:w("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:w("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:w("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:w("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:w("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:w("M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"),aligncenter:w("M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"),alignright:w("M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"),alignjustify:w("M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"),fullscreen:w("M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z"),clearformatic:w("m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"),numlist:w("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:w("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:w("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:w("M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"),indent:w("M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"),more:L('<circle class="f" cx="5" cy="12" r="1.7"/><circle class="f" cx="12" cy="12" r="1.7"/><circle class="f" cx="19" cy="12" r="1.7"/>'),image:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("M200-160h560v-240H200v240Zm640 80H120v-720h160v80h-80v240h560v-240h-80v-80h160v720ZM480-480Zm0 80v-80 80Zm0 0Zm-40-240v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),rowafter:w("M200-560h560v-240H200v240Zm-80 400v-720h720v720H680v-80h80v-240H200v240h80v80H120Zm360-320Zm0-80v80-80Zm0 0ZM440-80v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),rowdelete:w("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:w("M800-200v-560H560v560h240Zm-640 80v-160h80v80h240v-560H240v80h-80v-160h720v720H160Zm320-360Zm80 0h-80 80Zm0 0ZM160-360v-80H80v-80h80v-80h80v80h80v80h-80v80h-80Z"),colafter:w("M160-760v560h240v-560H160ZM80-120v-720h720v160h-80v-80H480v560h240v-80h80v160H80Zm400-360Zm-80 0h80-80Zm0 0Zm320 120v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"),coldelete:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("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:w("m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm504 104v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z"),fontsizedown:w("m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm384-16v-80h320v80H600Z"),historyic:w("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:w("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:w("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:w("M80-160v-160h160v160H80Zm240 0v-160h560v160H320ZM80-400v-160h160v160H80Zm240 0v-160h560v160H320ZM80-640v-160h160v160H80Zm240 0v-160h560v160H320Z"),ol_alpha:lt(["a","b","c"]),ol_roman:lt(["i","ii","iii"],6.5),ol_alphau:lt(["A","B","C"]),ol_romanu:lt(["I","II","III"],6.5),video:L('<rect x="3" y="6" width="13" height="12" rx="1.5"/><path d="M16 10l5-3v10l-5-3z"/>'),editic:L('<path d="M4 20l1-4.5L15.5 5 19 8.5 8.5 19 4 20z"/><path d="M13.5 6.5l4 4"/>'),letterspacing:L('<text x="2.5" y="13" font-size="12" stroke="none" fill="#222f3e" font-family="Arial" font-weight="bold">A</text><text x="13" y="13" font-size="12" stroke="none" fill="#222f3e" font-family="Arial" font-weight="bold">B</text><path d="M7 18.5h10"/><path class="f" d="M7.5 18.5 4.5 16.6v3.8z"/><path class="f" d="M16.5 18.5l3-1.9v3.8z"/>'),emojiic:L('<circle cx="12" cy="12" r="8.5"/><path d="M8.6 14.3a4.6 4.6 0 0 0 6.8 0"/><path d="M9.2 9.6v.7M14.8 9.6v.7"/>'),inlinecodeic:L('<path d="M8.5 8 4.5 12l4 4M15.5 8l4 4-4 4"/><path d="M13 6l-2 12"/>'),moverowup:L('<rect x="4" y="15.5" width="16" height="5" rx="1"/><path d="M12 12.5V4M8.5 7.5 12 4l3.5 3.5"/>'),moverowdown:L('<rect x="4" y="3.5" width="16" height="5" rx="1"/><path d="M12 11.5V20M8.5 16.5 12 20l3.5-3.5"/>'),movecolleft:L('<rect x="15.5" y="4" width="5" height="16" rx="1"/><path d="M12.5 12H4M7.5 8.5 4 12l3.5 3.5"/>'),movecolright:L('<rect x="3.5" y="4" width="5" height="16" rx="1"/><path d="M11.5 12H20M16.5 8.5 20 12l-3.5 3.5"/>'),codesampleic:L('<rect x="3.5" y="4" width="17" height="16" rx="2"/><path d="M3.5 8.5h17"/><path d="M9.5 12 7 14.25l2.5 2.25M14.5 12l2.5 2.25-2.5 2.25"/>')},ai=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"]),ci=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"]),re={"*":["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 ut(u){const t={},e=u.getAttribute&&u.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 hi(u){return u.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 di(u){return/^[0-9]+[\.\)،]/.test(u)?{ordered:!0}:/^[٠-٩۰-۹]+/.test(u)?{ordered:!0,style:"arabic-indic"}:/^[ivxlc]{2,}[\.\)]/.test(u)?{ordered:!0,style:"lower-roman"}:/^[IVXLC]{2,}[\.\)]/.test(u)?{ordered:!0,style:"upper-roman"}:/^[a-z][\.\)]/.test(u)?{ordered:!0,style:"lower-alpha"}:/^[A-Z][\.\)]/.test(u)?{ordered:!0,style:"upper-alpha"}:/^[ء-ي][\.\)،-]/.test(u)?{ordered:!0,style:"arabic-indic"}:{ordered:!1}}function ui(u){const t=s=>{const n=(s.getAttribute("style")||"")+" "+(s.className||"");return/mso-list\s*:(?!\s*ignore)/i.test(n)||/MsoListParagraph/i.test(n)},e=[];let i=null;Array.from(u.body.querySelectorAll("p")).forEach(s=>{if(!t(s)){i=null;return}const n=s.previousElementSibling;i&&n&&i[i.length-1]===n?i.push(s):(i=[s],e.push(i))}),e.forEach(s=>{const n=[],r=s[0];s.forEach(o=>{var C,E,I;const a=+(((C=(o.getAttribute("style")||"").match(/level(\d+)/i))==null?void 0:C[1])||1),d=Array.from(o.querySelectorAll("span")).find(A=>/mso-list\s*:\s*ignore/i.test(A.getAttribute("style")||"")),p=d?((E=d.textContent)==null?void 0:E.trim())||"":(((I=o.textContent)==null?void 0:I.trim().match(/^\S{1,4}/))||[""])[0],{ordered:m,style:v}=di(p);for(d&&d.remove();n.length&&n[n.length-1].level>a;)n.pop();if(!n.length||n[n.length-1].level<a){const A=u.createElement(m?"ol":"ul");if(m&&v&&(A.style.listStyleType=v),n.length){const j=n[n.length-1].list;(j.lastElementChild||j).appendChild(A)}else r.parentNode.insertBefore(A,r);n.push({list:A,level:a})}const b=u.createElement("li"),f=ut(o),y=["text-align","direction","unicode-bidi","color","font-size","font-family","background-color"].filter(A=>f[A]).map(A=>A+":"+f[A]).join(";");for(y&&b.setAttribute("style",y),o.getAttribute("dir")&&b.setAttribute("dir",o.getAttribute("dir"));o.firstChild;)b.appendChild(o.firstChild);n[n.length-1].list.appendChild(b),o.remove()})})}function pi(u){u.querySelectorAll('b[id^="docs-internal-guid"]').forEach(t=>{for(;t.firstChild;)t.parentNode.insertBefore(t.firstChild,t);t.remove()})}function mi(u){u.querySelectorAll("table").forEach(t=>{const e=t;ut(e)["border-collapse"]||(e.style.borderCollapse="collapse")}),u.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 n=s;i==="center"?(n.style.marginLeft=n.style.marginLeft||"auto",n.style.marginRight=n.style.marginRight||"auto"):i==="right"?n.style.marginLeft=n.style.marginLeft||"auto":i==="left"&&(n.style.marginRight=n.style.marginRight||"auto")})),e.removeAttribute("align")}),u.querySelectorAll("center table").forEach(t=>{const e=t;e.style.marginLeft=e.style.marginLeft||"auto",e.style.marginRight=e.style.marginRight||"auto"}),u.querySelectorAll("[bgcolor]").forEach(t=>{const e=t;e.style.backgroundColor=e.style.backgroundColor||e.getAttribute("bgcolor"),e.removeAttribute("bgcolor")})}function ht(u,t){Array.from(u.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(!ai.has(s)){if(s==="font"){const l=t.createElement("span");i.getAttribute("style")&&l.setAttribute("style",i.getAttribute("style")),i.getAttribute("color")&&(l.style.color=i.getAttribute("color")),i.getAttribute("face")&&(l.style.fontFamily=i.getAttribute("face"));const a=i.getAttribute("size");if(a&&!l.style.fontSize){const d={1:"8pt",2:"10pt",3:"12pt",4:"14pt",5:"18pt",6:"24pt",7:"36pt"};d[a]&&(l.style.fontSize=d[a])}for(;i.firstChild;)l.appendChild(i.firstChild);i.replaceWith(l),ht(l,t);return}for(ht(i,t);i.firstChild;)i.parentNode.insertBefore(i.firstChild,i);i.remove();return}const n=new Set([...re["*"]||[],...re[s]||[]]);if(Array.from(i.attributes).forEach(l=>{const a=l.name.toLowerCase();a!=="style"&&!n.has(a)&&i.removeAttribute(l.name)}),s==="a"){const l=i.getAttribute("href")||"";/^(https?:|mailto:|tel:|#)/i.test(l)||i.removeAttribute("href")}if(s==="img"){const l=i.getAttribute("src")||"";if(!/^(https?:|data:image\/|blob:)/i.test(l)){const a=t.createElement("span");a.textContent="[local image — paste it separately]",a.setAttribute("style","color:#a33;font-style:italic;font-size:12px"),i.replaceWith(a);return}}const r=ut(i),o=[];for(const[l,a]of Object.entries(r))ci.has(l)&&(/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(a)||l==="font-weight"&&/^(400|normal)$/i.test(a)||l==="font-style"&&/^normal$/i.test(a)||l==="text-decoration"&&/^none$/i.test(a)||o.push(l+":"+a));if(o.length?i.setAttribute("style",o.join(";")):i.removeAttribute("style"),i.removeAttribute("class"),ht(i,t),s==="span"&&!i.attributes.length){for(;i.firstChild;)i.parentNode.insertBefore(i.firstChild,i);i.remove()}})}function fi(u){const t=[],e=/<style[^>]*>([\s\S]*?)<\/style>/gi;let i;for(;i=e.exec(u);){let s=i[1].replace(/<!--|-->/g,"").replace(/\/\*[\s\S]*?\*\//g,"");s=s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi,""),s=s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g,"");let n;const r=/([^{}]+)\{([^}]*)\}/g;for(;n=r.exec(s);){const o=n[2].split(";").map(l=>{const a=l.indexOf(":");return a<1?null:[l.slice(0,a).trim().toLowerCase(),l.slice(a+1).trim()]}).filter(l=>!!l&&!!l[1]);o.length&&n[1].split(",").map(l=>l.trim()).filter(l=>l&&!l.startsWith("@")).forEach(l=>t.push({sel:l,decls:o}))}}return t}function gi(u,t){if(!t.length)return;const e=new Map;t.forEach(({sel:i,decls:s})=>{let n;try{n=u.querySelectorAll(i)}catch{return}n.forEach(r=>{let o=e.get(r);o||(o={},e.set(r,o)),s.forEach(([l,a])=>{o[l]=a})})}),e.forEach((i,s)=>{const n=ut(s),r=s.hasAttribute("dir"),o=s.hasAttribute("align"),l=Object.entries(i).filter(([p])=>!(p in n||(p==="direction"||p==="unicode-bidi")&&r||p==="text-align"&&(o||r)||(p==="background"||p==="background-color")&&s.hasAttribute("bgcolor")));if(!l.length)return;const a=l.map(([p,m])=>p+":"+m).join(";"),d=s.getAttribute("style");s.setAttribute("style",d?a+";"+d:a)})}function pe(u){return u.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g,t=>t.normalize("NFKC"))}function vi(u){const t=u.createTreeWalker(u.body,NodeFilter.SHOW_TEXT,null);let e;for(;e=t.nextNode();)/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue||"")&&(e.nodeValue=pe(e.nodeValue||""))}function bi(u,t="ltr"){const e=fi(u),i=new DOMParser().parseFromString(hi(u),"text/html");gi(i,e),/class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML)&&ui(i),pi(i),mi(i),ht(i.body,i),vi(i);const s=n=>{var r;return n&&n.tagName==="P"&&!((r=n.textContent)!=null&&r.trim())&&!n.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 yi(u){const t=pe(u).replace(/\r/g,""),e=i=>i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return/\n/.test(t)?t.split(/\n{2,}/).map(i=>`<p dir="auto">${e(i).replace(/\n/g,"<br>")||"<br>"}</p>`).join(""):e(t)}const xi=10*1024*1024,me=/^(https?:|data:image\/|blob:)/i;function le(u,t){const e=[],i="{\\"+t;let s=0;for(;(s=u.indexOf(i,s))!==-1;){const n=u[s+i.length];if(n&&/[a-z0-9]/i.test(n)){s+=i.length;continue}let r=0,o=s;for(;o<u.length;o++){const l=u[o];if(l==="\\"){o++;continue}if(l==="{")r++;else if(l==="}"&&(r--,!r))break}e.push({start:s,end:o+1,body:u.slice(s+i.length,o)}),s=o+1}return e}function Ci(u){const t=new Uint8Array(u.length/2);for(let e=0;e<t.length;e++)t[e]=parseInt(u.substr(e*2,2),16);return t}function wt(u){let t="";for(let e=0;e<u.length;e++)t+=String.fromCharCode(u[e]);return btoa(t)}function oe(u,t){t:for(let e=0;e+t.length<=u.length;e++){for(let i=0;i<t.length;i++)if(u[e+i]!==t[i])continue t;return e}return-1}const wi=[137,80,78,71],Ti=[255,216,255];function Ei(u){let t=null;if(/\\pngblip/.test(u)?t="image/png":/\\jpegblip/.test(u)?t="image/jpeg":(/\\wmetafile\d*/.test(u)||/\\emfblip/.test(u))&&(t="metafile"),!t)return null;let e=u.replace(/\{[^{}]*\}/g," ").replace(/\\[a-z]+-?\d*\s?/gi," ").replace(/[^0-9a-fA-F]/g,"");if(e.length%2&&(e=e.slice(0,-1)),!e)return null;const i=Ci(e);if(t==="metafile"){const s=oe(i,wi);if(s>=0)return"data:image/png;base64,"+wt(i.slice(s));const n=oe(i,Ti);return n>=0?"data:image/jpeg;base64,"+wt(i.slice(n)):null}return"data:"+t+";base64,"+wt(i)}function Si(u){if(!u||u.indexOf("\\pict")===-1)return[];let t=u;le(u,"nonshppict").reverse().forEach(i=>{t=t.slice(0,i.start)+t.slice(i.end)});let e=xi;return le(t,"pict").map(i=>{if(e<=0)return null;const s=Ei(i.body);return s&&(e-=s.length*.75),s})}function ae(u){const t=u.match(/^\s*(-?[\d.]+)\s*(pt|px|in|cm|mm)?\s*$/i);if(!t)return null;const e=parseFloat(t[1]);if(!isFinite(e)||e<=0)return null;const i=(t[2]||"px").toLowerCase(),s=i==="pt"?e*4/3:i==="in"?e*96:i==="cm"?e*96/2.54:i==="mm"?e*96/25.4:e;return Math.round(s)}function Mi(u,t){const e=u.match(new RegExp("\\s"+t+`\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));return e?e[1]??e[2]??e[3]??"":""}function Li(u){if(!/<v:imagedata\b/i.test(u))return u;const t=(i,s)=>{const n=Mi(i,"src");if(!n)return null;const r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`<img\\b[^>]*\\bsrc\\s*=\\s*["']?`+r,"i").test(u))return null;const o=(s.match(/<v:shape\b[^>]*\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/i)||[]).slice(1).find(Boolean)||"",l=ae((o.match(/(?:^|;)\s*width\s*:\s*([^;]+)/i)||[])[1]||""),a=ae((o.match(/(?:^|;)\s*height\s*:\s*([^;]+)/i)||[])[1]||"");return'<img src="'+n.replace(/"/g,""")+'"'+(l?' width="'+l+'"':"")+(a?' height="'+a+'"':"")+">"};let e=u.replace(/<!--\[if [^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi,(i,s)=>{const n=s.match(/<v:imagedata\b[^>]*>/i);return n&&t(n[0],s)||i});return e=e.replace(/<v:shape\b[^>]*>[\s\S]*?<\/v:shape\s*>/gi,i=>{const s=i.match(/<v:imagedata\b[^>]*>/i);return s&&t(s[0],i)||i}),e.replace(/<v:imagedata\b[^>]*>/gi,i=>t(i,"")||i)}function fe(u,t){if(!u||!t.length)return{html:u,injected:[]};const e=[];let i=0;return{html:Li(u).replace(/<img\b[^>]*>/gi,n=>{const r=(n.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i)||[])[1]||"";if(me.test(r))return n;const o=t[i++];return o?(e.push(o),/\ssrc\s*=\s*["']/i.test(n)?n.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i,'$1"'+o+'"'):n.replace(/(\ssrc\s*=\s*)[^\s>]+/i,'$1"'+o+'"')):n}),injected:e}}function ki(u,t){return!u||!t?{html:u,injected:[]}:fe(u,Si(t))}function Ai(u){const t=u.match(/<img\b[^>]*>/gi);return t?t.filter(e=>{const i=(e.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i)||[])[1]||"";return!me.test(i)}).length:0}function Hi(u,t){const e=u.match(/^data:([^;,]+);base64,(.*)$/);if(!e)return null;const i=(e[1].split("/")[1]||"png").replace(/[^a-z0-9]/gi,"")||"png";try{const s=atob(e[2]),n=new Uint8Array(s.length);for(let r=0;r<s.length;r++)n[r]=s.charCodeAt(r);return new File([n],t+"."+(i==="jpeg"?"jpg":i),{type:e[1]})}catch{return null}}function Ii(u){const t=new DataView(u),e=new Map;let i=-1;for(let o=u.byteLength-22;o>=Math.max(0,u.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 n=t.getUint32(i+16,!0);const r=new TextDecoder;for(let o=0;o<s&&t.getUint32(n,!0)===33639248;o++){const l=t.getUint16(n+10,!0),a=t.getUint32(n+20,!0),d=t.getUint16(n+28,!0),p=t.getUint16(n+30,!0),m=t.getUint16(n+32,!0),v=t.getUint32(n+42,!0),b=r.decode(new Uint8Array(u,n+46,d));e.set(b,{name:b,method:l,compSize:a,localOffset:v}),n+=46+d+p+m}return e}async function ce(u,t){const e=new DataView(u,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),n=t.localOffset+30+i+s,r=new Uint8Array(u.slice(n,n+t.compSize));if(t.method===0)return r;if(t.method!==8)throw new Error("Unsupported compression method "+t.method);const o=new Blob([r]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(o).arrayBuffer())}const he=u=>u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),dt=(u,t)=>Array.from(u.children).filter(e=>e.localName===t),B=(u,...t)=>{let e=u;for(const i of t){if(!e)return null;e=Array.from(e.children).find(s=>s.localName===i)||null}return e},q=(u,t="val")=>{if(!u)return"";for(const e of Array.from(u.attributes))if(e.localName===t)return e.value;return""},ot=(u,t)=>{const e=u?B(u,t):null;if(!e)return!1;const i=q(e);return i!=="false"&&i!=="0"},de={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"},qi={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",webp:"image/webp"};function Ri(u){let t="";for(let e=0;e<u.length;e+=32768)t+=String.fromCharCode(...u.subarray(e,e+32768));return btoa(t)}class Pi{constructor(t,e,i){this.rels=t,this.images=e,this.numFmt=i}convertBody(t){let e="",i=[];const s=n=>{for(;i.length>n;)e+=`</${i.pop()}>`};for(const n of Array.from(t.children))if(n.localName==="p"){const r=this.paraList(n);if(r){const o=r.ilvl+1;for(;i.length>o;)e+=`</${i.pop()}>`;for(i.length===o&&i[o-1]!==r.type&&(e+=`</${i.pop()}>`);i.length<o;)e+=`<${r.type}>`,i.push(r.type);e+=`<li>${this.runsOf(n)||"<br>"}</li>`;continue}s(0),e+=this.convertPara(n)}else n.localName==="tbl"?(s(0),e+=this.convertTable(n)):n.localName;return s(0),e||"<p><br></p>"}paraList(t){const e=B(t,"pPr","numPr");if(!e)return null;const i=q(B(e,"numId"));if(!i||i==="0")return null;const s=parseInt(q(B(e,"ilvl"))||"0",10)||0;return{type:this.numFmt.get(i)||"ul",ilvl:Math.min(s,8)}}convertPara(t){const e=B(t,"pPr"),i=q(B(t,"pPr","pStyle"));let s="p";const n=/^Heading([1-6])$/i.exec(i);n?s="h"+n[1]:/^Title$/i.test(i)&&(s="h1");const r=[],o=q(B(t,"pPr","jc"));o==="center"?r.push("text-align:center"):o==="right"||o==="end"?r.push("text-align:right"):(o==="both"||o==="distribute")&&r.push("text-align:justify"),e&&B(e,"bidi")&&r.push("direction:rtl");const l=this.runsOf(t),a=r.length?` style="${r.join(";")}"`:"";return`<${s}${a}>${l||"<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(q(i,"id"))||"";const n=q(i,"anchor");!s&&n&&(s="#"+n);const r=this.runsOf(i);e+=s?`<a href="${he(s)}">${r}</a>`:r}else(i.localName==="smartTag"||i.localName==="ins")&&(e+=this.runsOf(i));return e}convertRun(t){const e=B(t,"rPr");let i="";for(const p of Array.from(t.children))p.localName==="t"?i+=he(p.textContent||""):p.localName==="br"||p.localName==="cr"?i+="<br>":p.localName==="tab"?i+=" ":(p.localName==="drawing"||p.localName==="pict"||p.localName==="object")&&(i+=this.convertImage(p));if(!i)return"";const s=[],n=q(e?B(e,"color"):null);n&&n!=="auto"&&s.push("color:#"+n);const r=q(e?B(e,"highlight"):null);r&&de[r]&&s.push("background-color:"+de[r]);const o=parseFloat(q(e?B(e,"sz"):null));o&&s.push("font-size:"+Math.round(o/2*(4/3))+"px");const l=e?B(e,"rFonts"):null,a=q(l,"ascii")||q(l,"cs");a&&s.push(`font-family:'${a}'`),s.length&&(i=`<span style="${s.join(";")}">${i}</span>`),ot(e,"b")&&(i=`<strong>${i}</strong>`),ot(e,"i")&&(i=`<em>${i}</em>`),ot(e,"u")&&q(B(e,"u"))!=="none"&&(i=`<u>${i}</u>`),ot(e,"strike")&&(i=`<s>${i}</s>`);const d=q(e?B(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||q(o,"embed")||q(o,"link")),o.localName==="imagedata"&&(e=e||q(o,"id")),o.localName==="extent"){const l=parseFloat(o.getAttribute("cx")||"0");l&&(i=Math.round(l/9525))}for(const l of Array.from(o.children))s(l)};if(s(t),!e)return"";const n=this.images.get(e);if(!n)return"";const r=i?` width="${i}"`:"";return`<img src="${n}" alt=""${r}>`}convertTable(t){let e='<table style="border-collapse:collapse;width:100%"><tbody>';for(const i of dt(t,"tr")){e+="<tr>";for(const s of dt(i,"tc")){const n=parseInt(q(B(s,"tcPr","gridSpan"))||"1",10)||1,r=n>1?` colspan="${n}"`:"";let o="";for(const l of Array.from(s.children))l.localName==="p"?o+=this.convertPara(l):l.localName==="tbl"&&(o+=this.convertTable(l));e+=`<td style="border:1px solid #b9c2cc"${r}>${o||"<br>"}</td>`}e+="</tr>"}return e+"</tbody></table>"}}async function Bi(u){const t=u instanceof ArrayBuffer?u:await u.arrayBuffer(),e=Ii(t),i=new TextDecoder,s=async b=>{const f=e.get(b);return f?new DOMParser().parseFromString(i.decode(await ce(t,f)),"application/xml"):null},n=await s("word/document.xml"),r=n==null?void 0:n.getElementsByTagName("*");let o=null;if(r){for(const b of Array.from(r))if(b.localName==="body"){o=b;break}}if(!o)throw new Error("word/document.xml missing or invalid");const l=new Map,a=new Map,d=await s("word/_rels/document.xml.rels");if(d)for(const b of Array.from(d.getElementsByTagName("*"))){if(b.localName!=="Relationship")continue;const f=b.getAttribute("Id")||"",y=b.getAttribute("Target")||"",C=b.getAttribute("Type")||"";/hyperlink/i.test(C)?l.set(f,y):/image/i.test(C)&&a.set(f,y)}const p=new Map;for(const[b,f]of a){const y=f.startsWith("/")?f.slice(1):"word/"+f.replace(/^\.\//,""),C=e.get(y);if(!C)continue;const E=(y.split(".").pop()||"").toLowerCase(),I=qi[E];if(I)try{p.set(b,`data:${I};base64,${Ri(await ce(t,C))}`)}catch{}}const m=new Map,v=await s("word/numbering.xml");if(v){const b=new Map,f=Array.from(v.getElementsByTagName("*"));for(const y of f){if(y.localName!=="abstractNum")continue;const C=q(y,"abstractNumId"),E=dt(y,"lvl").find(A=>q(A,"ilvl")==="0")||dt(y,"lvl")[0],I=E?q(B(E,"numFmt")):"";b.set(C,I==="bullet"?"ul":"ol")}for(const y of f){if(y.localName!=="num")continue;const C=q(y,"numId"),E=q(B(y,"abstractNumId"));m.set(C,b.get(E)||"ul")}}return new Pi(l,p,m).convertBody(o)}const Di=["nw","ne","sw","se"],Tt=["img-left","img-right","img-top","img-center"],Et={"img-left":"tplimgleft","img-right":"tplimgright","img-top":"tplimgtop","img-center":"tplimgcenter"},Ni={"img-left":h.tplleft,"img-right":h.tplright,"img-top":h.tpltop,"img-center":h.tplcenter},Oi=".tox,.pop,.tblctx,.imgctx,.selctx,.dlg";let F=null,X=null,Mt=0,ue=!1;function at(){clearTimeout(Mt),X=null,F&&F.classList.remove("show")}function Fi(u){const t=u.dataset.tip;if(!t)return;X=u,clearTimeout(Mt);const e=F&&F.classList.contains("show")?60:350;Mt=window.setTimeout(()=>{if(X!==u||!document.contains(u))return;F||(F=document.createElement("div"),F.className="etip",document.body.appendChild(F)),F.textContent=t,F.classList.add("show");const i=u.getBoundingClientRect(),s=F.offsetWidth,n=F.offsetHeight;let r=i.left+i.width/2-s/2;r=Math.max(6,Math.min(r,innerWidth-s-6));let o=i.bottom+7;o+n>innerHeight-6&&(o=i.top-n-7),F.style.left=r+"px",F.style.top=o+"px"},e)}function Zi(){ue||(ue=!0,document.addEventListener("mouseover",u=>{const t=u.target,e=t.closest?t.closest("[title],[data-tip]"):null;if(!e||!e.closest(Oi)||e.closest(".earea")){e!==X&&at();return}const i=e.getAttribute("title");i&&(e.dataset.tip=i,e.removeAttribute("title"),e.getAttribute("aria-label")||e.setAttribute("aria-label",i)),e!==X&&Fi(e)}),document.addEventListener("mouseout",u=>{X&&!X.contains(u.relatedTarget)&&at()}),document.addEventListener("mousedown",at,!0),addEventListener("scroll",at,!0))}const _i=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u0780-\u07BF\u08A0-\u08FF\uFB1D-\uFB4F\uFB50-\uFDFF\uFE70-\uFEFF]/,$i=new RegExp("\\p{L}","u"),ji="p,div,li,td,th,blockquote,h1,h2,h3,h4,h5,h6,pre,figcaption";function Wi(u){for(const t of u){if(_i.test(t))return"rtl";if($i.test(t))return"ltr"}return null}const ct=["top","right","bottom","left"],Ui=/^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/i,Vi=/^(thin|medium|thick|[+-]?(\d+\.?\d*|\.\d+)(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?)$/i,zi=/^[+-]?0*(\.0*)?(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?$/i,Xi=/^border-(collapse|spacing|radius|image|block|inline|start|end)/i,Yi=/^border(?:-(top|right|bottom|left))?(?:-(width|style|color))?$/,Gi=/^(inherit|initial|unset|revert|revert-layer)$/i;function ge(u){const t=[];let e=0,i="";for(const s of u)s==="("?e++:s===")"&&e--,e===0&&/\s/.test(s)?(i&&t.push(i),i=""):i+=s;return i&&t.push(i),t}function Ki(u){const[t,e=t,i=t,s=e]=u;return[t,e,i,s]}function Qi(u){const t={width:"medium",style:"none",color:""};return ge(u).forEach(e=>{Ui.test(e)?t.style=e.toLowerCase():Vi.test(e)?t.width=e:t.color=e}),t}function Ji(u){return!u||/^currentcolor$/i.test(u)?"":/^windowtext$/i.test(u)?"#000000":u}function ts(u){if(u.width===null&&u.style===null&&u.color===null)return"";const t=u.style??"solid";return t==="none"||t==="hidden"||u.width&&zi.test(u.width)?"none":[u.width&&u.width!=="medium"?u.width:"",t,Ji(u.color||"")].filter(Boolean).join(" ")}function es(u){u.querySelectorAll("table,td,th").forEach(t=>{const e=t.getAttribute("style")||"";if(!/border/i.test(e))return;const i={top:{width:null,style:null,color:null},right:{width:null,style:null,color:null},bottom:{width:null,style:null,color:null},left:{width:null,style:null,color:null}},s=[];let n=!1,r=!1;if(e.split(";").forEach(a=>{const d=a.indexOf(":");if(d<1){a.trim()&&s.push(a.trim());return}const p=a.slice(0,d).trim().toLowerCase(),m=a.slice(d+1).trim(),v=Yi.exec(p);if(!v||Xi.test(p)){s.push(p+":"+m);return}if(Gi.test(m)){r=!0;return}n=!0;const b=v[1],f=v[2];if(f)if(b)i[b][f]=m;else{const y=Ki(ge(m));ct.forEach((C,E)=>{i[C][f]=y[E]})}else{const y=Qi(m);(b?[b]:ct.slice()).forEach(C=>{i[C]={...y}})}}),r||!n)return;const o=ct.map(a=>ts(i[a])),l=s.slice();o.every(a=>a&&a===o[0])?l.push("border:"+o[0]):ct.forEach((a,d)=>o[d]&&l.push(`border-${a}:`+o[d])),t.setAttribute("style",l.join(";"))})}function ve(u){let t="";return u.childNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE)t+=e.nodeValue||"";else if(e.nodeType===Node.ELEMENT_NODE){const i=e,s=(i.getAttribute("dir")||"").toLowerCase();if(s==="rtl"||s==="ltr")return;t+=ve(i)}}),t}var W;let is=(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.subStack=[],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.vidActive=null,this.vidCtx=null,this.vidHideTimer=null,this.vphActive=null,this.vphCtx=null,this.vphUploadTarget=null,this.selCtx=null,this.tbrMore=null,this.tbrExpanded=!1,this.codeActive=null,this.codeCtx=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??ti,imageFileTypes:t.imageFileTypes??["image/jpeg","image/jpg","image/png","image/gif","image/bmp","image/webp"],videoFileTypes:t.videoFileTypes??["video/mp4","video/webm","video/ogg"]},this.imageUploadHandler=t.imageUploadHandler,this.onImageUploadError=t.onImageUploadError,this.videoUploadHandler=t.videoUploadHandler,this.onVideoUploadError=t.onVideoUploadError,this.contentStyle=t.contentStyle,this.applyTheme(t),this.lang=this.options.language,this.draftStorageKey="tmclone-draft:"+this.options.draftKey,this.initDOM(),this.bindEvents(),this.initUI(),this.recordRevision(),this.stampExistingImages(),this.options.onReady(this)}t(t){const e=Ct(this.lang)[t];return typeof e=="string"?e:e.join(",")}tArr(t){return Ct(this.lang)[t]}dir(){return Ct(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),Zi(),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.vidInput=document.createElement("input"),this.vidInput.type="file",this.vidInput.accept=this.options.videoFileTypes.join(","),this.vidInput.style.display="none",t.appendChild(this.vidInput),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)}applyTheme(t){const e=document.documentElement;t.primaryColor&&e.style.setProperty("--fable-primary",t.primaryColor),t.toolbarGroupBackground&&e.style.setProperty("--fable-tgrp-bg",t.toolbarGroupBackground),t.uiFontFamily&&e.style.setProperty("--fable-ui-font",t.uiFontFamily)}scopeContentStyle(t){return t.replace(/\bbody\b/g,"."+this.contentClass)}bindGrip(t){let e=0,i=0;const s=n=>{e=n.clientY,i=this.ed.offsetHeight,n.preventDefault();const l=o=>{this.ed.style.height=Math.max(120,i+o.clientY-e)+"px"},r=()=>{window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",r)};window.addEventListener("mousemove",l),window.addEventListener("mouseup",r)};t.addEventListener("mousedown",s),this.listeners.push(()=>t.removeEventListener("mousedown",s))}bindEvents(){if(this.onDoc("mousedown",t=>{this.openPop&&!this.openPop.contains(t.target)&&!this.popAnchor.contains(t.target)&&!this.subContains(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.positionVphCtx(),this.positionVidCtx(),this.positionCodeCtx()}),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()),(t.key==="Delete"||t.key==="Backspace")&&this.vphActive&&(t.preventDefault(),this.removeVphPlaceholder()),t.key==="`"&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&this.tryCodeTyping(t),t.key==="Enter"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&this.tryExitBlockquote(t)}),this.on(this.ed,"paste",t=>this.handlePaste(t)),this.on(this.ed,"drop",t=>{var n,l,r,o;t.preventDefault();const e=t.target,i=(n=e.closest)==null?void 0:n.call(e,".img-ph:not(.vid-ph)");if(i&&this.ed.contains(i)&&!this.options.readonly){const a=Array.from(((l=t.dataTransfer)==null?void 0:l.files)||[]).find(u=>u.type.startsWith("image/"));a&&this.readImageFileInto(a,i);return}const s=(r=e.closest)==null?void 0:r.call(e,".vid-ph");if(s&&this.ed.contains(s)&&!this.options.readonly){const a=Array.from(((o=t.dataTransfer)==null?void 0:o.files)||[]).find(u=>u.type.startsWith("video/"));a&&this.readVideoFileInto(a,s)}}),this.on(this.ed,"dragover",t=>t.preventDefault()),this.on(this.ed,"mousedown",t=>{var u,p,m,v,b,f,y;const e=t.target,i=(u=e.closest)==null?void 0:u.call(e,"table");i&&this.ed.contains(i)?this.selectTableForResize(i):this.clearTableHandles();const s=(p=e.closest)==null?void 0:p.call(e,".img-ph:not(.vid-ph)");s&&this.ed.contains(s)&&!this.options.readonly?(t.preventDefault(),this.ed.focus(),this.selectImgPlaceholder(s)):this.clearImgPlaceholderSel();const n=(m=e.closest)==null?void 0:m.call(e,".vid-ph");n&&this.ed.contains(n)&&!this.options.readonly?(t.preventDefault(),this.ed.focus(),this.selectVphPlaceholder(n)):this.clearVphPlaceholderSel();const l=(v=e.closest)==null?void 0:v.call(e,".tpl");l&&this.ed.contains(l)&&!this.options.readonly?this.selectTemplate(l):this.clearTplSel();const r=(b=e.closest)==null?void 0:b.call(e,"pre.code-block");r&&this.ed.contains(r)&&!this.options.readonly?(t.preventDefault(),this.selectCodeEl(r)):this.clearCodeSel();const o=(f=e.closest)==null?void 0:f.call(e,"img");o&&this.ed.contains(o)&&!this.options.readonly?(t.preventDefault(),this.selectImage(o)):this.clearImageHandles();const a=(y=e.closest)==null?void 0:y.call(e,"video, .video-embed");a&&this.ed.contains(a)&&!this.options.readonly?(t.preventDefault(),this.selectVideo(a)):this.clearVidHandles()}),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,n,l,r;const e=(n=(s=t.target).closest)==null?void 0:n.call(s,"img");if(!e)return;const i=t.relatedTarget;i&&((l=this.imgCtx)!=null&&l.contains(i)||this.imgHandles.some(o=>o.contains(i))||((r=i.closest)==null?void 0:r.call(i,"img"))===e)||this.scheduleImgHide()}),this.on(this.ed,"scroll",()=>{this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.positionTplCtx(),this.positionVphCtx(),this.positionVidCtx(),this.positionCodeCtx()}),this.onWin("scroll",t=>{var s;const e=t.target;e instanceof Node&&((((s=this.openPop)==null?void 0:s.contains(e))??!1)||this.subContains(e))||this.closePop(),this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.positionTplCtx(),this.positionVphCtx(),this.positionVidCtx(),this.positionCodeCtx(),this.repositionSelToolbar()},!0),this.onWin("resize",()=>{this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.positionTplCtx(),this.positionVphCtx(),this.positionVidCtx(),this.positionCodeCtx(),this.repositionSelToolbar(),this.updateToolbarOverflow()}),typeof ResizeObserver<"u"){const t=new ResizeObserver(()=>this.updateToolbarOverflow());t.observe(this.shell),this.listeners.push(()=>t.disconnect())}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(),this.insertImageHTML(i.result,t.name.replace(/"/g,"")),this.onChange()},i.readAsDataURL(t)}),this.on(this.vidInput,"change",()=>{var s;const t=(s=this.vidInput.files)==null?void 0:s[0];if(!t)return;const e=this.vphUploadTarget;if(this.vphUploadTarget=null,e&&this.ed.contains(e)){this.readVideoFileInto(t,e);return}const i=new FileReader;i.onload=()=>{this.restoreSel(),document.execCommand("insertHTML",!1,`<video controls src="${i.result}" title="${t.name.replace(/"/g,"")}"></video>`),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.vphCtx&&this.vphCtx.contains(t.target)||this.vidCtx&&this.vidCtx.contains(t.target)||this.codeCtx&&this.codeCtx.contains(t.target)||this.openPop&&this.openPop.contains(t.target)||this.subContains(t.target)||(this.clearTableHandles(),this.clearImageHandles(),this.clearImgPlaceholderSel(),this.clearTplSel(),this.clearVphPlaceholderSel(),this.clearVidHandles(),this.clearCodeSel(),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}getContentForEmail(){const t=(r,o)=>{const a=(r.getAttribute("style")||"").trim();r.setAttribute("style",a?a.replace(/;?$/,"; ")+o:o)},e=document.createElement("div");e.innerHTML=this.ed.innerHTML;let i=null;e.querySelectorAll("[dir]").forEach(r=>{const o=(r.getAttribute("dir")||"").toLowerCase();if(o!=="rtl"&&o!=="ltr")return;const a=o;i||(i=a),/text-align\s*:/i.test(r.getAttribute("style")||"")||t(r,`text-align:${a==="rtl"?"right":"left"}`)}),e.querySelectorAll(ji).forEach(r=>{const o=(r.getAttribute("dir")||"").toLowerCase();if(o==="rtl"||o==="ltr")return;const a=Wi(ve(r));if(!a)return;i||(i=a),r.setAttribute("dir",a);const u=/text-align\s*:/i.test(r.getAttribute("style")||"");t(r,u?`direction:${a}`:`direction:${a};text-align:${a==="rtl"?"right":"left"}`)});const s=this.ed.querySelectorAll("img");e.querySelectorAll("img").forEach((r,o)=>{if(r.closest(".tpl-media"))return;const a=s[o],u=Math.round((a==null?void 0:a.getBoundingClientRect().width)||0);u>0&&!r.getAttribute("width")&&r.setAttribute("width",String(u));const p=r.getAttribute("style")||"";u>0&&!/(^|;)\s*width\s*:/i.test(p)&&t(r,`width:${u}px`),/max-width\s*:/i.test(r.getAttribute("style")||"")||t(r,"max-width:100%"),/(^|;)\s*height\s*:/i.test(r.getAttribute("style")||"")||t(r,"height:auto")}),es(e),e.querySelectorAll("table").forEach(r=>{const o=r.getAttribute("style")||"";/border-collapse\s*:/i.test(o)||t(r,"border-collapse:collapse"),!/border-spacing\s*:/i.test(o)&&!r.hasAttribute("cellspacing")&&r.setAttribute("cellspacing","0")});const n=i||this.ed.getAttribute("dir")||this.dir();return e.querySelectorAll("table:not([dir])").forEach(r=>{r.setAttribute("dir",n),/direction\s*:/i.test(r.getAttribute("style")||"")||t(r,`direction:${n}`)}),`<div dir="${n}" style="direction:${n};text-align:${n==="rtl"?"right":"left"}">${e.innerHTML}</div>`}setContent(t){this.ed.innerHTML=t||"<p><br></p>",this.refreshState(),this.clearTableHandles(),this.clearImageHandles(),this.clearImgPlaceholderSel(),this.clearTplSel(),this.clearVphPlaceholderSel(),this.clearVidHandles(),this.clearCodeSel(),this.clearSelToolbar(),this.onChange(),this.stampExistingImages()}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 Bi(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.clearVphPlaceholderSel(),this.clearVidHandles(),this.clearCodeSel(),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.vidInput&&this.vidInput.parentNode&&this.vidInput.parentNode.removeChild(this.vidInput),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}tryExitBlockquote(t){const e=window.getSelection();if(!e||!e.isCollapsed||!e.anchorNode||!this.ed.contains(e.anchorNode))return;const i=this.closestBlock(e.anchorNode);if(!i||i.tagName==="BLOCKQUOTE"||(i.textContent||"").trim()!=="")return;const s=i.closest("blockquote");if(!s||!this.ed.contains(s)||i!==s.lastElementChild)return;t.preventDefault();const n=document.createElement("p");n.appendChild(document.createElement("br")),s.after(n),i.remove(),s.firstElementChild||s.remove();const l=document.createRange();l.setStart(n,0),l.collapse(!0),e.removeAllRanges(),e.addRange(l),this.saveSel(),this.onChange()}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 n=document.createElement("button");n.type="button",n.className="revrestore",n.textContent=this.t("restore");let l=this.revisions.length-1;const r=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"}),o={},a=u=>{l=u,this.revisions.forEach((p,m)=>{var v;return(v=o[m])==null?void 0:v.classList.toggle("on",m===u)}),s.innerHTML=this.revisions[u].html,n.disabled=u===this.revisions.length-1};for(let u=this.revisions.length-1;u>=0;u--){const p=this.revisions[u],m=document.createElement("button");m.type="button";const v=(new DOMParser().parseFromString(p.html,"text/html").body.textContent||"").trim(),b=v?v.split(/\s+/).length:0,f=u===this.revisions.length-1;m.innerHTML=`<span>${f?this.t("currentver"):r.format(new Date(p.time))}</span><span class="wc">${b} ${this.t("words")}</span>`,m.addEventListener("click",()=>a(u)),o[u]=m,i.appendChild(m)}i.append(n),n.addEventListener("click",()=>{const u=this.revisions[l];u&&(this.recordRevision(),this.setContent(u.html),this.recordRevision(),this.closeDlg())}),e.append(i,s),t.appendChild(e),a(l)})}closeSub(){this.closeSubFrom(0)}closeSubFrom(t){for(;this.subStack.length>t;)this.subStack.pop().remove()}subContains(t){return this.subStack.some(e=>e.contains(t))}subLevelOf(t){if(t===this.openPop)return 0;const e=this.subStack.indexOf(t);return e===-1?this.subStack.length:e+1}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){const i=e.getBoundingClientRect(),s=e.closest(".pop");this.closeSubFrom(s?this.subLevelOf(s):0);const n=document.createElement("div");n.className="pop sub",n.dir=this.dir(),t.subBuild?t.subBuild(n):t.sub&&this.menuItems(n,t.sub),n.addEventListener("mousedown",a=>{a.target.tagName!=="INPUT"&&a.preventDefault()}),document.body.appendChild(n);let r=this.dir()==="rtl"?i.left-n.offsetWidth+2:i.right-2;r=Math.max(8,Math.min(r+scrollX,scrollX+innerWidth-n.offsetWidth-8));let o=i.top+scrollY-6;o=Math.max(8+scrollY,Math.min(o,scrollY+innerHeight-n.offsetHeight-8)),n.style.left=r+"px",n.style.top=o+"px",this.subStack.push(n)}popup(t,e,i){if(this.openPop&&this.popAnchor===t){this.closePop();return}this.closePop();const s=document.createElement("div");s.className="pop"+(i?" "+i:""),s.dir=this.dir(),e(s),document.body.appendChild(s);const n=t.getBoundingClientRect();s.style.minWidth=Math.max(160,Math.round(n.width))+"px";let l=n.bottom+scrollY+2;l=Math.max(8+scrollY,Math.min(l,scrollY+innerHeight-s.offsetHeight-8)),s.style.top=l+"px";let o=this.dir()==="rtl"?n.right-s.offsetWidth:n.left;o=Math.max(8,Math.min(o+scrollX,scrollX+innerWidth-s.offsetWidth-8)),s.style.left=o+"px",s.addEventListener("mousedown",a=>{a.target.tagName!=="INPUT"&&a.preventDefault()}),this.openPop=s,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),n=document.createElement("button");n.className="mi"+(i.on?" on":""),n.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>`:""}`,n.addEventListener("click",()=>{i.action&&(this.closePop(),i.action())}),n.addEventListener("mouseenter",()=>{var l;s?this.openSubFor(i,n):this.closeSubFrom(this.subLevelOf(t)),(l=i.hover)==null||l.call(i,!0)}),n.addEventListener("mouseleave",()=>{var l;return(l=i.hover)==null?void 0:l.call(i,!1)}),t.appendChild(n)})}tbtn(t,e,i,s){const n=document.createElement("button");return n.className="tbtn",n.type="button",n.title=e,n.innerHTML=t,s&&(n.dataset.id=s),n.addEventListener("mousedown",l=>l.preventDefault()),n.addEventListener("click",i),n}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 n=this.tbtn(t,e,()=>i(n),s);return n.classList.add("hasmenu"),n.insertAdjacentHTML("beforeend",h.chev),n.addEventListener("mousedown",()=>this.saveSel()),n}colorChips(){const t=s=>{const n=document.createElement("button");return n.type="button",n.className="cchip",n.title=s,n.addEventListener("mousedown",l=>{l.preventDefault(),this.saveSel()}),n},e=ni.map(s=>{const n=t(this.t("forecolor"));return n.style.background=s,n.addEventListener("click",()=>this.applyColor("fore",s)),n}),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 n=document.createElement("button");return n.className="tsel "+t,n.type="button",n.dataset.id=e,n.innerHTML=`<span class="lbl empty">${i||""}</span>${h.chev}`,n.addEventListener("mousedown",l=>{l.preventDefault(),this.saveSel()}),n.addEventListener("click",()=>s(n)),n}setListStyle(t,e){var n,l;this.restoreSel();const i=window.getSelection();if(!i)return;let s=(n=this.closestBlock(i.anchorNode))==null?void 0:n.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 a;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]],n=this.tArr(e==="ol"?"liststyles_ol":"liststyles_ul").slice(1),l=window.getSelection(),r=l?(a=this.closestBlock(l.anchorNode))==null?void 0:a.closest(e):null,o=r?r.style.listStyleType:"";this.popup(t,u=>{this.menuItems(u,[{label:this.t(e==="ol"?"numlist":"bullist"),icon:e==="ol"?h.numlist:h.bullist,on:document.queryCommandState(i),action:()=>this.exec(i)}]),u.insertAdjacentHTML("beforeend",'<div class="sep"></div>');const p=document.createElement("div");p.className="mi-grid",s.forEach(([m,v],b)=>{const f=document.createElement("button");f.className="mi"+(o===m?" on":""),f.innerHTML=`<span class="ic">${v}</span><span class="prev">${n[b]}</span>`,f.addEventListener("click",()=>{this.closePop(),this.setListStyle(e,m)}),p.appendChild(f)}),u.appendChild(p)})}buildPaletteInto(t,e,i){const s=document.createElement("div");s.className="cpal",ri.forEach(p=>{const m=document.createElement("button");m.type="button",m.style.background=p,m.title=p,m.addEventListener("click",()=>{this.closePop(),i(p)}),s.appendChild(m)}),t.appendChild(s),t.insertAdjacentHTML("beforeend",'<div class="sep"></div>');const n=document.createElement("div");n.className="cfoot";const l=/^#[0-9a-f]{6}$/i.test(e)?e:"#000000",r=document.createElement("div");r.className="cswatch cur",r.title=this.t("currentcolor"),r.style.background=l,r.innerHTML=h.check;const o=document.createElement("button");o.type="button",o.className="cswatch nocolor",o.title=this.t("removecolor"),o.addEventListener("click",()=>{this.closePop(),i(null)});const a=document.createElement("label");a.className="cswatch cwheel",a.title=this.t("customcolor"),a.innerHTML=h.palette;const u=document.createElement("input");u.type="color",u.value=l,u.addEventListener("change",()=>{this.closePop(),i(u.value)}),a.appendChild(u),n.append(r,o,a),t.appendChild(n)}colorMenu(t,e){this.popup(t,i=>{const s=e==="fore"?this.foreColor:this.backColor;this.buildPaletteInto(i,s,n=>this.applyColor(e,n))},e==="fore"?"pop-forecolor":"pop-backcolor")}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)}fontItems(){return this.options.fontFamilyFormats.map(([t,e])=>({label:t,previewStyle:`font-family:${e}`,on:this.currentFont()===t,action:()=>this.exec("fontName",e)}))}fontMenu(t){this.popup(t,e=>this.menuItems(e,this.fontItems()))}sizeItems(){return ei.map(t=>({label:t,on:this.currentSize()===t,action:()=>this.applyFontSize(t)}))}sizeMenu(t){this.popup(t,e=>this.menuItems(e,this.sizeItems()))}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 r=e.startOffset,o=e.startOffset;for(;r>0&&/\S/.test(l[r-1]);)r--;for(;o<l.length&&/\S/.test(l[o]);)o++;if(o>r){const a=document.createRange();a.setStart(i,r),a.setEnd(i,o),t.removeAllRanges(),t.addRange(a),this.savedRange=a.cloneRange();return}}const s=document.createTextNode("");e.insertNode(s);const n=document.createRange();n.setStart(s,0),n.setEnd(s,1),t.removeAllRanges(),t.addRange(n),this.savedRange=n.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(si,Math.max(ii,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),n=[];let l;for(;l=s.nextNode();)i.intersectsNode(l)&&n.push(l);n.forEach(r=>{const o=r===i.startContainer?i.startOffset:0,a=r===i.endContainer?i.endOffset:r.data.length;if(a<=o)return;const u=r.data.slice(o,a);let p=u;t==="lower"?p=u.toLowerCase():t==="upper"?p=u.toUpperCase():p=u.replace(/(^|\s)(\S)/g,(m,v,b)=>v+b.toUpperCase()),r.replaceData(o,a-o,p)}),this.saveSel(),this.refreshState(),this.onChange()}caseItems(){return[{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")}]}caseMenu(t){this.popup(t,e=>this.menuItems(e,this.caseItems()))}applyBlockStyle(t,e){this.restoreSel();const i=this.selectedBlocks(),s=t==="lineHeight"?"line-height":t==="wordSpacing"?"word-spacing":"letter-spacing";i.forEach(n=>{e?n.style[t]=e:n.style.removeProperty(s)}),this.saveSel(),this.onChange()}currentBlockStyle(t){const e=window.getSelection(),i=e?this.closestBlock(e.anchorNode):null;return i&&i.style[t]||""}blockStyleItems(t,e){const i=this.currentBlockStyle(t);return[{label:this.t("normal"),on:!i,action:()=>this.applyBlockStyle(t,"")},...e.map(s=>({label:s,on:i===s,action:()=>this.applyBlockStyle(t,s)}))]}lineHeightMenu(t){this.popup(t,e=>this.menuItems(e,this.blockStyleItems("lineHeight",te)))}wordSpacingMenu(t){this.popup(t,e=>this.menuItems(e,this.blockStyleItems("wordSpacing",ee)))}letterSpacingMenu(t){this.popup(t,e=>this.menuItems(e,this.blockStyleItems("letterSpacing",ie)))}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 n=window.getSelection();n&&(n.removeAllRanges(),n.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 n=window.getSelection();!n||n.isCollapsed?document.execCommand("insertHTML",!1,`<a href="${s.replace(/"/g,""")}">${s.replace(/&/g,"&").replace(/</g,"<")}</a>`):(document.execCommand("styleWithCSS",!1,"false"),document.execCommand("createLink",!1,s)),this.saveSel(),this.onChange()}}),this.dialog(this.t("linkttl"),s=>{const n=document.createElement("div");n.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"))||"",n.append(l,e),s.appendChild(n),setTimeout(()=>e.focus(),0)},i)}blockItems(){return ne.map(([t])=>({label:this.blockLabel(t),previewStyle:t.startsWith("h")?`font-weight:700;font-size:${22-2*+t[1]}px`:t==="pre"?"font-family:monospace":"",on:this.currentBlock()===t,action:()=>this.exec("formatBlock","<"+t+">")}))}blocksMenu(t){this.popup(t,e=>this.menuItems(e,this.blockItems()))}alignItems(){return[["justifyLeft","alignleft",h.alignleft],["justifyCenter","aligncenter",h.aligncenter],["justifyRight","alignright",h.alignright],["justifyFull","alignjustify",h.alignjustify]].map(([e,i,s])=>({label:this.t(i),icon:s,on:document.queryCommandState(e),action:()=>this.exec(e)}))}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 n=document.createElement("div");n.className="tgridlbl",n.textContent="1 × 1";const l=[];for(let r=0;r<8;r++)for(let o=0;o<10;o++){const a=document.createElement("span");a.dataset.r=String(r),a.dataset.c=String(o),a.addEventListener("mouseenter",()=>{l.forEach(u=>u.classList.toggle("hot",+u.dataset.r<=r&&+u.dataset.c<=o)),n.textContent=o+1+" × "+(r+1)}),a.addEventListener("click",()=>{this.closePop(),this.insertTable(r+1,o+1),e==null||e()}),l.push(a),s.appendChild(a)}i.append(s,n),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 n=0;n<e;n++)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)),e={undo:()=>this.tbtn(h.undo,this.t("undo"),()=>this.exec("undo"),"undo"),redo:()=>this.tbtn(h.redo,this.t("redo"),()=>this.exec("redo"),"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","",i=>this.fontMenu(i)),fontsize:()=>this.tsel("w-size","sizesel","",i=>this.sizeMenu(i)),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"),i=>this.colorMenu(i,"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"),i=>this.listMenu(i,"ul"),"insertUnorderedList"),numlist:()=>this.menuTbtn(h.numlist,this.t("numlist"),i=>this.listMenu(i,"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"),code:()=>this.tbtn(h.inlinecodeic,this.t("code"),()=>this.toggleInlineCode(),"code"),codesample:()=>this.tbtn(h.codesampleic,this.t("codesample"),()=>this.codeDlg()),changecase:()=>this.menuTbtn(h.caseic,this.t("changecase"),i=>this.caseMenu(i)),lineheight:()=>this.menuTbtn(h.lineheight,this.t("lineheight"),i=>this.lineHeightMenu(i)),wordspacing:()=>this.menuTbtn(h.wordspacing,this.t("wordspacing"),i=>this.wordSpacingMenu(i)),letterspacing:()=>this.menuTbtn(h.letterspacing,this.t("letterspacing"),i=>this.letterSpacingMenu(i)),removeformat:()=>this.tbtn(h.clearformatic,this.t("removeformat"),()=>this.exec("removeFormat")),blocks:()=>this.tsel("w-block","blocksel",this.t("para"),i=>this.blocksMenu(i)),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()),quickvideo:()=>this.tbtn(h.video,this.t("quickvideo"),()=>this.videoDlg()),quicktable:()=>t,template:()=>this.menuTbtn(h.templateic,this.t("template"),i=>this.templateMenu(i)),charmap:()=>this.tbtn(h.charic,this.t("charmap"),()=>this.charMap()),emoji:()=>this.tbtn(h.emojiic,this.t("emoji"),()=>this.emojiMap()),fullscreen:()=>this.tbtn(h.fullscreen,this.t("fullscreen"),()=>this.toggleFullscreen(),"fullscreen"),sourcecode:()=>this.tbtn(h.srcic,this.t("sourcecode"),()=>this.sourceDlg())};return e.styles=e.blocks,e.image=e.quickimage,e.media=e.quickvideo,e.table=e.quicktable,e}buildToolbar(){this.toolbar.innerHTML="";const t=this.options.toolbar===!0?Qe:this.options.toolbar,e=this.buildToolbarRegistry();this.parseToolbarString(t).forEach(i=>{const s=[];i.forEach(n=>{const l=e[n];if(!l){console.warn(`FableEditor: unknown toolbar item "${n}"`);return}const r=l();Array.isArray(r)?s.push(...r):s.push(r)}),s.length&&this.toolbar.appendChild(this.group(...s))}),this.tbrMore=this.tbtn(h.more,this.t("more"),()=>{this.tbrExpanded=!this.tbrExpanded,this.updateToolbarOverflow()}),this.tbrMore.classList.add("tbr-more"),this.toolbar.appendChild(this.tbrMore),this.syncColorSwatches(this.toolbar),this.updateToolbarOverflow()}updateToolbarOverflow(){const t=this.toolbar;if(!this.tbrMore)return;t.classList.add("tbr-measure");const e=t.scrollWidth>t.clientWidth+1;t.classList.remove("tbr-measure");const i=this.shell.offsetWidth<W.TBR_COLLAPSE_MAX;if(!e||!i){this.tbrExpanded=!1,t.classList.remove("collapsible","expanded"),this.tbrMore.classList.remove("on");return}t.classList.add("collapsible"),t.classList.toggle("expanded",this.tbrExpanded),this.tbrMore.classList.toggle("on",this.tbrExpanded)}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()),this.mItem("video",h.video,()=>this.videoDlg()),{label:this.t("inserttable"),icon:h.tableic,action:()=>this.tableGrid(this.menubar.querySelector('[data-menu-key="table"]')||this.menubar)},this.mItem("codesample",h.codesampleic,()=>this.codeDlg()),{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("emoji",h.emojiic,()=>this.emojiMap()),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("code",h.inlinecodeic,()=>this.toggleInlineCode()),this.mItem("quote",h.quote,()=>this.toggleBlock("blockquote")),"|",{label:this.t("fontfamily"),subBuild:s=>this.menuItems(s,this.fontItems())},{label:this.t("fontsize"),subBuild:s=>this.menuItems(s,this.sizeItems())},{label:this.t("blocks"),subBuild:s=>this.menuItems(s,this.blockItems())},{label:this.t("align"),subBuild:s=>this.menuItems(s,this.alignItems())},{label:this.t("lineheight"),icon:h.lineheight,subBuild:s=>this.menuItems(s,this.blockStyleItems("lineHeight",te))},{label:this.t("wordspacing"),icon:h.wordspacing,subBuild:s=>this.menuItems(s,this.blockStyleItems("wordSpacing",ee))},{label:this.t("letterspacing"),icon:h.letterspacing,subBuild:s=>this.menuItems(s,this.blockStyleItems("letterSpacing",ie))},"|",{label:this.t("forecolor"),icon:h.palette,subBuild:s=>this.buildPaletteInto(s,this.foreColor,n=>this.applyColor("fore",n))},{label:this.t("backcolor"),icon:h.backcolor,subBuild:s=>this.buildPaletteInto(s,this.backColor,n=>this.applyColor("back",n))},"|",this.mItem("bullist",h.bullist,()=>this.exec("insertUnorderedList")),this.mItem("numlist",h.numlist,()=>this.exec("insertOrderedList")),this.mItem("outdent",h.outdent,()=>this.exec("outdent")),this.mItem("indent",h.indent,()=>this.exec("indent")),"|",this.mItem("ltr",h.ltr,()=>this.setDir("ltr")),this.mItem("rtl",h.rtl,()=>this.setDir("rtl")),"|",{label:this.t("changecase"),icon:h.caseic,sub:this.caseItems()},"|",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("cellbg"),icon:h.palette,subBuild:s=>this.buildCellFillInto(s)}]},{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("moverowup"),icon:h.moverowup,action:()=>this.tableMove("rowup"),hover:s=>this.setOpTarget(s?"row":null)},{label:this.t("moverowdown"),icon:h.moverowdown,action:()=>this.tableMove("rowdown"),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("movecolleft"),icon:h.movecolleft,action:()=>this.tableMove("colleft"),hover:s=>this.setOpTarget(s?"col":null)},{label:this.t("movecolright"),icon:h.movecolright,action:()=>this.tableMove("colright"),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?Je: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 n=document.createElement("button");n.type="button",n.textContent=this.t(s),n.dataset.menuKey=s,n.addEventListener("mousedown",l=>{l.preventDefault(),this.saveSel()}),n.addEventListener("click",()=>this.popup(n,l=>this.menuItems(l,t[s]))),this.menubar.appendChild(n)})}tableOp(t){var o,a,u;this.restoreSel();const e=window.getSelection();if(!e)return;const i=((o=this.closestBlock(e.anchorNode))==null?void 0:o.closest("td,th"))||(e.anchorNode&&e.anchorNode.nodeType===1?(u=(a=e.anchorNode).closest)==null?void 0:u.call(a,"td,th"):null);if(!i)return;const s=i.parentElement,n=i.closest("table"),l=Array.from(s.children).indexOf(i),r=()=>{const p=s.cloneNode(!1);return Array.from(s.children).forEach(m=>{const v=document.createElement("td"),b=m.getAttribute("style");b&&v.setAttribute("style",b),v.style.removeProperty("background-color"),v.innerHTML="<br>",p.appendChild(v)}),p};if(t==="rowabove"&&s.before(r()),t==="rowbelow"&&s.after(r()),t==="delrow"){const p=s.parentElement;s.remove(),p.querySelector("tr")||n.remove()}(t==="colbefore"||t==="colafter")&&n.querySelectorAll("tr").forEach(p=>{const m=p.children[Math.min(l,p.children.length-1)],v=document.createElement("td"),b=m.getAttribute("style");b&&v.setAttribute("style",b),v.style.removeProperty("width"),v.style.removeProperty("background-color"),v.innerHTML="<br>",t==="colbefore"?m.before(v):m.after(v)}),t==="delcol"&&(n.querySelectorAll("tr").forEach(p=>{var m;return(m=p.children[l])==null?void 0:m.remove()}),n.querySelector("td,th")||n.remove()),t==="deltable"&&n.remove(),this.onChange(),this.positionTableHandles()}tableMove(t){this.restoreSel();const e=this.currentCell();if(!e)return;const i=e.parentElement,s=e.closest("table"),n=Array.from(i.children).indexOf(e);if(t==="rowup"){const o=i.previousElementSibling;o&&o.before(i)}if(t==="rowdown"){const o=i.nextElementSibling;o&&o.after(i)}t==="colleft"&&n>0&&s.querySelectorAll("tr").forEach(o=>{const a=o.children[n],u=o.children[n-1];a&&u&&u.before(a)}),t==="colright"&&s.querySelectorAll("tr").forEach(o=>{const a=o.children[n],u=o.children[n+1];a&&u&&u.after(a)});const l=document.createRange();l.selectNodeContents(e),l.collapse(!0);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(l)),this.saveSel(),this.onChange(),this.positionTableHandles(),this.positionCellMarker()}alignTable(t){const e=this.tblActive;e&&(e.style.marginLeft=t==="left"?"0":"auto",e.style.marginRight=t==="right"?"0":"auto",this.onChange(),this.positionTableHandles())}buildCellFillInto(t){const e=s=>{const n=this.currentCell();if(!n){alert(this.t("nocell"));return}this.setOrClear(n,"background-color",s||""),this.onChange()},i=this.currentCell();this.buildPaletteInto(t,this.cssToHex(i?i.style.backgroundColor:""),e)}cssToHex(t){const e=t.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);return e?"#"+e.slice(1,4).map(i=>(+i).toString(16).padStart(2,"0")).join(""):t}cellFillMenu(t){this.popup(t,e=>this.buildCellFillInto(e),"pop-cellbg")}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,n,l;const r="display:flex;align-items:center;gap:10px;margin:10px 0",o="width:120px;color:#556;flex:none",a="flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit",u=t.querySelector("td,th"),p=t.style.width||"",m=u&&u.style.padding?parseFloat(u.style.padding):"",v=t.style.borderSpacing?parseFloat(t.style.borderSpacing):"",b=t.style.borderWidth?parseFloat(t.style.borderWidth):"",f=t.style.marginLeft,y=t.style.marginRight,C=f==="auto"&&y==="auto"?"center":f==="auto"?"right":y==="auto"&&f==="0"?"left":"";this.dialog(this.t("tablepropsttl"),E=>{const I=(A,j)=>{const Z=document.createElement("div");Z.style.cssText=r;const _=document.createElement("span");_.style.cssText=o,_.textContent=this.t(A),Z.append(_,j),E.appendChild(Z)};e=document.createElement("input"),e.type="text",e.style.cssText=a,e.placeholder="e.g. 600px or 100%",e.value=p,I("tblwidth",e),i=document.createElement("input"),i.type="number",i.min="0",i.style.cssText=a,i.value=String(m),I("tblcellpadding",i),s=document.createElement("input"),s.type="number",s.min="0",s.style.cssText=a,s.value=String(v),I("tblcellspacing",s),n=document.createElement("input"),n.type="number",n.min="0",n.style.cssText=a,n.value=String(b),I("tblborder",n),l=document.createElement("select"),l.style.cssText=a,[["","alignnone"],["left","alignleft"],["center","aligncenter"],["right","alignright"]].forEach(([A,j])=>{const Z=document.createElement("option");Z.value=A,Z.textContent=this.t(j),A===C&&(Z.selected=!0),l.appendChild(Z)}),I("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:n.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 n=document.createElement("span");n.style.cssText="width:120px;color:#556;flex:none",n.textContent=e,s.append(n,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,n])=>{const l=document.createElement("option");l.value=s,l.textContent=n,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 n=document.createElement("label");n.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,n.append(l,document.createTextNode(this.t("fill"))),s.addEventListener("input",()=>l.checked=!0),e.append(s,n),{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,n,l;this.dialog(this.t("cellprops").replace("…",""),r=>{e=this.formInput(t.style.width,"e.g. 120px / 25%"),this.formRow(r,this.t("tblwidth"),e),i=this.formInput(t.style.height,"e.g. 40px"),this.formRow(r,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(r,this.t("tblalign"),s),n=this.formSelect([["",this.t("alignnone")],["top",this.t("valigntop")],["middle",this.t("valignmiddle")],["bottom",this.t("valignbottom")]],t.style.verticalAlign||""),this.formRow(r,this.t("valign"),n),l=this.formBg(t.style.backgroundColor||""),this.formRow(r,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",n.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("…",""),n=>{i=this.formInput(e.style.height,"e.g. 40px"),this.formRow(n,this.t("tblheight"),i),s=this.formBg(e.style.backgroundColor||""),this.formRow(n,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),n=Array.from(i.rows).map(o=>o.cells[s]).filter(Boolean);let l,r;this.dialog(this.t("colprops").replace("…",""),o=>{l=this.formInput(t.style.width,"e.g. 120px / 25%"),this.formRow(o,this.t("tblwidth"),l),r=this.formBg(t.style.backgroundColor||""),this.formRow(o,this.t("backcolor"),r.wrap)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{n.forEach(o=>{this.setOrClear(o,"width",l.value.trim()),this.setOrClear(o,"background-color",r.fill.checked?r.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
|
-
<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(n=>{const
|
|
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),Zi(),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.vidInput=document.createElement("input"),this.vidInput.type="file",this.vidInput.accept=this.options.videoFileTypes.join(","),this.vidInput.style.display="none",t.appendChild(this.vidInput),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)}applyTheme(t){const e=document.documentElement;t.primaryColor&&e.style.setProperty("--fable-primary",t.primaryColor),t.toolbarGroupBackground&&e.style.setProperty("--fable-tgrp-bg",t.toolbarGroupBackground),t.uiFontFamily&&e.style.setProperty("--fable-ui-font",t.uiFontFamily)}scopeContentStyle(t){return t.replace(/\bbody\b/g,"."+this.contentClass)}bindGrip(t){let e=0,i=0;const s=n=>{e=n.clientY,i=this.ed.offsetHeight,n.preventDefault();const r=l=>{this.ed.style.height=Math.max(120,i+l.clientY-e)+"px"},o=()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)};t.addEventListener("mousedown",s),this.listeners.push(()=>t.removeEventListener("mousedown",s))}bindEvents(){if(this.onDoc("mousedown",t=>{this.openPop&&!this.openPop.contains(t.target)&&!this.popAnchor.contains(t.target)&&!this.subContains(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.positionVphCtx(),this.positionVidCtx(),this.positionCodeCtx()}),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()),(t.key==="Delete"||t.key==="Backspace")&&this.vphActive&&(t.preventDefault(),this.removeVphPlaceholder()),t.key==="`"&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&this.tryCodeTyping(t),t.key==="Enter"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&this.tryExitBlockquote(t)}),this.on(this.ed,"paste",t=>this.handlePaste(t)),this.on(this.ed,"drop",t=>{var n,r,o,l;t.preventDefault();const e=t.target,i=(n=e.closest)==null?void 0:n.call(e,".img-ph:not(.vid-ph)");if(i&&this.ed.contains(i)&&!this.options.readonly){const a=Array.from(((r=t.dataTransfer)==null?void 0:r.files)||[]).find(d=>d.type.startsWith("image/"));a&&this.readImageFileInto(a,i);return}const s=(o=e.closest)==null?void 0:o.call(e,".vid-ph");if(s&&this.ed.contains(s)&&!this.options.readonly){const a=Array.from(((l=t.dataTransfer)==null?void 0:l.files)||[]).find(d=>d.type.startsWith("video/"));a&&this.readVideoFileInto(a,s)}}),this.on(this.ed,"dragover",t=>t.preventDefault()),this.on(this.ed,"mousedown",t=>{var d,p,m,v,b,f,y;const e=t.target,i=(d=e.closest)==null?void 0:d.call(e,"table");i&&this.ed.contains(i)?this.selectTableForResize(i):this.clearTableHandles();const s=(p=e.closest)==null?void 0:p.call(e,".img-ph:not(.vid-ph)");s&&this.ed.contains(s)&&!this.options.readonly?(t.preventDefault(),this.ed.focus(),this.selectImgPlaceholder(s)):this.clearImgPlaceholderSel();const n=(m=e.closest)==null?void 0:m.call(e,".vid-ph");n&&this.ed.contains(n)&&!this.options.readonly?(t.preventDefault(),this.ed.focus(),this.selectVphPlaceholder(n)):this.clearVphPlaceholderSel();const r=(v=e.closest)==null?void 0:v.call(e,".tpl");r&&this.ed.contains(r)&&!this.options.readonly?this.selectTemplate(r):this.clearTplSel();const o=(b=e.closest)==null?void 0:b.call(e,"pre.code-block");o&&this.ed.contains(o)&&!this.options.readonly?(t.preventDefault(),this.selectCodeEl(o)):this.clearCodeSel();const l=(f=e.closest)==null?void 0:f.call(e,"img");l&&this.ed.contains(l)&&!this.options.readonly?(t.preventDefault(),this.selectImage(l)):this.clearImageHandles();const a=(y=e.closest)==null?void 0:y.call(e,"video, .video-embed");a&&this.ed.contains(a)&&!this.options.readonly?(t.preventDefault(),this.selectVideo(a)):this.clearVidHandles()}),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,n,r,o;const e=(n=(s=t.target).closest)==null?void 0:n.call(s,"img");if(!e)return;const i=t.relatedTarget;i&&((r=this.imgCtx)!=null&&r.contains(i)||this.imgHandles.some(l=>l.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.positionVphCtx(),this.positionVidCtx(),this.positionCodeCtx()}),this.onWin("scroll",t=>{var s;const e=t.target;e instanceof Node&&((((s=this.openPop)==null?void 0:s.contains(e))??!1)||this.subContains(e))||this.closePop(),this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.positionTplCtx(),this.positionVphCtx(),this.positionVidCtx(),this.positionCodeCtx(),this.repositionSelToolbar()},!0),this.onWin("resize",()=>{this.positionTableHandles(),this.positionImageHandles(),this.positionImgPhCtx(),this.positionTplCtx(),this.positionVphCtx(),this.positionVidCtx(),this.positionCodeCtx(),this.repositionSelToolbar(),this.updateToolbarOverflow()}),typeof ResizeObserver<"u"){const t=new ResizeObserver(()=>this.updateToolbarOverflow());t.observe(this.shell),this.listeners.push(()=>t.disconnect())}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(),this.insertImageHTML(i.result,t.name.replace(/"/g,"")),this.onChange()},i.readAsDataURL(t)}),this.on(this.vidInput,"change",()=>{var s;const t=(s=this.vidInput.files)==null?void 0:s[0];if(!t)return;const e=this.vphUploadTarget;if(this.vphUploadTarget=null,e&&this.ed.contains(e)){this.readVideoFileInto(t,e);return}const i=new FileReader;i.onload=()=>{this.restoreSel(),document.execCommand("insertHTML",!1,`<video controls src="${i.result}" title="${t.name.replace(/"/g,"")}"></video>`),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.vphCtx&&this.vphCtx.contains(t.target)||this.vidCtx&&this.vidCtx.contains(t.target)||this.codeCtx&&this.codeCtx.contains(t.target)||this.openPop&&this.openPop.contains(t.target)||this.subContains(t.target)||(this.clearTableHandles(),this.clearImageHandles(),this.clearImgPlaceholderSel(),this.clearTplSel(),this.clearVphPlaceholderSel(),this.clearVidHandles(),this.clearCodeSel(),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}getContentForEmail(){const t=(l,a)=>{const d=(l.getAttribute("style")||"").trim();l.setAttribute("style",d?d.replace(/;?$/,"; ")+a:a)},e=(l,a)=>{const d=(l.getAttribute("style")||"").split(";").map(p=>p.trim()).filter(p=>p&&!/^width\s*:/i.test(p));d.push(`width:${a}px`),l.setAttribute("style",d.join("; "))},i=document.createElement("div");i.innerHTML=this.ed.innerHTML;let s=null;i.querySelectorAll("[dir]").forEach(l=>{const a=(l.getAttribute("dir")||"").toLowerCase();if(a!=="rtl"&&a!=="ltr")return;const d=a;s||(s=d),/text-align\s*:/i.test(l.getAttribute("style")||"")||t(l,`text-align:${d==="rtl"?"right":"left"}`)}),i.querySelectorAll(ji).forEach(l=>{const a=(l.getAttribute("dir")||"").toLowerCase();if(a==="rtl"||a==="ltr")return;const d=Wi(ve(l));if(!d)return;s||(s=d),l.setAttribute("dir",d);const p=/text-align\s*:/i.test(l.getAttribute("style")||"");t(l,p?`direction:${d}`:`direction:${d};text-align:${d==="rtl"?"right":"left"}`)});const n=this.ed.querySelectorAll("img");i.querySelectorAll("img").forEach((l,a)=>{if(l.closest(".tpl-media"))return;const d=n[a],p=Math.round((d==null?void 0:d.offsetWidth)||0);p>0&&(l.setAttribute("width",String(p)),l.removeAttribute("height"),e(l,p)),/max-width\s*:/i.test(l.getAttribute("style")||"")||t(l,"max-width:100%"),/(^|;)\s*height\s*:/i.test(l.getAttribute("style")||"")||t(l,"height:auto")}),es(i),i.querySelectorAll("table").forEach(l=>{const a=l.getAttribute("style")||"";/border-collapse\s*:/i.test(a)||t(l,"border-collapse:collapse"),!/border-spacing\s*:/i.test(a)&&!l.hasAttribute("cellspacing")&&l.setAttribute("cellspacing","0")});const r=s||this.ed.getAttribute("dir")||this.dir();return i.querySelectorAll("table:not([dir])").forEach(l=>{l.setAttribute("dir",r),/direction\s*:/i.test(l.getAttribute("style")||"")||t(l,`direction:${r}`)}),`<div dir="${r}" style="direction:${r};text-align:${r==="rtl"?"right":"left"}">${i.innerHTML}</div>`}setContent(t){this.ed.innerHTML=t||"<p><br></p>",this.refreshState(),this.clearTableHandles(),this.clearImageHandles(),this.clearImgPlaceholderSel(),this.clearTplSel(),this.clearVphPlaceholderSel(),this.clearVidHandles(),this.clearCodeSel(),this.clearSelToolbar(),this.onChange(),this.stampExistingImages()}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 Bi(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.clearVphPlaceholderSel(),this.clearVidHandles(),this.clearCodeSel(),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.vidInput&&this.vidInput.parentNode&&this.vidInput.parentNode.removeChild(this.vidInput),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}tryExitBlockquote(t){const e=window.getSelection();if(!e||!e.isCollapsed||!e.anchorNode||!this.ed.contains(e.anchorNode))return;const i=this.closestBlock(e.anchorNode);if(!i||i.tagName==="BLOCKQUOTE"||(i.textContent||"").trim()!=="")return;const s=i.closest("blockquote");if(!s||!this.ed.contains(s)||i!==s.lastElementChild)return;t.preventDefault();const n=document.createElement("p");n.appendChild(document.createElement("br")),s.after(n),i.remove(),s.firstElementChild||s.remove();const r=document.createRange();r.setStart(n,0),r.collapse(!0),e.removeAllRanges(),e.addRange(r),this.saveSel(),this.onChange()}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 n=document.createElement("button");n.type="button",n.className="revrestore",n.textContent=this.t("restore");let r=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"}),l={},a=d=>{r=d,this.revisions.forEach((p,m)=>{var v;return(v=l[m])==null?void 0:v.classList.toggle("on",m===d)}),s.innerHTML=this.revisions[d].html,n.disabled=d===this.revisions.length-1};for(let d=this.revisions.length-1;d>=0;d--){const p=this.revisions[d],m=document.createElement("button");m.type="button";const v=(new DOMParser().parseFromString(p.html,"text/html").body.textContent||"").trim(),b=v?v.split(/\s+/).length:0,f=d===this.revisions.length-1;m.innerHTML=`<span>${f?this.t("currentver"):o.format(new Date(p.time))}</span><span class="wc">${b} ${this.t("words")}</span>`,m.addEventListener("click",()=>a(d)),l[d]=m,i.appendChild(m)}i.append(n),n.addEventListener("click",()=>{const d=this.revisions[r];d&&(this.recordRevision(),this.setContent(d.html),this.recordRevision(),this.closeDlg())}),e.append(i,s),t.appendChild(e),a(r)})}closeSub(){this.closeSubFrom(0)}closeSubFrom(t){for(;this.subStack.length>t;)this.subStack.pop().remove()}subContains(t){return this.subStack.some(e=>e.contains(t))}subLevelOf(t){if(t===this.openPop)return 0;const e=this.subStack.indexOf(t);return e===-1?this.subStack.length:e+1}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){const i=e.getBoundingClientRect(),s=e.closest(".pop");this.closeSubFrom(s?this.subLevelOf(s):0);const n=document.createElement("div");n.className="pop sub",n.dir=this.dir(),t.subBuild?t.subBuild(n):t.sub&&this.menuItems(n,t.sub),n.addEventListener("mousedown",a=>{a.target.tagName!=="INPUT"&&a.preventDefault()}),document.body.appendChild(n);let o=this.dir()==="rtl"?i.left-n.offsetWidth+2:i.right-2;o=Math.max(8,Math.min(o+scrollX,scrollX+innerWidth-n.offsetWidth-8));let l=i.top+scrollY-6;l=Math.max(8+scrollY,Math.min(l,scrollY+innerHeight-n.offsetHeight-8)),n.style.left=o+"px",n.style.top=l+"px",this.subStack.push(n)}popup(t,e,i){if(this.openPop&&this.popAnchor===t){this.closePop();return}this.closePop();const s=document.createElement("div");s.className="pop"+(i?" "+i:""),s.dir=this.dir(),e(s),document.body.appendChild(s);const n=t.getBoundingClientRect();s.style.minWidth=Math.max(160,Math.round(n.width))+"px";let r=n.bottom+scrollY+2;r=Math.max(8+scrollY,Math.min(r,scrollY+innerHeight-s.offsetHeight-8)),s.style.top=r+"px";let l=this.dir()==="rtl"?n.right-s.offsetWidth:n.left;l=Math.max(8,Math.min(l+scrollX,scrollX+innerWidth-s.offsetWidth-8)),s.style.left=l+"px",s.addEventListener("mousedown",a=>{a.target.tagName!=="INPUT"&&a.preventDefault()}),this.openPop=s,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),n=document.createElement("button");n.className="mi"+(i.on?" on":""),n.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>`:""}`,n.addEventListener("click",()=>{i.action&&(this.closePop(),i.action())}),n.addEventListener("mouseenter",()=>{var r;s?this.openSubFor(i,n):this.closeSubFrom(this.subLevelOf(t)),(r=i.hover)==null||r.call(i,!0)}),n.addEventListener("mouseleave",()=>{var r;return(r=i.hover)==null?void 0:r.call(i,!1)}),t.appendChild(n)})}tbtn(t,e,i,s){const n=document.createElement("button");return n.className="tbtn",n.type="button",n.title=e,n.innerHTML=t,s&&(n.dataset.id=s),n.addEventListener("mousedown",r=>r.preventDefault()),n.addEventListener("click",i),n}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 n=this.tbtn(t,e,()=>i(n),s);return n.classList.add("hasmenu"),n.insertAdjacentHTML("beforeend",h.chev),n.addEventListener("mousedown",()=>this.saveSel()),n}colorChips(){const t=s=>{const n=document.createElement("button");return n.type="button",n.className="cchip",n.title=s,n.addEventListener("mousedown",r=>{r.preventDefault(),this.saveSel()}),n},e=ni.map(s=>{const n=t(this.t("forecolor"));return n.style.background=s,n.addEventListener("click",()=>this.applyColor("fore",s)),n}),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 n=document.createElement("button");return n.className="tsel "+t,n.type="button",n.dataset.id=e,n.innerHTML=`<span class="lbl empty">${i||""}</span>${h.chev}`,n.addEventListener("mousedown",r=>{r.preventDefault(),this.saveSel()}),n.addEventListener("click",()=>s(n)),n}setListStyle(t,e){var n,r;this.restoreSel();const i=window.getSelection();if(!i)return;let s=(n=this.closestBlock(i.anchorNode))==null?void 0:n.closest(t);s||(this.exec(t==="ol"?"insertOrderedList":"insertUnorderedList"),s=(r=this.closestBlock(i.anchorNode))==null?void 0:r.closest(t)),s&&(s.style.listStyleType=e),this.saveSel(),this.onChange()}listMenu(t,e){var a;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]],n=this.tArr(e==="ol"?"liststyles_ol":"liststyles_ul").slice(1),r=window.getSelection(),o=r?(a=this.closestBlock(r.anchorNode))==null?void 0:a.closest(e):null,l=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 p=document.createElement("div");p.className="mi-grid",s.forEach(([m,v],b)=>{const f=document.createElement("button");f.className="mi"+(l===m?" on":""),f.innerHTML=`<span class="ic">${v}</span><span class="prev">${n[b]}</span>`,f.addEventListener("click",()=>{this.closePop(),this.setListStyle(e,m)}),p.appendChild(f)}),d.appendChild(p)})}buildPaletteInto(t,e,i){const s=document.createElement("div");s.className="cpal",ri.forEach(p=>{const m=document.createElement("button");m.type="button",m.style.background=p,m.title=p,m.addEventListener("click",()=>{this.closePop(),i(p)}),s.appendChild(m)}),t.appendChild(s),t.insertAdjacentHTML("beforeend",'<div class="sep"></div>');const n=document.createElement("div");n.className="cfoot";const r=/^#[0-9a-f]{6}$/i.test(e)?e:"#000000",o=document.createElement("div");o.className="cswatch cur",o.title=this.t("currentcolor"),o.style.background=r,o.innerHTML=h.check;const l=document.createElement("button");l.type="button",l.className="cswatch nocolor",l.title=this.t("removecolor"),l.addEventListener("click",()=>{this.closePop(),i(null)});const a=document.createElement("label");a.className="cswatch cwheel",a.title=this.t("customcolor"),a.innerHTML=h.palette;const d=document.createElement("input");d.type="color",d.value=r,d.addEventListener("change",()=>{this.closePop(),i(d.value)}),a.appendChild(d),n.append(o,l,a),t.appendChild(n)}colorMenu(t,e){this.popup(t,i=>{const s=e==="fore"?this.foreColor:this.backColor;this.buildPaletteInto(i,s,n=>this.applyColor(e,n))},e==="fore"?"pop-forecolor":"pop-backcolor")}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)}fontItems(){return this.options.fontFamilyFormats.map(([t,e])=>({label:t,previewStyle:`font-family:${e}`,on:this.currentFont()===t,action:()=>this.exec("fontName",e)}))}fontMenu(t){this.popup(t,e=>this.menuItems(e,this.fontItems()))}sizeItems(){return ei.map(t=>({label:t,on:this.currentSize()===t,action:()=>this.applyFontSize(t)}))}sizeMenu(t){this.popup(t,e=>this.menuItems(e,this.sizeItems()))}ensureSizeTarget(){const t=window.getSelection();if(!t)return;if(!t.rangeCount){const r=document.createRange();r.selectNodeContents(this.ed),r.collapse(!0),t.addRange(r)}if(!t.isCollapsed)return;const e=t.getRangeAt(0),i=e.startContainer;if(i.nodeType===3){const r=i.data;let o=e.startOffset,l=e.startOffset;for(;o>0&&/\S/.test(r[o-1]);)o--;for(;l<r.length&&/\S/.test(r[l]);)l++;if(l>o){const a=document.createRange();a.setStart(i,o),a.setEnd(i,l),t.removeAllRanges(),t.addRange(a),this.savedRange=a.cloneRange();return}}const s=document.createTextNode("");e.insertNode(s);const n=document.createRange();n.setStart(s,0),n.setEnd(s,1),t.removeAllRanges(),t.addRange(n),this.savedRange=n.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(si,Math.max(ii,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),n=[];let r;for(;r=s.nextNode();)i.intersectsNode(r)&&n.push(r);n.forEach(o=>{const l=o===i.startContainer?i.startOffset:0,a=o===i.endContainer?i.endOffset:o.data.length;if(a<=l)return;const d=o.data.slice(l,a);let p=d;t==="lower"?p=d.toLowerCase():t==="upper"?p=d.toUpperCase():p=d.replace(/(^|\s)(\S)/g,(m,v,b)=>v+b.toUpperCase()),o.replaceData(l,a-l,p)}),this.saveSel(),this.refreshState(),this.onChange()}caseItems(){return[{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")}]}caseMenu(t){this.popup(t,e=>this.menuItems(e,this.caseItems()))}applyBlockStyle(t,e){this.restoreSel();const i=this.selectedBlocks(),s=t==="lineHeight"?"line-height":t==="wordSpacing"?"word-spacing":"letter-spacing";i.forEach(n=>{e?n.style[t]=e:n.style.removeProperty(s)}),this.saveSel(),this.onChange()}currentBlockStyle(t){const e=window.getSelection(),i=e?this.closestBlock(e.anchorNode):null;return i&&i.style[t]||""}blockStyleItems(t,e){const i=this.currentBlockStyle(t);return[{label:this.t("normal"),on:!i,action:()=>this.applyBlockStyle(t,"")},...e.map(s=>({label:s,on:i===s,action:()=>this.applyBlockStyle(t,s)}))]}lineHeightMenu(t){this.popup(t,e=>this.menuItems(e,this.blockStyleItems("lineHeight",te)))}wordSpacingMenu(t){this.popup(t,e=>this.menuItems(e,this.blockStyleItems("wordSpacing",ee)))}letterSpacingMenu(t){this.popup(t,e=>this.menuItems(e,this.blockStyleItems("letterSpacing",ie)))}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 n=window.getSelection();n&&(n.removeAllRanges(),n.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 n=window.getSelection();!n||n.isCollapsed?document.execCommand("insertHTML",!1,`<a href="${s.replace(/"/g,""")}">${s.replace(/&/g,"&").replace(/</g,"<")}</a>`):(document.execCommand("styleWithCSS",!1,"false"),document.execCommand("createLink",!1,s)),this.saveSel(),this.onChange()}}),this.dialog(this.t("linkttl"),s=>{const n=document.createElement("div");n.style.cssText="display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";const r=document.createElement("span");r.style.cssText="width:60px;color:#556;flex:none",r.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"))||"",n.append(r,e),s.appendChild(n),setTimeout(()=>e.focus(),0)},i)}blockItems(){return ne.map(([t])=>({label:this.blockLabel(t),previewStyle:t.startsWith("h")?`font-weight:700;font-size:${22-2*+t[1]}px`:t==="pre"?"font-family:monospace":"",on:this.currentBlock()===t,action:()=>this.exec("formatBlock","<"+t+">")}))}blocksMenu(t){this.popup(t,e=>this.menuItems(e,this.blockItems()))}alignItems(){return[["justifyLeft","alignleft",h.alignleft],["justifyCenter","aligncenter",h.aligncenter],["justifyRight","alignright",h.alignright],["justifyFull","alignjustify",h.alignjustify]].map(([e,i,s])=>({label:this.t(i),icon:s,on:document.queryCommandState(e),action:()=>this.exec(e)}))}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 n=document.createElement("div");n.className="tgridlbl",n.textContent="1 × 1";const r=[];for(let o=0;o<8;o++)for(let l=0;l<10;l++){const a=document.createElement("span");a.dataset.r=String(o),a.dataset.c=String(l),a.addEventListener("mouseenter",()=>{r.forEach(d=>d.classList.toggle("hot",+d.dataset.r<=o&&+d.dataset.c<=l)),n.textContent=l+1+" × "+(o+1)}),a.addEventListener("click",()=>{this.closePop(),this.insertTable(o+1,l+1),e==null||e()}),r.push(a),s.appendChild(a)}i.append(s,n),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 n=0;n<e;n++)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)),e={undo:()=>this.tbtn(h.undo,this.t("undo"),()=>this.exec("undo"),"undo"),redo:()=>this.tbtn(h.redo,this.t("redo"),()=>this.exec("redo"),"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","",i=>this.fontMenu(i)),fontsize:()=>this.tsel("w-size","sizesel","",i=>this.sizeMenu(i)),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"),i=>this.colorMenu(i,"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"),i=>this.listMenu(i,"ul"),"insertUnorderedList"),numlist:()=>this.menuTbtn(h.numlist,this.t("numlist"),i=>this.listMenu(i,"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"),code:()=>this.tbtn(h.inlinecodeic,this.t("code"),()=>this.toggleInlineCode(),"code"),codesample:()=>this.tbtn(h.codesampleic,this.t("codesample"),()=>this.codeDlg()),changecase:()=>this.menuTbtn(h.caseic,this.t("changecase"),i=>this.caseMenu(i)),lineheight:()=>this.menuTbtn(h.lineheight,this.t("lineheight"),i=>this.lineHeightMenu(i)),wordspacing:()=>this.menuTbtn(h.wordspacing,this.t("wordspacing"),i=>this.wordSpacingMenu(i)),letterspacing:()=>this.menuTbtn(h.letterspacing,this.t("letterspacing"),i=>this.letterSpacingMenu(i)),removeformat:()=>this.tbtn(h.clearformatic,this.t("removeformat"),()=>this.exec("removeFormat")),blocks:()=>this.tsel("w-block","blocksel",this.t("para"),i=>this.blocksMenu(i)),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()),quickvideo:()=>this.tbtn(h.video,this.t("quickvideo"),()=>this.videoDlg()),quicktable:()=>t,template:()=>this.menuTbtn(h.templateic,this.t("template"),i=>this.templateMenu(i)),charmap:()=>this.tbtn(h.charic,this.t("charmap"),()=>this.charMap()),emoji:()=>this.tbtn(h.emojiic,this.t("emoji"),()=>this.emojiMap()),fullscreen:()=>this.tbtn(h.fullscreen,this.t("fullscreen"),()=>this.toggleFullscreen(),"fullscreen"),sourcecode:()=>this.tbtn(h.srcic,this.t("sourcecode"),()=>this.sourceDlg())};return e.styles=e.blocks,e.image=e.quickimage,e.media=e.quickvideo,e.table=e.quicktable,e}buildToolbar(){this.toolbar.innerHTML="";const t=this.options.toolbar===!0?Qe:this.options.toolbar,e=this.buildToolbarRegistry();this.parseToolbarString(t).forEach(i=>{const s=[];i.forEach(n=>{const r=e[n];if(!r){console.warn(`FableEditor: unknown toolbar item "${n}"`);return}const o=r();Array.isArray(o)?s.push(...o):s.push(o)}),s.length&&this.toolbar.appendChild(this.group(...s))}),this.tbrMore=this.tbtn(h.more,this.t("more"),()=>{this.tbrExpanded=!this.tbrExpanded,this.updateToolbarOverflow()}),this.tbrMore.classList.add("tbr-more"),this.toolbar.appendChild(this.tbrMore),this.syncColorSwatches(this.toolbar),this.updateToolbarOverflow()}updateToolbarOverflow(){const t=this.toolbar;if(!this.tbrMore)return;t.classList.add("tbr-measure");const e=t.scrollWidth>t.clientWidth+1;t.classList.remove("tbr-measure");const i=this.shell.offsetWidth<W.TBR_COLLAPSE_MAX;if(!e||!i){this.tbrExpanded=!1,t.classList.remove("collapsible","expanded"),this.tbrMore.classList.remove("on");return}t.classList.add("collapsible"),t.classList.toggle("expanded",this.tbrExpanded),this.tbrMore.classList.toggle("on",this.tbrExpanded)}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()),this.mItem("video",h.video,()=>this.videoDlg()),{label:this.t("inserttable"),icon:h.tableic,action:()=>this.tableGrid(this.menubar.querySelector('[data-menu-key="table"]')||this.menubar)},this.mItem("codesample",h.codesampleic,()=>this.codeDlg()),{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("emoji",h.emojiic,()=>this.emojiMap()),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("code",h.inlinecodeic,()=>this.toggleInlineCode()),this.mItem("quote",h.quote,()=>this.toggleBlock("blockquote")),"|",{label:this.t("fontfamily"),subBuild:s=>this.menuItems(s,this.fontItems())},{label:this.t("fontsize"),subBuild:s=>this.menuItems(s,this.sizeItems())},{label:this.t("blocks"),subBuild:s=>this.menuItems(s,this.blockItems())},{label:this.t("align"),subBuild:s=>this.menuItems(s,this.alignItems())},{label:this.t("lineheight"),icon:h.lineheight,subBuild:s=>this.menuItems(s,this.blockStyleItems("lineHeight",te))},{label:this.t("wordspacing"),icon:h.wordspacing,subBuild:s=>this.menuItems(s,this.blockStyleItems("wordSpacing",ee))},{label:this.t("letterspacing"),icon:h.letterspacing,subBuild:s=>this.menuItems(s,this.blockStyleItems("letterSpacing",ie))},"|",{label:this.t("forecolor"),icon:h.palette,subBuild:s=>this.buildPaletteInto(s,this.foreColor,n=>this.applyColor("fore",n))},{label:this.t("backcolor"),icon:h.backcolor,subBuild:s=>this.buildPaletteInto(s,this.backColor,n=>this.applyColor("back",n))},"|",this.mItem("bullist",h.bullist,()=>this.exec("insertUnorderedList")),this.mItem("numlist",h.numlist,()=>this.exec("insertOrderedList")),this.mItem("outdent",h.outdent,()=>this.exec("outdent")),this.mItem("indent",h.indent,()=>this.exec("indent")),"|",this.mItem("ltr",h.ltr,()=>this.setDir("ltr")),this.mItem("rtl",h.rtl,()=>this.setDir("rtl")),"|",{label:this.t("changecase"),icon:h.caseic,sub:this.caseItems()},"|",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("cellbg"),icon:h.palette,subBuild:s=>this.buildCellFillInto(s)}]},{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("moverowup"),icon:h.moverowup,action:()=>this.tableMove("rowup"),hover:s=>this.setOpTarget(s?"row":null)},{label:this.t("moverowdown"),icon:h.moverowdown,action:()=>this.tableMove("rowdown"),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("movecolleft"),icon:h.movecolleft,action:()=>this.tableMove("colleft"),hover:s=>this.setOpTarget(s?"col":null)},{label:this.t("movecolright"),icon:h.movecolright,action:()=>this.tableMove("colright"),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?Je: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 n=document.createElement("button");n.type="button",n.textContent=this.t(s),n.dataset.menuKey=s,n.addEventListener("mousedown",r=>{r.preventDefault(),this.saveSel()}),n.addEventListener("click",()=>this.popup(n,r=>this.menuItems(r,t[s]))),this.menubar.appendChild(n)})}tableOp(t){var l,a,d;this.restoreSel();const e=window.getSelection();if(!e)return;const i=((l=this.closestBlock(e.anchorNode))==null?void 0:l.closest("td,th"))||(e.anchorNode&&e.anchorNode.nodeType===1?(d=(a=e.anchorNode).closest)==null?void 0:d.call(a,"td,th"):null);if(!i)return;const s=i.parentElement,n=i.closest("table"),r=Array.from(s.children).indexOf(i),o=()=>{const p=s.cloneNode(!1);return Array.from(s.children).forEach(m=>{const v=document.createElement("td"),b=m.getAttribute("style");b&&v.setAttribute("style",b),v.style.removeProperty("background-color"),v.innerHTML="<br>",p.appendChild(v)}),p};if(t==="rowabove"&&s.before(o()),t==="rowbelow"&&s.after(o()),t==="delrow"){const p=s.parentElement;s.remove(),p.querySelector("tr")||n.remove()}(t==="colbefore"||t==="colafter")&&n.querySelectorAll("tr").forEach(p=>{const m=p.children[Math.min(r,p.children.length-1)],v=document.createElement("td"),b=m.getAttribute("style");b&&v.setAttribute("style",b),v.style.removeProperty("width"),v.style.removeProperty("background-color"),v.innerHTML="<br>",t==="colbefore"?m.before(v):m.after(v)}),t==="delcol"&&(n.querySelectorAll("tr").forEach(p=>{var m;return(m=p.children[r])==null?void 0:m.remove()}),n.querySelector("td,th")||n.remove()),t==="deltable"&&n.remove(),this.onChange(),this.positionTableHandles()}tableMove(t){this.restoreSel();const e=this.currentCell();if(!e)return;const i=e.parentElement,s=e.closest("table"),n=Array.from(i.children).indexOf(e);if(t==="rowup"){const l=i.previousElementSibling;l&&l.before(i)}if(t==="rowdown"){const l=i.nextElementSibling;l&&l.after(i)}t==="colleft"&&n>0&&s.querySelectorAll("tr").forEach(l=>{const a=l.children[n],d=l.children[n-1];a&&d&&d.before(a)}),t==="colright"&&s.querySelectorAll("tr").forEach(l=>{const a=l.children[n],d=l.children[n+1];a&&d&&d.after(a)});const r=document.createRange();r.selectNodeContents(e),r.collapse(!0);const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(r)),this.saveSel(),this.onChange(),this.positionTableHandles(),this.positionCellMarker()}alignTable(t){const e=this.tblActive;e&&(e.style.marginLeft=t==="left"?"0":"auto",e.style.marginRight=t==="right"?"0":"auto",this.onChange(),this.positionTableHandles())}buildCellFillInto(t){const e=s=>{const n=this.currentCell();if(!n){alert(this.t("nocell"));return}this.setOrClear(n,"background-color",s||""),this.onChange()},i=this.currentCell();this.buildPaletteInto(t,this.cssToHex(i?i.style.backgroundColor:""),e)}cssToHex(t){const e=t.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);return e?"#"+e.slice(1,4).map(i=>(+i).toString(16).padStart(2,"0")).join(""):t}cellFillMenu(t){this.popup(t,e=>this.buildCellFillInto(e),"pop-cellbg")}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,n,r;const o="display:flex;align-items:center;gap:10px;margin:10px 0",l="width:120px;color:#556;flex:none",a="flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit",d=t.querySelector("td,th"),p=t.style.width||"",m=d&&d.style.padding?parseFloat(d.style.padding):"",v=t.style.borderSpacing?parseFloat(t.style.borderSpacing):"",b=t.style.borderWidth?parseFloat(t.style.borderWidth):"",f=t.style.marginLeft,y=t.style.marginRight,C=f==="auto"&&y==="auto"?"center":f==="auto"?"right":y==="auto"&&f==="0"?"left":"";this.dialog(this.t("tablepropsttl"),E=>{const I=(A,j)=>{const Z=document.createElement("div");Z.style.cssText=o;const _=document.createElement("span");_.style.cssText=l,_.textContent=this.t(A),Z.append(_,j),E.appendChild(Z)};e=document.createElement("input"),e.type="text",e.style.cssText=a,e.placeholder="e.g. 600px or 100%",e.value=p,I("tblwidth",e),i=document.createElement("input"),i.type="number",i.min="0",i.style.cssText=a,i.value=String(m),I("tblcellpadding",i),s=document.createElement("input"),s.type="number",s.min="0",s.style.cssText=a,s.value=String(v),I("tblcellspacing",s),n=document.createElement("input"),n.type="number",n.min="0",n.style.cssText=a,n.value=String(b),I("tblborder",n),r=document.createElement("select"),r.style.cssText=a,[["","alignnone"],["left","alignleft"],["center","aligncenter"],["right","alignright"]].forEach(([A,j])=>{const Z=document.createElement("option");Z.value=A,Z.textContent=this.t(j),A===C&&(Z.selected=!0),r.appendChild(Z)}),I("tblalign",r)},[{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:n.value.trim(),align:r.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 n=document.createElement("span");n.style.cssText="width:120px;color:#556;flex:none",n.textContent=e,s.append(n,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,n])=>{const r=document.createElement("option");r.value=s,r.textContent=n,s===e&&(r.selected=!0),i.appendChild(r)}),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 n=document.createElement("label");n.style.cssText="display:flex;align-items:center;gap:6px;cursor:pointer;color:#556";const r=document.createElement("input");return r.type="checkbox",r.checked=!!i,n.append(r,document.createTextNode(this.t("fill"))),s.addEventListener("input",()=>r.checked=!0),e.append(s,n),{wrap:e,color:s,fill:r}}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,n,r;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),n=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"),n),r=this.formBg(t.style.backgroundColor||""),this.formRow(o,this.t("backcolor"),r.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",n.value),this.setOrClear(t,"background-color",r.fill.checked?r.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("…",""),n=>{i=this.formInput(e.style.height,"e.g. 40px"),this.formRow(n,this.t("tblheight"),i),s=this.formBg(e.style.backgroundColor||""),this.formRow(n,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),n=Array.from(i.rows).map(l=>l.cells[s]).filter(Boolean);let r,o;this.dialog(this.t("colprops").replace("…",""),l=>{r=this.formInput(t.style.width,"e.g. 120px / 25%"),this.formRow(l,this.t("tblwidth"),r),o=this.formBg(t.style.backgroundColor||""),this.formRow(l,this.t("backcolor"),o.wrap)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{n.forEach(l=>{this.setOrClear(l,"width",r.value.trim()),this.setOrClear(l,"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
|
+
<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(n=>{const r=document.createElement("button");r.type="button",r.textContent=n.label,n.primary&&(r.className="pri"),r.onclick=n.action,s.querySelector("footer").appendChild(r)}),this.dlgOvl.appendChild(s),this.dlgOvl.addEventListener("mousedown",n=>{n.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=>{var s;(s=t.closest(".dlg"))==null||s.classList.add("dlg-preview");const e=document.createElement("div");e.className="pv-box";const i=this.contentWidth();e.style.cssText=`width:${i>0?Math.round(i):640}px;max-width:100%;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)})}glyphPickerDlg(t,e,i){this.saveSel(),this.dialog(t,s=>{const n=document.createElement("div");n.className="chmap";const l=document.createElement("div");l.className="chtabs";const r=document.createElement("div");r.className="chpanel";const o=document.createElement("div");o.className="chgrid"+(i?" emgrid":""),r.appendChild(o);const a=u=>{l.querySelectorAll("button").forEach((p,m)=>p.classList.toggle("on",m===u)),o.innerHTML="",e[u].chars.forEach(p=>{const m=document.createElement("button");m.type="button",m.textContent=p,m.onclick=()=>{this.closeDlg(),this.exec("insertText",p)},o.appendChild(m)}),r.scrollTop=0};e.forEach((u,p)=>{const m=document.createElement("button");m.type="button",m.textContent=this.t(u.key),m.addEventListener("click",()=>a(p)),l.appendChild(m)}),n.append(l,r),s.appendChild(n),a(0)})}charMap(){this.glyphPickerDlg(this.t("charmap").replace("…",""),li,!1)}emojiMap(){this.glyphPickerDlg(this.t("emoji").replace("…",""),oi,!0)}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(){var e;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())),(e=this.phActive)!=null&&e.closest(".tpl-media")&&t.append(this.ctxBtn(h.video,this.t("quickvideo"),()=>this.swapPlaceholderKind("video"))),t.append(this.ctxSep(),this.ctxBtn(h.trash,this.t("deleteimg"),()=>this.removeImgPlaceholder())),this.positionImgPhCtx())}swapPlaceholderKind(t){const e=t==="video"?this.phActive:this.vphActive;if(!e)return;const i=document.createElement("div");i.innerHTML=t==="video"?this.vidPhHTML():this.imgPhHTML();const s=i.firstElementChild;t==="video"?this.clearImgPlaceholderSel():this.clearVphPlaceholderSel(),e.replaceWith(s),t==="video"?this.selectVphPlaceholder(s):this.selectImgPlaceholder(s),this.onChange()}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 n=e.value.trim(),l=this.phActive;if(!l)return;if(!/^(https?:|data:image\/|blob:)/i.test(n)){e.classList.add("err"),e.focus();return}i.disabled=!0,e.disabled=!0;const r=new Image;r.onload=()=>this.replacePlaceholderWithImage(l,n,""),r.onerror=()=>{i.disabled=!1,e.disabled=!1,e.classList.add("err"),e.focus()},r.src=n};i.addEventListener("click",s),e.addEventListener("input",()=>e.classList.remove("err")),e.addEventListener("keydown",n=>{n.key==="Enter"?(n.preventDefault(),s()):n.key==="Escape"&&(n.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(n=>{this.ed.contains(e)&&this.replacePlaceholderWithImage(e,n,i)}).catch(n=>{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,n,t))})}replacePlaceholderWithImage(t,e,i){const s=document.createElement("img");s.src=e,s.alt="",i&&(s.title=i),t.replaceWith(s),this.stampImageSize(s),this.phActive===t&&this.clearImgPlaceholderSel(),this.refreshState(),this.onChange()}contentWidth(){const t=getComputedStyle(this.ed),e=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0);return Math.max(0,this.ed.clientWidth-e)}insertImageHTML(t,e){const i="fable-img-"+Date.now().toString(36)+Math.random().toString(36).slice(2,6);document.execCommand("insertHTML",!1,`<img id="${i}" src="${t}"${e?` title="${e}"`:""} alt="">`);const s=this.ed.querySelector("#"+i);s&&(s.removeAttribute("id"),this.stampImageSize(s))}stampImageSize(t,e){const i=n=>{e?e(n):n&&this.onChange()},s=()=>{if(!this.ed.contains(t)||t.closest(".tpl-media")||t.getAttribute("width")||t.getAttribute("height")||t.style.width||t.style.height)return i(!1);const n=t.naturalWidth;if(!n)return i(!1);const l=this.contentWidth(),r=Math.round(l>0?Math.min(n,l):n);t.setAttribute("width",String(r)),t.style.width=r+"px",t.style.height="auto",i(!0)};t.complete&&t.naturalWidth?s():(t.addEventListener("load",s,{once:!0}),t.addEventListener("error",()=>i(!1),{once:!0}))}stampExistingImages(){const t=Array.from(this.ed.querySelectorAll("img"));if(!t.length)return;let e=t.length,i=!1;const s=n=>{n&&(i=!0),--e===0&&i&&this.onChange()};t.forEach(n=>this.stampImageSize(n,s))}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 n=t.bottom+scrollY+8;t.bottom+8+i>innerHeight-4&&(n=Math.max(this.ctxMinTop(),t.top+scrollY-i-8)),this.phCtx.style.left=s+"px",this.phCtx.style.top=n+"px"}pickVideo(){this.vidInput.value="",this.vidInput.click()}vidPhHTML(t){return`<div class="img-ph vid-ph"${t?` id="${t}"`:""} contenteditable="false">${h.video}<span>${this.t("dropvideo")}</span></div>`}insertVideoPlaceholder(){this.restoreSel();const t="vid-ph-"+Date.now().toString(36)+Math.random().toString(36).slice(2,6);document.execCommand("insertHTML",!1,this.vidPhHTML(t));const e=this.ed.querySelector("#"+t);e&&(e.removeAttribute("id"),this.selectVphPlaceholder(e)),this.onChange()}clearVphPlaceholderSel(){var t,e;(t=this.vphCtx)==null||t.remove(),this.vphCtx=null,(e=this.vphActive)==null||e.classList.remove("active"),this.vphActive=null}removeVphPlaceholder(){const t=this.vphActive;t&&(this.clearVphPlaceholderSel(),(t.closest(".tpl-media")||t).remove(),this.refreshState(),this.onChange())}selectVphPlaceholder(t){this.vphActive!==t&&(this.clearVphPlaceholderSel(),this.vphActive=t,t.classList.add("active"),this.vphCtx=document.createElement("div"),this.vphCtx.className="imgctx img-ph-ctx",this.vphCtx.dir=this.dir(),document.body.appendChild(this.vphCtx),this.renderVphCtxButtons())}renderVphCtxButtons(){var e;const t=this.vphCtx;t&&(t.innerHTML="",t.append(this.ctxBtn(h.uploadic,this.t("uploadvideo"),()=>{this.vphUploadTarget=this.vphActive,this.pickVideo()}),this.ctxBtn(h.link,this.t("videolink"),()=>this.renderVphCtxUrlInput())),(e=this.vphActive)!=null&&e.closest(".tpl-media")&&t.append(this.ctxBtn(h.image,this.t("quickimage"),()=>this.swapPlaceholderKind("image"))),t.append(this.ctxSep(),this.ctxBtn(h.trash,this.t("deletevideo"),()=>this.removeVphPlaceholder())),this.positionVphCtx())}renderVphCtxUrlInput(){const t=this.vphCtx;if(!t)return;t.innerHTML="";const e=document.createElement("input");e.type="url",e.className="urlinp",e.placeholder=this.t("videourlph");const i=document.createElement("button");i.type="button",i.className="txtbtn",i.textContent=this.t("insertvideo");const s=()=>{const n=e.value.trim(),l=this.vphActive;if(!l)return;if(!/^(https?:|data:video\/|blob:)/i.test(n)){e.classList.add("err"),e.focus();return}const r=this.videoEmbedUrl(n);if(r){this.replacePlaceholderWithEmbed(l,r);return}i.disabled=!0,e.disabled=!0;const o=document.createElement("video");o.preload="metadata",o.onloadedmetadata=()=>this.replacePlaceholderWithVideo(l,n,""),o.onerror=()=>{i.disabled=!1,e.disabled=!1,e.classList.add("err"),e.focus()},o.src=n};i.addEventListener("click",s),e.addEventListener("input",()=>e.classList.remove("err")),e.addEventListener("keydown",n=>{n.key==="Enter"?(n.preventDefault(),s()):n.key==="Escape"&&(n.stopPropagation(),this.renderVphCtxButtons())}),t.append(e,i),this.positionVphCtx(),e.focus()}readVideoFileInto(t,e){if(e.classList.contains("uploading"))return;if(this.videoUploadHandler){this.uploadVideoFile(t,e);return}const i=new FileReader;i.onload=()=>{this.ed.contains(e)&&this.replacePlaceholderWithVideo(e,i.result,t.name.replace(/"/g,""))},i.readAsDataURL(t)}uploadVideoFile(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.videoUploadHandler(t).then(n=>{this.ed.contains(e)&&this.replacePlaceholderWithVideo(e,n,i)}).catch(n=>{var l;this.ed.contains(e)&&(e.classList.remove("uploading"),e.classList.add("upload-error"),s&&(s.textContent=this.t("uploadfailed")),(l=this.onVideoUploadError)==null||l.call(this,n,t))})}replacePlaceholderWithVideo(t,e,i){const s=document.createElement("video");s.controls=!0,s.src=e,i&&(s.title=i),t.replaceWith(s),this.vphActive===t&&this.clearVphPlaceholderSel(),this.refreshState(),this.onChange()}replacePlaceholderWithEmbed(t,e){const i=document.createElement("div");i.innerHTML=this.videoEmbedHTML(e),t.replaceWith(i.firstElementChild),this.vphActive===t&&this.clearVphPlaceholderSel(),this.refreshState(),this.onChange()}positionVphCtx(){if(this.vphActive&&!document.body.contains(this.vphActive)){this.clearVphPlaceholderSel();return}if(!this.vphActive||!this.vphCtx)return;const t=this.vphActive.getBoundingClientRect(),e=this.vphCtx.offsetWidth,i=this.vphCtx.offsetHeight;let s=t.left+scrollX+(t.width-e)/2;s=Math.max(8+scrollX,Math.min(s,scrollX+innerWidth-e-8));let n=t.bottom+scrollY+8;t.bottom+8+i>innerHeight-4&&(n=Math.max(this.ctxMinTop(),t.top+scrollY-i-8)),this.vphCtx.style.left=s+"px",this.vphCtx.style.top=n+"px"}cancelVidHide(){this.vidHideTimer!=null&&(window.clearTimeout(this.vidHideTimer),this.vidHideTimer=null)}clearVidHandles(){var t,e;this.cancelVidHide(),(t=this.vidCtx)==null||t.remove(),this.vidCtx=null,(e=this.vidActive)==null||e.classList.remove("vid-selected"),this.vidActive=null}selectVideo(t){this.vidActive!==t&&(this.clearVidHandles(),this.vidActive=t,t.classList.add("vid-selected"),this.vidCtx=this.buildVideoCtxToolbar(t),this.positionVidCtx())}buildVideoCtxToolbar(t){const e=document.createElement("div");e.className="imgctx",e.dir=this.dir();const i=()=>{var u;const a=this.buildVideoCtxToolbar(t);(u=this.vidCtx)==null||u.replaceWith(a),this.vidCtx=a,this.positionVidCtx()},s=a=>{this.setVideoAlign(t,a),i()},n=t.style.float==="left",l=t.style.float==="right",r=!n&&!l&&t.style.marginLeft==="auto"&&t.style.marginRight==="auto",o=(a,u,p,m)=>{const v=this.ctxBtn(a,u,m);return v.classList.toggle("on",p),v};return e.append(o(h.alignleft,this.t("alignleft"),n,()=>s("left")),o(h.aligncenter,this.t("aligncenter"),r,()=>s("center")),o(h.alignright,this.t("alignright"),l,()=>s("right")),this.ctxSep(),o(h.trash,this.t("deletevideo"),!1,()=>{t.remove(),this.clearVidHandles(),this.onChange()})),e.addEventListener("mousedown",a=>a.preventDefault()),e.addEventListener("mouseenter",()=>this.cancelVidHide()),e.addEventListener("mouseleave",()=>{this.cancelVidHide(),this.vidHideTimer=window.setTimeout(()=>this.clearVidHandles(),250)}),document.body.appendChild(e),e}setVideoAlign(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()}positionVidCtx(){if(!this.vidActive||!document.body.contains(this.vidActive)){this.clearVidHandles();return}const t=this.vidActive.getBoundingClientRect();if(!this.vidCtx)return;const e=this.vidCtx.offsetWidth,i=this.vidCtx.offsetHeight;let s=t.left+scrollX+(t.width-e)/2;s=Math.max(8+scrollX,Math.min(s,scrollX+innerWidth-e-8));let n=t.top+scrollY-i-8;n<this.ctxMinTop()&&(n=t.bottom+scrollY+8),this.vidCtx.style.left=s+"px",this.vidCtx.style.top=n+"px"}videoEmbedUrl(t){let e=t.match(/^https?:\/\/(?:www\.|m\.)?youtube\.com\/watch\?(?:[^\s#]*[?&])?v=([\w-]{5,})/i);return e||(e=t.match(/^https?:\/\/(?:www\.)?(?:youtu\.be|youtube\.com\/(?:embed|shorts|live))\/([\w-]{5,})/i)),e?"https://www.youtube.com/embed/"+e[1]:(e=t.match(/^https?:\/\/(?:www\.)?vimeo\.com\/(\d+)/i),e?"https://player.vimeo.com/video/"+e[1]:(e=t.match(/^https?:\/\/(?:www\.)?dailymotion\.com\/video\/(\w+)/i),e?"https://www.dailymotion.com/embed/video/"+e[1]:null))}videoEmbedHTML(t,e=560,i=314){return`<span class="video-embed" contenteditable="false"><iframe src="${t}" width="${e}" height="${i}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></span>`}videoDlg(){this.saveSel();let t,e,i,s,n,l;const r=(a,u)=>{const p=document.createElement("div");p.className="dfield";const m=document.createElement("label");return m.textContent=this.t(a),p.append(m,u),p},o=()=>{const a=document.createElement("input");return a.type="url",a};this.dialog(this.t("videodlgttl"),a=>{const u=document.createElement("div");u.className="dtabs";const p=[],m=(f,y)=>{const C=document.createElement("button");C.type="button",C.textContent=this.t(f);const E=document.createElement("div");E.className="dtabpanel",y(E);const I=p.length;p.push(E),C.addEventListener("click",()=>v(I)),u.appendChild(C)},v=f=>{u.querySelectorAll("button").forEach((y,C)=>y.classList.toggle("on",C===f)),p.forEach((y,C)=>y.style.display=C===f?"":"none")};m("vidgeneral",f=>{t=o(),t.placeholder=this.t("videourlph");const y=document.createElement("div");y.className="drow";const C=document.createElement("button");C.type="button",C.className="txtbtn",C.textContent=this.t("uploadvideo");const E=document.createElement("input");E.type="file",E.accept=this.options.videoFileTypes.join(","),E.style.display="none",C.addEventListener("click",()=>{E.value="",E.click()}),E.addEventListener("change",()=>{var Z;const A=(Z=E.files)==null?void 0:Z[0];if(!A)return;C.disabled=!0,C.textContent=this.t("uploading");const j=_=>{t.value=_,C.disabled=!1,C.textContent=this.t("uploadvideo")};if(this.videoUploadHandler)this.videoUploadHandler(A).then(j).catch(_=>{var et;C.disabled=!1,C.textContent=this.t("uploadfailed"),(et=this.onVideoUploadError)==null||et.call(this,_,A)});else{const _=new FileReader;_.onload=()=>j(_.result),_.readAsDataURL(A)}}),y.append(t,C,E),t.style.flex="1",f.appendChild(r("vidsource",y));const I=document.createElement("div");I.className="drow",e=document.createElement("input"),e.type="number",e.value="560",i=document.createElement("input"),i.type="number",i.value="314",I.append(r("tblwidth",e),r("tblheight",i)),f.appendChild(I)}),m("vidembed",f=>{const y=document.createElement("p");y.textContent=this.t("vidembedhint"),y.style.cssText="margin:0 0 8px;color:#556;font-size:13.5px",s=document.createElement("textarea"),s.style.cssText="width:100%;box-sizing:border-box;height:160px",f.append(y,s)}),m("vidadvanced",f=>{n=o(),l=o(),f.append(r("vidaltsource",n),r("vidposter",l))});const b=document.createElement("div");b.className="dtabbody",p.forEach(f=>b.appendChild(f)),a.append(u,b),v(0),setTimeout(()=>t.focus(),0)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{const a=s.value.trim(),u=t.value.trim(),p=parseInt(e.value,10)||560,m=parseInt(i.value,10)||314;if(this.closeDlg(),!a&&!u)return;if(this.restoreSel(),a){document.execCommand("insertHTML",!1,`<span class="video-embed" contenteditable="false">${a}</span>`),this.onChange();return}const v=this.videoEmbedUrl(u);if(v)document.execCommand("insertHTML",!1,this.videoEmbedHTML(v,p,m));else{const b=n.value.trim(),f=l.value.trim();document.execCommand("insertHTML",!1,`<video controls width="${p}" height="${m}"${f?` poster="${this.escapeAttr(f)}"`:""}><source src="${this.escapeAttr(u)}">${b?`<source src="${this.escapeAttr(b)}">`:""}</video>`)}this.onChange()}}])}escapeAttr(t){return t.replace(/&/g,"&").replace(/"/g,""")}escHtml(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}closestInlineCode(){const t=window.getSelection(),e=t&&this.ed.contains(t.anchorNode)?t.anchorNode:null;if(!e)return null;const i=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement,s=i==null?void 0:i.closest("code");return s&&this.ed.contains(s)&&!s.closest("pre")?s:null}toggleInlineCode(){this.restoreSel();const t=window.getSelection();if(!t||!t.rangeCount)return;const e=this.closestInlineCode();if(e){const i=e.firstChild,s=e.lastChild;for(;e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);if(e.remove(),i&&s){const n=document.createRange();n.setStartBefore(i),n.setEndAfter(s),t.removeAllRanges(),t.addRange(n)}}else{const i=t.getRangeAt(0);if(i.collapsed||this.closestBlock(i.startContainer)!==this.closestBlock(i.endContainer))return;const s=document.createElement("code");s.appendChild(i.extractContents()),i.insertNode(s);const n=document.createRange();n.selectNodeContents(s),t.removeAllRanges(),t.addRange(n)}this.saveSel(),this.refreshState(),this.onChange()}tryCodeTyping(t){var u;const e=window.getSelection();if(!e||!e.isCollapsed||!e.anchorNode)return;const i=e.anchorNode;if(i.nodeType!==Node.TEXT_NODE||!this.ed.contains(i)||(u=i.parentElement)!=null&&u.closest("code, pre"))return;const n=(i.textContent||"").slice(0,e.anchorOffset).match(/(?:^|[^`])`([^`]+)$/);if(!n)return;const l=n[1];if(/^\s|\s$/.test(l))return;t.preventDefault();const r=document.createRange();r.setStart(i,e.anchorOffset-l.length-1),r.setEnd(i,e.anchorOffset),r.deleteContents();const o=document.createElement("code");o.textContent=l,r.insertNode(o);const a=document.createRange();a.setStartAfter(o),a.collapse(!0),e.removeAllRanges(),e.addRange(a),this.saveSel(),this.onChange()}dlgSelect(t,e){var o;let i=e;const s=document.createElement("div");s.className="dsel";const n=document.createElement("button");n.type="button",n.className="dsel-btn";const l=document.createElement("span");l.className="lbl",l.textContent=((o=t.find(([a])=>a===e))==null?void 0:o[1])||"",n.append(l),n.insertAdjacentHTML("beforeend",h.chev);const r=document.createElement("div");return r.className="dsel-list",t.forEach(([a,u])=>{const p=document.createElement("button");p.type="button",p.textContent=u,p.classList.toggle("on",a===i),p.addEventListener("click",()=>{i=a,l.textContent=u,r.querySelectorAll("button").forEach(m=>m.classList.toggle("on",m===p)),s.classList.remove("open"),n.focus()}),r.appendChild(p)}),n.addEventListener("click",()=>{var a;s.classList.toggle("open"),s.classList.contains("open")&&((a=r.querySelector(".on"))==null||a.scrollIntoView({block:"nearest"}))}),s.addEventListener("focusout",a=>{s.contains(a.relatedTarget)||s.classList.remove("open")}),s.addEventListener("keydown",a=>{a.key==="Escape"&&s.classList.contains("open")&&(a.stopPropagation(),s.classList.remove("open"),n.focus())}),s.append(n,r),{el:s,value:()=>i}}codeDlg(t){this.saveSel();let e,i;this.dialog(this.t("codedlgttl"),s=>{var r;const n=document.createElement("div");n.className="dfield";const l=document.createElement("label");l.textContent=this.t("codelang"),e=this.dlgSelect(se,(t==null?void 0:t.dataset.lang)||"plain"),n.append(l,e.el),i=document.createElement("textarea"),i.className="code-input",i.spellcheck=!1,i.value=((r=t==null?void 0:t.querySelector("code"))==null?void 0:r.textContent)||"",i.placeholder="const answer = 42;",s.append(n,i),setTimeout(()=>i.focus(),0)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{var r;const s=i.value.replace(/\s+$/,""),n=e.value(),l=((r=se.find(([o])=>o===n))==null?void 0:r[1])||n;if(this.closeDlg(),!!s.trim()){if(t){t.dataset.lang=n,t.setAttribute("data-lang-label",l);const o=t.querySelector("code")||t;o.textContent=s,this.clearCodeSel(),this.onChange();return}this.restoreSel(),document.execCommand("insertHTML",!1,`<pre class="code-block" contenteditable="false" data-lang="${n}" data-lang-label="${this.escapeAttr(l)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`),this.onChange()}}}])}clearCodeSel(){var t,e;(t=this.codeCtx)==null||t.remove(),this.codeCtx=null,(e=this.codeActive)==null||e.classList.remove("code-selected"),this.codeActive=null}selectCodeEl(t){this.codeActive!==t&&(this.clearCodeSel(),this.codeActive=t,t.classList.add("code-selected"),this.codeCtx=this.buildCodeCtxToolbar(t),this.positionCodeCtx())}buildCodeCtxToolbar(t){const e=document.createElement("div");return e.className="imgctx",e.dir=this.dir(),e.append(this.ctxBtn(h.editic,this.t("editcode"),()=>this.codeDlg(t)),this.ctxBtn(h.copyic,this.t("copycode"),()=>this.copyCodeBlock(t)),this.ctxSep(),this.ctxBtn(h.trash,this.t("deletecode"),()=>{t.remove(),this.clearCodeSel(),this.onChange()})),e.addEventListener("mousedown",i=>i.preventDefault()),document.body.appendChild(e),e}copyCodeBlock(t){var s,n;const e=((s=t.querySelector("code"))==null?void 0:s.textContent)??t.textContent??"";if((n=navigator.clipboard)!=null&&n.writeText){navigator.clipboard.writeText(e).catch(()=>{});return}const i=document.createElement("textarea");i.value=e,document.body.appendChild(i),i.select(),document.execCommand("copy"),i.remove()}positionCodeCtx(){if(!this.codeActive||!document.body.contains(this.codeActive)){this.clearCodeSel();return}const t=this.codeActive.getBoundingClientRect();if(!this.codeCtx)return;const e=this.codeCtx.offsetWidth,i=this.codeCtx.offsetHeight;let s=t.left+scrollX+(t.width-e)/2;s=Math.max(8+scrollX,Math.min(s,scrollX+innerWidth-e-8));let n=t.top+scrollY-i-8;n<this.ctxMinTop()&&(n=t.bottom+scrollY+8),this.codeCtx.style.left=s+"px",this.codeCtx.style.top=n+"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=o=>`<span class="pv-l" style="width:${o}%"></span>`,n=o=>`<span class="pv-col">${o}</span>`,l=o=>`<span class="pv-row">${o}</span>`,r=n(i+s(100)+s(88));return t==="img-left"?`<span class="pv">${l(e+r)}${s(100)}${s(72)}</span>`:t==="img-right"?`<span class="pv">${l(r+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",Tt.forEach(s=>{const n=document.createElement("button");n.type="button",n.className="tpltile",n.title=this.t(Et[s]),n.innerHTML=this.tplPreviewHTML(s)+`<span class="tpllbl">${this.t(Et[s])}</span>`,n.addEventListener("click",()=>{this.closePop(),this.insertTemplate(s),e==null||e()}),i.appendChild(n)}),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="",Tt.forEach(i=>{const s=this.ctxBtn(Ni[i],this.t(Et[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;Tt.forEach(n=>e.classList.remove("tpl-"+n)),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 n=t.top+scrollY-i-8;n<this.ctxMinTop()&&(n=t.bottom+scrollY+8),this.tplCtx.style.left=s+"px",this.tplCtx.style.top=n+"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,n;(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,(n=this.tblActive)==null||n.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 u;const t=this.tblOpMarkKind,e=t?this.currentCell():null;if(!t||!e||!this.tblActive||e.closest("table")!==this.tblActive){(u=this.tblOpMark)==null||u.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(),n=e.parentElement.getBoundingClientRect(),l=t==="row"?n.left:s.left,r=t==="row"?n.top:i.top,o=t==="row"?n.width:s.width,a=t==="row"?n.height:i.height;this.tblOpMark.style.left=l+scrollX+"px",this.tblOpMark.style.top=r+scrollY+"px",this.tblOpMark.style.width=o+"px",this.tblOpMark.style.height=a+"px"}ctxMinTop(){return Math.max(scrollY+4,this.ed.getBoundingClientRect().top+scrollY-2)}ctxBtn(t,e,i,s){const n=document.createElement("button");return n.type="button",n.title=e,n.innerHTML=t,s&&(n.dataset.id=s),n.addEventListener("mousedown",l=>l.preventDefault()),n.addEventListener("click",i),n}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=(s,n)=>(s.addEventListener("mouseenter",()=>this.setOpTarget(n)),s.addEventListener("mouseleave",()=>this.setOpTarget(null)),s),i=this.ctxBtn(h.palette,this.t("cellbg"),()=>this.cellFillMenu(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.moverowup,this.t("moverowup"),()=>this.tableMove("rowup")),"row"),e(this.ctxBtn(h.moverowdown,this.t("moverowdown"),()=>this.tableMove("rowdown")),"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.movecolleft,this.t("movecolleft"),()=>this.tableMove("colleft")),"col"),e(this.ctxBtn(h.movecolright,this.t("movecolright"),()=>this.tableMove("colright")),"col"),e(this.ctxBtn(h.coldelete,this.t("delcol"),()=>this.tableOp("delcol")),"col"),this.ctxSep(),this.ctxBtn(h.alignleft,this.t("tblalignleft"),()=>this.alignTable("left")),this.ctxBtn(h.aligncenter,this.t("tblaligncenter"),()=>this.alignTable("center")),this.ctxBtn(h.alignright,this.t("tblalignright"),()=>this.alignTable("right")),this.ctxSep(),i,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,n=e.right+scrollX,l=e.bottom+scrollY;if(this.tblCorner&&(this.tblCorner.style.top=l-5+"px",this.tblCorner.style.left=(t?s-5:n-5)+"px",this.tblCorner.style.cursor=t?"nesw-resize":"nwse-resize"),this.tblCtx){const o=this.tblCtx.offsetWidth,a=this.tblCtx.offsetHeight;let u=s+(n-s)/2-o/2;u=Math.max(8+scrollX,Math.min(u,scrollX+innerWidth-o-8));let p=i-a-8;p<this.ctxMinTop()&&(p=l+8),this.tblCtx.style.left=u+"px",this.tblCtx.style.top=p+"px"}this.tblColBars.forEach(o=>o.remove()),this.tblColBars=[];const r=this.tblActive.rows[0];if(r)for(let o=0;o<r.cells.length-1;o++){const a=r.cells[o].getBoundingClientRect(),u=(t?a.left:a.right)+scrollX,p=document.createElement("div");p.className="tbl-colbar",p.style.top=i+"px",p.style.left=u+"px",p.style.height=l-i+"px",document.body.appendChild(p),p.addEventListener("mousedown",m=>this.startColBarDrag(m,o)),this.tblColBars.push(p)}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,n=e.getBoundingClientRect().width;e.style.tableLayout=e.style.tableLayout||"fixed",this.withNoTextSelect(l=>{const r=a=>{const u=i?-(a.clientX-s):a.clientX-s;e.style.width=Math.max(60,Math.round(n+u))+"px",this.positionTableHandles()},o=()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o),l(),this.onChange()};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)})}startColBarDrag(t,e){t.preventDefault(),t.stopPropagation();const i=this.tblActive;if(!i)return;const s=this.ed.getAttribute("dir")==="rtl",n=Array.from(i.rows),l=n.map(p=>p.cells[e]).filter(Boolean),r=n.map(p=>p.cells[e+1]).filter(Boolean);if(!l.length||!r.length)return;const o=t.clientX,a=l[0].getBoundingClientRect().width,u=r[0].getBoundingClientRect().width;i.style.tableLayout="fixed",this.withNoTextSelect(p=>{const m=b=>{const f=(s?-1:1)*(b.clientX-o);l.forEach(y=>y.style.width=Math.max(24,Math.round(a+f))+"px"),r.forEach(y=>y.style.width=Math.max(24,Math.round(u-f))+"px"),this.positionTableHandles()},v=()=>{window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",v),p(),this.onChange()};window.addEventListener("mousemove",m),window.addEventListener("mouseup",v)})}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=Di.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 u;const a=this.buildImageCtxToolbar(t);(u=this.imgCtx)==null||u.replaceWith(a),this.imgCtx=a,this.positionImageHandles()},s=a=>{this.setImageAlign(t,a),i()},n=t.style.float==="left",l=t.style.float==="right",r=!n&&!l&&t.style.marginLeft==="auto"&&t.style.marginRight==="auto",o=(a,u,p,m)=>{const v=this.ctxBtn(a,u,m);return v.classList.toggle("on",p),v};return e.append(o(h.alignleft,this.t("alignleft"),n,()=>s("left")),o(h.aligncenter,this.t("aligncenter"),r,()=>s("center")),o(h.alignright,this.t("alignright"),l,()=>s("right")),this.ctxSep(),o(h.rotateleft,this.t("rotateleft"),!1,()=>{this.rotateImage(t,-90),i()}),o(h.rotateright,this.t("rotateright"),!1,()=>{this.rotateImage(t,90),i()}),this.ctxSep(),o(h.fliphorizontal,this.t("fliphorizontal"),t.dataset.flipx==="1",()=>{this.flipImage(t,"x"),i()}),o(h.flipvertical,this.t("flipvertical"),t.dataset.flipy==="1",()=>{this.flipImage(t,"y"),i()}),this.ctxSep(),o(h.trash,this.t("deleteimg"),!1,()=>{const a=t.closest(".tpl-media");a&&this.ed.contains(a)?t.outerHTML=this.imgPhHTML():t.remove(),this.clearImageHandles(),this.onChange()})),e.addEventListener("mousedown",a=>a.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,n=t.bottom+scrollY,l={nw:[i,e],ne:[s,e],sw:[i,n],se:[s,n]};if(this.imgHandles.forEach(r=>{const[o,a]=l[r.dataset.corner];r.style.left=o-5+"px",r.style.top=a-5+"px"}),this.imgCtx){const r=this.imgCtx.offsetWidth,o=this.imgCtx.offsetHeight;let a=i+(s-i)/2-r/2;a=Math.max(8+scrollX,Math.min(a,scrollX+innerWidth-r-8));let u=e-o-8;u<this.ctxMinTop()&&(u=n+8),this.imgCtx.style.left=a+"px",this.imgCtx.style.top=u+"px"}}startImageResizeDrag(t,e){t.preventDefault();const i=this.imgActive;if(!i)return;this.cancelImgHide();const s=t.clientX,n=i.getBoundingClientRect().width,l=e==="nw"||e==="sw"?-1:1;this.withNoTextSelect(r=>{const o=u=>{i.style.width=Math.max(24,Math.round(n+l*(u.clientX-s)))+"px",i.style.height="auto",this.positionImageHandles()},a=()=>{window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a),r();const u=parseInt(i.style.width,10);u>0&&!i.closest(".tpl-media")&&(i.setAttribute("width",String(u)),i.removeAttribute("height")),this.onChange()};window.addEventListener("mousemove",o),window.addEventListener("mouseup",a)})}toggleBlock(t){const e=this.currentBlock()===t;this.exec("formatBlock",e?"<p>":"<"+t+">"),t==="blockquote"&&e&&this.unwrapBlockquote()}unwrapBlockquote(){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==="BLOCKQUOTE"){const i=e,s=i.parentNode;for(;i.firstChild;)s.insertBefore(i.firstChild,i);s.removeChild(i),this.onChange();return}e=e.parentNode}}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 r;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"));(r=i.querySelector("svg"))==null||r.insertAdjacentHTML("afterend",'<span class="colorbar" data-cb="back"></span>');const s=this.ctxBtn(h.caseic,this.t("changecase"),()=>this.caseMenu(s)),n=this.ctxBtn(h.lineheight,this.t("lineheight"),()=>this.lineHeightMenu(n)),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(h.inlinecodeic,this.t("code"),()=>this.toggleInlineCode(),"code"),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,n,l),t.addEventListener("mousedown",o=>o.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,n=e.right+scrollX,l=e.bottom+scrollY,r=this.selCtx.offsetWidth,o=this.selCtx.offsetHeight;let a=s+(n-s)/2-r/2;a=Math.max(8+scrollX,Math.min(a,scrollX+innerWidth-r-8));let u=i-o-8;u<this.ctxMinTop()&&(u=l+8),this.selCtx.style.left=a+"px",this.selCtx.style.top=u+"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";let e=t.anchorNode;for(;e&&e!==this.ed;){if(e.nodeType===1&&e.tagName==="BLOCKQUOTE")return"blockquote";e=e.parentNode}const i=this.closestBlock(t.anchorNode);return i?i.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 o,a,u;const t=window.getSelection(),e=t?this.ed.contains(t.anchorNode):!1,i=this.currentBlock();[this.toolbar,this.selCtx].filter(Boolean).forEach(p=>{["bold","italic","underline","strikeThrough","justifyLeft","justifyCenter","justifyRight","justifyFull","insertOrderedList","insertUnorderedList"].forEach(v=>{const b=p.querySelector(`[data-id=${v}]`);b&&b.classList.toggle("on",e&&document.queryCommandState(v))}),["h2","h3","blockquote"].forEach(v=>{const b=p.querySelector(`[data-id=${v}]`);b&&b.classList.toggle("on",e&&i===v)});const m=p.querySelector("[data-id=code]");m&&m.classList.toggle("on",e&&!!this.closestInlineCode())});const n=t?this.closestBlock(t.anchorNode):null,l=((o=n==null?void 0:n.closest("[dir]"))==null?void 0:o.getAttribute("dir"))||this.ed.getAttribute("dir")||this.dir();(a=this.toolbar.querySelector("[data-id=ltr]"))==null||a.classList.toggle("on",e&&l==="ltr"),(u=this.toolbar.querySelector("[data-id=rtl]"))==null||u.classList.toggle("on",e&&l==="rtl");const r=(p,m,v)=>{const b=this.toolbar.querySelector(`[data-id=${p}] .lbl`);b&&(b.textContent=m||v||"",b.classList.toggle("empty",!m))};r("fontsel",this.currentFont()),r("sizesel",this.currentSize().replace("px","")),e&&r("blocksel",ne.some(p=>p[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(n=>n.type.startsWith("image/"));if(s&&!i){const n=new FileReader;n.onload=()=>{this.insertImageHTML(n.result),this.onChange()},n.readAsDataURL(s.getAsFile());return}if(!i){const n=e.getData("text/plain"),l=/^\S+$/.test(n.trim())?this.videoEmbedUrl(n.trim()):null;if(l){document.execCommand("insertHTML",!1,this.videoEmbedHTML(l)),this.onChange();return}}i?this.pasteRichHTML(i,e,s):(document.execCommand("insertHTML",!1,yi(e.getData("text/plain"))),this.onChange())}pasteRichHTML(t,e,i){let s=[];const n=e.getData("text/rtf");if(n){const l=ki(t,n);t=l.html,s=l.injected}if(i&&Ai(t)===1){const l=i.getAsFile();if(l){const r=t;this.saveSel();const o=new FileReader;o.onload=()=>{const a=fe(r,[o.result]);this.finishRichPaste(a.html,s.concat(a.injected),!0)},o.onerror=()=>this.finishRichPaste(r,s,!0),o.readAsDataURL(l);return}}this.finishRichPaste(t,s)}finishRichPaste(t,e,i=!1){if(!this.imageUploadHandler||!e.length){this.insertPastedHTML(t,i);return}const s=this.imageUploadHandler,n=e.filter((l,r)=>e.indexOf(l)===r);i||this.saveSel(),Promise.all(n.map((l,r)=>{const o=Hi(l,"pasted-image-"+(r+1));return o?s(o).catch(a=>{var u;return(u=this.onImageUploadError)==null||u.call(this,a,o),l}):Promise.resolve(l)})).then(l=>{let r=t;n.forEach((o,a)=>{l[a]!==o&&(r=r.split(o).join(l[a]))}),this.insertPastedHTML(r,!0)})}insertPastedHTML(t,e=!1){e&&this.restoreSel(),document.execCommand("insertHTML",!1,bi(t,this.dir())),e&&this.saveSel(),this.onChange()}initUI(){this.closePop(),this.closeDlg(),this.clearTableHandles(),this.clearImgPlaceholderSel(),this.clearVphPlaceholderSel(),this.clearVidHandles(),this.clearCodeSel(),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.TBR_COLLAPSE_MAX=992,W);const be=N.forwardRef(({value:d,defaultValue:t,onChange:e,onReady:i,className:s,style:n,...l},r)=>{const o=N.useRef(null),a=N.useRef(null),u=N.useRef(!1),p=N.useRef(d??t),m=N.useRef(null),v=N.useRef(e),b=N.useRef(i);return v.current=e,b.current=i,N.useImperativeHandle(r,()=>({getContent:()=>{var f;return((f=a.current)==null?void 0:f.getContent())??""},getContentForEmail:()=>{var f;return((f=a.current)==null?void 0:f.getContentForEmail())??""},setContent:f=>{var y;return(y=a.current)==null?void 0:y.setContent(f)},insertContent:f=>{var y;return(y=a.current)==null?void 0:y.insertContent(f)},setLanguage:f=>{var y;return(y=a.current)==null?void 0:y.setLanguage(f)},focus:()=>{var f;return(f=a.current)==null?void 0:f.focus()},destroy:()=>{var f;return(f=a.current)==null?void 0:f.destroy()},importWordFile:f=>{var y;return((y=a.current)==null?void 0:y.importWordFile(f))??Promise.resolve()},restoreDraft:()=>{var f;return((f=a.current)==null?void 0:f.restoreDraft())??!1},getRevisions:()=>{var f;return((f=a.current)==null?void 0:f.getRevisions())??[]}})),N.useEffect(()=>{if(!o.current)return;const f=new is({target:o.current,initialContent:p.current,onChange:y=>{var C;u.current=!0,p.current=y,(C=v.current)==null||C.call(v,y)},onReady:y=>{var C;return(C=b.current)==null?void 0:C.call(b,y)},...l});return a.current=f,()=>{f.destroy(),a.current=null}},[]),N.useEffect(()=>{var f,y;if(d!==void 0&&d!==p.current){if(u.current){u.current=!1;return}if((f=o.current)!=null&&f.contains(document.activeElement)){m.current=d;return}p.current=d,(y=a.current)==null||y.setContent(d)}},[d]),N.useEffect(()=>{const f=o.current;if(!f)return;const y=C=>{var A;if(m.current===null)return;const E=C.relatedTarget;if(E&&f.contains(E))return;const I=m.current;m.current=null,p.current=I,(A=a.current)==null||A.setContent(I)};return f.addEventListener("focusout",y),()=>f.removeEventListener("focusout",y)},[]),N.useEffect(()=>{var f;l.language&&((f=a.current)==null||f.setLanguage(l.language))},[l.language]),Ge.jsx("div",{ref:o,className:s,style:n})});be.displayName="FableEditor";exports.FableEditor=be;
|
|
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=>{var s;(s=t.closest(".dlg"))==null||s.classList.add("dlg-preview");const e=document.createElement("div");e.className="pv-box";const i=this.contentWidth();e.style.cssText=`width:${i>0?Math.round(i):640}px;max-width:100%;max-height:52vh;overflow:auto;box-sizing:content-box;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)})}glyphPickerDlg(t,e,i){this.saveSel(),this.dialog(t,s=>{const n=document.createElement("div");n.className="chmap";const r=document.createElement("div");r.className="chtabs";const o=document.createElement("div");o.className="chpanel";const l=document.createElement("div");l.className="chgrid"+(i?" emgrid":""),o.appendChild(l);const a=d=>{r.querySelectorAll("button").forEach((p,m)=>p.classList.toggle("on",m===d)),l.innerHTML="",e[d].chars.forEach(p=>{const m=document.createElement("button");m.type="button",m.textContent=p,m.onclick=()=>{this.closeDlg(),this.exec("insertText",p)},l.appendChild(m)}),o.scrollTop=0};e.forEach((d,p)=>{const m=document.createElement("button");m.type="button",m.textContent=this.t(d.key),m.addEventListener("click",()=>a(p)),r.appendChild(m)}),n.append(r,o),s.appendChild(n),a(0)})}charMap(){this.glyphPickerDlg(this.t("charmap").replace("…",""),li,!1)}emojiMap(){this.glyphPickerDlg(this.t("emoji").replace("…",""),oi,!0)}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(){var e;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())),(e=this.phActive)!=null&&e.closest(".tpl-media")&&t.append(this.ctxBtn(h.video,this.t("quickvideo"),()=>this.swapPlaceholderKind("video"))),t.append(this.ctxSep(),this.ctxBtn(h.trash,this.t("deleteimg"),()=>this.removeImgPlaceholder())),this.positionImgPhCtx())}swapPlaceholderKind(t){const e=t==="video"?this.phActive:this.vphActive;if(!e)return;const i=document.createElement("div");i.innerHTML=t==="video"?this.vidPhHTML():this.imgPhHTML();const s=i.firstElementChild;t==="video"?this.clearImgPlaceholderSel():this.clearVphPlaceholderSel(),e.replaceWith(s),t==="video"?this.selectVphPlaceholder(s):this.selectImgPlaceholder(s),this.onChange()}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 n=e.value.trim(),r=this.phActive;if(!r)return;if(!/^(https?:|data:image\/|blob:)/i.test(n)){e.classList.add("err"),e.focus();return}i.disabled=!0,e.disabled=!0;const o=new Image;o.onload=()=>this.replacePlaceholderWithImage(r,n,""),o.onerror=()=>{i.disabled=!1,e.disabled=!1,e.classList.add("err"),e.focus()},o.src=n};i.addEventListener("click",s),e.addEventListener("input",()=>e.classList.remove("err")),e.addEventListener("keydown",n=>{n.key==="Enter"?(n.preventDefault(),s()):n.key==="Escape"&&(n.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(n=>{this.ed.contains(e)&&this.replacePlaceholderWithImage(e,n,i)}).catch(n=>{var r;this.ed.contains(e)&&(e.classList.remove("uploading"),e.classList.add("upload-error"),s&&(s.textContent=this.t("uploadfailed")),(r=this.onImageUploadError)==null||r.call(this,n,t))})}replacePlaceholderWithImage(t,e,i){const s=document.createElement("img");s.src=e,s.alt="",i&&(s.title=i),t.replaceWith(s),this.stampImageSize(s),this.phActive===t&&this.clearImgPlaceholderSel(),this.refreshState(),this.onChange()}contentWidth(){const t=getComputedStyle(this.ed),e=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0);return Math.max(0,this.ed.clientWidth-e)}insertImageHTML(t,e){const i="fable-img-"+Date.now().toString(36)+Math.random().toString(36).slice(2,6);document.execCommand("insertHTML",!1,`<img id="${i}" src="${t}"${e?` title="${e}"`:""} alt="">`);const s=this.ed.querySelector("#"+i);s&&(s.removeAttribute("id"),this.stampImageSize(s))}stampImageSize(t,e){const i=n=>{e?e(n):n&&this.onChange()},s=()=>{if(!this.ed.contains(t)||t.closest(".tpl-media")||t.getAttribute("width")||t.getAttribute("height")||t.style.width||t.style.height)return i(!1);const n=t.naturalWidth;if(!n)return i(!1);const r=this.contentWidth(),o=Math.round(r>0?Math.min(n,r):n);t.setAttribute("width",String(o)),t.style.width=o+"px",t.style.height="auto",i(!0)};t.complete&&t.naturalWidth?s():(t.addEventListener("load",s,{once:!0}),t.addEventListener("error",()=>i(!1),{once:!0}))}stampExistingImages(){const t=Array.from(this.ed.querySelectorAll("img"));if(!t.length)return;let e=t.length,i=!1;const s=n=>{n&&(i=!0),--e===0&&i&&this.onChange()};t.forEach(n=>this.stampImageSize(n,s))}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 n=t.bottom+scrollY+8;t.bottom+8+i>innerHeight-4&&(n=Math.max(this.ctxMinTop(),t.top+scrollY-i-8)),this.phCtx.style.left=s+"px",this.phCtx.style.top=n+"px"}pickVideo(){this.vidInput.value="",this.vidInput.click()}vidPhHTML(t){return`<div class="img-ph vid-ph"${t?` id="${t}"`:""} contenteditable="false">${h.video}<span>${this.t("dropvideo")}</span></div>`}insertVideoPlaceholder(){this.restoreSel();const t="vid-ph-"+Date.now().toString(36)+Math.random().toString(36).slice(2,6);document.execCommand("insertHTML",!1,this.vidPhHTML(t));const e=this.ed.querySelector("#"+t);e&&(e.removeAttribute("id"),this.selectVphPlaceholder(e)),this.onChange()}clearVphPlaceholderSel(){var t,e;(t=this.vphCtx)==null||t.remove(),this.vphCtx=null,(e=this.vphActive)==null||e.classList.remove("active"),this.vphActive=null}removeVphPlaceholder(){const t=this.vphActive;t&&(this.clearVphPlaceholderSel(),(t.closest(".tpl-media")||t).remove(),this.refreshState(),this.onChange())}selectVphPlaceholder(t){this.vphActive!==t&&(this.clearVphPlaceholderSel(),this.vphActive=t,t.classList.add("active"),this.vphCtx=document.createElement("div"),this.vphCtx.className="imgctx img-ph-ctx",this.vphCtx.dir=this.dir(),document.body.appendChild(this.vphCtx),this.renderVphCtxButtons())}renderVphCtxButtons(){var e;const t=this.vphCtx;t&&(t.innerHTML="",t.append(this.ctxBtn(h.uploadic,this.t("uploadvideo"),()=>{this.vphUploadTarget=this.vphActive,this.pickVideo()}),this.ctxBtn(h.link,this.t("videolink"),()=>this.renderVphCtxUrlInput())),(e=this.vphActive)!=null&&e.closest(".tpl-media")&&t.append(this.ctxBtn(h.image,this.t("quickimage"),()=>this.swapPlaceholderKind("image"))),t.append(this.ctxSep(),this.ctxBtn(h.trash,this.t("deletevideo"),()=>this.removeVphPlaceholder())),this.positionVphCtx())}renderVphCtxUrlInput(){const t=this.vphCtx;if(!t)return;t.innerHTML="";const e=document.createElement("input");e.type="url",e.className="urlinp",e.placeholder=this.t("videourlph");const i=document.createElement("button");i.type="button",i.className="txtbtn",i.textContent=this.t("insertvideo");const s=()=>{const n=e.value.trim(),r=this.vphActive;if(!r)return;if(!/^(https?:|data:video\/|blob:)/i.test(n)){e.classList.add("err"),e.focus();return}const o=this.videoEmbedUrl(n);if(o){this.replacePlaceholderWithEmbed(r,o);return}i.disabled=!0,e.disabled=!0;const l=document.createElement("video");l.preload="metadata",l.onloadedmetadata=()=>this.replacePlaceholderWithVideo(r,n,""),l.onerror=()=>{i.disabled=!1,e.disabled=!1,e.classList.add("err"),e.focus()},l.src=n};i.addEventListener("click",s),e.addEventListener("input",()=>e.classList.remove("err")),e.addEventListener("keydown",n=>{n.key==="Enter"?(n.preventDefault(),s()):n.key==="Escape"&&(n.stopPropagation(),this.renderVphCtxButtons())}),t.append(e,i),this.positionVphCtx(),e.focus()}readVideoFileInto(t,e){if(e.classList.contains("uploading"))return;if(this.videoUploadHandler){this.uploadVideoFile(t,e);return}const i=new FileReader;i.onload=()=>{this.ed.contains(e)&&this.replacePlaceholderWithVideo(e,i.result,t.name.replace(/"/g,""))},i.readAsDataURL(t)}uploadVideoFile(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.videoUploadHandler(t).then(n=>{this.ed.contains(e)&&this.replacePlaceholderWithVideo(e,n,i)}).catch(n=>{var r;this.ed.contains(e)&&(e.classList.remove("uploading"),e.classList.add("upload-error"),s&&(s.textContent=this.t("uploadfailed")),(r=this.onVideoUploadError)==null||r.call(this,n,t))})}replacePlaceholderWithVideo(t,e,i){const s=document.createElement("video");s.controls=!0,s.src=e,i&&(s.title=i),t.replaceWith(s),this.vphActive===t&&this.clearVphPlaceholderSel(),this.refreshState(),this.onChange()}replacePlaceholderWithEmbed(t,e){const i=document.createElement("div");i.innerHTML=this.videoEmbedHTML(e),t.replaceWith(i.firstElementChild),this.vphActive===t&&this.clearVphPlaceholderSel(),this.refreshState(),this.onChange()}positionVphCtx(){if(this.vphActive&&!document.body.contains(this.vphActive)){this.clearVphPlaceholderSel();return}if(!this.vphActive||!this.vphCtx)return;const t=this.vphActive.getBoundingClientRect(),e=this.vphCtx.offsetWidth,i=this.vphCtx.offsetHeight;let s=t.left+scrollX+(t.width-e)/2;s=Math.max(8+scrollX,Math.min(s,scrollX+innerWidth-e-8));let n=t.bottom+scrollY+8;t.bottom+8+i>innerHeight-4&&(n=Math.max(this.ctxMinTop(),t.top+scrollY-i-8)),this.vphCtx.style.left=s+"px",this.vphCtx.style.top=n+"px"}cancelVidHide(){this.vidHideTimer!=null&&(window.clearTimeout(this.vidHideTimer),this.vidHideTimer=null)}clearVidHandles(){var t,e;this.cancelVidHide(),(t=this.vidCtx)==null||t.remove(),this.vidCtx=null,(e=this.vidActive)==null||e.classList.remove("vid-selected"),this.vidActive=null}selectVideo(t){this.vidActive!==t&&(this.clearVidHandles(),this.vidActive=t,t.classList.add("vid-selected"),this.vidCtx=this.buildVideoCtxToolbar(t),this.positionVidCtx())}buildVideoCtxToolbar(t){const e=document.createElement("div");e.className="imgctx",e.dir=this.dir();const i=()=>{var d;const a=this.buildVideoCtxToolbar(t);(d=this.vidCtx)==null||d.replaceWith(a),this.vidCtx=a,this.positionVidCtx()},s=a=>{this.setVideoAlign(t,a),i()},n=t.style.float==="left",r=t.style.float==="right",o=!n&&!r&&t.style.marginLeft==="auto"&&t.style.marginRight==="auto",l=(a,d,p,m)=>{const v=this.ctxBtn(a,d,m);return v.classList.toggle("on",p),v};return e.append(l(h.alignleft,this.t("alignleft"),n,()=>s("left")),l(h.aligncenter,this.t("aligncenter"),o,()=>s("center")),l(h.alignright,this.t("alignright"),r,()=>s("right")),this.ctxSep(),l(h.trash,this.t("deletevideo"),!1,()=>{t.remove(),this.clearVidHandles(),this.onChange()})),e.addEventListener("mousedown",a=>a.preventDefault()),e.addEventListener("mouseenter",()=>this.cancelVidHide()),e.addEventListener("mouseleave",()=>{this.cancelVidHide(),this.vidHideTimer=window.setTimeout(()=>this.clearVidHandles(),250)}),document.body.appendChild(e),e}setVideoAlign(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()}positionVidCtx(){if(!this.vidActive||!document.body.contains(this.vidActive)){this.clearVidHandles();return}const t=this.vidActive.getBoundingClientRect();if(!this.vidCtx)return;const e=this.vidCtx.offsetWidth,i=this.vidCtx.offsetHeight;let s=t.left+scrollX+(t.width-e)/2;s=Math.max(8+scrollX,Math.min(s,scrollX+innerWidth-e-8));let n=t.top+scrollY-i-8;n<this.ctxMinTop()&&(n=t.bottom+scrollY+8),this.vidCtx.style.left=s+"px",this.vidCtx.style.top=n+"px"}videoEmbedUrl(t){let e=t.match(/^https?:\/\/(?:www\.|m\.)?youtube\.com\/watch\?(?:[^\s#]*[?&])?v=([\w-]{5,})/i);return e||(e=t.match(/^https?:\/\/(?:www\.)?(?:youtu\.be|youtube\.com\/(?:embed|shorts|live))\/([\w-]{5,})/i)),e?"https://www.youtube.com/embed/"+e[1]:(e=t.match(/^https?:\/\/(?:www\.)?vimeo\.com\/(\d+)/i),e?"https://player.vimeo.com/video/"+e[1]:(e=t.match(/^https?:\/\/(?:www\.)?dailymotion\.com\/video\/(\w+)/i),e?"https://www.dailymotion.com/embed/video/"+e[1]:null))}videoEmbedHTML(t,e=560,i=314){return`<span class="video-embed" contenteditable="false"><iframe src="${t}" width="${e}" height="${i}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></span>`}videoDlg(){this.saveSel();let t,e,i,s,n,r;const o=(a,d)=>{const p=document.createElement("div");p.className="dfield";const m=document.createElement("label");return m.textContent=this.t(a),p.append(m,d),p},l=()=>{const a=document.createElement("input");return a.type="url",a};this.dialog(this.t("videodlgttl"),a=>{const d=document.createElement("div");d.className="dtabs";const p=[],m=(f,y)=>{const C=document.createElement("button");C.type="button",C.textContent=this.t(f);const E=document.createElement("div");E.className="dtabpanel",y(E);const I=p.length;p.push(E),C.addEventListener("click",()=>v(I)),d.appendChild(C)},v=f=>{d.querySelectorAll("button").forEach((y,C)=>y.classList.toggle("on",C===f)),p.forEach((y,C)=>y.style.display=C===f?"":"none")};m("vidgeneral",f=>{t=l(),t.placeholder=this.t("videourlph");const y=document.createElement("div");y.className="drow";const C=document.createElement("button");C.type="button",C.className="txtbtn",C.textContent=this.t("uploadvideo");const E=document.createElement("input");E.type="file",E.accept=this.options.videoFileTypes.join(","),E.style.display="none",C.addEventListener("click",()=>{E.value="",E.click()}),E.addEventListener("change",()=>{var Z;const A=(Z=E.files)==null?void 0:Z[0];if(!A)return;C.disabled=!0,C.textContent=this.t("uploading");const j=_=>{t.value=_,C.disabled=!1,C.textContent=this.t("uploadvideo")};if(this.videoUploadHandler)this.videoUploadHandler(A).then(j).catch(_=>{var et;C.disabled=!1,C.textContent=this.t("uploadfailed"),(et=this.onVideoUploadError)==null||et.call(this,_,A)});else{const _=new FileReader;_.onload=()=>j(_.result),_.readAsDataURL(A)}}),y.append(t,C,E),t.style.flex="1",f.appendChild(o("vidsource",y));const I=document.createElement("div");I.className="drow",e=document.createElement("input"),e.type="number",e.value="560",i=document.createElement("input"),i.type="number",i.value="314",I.append(o("tblwidth",e),o("tblheight",i)),f.appendChild(I)}),m("vidembed",f=>{const y=document.createElement("p");y.textContent=this.t("vidembedhint"),y.style.cssText="margin:0 0 8px;color:#556;font-size:13.5px",s=document.createElement("textarea"),s.style.cssText="width:100%;box-sizing:border-box;height:160px",f.append(y,s)}),m("vidadvanced",f=>{n=l(),r=l(),f.append(o("vidaltsource",n),o("vidposter",r))});const b=document.createElement("div");b.className="dtabbody",p.forEach(f=>b.appendChild(f)),a.append(d,b),v(0),setTimeout(()=>t.focus(),0)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{const a=s.value.trim(),d=t.value.trim(),p=parseInt(e.value,10)||560,m=parseInt(i.value,10)||314;if(this.closeDlg(),!a&&!d)return;if(this.restoreSel(),a){document.execCommand("insertHTML",!1,`<span class="video-embed" contenteditable="false">${a}</span>`),this.onChange();return}const v=this.videoEmbedUrl(d);if(v)document.execCommand("insertHTML",!1,this.videoEmbedHTML(v,p,m));else{const b=n.value.trim(),f=r.value.trim();document.execCommand("insertHTML",!1,`<video controls width="${p}" height="${m}"${f?` poster="${this.escapeAttr(f)}"`:""}><source src="${this.escapeAttr(d)}">${b?`<source src="${this.escapeAttr(b)}">`:""}</video>`)}this.onChange()}}])}escapeAttr(t){return t.replace(/&/g,"&").replace(/"/g,""")}escHtml(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}closestInlineCode(){const t=window.getSelection(),e=t&&this.ed.contains(t.anchorNode)?t.anchorNode:null;if(!e)return null;const i=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement,s=i==null?void 0:i.closest("code");return s&&this.ed.contains(s)&&!s.closest("pre")?s:null}toggleInlineCode(){this.restoreSel();const t=window.getSelection();if(!t||!t.rangeCount)return;const e=this.closestInlineCode();if(e){const i=e.firstChild,s=e.lastChild;for(;e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);if(e.remove(),i&&s){const n=document.createRange();n.setStartBefore(i),n.setEndAfter(s),t.removeAllRanges(),t.addRange(n)}}else{const i=t.getRangeAt(0);if(i.collapsed||this.closestBlock(i.startContainer)!==this.closestBlock(i.endContainer))return;const s=document.createElement("code");s.appendChild(i.extractContents()),i.insertNode(s);const n=document.createRange();n.selectNodeContents(s),t.removeAllRanges(),t.addRange(n)}this.saveSel(),this.refreshState(),this.onChange()}tryCodeTyping(t){var d;const e=window.getSelection();if(!e||!e.isCollapsed||!e.anchorNode)return;const i=e.anchorNode;if(i.nodeType!==Node.TEXT_NODE||!this.ed.contains(i)||(d=i.parentElement)!=null&&d.closest("code, pre"))return;const n=(i.textContent||"").slice(0,e.anchorOffset).match(/(?:^|[^`])`([^`]+)$/);if(!n)return;const r=n[1];if(/^\s|\s$/.test(r))return;t.preventDefault();const o=document.createRange();o.setStart(i,e.anchorOffset-r.length-1),o.setEnd(i,e.anchorOffset),o.deleteContents();const l=document.createElement("code");l.textContent=r,o.insertNode(l);const a=document.createRange();a.setStartAfter(l),a.collapse(!0),e.removeAllRanges(),e.addRange(a),this.saveSel(),this.onChange()}dlgSelect(t,e){var l;let i=e;const s=document.createElement("div");s.className="dsel";const n=document.createElement("button");n.type="button",n.className="dsel-btn";const r=document.createElement("span");r.className="lbl",r.textContent=((l=t.find(([a])=>a===e))==null?void 0:l[1])||"",n.append(r),n.insertAdjacentHTML("beforeend",h.chev);const o=document.createElement("div");return o.className="dsel-list",t.forEach(([a,d])=>{const p=document.createElement("button");p.type="button",p.textContent=d,p.classList.toggle("on",a===i),p.addEventListener("click",()=>{i=a,r.textContent=d,o.querySelectorAll("button").forEach(m=>m.classList.toggle("on",m===p)),s.classList.remove("open"),n.focus()}),o.appendChild(p)}),n.addEventListener("click",()=>{var a;s.classList.toggle("open"),s.classList.contains("open")&&((a=o.querySelector(".on"))==null||a.scrollIntoView({block:"nearest"}))}),s.addEventListener("focusout",a=>{s.contains(a.relatedTarget)||s.classList.remove("open")}),s.addEventListener("keydown",a=>{a.key==="Escape"&&s.classList.contains("open")&&(a.stopPropagation(),s.classList.remove("open"),n.focus())}),s.append(n,o),{el:s,value:()=>i}}codeDlg(t){this.saveSel();let e,i;this.dialog(this.t("codedlgttl"),s=>{var o;const n=document.createElement("div");n.className="dfield";const r=document.createElement("label");r.textContent=this.t("codelang"),e=this.dlgSelect(se,(t==null?void 0:t.dataset.lang)||"plain"),n.append(r,e.el),i=document.createElement("textarea"),i.className="code-input",i.spellcheck=!1,i.value=((o=t==null?void 0:t.querySelector("code"))==null?void 0:o.textContent)||"",i.placeholder="const answer = 42;",s.append(n,i),setTimeout(()=>i.focus(),0)},[{label:this.t("cancel"),action:()=>this.closeDlg()},{label:this.t("save"),primary:!0,action:()=>{var o;const s=i.value.replace(/\s+$/,""),n=e.value(),r=((o=se.find(([l])=>l===n))==null?void 0:o[1])||n;if(this.closeDlg(),!!s.trim()){if(t){t.dataset.lang=n,t.setAttribute("data-lang-label",r);const l=t.querySelector("code")||t;l.textContent=s,this.clearCodeSel(),this.onChange();return}this.restoreSel(),document.execCommand("insertHTML",!1,`<pre class="code-block" contenteditable="false" data-lang="${n}" data-lang-label="${this.escapeAttr(r)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`),this.onChange()}}}])}clearCodeSel(){var t,e;(t=this.codeCtx)==null||t.remove(),this.codeCtx=null,(e=this.codeActive)==null||e.classList.remove("code-selected"),this.codeActive=null}selectCodeEl(t){this.codeActive!==t&&(this.clearCodeSel(),this.codeActive=t,t.classList.add("code-selected"),this.codeCtx=this.buildCodeCtxToolbar(t),this.positionCodeCtx())}buildCodeCtxToolbar(t){const e=document.createElement("div");return e.className="imgctx",e.dir=this.dir(),e.append(this.ctxBtn(h.editic,this.t("editcode"),()=>this.codeDlg(t)),this.ctxBtn(h.copyic,this.t("copycode"),()=>this.copyCodeBlock(t)),this.ctxSep(),this.ctxBtn(h.trash,this.t("deletecode"),()=>{t.remove(),this.clearCodeSel(),this.onChange()})),e.addEventListener("mousedown",i=>i.preventDefault()),document.body.appendChild(e),e}copyCodeBlock(t){var s,n;const e=((s=t.querySelector("code"))==null?void 0:s.textContent)??t.textContent??"";if((n=navigator.clipboard)!=null&&n.writeText){navigator.clipboard.writeText(e).catch(()=>{});return}const i=document.createElement("textarea");i.value=e,document.body.appendChild(i),i.select(),document.execCommand("copy"),i.remove()}positionCodeCtx(){if(!this.codeActive||!document.body.contains(this.codeActive)){this.clearCodeSel();return}const t=this.codeActive.getBoundingClientRect();if(!this.codeCtx)return;const e=this.codeCtx.offsetWidth,i=this.codeCtx.offsetHeight;let s=t.left+scrollX+(t.width-e)/2;s=Math.max(8+scrollX,Math.min(s,scrollX+innerWidth-e-8));let n=t.top+scrollY-i-8;n<this.ctxMinTop()&&(n=t.bottom+scrollY+8),this.codeCtx.style.left=s+"px",this.codeCtx.style.top=n+"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=l=>`<span class="pv-l" style="width:${l}%"></span>`,n=l=>`<span class="pv-col">${l}</span>`,r=l=>`<span class="pv-row">${l}</span>`,o=n(i+s(100)+s(88));return t==="img-left"?`<span class="pv">${r(e+o)}${s(100)}${s(72)}</span>`:t==="img-right"?`<span class="pv">${r(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",Tt.forEach(s=>{const n=document.createElement("button");n.type="button",n.className="tpltile",n.title=this.t(Et[s]),n.innerHTML=this.tplPreviewHTML(s)+`<span class="tpllbl">${this.t(Et[s])}</span>`,n.addEventListener("click",()=>{this.closePop(),this.insertTemplate(s),e==null||e()}),i.appendChild(n)}),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="",Tt.forEach(i=>{const s=this.ctxBtn(Ni[i],this.t(Et[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;Tt.forEach(n=>e.classList.remove("tpl-"+n)),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 n=t.top+scrollY-i-8;n<this.ctxMinTop()&&(n=t.bottom+scrollY+8),this.tplCtx.style.left=s+"px",this.tplCtx.style.top=n+"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,n;(t=this.tblCorner)==null||t.remove(),this.tblCorner=null,this.tblColBars.forEach(r=>r.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,(n=this.tblActive)==null||n.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(),n=e.parentElement.getBoundingClientRect(),r=t==="row"?n.left:s.left,o=t==="row"?n.top:i.top,l=t==="row"?n.width:s.width,a=t==="row"?n.height:i.height;this.tblOpMark.style.left=r+scrollX+"px",this.tblOpMark.style.top=o+scrollY+"px",this.tblOpMark.style.width=l+"px",this.tblOpMark.style.height=a+"px"}ctxMinTop(){return Math.max(scrollY+4,this.ed.getBoundingClientRect().top+scrollY-2)}ctxBtn(t,e,i,s){const n=document.createElement("button");return n.type="button",n.title=e,n.innerHTML=t,s&&(n.dataset.id=s),n.addEventListener("mousedown",r=>r.preventDefault()),n.addEventListener("click",i),n}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=(s,n)=>(s.addEventListener("mouseenter",()=>this.setOpTarget(n)),s.addEventListener("mouseleave",()=>this.setOpTarget(null)),s),i=this.ctxBtn(h.palette,this.t("cellbg"),()=>this.cellFillMenu(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.moverowup,this.t("moverowup"),()=>this.tableMove("rowup")),"row"),e(this.ctxBtn(h.moverowdown,this.t("moverowdown"),()=>this.tableMove("rowdown")),"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.movecolleft,this.t("movecolleft"),()=>this.tableMove("colleft")),"col"),e(this.ctxBtn(h.movecolright,this.t("movecolright"),()=>this.tableMove("colright")),"col"),e(this.ctxBtn(h.coldelete,this.t("delcol"),()=>this.tableOp("delcol")),"col"),this.ctxSep(),this.ctxBtn(h.alignleft,this.t("tblalignleft"),()=>this.alignTable("left")),this.ctxBtn(h.aligncenter,this.t("tblaligncenter"),()=>this.alignTable("center")),this.ctxBtn(h.alignright,this.t("tblalignright"),()=>this.alignTable("right")),this.ctxSep(),i,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,n=e.right+scrollX,r=e.bottom+scrollY;if(this.tblCorner&&(this.tblCorner.style.top=r-5+"px",this.tblCorner.style.left=(t?s-5:n-5)+"px",this.tblCorner.style.cursor=t?"nesw-resize":"nwse-resize"),this.tblCtx){const l=this.tblCtx.offsetWidth,a=this.tblCtx.offsetHeight;let d=s+(n-s)/2-l/2;d=Math.max(8+scrollX,Math.min(d,scrollX+innerWidth-l-8));let p=i-a-8;p<this.ctxMinTop()&&(p=r+8),this.tblCtx.style.left=d+"px",this.tblCtx.style.top=p+"px"}this.tblColBars.forEach(l=>l.remove()),this.tblColBars=[];const o=this.tblActive.rows[0];if(o)for(let l=0;l<o.cells.length-1;l++){const a=o.cells[l].getBoundingClientRect(),d=(t?a.left:a.right)+scrollX,p=document.createElement("div");p.className="tbl-colbar",p.style.top=i+"px",p.style.left=d+"px",p.style.height=r-i+"px",document.body.appendChild(p),p.addEventListener("mousedown",m=>this.startColBarDrag(m,l)),this.tblColBars.push(p)}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,n=e.getBoundingClientRect().width;e.style.tableLayout=e.style.tableLayout||"fixed",this.withNoTextSelect(r=>{const o=a=>{const d=i?-(a.clientX-s):a.clientX-s;e.style.width=Math.max(60,Math.round(n+d))+"px",this.positionTableHandles()},l=()=>{window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",l),r(),this.onChange()};window.addEventListener("mousemove",o),window.addEventListener("mouseup",l)})}startColBarDrag(t,e){t.preventDefault(),t.stopPropagation();const i=this.tblActive;if(!i)return;const s=this.ed.getAttribute("dir")==="rtl",n=Array.from(i.rows),r=n.map(p=>p.cells[e]).filter(Boolean),o=n.map(p=>p.cells[e+1]).filter(Boolean);if(!r.length||!o.length)return;const l=t.clientX,a=r[0].getBoundingClientRect().width,d=o[0].getBoundingClientRect().width;i.style.tableLayout="fixed",this.withNoTextSelect(p=>{const m=b=>{const f=(s?-1:1)*(b.clientX-l);r.forEach(y=>y.style.width=Math.max(24,Math.round(a+f))+"px"),o.forEach(y=>y.style.width=Math.max(24,Math.round(d-f))+"px"),this.positionTableHandles()},v=()=>{window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",v),p(),this.onChange()};window.addEventListener("mousemove",m),window.addEventListener("mouseup",v)})}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=Di.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 a=this.buildImageCtxToolbar(t);(d=this.imgCtx)==null||d.replaceWith(a),this.imgCtx=a,this.positionImageHandles()},s=a=>{this.setImageAlign(t,a),i()},n=t.style.float==="left",r=t.style.float==="right",o=!n&&!r&&t.style.marginLeft==="auto"&&t.style.marginRight==="auto",l=(a,d,p,m)=>{const v=this.ctxBtn(a,d,m);return v.classList.toggle("on",p),v};return e.append(l(h.alignleft,this.t("alignleft"),n,()=>s("left")),l(h.aligncenter,this.t("aligncenter"),o,()=>s("center")),l(h.alignright,this.t("alignright"),r,()=>s("right")),this.ctxSep(),l(h.rotateleft,this.t("rotateleft"),!1,()=>{this.rotateImage(t,-90),i()}),l(h.rotateright,this.t("rotateright"),!1,()=>{this.rotateImage(t,90),i()}),this.ctxSep(),l(h.fliphorizontal,this.t("fliphorizontal"),t.dataset.flipx==="1",()=>{this.flipImage(t,"x"),i()}),l(h.flipvertical,this.t("flipvertical"),t.dataset.flipy==="1",()=>{this.flipImage(t,"y"),i()}),this.ctxSep(),l(h.trash,this.t("deleteimg"),!1,()=>{const a=t.closest(".tpl-media");a&&this.ed.contains(a)?t.outerHTML=this.imgPhHTML():t.remove(),this.clearImageHandles(),this.onChange()})),e.addEventListener("mousedown",a=>a.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,n=t.bottom+scrollY,r={nw:[i,e],ne:[s,e],sw:[i,n],se:[s,n]};if(this.imgHandles.forEach(o=>{const[l,a]=r[o.dataset.corner];o.style.left=l-5+"px",o.style.top=a-5+"px"}),this.imgCtx){const o=this.imgCtx.offsetWidth,l=this.imgCtx.offsetHeight;let a=i+(s-i)/2-o/2;a=Math.max(8+scrollX,Math.min(a,scrollX+innerWidth-o-8));let d=e-l-8;d<this.ctxMinTop()&&(d=n+8),this.imgCtx.style.left=a+"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,n=i.offsetWidth||i.getBoundingClientRect().width,r=e==="nw"||e==="sw"?-1:1,o=Math.round(this.contentWidth());this.withNoTextSelect(l=>{const a=p=>{let m=Math.max(24,Math.round(n+r*(p.clientX-s)));o>0&&(m=Math.min(m,o)),i.style.width=m+"px",i.style.height="auto",this.positionImageHandles()},d=()=>{window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",d),l();const p=Math.round(i.offsetWidth)||parseInt(i.style.width,10);p>0&&!i.closest(".tpl-media")&&(i.style.width=p+"px",i.setAttribute("width",String(p)),i.removeAttribute("height")),this.onChange()};window.addEventListener("mousemove",a),window.addEventListener("mouseup",d)})}toggleBlock(t){const e=this.currentBlock()===t;this.exec("formatBlock",e?"<p>":"<"+t+">"),t==="blockquote"&&e&&this.unwrapBlockquote()}unwrapBlockquote(){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==="BLOCKQUOTE"){const i=e,s=i.parentNode;for(;i.firstChild;)s.insertBefore(i.firstChild,i);s.removeChild(i),this.onChange();return}e=e.parentNode}}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)),n=this.ctxBtn(h.lineheight,this.t("lineheight"),()=>this.lineHeightMenu(n)),r=this.ctxBtn(h.wordspacing,this.t("wordspacing"),()=>this.wordSpacingMenu(r));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(h.inlinecodeic,this.t("code"),()=>this.toggleInlineCode(),"code"),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,n,r),t.addEventListener("mousedown",l=>l.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,n=e.right+scrollX,r=e.bottom+scrollY,o=this.selCtx.offsetWidth,l=this.selCtx.offsetHeight;let a=s+(n-s)/2-o/2;a=Math.max(8+scrollX,Math.min(a,scrollX+innerWidth-o-8));let d=i-l-8;d<this.ctxMinTop()&&(d=r+8),this.selCtx.style.left=a+"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";let e=t.anchorNode;for(;e&&e!==this.ed;){if(e.nodeType===1&&e.tagName==="BLOCKQUOTE")return"blockquote";e=e.parentNode}const i=this.closestBlock(t.anchorNode);return i?i.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 l,a,d;const t=window.getSelection(),e=t?this.ed.contains(t.anchorNode):!1,i=this.currentBlock();[this.toolbar,this.selCtx].filter(Boolean).forEach(p=>{["bold","italic","underline","strikeThrough","justifyLeft","justifyCenter","justifyRight","justifyFull","insertOrderedList","insertUnorderedList"].forEach(v=>{const b=p.querySelector(`[data-id=${v}]`);b&&b.classList.toggle("on",e&&document.queryCommandState(v))}),["h2","h3","blockquote"].forEach(v=>{const b=p.querySelector(`[data-id=${v}]`);b&&b.classList.toggle("on",e&&i===v)});const m=p.querySelector("[data-id=code]");m&&m.classList.toggle("on",e&&!!this.closestInlineCode())});const n=t?this.closestBlock(t.anchorNode):null,r=((l=n==null?void 0:n.closest("[dir]"))==null?void 0:l.getAttribute("dir"))||this.ed.getAttribute("dir")||this.dir();(a=this.toolbar.querySelector("[data-id=ltr]"))==null||a.classList.toggle("on",e&&r==="ltr"),(d=this.toolbar.querySelector("[data-id=rtl]"))==null||d.classList.toggle("on",e&&r==="rtl");const o=(p,m,v)=>{const b=this.toolbar.querySelector(`[data-id=${p}] .lbl`);b&&(b.textContent=m||v||"",b.classList.toggle("empty",!m))};o("fontsel",this.currentFont()),o("sizesel",this.currentSize().replace("px","")),e&&o("blocksel",ne.some(p=>p[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(n=>n.type.startsWith("image/"));if(s&&!i){const n=new FileReader;n.onload=()=>{this.insertImageHTML(n.result),this.onChange()},n.readAsDataURL(s.getAsFile());return}if(!i){const n=e.getData("text/plain"),r=/^\S+$/.test(n.trim())?this.videoEmbedUrl(n.trim()):null;if(r){document.execCommand("insertHTML",!1,this.videoEmbedHTML(r)),this.onChange();return}}i?this.pasteRichHTML(i,e,s):(document.execCommand("insertHTML",!1,yi(e.getData("text/plain"))),this.onChange())}pasteRichHTML(t,e,i){let s=[];const n=e.getData("text/rtf");if(n){const r=ki(t,n);t=r.html,s=r.injected}if(i&&Ai(t)===1){const r=i.getAsFile();if(r){const o=t;this.saveSel();const l=new FileReader;l.onload=()=>{const a=fe(o,[l.result]);this.finishRichPaste(a.html,s.concat(a.injected),!0)},l.onerror=()=>this.finishRichPaste(o,s,!0),l.readAsDataURL(r);return}}this.finishRichPaste(t,s)}finishRichPaste(t,e,i=!1){if(!this.imageUploadHandler||!e.length){this.insertPastedHTML(t,i);return}const s=this.imageUploadHandler,n=e.filter((r,o)=>e.indexOf(r)===o);i||this.saveSel(),Promise.all(n.map((r,o)=>{const l=Hi(r,"pasted-image-"+(o+1));return l?s(l).catch(a=>{var d;return(d=this.onImageUploadError)==null||d.call(this,a,l),r}):Promise.resolve(r)})).then(r=>{let o=t;n.forEach((l,a)=>{r[a]!==l&&(o=o.split(l).join(r[a]))}),this.insertPastedHTML(o,!0)})}insertPastedHTML(t,e=!1){e&&this.restoreSel(),document.execCommand("insertHTML",!1,bi(t,this.dir())),e&&this.saveSel(),this.onChange()}initUI(){this.closePop(),this.closeDlg(),this.clearTableHandles(),this.clearImgPlaceholderSel(),this.clearVphPlaceholderSel(),this.clearVidHandles(),this.clearCodeSel(),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.TBR_COLLAPSE_MAX=992,W);const be=N.forwardRef(({value:u,defaultValue:t,onChange:e,onReady:i,className:s,style:n,...r},o)=>{const l=N.useRef(null),a=N.useRef(null),d=N.useRef(!1),p=N.useRef(u??t),m=N.useRef(null),v=N.useRef(e),b=N.useRef(i);return v.current=e,b.current=i,N.useImperativeHandle(o,()=>({getContent:()=>{var f;return((f=a.current)==null?void 0:f.getContent())??""},getContentForEmail:()=>{var f;return((f=a.current)==null?void 0:f.getContentForEmail())??""},setContent:f=>{var y;return(y=a.current)==null?void 0:y.setContent(f)},insertContent:f=>{var y;return(y=a.current)==null?void 0:y.insertContent(f)},setLanguage:f=>{var y;return(y=a.current)==null?void 0:y.setLanguage(f)},focus:()=>{var f;return(f=a.current)==null?void 0:f.focus()},destroy:()=>{var f;return(f=a.current)==null?void 0:f.destroy()},importWordFile:f=>{var y;return((y=a.current)==null?void 0:y.importWordFile(f))??Promise.resolve()},restoreDraft:()=>{var f;return((f=a.current)==null?void 0:f.restoreDraft())??!1},getRevisions:()=>{var f;return((f=a.current)==null?void 0:f.getRevisions())??[]}})),N.useEffect(()=>{if(!l.current)return;const f=new is({target:l.current,initialContent:p.current,onChange:y=>{var C;d.current=!0,p.current=y,(C=v.current)==null||C.call(v,y)},onReady:y=>{var C;return(C=b.current)==null?void 0:C.call(b,y)},...r});return a.current=f,()=>{f.destroy(),a.current=null}},[]),N.useEffect(()=>{var f,y;if(u!==void 0&&u!==p.current){if(d.current){d.current=!1;return}if((f=l.current)!=null&&f.contains(document.activeElement)){m.current=u;return}p.current=u,(y=a.current)==null||y.setContent(u)}},[u]),N.useEffect(()=>{const f=l.current;if(!f)return;const y=C=>{var A;if(m.current===null)return;const E=C.relatedTarget;if(E&&f.contains(E))return;const I=m.current;m.current=null,p.current=I,(A=a.current)==null||A.setContent(I)};return f.addEventListener("focusout",y),()=>f.removeEventListener("focusout",y)},[]),N.useEffect(()=>{var f;r.language&&((f=a.current)==null||f.setLanguage(r.language))},[r.language]),Ge.jsx("div",{ref:l,className:s,style:n})});be.displayName="FableEditor";exports.FableEditor=be;
|