fable-editor 1.0.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.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +175 -0
  3. package/dist/angular/LICENSE +21 -0
  4. package/dist/angular/README.md +175 -0
  5. package/dist/angular/angular/fable-editor.component.d.ts +29 -0
  6. package/dist/angular/angular/fable-editor.module.d.ts +7 -0
  7. package/dist/angular/angular/index.d.ts +2 -0
  8. package/dist/angular/core/config.d.ts +17 -0
  9. package/dist/angular/core/docx-import.d.ts +1 -0
  10. package/dist/angular/core/editor.d.ts +219 -0
  11. package/dist/angular/core/i18n.d.ts +139 -0
  12. package/dist/angular/core/icons.d.ts +2 -0
  13. package/dist/angular/core/index.d.ts +7 -0
  14. package/dist/angular/core/paste-engine.d.ts +6 -0
  15. package/dist/angular/core/types.d.ts +87 -0
  16. package/dist/angular/esm2022/angular/fable-editor.component.mjs +101 -0
  17. package/dist/angular/esm2022/angular/fable-editor.module.mjs +16 -0
  18. package/dist/angular/esm2022/angular/index.mjs +3 -0
  19. package/dist/angular/esm2022/core/config.mjs +122 -0
  20. package/dist/angular/esm2022/core/docx-import.mjs +391 -0
  21. package/dist/angular/esm2022/core/editor.mjs +2700 -0
  22. package/dist/angular/esm2022/core/i18n.mjs +278 -0
  23. package/dist/angular/esm2022/core/icons.mjs +89 -0
  24. package/dist/angular/esm2022/core/index.mjs +6 -0
  25. package/dist/angular/esm2022/core/paste-engine.mjs +482 -0
  26. package/dist/angular/esm2022/core/types.mjs +2 -0
  27. package/dist/angular/esm2022/fable-editor.mjs +5 -0
  28. package/dist/angular/esm2022/index.mjs +2 -0
  29. package/dist/angular/fesm2022/fable-editor.mjs +4176 -0
  30. package/dist/angular/fesm2022/fable-editor.mjs.map +1 -0
  31. package/dist/angular/index.d.ts +1 -0
  32. package/dist/core/config.d.ts +18 -0
  33. package/dist/core/config.d.ts.map +1 -0
  34. package/dist/core/docx-import.d.ts +2 -0
  35. package/dist/core/docx-import.d.ts.map +1 -0
  36. package/dist/core/editor.css +1175 -0
  37. package/dist/core/editor.d.ts +221 -0
  38. package/dist/core/editor.d.ts.map +1 -0
  39. package/dist/core/i18n.d.ts +141 -0
  40. package/dist/core/i18n.d.ts.map +1 -0
  41. package/dist/core/icons.d.ts +3 -0
  42. package/dist/core/icons.d.ts.map +1 -0
  43. package/dist/core/index.cjs +12 -0
  44. package/dist/core/index.d.ts +8 -0
  45. package/dist/core/index.d.ts.map +1 -0
  46. package/dist/core/index.mjs +2789 -0
  47. package/dist/core/paste-engine.d.ts +7 -0
  48. package/dist/core/paste-engine.d.ts.map +1 -0
  49. package/dist/core/types.d.ts +88 -0
  50. package/dist/core/types.d.ts.map +1 -0
  51. package/dist/react/FableEditor.d.ts +13 -0
  52. package/dist/react/FableEditor.d.ts.map +1 -0
  53. package/dist/react/index.cjs +41 -0
  54. package/dist/react/index.d.ts +3 -0
  55. package/dist/react/index.d.ts.map +1 -0
  56. package/dist/react/index.mjs +3471 -0
  57. package/package.json +105 -0
  58. package/style.css +1175 -0
