fable-editor 1.2.7 → 1.3.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.
@@ -1,5 +1,5 @@
1
- import ce, { forwardRef as _e, useRef as z, useImperativeHandle as $e, useEffect as ot } from "react";
2
- var Et = { exports: {} }, J = {};
1
+ import ue, { forwardRef as Ve, useRef as z, useImperativeHandle as ze, useEffect as lt } from "react";
2
+ var St = { exports: {} }, J = {};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.min.js
@@ -9,19 +9,19 @@ var Et = { exports: {} }, J = {};
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
- var Gt;
13
- function je() {
14
- if (Gt) return J;
15
- Gt = 1;
16
- var p = ce, t = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, s = p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, n = { key: !0, ref: !0, __self: !0, __source: !0 };
17
- function l(r, o, c) {
18
- var d, u = {}, m = null, b = null;
19
- c !== void 0 && (m = "" + c), o.key !== void 0 && (m = "" + o.key), o.ref !== void 0 && (b = o.ref);
20
- for (d in o) i.call(o, d) && !n.hasOwnProperty(d) && (u[d] = o[d]);
21
- if (r && r.defaultProps) for (d in o = r.defaultProps, o) u[d] === void 0 && (u[d] = o[d]);
22
- return { $$typeof: t, type: r, key: m, ref: b, props: u, _owner: s.current };
23
- }
24
- return J.Fragment = e, J.jsx = l, J.jsxs = l, J;
12
+ var Kt;
13
+ function Xe() {
14
+ if (Kt) return J;
15
+ Kt = 1;
16
+ var u = ue, 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 };
17
+ function r(l, o, a) {
18
+ var d, p = {}, m = null, b = null;
19
+ a !== void 0 && (m = "" + a), o.key !== void 0 && (m = "" + o.key), o.ref !== void 0 && (b = o.ref);
20
+ for (d in o) i.call(o, d) && !n.hasOwnProperty(d) && (p[d] = o[d]);
21
+ if (l && l.defaultProps) for (d in o = l.defaultProps, o) p[d] === void 0 && (p[d] = o[d]);
22
+ return { $$typeof: t, type: l, key: m, ref: b, props: p, _owner: s.current };
23
+ }
24
+ return J.Fragment = e, J.jsx = r, J.jsxs = r, J;
25
25
  }
26
26
  var tt = {};
27
27
  /**
@@ -33,61 +33,61 @@ var tt = {};
33
33
  * This source code is licensed under the MIT license found in the
34
34
  * LICENSE file in the root directory of this source tree.
35
35
  */
