@clevertask/scribe 0.1.5 → 0.1.7

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.
@@ -0,0 +1,825 @@
1
+ import { t as e } from "./rolldown-runtime-CtkjhSXr.js";
2
+ import { t } from "./dist-BQjH-i-q.js";
3
+ import * as n from "react";
4
+ import r, { createContext as i, forwardRef as a, useContext as o, useDebugValue as s, useEffect as c, useLayoutEffect as l, useMemo as u, useRef as d, useState as f, version as p } from "react";
5
+ import m, { flushSync as h } from "react-dom";
6
+ import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
7
+ //#region builtin:esm-external-require-react
8
+ var y = /* @__PURE__ */ e(((e, t) => {
9
+ t.exports = { ...n };
10
+ })), b = /* @__PURE__ */ e(((e) => {
11
+ var t = y();
12
+ function n(e, t) {
13
+ return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
14
+ }
15
+ var r = typeof Object.is == "function" ? Object.is : n, i = t.useState, a = t.useEffect, o = t.useLayoutEffect, s = t.useDebugValue;
16
+ function c(e, t) {
17
+ var n = t(), r = i({ inst: {
18
+ value: n,
19
+ getSnapshot: t
20
+ } }), c = r[0].inst, u = r[1];
21
+ return o(function() {
22
+ c.value = n, c.getSnapshot = t, l(c) && u({ inst: c });
23
+ }, [
24
+ e,
25
+ n,
26
+ t
27
+ ]), a(function() {
28
+ return l(c) && u({ inst: c }), e(function() {
29
+ l(c) && u({ inst: c });
30
+ });
31
+ }, [e]), s(n), n;
32
+ }
33
+ function l(e) {
34
+ var t = e.getSnapshot;
35
+ e = e.value;
36
+ try {
37
+ var n = t();
38
+ return !r(e, n);
39
+ } catch {
40
+ return !0;
41
+ }
42
+ }
43
+ function u(e, t) {
44
+ return t();
45
+ }
46
+ var d = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? u : c;
47
+ e.useSyncExternalStore = t.useSyncExternalStore === void 0 ? d : t.useSyncExternalStore;
48
+ })), ee = /* @__PURE__ */ e(((e) => {
49
+ process.env.NODE_ENV !== "production" && (function() {
50
+ function t(e, t) {
51
+ return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
52
+ }
53
+ function n(e, t) {
54
+ d || a.startTransition === void 0 || (d = !0, console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
55
+ var n = t();
56
+ if (!f) {
57
+ var i = t();
58
+ o(n, i) || (console.error("The result of getSnapshot should be cached to avoid an infinite loop"), f = !0);
59
+ }
60
+ i = s({ inst: {
61
+ value: n,
62
+ getSnapshot: t
63
+ } });
64
+ var p = i[0].inst, m = i[1];
65
+ return l(function() {
66
+ p.value = n, p.getSnapshot = t, r(p) && m({ inst: p });
67
+ }, [
68
+ e,
69
+ n,
70
+ t
71
+ ]), c(function() {
72
+ return r(p) && m({ inst: p }), e(function() {
73
+ r(p) && m({ inst: p });
74
+ });
75
+ }, [e]), u(n), n;
76
+ }
77
+ function r(e) {
78
+ var t = e.getSnapshot;
79
+ e = e.value;
80
+ try {
81
+ var n = t();
82
+ return !o(e, n);
83
+ } catch {
84
+ return !0;
85
+ }
86
+ }
87
+ function i(e, t) {
88
+ return t();
89
+ }
90
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
91
+ var a = y(), o = typeof Object.is == "function" ? Object.is : t, s = a.useState, c = a.useEffect, l = a.useLayoutEffect, u = a.useDebugValue, d = !1, f = !1, p = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? i : n;
92
+ e.useSyncExternalStore = a.useSyncExternalStore === void 0 ? p : a.useSyncExternalStore, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
93
+ })();
94
+ })), x = /* @__PURE__ */ e(((e, t) => {
95
+ process.env.NODE_ENV === "production" ? t.exports = b() : t.exports = ee();
96
+ })), S = x(), { getOwnPropertyNames: te, getOwnPropertySymbols: C } = Object, { hasOwnProperty: w } = Object.prototype;
97
+ function T(e, t) {
98
+ return function(n, r, i) {
99
+ return e(n, r, i) && t(n, r, i);
100
+ };
101
+ }
102
+ function E(e) {
103
+ return function(t, n, r) {
104
+ if (!t || !n || typeof t != "object" || typeof n != "object") return e(t, n, r);
105
+ let { cache: i } = r, a = i.get(t), o = i.get(n);
106
+ if (a && o) return a === n && o === t;
107
+ i.set(t, n), i.set(n, t);
108
+ let s = e(t, n, r);
109
+ return i.delete(t), i.delete(n), s;
110
+ };
111
+ }
112
+ function ne(e) {
113
+ return e?.[Symbol.toStringTag];
114
+ }
115
+ function D(e) {
116
+ return te(e).concat(C(e));
117
+ }
118
+ var O = Object.hasOwn || ((e, t) => w.call(e, t));
119
+ function k(e, t) {
120
+ return e === t || !e && !t && e !== e && t !== t;
121
+ }
122
+ var A = "__v", re = "__o", ie = "_owner", { getOwnPropertyDescriptor: j, keys: M } = Object;
123
+ function ae(e, t) {
124
+ return e.byteLength === t.byteLength && R(new Uint8Array(e), new Uint8Array(t));
125
+ }
126
+ function oe(e, t, n) {
127
+ let r = e.length;
128
+ if (t.length !== r) return !1;
129
+ for (; r-- > 0;) if (!n.equals(e[r], t[r], r, r, e, t, n)) return !1;
130
+ return !0;
131
+ }
132
+ function se(e, t) {
133
+ return e.byteLength === t.byteLength && R(new Uint8Array(e.buffer, e.byteOffset, e.byteLength), new Uint8Array(t.buffer, t.byteOffset, t.byteLength));
134
+ }
135
+ function ce(e, t) {
136
+ return k(e.getTime(), t.getTime());
137
+ }
138
+ function le(e, t) {
139
+ return e.name === t.name && e.message === t.message && e.cause === t.cause && e.stack === t.stack;
140
+ }
141
+ function ue(e, t) {
142
+ return e === t;
143
+ }
144
+ function N(e, t, n) {
145
+ let r = e.size;
146
+ if (r !== t.size) return !1;
147
+ if (!r) return !0;
148
+ let i = Array(r), a = e.entries(), o, s, c = 0;
149
+ for (; (o = a.next()) && !o.done;) {
150
+ let r = t.entries(), a = !1, l = 0;
151
+ for (; (s = r.next()) && !s.done;) {
152
+ if (i[l]) {
153
+ l++;
154
+ continue;
155
+ }
156
+ let r = o.value, u = s.value;
157
+ if (n.equals(r[0], u[0], c, l, e, t, n) && n.equals(r[1], u[1], r[0], u[0], e, t, n)) {
158
+ a = i[l] = !0;
159
+ break;
160
+ }
161
+ l++;
162
+ }
163
+ if (!a) return !1;
164
+ c++;
165
+ }
166
+ return !0;
167
+ }
168
+ var de = k;
169
+ function fe(e, t, n) {
170
+ let r = M(e), i = r.length;
171
+ if (M(t).length !== i) return !1;
172
+ for (; i-- > 0;) if (!B(e, t, n, r[i])) return !1;
173
+ return !0;
174
+ }
175
+ function P(e, t, n) {
176
+ let r = D(e), i = r.length;
177
+ if (D(t).length !== i) return !1;
178
+ let a, o, s;
179
+ for (; i-- > 0;) if (a = r[i], !B(e, t, n, a) || (o = j(e, a), s = j(t, a), (o || s) && (!o || !s || o.configurable !== s.configurable || o.enumerable !== s.enumerable || o.writable !== s.writable))) return !1;
180
+ return !0;
181
+ }
182
+ function F(e, t) {
183
+ return k(e.valueOf(), t.valueOf());
184
+ }
185
+ function I(e, t) {
186
+ return e.source === t.source && e.flags === t.flags;
187
+ }
188
+ function L(e, t, n) {
189
+ let r = e.size;
190
+ if (r !== t.size) return !1;
191
+ if (!r) return !0;
192
+ let i = Array(r), a = e.values(), o, s;
193
+ for (; (o = a.next()) && !o.done;) {
194
+ let r = t.values(), a = !1, c = 0;
195
+ for (; (s = r.next()) && !s.done;) {
196
+ if (!i[c] && n.equals(o.value, s.value, o.value, s.value, e, t, n)) {
197
+ a = i[c] = !0;
198
+ break;
199
+ }
200
+ c++;
201
+ }
202
+ if (!a) return !1;
203
+ }
204
+ return !0;
205
+ }
206
+ function R(e, t) {
207
+ let n = e.byteLength;
208
+ if (t.byteLength !== n || e.byteOffset !== t.byteOffset) return !1;
209
+ for (; n-- > 0;) if (e[n] !== t[n]) return !1;
210
+ return !0;
211
+ }
212
+ function z(e, t) {
213
+ return e.hostname === t.hostname && e.pathname === t.pathname && e.protocol === t.protocol && e.port === t.port && e.hash === t.hash && e.username === t.username && e.password === t.password;
214
+ }
215
+ function B(e, t, n, r) {
216
+ return (r === ie || r === re || r === A) && (e.$$typeof || t.$$typeof) ? !0 : O(t, r) && n.equals(e[r], t[r], r, r, e, t, n);
217
+ }
218
+ var V = "[object ArrayBuffer]", pe = "[object Arguments]", me = "[object Boolean]", he = "[object DataView]", ge = "[object Date]", _e = "[object Error]", ve = "[object Map]", ye = "[object Number]", be = "[object Object]", xe = "[object RegExp]", Se = "[object Set]", Ce = "[object String]", we = {
219
+ "[object Int8Array]": !0,
220
+ "[object Uint8Array]": !0,
221
+ "[object Uint8ClampedArray]": !0,
222
+ "[object Int16Array]": !0,
223
+ "[object Uint16Array]": !0,
224
+ "[object Int32Array]": !0,
225
+ "[object Uint32Array]": !0,
226
+ "[object Float16Array]": !0,
227
+ "[object Float32Array]": !0,
228
+ "[object Float64Array]": !0,
229
+ "[object BigInt64Array]": !0,
230
+ "[object BigUint64Array]": !0
231
+ }, Te = "[object URL]", Ee = Object.prototype.toString;
232
+ function De({ areArrayBuffersEqual: e, areArraysEqual: t, areDataViewsEqual: n, areDatesEqual: r, areErrorsEqual: i, areFunctionsEqual: a, areMapsEqual: o, areNumbersEqual: s, areObjectsEqual: c, arePrimitiveWrappersEqual: l, areRegExpsEqual: u, areSetsEqual: d, areTypedArraysEqual: f, areUrlsEqual: p, unknownTagComparators: m }) {
233
+ return function(h, g, _) {
234
+ if (h === g) return !0;
235
+ if (h == null || g == null) return !1;
236
+ let v = typeof h;
237
+ if (v !== typeof g) return !1;
238
+ if (v !== "object") return v === "number" ? s(h, g, _) : v === "function" && a(h, g, _);
239
+ let y = h.constructor;
240
+ if (y !== g.constructor) return !1;
241
+ if (y === Object) return c(h, g, _);
242
+ if (Array.isArray(h)) return t(h, g, _);
243
+ if (y === Date) return r(h, g, _);
244
+ if (y === RegExp) return u(h, g, _);
245
+ if (y === Map) return o(h, g, _);
246
+ if (y === Set) return d(h, g, _);
247
+ let b = Ee.call(h);
248
+ if (b === ge) return r(h, g, _);
249
+ if (b === xe) return u(h, g, _);
250
+ if (b === ve) return o(h, g, _);
251
+ if (b === Se) return d(h, g, _);
252
+ if (b === be) return typeof h.then != "function" && typeof g.then != "function" && c(h, g, _);
253
+ if (b === Te) return p(h, g, _);
254
+ if (b === _e) return i(h, g, _);
255
+ if (b === pe) return c(h, g, _);
256
+ if (we[b]) return f(h, g, _);
257
+ if (b === V) return e(h, g, _);
258
+ if (b === he) return n(h, g, _);
259
+ if (b === me || b === ye || b === Ce) return l(h, g, _);
260
+ if (m) {
261
+ let e = m[b];
262
+ if (!e) {
263
+ let t = ne(h);
264
+ t && (e = m[t]);
265
+ }
266
+ if (e) return e(h, g, _);
267
+ }
268
+ return !1;
269
+ };
270
+ }
271
+ function Oe({ circular: e, createCustomConfig: t, strict: n }) {
272
+ let r = {
273
+ areArrayBuffersEqual: ae,
274
+ areArraysEqual: n ? P : oe,
275
+ areDataViewsEqual: se,
276
+ areDatesEqual: ce,
277
+ areErrorsEqual: le,
278
+ areFunctionsEqual: ue,
279
+ areMapsEqual: n ? T(N, P) : N,
280
+ areNumbersEqual: de,
281
+ areObjectsEqual: n ? P : fe,
282
+ arePrimitiveWrappersEqual: F,
283
+ areRegExpsEqual: I,
284
+ areSetsEqual: n ? T(L, P) : L,
285
+ areTypedArraysEqual: n ? T(R, P) : R,
286
+ areUrlsEqual: z,
287
+ unknownTagComparators: void 0
288
+ };
289
+ if (t && (r = Object.assign({}, r, t(r))), e) {
290
+ let e = E(r.areArraysEqual), t = E(r.areMapsEqual), n = E(r.areObjectsEqual), i = E(r.areSetsEqual);
291
+ r = Object.assign({}, r, {
292
+ areArraysEqual: e,
293
+ areMapsEqual: t,
294
+ areObjectsEqual: n,
295
+ areSetsEqual: i
296
+ });
297
+ }
298
+ return r;
299
+ }
300
+ function ke(e) {
301
+ return function(t, n, r, i, a, o, s) {
302
+ return e(t, n, s);
303
+ };
304
+ }
305
+ function Ae({ circular: e, comparator: t, createState: n, equals: r, strict: i }) {
306
+ if (n) return function(a, o) {
307
+ let { cache: s = e ? /* @__PURE__ */ new WeakMap() : void 0, meta: c } = n();
308
+ return t(a, o, {
309
+ cache: s,
310
+ equals: r,
311
+ meta: c,
312
+ strict: i
313
+ });
314
+ };
315
+ if (e) return function(e, n) {
316
+ return t(e, n, {
317
+ cache: /* @__PURE__ */ new WeakMap(),
318
+ equals: r,
319
+ meta: void 0,
320
+ strict: i
321
+ });
322
+ };
323
+ let a = {
324
+ cache: void 0,
325
+ equals: r,
326
+ meta: void 0,
327
+ strict: i
328
+ };
329
+ return function(e, n) {
330
+ return t(e, n, a);
331
+ };
332
+ }
333
+ var je = H();
334
+ H({ strict: !0 }), H({ circular: !0 }), H({
335
+ circular: !0,
336
+ strict: !0
337
+ }), H({ createInternalComparator: () => k }), H({
338
+ strict: !0,
339
+ createInternalComparator: () => k
340
+ }), H({
341
+ circular: !0,
342
+ createInternalComparator: () => k
343
+ }), H({
344
+ circular: !0,
345
+ createInternalComparator: () => k,
346
+ strict: !0
347
+ });
348
+ function H(e = {}) {
349
+ let { circular: t = !1, createInternalComparator: n, createState: r, strict: i = !1 } = e, a = De(Oe(e));
350
+ return Ae({
351
+ circular: t,
352
+ comparator: a,
353
+ createState: r,
354
+ equals: n ? n(a) : ke(a),
355
+ strict: i
356
+ });
357
+ }
358
+ //#endregion
359
+ //#region node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.5/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js
360
+ var Me = /* @__PURE__ */ e(((e) => {
361
+ var t = y(), n = x();
362
+ function r(e, t) {
363
+ return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
364
+ }
365
+ var i = typeof Object.is == "function" ? Object.is : r, a = n.useSyncExternalStore, o = t.useRef, s = t.useEffect, c = t.useMemo, l = t.useDebugValue;
366
+ e.useSyncExternalStoreWithSelector = function(e, t, n, r, u) {
367
+ var d = o(null);
368
+ if (d.current === null) {
369
+ var f = {
370
+ hasValue: !1,
371
+ value: null
372
+ };
373
+ d.current = f;
374
+ } else f = d.current;
375
+ d = c(function() {
376
+ function e(e) {
377
+ if (!a) {
378
+ if (a = !0, o = e, e = r(e), u !== void 0 && f.hasValue) {
379
+ var t = f.value;
380
+ if (u(t, e)) return s = t;
381
+ }
382
+ return s = e;
383
+ }
384
+ if (t = s, i(o, e)) return t;
385
+ var n = r(e);
386
+ return u !== void 0 && u(t, n) ? (o = e, t) : (o = e, s = n);
387
+ }
388
+ var a = !1, o, s, c = n === void 0 ? null : n;
389
+ return [function() {
390
+ return e(t());
391
+ }, c === null ? void 0 : function() {
392
+ return e(c());
393
+ }];
394
+ }, [
395
+ t,
396
+ n,
397
+ r,
398
+ u
399
+ ]);
400
+ var p = a(e, d[0], d[1]);
401
+ return s(function() {
402
+ f.hasValue = !0, f.value = p;
403
+ }, [p]), l(p), p;
404
+ };
405
+ })), Ne = /* @__PURE__ */ e(((e) => {
406
+ process.env.NODE_ENV !== "production" && (function() {
407
+ function t(e, t) {
408
+ return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
409
+ }
410
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
411
+ var n = y(), r = x(), i = typeof Object.is == "function" ? Object.is : t, a = r.useSyncExternalStore, o = n.useRef, s = n.useEffect, c = n.useMemo, l = n.useDebugValue;
412
+ e.useSyncExternalStoreWithSelector = function(e, t, n, r, u) {
413
+ var d = o(null);
414
+ if (d.current === null) {
415
+ var f = {
416
+ hasValue: !1,
417
+ value: null
418
+ };
419
+ d.current = f;
420
+ } else f = d.current;
421
+ d = c(function() {
422
+ function e(e) {
423
+ if (!a) {
424
+ if (a = !0, o = e, e = r(e), u !== void 0 && f.hasValue) {
425
+ var t = f.value;
426
+ if (u(t, e)) return s = t;
427
+ }
428
+ return s = e;
429
+ }
430
+ if (t = s, i(o, e)) return t;
431
+ var n = r(e);
432
+ return u !== void 0 && u(t, n) ? (o = e, t) : (o = e, s = n);
433
+ }
434
+ var a = !1, o, s, c = n === void 0 ? null : n;
435
+ return [function() {
436
+ return e(t());
437
+ }, c === null ? void 0 : function() {
438
+ return e(c());
439
+ }];
440
+ }, [
441
+ t,
442
+ n,
443
+ r,
444
+ u
445
+ ]);
446
+ var p = a(e, d[0], d[1]);
447
+ return s(function() {
448
+ f.hasValue = !0, f.value = p;
449
+ }, [p]), l(p), p;
450
+ }, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
451
+ })();
452
+ })), Pe = (/* @__PURE__ */ e(((e, t) => {
453
+ process.env.NODE_ENV === "production" ? t.exports = Me() : t.exports = Ne();
454
+ })))(), Fe = (...e) => (t) => {
455
+ e.forEach((e) => {
456
+ typeof e == "function" ? e(t) : e && (e.current = t);
457
+ });
458
+ }, Ie = ({ contentComponent: e }) => {
459
+ let t = (0, S.useSyncExternalStore)(e.subscribe, e.getSnapshot, e.getServerSnapshot);
460
+ return /* @__PURE__ */ _(g, { children: Object.values(t) });
461
+ };
462
+ function Le() {
463
+ let e = /* @__PURE__ */ new Set(), t = {}, n = !1, r = () => {
464
+ n || !e.size || (n = !0, queueMicrotask(() => {
465
+ n = !1, e.forEach((e) => e());
466
+ }));
467
+ };
468
+ return {
469
+ subscribe(t) {
470
+ return e.add(t), () => {
471
+ e.delete(t);
472
+ };
473
+ },
474
+ getSnapshot() {
475
+ return t;
476
+ },
477
+ getServerSnapshot() {
478
+ return t;
479
+ },
480
+ setRenderer(e, n) {
481
+ t = {
482
+ ...t,
483
+ [e]: m.createPortal(n.reactElement, n.element, e)
484
+ }, r();
485
+ },
486
+ removeRenderer(e) {
487
+ let n = { ...t };
488
+ delete n[e], t = n, r();
489
+ }
490
+ };
491
+ }
492
+ var Re = class extends r.Component {
493
+ constructor(e) {
494
+ super(e), this.editorContentRef = r.createRef();
495
+ }
496
+ componentDidMount() {
497
+ this.init();
498
+ }
499
+ componentDidUpdate() {
500
+ this.init();
501
+ }
502
+ init() {
503
+ let e = this.props.editor;
504
+ if (e && !e.isDestroyed && e.view.dom?.parentNode) {
505
+ if (e.contentComponent) return;
506
+ let t = this.editorContentRef.current;
507
+ t.append(...e.view.dom.parentNode.childNodes), e.setOptions({ element: t }), e.contentComponent = Le(), e.createNodeViews(), e.isEditorContentInitialized = !0, this.forceUpdate();
508
+ }
509
+ }
510
+ componentWillUnmount() {
511
+ let e = this.props.editor;
512
+ if (e) {
513
+ e.isEditorContentInitialized = !1, e.isDestroyed || e.view.setProps({ nodeViews: {} }), e.contentComponent = null;
514
+ try {
515
+ if (!e.view.dom?.parentNode) return;
516
+ let t = document.createElement("div");
517
+ t.append(...e.view.dom.parentNode.childNodes), e.setOptions({ element: t });
518
+ } catch {}
519
+ }
520
+ }
521
+ render() {
522
+ let { editor: e, innerRef: t, ...n } = this.props;
523
+ return /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _("div", {
524
+ ref: Fe(t, this.editorContentRef),
525
+ ...n
526
+ }), e?.contentComponent && /* @__PURE__ */ _(Ie, { contentComponent: e.contentComponent })] });
527
+ }
528
+ }, ze = a((e, t) => {
529
+ let n = r.useMemo(() => Math.floor(Math.random() * 4294967295).toString(), [e.editor]);
530
+ return r.createElement(Re, {
531
+ key: n,
532
+ innerRef: t,
533
+ ...e
534
+ });
535
+ }), U = r.memo(ze), Be = typeof window < "u" ? l : c, Ve = class {
536
+ constructor(e) {
537
+ this.transactionNumber = 0, this.lastTransactionNumber = 0, this.subscribers = /* @__PURE__ */ new Set(), this.editor = e, this.lastSnapshot = {
538
+ editor: e,
539
+ transactionNumber: 0
540
+ }, this.getSnapshot = this.getSnapshot.bind(this), this.getServerSnapshot = this.getServerSnapshot.bind(this), this.watch = this.watch.bind(this), this.subscribe = this.subscribe.bind(this);
541
+ }
542
+ getSnapshot() {
543
+ return this.transactionNumber === this.lastTransactionNumber ? this.lastSnapshot : (this.lastTransactionNumber = this.transactionNumber, this.lastSnapshot = {
544
+ editor: this.editor,
545
+ transactionNumber: this.transactionNumber
546
+ }, this.lastSnapshot);
547
+ }
548
+ getServerSnapshot() {
549
+ return {
550
+ editor: null,
551
+ transactionNumber: 0
552
+ };
553
+ }
554
+ subscribe(e) {
555
+ return this.subscribers.add(e), () => {
556
+ this.subscribers.delete(e);
557
+ };
558
+ }
559
+ watch(e) {
560
+ if (this.editor = e, this.editor) {
561
+ let e, t = (t) => {
562
+ t?.transaction !== void 0 && t.transaction === e || (e = t?.transaction, this.transactionNumber += 1, this.subscribers.forEach((e) => e()));
563
+ }, n = this.editor;
564
+ return n.on("transaction", t), n.on("update", t), () => {
565
+ n.off("transaction", t), n.off("update", t);
566
+ };
567
+ }
568
+ }
569
+ };
570
+ function W(e) {
571
+ let [t] = f(() => new Ve(e.editor)), n = (0, Pe.useSyncExternalStoreWithSelector)(t.subscribe, t.getSnapshot, t.getServerSnapshot, e.selector, e.equalityFn ?? je);
572
+ return Be(() => t.watch(e.editor), [e.editor, t]), s(n), n;
573
+ }
574
+ var G = process.env.NODE_ENV !== "production", K = typeof window > "u", He = K || !!(typeof window < "u" && window.next), Ue = class e {
575
+ constructor(e) {
576
+ this.editor = null, this.subscriptions = /* @__PURE__ */ new Set(), this.isComponentMounted = !1, this.previousDeps = null, this.instanceId = "", this.options = e, this.subscriptions = /* @__PURE__ */ new Set(), this.setEditor(this.getInitialEditor()), this.scheduleDestroy(), this.getEditor = this.getEditor.bind(this), this.getServerSnapshot = this.getServerSnapshot.bind(this), this.subscribe = this.subscribe.bind(this), this.refreshEditorInstance = this.refreshEditorInstance.bind(this), this.scheduleDestroy = this.scheduleDestroy.bind(this), this.onRender = this.onRender.bind(this), this.createEditor = this.createEditor.bind(this);
577
+ }
578
+ setEditor(e) {
579
+ this.editor = e, this.instanceId = Math.random().toString(36).slice(2, 9), this.subscriptions.forEach((e) => e());
580
+ }
581
+ getInitialEditor() {
582
+ let e = this.options.current.immediatelyRender, t = e ?? !0;
583
+ return K ? (t && G && console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"), t = !1) : He && e === void 0 && (t = !1, G && console.warn("Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client.")), t ? this.createEditor() : null;
584
+ }
585
+ createEditor() {
586
+ return new t({
587
+ ...this.options.current,
588
+ onBeforeCreate: (...e) => {
589
+ var t;
590
+ return (t = this.options.current).onBeforeCreate?.call(t, ...e);
591
+ },
592
+ onBlur: (...e) => {
593
+ var t;
594
+ return (t = this.options.current).onBlur?.call(t, ...e);
595
+ },
596
+ onCreate: (...e) => {
597
+ var t;
598
+ return (t = this.options.current).onCreate?.call(t, ...e);
599
+ },
600
+ onDestroy: (...e) => {
601
+ var t;
602
+ return (t = this.options.current).onDestroy?.call(t, ...e);
603
+ },
604
+ onFocus: (...e) => {
605
+ var t;
606
+ return (t = this.options.current).onFocus?.call(t, ...e);
607
+ },
608
+ onSelectionUpdate: (...e) => {
609
+ var t;
610
+ return (t = this.options.current).onSelectionUpdate?.call(t, ...e);
611
+ },
612
+ onTransaction: (...e) => {
613
+ var t;
614
+ return (t = this.options.current).onTransaction?.call(t, ...e);
615
+ },
616
+ onUpdate: (...e) => {
617
+ var t;
618
+ return (t = this.options.current).onUpdate?.call(t, ...e);
619
+ },
620
+ onContentError: (...e) => {
621
+ var t;
622
+ return (t = this.options.current).onContentError?.call(t, ...e);
623
+ },
624
+ onDrop: (...e) => {
625
+ var t;
626
+ return (t = this.options.current).onDrop?.call(t, ...e);
627
+ },
628
+ onPaste: (...e) => {
629
+ var t;
630
+ return (t = this.options.current).onPaste?.call(t, ...e);
631
+ },
632
+ onDelete: (...e) => {
633
+ var t;
634
+ return (t = this.options.current).onDelete?.call(t, ...e);
635
+ },
636
+ onMount: (...e) => {
637
+ var t;
638
+ return (t = this.options.current).onMount?.call(t, ...e);
639
+ },
640
+ onUnmount: (...e) => {
641
+ var t;
642
+ return (t = this.options.current).onUnmount?.call(t, ...e);
643
+ }
644
+ });
645
+ }
646
+ getEditor() {
647
+ return this.editor;
648
+ }
649
+ getServerSnapshot() {
650
+ return null;
651
+ }
652
+ subscribe(e) {
653
+ return this.subscriptions.add(e), () => {
654
+ this.subscriptions.delete(e);
655
+ };
656
+ }
657
+ static compareOptions(e, t) {
658
+ return Object.keys(e).every((n) => [
659
+ "onCreate",
660
+ "onBeforeCreate",
661
+ "onDestroy",
662
+ "onUpdate",
663
+ "onTransaction",
664
+ "onFocus",
665
+ "onBlur",
666
+ "onSelectionUpdate",
667
+ "onContentError",
668
+ "onDrop",
669
+ "onPaste"
670
+ ].includes(n) ? !0 : n === "extensions" && e.extensions && t.extensions ? e.extensions.length === t.extensions.length && e.extensions.every((e, n) => e === t.extensions?.[n]) : e[n] === t[n]);
671
+ }
672
+ onRender(t) {
673
+ return () => (this.isComponentMounted = !0, clearTimeout(this.scheduledDestructionTimeout), this.editor && !this.editor.isDestroyed && t.length === 0 ? e.compareOptions(this.options.current, this.editor.options) || this.editor.setOptions({
674
+ ...this.options.current,
675
+ editable: this.editor.isEditable
676
+ }) : this.refreshEditorInstance(t), () => {
677
+ this.isComponentMounted = !1, this.scheduleDestroy();
678
+ });
679
+ }
680
+ refreshEditorInstance(e) {
681
+ if (this.editor && !this.editor.isDestroyed) {
682
+ if (this.previousDeps === null) {
683
+ this.previousDeps = e;
684
+ return;
685
+ }
686
+ if (this.previousDeps.length === e.length && this.previousDeps.every((t, n) => t === e[n])) return;
687
+ }
688
+ this.editor && !this.editor.isDestroyed && this.editor.destroy(), this.setEditor(this.createEditor()), this.previousDeps = e;
689
+ }
690
+ scheduleDestroy() {
691
+ let e = this.instanceId, t = this.editor;
692
+ this.scheduledDestructionTimeout = setTimeout(() => {
693
+ if (this.isComponentMounted && this.instanceId === e) {
694
+ t && t.setOptions(this.options.current);
695
+ return;
696
+ }
697
+ t && !t.isDestroyed && (t.destroy(), this.instanceId === e && this.setEditor(null));
698
+ }, 1);
699
+ }
700
+ };
701
+ function We(e = {}, t = []) {
702
+ let n = d(e);
703
+ n.current = e;
704
+ let [r] = f(() => new Ue(n)), i = (0, S.useSyncExternalStore)(r.subscribe, r.getEditor, r.getServerSnapshot);
705
+ return s(i), c(r.onRender(t)), W({
706
+ editor: i,
707
+ selector: ({ transactionNumber: t }) => e.shouldRerenderOnTransaction === !1 || e.shouldRerenderOnTransaction === void 0 ? null : e.immediatelyRender && t === 0 ? 0 : t + 1
708
+ }), i;
709
+ }
710
+ var q = i({ editor: null });
711
+ q.Consumer;
712
+ var Ge = () => o(q), Ke = i({
713
+ onDragStart: () => {},
714
+ nodeViewContentChildren: void 0,
715
+ nodeViewContentRef: () => {}
716
+ }), J = () => o(Ke);
717
+ r.forwardRef((e, t) => {
718
+ let { onDragStart: n } = J();
719
+ return /* @__PURE__ */ _(e.as || "div", {
720
+ ...e,
721
+ ref: t,
722
+ "data-node-view-wrapper": "",
723
+ onDragStart: n,
724
+ style: {
725
+ whiteSpace: "normal",
726
+ ...e.style
727
+ }
728
+ });
729
+ });
730
+ function Y(e) {
731
+ return !!(typeof e == "function" && e.prototype && e.prototype.isReactComponent);
732
+ }
733
+ function X(e) {
734
+ return !!(typeof e == "object" && e.$$typeof && (e.$$typeof.toString() === "Symbol(react.forward_ref)" || e.$$typeof.description === "react.forward_ref"));
735
+ }
736
+ function qe(e) {
737
+ return !!(typeof e == "object" && e.$$typeof && (e.$$typeof.toString() === "Symbol(react.memo)" || e.$$typeof.description === "react.memo"));
738
+ }
739
+ function Je(e) {
740
+ if (Y(e) || X(e)) return !0;
741
+ if (qe(e)) {
742
+ let t = e.type;
743
+ if (t) return Y(t) || X(t);
744
+ }
745
+ return !1;
746
+ }
747
+ function Ye() {
748
+ try {
749
+ if (p) return parseInt(p.split(".")[0], 10) >= 19;
750
+ } catch {}
751
+ return !1;
752
+ }
753
+ var Xe = class {
754
+ constructor(e, { editor: t, props: n = {}, as: r = "div", className: i = "" }) {
755
+ this.ref = null, this.destroyed = !1, this.id = Math.floor(Math.random() * 4294967295).toString(), this.component = e, this.editor = t, this.props = n, this.element = document.createElement(r), this.element.classList.add("react-renderer"), i && this.element.classList.add(...i.split(" ")), this.editor.isEditorContentInitialized ? h(() => {
756
+ this.render();
757
+ }) : queueMicrotask(() => {
758
+ this.destroyed || this.render();
759
+ });
760
+ }
761
+ render() {
762
+ var e;
763
+ if (this.destroyed) return;
764
+ let t = this.component, n = this.props, r = this.editor, i = Ye(), a = Je(t), o = { ...n };
765
+ o.ref && !(i || a) && delete o.ref, !o.ref && (i || a) && (o.ref = (e) => {
766
+ this.ref = e;
767
+ }), this.reactElement = /* @__PURE__ */ _(t, { ...o }), (e = r?.contentComponent) == null || e.setRenderer(this.id, this);
768
+ }
769
+ updateProps(e = {}) {
770
+ if (this.destroyed) return;
771
+ let t = !1, n = Object.keys(e);
772
+ for (let r = 0; r < n.length; r += 1) {
773
+ let i = n[r];
774
+ if (e[i] !== this.props[i]) {
775
+ t = !0;
776
+ break;
777
+ }
778
+ }
779
+ t && (this.props = {
780
+ ...this.props,
781
+ ...e
782
+ }, this.render());
783
+ }
784
+ destroy() {
785
+ var e;
786
+ this.destroyed = !0, (e = this.editor?.contentComponent) == null || e.removeRenderer(this.id);
787
+ try {
788
+ this.element && this.element.parentNode && this.element.parentNode.removeChild(this.element);
789
+ } catch {}
790
+ }
791
+ updateAttributes(e) {
792
+ Object.keys(e).forEach((t) => {
793
+ this.element.setAttribute(t, e[t]);
794
+ });
795
+ }
796
+ };
797
+ r.createContext({ markViewContentRef: () => {} });
798
+ var Z = i({ get editor() {
799
+ throw Error("useTiptap must be used within a <Tiptap> provider");
800
+ } });
801
+ Z.displayName = "TiptapContext";
802
+ var Ze = () => o(Z);
803
+ function Q({ children: e, ...t }) {
804
+ let n = "editor" in t ? t.editor : t.instance;
805
+ if (!n) throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");
806
+ let r = u(() => ({ editor: n }), [n]), i = u(() => ({ editor: n }), [n]);
807
+ return /* @__PURE__ */ _(q.Provider, {
808
+ value: i,
809
+ children: /* @__PURE__ */ _(Z.Provider, {
810
+ value: r,
811
+ children: e
812
+ })
813
+ });
814
+ }
815
+ Q.displayName = "Tiptap";
816
+ function $({ ...e }) {
817
+ let { editor: t } = Ze();
818
+ return /* @__PURE__ */ _(U, {
819
+ editor: t,
820
+ ...e
821
+ });
822
+ }
823
+ $.displayName = "Tiptap.Content", Object.assign(Q, { Content: $ });
824
+ //#endregion
825
+ export { W as a, We as i, Xe as n, Ge as r, U as t };