@@ -0,0 +1,3471 @@
1
+ import Gt, { forwardRef as qe, useRef as X, useImperativeHandle as Le, useEffect as gt } from "react";
2
+ var bt = { exports: {} }, G = {};
3
+ /**
4
+ * @license React
5
+ * react-jsx-runtime.production.min.js
6
+ *
7
+ * Copyright (c) Facebook, Inc. and its affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ var zt;
13
+ function Ie() {
14
+ if (zt) return G;
15
+ zt = 1;
16
+ var m = Gt, t = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, s = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, r = { key: !0, ref: !0, __self: !0, __source: !0 };
17
+ function l(o, a, c) {
18
+ var d, u = {}, v = null, b = null;
19
+ c !== void 0 && (v = "" + c), a.key !== void 0 && (v = "" + a.key), a.ref !== void 0 && (b = a.ref);
20
+ for (d in a) i.call(a, d) && !r.hasOwnProperty(d) && (u[d] = a[d]);
21
+ if (o && o.defaultProps) for (d in a = o.defaultProps, a) u[d] === void 0 && (u[d] = a[d]);
22
+ return { $$typeof: t, type: o, key: v, ref: b, props: u, _owner: s.current };
23
+ }
24
+ return G.Fragment = e, G.jsx = l, G.jsxs = l, G;
25
+ }
26
+ var K = {};
27
+ /**
28
+ * @license React
29
+ * react-jsx-runtime.development.js
30
+ *
31
+ * Copyright (c) Facebook, Inc. and its affiliates.
32
+ *
33
+ * This source code is licensed under the MIT license found in the
34
+ * LICENSE file in the root directory of this source tree.
35
+ */
36
+ var Wt;
37
+ function Ae() {
38
+ return Wt || (Wt = 1, process.env.NODE_ENV !== "production" && function() {
39
+ var m = Gt, t = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), r = Symbol.for("react.profiler"), l = Symbol.for("react.provider"), o = Symbol.for("react.context"), a = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), u = Symbol.for("react.memo"), v = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), f = Symbol.iterator, w = "@@iterator";
40
+ function E(n) {
41
+ if (n === null || typeof n != "object")
42
+ return null;
43
+ var p = f && n[f] || n[w];
44
+ return typeof p == "function" ? p : null;
45
+ }
46
+ var q = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
47
+ function M(n) {
48
+ {
49
+ for (var p = arguments.length, g = new Array(p > 1 ? p - 1 : 0), C = 1; C < p; C++)
50
+ g[C - 1] = arguments[C];
51
+ D("error", n, g);
52
+ }
53
+ }
54
+ function D(n, p, g) {
55
+ {
56
+ var C = q.ReactDebugCurrentFrame, S = C.getStackAddendum();
57
+ S !== "" && (p += "%s", g = g.concat([S]));
58
+ var k = g.map(function(T) {
59
+ return String(T);
60
+ });
61
+ k.unshift("Warning: " + p), Function.prototype.apply.call(console[n], console, k);
62
+ }
63
+ }
64
+ var I = !1, F = !1, B = !1, Y = !1, Jt = !1, yt;
65
+ yt = Symbol.for("react.module.reference");
66
+ function te(n) {
67
+ return !!(typeof n == "string" || typeof n == "function" || n === i || n === r || Jt || n === s || n === c || n === d || Y || n === b || I || F || B || typeof n == "object" && n !== null && (n.$$typeof === v || n.$$typeof === u || n.$$typeof === l || n.$$typeof === o || n.$$typeof === a || // This needs to include all possible module reference object
68
+ // types supported by any Flight configuration anywhere since
69
+ // we don't know which Flight build this will end up being used
70
+ // with.
71
+ n.$$typeof === yt || n.getModuleId !== void 0));
72
+ }
73
+ function ee(n, p, g) {
74
+ var C = n.displayName;
75
+ if (C)
76
+ return C;
77
+ var S = p.displayName || p.name || "";
78
+ return S !== "" ? g + "(" + S + ")" : g;
79
+ }
80
+ function wt(n) {
81
+ return n.displayName || "Context";
82
+ }
83
+ function _(n) {
84
+ if (n == null)
85
+ return null;
86
+ if (typeof n.tag == "number" && M("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof n == "function")
87
+ return n.displayName || n.name || null;
88
+ if (typeof n == "string")
89
+ return n;
90
+ switch (n) {
91
+ case i:
92
+ return "Fragment";
93
+ case e:
94
+ return "Portal";
95
+ case r:
96
+ return "Profiler";
97
+ case s:
98
+ return "StrictMode";
99
+ case c:
100
+ return "Suspense";
101
+ case d:
102
+ return "SuspenseList";
103
+ }
104
+ if (typeof n == "object")
105
+ switch (n.$$typeof) {
106
+ case o:
107
+ var p = n;
108
+ return wt(p) + ".Consumer";
109
+ case l:
110
+ var g = n;
111
+ return wt(g._context) + ".Provider";
112
+ case a:
113
+ return ee(n, n.render, "ForwardRef");
114
+ case u:
115
+ var C = n.displayName || null;
116
+ return C !== null ? C : _(n.type) || "Memo";
117
+ case v: {
118
+ var S = n, k = S._payload, T = S._init;
119
+ try {
120
+ return _(T(k));
121
+ } catch {
122
+ return null;
123
+ }
124
+ }
125
+ }
126
+ return null;
127
+ }
128
+ var $ = Object.assign, Q = 0, Ct, xt, Tt, Et, St, Mt, kt;
129
+ function Ht() {
130
+ }
131
+ Ht.__reactDisabledLog = !0;
132
+ function ie() {
133
+ {
134
+ if (Q === 0) {
135
+ Ct = console.log, xt = console.info, Tt = console.warn, Et = console.error, St = console.group, Mt = console.groupCollapsed, kt = console.groupEnd;
136
+ var n = {
137
+ configurable: !0,
138
+ enumerable: !0,
139
+ value: Ht,
140
+ writable: !0
141
+ };
142
+ Object.defineProperties(console, {
143
+ info: n,
144
+ log: n,
145
+ warn: n,
146
+ error: n,
147
+ group: n,
148
+ groupCollapsed: n,
149
+ groupEnd: n
150
+ });
151
+ }
152
+ Q++;
153
+ }
154
+ }
155
+ function se() {
156
+ {
157
+ if (Q--, Q === 0) {
158
+ var n = {
159
+ configurable: !0,
160
+ enumerable: !0,
161
+ writable: !0
162
+ };
163
+ Object.defineProperties(console, {
164
+ log: $({}, n, {
165
+ value: Ct
166
+ }),
167
+ info: $({}, n, {
168
+ value: xt
169
+ }),
170
+ warn: $({}, n, {
171
+ value: Tt
172
+ }),
173
+ error: $({}, n, {
174
+ value: Et
175
+ }),
176
+ group: $({}, n, {
177
+ value: St
178
+ }),
179
+ groupCollapsed: $({}, n, {
180
+ value: Mt
181
+ }),
182
+ groupEnd: $({}, n, {
183
+ value: kt
184
+ })
185
+ });
186
+ }
187
+ Q < 0 && M("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
188
+ }
189
+ }
190
+ var at = q.ReactCurrentDispatcher, ct;
191
+ function J(n, p, g) {
192
+ {
193
+ if (ct === void 0)
194
+ try {
195
+ throw Error();
196
+ } catch (S) {
197
+ var C = S.stack.trim().match(/\n( *(at )?)/);
198
+ ct = C && C[1] || "";
199
+ }
200
+ return `
201
+ ` + ct + n;
202
+ }
203
+ }
204
+ var ht = !1, tt;
205
+ {
206
+ var re = typeof WeakMap == "function" ? WeakMap : Map;
207
+ tt = new re();
208
+ }
209
+ function qt(n, p) {
210
+ if (!n || ht)
211
+ return "";
212
+ {
213
+ var g = tt.get(n);
214
+ if (g !== void 0)
215
+ return g;
216
+ }
217
+ var C;
218
+ ht = !0;
219
+ var S = Error.prepareStackTrace;
220
+ Error.prepareStackTrace = void 0;
221
+ var k;
222
+ k = at.current, at.current = null, ie();
223
+ try {
224
+ if (p) {
225
+ var T = function() {
226
+ throw Error();
227
+ };
228
+ if (Object.defineProperty(T.prototype, "props", {
229
+ set: function() {
230
+ throw Error();
231
+ }
232
+ }), typeof Reflect == "object" && Reflect.construct) {
233
+ try {
234
+ Reflect.construct(T, []);
235
+ } catch (N) {
236
+ C = N;
237
+ }
238
+ Reflect.construct(n, [], T);
239
+ } else {
240
+ try {
241
+ T.call();
242
+ } catch (N) {
243
+ C = N;
244
+ }
245
+ n.call(T.prototype);
246
+ }
247
+ } else {
248
+ try {
249
+ throw Error();
250
+ } catch (N) {
251
+ C = N;
252
+ }
253
+ n();
254
+ }
255
+ } catch (N) {
256
+ if (N && C && typeof N.stack == "string") {
257
+ for (var x = N.stack.split(`
258
+ `), P = C.stack.split(`
259
+ `), L = x.length - 1, A = P.length - 1; L >= 1 && A >= 0 && x[L] !== P[A]; )
260
+ A--;
261
+ for (; L >= 1 && A >= 0; L--, A--)
262
+ if (x[L] !== P[A]) {
263
+ if (L !== 1 || A !== 1)
264
+ do
265
+ if (L--, A--, A < 0 || x[L] !== P[A]) {
266
+ var O = `
267
+ ` + x[L].replace(" at new ", " at ");
268
+ return n.displayName && O.includes("<anonymous>") && (O = O.replace("<anonymous>", n.displayName)), typeof n == "function" && tt.set(n, O), O;
269
+ }
270
+ while (L >= 1 && A >= 0);
271
+ break;
272
+ }
273
+ }
274
+ } finally {
275
+ ht = !1, at.current = k, se(), Error.prepareStackTrace = S;
276
+ }
277
+ var U = n ? n.displayName || n.name : "", j = U ? J(U) : "";
278
+ return typeof n == "function" && tt.set(n, j), j;
279
+ }
280
+ function ne(n, p, g) {
281
+ return qt(n, !1);
282
+ }
283
+ function le(n) {
284
+ var p = n.prototype;
285
+ return !!(p && p.isReactComponent);
286
+ }
287
+ function et(n, p, g) {
288
+ if (n == null)
289
+ return "";
290
+ if (typeof n == "function")
291
+ return qt(n, le(n));
292
+ if (typeof n == "string")
293
+ return J(n);
294
+ switch (n) {
295
+ case c:
296
+ return J("Suspense");
297
+ case d:
298
+ return J("SuspenseList");
299
+ }
300
+ if (typeof n == "object")
301
+ switch (n.$$typeof) {
302
+ case a:
303
+ return ne(n.render);
304
+ case u:
305
+ return et(n.type, p, g);
306
+ case v: {
307
+ var C = n, S = C._payload, k = C._init;
308
+ try {
309
+ return et(k(S), p, g);
310
+ } catch {
311
+ }
312
+ }
313
+ }
314
+ return "";
315
+ }
316
+ var V = Object.prototype.hasOwnProperty, Lt = {}, It = q.ReactDebugCurrentFrame;
317
+ function it(n) {
318
+ if (n) {
319
+ var p = n._owner, g = et(n.type, n._source, p ? p.type : null);
320
+ It.setExtraStackFrame(g);
321
+ } else
322
+ It.setExtraStackFrame(null);
323
+ }
324
+ function oe(n, p, g, C, S) {
325
+ {
326
+ var k = Function.call.bind(V);
327
+ for (var T in n)
328
+ if (k(n, T)) {
329
+ var x = void 0;
330
+ try {
331
+ if (typeof n[T] != "function") {
332
+ var P = Error((C || "React class") + ": " + g + " type `" + T + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof n[T] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
333
+ throw P.name = "Invariant Violation", P;
334
+ }
335
+ x = n[T](p, T, C, g, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
336
+ } catch (L) {
337
+ x = L;
338
+ }
339
+ x && !(x instanceof Error) && (it(S), M("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", C || "React class", g, T, typeof x), it(null)), x instanceof Error && !(x.message in Lt) && (Lt[x.message] = !0, it(S), M("Failed %s type: %s", g, x.message), it(null));
340
+ }
341
+ }
342
+ }
343
+ var ae = Array.isArray;
344
+ function dt(n) {
345
+ return ae(n);
346
+ }
347
+ function ce(n) {
348
+ {
349
+ var p = typeof Symbol == "function" && Symbol.toStringTag, g = p && n[Symbol.toStringTag] || n.constructor.name || "Object";
350
+ return g;
351
+ }
352
+ }
353
+ function he(n) {
354
+ try {
355
+ return At(n), !1;
356
+ } catch {
357
+ return !0;
358
+ }
359
+ }
360
+ function At(n) {
361
+ return "" + n;
362
+ }
363
+ function Rt(n) {
364
+ if (he(n))
365
+ return M("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ce(n)), At(n);
366
+ }
367
+ var Zt = q.ReactCurrentOwner, de = {
368
+ key: !0,
369
+ ref: !0,
370
+ __self: !0,
371
+ __source: !0
372
+ }, Dt, Pt;
373
+ function ue(n) {
374
+ if (V.call(n, "ref")) {
375
+ var p = Object.getOwnPropertyDescriptor(n, "ref").get;
376
+ if (p && p.isReactWarning)
377
+ return !1;
378
+ }
379
+ return n.ref !== void 0;
380
+ }
381
+ function pe(n) {
382
+ if (V.call(n, "key")) {
383
+ var p = Object.getOwnPropertyDescriptor(n, "key").get;
384
+ if (p && p.isReactWarning)
385
+ return !1;
386
+ }
387
+ return n.key !== void 0;
388
+ }
389
+ function me(n, p) {
390
+ typeof n.ref == "string" && Zt.current;
391
+ }
392
+ function fe(n, p) {
393
+ {
394
+ var g = function() {
395
+ Dt || (Dt = !0, M("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", p));
396
+ };
397
+ g.isReactWarning = !0, Object.defineProperty(n, "key", {
398
+ get: g,
399
+ configurable: !0
400
+ });
401
+ }
402
+ }
403
+ function ge(n, p) {
404
+ {
405
+ var g = function() {
406
+ Pt || (Pt = !0, M("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", p));
407
+ };
408
+ g.isReactWarning = !0, Object.defineProperty(n, "ref", {
409
+ get: g,
410
+ configurable: !0
411
+ });
412
+ }
413
+ }
414
+ var ve = function(n, p, g, C, S, k, T) {
415
+ var x = {
416
+ // This tag allows us to uniquely identify this as a React Element
417
+ $$typeof: t,
418
+ // Built-in properties that belong on the element
419
+ type: n,
420
+ key: p,
421
+ ref: g,
422
+ props: T,
423
+ // Record the component responsible for creating this element.
424
+ _owner: k
425
+ };
426
+ return x._store = {}, Object.defineProperty(x._store, "validated", {
427
+ configurable: !1,
428
+ enumerable: !1,
429
+ writable: !0,
430
+ value: !1
431
+ }), Object.defineProperty(x, "_self", {
432
+ configurable: !1,
433
+ enumerable: !1,
434
+ writable: !1,
435
+ value: C
436
+ }), Object.defineProperty(x, "_source", {
437
+ configurable: !1,
438
+ enumerable: !1,
439
+ writable: !1,
440
+ value: S
441
+ }), Object.freeze && (Object.freeze(x.props), Object.freeze(x)), x;
442
+ };
443
+ function be(n, p, g, C, S) {
444
+ {
445
+ var k, T = {}, x = null, P = null;
446
+ g !== void 0 && (Rt(g), x = "" + g), pe(p) && (Rt(p.key), x = "" + p.key), ue(p) && (P = p.ref, me(p, S));
447
+ for (k in p)
448
+ V.call(p, k) && !de.hasOwnProperty(k) && (T[k] = p[k]);
449
+ if (n && n.defaultProps) {
450
+ var L = n.defaultProps;
451
+ for (k in L)
452
+ T[k] === void 0 && (T[k] = L[k]);
453
+ }
454
+ if (x || P) {
455
+ var A = typeof n == "function" ? n.displayName || n.name || "Unknown" : n;
456
+ x && fe(T, A), P && ge(T, A);
457
+ }
458
+ return ve(n, x, P, S, C, Zt.current, T);
459
+ }
460
+ }
461
+ var ut = q.ReactCurrentOwner, Nt = q.ReactDebugCurrentFrame;
462
+ function W(n) {
463
+ if (n) {
464
+ var p = n._owner, g = et(n.type, n._source, p ? p.type : null);
465
+ Nt.setExtraStackFrame(g);
466
+ } else
467
+ Nt.setExtraStackFrame(null);
468
+ }
469
+ var pt;
470
+ pt = !1;
471
+ function mt(n) {
472
+ return typeof n == "object" && n !== null && n.$$typeof === t;
473
+ }
474
+ function Ot() {
475
+ {
476
+ if (ut.current) {
477
+ var n = _(ut.current.type);
478
+ if (n)
479
+ return `
480
+
481
+ Check the render method of \`` + n + "`.";
482
+ }
483
+ return "";
484
+ }
485
+ }
486
+ function ye(n) {
487
+ return "";
488
+ }
489
+ var Bt = {};
490
+ function we(n) {
491
+ {
492
+ var p = Ot();
493
+ if (!p) {
494
+ var g = typeof n == "string" ? n : n.displayName || n.name;
495
+ g && (p = `
496
+
497
+ Check the top-level render call using <` + g + ">.");
498
+ }
499
+ return p;
500
+ }
501
+ }
502
+ function Ft(n, p) {
503
+ {
504
+ if (!n._store || n._store.validated || n.key != null)
505
+ return;
506
+ n._store.validated = !0;
507
+ var g = we(p);
508
+ if (Bt[g])
509
+ return;
510
+ Bt[g] = !0;
511
+ var C = "";
512
+ n && n._owner && n._owner !== ut.current && (C = " It was passed a child from " + _(n._owner.type) + "."), W(n), M('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', g, C), W(null);
513
+ }
514
+ }
515
+ function _t(n, p) {
516
+ {
517
+ if (typeof n != "object")
518
+ return;
519
+ if (dt(n))
520
+ for (var g = 0; g < n.length; g++) {
521
+ var C = n[g];
522
+ mt(C) && Ft(C, p);
523
+ }
524
+ else if (mt(n))
525
+ n._store && (n._store.validated = !0);
526
+ else if (n) {
527
+ var S = E(n);
528
+ if (typeof S == "function" && S !== n.entries)
529
+ for (var k = S.call(n), T; !(T = k.next()).done; )
530
+ mt(T.value) && Ft(T.value, p);
531
+ }
532
+ }
533
+ }
534
+ function Ce(n) {
535
+ {
536
+ var p = n.type;
537
+ if (p == null || typeof p == "string")
538
+ return;
539
+ var g;
540
+ if (typeof p == "function")
541
+ g = p.propTypes;
542
+ else if (typeof p == "object" && (p.$$typeof === a || // Note: Memo only checks outer props here.
543
+ // Inner props are checked in the reconciler.
544
+ p.$$typeof === u))
545
+ g = p.propTypes;
546
+ else
547
+ return;
548
+ if (g) {
549
+ var C = _(p);
550
+ oe(g, n.props, "prop", C, n);
551
+ } else if (p.PropTypes !== void 0 && !pt) {
552
+ pt = !0;
553
+ var S = _(p);
554
+ M("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", S || "Unknown");
555
+ }
556
+ typeof p.getDefaultProps == "function" && !p.getDefaultProps.isReactClassApproved && M("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
557
+ }
558
+ }
559
+ function xe(n) {
560
+ {
561
+ for (var p = Object.keys(n.props), g = 0; g < p.length; g++) {
562
+ var C = p[g];
563
+ if (C !== "children" && C !== "key") {
564
+ W(n), M("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", C), W(null);
565
+ break;
566
+ }
567
+ }
568
+ n.ref !== null && (W(n), M("Invalid attribute `ref` supplied to `React.Fragment`."), W(null));
569
+ }
570
+ }
571
+ var $t = {};
572
+ function jt(n, p, g, C, S, k) {
573
+ {
574
+ var T = te(n);
575
+ if (!T) {
576
+ var x = "";
577
+ (n === void 0 || typeof n == "object" && n !== null && Object.keys(n).length === 0) && (x += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
578
+ var P = ye();
579
+ P ? x += P : x += Ot();
580
+ var L;
581
+ n === null ? L = "null" : dt(n) ? L = "array" : n !== void 0 && n.$$typeof === t ? (L = "<" + (_(n.type) || "Unknown") + " />", x = " Did you accidentally export a JSX literal instead of a component?") : L = typeof n, M("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", L, x);
582
+ }
583
+ var A = be(n, p, g, S, k);
584
+ if (A == null)
585
+ return A;
586
+ if (T) {
587
+ var O = p.children;
588
+ if (O !== void 0)
589
+ if (C)
590
+ if (dt(O)) {
591
+ for (var U = 0; U < O.length; U++)
592
+ _t(O[U], n);
593
+ Object.freeze && Object.freeze(O);
594
+ } else
595
+ M("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
596
+ else
597
+ _t(O, n);
598
+ }
599
+ if (V.call(p, "key")) {
600
+ var j = _(n), N = Object.keys(p).filter(function(He) {
601
+ return He !== "key";
602
+ }), ft = N.length > 0 ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}";
603
+ if (!$t[j + ft]) {
604
+ var ke = N.length > 0 ? "{" + N.join(": ..., ") + ": ...}" : "{}";
605
+ M(`A props object containing a "key" prop is being spread into JSX:
606
+ let props = %s;
607
+ <%s {...props} />
608
+ React keys must be passed directly to JSX without using spread:
609
+ let props = %s;
610
+ <%s key={someKey} {...props} />`, ft, j, ke, j), $t[j + ft] = !0;
611
+ }
612
+ }
613
+ return n === i ? xe(A) : Ce(A), A;
614
+ }
615
+ }
616
+ function Te(n, p, g) {
617
+ return jt(n, p, g, !0);
618
+ }
619
+ function Ee(n, p, g) {
620
+ return jt(n, p, g, !1);
621
+ }
622
+ var Se = Ee, Me = Te;
623
+ K.Fragment = i, K.jsx = Se, K.jsxs = Me;
624
+ }()), K;
625
+ }
626
+ process.env.NODE_ENV === "production" ? bt.exports = Ie() : bt.exports = Ae();
627
+ var Re = bt.exports;
628
+ const Ze = {
629
+ en: {
630
+ dir: "ltr",
631
+ file: "File",
632
+ edit: "Edit",
633
+ view: "View",
634
+ insert: "Insert",
635
+ format: "Format",
636
+ tools: "Tools",
637
+ table: "Table",
638
+ help: "Help",
639
+ newdoc: "New document",
640
+ preview: "Preview",
641
+ print: "Print…",
642
+ undo: "Undo",
643
+ redo: "Redo",
644
+ cut: "Cut",
645
+ copy: "Copy",
646
+ paste: "Paste",
647
+ selectall: "Select all",
648
+ fullscreen: "Fullscreen",
649
+ sourcecode: "Source code",
650
+ wordcount: "Word count",
651
+ image: "Image…",
652
+ inserttable: "Table",
653
+ hr: "Horizontal line",
654
+ charmap: "Special character…",
655
+ datetime: "Date/time",
656
+ pagebreak: "Page break",
657
+ nbsp: "Nonbreaking space",
658
+ bold: "Bold",
659
+ italic: "Italic",
660
+ underline: "Underline",
661
+ strikethrough: "Strikethrough",
662
+ superscript: "Superscript",
663
+ subscript: "Subscript",
664
+ clearformat: "Clear formatting",
665
+ rowabove: "Insert row before",
666
+ rowbelow: "Insert row after",
667
+ delrow: "Delete row",
668
+ colbefore: "Insert column before",
669
+ colafter: "Insert column after",
670
+ delcol: "Delete column",
671
+ deltable: "Delete table",
672
+ ltr: "Left to right",
673
+ rtl: "Right to left",
674
+ alignleft: "Align left",
675
+ aligncenter: "Align center",
676
+ alignright: "Align right",
677
+ alignjustify: "Justify",
678
+ numlist: "Numbered list",
679
+ bullist: "Bullet list",
680
+ forecolor: "Text color",
681
+ backcolor: "Background color",
682
+ removeformat: "Clear formatting",
683
+ outdent: "Decrease indent",
684
+ indent: "Increase indent",
685
+ fontfamily: "Font family",
686
+ fontsize: "Font size",
687
+ blocks: "Blocks",
688
+ quickimage: "Insert image",
689
+ quicktable: "Insert table",
690
+ more: "More…",
691
+ para: "Paragraph",
692
+ heading: "Heading",
693
+ pre: "Preformatted",
694
+ removecolor: "Remove color",
695
+ currentcolor: "Current color",
696
+ statushelp: "Press Alt+0 for help",
697
+ words: "words",
698
+ helpttl: "Help",
699
+ shortcuts: "Handy shortcuts",
700
+ close: "Close",
701
+ save: "Save",
702
+ cancel: "Cancel",
703
+ srcttl: "Source code",
704
+ wcttl: "Word count",
705
+ wcwords: "Words",
706
+ wcchars: "Characters",
707
+ pastehint: "Use Ctrl+V / ⌘V to paste",
708
+ liststyles_ol: ["Default", "Lower alpha", "Lower roman", "Upper alpha", "Upper roman"],
709
+ liststyles_ul: ["Default", "Circle", "Square"],
710
+ previewttl: "Preview",
711
+ tablepropsttl: "Table properties",
712
+ tblwidth: "Width",
713
+ tblcellspacing: "Cell spacing",
714
+ tblcellpadding: "Cell padding",
715
+ tblborder: "Border width",
716
+ tblalign: "Alignment",
717
+ alignnone: "None",
718
+ quote: "Blockquote",
719
+ link: "Link…",
720
+ linkttl: "Insert/edit link",
721
+ linkurl: "URL",
722
+ unlink: "Remove link",
723
+ lineheight: "Line height",
724
+ wordspacing: "Word spacing",
725
+ changecase: "Change case",
726
+ lowercase: "Lowercase",
727
+ uppercase: "Uppercase",
728
+ capitalize: "Capitalize Each Word",
729
+ customcolor: "Custom color…",
730
+ normal: "Normal",
731
+ revhistory: "Revision history",
732
+ revempty: "No revisions yet",
733
+ restore: "Restore",
734
+ currentver: "Current version",
735
+ importword: "Import from Word…",
736
+ importfail: "Could not import this file. Please choose a valid .docx document.",
737
+ restoredraft: "Restore last draft",
738
+ draftempty: "No saved draft found",
739
+ deleteimg: "Delete image",
740
+ rotateleft: "Rotate left",
741
+ rotateright: "Rotate right",
742
+ fliphorizontal: "Flip horizontal",
743
+ flipvertical: "Flip vertical",
744
+ cell: "Cell",
745
+ row: "Row",
746
+ column: "Column",
747
+ cellprops: "Cell properties…",
748
+ rowprops: "Row properties…",
749
+ colprops: "Column properties…",
750
+ tblheight: "Height",
751
+ valign: "Vertical align",
752
+ valigntop: "Top",
753
+ valignmiddle: "Middle",
754
+ valignbottom: "Bottom",
755
+ fill: "Fill",
756
+ nocell: "Click inside a table cell first",
757
+ uploadimg: "Upload from computer",
758
+ imagelink: "Insert from URL",
759
+ imageurlph: "Paste image URL…",
760
+ insertimg: "Insert",
761
+ dropimage: "Drop image here",
762
+ uploading: "Uploading…",
763
+ uploadfailed: "Upload failed — click to retry"
764
+ },
765
+ ar: {
766
+ dir: "rtl",
767
+ file: "ملف",
768
+ edit: "تحرير",
769
+ view: "عرض",
770
+ insert: "إدراج",
771
+ format: "التنسيق",
772
+ tools: "الأدوات",
773
+ table: "جدول",
774
+ help: "تعليمات",
775
+ newdoc: "مستند جديد",
776
+ preview: "معاينة",
777
+ print: "طباعة…",
778
+ undo: "تراجع",
779
+ redo: "إعادة",
780
+ cut: "قص",
781
+ copy: "نسخ",
782
+ paste: "لصق",
783
+ selectall: "تحديد الكل",
784
+ fullscreen: "ملء الشاشة",
785
+ sourcecode: "الكود المصدري",
786
+ wordcount: "عدد الكلمات",
787
+ image: "صورة…",
788
+ inserttable: "جدول",
789
+ hr: "خط أفقي",
790
+ charmap: "رمز خاص…",
791
+ datetime: "التاريخ/الوقت",
792
+ pagebreak: "فاصل الصفحة",
793
+ nbsp: "مسافة غير فاصلة",
794
+ bold: "غامق",
795
+ italic: "مائل",
796
+ underline: "تسطير",
797
+ strikethrough: "يتوسطه خط",
798
+ superscript: "نص مرتفع",
799
+ subscript: "نص منخفض",
800
+ clearformat: "مسح التنسيق",
801
+ rowabove: "إدراج صف قبل",
802
+ rowbelow: "إدراج صف بعد",
803
+ delrow: "حذف الصف",
804
+ colbefore: "إدراج عمود قبل",
805
+ colafter: "إدراج عمود بعد",
806
+ delcol: "حذف العمود",
807
+ deltable: "حذف الجدول",
808
+ ltr: "من اليسار إلى اليمين",
809
+ rtl: "من اليمين إلى اليسار",
810
+ alignleft: "محاذاة لليسار",
811
+ aligncenter: "توسيط",
812
+ alignright: "محاذاة لليمين",
813
+ alignjustify: "ضبط",
814
+ numlist: "قائمة رقمية",
815
+ bullist: "قائمة نقطية",
816
+ forecolor: "لون النص",
817
+ backcolor: "لون الخلفية",
818
+ removeformat: "مسح التنسيق",
819
+ outdent: "إنقاص المسافة البادئة",
820
+ indent: "زيادة المسافة البادئة",
821
+ fontfamily: "عائلة الخط",
822
+ fontsize: "حجم الخط",
823
+ blocks: "الفقرات",
824
+ quickimage: "إدراج صورة",
825
+ quicktable: "إدراج جدول",
826
+ more: "المزيد…",
827
+ para: "الفقرة",
828
+ heading: "العنوان",
829
+ pre: "منسق مسبقاً",
830
+ removecolor: "إزالة اللون",
831
+ currentcolor: "اللون الحالي",
832
+ statushelp: "اضغط على Alt+0 للحصول على مساعدة",
833
+ words: "الكلمات",
834
+ helpttl: "تعليمات",
835
+ shortcuts: "اختصارات مفيدة",
836
+ close: "إغلاق",
837
+ save: "حفظ",
838
+ cancel: "إلغاء",
839
+ srcttl: "الكود المصدري",
840
+ wcttl: "عدد الكلمات",
841
+ wcwords: "الكلمات",
842
+ wcchars: "الأحرف",
843
+ pastehint: "استخدم Ctrl+V / ⌘V للصق",
844
+ liststyles_ol: ["افتراضي", "أبجدي صغير", "روماني صغير", "أبجدي كبير", "روماني كبير"],
845
+ liststyles_ul: ["افتراضي", "دائرة", "مربع"],
846
+ previewttl: "معاينة",
847
+ tablepropsttl: "خصائص الجدول",
848
+ tblwidth: "العرض",
849
+ tblcellspacing: "تباعد الخلايا",
850
+ tblcellpadding: "حشو الخلايا",
851
+ tblborder: "عرض الحدود",
852
+ tblalign: "المحاذاة",
853
+ alignnone: "بدون",
854
+ quote: "اقتباس",
855
+ link: "رابط…",
856
+ linkttl: "إدراج/تعديل رابط",
857
+ linkurl: "الرابط",
858
+ unlink: "إزالة الرابط",
859
+ lineheight: "تباعد الأسطر",
860
+ wordspacing: "تباعد الكلمات",
861
+ changecase: "تغيير حالة الأحرف",
862
+ lowercase: "أحرف صغيرة",
863
+ uppercase: "أحرف كبيرة",
864
+ capitalize: "تكبير أول حرف",
865
+ customcolor: "لون مخصص…",
866
+ normal: "عادي",
867
+ revhistory: "سجل المراجعات",
868
+ revempty: "لا توجد مراجعات بعد",
869
+ restore: "استعادة",
870
+ currentver: "النسخة الحالية",
871
+ importword: "استيراد من Word…",
872
+ importfail: "تعذر استيراد هذا الملف. الرجاء اختيار مستند ‎.docx صالح.",
873
+ restoredraft: "استعادة آخر مسودة",
874
+ draftempty: "لا توجد مسودة محفوظة",
875
+ deleteimg: "حذف الصورة",
876
+ rotateleft: "تدوير لليسار",
877
+ rotateright: "تدوير لليمين",
878
+ fliphorizontal: "قلب أفقي",
879
+ flipvertical: "قلب رأسي",
880
+ cell: "خلية",
881
+ row: "صف",
882
+ column: "عمود",
883
+ cellprops: "خصائص الخلية…",
884
+ rowprops: "خصائص الصف…",
885
+ colprops: "خصائص العمود…",
886
+ tblheight: "الارتفاع",
887
+ valign: "محاذاة عمودية",
888
+ valigntop: "أعلى",
889
+ valignmiddle: "وسط",
890
+ valignbottom: "أسفل",
891
+ fill: "تعبئة",
892
+ nocell: "انقر داخل خلية جدول أولاً",
893
+ uploadimg: "رفع من الجهاز",
894
+ imagelink: "إدراج من رابط",
895
+ imageurlph: "الصق رابط الصورة…",
896
+ insertimg: "إدراج",
897
+ dropimage: "أسقط الصورة هنا",
898
+ uploading: "جارٍ الرفع…",
899
+ uploadfailed: "فشل الرفع — انقر لإعادة المحاولة"
900
+ }
901
+ };
902
+ function vt(m) {
903
+ return Ze[m];
904
+ }
905
+ const De = "undo redo | preview print | importword revhistory | fontfamily fontsize | fontsizeincrease fontsizedecrease | bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | link blockquote changecase lineheight wordspacing | removeformat | blocks | ltr rtl | quickimage quicktable charmap | fullscreen sourcecode", Pe = "file edit view insert format tools table help", Ne = [
906
+ ["Andale Mono", "andale mono,times"],
907
+ ["Arial", "arial,helvetica,sans-serif"],
908
+ ["Arial Black", "arial black,avant garde"],
909
+ ["Book Antiqua", "book antiqua,palatino"],
910
+ ["Comic Sans MS", "comic sans ms,sans-serif"],
911
+ ["Courier New", "courier new,courier"],
912
+ ["Georgia", "georgia,palatino"],
913
+ ["Helvetica", "helvetica"],
914
+ ["Impact", "impact,chicago"],
915
+ ["Oswald", "oswald"],
916
+ ["Sakkal Majalla", "sakkal majalla"],
917
+ ["Symbol", "symbol"],
918
+ ["Tahoma", "tahoma,arial,helvetica,sans-serif"],
919
+ ["Terminal", "terminal,monaco"],
920
+ ["Times New Roman", "times new roman,times"],
921
+ ["Trebuchet MS", "trebuchet ms,geneva"],
922
+ ["Verdana", "verdana,geneva"],
923
+ ["Webdings", "webdings"],
924
+ ["Wingdings", "wingdings,zapf dingbats"]
925
+ ], Oe = ["8px", "9px", "10px", "11px", "12px", "14px", "16px", "18px", "20px", "24px", "28px", "32px", "36px", "48px", "72px", "96px"], Be = 1, Fe = 100, _e = ["1", "1.15", "1.4", "1.5", "1.75", "2", "2.5", "3"], $e = ["1px", "2px", "4px", "6px", "8px", "12px"], Ut = [
926
+ ["p", "para"],
927
+ ["h1", "heading1"],
928
+ ["h2", "heading2"],
929
+ ["h3", "heading3"],
930
+ ["h4", "heading4"],
931
+ ["h5", "heading5"],
932
+ ["h6", "heading6"],
933
+ ["pre", "pre"]
934
+ ], je = ["#F76707", "#4263EB", "#CC5DE8"], ze = [
935
+ "#BFEDD2",
936
+ "#FBEEB8",
937
+ "#F8CAC6",
938
+ "#ECCAFA",
939
+ "#C2E0F4",
940
+ "#2DC26B",
941
+ "#F1C40F",
942
+ "#E03E2D",
943
+ "#B96AD9",
944
+ "#3598DB",
945
+ "#169179",
946
+ "#E67E23",
947
+ "#BA372A",
948
+ "#843FA1",
949
+ "#236FA1",
950
+ "#ECF0F1",
951
+ "#CED4D9",
952
+ "#95A5A6",
953
+ "#7E8C8D",
954
+ "#34495E",
955
+ "#000000",
956
+ "#FFFFFF"
957
+ ], We = [
958
+ "©",
959
+ "®",
960
+ "™",
961
+ "§",
962
+ "¶",
963
+ "†",
964
+ "‡",
965
+ "•",
966
+ "…",
967
+ "′",
968
+ "″",
969
+ "‰",
970
+ "°",
971
+ "±",
972
+ "×",
973
+ "÷",
974
+ "≈",
975
+ "≠",
976
+ "≤",
977
+ "≥",
978
+ "∞",
979
+ "µ",
980
+ "√",
981
+ "∑",
982
+ "€",
983
+ "£",
984
+ "¥",
985
+ "¢",
986
+ "←",
987
+ "→",
988
+ "↑",
989
+ "↓",
990
+ "«",
991
+ "»",
992
+ "“",
993
+ "”",
994
+ "‘",
995
+ "’",
996
+ "–",
997
+ "—",
998
+ "؟",
999
+ "،",
1000
+ "؛",
1001
+ "٪",
1002
+ "٭",
1003
+ "ـ",
1004
+ "٠",
1005
+ "١"
1006
+ ], R = (m, t) => `<svg viewBox="${t || "0 0 24 24"}">${m}</svg>`, y = (m) => R(`<path class="f" d="${m}"/>`, "0 -960 960 960"), st = (m, t = 7.5) => R(
1007
+ '<path d="M10 6h10M10 12h10M10 18h10"/>' + m.map(
1008
+ (e, i) => `<text x="2.5" y="${8.4 + i * 6}" font-size="${t}" stroke="none" fill="#222f3e" font-family="Arial">${e}</text>`
1009
+ ).join("")
1010
+ ), h = {
1011
+ bold: y(
1012
+ "M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"
1013
+ ),
1014
+ italic: y("M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"),
1015
+ underline: y(
1016
+ "M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"
1017
+ ),
1018
+ strikethrough: y(
1019
+ "M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z"
1020
+ ),
1021
+ undo: y("M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"),
1022
+ redo: y("M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"),
1023
+ ltr: y(
1024
+ "M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm0-280v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80ZM680-80l-56-56 64-64H120v-80h568l-64-64 56-56 160 160L680-80Z"
1025
+ ),
1026
+ rtl: y(
1027
+ "M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm-88 160 64 64-56 56-160-160 160-160 56 56-64 64h568v80H272Zm88-440v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Z"
1028
+ ),
1029
+ alignleft: y(
1030
+ "M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"
1031
+ ),
1032
+ aligncenter: y(
1033
+ "M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"
1034
+ ),
1035
+ alignright: y(
1036
+ "M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"
1037
+ ),
1038
+ alignjustify: y(
1039
+ "M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"
1040
+ ),
1041
+ fullscreen: y(
1042
+ "M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z"
1043
+ ),
1044
+ clearformatic: y(
1045
+ "m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"
1046
+ ),
1047
+ numlist: y(
1048
+ "M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"
1049
+ ),
1050
+ bullist: y(
1051
+ "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"
1052
+ ),
1053
+ chev: R('<path d="M2 3.5 6 7.5 10 3.5"/>', "0 0 12 11"),
1054
+ backcolor: y(
1055
+ "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"
1056
+ ),
1057
+ outdent: y(
1058
+ "M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"
1059
+ ),
1060
+ indent: y(
1061
+ "M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"
1062
+ ),
1063
+ image: y(
1064
+ "M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"
1065
+ ),
1066
+ uploadic: y(
1067
+ "M440-200v-326L336-422l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-80q-33 0-56.5-23.5T160-160v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-80H240Z"
1068
+ ),
1069
+ tableic: y(
1070
+ "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"
1071
+ ),
1072
+ hric: R('<path d="M4 12h16"/>'),
1073
+ charic: y(
1074
+ "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"
1075
+ ),
1076
+ dateic: R(
1077
+ '<rect x="4" y="6" width="16" height="14" rx="1.5"/><path d="M4 10h16M8 4v4M16 4v4"/>'
1078
+ ),
1079
+ pbic: y(
1080
+ "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"
1081
+ ),
1082
+ nbspic: R('<path d="M6 12v4h12v-4"/>'),
1083
+ srcic: y(
1084
+ "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"
1085
+ ),
1086
+ prevw: y(
1087
+ "M607.5-372.5Q660-425 660-500t-52.5-127.5Q555-680 480-680t-127.5 52.5Q300-575 300-500t52.5 127.5Q405-320 480-320t127.5-52.5Zm-204-51Q372-455 372-500t31.5-76.5Q435-608 480-608t76.5 31.5Q588-545 588-500t-31.5 76.5Q525-392 480-392t-76.5-31.5ZM214-281.5Q94-363 40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200q-146 0-266-81.5ZM480-500Zm207.5 160.5Q782-399 832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280q113 0 207.5-59.5Z"
1088
+ ),
1089
+ printic: y(
1090
+ "M640-640v-120H320v120h-80v-200h480v200h-80Zm-480 80h640-640Zm560 100q17 0 28.5-11.5T760-500q0-17-11.5-28.5T720-540q-17 0-28.5 11.5T680-500q0 17 11.5 28.5T720-460Zm-80 260v-160H320v160h320Zm80 80H240v-160H80v-240q0-51 35-85.5t85-34.5h560q51 0 85.5 34.5T880-520v240H720v160Zm80-240v-160q0-17-11.5-28.5T760-560H200q-17 0-28.5 11.5T160-520v160h80v-80h480v80h80Z"
1091
+ ),
1092
+ cutic: y(
1093
+ "M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-520l-80-80 240-240h120v40L600-520ZM296.5-663.5Q320-687 320-720t-23.5-56.5Q273-800 240-800t-56.5 23.5Q160-753 160-720t23.5 56.5Q207-640 240-640t56.5-23.5ZM494-466q6-6 6-14t-6-14q-6-6-14-6t-14 6q-6 6-6 14t6 14q6 6 14 6t14-6ZM296.5-183.5Q320-207 320-240t-23.5-56.5Q273-320 240-320t-56.5 23.5Q160-273 160-240t23.5 56.5Q207-160 240-160t56.5-23.5Z"
1094
+ ),
1095
+ copyic: y(
1096
+ "M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"
1097
+ ),
1098
+ pasteic: y(
1099
+ "M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm308.5-571.5Q520-783 520-800t-11.5-28.5Q497-840 480-840t-28.5 11.5Q440-817 440-800t11.5 28.5Q463-760 480-760t28.5-11.5Z"
1100
+ ),
1101
+ selall: y(
1102
+ "M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T200-840v80Zm80 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z"
1103
+ ),
1104
+ superscriptic: y(
1105
+ "M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"
1106
+ ),
1107
+ subscriptic: y(
1108
+ "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"
1109
+ ),
1110
+ newic: R('<path d="M6 3h8l5 5v13H6z"/><path d="M14 3v5h5"/>'),
1111
+ helpic: R(
1112
+ '<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"/>'
1113
+ ),
1114
+ wcic: R('<path d="M4 6h16M4 10h16M4 14h9"/><path d="M15 17.5l2 2 3.6-4"/>'),
1115
+ rowbefore: y(
1116
+ "M200-160h560v-240H200v240Zm640 80H120v-720h160v80h-80v240h560v-240h-80v-80h160v720ZM480-480Zm0 80v-80 80Zm0 0Zm-40-240v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"
1117
+ ),
1118
+ rowafter: y(
1119
+ "M200-560h560v-240H200v240Zm-80 400v-720h720v720H680v-80h80v-240H200v240h80v80H120Zm360-320Zm0-80v80-80Zm0 0ZM440-80v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"
1120
+ ),
1121
+ rowdelete: y(
1122
+ "M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200ZM200-200h560v-560H200ZM200-400v-160h560v160H200ZM330-580l250 250 50-50-250-250ZM330-380l250-250 50 50-250 250Z"
1123
+ ),
1124
+ colbefore: y(
1125
+ "M800-200v-560H560v560h240Zm-640 80v-160h80v80h240v-560H240v80h-80v-160h720v720H160Zm320-360Zm80 0h-80 80Zm0 0ZM160-360v-80H80v-80h80v-80h80v80h80v80h-80v80h-80Z"
1126
+ ),
1127
+ colafter: y(
1128
+ "M160-760v560h240v-560H160ZM80-120v-720h720v160h-80v-80H480v560h240v-80h80v160H80Zm400-360Zm-80 0h80-80Zm0 0Zm320 120v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"
1129
+ ),
1130
+ coldelete: y(
1131
+ "M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200ZM200-200h560v-560H200ZM400-200v-560h160v560H400ZM330-580l250 250 50-50-250-250ZM330-380l250-250 50 50-250 250Z"
1132
+ ),
1133
+ tabledelete: R(
1134
+ '<rect x="4" y="5" width="16" height="14" rx="1.5"/><path d="M4 10h16M4 14.5h16M9.5 5v14M14.5 5v14"/><path d="M6.5 6.5l11 11M17.5 6.5l-11 11" stroke-width="2.1"/>'
1135
+ ),
1136
+ quote: y(
1137
+ "m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92ZM362.5-517.5Q380-535 380-560t-17.5-42.5Q345-620 320-620t-42.5 17.5Q260-585 260-560t17.5 42.5Q295-500 320-500t42.5-17.5Zm360 0Q740-535 740-560t-17.5-42.5Q705-620 680-620t-42.5 17.5Q620-585 620-560t17.5 42.5Q655-500 680-500t42.5-17.5ZM680-560Zm-360 0Z"
1138
+ ),
1139
+ link: y(
1140
+ "M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"
1141
+ ),
1142
+ lineheight: y(
1143
+ "M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z"
1144
+ ),
1145
+ wordspacing: y(
1146
+ "M320-80 160-240l160-160 57 56-64 64h334l-63-64 56-56 160 160L640-80l-57-56 64-64H313l63 64-56 56ZM200-480v-400h80v400h-80Zm240 0v-400h80v400h-80Zm240 0v-400h80v400h-80Z"
1147
+ ),
1148
+ caseic: y(
1149
+ "m131-252 165-440h79l165 440h-76l-39-112H247l-40 112h-76Zm139-176h131l-64-182h-4l-63 182Zm395 186q-51 0-81-27.5T554-342q0-44 34.5-72.5T677-443q23 0 45 4t38 11v-12q0-29-20.5-47T685-505q-23 0-42 9.5T610-468l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T689-393q-32 0-50 14t-18 37q0 20 16 33t40 13Z"
1150
+ ),
1151
+ uppercaseic: y(
1152
+ "M660-240v-248l-64 64-56-56 160-160 160 160-56 56-64-64v248h-80Zm-540 0 165-440h79l165 440h-76l-39-113H236l-40 113h-76Zm139-177h131l-65-182h-4l-62 182Z"
1153
+ ),
1154
+ lowercaseic: y(
1155
+ "M300-240q-51 0-81-27.5T189-340q0-44 34.5-72.5T312-441q23 0 45 4t38 11v-12q0-29-20.5-47T320-503q-23 0-42 9.5T245-466l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T324-391q-32 0-50 14t-18 37q0 20 16 33t40 13Zm388 54L540-400l56-56 64 64v-248h80v248l64-64 56 56-160 160Z"
1156
+ ),
1157
+ capitalizeic: y(
1158
+ "M344-250v-366H224v-64h308v64H412v366h-68Zm344 10q-44 0-69-25.5T594-336v-162h-54v-58h54v-87h66v87h74v58h-74v148q0 23 10.5 36t28.5 13q9 0 18.5-3.5T736-314v65q-10 5-22 7t-26 2Z"
1159
+ ),
1160
+ fontsizeup: y(
1161
+ "m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm504 104v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z"
1162
+ ),
1163
+ fontsizedown: y(
1164
+ "m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm384-16v-80h320v80H600Z"
1165
+ ),
1166
+ historyic: y(
1167
+ "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"
1168
+ ),
1169
+ wordic: R(
1170
+ '<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>'
1171
+ ),
1172
+ draftic: y(
1173
+ "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"
1174
+ ),
1175
+ trash: R(
1176
+ '<path d="M5 7h14M10 7V5h4v2M7.5 7l1 13h7l1-13"/>'
1177
+ ),
1178
+ rotateleft: R(
1179
+ '<polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>'
1180
+ ),
1181
+ rotateright: R(
1182
+ '<polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>'
1183
+ ),
1184
+ fliphorizontal: R(
1185
+ '<path d="M12 3v18"/><path d="M7 8l-4 4 4 4"/><path d="M17 8l4 4-4 4"/>'
1186
+ ),
1187
+ flipvertical: R(
1188
+ '<path d="M3 12h18"/><path d="M8 7l4-4 4 4"/><path d="M8 17l4 4 4-4"/>'
1189
+ ),
1190
+ check: R('<path d="M5 12.5 9.5 17 19 7"/>'),
1191
+ palette: R(
1192
+ '<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"/>'
1193
+ ),
1194
+ ul_circle: y(
1195
+ "M280-600v-80h560v80H280Zm0 160v-80h560v80H280Zm0 160v-80h560v80H280ZM160-600q-17 0-28.5-11.5T120-640q0-17 11.5-28.5T160-680q17 0 28.5 11.5T200-640q0 17-11.5 28.5T160-600Zm0 160q-17 0-28.5-11.5T120-480q0-17 11.5-28.5T160-520q17 0 28.5 11.5T200-480q0 17-11.5 28.5T160-440Zm0 160q-17 0-28.5-11.5T120-320q0-17 11.5-28.5T160-360q17 0 28.5 11.5T200-320q0 17-11.5 28.5T160-280Z"
1196
+ ),
1197
+ ul_square: y(
1198
+ "M80-160v-160h160v160H80Zm240 0v-160h560v160H320ZM80-400v-160h160v160H80Zm240 0v-160h560v160H320ZM80-640v-160h160v160H80Zm240 0v-160h560v160H320Z"
1199
+ ),
1200
+ ol_alpha: st(["a", "b", "c"]),
1201
+ ol_roman: st(["i", "ii", "iii"], 6.5),
1202
+ ol_alphau: st(["A", "B", "C"]),
1203
+ ol_romanu: st(["I", "II", "III"], 6.5)
1204
+ }, Ue = /* @__PURE__ */ new Set([
1205
+ "p",
1206
+ "div",
1207
+ "span",
1208
+ "br",
1209
+ "hr",
1210
+ "a",
1211
+ "b",
1212
+ "strong",
1213
+ "i",
1214
+ "em",
1215
+ "u",
1216
+ "s",
1217
+ "strike",
1218
+ "sub",
1219
+ "sup",
1220
+ "h1",
1221
+ "h2",
1222
+ "h3",
1223
+ "h4",
1224
+ "h5",
1225
+ "h6",
1226
+ "blockquote",
1227
+ "pre",
1228
+ "code",
1229
+ "ul",
1230
+ "ol",
1231
+ "li",
1232
+ "table",
1233
+ "thead",
1234
+ "tbody",
1235
+ "tfoot",
1236
+ "tr",
1237
+ "td",
1238
+ "th",
1239
+ "caption",
1240
+ "colgroup",
1241
+ "col",
1242
+ "img",
1243
+ "figure",
1244
+ "figcaption",
1245
+ "mark"
1246
+ ]), Xe = /* @__PURE__ */ new Set([
1247
+ "text-align",
1248
+ "direction",
1249
+ "unicode-bidi",
1250
+ "font-weight",
1251
+ "font-style",
1252
+ "text-decoration",
1253
+ "text-decoration-line",
1254
+ "color",
1255
+ "background-color",
1256
+ "background",
1257
+ "background-image",
1258
+ "background-position",
1259
+ "background-repeat",
1260
+ "background-size",
1261
+ "font-size",
1262
+ "font-family",
1263
+ "line-height",
1264
+ "letter-spacing",
1265
+ "vertical-align",
1266
+ "text-indent",
1267
+ "margin",
1268
+ "margin-top",
1269
+ "margin-bottom",
1270
+ "margin-left",
1271
+ "margin-right",
1272
+ "margin-inline-start",
1273
+ "margin-inline-end",
1274
+ "padding",
1275
+ "padding-top",
1276
+ "padding-bottom",
1277
+ "padding-left",
1278
+ "padding-right",
1279
+ "width",
1280
+ "height",
1281
+ "min-width",
1282
+ "max-width",
1283
+ "min-height",
1284
+ "max-height",
1285
+ "border",
1286
+ "border-top",
1287
+ "border-right",
1288
+ "border-bottom",
1289
+ "border-left",
1290
+ "border-color",
1291
+ "border-style",
1292
+ "border-width",
1293
+ "border-radius",
1294
+ "border-collapse",
1295
+ "border-spacing",
1296
+ "table-layout",
1297
+ "float",
1298
+ "display",
1299
+ "box-sizing",
1300
+ "list-style-type",
1301
+ "white-space"
1302
+ ]), Xt = {
1303
+ "*": ["dir", "lang", "colspan", "rowspan"],
1304
+ a: ["href", "target", "rel", "title"],
1305
+ img: ["src", "alt", "width", "height", "title"],
1306
+ col: ["span", "width"],
1307
+ td: ["width", "valign"],
1308
+ th: ["width", "valign"],
1309
+ table: ["width", "cellpadding", "cellspacing"]
1310
+ };
1311
+ function ot(m) {
1312
+ const t = {}, e = m.getAttribute && m.getAttribute("style");
1313
+ return e && e.split(";").forEach((i) => {
1314
+ const s = i.indexOf(":");
1315
+ s < 1 || (t[i.slice(0, s).trim().toLowerCase()] = i.slice(s + 1).trim());
1316
+ }), t;
1317
+ }
1318
+ function Ye(m) {
1319
+ return m.replace(/<!--\[if !supportLists\]-->([\s\S]*?)<!--\[endif\]-->/gi, "$1").replace(/<!--\[if !supportLists\]>([\s\S]*?)<!\[endif\]-->/gi, "$1").replace(/<!\[if !supportLists\]>([\s\S]*?)<!\[endif\]>/gi, "$1").replace(/<!--\[if [\s\S]*?<!\[endif\]-->/gi, "").replace(/<!--[\s\S]*?-->/g, "").replace(/<(script|style|xml|title)[\s\S]*?<\/\1>/gi, "").replace(/<\/?(meta|link)[^>]*>/gi, "").replace(/<\?xml[\s\S]*?\?>/gi, "").replace(/<\/?(o|v|w|m|st1):[^>]*>/gi, "");
1320
+ }
1321
+ function Qe(m) {
1322
+ return /^[0-9]+[\.\)،]/.test(m) ? { ordered: !0 } : /^[٠-٩۰-۹]+/.test(m) ? { ordered: !0, style: "arabic-indic" } : /^[ivxlc]{2,}[\.\)]/.test(m) ? { ordered: !0, style: "lower-roman" } : /^[IVXLC]{2,}[\.\)]/.test(m) ? { ordered: !0, style: "upper-roman" } : /^[a-z][\.\)]/.test(m) ? { ordered: !0, style: "lower-alpha" } : /^[A-Z][\.\)]/.test(m) ? { ordered: !0, style: "upper-alpha" } : /^[ء-ي][\.\)،-]/.test(m) ? { ordered: !0, style: "arabic-indic" } : { ordered: !1 };
1323
+ }
1324
+ function Ve(m) {
1325
+ const t = (s) => {
1326
+ const r = (s.getAttribute("style") || "") + " " + (s.className || "");
1327
+ return /mso-list\s*:(?!\s*ignore)/i.test(r) || /MsoListParagraph/i.test(r);
1328
+ }, e = [];
1329
+ let i = null;
1330
+ Array.from(m.body.querySelectorAll("p")).forEach((s) => {
1331
+ if (!t(s)) {
1332
+ i = null;
1333
+ return;
1334
+ }
1335
+ const r = s.previousElementSibling;
1336
+ i && r && i[i.length - 1] === r ? i.push(s) : (i = [s], e.push(i));
1337
+ }), e.forEach((s) => {
1338
+ const r = [], l = s[0];
1339
+ s.forEach((o) => {
1340
+ var q, M, D;
1341
+ const c = +(((q = (o.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : q[1]) || 1), d = Array.from(o.querySelectorAll("span")).find(
1342
+ (I) => /mso-list\s*:\s*ignore/i.test(I.getAttribute("style") || "")
1343
+ ), u = d ? ((M = d.textContent) == null ? void 0 : M.trim()) || "" : (((D = o.textContent) == null ? void 0 : D.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: v, style: b } = Qe(u);
1344
+ for (d && d.remove(); r.length && r[r.length - 1].level > c; ) r.pop();
1345
+ if (!r.length || r[r.length - 1].level < c) {
1346
+ const I = m.createElement(v ? "ol" : "ul");
1347
+ if (v && b && (I.style.listStyleType = b), r.length) {
1348
+ const F = r[r.length - 1].list;
1349
+ (F.lastElementChild || F).appendChild(I);
1350
+ } else
1351
+ l.parentNode.insertBefore(I, l);
1352
+ r.push({ list: I, level: c });
1353
+ }
1354
+ const f = m.createElement("li"), w = ot(o), E = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((I) => w[I]).map((I) => I + ":" + w[I]).join(";");
1355
+ for (E && f.setAttribute("style", E), o.getAttribute("dir") && f.setAttribute("dir", o.getAttribute("dir")); o.firstChild; ) f.appendChild(o.firstChild);
1356
+ r[r.length - 1].list.appendChild(f), o.remove();
1357
+ });
1358
+ });
1359
+ }
1360
+ function Ge(m) {
1361
+ m.querySelectorAll('b[id^="docs-internal-guid"]').forEach((t) => {
1362
+ for (; t.firstChild; ) t.parentNode.insertBefore(t.firstChild, t);
1363
+ t.remove();
1364
+ });
1365
+ }
1366
+ function Ke(m) {
1367
+ m.querySelectorAll("table").forEach((t) => {
1368
+ const e = t;
1369
+ ot(e)["border-collapse"] || (e.style.borderCollapse = "collapse");
1370
+ }), m.querySelectorAll("[align]").forEach((t) => {
1371
+ const e = t, i = e.getAttribute("align").toLowerCase();
1372
+ 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) => {
1373
+ if (s.tagName.toLowerCase() !== "table") return;
1374
+ const r = s;
1375
+ i === "center" ? (r.style.marginLeft = r.style.marginLeft || "auto", r.style.marginRight = r.style.marginRight || "auto") : i === "right" ? r.style.marginLeft = r.style.marginLeft || "auto" : i === "left" && (r.style.marginRight = r.style.marginRight || "auto");
1376
+ })), e.removeAttribute("align");
1377
+ }), m.querySelectorAll("center table").forEach((t) => {
1378
+ const e = t;
1379
+ e.style.marginLeft = e.style.marginLeft || "auto", e.style.marginRight = e.style.marginRight || "auto";
1380
+ }), m.querySelectorAll("[bgcolor]").forEach((t) => {
1381
+ const e = t;
1382
+ e.style.backgroundColor = e.style.backgroundColor || e.getAttribute("bgcolor"), e.removeAttribute("bgcolor");
1383
+ });
1384
+ }
1385
+ function nt(m, t) {
1386
+ Array.from(m.childNodes).forEach((e) => {
1387
+ if (e.nodeType === Node.COMMENT_NODE) {
1388
+ e.remove();
1389
+ return;
1390
+ }
1391
+ if (e.nodeType !== Node.ELEMENT_NODE) return;
1392
+ const i = e, s = i.tagName.toLowerCase();
1393
+ if (!Ue.has(s)) {
1394
+ if (s === "font") {
1395
+ const a = t.createElement("span");
1396
+ i.getAttribute("style") && a.setAttribute("style", i.getAttribute("style")), i.getAttribute("color") && (a.style.color = i.getAttribute("color")), i.getAttribute("face") && (a.style.fontFamily = i.getAttribute("face"));
1397
+ const c = i.getAttribute("size");
1398
+ if (c && !a.style.fontSize) {
1399
+ const d = {
1400
+ 1: "8pt",
1401
+ 2: "10pt",
1402
+ 3: "12pt",
1403
+ 4: "14pt",
1404
+ 5: "18pt",
1405
+ 6: "24pt",
1406
+ 7: "36pt"
1407
+ };
1408
+ d[c] && (a.style.fontSize = d[c]);
1409
+ }
1410
+ for (; i.firstChild; ) a.appendChild(i.firstChild);
1411
+ i.replaceWith(a), nt(a, t);
1412
+ return;
1413
+ }
1414
+ for (nt(i, t); i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
1415
+ i.remove();
1416
+ return;
1417
+ }
1418
+ const r = /* @__PURE__ */ new Set([...Xt["*"] || [], ...Xt[s] || []]);
1419
+ if (Array.from(i.attributes).forEach((a) => {
1420
+ const c = a.name.toLowerCase();
1421
+ c !== "style" && !r.has(c) && i.removeAttribute(a.name);
1422
+ }), s === "a") {
1423
+ const a = i.getAttribute("href") || "";
1424
+ /^(https?:|mailto:|tel:|#)/i.test(a) || i.removeAttribute("href");
1425
+ }
1426
+ if (s === "img") {
1427
+ const a = i.getAttribute("src") || "";
1428
+ if (!/^(https?:|data:image\/|blob:)/i.test(a)) {
1429
+ const c = t.createElement("span");
1430
+ c.textContent = "[local image — paste it separately]", c.setAttribute("style", "color:#a33;font-style:italic;font-size:12px"), i.replaceWith(c);
1431
+ return;
1432
+ }
1433
+ }
1434
+ const l = ot(i), o = [];
1435
+ for (const [a, c] of Object.entries(l))
1436
+ Xe.has(a) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(c) || a === "font-weight" && /^(400|normal)$/i.test(c) || a === "font-style" && /^normal$/i.test(c) || a === "text-decoration" && /^none$/i.test(c) || o.push(a + ":" + c));
1437
+ if (o.length ? i.setAttribute("style", o.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), nt(i, t), s === "span" && !i.attributes.length) {
1438
+ for (; i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
1439
+ i.remove();
1440
+ }
1441
+ });
1442
+ }
1443
+ function Je(m) {
1444
+ const t = [], e = /<style[^>]*>([\s\S]*?)<\/style>/gi;
1445
+ let i;
1446
+ for (; i = e.exec(m); ) {
1447
+ let s = i[1].replace(/<!--|-->/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
1448
+ s = s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi, ""), s = s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g, "");
1449
+ let r;
1450
+ const l = /([^{}]+)\{([^}]*)\}/g;
1451
+ for (; r = l.exec(s); ) {
1452
+ const o = r[2].split(";").map((a) => {
1453
+ const c = a.indexOf(":");
1454
+ return c < 1 ? null : [a.slice(0, c).trim().toLowerCase(), a.slice(c + 1).trim()];
1455
+ }).filter((a) => !!a && !!a[1]);
1456
+ o.length && r[1].split(",").map((a) => a.trim()).filter((a) => a && !a.startsWith("@")).forEach((a) => t.push({ sel: a, decls: o }));
1457
+ }
1458
+ }
1459
+ return t;
1460
+ }
1461
+ function ti(m, t) {
1462
+ if (!t.length) return;
1463
+ const e = /* @__PURE__ */ new Map();
1464
+ t.forEach(({ sel: i, decls: s }) => {
1465
+ let r;
1466
+ try {
1467
+ r = m.querySelectorAll(i);
1468
+ } catch {
1469
+ return;
1470
+ }
1471
+ r.forEach((l) => {
1472
+ let o = e.get(l);
1473
+ o || (o = {}, e.set(l, o)), s.forEach(([a, c]) => {
1474
+ o[a] = c;
1475
+ });
1476
+ });
1477
+ }), e.forEach((i, s) => {
1478
+ const r = ot(s), l = s.hasAttribute("dir"), o = s.hasAttribute("align"), a = Object.entries(i).filter(([u]) => !(u in r || (u === "direction" || u === "unicode-bidi") && l || u === "text-align" && (o || l) || (u === "background" || u === "background-color") && s.hasAttribute("bgcolor")));
1479
+ if (!a.length) return;
1480
+ const c = a.map(([u, v]) => u + ":" + v).join(";"), d = s.getAttribute("style");
1481
+ s.setAttribute("style", d ? c + ";" + d : c);
1482
+ });
1483
+ }
1484
+ function Kt(m) {
1485
+ return m.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g, (t) => t.normalize("NFKC"));
1486
+ }
1487
+ function ei(m) {
1488
+ const t = m.createTreeWalker(m.body, NodeFilter.SHOW_TEXT, null);
1489
+ let e;
1490
+ for (; e = t.nextNode(); )
1491
+ /[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue = Kt(e.nodeValue || ""));
1492
+ }
1493
+ function ii(m, t = "ltr") {
1494
+ const e = Je(m), i = new DOMParser().parseFromString(Ye(m), "text/html");
1495
+ ti(i, e), /class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML) && Ve(i), Ge(i), Ke(i), nt(i.body, i), ei(i);
1496
+ const s = (r) => {
1497
+ var l;
1498
+ return r && r.tagName === "P" && !((l = r.textContent) != null && l.trim()) && !r.querySelector("img,table");
1499
+ };
1500
+ for (; s(i.body.firstElementChild); ) i.body.firstElementChild.remove();
1501
+ for (; s(i.body.lastElementChild); ) i.body.lastElementChild.remove();
1502
+ return i.body.innerHTML.trim();
1503
+ }
1504
+ function si(m) {
1505
+ const t = Kt(m).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1506
+ return /\n/.test(t) ? t.split(/\n{2,}/).map((i) => `<p dir="auto">${e(i).replace(/\n/g, "<br>") || "<br>"}</p>`).join("") : e(t);
1507
+ }
1508
+ function ri(m) {
1509
+ const t = new DataView(m), e = /* @__PURE__ */ new Map();
1510
+ let i = -1;
1511
+ for (let o = m.byteLength - 22; o >= Math.max(0, m.byteLength - 22 - 65535); o--)
1512
+ if (t.getUint32(o, !0) === 101010256) {
1513
+ i = o;
1514
+ break;
1515
+ }
1516
+ if (i < 0) throw new Error("EOCD not found");
1517
+ const s = t.getUint16(i + 10, !0);
1518
+ let r = t.getUint32(i + 16, !0);
1519
+ const l = new TextDecoder();
1520
+ for (let o = 0; o < s && t.getUint32(r, !0) === 33639248; o++) {
1521
+ const a = t.getUint16(r + 10, !0), c = t.getUint32(r + 20, !0), d = t.getUint16(r + 28, !0), u = t.getUint16(r + 30, !0), v = t.getUint16(r + 32, !0), b = t.getUint32(r + 42, !0), f = l.decode(new Uint8Array(m, r + 46, d));
1522
+ e.set(f, { name: f, method: a, compSize: c, localOffset: b }), r += 46 + d + u + v;
1523
+ }
1524
+ return e;
1525
+ }
1526
+ async function Yt(m, t) {
1527
+ const e = new DataView(m, t.localOffset);
1528
+ if (e.getUint32(0, !0) !== 67324752) throw new Error("Bad local header");
1529
+ const i = e.getUint16(26, !0), s = e.getUint16(28, !0), r = t.localOffset + 30 + i + s, l = new Uint8Array(m.slice(r, r + t.compSize));
1530
+ if (t.method === 0) return l;
1531
+ if (t.method !== 8) throw new Error("Unsupported compression method " + t.method);
1532
+ const o = new Blob([l]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
1533
+ return new Uint8Array(await new Response(o).arrayBuffer());
1534
+ }
1535
+ const Qt = (m) => m.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), lt = (m, t) => Array.from(m.children).filter((e) => e.localName === t), Z = (m, ...t) => {
1536
+ let e = m;
1537
+ for (const i of t) {
1538
+ if (!e) return null;
1539
+ e = Array.from(e.children).find((s) => s.localName === i) || null;
1540
+ }
1541
+ return e;
1542
+ }, H = (m, t = "val") => {
1543
+ if (!m) return "";
1544
+ for (const e of Array.from(m.attributes))
1545
+ if (e.localName === t) return e.value;
1546
+ return "";
1547
+ }, rt = (m, t) => {
1548
+ const e = m ? Z(m, t) : null;
1549
+ if (!e) return !1;
1550
+ const i = H(e);
1551
+ return i !== "false" && i !== "0";
1552
+ }, Vt = {
1553
+ yellow: "#FFFF00",
1554
+ green: "#00FF00",
1555
+ cyan: "#00FFFF",
1556
+ magenta: "#FF00FF",
1557
+ blue: "#0000FF",
1558
+ red: "#FF0000",
1559
+ darkBlue: "#00008B",
1560
+ darkCyan: "#008B8B",
1561
+ darkGreen: "#006400",
1562
+ darkMagenta: "#8B008B",
1563
+ darkRed: "#8B0000",
1564
+ darkYellow: "#808000",
1565
+ darkGray: "#A9A9A9",
1566
+ lightGray: "#D3D3D3",
1567
+ black: "#000000",
1568
+ white: "#FFFFFF"
1569
+ }, ni = {
1570
+ png: "image/png",
1571
+ jpg: "image/jpeg",
1572
+ jpeg: "image/jpeg",
1573
+ gif: "image/gif",
1574
+ bmp: "image/bmp",
1575
+ webp: "image/webp"
1576
+ };
1577
+ function li(m) {
1578
+ let t = "";
1579
+ for (let e = 0; e < m.length; e += 32768)
1580
+ t += String.fromCharCode(...m.subarray(e, e + 32768));
1581
+ return btoa(t);
1582
+ }
1583
+ class oi {
1584
+ constructor(t, e, i) {
1585
+ this.rels = t, this.images = e, this.numFmt = i;
1586
+ }
1587
+ convertBody(t) {
1588
+ let e = "", i = [];
1589
+ const s = (r) => {
1590
+ for (; i.length > r; ) e += `</${i.pop()}>`;
1591
+ };
1592
+ for (const r of Array.from(t.children))
1593
+ if (r.localName === "p") {
1594
+ const l = this.paraList(r);
1595
+ if (l) {
1596
+ const o = l.ilvl + 1;
1597
+ for (; i.length > o; ) e += `</${i.pop()}>`;
1598
+ for (i.length === o && i[o - 1] !== l.type && (e += `</${i.pop()}>`); i.length < o; )
1599
+ e += `<${l.type}>`, i.push(l.type);
1600
+ e += `<li>${this.runsOf(r) || "<br>"}</li>`;
1601
+ continue;
1602
+ }
1603
+ s(0), e += this.convertPara(r);
1604
+ } else r.localName === "tbl" ? (s(0), e += this.convertTable(r)) : r.localName;
1605
+ return s(0), e || "<p><br></p>";
1606
+ }
1607
+ paraList(t) {
1608
+ const e = Z(t, "pPr", "numPr");
1609
+ if (!e) return null;
1610
+ const i = H(Z(e, "numId"));
1611
+ if (!i || i === "0") return null;
1612
+ const s = parseInt(H(Z(e, "ilvl")) || "0", 10) || 0;
1613
+ return { type: this.numFmt.get(i) || "ul", ilvl: Math.min(s, 8) };
1614
+ }
1615
+ convertPara(t) {
1616
+ const e = Z(t, "pPr"), i = H(Z(t, "pPr", "pStyle"));
1617
+ let s = "p";
1618
+ const r = /^Heading([1-6])$/i.exec(i);
1619
+ r ? s = "h" + r[1] : /^Title$/i.test(i) && (s = "h1");
1620
+ const l = [], o = H(Z(t, "pPr", "jc"));
1621
+ o === "center" ? l.push("text-align:center") : o === "right" || o === "end" ? l.push("text-align:right") : (o === "both" || o === "distribute") && l.push("text-align:justify"), e && Z(e, "bidi") && l.push("direction:rtl");
1622
+ const a = this.runsOf(t), c = l.length ? ` style="${l.join(";")}"` : "";
1623
+ return `<${s}${c}>${a || "<br>"}</${s}>`;
1624
+ }
1625
+ runsOf(t) {
1626
+ let e = "";
1627
+ for (const i of Array.from(t.children))
1628
+ if (i.localName === "r") e += this.convertRun(i);
1629
+ else if (i.localName === "hyperlink") {
1630
+ let s = this.rels.get(H(i, "id")) || "";
1631
+ const r = H(i, "anchor");
1632
+ !s && r && (s = "#" + r);
1633
+ const l = this.runsOf(i);
1634
+ e += s ? `<a href="${Qt(s)}">${l}</a>` : l;
1635
+ } else (i.localName === "smartTag" || i.localName === "ins") && (e += this.runsOf(i));
1636
+ return e;
1637
+ }
1638
+ convertRun(t) {
1639
+ const e = Z(t, "rPr");
1640
+ let i = "";
1641
+ for (const u of Array.from(t.children))
1642
+ u.localName === "t" ? i += Qt(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));
1643
+ if (!i) return "";
1644
+ const s = [], r = H(e ? Z(e, "color") : null);
1645
+ r && r !== "auto" && s.push("color:#" + r);
1646
+ const l = H(e ? Z(e, "highlight") : null);
1647
+ l && Vt[l] && s.push("background-color:" + Vt[l]);
1648
+ const o = parseFloat(H(e ? Z(e, "sz") : null));
1649
+ o && s.push("font-size:" + Math.round(o / 2 * (4 / 3)) + "px");
1650
+ const a = e ? Z(e, "rFonts") : null, c = H(a, "ascii") || H(a, "cs");
1651
+ c && s.push(`font-family:'${c}'`), s.length && (i = `<span style="${s.join(";")}">${i}</span>`), rt(e, "b") && (i = `<strong>${i}</strong>`), rt(e, "i") && (i = `<em>${i}</em>`), rt(e, "u") && H(Z(e, "u")) !== "none" && (i = `<u>${i}</u>`), rt(e, "strike") && (i = `<s>${i}</s>`);
1652
+ const d = H(e ? Z(e, "vertAlign") : null);
1653
+ return d === "superscript" ? i = `<sup>${i}</sup>` : d === "subscript" && (i = `<sub>${i}</sub>`), i;
1654
+ }
1655
+ convertImage(t) {
1656
+ let e = "", i = 0;
1657
+ const s = (o) => {
1658
+ if (o.localName === "blip" && (e = e || H(o, "embed") || H(o, "link")), o.localName === "imagedata" && (e = e || H(o, "id")), o.localName === "extent") {
1659
+ const a = parseFloat(o.getAttribute("cx") || "0");
1660
+ a && (i = Math.round(a / 9525));
1661
+ }
1662
+ for (const a of Array.from(o.children)) s(a);
1663
+ };
1664
+ if (s(t), !e) return "";
1665
+ const r = this.images.get(e);
1666
+ if (!r) return "";
1667
+ const l = i ? ` width="${i}"` : "";
1668
+ return `<img src="${r}" alt=""${l}>`;
1669
+ }
1670
+ convertTable(t) {
1671
+ let e = '<table style="border-collapse:collapse;width:100%"><tbody>';
1672
+ for (const i of lt(t, "tr")) {
1673
+ e += "<tr>";
1674
+ for (const s of lt(i, "tc")) {
1675
+ const r = parseInt(H(Z(s, "tcPr", "gridSpan")) || "1", 10) || 1, l = r > 1 ? ` colspan="${r}"` : "";
1676
+ let o = "";
1677
+ for (const a of Array.from(s.children))
1678
+ a.localName === "p" ? o += this.convertPara(a) : a.localName === "tbl" && (o += this.convertTable(a));
1679
+ e += `<td style="border:1px solid #b9c2cc"${l}>${o || "<br>"}</td>`;
1680
+ }
1681
+ e += "</tr>";
1682
+ }
1683
+ return e + "</tbody></table>";
1684
+ }
1685
+ }
1686
+ async function ai(m) {
1687
+ const t = m instanceof ArrayBuffer ? m : await m.arrayBuffer(), e = ri(t), i = new TextDecoder(), s = async (f) => {
1688
+ const w = e.get(f);
1689
+ return w ? new DOMParser().parseFromString(i.decode(await Yt(t, w)), "application/xml") : null;
1690
+ }, r = await s("word/document.xml"), l = r == null ? void 0 : r.getElementsByTagName("*");
1691
+ let o = null;
1692
+ if (l) {
1693
+ for (const f of Array.from(l))
1694
+ if (f.localName === "body") {
1695
+ o = f;
1696
+ break;
1697
+ }
1698
+ }
1699
+ if (!o) throw new Error("word/document.xml missing or invalid");
1700
+ const a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), d = await s("word/_rels/document.xml.rels");
1701
+ if (d)
1702
+ for (const f of Array.from(d.getElementsByTagName("*"))) {
1703
+ if (f.localName !== "Relationship") continue;
1704
+ const w = f.getAttribute("Id") || "", E = f.getAttribute("Target") || "", q = f.getAttribute("Type") || "";
1705
+ /hyperlink/i.test(q) ? a.set(w, E) : /image/i.test(q) && c.set(w, E);
1706
+ }
1707
+ const u = /* @__PURE__ */ new Map();
1708
+ for (const [f, w] of c) {
1709
+ const E = w.startsWith("/") ? w.slice(1) : "word/" + w.replace(/^\.\//, ""), q = e.get(E);
1710
+ if (!q) continue;
1711
+ const M = (E.split(".").pop() || "").toLowerCase(), D = ni[M];
1712
+ if (D)
1713
+ try {
1714
+ u.set(f, `data:${D};base64,${li(await Yt(t, q))}`);
1715
+ } catch {
1716
+ }
1717
+ }
1718
+ const v = /* @__PURE__ */ new Map(), b = await s("word/numbering.xml");
1719
+ if (b) {
1720
+ const f = /* @__PURE__ */ new Map(), w = Array.from(b.getElementsByTagName("*"));
1721
+ for (const E of w) {
1722
+ if (E.localName !== "abstractNum") continue;
1723
+ const q = H(E, "abstractNumId"), M = lt(E, "lvl").find((I) => H(I, "ilvl") === "0") || lt(E, "lvl")[0], D = M ? H(Z(M, "numFmt")) : "";
1724
+ f.set(q, D === "bullet" ? "ul" : "ol");
1725
+ }
1726
+ for (const E of w) {
1727
+ if (E.localName !== "num") continue;
1728
+ const q = H(E, "numId"), M = H(Z(E, "abstractNumId"));
1729
+ v.set(q, f.get(M) || "ul");
1730
+ }
1731
+ }
1732
+ return new oi(a, u, v).convertBody(o);
1733
+ }
1734
+ const ci = ["nw", "ne", "sw", "se"];
1735
+ var z;
1736
+ let hi = (z = class {
1737
+ constructor(t) {
1738
+ this.lang = "en", this.contentClass = "fable-content-" + z.instanceCounter++, this.contentStyleEl = null, this.savedRange = null, this.foreColor = "#000000", this.backColor = "#FACC15", this.openPop = null, this.openSubEl = null, this.popAnchor = null, this.dlgOvl = null, this.tblActive = null, this.tblCorner = null, this.tblColBars = [], this.tblCtx = null, this.tblCellMark = null, this.tblOpMark = null, this.tblOpMarkKind = null, this.imgActive = null, this.imgHandles = [], this.imgCtx = null, this.imgHideTimer = null, this.phActive = null, this.phCtx = null, this.phUploadTarget = null, this.selCtx = null, this.revisions = [], this.revTimer = null, this.draftTimer = null, this.draftStorageKey = "", this.listeners = [], this.isDestroyed = !1, this.options = {
1739
+ target: t.target,
1740
+ language: t.language || "en",
1741
+ height: t.height ?? 302,
1742
+ initialContent: t.initialContent ?? "<p><br></p>",
1743
+ onChange: t.onChange || (() => {
1744
+ }),
1745
+ onReady: t.onReady || (() => {
1746
+ }),
1747
+ menubar: t.menubar ?? !0,
1748
+ toolbar: t.toolbar ?? !0,
1749
+ statusbar: t.statusbar ?? !0,
1750
+ readonly: t.readonly ?? !1,
1751
+ draftKey: t.draftKey ?? (typeof location < "u" ? location.pathname : "default"),
1752
+ fontFamilyFormats: t.fontFamilyFormats ?? Ne,
1753
+ imageFileTypes: t.imageFileTypes ?? ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/bmp", "image/webp"]
1754
+ }, this.imageUploadHandler = t.imageUploadHandler, this.onImageUploadError = t.onImageUploadError, this.contentStyle = t.contentStyle, this.lang = this.options.language, this.draftStorageKey = "tmclone-draft:" + this.options.draftKey, this.initDOM(), this.bindEvents(), this.initUI(), this.recordRevision(), this.options.onReady(this);
1755
+ }
1756
+ t(t) {
1757
+ const e = vt(this.lang)[t];
1758
+ return typeof e == "string" ? e : e.join(",");
1759
+ }
1760
+ tArr(t) {
1761
+ return vt(this.lang)[t];
1762
+ }
1763
+ dir() {
1764
+ return vt(this.lang).dir;
1765
+ }
1766
+ /* ---------------------------------------------------------- DOM setup */
1767
+ initDOM() {
1768
+ const t = this.options.target;
1769
+ t.innerHTML = "", t.classList.add("tox-root"), this.shell = document.createElement("div"), this.shell.className = "tox", this.menubar = document.createElement("div"), this.menubar.className = "mnb", this.toolbar = document.createElement("div"), this.toolbar.className = "tbr", this.ed = document.createElement("div"), this.ed.className = "earea " + this.contentClass, this.ed.setAttribute("contenteditable", (!this.options.readonly).toString()), this.ed.spellcheck = !0, this.ed.innerHTML = this.options.initialContent, this.ed.style.height = this.options.height + "px", this.statusbar = document.createElement("div"), this.statusbar.className = "sbar", this.statusbar.innerHTML = `
1770
+ <span class="mid"></span>
1771
+ <span class="words"></span>
1772
+ <span class="grip">
1773
+ <svg viewBox="0 0 12 12"><path d="M11 1 1 11M11 6 6 11M11 11h0"/></svg>
1774
+ </span>
1775
+ `, this.sbHelp = this.statusbar.querySelector(".mid"), this.sbWords = this.statusbar.querySelector(".words");
1776
+ const e = this.statusbar.querySelector(".grip");
1777
+ this.bindGrip(e), this.shell.appendChild(this.menubar), this.shell.appendChild(this.toolbar), this.shell.appendChild(this.ed), this.shell.appendChild(this.statusbar), this.contentStyle && (this.contentStyleEl = document.createElement("style"), this.contentStyleEl.textContent = this.scopeContentStyle(this.contentStyle), this.shell.appendChild(this.contentStyleEl)), t.appendChild(this.shell), this.options.statusbar || (this.statusbar.style.display = "none"), this.imgInput = document.createElement("input"), this.imgInput.type = "file", this.imgInput.accept = this.options.imageFileTypes.join(","), this.imgInput.style.display = "none", t.appendChild(this.imgInput), this.docInput = document.createElement("input"), this.docInput.type = "file", this.docInput.accept = ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", this.docInput.style.display = "none", t.appendChild(this.docInput);
1778
+ }
1779
+ /** Rewrites the literal word `body` in a user-supplied `contentStyle` string to a
1780
+ * selector scoped to this instance's content div. Everything else passes through
1781
+ * verbatim, since `.ed` is a plain div in the host page (not an iframe) and an
1782
+ * unscoped `body { ... }` rule would otherwise leak onto the host page's body. */
1783
+ scopeContentStyle(t) {
1784
+ return t.replace(/\bbody\b/g, "." + this.contentClass);
1785
+ }
1786
+ bindGrip(t) {
1787
+ let e = 0, i = 0;
1788
+ const s = (r) => {
1789
+ e = r.clientY, i = this.ed.offsetHeight, r.preventDefault();
1790
+ const l = (a) => {
1791
+ this.ed.style.height = Math.max(120, i + a.clientY - e) + "px";
1792
+ }, o = () => {
1793
+ window.removeEventListener("mousemove", l), window.removeEventListener("mouseup", o);
1794
+ };
1795
+ window.addEventListener("mousemove", l), window.addEventListener("mouseup", o);
1796
+ };
1797
+ t.addEventListener("mousedown", s), this.listeners.push(() => t.removeEventListener("mousedown", s));
1798
+ }
1799
+ /* ---------------------------------------------------------- event binding */
1800
+ bindEvents() {
1801
+ this.onDoc("mousedown", (t) => {
1802
+ this.openPop && !this.openPop.contains(t.target) && !this.popAnchor.contains(t.target) && !(this.openSubEl && this.openSubEl.contains(t.target)) && this.closePop();
1803
+ }), this.onDoc("keydown", (t) => {
1804
+ t.key === "Escape" && (this.closePop(), this.closeDlg());
1805
+ }), this.onDoc("selectionchange", () => {
1806
+ const t = window.getSelection();
1807
+ t && this.ed.contains(t.anchorNode) ? (this.saveSel(), this.refreshState(), this.updateSelToolbar(t), this.positionCellMarker()) : this.clearSelToolbar();
1808
+ }), this.on(this.ed, "input", () => {
1809
+ this.refreshState(), this.onChange(), this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx();
1810
+ }), this.on(this.ed, "keydown", (t) => {
1811
+ t.altKey && t.key === "0" && (t.preventDefault(), this.helpDlg());
1812
+ }), this.on(this.ed, "paste", (t) => this.handlePaste(t)), this.on(this.ed, "drop", (t) => {
1813
+ var s, r, l;
1814
+ t.preventDefault();
1815
+ const e = (r = (s = t.target).closest) == null ? void 0 : r.call(s, ".img-ph");
1816
+ if (!e || !this.ed.contains(e) || this.options.readonly) return;
1817
+ const i = Array.from(((l = t.dataTransfer) == null ? void 0 : l.files) || []).find((o) => o.type.startsWith("image/"));
1818
+ i && this.readImageFileInto(i, e);
1819
+ }), this.on(this.ed, "dragover", (t) => t.preventDefault()), this.on(this.ed, "mousedown", (t) => {
1820
+ var l, o, a;
1821
+ const e = t.target, i = (l = e.closest) == null ? void 0 : l.call(e, "table");
1822
+ i && this.ed.contains(i) ? this.selectTableForResize(i) : this.clearTableHandles();
1823
+ const s = (o = e.closest) == null ? void 0 : o.call(e, ".img-ph");
1824
+ s && this.ed.contains(s) && !this.options.readonly ? (t.preventDefault(), this.selectImgPlaceholder(s)) : this.clearImgPlaceholderSel();
1825
+ const r = (a = e.closest) == null ? void 0 : a.call(e, "img");
1826
+ r && this.ed.contains(r) && !this.options.readonly ? (t.preventDefault(), this.selectImage(r)) : this.clearImageHandles();
1827
+ }), this.on(this.ed, "mouseover", (t) => {
1828
+ var i, s;
1829
+ if (this.options.readonly) return;
1830
+ const e = (s = (i = t.target).closest) == null ? void 0 : s.call(i, "img");
1831
+ e && this.ed.contains(e) && (this.cancelImgHide(), this.selectImage(e));
1832
+ }), this.on(this.ed, "mouseout", (t) => {
1833
+ var s, r, l, o;
1834
+ const e = (r = (s = t.target).closest) == null ? void 0 : r.call(s, "img");
1835
+ if (!e) return;
1836
+ const i = t.relatedTarget;
1837
+ i && ((l = this.imgCtx) != null && l.contains(i) || this.imgHandles.some((a) => a.contains(i)) || ((o = i.closest) == null ? void 0 : o.call(i, "img")) === e) || this.scheduleImgHide();
1838
+ }), this.on(this.ed, "scroll", () => {
1839
+ this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx();
1840
+ }), this.onWin(
1841
+ "scroll",
1842
+ () => {
1843
+ this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.repositionSelToolbar();
1844
+ },
1845
+ !0
1846
+ ), this.onWin("resize", () => {
1847
+ this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.repositionSelToolbar();
1848
+ }), this.on(this.imgInput, "change", () => {
1849
+ var s;
1850
+ const t = (s = this.imgInput.files) == null ? void 0 : s[0];
1851
+ if (!t) return;
1852
+ const e = this.phUploadTarget;
1853
+ if (this.phUploadTarget = null, e && this.ed.contains(e)) {
1854
+ this.readImageFileInto(t, e);
1855
+ return;
1856
+ }
1857
+ const i = new FileReader();
1858
+ i.onload = () => {
1859
+ this.restoreSel(), document.execCommand(
1860
+ "insertHTML",
1861
+ !1,
1862
+ `<img src="${i.result}" title="${t.name.replace(/"/g, "")}" alt="">`
1863
+ ), this.onChange();
1864
+ }, i.readAsDataURL(t);
1865
+ }), this.on(this.docInput, "change", () => {
1866
+ var e;
1867
+ const t = (e = this.docInput.files) == null ? void 0 : e[0];
1868
+ t && this.importWordFile(t).catch(() => alert(this.t("importfail")));
1869
+ }), this.onDoc("mousedown", (t) => {
1870
+ this.ed.contains(t.target) || t.target === this.tblCorner || this.tblColBars.includes(t.target) || this.tblCtx && this.tblCtx.contains(t.target) || this.imgHandles.includes(t.target) || this.imgCtx && this.imgCtx.contains(t.target) || this.phCtx && this.phCtx.contains(t.target) || this.selCtx && this.selCtx.contains(t.target) || this.openPop && this.openPop.contains(t.target) || this.openSubEl && this.openSubEl.contains(t.target) || (this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearSelToolbar());
1871
+ });
1872
+ }
1873
+ on(t, e, i) {
1874
+ t.addEventListener(e, i), this.listeners.push(() => t.removeEventListener(e, i));
1875
+ }
1876
+ onDoc(t, e) {
1877
+ document.addEventListener(t, e), this.listeners.push(() => document.removeEventListener(t, e));
1878
+ }
1879
+ onWin(t, e, i) {
1880
+ window.addEventListener(t, e, i), this.listeners.push(() => window.removeEventListener(t, e, i));
1881
+ }
1882
+ /* ---------------------------------------------------------- public API */
1883
+ getContent() {
1884
+ return this.ed.innerHTML;
1885
+ }
1886
+ setContent(t) {
1887
+ this.ed.innerHTML = t || "<p><br></p>", this.refreshState(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearSelToolbar(), this.onChange();
1888
+ }
1889
+ insertContent(t) {
1890
+ this.restoreSel(), document.execCommand("insertHTML", !1, t), this.saveSel(), this.refreshState(), this.onChange();
1891
+ }
1892
+ setLanguage(t) {
1893
+ this.lang = t, this.initUI();
1894
+ }
1895
+ focus() {
1896
+ this.ed.focus();
1897
+ }
1898
+ async importWordFile(t) {
1899
+ const e = await ai(t);
1900
+ this.recordRevision(), this.setContent(e), this.recordRevision();
1901
+ }
1902
+ restoreDraft() {
1903
+ let t = null;
1904
+ try {
1905
+ t = localStorage.getItem(this.draftStorageKey);
1906
+ } catch {
1907
+ }
1908
+ if (!t) return !1;
1909
+ try {
1910
+ const e = JSON.parse(t);
1911
+ return e.html ? (this.recordRevision(), this.setContent(e.html), !0) : !1;
1912
+ } catch {
1913
+ return !1;
1914
+ }
1915
+ }
1916
+ getRevisions() {
1917
+ return this.revisions.slice();
1918
+ }
1919
+ destroy() {
1920
+ this.isDestroyed || (this.isDestroyed = !0, this.revTimer != null && window.clearTimeout(this.revTimer), this.draftTimer != null && window.clearTimeout(this.draftTimer), this.closePop(), this.closeDlg(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearSelToolbar(), this.listeners.forEach((t) => t()), this.listeners = [], this.shell && this.shell.parentNode && this.shell.parentNode.removeChild(this.shell), this.imgInput && this.imgInput.parentNode && this.imgInput.parentNode.removeChild(this.imgInput), this.docInput && this.docInput.parentNode && this.docInput.parentNode.removeChild(this.docInput), this.contentStyleEl = null);
1921
+ }
1922
+ /* ---------------------------------------------------------- selection */
1923
+ saveSel() {
1924
+ const t = window.getSelection();
1925
+ t && t.rangeCount && this.ed.contains(t.anchorNode) && (this.savedRange = t.getRangeAt(0).cloneRange());
1926
+ }
1927
+ restoreSel() {
1928
+ if (!this.savedRange) {
1929
+ this.ed.focus();
1930
+ return;
1931
+ }
1932
+ this.ed.focus();
1933
+ const t = window.getSelection();
1934
+ t && (t.removeAllRanges(), t.addRange(this.savedRange));
1935
+ }
1936
+ exec(t, e) {
1937
+ this.restoreSel(), document.execCommand("styleWithCSS", !1, t !== "fontSize" ? "true" : "false"), document.execCommand(t, !1, e ?? void 0), this.saveSel(), this.refreshState(), this.onChange();
1938
+ }
1939
+ closestBlock(t) {
1940
+ for (; t && t !== this.ed; ) {
1941
+ if (t.nodeType === 1 && /^(P|DIV|H[1-6]|LI|PRE|BLOCKQUOTE|TD|TH)$/i.test(t.tagName))
1942
+ return t;
1943
+ t = t.parentNode;
1944
+ }
1945
+ return null;
1946
+ }
1947
+ selectedBlocks() {
1948
+ const t = window.getSelection();
1949
+ if (!t || !t.rangeCount || !this.ed.contains(t.anchorNode)) return [];
1950
+ const e = t.getRangeAt(0), i = Array.from(this.ed.querySelectorAll("p,h1,h2,h3,h4,h5,h6,li,pre,blockquote,td,th")).filter(
1951
+ (s) => e.intersectsNode(s)
1952
+ );
1953
+ if (!i.length) {
1954
+ const s = this.closestBlock(t.anchorNode);
1955
+ if (s) return [s];
1956
+ }
1957
+ return i;
1958
+ }
1959
+ onChange() {
1960
+ this.options.onChange(this.ed.innerHTML), this.scheduleRevision(), this.scheduleDraftSave();
1961
+ }
1962
+ /* ---------------------------------------------------------- revisions / drafts */
1963
+ recordRevision() {
1964
+ const t = this.ed.innerHTML, e = this.revisions[this.revisions.length - 1];
1965
+ e && e.html === t || (this.revisions.push({ time: Date.now(), html: t }), this.revisions.length > 30 && this.revisions.shift());
1966
+ }
1967
+ scheduleRevision() {
1968
+ this.revTimer != null && window.clearTimeout(this.revTimer), this.revTimer = window.setTimeout(() => {
1969
+ this.revTimer = null, this.recordRevision();
1970
+ }, 1500);
1971
+ }
1972
+ scheduleDraftSave() {
1973
+ this.draftTimer != null && window.clearTimeout(this.draftTimer), this.draftTimer = window.setTimeout(() => {
1974
+ this.draftTimer = null;
1975
+ try {
1976
+ localStorage.setItem(this.draftStorageKey, JSON.stringify({ time: Date.now(), html: this.ed.innerHTML }));
1977
+ } catch {
1978
+ }
1979
+ }, 800);
1980
+ }
1981
+ revisionDlg() {
1982
+ this.recordRevision(), this.dialog(this.t("revhistory"), (t) => {
1983
+ if (!this.revisions.length) {
1984
+ t.innerHTML = `<p style="color:#556">${this.t("revempty")}</p>`;
1985
+ return;
1986
+ }
1987
+ const e = document.createElement("div");
1988
+ e.className = "revwrap";
1989
+ const i = document.createElement("div");
1990
+ i.className = "revlist";
1991
+ const s = document.createElement("div");
1992
+ s.className = "revprev";
1993
+ const r = document.createElement("button");
1994
+ r.type = "button", r.className = "revrestore", r.textContent = this.t("restore");
1995
+ let l = this.revisions.length - 1;
1996
+ const o = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
1997
+ year: "numeric",
1998
+ month: "short",
1999
+ day: "numeric",
2000
+ hour: "2-digit",
2001
+ minute: "2-digit",
2002
+ second: "2-digit"
2003
+ }), a = {}, c = (d) => {
2004
+ l = d, this.revisions.forEach((u, v) => {
2005
+ var b;
2006
+ return (b = a[v]) == null ? void 0 : b.classList.toggle("on", v === d);
2007
+ }), s.innerHTML = this.revisions[d].html, r.disabled = d === this.revisions.length - 1;
2008
+ };
2009
+ for (let d = this.revisions.length - 1; d >= 0; d--) {
2010
+ const u = this.revisions[d], v = document.createElement("button");
2011
+ v.type = "button";
2012
+ const b = (new DOMParser().parseFromString(u.html, "text/html").body.textContent || "").trim(), f = b ? b.split(/\s+/).length : 0, w = d === this.revisions.length - 1;
2013
+ v.innerHTML = `<span>${w ? this.t("currentver") : o.format(new Date(u.time))}</span><span class="wc">${f} ${this.t("words")}</span>`, v.addEventListener("click", () => c(d)), a[d] = v, i.appendChild(v);
2014
+ }
2015
+ i.append(r), r.addEventListener("click", () => {
2016
+ const d = this.revisions[l];
2017
+ d && (this.recordRevision(), this.setContent(d.html), this.recordRevision(), this.closeDlg());
2018
+ }), e.append(i, s), t.appendChild(e), c(l);
2019
+ });
2020
+ }
2021
+ /* ---------------------------------------------------------- popups / menus */
2022
+ closeSub() {
2023
+ var t;
2024
+ (t = this.openSubEl) == null || t.remove(), this.openSubEl = null;
2025
+ }
2026
+ closePop() {
2027
+ var t;
2028
+ this.closeSub(), this.openPop && (this.openPop.remove(), this.openPop = null, (t = this.popAnchor) == null || t.classList.remove("open"), this.popAnchor = null, this.setOpTarget(null));
2029
+ }
2030
+ openSubFor(t, e) {
2031
+ this.closeSub();
2032
+ const i = document.createElement("div");
2033
+ i.className = "pop sub", i.dir = this.dir(), t.subBuild ? t.subBuild(i) : t.sub && this.menuItems(i, t.sub), i.addEventListener("mousedown", (a) => {
2034
+ a.target.tagName !== "INPUT" && a.preventDefault();
2035
+ }), document.body.appendChild(i);
2036
+ const s = e.getBoundingClientRect();
2037
+ let l = this.dir() === "rtl" ? s.left - i.offsetWidth + 2 : s.right - 2;
2038
+ l = Math.max(8, Math.min(l + scrollX, scrollX + innerWidth - i.offsetWidth - 8));
2039
+ let o = s.top + scrollY - 6;
2040
+ o = Math.max(8 + scrollY, Math.min(o, scrollY + innerHeight - i.offsetHeight - 8)), i.style.left = l + "px", i.style.top = o + "px", this.openSubEl = i;
2041
+ }
2042
+ popup(t, e) {
2043
+ if (this.openPop && this.popAnchor === t) {
2044
+ this.closePop();
2045
+ return;
2046
+ }
2047
+ this.closePop();
2048
+ const i = document.createElement("div");
2049
+ i.className = "pop", i.dir = this.dir(), e(i), document.body.appendChild(i);
2050
+ const s = t.getBoundingClientRect();
2051
+ i.style.minWidth = Math.max(160, Math.round(s.width)) + "px", i.style.top = s.bottom + scrollY + 2 + "px";
2052
+ let l = this.dir() === "rtl" ? s.right - i.offsetWidth : s.left;
2053
+ l = Math.max(8, Math.min(l + scrollX, scrollX + innerWidth - i.offsetWidth - 8)), i.style.left = l + "px", i.addEventListener("mousedown", (o) => {
2054
+ o.target.tagName !== "INPUT" && o.preventDefault();
2055
+ }), this.openPop = i, this.popAnchor = t, t.classList.add("open");
2056
+ }
2057
+ menuItems(t, e) {
2058
+ e.forEach((i) => {
2059
+ if (i === "|") {
2060
+ t.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
2061
+ return;
2062
+ }
2063
+ const s = !!(i.sub || i.subBuild), r = document.createElement("button");
2064
+ r.className = "mi" + (i.on ? " on" : ""), r.innerHTML = `<span class="ic">${i.icon || ""}</span><span class="prev" ${i.previewStyle ? `style="${i.previewStyle}"` : ""}>${i.label}</span>${i.shortcut ? `<span class="sc">${i.shortcut}</span>` : ""}${s ? `<span class="subarrow">${h.chev}</span>` : ""}`, r.addEventListener("click", () => {
2065
+ i.action && (this.closePop(), i.action());
2066
+ }), r.addEventListener("mouseenter", () => {
2067
+ var l;
2068
+ s ? this.openSubFor(i, r) : this.openSubEl && t !== this.openSubEl && this.closeSub(), (l = i.hover) == null || l.call(i, !0);
2069
+ }), r.addEventListener("mouseleave", () => {
2070
+ var l;
2071
+ return (l = i.hover) == null ? void 0 : l.call(i, !1);
2072
+ }), t.appendChild(r);
2073
+ });
2074
+ }
2075
+ /* ---------------------------------------------------------- toolbar builders */
2076
+ tbtn(t, e, i, s) {
2077
+ const r = document.createElement("button");
2078
+ return r.className = "tbtn", r.type = "button", r.title = e, r.innerHTML = t, s && (r.dataset.id = s), r.addEventListener("mousedown", (l) => l.preventDefault()), r.addEventListener("click", i), r;
2079
+ }
2080
+ /** Font-size increase / decrease step button. */
2081
+ stepBtn(t) {
2082
+ const e = t > 0 ? "+" : "−", i = t > 0 ? h.fontsizeup : h.fontsizedown, s = this.tbtn(i, this.t("fontsize") + " " + e, () => this.stepFontSize(t));
2083
+ return s.addEventListener("mousedown", () => this.saveSel()), s;
2084
+ }
2085
+ /** Toolbar icon button that opens a popup menu anchored to itself. */
2086
+ menuTbtn(t, e, i, s) {
2087
+ const r = this.tbtn(t, e, () => i(r), s);
2088
+ return r.classList.add("hasmenu"), r.insertAdjacentHTML("beforeend", h.chev), r.addEventListener("mousedown", () => this.saveSel()), r;
2089
+ }
2090
+ /** Quick text-color chips plus a "more" chip that opens the full palette. */
2091
+ colorChips() {
2092
+ const t = (s) => {
2093
+ const r = document.createElement("button");
2094
+ return r.type = "button", r.className = "cchip", r.title = s, r.addEventListener("mousedown", (l) => {
2095
+ l.preventDefault(), this.saveSel();
2096
+ }), r;
2097
+ }, e = je.map((s) => {
2098
+ const r = t(this.t("forecolor"));
2099
+ return r.style.background = s, r.addEventListener("click", () => this.applyColor("fore", s)), r;
2100
+ }), i = t(this.t("forecolor"));
2101
+ return i.classList.add("more"), i.dataset.cb = "fore", i.innerHTML = h.chev, i.addEventListener("click", () => this.colorMenu(i, "fore")), [...e, i];
2102
+ }
2103
+ group(...t) {
2104
+ const e = document.createElement("div");
2105
+ return e.className = "tgrp", t.forEach((i) => {
2106
+ i.classList.add("gbtn"), e.appendChild(i);
2107
+ }), e;
2108
+ }
2109
+ tsel(t, e, i, s) {
2110
+ const r = document.createElement("button");
2111
+ return r.className = "tsel " + t, r.type = "button", r.dataset.id = e, r.innerHTML = `<span class="lbl empty">${i || ""}</span>${h.chev}`, r.addEventListener("mousedown", (l) => {
2112
+ l.preventDefault(), this.saveSel();
2113
+ }), r.addEventListener("click", () => s(r)), r;
2114
+ }
2115
+ setListStyle(t, e) {
2116
+ var r, l;
2117
+ this.restoreSel();
2118
+ const i = window.getSelection();
2119
+ if (!i) return;
2120
+ let s = (r = this.closestBlock(i.anchorNode)) == null ? void 0 : r.closest(t);
2121
+ 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();
2122
+ }
2123
+ listMenu(t, e) {
2124
+ var c;
2125
+ const i = e === "ol" ? "insertOrderedList" : "insertUnorderedList", s = e === "ol" ? [
2126
+ ["lower-alpha", h.ol_alpha],
2127
+ ["lower-roman", h.ol_roman],
2128
+ ["upper-alpha", h.ol_alphau],
2129
+ ["upper-roman", h.ol_romanu]
2130
+ ] : [
2131
+ ["circle", h.ul_circle],
2132
+ ["square", h.ul_square]
2133
+ ], r = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), l = window.getSelection(), o = l ? (c = this.closestBlock(l.anchorNode)) == null ? void 0 : c.closest(e) : null, a = o ? o.style.listStyleType : "";
2134
+ this.popup(t, (d) => {
2135
+ this.menuItems(d, [
2136
+ {
2137
+ label: this.t(e === "ol" ? "numlist" : "bullist"),
2138
+ icon: e === "ol" ? h.numlist : h.bullist,
2139
+ on: document.queryCommandState(i),
2140
+ action: () => this.exec(i)
2141
+ }
2142
+ ]), d.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
2143
+ const u = document.createElement("div");
2144
+ u.className = "mi-grid", s.forEach(([v, b], f) => {
2145
+ const w = document.createElement("button");
2146
+ w.className = "mi" + (a === v ? " on" : ""), w.innerHTML = `<span class="ic">${b}</span><span class="prev">${r[f]}</span>`, w.addEventListener("click", () => {
2147
+ this.closePop(), this.setListStyle(e, v);
2148
+ }), u.appendChild(w);
2149
+ }), d.appendChild(u);
2150
+ });
2151
+ }
2152
+ colorMenu(t, e) {
2153
+ this.popup(t, (i) => {
2154
+ const s = document.createElement("div");
2155
+ s.className = "cpal", ze.forEach((u) => {
2156
+ const v = document.createElement("button");
2157
+ v.style.background = u, v.title = u, v.addEventListener("click", () => {
2158
+ this.closePop(), this.applyColor(e, u);
2159
+ }), s.appendChild(v);
2160
+ }), i.appendChild(s), i.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
2161
+ const r = document.createElement("div");
2162
+ r.className = "cfoot";
2163
+ const l = document.createElement("div");
2164
+ l.className = "cswatch cur", l.title = this.t("currentcolor");
2165
+ const o = e === "fore" ? this.foreColor : this.backColor;
2166
+ l.style.background = /^#[0-9a-f]{6}$/i.test(o) ? o : "#000000", l.innerHTML = h.check;
2167
+ const a = document.createElement("button");
2168
+ a.type = "button", a.className = "cswatch nocolor", a.title = this.t("removecolor"), a.addEventListener("click", () => {
2169
+ this.closePop(), this.applyColor(e, null);
2170
+ });
2171
+ const c = document.createElement("label");
2172
+ c.className = "cswatch cwheel", c.title = this.t("customcolor"), c.innerHTML = h.palette;
2173
+ const d = document.createElement("input");
2174
+ d.type = "color", d.value = /^#[0-9a-f]{6}$/i.test(o) ? o : "#000000", d.addEventListener("change", () => {
2175
+ this.closePop(), this.applyColor(e, d.value);
2176
+ }), c.appendChild(d), r.append(l, a, c), i.appendChild(r);
2177
+ });
2178
+ }
2179
+ applyColor(t, e) {
2180
+ t === "fore" ? (this.foreColor = e || "#000000", this.exec("foreColor", e || "#000000")) : (this.backColor = e || "transparent", this.exec("hiliteColor", e || "transparent")), this.syncColorSwatches(this.toolbar), this.selCtx && this.syncColorSwatches(this.selCtx);
2181
+ }
2182
+ syncColorSwatches(t) {
2183
+ t.querySelectorAll("[data-cb=fore]").forEach((e) => e.style.background = this.foreColor), t.querySelectorAll("[data-cb=back]").forEach((e) => e.style.background = this.backColor);
2184
+ }
2185
+ fontMenu(t) {
2186
+ this.popup(t, (e) => {
2187
+ this.menuItems(
2188
+ e,
2189
+ this.options.fontFamilyFormats.map(([i, s]) => ({
2190
+ label: i,
2191
+ previewStyle: `font-family:${s}`,
2192
+ on: this.currentFont() === i,
2193
+ action: () => this.exec("fontName", s)
2194
+ }))
2195
+ );
2196
+ });
2197
+ }
2198
+ sizeMenu(t) {
2199
+ this.popup(t, (e) => {
2200
+ this.menuItems(
2201
+ e,
2202
+ Oe.map((i) => ({
2203
+ label: i,
2204
+ on: this.currentSize() === i,
2205
+ action: () => this.applyFontSize(i)
2206
+ }))
2207
+ );
2208
+ });
2209
+ }
2210
+ /** Font sizing needs a non-collapsed range. With a bare caret, grow the
2211
+ selection to the word under it; in an empty spot, select a zero-width
2212
+ space so the new size applies to what gets typed next. */
2213
+ ensureSizeTarget() {
2214
+ const t = window.getSelection();
2215
+ if (!t) return;
2216
+ if (!t.rangeCount) {
2217
+ const l = document.createRange();
2218
+ l.selectNodeContents(this.ed), l.collapse(!0), t.addRange(l);
2219
+ }
2220
+ if (!t.isCollapsed) return;
2221
+ const e = t.getRangeAt(0), i = e.startContainer;
2222
+ if (i.nodeType === 3) {
2223
+ const l = i.data;
2224
+ let o = e.startOffset, a = e.startOffset;
2225
+ for (; o > 0 && /\S/.test(l[o - 1]); ) o--;
2226
+ for (; a < l.length && /\S/.test(l[a]); ) a++;
2227
+ if (a > o) {
2228
+ const c = document.createRange();
2229
+ c.setStart(i, o), c.setEnd(i, a), t.removeAllRanges(), t.addRange(c), this.savedRange = c.cloneRange();
2230
+ return;
2231
+ }
2232
+ }
2233
+ const s = document.createTextNode("​");
2234
+ e.insertNode(s);
2235
+ const r = document.createRange();
2236
+ r.setStart(s, 0), r.setEnd(s, 1), t.removeAllRanges(), t.addRange(r), this.savedRange = r.cloneRange();
2237
+ }
2238
+ applyFontSize(t) {
2239
+ this.restoreSel(), this.ensureSizeTarget(), document.execCommand("styleWithCSS", !1, "false"), document.execCommand("fontSize", !1, "7");
2240
+ const e = [];
2241
+ if (this.ed.querySelectorAll('font[size="7"]').forEach((i) => {
2242
+ const s = document.createElement("span");
2243
+ for (s.style.fontSize = t; i.firstChild; ) s.appendChild(i.firstChild);
2244
+ i.replaceWith(s), e.push(s);
2245
+ }), e.length) {
2246
+ const i = document.createRange();
2247
+ i.setStart(e[0], 0), i.setEnd(e[e.length - 1], e[e.length - 1].childNodes.length);
2248
+ const s = window.getSelection();
2249
+ s && (s.removeAllRanges(), s.addRange(i));
2250
+ }
2251
+ this.saveSel(), this.refreshState(), this.onChange();
2252
+ }
2253
+ stepFontSize(t) {
2254
+ const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(Fe, Math.max(Be, e + t));
2255
+ i !== e && this.applyFontSize(i + "px");
2256
+ }
2257
+ /* ------------------------------------------------ case / spacing / link */
2258
+ transformCase(t) {
2259
+ this.restoreSel();
2260
+ const e = window.getSelection();
2261
+ if (!e || !e.rangeCount || e.isCollapsed) return;
2262
+ const i = e.getRangeAt(0), s = document.createTreeWalker(this.ed, NodeFilter.SHOW_TEXT), r = [];
2263
+ let l;
2264
+ for (; l = s.nextNode(); ) i.intersectsNode(l) && r.push(l);
2265
+ r.forEach((o) => {
2266
+ const a = o === i.startContainer ? i.startOffset : 0, c = o === i.endContainer ? i.endOffset : o.data.length;
2267
+ if (c <= a) return;
2268
+ const d = o.data.slice(a, c);
2269
+ let u = d;
2270
+ t === "lower" ? u = d.toLowerCase() : t === "upper" ? u = d.toUpperCase() : u = d.replace(/(^|\s)(\S)/g, (v, b, f) => b + f.toUpperCase()), o.replaceData(a, c - a, u);
2271
+ }), this.saveSel(), this.refreshState(), this.onChange();
2272
+ }
2273
+ caseMenu(t) {
2274
+ this.popup(t, (e) => {
2275
+ this.menuItems(e, [
2276
+ { label: this.t("lowercase"), icon: h.lowercaseic, action: () => this.transformCase("lower") },
2277
+ { label: this.t("uppercase"), icon: h.uppercaseic, action: () => this.transformCase("upper") },
2278
+ { label: this.t("capitalize"), icon: h.capitalizeic, action: () => this.transformCase("capitalize") }
2279
+ ]);
2280
+ });
2281
+ }
2282
+ applyBlockStyle(t, e) {
2283
+ this.restoreSel(), this.selectedBlocks().forEach((s) => {
2284
+ e ? s.style[t] = e : s.style.removeProperty(t === "lineHeight" ? "line-height" : "word-spacing");
2285
+ }), this.saveSel(), this.onChange();
2286
+ }
2287
+ currentBlockStyle(t) {
2288
+ const e = window.getSelection(), i = e ? this.closestBlock(e.anchorNode) : null;
2289
+ return i && i.style[t] || "";
2290
+ }
2291
+ lineHeightMenu(t) {
2292
+ const e = this.currentBlockStyle("lineHeight");
2293
+ this.popup(t, (i) => {
2294
+ this.menuItems(i, [
2295
+ { label: this.t("normal"), on: !e, action: () => this.applyBlockStyle("lineHeight", "") },
2296
+ ..._e.map((s) => ({
2297
+ label: s,
2298
+ on: e === s,
2299
+ action: () => this.applyBlockStyle("lineHeight", s)
2300
+ }))
2301
+ ]);
2302
+ });
2303
+ }
2304
+ wordSpacingMenu(t) {
2305
+ const e = this.currentBlockStyle("wordSpacing");
2306
+ this.popup(t, (i) => {
2307
+ this.menuItems(i, [
2308
+ { label: this.t("normal"), on: !e, action: () => this.applyBlockStyle("wordSpacing", "") },
2309
+ ...$e.map((s) => ({
2310
+ label: s,
2311
+ on: e === s,
2312
+ action: () => this.applyBlockStyle("wordSpacing", s)
2313
+ }))
2314
+ ]);
2315
+ });
2316
+ }
2317
+ closestAnchor() {
2318
+ const t = window.getSelection();
2319
+ let e = t && this.ed.contains(t.anchorNode) ? t.anchorNode : null;
2320
+ for (; e && e !== this.ed; ) {
2321
+ if (e.nodeType === 1 && e.tagName === "A") return e;
2322
+ e = e.parentNode;
2323
+ }
2324
+ return null;
2325
+ }
2326
+ linkDlg() {
2327
+ this.saveSel();
2328
+ const t = this.closestAnchor();
2329
+ let e;
2330
+ const i = [];
2331
+ t && i.push({
2332
+ label: this.t("unlink"),
2333
+ action: () => {
2334
+ const s = document.createRange();
2335
+ s.selectNodeContents(t);
2336
+ const r = window.getSelection();
2337
+ r && (r.removeAllRanges(), r.addRange(s)), document.execCommand("unlink"), this.closeDlg(), this.onChange();
2338
+ }
2339
+ }), i.push(
2340
+ { label: this.t("cancel"), action: () => this.closeDlg() },
2341
+ {
2342
+ label: this.t("save"),
2343
+ primary: !0,
2344
+ action: () => {
2345
+ const s = e.value.trim();
2346
+ if (this.closeDlg(), !s) return;
2347
+ if (t) {
2348
+ t.setAttribute("href", s), this.onChange();
2349
+ return;
2350
+ }
2351
+ this.restoreSel();
2352
+ const r = window.getSelection();
2353
+ !r || r.isCollapsed ? document.execCommand("insertHTML", !1, `<a href="${s.replace(/"/g, "&quot;")}">${s.replace(/&/g, "&amp;").replace(/</g, "&lt;")}</a>`) : (document.execCommand("styleWithCSS", !1, "false"), document.execCommand("createLink", !1, s)), this.saveSel(), this.onChange();
2354
+ }
2355
+ }
2356
+ ), this.dialog(
2357
+ this.t("linkttl"),
2358
+ (s) => {
2359
+ const r = document.createElement("div");
2360
+ r.style.cssText = "display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";
2361
+ const l = document.createElement("span");
2362
+ l.style.cssText = "width:60px;color:#556;flex:none", l.textContent = this.t("linkurl"), e = document.createElement("input"), e.type = "url", e.placeholder = "https://", e.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", e.value = (t == null ? void 0 : t.getAttribute("href")) || "", r.append(l, e), s.appendChild(r), setTimeout(() => e.focus(), 0);
2363
+ },
2364
+ i
2365
+ );
2366
+ }
2367
+ blocksMenu(t) {
2368
+ this.popup(t, (e) => {
2369
+ this.menuItems(
2370
+ e,
2371
+ Ut.map(([i, s]) => ({
2372
+ label: this.blockLabel(i),
2373
+ previewStyle: i.startsWith("h") ? `font-weight:700;font-size:${22 - 2 * +i[1]}px` : i === "pre" ? "font-family:monospace" : "",
2374
+ on: this.currentBlock() === i,
2375
+ action: () => this.exec("formatBlock", "<" + i + ">")
2376
+ }))
2377
+ );
2378
+ });
2379
+ }
2380
+ blockLabel(t) {
2381
+ return t === "p" ? this.t("para") : t === "pre" ? this.t("pre") : this.t("heading") + " " + t[1];
2382
+ }
2383
+ tableGrid(t, e) {
2384
+ this.popup(t, (i) => this.buildTableGridInto(i, e));
2385
+ }
2386
+ buildTableGridInto(t, e) {
2387
+ {
2388
+ const i = document.createElement("div");
2389
+ i.className = "tgridwrap";
2390
+ const s = document.createElement("div");
2391
+ s.className = "tgrid";
2392
+ const r = document.createElement("div");
2393
+ r.className = "tgridlbl", r.textContent = "1 × 1";
2394
+ const l = [];
2395
+ for (let o = 0; o < 8; o++)
2396
+ for (let a = 0; a < 10; a++) {
2397
+ const c = document.createElement("span");
2398
+ c.dataset.r = String(o), c.dataset.c = String(a), c.addEventListener("mouseenter", () => {
2399
+ l.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= o && +d.dataset.c <= a)), r.textContent = a + 1 + " × " + (o + 1);
2400
+ }), c.addEventListener("click", () => {
2401
+ this.closePop(), this.insertTable(o + 1, a + 1), e == null || e();
2402
+ }), l.push(c), s.appendChild(c);
2403
+ }
2404
+ i.append(s, r), t.appendChild(i);
2405
+ }
2406
+ }
2407
+ insertTable(t, e) {
2408
+ this.restoreSel();
2409
+ let i = '<table style="border-collapse:collapse;width:100%;table-layout:fixed"><tbody>';
2410
+ for (let s = 0; s < t; s++) {
2411
+ i += "<tr>";
2412
+ for (let r = 0; r < e; r++) i += '<td style="border:1px solid #b9c2cc"><br></td>';
2413
+ i += "</tr>";
2414
+ }
2415
+ i += "</tbody></table><p><br></p>", document.execCommand("insertHTML", !1, i), this.saveSel(), this.onChange();
2416
+ }
2417
+ setDir(t) {
2418
+ this.restoreSel();
2419
+ const e = this.selectedBlocks();
2420
+ e.length ? e.forEach((i) => i.setAttribute("dir", t)) : this.ed.setAttribute("dir", t), this.saveSel(), this.refreshState(), this.onChange();
2421
+ }
2422
+ /** Splits a toolbar layout string into groups of item names: `|` separates visual
2423
+ * groups, whitespace separates items within a group. Empty groups/tokens (e.g. from
2424
+ * leading/trailing/doubled separators) are dropped. Pure function. */
2425
+ parseToolbarString(t) {
2426
+ return t.split("|").map((e) => e.trim().split(/\s+/).filter(Boolean)).filter((e) => e.length > 0);
2427
+ }
2428
+ /** Maps every supported toolbar item name to a builder for that one control. Each
2429
+ * entry is a direct lift of what used to be an inline call in `buildToolbar()` — no
2430
+ * behavior changes, just named lookup. Only `forecolor` yields multiple elements
2431
+ * (the quick color chips); everything else yields one. */
2432
+ buildToolbarRegistry() {
2433
+ const t = this.tbtn(h.tableic, this.t("quicktable"), () => this.tableGrid(t));
2434
+ return {
2435
+ undo: () => this.tbtn(h.undo, this.t("undo"), () => this.exec("undo")),
2436
+ redo: () => this.tbtn(h.redo, this.t("redo"), () => this.exec("redo")),
2437
+ preview: () => this.tbtn(h.prevw, this.t("preview"), () => this.previewDlg()),
2438
+ print: () => this.tbtn(h.printic, this.t("print"), () => this.printDoc()),
2439
+ importword: () => this.tbtn(h.wordic, this.t("importword"), () => this.pickWordDoc()),
2440
+ revhistory: () => this.tbtn(h.historyic, this.t("revhistory"), () => this.revisionDlg()),
2441
+ fontfamily: () => this.tsel("w-font", "fontsel", "", (e) => this.fontMenu(e)),
2442
+ fontsize: () => this.tsel("w-size", "sizesel", "", (e) => this.sizeMenu(e)),
2443
+ fontsizeincrease: () => this.stepBtn(1),
2444
+ fontsizedecrease: () => this.stepBtn(-1),
2445
+ bold: () => this.tbtn(h.bold, this.t("bold"), () => this.exec("bold"), "bold"),
2446
+ italic: () => this.tbtn(h.italic, this.t("italic"), () => this.exec("italic"), "italic"),
2447
+ underline: () => this.tbtn(h.underline, this.t("underline"), () => this.exec("underline"), "underline"),
2448
+ strikethrough: () => this.tbtn(h.strikethrough, this.t("strikethrough"), () => this.exec("strikeThrough"), "strikeThrough"),
2449
+ forecolor: () => this.colorChips(),
2450
+ backcolor: () => this.menuTbtn(
2451
+ h.backcolor + '<span class="colorbar" data-cb="back"></span>',
2452
+ this.t("backcolor"),
2453
+ (e) => this.colorMenu(e, "back")
2454
+ ),
2455
+ alignleft: () => this.tbtn(h.alignleft, this.t("alignleft"), () => this.exec("justifyLeft"), "justifyLeft"),
2456
+ aligncenter: () => this.tbtn(h.aligncenter, this.t("aligncenter"), () => this.exec("justifyCenter"), "justifyCenter"),
2457
+ alignright: () => this.tbtn(h.alignright, this.t("alignright"), () => this.exec("justifyRight"), "justifyRight"),
2458
+ alignjustify: () => this.tbtn(h.alignjustify, this.t("alignjustify"), () => this.exec("justifyFull"), "justifyFull"),
2459
+ bullist: () => this.menuTbtn(h.bullist, this.t("bullist"), (e) => this.listMenu(e, "ul"), "insertUnorderedList"),
2460
+ numlist: () => this.menuTbtn(h.numlist, this.t("numlist"), (e) => this.listMenu(e, "ol"), "insertOrderedList"),
2461
+ outdent: () => this.tbtn(h.outdent, this.t("outdent"), () => this.exec("outdent")),
2462
+ indent: () => this.tbtn(h.indent, this.t("indent"), () => this.exec("indent")),
2463
+ link: () => this.tbtn(h.link, this.t("linkttl"), () => this.linkDlg()),
2464
+ blockquote: () => this.tbtn(h.quote, this.t("quote"), () => this.toggleBlock("blockquote"), "blockquote"),
2465
+ changecase: () => this.menuTbtn(h.caseic, this.t("changecase"), (e) => this.caseMenu(e)),
2466
+ lineheight: () => this.menuTbtn(h.lineheight, this.t("lineheight"), (e) => this.lineHeightMenu(e)),
2467
+ wordspacing: () => this.menuTbtn(h.wordspacing, this.t("wordspacing"), (e) => this.wordSpacingMenu(e)),
2468
+ removeformat: () => this.tbtn(h.clearformatic, this.t("removeformat"), () => this.exec("removeFormat")),
2469
+ blocks: () => this.tsel("w-block", "blocksel", this.t("para"), (e) => this.blocksMenu(e)),
2470
+ ltr: () => this.tbtn(h.ltr, this.t("ltr"), () => this.setDir("ltr"), "ltr"),
2471
+ rtl: () => this.tbtn(h.rtl, this.t("rtl"), () => this.setDir("rtl"), "rtl"),
2472
+ quickimage: () => this.tbtn(h.image, this.t("quickimage"), () => this.insertImagePlaceholder()),
2473
+ quicktable: () => t,
2474
+ charmap: () => this.tbtn(h.charic, this.t("charmap"), () => this.charMap()),
2475
+ fullscreen: () => this.tbtn(h.fullscreen, this.t("fullscreen"), () => this.toggleFullscreen(), "fullscreen"),
2476
+ sourcecode: () => this.tbtn(h.srcic, this.t("sourcecode"), () => this.sourceDlg())
2477
+ };
2478
+ }
2479
+ buildToolbar() {
2480
+ this.toolbar.innerHTML = "";
2481
+ const t = this.options.toolbar === !0 ? De : this.options.toolbar, e = this.buildToolbarRegistry();
2482
+ this.parseToolbarString(t).forEach((i) => {
2483
+ const s = [];
2484
+ i.forEach((r) => {
2485
+ const l = e[r];
2486
+ if (!l) {
2487
+ console.warn(`FableEditor: unknown toolbar item "${r}"`);
2488
+ return;
2489
+ }
2490
+ const o = l();
2491
+ Array.isArray(o) ? s.push(...o) : s.push(o);
2492
+ }), s.length && this.toolbar.appendChild(this.group(...s));
2493
+ }), this.syncColorSwatches(this.toolbar);
2494
+ }
2495
+ /* ---------------------------------------------------------- menubar */
2496
+ mItem(t, e, i, s) {
2497
+ return { label: this.t(t), icon: e, action: i, shortcut: s };
2498
+ }
2499
+ buildMenubar() {
2500
+ this.menubar.innerHTML = "";
2501
+ const t = {
2502
+ file: [
2503
+ this.mItem("newdoc", h.newic, () => {
2504
+ this.recordRevision(), this.ed.innerHTML = "<p><br></p>", this.onChange();
2505
+ }),
2506
+ "|",
2507
+ this.mItem("importword", h.wordic, () => this.pickWordDoc()),
2508
+ this.mItem("restoredraft", h.draftic, () => {
2509
+ this.restoreDraft() || alert(this.t("draftempty"));
2510
+ }),
2511
+ this.mItem("revhistory", h.historyic, () => this.revisionDlg()),
2512
+ "|",
2513
+ this.mItem("preview", h.prevw, () => this.previewDlg()),
2514
+ this.mItem("print", h.printic, () => this.printDoc(), "Ctrl+P")
2515
+ ],
2516
+ edit: [
2517
+ this.mItem("undo", h.undo, () => this.exec("undo"), "Ctrl+Z"),
2518
+ this.mItem("redo", h.redo, () => this.exec("redo"), "Ctrl+Y"),
2519
+ "|",
2520
+ this.mItem("cut", h.cutic, () => this.exec("cut"), "Ctrl+X"),
2521
+ this.mItem("copy", h.copyic, () => this.exec("copy"), "Ctrl+C"),
2522
+ this.mItem("paste", h.pasteic, () => alert(this.t("pastehint")), "Ctrl+V"),
2523
+ "|",
2524
+ this.mItem("selectall", h.selall, () => this.exec("selectAll"), "Ctrl+A")
2525
+ ],
2526
+ view: [
2527
+ this.mItem("fullscreen", h.fullscreen, () => this.toggleFullscreen()),
2528
+ this.mItem("preview", h.prevw, () => this.previewDlg()),
2529
+ this.mItem("sourcecode", h.srcic, () => this.sourceDlg())
2530
+ ],
2531
+ insert: [
2532
+ this.mItem("link", h.link, () => this.linkDlg()),
2533
+ this.mItem("image", h.image, () => this.insertImagePlaceholder()),
2534
+ { label: this.t("inserttable"), icon: h.tableic, action: () => this.tableGrid(this.menubar.querySelector('[data-menu-key="table"]') || this.menubar) },
2535
+ this.mItem("hr", h.hric, () => this.exec("insertHorizontalRule")),
2536
+ "|",
2537
+ this.mItem("charmap", h.charic, () => this.charMap()),
2538
+ this.mItem(
2539
+ "datetime",
2540
+ h.dateic,
2541
+ () => this.exec("insertText", (/* @__PURE__ */ new Date()).toLocaleString(this.lang === "ar" ? "ar-AE" : "en-GB"))
2542
+ ),
2543
+ "|",
2544
+ {
2545
+ label: this.t("pagebreak"),
2546
+ icon: h.pbic,
2547
+ action: () => {
2548
+ this.restoreSel(), document.execCommand("insertHTML", !1, '<hr class="pagebreak"><p><br></p>'), this.onChange();
2549
+ }
2550
+ },
2551
+ this.mItem("nbsp", h.nbspic, () => this.exec("insertText", " "))
2552
+ ],
2553
+ format: [
2554
+ this.mItem("bold", h.bold, () => this.exec("bold"), "Ctrl+B"),
2555
+ this.mItem("italic", h.italic, () => this.exec("italic"), "Ctrl+I"),
2556
+ this.mItem("underline", h.underline, () => this.exec("underline"), "Ctrl+U"),
2557
+ this.mItem("strikethrough", h.strikethrough, () => this.exec("strikeThrough")),
2558
+ this.mItem("superscript", h.superscriptic, () => this.exec("superscript")),
2559
+ this.mItem("subscript", h.subscriptic, () => this.exec("subscript")),
2560
+ "|",
2561
+ this.mItem("lowercase", h.lowercaseic, () => this.transformCase("lower")),
2562
+ this.mItem("uppercase", h.uppercaseic, () => this.transformCase("upper")),
2563
+ this.mItem("capitalize", h.capitalizeic, () => this.transformCase("capitalize")),
2564
+ "|",
2565
+ this.mItem("clearformat", h.clearformatic, () => this.exec("removeFormat"))
2566
+ ],
2567
+ tools: [this.mItem("sourcecode", h.srcic, () => this.sourceDlg()), this.mItem("wordcount", h.wcic, () => this.wordCountDlg())],
2568
+ table: [
2569
+ { label: this.t("inserttable"), icon: h.tableic, subBuild: (s) => this.buildTableGridInto(s) },
2570
+ "|",
2571
+ {
2572
+ label: this.t("cell"),
2573
+ sub: [{ label: this.t("cellprops"), icon: h.tableic, action: () => this.cellPropsDlg() }]
2574
+ },
2575
+ {
2576
+ label: this.t("row"),
2577
+ sub: [
2578
+ { label: this.t("rowabove"), icon: h.rowbefore, action: () => this.tableOp("rowabove"), hover: (s) => this.setOpTarget(s ? "row" : null) },
2579
+ { label: this.t("rowbelow"), icon: h.rowafter, action: () => this.tableOp("rowbelow"), hover: (s) => this.setOpTarget(s ? "row" : null) },
2580
+ { label: this.t("delrow"), icon: h.rowdelete, action: () => this.tableOp("delrow"), hover: (s) => this.setOpTarget(s ? "row" : null) },
2581
+ "|",
2582
+ { label: this.t("rowprops"), icon: h.tableic, action: () => this.rowPropsDlg(), hover: (s) => this.setOpTarget(s ? "row" : null) }
2583
+ ]
2584
+ },
2585
+ {
2586
+ label: this.t("column"),
2587
+ sub: [
2588
+ { label: this.t("colbefore"), icon: h.colbefore, action: () => this.tableOp("colbefore"), hover: (s) => this.setOpTarget(s ? "col" : null) },
2589
+ { label: this.t("colafter"), icon: h.colafter, action: () => this.tableOp("colafter"), hover: (s) => this.setOpTarget(s ? "col" : null) },
2590
+ { label: this.t("delcol"), icon: h.coldelete, action: () => this.tableOp("delcol"), hover: (s) => this.setOpTarget(s ? "col" : null) },
2591
+ "|",
2592
+ { label: this.t("colprops"), icon: h.tableic, action: () => this.colPropsDlg(), hover: (s) => this.setOpTarget(s ? "col" : null) }
2593
+ ]
2594
+ },
2595
+ "|",
2596
+ {
2597
+ label: this.t("tablepropsttl"),
2598
+ icon: h.tableic,
2599
+ action: () => {
2600
+ const s = this.currentCell();
2601
+ if (!s) {
2602
+ alert(this.t("nocell"));
2603
+ return;
2604
+ }
2605
+ this.tblActive = s.closest("table"), this.tablePropsDlg();
2606
+ }
2607
+ },
2608
+ { label: this.t("deltable"), icon: h.tabledelete, action: () => this.tableOp("deltable") }
2609
+ ],
2610
+ help: [this.mItem("helpttl", h.helpic, () => this.helpDlg(), "Alt+0")]
2611
+ }, e = this.options.menubar === !0 ? Pe : this.options.menubar, i = /* @__PURE__ */ new Set();
2612
+ e.split(/\s+/).filter(Boolean).forEach((s) => {
2613
+ if (i.has(s)) return;
2614
+ if (i.add(s), !t[s]) {
2615
+ console.warn(`FableEditor: unknown menubar item "${s}"`);
2616
+ return;
2617
+ }
2618
+ const r = document.createElement("button");
2619
+ r.type = "button", r.textContent = this.t(s), r.dataset.menuKey = s, r.addEventListener("mousedown", (l) => {
2620
+ l.preventDefault(), this.saveSel();
2621
+ }), r.addEventListener("click", () => this.popup(r, (l) => this.menuItems(l, t[s]))), this.menubar.appendChild(r);
2622
+ });
2623
+ }
2624
+ /* ---------------------------------------------------------- table ops */
2625
+ tableOp(t) {
2626
+ var a, c, d;
2627
+ this.restoreSel();
2628
+ const e = window.getSelection();
2629
+ if (!e) return;
2630
+ const i = ((a = this.closestBlock(e.anchorNode)) == null ? void 0 : a.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (d = (c = e.anchorNode).closest) == null ? void 0 : d.call(c, "td,th") : null);
2631
+ if (!i) return;
2632
+ const s = i.parentElement, r = i.closest("table"), l = Array.from(s.children).indexOf(i), o = () => {
2633
+ const u = s.cloneNode(!1);
2634
+ return Array.from(s.children).forEach((v) => {
2635
+ const b = document.createElement("td"), f = v.getAttribute("style");
2636
+ f && b.setAttribute("style", f), b.style.removeProperty("background-color"), b.innerHTML = "<br>", u.appendChild(b);
2637
+ }), u;
2638
+ };
2639
+ if (t === "rowabove" && s.before(o()), t === "rowbelow" && s.after(o()), t === "delrow") {
2640
+ const u = s.parentElement;
2641
+ s.remove(), u.querySelector("tr") || r.remove();
2642
+ }
2643
+ (t === "colbefore" || t === "colafter") && r.querySelectorAll("tr").forEach((u) => {
2644
+ const v = u.children[Math.min(l, u.children.length - 1)], b = document.createElement("td"), f = v.getAttribute("style");
2645
+ f && b.setAttribute("style", f), b.style.removeProperty("width"), b.style.removeProperty("background-color"), b.innerHTML = "<br>", t === "colbefore" ? v.before(b) : v.after(b);
2646
+ }), t === "delcol" && (r.querySelectorAll("tr").forEach((u) => {
2647
+ var v;
2648
+ return (v = u.children[l]) == null ? void 0 : v.remove();
2649
+ }), r.querySelector("td,th") || r.remove()), t === "deltable" && r.remove(), this.onChange(), this.positionTableHandles();
2650
+ }
2651
+ applyTableProps(t, e) {
2652
+ e.width ? t.style.width = /^\d+$/.test(e.width) ? e.width + "px" : e.width : t.style.removeProperty("width");
2653
+ const i = Array.from(t.querySelectorAll("td,th"));
2654
+ e.cellpadding !== "" ? i.forEach((s) => s.style.padding = e.cellpadding + "px") : i.forEach((s) => s.style.removeProperty("padding")), e.cellspacing !== "" ? (t.style.borderCollapse = "separate", t.style.borderSpacing = e.cellspacing + "px") : (t.style.borderCollapse = "collapse", t.style.removeProperty("border-spacing")), e.border !== "" && +e.border > 0 ? (t.style.border = e.border + "px solid #b9c2cc", i.forEach((s) => s.style.border = e.border + "px solid #b9c2cc")) : (t.style.removeProperty("border"), i.forEach((s) => s.style.removeProperty("border"))), t.style.removeProperty("margin-left"), t.style.removeProperty("margin-right"), e.align === "center" ? (t.style.marginLeft = "auto", t.style.marginRight = "auto") : e.align === "right" ? (t.style.marginLeft = "auto", t.style.marginRight = "0") : e.align === "left" && (t.style.marginLeft = "0", t.style.marginRight = "auto");
2655
+ }
2656
+ tablePropsDlg() {
2657
+ const t = this.tblActive;
2658
+ if (!t) return;
2659
+ let e, i, s, r, l;
2660
+ const o = "display:flex;align-items:center;gap:10px;margin:10px 0", a = "width:120px;color:#556;flex:none", c = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", d = t.querySelector("td,th"), u = t.style.width || "", v = d && d.style.padding ? parseFloat(d.style.padding) : "", b = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", f = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", w = t.style.marginLeft, E = t.style.marginRight, q = w === "auto" && E === "auto" ? "center" : w === "auto" ? "right" : E === "auto" && w === "0" ? "left" : "";
2661
+ this.dialog(
2662
+ this.t("tablepropsttl"),
2663
+ (M) => {
2664
+ const D = (I, F) => {
2665
+ const B = document.createElement("div");
2666
+ B.style.cssText = o;
2667
+ const Y = document.createElement("span");
2668
+ Y.style.cssText = a, Y.textContent = this.t(I), B.append(Y, F), M.appendChild(B);
2669
+ };
2670
+ e = document.createElement("input"), e.type = "text", e.style.cssText = c, e.placeholder = "e.g. 600px or 100%", e.value = u, D("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = c, i.value = String(v), D("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = c, s.value = String(b), D("tblcellspacing", s), r = document.createElement("input"), r.type = "number", r.min = "0", r.style.cssText = c, r.value = String(f), D("tblborder", r), l = document.createElement("select"), l.style.cssText = c, [
2671
+ ["", "alignnone"],
2672
+ ["left", "alignleft"],
2673
+ ["center", "aligncenter"],
2674
+ ["right", "alignright"]
2675
+ ].forEach(([I, F]) => {
2676
+ const B = document.createElement("option");
2677
+ B.value = I, B.textContent = this.t(F), I === q && (B.selected = !0), l.appendChild(B);
2678
+ }), D("tblalign", l);
2679
+ },
2680
+ [
2681
+ { label: this.t("cancel"), action: () => this.closeDlg() },
2682
+ {
2683
+ label: this.t("save"),
2684
+ primary: !0,
2685
+ action: () => {
2686
+ this.applyTableProps(t, {
2687
+ width: e.value.trim(),
2688
+ cellpadding: i.value.trim(),
2689
+ cellspacing: s.value.trim(),
2690
+ border: r.value.trim(),
2691
+ align: l.value
2692
+ }), this.closeDlg(), this.onChange(), this.positionTableHandles();
2693
+ }
2694
+ }
2695
+ ]
2696
+ );
2697
+ }
2698
+ /* ------------------------------------------- cell / row / column props */
2699
+ currentCell() {
2700
+ let t = this.savedRange ? this.savedRange.startContainer : null;
2701
+ if (!t || !this.ed.contains(t)) {
2702
+ const e = window.getSelection();
2703
+ t = e && this.ed.contains(e.anchorNode) ? e.anchorNode : null;
2704
+ }
2705
+ for (; t && t !== this.ed; ) {
2706
+ if (t.nodeType === 1 && /^(TD|TH)$/.test(t.tagName))
2707
+ return t;
2708
+ t = t.parentNode;
2709
+ }
2710
+ return null;
2711
+ }
2712
+ toHexColor(t) {
2713
+ if (/^#[0-9a-fA-F]{6}$/.test(t)) return t;
2714
+ const e = /rgba?\((\d+)[,\s]+(\d+)[,\s]+(\d+)/.exec(t);
2715
+ return e ? "#" + [e[1], e[2], e[3]].map((i) => (+i).toString(16).padStart(2, "0")).join("") : "";
2716
+ }
2717
+ formRow(t, e, i) {
2718
+ const s = document.createElement("div");
2719
+ s.style.cssText = "display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";
2720
+ const r = document.createElement("span");
2721
+ r.style.cssText = "width:120px;color:#556;flex:none", r.textContent = e, s.append(r, i), t.appendChild(s);
2722
+ }
2723
+ formInput(t, e = "") {
2724
+ const i = document.createElement("input");
2725
+ return i.type = "text", i.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;min-width:0", i.value = t, i.placeholder = e, i;
2726
+ }
2727
+ formSelect(t, e) {
2728
+ const i = document.createElement("select");
2729
+ return i.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;background:#fff", t.forEach(([s, r]) => {
2730
+ const l = document.createElement("option");
2731
+ l.value = s, l.textContent = r, s === e && (l.selected = !0), i.appendChild(l);
2732
+ }), i;
2733
+ }
2734
+ formBg(t) {
2735
+ const e = document.createElement("div");
2736
+ e.style.cssText = "flex:1;display:flex;align-items:center;gap:8px";
2737
+ const i = this.toHexColor(t), s = document.createElement("input");
2738
+ 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";
2739
+ const r = document.createElement("label");
2740
+ r.style.cssText = "display:flex;align-items:center;gap:6px;cursor:pointer;color:#556";
2741
+ const l = document.createElement("input");
2742
+ return l.type = "checkbox", l.checked = !!i, r.append(l, document.createTextNode(this.t("fill"))), s.addEventListener("input", () => l.checked = !0), e.append(s, r), { wrap: e, color: s, fill: l };
2743
+ }
2744
+ setOrClear(t, e, i) {
2745
+ i ? t.style.setProperty(e, /^(width|height)$/.test(e) && /^\d+$/.test(i) ? i + "px" : i) : t.style.removeProperty(e);
2746
+ }
2747
+ cellPropsDlg() {
2748
+ const t = this.currentCell();
2749
+ if (!t) {
2750
+ alert(this.t("nocell"));
2751
+ return;
2752
+ }
2753
+ let e, i, s, r, l;
2754
+ this.dialog(
2755
+ this.t("cellprops").replace("…", ""),
2756
+ (o) => {
2757
+ e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(o, this.t("tblwidth"), e), i = this.formInput(t.style.height, "e.g. 40px"), this.formRow(o, this.t("tblheight"), i), s = this.formSelect(
2758
+ [
2759
+ ["", this.t("alignnone")],
2760
+ ["left", this.t("alignleft")],
2761
+ ["center", this.t("aligncenter")],
2762
+ ["right", this.t("alignright")]
2763
+ ],
2764
+ t.style.textAlign || ""
2765
+ ), this.formRow(o, this.t("tblalign"), s), r = this.formSelect(
2766
+ [
2767
+ ["", this.t("alignnone")],
2768
+ ["top", this.t("valigntop")],
2769
+ ["middle", this.t("valignmiddle")],
2770
+ ["bottom", this.t("valignbottom")]
2771
+ ],
2772
+ t.style.verticalAlign || ""
2773
+ ), this.formRow(o, this.t("valign"), r), l = this.formBg(t.style.backgroundColor || ""), this.formRow(o, this.t("backcolor"), l.wrap);
2774
+ },
2775
+ [
2776
+ { label: this.t("cancel"), action: () => this.closeDlg() },
2777
+ {
2778
+ label: this.t("save"),
2779
+ primary: !0,
2780
+ action: () => {
2781
+ this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", r.value), this.setOrClear(t, "background-color", l.fill.checked ? l.color.value : ""), this.closeDlg(), this.onChange(), this.positionTableHandles();
2782
+ }
2783
+ }
2784
+ ]
2785
+ );
2786
+ }
2787
+ rowPropsDlg() {
2788
+ const t = this.currentCell();
2789
+ if (!t) {
2790
+ alert(this.t("nocell"));
2791
+ return;
2792
+ }
2793
+ const e = t.parentElement;
2794
+ let i, s;
2795
+ this.dialog(
2796
+ this.t("rowprops").replace("…", ""),
2797
+ (r) => {
2798
+ i = this.formInput(e.style.height, "e.g. 40px"), this.formRow(r, this.t("tblheight"), i), s = this.formBg(e.style.backgroundColor || ""), this.formRow(r, this.t("backcolor"), s.wrap);
2799
+ },
2800
+ [
2801
+ { label: this.t("cancel"), action: () => this.closeDlg() },
2802
+ {
2803
+ label: this.t("save"),
2804
+ primary: !0,
2805
+ action: () => {
2806
+ this.setOrClear(e, "height", i.value.trim()), this.setOrClear(e, "background-color", s.fill.checked ? s.color.value : ""), this.closeDlg(), this.onChange(), this.positionTableHandles();
2807
+ }
2808
+ }
2809
+ ]
2810
+ );
2811
+ }
2812
+ colPropsDlg() {
2813
+ const t = this.currentCell();
2814
+ if (!t) {
2815
+ alert(this.t("nocell"));
2816
+ return;
2817
+ }
2818
+ const e = t.parentElement, i = t.closest("table"), s = Array.from(e.children).indexOf(t), r = Array.from(i.rows).map((a) => a.cells[s]).filter(Boolean);
2819
+ let l, o;
2820
+ this.dialog(
2821
+ this.t("colprops").replace("…", ""),
2822
+ (a) => {
2823
+ l = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(a, this.t("tblwidth"), l), o = this.formBg(t.style.backgroundColor || ""), this.formRow(a, this.t("backcolor"), o.wrap);
2824
+ },
2825
+ [
2826
+ { label: this.t("cancel"), action: () => this.closeDlg() },
2827
+ {
2828
+ label: this.t("save"),
2829
+ primary: !0,
2830
+ action: () => {
2831
+ r.forEach((a) => {
2832
+ this.setOrClear(a, "width", l.value.trim()), this.setOrClear(a, "background-color", o.fill.checked ? o.color.value : "");
2833
+ }), this.closeDlg(), this.onChange(), this.positionTableHandles();
2834
+ }
2835
+ }
2836
+ ]
2837
+ );
2838
+ }
2839
+ /* ---------------------------------------------------------- dialogs */
2840
+ closeDlg() {
2841
+ this.dlgOvl && (this.dlgOvl.remove(), this.dlgOvl = null);
2842
+ }
2843
+ dialog(t, e, i) {
2844
+ this.closeDlg(), this.closePop(), this.dlgOvl = document.createElement("div"), this.dlgOvl.className = "ovl";
2845
+ const s = document.createElement("div");
2846
+ s.className = "dlg", s.dir = this.dir(), s.innerHTML = `<header><span>${t}</span><button type="button">×</button></header>
2847
+ <div class="body"></div><footer></footer>`, s.querySelector("header button").onclick = () => this.closeDlg(), e(s.querySelector(".body")), (i || [{ label: this.t("close"), primary: !0, action: () => this.closeDlg() }]).forEach((r) => {
2848
+ const l = document.createElement("button");
2849
+ l.type = "button", l.textContent = r.label, r.primary && (l.className = "pri"), l.onclick = r.action, s.querySelector("footer").appendChild(l);
2850
+ }), this.dlgOvl.appendChild(s), this.dlgOvl.addEventListener("mousedown", (r) => {
2851
+ r.target === this.dlgOvl && this.closeDlg();
2852
+ }), document.body.appendChild(this.dlgOvl);
2853
+ }
2854
+ sourceDlg() {
2855
+ let t;
2856
+ this.dialog(
2857
+ this.t("srcttl"),
2858
+ (e) => {
2859
+ t = document.createElement("textarea"), t.value = this.ed.innerHTML.replace(/></g, `>
2860
+ <`), e.appendChild(t);
2861
+ },
2862
+ [
2863
+ { label: this.t("cancel"), action: () => this.closeDlg() },
2864
+ {
2865
+ label: this.t("save"),
2866
+ primary: !0,
2867
+ action: () => {
2868
+ this.ed.innerHTML = t.value, this.closeDlg(), this.onChange();
2869
+ }
2870
+ }
2871
+ ]
2872
+ );
2873
+ }
2874
+ helpDlg() {
2875
+ this.dialog(this.t("helpttl"), (t) => {
2876
+ const e = [
2877
+ ["Ctrl+B", this.t("bold")],
2878
+ ["Ctrl+I", this.t("italic")],
2879
+ ["Ctrl+U", this.t("underline")],
2880
+ ["Ctrl+Z", this.t("undo")],
2881
+ ["Ctrl+Y", this.t("redo")],
2882
+ ["Ctrl+A", this.t("selectall")],
2883
+ ["Alt+0", this.t("helpttl")]
2884
+ ];
2885
+ t.innerHTML = `<p style="color:#556">${this.t("shortcuts")}</p>
2886
+ <table class="kbd">${e.map((i) => `<tr><td>${i[1]}</td><td><kbd>${i[0]}</kbd></td></tr>`).join("")}</table>`;
2887
+ });
2888
+ }
2889
+ wordCountDlg() {
2890
+ this.dialog(this.t("wcttl"), (t) => {
2891
+ var e;
2892
+ t.innerHTML = `<table class="kbd">
2893
+ <tr><td>${this.t("wcwords")}</td><td>${this.countWords()}</td></tr>
2894
+ <tr><td>${this.t("wcchars")}</td><td>${((e = this.ed.textContent) == null ? void 0 : e.replace(/\s/g, "").length) ?? 0}</td></tr></table>`;
2895
+ });
2896
+ }
2897
+ previewDlg() {
2898
+ this.dialog(this.t("previewttl"), (t) => {
2899
+ const e = document.createElement("div");
2900
+ 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);
2901
+ });
2902
+ }
2903
+ charMap() {
2904
+ this.dialog(
2905
+ this.t("charmap").replace("…", ""),
2906
+ (t) => {
2907
+ const e = document.createElement("div");
2908
+ e.className = "chgrid", We.forEach((i) => {
2909
+ const s = document.createElement("button");
2910
+ s.textContent = i, s.onclick = () => {
2911
+ this.closeDlg(), this.exec("insertText", i);
2912
+ }, e.appendChild(s);
2913
+ }), t.appendChild(e);
2914
+ }
2915
+ );
2916
+ }
2917
+ printDoc() {
2918
+ const t = window.open("", "_blank");
2919
+ t && (t.document.write(
2920
+ `<html dir="${this.dir()}"><body style="font-family:Helvetica,Arial,sans-serif;font-size:14px">${this.ed.innerHTML}</body></html>`
2921
+ ), t.document.close(), t.focus(), t.print());
2922
+ }
2923
+ pickImage() {
2924
+ this.imgInput.value = "", this.imgInput.click();
2925
+ }
2926
+ /* ---------------------------------------------- image upload placeholder */
2927
+ insertImagePlaceholder() {
2928
+ this.restoreSel();
2929
+ const t = "img-ph-" + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
2930
+ document.execCommand(
2931
+ "insertHTML",
2932
+ !1,
2933
+ `<div class="img-ph" id="${t}" contenteditable="false">${h.image}<span>${this.t("dropimage")}</span></div>`
2934
+ );
2935
+ const e = this.ed.querySelector("#" + t);
2936
+ e && (e.removeAttribute("id"), this.selectImgPlaceholder(e)), this.onChange();
2937
+ }
2938
+ clearImgPlaceholderSel() {
2939
+ var t, e;
2940
+ (t = this.phCtx) == null || t.remove(), this.phCtx = null, (e = this.phActive) == null || e.classList.remove("active"), this.phActive = null;
2941
+ }
2942
+ selectImgPlaceholder(t) {
2943
+ this.phActive !== t && (this.clearImgPlaceholderSel(), this.phActive = t, t.classList.add("active"), this.phCtx = document.createElement("div"), this.phCtx.className = "imgctx img-ph-ctx", this.phCtx.dir = this.dir(), document.body.appendChild(this.phCtx), this.renderPhCtxButtons());
2944
+ }
2945
+ renderPhCtxButtons() {
2946
+ const t = this.phCtx;
2947
+ t && (t.innerHTML = "", t.append(
2948
+ this.ctxBtn(h.uploadic, this.t("uploadimg"), () => {
2949
+ this.phUploadTarget = this.phActive, this.pickImage();
2950
+ }),
2951
+ this.ctxBtn(h.link, this.t("imagelink"), () => this.renderPhCtxUrlInput())
2952
+ ), this.positionImgPhCtx());
2953
+ }
2954
+ renderPhCtxUrlInput() {
2955
+ const t = this.phCtx;
2956
+ if (!t) return;
2957
+ t.innerHTML = "";
2958
+ const e = document.createElement("input");
2959
+ e.type = "url", e.className = "urlinp", e.placeholder = this.t("imageurlph");
2960
+ const i = document.createElement("button");
2961
+ i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertimg");
2962
+ const s = () => {
2963
+ const r = e.value.trim(), l = this.phActive;
2964
+ if (!l) return;
2965
+ if (!/^(https?:|data:image\/|blob:)/i.test(r)) {
2966
+ e.classList.add("err"), e.focus();
2967
+ return;
2968
+ }
2969
+ i.disabled = !0, e.disabled = !0;
2970
+ const o = new Image();
2971
+ o.onload = () => this.replacePlaceholderWithImage(l, r, ""), o.onerror = () => {
2972
+ i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
2973
+ }, o.src = r;
2974
+ };
2975
+ i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (r) => {
2976
+ r.key === "Enter" ? (r.preventDefault(), s()) : r.key === "Escape" && (r.stopPropagation(), this.renderPhCtxButtons());
2977
+ }), t.append(e, i), this.positionImgPhCtx(), e.focus();
2978
+ }
2979
+ readImageFileInto(t, e) {
2980
+ if (e.classList.contains("uploading")) return;
2981
+ if (this.imageUploadHandler) {
2982
+ this.uploadImageFile(t, e);
2983
+ return;
2984
+ }
2985
+ const i = new FileReader();
2986
+ i.onload = () => {
2987
+ this.ed.contains(e) && this.replacePlaceholderWithImage(e, i.result, t.name.replace(/"/g, ""));
2988
+ }, i.readAsDataURL(t);
2989
+ }
2990
+ /** Runs the host-supplied imageUploadHandler instead of inlining base64,
2991
+ * so apps can route the file to S3 / Azure Blob / their own server. */
2992
+ uploadImageFile(t, e) {
2993
+ const i = t.name.replace(/"/g, "");
2994
+ e.classList.remove("upload-error"), e.classList.add("uploading");
2995
+ const s = e.querySelector("span");
2996
+ s && (s.textContent = this.t("uploading")), this.imageUploadHandler(t).then((r) => {
2997
+ this.ed.contains(e) && this.replacePlaceholderWithImage(e, r, i);
2998
+ }).catch((r) => {
2999
+ var l;
3000
+ this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (l = this.onImageUploadError) == null || l.call(this, r, t));
3001
+ });
3002
+ }
3003
+ replacePlaceholderWithImage(t, e, i) {
3004
+ const s = document.createElement("img");
3005
+ s.src = e, s.alt = "", i && (s.title = i), t.replaceWith(s), this.phActive === t && this.clearImgPlaceholderSel(), this.refreshState(), this.onChange();
3006
+ }
3007
+ positionImgPhCtx() {
3008
+ if (this.phActive && !document.body.contains(this.phActive)) {
3009
+ this.clearImgPlaceholderSel();
3010
+ return;
3011
+ }
3012
+ if (!this.phActive || !this.phCtx) return;
3013
+ const t = this.phActive.getBoundingClientRect(), e = this.phCtx.offsetWidth, i = this.phCtx.offsetHeight;
3014
+ let s = t.left + scrollX + (t.width - e) / 2;
3015
+ s = Math.max(8 + scrollX, Math.min(s, scrollX + innerWidth - e - 8));
3016
+ let r = t.bottom + scrollY + 8;
3017
+ t.bottom + 8 + i > innerHeight - 4 && (r = Math.max(this.ctxMinTop(), t.top + scrollY - i - 8)), this.phCtx.style.left = s + "px", this.phCtx.style.top = r + "px";
3018
+ }
3019
+ pickWordDoc() {
3020
+ this.docInput.value = "", this.docInput.click();
3021
+ }
3022
+ /* ---------------------------------------------------------- fullscreen */
3023
+ toggleFullscreen() {
3024
+ this.shell.classList.toggle("fullscreen");
3025
+ const t = this.toolbar.querySelector("[data-id=fullscreen]");
3026
+ t == null || t.classList.toggle("on", this.shell.classList.contains("fullscreen")), this.positionTableHandles();
3027
+ }
3028
+ /* ---------------------------------------------------------- table resize */
3029
+ clearTableHandles() {
3030
+ var t, e, i, s, r;
3031
+ (t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((l) => l.remove()), this.tblColBars = [], (e = this.tblCtx) == null || e.remove(), this.tblCtx = null, (i = this.tblCellMark) == null || i.remove(), this.tblCellMark = null, (s = this.tblOpMark) == null || s.remove(), this.tblOpMark = null, this.tblOpMarkKind = null, (r = this.tblActive) == null || r.classList.remove("tbl-selected"), this.tblActive = null;
3032
+ }
3033
+ /** Blue outline around the cell that holds the caret, so it is clear
3034
+ which cell / row / column the table operations will target. */
3035
+ positionCellMarker() {
3036
+ if (!this.tblCellMark) return;
3037
+ const t = this.currentCell();
3038
+ if (!t || !this.tblActive || t.closest("table") !== this.tblActive) {
3039
+ this.tblCellMark.style.display = "none";
3040
+ return;
3041
+ }
3042
+ const e = t.getBoundingClientRect();
3043
+ this.tblCellMark.style.display = "block", this.tblCellMark.style.left = e.left + scrollX + "px", this.tblCellMark.style.top = e.top + scrollY + "px", this.tblCellMark.style.width = e.width + "px", this.tblCellMark.style.height = e.height + "px";
3044
+ }
3045
+ /** Dashed highlight over the whole row / column an operation targets,
3046
+ shown while its button or menu item is hovered. */
3047
+ setOpTarget(t) {
3048
+ this.tblOpMarkKind = t, this.positionOpMark();
3049
+ }
3050
+ positionOpMark() {
3051
+ var d;
3052
+ const t = this.tblOpMarkKind, e = t ? this.currentCell() : null;
3053
+ if (!t || !e || !this.tblActive || e.closest("table") !== this.tblActive) {
3054
+ (d = this.tblOpMark) == null || d.remove(), this.tblOpMark = null;
3055
+ return;
3056
+ }
3057
+ this.tblOpMark || (this.tblOpMark = document.createElement("div"), this.tblOpMark.className = "tbl-opmark", document.body.appendChild(this.tblOpMark));
3058
+ const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), r = e.parentElement.getBoundingClientRect(), l = t === "row" ? r.left : s.left, o = t === "row" ? r.top : i.top, a = t === "row" ? r.width : s.width, c = t === "row" ? r.height : i.height;
3059
+ this.tblOpMark.style.left = l + scrollX + "px", this.tblOpMark.style.top = o + scrollY + "px", this.tblOpMark.style.width = a + "px", this.tblOpMark.style.height = c + "px";
3060
+ }
3061
+ /** Lowest allowed top for floating context toolbars — keeps them from
3062
+ covering the editor menubar/toolbar when the target sits on the first line. */
3063
+ ctxMinTop() {
3064
+ return Math.max(scrollY + 4, this.ed.getBoundingClientRect().top + scrollY - 2);
3065
+ }
3066
+ ctxBtn(t, e, i, s) {
3067
+ const r = document.createElement("button");
3068
+ return r.type = "button", r.title = e, r.innerHTML = t, s && (r.dataset.id = s), r.addEventListener("mousedown", (l) => l.preventDefault()), r.addEventListener("click", i), r;
3069
+ }
3070
+ ctxSep() {
3071
+ const t = document.createElement("div");
3072
+ return t.className = "sep", t;
3073
+ }
3074
+ buildTableCtxToolbar() {
3075
+ const t = document.createElement("div");
3076
+ t.className = "tblctx", t.dir = this.dir();
3077
+ const e = (i, s) => (i.addEventListener("mouseenter", () => this.setOpTarget(s)), i.addEventListener("mouseleave", () => this.setOpTarget(null)), i);
3078
+ return t.append(
3079
+ e(this.ctxBtn(h.rowbefore, this.t("rowabove"), () => this.tableOp("rowabove")), "row"),
3080
+ e(this.ctxBtn(h.rowafter, this.t("rowbelow"), () => this.tableOp("rowbelow")), "row"),
3081
+ e(this.ctxBtn(h.rowdelete, this.t("delrow"), () => this.tableOp("delrow")), "row"),
3082
+ this.ctxSep(),
3083
+ e(this.ctxBtn(h.colbefore, this.t("colbefore"), () => this.tableOp("colbefore")), "col"),
3084
+ e(this.ctxBtn(h.colafter, this.t("colafter"), () => this.tableOp("colafter")), "col"),
3085
+ e(this.ctxBtn(h.coldelete, this.t("delcol"), () => this.tableOp("delcol")), "col"),
3086
+ this.ctxSep(),
3087
+ this.ctxBtn(h.tabledelete, this.t("deltable"), () => this.tableOp("deltable")),
3088
+ this.ctxBtn(h.tableic, this.t("tablepropsttl"), () => this.tablePropsDlg())
3089
+ ), document.body.appendChild(t), t;
3090
+ }
3091
+ positionTableHandles() {
3092
+ if (!this.tblActive || !document.body.contains(this.tblActive)) {
3093
+ this.clearTableHandles();
3094
+ return;
3095
+ }
3096
+ const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, r = e.right + scrollX, l = e.bottom + scrollY;
3097
+ if (this.tblCorner && (this.tblCorner.style.top = l - 5 + "px", this.tblCorner.style.left = (t ? s - 5 : r - 5) + "px", this.tblCorner.style.cursor = t ? "nesw-resize" : "nwse-resize"), this.tblCtx) {
3098
+ const a = this.tblCtx.offsetWidth, c = this.tblCtx.offsetHeight;
3099
+ let d = s + (r - s) / 2 - a / 2;
3100
+ d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth - a - 8));
3101
+ let u = i - c - 8;
3102
+ u < this.ctxMinTop() && (u = l + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = u + "px";
3103
+ }
3104
+ this.tblColBars.forEach((a) => a.remove()), this.tblColBars = [];
3105
+ const o = this.tblActive.rows[0];
3106
+ if (o)
3107
+ for (let a = 0; a < o.cells.length - 1; a++) {
3108
+ const c = o.cells[a].getBoundingClientRect(), d = (t ? c.left : c.right) + scrollX, u = document.createElement("div");
3109
+ u.className = "tbl-colbar", u.style.top = i + "px", u.style.left = d + "px", u.style.height = l - i + "px", document.body.appendChild(u), u.addEventListener("mousedown", (v) => this.startColBarDrag(v, a)), this.tblColBars.push(u);
3110
+ }
3111
+ this.positionCellMarker(), this.positionOpMark();
3112
+ }
3113
+ selectTableForResize(t) {
3114
+ this.tblActive !== t && (this.clearTableHandles(), this.tblActive = t, t.classList.add("tbl-selected"), this.tblCorner = document.createElement("div"), this.tblCorner.className = "tbl-handle", document.body.appendChild(this.tblCorner), this.tblCorner.addEventListener("mousedown", (e) => this.startTableCornerDrag(e)), this.tblCellMark = document.createElement("div"), this.tblCellMark.className = "tbl-cellmark", this.tblCellMark.style.display = "none", document.body.appendChild(this.tblCellMark), this.tblCtx = this.buildTableCtxToolbar(), this.positionTableHandles());
3115
+ }
3116
+ withNoTextSelect(t) {
3117
+ const e = document.body.style.userSelect;
3118
+ document.body.style.userSelect = "none", t(() => {
3119
+ document.body.style.userSelect = e;
3120
+ });
3121
+ }
3122
+ startTableCornerDrag(t) {
3123
+ t.preventDefault();
3124
+ const e = this.tblActive;
3125
+ if (!e) return;
3126
+ const i = this.ed.getAttribute("dir") === "rtl", s = t.clientX, r = e.getBoundingClientRect().width;
3127
+ e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((l) => {
3128
+ const o = (c) => {
3129
+ const d = i ? -(c.clientX - s) : c.clientX - s;
3130
+ e.style.width = Math.max(60, Math.round(r + d)) + "px", this.positionTableHandles();
3131
+ }, a = () => {
3132
+ window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", a), l(), this.onChange();
3133
+ };
3134
+ window.addEventListener("mousemove", o), window.addEventListener("mouseup", a);
3135
+ });
3136
+ }
3137
+ startColBarDrag(t, e) {
3138
+ t.preventDefault(), t.stopPropagation();
3139
+ const i = this.tblActive;
3140
+ if (!i) return;
3141
+ const s = this.ed.getAttribute("dir") === "rtl", r = Array.from(i.rows), l = r.map((u) => u.cells[e]).filter(Boolean), o = r.map((u) => u.cells[e + 1]).filter(Boolean);
3142
+ if (!l.length || !o.length) return;
3143
+ const a = t.clientX, c = l[0].getBoundingClientRect().width, d = o[0].getBoundingClientRect().width;
3144
+ i.style.tableLayout = "fixed", this.withNoTextSelect((u) => {
3145
+ const v = (f) => {
3146
+ const w = (s ? -1 : 1) * (f.clientX - a);
3147
+ l.forEach((E) => E.style.width = Math.max(24, Math.round(c + w)) + "px"), o.forEach((E) => E.style.width = Math.max(24, Math.round(d - w)) + "px"), this.positionTableHandles();
3148
+ }, b = () => {
3149
+ window.removeEventListener("mousemove", v), window.removeEventListener("mouseup", b), u(), this.onChange();
3150
+ };
3151
+ window.addEventListener("mousemove", v), window.addEventListener("mouseup", b);
3152
+ });
3153
+ }
3154
+ /* ---------------------------------------------------------- image toolbar / resize */
3155
+ cancelImgHide() {
3156
+ this.imgHideTimer != null && (window.clearTimeout(this.imgHideTimer), this.imgHideTimer = null);
3157
+ }
3158
+ scheduleImgHide() {
3159
+ this.cancelImgHide(), this.imgHideTimer = window.setTimeout(() => this.clearImageHandles(), 250);
3160
+ }
3161
+ clearImageHandles() {
3162
+ var t, e;
3163
+ 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;
3164
+ }
3165
+ selectImage(t) {
3166
+ this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles = ci.map((e) => {
3167
+ const i = document.createElement("div");
3168
+ 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;
3169
+ }), this.imgCtx = this.buildImageCtxToolbar(t), this.positionImageHandles());
3170
+ }
3171
+ buildImageCtxToolbar(t) {
3172
+ const e = document.createElement("div");
3173
+ e.className = "imgctx", e.dir = this.dir();
3174
+ const i = () => {
3175
+ var d;
3176
+ const c = this.buildImageCtxToolbar(t);
3177
+ (d = this.imgCtx) == null || d.replaceWith(c), this.imgCtx = c, this.positionImageHandles();
3178
+ }, s = (c) => {
3179
+ this.setImageAlign(t, c), i();
3180
+ }, r = t.style.float === "left", l = t.style.float === "right", o = !r && !l && t.style.marginLeft === "auto" && t.style.marginRight === "auto", a = (c, d, u, v) => {
3181
+ const b = this.ctxBtn(c, d, v);
3182
+ return b.classList.toggle("on", u), b;
3183
+ };
3184
+ return e.append(
3185
+ a(h.alignleft, this.t("alignleft"), r, () => s("left")),
3186
+ a(h.aligncenter, this.t("aligncenter"), o, () => s("center")),
3187
+ a(h.alignright, this.t("alignright"), l, () => s("right")),
3188
+ this.ctxSep(),
3189
+ a(h.rotateleft, this.t("rotateleft"), !1, () => {
3190
+ this.rotateImage(t, -90), i();
3191
+ }),
3192
+ a(h.rotateright, this.t("rotateright"), !1, () => {
3193
+ this.rotateImage(t, 90), i();
3194
+ }),
3195
+ this.ctxSep(),
3196
+ a(h.fliphorizontal, this.t("fliphorizontal"), t.dataset.flipx === "1", () => {
3197
+ this.flipImage(t, "x"), i();
3198
+ }),
3199
+ a(h.flipvertical, this.t("flipvertical"), t.dataset.flipy === "1", () => {
3200
+ this.flipImage(t, "y"), i();
3201
+ }),
3202
+ this.ctxSep(),
3203
+ a(h.trash, this.t("deleteimg"), !1, () => {
3204
+ t.remove(), this.clearImageHandles(), this.onChange();
3205
+ })
3206
+ ), e.addEventListener("mousedown", (c) => c.preventDefault()), e.addEventListener("mouseenter", () => this.cancelImgHide()), e.addEventListener("mouseleave", () => this.scheduleImgHide()), document.body.appendChild(e), e;
3207
+ }
3208
+ setImageAlign(t, e) {
3209
+ 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();
3210
+ }
3211
+ applyImgTransform(t) {
3212
+ const e = parseInt(t.dataset.rotate || "0", 10), i = t.dataset.flipx === "1" ? -1 : 1, s = t.dataset.flipy === "1" ? -1 : 1;
3213
+ t.style.transform = e || i < 0 || s < 0 ? `rotate(${e}deg) scale(${i}, ${s})` : "";
3214
+ }
3215
+ rotateImage(t, e) {
3216
+ const i = ((parseInt(t.dataset.rotate || "0", 10) + e) % 360 + 360) % 360;
3217
+ t.dataset.rotate = String(i), this.applyImgTransform(t), this.positionImageHandles(), this.onChange();
3218
+ }
3219
+ flipImage(t, e) {
3220
+ const i = e === "x" ? "flipx" : "flipy";
3221
+ t.dataset[i] = t.dataset[i] === "1" ? "" : "1", this.applyImgTransform(t), this.positionImageHandles(), this.onChange();
3222
+ }
3223
+ positionImageHandles() {
3224
+ if (!this.imgActive || !document.body.contains(this.imgActive)) {
3225
+ this.clearImageHandles();
3226
+ return;
3227
+ }
3228
+ const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, r = t.bottom + scrollY, l = {
3229
+ nw: [i, e],
3230
+ ne: [s, e],
3231
+ sw: [i, r],
3232
+ se: [s, r]
3233
+ };
3234
+ if (this.imgHandles.forEach((o) => {
3235
+ const [a, c] = l[o.dataset.corner];
3236
+ o.style.left = a - 5 + "px", o.style.top = c - 5 + "px";
3237
+ }), this.imgCtx) {
3238
+ const o = this.imgCtx.offsetWidth, a = this.imgCtx.offsetHeight;
3239
+ let c = i + (s - i) / 2 - o / 2;
3240
+ c = Math.max(8 + scrollX, Math.min(c, scrollX + innerWidth - o - 8));
3241
+ let d = e - a - 8;
3242
+ d < this.ctxMinTop() && (d = r + 8), this.imgCtx.style.left = c + "px", this.imgCtx.style.top = d + "px";
3243
+ }
3244
+ }
3245
+ startImageResizeDrag(t, e) {
3246
+ t.preventDefault();
3247
+ const i = this.imgActive;
3248
+ if (!i) return;
3249
+ this.cancelImgHide();
3250
+ const s = t.clientX, r = i.getBoundingClientRect().width, l = e === "nw" || e === "sw" ? -1 : 1;
3251
+ this.withNoTextSelect((o) => {
3252
+ const a = (d) => {
3253
+ i.style.width = Math.max(24, Math.round(r + l * (d.clientX - s))) + "px", i.style.height = "auto", this.positionImageHandles();
3254
+ }, c = () => {
3255
+ window.removeEventListener("mousemove", a), window.removeEventListener("mouseup", c), o(), this.onChange();
3256
+ };
3257
+ window.addEventListener("mousemove", a), window.addEventListener("mouseup", c);
3258
+ });
3259
+ }
3260
+ /* ---------------------------------------------------------- selection bubble toolbar */
3261
+ toggleBlock(t) {
3262
+ this.exec("formatBlock", this.currentBlock() === t ? "<p>" : "<" + t + ">");
3263
+ }
3264
+ clearSelToolbar() {
3265
+ var t;
3266
+ (t = this.selCtx) == null || t.remove(), this.selCtx = null;
3267
+ }
3268
+ updateSelToolbar(t) {
3269
+ if (this.options.readonly || t.isCollapsed || !t.rangeCount) {
3270
+ this.clearSelToolbar();
3271
+ return;
3272
+ }
3273
+ const e = t.getRangeAt(0), i = e.getBoundingClientRect();
3274
+ if (!i.width && !i.height) {
3275
+ this.clearSelToolbar();
3276
+ return;
3277
+ }
3278
+ this.selCtx || (this.selCtx = this.buildSelToolbar()), this.positionSelToolbar(e);
3279
+ }
3280
+ buildSelToolbar() {
3281
+ var o;
3282
+ const t = document.createElement("div");
3283
+ t.className = "selctx", t.dir = this.dir();
3284
+ const e = this.ctxBtn(
3285
+ '<b style="font:600 15px/1 Georgia,serif">A</b><span class="colorbar" data-cb="fore"></span>',
3286
+ this.t("forecolor"),
3287
+ () => this.colorMenu(e, "fore")
3288
+ ), i = this.ctxBtn(h.backcolor, this.t("backcolor"), () => this.colorMenu(i, "back"));
3289
+ (o = i.querySelector("svg")) == null || o.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
3290
+ const s = this.ctxBtn(h.caseic, this.t("changecase"), () => this.caseMenu(s)), r = this.ctxBtn(h.lineheight, this.t("lineheight"), () => this.lineHeightMenu(r)), l = this.ctxBtn(h.wordspacing, this.t("wordspacing"), () => this.wordSpacingMenu(l));
3291
+ return t.append(
3292
+ this.ctxBtn(h.bold, this.t("bold"), () => this.exec("bold"), "bold"),
3293
+ this.ctxBtn(h.italic, this.t("italic"), () => this.exec("italic"), "italic"),
3294
+ e,
3295
+ i,
3296
+ this.ctxSep(),
3297
+ this.ctxBtn(h.quote, this.t("quote"), () => this.toggleBlock("blockquote"), "blockquote"),
3298
+ this.ctxBtn('<b style="font:700 12px/1 Arial,sans-serif">H2</b>', this.blockLabel("h2"), () => this.toggleBlock("h2"), "h2"),
3299
+ this.ctxBtn('<b style="font:700 12px/1 Arial,sans-serif">H3</b>', this.blockLabel("h3"), () => this.toggleBlock("h3"), "h3"),
3300
+ this.ctxSep(),
3301
+ this.ctxBtn(h.link, this.t("linkttl"), () => this.linkDlg()),
3302
+ s,
3303
+ r,
3304
+ l
3305
+ ), t.addEventListener("mousedown", (a) => a.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
3306
+ }
3307
+ positionSelToolbar(t) {
3308
+ if (!this.selCtx) return;
3309
+ const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, r = e.right + scrollX, l = e.bottom + scrollY, o = this.selCtx.offsetWidth, a = this.selCtx.offsetHeight;
3310
+ let c = s + (r - s) / 2 - o / 2;
3311
+ c = Math.max(8 + scrollX, Math.min(c, scrollX + innerWidth - o - 8));
3312
+ let d = i - a - 8;
3313
+ d < this.ctxMinTop() && (d = l + 8), this.selCtx.style.left = c + "px", this.selCtx.style.top = d + "px";
3314
+ }
3315
+ repositionSelToolbar() {
3316
+ if (!this.selCtx) return;
3317
+ const t = window.getSelection();
3318
+ t && t.rangeCount && !t.isCollapsed && this.ed.contains(t.anchorNode) && this.positionSelToolbar(t.getRangeAt(0));
3319
+ }
3320
+ /* ---------------------------------------------------------- state sync */
3321
+ currentBlock() {
3322
+ const t = window.getSelection();
3323
+ if (!t || !t.anchorNode || !this.ed.contains(t.anchorNode)) return "p";
3324
+ const e = this.closestBlock(t.anchorNode);
3325
+ return e ? e.tagName.toLowerCase().replace("div", "p") : "p";
3326
+ }
3327
+ /** Element whose computed font reflects the current caret, falling back to the editor root before any selection lands inside it. */
3328
+ fontRefEl() {
3329
+ const t = window.getSelection();
3330
+ return t && t.anchorNode && this.ed.contains(t.anchorNode) ? t.anchorNode.nodeType === 1 ? t.anchorNode : t.anchorNode.parentElement : this.ed;
3331
+ }
3332
+ currentFont() {
3333
+ const t = getComputedStyle(this.fontRefEl()).fontFamily.toLowerCase(), e = this.options.fontFamilyFormats.find(([i, s]) => t.includes(s.split(",")[0].toLowerCase()));
3334
+ return e ? e[0] : "";
3335
+ }
3336
+ currentSize() {
3337
+ const t = Math.round(parseFloat(getComputedStyle(this.fontRefEl()).fontSize));
3338
+ return t > 0 ? t + "px" : "";
3339
+ }
3340
+ refreshState() {
3341
+ var a, c, d;
3342
+ const t = window.getSelection(), e = t ? this.ed.contains(t.anchorNode) : !1, i = this.currentBlock();
3343
+ [this.toolbar, this.selCtx].filter(Boolean).forEach((u) => {
3344
+ [
3345
+ "bold",
3346
+ "italic",
3347
+ "underline",
3348
+ "strikeThrough",
3349
+ "justifyLeft",
3350
+ "justifyCenter",
3351
+ "justifyRight",
3352
+ "justifyFull",
3353
+ "insertOrderedList",
3354
+ "insertUnorderedList"
3355
+ ].forEach((v) => {
3356
+ const b = u.querySelector(`[data-id=${v}]`);
3357
+ b && b.classList.toggle("on", e && document.queryCommandState(v));
3358
+ }), ["h2", "h3", "blockquote"].forEach((v) => {
3359
+ const b = u.querySelector(`[data-id=${v}]`);
3360
+ b && b.classList.toggle("on", e && i === v);
3361
+ });
3362
+ });
3363
+ const r = t ? this.closestBlock(t.anchorNode) : null, l = ((a = r == null ? void 0 : r.closest("[dir]")) == null ? void 0 : a.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
3364
+ (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");
3365
+ const o = (u, v, b) => {
3366
+ const f = this.toolbar.querySelector(`[data-id=${u}] .lbl`);
3367
+ f && (f.textContent = v || b || "", f.classList.toggle("empty", !v));
3368
+ };
3369
+ o("fontsel", this.currentFont()), o("sizesel", this.currentSize().replace("px", "")), e && o("blocksel", Ut.some((u) => u[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
3370
+ }
3371
+ countWords() {
3372
+ const t = (this.ed.textContent || "").trim();
3373
+ return t ? t.split(/\s+/).length : 0;
3374
+ }
3375
+ /* ---------------------------------------------------------- paste */
3376
+ handlePaste(t) {
3377
+ const e = t.clipboardData;
3378
+ if (!e) return;
3379
+ t.preventDefault();
3380
+ const i = e.getData("text/html"), s = Array.from(e.items).find((r) => r.type.startsWith("image/"));
3381
+ if (s && !i) {
3382
+ const r = new FileReader();
3383
+ r.onload = () => {
3384
+ document.execCommand("insertHTML", !1, `<img src="${r.result}" alt="">`), this.onChange();
3385
+ }, r.readAsDataURL(s.getAsFile());
3386
+ return;
3387
+ }
3388
+ i ? document.execCommand("insertHTML", !1, ii(i, this.dir())) : document.execCommand("insertHTML", !1, si(e.getData("text/plain"))), this.onChange();
3389
+ }
3390
+ /* ---------------------------------------------------------- init */
3391
+ initUI() {
3392
+ this.closePop(), this.closeDlg(), this.clearTableHandles(), this.clearImgPlaceholderSel(), this.shell.dir = this.dir(), this.ed.dir = this.dir(), this.options.menubar ? this.buildMenubar() : this.menubar.style.display = "none", this.options.toolbar ? this.buildToolbar() : this.toolbar.style.display = "none", this.sbHelp.textContent = this.t("statushelp"), this.refreshState();
3393
+ }
3394
+ }, z.instanceCounter = 0, z);
3395
+ const di = qe(
3396
+ ({ value: m, defaultValue: t, onChange: e, onReady: i, className: s, style: r, ...l }, o) => {
3397
+ const a = X(null), c = X(null), d = X(!1), u = X(m ?? t), v = X(e), b = X(i);
3398
+ return v.current = e, b.current = i, Le(o, () => ({
3399
+ getContent: () => {
3400
+ var f;
3401
+ return ((f = c.current) == null ? void 0 : f.getContent()) ?? "";
3402
+ },
3403
+ setContent: (f) => {
3404
+ var w;
3405
+ return (w = c.current) == null ? void 0 : w.setContent(f);
3406
+ },
3407
+ insertContent: (f) => {
3408
+ var w;
3409
+ return (w = c.current) == null ? void 0 : w.insertContent(f);
3410
+ },
3411
+ setLanguage: (f) => {
3412
+ var w;
3413
+ return (w = c.current) == null ? void 0 : w.setLanguage(f);
3414
+ },
3415
+ focus: () => {
3416
+ var f;
3417
+ return (f = c.current) == null ? void 0 : f.focus();
3418
+ },
3419
+ destroy: () => {
3420
+ var f;
3421
+ return (f = c.current) == null ? void 0 : f.destroy();
3422
+ },
3423
+ importWordFile: (f) => {
3424
+ var w;
3425
+ return ((w = c.current) == null ? void 0 : w.importWordFile(f)) ?? Promise.resolve();
3426
+ },
3427
+ restoreDraft: () => {
3428
+ var f;
3429
+ return ((f = c.current) == null ? void 0 : f.restoreDraft()) ?? !1;
3430
+ },
3431
+ getRevisions: () => {
3432
+ var f;
3433
+ return ((f = c.current) == null ? void 0 : f.getRevisions()) ?? [];
3434
+ }
3435
+ })), gt(() => {
3436
+ if (!a.current) return;
3437
+ const f = new hi({
3438
+ target: a.current,
3439
+ initialContent: u.current,
3440
+ onChange: (w) => {
3441
+ var E;
3442
+ d.current = !0, u.current = w, (E = v.current) == null || E.call(v, w);
3443
+ },
3444
+ onReady: (w) => {
3445
+ var E;
3446
+ return (E = b.current) == null ? void 0 : E.call(b, w);
3447
+ },
3448
+ ...l
3449
+ });
3450
+ return c.current = f, () => {
3451
+ f.destroy(), c.current = null;
3452
+ };
3453
+ }, []), gt(() => {
3454
+ var f;
3455
+ if (m !== void 0 && m !== u.current) {
3456
+ if (d.current) {
3457
+ d.current = !1;
3458
+ return;
3459
+ }
3460
+ u.current = m, (f = c.current) == null || f.setContent(m);
3461
+ }
3462
+ }, [m]), gt(() => {
3463
+ var f;
3464
+ l.language && ((f = c.current) == null || f.setLanguage(l.language));
3465
+ }, [l.language]), /* @__PURE__ */ Re.jsx("div", { ref: a, className: s, style: r });
3466
+ }
3467
+ );
3468
+ di.displayName = "FableEditor";
3469
+ export {
3470
+ di as FableEditor
3471
+ };