@anilkumarteach/editor-ak 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2454 @@
1
+ import gt, { useState as R, useRef as F, useEffect as z, useCallback as C } from "react";
2
+ var Me = { exports: {} }, be = {};
3
+ var ut;
4
+ function Ft() {
5
+ if (ut) return be;
6
+ ut = 1;
7
+ var r = gt, n = /* @__PURE__ */ Symbol.for("react.element"), d = /* @__PURE__ */ Symbol.for("react.fragment"), o = Object.prototype.hasOwnProperty, i = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
8
+ function c(m, x, k) {
9
+ var p, j = {}, h = null, f = null;
10
+ k !== void 0 && (h = "" + k), x.key !== void 0 && (h = "" + x.key), x.ref !== void 0 && (f = x.ref);
11
+ for (p in x) o.call(x, p) && !s.hasOwnProperty(p) && (j[p] = x[p]);
12
+ if (m && m.defaultProps) for (p in x = m.defaultProps, x) j[p] === void 0 && (j[p] = x[p]);
13
+ return { $$typeof: n, type: m, key: h, ref: f, props: j, _owner: i.current };
14
+ }
15
+ return be.Fragment = d, be.jsx = c, be.jsxs = c, be;
16
+ }
17
+ var je = {};
18
+ var ft;
19
+ function Ut() {
20
+ return ft || (ft = 1, process.env.NODE_ENV !== "production" && (function() {
21
+ var r = gt, n = /* @__PURE__ */ Symbol.for("react.element"), d = /* @__PURE__ */ Symbol.for("react.portal"), o = /* @__PURE__ */ Symbol.for("react.fragment"), i = /* @__PURE__ */ Symbol.for("react.strict_mode"), s = /* @__PURE__ */ Symbol.for("react.profiler"), c = /* @__PURE__ */ Symbol.for("react.provider"), m = /* @__PURE__ */ Symbol.for("react.context"), x = /* @__PURE__ */ Symbol.for("react.forward_ref"), k = /* @__PURE__ */ Symbol.for("react.suspense"), p = /* @__PURE__ */ Symbol.for("react.suspense_list"), j = /* @__PURE__ */ Symbol.for("react.memo"), h = /* @__PURE__ */ Symbol.for("react.lazy"), f = /* @__PURE__ */ Symbol.for("react.offscreen"), g = Symbol.iterator, N = "@@iterator";
22
+ function M(t) {
23
+ if (t === null || typeof t != "object")
24
+ return null;
25
+ var a = g && t[g] || t[N];
26
+ return typeof a == "function" ? a : null;
27
+ }
28
+ var S = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
29
+ function I(t) {
30
+ {
31
+ for (var a = arguments.length, u = new Array(a > 1 ? a - 1 : 0), b = 1; b < a; b++)
32
+ u[b - 1] = arguments[b];
33
+ Z("error", t, u);
34
+ }
35
+ }
36
+ function Z(t, a, u) {
37
+ {
38
+ var b = S.ReactDebugCurrentFrame, E = b.getStackAddendum();
39
+ E !== "" && (a += "%s", u = u.concat([E]));
40
+ var $ = u.map(function(T) {
41
+ return String(T);
42
+ });
43
+ $.unshift("Warning: " + a), Function.prototype.apply.call(console[t], console, $);
44
+ }
45
+ }
46
+ var _ = !1, U = !1, H = !1, ae = !1, ke = !1, ye;
47
+ ye = /* @__PURE__ */ Symbol.for("react.module.reference");
48
+ function Pe(t) {
49
+ return !!(typeof t == "string" || typeof t == "function" || t === o || t === s || ke || t === i || t === k || t === p || ae || t === f || _ || U || H || typeof t == "object" && t !== null && (t.$$typeof === h || t.$$typeof === j || t.$$typeof === c || t.$$typeof === m || t.$$typeof === x || // This needs to include all possible module reference object
50
+ // types supported by any Flight configuration anywhere since
51
+ // we don't know which Flight build this will end up being used
52
+ // with.
53
+ t.$$typeof === ye || t.getModuleId !== void 0));
54
+ }
55
+ function we(t, a, u) {
56
+ var b = t.displayName;
57
+ if (b)
58
+ return b;
59
+ var E = a.displayName || a.name || "";
60
+ return E !== "" ? u + "(" + E + ")" : u;
61
+ }
62
+ function B(t) {
63
+ return t.displayName || "Context";
64
+ }
65
+ function X(t) {
66
+ if (t == null)
67
+ return null;
68
+ if (typeof t.tag == "number" && I("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof t == "function")
69
+ return t.displayName || t.name || null;
70
+ if (typeof t == "string")
71
+ return t;
72
+ switch (t) {
73
+ case o:
74
+ return "Fragment";
75
+ case d:
76
+ return "Portal";
77
+ case s:
78
+ return "Profiler";
79
+ case i:
80
+ return "StrictMode";
81
+ case k:
82
+ return "Suspense";
83
+ case p:
84
+ return "SuspenseList";
85
+ }
86
+ if (typeof t == "object")
87
+ switch (t.$$typeof) {
88
+ case m:
89
+ var a = t;
90
+ return B(a) + ".Consumer";
91
+ case c:
92
+ var u = t;
93
+ return B(u._context) + ".Provider";
94
+ case x:
95
+ return we(t, t.render, "ForwardRef");
96
+ case j:
97
+ var b = t.displayName || null;
98
+ return b !== null ? b : X(t.type) || "Memo";
99
+ case h: {
100
+ var E = t, $ = E._payload, T = E._init;
101
+ try {
102
+ return X(T($));
103
+ } catch {
104
+ return null;
105
+ }
106
+ }
107
+ }
108
+ return null;
109
+ }
110
+ var K = Object.assign, ee = 0, Ce, Ne, me, Le, Te, Se, W;
111
+ function Y() {
112
+ }
113
+ Y.__reactDisabledLog = !0;
114
+ function Ae() {
115
+ {
116
+ if (ee === 0) {
117
+ Ce = console.log, Ne = console.info, me = console.warn, Le = console.error, Te = console.group, Se = console.groupCollapsed, W = console.groupEnd;
118
+ var t = {
119
+ configurable: !0,
120
+ enumerable: !0,
121
+ value: Y,
122
+ writable: !0
123
+ };
124
+ Object.defineProperties(console, {
125
+ info: t,
126
+ log: t,
127
+ warn: t,
128
+ error: t,
129
+ group: t,
130
+ groupCollapsed: t,
131
+ groupEnd: t
132
+ });
133
+ }
134
+ ee++;
135
+ }
136
+ }
137
+ function He() {
138
+ {
139
+ if (ee--, ee === 0) {
140
+ var t = {
141
+ configurable: !0,
142
+ enumerable: !0,
143
+ writable: !0
144
+ };
145
+ Object.defineProperties(console, {
146
+ log: K({}, t, {
147
+ value: Ce
148
+ }),
149
+ info: K({}, t, {
150
+ value: Ne
151
+ }),
152
+ warn: K({}, t, {
153
+ value: me
154
+ }),
155
+ error: K({}, t, {
156
+ value: Le
157
+ }),
158
+ group: K({}, t, {
159
+ value: Te
160
+ }),
161
+ groupCollapsed: K({}, t, {
162
+ value: Se
163
+ }),
164
+ groupEnd: K({}, t, {
165
+ value: W
166
+ })
167
+ });
168
+ }
169
+ ee < 0 && I("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
170
+ }
171
+ }
172
+ var he = S.ReactCurrentDispatcher, pe;
173
+ function Q(t, a, u) {
174
+ {
175
+ if (pe === void 0)
176
+ try {
177
+ throw Error();
178
+ } catch (E) {
179
+ var b = E.stack.trim().match(/\n( *(at )?)/);
180
+ pe = b && b[1] || "";
181
+ }
182
+ return `
183
+ ` + pe + t;
184
+ }
185
+ }
186
+ var xe = !1, te;
187
+ {
188
+ var Be = typeof WeakMap == "function" ? WeakMap : Map;
189
+ te = new Be();
190
+ }
191
+ function ie(t, a) {
192
+ if (!t || xe)
193
+ return "";
194
+ {
195
+ var u = te.get(t);
196
+ if (u !== void 0)
197
+ return u;
198
+ }
199
+ var b;
200
+ xe = !0;
201
+ var E = Error.prepareStackTrace;
202
+ Error.prepareStackTrace = void 0;
203
+ var $;
204
+ $ = he.current, he.current = null, Ae();
205
+ try {
206
+ if (a) {
207
+ var T = function() {
208
+ throw Error();
209
+ };
210
+ if (Object.defineProperty(T.prototype, "props", {
211
+ set: function() {
212
+ throw Error();
213
+ }
214
+ }), typeof Reflect == "object" && Reflect.construct) {
215
+ try {
216
+ Reflect.construct(T, []);
217
+ } catch (q) {
218
+ b = q;
219
+ }
220
+ Reflect.construct(t, [], T);
221
+ } else {
222
+ try {
223
+ T.call();
224
+ } catch (q) {
225
+ b = q;
226
+ }
227
+ t.call(T.prototype);
228
+ }
229
+ } else {
230
+ try {
231
+ throw Error();
232
+ } catch (q) {
233
+ b = q;
234
+ }
235
+ t();
236
+ }
237
+ } catch (q) {
238
+ if (q && b && typeof q.stack == "string") {
239
+ for (var w = q.stack.split(`
240
+ `), V = b.stack.split(`
241
+ `), O = w.length - 1, P = V.length - 1; O >= 1 && P >= 0 && w[O] !== V[P]; )
242
+ P--;
243
+ for (; O >= 1 && P >= 0; O--, P--)
244
+ if (w[O] !== V[P]) {
245
+ if (O !== 1 || P !== 1)
246
+ do
247
+ if (O--, P--, P < 0 || w[O] !== V[P]) {
248
+ var J = `
249
+ ` + w[O].replace(" at new ", " at ");
250
+ return t.displayName && J.includes("<anonymous>") && (J = J.replace("<anonymous>", t.displayName)), typeof t == "function" && te.set(t, J), J;
251
+ }
252
+ while (O >= 1 && P >= 0);
253
+ break;
254
+ }
255
+ }
256
+ } finally {
257
+ xe = !1, he.current = $, He(), Error.prepareStackTrace = E;
258
+ }
259
+ var fe = t ? t.displayName || t.name : "", oe = fe ? Q(fe) : "";
260
+ return typeof t == "function" && te.set(t, oe), oe;
261
+ }
262
+ function ge(t, a, u) {
263
+ return ie(t, !1);
264
+ }
265
+ function le(t) {
266
+ var a = t.prototype;
267
+ return !!(a && a.isReactComponent);
268
+ }
269
+ function ce(t, a, u) {
270
+ if (t == null)
271
+ return "";
272
+ if (typeof t == "function")
273
+ return ie(t, le(t));
274
+ if (typeof t == "string")
275
+ return Q(t);
276
+ switch (t) {
277
+ case k:
278
+ return Q("Suspense");
279
+ case p:
280
+ return Q("SuspenseList");
281
+ }
282
+ if (typeof t == "object")
283
+ switch (t.$$typeof) {
284
+ case x:
285
+ return ge(t.render);
286
+ case j:
287
+ return ce(t.type, a, u);
288
+ case h: {
289
+ var b = t, E = b._payload, $ = b._init;
290
+ try {
291
+ return ce($(E), a, u);
292
+ } catch {
293
+ }
294
+ }
295
+ }
296
+ return "";
297
+ }
298
+ var re = Object.prototype.hasOwnProperty, Re = {}, Ee = S.ReactDebugCurrentFrame;
299
+ function de(t) {
300
+ if (t) {
301
+ var a = t._owner, u = ce(t.type, t._source, a ? a.type : null);
302
+ Ee.setExtraStackFrame(u);
303
+ } else
304
+ Ee.setExtraStackFrame(null);
305
+ }
306
+ function We(t, a, u, b, E) {
307
+ {
308
+ var $ = Function.call.bind(re);
309
+ for (var T in t)
310
+ if ($(t, T)) {
311
+ var w = void 0;
312
+ try {
313
+ if (typeof t[T] != "function") {
314
+ var V = Error((b || "React class") + ": " + u + " type `" + T + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof t[T] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
315
+ throw V.name = "Invariant Violation", V;
316
+ }
317
+ w = t[T](a, T, b, u, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
318
+ } catch (O) {
319
+ w = O;
320
+ }
321
+ w && !(w instanceof Error) && (de(E), I("%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).", b || "React class", u, T, typeof w), de(null)), w instanceof Error && !(w.message in Re) && (Re[w.message] = !0, de(E), I("Failed %s type: %s", u, w.message), de(null));
322
+ }
323
+ }
324
+ }
325
+ var Ve = Array.isArray;
326
+ function ve(t) {
327
+ return Ve(t);
328
+ }
329
+ function Fe(t) {
330
+ {
331
+ var a = typeof Symbol == "function" && Symbol.toStringTag, u = a && t[Symbol.toStringTag] || t.constructor.name || "Object";
332
+ return u;
333
+ }
334
+ }
335
+ function l(t) {
336
+ try {
337
+ return y(t), !1;
338
+ } catch {
339
+ return !0;
340
+ }
341
+ }
342
+ function y(t) {
343
+ return "" + t;
344
+ }
345
+ function L(t) {
346
+ if (l(t))
347
+ return I("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Fe(t)), y(t);
348
+ }
349
+ var v = S.ReactCurrentOwner, D = {
350
+ key: !0,
351
+ ref: !0,
352
+ __self: !0,
353
+ __source: !0
354
+ }, G, ne;
355
+ function Ue(t) {
356
+ if (re.call(t, "ref")) {
357
+ var a = Object.getOwnPropertyDescriptor(t, "ref").get;
358
+ if (a && a.isReactWarning)
359
+ return !1;
360
+ }
361
+ return t.ref !== void 0;
362
+ }
363
+ function qe(t) {
364
+ if (re.call(t, "key")) {
365
+ var a = Object.getOwnPropertyDescriptor(t, "key").get;
366
+ if (a && a.isReactWarning)
367
+ return !1;
368
+ }
369
+ return t.key !== void 0;
370
+ }
371
+ function ze(t, a) {
372
+ typeof t.ref == "string" && v.current;
373
+ }
374
+ function Ye(t, a) {
375
+ {
376
+ var u = function() {
377
+ G || (G = !0, I("%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)", a));
378
+ };
379
+ u.isReactWarning = !0, Object.defineProperty(t, "key", {
380
+ get: u,
381
+ configurable: !0
382
+ });
383
+ }
384
+ }
385
+ function _e(t, a) {
386
+ {
387
+ var u = function() {
388
+ ne || (ne = !0, I("%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)", a));
389
+ };
390
+ u.isReactWarning = !0, Object.defineProperty(t, "ref", {
391
+ get: u,
392
+ configurable: !0
393
+ });
394
+ }
395
+ }
396
+ var $e = function(t, a, u, b, E, $, T) {
397
+ var w = {
398
+ // This tag allows us to uniquely identify this as a React Element
399
+ $$typeof: n,
400
+ // Built-in properties that belong on the element
401
+ type: t,
402
+ key: a,
403
+ ref: u,
404
+ props: T,
405
+ // Record the component responsible for creating this element.
406
+ _owner: $
407
+ };
408
+ return w._store = {}, Object.defineProperty(w._store, "validated", {
409
+ configurable: !1,
410
+ enumerable: !1,
411
+ writable: !0,
412
+ value: !1
413
+ }), Object.defineProperty(w, "_self", {
414
+ configurable: !1,
415
+ enumerable: !1,
416
+ writable: !1,
417
+ value: b
418
+ }), Object.defineProperty(w, "_source", {
419
+ configurable: !1,
420
+ enumerable: !1,
421
+ writable: !1,
422
+ value: E
423
+ }), Object.freeze && (Object.freeze(w.props), Object.freeze(w)), w;
424
+ };
425
+ function $t(t, a, u, b, E) {
426
+ {
427
+ var $, T = {}, w = null, V = null;
428
+ u !== void 0 && (L(u), w = "" + u), qe(a) && (L(a.key), w = "" + a.key), Ue(a) && (V = a.ref, ze(a, E));
429
+ for ($ in a)
430
+ re.call(a, $) && !D.hasOwnProperty($) && (T[$] = a[$]);
431
+ if (t && t.defaultProps) {
432
+ var O = t.defaultProps;
433
+ for ($ in O)
434
+ T[$] === void 0 && (T[$] = O[$]);
435
+ }
436
+ if (w || V) {
437
+ var P = typeof t == "function" ? t.displayName || t.name || "Unknown" : t;
438
+ w && Ye(T, P), V && _e(T, P);
439
+ }
440
+ return $e(t, w, V, E, b, v.current, T);
441
+ }
442
+ }
443
+ var Je = S.ReactCurrentOwner, ot = S.ReactDebugCurrentFrame;
444
+ function ue(t) {
445
+ if (t) {
446
+ var a = t._owner, u = ce(t.type, t._source, a ? a.type : null);
447
+ ot.setExtraStackFrame(u);
448
+ } else
449
+ ot.setExtraStackFrame(null);
450
+ }
451
+ var Ke;
452
+ Ke = !1;
453
+ function Ge(t) {
454
+ return typeof t == "object" && t !== null && t.$$typeof === n;
455
+ }
456
+ function st() {
457
+ {
458
+ if (Je.current) {
459
+ var t = X(Je.current.type);
460
+ if (t)
461
+ return `
462
+
463
+ Check the render method of \`` + t + "`.";
464
+ }
465
+ return "";
466
+ }
467
+ }
468
+ function Mt(t) {
469
+ return "";
470
+ }
471
+ var at = {};
472
+ function It(t) {
473
+ {
474
+ var a = st();
475
+ if (!a) {
476
+ var u = typeof t == "string" ? t : t.displayName || t.name;
477
+ u && (a = `
478
+
479
+ Check the top-level render call using <` + u + ">.");
480
+ }
481
+ return a;
482
+ }
483
+ }
484
+ function it(t, a) {
485
+ {
486
+ if (!t._store || t._store.validated || t.key != null)
487
+ return;
488
+ t._store.validated = !0;
489
+ var u = It(a);
490
+ if (at[u])
491
+ return;
492
+ at[u] = !0;
493
+ var b = "";
494
+ t && t._owner && t._owner !== Je.current && (b = " It was passed a child from " + X(t._owner.type) + "."), ue(t), I('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', u, b), ue(null);
495
+ }
496
+ }
497
+ function lt(t, a) {
498
+ {
499
+ if (typeof t != "object")
500
+ return;
501
+ if (ve(t))
502
+ for (var u = 0; u < t.length; u++) {
503
+ var b = t[u];
504
+ Ge(b) && it(b, a);
505
+ }
506
+ else if (Ge(t))
507
+ t._store && (t._store.validated = !0);
508
+ else if (t) {
509
+ var E = M(t);
510
+ if (typeof E == "function" && E !== t.entries)
511
+ for (var $ = E.call(t), T; !(T = $.next()).done; )
512
+ Ge(T.value) && it(T.value, a);
513
+ }
514
+ }
515
+ }
516
+ function Dt(t) {
517
+ {
518
+ var a = t.type;
519
+ if (a == null || typeof a == "string")
520
+ return;
521
+ var u;
522
+ if (typeof a == "function")
523
+ u = a.propTypes;
524
+ else if (typeof a == "object" && (a.$$typeof === x || // Note: Memo only checks outer props here.
525
+ // Inner props are checked in the reconciler.
526
+ a.$$typeof === j))
527
+ u = a.propTypes;
528
+ else
529
+ return;
530
+ if (u) {
531
+ var b = X(a);
532
+ We(u, t.props, "prop", b, t);
533
+ } else if (a.PropTypes !== void 0 && !Ke) {
534
+ Ke = !0;
535
+ var E = X(a);
536
+ I("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", E || "Unknown");
537
+ }
538
+ typeof a.getDefaultProps == "function" && !a.getDefaultProps.isReactClassApproved && I("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
539
+ }
540
+ }
541
+ function Ot(t) {
542
+ {
543
+ for (var a = Object.keys(t.props), u = 0; u < a.length; u++) {
544
+ var b = a[u];
545
+ if (b !== "children" && b !== "key") {
546
+ ue(t), I("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", b), ue(null);
547
+ break;
548
+ }
549
+ }
550
+ t.ref !== null && (ue(t), I("Invalid attribute `ref` supplied to `React.Fragment`."), ue(null));
551
+ }
552
+ }
553
+ var ct = {};
554
+ function dt(t, a, u, b, E, $) {
555
+ {
556
+ var T = Pe(t);
557
+ if (!T) {
558
+ var w = "";
559
+ (t === void 0 || typeof t == "object" && t !== null && Object.keys(t).length === 0) && (w += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
560
+ var V = Mt();
561
+ V ? w += V : w += st();
562
+ var O;
563
+ t === null ? O = "null" : ve(t) ? O = "array" : t !== void 0 && t.$$typeof === n ? (O = "<" + (X(t.type) || "Unknown") + " />", w = " Did you accidentally export a JSX literal instead of a component?") : O = typeof t, I("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", O, w);
564
+ }
565
+ var P = $t(t, a, u, E, $);
566
+ if (P == null)
567
+ return P;
568
+ if (T) {
569
+ var J = a.children;
570
+ if (J !== void 0)
571
+ if (b)
572
+ if (ve(J)) {
573
+ for (var fe = 0; fe < J.length; fe++)
574
+ lt(J[fe], t);
575
+ Object.freeze && Object.freeze(J);
576
+ } else
577
+ I("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
578
+ else
579
+ lt(J, t);
580
+ }
581
+ if (re.call(a, "key")) {
582
+ var oe = X(t), q = Object.keys(a).filter(function(Vt) {
583
+ return Vt !== "key";
584
+ }), Xe = q.length > 0 ? "{key: someKey, " + q.join(": ..., ") + ": ...}" : "{key: someKey}";
585
+ if (!ct[oe + Xe]) {
586
+ var Wt = q.length > 0 ? "{" + q.join(": ..., ") + ": ...}" : "{}";
587
+ I(`A props object containing a "key" prop is being spread into JSX:
588
+ let props = %s;
589
+ <%s {...props} />
590
+ React keys must be passed directly to JSX without using spread:
591
+ let props = %s;
592
+ <%s key={someKey} {...props} />`, Xe, oe, Wt, oe), ct[oe + Xe] = !0;
593
+ }
594
+ }
595
+ return t === o ? Ot(P) : Dt(P), P;
596
+ }
597
+ }
598
+ function Pt(t, a, u) {
599
+ return dt(t, a, u, !0);
600
+ }
601
+ function At(t, a, u) {
602
+ return dt(t, a, u, !1);
603
+ }
604
+ var Ht = At, Bt = Pt;
605
+ je.Fragment = o, je.jsx = Ht, je.jsxs = Bt;
606
+ })()), je;
607
+ }
608
+ var mt;
609
+ function qt() {
610
+ return mt || (mt = 1, process.env.NODE_ENV === "production" ? Me.exports = Ft() : Me.exports = Ut()), Me.exports;
611
+ }
612
+ var e = qt();
613
+ const vt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
614
+ /* @__PURE__ */ e.jsx("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
615
+ /* @__PURE__ */ e.jsx("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
616
+ ] }), bt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
617
+ /* @__PURE__ */ e.jsx("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
618
+ /* @__PURE__ */ e.jsx("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
619
+ /* @__PURE__ */ e.jsx("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
620
+ ] }), jt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
621
+ /* @__PURE__ */ e.jsx("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
622
+ /* @__PURE__ */ e.jsx("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
623
+ ] }), kt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
624
+ /* @__PURE__ */ e.jsx("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
625
+ /* @__PURE__ */ e.jsx("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
626
+ /* @__PURE__ */ e.jsx("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
627
+ ] }), yt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
628
+ /* @__PURE__ */ e.jsx("line", { x1: "8", y1: "6", x2: "21", y2: "6" }),
629
+ /* @__PURE__ */ e.jsx("line", { x1: "8", y1: "12", x2: "21", y2: "12" }),
630
+ /* @__PURE__ */ e.jsx("line", { x1: "8", y1: "18", x2: "21", y2: "18" }),
631
+ /* @__PURE__ */ e.jsx("line", { x1: "3", y1: "6", x2: "3.01", y2: "6" }),
632
+ /* @__PURE__ */ e.jsx("line", { x1: "3", y1: "12", x2: "3.01", y2: "12" }),
633
+ /* @__PURE__ */ e.jsx("line", { x1: "3", y1: "18", x2: "3.01", y2: "18" })
634
+ ] }), wt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
635
+ /* @__PURE__ */ e.jsx("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
636
+ /* @__PURE__ */ e.jsx("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
637
+ /* @__PURE__ */ e.jsx("line", { x1: "10", y1: "18", x2: "21", y2: "18" }),
638
+ /* @__PURE__ */ e.jsx("path", { d: "M4 6h1v4" }),
639
+ /* @__PURE__ */ e.jsx("path", { d: "M4 10h2" }),
640
+ /* @__PURE__ */ e.jsx("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
641
+ ] }), Ct = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
642
+ /* @__PURE__ */ e.jsx("polyline", { points: "9 11 12 14 22 4" }),
643
+ /* @__PURE__ */ e.jsx("path", { d: "M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11" })
644
+ ] }), Nt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
645
+ /* @__PURE__ */ e.jsx("path", { d: "M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z" }),
646
+ /* @__PURE__ */ e.jsx("path", { d: "M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v4z" })
647
+ ] }), De = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
648
+ /* @__PURE__ */ e.jsx("polyline", { points: "16 18 22 12 16 6" }),
649
+ /* @__PURE__ */ e.jsx("polyline", { points: "8 6 2 12 8 18" })
650
+ ] }), Lt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsx("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e.jsx("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) }), Oe = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
651
+ /* @__PURE__ */ e.jsx("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
652
+ /* @__PURE__ */ e.jsx("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
653
+ ] }), zt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
654
+ /* @__PURE__ */ e.jsx("path", { d: "M3 7v6h6" }),
655
+ /* @__PURE__ */ e.jsx("path", { d: "M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13" })
656
+ ] }), Yt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
657
+ /* @__PURE__ */ e.jsx("path", { d: "M21 7v6h-6" }),
658
+ /* @__PURE__ */ e.jsx("path", { d: "M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7" })
659
+ ] }), Tt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsx("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e.jsx("polyline", { points: "6 9 12 15 18 9" }) }), Jt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsx("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e.jsx("polyline", { points: "20 6 9 17 4 12" }) }), St = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
660
+ /* @__PURE__ */ e.jsx("polyline", { points: "4 7 4 4 20 4 20 7" }),
661
+ /* @__PURE__ */ e.jsx("line", { x1: "9", y1: "20", x2: "15", y2: "20" }),
662
+ /* @__PURE__ */ e.jsx("line", { x1: "12", y1: "4", x2: "12", y2: "20" })
663
+ ] }), Rt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
664
+ /* @__PURE__ */ e.jsx("path", { d: "M4 12h8" }),
665
+ /* @__PURE__ */ e.jsx("path", { d: "M4 18V6" }),
666
+ /* @__PURE__ */ e.jsx("path", { d: "M12 18V6" }),
667
+ /* @__PURE__ */ e.jsx("path", { d: "m17 12 3-2v8" })
668
+ ] }), Et = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
669
+ /* @__PURE__ */ e.jsx("path", { d: "M4 12h8" }),
670
+ /* @__PURE__ */ e.jsx("path", { d: "M4 18V6" }),
671
+ /* @__PURE__ */ e.jsx("path", { d: "M12 18V6" }),
672
+ /* @__PURE__ */ e.jsx("path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" })
673
+ ] }), _t = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
674
+ /* @__PURE__ */ e.jsx("path", { d: "M4 12h8" }),
675
+ /* @__PURE__ */ e.jsx("path", { d: "M4 18V6" }),
676
+ /* @__PURE__ */ e.jsx("path", { d: "M12 18V6" }),
677
+ /* @__PURE__ */ e.jsx("path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2" }),
678
+ /* @__PURE__ */ e.jsx("path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" })
679
+ ] }), Ie = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
680
+ /* @__PURE__ */ e.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
681
+ /* @__PURE__ */ e.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
682
+ ] }), tt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
683
+ /* @__PURE__ */ e.jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }),
684
+ /* @__PURE__ */ e.jsx("circle", { cx: "8.5", cy: "8.5", r: "1.5" }),
685
+ /* @__PURE__ */ e.jsx("polyline", { points: "21 15 16 10 5 21" })
686
+ ] }), rt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
687
+ /* @__PURE__ */ e.jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
688
+ /* @__PURE__ */ e.jsx("path", { d: "M3 9h18" }),
689
+ /* @__PURE__ */ e.jsx("path", { d: "M3 15h18" }),
690
+ /* @__PURE__ */ e.jsx("path", { d: "M9 3v18" }),
691
+ /* @__PURE__ */ e.jsx("path", { d: "M15 3v18" })
692
+ ] }), Kt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
693
+ /* @__PURE__ */ e.jsx("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
694
+ /* @__PURE__ */ e.jsx("polyline", { points: "7 10 12 15 17 10" }),
695
+ /* @__PURE__ */ e.jsx("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
696
+ ] }), Gt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
697
+ /* @__PURE__ */ e.jsx("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
698
+ /* @__PURE__ */ e.jsx("polyline", { points: "14 2 14 8 20 8" }),
699
+ /* @__PURE__ */ e.jsx("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
700
+ /* @__PURE__ */ e.jsx("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
701
+ /* @__PURE__ */ e.jsx("line", { x1: "10", y1: "9", x2: "8", y2: "9" })
702
+ ] }), ht = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
703
+ /* @__PURE__ */ e.jsx("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
704
+ /* @__PURE__ */ e.jsx("polyline", { points: "17 8 12 3 7 8" }),
705
+ /* @__PURE__ */ e.jsx("line", { x1: "12", y1: "3", x2: "12", y2: "15" })
706
+ ] }), et = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
707
+ /* @__PURE__ */ e.jsx("circle", { cx: "12", cy: "12", r: "10" }),
708
+ /* @__PURE__ */ e.jsx("polyline", { points: "12 6 12 12 16 14" })
709
+ ] }), Xt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
710
+ /* @__PURE__ */ e.jsx("polyline", { points: "3 6 5 6 21 6" }),
711
+ /* @__PURE__ */ e.jsx("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }),
712
+ /* @__PURE__ */ e.jsx("line", { x1: "10", y1: "11", x2: "10", y2: "17" }),
713
+ /* @__PURE__ */ e.jsx("line", { x1: "14", y1: "11", x2: "14", y2: "17" })
714
+ ] }), Qt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
715
+ /* @__PURE__ */ e.jsx("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
716
+ /* @__PURE__ */ e.jsx("path", { d: "M3 3v5h5" })
717
+ ] }), Zt = ({ className: r = "w-4 h-4" }) => /* @__PURE__ */ e.jsxs("svg", { className: r, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
718
+ /* @__PURE__ */ e.jsx("path", { d: "M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z" }),
719
+ /* @__PURE__ */ e.jsx("polyline", { points: "14 2 14 8 20 8" }),
720
+ /* @__PURE__ */ e.jsx("circle", { cx: "10", cy: "13", r: "2" }),
721
+ /* @__PURE__ */ e.jsx("path", { d: "m20 17-1.09-1.09a2 2 0 0 0-2.82 0L10 22" })
722
+ ] }), nt = ({
723
+ content: r,
724
+ children: n,
725
+ position: d = "bottom",
726
+ shortcut: o
727
+ }) => {
728
+ const [i, s] = R(!1), [c, m] = R({ x: 0, y: 0 }), x = F(null), k = F(null), p = F(), j = () => {
729
+ p.current = window.setTimeout(() => {
730
+ s(!0);
731
+ }, 400);
732
+ }, h = () => {
733
+ p.current && clearTimeout(p.current), s(!1);
734
+ };
735
+ return z(() => {
736
+ if (i && x.current && k.current) {
737
+ const f = x.current.getBoundingClientRect(), g = k.current.getBoundingClientRect();
738
+ let N = 0, M = 0;
739
+ switch (d) {
740
+ case "top":
741
+ N = f.left + (f.width - g.width) / 2, M = f.top - g.height - 8;
742
+ break;
743
+ case "bottom":
744
+ N = f.left + (f.width - g.width) / 2, M = f.bottom + 8;
745
+ break;
746
+ case "left":
747
+ N = f.left - g.width - 8, M = f.top + (f.height - g.height) / 2;
748
+ break;
749
+ case "right":
750
+ N = f.right + 8, M = f.top + (f.height - g.height) / 2;
751
+ break;
752
+ }
753
+ N = Math.max(8, Math.min(N, window.innerWidth - g.width - 8)), M = Math.max(8, Math.min(M, window.innerHeight - g.height - 8)), m({ x: N, y: M });
754
+ }
755
+ }, [i, d]), z(() => () => {
756
+ p.current && clearTimeout(p.current);
757
+ }, []), /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
758
+ /* @__PURE__ */ e.jsx(
759
+ "div",
760
+ {
761
+ ref: x,
762
+ onMouseEnter: j,
763
+ onMouseLeave: h,
764
+ onFocus: j,
765
+ onBlur: h,
766
+ className: "inline-flex",
767
+ children: n
768
+ }
769
+ ),
770
+ i && /* @__PURE__ */ e.jsxs(
771
+ "div",
772
+ {
773
+ ref: k,
774
+ className: "fixed z-50 px-2.5 py-1.5 text-xs font-medium rounded-md shadow-lg animate-fade-in pointer-events-none bg-tooltip text-tooltip-foreground",
775
+ style: {
776
+ left: c.x,
777
+ top: c.y
778
+ },
779
+ children: [
780
+ /* @__PURE__ */ e.jsx("span", { children: r }),
781
+ o && /* @__PURE__ */ e.jsx("span", { className: "ml-2 opacity-70 font-mono", children: o })
782
+ ]
783
+ }
784
+ )
785
+ ] });
786
+ }, A = ({
787
+ icon: r,
788
+ tooltip: n,
789
+ shortcut: d,
790
+ isActive: o = !1,
791
+ onClick: i,
792
+ disabled: s = !1
793
+ }) => {
794
+ const c = "p-2 rounded-md transition-all duration-150 flex items-center justify-center hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 disabled:opacity-40 disabled:cursor-not-allowed", m = o ? "bg-accent text-accent-foreground" : "";
795
+ return /* @__PURE__ */ e.jsx(nt, { content: n, shortcut: d, children: /* @__PURE__ */ e.jsx(
796
+ "button",
797
+ {
798
+ type: "button",
799
+ onClick: i,
800
+ disabled: s,
801
+ className: `${c} ${m}`,
802
+ "aria-pressed": o,
803
+ children: r
804
+ }
805
+ ) });
806
+ }, Qe = [
807
+ { name: "DM Sans", value: "dm-sans", className: "font-sans-editor" },
808
+ { name: "Merriweather", value: "merriweather", className: "font-serif-editor" },
809
+ { name: "Playfair Display", value: "playfair", className: "font-display-editor" },
810
+ { name: "JetBrains Mono", value: "jetbrains", className: "font-mono-editor" },
811
+ { name: "Arial", value: "arial", className: "font-arial" },
812
+ { name: "Georgia", value: "georgia", className: "font-georgia" },
813
+ { name: "Verdana", value: "verdana", className: "font-verdana" },
814
+ { name: "Courier New", value: "courier", className: "font-courier" },
815
+ { name: "Times New Roman", value: "times", className: "font-times" }
816
+ ], er = ({ currentFont: r, onFontChange: n }) => {
817
+ const [d, o] = R(!1), i = F(null), s = Qe.find((c) => c.value === r) || Qe[0];
818
+ return z(() => {
819
+ const c = (m) => {
820
+ i.current && !i.current.contains(m.target) && o(!1);
821
+ };
822
+ return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
823
+ }, []), /* @__PURE__ */ e.jsxs("div", { className: "relative", ref: i, children: [
824
+ /* @__PURE__ */ e.jsx(nt, { content: "Font family", children: /* @__PURE__ */ e.jsxs(
825
+ "button",
826
+ {
827
+ type: "button",
828
+ onClick: () => o(!d),
829
+ className: `flex items-center gap-1.5 px-3 py-1.5 rounded-md transition-all duration-150 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 text-sm font-medium min-w-[140px] justify-between ${d ? "bg-secondary" : ""}`,
830
+ children: [
831
+ /* @__PURE__ */ e.jsx("span", { className: s.className, children: s.name }),
832
+ /* @__PURE__ */ e.jsx(Tt, { className: `w-4 h-4 transition-transform duration-200 ${d ? "rotate-180" : ""}` })
833
+ ]
834
+ }
835
+ ) }),
836
+ d && /* @__PURE__ */ e.jsx("div", { className: "absolute top-full left-0 mt-1 w-52 py-1 rounded-lg shadow-dropdown animate-scale-in z-50 bg-popover border border-border", children: Qe.map((c) => /* @__PURE__ */ e.jsxs(
837
+ "button",
838
+ {
839
+ type: "button",
840
+ onClick: () => {
841
+ n(c), o(!1);
842
+ },
843
+ className: `w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors hover:bg-accent ${c.value === r ? "bg-accent" : ""}`,
844
+ children: [
845
+ /* @__PURE__ */ e.jsx("span", { className: `flex-1 text-left ${c.className}`, children: c.name }),
846
+ c.value === r && /* @__PURE__ */ e.jsx(Jt, { className: "w-4 h-4 text-primary" })
847
+ ]
848
+ },
849
+ c.value
850
+ )) })
851
+ ] });
852
+ }, Ze = [
853
+ { name: "Paragraph", value: "p", icon: /* @__PURE__ */ e.jsx(St, { className: "w-4 h-4" }) },
854
+ { name: "Heading 1", value: "h1", icon: /* @__PURE__ */ e.jsx(Rt, { className: "w-4 h-4" }) },
855
+ { name: "Heading 2", value: "h2", icon: /* @__PURE__ */ e.jsx(Et, { className: "w-4 h-4" }) },
856
+ { name: "Heading 3", value: "h3", icon: /* @__PURE__ */ e.jsx(_t, { className: "w-4 h-4" }) }
857
+ ], tr = ({ currentHeading: r, onHeadingChange: n }) => {
858
+ const [d, o] = R(!1), i = F(null), s = Ze.find((c) => c.value === r) || Ze[0];
859
+ return z(() => {
860
+ const c = (m) => {
861
+ i.current && !i.current.contains(m.target) && o(!1);
862
+ };
863
+ return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
864
+ }, []), /* @__PURE__ */ e.jsxs("div", { className: "relative", ref: i, children: [
865
+ /* @__PURE__ */ e.jsx(nt, { content: "Text style", children: /* @__PURE__ */ e.jsxs(
866
+ "button",
867
+ {
868
+ type: "button",
869
+ onClick: () => o(!d),
870
+ className: `flex items-center gap-1.5 px-3 py-1.5 rounded-md transition-all duration-150 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 text-sm font-medium min-w-[120px] justify-between ${d ? "bg-secondary" : ""}`,
871
+ children: [
872
+ /* @__PURE__ */ e.jsxs("span", { className: "flex items-center gap-2", children: [
873
+ s.icon,
874
+ s.name
875
+ ] }),
876
+ /* @__PURE__ */ e.jsx(Tt, { className: `w-4 h-4 transition-transform duration-200 ${d ? "rotate-180" : ""}` })
877
+ ]
878
+ }
879
+ ) }),
880
+ d && /* @__PURE__ */ e.jsx("div", { className: "absolute top-full left-0 mt-1 w-44 py-1 rounded-lg shadow-dropdown animate-scale-in z-50 bg-popover border border-border", children: Ze.map((c) => /* @__PURE__ */ e.jsxs(
881
+ "button",
882
+ {
883
+ type: "button",
884
+ onClick: () => {
885
+ n(c.value), o(!1);
886
+ },
887
+ className: `w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors hover:bg-accent ${c.value === r ? "bg-accent" : ""}`,
888
+ children: [
889
+ c.icon,
890
+ /* @__PURE__ */ e.jsx("span", { className: `${c.value === "h1" ? "text-lg font-bold" : ""} ${c.value === "h2" ? "text-base font-semibold" : ""} ${c.value === "h3" ? "text-sm font-semibold" : ""}`, children: c.name })
891
+ ]
892
+ },
893
+ c.value
894
+ )) })
895
+ ] });
896
+ }, rr = ({
897
+ formatState: r,
898
+ currentFont: n,
899
+ onFormat: d,
900
+ onFontChange: o,
901
+ onHeadingChange: i,
902
+ onUndo: s,
903
+ onRedo: c,
904
+ canUndo: m,
905
+ canRedo: x,
906
+ onInsertLink: k
907
+ }) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1 px-3 py-2 border-b rounded-t-lg flex-wrap bg-toolbar border-toolbar-border", children: [
908
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-0.5 mr-2", children: [
909
+ /* @__PURE__ */ e.jsx(
910
+ A,
911
+ {
912
+ icon: /* @__PURE__ */ e.jsx(zt, { className: "w-4 h-4" }),
913
+ tooltip: "Undo",
914
+ shortcut: "⌘Z",
915
+ onClick: s,
916
+ disabled: !m
917
+ }
918
+ ),
919
+ /* @__PURE__ */ e.jsx(
920
+ A,
921
+ {
922
+ icon: /* @__PURE__ */ e.jsx(Yt, { className: "w-4 h-4" }),
923
+ tooltip: "Redo",
924
+ shortcut: "⌘⇧Z",
925
+ onClick: c,
926
+ disabled: !x
927
+ }
928
+ )
929
+ ] }),
930
+ /* @__PURE__ */ e.jsx("div", { className: "w-px h-6 bg-border mx-1" }),
931
+ /* @__PURE__ */ e.jsx(er, { currentFont: n, onFontChange: o }),
932
+ /* @__PURE__ */ e.jsx(tr, { currentHeading: r.heading, onHeadingChange: i }),
933
+ /* @__PURE__ */ e.jsx("div", { className: "w-px h-6 bg-border mx-1" }),
934
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-0.5", children: [
935
+ /* @__PURE__ */ e.jsx(
936
+ A,
937
+ {
938
+ icon: /* @__PURE__ */ e.jsx(vt, { className: "w-4 h-4" }),
939
+ tooltip: "Bold",
940
+ shortcut: "⌘B",
941
+ isActive: r.bold,
942
+ onClick: () => d("bold")
943
+ }
944
+ ),
945
+ /* @__PURE__ */ e.jsx(
946
+ A,
947
+ {
948
+ icon: /* @__PURE__ */ e.jsx(bt, { className: "w-4 h-4" }),
949
+ tooltip: "Italic",
950
+ shortcut: "⌘I",
951
+ isActive: r.italic,
952
+ onClick: () => d("italic")
953
+ }
954
+ ),
955
+ /* @__PURE__ */ e.jsx(
956
+ A,
957
+ {
958
+ icon: /* @__PURE__ */ e.jsx(jt, { className: "w-4 h-4" }),
959
+ tooltip: "Underline",
960
+ shortcut: "⌘U",
961
+ isActive: r.underline,
962
+ onClick: () => d("underline")
963
+ }
964
+ ),
965
+ /* @__PURE__ */ e.jsx(
966
+ A,
967
+ {
968
+ icon: /* @__PURE__ */ e.jsx(kt, { className: "w-4 h-4" }),
969
+ tooltip: "Strikethrough",
970
+ shortcut: "⌘⇧S",
971
+ isActive: r.strikethrough,
972
+ onClick: () => d("strikethrough")
973
+ }
974
+ )
975
+ ] }),
976
+ /* @__PURE__ */ e.jsx("div", { className: "w-px h-6 bg-border mx-1" }),
977
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-0.5", children: [
978
+ /* @__PURE__ */ e.jsx(
979
+ A,
980
+ {
981
+ icon: /* @__PURE__ */ e.jsx(yt, { className: "w-4 h-4" }),
982
+ tooltip: "Bullet list",
983
+ shortcut: "⌘⇧8",
984
+ isActive: r.unorderedList,
985
+ onClick: () => d("unorderedList")
986
+ }
987
+ ),
988
+ /* @__PURE__ */ e.jsx(
989
+ A,
990
+ {
991
+ icon: /* @__PURE__ */ e.jsx(wt, { className: "w-4 h-4" }),
992
+ tooltip: "Numbered list",
993
+ shortcut: "⌘⇧7",
994
+ isActive: r.orderedList,
995
+ onClick: () => d("orderedList")
996
+ }
997
+ ),
998
+ /* @__PURE__ */ e.jsx(
999
+ A,
1000
+ {
1001
+ icon: /* @__PURE__ */ e.jsx(Ct, { className: "w-4 h-4" }),
1002
+ tooltip: "Task list",
1003
+ shortcut: "⌘⇧9",
1004
+ isActive: r.taskList,
1005
+ onClick: () => d("taskList")
1006
+ }
1007
+ )
1008
+ ] }),
1009
+ /* @__PURE__ */ e.jsx("div", { className: "w-px h-6 bg-border mx-1" }),
1010
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-0.5", children: [
1011
+ /* @__PURE__ */ e.jsx(
1012
+ A,
1013
+ {
1014
+ icon: /* @__PURE__ */ e.jsx(Nt, { className: "w-4 h-4" }),
1015
+ tooltip: "Blockquote",
1016
+ shortcut: "⌘⇧B",
1017
+ isActive: r.blockquote,
1018
+ onClick: () => d("blockquote")
1019
+ }
1020
+ ),
1021
+ /* @__PURE__ */ e.jsx(
1022
+ A,
1023
+ {
1024
+ icon: /* @__PURE__ */ e.jsx(De, { className: "w-4 h-4" }),
1025
+ tooltip: "Code block",
1026
+ shortcut: "⌘⇧C",
1027
+ isActive: r.code,
1028
+ onClick: () => d("code")
1029
+ }
1030
+ ),
1031
+ /* @__PURE__ */ e.jsx(
1032
+ A,
1033
+ {
1034
+ icon: /* @__PURE__ */ e.jsx(Lt, { className: "w-4 h-4" }),
1035
+ tooltip: "Horizontal rule",
1036
+ onClick: () => d("horizontalRule")
1037
+ }
1038
+ )
1039
+ ] }),
1040
+ /* @__PURE__ */ e.jsx("div", { className: "w-px h-6 bg-border mx-1" }),
1041
+ /* @__PURE__ */ e.jsx(
1042
+ A,
1043
+ {
1044
+ icon: /* @__PURE__ */ e.jsx(Oe, { className: "w-4 h-4" }),
1045
+ tooltip: "Insert link",
1046
+ shortcut: "⌘K",
1047
+ onClick: k
1048
+ }
1049
+ )
1050
+ ] }), nr = ({
1051
+ formatState: r,
1052
+ onFormat: n,
1053
+ onInsertLink: d,
1054
+ editorRef: o
1055
+ }) => {
1056
+ const [i, s] = R(!1), [c, m] = R({ x: 0, y: 0 }), x = F(null);
1057
+ return z(() => {
1058
+ const k = () => {
1059
+ const p = window.getSelection();
1060
+ if (!p || p.isCollapsed || !o.current) {
1061
+ s(!1);
1062
+ return;
1063
+ }
1064
+ const j = p.getRangeAt(0);
1065
+ if (!o.current.contains(j.commonAncestorContainer)) {
1066
+ s(!1);
1067
+ return;
1068
+ }
1069
+ if (!p.toString().trim()) {
1070
+ s(!1);
1071
+ return;
1072
+ }
1073
+ const f = j.getBoundingClientRect();
1074
+ let g = f.left + f.width / 2, N = f.top - 50;
1075
+ if (x.current) {
1076
+ const M = x.current.offsetWidth || 300;
1077
+ g = Math.max(M / 2 + 8, Math.min(g, window.innerWidth - M / 2 - 8));
1078
+ }
1079
+ N < 10 && (N = f.bottom + 10), m({ x: g, y: N }), s(!0);
1080
+ };
1081
+ return document.addEventListener("selectionchange", k), () => document.removeEventListener("selectionchange", k);
1082
+ }, [o]), i ? /* @__PURE__ */ e.jsxs(
1083
+ "div",
1084
+ {
1085
+ ref: x,
1086
+ className: "fixed z-50 flex items-center gap-0.5 px-2 py-1.5 rounded-lg shadow-floating animate-scale-in bg-popover border border-border",
1087
+ style: {
1088
+ left: c.x,
1089
+ top: c.y,
1090
+ transform: "translateX(-50%)"
1091
+ },
1092
+ onMouseDown: (k) => k.preventDefault(),
1093
+ children: [
1094
+ /* @__PURE__ */ e.jsx(
1095
+ A,
1096
+ {
1097
+ icon: /* @__PURE__ */ e.jsx(vt, { className: "w-4 h-4" }),
1098
+ tooltip: "Bold",
1099
+ shortcut: "⌘B",
1100
+ isActive: r.bold,
1101
+ onClick: () => n("bold")
1102
+ }
1103
+ ),
1104
+ /* @__PURE__ */ e.jsx(
1105
+ A,
1106
+ {
1107
+ icon: /* @__PURE__ */ e.jsx(bt, { className: "w-4 h-4" }),
1108
+ tooltip: "Italic",
1109
+ shortcut: "⌘I",
1110
+ isActive: r.italic,
1111
+ onClick: () => n("italic")
1112
+ }
1113
+ ),
1114
+ /* @__PURE__ */ e.jsx(
1115
+ A,
1116
+ {
1117
+ icon: /* @__PURE__ */ e.jsx(jt, { className: "w-4 h-4" }),
1118
+ tooltip: "Underline",
1119
+ shortcut: "⌘U",
1120
+ isActive: r.underline,
1121
+ onClick: () => n("underline")
1122
+ }
1123
+ ),
1124
+ /* @__PURE__ */ e.jsx(
1125
+ A,
1126
+ {
1127
+ icon: /* @__PURE__ */ e.jsx(kt, { className: "w-4 h-4" }),
1128
+ tooltip: "Strikethrough",
1129
+ isActive: r.strikethrough,
1130
+ onClick: () => n("strikethrough")
1131
+ }
1132
+ ),
1133
+ /* @__PURE__ */ e.jsx("div", { className: "w-px h-5 bg-border mx-1" }),
1134
+ /* @__PURE__ */ e.jsx(
1135
+ A,
1136
+ {
1137
+ icon: /* @__PURE__ */ e.jsx(De, { className: "w-4 h-4" }),
1138
+ tooltip: "Inline code",
1139
+ isActive: r.code,
1140
+ onClick: () => n("inlineCode")
1141
+ }
1142
+ ),
1143
+ /* @__PURE__ */ e.jsx(
1144
+ A,
1145
+ {
1146
+ icon: /* @__PURE__ */ e.jsx(Oe, { className: "w-4 h-4" }),
1147
+ tooltip: "Insert link",
1148
+ shortcut: "⌘K",
1149
+ onClick: d
1150
+ }
1151
+ )
1152
+ ]
1153
+ }
1154
+ ) : null;
1155
+ }, or = ({
1156
+ isOpen: r,
1157
+ onClose: n,
1158
+ onInsert: d,
1159
+ selectedText: o = ""
1160
+ }) => {
1161
+ const [i, s] = R(""), [c, m] = R(o), x = F(null);
1162
+ z(() => {
1163
+ r && (m(o), s(""), setTimeout(() => x.current?.focus(), 100));
1164
+ }, [r, o]);
1165
+ const k = (p) => {
1166
+ if (p.preventDefault(), i.trim()) {
1167
+ let j = i.trim();
1168
+ !j.startsWith("http://") && !j.startsWith("https://") && (j = "https://" + j), d(j, c || void 0), n();
1169
+ }
1170
+ };
1171
+ return r ? /* @__PURE__ */ e.jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm animate-fade-in", children: /* @__PURE__ */ e.jsxs("div", { className: "w-full max-w-md p-6 rounded-xl shadow-floating animate-scale-in bg-card border border-border", children: [
1172
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between mb-4", children: [
1173
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 text-foreground", children: [
1174
+ /* @__PURE__ */ e.jsx(Oe, { className: "w-5 h-5" }),
1175
+ /* @__PURE__ */ e.jsx("h2", { className: "text-lg font-semibold", children: "Insert Link" })
1176
+ ] }),
1177
+ /* @__PURE__ */ e.jsx(
1178
+ "button",
1179
+ {
1180
+ type: "button",
1181
+ onClick: n,
1182
+ className: "p-1 rounded-md hover:bg-secondary transition-colors",
1183
+ children: /* @__PURE__ */ e.jsx(Ie, { className: "w-5 h-5" })
1184
+ }
1185
+ )
1186
+ ] }),
1187
+ /* @__PURE__ */ e.jsxs("form", { onSubmit: k, className: "space-y-4", children: [
1188
+ /* @__PURE__ */ e.jsxs("div", { children: [
1189
+ /* @__PURE__ */ e.jsx("label", { className: "block text-sm font-medium mb-1.5 text-foreground", children: "URL" }),
1190
+ /* @__PURE__ */ e.jsx(
1191
+ "input",
1192
+ {
1193
+ ref: x,
1194
+ type: "text",
1195
+ value: i,
1196
+ onChange: (p) => s(p.target.value),
1197
+ placeholder: "https://example.com",
1198
+ className: "w-full px-3 py-2 rounded-lg border transition-colors bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent placeholder:text-muted-foreground"
1199
+ }
1200
+ )
1201
+ ] }),
1202
+ /* @__PURE__ */ e.jsxs("div", { children: [
1203
+ /* @__PURE__ */ e.jsx("label", { className: "block text-sm font-medium mb-1.5 text-foreground", children: "Text (optional)" }),
1204
+ /* @__PURE__ */ e.jsx(
1205
+ "input",
1206
+ {
1207
+ type: "text",
1208
+ value: c,
1209
+ onChange: (p) => m(p.target.value),
1210
+ placeholder: "Link text",
1211
+ className: "w-full px-3 py-2 rounded-lg border transition-colors bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent placeholder:text-muted-foreground"
1212
+ }
1213
+ )
1214
+ ] }),
1215
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end gap-2 pt-2", children: [
1216
+ /* @__PURE__ */ e.jsx(
1217
+ "button",
1218
+ {
1219
+ type: "button",
1220
+ onClick: n,
1221
+ className: "px-4 py-2 rounded-lg font-medium transition-colors bg-secondary text-secondary-foreground hover:bg-secondary/80",
1222
+ children: "Cancel"
1223
+ }
1224
+ ),
1225
+ /* @__PURE__ */ e.jsx(
1226
+ "button",
1227
+ {
1228
+ type: "submit",
1229
+ disabled: !i.trim(),
1230
+ className: "px-4 py-2 rounded-lg font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed",
1231
+ children: "Insert"
1232
+ }
1233
+ )
1234
+ ] })
1235
+ ] })
1236
+ ] }) }) : null;
1237
+ }, sr = [
1238
+ { id: "paragraph", label: "Text", description: "Plain text paragraph", icon: /* @__PURE__ */ e.jsx(St, { className: "w-4 h-4" }), action: "paragraph", category: "Basic" },
1239
+ { id: "h1", label: "Heading 1", description: "Large section heading", icon: /* @__PURE__ */ e.jsx(Rt, { className: "w-4 h-4" }), action: "h1", category: "Headings" },
1240
+ { id: "h2", label: "Heading 2", description: "Medium section heading", icon: /* @__PURE__ */ e.jsx(Et, { className: "w-4 h-4" }), action: "h2", category: "Headings" },
1241
+ { id: "h3", label: "Heading 3", description: "Small section heading", icon: /* @__PURE__ */ e.jsx(_t, { className: "w-4 h-4" }), action: "h3", category: "Headings" },
1242
+ { id: "bulletList", label: "Bullet List", description: "Create a bulleted list", icon: /* @__PURE__ */ e.jsx(yt, { className: "w-4 h-4" }), action: "unorderedList", category: "Lists" },
1243
+ { id: "numberedList", label: "Numbered List", description: "Create a numbered list", icon: /* @__PURE__ */ e.jsx(wt, { className: "w-4 h-4" }), action: "orderedList", category: "Lists" },
1244
+ { id: "taskList", label: "Task List", description: "Create a task checklist", icon: /* @__PURE__ */ e.jsx(Ct, { className: "w-4 h-4" }), action: "taskList", category: "Lists" },
1245
+ { id: "blockquote", label: "Quote", description: "Create a blockquote", icon: /* @__PURE__ */ e.jsx(Nt, { className: "w-4 h-4" }), action: "blockquote", category: "Blocks" },
1246
+ { id: "codeBlock", label: "Code Block", description: "Add a code snippet", icon: /* @__PURE__ */ e.jsx(De, { className: "w-4 h-4" }), action: "code", category: "Blocks" },
1247
+ { id: "divider", label: "Divider", description: "Visual separator line", icon: /* @__PURE__ */ e.jsx(Lt, { className: "w-4 h-4" }), action: "horizontalRule", category: "Blocks" },
1248
+ { id: "table", label: "Table", description: "Insert a table", icon: /* @__PURE__ */ e.jsx(rt, { className: "w-4 h-4" }), action: "table", category: "Advanced" },
1249
+ { id: "image", label: "Image", description: "Upload or embed image", icon: /* @__PURE__ */ e.jsx(tt, { className: "w-4 h-4" }), action: "image", category: "Advanced" }
1250
+ ], ar = ({
1251
+ isOpen: r,
1252
+ position: n,
1253
+ searchQuery: d,
1254
+ onSelect: o,
1255
+ onClose: i
1256
+ }) => {
1257
+ const [s, c] = R(0), m = F(null), x = sr.filter(
1258
+ (h) => h.label.toLowerCase().includes(d.toLowerCase()) || h.description.toLowerCase().includes(d.toLowerCase())
1259
+ ), k = x.reduce((h, f) => (h[f.category] || (h[f.category] = []), h[f.category].push(f), h), {});
1260
+ z(() => {
1261
+ c(0);
1262
+ }, [d]), z(() => {
1263
+ const h = (f) => {
1264
+ m.current && !m.current.contains(f.target) && i();
1265
+ };
1266
+ return r && document.addEventListener("mousedown", h), () => {
1267
+ document.removeEventListener("mousedown", h);
1268
+ };
1269
+ }, [r, i]);
1270
+ const p = C(
1271
+ (h) => {
1272
+ if (r)
1273
+ switch (h.key) {
1274
+ case "ArrowDown":
1275
+ h.preventDefault(), c((f) => (f + 1) % x.length);
1276
+ break;
1277
+ case "ArrowUp":
1278
+ h.preventDefault(), c((f) => (f - 1 + x.length) % x.length);
1279
+ break;
1280
+ case "Enter":
1281
+ h.preventDefault(), x[s] && o(x[s].action);
1282
+ break;
1283
+ case "Escape":
1284
+ h.preventDefault(), i();
1285
+ break;
1286
+ }
1287
+ },
1288
+ [r, x, s, o, i]
1289
+ );
1290
+ if (z(() => (document.addEventListener("keydown", p), () => document.removeEventListener("keydown", p)), [p]), !r || x.length === 0) return null;
1291
+ let j = 0;
1292
+ return /* @__PURE__ */ e.jsx(
1293
+ "div",
1294
+ {
1295
+ ref: m,
1296
+ className: "fixed z-50 w-72 max-h-80 overflow-y-auto rounded-lg border shadow-lg animate-scale-in bg-popover border-border",
1297
+ style: { top: n.top, left: n.left },
1298
+ children: Object.entries(k).map(([h, f]) => /* @__PURE__ */ e.jsxs("div", { children: [
1299
+ /* @__PURE__ */ e.jsx("div", { className: "px-3 py-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider", children: h }),
1300
+ f.map((g) => {
1301
+ const N = j++;
1302
+ return /* @__PURE__ */ e.jsxs(
1303
+ "button",
1304
+ {
1305
+ className: `w-full flex items-center gap-3 px-3 py-2 text-left transition-colors ${N === s ? "bg-accent text-accent-foreground" : "hover:bg-muted"}`,
1306
+ onClick: () => o(g.action),
1307
+ onMouseEnter: () => c(N),
1308
+ children: [
1309
+ /* @__PURE__ */ e.jsx("div", { className: "flex-shrink-0 w-8 h-8 flex items-center justify-center rounded-md bg-secondary text-secondary-foreground", children: g.icon }),
1310
+ /* @__PURE__ */ e.jsxs("div", { className: "flex-1 min-w-0", children: [
1311
+ /* @__PURE__ */ e.jsx("div", { className: "text-sm font-medium", children: g.label }),
1312
+ /* @__PURE__ */ e.jsx("div", { className: "text-xs text-muted-foreground truncate", children: g.description })
1313
+ ] })
1314
+ ]
1315
+ },
1316
+ g.id
1317
+ );
1318
+ })
1319
+ ] }, h))
1320
+ }
1321
+ );
1322
+ }, ir = ({ isOpen: r, onClose: n, onInsert: d }) => {
1323
+ const [o, i] = R("upload"), [s, c] = R(""), [m, x] = R(""), [k, p] = R(!1), [j, h] = R(null), f = F(null), g = C((_) => {
1324
+ if (!_.type.startsWith("image/")) {
1325
+ alert("Please select an image file");
1326
+ return;
1327
+ }
1328
+ const U = new FileReader();
1329
+ U.onload = (H) => {
1330
+ const ae = H.target?.result;
1331
+ h(ae);
1332
+ }, U.readAsDataURL(_);
1333
+ }, []), N = C((_) => {
1334
+ _.preventDefault(), p(!1);
1335
+ const U = _.dataTransfer.files[0];
1336
+ U && g(U);
1337
+ }, [g]), M = C((_) => {
1338
+ _.preventDefault(), p(!0);
1339
+ }, []), S = C((_) => {
1340
+ _.preventDefault(), p(!1);
1341
+ }, []), I = () => {
1342
+ const _ = o === "upload" ? j : s;
1343
+ _ && (d(_, m || void 0), Z());
1344
+ }, Z = () => {
1345
+ c(""), x(""), h(null), n();
1346
+ };
1347
+ return r ? /* @__PURE__ */ e.jsx(
1348
+ "div",
1349
+ {
1350
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm animate-fade-in",
1351
+ onClick: n,
1352
+ children: /* @__PURE__ */ e.jsxs(
1353
+ "div",
1354
+ {
1355
+ className: "w-full max-w-md rounded-xl border shadow-xl overflow-hidden animate-scale-in bg-card border-border",
1356
+ onClick: (_) => _.stopPropagation(),
1357
+ children: [
1358
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between px-4 py-3 border-b border-border bg-muted/50", children: [
1359
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1360
+ /* @__PURE__ */ e.jsx(tt, { className: "w-5 h-5 text-muted-foreground" }),
1361
+ /* @__PURE__ */ e.jsx("h3", { className: "font-semibold", children: "Insert Image" })
1362
+ ] }),
1363
+ /* @__PURE__ */ e.jsx(
1364
+ "button",
1365
+ {
1366
+ onClick: n,
1367
+ className: "text-muted-foreground hover:text-foreground transition-colors",
1368
+ children: /* @__PURE__ */ e.jsx(Ie, { className: "w-5 h-5" })
1369
+ }
1370
+ )
1371
+ ] }),
1372
+ /* @__PURE__ */ e.jsxs("div", { className: "flex border-b border-border", children: [
1373
+ /* @__PURE__ */ e.jsxs(
1374
+ "button",
1375
+ {
1376
+ onClick: () => i("upload"),
1377
+ className: `flex-1 px-4 py-2 text-sm font-medium transition-colors ${o === "upload" ? "border-b-2 border-primary text-primary" : "text-muted-foreground hover:text-foreground"}`,
1378
+ children: [
1379
+ /* @__PURE__ */ e.jsx(ht, { className: "w-4 h-4 inline mr-2" }),
1380
+ "Upload"
1381
+ ]
1382
+ }
1383
+ ),
1384
+ /* @__PURE__ */ e.jsxs(
1385
+ "button",
1386
+ {
1387
+ onClick: () => i("url"),
1388
+ className: `flex-1 px-4 py-2 text-sm font-medium transition-colors ${o === "url" ? "border-b-2 border-primary text-primary" : "text-muted-foreground hover:text-foreground"}`,
1389
+ children: [
1390
+ /* @__PURE__ */ e.jsx(Oe, { className: "w-4 h-4 inline mr-2" }),
1391
+ "URL"
1392
+ ]
1393
+ }
1394
+ )
1395
+ ] }),
1396
+ /* @__PURE__ */ e.jsxs("div", { className: "p-4 space-y-4", children: [
1397
+ o === "upload" ? /* @__PURE__ */ e.jsxs(
1398
+ "div",
1399
+ {
1400
+ onDrop: N,
1401
+ onDragOver: M,
1402
+ onDragLeave: S,
1403
+ onClick: () => f.current?.click(),
1404
+ className: `border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${k ? "border-primary bg-primary/5" : "border-border hover:border-muted-foreground"} ${j ? "border-solid" : ""}`,
1405
+ children: [
1406
+ j ? /* @__PURE__ */ e.jsxs("div", { className: "relative", children: [
1407
+ /* @__PURE__ */ e.jsx(
1408
+ "img",
1409
+ {
1410
+ src: j,
1411
+ alt: "Preview",
1412
+ className: "max-h-48 mx-auto rounded-lg"
1413
+ }
1414
+ ),
1415
+ /* @__PURE__ */ e.jsx(
1416
+ "button",
1417
+ {
1418
+ onClick: (_) => {
1419
+ _.stopPropagation(), h(null);
1420
+ },
1421
+ className: "absolute top-2 right-2 p-1 rounded-full bg-destructive text-destructive-foreground",
1422
+ children: /* @__PURE__ */ e.jsx(Ie, { className: "w-4 h-4" })
1423
+ }
1424
+ )
1425
+ ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1426
+ /* @__PURE__ */ e.jsx(ht, { className: "w-10 h-10 mx-auto mb-2 text-muted-foreground" }),
1427
+ /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground", children: "Drag and drop an image, or click to select" }),
1428
+ /* @__PURE__ */ e.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: "Supports: JPG, PNG, GIF, WebP" })
1429
+ ] }),
1430
+ /* @__PURE__ */ e.jsx(
1431
+ "input",
1432
+ {
1433
+ ref: f,
1434
+ type: "file",
1435
+ accept: "image/*",
1436
+ className: "hidden",
1437
+ onChange: (_) => {
1438
+ const U = _.target.files?.[0];
1439
+ U && g(U);
1440
+ }
1441
+ }
1442
+ )
1443
+ ]
1444
+ }
1445
+ ) : /* @__PURE__ */ e.jsxs("div", { children: [
1446
+ /* @__PURE__ */ e.jsx("label", { className: "block text-sm font-medium mb-1.5", children: "Image URL" }),
1447
+ /* @__PURE__ */ e.jsx(
1448
+ "input",
1449
+ {
1450
+ type: "url",
1451
+ value: s,
1452
+ onChange: (_) => c(_.target.value),
1453
+ placeholder: "https://example.com/image.jpg",
1454
+ className: "w-full px-3 py-2 rounded-lg border text-sm bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring"
1455
+ }
1456
+ ),
1457
+ s && /* @__PURE__ */ e.jsx("div", { className: "mt-3", children: /* @__PURE__ */ e.jsx(
1458
+ "img",
1459
+ {
1460
+ src: s,
1461
+ alt: "Preview",
1462
+ className: "max-h-32 mx-auto rounded-lg",
1463
+ onError: (_) => {
1464
+ _.target.style.display = "none";
1465
+ }
1466
+ }
1467
+ ) })
1468
+ ] }),
1469
+ /* @__PURE__ */ e.jsxs("div", { children: [
1470
+ /* @__PURE__ */ e.jsx("label", { className: "block text-sm font-medium mb-1.5", children: "Alt Text (optional)" }),
1471
+ /* @__PURE__ */ e.jsx(
1472
+ "input",
1473
+ {
1474
+ type: "text",
1475
+ value: m,
1476
+ onChange: (_) => x(_.target.value),
1477
+ placeholder: "Describe the image...",
1478
+ className: "w-full px-3 py-2 rounded-lg border text-sm bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring"
1479
+ }
1480
+ )
1481
+ ] }),
1482
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end gap-2 pt-2", children: [
1483
+ /* @__PURE__ */ e.jsx(
1484
+ "button",
1485
+ {
1486
+ onClick: Z,
1487
+ className: "px-4 py-2 rounded-lg text-sm font-medium transition-colors hover:bg-muted",
1488
+ children: "Cancel"
1489
+ }
1490
+ ),
1491
+ /* @__PURE__ */ e.jsx(
1492
+ "button",
1493
+ {
1494
+ onClick: I,
1495
+ disabled: o === "upload" ? !j : !s,
1496
+ className: "px-4 py-2 rounded-lg text-sm font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed",
1497
+ children: "Insert Image"
1498
+ }
1499
+ )
1500
+ ] })
1501
+ ] })
1502
+ ]
1503
+ }
1504
+ )
1505
+ }
1506
+ ) : null;
1507
+ }, lr = ({ isOpen: r, onClose: n, onInsert: d }) => {
1508
+ const [o, i] = R(3), [s, c] = R(3), [m, x] = R({ row: 0, col: 0 }), k = () => {
1509
+ d(o, s), n();
1510
+ };
1511
+ return r ? /* @__PURE__ */ e.jsx(
1512
+ "div",
1513
+ {
1514
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm animate-fade-in",
1515
+ onClick: n,
1516
+ children: /* @__PURE__ */ e.jsxs(
1517
+ "div",
1518
+ {
1519
+ className: "w-full max-w-sm rounded-xl border shadow-xl overflow-hidden animate-scale-in bg-card border-border",
1520
+ onClick: (p) => p.stopPropagation(),
1521
+ children: [
1522
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between px-4 py-3 border-b border-border bg-muted/50", children: [
1523
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1524
+ /* @__PURE__ */ e.jsx(rt, { className: "w-5 h-5 text-muted-foreground" }),
1525
+ /* @__PURE__ */ e.jsx("h3", { className: "font-semibold", children: "Insert Table" })
1526
+ ] }),
1527
+ /* @__PURE__ */ e.jsx(
1528
+ "button",
1529
+ {
1530
+ onClick: n,
1531
+ className: "text-muted-foreground hover:text-foreground transition-colors",
1532
+ children: /* @__PURE__ */ e.jsx(Ie, { className: "w-5 h-5" })
1533
+ }
1534
+ )
1535
+ ] }),
1536
+ /* @__PURE__ */ e.jsxs("div", { className: "p-4 space-y-4", children: [
1537
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center", children: [
1538
+ /* @__PURE__ */ e.jsx("div", { className: "grid gap-1 p-2 rounded-lg bg-muted/50", children: Array.from({ length: 6 }, (p, j) => /* @__PURE__ */ e.jsx("div", { className: "flex gap-1", children: Array.from({ length: 6 }, (h, f) => /* @__PURE__ */ e.jsx(
1539
+ "button",
1540
+ {
1541
+ className: `w-6 h-6 rounded border-2 transition-all ${j < m.row && f < m.col ? "bg-primary border-primary" : "border-border hover:border-muted-foreground"}`,
1542
+ onMouseEnter: () => x({ row: j + 1, col: f + 1 }),
1543
+ onClick: () => {
1544
+ i(j + 1), c(f + 1);
1545
+ }
1546
+ },
1547
+ f
1548
+ )) }, j)) }),
1549
+ /* @__PURE__ */ e.jsxs("p", { className: "text-sm text-muted-foreground mt-2", children: [
1550
+ m.row,
1551
+ " × ",
1552
+ m.col
1553
+ ] })
1554
+ ] }),
1555
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4 justify-center", children: [
1556
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1557
+ /* @__PURE__ */ e.jsx("label", { className: "text-sm font-medium", children: "Rows:" }),
1558
+ /* @__PURE__ */ e.jsx(
1559
+ "input",
1560
+ {
1561
+ type: "number",
1562
+ min: "1",
1563
+ max: "20",
1564
+ value: o,
1565
+ onChange: (p) => i(Math.max(1, Math.min(20, parseInt(p.target.value) || 1))),
1566
+ className: "w-16 px-2 py-1 rounded border text-sm text-center bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring"
1567
+ }
1568
+ )
1569
+ ] }),
1570
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1571
+ /* @__PURE__ */ e.jsx("label", { className: "text-sm font-medium", children: "Columns:" }),
1572
+ /* @__PURE__ */ e.jsx(
1573
+ "input",
1574
+ {
1575
+ type: "number",
1576
+ min: "1",
1577
+ max: "10",
1578
+ value: s,
1579
+ onChange: (p) => c(Math.max(1, Math.min(10, parseInt(p.target.value) || 1))),
1580
+ className: "w-16 px-2 py-1 rounded border text-sm text-center bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring"
1581
+ }
1582
+ )
1583
+ ] })
1584
+ ] }),
1585
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end gap-2 pt-2", children: [
1586
+ /* @__PURE__ */ e.jsx(
1587
+ "button",
1588
+ {
1589
+ onClick: n,
1590
+ className: "px-4 py-2 rounded-lg text-sm font-medium transition-colors hover:bg-muted",
1591
+ children: "Cancel"
1592
+ }
1593
+ ),
1594
+ /* @__PURE__ */ e.jsx(
1595
+ "button",
1596
+ {
1597
+ onClick: k,
1598
+ className: "px-4 py-2 rounded-lg text-sm font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90",
1599
+ children: "Insert Table"
1600
+ }
1601
+ )
1602
+ ] })
1603
+ ] })
1604
+ ]
1605
+ }
1606
+ )
1607
+ }
1608
+ ) : null;
1609
+ }, cr = ({
1610
+ isOpen: r,
1611
+ onClose: n,
1612
+ versions: d,
1613
+ onRestore: o,
1614
+ onDelete: i
1615
+ }) => {
1616
+ if (!r) return null;
1617
+ const s = (c) => {
1618
+ const m = new Date(c), k = (/* @__PURE__ */ new Date()).getTime() - m.getTime();
1619
+ return k < 6e4 ? "Just now" : k < 36e5 ? `${Math.floor(k / 6e4)} min ago` : k < 864e5 ? `${Math.floor(k / 36e5)} hours ago` : m.toLocaleDateString("en-US", {
1620
+ month: "short",
1621
+ day: "numeric",
1622
+ hour: "2-digit",
1623
+ minute: "2-digit"
1624
+ });
1625
+ };
1626
+ return /* @__PURE__ */ e.jsx(
1627
+ "div",
1628
+ {
1629
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm animate-fade-in",
1630
+ onClick: n,
1631
+ children: /* @__PURE__ */ e.jsxs(
1632
+ "div",
1633
+ {
1634
+ className: "w-full max-w-md max-h-[70vh] rounded-xl border shadow-xl overflow-hidden animate-scale-in bg-card border-border",
1635
+ onClick: (c) => c.stopPropagation(),
1636
+ children: [
1637
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between px-4 py-3 border-b border-border bg-muted/50", children: [
1638
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1639
+ /* @__PURE__ */ e.jsx(et, { className: "w-5 h-5 text-muted-foreground" }),
1640
+ /* @__PURE__ */ e.jsx("h3", { className: "font-semibold", children: "Version History" })
1641
+ ] }),
1642
+ /* @__PURE__ */ e.jsx(
1643
+ "button",
1644
+ {
1645
+ onClick: n,
1646
+ className: "text-muted-foreground hover:text-foreground transition-colors text-lg",
1647
+ children: "✕"
1648
+ }
1649
+ )
1650
+ ] }),
1651
+ /* @__PURE__ */ e.jsx("div", { className: "overflow-y-auto max-h-96", children: d.length === 0 ? /* @__PURE__ */ e.jsxs("div", { className: "px-4 py-8 text-center text-muted-foreground", children: [
1652
+ /* @__PURE__ */ e.jsx(et, { className: "w-10 h-10 mx-auto mb-2 opacity-50" }),
1653
+ /* @__PURE__ */ e.jsx("p", { children: "No versions saved yet" }),
1654
+ /* @__PURE__ */ e.jsx("p", { className: "text-sm", children: "Changes are automatically saved" })
1655
+ ] }) : /* @__PURE__ */ e.jsx("div", { className: "divide-y divide-border", children: [...d].reverse().map((c, m) => /* @__PURE__ */ e.jsxs(
1656
+ "div",
1657
+ {
1658
+ className: "px-4 py-3 hover:bg-muted/50 transition-colors group",
1659
+ children: [
1660
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
1661
+ /* @__PURE__ */ e.jsxs("div", { children: [
1662
+ /* @__PURE__ */ e.jsx("div", { className: "font-medium text-sm", children: m === 0 ? "Current Version" : c.title }),
1663
+ /* @__PURE__ */ e.jsx("div", { className: "text-xs text-muted-foreground", children: s(c.timestamp) })
1664
+ ] }),
1665
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity", children: [
1666
+ m !== 0 && /* @__PURE__ */ e.jsx(
1667
+ "button",
1668
+ {
1669
+ onClick: () => o(c.id),
1670
+ className: "p-1.5 rounded-md transition-colors hover:bg-primary/10 text-primary",
1671
+ title: "Restore this version",
1672
+ children: /* @__PURE__ */ e.jsx(Qt, { className: "w-4 h-4" })
1673
+ }
1674
+ ),
1675
+ /* @__PURE__ */ e.jsx(
1676
+ "button",
1677
+ {
1678
+ onClick: () => i(c.id),
1679
+ className: "p-1.5 rounded-md transition-colors hover:bg-destructive/10 text-destructive",
1680
+ title: "Delete this version",
1681
+ children: /* @__PURE__ */ e.jsx(Xt, { className: "w-4 h-4" })
1682
+ }
1683
+ )
1684
+ ] })
1685
+ ] }),
1686
+ /* @__PURE__ */ e.jsxs("div", { className: "mt-1 text-xs text-muted-foreground line-clamp-2", children: [
1687
+ c.content.replace(/<[^>]*>/g, "").slice(0, 100),
1688
+ "..."
1689
+ ] })
1690
+ ]
1691
+ },
1692
+ c.id
1693
+ )) }) })
1694
+ ]
1695
+ }
1696
+ )
1697
+ }
1698
+ );
1699
+ }, dr = ({
1700
+ onExportHTML: r,
1701
+ onExportMarkdown: n,
1702
+ onExportPDF: d
1703
+ }) => {
1704
+ const [o, i] = R(!1), s = F(null);
1705
+ z(() => {
1706
+ const m = (x) => {
1707
+ s.current && !s.current.contains(x.target) && i(!1);
1708
+ };
1709
+ return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
1710
+ }, []);
1711
+ const c = [
1712
+ { label: "Export as HTML", icon: /* @__PURE__ */ e.jsx(De, { className: "w-4 h-4" }), action: r },
1713
+ { label: "Export as Markdown", icon: /* @__PURE__ */ e.jsx(Gt, { className: "w-4 h-4" }), action: n },
1714
+ { label: "Export as PDF", icon: /* @__PURE__ */ e.jsx(Zt, { className: "w-4 h-4" }), action: d }
1715
+ ];
1716
+ return /* @__PURE__ */ e.jsxs("div", { ref: s, className: "relative", children: [
1717
+ /* @__PURE__ */ e.jsxs(
1718
+ "button",
1719
+ {
1720
+ onClick: () => i(!o),
1721
+ className: `flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium transition-colors hover:bg-muted text-muted-foreground hover:text-foreground ${o ? "bg-muted text-foreground" : ""}`,
1722
+ children: [
1723
+ /* @__PURE__ */ e.jsx(Kt, { className: "w-4 h-4" }),
1724
+ "Export"
1725
+ ]
1726
+ }
1727
+ ),
1728
+ o && /* @__PURE__ */ e.jsx("div", { className: "absolute top-full right-0 mt-1 w-48 rounded-lg border shadow-lg overflow-hidden z-50 animate-scale-in bg-popover border-border", children: c.map((m) => /* @__PURE__ */ e.jsxs(
1729
+ "button",
1730
+ {
1731
+ onClick: () => {
1732
+ m.action(), i(!1);
1733
+ },
1734
+ className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm transition-colors hover:bg-muted text-left",
1735
+ children: [
1736
+ /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground", children: m.icon }),
1737
+ m.label
1738
+ ]
1739
+ },
1740
+ m.label
1741
+ )) })
1742
+ ] });
1743
+ }, ur = (r = "") => {
1744
+ const [n, d] = R([{ content: r }]), [o, i] = R(0), s = F(0), c = C((j, h) => {
1745
+ const f = Date.now();
1746
+ f - s.current < 500 || (s.current = f, d((g) => {
1747
+ const N = g.slice(0, o + 1);
1748
+ return N[N.length - 1]?.content === j ? g : (N.length >= 100 && N.shift(), [...N, { content: j, cursorPosition: h }]);
1749
+ }), i((g) => Math.min(g + 1, 99)));
1750
+ }, [o]), m = C(() => o > 0 ? (i(o - 1), n[o - 1]) : null, [o, n]), x = C(() => o < n.length - 1 ? (i(o + 1), n[o + 1]) : null, [o, n]), k = o > 0, p = o < n.length - 1;
1751
+ return {
1752
+ saveToHistory: c,
1753
+ undo: m,
1754
+ redo: x,
1755
+ canUndo: k,
1756
+ canRedo: p
1757
+ };
1758
+ }, fr = [
1759
+ // Headers
1760
+ { pattern: /^# (.+)$/, replacement: (r, n) => `<h1>${n}</h1>`, format: "h1" },
1761
+ { pattern: /^## (.+)$/, replacement: (r, n) => `<h2>${n}</h2>`, format: "h2" },
1762
+ { pattern: /^### (.+)$/, replacement: (r, n) => `<h3>${n}</h3>`, format: "h3" },
1763
+ // Lists
1764
+ { pattern: /^- (.+)$/, replacement: (r, n) => `<ul><li>${n}</li></ul>`, format: "unorderedList" },
1765
+ { pattern: /^\* (.+)$/, replacement: (r, n) => `<ul><li>${n}</li></ul>`, format: "unorderedList" },
1766
+ { pattern: /^\d+\. (.+)$/, replacement: (r, n) => `<ol><li>${n}</li></ol>`, format: "orderedList" },
1767
+ // Task list
1768
+ { pattern: /^- \[ \] (.+)$/, replacement: (r, n) => `<div class="task-item"><span class="task-checkbox"></span><span class="task-text">${n}</span></div>`, format: "taskList" },
1769
+ { pattern: /^- \[x\] (.+)$/i, replacement: (r, n) => `<div class="task-item"><span class="task-checkbox checked"></span><span class="task-text completed">${n}</span></div>`, format: "taskList" },
1770
+ // Blockquote
1771
+ { pattern: /^> (.+)$/, replacement: (r, n) => `<blockquote>${n}</blockquote>`, format: "blockquote" },
1772
+ // Code block
1773
+ { pattern: /^```(.*)$/, replacement: () => "<pre><code></code></pre>", format: "code" },
1774
+ // Horizontal rule
1775
+ { pattern: /^---$/, replacement: () => "<hr>" },
1776
+ { pattern: /^\*\*\*$/, replacement: () => "<hr>" }
1777
+ ], mr = [
1778
+ // Bold
1779
+ { pattern: /\*\*(.+?)\*\*/, replacement: (r, n) => `<strong>${n}</strong>` },
1780
+ { pattern: /__(.+?)__/, replacement: (r, n) => `<strong>${n}</strong>` },
1781
+ // Italic
1782
+ { pattern: /\*(.+?)\*/, replacement: (r, n) => `<em>${n}</em>` },
1783
+ { pattern: /_(.+?)_/, replacement: (r, n) => `<em>${n}</em>` },
1784
+ // Strikethrough
1785
+ { pattern: /~~(.+?)~~/, replacement: (r, n) => `<s>${n}</s>` },
1786
+ // Inline code
1787
+ { pattern: /`(.+?)`/, replacement: (r, n) => `<code>${n}</code>` },
1788
+ // Links
1789
+ { pattern: /\[(.+?)\]\((.+?)\)/, replacement: (r, n, d) => `<a href="${d}">${n}</a>` }
1790
+ ], hr = () => {
1791
+ const r = C((d) => {
1792
+ for (const { pattern: i, replacement: s, format: c } of fr)
1793
+ if (d.match(i))
1794
+ return {
1795
+ html: d.replace(i, s),
1796
+ format: c
1797
+ };
1798
+ let o = d;
1799
+ for (const { pattern: i, replacement: s } of mr)
1800
+ o = o.replace(i, s);
1801
+ return o !== d ? { html: `<p>${o}</p>` } : { html: d };
1802
+ }, []), n = C((d) => {
1803
+ const o = [];
1804
+ if (!d) return o;
1805
+ let i = d;
1806
+ for (; i; ) {
1807
+ const s = i.tagName?.toLowerCase();
1808
+ (s === "strong" || s === "b") && o.push("bold"), (s === "em" || s === "i") && o.push("italic"), s === "u" && o.push("underline"), (s === "s" || s === "strike" || s === "del") && o.push("strikethrough"), s === "code" && i.parentElement?.tagName?.toLowerCase() !== "pre" && o.push("inlineCode"), s === "pre" && o.push("code"), s === "blockquote" && o.push("blockquote"), s === "ul" && o.push("unorderedList"), s === "ol" && o.push("orderedList"), s === "h1" && o.push("h1"), s === "h2" && o.push("h2"), s === "h3" && o.push("h3"), i.classList?.contains("task-list") && o.push("taskList"), i = i.parentElement;
1809
+ }
1810
+ return [...new Set(o)];
1811
+ }, []);
1812
+ return {
1813
+ processMarkdown: r,
1814
+ detectActiveFormats: n
1815
+ };
1816
+ }, se = "docuedit_documents", pr = 5e3, pt = 50, xr = (r = "default") => {
1817
+ const [n, d] = R({
1818
+ currentDocumentId: r,
1819
+ versions: [],
1820
+ lastSaved: null,
1821
+ isSaving: !1
1822
+ }), o = F(""), i = F(null);
1823
+ z(() => {
1824
+ const h = localStorage.getItem(se);
1825
+ if (h)
1826
+ try {
1827
+ const g = JSON.parse(h)[r] || [];
1828
+ d((N) => ({
1829
+ ...N,
1830
+ versions: g,
1831
+ lastSaved: g.length > 0 ? g[g.length - 1].timestamp : null
1832
+ }));
1833
+ } catch (f) {
1834
+ console.error("Failed to load autosave data:", f);
1835
+ }
1836
+ }, [r]);
1837
+ const s = C((h, f = !1) => {
1838
+ const g = localStorage.getItem(se), N = g ? JSON.parse(g) : {}, M = Date.now(), S = N[r] || [];
1839
+ if (f || S.length === 0) {
1840
+ const I = {
1841
+ id: `v_${M}`,
1842
+ content: h,
1843
+ timestamp: M,
1844
+ title: `Version ${S.length + 1}`
1845
+ };
1846
+ S.push(I), S.length > pt && S.splice(0, S.length - pt);
1847
+ } else
1848
+ S.length > 0 && (S[S.length - 1] = {
1849
+ ...S[S.length - 1],
1850
+ content: h,
1851
+ timestamp: M
1852
+ });
1853
+ N[r] = S, localStorage.setItem(se, JSON.stringify(N)), d((I) => ({
1854
+ ...I,
1855
+ versions: S,
1856
+ lastSaved: M,
1857
+ isSaving: !1
1858
+ }));
1859
+ }, [r]), c = C((h, f = !1) => {
1860
+ o.current = h, d((g) => ({ ...g, isSaving: !0 })), setTimeout(() => {
1861
+ s(h, f);
1862
+ }, 100);
1863
+ }, [s]), m = C(() => {
1864
+ o.current && s(o.current, !0);
1865
+ }, [s]), x = C((h) => n.versions.find((g) => g.id === h)?.content || null, [n.versions]), k = C(() => n.versions.length === 0 ? null : n.versions[n.versions.length - 1].content, [n.versions]), p = C((h) => {
1866
+ const f = localStorage.getItem(se), g = f ? JSON.parse(f) : {}, M = (g[r] || []).filter((S) => S.id !== h);
1867
+ g[r] = M, localStorage.setItem(se, JSON.stringify(g)), d((S) => ({
1868
+ ...S,
1869
+ versions: M
1870
+ }));
1871
+ }, [r]), j = C(() => {
1872
+ const h = localStorage.getItem(se), f = h ? JSON.parse(h) : {};
1873
+ delete f[r], localStorage.setItem(se, JSON.stringify(f)), d((g) => ({
1874
+ ...g,
1875
+ versions: [],
1876
+ lastSaved: null
1877
+ }));
1878
+ }, [r]);
1879
+ return z(() => (i.current = setInterval(() => {
1880
+ o.current && s(o.current, !1);
1881
+ }, pr), () => {
1882
+ i.current && clearInterval(i.current);
1883
+ }), [s]), {
1884
+ save: c,
1885
+ createVersionSnapshot: m,
1886
+ loadVersion: x,
1887
+ getLatestContent: k,
1888
+ deleteVersion: p,
1889
+ clearAllVersions: j,
1890
+ versions: n.versions,
1891
+ lastSaved: n.lastSaved,
1892
+ isSaving: n.isSaving
1893
+ };
1894
+ }, gr = (r) => {
1895
+ let n = r;
1896
+ n = n.replace(/<div class="task-list">([\s\S]*?)<\/div>/gi, (o, i) => i), n = n.replace(/<div class="task-item">([\s\S]*?)<\/div>/gi, (o, i) => {
1897
+ const s = i.includes("checked"), c = i.match(/<span class="task-text"[^>]*>([\s\S]*?)<\/span>/i), m = c ? c[1].trim() : "";
1898
+ return s ? `- [x] ${m}
1899
+ ` : `- [ ] ${m}
1900
+ `;
1901
+ }), n = n.replace(/<span class="task-checkbox[^"]*"[^>]*><\/span>/gi, ""), n = n.replace(/<span class="task-text"[^>]*>([\s\S]*?)<\/span>/gi, "$1"), n = n.replace(/<h1[^>]*>([\s\S]*?)<\/h1>/gi, `# $1
1902
+
1903
+ `), n = n.replace(/<h2[^>]*>([\s\S]*?)<\/h2>/gi, `## $1
1904
+
1905
+ `), n = n.replace(/<h3[^>]*>([\s\S]*?)<\/h3>/gi, `### $1
1906
+
1907
+ `), n = n.replace(/<h4[^>]*>([\s\S]*?)<\/h4>/gi, `#### $1
1908
+
1909
+ `), n = n.replace(/<h5[^>]*>([\s\S]*?)<\/h5>/gi, `##### $1
1910
+
1911
+ `), n = n.replace(/<h6[^>]*>([\s\S]*?)<\/h6>/gi, `###### $1
1912
+
1913
+ `), n = n.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/gi, "**$1**"), n = n.replace(/<b[^>]*>([\s\S]*?)<\/b>/gi, "**$1**"), n = n.replace(/<em[^>]*>([\s\S]*?)<\/em>/gi, "*$1*"), n = n.replace(/<i[^>]*>([\s\S]*?)<\/i>/gi, "*$1*"), n = n.replace(/<u[^>]*>([\s\S]*?)<\/u>/gi, "<u>$1</u>"), n = n.replace(/<s[^>]*>([\s\S]*?)<\/s>/gi, "~~$1~~"), n = n.replace(/<strike[^>]*>([\s\S]*?)<\/strike>/gi, "~~$1~~"), n = n.replace(/<pre[^>]*><code[^>]*>([\s\S]*?)<\/code><\/pre>/gi, "```\n$1\n```\n\n"), n = n.replace(/<code[^>]*>([\s\S]*?)<\/code>/gi, "`$1`"), n = n.replace(/<a[^>]*href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi, "[$2]($1)"), n = n.replace(/<img[^>]*src="([^"]*)"[^>]*alt="([^"]*)"[^>]*\/?>/gi, "![$2]($1)"), n = n.replace(/<img[^>]*src="([^"]*)"[^>]*\/?>/gi, "![]($1)"), n = n.replace(/<ul[^>]*>([\s\S]*?)<\/ul>/gi, (o, i) => i.replace(/<li[^>]*>([\s\S]*?)<\/li>/gi, `- $1
1914
+ `) + `
1915
+ `), n = n.replace(/<ol[^>]*>([\s\S]*?)<\/ol>/gi, (o, i) => {
1916
+ let s = 0;
1917
+ return i.replace(/<li[^>]*>([\s\S]*?)<\/li>/gi, () => (s++, `${s}. $1
1918
+ `)) + `
1919
+ `;
1920
+ }), n = n.replace(/<blockquote[^>]*>([\s\S]*?)<\/blockquote>/gi, (o, i) => i.split(`
1921
+ `).map((s) => `> ${s}`).join(`
1922
+ `) + `
1923
+
1924
+ `), n = n.replace(/<hr[^>]*\/?>/gi, `
1925
+ ---
1926
+
1927
+ `), n = n.replace(/<p[^>]*>([\s\S]*?)<\/p>/gi, `$1
1928
+
1929
+ `), n = n.replace(/<br[^>]*\/?>/gi, `
1930
+ `), n = n.replace(/<div[^>]*>([\s\S]*?)<\/div>/gi, `$1
1931
+ `), n = n.replace(/<[^>]+>/g, ""), n = n.replace(/\n{3,}/g, `
1932
+
1933
+ `), n = n.trim();
1934
+ const d = document.createElement("textarea");
1935
+ return d.innerHTML = n, n = d.value, n;
1936
+ }, vr = (r, n = "Document") => {
1937
+ const d = window.open("", "_blank");
1938
+ if (!d) {
1939
+ alert("Please allow pop-ups to export PDF");
1940
+ return;
1941
+ }
1942
+ d.document.write(`
1943
+ <!DOCTYPE html>
1944
+ <html>
1945
+ <head>
1946
+ <title>${n}</title>
1947
+
1948
+ <style>
1949
+ body {
1950
+ font-family: 'Georgia', serif;
1951
+ max-width: 800px;
1952
+ margin: 40px auto;
1953
+ padding: 20px;
1954
+ line-height: 1.6;
1955
+ color: #333;
1956
+ }
1957
+ h1 { font-size: 2.5em; margin-bottom: 0.5em; }
1958
+ h2 { font-size: 2em; margin-bottom: 0.4em; margin-top: 1.5em; }
1959
+ h3 { font-size: 1.5em; margin-bottom: 0.3em; margin-top: 1.2em; }
1960
+ p { margin-bottom: 1em; }
1961
+ blockquote {
1962
+ border-left: 3px solid #3b82f6;
1963
+ padding-left: 1em;
1964
+ margin: 1em 0;
1965
+ color: #555;
1966
+ font-style: italic;
1967
+ }
1968
+ pre {
1969
+ background: #f5f5f5;
1970
+ padding: 1em;
1971
+ border-radius: 4px;
1972
+ overflow-x: auto;
1973
+ }
1974
+ code {
1975
+ background: #f5f5f5;
1976
+ padding: 0.2em 0.4em;
1977
+ border-radius: 3px;
1978
+ font-family: 'Consolas', monospace;
1979
+ }
1980
+ pre code { background: transparent; padding: 0; }
1981
+ ul, ol { margin: 1em 0; padding-left: 2em; }
1982
+ li { margin-bottom: 0.5em; }
1983
+ hr { border: none; border-top: 2px solid #eee; margin: 2em 0; }
1984
+ img { max-width: 100%; height: auto; }
1985
+ table { border-collapse: collapse; width: 100%; margin: 1em 0; }
1986
+ th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
1987
+ th { background: #f5f5f5; }
1988
+ .task-list { list-style: none; padding-left: 0; }
1989
+ .task-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
1990
+ .task-checkbox { width: 16px; height: 16px; border: 2px solid #888; border-radius: 3px; display: inline-block; }
1991
+ .task-checkbox.checked { background: #3b82f6; border-color: #3b82f6; }
1992
+ </style>
1993
+
1994
+ </head>
1995
+ <body>
1996
+ ${r}
1997
+ </body>
1998
+ </html>
1999
+ `), d.document.close(), setTimeout(() => {
2000
+ d.print();
2001
+ }, 500);
2002
+ }, xt = (r, n, d) => {
2003
+ const o = new Blob([r], { type: d }), i = URL.createObjectURL(o), s = document.createElement("a");
2004
+ s.href = i, s.download = n, document.body.appendChild(s), s.click(), document.body.removeChild(s), URL.revokeObjectURL(i);
2005
+ }, br = () => {
2006
+ const r = C((o, i = "document") => {
2007
+ const s = `<!DOCTYPE html>
2008
+ <html lang="en">
2009
+ <head>
2010
+ <meta charset="UTF-8">
2011
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
2012
+ <title>${i}</title>
2013
+ <style>
2014
+ body { font-family: Georgia, serif; max-width: 800px; margin: 40px auto; padding: 20px; line-height: 1.6; }
2015
+ h1 { font-size: 2.5em; }
2016
+ h2 { font-size: 2em; }
2017
+ h3 { font-size: 1.5em; }
2018
+ blockquote { border-left: 3px solid #3b82f6; padding-left: 1em; color: #555; font-style: italic; }
2019
+ pre { background: #f5f5f5; padding: 1em; border-radius: 4px; }
2020
+ code { background: #f5f5f5; padding: 0.2em 0.4em; border-radius: 3px; font-family: Consolas, monospace; }
2021
+ pre code { background: transparent; }
2022
+ img { max-width: 100%; }
2023
+ table { border-collapse: collapse; width: 100%; }
2024
+ th, td { border: 1px solid #ddd; padding: 8px; }
2025
+ th { background: #f5f5f5; }
2026
+ </style>
2027
+ </head>
2028
+ <body>
2029
+ ${o}
2030
+ </body>
2031
+ </html>`;
2032
+ xt(s, `${i}.html`, "text/html");
2033
+ }, []), n = C((o, i = "document") => {
2034
+ const s = gr(o);
2035
+ xt(s, `${i}.md`, "text/markdown");
2036
+ }, []), d = C((o, i = "Document") => {
2037
+ vr(o, i);
2038
+ }, []);
2039
+ return {
2040
+ exportHTML: r,
2041
+ exportMarkdown: n,
2042
+ exportPDF: d
2043
+ };
2044
+ }, jr = {
2045
+ bold: !1,
2046
+ italic: !1,
2047
+ underline: !1,
2048
+ strikethrough: !1,
2049
+ orderedList: !1,
2050
+ unorderedList: !1,
2051
+ taskList: !1,
2052
+ blockquote: !1,
2053
+ code: !1,
2054
+ heading: "p"
2055
+ }, yr = () => {
2056
+ const r = F(null), [n, d] = R(jr), [o, i] = R("dm-sans"), [s, c] = R(!1), [m, x] = R(""), k = F(null), [p, j] = R(!1), [h, f] = R({ top: 0, left: 0 }), [g, N] = R(""), [M, S] = R(!1), [I, Z] = R(!1), [_, U] = R(!1), { saveToHistory: H, undo: ae, redo: ke, canUndo: ye, canRedo: Pe } = ur(), { detectActiveFormats: we } = hr(), { save: B, versions: X, lastSaved: K, loadVersion: ee, deleteVersion: Ce, getLatestContent: Ne, createVersionSnapshot: me } = xr(), { exportHTML: Le, exportMarkdown: Te, exportPDF: Se } = br();
2057
+ z(() => {
2058
+ const l = Ne();
2059
+ l && r.current && (r.current.innerHTML = l);
2060
+ }, []);
2061
+ const W = C(() => {
2062
+ const l = window.getSelection();
2063
+ if (!l || !l.rangeCount) return;
2064
+ const L = l.getRangeAt(0).commonAncestorContainer.parentElement, v = we(L);
2065
+ d({
2066
+ bold: v.includes("bold") || document.queryCommandState("bold"),
2067
+ italic: v.includes("italic") || document.queryCommandState("italic"),
2068
+ underline: v.includes("underline") || document.queryCommandState("underline"),
2069
+ strikethrough: v.includes("strikethrough") || document.queryCommandState("strikeThrough"),
2070
+ orderedList: v.includes("orderedList"),
2071
+ unorderedList: v.includes("unorderedList"),
2072
+ taskList: v.includes("taskList"),
2073
+ blockquote: v.includes("blockquote"),
2074
+ code: v.includes("code") || v.includes("inlineCode"),
2075
+ heading: v.find((D) => D.match(/^h[1-3]$/)) || "p"
2076
+ });
2077
+ }, [we]), Y = C((l) => {
2078
+ if (r.current) {
2079
+ switch (r.current.focus(), l) {
2080
+ case "bold":
2081
+ document.execCommand("bold", !1);
2082
+ break;
2083
+ case "italic":
2084
+ document.execCommand("italic", !1);
2085
+ break;
2086
+ case "underline":
2087
+ document.execCommand("underline", !1);
2088
+ break;
2089
+ case "strikethrough":
2090
+ document.execCommand("strikeThrough", !1);
2091
+ break;
2092
+ case "orderedList":
2093
+ document.execCommand("insertOrderedList", !1);
2094
+ break;
2095
+ case "unorderedList":
2096
+ document.execCommand("insertUnorderedList", !1);
2097
+ break;
2098
+ case "taskList":
2099
+ Ae();
2100
+ break;
2101
+ case "blockquote":
2102
+ He();
2103
+ break;
2104
+ case "code":
2105
+ he();
2106
+ break;
2107
+ case "inlineCode":
2108
+ pe("code");
2109
+ break;
2110
+ case "horizontalRule":
2111
+ document.execCommand("insertHorizontalRule", !1);
2112
+ break;
2113
+ case "paragraph":
2114
+ document.execCommand("formatBlock", !1, "p");
2115
+ break;
2116
+ case "h1":
2117
+ case "h2":
2118
+ case "h3":
2119
+ document.execCommand("formatBlock", !1, l);
2120
+ break;
2121
+ case "image":
2122
+ S(!0);
2123
+ return;
2124
+ case "table":
2125
+ Z(!0);
2126
+ return;
2127
+ }
2128
+ H(r.current.innerHTML), B(r.current.innerHTML), W();
2129
+ }
2130
+ }, [H, W, B]), Ae = () => {
2131
+ document.execCommand("insertHTML", !1, `<div class="task-list"><div class="task-item"><span class="task-checkbox" onclick="this.classList.toggle('checked'); this.nextElementSibling.classList.toggle('completed');"></span><span class="task-text" contenteditable="true">Task item</span></div></div>`);
2132
+ }, He = () => {
2133
+ const l = window.getSelection();
2134
+ if (!l || !l.rangeCount) return;
2135
+ const L = l.getRangeAt(0).commonAncestorContainer.parentElement?.closest("blockquote");
2136
+ if (L) {
2137
+ const v = L.innerHTML;
2138
+ L.outerHTML = `<p>${v}</p>`;
2139
+ } else {
2140
+ const v = l.toString() || "Quote text here...";
2141
+ document.execCommand("insertHTML", !1, `<blockquote>${v}</blockquote>`);
2142
+ }
2143
+ }, he = () => {
2144
+ const l = window.getSelection();
2145
+ if (!l || !l.rangeCount) return;
2146
+ const y = l.toString() || "Code here...";
2147
+ document.execCommand("insertHTML", !1, `<pre><code>${y}</code></pre><p></p>`);
2148
+ }, pe = (l) => {
2149
+ const y = window.getSelection();
2150
+ if (!y || !y.rangeCount || y.isCollapsed) return;
2151
+ const L = y.getRangeAt(0), v = L.toString(), D = L.commonAncestorContainer.parentElement;
2152
+ if (D?.tagName?.toLowerCase() === l) {
2153
+ const G = document.createTextNode(v);
2154
+ D.replaceWith(G);
2155
+ } else
2156
+ document.execCommand("insertHTML", !1, `<${l}>${v}</${l}>`);
2157
+ }, Q = C((l, y) => {
2158
+ if (!r.current) return;
2159
+ r.current.focus();
2160
+ const L = `<img src="${l}" alt="${y || ""}" class="editor-image" style="max-width: 100%; border-radius: 8px;" /><p></p>`;
2161
+ document.execCommand("insertHTML", !1, L), H(r.current.innerHTML), B(r.current.innerHTML), S(!1);
2162
+ }, [H, B]), xe = C((l, y) => {
2163
+ if (!r.current) return;
2164
+ r.current.focus();
2165
+ let L = '<table class="editor-table"><thead><tr>';
2166
+ for (let v = 0; v < y; v++)
2167
+ L += "<th>Header</th>";
2168
+ L += "</tr></thead><tbody>";
2169
+ for (let v = 0; v < l - 1; v++) {
2170
+ L += "<tr>";
2171
+ for (let D = 0; D < y; D++)
2172
+ L += "<td>Cell</td>";
2173
+ L += "</tr>";
2174
+ }
2175
+ L += "</tbody></table><p></p>", document.execCommand("insertHTML", !1, L), H(r.current.innerHTML), B(r.current.innerHTML), Z(!1);
2176
+ }, [H, B]), te = C((l) => {
2177
+ r.current && (r.current.focus(), document.execCommand("formatBlock", !1, l === "p" ? "p" : l), H(r.current.innerHTML), B(r.current.innerHTML), W());
2178
+ }, [H, W, B]), Be = C((l) => {
2179
+ i(l.value);
2180
+ }, []), ie = C(() => {
2181
+ const l = ae();
2182
+ l && r.current && (r.current.innerHTML = l.content, W());
2183
+ }, [ae, W]), ge = C(() => {
2184
+ const l = ke();
2185
+ l && r.current && (r.current.innerHTML = l.content, W());
2186
+ }, [ke, W]), le = C(() => {
2187
+ const l = window.getSelection();
2188
+ l && l.rangeCount > 0 && (k.current = l.getRangeAt(0).cloneRange(), x(l.toString())), c(!0);
2189
+ }, []), ce = C((l, y) => {
2190
+ if (!r.current) return;
2191
+ if (r.current.focus(), k.current) {
2192
+ const v = window.getSelection();
2193
+ v?.removeAllRanges(), v?.addRange(k.current);
2194
+ }
2195
+ const L = y || m || l;
2196
+ document.execCommand("insertHTML", !1, `<a href="${l}" target="_blank" rel="noopener noreferrer">${L}</a>`), H(r.current.innerHTML), B(r.current.innerHTML), c(!1), x(""), k.current = null;
2197
+ }, [m, H, B]), re = C((l) => {
2198
+ if (!r.current) return;
2199
+ const y = window.getSelection();
2200
+ if (y && y.rangeCount > 0) {
2201
+ const v = y.getRangeAt(0).startContainer;
2202
+ if (v.nodeType === Node.TEXT_NODE && v.textContent) {
2203
+ const D = v.textContent.lastIndexOf("/");
2204
+ D >= 0 && (v.textContent = v.textContent.substring(0, D));
2205
+ }
2206
+ }
2207
+ j(!1), N(""), Y(l);
2208
+ }, [Y]), Re = C((l) => {
2209
+ const L = navigator.platform.toUpperCase().indexOf("MAC") >= 0 ? l.metaKey : l.ctrlKey;
2210
+ if (l.key === "Escape" && p) {
2211
+ j(!1);
2212
+ return;
2213
+ }
2214
+ if (L)
2215
+ switch (l.key.toLowerCase()) {
2216
+ case "b":
2217
+ l.preventDefault(), Y("bold");
2218
+ break;
2219
+ case "i":
2220
+ l.preventDefault(), Y("italic");
2221
+ break;
2222
+ case "u":
2223
+ l.preventDefault(), Y("underline");
2224
+ break;
2225
+ case "k":
2226
+ l.preventDefault(), le();
2227
+ break;
2228
+ case "s":
2229
+ l.preventDefault(), me();
2230
+ break;
2231
+ case "z":
2232
+ l.preventDefault(), l.shiftKey ? ge() : ie();
2233
+ break;
2234
+ }
2235
+ if (l.key === " " || l.key === "Enter") {
2236
+ const v = window.getSelection();
2237
+ if (!v || !v.rangeCount) return;
2238
+ const D = v.getRangeAt(0), G = D.startContainer.textContent || "", ne = D.startOffset, Ue = G.substring(0, ne), qe = [
2239
+ { regex: /^# $/, format: "h1", heading: "h1" },
2240
+ { regex: /^## $/, format: "h2", heading: "h2" },
2241
+ { regex: /^### $/, format: "h3", heading: "h3" },
2242
+ { regex: /^- $/, format: "unorderedList" },
2243
+ { regex: /^\* $/, format: "unorderedList" },
2244
+ { regex: /^\d+\. $/, format: "orderedList" },
2245
+ { regex: /^> $/, format: "blockquote" },
2246
+ { regex: /^- \[ \] $/, format: "taskList" },
2247
+ { regex: /^```$/, format: "code" },
2248
+ { regex: /^---$/, format: "horizontalRule" }
2249
+ ];
2250
+ for (const { regex: ze, format: Ye, heading: _e } of qe)
2251
+ if (ze.test(Ue)) {
2252
+ l.preventDefault();
2253
+ const $e = D.startContainer;
2254
+ $e.nodeType === Node.TEXT_NODE && ($e.textContent = ""), _e ? te(_e) : Y(Ye);
2255
+ return;
2256
+ }
2257
+ }
2258
+ }, [Y, te, le, ie, ge, p, me]), Ee = C(() => {
2259
+ if (!r.current) return;
2260
+ const l = window.getSelection();
2261
+ if (l && l.rangeCount > 0) {
2262
+ const y = l.getRangeAt(0), L = y.startContainer.textContent || "", v = y.startOffset, G = L.substring(0, v).match(/\/([a-zA-Z]*)$/);
2263
+ if (G) {
2264
+ const ne = y.getBoundingClientRect();
2265
+ f({ top: ne.bottom + 8, left: ne.left }), N(G[1]), j(!0);
2266
+ } else
2267
+ j(!1);
2268
+ }
2269
+ H(r.current.innerHTML), B(r.current.innerHTML), W();
2270
+ }, [H, W, B]), de = C((l) => {
2271
+ const y = l.clipboardData.items;
2272
+ for (const L of y)
2273
+ if (L.type.startsWith("image/")) {
2274
+ l.preventDefault();
2275
+ const v = L.getAsFile();
2276
+ if (v) {
2277
+ const D = new FileReader();
2278
+ D.onload = (G) => {
2279
+ Q(G.target?.result);
2280
+ }, D.readAsDataURL(v);
2281
+ }
2282
+ return;
2283
+ }
2284
+ }, [Q]), We = C((l) => {
2285
+ const y = l.dataTransfer.files;
2286
+ for (const L of y)
2287
+ if (L.type.startsWith("image/")) {
2288
+ l.preventDefault();
2289
+ const v = new FileReader();
2290
+ v.onload = (D) => {
2291
+ Q(D.target?.result);
2292
+ }, v.readAsDataURL(L);
2293
+ return;
2294
+ }
2295
+ }, [Q]), Ve = C((l) => {
2296
+ const y = ee(l);
2297
+ y && r.current && (r.current.innerHTML = y, H(y), B(y, !0), U(!1));
2298
+ }, [ee, H, B]);
2299
+ z(() => {
2300
+ const l = () => W();
2301
+ return document.addEventListener("selectionchange", l), () => document.removeEventListener("selectionchange", l);
2302
+ }, [W]);
2303
+ const ve = () => ({
2304
+ "dm-sans": "font-sans-editor",
2305
+ merriweather: "font-serif-editor",
2306
+ playfair: "font-display-editor",
2307
+ jetbrains: "font-mono-editor",
2308
+ arial: "font-arial",
2309
+ georgia: "font-georgia",
2310
+ verdana: "font-verdana",
2311
+ courier: "font-courier",
2312
+ times: "font-times"
2313
+ })[o] || "font-sans-editor", Fe = () => {
2314
+ if (!K) return "Not saved yet";
2315
+ const l = Date.now() - K;
2316
+ return l < 6e4 ? "Just now" : l < 36e5 ? `${Math.floor(l / 6e4)} min ago` : new Date(K).toLocaleTimeString();
2317
+ };
2318
+ return /* @__PURE__ */ e.jsxs("div", { className: "w-full max-w-4xl mx-auto", children: [
2319
+ /* @__PURE__ */ e.jsxs("div", { className: "rounded-xl border shadow-toolbar overflow-hidden bg-card border-editor-border", children: [
2320
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between px-4 py-2 border-b border-border bg-muted/30", children: [
2321
+ /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ e.jsxs(
2322
+ "button",
2323
+ {
2324
+ onClick: () => U(!0),
2325
+ className: "flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",
2326
+ children: [
2327
+ /* @__PURE__ */ e.jsx(et, { className: "w-4 h-4" }),
2328
+ /* @__PURE__ */ e.jsxs("span", { children: [
2329
+ "Saved ",
2330
+ Fe()
2331
+ ] })
2332
+ ]
2333
+ }
2334
+ ) }),
2335
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
2336
+ /* @__PURE__ */ e.jsxs(
2337
+ "button",
2338
+ {
2339
+ onClick: () => S(!0),
2340
+ className: "flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium transition-colors hover:bg-muted text-muted-foreground hover:text-foreground",
2341
+ children: [
2342
+ /* @__PURE__ */ e.jsx(tt, { className: "w-4 h-4" }),
2343
+ "Image"
2344
+ ]
2345
+ }
2346
+ ),
2347
+ /* @__PURE__ */ e.jsxs(
2348
+ "button",
2349
+ {
2350
+ onClick: () => Z(!0),
2351
+ className: "flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium transition-colors hover:bg-muted text-muted-foreground hover:text-foreground",
2352
+ children: [
2353
+ /* @__PURE__ */ e.jsx(rt, { className: "w-4 h-4" }),
2354
+ "Table"
2355
+ ]
2356
+ }
2357
+ ),
2358
+ /* @__PURE__ */ e.jsx(
2359
+ dr,
2360
+ {
2361
+ onExportHTML: () => Le(r.current?.innerHTML || "", "document"),
2362
+ onExportMarkdown: () => Te(r.current?.innerHTML || "", "document"),
2363
+ onExportPDF: () => Se(r.current?.innerHTML || "", "Document")
2364
+ }
2365
+ )
2366
+ ] })
2367
+ ] }),
2368
+ /* @__PURE__ */ e.jsx(
2369
+ rr,
2370
+ {
2371
+ formatState: n,
2372
+ currentFont: o,
2373
+ onFormat: Y,
2374
+ onFontChange: Be,
2375
+ onHeadingChange: te,
2376
+ onUndo: ie,
2377
+ onRedo: ge,
2378
+ canUndo: ye,
2379
+ canRedo: Pe,
2380
+ onInsertLink: le
2381
+ }
2382
+ ),
2383
+ /* @__PURE__ */ e.jsxs(
2384
+ "div",
2385
+ {
2386
+ ref: r,
2387
+ className: `editor-content p-6 md:p-8 min-h-[500px] focus:outline-none ${ve()} bg-editor`,
2388
+ contentEditable: !0,
2389
+ onInput: Ee,
2390
+ onKeyDown: Re,
2391
+ onPaste: de,
2392
+ onDrop: We,
2393
+ onDragOver: (l) => l.preventDefault(),
2394
+ suppressContentEditableWarning: !0,
2395
+ "data-placeholder": "Start writing... Type '/' for commands, or use markdown shortcuts like # for headings",
2396
+ children: [
2397
+ /* @__PURE__ */ e.jsx("h1", { children: "Welcome to DocuEdit" }),
2398
+ /* @__PURE__ */ e.jsxs("p", { children: [
2399
+ "A powerful rich text editor with ",
2400
+ /* @__PURE__ */ e.jsx("strong", { children: "autosave" }),
2401
+ ", ",
2402
+ /* @__PURE__ */ e.jsx("em", { children: "version history" }),
2403
+ ", and ",
2404
+ /* @__PURE__ */ e.jsx("u", { children: "export" }),
2405
+ " features."
2406
+ ] }),
2407
+ /* @__PURE__ */ e.jsx("h2", { children: "Quick Commands" }),
2408
+ /* @__PURE__ */ e.jsxs("ul", { children: [
2409
+ /* @__PURE__ */ e.jsxs("li", { children: [
2410
+ "Type ",
2411
+ /* @__PURE__ */ e.jsx("code", { children: "/" }),
2412
+ " to open the slash command menu"
2413
+ ] }),
2414
+ /* @__PURE__ */ e.jsx("li", { children: "Drag & drop or paste images directly" }),
2415
+ /* @__PURE__ */ e.jsxs("li", { children: [
2416
+ "Press ",
2417
+ /* @__PURE__ */ e.jsx("code", { children: "Ctrl/Cmd + S" }),
2418
+ " to create a version snapshot"
2419
+ ] })
2420
+ ] }),
2421
+ /* @__PURE__ */ e.jsx("h3", { children: "Export Options" }),
2422
+ /* @__PURE__ */ e.jsx("p", { children: "Export your document as HTML, Markdown, or PDF using the export menu above." })
2423
+ ]
2424
+ }
2425
+ )
2426
+ ] }),
2427
+ /* @__PURE__ */ e.jsx(
2428
+ nr,
2429
+ {
2430
+ formatState: { bold: n.bold, italic: n.italic, underline: n.underline, strikethrough: n.strikethrough, code: n.code },
2431
+ onFormat: Y,
2432
+ onInsertLink: le,
2433
+ editorRef: r
2434
+ }
2435
+ ),
2436
+ /* @__PURE__ */ e.jsx(
2437
+ ar,
2438
+ {
2439
+ isOpen: p,
2440
+ position: h,
2441
+ searchQuery: g,
2442
+ onSelect: re,
2443
+ onClose: () => j(!1)
2444
+ }
2445
+ ),
2446
+ /* @__PURE__ */ e.jsx(or, { isOpen: s, onClose: () => c(!1), onInsert: ce, selectedText: m }),
2447
+ /* @__PURE__ */ e.jsx(ir, { isOpen: M, onClose: () => S(!1), onInsert: Q }),
2448
+ /* @__PURE__ */ e.jsx(lr, { isOpen: I, onClose: () => Z(!1), onInsert: xe }),
2449
+ /* @__PURE__ */ e.jsx(cr, { isOpen: _, onClose: () => U(!1), versions: X, onRestore: Ve, onDelete: Ce })
2450
+ ] });
2451
+ };
2452
+ export {
2453
+ yr as RichTextEditor
2454
+ };