36
- var Kt;
37
- function We() {
38
- return Kt || (Kt = 1, process.env.NODE_ENV !== "production" && function() {
39
- var p = ce, 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"), l = Symbol.for("react.provider"), r = Symbol.for("react.context"), o = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), u = Symbol.for("react.memo"), m = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), y = Symbol.iterator, g = "@@iterator";
40
- function x(a) {
41
- if (a === null || typeof a != "object")
36
+ var Jt;
37
+ function Ye() {
38
+ return Jt || (Jt = 1, process.env.NODE_ENV !== "production" && function() {
39
+ var u = ue, 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"), l = Symbol.for("react.context"), o = 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"), b = Symbol.for("react.offscreen"), y = Symbol.iterator, g = "@@iterator";
40
+ function x(c) {
41
+ if (c === null || typeof c != "object")
42
42
  return null;
43
- var f = y && a[y] || a[g];
43
+ var f = y && c[y] || c[g];
44
44
  return typeof f == "function" ? f : null;
45
45
  }
46
- var w = p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
47
- function E(a) {
46
+ var w = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
47
+ function E(c) {
48
48
  {
49
49
  for (var f = arguments.length, v = new Array(f > 1 ? f - 1 : 0), T = 1; T < f; T++)
50
50
  v[T - 1] = arguments[T];
51
- I("error", a, v);
51
+ I("error", c, v);
52
52
  }
53
53
  }
54
- function I(a, f, v) {
54
+ function I(c, f, v) {
55
55
  {
56
- var T = w.ReactDebugCurrentFrame, L = T.getStackAddendum();
57
- L !== "" && (f += "%s", v = v.concat([L]));
58
- var A = v.map(function(M) {
56
+ var T = w.ReactDebugCurrentFrame, k = T.getStackAddendum();
57
+ k !== "" && (f += "%s", v = v.concat([k]));
58
+ var H = v.map(function(M) {
59
59
  return String(M);
60
60
  });
61
- A.unshift("Warning: " + f), Function.prototype.apply.call(console[a], console, A);
61
+ H.unshift("Warning: " + f), Function.prototype.apply.call(console[c], console, H);
62
62
  }
63
63
  }
64
- var H = !1, $ = !1, O = !1, F = !1, et = !1, Mt;
65
- Mt = Symbol.for("react.module.reference");
66
- function ue(a) {
67
- return !!(typeof a == "string" || typeof a == "function" || a === i || a === n || et || a === s || a === c || a === d || F || a === b || H || $ || O || typeof a == "object" && a !== null && (a.$$typeof === m || a.$$typeof === u || a.$$typeof === l || a.$$typeof === r || a.$$typeof === o || // This needs to include all possible module reference object
64
+ var A = !1, $ = !1, Z = !1, F = !1, et = !1, Lt;
65
+ Lt = Symbol.for("react.module.reference");
66
+ function ve(c) {
67
+ return !!(typeof c == "string" || typeof c == "function" || c === i || c === n || et || c === s || c === a || c === d || F || c === b || A || $ || Z || typeof c == "object" && c !== null && (c.$$typeof === m || c.$$typeof === p || c.$$typeof === r || c.$$typeof === l || c.$$typeof === o || // This needs to include all possible module reference object
68
68
  // types supported by any Flight configuration anywhere since
69
69
  // we don't know which Flight build this will end up being used
70
70
  // with.
71
- a.$$typeof === Mt || a.getModuleId !== void 0));
71
+ c.$$typeof === Lt || c.getModuleId !== void 0));
72
72
  }
73
- function pe(a, f, v) {
74
- var T = a.displayName;
73
+ function be(c, f, v) {
74
+ var T = c.displayName;
75
75
  if (T)
76
76
  return T;
77
- var L = f.displayName || f.name || "";
78
- return L !== "" ? v + "(" + L + ")" : v;
77
+ var k = f.displayName || f.name || "";
78
+ return k !== "" ? v + "(" + k + ")" : v;
79
79
  }
80
- function kt(a) {
81
- return a.displayName || "Context";
80
+ function kt(c) {
81
+ return c.displayName || "Context";
82
82
  }
83
- function W(a) {
84
- if (a == null)
83
+ function W(c) {
84
+ if (c == null)
85
85
  return null;
86
- if (typeof a.tag == "number" && E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof a == "function")
87
- return a.displayName || a.name || null;
88
- if (typeof a == "string")
89
- return a;
90
- switch (a) {
86
+ 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")
87
+ return c.displayName || c.name || null;
88
+ if (typeof c == "string")
89
+ return c;
90
+ switch (c) {
91
91
  case i:
92
92
  return "Fragment";
93
93
  case e:
@@ -96,28 +96,28 @@ function We() {
96
96
  return "Profiler";
97
97
  case s:
98
98
  return "StrictMode";
99
- case c:
99
+ case a:
100
100
  return "Suspense";
101
101
  case d:
102
102
  return "SuspenseList";
103
103
  }
104
- if (typeof a == "object")
105
- switch (a.$$typeof) {
106
- case r:
107
- var f = a;
108
- return kt(f) + ".Consumer";
104
+ if (typeof c == "object")
105
+ switch (c.$$typeof) {
109
106
  case l:
110
- var v = a;
107
+ var f = c;
108
+ return kt(f) + ".Consumer";
109
+ case r:
110
+ var v = c;
111
111
  return kt(v._context) + ".Provider";
112
112
  case o:
113
- return pe(a, a.render, "ForwardRef");
114
- case u:
115
- var T = a.displayName || null;
116
- return T !== null ? T : W(a.type) || "Memo";
113
+ return be(c, c.render, "ForwardRef");
114
+ case p:
115
+ var T = c.displayName || null;
116
+ return T !== null ? T : W(c.type) || "Memo";
117
117
  case m: {
118
- var L = a, A = L._payload, M = L._init;
118
+ var k = c, H = k._payload, M = k._init;
119
119
  try {
120
- return W(M(A));
120
+ return W(M(H));
121
121
  } catch {
122
122
  return null;
123
123
  }
@@ -125,101 +125,101 @@ function We() {
125
125
  }
126
126
  return null;
127
127
  }
128
- var V = Object.assign, G = 0, Lt, Ht, At, It, qt, Rt, Pt;
129
- function Bt() {
128
+ var U = Object.assign, Q = 0, At, Ht, It, qt, Rt, Pt, Bt;
129
+ function Nt() {
130
130
  }
131
- Bt.__reactDisabledLog = !0;
132
- function me() {
131
+ Nt.__reactDisabledLog = !0;
132
+ function ye() {
133
133
  {
134
- if (G === 0) {
135
- Lt = console.log, Ht = console.info, At = console.warn, It = console.error, qt = console.group, Rt = console.groupCollapsed, Pt = console.groupEnd;
136
- var a = {
134
+ if (Q === 0) {
135
+ At = console.log, Ht = console.info, It = console.warn, qt = console.error, Rt = console.group, Pt = console.groupCollapsed, Bt = console.groupEnd;
136
+ var c = {
137
137
  configurable: !0,
138
138
  enumerable: !0,
139
- value: Bt,
139
+ value: Nt,
140
140
  writable: !0
141
141
  };
142
142
  Object.defineProperties(console, {
143
- info: a,
144
- log: a,
145
- warn: a,
146
- error: a,
147
- group: a,
148
- groupCollapsed: a,
149
- groupEnd: a
143
+ info: c,
144
+ log: c,
145
+ warn: c,
146
+ error: c,
147
+ group: c,
148
+ groupCollapsed: c,
149
+ groupEnd: c
150
150
  });
151
151
  }
152
- G++;
152
+ Q++;
153
153
  }
154
154
  }
155
- function fe() {
155
+ function xe() {
156
156
  {
157
- if (G--, G === 0) {
158
- var a = {
157
+ if (Q--, Q === 0) {
158
+ var c = {
159
159
  configurable: !0,
160
160
  enumerable: !0,
161
161
  writable: !0
162
162
  };
163
163
  Object.defineProperties(console, {
164
- log: V({}, a, {
165
- value: Lt
164
+ log: U({}, c, {
165
+ value: At
166
166
  }),
167
- info: V({}, a, {
167
+ info: U({}, c, {
168
168
  value: Ht
169
169
  }),
170
- warn: V({}, a, {
171
- value: At
172
- }),
173
- error: V({}, a, {
170
+ warn: U({}, c, {
174
171
  value: It
175
172
  }),
176
- group: V({}, a, {
173
+ error: U({}, c, {
177
174
  value: qt
178
175
  }),
179
- groupCollapsed: V({}, a, {
176
+ group: U({}, c, {
180
177
  value: Rt
181
178
  }),
182
- groupEnd: V({}, a, {
179
+ groupCollapsed: U({}, c, {
183
180
  value: Pt
181
+ }),
182
+ groupEnd: U({}, c, {
183
+ value: Bt
184
184
  })
185
185
  });
186
186
  }
187
- G < 0 && E("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
187
+ Q < 0 && E("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
188
188
  }
189
189
  }
190
190
  var pt = w.ReactCurrentDispatcher, mt;
191
- function it(a, f, v) {
191
+ function it(c, f, v) {
192
192
  {
193
193
  if (mt === void 0)
194
194
  try {
195
195
  throw Error();
196
- } catch (L) {
197
- var T = L.stack.trim().match(/\n( *(at )?)/);
196
+ } catch (k) {
197
+ var T = k.stack.trim().match(/\n( *(at )?)/);
198
198
  mt = T && T[1] || "";
199
199
  }
200
200
  return `
201
- ` + mt + a;
201
+ ` + mt + c;
202
202
  }
203
203
  }
204
204
  var ft = !1, st;
205
205
  {
206
- var ge = typeof WeakMap == "function" ? WeakMap : Map;
207
- st = new ge();
206
+ var Ce = typeof WeakMap == "function" ? WeakMap : Map;
207
+ st = new Ce();
208
208
  }
209
- function Nt(a, f) {
210
- if (!a || ft)
209
+ function Dt(c, f) {
210
+ if (!c || ft)
211
211
  return "";
212
212
  {
213
- var v = st.get(a);
213
+ var v = st.get(c);
214
214
  if (v !== void 0)
215
215
  return v;
216
216
  }
217
217
  var T;
218
218
  ft = !0;
219
- var L = Error.prepareStackTrace;
219
+ var k = Error.prepareStackTrace;
220
220
  Error.prepareStackTrace = void 0;
221
- var A;
222
- A = pt.current, pt.current = null, me();
221
+ var H;
222
+ H = pt.current, pt.current = null, ye();
223
223
  try {
224
224
  if (f) {
225
225
  var M = function() {
@@ -235,14 +235,14 @@ function We() {
235
235
  } catch (D) {
236
236
  T = D;
237
237
  }
238
- Reflect.construct(a, [], M);
238
+ Reflect.construct(c, [], M);
239
239
  } else {
240
240
  try {
241
241
  M.call();
242
242
  } catch (D) {
243
243
  T = D;
244
244
  }
245
- a.call(M.prototype);
245
+ c.call(M.prototype);
246
246
  }
247
247
  } else {
248
248
  try {
@@ -250,7 +250,7 @@ function We() {
250
250
  } catch (D) {
251
251
  T = D;
252
252
  }
253
- a();
253
+ c();
254
254
  }
255
255
  } catch (D) {
256
256
  if (D && T && typeof D.stack == "string") {
@@ -265,163 +265,163 @@ function We() {
265
265
  if (R--, P--, P < 0 || S[R] !== N[P]) {
266
266
  var _ = `
267
267
  ` + S[R].replace(" at new ", " at ");
268
- return a.displayName && _.includes("<anonymous>") && (_ = _.replace("<anonymous>", a.displayName)), typeof a == "function" && st.set(a, _), _;
268
+ return c.displayName && _.includes("<anonymous>") && (_ = _.replace("<anonymous>", c.displayName)), typeof c == "function" && st.set(c, _), _;
269
269
  }
270
270
  while (R >= 1 && P >= 0);
271
271
  break;
272
272
  }
273
273
  }
274
274
  } finally {
275
- ft = !1, pt.current = A, fe(), Error.prepareStackTrace = L;
275
+ ft = !1, pt.current = H, xe(), Error.prepareStackTrace = k;
276
276
  }
277
- var Q = a ? a.displayName || a.name : "", U = Q ? it(Q) : "";
278
- return typeof a == "function" && st.set(a, U), U;
277
+ var G = c ? c.displayName || c.name : "", V = G ? it(G) : "";
278
+ return typeof c == "function" && st.set(c, V), V;
279
279
  }
280
- function ve(a, f, v) {
281
- return Nt(a, !1);
280
+ function we(c, f, v) {
281
+ return Dt(c, !1);
282
282
  }
283
- function be(a) {
284
- var f = a.prototype;
283
+ function Te(c) {
284
+ var f = c.prototype;
285
285
  return !!(f && f.isReactComponent);
286
286
  }
287
- function nt(a, f, v) {
288
- if (a == null)
287
+ function nt(c, f, v) {
288
+ if (c == null)
289
289
  return "";
290
- if (typeof a == "function")
291
- return Nt(a, be(a));
292
- if (typeof a == "string")
293
- return it(a);
294
- switch (a) {
295
- case c:
290
+ if (typeof c == "function")
291
+ return Dt(c, Te(c));
292
+ if (typeof c == "string")
293
+ return it(c);
294
+ switch (c) {
295
+ case a:
296
296
  return it("Suspense");
297
297
  case d:
298
298
  return it("SuspenseList");
299
299
  }
300
- if (typeof a == "object")
301
- switch (a.$$typeof) {
300
+ if (typeof c == "object")
301
+ switch (c.$$typeof) {
302
302
  case o:
303
- return ve(a.render);
304
- case u:
305
- return nt(a.type, f, v);
303
+ return we(c.render);
304
+ case p:
305
+ return nt(c.type, f, v);
306
306
  case m: {
307
- var T = a, L = T._payload, A = T._init;
307
+ var T = c, k = T._payload, H = T._init;
308
308
  try {
309
- return nt(A(L), f, v);
309
+ return nt(H(k), f, v);
310
310
  } catch {
311
311
  }
312
312
  }
313
313
  }
314
314
  return "";
315
315
  }
316
- var K = Object.prototype.hasOwnProperty, Dt = {}, Zt = w.ReactDebugCurrentFrame;
317
- function lt(a) {
318
- if (a) {
319
- var f = a._owner, v = nt(a.type, a._source, f ? f.type : null);
316
+ var K = Object.prototype.hasOwnProperty, Ot = {}, Zt = w.ReactDebugCurrentFrame;
317
+ function rt(c) {
318
+ if (c) {
319
+ var f = c._owner, v = nt(c.type, c._source, f ? f.type : null);
320
320
  Zt.setExtraStackFrame(v);
321
321
  } else
322
322
  Zt.setExtraStackFrame(null);
323
323
  }
324
- function ye(a, f, v, T, L) {
324
+ function Ee(c, f, v, T, k) {
325
325
  {
326
- var A = Function.call.bind(K);
327
- for (var M in a)
328
- if (A(a, M)) {
326
+ var H = Function.call.bind(K);
327
+ for (var M in c)
328
+ if (H(c, M)) {
329
329
  var S = void 0;
330
330
  try {
331
- if (typeof a[M] != "function") {
332
- var N = Error((T || "React class") + ": " + v + " type `" + M + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof a[M] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
331
+ if (typeof c[M] != "function") {
332
+ var N = Error((T || "React class") + ": " + v + " 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`.");
333
333
  throw N.name = "Invariant Violation", N;
334
334
  }
335
- S = a[M](f, M, T, v, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
335
+ S = c[M](f, M, T, v, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
336
336
  } catch (R) {
337
337
  S = R;
338
338
  }
339
- S && !(S instanceof Error) && (lt(L), 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", v, M, typeof S), lt(null)), S instanceof Error && !(S.message in Dt) && (Dt[S.message] = !0, lt(L), E("Failed %s type: %s", v, S.message), lt(null));
339
+ 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", v, M, typeof S), rt(null)), S instanceof Error && !(S.message in Ot) && (Ot[S.message] = !0, rt(k), E("Failed %s type: %s", v, S.message), rt(null));
340
340
  }
341
341
  }
342
342
  }
343
- var xe = Array.isArray;
344
- function gt(a) {
345
- return xe(a);
343
+ var Se = Array.isArray;
344
+ function gt(c) {
345
+ return Se(c);
346
346
  }
347
- function Ce(a) {
347
+ function Me(c) {
348
348
  {
349
- var f = typeof Symbol == "function" && Symbol.toStringTag, v = f && a[Symbol.toStringTag] || a.constructor.name || "Object";
349
+ var f = typeof Symbol == "function" && Symbol.toStringTag, v = f && c[Symbol.toStringTag] || c.constructor.name || "Object";
350
350
  return v;
351
351
  }
352
352
  }
353
- function we(a) {
353
+ function Le(c) {
354
354
  try {
355
- return Ot(a), !1;
355
+ return Ft(c), !1;
356
356
  } catch {
357
357
  return !0;
358
358
  }
359
359
  }
360
- function Ot(a) {
361
- return "" + a;
360
+ function Ft(c) {
361
+ return "" + c;
362
362
  }
363
- function Ft(a) {
364
- if (we(a))
365
- return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ce(a)), Ot(a);
363
+ function _t(c) {
364
+ if (Le(c))
365
+ return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Me(c)), Ft(c);
366
366
  }
367
- var _t = w.ReactCurrentOwner, Te = {
367
+ var $t = w.ReactCurrentOwner, ke = {
368
368
  key: !0,
369
369
  ref: !0,
370
370
  __self: !0,
371
371
  __source: !0
372
- }, $t, jt;
373
- function Ee(a) {
374
- if (K.call(a, "ref")) {
375
- var f = Object.getOwnPropertyDescriptor(a, "ref").get;
372
+ }, jt, Wt;
373
+ function Ae(c) {
374
+ if (K.call(c, "ref")) {
375
+ var f = Object.getOwnPropertyDescriptor(c, "ref").get;
376
376
  if (f && f.isReactWarning)
377
377
  return !1;
378
378
  }
379
- return a.ref !== void 0;
379
+ return c.ref !== void 0;
380
380
  }
381
- function Se(a) {
382
- if (K.call(a, "key")) {
383
- var f = Object.getOwnPropertyDescriptor(a, "key").get;
381
+ function He(c) {
382
+ if (K.call(c, "key")) {
383
+ var f = Object.getOwnPropertyDescriptor(c, "key").get;
384
384
  if (f && f.isReactWarning)
385
385
  return !1;
386
386
  }
387
- return a.key !== void 0;
387
+ return c.key !== void 0;
388
388
  }
389
- function Me(a, f) {
390
- typeof a.ref == "string" && _t.current;
389
+ function Ie(c, f) {
390
+ typeof c.ref == "string" && $t.current;
391
391
  }
392
- function ke(a, f) {
392
+ function qe(c, f) {
393
393
  {
394
394
  var v = function() {
395
- $t || ($t = !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)", f));
395
+ 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)", f));
396
396
  };
397
- v.isReactWarning = !0, Object.defineProperty(a, "key", {
397
+ v.isReactWarning = !0, Object.defineProperty(c, "key", {
398
398
  get: v,
399
399
  configurable: !0
400
400
  });
401
401
  }
402
402
  }
403
- function Le(a, f) {
403
+ function Re(c, f) {
404
404
  {
405
405
  var v = function() {
406
- jt || (jt = !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)", f));
406
+ 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)", f));
407
407
  };
408
- v.isReactWarning = !0, Object.defineProperty(a, "ref", {
408
+ v.isReactWarning = !0, Object.defineProperty(c, "ref", {
409
409
  get: v,
410
410
  configurable: !0
411
411
  });
412
412
  }
413
413
  }
414
- var He = function(a, f, v, T, L, A, M) {
414
+ var Pe = function(c, f, v, T, k, H, M) {
415
415
  var S = {
416
416
  // This tag allows us to uniquely identify this as a React Element
417
417
  $$typeof: t,
418
418
  // Built-in properties that belong on the element
419
- type: a,
419
+ type: c,
420
420
  key: f,
421
421
  ref: v,
422
422
  props: M,
423
423
  // Record the component responsible for creating this element.
424
- _owner: A
424
+ _owner: H
425
425
  };
426
426
  return S._store = {}, Object.defineProperty(S._store, "validated", {
427
427
  configurable: !1,
@@ -437,61 +437,61 @@ function We() {
437
437
  configurable: !1,
438
438
  enumerable: !1,
439
439
  writable: !1,
440
- value: L
440
+ value: k
441
441
  }), Object.freeze && (Object.freeze(S.props), Object.freeze(S)), S;
442
442
  };
443
- function Ae(a, f, v, T, L) {
443
+ function Be(c, f, v, T, k) {
444
444
  {
445
- var A, M = {}, S = null, N = null;
446
- v !== void 0 && (Ft(v), S = "" + v), Se(f) && (Ft(f.key), S = "" + f.key), Ee(f) && (N = f.ref, Me(f, L));
447
- for (A in f)
448
- K.call(f, A) && !Te.hasOwnProperty(A) && (M[A] = f[A]);
449
- if (a && a.defaultProps) {
450
- var R = a.defaultProps;
451
- for (A in R)
452
- M[A] === void 0 && (M[A] = R[A]);
445
+ var H, M = {}, S = null, N = null;
446
+ v !== void 0 && (_t(v), S = "" + v), He(f) && (_t(f.key), S = "" + f.key), Ae(f) && (N = f.ref, Ie(f, k));
447
+ for (H in f)
448
+ K.call(f, H) && !ke.hasOwnProperty(H) && (M[H] = f[H]);
449
+ if (c && c.defaultProps) {
450
+ var R = c.defaultProps;
451
+ for (H in R)
452
+ M[H] === void 0 && (M[H] = R[H]);
453
453
  }
454
454
  if (S || N) {
455
- var P = typeof a == "function" ? a.displayName || a.name || "Unknown" : a;
456
- S && ke(M, P), N && Le(M, P);
455
+ var P = typeof c == "function" ? c.displayName || c.name || "Unknown" : c;
456
+ S && qe(M, P), N && Re(M, P);
457
457
  }
458
- return He(a, S, N, L, T, _t.current, M);
458
+ return Pe(c, S, N, k, T, $t.current, M);
459
459
  }
460
460
  }
461
- var vt = w.ReactCurrentOwner, Wt = w.ReactDebugCurrentFrame;
462
- function Y(a) {
463
- if (a) {
464
- var f = a._owner, v = nt(a.type, a._source, f ? f.type : null);
465
- Wt.setExtraStackFrame(v);
461
+ var vt = w.ReactCurrentOwner, Ut = w.ReactDebugCurrentFrame;
462
+ function Y(c) {
463
+ if (c) {
464
+ var f = c._owner, v = nt(c.type, c._source, f ? f.type : null);
465
+ Ut.setExtraStackFrame(v);
466
466
  } else
467
- Wt.setExtraStackFrame(null);
467
+ Ut.setExtraStackFrame(null);
468
468
  }
469
469
  var bt;
470
470
  bt = !1;
471
- function yt(a) {
472
- return typeof a == "object" && a !== null && a.$$typeof === t;
471
+ function yt(c) {
472
+ return typeof c == "object" && c !== null && c.$$typeof === t;
473
473
  }
474
474
  function Vt() {
475
475
  {
476
476
  if (vt.current) {
477
- var a = W(vt.current.type);
478
- if (a)
477
+ var c = W(vt.current.type);
478
+ if (c)
479
479
  return `
480
480
 
481
- Check the render method of \`` + a + "`.";
481
+ Check the render method of \`` + c + "`.";
482
482
  }
483
483
  return "";
484
484
  }
485
485
  }
486
- function Ie(a) {
486
+ function Ne(c) {
487
487
  return "";
488
488
  }
489
- var Ut = {};
490
- function qe(a) {
489
+ var zt = {};
490
+ function De(c) {
491
491
  {
492
492
  var f = Vt();
493
493
  if (!f) {
494
- var v = typeof a == "string" ? a : a.displayName || a.name;
494
+ var v = typeof c == "string" ? c : c.displayName || c.name;
495
495
  v && (f = `
496
496
 
497
497
  Check the top-level render call using <` + v + ">.");
@@ -499,41 +499,41 @@ Check the top-level render call using <` + v + ">.");
499
499
  return f;
500
500
  }
501
501
  }
502
- function zt(a, f) {
502
+ function Xt(c, f) {
503
503
  {
504
- if (!a._store || a._store.validated || a.key != null)
504
+ if (!c._store || c._store.validated || c.key != null)
505
505
  return;
506
- a._store.validated = !0;
507
- var v = qe(f);
508
- if (Ut[v])
506
+ c._store.validated = !0;
507
+ var v = De(f);
508
+ if (zt[v])
509
509
  return;
510
- Ut[v] = !0;
510
+ zt[v] = !0;
511
511
  var T = "";
512
- a && a._owner && a._owner !== vt.current && (T = " It was passed a child from " + W(a._owner.type) + "."), Y(a), E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', v, T), Y(null);
512
+ c && c._owner && c._owner !== vt.current && (T = " It was passed a child from " + W(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.', v, T), Y(null);
513
513
  }
514
514
  }
515
- function Xt(a, f) {
515
+ function Yt(c, f) {
516
516
  {
517
- if (typeof a != "object")
517
+ if (typeof c != "object")
518
518
  return;
519
- if (gt(a))
520
- for (var v = 0; v < a.length; v++) {
521
- var T = a[v];
522
- yt(T) && zt(T, f);
519
+ if (gt(c))
520
+ for (var v = 0; v < c.length; v++) {
521
+ var T = c[v];
522
+ yt(T) && Xt(T, f);
523
523
  }
524
- else if (yt(a))
525
- a._store && (a._store.validated = !0);
526
- else if (a) {
527
- var L = x(a);
528
- if (typeof L == "function" && L !== a.entries)
529
- for (var A = L.call(a), M; !(M = A.next()).done; )
530
- yt(M.value) && zt(M.value, f);
524
+ else if (yt(c))
525
+ c._store && (c._store.validated = !0);
526
+ else if (c) {
527
+ var k = x(c);
528
+ if (typeof k == "function" && k !== c.entries)
529
+ for (var H = k.call(c), M; !(M = H.next()).done; )
530
+ yt(M.value) && Xt(M.value, f);
531
531
  }
532
532
  }
533
533
  }
534
- function Re(a) {
534
+ function Oe(c) {
535
535
  {
536
- var f = a.type;
536
+ var f = c.type;
537
537
  if (f == null || typeof f == "string")
538
538
  return;
539
539
  var v;
@@ -541,46 +541,46 @@ Check the top-level render call using <` + v + ">.");
541
541
  v = f.propTypes;
542
542
  else if (typeof f == "object" && (f.$$typeof === o || // Note: Memo only checks outer props here.
543
543
  // Inner props are checked in the reconciler.
544
- f.$$typeof === u))
544
+ f.$$typeof === p))
545
545
  v = f.propTypes;
546
546
  else
547
547
  return;
548
548
  if (v) {
549
549
  var T = W(f);
550
- ye(v, a.props, "prop", T, a);
550
+ Ee(v, c.props, "prop", T, c);
551
551
  } else if (f.PropTypes !== void 0 && !bt) {
552
552
  bt = !0;
553
- var L = W(f);
554
- E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", L || "Unknown");
553
+ var k = W(f);
554
+ E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", k || "Unknown");
555
555
  }
556
556
  typeof f.getDefaultProps == "function" && !f.getDefaultProps.isReactClassApproved && E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
557
557
  }
558
558
  }
559
- function Pe(a) {
559
+ function Ze(c) {
560
560
  {
561
- for (var f = Object.keys(a.props), v = 0; v < f.length; v++) {
561
+ for (var f = Object.keys(c.props), v = 0; v < f.length; v++) {
562
562
  var T = f[v];
563
563
  if (T !== "children" && T !== "key") {
564
- Y(a), E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", T), Y(null);
564
+ Y(c), E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", T), Y(null);
565
565
  break;
566
566
  }
567
567
  }
568
- a.ref !== null && (Y(a), E("Invalid attribute `ref` supplied to `React.Fragment`."), Y(null));
568
+ c.ref !== null && (Y(c), E("Invalid attribute `ref` supplied to `React.Fragment`."), Y(null));
569
569
  }
570
570
  }
571
- var Yt = {};
572
- function Qt(a, f, v, T, L, A) {
571
+ var Gt = {};
572
+ function Qt(c, f, v, T, k, H) {
573
573
  {
574
- var M = ue(a);
574
+ var M = ve(c);
575
575
  if (!M) {
576
576
  var S = "";
577
- (a === void 0 || typeof a == "object" && a !== null && Object.keys(a).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.");
578
- var N = Ie();
577
+ (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.");
578
+ var N = Ne();
579
579
  N ? S += N : S += Vt();
580
580
  var R;
581
- a === null ? R = "null" : gt(a) ? R = "array" : a !== void 0 && a.$$typeof === t ? (R = "<" + (W(a.type) || "Unknown") + " />", S = " Did you accidentally export a JSX literal instead of a component?") : R = typeof a, 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);
581
+ c === null ? R = "null" : gt(c) ? R = "array" : c !== void 0 && c.$$typeof === t ? (R = "<" + (W(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);
582
582
  }
583
- var P = Ae(a, f, v, L, A);
583
+ var P = Be(c, f, v, k, H);
584
584
  if (P == null)
585
585
  return P;
586
586
  if (M) {
@@ -588,44 +588,44 @@ Check the top-level render call using <` + v + ">.");
588
588
  if (_ !== void 0)
589
589
  if (T)
590
590
  if (gt(_)) {
591
- for (var Q = 0; Q < _.length; Q++)
592
- Xt(_[Q], a);
591
+ for (var G = 0; G < _.length; G++)
592
+ Yt(_[G], c);
593
593
  Object.freeze && Object.freeze(_);
594
594
  } else
595
595
  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.");
596
596
  else
597
- Xt(_, a);
597
+ Yt(_, c);
598
598
  }
599
599
  if (K.call(f, "key")) {
600
- var U = W(a), D = Object.keys(f).filter(function(Fe) {
601
- return Fe !== "key";
600
+ var V = W(c), D = Object.keys(f).filter(function(Ue) {
601
+ return Ue !== "key";
602
602
  }), xt = D.length > 0 ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}";
603
- if (!Yt[U + xt]) {
604
- var Oe = D.length > 0 ? "{" + D.join(": ..., ") + ": ...}" : "{}";
603
+ if (!Gt[V + xt]) {
604
+ var We = D.length > 0 ? "{" + D.join(": ..., ") + ": ...}" : "{}";
605
605
  E(`A props object containing a "key" prop is being spread into JSX:
606
606
  let props = %s;
607
607
  <%s {...props} />
608
608
  React keys must be passed directly to JSX without using spread:
609
609
  let props = %s;
610
- <%s key={someKey} {...props} />`, xt, U, Oe, U), Yt[U + xt] = !0;
610
+ <%s key={someKey} {...props} />`, xt, V, We, V), Gt[V + xt] = !0;
611
611
  }
612
612
  }
613
- return a === i ? Pe(P) : Re(P), P;
613
+ return c === i ? Ze(P) : Oe(P), P;
614
614
  }
615
615
  }
616
- function Be(a, f, v) {
617
- return Qt(a, f, v, !0);
616
+ function Fe(c, f, v) {
617
+ return Qt(c, f, v, !0);
618
618
  }
619
- function Ne(a, f, v) {
620
- return Qt(a, f, v, !1);
619
+ function _e(c, f, v) {
620
+ return Qt(c, f, v, !1);
621
621
  }
622
- var De = Ne, Ze = Be;
623
- tt.Fragment = i, tt.jsx = De, tt.jsxs = Ze;
622
+ var $e = _e, je = Fe;
623
+ tt.Fragment = i, tt.jsx = $e, tt.jsxs = je;
624
624
  }()), tt;
625
625
  }
626
- process.env.NODE_ENV === "production" ? Et.exports = je() : Et.exports = We();
627
- var Ve = Et.exports;
628
- const Ue = {
626
+ process.env.NODE_ENV === "production" ? St.exports = Xe() : St.exports = Ye();
627
+ var Ge = St.exports;
628
+ const Qe = {
629
629
  en: {
630
630
  dir: "ltr",
631
631
  file: "File",
@@ -1011,10 +1011,10 @@ const Ue = {
1011
1011
  emcat_flags: "أعلام"
1012
1012
  }
1013
1013
  };
1014
- function Ct(p) {
1015
- return Ue[p];
1014
+ function Ct(u) {
1015
+ return Qe[u];
1016
1016
  }
1017
- const ze = "undo redo | preview print | importword revhistory | fontfamily fontsize | fontsizeincrease fontsizedecrease | bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | link blockquote code changecase lineheight wordspacing letterspacing | removeformat | blocks | ltr rtl | quickimage quickvideo quicktable codesample template charmap emoji | fullscreen sourcecode", Xe = "file edit view insert format tools table help", Ye = [
1017
+ const Ke = "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 = [
1018
1018
  ["Andale Mono", "andale mono,times"],
1019
1019
  ["Arial", "arial,helvetica,sans-serif"],
1020
1020
  ["Arial Black", "arial black,avant garde"],
@@ -1034,7 +1034,7 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
1034
1034
  ["Verdana", "verdana,geneva"],
1035
1035
  ["Webdings", "webdings"],
1036
1036
  ["Wingdings", "wingdings,zapf dingbats"]
1037
- ], Qe = ["8px", "9px", "10px", "11px", "12px", "14px", "16px", "18px", "20px", "24px", "28px", "32px", "36px", "48px", "72px", "96px"], Ge = 1, Ke = 100, Jt = ["1", "1.15", "1.4", "1.5", "1.75", "2", "2.5", "3"], te = ["1px", "2px", "4px", "6px", "8px", "12px"], ee = ["0.5px", "1px", "1.5px", "2px", "3px", "4px"], ie = [
1037
+ ], 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 = [
1038
1038
  ["plain", "Plain text"],
1039
1039
  ["html", "HTML/XML"],
1040
1040
  ["css", "CSS"],
@@ -1051,7 +1051,7 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
1051
1051
  ["rust", "Rust"],
1052
1052
  ["sql", "SQL"],
1053
1053
  ["bash", "Bash/Shell"]
1054
- ], se = [
1054
+ ], ne = [
1055
1055
  ["p", "para"],
1056
1056
  ["h1", "heading1"],
1057
1057
  ["h2", "heading2"],
@@ -1060,7 +1060,7 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
1060
1060
  ["h5", "heading5"],
1061
1061
  ["h6", "heading6"],
1062
1062
  ["pre", "pre"]
1063
- ], Je = ["#F76707", "#4263EB", "#CC5DE8"], ti = [
1063
+ ], ni = ["#F76707", "#4263EB", "#CC5DE8"], ri = [
1064
1064
  "#FFFFFF",
1065
1065
  "#F4F4F4",
1066
1066
  "#E8EAED",
@@ -1086,7 +1086,7 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
1086
1086
  "#8E24AA",
1087
1087
  "#C2185B",
1088
1088
  "#6D4C41"
1089
- ], ei = [
1089
+ ], li = [
1090
1090
  {
1091
1091
  key: "chcat_currency",
1092
1092
  chars: [
@@ -1426,7 +1426,7 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
1426
1426
  "ة"
1427
1427
  ]
1428
1428
  }
1429
- ], ii = [
1429
+ ], oi = [
1430
1430
  {
1431
1431
  key: "emcat_smileys",
1432
1432
  chars: [
@@ -2151,8 +2151,8 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
2151
2151
  "🇲🇦"
2152
2152
  ]
2153
2153
  }
2154
- ], k = (p, t) => `<svg viewBox="${t || "0 0 24 24"}">${p}</svg>`, C = (p) => k(`<path class="f" d="${p}"/>`, "0 -960 960 960"), rt = (p, t = 7.5) => k(
2155
- '<path d="M10 6h10M10 12h10M10 18h10"/>' + p.map(
2154
+ ], L = (u, t) => `<svg viewBox="${t || "0 0 24 24"}">${u}</svg>`, C = (u) => L(`<path class="f" d="${u}"/>`, "0 -960 960 960"), ot = (u, t = 7.5) => L(
2155
+ '<path d="M10 6h10M10 12h10M10 18h10"/>' + u.map(
2156
2156
  (e, i) => `<text x="2.5" y="${8.4 + i * 6}" font-size="${t}" stroke="none" fill="#222f3e" font-family="Arial">${e}</text>`
2157
2157
  ).join("")
2158
2158
  ), h = {
@@ -2198,7 +2198,7 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
2198
2198
  bullist: C(
2199
2199
  "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"
2200
2200
  ),
2201
- chev: k('<path d="M2 3.5 6 7.5 10 3.5"/>', "0 0 12 11"),
2201
+ chev: L('<path d="M2 3.5 6 7.5 10 3.5"/>', "0 0 12 11"),
2202
2202
  backcolor: C(
2203
2203
  "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"
2204
2204
  ),
@@ -2208,7 +2208,7 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
2208
2208
  indent: C(
2209
2209
  "M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"
2210
2210
  ),
2211
- more: k(
2211
+ more: L(
2212
2212
  '<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"/>'
2213
2213
  ),
2214
2214
  image: C(
@@ -2220,17 +2220,17 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
2220
2220
  tableic: C(
2221
2221
  "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"
2222
2222
  ),
2223
- hric: k('<path d="M4 12h16"/>'),
2223
+ hric: L('<path d="M4 12h16"/>'),
2224
2224
  charic: C(
2225
2225
  "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"
2226
2226
  ),
2227
- dateic: k(
2227
+ dateic: L(
2228
2228
  '<rect x="4" y="6" width="16" height="14" rx="1.5"/><path d="M4 10h16M8 4v4M16 4v4"/>'
2229
2229
  ),
2230
2230
  pbic: C(
2231
2231
  "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"
2232
2232
  ),
2233
- nbspic: k('<path d="M6 12v4h12v-4"/>'),
2233
+ nbspic: L('<path d="M6 12v4h12v-4"/>'),
2234
2234
  srcic: C(
2235
2235
  "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"
2236
2236
  ),
@@ -2258,11 +2258,11 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
2258
2258
  subscriptic: C(
2259
2259
  "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"
2260
2260
  ),
2261
- newic: k('<path d="M6 3h8l5 5v13H6z"/><path d="M14 3v5h5"/>'),
2262
- helpic: k(
2261
+ newic: L('<path d="M6 3h8l5 5v13H6z"/><path d="M14 3v5h5"/>'),
2262
+ helpic: L(
2263
2263
  '<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"/>'
2264
2264
  ),
2265
- wcic: k('<path d="M4 6h16M4 10h16M4 14h9"/><path d="M15 17.5l2 2 3.6-4"/>'),
2265
+ wcic: L('<path d="M4 6h16M4 10h16M4 14h9"/><path d="M15 17.5l2 2 3.6-4"/>'),
2266
2266
  rowbefore: C(
2267
2267
  "M200-160h560v-240H200v240Zm640 80H120v-720h160v80h-80v240h560v-240h-80v-80h160v720ZM480-480Zm0 80v-80 80Zm0 0Zm-40-240v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"
2268
2268
  ),
@@ -2314,44 +2314,44 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
2314
2314
  historyic: C(
2315
2315
  "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"
2316
2316
  ),
2317
- wordic: k(
2317
+ wordic: L(
2318
2318
  '<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>'
2319
2319
  ),
2320
2320
  draftic: C(
2321
2321
  "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"
2322
2322
  ),
2323
- trash: k(
2323
+ trash: L(
2324
2324
  '<path d="M5 7h14M10 7V5h4v2M7.5 7l1 13h7l1-13"/>'
2325
2325
  ),
2326
- templateic: k(
2326
+ templateic: L(
2327
2327
  '<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"/>'
2328
2328
  ),
2329
- tplleft: k(
2329
+ tplleft: L(
2330
2330
  '<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"/>'
2331
2331
  ),
2332
- tplright: k(
2332
+ tplright: L(
2333
2333
  '<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"/>'
2334
2334
  ),
2335
- tpltop: k(
2335
+ tpltop: L(
2336
2336
  '<rect x="5" y="3" width="14" height="9" rx=".8"/><path d="M3 15h18M3 18h18M3 21h12"/>'
2337
2337
  ),
2338
- tplcenter: k(
2338
+ tplcenter: L(
2339
2339
  '<path d="M3 4h18M3 7h18M3 10h12"/><rect x="5" y="12.5" width="14" height="9" rx=".8"/>'
2340
2340
  ),
2341
- rotateleft: k(
2341
+ rotateleft: L(
2342
2342
  '<polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>'
2343
2343
  ),
2344
- rotateright: k(
2344
+ rotateright: L(
2345
2345
  '<polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>'
2346
2346
  ),
2347
- fliphorizontal: k(
2347
+ fliphorizontal: L(
2348
2348
  '<path d="M12 3v18"/><path d="M7 8l-4 4 4 4"/><path d="M17 8l4 4-4 4"/>'
2349
2349
  ),
2350
- flipvertical: k(
2350
+ flipvertical: L(
2351
2351
  '<path d="M3 12h18"/><path d="M8 7l4-4 4 4"/><path d="M8 17l4 4 4-4"/>'
2352
2352
  ),
2353
- check: k('<path d="M5 12.5 9.5 17 19 7"/>'),
2354
- palette: k(
2353
+ check: L('<path d="M5 12.5 9.5 17 19 7"/>'),
2354
+ palette: L(
2355
2355
  '<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"/>'
2356
2356
  ),
2357
2357
  ul_circle: C(
@@ -2360,27 +2360,27 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
2360
2360
  ul_square: C(
2361
2361
  "M80-160v-160h160v160H80Zm240 0v-160h560v160H320ZM80-400v-160h160v160H80Zm240 0v-160h560v160H320ZM80-640v-160h160v160H80Zm240 0v-160h560v160H320Z"
2362
2362
  ),
2363
- ol_alpha: rt(["a", "b", "c"]),
2364
- ol_roman: rt(["i", "ii", "iii"], 6.5),
2365
- ol_alphau: rt(["A", "B", "C"]),
2366
- ol_romanu: rt(["I", "II", "III"], 6.5),
2367
- video: k('<rect x="3" y="6" width="13" height="12" rx="1.5"/><path d="M16 10l5-3v10l-5-3z"/>'),
2368
- editic: k('<path d="M4 20l1-4.5L15.5 5 19 8.5 8.5 19 4 20z"/><path d="M13.5 6.5l4 4"/>'),
2369
- letterspacing: k(
2363
+ ol_alpha: ot(["a", "b", "c"]),
2364
+ ol_roman: ot(["i", "ii", "iii"], 6.5),
2365
+ ol_alphau: ot(["A", "B", "C"]),
2366
+ ol_romanu: ot(["I", "II", "III"], 6.5),
2367
+ video: L('<rect x="3" y="6" width="13" height="12" rx="1.5"/><path d="M16 10l5-3v10l-5-3z"/>'),
2368
+ 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"/>'),
2369
+ letterspacing: L(
2370
2370
  '<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"/>'
2371
2371
  ),
2372
- emojiic: k(
2372
+ emojiic: L(
2373
2373
  '<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"/>'
2374
2374
  ),
2375
- inlinecodeic: k('<path d="M8.5 8 4.5 12l4 4M15.5 8l4 4-4 4"/><path d="M13 6l-2 12"/>'),
2376
- moverowup: k('<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"/>'),
2377
- moverowdown: k('<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"/>'),
2378
- movecolleft: k('<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"/>'),
2379
- movecolright: k('<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"/>'),
2380
- codesampleic: k(
2375
+ inlinecodeic: L('<path d="M8.5 8 4.5 12l4 4M15.5 8l4 4-4 4"/><path d="M13 6l-2 12"/>'),
2376
+ 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"/>'),
2377
+ 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"/>'),
2378
+ 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"/>'),
2379
+ 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"/>'),
2380
+ codesampleic: L(
2381
2381
  '<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"/>'
2382
2382
  )
2383
- }, si = /* @__PURE__ */ new Set([
2383
+ }, ai = /* @__PURE__ */ new Set([
2384
2384
  "p",
2385
2385
  "div",
2386
2386
  "span",
@@ -2422,7 +2422,7 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
2422
2422
  "figure",
2423
2423
  "figcaption",
2424
2424
  "mark"
2425
- ]), ni = /* @__PURE__ */ new Set([
2425
+ ]), ci = /* @__PURE__ */ new Set([
2426
2426
  "text-align",
2427
2427
  "direction",
2428
2428
  "unicode-bidi",
@@ -2478,7 +2478,7 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
2478
2478
  "box-sizing",
2479
2479
  "list-style-type",
2480
2480
  "white-space"
2481
- ]), ne = {
2481
+ ]), re = {
2482
2482
  "*": ["dir", "lang", "colspan", "rowspan"],
2483
2483
  a: ["href", "target", "rel", "title"],
2484
2484
  img: ["src", "alt", "width", "height", "title"],
@@ -2487,26 +2487,26 @@ const ze = "undo redo | preview print | importword revhistory | fontfamily fonts
2487
2487
  th: ["width", "valign"],
2488
2488
  table: ["width", "cellpadding", "cellspacing"]
2489
2489
  };
2490
- function ut(p) {
2491
- const t = {}, e = p.getAttribute && p.getAttribute("style");
2490
+ function ut(u) {
2491
+ const t = {}, e = u.getAttribute && u.getAttribute("style");
2492
2492
  return e && e.split(";").forEach((i) => {
2493
2493
  const s = i.indexOf(":");
2494
2494
  s < 1 || (t[i.slice(0, s).trim().toLowerCase()] = i.slice(s + 1).trim());
2495
2495
  }), t;
2496
2496
  }
2497
- function li(p) {
2498
- return p.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, "");
2497
+ function hi(u) {
2498
+ 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, "");
2499
2499
  }
2500
- function oi(p) {
2501
- return /^[0-9]+[\.\)،]/.test(p) ? { ordered: !0 } : /^[٠-٩۰-۹]+/.test(p) ? { ordered: !0, style: "arabic-indic" } : /^[ivxlc]{2,}[\.\)]/.test(p) ? { ordered: !0, style: "lower-roman" } : /^[IVXLC]{2,}[\.\)]/.test(p) ? { ordered: !0, style: "upper-roman" } : /^[a-z][\.\)]/.test(p) ? { ordered: !0, style: "lower-alpha" } : /^[A-Z][\.\)]/.test(p) ? { ordered: !0, style: "upper-alpha" } : /^[ء-ي][\.\)،-]/.test(p) ? { ordered: !0, style: "arabic-indic" } : { ordered: !1 };
2500
+ function di(u) {
2501
+ 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 };
2502
2502
  }
2503
- function ri(p) {
2503
+ function ui(u) {
2504
2504
  const t = (s) => {
2505
2505
  const n = (s.getAttribute("style") || "") + " " + (s.className || "");
2506
2506
  return /mso-list\s*:(?!\s*ignore)/i.test(n) || /MsoListParagraph/i.test(n);
2507
2507
  }, e = [];
2508
2508
  let i = null;
2509
- Array.from(p.body.querySelectorAll("p")).forEach((s) => {
2509
+ Array.from(u.body.querySelectorAll("p")).forEach((s) => {
2510
2510
  if (!t(s)) {
2511
2511
  i = null;
2512
2512
  return;
@@ -2514,67 +2514,67 @@ function ri(p) {
2514
2514
  const n = s.previousElementSibling;
2515
2515
  i && n && i[i.length - 1] === n ? i.push(s) : (i = [s], e.push(i));
2516
2516
  }), e.forEach((s) => {
2517
- const n = [], l = s[0];
2518
- s.forEach((r) => {
2517
+ const n = [], r = s[0];
2518
+ s.forEach((l) => {
2519
2519
  var w, E, I;
2520
- const c = +(((w = (r.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : w[1]) || 1), d = Array.from(r.querySelectorAll("span")).find(
2521
- (H) => /mso-list\s*:\s*ignore/i.test(H.getAttribute("style") || "")
2522
- ), u = d ? ((E = d.textContent) == null ? void 0 : E.trim()) || "" : (((I = r.textContent) == null ? void 0 : I.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: m, style: b } = oi(u);
2523
- for (d && d.remove(); n.length && n[n.length - 1].level > c; ) n.pop();
2524
- if (!n.length || n[n.length - 1].level < c) {
2525
- const H = p.createElement(m ? "ol" : "ul");
2526
- if (m && b && (H.style.listStyleType = b), n.length) {
2520
+ const a = +(((w = (l.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : w[1]) || 1), d = Array.from(l.querySelectorAll("span")).find(
2521
+ (A) => /mso-list\s*:\s*ignore/i.test(A.getAttribute("style") || "")
2522
+ ), p = d ? ((E = d.textContent) == null ? void 0 : E.trim()) || "" : (((I = l.textContent) == null ? void 0 : I.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: m, style: b } = di(p);
2523
+ for (d && d.remove(); n.length && n[n.length - 1].level > a; ) n.pop();
2524
+ if (!n.length || n[n.length - 1].level < a) {
2525
+ const A = u.createElement(m ? "ol" : "ul");
2526
+ if (m && b && (A.style.listStyleType = b), n.length) {
2527
2527
  const $ = n[n.length - 1].list;
2528
- ($.lastElementChild || $).appendChild(H);
2528
+ ($.lastElementChild || $).appendChild(A);
2529
2529
  } else
2530
- l.parentNode.insertBefore(H, l);
2531
- n.push({ list: H, level: c });
2530
+ r.parentNode.insertBefore(A, r);
2531
+ n.push({ list: A, level: a });
2532
2532
  }
2533
- const y = p.createElement("li"), g = ut(r), x = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((H) => g[H]).map((H) => H + ":" + g[H]).join(";");
2534
- for (x && y.setAttribute("style", x), r.getAttribute("dir") && y.setAttribute("dir", r.getAttribute("dir")); r.firstChild; ) y.appendChild(r.firstChild);
2535
- n[n.length - 1].list.appendChild(y), r.remove();
2533
+ const y = u.createElement("li"), g = ut(l), x = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((A) => g[A]).map((A) => A + ":" + g[A]).join(";");
2534
+ for (x && y.setAttribute("style", x), l.getAttribute("dir") && y.setAttribute("dir", l.getAttribute("dir")); l.firstChild; ) y.appendChild(l.firstChild);
2535
+ n[n.length - 1].list.appendChild(y), l.remove();
2536
2536
  });
2537
2537
  });
2538
2538
  }
2539
- function ai(p) {
2540
- p.querySelectorAll('b[id^="docs-internal-guid"]').forEach((t) => {
2539
+ function pi(u) {
2540
+ u.querySelectorAll('b[id^="docs-internal-guid"]').forEach((t) => {
2541
2541
  for (; t.firstChild; ) t.parentNode.insertBefore(t.firstChild, t);
2542
2542
  t.remove();
2543
2543
  });
2544
2544
  }
2545
- function ci(p) {
2546
- p.querySelectorAll("table").forEach((t) => {
2545
+ function mi(u) {
2546
+ u.querySelectorAll("table").forEach((t) => {
2547
2547
  const e = t;
2548
2548
  ut(e)["border-collapse"] || (e.style.borderCollapse = "collapse");
2549
- }), p.querySelectorAll("[align]").forEach((t) => {
2549
+ }), u.querySelectorAll("[align]").forEach((t) => {
2550
2550
  const e = t, i = e.getAttribute("align").toLowerCase();
2551
2551
  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) => {
2552
2552
  if (s.tagName.toLowerCase() !== "table") return;
2553
2553
  const n = s;
2554
2554
  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");
2555
2555
  })), e.removeAttribute("align");
2556
- }), p.querySelectorAll("center table").forEach((t) => {
2556
+ }), u.querySelectorAll("center table").forEach((t) => {
2557
2557
  const e = t;
2558
2558
  e.style.marginLeft = e.style.marginLeft || "auto", e.style.marginRight = e.style.marginRight || "auto";
2559
- }), p.querySelectorAll("[bgcolor]").forEach((t) => {
2559
+ }), u.querySelectorAll("[bgcolor]").forEach((t) => {
2560
2560
  const e = t;
2561
2561
  e.style.backgroundColor = e.style.backgroundColor || e.getAttribute("bgcolor"), e.removeAttribute("bgcolor");
2562
2562
  });
2563
2563
  }
2564
- function ht(p, t) {
2565
- Array.from(p.childNodes).forEach((e) => {
2564
+ function ht(u, t) {
2565
+ Array.from(u.childNodes).forEach((e) => {
2566
2566
  if (e.nodeType === Node.COMMENT_NODE) {
2567
2567
  e.remove();
2568
2568
  return;
2569
2569
  }
2570
2570
  if (e.nodeType !== Node.ELEMENT_NODE) return;
2571
2571
  const i = e, s = i.tagName.toLowerCase();
2572
- if (!si.has(s)) {
2572
+ if (!ai.has(s)) {
2573
2573
  if (s === "font") {
2574
2574
  const o = t.createElement("span");
2575
2575
  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"));
2576
- const c = i.getAttribute("size");
2577
- if (c && !o.style.fontSize) {
2576
+ const a = i.getAttribute("size");
2577
+ if (a && !o.style.fontSize) {
2578
2578
  const d = {
2579
2579
  1: "8pt",
2580
2580
  2: "10pt",
@@ -2584,7 +2584,7 @@ function ht(p, t) {
2584
2584
  6: "24pt",
2585
2585
  7: "36pt"
2586
2586
  };
2587
- d[c] && (o.style.fontSize = d[c]);
2587
+ d[a] && (o.style.fontSize = d[a]);
2588
2588
  }
2589
2589
  for (; i.firstChild; ) o.appendChild(i.firstChild);
2590
2590
  i.replaceWith(o), ht(o, t);
@@ -2594,10 +2594,10 @@ function ht(p, t) {
2594
2594
  i.remove();
2595
2595
  return;
2596
2596
  }
2597
- const n = /* @__PURE__ */ new Set([...ne["*"] || [], ...ne[s] || []]);
2597
+ const n = /* @__PURE__ */ new Set([...re["*"] || [], ...re[s] || []]);
2598
2598
  if (Array.from(i.attributes).forEach((o) => {
2599
- const c = o.name.toLowerCase();
2600
- c !== "style" && !n.has(c) && i.removeAttribute(o.name);
2599
+ const a = o.name.toLowerCase();
2600
+ a !== "style" && !n.has(a) && i.removeAttribute(o.name);
2601
2601
  }), s === "a") {
2602
2602
  const o = i.getAttribute("href") || "";
2603
2603
  /^(https?:|mailto:|tel:|#)/i.test(o) || i.removeAttribute("href");
@@ -2605,130 +2605,233 @@ function ht(p, t) {
2605
2605
  if (s === "img") {
2606
2606
  const o = i.getAttribute("src") || "";
2607
2607
  if (!/^(https?:|data:image\/|blob:)/i.test(o)) {
2608
- const c = t.createElement("span");
2609
- c.textContent = "[local image — paste it separately]", c.setAttribute("style", "color:#a33;font-style:italic;font-size:12px"), i.replaceWith(c);
2608
+ const a = t.createElement("span");
2609
+ a.textContent = "[local image — paste it separately]", a.setAttribute("style", "color:#a33;font-style:italic;font-size:12px"), i.replaceWith(a);
2610
2610
  return;
2611
2611
  }
2612
2612
  }
2613
- const l = ut(i), r = [];
2614
- for (const [o, c] of Object.entries(l))
2615
- ni.has(o) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(c) || o === "font-weight" && /^(400|normal)$/i.test(c) || o === "font-style" && /^normal$/i.test(c) || o === "text-decoration" && /^none$/i.test(c) || r.push(o + ":" + c));
2616
- if (r.length ? i.setAttribute("style", r.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), ht(i, t), s === "span" && !i.attributes.length) {
2613
+ const r = ut(i), l = [];
2614
+ for (const [o, a] of Object.entries(r))
2615
+ 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) || l.push(o + ":" + a));
2616
+ if (l.length ? i.setAttribute("style", l.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), ht(i, t), s === "span" && !i.attributes.length) {
2617
2617
  for (; i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
2618
2618
  i.remove();
2619
2619
  }
2620
2620
  });
2621
2621
  }
2622
- function hi(p) {
2622
+ function fi(u) {
2623
2623
  const t = [], e = /<style[^>]*>([\s\S]*?)<\/style>/gi;
2624
2624
  let i;
2625
- for (; i = e.exec(p); ) {
2625
+ for (; i = e.exec(u); ) {
2626
2626
  let s = i[1].replace(/<!--|-->/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
2627
2627
  s = s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi, ""), s = s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g, "");
2628
2628
  let n;
2629
- const l = /([^{}]+)\{([^}]*)\}/g;
2630
- for (; n = l.exec(s); ) {
2631
- const r = n[2].split(";").map((o) => {
2632
- const c = o.indexOf(":");
2633
- return c < 1 ? null : [o.slice(0, c).trim().toLowerCase(), o.slice(c + 1).trim()];
2629
+ const r = /([^{}]+)\{([^}]*)\}/g;
2630
+ for (; n = r.exec(s); ) {
2631
+ const l = n[2].split(";").map((o) => {
2632
+ const a = o.indexOf(":");
2633
+ return a < 1 ? null : [o.slice(0, a).trim().toLowerCase(), o.slice(a + 1).trim()];
2634
2634
  }).filter((o) => !!o && !!o[1]);
2635
- r.length && n[1].split(",").map((o) => o.trim()).filter((o) => o && !o.startsWith("@")).forEach((o) => t.push({ sel: o, decls: r }));
2635
+ l.length && n[1].split(",").map((o) => o.trim()).filter((o) => o && !o.startsWith("@")).forEach((o) => t.push({ sel: o, decls: l }));
2636
2636
  }
2637
2637
  }
2638
2638
  return t;
2639
2639
  }
2640
- function di(p, t) {
2640
+ function gi(u, t) {
2641
2641
  if (!t.length) return;
2642
2642
  const e = /* @__PURE__ */ new Map();
2643
2643
  t.forEach(({ sel: i, decls: s }) => {
2644
2644
  let n;
2645
2645
  try {
2646
- n = p.querySelectorAll(i);
2646
+ n = u.querySelectorAll(i);
2647
2647
  } catch {
2648
2648
  return;
2649
2649
  }
2650
- n.forEach((l) => {
2651
- let r = e.get(l);
2652
- r || (r = {}, e.set(l, r)), s.forEach(([o, c]) => {
2653
- r[o] = c;
2650
+ n.forEach((r) => {
2651
+ let l = e.get(r);
2652
+ l || (l = {}, e.set(r, l)), s.forEach(([o, a]) => {
2653
+ l[o] = a;
2654
2654
  });
2655
2655
  });
2656
2656
  }), e.forEach((i, s) => {
2657
- const n = ut(s), l = s.hasAttribute("dir"), r = s.hasAttribute("align"), o = Object.entries(i).filter(([u]) => !(u in n || (u === "direction" || u === "unicode-bidi") && l || u === "text-align" && (r || l) || (u === "background" || u === "background-color") && s.hasAttribute("bgcolor")));
2657
+ const n = ut(s), r = s.hasAttribute("dir"), l = s.hasAttribute("align"), o = Object.entries(i).filter(([p]) => !(p in n || (p === "direction" || p === "unicode-bidi") && r || p === "text-align" && (l || r) || (p === "background" || p === "background-color") && s.hasAttribute("bgcolor")));
2658
2658
  if (!o.length) return;
2659
- const c = o.map(([u, m]) => u + ":" + m).join(";"), d = s.getAttribute("style");
2660
- s.setAttribute("style", d ? c + ";" + d : c);
2659
+ const a = o.map(([p, m]) => p + ":" + m).join(";"), d = s.getAttribute("style");
2660
+ s.setAttribute("style", d ? a + ";" + d : a);
2661
2661
  });
2662
2662
  }
2663
- function he(p) {
2664
- return p.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g, (t) => t.normalize("NFKC"));
2663
+ function pe(u) {
2664
+ return u.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g, (t) => t.normalize("NFKC"));
2665
2665
  }
2666
- function ui(p) {
2667
- const t = p.createTreeWalker(p.body, NodeFilter.SHOW_TEXT, null);
2666
+ function vi(u) {
2667
+ const t = u.createTreeWalker(u.body, NodeFilter.SHOW_TEXT, null);
2668
2668
  let e;
2669
2669
  for (; e = t.nextNode(); )
2670
- /[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue = he(e.nodeValue || ""));
2670
+ /[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue = pe(e.nodeValue || ""));
2671
2671
  }
2672
- function pi(p, t = "ltr") {
2673
- const e = hi(p), i = new DOMParser().parseFromString(li(p), "text/html");
2674
- di(i, e), /class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML) && ri(i), ai(i), ci(i), ht(i.body, i), ui(i);
2672
+ function bi(u, t = "ltr") {
2673
+ const e = fi(u), i = new DOMParser().parseFromString(hi(u), "text/html");
2674
+ 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);
2675
2675
  const s = (n) => {
2676
- var l;
2677
- return n && n.tagName === "P" && !((l = n.textContent) != null && l.trim()) && !n.querySelector("img,table");
2676
+ var r;
2677
+ return n && n.tagName === "P" && !((r = n.textContent) != null && r.trim()) && !n.querySelector("img,table");
2678
2678
  };
2679
2679
  for (; s(i.body.firstElementChild); ) i.body.firstElementChild.remove();
2680
2680
  for (; s(i.body.lastElementChild); ) i.body.lastElementChild.remove();
2681
2681
  return i.body.innerHTML.trim();
2682
2682
  }
2683
- function mi(p) {
2684
- const t = he(p).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2683
+ function yi(u) {
2684
+ const t = pe(u).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2685
2685
  return /\n/.test(t) ? t.split(/\n{2,}/).map((i) => `<p dir="auto">${e(i).replace(/\n/g, "<br>") || "<br>"}</p>`).join("") : e(t);
2686
2686
  }
2687
- function fi(p) {
2688
- const t = new DataView(p), e = /* @__PURE__ */ new Map();
2687
+ const xi = 10 * 1024 * 1024, me = /^(https?:|data:image\/|blob:)/i;
2688
+ function le(u, t) {
2689
+ const e = [], i = "{\\" + t;
2690
+ let s = 0;
2691
+ for (; (s = u.indexOf(i, s)) !== -1; ) {
2692
+ const n = u[s + i.length];
2693
+ if (n && /[a-z0-9]/i.test(n)) {
2694
+ s += i.length;
2695
+ continue;
2696
+ }
2697
+ let r = 0, l = s;
2698
+ for (; l < u.length; l++) {
2699
+ const o = u[l];
2700
+ if (o === "\\") {
2701
+ l++;
2702
+ continue;
2703
+ }
2704
+ if (o === "{") r++;
2705
+ else if (o === "}" && (r--, !r))
2706
+ break;
2707
+ }
2708
+ e.push({ start: s, end: l + 1, body: u.slice(s + i.length, l) }), s = l + 1;
2709
+ }
2710
+ return e;
2711
+ }
2712
+ function Ci(u) {
2713
+ const t = new Uint8Array(u.length / 2);
2714
+ for (let e = 0; e < t.length; e++) t[e] = parseInt(u.substr(e * 2, 2), 16);
2715
+ return t;
2716
+ }
2717
+ function wt(u) {
2718
+ let t = "";
2719
+ for (let e = 0; e < u.length; e++) t += String.fromCharCode(u[e]);
2720
+ return btoa(t);
2721
+ }
2722
+ function oe(u, t) {
2723
+ t: for (let e = 0; e + t.length <= u.length; e++) {
2724
+ for (let i = 0; i < t.length; i++) if (u[e + i] !== t[i]) continue t;
2725
+ return e;
2726
+ }
2727
+ return -1;
2728
+ }
2729
+ const wi = [137, 80, 78, 71], Ti = [255, 216, 255];
2730
+ function Ei(u) {
2731
+ let t = null;
2732
+ 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;
2733
+ let e = u.replace(/\{[^{}]*\}/g, "").replace(/\\[a-z]+-?\d*\s?/gi, "").replace(/[^0-9a-fA-F]/g, "");
2734
+ if (e.length % 2 && (e = e.slice(0, -1)), !e) return null;
2735
+ const i = Ci(e);
2736
+ if (t === "metafile") {
2737
+ const s = oe(i, wi);
2738
+ if (s >= 0) return "data:image/png;base64," + wt(i.slice(s));
2739
+ const n = oe(i, Ti);
2740
+ return n >= 0 ? "data:image/jpeg;base64," + wt(i.slice(n)) : null;
2741
+ }
2742
+ return "data:" + t + ";base64," + wt(i);
2743
+ }
2744
+ function Si(u) {
2745
+ if (!u || u.indexOf("\\pict") === -1) return [];
2746
+ let t = u;
2747
+ le(u, "nonshppict").reverse().forEach((i) => {
2748
+ t = t.slice(0, i.start) + t.slice(i.end);
2749
+ });
2750
+ let e = xi;
2751
+ return le(t, "pict").map((i) => {
2752
+ if (e <= 0) return null;
2753
+ const s = Ei(i.body);
2754
+ return s && (e -= s.length * 0.75), s;
2755
+ });
2756
+ }
2757
+ function fe(u, t) {
2758
+ if (!u || !t.length) return { html: u, injected: [] };
2759
+ const e = [];
2760
+ let i = 0;
2761
+ return { html: u.replace(/<img\b[^>]*>/gi, (n) => {
2762
+ const r = (n.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2763
+ if (me.test(r)) return n;
2764
+ const l = t[i++];
2765
+ return l ? (e.push(l), /\ssrc\s*=\s*["']/i.test(n) ? n.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i, '$1"' + l + '"') : n.replace(/(\ssrc\s*=\s*)[^\s>]+/i, '$1"' + l + '"')) : n;
2766
+ }), injected: e };
2767
+ }
2768
+ function Mi(u, t) {
2769
+ return !u || !t ? { html: u, injected: [] } : fe(u, Si(t));
2770
+ }
2771
+ function Li(u) {
2772
+ const t = u.match(/<img\b[^>]*>/gi);
2773
+ return t ? t.filter((e) => {
2774
+ const i = (e.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
2775
+ return !me.test(i);
2776
+ }).length : 0;
2777
+ }
2778
+ function ki(u, t) {
2779
+ const e = u.match(/^data:([^;,]+);base64,(.*)$/);
2780
+ if (!e) return null;
2781
+ const i = (e[1].split("/")[1] || "png").replace(/[^a-z0-9]/gi, "") || "png";
2782
+ try {
2783
+ const s = atob(e[2]), n = new Uint8Array(s.length);
2784
+ for (let r = 0; r < s.length; r++) n[r] = s.charCodeAt(r);
2785
+ return new File([n], t + "." + (i === "jpeg" ? "jpg" : i), { type: e[1] });
2786
+ } catch {
2787
+ return null;
2788
+ }
2789
+ }
2790
+ function Ai(u) {
2791
+ const t = new DataView(u), e = /* @__PURE__ */ new Map();
2689
2792
  let i = -1;
2690
- for (let r = p.byteLength - 22; r >= Math.max(0, p.byteLength - 22 - 65535); r--)
2691
- if (t.getUint32(r, !0) === 101010256) {
2692
- i = r;
2793
+ for (let l = u.byteLength - 22; l >= Math.max(0, u.byteLength - 22 - 65535); l--)
2794
+ if (t.getUint32(l, !0) === 101010256) {
2795
+ i = l;
2693
2796
  break;
2694
2797
  }
2695
2798
  if (i < 0) throw new Error("EOCD not found");
2696
2799
  const s = t.getUint16(i + 10, !0);
2697
2800
  let n = t.getUint32(i + 16, !0);
2698
- const l = new TextDecoder();
2699
- for (let r = 0; r < s && t.getUint32(n, !0) === 33639248; r++) {
2700
- const o = t.getUint16(n + 10, !0), c = t.getUint32(n + 20, !0), d = t.getUint16(n + 28, !0), u = t.getUint16(n + 30, !0), m = t.getUint16(n + 32, !0), b = t.getUint32(n + 42, !0), y = l.decode(new Uint8Array(p, n + 46, d));
2701
- e.set(y, { name: y, method: o, compSize: c, localOffset: b }), n += 46 + d + u + m;
2801
+ const r = new TextDecoder();
2802
+ for (let l = 0; l < s && t.getUint32(n, !0) === 33639248; l++) {
2803
+ const o = 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), b = t.getUint32(n + 42, !0), y = r.decode(new Uint8Array(u, n + 46, d));
2804
+ e.set(y, { name: y, method: o, compSize: a, localOffset: b }), n += 46 + d + p + m;
2702
2805
  }
2703
2806
  return e;
2704
2807
  }
2705
- async function le(p, t) {
2706
- const e = new DataView(p, t.localOffset);
2808
+ async function ae(u, t) {
2809
+ const e = new DataView(u, t.localOffset);
2707
2810
  if (e.getUint32(0, !0) !== 67324752) throw new Error("Bad local header");
2708
- const i = e.getUint16(26, !0), s = e.getUint16(28, !0), n = t.localOffset + 30 + i + s, l = new Uint8Array(p.slice(n, n + t.compSize));
2709
- if (t.method === 0) return l;
2811
+ 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));
2812
+ if (t.method === 0) return r;
2710
2813
  if (t.method !== 8) throw new Error("Unsupported compression method " + t.method);
2711
- const r = new Blob([l]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
2712
- return new Uint8Array(await new Response(r).arrayBuffer());
2814
+ const l = new Blob([r]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
2815
+ return new Uint8Array(await new Response(l).arrayBuffer());
2713
2816
  }
2714
- const oe = (p) => p.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), dt = (p, t) => Array.from(p.children).filter((e) => e.localName === t), B = (p, ...t) => {
2715
- let e = p;
2817
+ const ce = (u) => u.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), dt = (u, t) => Array.from(u.children).filter((e) => e.localName === t), B = (u, ...t) => {
2818
+ let e = u;
2716
2819
  for (const i of t) {
2717
2820
  if (!e) return null;
2718
2821
  e = Array.from(e.children).find((s) => s.localName === i) || null;
2719
2822
  }
2720
2823
  return e;
2721
- }, q = (p, t = "val") => {
2722
- if (!p) return "";
2723
- for (const e of Array.from(p.attributes))
2824
+ }, q = (u, t = "val") => {
2825
+ if (!u) return "";
2826
+ for (const e of Array.from(u.attributes))
2724
2827
  if (e.localName === t) return e.value;
2725
2828
  return "";
2726
- }, at = (p, t) => {
2727
- const e = p ? B(p, t) : null;
2829
+ }, at = (u, t) => {
2830
+ const e = u ? B(u, t) : null;
2728
2831
  if (!e) return !1;
2729
2832
  const i = q(e);
2730
2833
  return i !== "false" && i !== "0";
2731
- }, re = {
2834
+ }, he = {
2732
2835
  yellow: "#FFFF00",
2733
2836
  green: "#00FF00",
2734
2837
  cyan: "#00FFFF",
@@ -2745,7 +2848,7 @@ const oe = (p) => p.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "
2745
2848
  lightGray: "#D3D3D3",
2746
2849
  black: "#000000",
2747
2850
  white: "#FFFFFF"
2748
- }, gi = {
2851
+ }, Hi = {
2749
2852
  png: "image/png",
2750
2853
  jpg: "image/jpeg",
2751
2854
  jpeg: "image/jpeg",
@@ -2753,13 +2856,13 @@ const oe = (p) => p.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "
2753
2856
  bmp: "image/bmp",
2754
2857
  webp: "image/webp"
2755
2858
  };
2756
- function vi(p) {
2859
+ function Ii(u) {
2757
2860
  let t = "";
2758
- for (let e = 0; e < p.length; e += 32768)
2759
- t += String.fromCharCode(...p.subarray(e, e + 32768));
2861
+ for (let e = 0; e < u.length; e += 32768)
2862
+ t += String.fromCharCode(...u.subarray(e, e + 32768));
2760
2863
  return btoa(t);
2761
2864
  }
2762
- class bi {
2865
+ class qi {
2763
2866
  constructor(t, e, i) {
2764
2867
  this.rels = t, this.images = e, this.numFmt = i;
2765
2868
  }
@@ -2770,12 +2873,12 @@ class bi {
2770
2873
  };
2771
2874
  for (const n of Array.from(t.children))
2772
2875
  if (n.localName === "p") {
2773
- const l = this.paraList(n);
2774
- if (l) {
2775
- const r = l.ilvl + 1;
2776
- for (; i.length > r; ) e += `</${i.pop()}>`;
2777
- for (i.length === r && i[r - 1] !== l.type && (e += `</${i.pop()}>`); i.length < r; )
2778
- e += `<${l.type}>`, i.push(l.type);
2876
+ const r = this.paraList(n);
2877
+ if (r) {
2878
+ const l = r.ilvl + 1;
2879
+ for (; i.length > l; ) e += `</${i.pop()}>`;
2880
+ for (i.length === l && i[l - 1] !== r.type && (e += `</${i.pop()}>`); i.length < l; )
2881
+ e += `<${r.type}>`, i.push(r.type);
2779
2882
  e += `<li>${this.runsOf(n) || "<br>"}</li>`;
2780
2883
  continue;
2781
2884
  }
@@ -2796,10 +2899,10 @@ class bi {
2796
2899
  let s = "p";
2797
2900
  const n = /^Heading([1-6])$/i.exec(i);
2798
2901
  n ? s = "h" + n[1] : /^Title$/i.test(i) && (s = "h1");
2799
- const l = [], r = q(B(t, "pPr", "jc"));
2800
- 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");
2801
- const o = this.runsOf(t), c = l.length ? ` style="${l.join(";")}"` : "";
2802
- return `<${s}${c}>${o || "<br>"}</${s}>`;
2902
+ const r = [], l = q(B(t, "pPr", "jc"));
2903
+ l === "center" ? r.push("text-align:center") : l === "right" || l === "end" ? r.push("text-align:right") : (l === "both" || l === "distribute") && r.push("text-align:justify"), e && B(e, "bidi") && r.push("direction:rtl");
2904
+ const o = this.runsOf(t), a = r.length ? ` style="${r.join(";")}"` : "";
2905
+ return `<${s}${a}>${o || "<br>"}</${s}>`;
2803
2906
  }
2804
2907
  runsOf(t) {
2805
2908
  let e = "";
@@ -2809,88 +2912,88 @@ class bi {
2809
2912
  let s = this.rels.get(q(i, "id")) || "";
2810
2913
  const n = q(i, "anchor");
2811
2914
  !s && n && (s = "#" + n);
2812
- const l = this.runsOf(i);
2813
- e += s ? `<a href="${oe(s)}">${l}</a>` : l;
2915
+ const r = this.runsOf(i);
2916
+ e += s ? `<a href="${ce(s)}">${r}</a>` : r;
2814
2917
  } else (i.localName === "smartTag" || i.localName === "ins") && (e += this.runsOf(i));
2815
2918
  return e;
2816
2919
  }
2817
2920
  convertRun(t) {
2818
2921
  const e = B(t, "rPr");
2819
2922
  let i = "";
2820
- for (const u of Array.from(t.children))
2821
- u.localName === "t" ? i += oe(u.textContent || "") : u.localName === "br" || u.localName === "cr" ? i += "<br>" : u.localName === "tab" ? i += "&emsp;" : (u.localName === "drawing" || u.localName === "pict" || u.localName === "object") && (i += this.convertImage(u));
2923
+ for (const p of Array.from(t.children))
2924
+ p.localName === "t" ? i += ce(p.textContent || "") : p.localName === "br" || p.localName === "cr" ? i += "<br>" : p.localName === "tab" ? i += "&emsp;" : (p.localName === "drawing" || p.localName === "pict" || p.localName === "object") && (i += this.convertImage(p));
2822
2925
  if (!i) return "";
2823
2926
  const s = [], n = q(e ? B(e, "color") : null);
2824
2927
  n && n !== "auto" && s.push("color:#" + n);
2825
- const l = q(e ? B(e, "highlight") : null);
2826
- l && re[l] && s.push("background-color:" + re[l]);
2827
- const r = parseFloat(q(e ? B(e, "sz") : null));
2828
- r && s.push("font-size:" + Math.round(r / 2 * (4 / 3)) + "px");
2829
- const o = e ? B(e, "rFonts") : null, c = q(o, "ascii") || q(o, "cs");
2830
- c && s.push(`font-family:'${c}'`), s.length && (i = `<span style="${s.join(";")}">${i}</span>`), at(e, "b") && (i = `<strong>${i}</strong>`), at(e, "i") && (i = `<em>${i}</em>`), at(e, "u") && q(B(e, "u")) !== "none" && (i = `<u>${i}</u>`), at(e, "strike") && (i = `<s>${i}</s>`);
2928
+ const r = q(e ? B(e, "highlight") : null);
2929
+ r && he[r] && s.push("background-color:" + he[r]);
2930
+ const l = parseFloat(q(e ? B(e, "sz") : null));
2931
+ l && s.push("font-size:" + Math.round(l / 2 * (4 / 3)) + "px");
2932
+ const o = e ? B(e, "rFonts") : null, a = q(o, "ascii") || q(o, "cs");
2933
+ a && s.push(`font-family:'${a}'`), s.length && (i = `<span style="${s.join(";")}">${i}</span>`), at(e, "b") && (i = `<strong>${i}</strong>`), at(e, "i") && (i = `<em>${i}</em>`), at(e, "u") && q(B(e, "u")) !== "none" && (i = `<u>${i}</u>`), at(e, "strike") && (i = `<s>${i}</s>`);
2831
2934
  const d = q(e ? B(e, "vertAlign") : null);
2832
2935
  return d === "superscript" ? i = `<sup>${i}</sup>` : d === "subscript" && (i = `<sub>${i}</sub>`), i;
2833
2936
  }
2834
2937
  convertImage(t) {
2835
2938
  let e = "", i = 0;
2836
- const s = (r) => {
2837
- if (r.localName === "blip" && (e = e || q(r, "embed") || q(r, "link")), r.localName === "imagedata" && (e = e || q(r, "id")), r.localName === "extent") {
2838
- const o = parseFloat(r.getAttribute("cx") || "0");
2939
+ const s = (l) => {
2940
+ if (l.localName === "blip" && (e = e || q(l, "embed") || q(l, "link")), l.localName === "imagedata" && (e = e || q(l, "id")), l.localName === "extent") {
2941
+ const o = parseFloat(l.getAttribute("cx") || "0");
2839
2942
  o && (i = Math.round(o / 9525));
2840
2943
  }
2841
- for (const o of Array.from(r.children)) s(o);
2944
+ for (const o of Array.from(l.children)) s(o);
2842
2945
  };
2843
2946
  if (s(t), !e) return "";
2844
2947
  const n = this.images.get(e);
2845
2948
  if (!n) return "";
2846
- const l = i ? ` width="${i}"` : "";
2847
- return `<img src="${n}" alt=""${l}>`;
2949
+ const r = i ? ` width="${i}"` : "";
2950
+ return `<img src="${n}" alt=""${r}>`;
2848
2951
  }
2849
2952
  convertTable(t) {
2850
2953
  let e = '<table style="border-collapse:collapse;width:100%"><tbody>';
2851
2954
  for (const i of dt(t, "tr")) {
2852
2955
  e += "<tr>";
2853
2956
  for (const s of dt(i, "tc")) {
2854
- const n = parseInt(q(B(s, "tcPr", "gridSpan")) || "1", 10) || 1, l = n > 1 ? ` colspan="${n}"` : "";
2855
- let r = "";
2957
+ const n = parseInt(q(B(s, "tcPr", "gridSpan")) || "1", 10) || 1, r = n > 1 ? ` colspan="${n}"` : "";
2958
+ let l = "";
2856
2959
  for (const o of Array.from(s.children))
2857
- o.localName === "p" ? r += this.convertPara(o) : o.localName === "tbl" && (r += this.convertTable(o));
2858
- e += `<td style="border:1px solid #b9c2cc"${l}>${r || "<br>"}</td>`;
2960
+ o.localName === "p" ? l += this.convertPara(o) : o.localName === "tbl" && (l += this.convertTable(o));
2961
+ e += `<td style="border:1px solid #b9c2cc"${r}>${l || "<br>"}</td>`;
2859
2962
  }
2860
2963
  e += "</tr>";
2861
2964
  }
2862
2965
  return e + "</tbody></table>";
2863
2966
  }
2864
2967
  }
2865
- async function yi(p) {
2866
- const t = p instanceof ArrayBuffer ? p : await p.arrayBuffer(), e = fi(t), i = new TextDecoder(), s = async (y) => {
2968
+ async function Ri(u) {
2969
+ const t = u instanceof ArrayBuffer ? u : await u.arrayBuffer(), e = Ai(t), i = new TextDecoder(), s = async (y) => {
2867
2970
  const g = e.get(y);
2868
- return g ? new DOMParser().parseFromString(i.decode(await le(t, g)), "application/xml") : null;
2869
- }, n = await s("word/document.xml"), l = n == null ? void 0 : n.getElementsByTagName("*");
2870
- let r = null;
2871
- if (l) {
2872
- for (const y of Array.from(l))
2971
+ return g ? new DOMParser().parseFromString(i.decode(await ae(t, g)), "application/xml") : null;
2972
+ }, n = await s("word/document.xml"), r = n == null ? void 0 : n.getElementsByTagName("*");
2973
+ let l = null;
2974
+ if (r) {
2975
+ for (const y of Array.from(r))
2873
2976
  if (y.localName === "body") {
2874
- r = y;
2977
+ l = y;
2875
2978
  break;
2876
2979
  }
2877
2980
  }
2878
- if (!r) throw new Error("word/document.xml missing or invalid");
2879
- const o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), d = await s("word/_rels/document.xml.rels");
2981
+ if (!l) throw new Error("word/document.xml missing or invalid");
2982
+ const o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), d = await s("word/_rels/document.xml.rels");
2880
2983
  if (d)
2881
2984
  for (const y of Array.from(d.getElementsByTagName("*"))) {
2882
2985
  if (y.localName !== "Relationship") continue;
2883
2986
  const g = y.getAttribute("Id") || "", x = y.getAttribute("Target") || "", w = y.getAttribute("Type") || "";
2884
- /hyperlink/i.test(w) ? o.set(g, x) : /image/i.test(w) && c.set(g, x);
2987
+ /hyperlink/i.test(w) ? o.set(g, x) : /image/i.test(w) && a.set(g, x);
2885
2988
  }
2886
- const u = /* @__PURE__ */ new Map();
2887
- for (const [y, g] of c) {
2989
+ const p = /* @__PURE__ */ new Map();
2990
+ for (const [y, g] of a) {
2888
2991
  const x = g.startsWith("/") ? g.slice(1) : "word/" + g.replace(/^\.\//, ""), w = e.get(x);
2889
2992
  if (!w) continue;
2890
- const E = (x.split(".").pop() || "").toLowerCase(), I = gi[E];
2993
+ const E = (x.split(".").pop() || "").toLowerCase(), I = Hi[E];
2891
2994
  if (I)
2892
2995
  try {
2893
- u.set(y, `data:${I};base64,${vi(await le(t, w))}`);
2996
+ p.set(y, `data:${I};base64,${Ii(await ae(t, w))}`);
2894
2997
  } catch {
2895
2998
  }
2896
2999
  }
@@ -2899,7 +3002,7 @@ async function yi(p) {
2899
3002
  const y = /* @__PURE__ */ new Map(), g = Array.from(b.getElementsByTagName("*"));
2900
3003
  for (const x of g) {
2901
3004
  if (x.localName !== "abstractNum") continue;
2902
- const w = q(x, "abstractNumId"), E = dt(x, "lvl").find((H) => q(H, "ilvl") === "0") || dt(x, "lvl")[0], I = E ? q(B(E, "numFmt")) : "";
3005
+ const w = q(x, "abstractNumId"), E = dt(x, "lvl").find((A) => q(A, "ilvl") === "0") || dt(x, "lvl")[0], I = E ? q(B(E, "numFmt")) : "";
2903
3006
  y.set(w, I === "bullet" ? "ul" : "ol");
2904
3007
  }
2905
3008
  for (const x of g) {
@@ -2908,75 +3011,75 @@ async function yi(p) {
2908
3011
  m.set(w, y.get(E) || "ul");
2909
3012
  }
2910
3013
  }
2911
- return new bi(o, u, m).convertBody(r);
3014
+ return new qi(o, p, m).convertBody(l);
2912
3015
  }
2913
- const xi = ["nw", "ne", "sw", "se"], wt = ["img-left", "img-right", "img-top", "img-center"], Tt = {
3016
+ const Pi = ["nw", "ne", "sw", "se"], Tt = ["img-left", "img-right", "img-top", "img-center"], Et = {
2914
3017
  "img-left": "tplimgleft",
2915
3018
  "img-right": "tplimgright",
2916
3019
  "img-top": "tplimgtop",
2917
3020
  "img-center": "tplimgcenter"
2918
- }, Ci = {
3021
+ }, Bi = {
2919
3022
  "img-left": h.tplleft,
2920
3023
  "img-right": h.tplright,
2921
3024
  "img-top": h.tpltop,
2922
3025
  "img-center": h.tplcenter
2923
- }, wi = ".tox,.pop,.tblctx,.imgctx,.selctx,.dlg";
2924
- let Z = null, X = null, St = 0, ae = !1;
3026
+ }, Ni = ".tox,.pop,.tblctx,.imgctx,.selctx,.dlg";
3027
+ let O = null, X = null, Mt = 0, de = !1;
2925
3028
  function ct() {
2926
- clearTimeout(St), X = null, Z && Z.classList.remove("show");
3029
+ clearTimeout(Mt), X = null, O && O.classList.remove("show");
2927
3030
  }
2928
- function Ti(p) {
2929
- const t = p.dataset.tip;
3031
+ function Di(u) {
3032
+ const t = u.dataset.tip;
2930
3033
  if (!t) return;
2931
- X = p, clearTimeout(St);
2932
- const e = Z && Z.classList.contains("show") ? 60 : 350;
2933
- St = window.setTimeout(() => {
2934
- if (X !== p || !document.contains(p)) return;
2935
- Z || (Z = document.createElement("div"), Z.className = "etip", document.body.appendChild(Z)), Z.textContent = t, Z.classList.add("show");
2936
- const i = p.getBoundingClientRect(), s = Z.offsetWidth, n = Z.offsetHeight;
2937
- let l = i.left + i.width / 2 - s / 2;
2938
- l = Math.max(6, Math.min(l, innerWidth - s - 6));
2939
- let r = i.bottom + 7;
2940
- r + n > innerHeight - 6 && (r = i.top - n - 7), Z.style.left = l + "px", Z.style.top = r + "px";
3034
+ X = u, clearTimeout(Mt);
3035
+ const e = O && O.classList.contains("show") ? 60 : 350;
3036
+ Mt = window.setTimeout(() => {
3037
+ if (X !== u || !document.contains(u)) return;
3038
+ O || (O = document.createElement("div"), O.className = "etip", document.body.appendChild(O)), O.textContent = t, O.classList.add("show");
3039
+ const i = u.getBoundingClientRect(), s = O.offsetWidth, n = O.offsetHeight;
3040
+ let r = i.left + i.width / 2 - s / 2;
3041
+ r = Math.max(6, Math.min(r, innerWidth - s - 6));
3042
+ let l = i.bottom + 7;
3043
+ l + n > innerHeight - 6 && (l = i.top - n - 7), O.style.left = r + "px", O.style.top = l + "px";
2941
3044
  }, e);
2942
3045
  }
2943
- function Ei() {
2944
- ae || (ae = !0, document.addEventListener("mouseover", (p) => {
2945
- const t = p.target, e = t.closest ? t.closest("[title],[data-tip]") : null;
2946
- if (!e || !e.closest(wi) || e.closest(".earea")) {
3046
+ function Oi() {
3047
+ de || (de = !0, document.addEventListener("mouseover", (u) => {
3048
+ const t = u.target, e = t.closest ? t.closest("[title],[data-tip]") : null;
3049
+ if (!e || !e.closest(Ni) || e.closest(".earea")) {
2947
3050
  e !== X && ct();
2948
3051
  return;
2949
3052
  }
2950
3053
  const i = e.getAttribute("title");
2951
- i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !== X && Ti(e);
2952
- }), document.addEventListener("mouseout", (p) => {
2953
- X && !X.contains(p.relatedTarget) && ct();
3054
+ i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !== X && Di(e);
3055
+ }), document.addEventListener("mouseout", (u) => {
3056
+ X && !X.contains(u.relatedTarget) && ct();
2954
3057
  }), document.addEventListener("mousedown", ct, !0), addEventListener("scroll", ct, !0));
2955
3058
  }
2956
- const Si = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u0780-\u07BF\u08A0-\u08FF\uFB1D-\uFB4F\uFB50-\uFDFF\uFE70-\uFEFF]/, Mi = new RegExp("\\p{L}", "u"), ki = "p,div,li,td,th,blockquote,h1,h2,h3,h4,h5,h6,pre,figcaption";
2957
- function Li(p) {
2958
- for (const t of p) {
2959
- if (Si.test(t)) return "rtl";
2960
- if (Mi.test(t)) return "ltr";
3059
+ const Zi = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u0780-\u07BF\u08A0-\u08FF\uFB1D-\uFB4F\uFB50-\uFDFF\uFE70-\uFEFF]/, Fi = new RegExp("\\p{L}", "u"), _i = "p,div,li,td,th,blockquote,h1,h2,h3,h4,h5,h6,pre,figcaption";
3060
+ function $i(u) {
3061
+ for (const t of u) {
3062
+ if (Zi.test(t)) return "rtl";
3063
+ if (Fi.test(t)) return "ltr";
2961
3064
  }
2962
3065
  return null;
2963
3066
  }
2964
- function de(p) {
3067
+ function ge(u) {
2965
3068
  let t = "";
2966
- return p.childNodes.forEach((e) => {
3069
+ return u.childNodes.forEach((e) => {
2967
3070
  if (e.nodeType === Node.TEXT_NODE)
2968
3071
  t += e.nodeValue || "";
2969
3072
  else if (e.nodeType === Node.ELEMENT_NODE) {
2970
3073
  const i = e, s = (i.getAttribute("dir") || "").toLowerCase();
2971
3074
  if (s === "rtl" || s === "ltr") return;
2972
- t += de(i);
3075
+ t += ge(i);
2973
3076
  }
2974
3077
  }), t;
2975
3078
  }
2976
3079
  var j;
2977
- let Hi = (j = class {
3080
+ let ji = (j = class {
2978
3081
  constructor(t) {
2979
- this.lang = "en", this.contentClass = "fable-content-" + j.instanceCounter++, this.contentStyleEl = null, this.savedRange = null, this.foreColor = "#000000", this.backColor = "#FACC15", this.openPop = null, this.openSubEl = null, this.popAnchor = null, this.dlgOvl = null, this.tblActive = null, this.tblCorner = null, this.tblColBars = [], this.tblCtx = null, this.tblCellMark = null, this.tblOpMark = null, this.tblOpMarkKind = null, this.imgActive = null, this.imgHandles = [], this.imgCtx = null, this.imgHideTimer = null, this.phActive = null, this.phCtx = null, this.phUploadTarget = null, this.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 = {
3082
+ this.lang = "en", this.contentClass = "fable-content-" + j.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 = {
2980
3083
  target: t.target,
2981
3084
  language: t.language || "en",
2982
3085
  height: t.height ?? 302,
@@ -2990,10 +3093,10 @@ let Hi = (j = class {
2990
3093
  statusbar: t.statusbar ?? !0,
2991
3094
  readonly: t.readonly ?? !1,
2992
3095
  draftKey: t.draftKey ?? (typeof location < "u" ? location.pathname : "default"),
2993
- fontFamilyFormats: t.fontFamilyFormats ?? Ye,
3096
+ fontFamilyFormats: t.fontFamilyFormats ?? ti,
2994
3097
  imageFileTypes: t.imageFileTypes ?? ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/bmp", "image/webp"],
2995
3098
  videoFileTypes: t.videoFileTypes ?? ["video/mp4", "video/webm", "video/ogg"]
2996
- }, 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.options.onReady(this);
3099
+ }, 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);
2997
3100
  }
2998
3101
  t(t) {
2999
3102
  const e = Ct(this.lang)[t];
@@ -3016,7 +3119,7 @@ let Hi = (j = class {
3016
3119
  </span>
3017
3120
  `, this.sbHelp = this.statusbar.querySelector(".mid"), this.sbWords = this.statusbar.querySelector(".words");
3018
3121
  const e = this.statusbar.querySelector(".grip");
3019
- 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), Ei(), 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);
3122
+ 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), Oi(), 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);
3020
3123
  }
3021
3124
  /** Theme options land as CSS variables on the document root rather than the editor
3022
3125
  * shell, because dialogs, popups and floating context toolbars are appended to
@@ -3036,19 +3139,19 @@ let Hi = (j = class {
3036
3139
  let e = 0, i = 0;
3037
3140
  const s = (n) => {
3038
3141
  e = n.clientY, i = this.ed.offsetHeight, n.preventDefault();
3039
- const l = (o) => {
3142
+ const r = (o) => {
3040
3143
  this.ed.style.height = Math.max(120, i + o.clientY - e) + "px";
3041
- }, r = () => {
3042
- window.removeEventListener("mousemove", l), window.removeEventListener("mouseup", r);
3144
+ }, l = () => {
3145
+ window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", l);
3043
3146
  };
3044
- window.addEventListener("mousemove", l), window.addEventListener("mouseup", r);
3147
+ window.addEventListener("mousemove", r), window.addEventListener("mouseup", l);
3045
3148
  };
3046
3149
  t.addEventListener("mousedown", s), this.listeners.push(() => t.removeEventListener("mousedown", s));
3047
3150
  }
3048
3151
  /* ---------------------------------------------------------- event binding */
3049
3152
  bindEvents() {
3050
3153
  if (this.onDoc("mousedown", (t) => {
3051
- this.openPop && !this.openPop.contains(t.target) && !this.popAnchor.contains(t.target) && !(this.openSubEl && this.openSubEl.contains(t.target)) && this.closePop();
3154
+ this.openPop && !this.openPop.contains(t.target) && !this.popAnchor.contains(t.target) && !this.subContains(t.target) && this.closePop();
3052
3155
  }), this.onDoc("keydown", (t) => {
3053
3156
  t.key === "Escape" && (this.closePop(), this.closeDlg());
3054
3157
  }), this.onDoc("selectionchange", () => {
@@ -3059,52 +3162,54 @@ let Hi = (j = class {
3059
3162
  }), this.on(this.ed, "keydown", (t) => {
3060
3163
  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);
3061
3164
  }), this.on(this.ed, "paste", (t) => this.handlePaste(t)), this.on(this.ed, "drop", (t) => {
3062
- var n, l, r, o;
3165
+ var n, r, l, o;
3063
3166
  t.preventDefault();
3064
3167
  const e = t.target, i = (n = e.closest) == null ? void 0 : n.call(e, ".img-ph:not(.vid-ph)");
3065
3168
  if (i && this.ed.contains(i) && !this.options.readonly) {
3066
- const c = Array.from(((l = t.dataTransfer) == null ? void 0 : l.files) || []).find((d) => d.type.startsWith("image/"));
3067
- c && this.readImageFileInto(c, i);
3169
+ const a = Array.from(((r = t.dataTransfer) == null ? void 0 : r.files) || []).find((d) => d.type.startsWith("image/"));
3170
+ a && this.readImageFileInto(a, i);
3068
3171
  return;
3069
3172
  }
3070
- const s = (r = e.closest) == null ? void 0 : r.call(e, ".vid-ph");
3173
+ const s = (l = e.closest) == null ? void 0 : l.call(e, ".vid-ph");
3071
3174
  if (s && this.ed.contains(s) && !this.options.readonly) {
3072
- const c = Array.from(((o = t.dataTransfer) == null ? void 0 : o.files) || []).find((d) => d.type.startsWith("video/"));
3073
- c && this.readVideoFileInto(c, s);
3175
+ const a = Array.from(((o = t.dataTransfer) == null ? void 0 : o.files) || []).find((d) => d.type.startsWith("video/"));
3176
+ a && this.readVideoFileInto(a, s);
3074
3177
  }
3075
3178
  }), this.on(this.ed, "dragover", (t) => t.preventDefault()), this.on(this.ed, "mousedown", (t) => {
3076
- var d, u, m, b, y, g, x;
3179
+ var d, p, m, b, y, g, x;
3077
3180
  const e = t.target, i = (d = e.closest) == null ? void 0 : d.call(e, "table");
3078
3181
  i && this.ed.contains(i) ? this.selectTableForResize(i) : this.clearTableHandles();
3079
- const s = (u = e.closest) == null ? void 0 : u.call(e, ".img-ph:not(.vid-ph)");
3182
+ const s = (p = e.closest) == null ? void 0 : p.call(e, ".img-ph:not(.vid-ph)");
3080
3183
  s && this.ed.contains(s) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectImgPlaceholder(s)) : this.clearImgPlaceholderSel();
3081
3184
  const n = (m = e.closest) == null ? void 0 : m.call(e, ".vid-ph");
3082
3185
  n && this.ed.contains(n) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectVphPlaceholder(n)) : this.clearVphPlaceholderSel();
3083
- const l = (b = e.closest) == null ? void 0 : b.call(e, ".tpl");
3084
- l && this.ed.contains(l) && !this.options.readonly ? this.selectTemplate(l) : this.clearTplSel();
3085
- const r = (y = e.closest) == null ? void 0 : y.call(e, "pre.code-block");
3086
- r && this.ed.contains(r) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(r)) : this.clearCodeSel();
3186
+ const r = (b = e.closest) == null ? void 0 : b.call(e, ".tpl");
3187
+ r && this.ed.contains(r) && !this.options.readonly ? this.selectTemplate(r) : this.clearTplSel();
3188
+ const l = (y = e.closest) == null ? void 0 : y.call(e, "pre.code-block");
3189
+ l && this.ed.contains(l) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(l)) : this.clearCodeSel();
3087
3190
  const o = (g = e.closest) == null ? void 0 : g.call(e, "img");
3088
3191
  o && this.ed.contains(o) && !this.options.readonly ? (t.preventDefault(), this.selectImage(o)) : this.clearImageHandles();
3089
- const c = (x = e.closest) == null ? void 0 : x.call(e, "video, .video-embed");
3090
- c && this.ed.contains(c) && !this.options.readonly ? (t.preventDefault(), this.selectVideo(c)) : this.clearVidHandles();
3192
+ const a = (x = e.closest) == null ? void 0 : x.call(e, "video, .video-embed");
3193
+ a && this.ed.contains(a) && !this.options.readonly ? (t.preventDefault(), this.selectVideo(a)) : this.clearVidHandles();
3091
3194
  }), this.on(this.ed, "mouseover", (t) => {
3092
3195
  var i, s;
3093
3196
  if (this.options.readonly) return;
3094
3197
  const e = (s = (i = t.target).closest) == null ? void 0 : s.call(i, "img");
3095
3198
  e && this.ed.contains(e) && (this.cancelImgHide(), this.selectImage(e));
3096
3199
  }), this.on(this.ed, "mouseout", (t) => {
3097
- var s, n, l, r;
3200
+ var s, n, r, l;
3098
3201
  const e = (n = (s = t.target).closest) == null ? void 0 : n.call(s, "img");
3099
3202
  if (!e) return;
3100
3203
  const i = t.relatedTarget;
3101
- 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();
3204
+ i && ((r = this.imgCtx) != null && r.contains(i) || this.imgHandles.some((o) => o.contains(i)) || ((l = i.closest) == null ? void 0 : l.call(i, "img")) === e) || this.scheduleImgHide();
3102
3205
  }), this.on(this.ed, "scroll", () => {
3103
3206
  this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx(), this.positionVphCtx(), this.positionVidCtx(), this.positionCodeCtx();
3104
3207
  }), this.onWin(
3105
3208
  "scroll",
3106
- () => {
3107
- this.closePop(), this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx(), this.positionVphCtx(), this.positionVidCtx(), this.positionCodeCtx(), this.repositionSelToolbar();
3209
+ (t) => {
3210
+ var s;
3211
+ const e = t.target;
3212
+ 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();
3108
3213
  },
3109
3214
  !0
3110
3215
  ), this.onWin("resize", () => {
@@ -3124,11 +3229,7 @@ let Hi = (j = class {
3124
3229
  }
3125
3230
  const i = new FileReader();
3126
3231
  i.onload = () => {
3127
- this.restoreSel(), document.execCommand(
3128
- "insertHTML",
3129
- !1,
3130
- `<img src="${i.result}" title="${t.name.replace(/"/g, "")}" alt="">`
3131
- ), this.onChange();
3232
+ this.restoreSel(), this.insertImageHTML(i.result, t.name.replace(/"/g, "")), this.onChange();
3132
3233
  }, i.readAsDataURL(t);
3133
3234
  }), this.on(this.vidInput, "change", () => {
3134
3235
  var s;
@@ -3152,7 +3253,7 @@ let Hi = (j = class {
3152
3253
  const t = (e = this.docInput.files) == null ? void 0 : e[0];
3153
3254
  t && this.importWordFile(t).catch(() => alert(this.t("importfail")));
3154
3255
  }), this.onDoc("mousedown", (t) => {
3155
- 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.openSubEl && this.openSubEl.contains(t.target) || (this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearTplSel(), this.clearVphPlaceholderSel(), this.clearVidHandles(), this.clearCodeSel(), this.clearSelToolbar());
3256
+ 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());
3156
3257
  });
3157
3258
  }
3158
3259
  on(t, e, i) {
@@ -3182,33 +3283,41 @@ let Hi = (j = class {
3182
3283
  * content with no strongly-directional character anywhere falls back to the
3183
3284
  * editor's current direction. */
3184
3285
  getContentForEmail() {
3185
- const t = (l, r) => {
3186
- const o = (l.getAttribute("style") || "").trim();
3187
- l.setAttribute("style", o ? o.replace(/;?$/, "; ") + r : r);
3286
+ const t = (l, o) => {
3287
+ const a = (l.getAttribute("style") || "").trim();
3288
+ l.setAttribute("style", a ? a.replace(/;?$/, "; ") + o : o);
3188
3289
  }, e = document.createElement("div");
3189
3290
  e.innerHTML = this.ed.innerHTML;
3190
3291
  let i = null;
3191
3292
  e.querySelectorAll("[dir]").forEach((l) => {
3192
- const r = (l.getAttribute("dir") || "").toLowerCase();
3193
- if (r !== "rtl" && r !== "ltr") return;
3194
- const o = r;
3195
- i || (i = o), /text-align\s*:/i.test(l.getAttribute("style") || "") || t(l, `text-align:${o === "rtl" ? "right" : "left"}`);
3196
- }), e.querySelectorAll(ki).forEach((l) => {
3197
- const r = (l.getAttribute("dir") || "").toLowerCase();
3198
- if (r === "rtl" || r === "ltr") return;
3199
- const o = Li(de(l));
3200
- if (!o) return;
3201
- i || (i = o), l.setAttribute("dir", o);
3202
- const c = /text-align\s*:/i.test(l.getAttribute("style") || "");
3203
- t(l, c ? `direction:${o}` : `direction:${o};text-align:${o === "rtl" ? "right" : "left"}`);
3293
+ const o = (l.getAttribute("dir") || "").toLowerCase();
3294
+ if (o !== "rtl" && o !== "ltr") return;
3295
+ const a = o;
3296
+ i || (i = a), /text-align\s*:/i.test(l.getAttribute("style") || "") || t(l, `text-align:${a === "rtl" ? "right" : "left"}`);
3297
+ }), e.querySelectorAll(_i).forEach((l) => {
3298
+ const o = (l.getAttribute("dir") || "").toLowerCase();
3299
+ if (o === "rtl" || o === "ltr") return;
3300
+ const a = $i(ge(l));
3301
+ if (!a) return;
3302
+ i || (i = a), l.setAttribute("dir", a);
3303
+ const d = /text-align\s*:/i.test(l.getAttribute("style") || "");
3304
+ t(l, d ? `direction:${a}` : `direction:${a};text-align:${a === "rtl" ? "right" : "left"}`);
3305
+ });
3306
+ const s = this.ed.querySelectorAll("img");
3307
+ e.querySelectorAll("img").forEach((l, o) => {
3308
+ if (l.closest(".tpl-media")) return;
3309
+ const a = s[o], d = Math.round((a == null ? void 0 : a.getBoundingClientRect().width) || 0);
3310
+ d > 0 && !l.getAttribute("width") && l.setAttribute("width", String(d));
3311
+ const p = l.getAttribute("style") || "";
3312
+ d > 0 && !/(^|;)\s*width\s*:/i.test(p) && t(l, `width:${d}px`), /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");
3204
3313
  });
3205
- const s = i || this.ed.getAttribute("dir") || this.dir();
3314
+ const n = i || this.ed.getAttribute("dir") || this.dir();
3206
3315
  return e.querySelectorAll("table:not([dir])").forEach((l) => {
3207
- l.setAttribute("dir", s), /direction\s*:/i.test(l.getAttribute("style") || "") || t(l, `direction:${s}`);
3208
- }), `<div dir="${s}" style="direction:${s};text-align:${s === "rtl" ? "right" : "left"}">${e.innerHTML}</div>`;
3316
+ l.setAttribute("dir", n), /direction\s*:/i.test(l.getAttribute("style") || "") || t(l, `direction:${n}`);
3317
+ }), `<div dir="${n}" style="direction:${n};text-align:${n === "rtl" ? "right" : "left"}">${e.innerHTML}</div>`;
3209
3318
  }
3210
3319
  setContent(t) {
3211
- 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();
3320
+ 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();
3212
3321
  }
3213
3322
  insertContent(t) {
3214
3323
  this.restoreSel(), document.execCommand("insertHTML", !1, t), this.saveSel(), this.refreshState(), this.onChange();
@@ -3220,7 +3329,7 @@ let Hi = (j = class {
3220
3329
  this.ed.focus();
3221
3330
  }
3222
3331
  async importWordFile(t) {
3223
- const e = await yi(t);
3332
+ const e = await Ri(t);
3224
3333
  this.recordRevision(), this.setContent(e), this.recordRevision();
3225
3334
  }
3226
3335
  restoreDraft() {
@@ -3279,8 +3388,8 @@ let Hi = (j = class {
3279
3388
  t.preventDefault();
3280
3389
  const n = document.createElement("p");
3281
3390
  n.appendChild(document.createElement("br")), s.after(n), i.remove(), s.firstElementChild || s.remove();
3282
- const l = document.createRange();
3283
- l.setStart(n, 0), l.collapse(!0), e.removeAllRanges(), e.addRange(l), this.saveSel(), this.onChange();
3391
+ const r = document.createRange();
3392
+ r.setStart(n, 0), r.collapse(!0), e.removeAllRanges(), e.addRange(r), this.saveSel(), this.onChange();
3284
3393
  }
3285
3394
  selectedBlocks() {
3286
3395
  const t = window.getSelection();
@@ -3330,52 +3439,70 @@ let Hi = (j = class {
3330
3439
  s.className = "revprev";
3331
3440
  const n = document.createElement("button");
3332
3441
  n.type = "button", n.className = "revrestore", n.textContent = this.t("restore");
3333
- let l = this.revisions.length - 1;
3334
- const r = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
3442
+ let r = this.revisions.length - 1;
3443
+ const l = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
3335
3444
  year: "numeric",
3336
3445
  month: "short",
3337
3446
  day: "numeric",
3338
3447
  hour: "2-digit",
3339
3448
  minute: "2-digit",
3340
3449
  second: "2-digit"
3341
- }), o = {}, c = (d) => {
3342
- l = d, this.revisions.forEach((u, m) => {
3450
+ }), o = {}, a = (d) => {
3451
+ r = d, this.revisions.forEach((p, m) => {
3343
3452
  var b;
3344
3453
  return (b = o[m]) == null ? void 0 : b.classList.toggle("on", m === d);
3345
3454
  }), s.innerHTML = this.revisions[d].html, n.disabled = d === this.revisions.length - 1;
3346
3455
  };
3347
3456
  for (let d = this.revisions.length - 1; d >= 0; d--) {
3348
- const u = this.revisions[d], m = document.createElement("button");
3457
+ const p = this.revisions[d], m = document.createElement("button");
3349
3458
  m.type = "button";
3350
- const b = (new DOMParser().parseFromString(u.html, "text/html").body.textContent || "").trim(), y = b ? b.split(/\s+/).length : 0, g = d === this.revisions.length - 1;
3351
- m.innerHTML = `<span>${g ? this.t("currentver") : r.format(new Date(u.time))}</span><span class="wc">${y} ${this.t("words")}</span>`, m.addEventListener("click", () => c(d)), o[d] = m, i.appendChild(m);
3459
+ const b = (new DOMParser().parseFromString(p.html, "text/html").body.textContent || "").trim(), y = b ? b.split(/\s+/).length : 0, g = d === this.revisions.length - 1;
3460
+ m.innerHTML = `<span>${g ? this.t("currentver") : l.format(new Date(p.time))}</span><span class="wc">${y} ${this.t("words")}</span>`, m.addEventListener("click", () => a(d)), o[d] = m, i.appendChild(m);
3352
3461
  }
3353
3462
  i.append(n), n.addEventListener("click", () => {
3354
- const d = this.revisions[l];
3463
+ const d = this.revisions[r];
3355
3464
  d && (this.recordRevision(), this.setContent(d.html), this.recordRevision(), this.closeDlg());
3356
- }), e.append(i, s), t.appendChild(e), c(l);
3465
+ }), e.append(i, s), t.appendChild(e), a(r);
3357
3466
  });
3358
3467
  }
3359
3468
  /* ---------------------------------------------------------- popups / menus */
3360
3469
  closeSub() {
3361
- var t;
3362
- (t = this.openSubEl) == null || t.remove(), this.openSubEl = null;
3470
+ this.closeSubFrom(0);
3471
+ }
3472
+ /** Removes stacked flyouts from `level` (0 = shallowest) onward, keeping
3473
+ * anything shallower - e.g. hovering a sibling item inside the "Cell"
3474
+ * flyout should drop a deeper "Cell background" flyout but keep "Cell"
3475
+ * itself and the top-level popup it bridges to. */
3476
+ closeSubFrom(t) {
3477
+ for (; this.subStack.length > t; ) this.subStack.pop().remove();
3478
+ }
3479
+ /** True if `node` is inside any currently-open flyout submenu (any depth). */
3480
+ subContains(t) {
3481
+ return this.subStack.some((e) => e.contains(t));
3482
+ }
3483
+ /** 0 for the top-level popup itself; otherwise this container's depth in
3484
+ * the flyout stack + 1. Used to know how many deeper flyouts to close
3485
+ * when opening or hovering within `container`. */
3486
+ subLevelOf(t) {
3487
+ if (t === this.openPop) return 0;
3488
+ const e = this.subStack.indexOf(t);
3489
+ return e === -1 ? this.subStack.length : e + 1;
3363
3490
  }
3364
3491
  closePop() {
3365
3492
  var t;
3366
3493
  this.closeSub(), this.openPop && (this.openPop.remove(), this.openPop = null, (t = this.popAnchor) == null || t.classList.remove("open"), this.popAnchor = null, this.setOpTarget(null));
3367
3494
  }
3368
3495
  openSubFor(t, e) {
3369
- this.closeSub();
3370
- const i = document.createElement("div");
3371
- i.className = "pop sub", i.dir = this.dir(), t.subBuild ? t.subBuild(i) : t.sub && this.menuItems(i, t.sub), i.addEventListener("mousedown", (o) => {
3372
- o.target.tagName !== "INPUT" && o.preventDefault();
3373
- }), document.body.appendChild(i);
3374
- const s = e.getBoundingClientRect();
3375
- let l = this.dir() === "rtl" ? s.left - i.offsetWidth + 2 : s.right - 2;
3376
- l = Math.max(8, Math.min(l + scrollX, scrollX + innerWidth - i.offsetWidth - 8));
3377
- let r = s.top + scrollY - 6;
3378
- r = Math.max(8 + scrollY, Math.min(r, scrollY + innerHeight - i.offsetHeight - 8)), i.style.left = l + "px", i.style.top = r + "px", this.openSubEl = i;
3496
+ const i = e.getBoundingClientRect(), s = e.closest(".pop");
3497
+ this.closeSubFrom(s ? this.subLevelOf(s) : 0);
3498
+ const n = document.createElement("div");
3499
+ n.className = "pop sub", n.dir = this.dir(), t.subBuild ? t.subBuild(n) : t.sub && this.menuItems(n, t.sub), n.addEventListener("mousedown", (a) => {
3500
+ a.target.tagName !== "INPUT" && a.preventDefault();
3501
+ }), document.body.appendChild(n);
3502
+ let l = this.dir() === "rtl" ? i.left - n.offsetWidth + 2 : i.right - 2;
3503
+ l = Math.max(8, Math.min(l + scrollX, scrollX + innerWidth - n.offsetWidth - 8));
3504
+ let o = i.top + scrollY - 6;
3505
+ o = Math.max(8 + scrollY, Math.min(o, scrollY + innerHeight - n.offsetHeight - 8)), n.style.left = l + "px", n.style.top = o + "px", this.subStack.push(n);
3379
3506
  }
3380
3507
  popup(t, e, i) {
3381
3508
  if (this.openPop && this.popAnchor === t) {
@@ -3386,10 +3513,12 @@ let Hi = (j = class {
3386
3513
  const s = document.createElement("div");
3387
3514
  s.className = "pop" + (i ? " " + i : ""), s.dir = this.dir(), e(s), document.body.appendChild(s);
3388
3515
  const n = t.getBoundingClientRect();
3389
- s.style.minWidth = Math.max(160, Math.round(n.width)) + "px", s.style.top = n.bottom + scrollY + 2 + "px";
3390
- let r = this.dir() === "rtl" ? n.right - s.offsetWidth : n.left;
3391
- r = Math.max(8, Math.min(r + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = r + "px", s.addEventListener("mousedown", (o) => {
3392
- o.target.tagName !== "INPUT" && o.preventDefault();
3516
+ s.style.minWidth = Math.max(160, Math.round(n.width)) + "px";
3517
+ let r = n.bottom + scrollY + 2;
3518
+ r = Math.max(8 + scrollY, Math.min(r, scrollY + innerHeight - s.offsetHeight - 8)), s.style.top = r + "px";
3519
+ let o = this.dir() === "rtl" ? n.right - s.offsetWidth : n.left;
3520
+ o = Math.max(8, Math.min(o + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = o + "px", s.addEventListener("mousedown", (a) => {
3521
+ a.target.tagName !== "INPUT" && a.preventDefault();
3393
3522
  }), this.openPop = s, this.popAnchor = t, t.classList.add("open");
3394
3523
  }
3395
3524
  menuItems(t, e) {
@@ -3402,18 +3531,18 @@ let Hi = (j = class {
3402
3531
  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", () => {
3403
3532
  i.action && (this.closePop(), i.action());
3404
3533
  }), n.addEventListener("mouseenter", () => {
3405
- var l;
3406
- s ? this.openSubFor(i, n) : this.openSubEl && t !== this.openSubEl && this.closeSub(), (l = i.hover) == null || l.call(i, !0);
3534
+ var r;
3535
+ s ? this.openSubFor(i, n) : this.closeSubFrom(this.subLevelOf(t)), (r = i.hover) == null || r.call(i, !0);
3407
3536
  }), n.addEventListener("mouseleave", () => {
3408
- var l;
3409
- return (l = i.hover) == null ? void 0 : l.call(i, !1);
3537
+ var r;
3538
+ return (r = i.hover) == null ? void 0 : r.call(i, !1);
3410
3539
  }), t.appendChild(n);
3411
3540
  });
3412
3541
  }
3413
3542
  /* ---------------------------------------------------------- toolbar builders */
3414
3543
  tbtn(t, e, i, s) {
3415
3544
  const n = document.createElement("button");
3416
- 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;
3545
+ 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;
3417
3546
  }
3418
3547
  /** Font-size increase / decrease step button. */
3419
3548
  stepBtn(t) {
@@ -3429,10 +3558,10 @@ let Hi = (j = class {
3429
3558
  colorChips() {
3430
3559
  const t = (s) => {
3431
3560
  const n = document.createElement("button");
3432
- return n.type = "button", n.className = "cchip", n.title = s, n.addEventListener("mousedown", (l) => {
3433
- l.preventDefault(), this.saveSel();
3561
+ return n.type = "button", n.className = "cchip", n.title = s, n.addEventListener("mousedown", (r) => {
3562
+ r.preventDefault(), this.saveSel();
3434
3563
  }), n;
3435
- }, e = Je.map((s) => {
3564
+ }, e = ni.map((s) => {
3436
3565
  const n = t(this.t("forecolor"));
3437
3566
  return n.style.background = s, n.addEventListener("click", () => this.applyColor("fore", s)), n;
3438
3567
  }), i = t(this.t("forecolor"));
@@ -3446,20 +3575,20 @@ let Hi = (j = class {
3446
3575
  }
3447
3576
  tsel(t, e, i, s) {
3448
3577
  const n = document.createElement("button");
3449
- 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) => {
3450
- l.preventDefault(), this.saveSel();
3578
+ 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) => {
3579
+ r.preventDefault(), this.saveSel();
3451
3580
  }), n.addEventListener("click", () => s(n)), n;
3452
3581
  }
3453
3582
  setListStyle(t, e) {
3454
- var n, l;
3583
+ var n, r;
3455
3584
  this.restoreSel();
3456
3585
  const i = window.getSelection();
3457
3586
  if (!i) return;
3458
3587
  let s = (n = this.closestBlock(i.anchorNode)) == null ? void 0 : n.closest(t);
3459
- 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();
3588
+ 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();
3460
3589
  }
3461
3590
  listMenu(t, e) {
3462
- var c;
3591
+ var a;
3463
3592
  const i = e === "ol" ? "insertOrderedList" : "insertUnorderedList", s = e === "ol" ? [
3464
3593
  ["lower-alpha", h.ol_alpha],
3465
3594
  ["lower-roman", h.ol_roman],
@@ -3468,7 +3597,7 @@ let Hi = (j = class {
3468
3597
  ] : [
3469
3598
  ["circle", h.ul_circle],
3470
3599
  ["square", h.ul_square]
3471
- ], n = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), l = window.getSelection(), r = l ? (c = this.closestBlock(l.anchorNode)) == null ? void 0 : c.closest(e) : null, o = r ? r.style.listStyleType : "";
3600
+ ], n = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), r = window.getSelection(), l = r ? (a = this.closestBlock(r.anchorNode)) == null ? void 0 : a.closest(e) : null, o = l ? l.style.listStyleType : "";
3472
3601
  this.popup(t, (d) => {
3473
3602
  this.menuItems(d, [
3474
3603
  {
@@ -3478,13 +3607,13 @@ let Hi = (j = class {
3478
3607
  action: () => this.exec(i)
3479
3608
  }
3480
3609
  ]), d.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
3481
- const u = document.createElement("div");
3482
- u.className = "mi-grid", s.forEach(([m, b], y) => {
3610
+ const p = document.createElement("div");
3611
+ p.className = "mi-grid", s.forEach(([m, b], y) => {
3483
3612
  const g = document.createElement("button");
3484
3613
  g.className = "mi" + (o === m ? " on" : ""), g.innerHTML = `<span class="ic">${b}</span><span class="prev">${n[y]}</span>`, g.addEventListener("click", () => {
3485
3614
  this.closePop(), this.setListStyle(e, m);
3486
- }), u.appendChild(g);
3487
- }), d.appendChild(u);
3615
+ }), p.appendChild(g);
3616
+ }), d.appendChild(p);
3488
3617
  });
3489
3618
  }
3490
3619
  /** Shared color-picker popup body — swatch grid plus the current-color /
@@ -3492,26 +3621,26 @@ let Hi = (j = class {
3492
3621
  * table cell-background menu all show the identical popup. */
3493
3622
  buildPaletteInto(t, e, i) {
3494
3623
  const s = document.createElement("div");
3495
- s.className = "cpal", ti.forEach((u) => {
3624
+ s.className = "cpal", ri.forEach((p) => {
3496
3625
  const m = document.createElement("button");
3497
- m.type = "button", m.style.background = u, m.title = u, m.addEventListener("click", () => {
3498
- this.closePop(), i(u);
3626
+ m.type = "button", m.style.background = p, m.title = p, m.addEventListener("click", () => {
3627
+ this.closePop(), i(p);
3499
3628
  }), s.appendChild(m);
3500
3629
  }), t.appendChild(s), t.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
3501
3630
  const n = document.createElement("div");
3502
3631
  n.className = "cfoot";
3503
- const l = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", r = document.createElement("div");
3504
- r.className = "cswatch cur", r.title = this.t("currentcolor"), r.style.background = l, r.innerHTML = h.check;
3632
+ const r = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", l = document.createElement("div");
3633
+ l.className = "cswatch cur", l.title = this.t("currentcolor"), l.style.background = r, l.innerHTML = h.check;
3505
3634
  const o = document.createElement("button");
3506
3635
  o.type = "button", o.className = "cswatch nocolor", o.title = this.t("removecolor"), o.addEventListener("click", () => {
3507
3636
  this.closePop(), i(null);
3508
3637
  });
3509
- const c = document.createElement("label");
3510
- c.className = "cswatch cwheel", c.title = this.t("customcolor"), c.innerHTML = h.palette;
3638
+ const a = document.createElement("label");
3639
+ a.className = "cswatch cwheel", a.title = this.t("customcolor"), a.innerHTML = h.palette;
3511
3640
  const d = document.createElement("input");
3512
- d.type = "color", d.value = l, d.addEventListener("change", () => {
3641
+ d.type = "color", d.value = r, d.addEventListener("change", () => {
3513
3642
  this.closePop(), i(d.value);
3514
- }), c.appendChild(d), n.append(r, o, c), t.appendChild(n);
3643
+ }), a.appendChild(d), n.append(l, o, a), t.appendChild(n);
3515
3644
  }
3516
3645
  colorMenu(t, e) {
3517
3646
  this.popup(
@@ -3541,7 +3670,7 @@ let Hi = (j = class {
3541
3670
  this.popup(t, (e) => this.menuItems(e, this.fontItems()));
3542
3671
  }
3543
3672
  sizeItems() {
3544
- return Qe.map((t) => ({
3673
+ return ei.map((t) => ({
3545
3674
  label: t,
3546
3675
  on: this.currentSize() === t,
3547
3676
  action: () => this.applyFontSize(t)
@@ -3557,19 +3686,19 @@ let Hi = (j = class {
3557
3686
  const t = window.getSelection();
3558
3687
  if (!t) return;
3559
3688
  if (!t.rangeCount) {
3560
- const l = document.createRange();
3561
- l.selectNodeContents(this.ed), l.collapse(!0), t.addRange(l);
3689
+ const r = document.createRange();
3690
+ r.selectNodeContents(this.ed), r.collapse(!0), t.addRange(r);
3562
3691
  }
3563
3692
  if (!t.isCollapsed) return;
3564
3693
  const e = t.getRangeAt(0), i = e.startContainer;
3565
3694
  if (i.nodeType === 3) {
3566
- const l = i.data;
3567
- let r = e.startOffset, o = e.startOffset;
3568
- for (; r > 0 && /\S/.test(l[r - 1]); ) r--;
3569
- for (; o < l.length && /\S/.test(l[o]); ) o++;
3570
- if (o > r) {
3571
- const c = document.createRange();
3572
- c.setStart(i, r), c.setEnd(i, o), t.removeAllRanges(), t.addRange(c), this.savedRange = c.cloneRange();
3695
+ const r = i.data;
3696
+ let l = e.startOffset, o = e.startOffset;
3697
+ for (; l > 0 && /\S/.test(r[l - 1]); ) l--;
3698
+ for (; o < r.length && /\S/.test(r[o]); ) o++;
3699
+ if (o > l) {
3700
+ const a = document.createRange();
3701
+ a.setStart(i, l), a.setEnd(i, o), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
3573
3702
  return;
3574
3703
  }
3575
3704
  }
@@ -3594,7 +3723,7 @@ let Hi = (j = class {
3594
3723
  this.saveSel(), this.refreshState(), this.onChange();
3595
3724
  }
3596
3725
  stepFontSize(t) {
3597
- const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(Ke, Math.max(Ge, e + t));
3726
+ const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(si, Math.max(ii, e + t));
3598
3727
  i !== e && this.applyFontSize(i + "px");
3599
3728
  }
3600
3729
  /* ------------------------------------------------ case / spacing / link */
@@ -3603,14 +3732,14 @@ let Hi = (j = class {
3603
3732
  const e = window.getSelection();
3604
3733
  if (!e || !e.rangeCount || e.isCollapsed) return;
3605
3734
  const i = e.getRangeAt(0), s = document.createTreeWalker(this.ed, NodeFilter.SHOW_TEXT), n = [];
3606
- let l;
3607
- for (; l = s.nextNode(); ) i.intersectsNode(l) && n.push(l);
3608
- n.forEach((r) => {
3609
- const o = r === i.startContainer ? i.startOffset : 0, c = r === i.endContainer ? i.endOffset : r.data.length;
3610
- if (c <= o) return;
3611
- const d = r.data.slice(o, c);
3612
- let u = d;
3613
- t === "lower" ? u = d.toLowerCase() : t === "upper" ? u = d.toUpperCase() : u = d.replace(/(^|\s)(\S)/g, (m, b, y) => b + y.toUpperCase()), r.replaceData(o, c - o, u);
3735
+ let r;
3736
+ for (; r = s.nextNode(); ) i.intersectsNode(r) && n.push(r);
3737
+ n.forEach((l) => {
3738
+ const o = l === i.startContainer ? i.startOffset : 0, a = l === i.endContainer ? i.endOffset : l.data.length;
3739
+ if (a <= o) return;
3740
+ const d = l.data.slice(o, a);
3741
+ let p = d;
3742
+ t === "lower" ? p = d.toLowerCase() : t === "upper" ? p = d.toUpperCase() : p = d.replace(/(^|\s)(\S)/g, (m, b, y) => b + y.toUpperCase()), l.replaceData(o, a - o, p);
3614
3743
  }), this.saveSel(), this.refreshState(), this.onChange();
3615
3744
  }
3616
3745
  caseItems() {
@@ -3646,13 +3775,13 @@ let Hi = (j = class {
3646
3775
  ];
3647
3776
  }
3648
3777
  lineHeightMenu(t) {
3649
- this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("lineHeight", Jt)));
3778
+ this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("lineHeight", te)));
3650
3779
  }
3651
3780
  wordSpacingMenu(t) {
3652
- this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("wordSpacing", te)));
3781
+ this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("wordSpacing", ee)));
3653
3782
  }
3654
3783
  letterSpacingMenu(t) {
3655
- this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("letterSpacing", ee)));
3784
+ this.popup(t, (e) => this.menuItems(e, this.blockStyleItems("letterSpacing", ie)));
3656
3785
  }
3657
3786
  closestAnchor() {
3658
3787
  const t = window.getSelection();
@@ -3698,14 +3827,14 @@ let Hi = (j = class {
3698
3827
  (s) => {
3699
3828
  const n = document.createElement("div");
3700
3829
  n.style.cssText = "display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";
3701
- const l = document.createElement("span");
3702
- 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);
3830
+ const r = document.createElement("span");
3831
+ 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);
3703
3832
  },
3704
3833
  i
3705
3834
  );
3706
3835
  }
3707
3836
  blockItems() {
3708
- return se.map(([t]) => ({
3837
+ return ne.map(([t]) => ({
3709
3838
  label: this.blockLabel(t),
3710
3839
  previewStyle: t.startsWith("h") ? `font-weight:700;font-size:${22 - 2 * +t[1]}px` : t === "pre" ? "font-family:monospace" : "",
3711
3840
  on: this.currentBlock() === t,
@@ -3742,15 +3871,15 @@ let Hi = (j = class {
3742
3871
  s.className = "tgrid";
3743
3872
  const n = document.createElement("div");
3744
3873
  n.className = "tgridlbl", n.textContent = "1 × 1";
3745
- const l = [];
3746
- for (let r = 0; r < 8; r++)
3874
+ const r = [];
3875
+ for (let l = 0; l < 8; l++)
3747
3876
  for (let o = 0; o < 10; o++) {
3748
- const c = document.createElement("span");
3749
- c.dataset.r = String(r), c.dataset.c = String(o), c.addEventListener("mouseenter", () => {
3750
- l.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= r && +d.dataset.c <= o)), n.textContent = o + 1 + " × " + (r + 1);
3751
- }), c.addEventListener("click", () => {
3752
- this.closePop(), this.insertTable(r + 1, o + 1), e == null || e();
3753
- }), l.push(c), s.appendChild(c);
3877
+ const a = document.createElement("span");
3878
+ a.dataset.r = String(l), a.dataset.c = String(o), a.addEventListener("mouseenter", () => {
3879
+ r.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= l && +d.dataset.c <= o)), n.textContent = o + 1 + " × " + (l + 1);
3880
+ }), a.addEventListener("click", () => {
3881
+ this.closePop(), this.insertTable(l + 1, o + 1), e == null || e();
3882
+ }), r.push(a), s.appendChild(a);
3754
3883
  }
3755
3884
  i.append(s, n), t.appendChild(i);
3756
3885
  }
@@ -3782,8 +3911,8 @@ let Hi = (j = class {
3782
3911
  * (the quick color chips); everything else yields one. */
3783
3912
  buildToolbarRegistry() {
3784
3913
  const t = this.tbtn(h.tableic, this.t("quicktable"), () => this.tableGrid(t)), e = {
3785
- undo: () => this.tbtn(h.undo, this.t("undo"), () => this.exec("undo")),
3786
- redo: () => this.tbtn(h.redo, this.t("redo"), () => this.exec("redo")),
3914
+ undo: () => this.tbtn(h.undo, this.t("undo"), () => this.exec("undo"), "undo"),
3915
+ redo: () => this.tbtn(h.redo, this.t("redo"), () => this.exec("redo"), "redo"),
3787
3916
  preview: () => this.tbtn(h.prevw, this.t("preview"), () => this.previewDlg()),
3788
3917
  print: () => this.tbtn(h.printic, this.t("print"), () => this.printDoc()),
3789
3918
  importword: () => this.tbtn(h.wordic, this.t("importword"), () => this.pickWordDoc()),
@@ -3835,17 +3964,17 @@ let Hi = (j = class {
3835
3964
  }
3836
3965
  buildToolbar() {
3837
3966
  this.toolbar.innerHTML = "";
3838
- const t = this.options.toolbar === !0 ? ze : this.options.toolbar, e = this.buildToolbarRegistry();
3967
+ const t = this.options.toolbar === !0 ? Ke : this.options.toolbar, e = this.buildToolbarRegistry();
3839
3968
  this.parseToolbarString(t).forEach((i) => {
3840
3969
  const s = [];
3841
3970
  i.forEach((n) => {
3842
- const l = e[n];
3843
- if (!l) {
3971
+ const r = e[n];
3972
+ if (!r) {
3844
3973
  console.warn(`FableEditor: unknown toolbar item "${n}"`);
3845
3974
  return;
3846
3975
  }
3847
- const r = l();
3848
- Array.isArray(r) ? s.push(...r) : s.push(r);
3976
+ const l = r();
3977
+ Array.isArray(l) ? s.push(...l) : s.push(l);
3849
3978
  }), s.length && this.toolbar.appendChild(this.group(...s));
3850
3979
  }), this.tbrMore = this.tbtn(h.more, this.t("more"), () => {
3851
3980
  this.tbrExpanded = !this.tbrExpanded, this.updateToolbarOverflow();
@@ -3945,9 +4074,9 @@ let Hi = (j = class {
3945
4074
  { label: this.t("fontsize"), subBuild: (s) => this.menuItems(s, this.sizeItems()) },
3946
4075
  { label: this.t("blocks"), subBuild: (s) => this.menuItems(s, this.blockItems()) },
3947
4076
  { label: this.t("align"), subBuild: (s) => this.menuItems(s, this.alignItems()) },
3948
- { label: this.t("lineheight"), icon: h.lineheight, subBuild: (s) => this.menuItems(s, this.blockStyleItems("lineHeight", Jt)) },
3949
- { label: this.t("wordspacing"), icon: h.wordspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("wordSpacing", te)) },
3950
- { label: this.t("letterspacing"), icon: h.letterspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("letterSpacing", ee)) },
4077
+ { label: this.t("lineheight"), icon: h.lineheight, subBuild: (s) => this.menuItems(s, this.blockStyleItems("lineHeight", te)) },
4078
+ { label: this.t("wordspacing"), icon: h.wordspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("wordSpacing", ee)) },
4079
+ { label: this.t("letterspacing"), icon: h.letterspacing, subBuild: (s) => this.menuItems(s, this.blockStyleItems("letterSpacing", ie)) },
3951
4080
  "|",
3952
4081
  { label: this.t("forecolor"), icon: h.palette, subBuild: (s) => this.buildPaletteInto(s, this.foreColor, (n) => this.applyColor("fore", n)) },
3953
4082
  { label: this.t("backcolor"), icon: h.backcolor, subBuild: (s) => this.buildPaletteInto(s, this.backColor, (n) => this.applyColor("back", n)) },
@@ -4017,7 +4146,7 @@ let Hi = (j = class {
4017
4146
  { label: this.t("deltable"), icon: h.trash, action: () => this.tableOp("deltable") }
4018
4147
  ],
4019
4148
  help: [this.mItem("helpttl", h.helpic, () => this.helpDlg(), "Alt+0")]
4020
- }, e = this.options.menubar === !0 ? Xe : this.options.menubar, i = /* @__PURE__ */ new Set();
4149
+ }, e = this.options.menubar === !0 ? Je : this.options.menubar, i = /* @__PURE__ */ new Set();
4021
4150
  e.split(/\s+/).filter(Boolean).forEach((s) => {
4022
4151
  if (i.has(s)) return;
4023
4152
  if (i.add(s), !t[s]) {
@@ -4025,36 +4154,36 @@ let Hi = (j = class {
4025
4154
  return;
4026
4155
  }
4027
4156
  const n = document.createElement("button");
4028
- n.type = "button", n.textContent = this.t(s), n.dataset.menuKey = s, n.addEventListener("mousedown", (l) => {
4029
- l.preventDefault(), this.saveSel();
4030
- }), n.addEventListener("click", () => this.popup(n, (l) => this.menuItems(l, t[s]))), this.menubar.appendChild(n);
4157
+ n.type = "button", n.textContent = this.t(s), n.dataset.menuKey = s, n.addEventListener("mousedown", (r) => {
4158
+ r.preventDefault(), this.saveSel();
4159
+ }), n.addEventListener("click", () => this.popup(n, (r) => this.menuItems(r, t[s]))), this.menubar.appendChild(n);
4031
4160
  });
4032
4161
  }
4033
4162
  /* ---------------------------------------------------------- table ops */
4034
4163
  tableOp(t) {
4035
- var o, c, d;
4164
+ var o, a, d;
4036
4165
  this.restoreSel();
4037
4166
  const e = window.getSelection();
4038
4167
  if (!e) return;
4039
- const i = ((o = this.closestBlock(e.anchorNode)) == null ? void 0 : o.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (d = (c = e.anchorNode).closest) == null ? void 0 : d.call(c, "td,th") : null);
4168
+ const i = ((o = this.closestBlock(e.anchorNode)) == null ? void 0 : o.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (d = (a = e.anchorNode).closest) == null ? void 0 : d.call(a, "td,th") : null);
4040
4169
  if (!i) return;
4041
- const s = i.parentElement, n = i.closest("table"), l = Array.from(s.children).indexOf(i), r = () => {
4042
- const u = s.cloneNode(!1);
4170
+ const s = i.parentElement, n = i.closest("table"), r = Array.from(s.children).indexOf(i), l = () => {
4171
+ const p = s.cloneNode(!1);
4043
4172
  return Array.from(s.children).forEach((m) => {
4044
4173
  const b = document.createElement("td"), y = m.getAttribute("style");
4045
- y && b.setAttribute("style", y), b.style.removeProperty("background-color"), b.innerHTML = "<br>", u.appendChild(b);
4046
- }), u;
4174
+ y && b.setAttribute("style", y), b.style.removeProperty("background-color"), b.innerHTML = "<br>", p.appendChild(b);
4175
+ }), p;
4047
4176
  };
4048
- if (t === "rowabove" && s.before(r()), t === "rowbelow" && s.after(r()), t === "delrow") {
4049
- const u = s.parentElement;
4050
- s.remove(), u.querySelector("tr") || n.remove();
4177
+ if (t === "rowabove" && s.before(l()), t === "rowbelow" && s.after(l()), t === "delrow") {
4178
+ const p = s.parentElement;
4179
+ s.remove(), p.querySelector("tr") || n.remove();
4051
4180
  }
4052
- (t === "colbefore" || t === "colafter") && n.querySelectorAll("tr").forEach((u) => {
4053
- const m = u.children[Math.min(l, u.children.length - 1)], b = document.createElement("td"), y = m.getAttribute("style");
4181
+ (t === "colbefore" || t === "colafter") && n.querySelectorAll("tr").forEach((p) => {
4182
+ const m = p.children[Math.min(r, p.children.length - 1)], b = document.createElement("td"), y = m.getAttribute("style");
4054
4183
  y && b.setAttribute("style", y), b.style.removeProperty("width"), b.style.removeProperty("background-color"), b.innerHTML = "<br>", t === "colbefore" ? m.before(b) : m.after(b);
4055
- }), t === "delcol" && (n.querySelectorAll("tr").forEach((u) => {
4184
+ }), t === "delcol" && (n.querySelectorAll("tr").forEach((p) => {
4056
4185
  var m;
4057
- return (m = u.children[l]) == null ? void 0 : m.remove();
4186
+ return (m = p.children[r]) == null ? void 0 : m.remove();
4058
4187
  }), n.querySelector("td,th") || n.remove()), t === "deltable" && n.remove(), this.onChange(), this.positionTableHandles();
4059
4188
  }
4060
4189
  /** Reorders the current row/column: 'rowup'/'rowdown' swap the caret's row with
@@ -4074,16 +4203,16 @@ let Hi = (j = class {
4074
4203
  o && o.after(i);
4075
4204
  }
4076
4205
  t === "colleft" && n > 0 && s.querySelectorAll("tr").forEach((o) => {
4077
- const c = o.children[n], d = o.children[n - 1];
4078
- c && d && d.before(c);
4206
+ const a = o.children[n], d = o.children[n - 1];
4207
+ a && d && d.before(a);
4079
4208
  }), t === "colright" && s.querySelectorAll("tr").forEach((o) => {
4080
- const c = o.children[n], d = o.children[n + 1];
4081
- c && d && d.after(c);
4209
+ const a = o.children[n], d = o.children[n + 1];
4210
+ a && d && d.after(a);
4082
4211
  });
4083
- const l = document.createRange();
4084
- l.selectNodeContents(e), l.collapse(!0);
4085
- const r = window.getSelection();
4086
- r && (r.removeAllRanges(), r.addRange(l)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
4212
+ const r = document.createRange();
4213
+ r.selectNodeContents(e), r.collapse(!0);
4214
+ const l = window.getSelection();
4215
+ l && (l.removeAllRanges(), l.addRange(r)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
4087
4216
  }
4088
4217
  /** Align the whole table via auto margins — same semantics as the align
4089
4218
  * field in the table-properties dialog. */
@@ -4120,26 +4249,26 @@ let Hi = (j = class {
4120
4249
  tablePropsDlg() {
4121
4250
  const t = this.tblActive;
4122
4251
  if (!t) return;
4123
- let e, i, s, n, l;
4124
- const r = "display:flex;align-items:center;gap:10px;margin:10px 0", o = "width:120px;color:#556;flex:none", c = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", d = t.querySelector("td,th"), u = t.style.width || "", m = d && d.style.padding ? parseFloat(d.style.padding) : "", b = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", y = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", g = t.style.marginLeft, x = t.style.marginRight, w = g === "auto" && x === "auto" ? "center" : g === "auto" ? "right" : x === "auto" && g === "0" ? "left" : "";
4252
+ let e, i, s, n, r;
4253
+ const l = "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", d = t.querySelector("td,th"), p = t.style.width || "", m = d && d.style.padding ? parseFloat(d.style.padding) : "", b = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", y = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", g = t.style.marginLeft, x = t.style.marginRight, w = g === "auto" && x === "auto" ? "center" : g === "auto" ? "right" : x === "auto" && g === "0" ? "left" : "";
4125
4254
  this.dialog(
4126
4255
  this.t("tablepropsttl"),
4127
4256
  (E) => {
4128
- const I = (H, $) => {
4129
- const O = document.createElement("div");
4130
- O.style.cssText = r;
4257
+ const I = (A, $) => {
4258
+ const Z = document.createElement("div");
4259
+ Z.style.cssText = l;
4131
4260
  const F = document.createElement("span");
4132
- F.style.cssText = o, F.textContent = this.t(H), O.append(F, $), E.appendChild(O);
4261
+ F.style.cssText = o, F.textContent = this.t(A), Z.append(F, $), E.appendChild(Z);
4133
4262
  };
4134
- e = document.createElement("input"), e.type = "text", e.style.cssText = c, e.placeholder = "e.g. 600px or 100%", e.value = u, I("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = c, i.value = String(m), I("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = c, s.value = String(b), I("tblcellspacing", s), n = document.createElement("input"), n.type = "number", n.min = "0", n.style.cssText = c, n.value = String(y), I("tblborder", n), l = document.createElement("select"), l.style.cssText = c, [
4263
+ 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(b), I("tblcellspacing", s), n = document.createElement("input"), n.type = "number", n.min = "0", n.style.cssText = a, n.value = String(y), I("tblborder", n), r = document.createElement("select"), r.style.cssText = a, [
4135
4264
  ["", "alignnone"],
4136
4265
  ["left", "alignleft"],
4137
4266
  ["center", "aligncenter"],
4138
4267
  ["right", "alignright"]
4139
- ].forEach(([H, $]) => {
4140
- const O = document.createElement("option");
4141
- O.value = H, O.textContent = this.t($), H === w && (O.selected = !0), l.appendChild(O);
4142
- }), I("tblalign", l);
4268
+ ].forEach(([A, $]) => {
4269
+ const Z = document.createElement("option");
4270
+ Z.value = A, Z.textContent = this.t($), A === w && (Z.selected = !0), r.appendChild(Z);
4271
+ }), I("tblalign", r);
4143
4272
  },
4144
4273
  [
4145
4274
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4152,7 +4281,7 @@ let Hi = (j = class {
4152
4281
  cellpadding: i.value.trim(),
4153
4282
  cellspacing: s.value.trim(),
4154
4283
  border: n.value.trim(),
4155
- align: l.value
4284
+ align: r.value
4156
4285
  }), this.closeDlg(), this.onChange(), this.positionTableHandles();
4157
4286
  }
4158
4287
  }
@@ -4191,8 +4320,8 @@ let Hi = (j = class {
4191
4320
  formSelect(t, e) {
4192
4321
  const i = document.createElement("select");
4193
4322
  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]) => {
4194
- const l = document.createElement("option");
4195
- l.value = s, l.textContent = n, s === e && (l.selected = !0), i.appendChild(l);
4323
+ const r = document.createElement("option");
4324
+ r.value = s, r.textContent = n, s === e && (r.selected = !0), i.appendChild(r);
4196
4325
  }), i;
4197
4326
  }
4198
4327
  formBg(t) {
@@ -4202,8 +4331,8 @@ let Hi = (j = class {
4202
4331
  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";
4203
4332
  const n = document.createElement("label");
4204
4333
  n.style.cssText = "display:flex;align-items:center;gap:6px;cursor:pointer;color:#556";
4205
- const l = document.createElement("input");
4206
- 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 };
4334
+ const r = document.createElement("input");
4335
+ 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 };
4207
4336
  }
4208
4337
  setOrClear(t, e, i) {
4209
4338
  i ? t.style.setProperty(e, /^(width|height)$/.test(e) && /^\d+$/.test(i) ? i + "px" : i) : t.style.removeProperty(e);
@@ -4214,11 +4343,11 @@ let Hi = (j = class {
4214
4343
  alert(this.t("nocell"));
4215
4344
  return;
4216
4345
  }
4217
- let e, i, s, n, l;
4346
+ let e, i, s, n, r;
4218
4347
  this.dialog(
4219
4348
  this.t("cellprops").replace("…", ""),
4220
- (r) => {
4221
- 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(
4349
+ (l) => {
4350
+ e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(l, this.t("tblwidth"), e), i = this.formInput(t.style.height, "e.g. 40px"), this.formRow(l, this.t("tblheight"), i), s = this.formSelect(
4222
4351
  [
4223
4352
  ["", this.t("alignnone")],
4224
4353
  ["left", this.t("alignleft")],
@@ -4226,7 +4355,7 @@ let Hi = (j = class {
4226
4355
  ["right", this.t("alignright")]
4227
4356
  ],
4228
4357
  t.style.textAlign || ""
4229
- ), this.formRow(r, this.t("tblalign"), s), n = this.formSelect(
4358
+ ), this.formRow(l, this.t("tblalign"), s), n = this.formSelect(
4230
4359
  [
4231
4360
  ["", this.t("alignnone")],
4232
4361
  ["top", this.t("valigntop")],
@@ -4234,7 +4363,7 @@ let Hi = (j = class {
4234
4363
  ["bottom", this.t("valignbottom")]
4235
4364
  ],
4236
4365
  t.style.verticalAlign || ""
4237
- ), this.formRow(r, this.t("valign"), n), l = this.formBg(t.style.backgroundColor || ""), this.formRow(r, this.t("backcolor"), l.wrap);
4366
+ ), this.formRow(l, this.t("valign"), n), r = this.formBg(t.style.backgroundColor || ""), this.formRow(l, this.t("backcolor"), r.wrap);
4238
4367
  },
4239
4368
  [
4240
4369
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4242,7 +4371,7 @@ let Hi = (j = class {
4242
4371
  label: this.t("save"),
4243
4372
  primary: !0,
4244
4373
  action: () => {
4245
- 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();
4374
+ 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();
4246
4375
  }
4247
4376
  }
4248
4377
  ]
@@ -4280,11 +4409,11 @@ let Hi = (j = class {
4280
4409
  return;
4281
4410
  }
4282
4411
  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);
4283
- let l, r;
4412
+ let r, l;
4284
4413
  this.dialog(
4285
4414
  this.t("colprops").replace("…", ""),
4286
4415
  (o) => {
4287
- 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);
4416
+ r = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(o, this.t("tblwidth"), r), l = this.formBg(t.style.backgroundColor || ""), this.formRow(o, this.t("backcolor"), l.wrap);
4288
4417
  },
4289
4418
  [
4290
4419
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4293,7 +4422,7 @@ let Hi = (j = class {
4293
4422
  primary: !0,
4294
4423
  action: () => {
4295
4424
  n.forEach((o) => {
4296
- this.setOrClear(o, "width", l.value.trim()), this.setOrClear(o, "background-color", r.fill.checked ? r.color.value : "");
4425
+ this.setOrClear(o, "width", r.value.trim()), this.setOrClear(o, "background-color", l.fill.checked ? l.color.value : "");
4297
4426
  }), this.closeDlg(), this.onChange(), this.positionTableHandles();
4298
4427
  }
4299
4428
  }
@@ -4309,8 +4438,8 @@ let Hi = (j = class {
4309
4438
  const s = document.createElement("div");
4310
4439
  s.className = "dlg", s.dir = this.dir(), s.innerHTML = `<header><span>${t}</span><button type="button">×</button></header>
4311
4440
  <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) => {
4312
- const l = document.createElement("button");
4313
- l.type = "button", l.textContent = n.label, n.primary && (l.className = "pri"), l.onclick = n.action, s.querySelector("footer").appendChild(l);
4441
+ const r = document.createElement("button");
4442
+ r.type = "button", r.textContent = n.label, n.primary && (r.className = "pri"), r.onclick = n.action, s.querySelector("footer").appendChild(r);
4314
4443
  }), this.dlgOvl.appendChild(s), this.dlgOvl.addEventListener("mousedown", (n) => {
4315
4444
  n.target === this.dlgOvl && this.closeDlg();
4316
4445
  }), document.body.appendChild(this.dlgOvl);
@@ -4360,8 +4489,12 @@ let Hi = (j = class {
4360
4489
  }
4361
4490
  previewDlg() {
4362
4491
  this.dialog(this.t("previewttl"), (t) => {
4492
+ var s;
4493
+ (s = t.closest(".dlg")) == null || s.classList.add("dlg-preview");
4363
4494
  const e = document.createElement("div");
4364
- e.style.cssText = "width:640px;max-width:78vw;max-height:52vh;overflow:auto;border:1px solid #e3e3e3;border-radius:6px;padding:14px;font-family:Helvetica,Arial,sans-serif;font-size:14px", e.innerHTML = this.ed.innerHTML, t.appendChild(e);
4495
+ e.className = "pv-box";
4496
+ const i = this.contentWidth();
4497
+ 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);
4365
4498
  });
4366
4499
  }
4367
4500
  /** Two-pane picker shared by the special-character map and the emoji map:
@@ -4370,31 +4503,31 @@ let Hi = (j = class {
4370
4503
  this.saveSel(), this.dialog(t, (s) => {
4371
4504
  const n = document.createElement("div");
4372
4505
  n.className = "chmap";
4373
- const l = document.createElement("div");
4374
- l.className = "chtabs";
4375
4506
  const r = document.createElement("div");
4376
- r.className = "chpanel";
4507
+ r.className = "chtabs";
4508
+ const l = document.createElement("div");
4509
+ l.className = "chpanel";
4377
4510
  const o = document.createElement("div");
4378
- o.className = "chgrid" + (i ? " emgrid" : ""), r.appendChild(o);
4379
- const c = (d) => {
4380
- l.querySelectorAll("button").forEach((u, m) => u.classList.toggle("on", m === d)), o.innerHTML = "", e[d].chars.forEach((u) => {
4511
+ o.className = "chgrid" + (i ? " emgrid" : ""), l.appendChild(o);
4512
+ const a = (d) => {
4513
+ r.querySelectorAll("button").forEach((p, m) => p.classList.toggle("on", m === d)), o.innerHTML = "", e[d].chars.forEach((p) => {
4381
4514
  const m = document.createElement("button");
4382
- m.type = "button", m.textContent = u, m.onclick = () => {
4383
- this.closeDlg(), this.exec("insertText", u);
4515
+ m.type = "button", m.textContent = p, m.onclick = () => {
4516
+ this.closeDlg(), this.exec("insertText", p);
4384
4517
  }, o.appendChild(m);
4385
- }), r.scrollTop = 0;
4518
+ }), l.scrollTop = 0;
4386
4519
  };
4387
- e.forEach((d, u) => {
4520
+ e.forEach((d, p) => {
4388
4521
  const m = document.createElement("button");
4389
- m.type = "button", m.textContent = this.t(d.key), m.addEventListener("click", () => c(u)), l.appendChild(m);
4390
- }), n.append(l, r), s.appendChild(n), c(0);
4522
+ m.type = "button", m.textContent = this.t(d.key), m.addEventListener("click", () => a(p)), r.appendChild(m);
4523
+ }), n.append(r, l), s.appendChild(n), a(0);
4391
4524
  });
4392
4525
  }
4393
4526
  charMap() {
4394
- this.glyphPickerDlg(this.t("charmap").replace("…", ""), ei, !1);
4527
+ this.glyphPickerDlg(this.t("charmap").replace("…", ""), li, !1);
4395
4528
  }
4396
4529
  emojiMap() {
4397
- this.glyphPickerDlg(this.t("emoji").replace("…", ""), ii, !0);
4530
+ this.glyphPickerDlg(this.t("emoji").replace("…", ""), oi, !0);
4398
4531
  }
4399
4532
  printDoc() {
4400
4533
  const t = window.open("", "_blank");
@@ -4456,17 +4589,17 @@ let Hi = (j = class {
4456
4589
  const i = document.createElement("button");
4457
4590
  i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertimg");
4458
4591
  const s = () => {
4459
- const n = e.value.trim(), l = this.phActive;
4460
- if (!l) return;
4592
+ const n = e.value.trim(), r = this.phActive;
4593
+ if (!r) return;
4461
4594
  if (!/^(https?:|data:image\/|blob:)/i.test(n)) {
4462
4595
  e.classList.add("err"), e.focus();
4463
4596
  return;
4464
4597
  }
4465
4598
  i.disabled = !0, e.disabled = !0;
4466
- const r = new Image();
4467
- r.onload = () => this.replacePlaceholderWithImage(l, n, ""), r.onerror = () => {
4599
+ const l = new Image();
4600
+ l.onload = () => this.replacePlaceholderWithImage(r, n, ""), l.onerror = () => {
4468
4601
  i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
4469
- }, r.src = n;
4602
+ }, l.src = n;
4470
4603
  };
4471
4604
  i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (n) => {
4472
4605
  n.key === "Enter" ? (n.preventDefault(), s()) : n.key === "Escape" && (n.stopPropagation(), this.renderPhCtxButtons());
@@ -4492,13 +4625,64 @@ let Hi = (j = class {
4492
4625
  s && (s.textContent = this.t("uploading")), this.imageUploadHandler(t).then((n) => {
4493
4626
  this.ed.contains(e) && this.replacePlaceholderWithImage(e, n, i);
4494
4627
  }).catch((n) => {
4495
- var l;
4496
- 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));
4628
+ var r;
4629
+ 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));
4497
4630
  });
4498
4631
  }
4499
4632
  replacePlaceholderWithImage(t, e, i) {
4500
4633
  const s = document.createElement("img");
4501
- s.src = e, s.alt = "", i && (s.title = i), t.replaceWith(s), this.phActive === t && this.clearImgPlaceholderSel(), this.refreshState(), this.onChange();
4634
+ s.src = e, s.alt = "", i && (s.title = i), t.replaceWith(s), this.stampImageSize(s), this.phActive === t && this.clearImgPlaceholderSel(), this.refreshState(), this.onChange();
4635
+ }
4636
+ /** Width of the editor's text column — the width `.earea img { max-width:100% }`
4637
+ * clamps an oversized image to. */
4638
+ contentWidth() {
4639
+ const t = getComputedStyle(this.ed), e = (parseFloat(t.paddingLeft) || 0) + (parseFloat(t.paddingRight) || 0);
4640
+ return Math.max(0, this.ed.clientWidth - e);
4641
+ }
4642
+ /** Inserts an <img> through execCommand and stamps its size once it has decoded.
4643
+ * A throwaway id is the only way to get a handle on what insertHTML created. */
4644
+ insertImageHTML(t, e) {
4645
+ const i = "fable-img-" + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
4646
+ document.execCommand(
4647
+ "insertHTML",
4648
+ !1,
4649
+ `<img id="${i}" src="${t}"${e ? ` title="${e}"` : ""} alt="">`
4650
+ );
4651
+ const s = this.ed.querySelector("#" + i);
4652
+ s && (s.removeAttribute("id"), this.stampImageSize(s));
4653
+ }
4654
+ /** Gives a newly inserted image an explicit size so it renders the same in the
4655
+ * editor, in Preview and in a sent email. Without it the image only looks right
4656
+ * inside `.earea`, whose `max-width:100%` rule exists nowhere else — which is why
4657
+ * the same picture came out at a different size once the mail was sent.
4658
+ * Leaves alone: images inside a template media slot (deliberately fluid) and any
4659
+ * image that already carries a size from its source. */
4660
+ stampImageSize(t, e) {
4661
+ const i = (n) => {
4662
+ e ? e(n) : n && this.onChange();
4663
+ }, s = () => {
4664
+ if (!this.ed.contains(t) || t.closest(".tpl-media") || t.getAttribute("width") || t.getAttribute("height") || t.style.width || t.style.height) return i(!1);
4665
+ const n = t.naturalWidth;
4666
+ if (!n) return i(!1);
4667
+ const r = this.contentWidth(), l = Math.round(r > 0 ? Math.min(n, r) : n);
4668
+ t.setAttribute("width", String(l)), t.style.width = l + "px", t.style.height = "auto", i(!0);
4669
+ };
4670
+ t.complete && t.naturalWidth ? s() : (t.addEventListener("load", s, { once: !0 }), t.addEventListener("error", () => i(!1), { once: !0 }));
4671
+ }
4672
+ /** Sizes images in content that arrived from outside the editor — a document saved
4673
+ * before the editor started recording image sizes. Without this such a document
4674
+ * keeps rendering at one size here and another in a sent mail. Images that already
4675
+ * carry a size, and template slots, are left alone, so content written by a
4676
+ * current version passes through untouched. Emits one change after the images have
4677
+ * settled rather than one per image, and none at all if nothing needed stamping. */
4678
+ stampExistingImages() {
4679
+ const t = Array.from(this.ed.querySelectorAll("img"));
4680
+ if (!t.length) return;
4681
+ let e = t.length, i = !1;
4682
+ const s = (n) => {
4683
+ n && (i = !0), --e === 0 && i && this.onChange();
4684
+ };
4685
+ t.forEach((n) => this.stampImageSize(n, s));
4502
4686
  }
4503
4687
  positionImgPhCtx() {
4504
4688
  if (this.phActive && !document.body.contains(this.phActive)) {
@@ -4556,20 +4740,20 @@ let Hi = (j = class {
4556
4740
  const i = document.createElement("button");
4557
4741
  i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertvideo");
4558
4742
  const s = () => {
4559
- const n = e.value.trim(), l = this.vphActive;
4560
- if (!l) return;
4743
+ const n = e.value.trim(), r = this.vphActive;
4744
+ if (!r) return;
4561
4745
  if (!/^(https?:|data:video\/|blob:)/i.test(n)) {
4562
4746
  e.classList.add("err"), e.focus();
4563
4747
  return;
4564
4748
  }
4565
- const r = this.videoEmbedUrl(n);
4566
- if (r) {
4567
- this.replacePlaceholderWithEmbed(l, r);
4749
+ const l = this.videoEmbedUrl(n);
4750
+ if (l) {
4751
+ this.replacePlaceholderWithEmbed(r, l);
4568
4752
  return;
4569
4753
  }
4570
4754
  i.disabled = !0, e.disabled = !0;
4571
4755
  const o = document.createElement("video");
4572
- o.preload = "metadata", o.onloadedmetadata = () => this.replacePlaceholderWithVideo(l, n, ""), o.onerror = () => {
4756
+ o.preload = "metadata", o.onloadedmetadata = () => this.replacePlaceholderWithVideo(r, n, ""), o.onerror = () => {
4573
4757
  i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
4574
4758
  }, o.src = n;
4575
4759
  };
@@ -4597,8 +4781,8 @@ let Hi = (j = class {
4597
4781
  s && (s.textContent = this.t("uploading")), this.videoUploadHandler(t).then((n) => {
4598
4782
  this.ed.contains(e) && this.replacePlaceholderWithVideo(e, n, i);
4599
4783
  }).catch((n) => {
4600
- var l;
4601
- 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));
4784
+ var r;
4785
+ 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));
4602
4786
  });
4603
4787
  }
4604
4788
  replacePlaceholderWithVideo(t, e, i) {
@@ -4638,23 +4822,23 @@ let Hi = (j = class {
4638
4822
  e.className = "imgctx", e.dir = this.dir();
4639
4823
  const i = () => {
4640
4824
  var d;
4641
- const c = this.buildVideoCtxToolbar(t);
4642
- (d = this.vidCtx) == null || d.replaceWith(c), this.vidCtx = c, this.positionVidCtx();
4643
- }, s = (c) => {
4644
- this.setVideoAlign(t, c), i();
4645
- }, n = t.style.float === "left", l = t.style.float === "right", r = !n && !l && t.style.marginLeft === "auto" && t.style.marginRight === "auto", o = (c, d, u, m) => {
4646
- const b = this.ctxBtn(c, d, m);
4647
- return b.classList.toggle("on", u), b;
4825
+ const a = this.buildVideoCtxToolbar(t);
4826
+ (d = this.vidCtx) == null || d.replaceWith(a), this.vidCtx = a, this.positionVidCtx();
4827
+ }, s = (a) => {
4828
+ this.setVideoAlign(t, a), i();
4829
+ }, n = t.style.float === "left", r = t.style.float === "right", l = !n && !r && t.style.marginLeft === "auto" && t.style.marginRight === "auto", o = (a, d, p, m) => {
4830
+ const b = this.ctxBtn(a, d, m);
4831
+ return b.classList.toggle("on", p), b;
4648
4832
  };
4649
4833
  return e.append(
4650
4834
  o(h.alignleft, this.t("alignleft"), n, () => s("left")),
4651
- o(h.aligncenter, this.t("aligncenter"), r, () => s("center")),
4652
- o(h.alignright, this.t("alignright"), l, () => s("right")),
4835
+ o(h.aligncenter, this.t("aligncenter"), l, () => s("center")),
4836
+ o(h.alignright, this.t("alignright"), r, () => s("right")),
4653
4837
  this.ctxSep(),
4654
4838
  o(h.trash, this.t("deletevideo"), !1, () => {
4655
4839
  t.remove(), this.clearVidHandles(), this.onChange();
4656
4840
  })
4657
- ), e.addEventListener("mousedown", (c) => c.preventDefault()), e.addEventListener("mouseenter", () => this.cancelVidHide()), e.addEventListener("mouseleave", () => {
4841
+ ), e.addEventListener("mousedown", (a) => a.preventDefault()), e.addEventListener("mouseenter", () => this.cancelVidHide()), e.addEventListener("mouseleave", () => {
4658
4842
  this.cancelVidHide(), this.vidHideTimer = window.setTimeout(() => this.clearVidHandles(), 250);
4659
4843
  }), document.body.appendChild(e), e;
4660
4844
  }
@@ -4691,30 +4875,30 @@ let Hi = (j = class {
4691
4875
  * (videoUploadHandler when configured, else inline base64). */
4692
4876
  videoDlg() {
4693
4877
  this.saveSel();
4694
- let t, e, i, s, n, l;
4695
- const r = (c, d) => {
4696
- const u = document.createElement("div");
4697
- u.className = "dfield";
4878
+ let t, e, i, s, n, r;
4879
+ const l = (a, d) => {
4880
+ const p = document.createElement("div");
4881
+ p.className = "dfield";
4698
4882
  const m = document.createElement("label");
4699
- return m.textContent = this.t(c), u.append(m, d), u;
4883
+ return m.textContent = this.t(a), p.append(m, d), p;
4700
4884
  }, o = () => {
4701
- const c = document.createElement("input");
4702
- return c.type = "url", c;
4885
+ const a = document.createElement("input");
4886
+ return a.type = "url", a;
4703
4887
  };
4704
4888
  this.dialog(
4705
4889
  this.t("videodlgttl"),
4706
- (c) => {
4890
+ (a) => {
4707
4891
  const d = document.createElement("div");
4708
4892
  d.className = "dtabs";
4709
- const u = [], m = (g, x) => {
4893
+ const p = [], m = (g, x) => {
4710
4894
  const w = document.createElement("button");
4711
4895
  w.type = "button", w.textContent = this.t(g);
4712
4896
  const E = document.createElement("div");
4713
4897
  E.className = "dtabpanel", x(E);
4714
- const I = u.length;
4715
- u.push(E), w.addEventListener("click", () => b(I)), d.appendChild(w);
4898
+ const I = p.length;
4899
+ p.push(E), w.addEventListener("click", () => b(I)), d.appendChild(w);
4716
4900
  }, b = (g) => {
4717
- d.querySelectorAll("button").forEach((x, w) => x.classList.toggle("on", w === g)), u.forEach((x, w) => x.style.display = w === g ? "" : "none");
4901
+ d.querySelectorAll("button").forEach((x, w) => x.classList.toggle("on", w === g)), p.forEach((x, w) => x.style.display = w === g ? "" : "none");
4718
4902
  };
4719
4903
  m("vidgeneral", (g) => {
4720
4904
  t = o(), t.placeholder = this.t("videourlph");
@@ -4726,33 +4910,33 @@ let Hi = (j = class {
4726
4910
  E.type = "file", E.accept = this.options.videoFileTypes.join(","), E.style.display = "none", w.addEventListener("click", () => {
4727
4911
  E.value = "", E.click();
4728
4912
  }), E.addEventListener("change", () => {
4729
- var O;
4730
- const H = (O = E.files) == null ? void 0 : O[0];
4731
- if (!H) return;
4913
+ var Z;
4914
+ const A = (Z = E.files) == null ? void 0 : Z[0];
4915
+ if (!A) return;
4732
4916
  w.disabled = !0, w.textContent = this.t("uploading");
4733
4917
  const $ = (F) => {
4734
4918
  t.value = F, w.disabled = !1, w.textContent = this.t("uploadvideo");
4735
4919
  };
4736
4920
  if (this.videoUploadHandler)
4737
- this.videoUploadHandler(H).then($).catch((F) => {
4921
+ this.videoUploadHandler(A).then($).catch((F) => {
4738
4922
  var et;
4739
- w.disabled = !1, w.textContent = this.t("uploadfailed"), (et = this.onVideoUploadError) == null || et.call(this, F, H);
4923
+ w.disabled = !1, w.textContent = this.t("uploadfailed"), (et = this.onVideoUploadError) == null || et.call(this, F, A);
4740
4924
  });
4741
4925
  else {
4742
4926
  const F = new FileReader();
4743
- F.onload = () => $(F.result), F.readAsDataURL(H);
4927
+ F.onload = () => $(F.result), F.readAsDataURL(A);
4744
4928
  }
4745
- }), x.append(t, w, E), t.style.flex = "1", g.appendChild(r("vidsource", x));
4929
+ }), x.append(t, w, E), t.style.flex = "1", g.appendChild(l("vidsource", x));
4746
4930
  const I = document.createElement("div");
4747
- 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)), g.appendChild(I);
4931
+ 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(l("tblwidth", e), l("tblheight", i)), g.appendChild(I);
4748
4932
  }), m("vidembed", (g) => {
4749
4933
  const x = document.createElement("p");
4750
4934
  x.textContent = this.t("vidembedhint"), x.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", g.append(x, s);
4751
4935
  }), m("vidadvanced", (g) => {
4752
- n = o(), l = o(), g.append(r("vidaltsource", n), r("vidposter", l));
4936
+ n = o(), r = o(), g.append(l("vidaltsource", n), l("vidposter", r));
4753
4937
  });
4754
4938
  const y = document.createElement("div");
4755
- y.className = "dtabbody", u.forEach((g) => y.appendChild(g)), c.append(d, y), b(0), setTimeout(() => t.focus(), 0);
4939
+ y.className = "dtabbody", p.forEach((g) => y.appendChild(g)), a.append(d, y), b(0), setTimeout(() => t.focus(), 0);
4756
4940
  },
4757
4941
  [
4758
4942
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4760,21 +4944,21 @@ let Hi = (j = class {
4760
4944
  label: this.t("save"),
4761
4945
  primary: !0,
4762
4946
  action: () => {
4763
- const c = s.value.trim(), d = t.value.trim(), u = parseInt(e.value, 10) || 560, m = parseInt(i.value, 10) || 314;
4764
- if (this.closeDlg(), !c && !d) return;
4765
- if (this.restoreSel(), c) {
4766
- document.execCommand("insertHTML", !1, `<span class="video-embed" contenteditable="false">${c}</span>`), this.onChange();
4947
+ const a = s.value.trim(), d = t.value.trim(), p = parseInt(e.value, 10) || 560, m = parseInt(i.value, 10) || 314;
4948
+ if (this.closeDlg(), !a && !d) return;
4949
+ if (this.restoreSel(), a) {
4950
+ document.execCommand("insertHTML", !1, `<span class="video-embed" contenteditable="false">${a}</span>`), this.onChange();
4767
4951
  return;
4768
4952
  }
4769
4953
  const b = this.videoEmbedUrl(d);
4770
4954
  if (b)
4771
- document.execCommand("insertHTML", !1, this.videoEmbedHTML(b, u, m));
4955
+ document.execCommand("insertHTML", !1, this.videoEmbedHTML(b, p, m));
4772
4956
  else {
4773
- const y = n.value.trim(), g = l.value.trim();
4957
+ const y = n.value.trim(), g = r.value.trim();
4774
4958
  document.execCommand(
4775
4959
  "insertHTML",
4776
4960
  !1,
4777
- `<video controls width="${u}" height="${m}"${g ? ` poster="${this.escapeAttr(g)}"` : ""}><source src="${this.escapeAttr(d)}">${y ? `<source src="${this.escapeAttr(y)}">` : ""}</video>`
4961
+ `<video controls width="${p}" height="${m}"${g ? ` poster="${this.escapeAttr(g)}"` : ""}><source src="${this.escapeAttr(d)}">${y ? `<source src="${this.escapeAttr(y)}">` : ""}</video>`
4778
4962
  );
4779
4963
  }
4780
4964
  this.onChange();
@@ -4832,15 +5016,15 @@ let Hi = (j = class {
4832
5016
  if (i.nodeType !== Node.TEXT_NODE || !this.ed.contains(i) || (d = i.parentElement) != null && d.closest("code, pre")) return;
4833
5017
  const n = (i.textContent || "").slice(0, e.anchorOffset).match(/(?:^|[^`])`([^`]+)$/);
4834
5018
  if (!n) return;
4835
- const l = n[1];
4836
- if (/^\s|\s$/.test(l)) return;
5019
+ const r = n[1];
5020
+ if (/^\s|\s$/.test(r)) return;
4837
5021
  t.preventDefault();
4838
- const r = document.createRange();
4839
- r.setStart(i, e.anchorOffset - l.length - 1), r.setEnd(i, e.anchorOffset), r.deleteContents();
5022
+ const l = document.createRange();
5023
+ l.setStart(i, e.anchorOffset - r.length - 1), l.setEnd(i, e.anchorOffset), l.deleteContents();
4840
5024
  const o = document.createElement("code");
4841
- o.textContent = l, r.insertNode(o);
4842
- const c = document.createRange();
4843
- c.setStartAfter(o), c.collapse(!0), e.removeAllRanges(), e.addRange(c), this.saveSel(), this.onChange();
5025
+ o.textContent = r, l.insertNode(o);
5026
+ const a = document.createRange();
5027
+ a.setStartAfter(o), a.collapse(!0), e.removeAllRanges(), e.addRange(a), this.saveSel(), this.onChange();
4844
5028
  }
4845
5029
  /** Custom dropdown for dialog fields (a native <select> popup can't be styled):
4846
5030
  * a field-styled button showing the current choice that opens a floating,
@@ -4852,22 +5036,22 @@ let Hi = (j = class {
4852
5036
  s.className = "dsel";
4853
5037
  const n = document.createElement("button");
4854
5038
  n.type = "button", n.className = "dsel-btn";
4855
- const l = document.createElement("span");
4856
- l.className = "lbl", l.textContent = ((o = t.find(([c]) => c === e)) == null ? void 0 : o[1]) || "", n.append(l), n.insertAdjacentHTML("beforeend", h.chev);
4857
- const r = document.createElement("div");
4858
- return r.className = "dsel-list", t.forEach(([c, d]) => {
4859
- const u = document.createElement("button");
4860
- u.type = "button", u.textContent = d, u.classList.toggle("on", c === i), u.addEventListener("click", () => {
4861
- i = c, l.textContent = d, r.querySelectorAll("button").forEach((m) => m.classList.toggle("on", m === u)), s.classList.remove("open"), n.focus();
4862
- }), r.appendChild(u);
5039
+ const r = document.createElement("span");
5040
+ r.className = "lbl", r.textContent = ((o = t.find(([a]) => a === e)) == null ? void 0 : o[1]) || "", n.append(r), n.insertAdjacentHTML("beforeend", h.chev);
5041
+ const l = document.createElement("div");
5042
+ return l.className = "dsel-list", t.forEach(([a, d]) => {
5043
+ const p = document.createElement("button");
5044
+ p.type = "button", p.textContent = d, p.classList.toggle("on", a === i), p.addEventListener("click", () => {
5045
+ i = a, r.textContent = d, l.querySelectorAll("button").forEach((m) => m.classList.toggle("on", m === p)), s.classList.remove("open"), n.focus();
5046
+ }), l.appendChild(p);
4863
5047
  }), n.addEventListener("click", () => {
4864
- var c;
4865
- s.classList.toggle("open"), s.classList.contains("open") && ((c = r.querySelector(".on")) == null || c.scrollIntoView({ block: "nearest" }));
4866
- }), s.addEventListener("focusout", (c) => {
4867
- s.contains(c.relatedTarget) || s.classList.remove("open");
4868
- }), s.addEventListener("keydown", (c) => {
4869
- c.key === "Escape" && s.classList.contains("open") && (c.stopPropagation(), s.classList.remove("open"), n.focus());
4870
- }), s.append(n, r), { el: s, value: () => i };
5048
+ var a;
5049
+ s.classList.toggle("open"), s.classList.contains("open") && ((a = l.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
5050
+ }), s.addEventListener("focusout", (a) => {
5051
+ s.contains(a.relatedTarget) || s.classList.remove("open");
5052
+ }), s.addEventListener("keydown", (a) => {
5053
+ a.key === "Escape" && s.classList.contains("open") && (a.stopPropagation(), s.classList.remove("open"), n.focus());
5054
+ }), s.append(n, l), { el: s, value: () => i };
4871
5055
  }
4872
5056
  /** Insert/edit-code-sample dialog: language dropdown + monospace textarea to
4873
5057
  * paste or type code into. Inserts a non-editable <pre class="code-block">
@@ -4878,11 +5062,11 @@ let Hi = (j = class {
4878
5062
  this.dialog(
4879
5063
  this.t("codedlgttl"),
4880
5064
  (s) => {
4881
- var r;
5065
+ var l;
4882
5066
  const n = document.createElement("div");
4883
5067
  n.className = "dfield";
4884
- const l = document.createElement("label");
4885
- l.textContent = this.t("codelang"), e = this.dlgSelect(ie, (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);
5068
+ const r = document.createElement("label");
5069
+ 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 = ((l = t == null ? void 0 : t.querySelector("code")) == null ? void 0 : l.textContent) || "", i.placeholder = "const answer = 42;", s.append(n, i), setTimeout(() => i.focus(), 0);
4886
5070
  },
4887
5071
  [
4888
5072
  { label: this.t("cancel"), action: () => this.closeDlg() },
@@ -4890,11 +5074,11 @@ let Hi = (j = class {
4890
5074
  label: this.t("save"),
4891
5075
  primary: !0,
4892
5076
  action: () => {
4893
- var r;
4894
- const s = i.value.replace(/\s+$/, ""), n = e.value(), l = ((r = ie.find(([o]) => o === n)) == null ? void 0 : r[1]) || n;
5077
+ var l;
5078
+ const s = i.value.replace(/\s+$/, ""), n = e.value(), r = ((l = se.find(([o]) => o === n)) == null ? void 0 : l[1]) || n;
4895
5079
  if (this.closeDlg(), !!s.trim()) {
4896
5080
  if (t) {
4897
- t.dataset.lang = n, t.setAttribute("data-lang-label", l);
5081
+ t.dataset.lang = n, t.setAttribute("data-lang-label", r);
4898
5082
  const o = t.querySelector("code") || t;
4899
5083
  o.textContent = s, this.clearCodeSel(), this.onChange();
4900
5084
  return;
@@ -4902,7 +5086,7 @@ let Hi = (j = class {
4902
5086
  this.restoreSel(), document.execCommand(
4903
5087
  "insertHTML",
4904
5088
  !1,
4905
- `<pre class="code-block" contenteditable="false" data-lang="${n}" data-lang-label="${this.escapeAttr(l)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`
5089
+ `<pre class="code-block" contenteditable="false" data-lang="${n}" data-lang-label="${this.escapeAttr(r)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`
4906
5090
  ), this.onChange();
4907
5091
  }
4908
5092
  }
@@ -4959,14 +5143,14 @@ let Hi = (j = class {
4959
5143
  /** Miniature div-based mockup of a layout, mirroring what the block looks
4960
5144
  like in the editor: grey box = image slot, bars = heading/paragraph. */
4961
5145
  tplPreviewHTML(t) {
4962
- 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));
4963
- 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>`;
5146
+ 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>`, r = (o) => `<span class="pv-row">${o}</span>`, l = n(i + s(100) + s(88));
5147
+ return t === "img-left" ? `<span class="pv">${r(e + l)}${s(100)}${s(72)}</span>` : t === "img-right" ? `<span class="pv">${r(l + 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>`;
4964
5148
  }
4965
5149
  buildTemplatePickInto(t, e) {
4966
5150
  const i = document.createElement("div");
4967
- i.className = "tplpick", wt.forEach((s) => {
5151
+ i.className = "tplpick", Tt.forEach((s) => {
4968
5152
  const n = document.createElement("button");
4969
- n.type = "button", n.className = "tpltile", n.title = this.t(Tt[s]), n.innerHTML = this.tplPreviewHTML(s) + `<span class="tpllbl">${this.t(Tt[s])}</span>`, n.addEventListener("click", () => {
5153
+ 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", () => {
4970
5154
  this.closePop(), this.insertTemplate(s), e == null || e();
4971
5155
  }), i.appendChild(n);
4972
5156
  }), t.appendChild(i);
@@ -4985,15 +5169,15 @@ let Hi = (j = class {
4985
5169
  }
4986
5170
  renderTplCtxButtons() {
4987
5171
  const t = this.tplCtx, e = this.tplActive;
4988
- !t || !e || (t.innerHTML = "", wt.forEach((i) => {
4989
- const s = this.ctxBtn(Ci[i], this.t(Tt[i]), () => this.setTplLayout(i));
5172
+ !t || !e || (t.innerHTML = "", Tt.forEach((i) => {
5173
+ const s = this.ctxBtn(Bi[i], this.t(Et[i]), () => this.setTplLayout(i));
4990
5174
  s.classList.toggle("on", e.classList.contains("tpl-" + i)), t.appendChild(s);
4991
5175
  }), t.append(this.ctxSep(), this.ctxBtn(h.trash, this.t("deltemplate"), () => this.removeTemplate())), this.positionTplCtx());
4992
5176
  }
4993
5177
  setTplLayout(t) {
4994
5178
  const e = this.tplActive;
4995
5179
  if (!e) return;
4996
- wt.forEach((n) => e.classList.remove("tpl-" + n)), e.classList.add("tpl-" + t);
5180
+ Tt.forEach((n) => e.classList.remove("tpl-" + n)), e.classList.add("tpl-" + t);
4997
5181
  const i = e.querySelector(":scope > .tpl-media"), s = e.querySelector(":scope > .tpl-text");
4998
5182
  i && s && (t === "img-center" ? e.appendChild(i) : e.insertBefore(i, s)), this.renderTplCtxButtons(), this.positionImgPhCtx(), this.positionImageHandles(), this.onChange();
4999
5183
  }
@@ -5025,7 +5209,7 @@ let Hi = (j = class {
5025
5209
  /* ---------------------------------------------------------- table resize */
5026
5210
  clearTableHandles() {
5027
5211
  var t, e, i, s, n;
5028
- (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;
5212
+ (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;
5029
5213
  }
5030
5214
  /** Blue outline around the cell that holds the caret, so it is clear
5031
5215
  which cell / row / column the table operations will target. */
@@ -5052,8 +5236,8 @@ let Hi = (j = class {
5052
5236
  return;
5053
5237
  }
5054
5238
  this.tblOpMark || (this.tblOpMark = document.createElement("div"), this.tblOpMark.className = "tbl-opmark", document.body.appendChild(this.tblOpMark));
5055
- 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, c = t === "row" ? n.height : i.height;
5056
- this.tblOpMark.style.left = l + scrollX + "px", this.tblOpMark.style.top = r + scrollY + "px", this.tblOpMark.style.width = o + "px", this.tblOpMark.style.height = c + "px";
5239
+ const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), n = e.parentElement.getBoundingClientRect(), r = t === "row" ? n.left : s.left, l = t === "row" ? n.top : i.top, o = t === "row" ? n.width : s.width, a = t === "row" ? n.height : i.height;
5240
+ this.tblOpMark.style.left = r + scrollX + "px", this.tblOpMark.style.top = l + scrollY + "px", this.tblOpMark.style.width = o + "px", this.tblOpMark.style.height = a + "px";
5057
5241
  }
5058
5242
  /** Lowest allowed top for floating context toolbars — keeps them from
5059
5243
  covering the editor menubar/toolbar when the target sits on the first line. */
@@ -5062,7 +5246,7 @@ let Hi = (j = class {
5062
5246
  }
5063
5247
  ctxBtn(t, e, i, s) {
5064
5248
  const n = document.createElement("button");
5065
- 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;
5249
+ 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;
5066
5250
  }
5067
5251
  ctxSep() {
5068
5252
  const t = document.createElement("div");
@@ -5099,20 +5283,20 @@ let Hi = (j = class {
5099
5283
  this.clearTableHandles();
5100
5284
  return;
5101
5285
  }
5102
- 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;
5103
- 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) {
5104
- const o = this.tblCtx.offsetWidth, c = this.tblCtx.offsetHeight;
5286
+ 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;
5287
+ 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) {
5288
+ const o = this.tblCtx.offsetWidth, a = this.tblCtx.offsetHeight;
5105
5289
  let d = s + (n - s) / 2 - o / 2;
5106
5290
  d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth - o - 8));
5107
- let u = i - c - 8;
5108
- u < this.ctxMinTop() && (u = l + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = u + "px";
5291
+ let p = i - a - 8;
5292
+ p < this.ctxMinTop() && (p = r + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = p + "px";
5109
5293
  }
5110
5294
  this.tblColBars.forEach((o) => o.remove()), this.tblColBars = [];
5111
- const r = this.tblActive.rows[0];
5112
- if (r)
5113
- for (let o = 0; o < r.cells.length - 1; o++) {
5114
- const c = r.cells[o].getBoundingClientRect(), d = (t ? c.left : c.right) + scrollX, u = document.createElement("div");
5115
- u.className = "tbl-colbar", u.style.top = i + "px", u.style.left = d + "px", u.style.height = l - i + "px", document.body.appendChild(u), u.addEventListener("mousedown", (m) => this.startColBarDrag(m, o)), this.tblColBars.push(u);
5295
+ const l = this.tblActive.rows[0];
5296
+ if (l)
5297
+ for (let o = 0; o < l.cells.length - 1; o++) {
5298
+ const a = l.cells[o].getBoundingClientRect(), d = (t ? a.left : a.right) + scrollX, p = document.createElement("div");
5299
+ 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, o)), this.tblColBars.push(p);
5116
5300
  }
5117
5301
  this.positionCellMarker(), this.positionOpMark();
5118
5302
  }
@@ -5130,29 +5314,29 @@ let Hi = (j = class {
5130
5314
  const e = this.tblActive;
5131
5315
  if (!e) return;
5132
5316
  const i = this.ed.getAttribute("dir") === "rtl", s = t.clientX, n = e.getBoundingClientRect().width;
5133
- e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((l) => {
5134
- const r = (c) => {
5135
- const d = i ? -(c.clientX - s) : c.clientX - s;
5317
+ e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((r) => {
5318
+ const l = (a) => {
5319
+ const d = i ? -(a.clientX - s) : a.clientX - s;
5136
5320
  e.style.width = Math.max(60, Math.round(n + d)) + "px", this.positionTableHandles();
5137
5321
  }, o = () => {
5138
- window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", o), l(), this.onChange();
5322
+ window.removeEventListener("mousemove", l), window.removeEventListener("mouseup", o), r(), this.onChange();
5139
5323
  };
5140
- window.addEventListener("mousemove", r), window.addEventListener("mouseup", o);
5324
+ window.addEventListener("mousemove", l), window.addEventListener("mouseup", o);
5141
5325
  });
5142
5326
  }
5143
5327
  startColBarDrag(t, e) {
5144
5328
  t.preventDefault(), t.stopPropagation();
5145
5329
  const i = this.tblActive;
5146
5330
  if (!i) return;
5147
- const s = this.ed.getAttribute("dir") === "rtl", n = Array.from(i.rows), l = n.map((u) => u.cells[e]).filter(Boolean), r = n.map((u) => u.cells[e + 1]).filter(Boolean);
5148
- if (!l.length || !r.length) return;
5149
- const o = t.clientX, c = l[0].getBoundingClientRect().width, d = r[0].getBoundingClientRect().width;
5150
- i.style.tableLayout = "fixed", this.withNoTextSelect((u) => {
5331
+ const s = this.ed.getAttribute("dir") === "rtl", n = Array.from(i.rows), r = n.map((p) => p.cells[e]).filter(Boolean), l = n.map((p) => p.cells[e + 1]).filter(Boolean);
5332
+ if (!r.length || !l.length) return;
5333
+ const o = t.clientX, a = r[0].getBoundingClientRect().width, d = l[0].getBoundingClientRect().width;
5334
+ i.style.tableLayout = "fixed", this.withNoTextSelect((p) => {
5151
5335
  const m = (y) => {
5152
5336
  const g = (s ? -1 : 1) * (y.clientX - o);
5153
- l.forEach((x) => x.style.width = Math.max(24, Math.round(c + g)) + "px"), r.forEach((x) => x.style.width = Math.max(24, Math.round(d - g)) + "px"), this.positionTableHandles();
5337
+ r.forEach((x) => x.style.width = Math.max(24, Math.round(a + g)) + "px"), l.forEach((x) => x.style.width = Math.max(24, Math.round(d - g)) + "px"), this.positionTableHandles();
5154
5338
  }, b = () => {
5155
- window.removeEventListener("mousemove", m), window.removeEventListener("mouseup", b), u(), this.onChange();
5339
+ window.removeEventListener("mousemove", m), window.removeEventListener("mouseup", b), p(), this.onChange();
5156
5340
  };
5157
5341
  window.addEventListener("mousemove", m), window.addEventListener("mouseup", b);
5158
5342
  });
@@ -5169,7 +5353,7 @@ let Hi = (j = class {
5169
5353
  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;
5170
5354
  }
5171
5355
  selectImage(t) {
5172
- this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles = xi.map((e) => {
5356
+ this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles = Pi.map((e) => {
5173
5357
  const i = document.createElement("div");
5174
5358
  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;
5175
5359
  }), this.imgCtx = this.buildImageCtxToolbar(t), this.positionImageHandles());
@@ -5179,18 +5363,18 @@ let Hi = (j = class {
5179
5363
  e.className = "imgctx", e.dir = this.dir();
5180
5364
  const i = () => {
5181
5365
  var d;
5182
- const c = this.buildImageCtxToolbar(t);
5183
- (d = this.imgCtx) == null || d.replaceWith(c), this.imgCtx = c, this.positionImageHandles();
5184
- }, s = (c) => {
5185
- this.setImageAlign(t, c), i();
5186
- }, n = t.style.float === "left", l = t.style.float === "right", r = !n && !l && t.style.marginLeft === "auto" && t.style.marginRight === "auto", o = (c, d, u, m) => {
5187
- const b = this.ctxBtn(c, d, m);
5188
- return b.classList.toggle("on", u), b;
5366
+ const a = this.buildImageCtxToolbar(t);
5367
+ (d = this.imgCtx) == null || d.replaceWith(a), this.imgCtx = a, this.positionImageHandles();
5368
+ }, s = (a) => {
5369
+ this.setImageAlign(t, a), i();
5370
+ }, n = t.style.float === "left", r = t.style.float === "right", l = !n && !r && t.style.marginLeft === "auto" && t.style.marginRight === "auto", o = (a, d, p, m) => {
5371
+ const b = this.ctxBtn(a, d, m);
5372
+ return b.classList.toggle("on", p), b;
5189
5373
  };
5190
5374
  return e.append(
5191
5375
  o(h.alignleft, this.t("alignleft"), n, () => s("left")),
5192
- o(h.aligncenter, this.t("aligncenter"), r, () => s("center")),
5193
- o(h.alignright, this.t("alignright"), l, () => s("right")),
5376
+ o(h.aligncenter, this.t("aligncenter"), l, () => s("center")),
5377
+ o(h.alignright, this.t("alignright"), r, () => s("right")),
5194
5378
  this.ctxSep(),
5195
5379
  o(h.rotateleft, this.t("rotateleft"), !1, () => {
5196
5380
  this.rotateImage(t, -90), i();
@@ -5207,10 +5391,10 @@ let Hi = (j = class {
5207
5391
  }),
5208
5392
  this.ctxSep(),
5209
5393
  o(h.trash, this.t("deleteimg"), !1, () => {
5210
- const c = t.closest(".tpl-media");
5211
- c && this.ed.contains(c) ? t.outerHTML = this.imgPhHTML() : t.remove(), this.clearImageHandles(), this.onChange();
5394
+ const a = t.closest(".tpl-media");
5395
+ a && this.ed.contains(a) ? t.outerHTML = this.imgPhHTML() : t.remove(), this.clearImageHandles(), this.onChange();
5212
5396
  })
5213
- ), e.addEventListener("mousedown", (c) => c.preventDefault()), e.addEventListener("mouseenter", () => this.cancelImgHide()), e.addEventListener("mouseleave", () => this.scheduleImgHide()), document.body.appendChild(e), e;
5397
+ ), e.addEventListener("mousedown", (a) => a.preventDefault()), e.addEventListener("mouseenter", () => this.cancelImgHide()), e.addEventListener("mouseleave", () => this.scheduleImgHide()), document.body.appendChild(e), e;
5214
5398
  }
5215
5399
  setImageAlign(t, e) {
5216
5400
  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();
@@ -5232,21 +5416,21 @@ let Hi = (j = class {
5232
5416
  this.clearImageHandles();
5233
5417
  return;
5234
5418
  }
5235
- const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, n = t.bottom + scrollY, l = {
5419
+ const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, n = t.bottom + scrollY, r = {
5236
5420
  nw: [i, e],
5237
5421
  ne: [s, e],
5238
5422
  sw: [i, n],
5239
5423
  se: [s, n]
5240
5424
  };
5241
- if (this.imgHandles.forEach((r) => {
5242
- const [o, c] = l[r.dataset.corner];
5243
- r.style.left = o - 5 + "px", r.style.top = c - 5 + "px";
5425
+ if (this.imgHandles.forEach((l) => {
5426
+ const [o, a] = r[l.dataset.corner];
5427
+ l.style.left = o - 5 + "px", l.style.top = a - 5 + "px";
5244
5428
  }), this.imgCtx) {
5245
- const r = this.imgCtx.offsetWidth, o = this.imgCtx.offsetHeight;
5246
- let c = i + (s - i) / 2 - r / 2;
5247
- c = Math.max(8 + scrollX, Math.min(c, scrollX + innerWidth - r - 8));
5429
+ const l = this.imgCtx.offsetWidth, o = this.imgCtx.offsetHeight;
5430
+ let a = i + (s - i) / 2 - l / 2;
5431
+ a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - l - 8));
5248
5432
  let d = e - o - 8;
5249
- d < this.ctxMinTop() && (d = n + 8), this.imgCtx.style.left = c + "px", this.imgCtx.style.top = d + "px";
5433
+ d < this.ctxMinTop() && (d = n + 8), this.imgCtx.style.left = a + "px", this.imgCtx.style.top = d + "px";
5250
5434
  }
5251
5435
  }
5252
5436
  startImageResizeDrag(t, e) {
@@ -5254,14 +5438,16 @@ let Hi = (j = class {
5254
5438
  const i = this.imgActive;
5255
5439
  if (!i) return;
5256
5440
  this.cancelImgHide();
5257
- const s = t.clientX, n = i.getBoundingClientRect().width, l = e === "nw" || e === "sw" ? -1 : 1;
5258
- this.withNoTextSelect((r) => {
5441
+ const s = t.clientX, n = i.getBoundingClientRect().width, r = e === "nw" || e === "sw" ? -1 : 1;
5442
+ this.withNoTextSelect((l) => {
5259
5443
  const o = (d) => {
5260
- i.style.width = Math.max(24, Math.round(n + l * (d.clientX - s))) + "px", i.style.height = "auto", this.positionImageHandles();
5261
- }, c = () => {
5262
- window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", c), r(), this.onChange();
5444
+ i.style.width = Math.max(24, Math.round(n + r * (d.clientX - s))) + "px", i.style.height = "auto", this.positionImageHandles();
5445
+ }, a = () => {
5446
+ window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", a), l();
5447
+ const d = parseInt(i.style.width, 10);
5448
+ d > 0 && !i.closest(".tpl-media") && (i.setAttribute("width", String(d)), i.removeAttribute("height")), this.onChange();
5263
5449
  };
5264
- window.addEventListener("mousemove", o), window.addEventListener("mouseup", c);
5450
+ window.addEventListener("mousemove", o), window.addEventListener("mouseup", a);
5265
5451
  });
5266
5452
  }
5267
5453
  /* ---------------------------------------------------------- selection bubble toolbar */
@@ -5300,7 +5486,7 @@ let Hi = (j = class {
5300
5486
  this.selCtx || (this.selCtx = this.buildSelToolbar()), this.positionSelToolbar(e);
5301
5487
  }
5302
5488
  buildSelToolbar() {
5303
- var r;
5489
+ var l;
5304
5490
  const t = document.createElement("div");
5305
5491
  t.className = "selctx", t.dir = this.dir();
5306
5492
  const e = this.ctxBtn(
@@ -5308,8 +5494,8 @@ let Hi = (j = class {
5308
5494
  this.t("forecolor"),
5309
5495
  () => this.colorMenu(e, "fore")
5310
5496
  ), i = this.ctxBtn(h.backcolor, this.t("backcolor"), () => this.colorMenu(i, "back"));
5311
- (r = i.querySelector("svg")) == null || r.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
5312
- 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));
5497
+ (l = i.querySelector("svg")) == null || l.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
5498
+ 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));
5313
5499
  return t.append(
5314
5500
  this.ctxBtn(h.bold, this.t("bold"), () => this.exec("bold"), "bold"),
5315
5501
  this.ctxBtn(h.italic, this.t("italic"), () => this.exec("italic"), "italic"),
@@ -5324,16 +5510,16 @@ let Hi = (j = class {
5324
5510
  this.ctxBtn(h.link, this.t("linkttl"), () => this.linkDlg()),
5325
5511
  s,
5326
5512
  n,
5327
- l
5513
+ r
5328
5514
  ), t.addEventListener("mousedown", (o) => o.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
5329
5515
  }
5330
5516
  positionSelToolbar(t) {
5331
5517
  if (!this.selCtx) return;
5332
- 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;
5333
- let c = s + (n - s) / 2 - r / 2;
5334
- c = Math.max(8 + scrollX, Math.min(c, scrollX + innerWidth - r - 8));
5518
+ const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, n = e.right + scrollX, r = e.bottom + scrollY, l = this.selCtx.offsetWidth, o = this.selCtx.offsetHeight;
5519
+ let a = s + (n - s) / 2 - l / 2;
5520
+ a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - l - 8));
5335
5521
  let d = i - o - 8;
5336
- d < this.ctxMinTop() && (d = l + 8), this.selCtx.style.left = c + "px", this.selCtx.style.top = d + "px";
5522
+ d < this.ctxMinTop() && (d = r + 8), this.selCtx.style.left = a + "px", this.selCtx.style.top = d + "px";
5337
5523
  }
5338
5524
  repositionSelToolbar() {
5339
5525
  if (!this.selCtx) return;
@@ -5366,9 +5552,9 @@ let Hi = (j = class {
5366
5552
  return t > 0 ? t + "px" : "";
5367
5553
  }
5368
5554
  refreshState() {
5369
- var o, c, d;
5555
+ var o, a, d;
5370
5556
  const t = window.getSelection(), e = t ? this.ed.contains(t.anchorNode) : !1, i = this.currentBlock();
5371
- [this.toolbar, this.selCtx].filter(Boolean).forEach((u) => {
5557
+ [this.toolbar, this.selCtx].filter(Boolean).forEach((p) => {
5372
5558
  [
5373
5559
  "bold",
5374
5560
  "italic",
@@ -5381,22 +5567,22 @@ let Hi = (j = class {
5381
5567
  "insertOrderedList",
5382
5568
  "insertUnorderedList"
5383
5569
  ].forEach((b) => {
5384
- const y = u.querySelector(`[data-id=${b}]`);
5570
+ const y = p.querySelector(`[data-id=${b}]`);
5385
5571
  y && y.classList.toggle("on", e && document.queryCommandState(b));
5386
5572
  }), ["h2", "h3", "blockquote"].forEach((b) => {
5387
- const y = u.querySelector(`[data-id=${b}]`);
5573
+ const y = p.querySelector(`[data-id=${b}]`);
5388
5574
  y && y.classList.toggle("on", e && i === b);
5389
5575
  });
5390
- const m = u.querySelector("[data-id=code]");
5576
+ const m = p.querySelector("[data-id=code]");
5391
5577
  m && m.classList.toggle("on", e && !!this.closestInlineCode());
5392
5578
  });
5393
- 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();
5394
- (c = this.toolbar.querySelector("[data-id=ltr]")) == null || c.classList.toggle("on", e && l === "ltr"), (d = this.toolbar.querySelector("[data-id=rtl]")) == null || d.classList.toggle("on", e && l === "rtl");
5395
- const r = (u, m, b) => {
5396
- const y = this.toolbar.querySelector(`[data-id=${u}] .lbl`);
5579
+ const n = t ? this.closestBlock(t.anchorNode) : null, r = ((o = n == null ? void 0 : n.closest("[dir]")) == null ? void 0 : o.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
5580
+ (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");
5581
+ const l = (p, m, b) => {
5582
+ const y = this.toolbar.querySelector(`[data-id=${p}] .lbl`);
5397
5583
  y && (y.textContent = m || b || "", y.classList.toggle("empty", !m));
5398
5584
  };
5399
- r("fontsel", this.currentFont()), r("sizesel", this.currentSize().replace("px", "")), e && r("blocksel", se.some((u) => u[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
5585
+ l("fontsel", this.currentFont()), l("sizesel", this.currentSize().replace("px", "")), e && l("blocksel", ne.some((p) => p[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
5400
5586
  }
5401
5587
  countWords() {
5402
5588
  const t = (this.ed.textContent || "").trim();
@@ -5411,118 +5597,175 @@ let Hi = (j = class {
5411
5597
  if (s && !i) {
5412
5598
  const n = new FileReader();
5413
5599
  n.onload = () => {
5414
- document.execCommand("insertHTML", !1, `<img src="${n.result}" alt="">`), this.onChange();
5600
+ this.insertImageHTML(n.result), this.onChange();
5415
5601
  }, n.readAsDataURL(s.getAsFile());
5416
5602
  return;
5417
5603
  }
5418
5604
  if (!i) {
5419
- const n = e.getData("text/plain"), l = /^\S+$/.test(n.trim()) ? this.videoEmbedUrl(n.trim()) : null;
5420
- if (l) {
5421
- document.execCommand("insertHTML", !1, this.videoEmbedHTML(l)), this.onChange();
5605
+ const n = e.getData("text/plain"), r = /^\S+$/.test(n.trim()) ? this.videoEmbedUrl(n.trim()) : null;
5606
+ if (r) {
5607
+ document.execCommand("insertHTML", !1, this.videoEmbedHTML(r)), this.onChange();
5422
5608
  return;
5423
5609
  }
5424
5610
  }
5425
- i ? document.execCommand("insertHTML", !1, pi(i, this.dir())) : document.execCommand("insertHTML", !1, mi(e.getData("text/plain"))), this.onChange();
5611
+ i ? this.pasteRichHTML(i, e, s) : (document.execCommand("insertHTML", !1, yi(e.getData("text/plain"))), this.onChange());
5612
+ }
5613
+ /** Rich-HTML paste. Before the (untouched) paste engine runs, pictures Word left
5614
+ * behind as unreadable file:// refs are pulled out of the clipboard's RTF flavor
5615
+ * and inlined — the same pairing TinyMCE PowerPaste does for
5616
+ * powerpaste_allow_local_images. Everything the engine already handled is
5617
+ * unaffected: with no RTF, or no recoverable picture, the HTML reaches it
5618
+ * byte-identical to before. */
5619
+ pasteRichHTML(t, e, i) {
5620
+ let s = [];
5621
+ const n = e.getData("text/rtf");
5622
+ if (n) {
5623
+ const r = Mi(t, n);
5624
+ t = r.html, s = r.injected;
5625
+ }
5626
+ if (i && Li(t) === 1) {
5627
+ const r = i.getAsFile();
5628
+ if (r) {
5629
+ const l = t;
5630
+ this.saveSel();
5631
+ const o = new FileReader();
5632
+ o.onload = () => {
5633
+ const a = fe(l, [o.result]);
5634
+ this.finishRichPaste(a.html, s.concat(a.injected), !0);
5635
+ }, o.onerror = () => this.finishRichPaste(l, s, !0), o.readAsDataURL(r);
5636
+ return;
5637
+ }
5638
+ }
5639
+ this.finishRichPaste(t, s);
5640
+ }
5641
+ /** Hands recovered pictures to the host's imageUploadHandler when one is
5642
+ * configured (PowerPaste's automatic_uploads equivalent), then inserts. Without a
5643
+ * handler they stay inline base64, which is what PowerPaste does by default. */
5644
+ finishRichPaste(t, e, i = !1) {
5645
+ if (!this.imageUploadHandler || !e.length) {
5646
+ this.insertPastedHTML(t, i);
5647
+ return;
5648
+ }
5649
+ const s = this.imageUploadHandler, n = e.filter((r, l) => e.indexOf(r) === l);
5650
+ i || this.saveSel(), Promise.all(
5651
+ n.map((r, l) => {
5652
+ const o = ki(r, "pasted-image-" + (l + 1));
5653
+ return o ? s(o).catch((a) => {
5654
+ var d;
5655
+ return (d = this.onImageUploadError) == null || d.call(this, a, o), r;
5656
+ }) : Promise.resolve(r);
5657
+ })
5658
+ ).then((r) => {
5659
+ let l = t;
5660
+ n.forEach((o, a) => {
5661
+ r[a] !== o && (l = l.split(o).join(r[a]));
5662
+ }), this.insertPastedHTML(l, !0);
5663
+ });
5664
+ }
5665
+ /** `deferred` means the insert is happening after an async hop, so the caret the
5666
+ * paste started from has to be put back first. */
5667
+ insertPastedHTML(t, e = !1) {
5668
+ e && this.restoreSel(), document.execCommand("insertHTML", !1, bi(t, this.dir())), e && this.saveSel(), this.onChange();
5426
5669
  }
5427
5670
  /* ---------------------------------------------------------- init */
5428
5671
  initUI() {
5429
5672
  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();
5430
5673
  }
5431
5674
  }, j.instanceCounter = 0, j.TBR_COLLAPSE_MAX = 992, j);
5432
- const Ai = _e(
5433
- ({ value: p, defaultValue: t, onChange: e, onReady: i, className: s, style: n, ...l }, r) => {
5434
- const o = z(null), c = z(null), d = z(!1), u = z(p ?? t), m = z(null), b = z(e), y = z(i);
5435
- return b.current = e, y.current = i, $e(r, () => ({
5675
+ const Wi = Ve(
5676
+ ({ value: u, defaultValue: t, onChange: e, onReady: i, className: s, style: n, ...r }, l) => {
5677
+ const o = z(null), a = z(null), d = z(!1), p = z(u ?? t), m = z(null), b = z(e), y = z(i);
5678
+ return b.current = e, y.current = i, ze(l, () => ({
5436
5679
  getContent: () => {
5437
5680
  var g;
5438
- return ((g = c.current) == null ? void 0 : g.getContent()) ?? "";
5681
+ return ((g = a.current) == null ? void 0 : g.getContent()) ?? "";
5439
5682
  },
5440
5683
  getContentForEmail: () => {
5441
5684
  var g;
5442
- return ((g = c.current) == null ? void 0 : g.getContentForEmail()) ?? "";
5685
+ return ((g = a.current) == null ? void 0 : g.getContentForEmail()) ?? "";
5443
5686
  },
5444
5687
  setContent: (g) => {
5445
5688
  var x;
5446
- return (x = c.current) == null ? void 0 : x.setContent(g);
5689
+ return (x = a.current) == null ? void 0 : x.setContent(g);
5447
5690
  },
5448
5691
  insertContent: (g) => {
5449
5692
  var x;
5450
- return (x = c.current) == null ? void 0 : x.insertContent(g);
5693
+ return (x = a.current) == null ? void 0 : x.insertContent(g);
5451
5694
  },
5452
5695
  setLanguage: (g) => {
5453
5696
  var x;
5454
- return (x = c.current) == null ? void 0 : x.setLanguage(g);
5697
+ return (x = a.current) == null ? void 0 : x.setLanguage(g);
5455
5698
  },
5456
5699
  focus: () => {
5457
5700
  var g;
5458
- return (g = c.current) == null ? void 0 : g.focus();
5701
+ return (g = a.current) == null ? void 0 : g.focus();
5459
5702
  },
5460
5703
  destroy: () => {
5461
5704
  var g;
5462
- return (g = c.current) == null ? void 0 : g.destroy();
5705
+ return (g = a.current) == null ? void 0 : g.destroy();
5463
5706
  },
5464
5707
  importWordFile: (g) => {
5465
5708
  var x;
5466
- return ((x = c.current) == null ? void 0 : x.importWordFile(g)) ?? Promise.resolve();
5709
+ return ((x = a.current) == null ? void 0 : x.importWordFile(g)) ?? Promise.resolve();
5467
5710
  },
5468
5711
  restoreDraft: () => {
5469
5712
  var g;
5470
- return ((g = c.current) == null ? void 0 : g.restoreDraft()) ?? !1;
5713
+ return ((g = a.current) == null ? void 0 : g.restoreDraft()) ?? !1;
5471
5714
  },
5472
5715
  getRevisions: () => {
5473
5716
  var g;
5474
- return ((g = c.current) == null ? void 0 : g.getRevisions()) ?? [];
5717
+ return ((g = a.current) == null ? void 0 : g.getRevisions()) ?? [];
5475
5718
  }
5476
- })), ot(() => {
5719
+ })), lt(() => {
5477
5720
  if (!o.current) return;
5478
- const g = new Hi({
5721
+ const g = new ji({
5479
5722
  target: o.current,
5480
- initialContent: u.current,
5723
+ initialContent: p.current,
5481
5724
  onChange: (x) => {
5482
5725
  var w;
5483
- d.current = !0, u.current = x, (w = b.current) == null || w.call(b, x);
5726
+ d.current = !0, p.current = x, (w = b.current) == null || w.call(b, x);
5484
5727
  },
5485
5728
  onReady: (x) => {
5486
5729
  var w;
5487
5730
  return (w = y.current) == null ? void 0 : w.call(y, x);
5488
5731
  },
5489
- ...l
5732
+ ...r
5490
5733
  });
5491
- return c.current = g, () => {
5492
- g.destroy(), c.current = null;
5734
+ return a.current = g, () => {
5735
+ g.destroy(), a.current = null;
5493
5736
  };
5494
- }, []), ot(() => {
5737
+ }, []), lt(() => {
5495
5738
  var g, x;
5496
- if (p !== void 0 && p !== u.current) {
5739
+ if (u !== void 0 && u !== p.current) {
5497
5740
  if (d.current) {
5498
5741
  d.current = !1;
5499
5742
  return;
5500
5743
  }
5501
5744
  if ((g = o.current) != null && g.contains(document.activeElement)) {
5502
- m.current = p;
5745
+ m.current = u;
5503
5746
  return;
5504
5747
  }
5505
- u.current = p, (x = c.current) == null || x.setContent(p);
5748
+ p.current = u, (x = a.current) == null || x.setContent(u);
5506
5749
  }
5507
- }, [p]), ot(() => {
5750
+ }, [u]), lt(() => {
5508
5751
  const g = o.current;
5509
5752
  if (!g) return;
5510
5753
  const x = (w) => {
5511
- var H;
5754
+ var A;
5512
5755
  if (m.current === null) return;
5513
5756
  const E = w.relatedTarget;
5514
5757
  if (E && g.contains(E)) return;
5515
5758
  const I = m.current;
5516
- m.current = null, u.current = I, (H = c.current) == null || H.setContent(I);
5759
+ m.current = null, p.current = I, (A = a.current) == null || A.setContent(I);
5517
5760
  };
5518
5761
  return g.addEventListener("focusout", x), () => g.removeEventListener("focusout", x);
5519
- }, []), ot(() => {
5762
+ }, []), lt(() => {
5520
5763
  var g;
5521
- l.language && ((g = c.current) == null || g.setLanguage(l.language));
5522
- }, [l.language]), /* @__PURE__ */ Ve.jsx("div", { ref: o, className: s, style: n });
5764
+ r.language && ((g = a.current) == null || g.setLanguage(r.language));
5765
+ }, [r.language]), /* @__PURE__ */ Ge.jsx("div", { ref: o, className: s, style: n });
5523
5766
  }
5524
5767
  );
5525
- Ai.displayName = "FableEditor";
5768
+ Wi.displayName = "FableEditor";
5526
5769
  export {
5527
- Ai as FableEditor
5770
+ Wi as FableEditor
5528
5771
  };