@wangeditor-next/yjs 0.1.2 → 0.1.3

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 CHANGED
@@ -1,1438 +1,2 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('slate'), require('yjs')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'slate', 'yjs'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.WangEditorYjsModule = {}, global.slate, global.Y));
5
- })(this, (function (exports, slate, Y) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n["default"] = e;
22
- return Object.freeze(n);
23
- }
24
-
25
- var Y__namespace = /*#__PURE__*/_interopNamespace(Y);
26
-
27
- /******************************************************************************
28
- Copyright (c) Microsoft Corporation.
29
-
30
- Permission to use, copy, modify, and/or distribute this software for any
31
- purpose with or without fee is hereby granted.
32
-
33
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
34
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
35
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
36
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
37
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
38
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39
- PERFORMANCE OF THIS SOFTWARE.
40
- ***************************************************************************** */
41
-
42
- var __assign = function() {
43
- __assign = Object.assign || function __assign(t) {
44
- for (var s, i = 1, n = arguments.length; i < n; i++) {
45
- s = arguments[i];
46
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
47
- }
48
- return t;
49
- };
50
- return __assign.apply(this, arguments);
51
- };
52
-
53
- function __rest(s, e) {
54
- var t = {};
55
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
56
- t[p] = s[p];
57
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
58
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
59
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
60
- t[p[i]] = s[p[i]];
61
- }
62
- return t;
63
- }
64
-
65
- function __values(o) {
66
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
67
- if (m) return m.call(o);
68
- if (o && typeof o.length === "number") return {
69
- next: function () {
70
- if (o && i >= o.length) o = void 0;
71
- return { value: o && o[i++], done: !o };
72
- }
73
- };
74
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
75
- }
76
-
77
- function __read(o, n) {
78
- var m = typeof Symbol === "function" && o[Symbol.iterator];
79
- if (!m) return o;
80
- var i = m.call(o), r, ar = [], e;
81
- try {
82
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
83
- }
84
- catch (error) { e = { error: error }; }
85
- finally {
86
- try {
87
- if (r && !r.done && (m = i["return"])) m.call(i);
88
- }
89
- finally { if (e) throw e.error; }
90
- }
91
- return ar;
92
- }
93
-
94
- function __spreadArray(to, from, pack) {
95
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
96
- if (ar || !(i in from)) {
97
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
98
- ar[i] = from[i];
99
- }
100
- }
101
- return to.concat(ar || Array.prototype.slice.call(from));
102
- }
103
-
104
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
105
- var e = new Error(message);
106
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
107
- };
108
-
109
- function isObject(o) {
110
- return Object.prototype.toString.call(o) === '[object Object]';
111
- }
112
- function isPlainObject(o) {
113
- if (!isObject(o)) {
114
- return false;
115
- }
116
- // If has modified constructor
117
- var ctor = o.constructor;
118
- if (ctor === undefined) {
119
- return true;
120
- }
121
- // If has modified prototype
122
- var prot = ctor.prototype;
123
- if (isObject(prot) === false) {
124
- return false;
125
- }
126
- // If constructor does not have an Object-specific method
127
- if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOfOf')) {
128
- return false;
129
- }
130
- // Most likely a plain Object
131
- return true;
132
- }
133
- // Slates deep equality function: https://github.com/ianstormtaylor/slate/blob/68aff89e892fe15a16314398ff052ade6068900b/packages/slate/src/utils/deep-equal.ts#L13
134
- // We have to match slates deepEquals behavior to merge insert deltas in the same way slate does.
135
- function deepEquals(node, another) {
136
- // eslint-disable-next-line guard-for-in
137
- for (var key in node) {
138
- var a = node[key];
139
- var b = another[key];
140
- if (isPlainObject(a) && isPlainObject(b)) {
141
- if (!deepEquals(a, b)) {
142
- return false;
143
- }
144
- }
145
- else if (Array.isArray(a) && Array.isArray(b)) {
146
- if (a.length !== b.length)
147
- return false;
148
- for (var i = 0; i < a.length; i++) {
149
- if (a[i] !== b[i]) {
150
- return false;
151
- }
152
- }
153
- }
154
- else if (a !== b) {
155
- return false;
156
- }
157
- }
158
- for (var key in another) {
159
- if (node[key] === undefined && another[key] !== undefined) {
160
- return false;
161
- }
162
- }
163
- return true;
164
- }
165
- function pick(obj) {
166
- var keys = [];
167
- for (var _i = 1; _i < arguments.length; _i++) {
168
- keys[_i - 1] = arguments[_i];
169
- }
170
- return Object.fromEntries(Object.entries(obj).filter(function (_a) {
171
- var _b = __read(_a, 1), key = _b[0];
172
- return keys.includes(key);
173
- }));
174
- }
175
- function omit(obj) {
176
- var keys = [];
177
- for (var _i = 1; _i < arguments.length; _i++) {
178
- keys[_i - 1] = arguments[_i];
179
- }
180
- return Object.fromEntries(Object.entries(obj).filter(function (_a) {
181
- var _b = __read(_a, 1), key = _b[0];
182
- return !keys.includes(key);
183
- }));
184
- }
185
- function omitNullEntries(obj) {
186
- return Object.fromEntries(Object.entries(obj).filter(function (_a) {
187
- var _b = __read(_a, 2), value = _b[1];
188
- return value !== null;
189
- }));
190
- }
191
-
192
- function normalizeInsertDelta(delta) {
193
- var e_1, _a;
194
- var _b, _c;
195
- var normalized = [];
196
- try {
197
- for (var delta_1 = __values(delta), delta_1_1 = delta_1.next(); !delta_1_1.done; delta_1_1 = delta_1.next()) {
198
- var element = delta_1_1.value;
199
- if (typeof element.insert === 'string' && element.insert.length === 0) {
200
- continue;
201
- }
202
- var prev = normalized[normalized.length - 1];
203
- if (!prev || typeof prev.insert !== 'string' || typeof element.insert !== 'string') {
204
- normalized.push(element);
205
- continue;
206
- }
207
- var merge = prev.attributes === element.attributes ||
208
- (!prev.attributes === !element.attributes &&
209
- deepEquals((_b = prev.attributes) !== null && _b !== void 0 ? _b : {}, (_c = element.attributes) !== null && _c !== void 0 ? _c : {}));
210
- if (merge) {
211
- prev.insert += element.insert;
212
- continue;
213
- }
214
- normalized.push(element);
215
- }
216
- }
217
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
218
- finally {
219
- try {
220
- if (delta_1_1 && !delta_1_1.done && (_a = delta_1.return)) _a.call(delta_1);
221
- }
222
- finally { if (e_1) throw e_1.error; }
223
- }
224
- return normalized;
225
- }
226
- function yTextToInsertDelta(yText) {
227
- return normalizeInsertDelta(yText.toDelta());
228
- }
229
- function getInsertLength(_a) {
230
- var insert = _a.insert;
231
- return typeof insert === 'string' ? insert.length : 1;
232
- }
233
- function getInsertDeltaLength(delta) {
234
- return delta.reduce(function (curr, element) { return curr + getInsertLength(element); }, 0);
235
- }
236
- function sliceInsertDelta(delta, start, length) {
237
- if (length < 1) {
238
- return [];
239
- }
240
- var currentOffset = 0;
241
- var sliced = [];
242
- var end = start + length;
243
- for (var i = 0; i < delta.length; i++) {
244
- if (currentOffset >= end) {
245
- break;
246
- }
247
- var element = delta[i];
248
- var elementLength = getInsertLength(element);
249
- if (currentOffset + elementLength <= start) {
250
- currentOffset += elementLength;
251
- continue;
252
- }
253
- if (typeof element.insert !== 'string') {
254
- currentOffset += elementLength;
255
- sliced.push(element);
256
- continue;
257
- }
258
- var startOffset = Math.max(0, start - currentOffset);
259
- var endOffset = Math.min(elementLength, elementLength - (currentOffset + elementLength - end));
260
- sliced.push(__assign(__assign({}, element), { insert: element.insert.slice(startOffset, endOffset) }));
261
- currentOffset += elementLength;
262
- }
263
- return sliced;
264
- }
265
-
266
- function getProperties(node) {
267
- return omit(node, (slate.Text.isText(node) ? 'text' : 'children'));
268
- }
269
-
270
- function yTextToSlateElement(yText) {
271
- var delta = yTextToInsertDelta(yText);
272
- var children = delta.length > 0 ? delta.map(deltaInsertToSlateNode) : [{ text: '' }];
273
- return __assign(__assign({}, yText.getAttributes()), { children: children });
274
- }
275
- function deltaInsertToSlateNode(insert) {
276
- if (typeof insert.insert === 'string') {
277
- return __assign(__assign({}, insert.attributes), { text: insert.insert });
278
- }
279
- return yTextToSlateElement(insert.insert);
280
- }
281
- function slateNodesToInsertDelta(nodes) {
282
- return nodes.map(function (node) {
283
- if (slate.Text.isText(node)) {
284
- return { insert: node.text, attributes: getProperties(node) };
285
- }
286
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
287
- return { insert: slateElementToYText(node) };
288
- });
289
- }
290
- function slateElementToYText(_a) {
291
- var children = _a.children, attributes = __rest(_a, ["children"]);
292
- var yElement = new Y__namespace.XmlText();
293
- Object.entries(attributes).forEach(function (_a) {
294
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
295
- yElement.setAttribute(key, value);
296
- });
297
- yElement.applyDelta(slateNodesToInsertDelta(children), { sanitize: false });
298
- return yElement;
299
- }
300
-
301
- function getSlateNodeYLength(node) {
302
- if (!node) {
303
- return 0;
304
- }
305
- return slate.Text.isText(node) ? node.text.length : 1;
306
- }
307
- function slatePathOffsetToYOffset(element, pathOffset) {
308
- return element.children
309
- .slice(0, pathOffset)
310
- .reduce(function (yOffset, node) { return yOffset + getSlateNodeYLength(node); }, 0);
311
- }
312
- function getYTarget(yRoot, slateRoot, path) {
313
- var _a;
314
- if (path.length === 0) {
315
- throw new Error('Path has to a have a length >= 1');
316
- }
317
- if (slate.Text.isText(slateRoot)) {
318
- throw new Error('Cannot descent into slate text');
319
- }
320
- var _b = __read(path), pathOffset = _b[0], childPath = _b.slice(1);
321
- var yOffset = slatePathOffsetToYOffset(slateRoot, pathOffset);
322
- var targetNode = slateRoot.children[pathOffset];
323
- var delta = yTextToInsertDelta(yRoot);
324
- var targetLength = getSlateNodeYLength(targetNode);
325
- var targetDelta = sliceInsertDelta(delta, yOffset, targetLength);
326
- if (targetDelta.length > 1) {
327
- throw new Error("Path doesn't match yText, yTarget spans multiple nodes");
328
- }
329
- var yTarget = (_a = targetDelta[0]) === null || _a === void 0 ? void 0 : _a.insert;
330
- if (childPath.length > 0) {
331
- if (!(yTarget instanceof Y__namespace.XmlText)) {
332
- throw new Error("Path doesn't match yText, cannot descent into non-yText");
333
- }
334
- return getYTarget(yTarget, targetNode, childPath);
335
- }
336
- return {
337
- yParent: yRoot,
338
- textRange: { start: yOffset, end: yOffset + targetLength },
339
- yTarget: yTarget instanceof Y__namespace.XmlText ? yTarget : undefined,
340
- slateParent: slateRoot,
341
- slateTarget: targetNode,
342
- targetDelta: targetDelta,
343
- };
344
- }
345
- function yOffsetToSlateOffsets(parent, yOffset, opts) {
346
- if (opts === void 0) { opts = {}; }
347
- var _a = opts.assoc, assoc = _a === void 0 ? 0 : _a, _b = opts.insert, insert = _b === void 0 ? false : _b;
348
- var currentOffset = 0;
349
- var lastNonEmptyPathOffset = 0;
350
- for (var pathOffset = 0; pathOffset < parent.children.length; pathOffset++) {
351
- var child_1 = parent.children[pathOffset];
352
- var nodeLength = slate.Text.isText(child_1) ? child_1.text.length : 1;
353
- if (nodeLength > 0) {
354
- lastNonEmptyPathOffset = pathOffset;
355
- }
356
- var endOffset = currentOffset + nodeLength;
357
- if (nodeLength > 0 && (assoc >= 0 ? endOffset > yOffset : endOffset >= yOffset)) {
358
- return [pathOffset, yOffset - currentOffset];
359
- }
360
- currentOffset += nodeLength;
361
- }
362
- if (yOffset > currentOffset + (insert ? 1 : 0)) {
363
- throw new Error('yOffset out of bounds');
364
- }
365
- if (insert) {
366
- return [parent.children.length, 0];
367
- }
368
- var child = parent.children[lastNonEmptyPathOffset];
369
- var textOffset = slate.Text.isText(child) ? child.text.length : 1;
370
- return [lastNonEmptyPathOffset, textOffset];
371
- }
372
- function getSlatePath(sharedRoot, slateRoot, yText) {
373
- var yNodePath = [yText];
374
- while (yNodePath[0] !== sharedRoot) {
375
- var yParent = yNodePath[0].parent;
376
- if (!yParent) {
377
- throw new Error("yText isn't a descendant of root element");
378
- }
379
- if (!(yParent instanceof Y__namespace.XmlText)) {
380
- throw new Error('Unexpected y parent type');
381
- }
382
- yNodePath.unshift(yParent);
383
- }
384
- if (yNodePath.length < 2) {
385
- return [];
386
- }
387
- var slateParent = slateRoot;
388
- return yNodePath.reduce(function (path, yParent, idx) {
389
- var e_1, _a;
390
- var yChild = yNodePath[idx + 1];
391
- if (!yChild) {
392
- return path;
393
- }
394
- var yOffset = 0;
395
- var currentDelta = yTextToInsertDelta(yParent);
396
- try {
397
- for (var currentDelta_1 = __values(currentDelta), currentDelta_1_1 = currentDelta_1.next(); !currentDelta_1_1.done; currentDelta_1_1 = currentDelta_1.next()) {
398
- var element = currentDelta_1_1.value;
399
- if (element.insert === yChild) {
400
- break;
401
- }
402
- yOffset += typeof element.insert === 'string' ? element.insert.length : 1;
403
- }
404
- }
405
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
406
- finally {
407
- try {
408
- if (currentDelta_1_1 && !currentDelta_1_1.done && (_a = currentDelta_1.return)) _a.call(currentDelta_1);
409
- }
410
- finally { if (e_1) throw e_1.error; }
411
- }
412
- if (slate.Text.isText(slateParent)) {
413
- throw new Error('Cannot descent into slate text');
414
- }
415
- var _b = __read(yOffsetToSlateOffsets(slateParent, yOffset), 1), pathOffset = _b[0];
416
- slateParent = slateParent.children[pathOffset];
417
- return path.concat(pathOffset);
418
- }, []);
419
- }
420
-
421
- function applyDelta(node, slatePath, delta) {
422
- var ops = [];
423
- var yOffset = delta.reduce(function (length, change) {
424
- if ('retain' in change) {
425
- return length + change.retain;
426
- }
427
- if ('delete' in change) {
428
- return length + change.delete;
429
- }
430
- return length;
431
- }, 0);
432
- // Apply changes in reverse order to avoid path changes.
433
- delta.reverse().forEach(function (change) {
434
- var _a;
435
- if ('attributes' in change && 'retain' in change) {
436
- var _b = __read(yOffsetToSlateOffsets(node, yOffset - change.retain), 2), startPathOffset = _b[0], startTextOffset = _b[1];
437
- var _c = __read(yOffsetToSlateOffsets(node, yOffset, { assoc: -1 }), 2), endPathOffset = _c[0], endTextOffset = _c[1];
438
- for (var pathOffset = endPathOffset; pathOffset >= startPathOffset; pathOffset--) {
439
- var child = node.children[pathOffset];
440
- var childPath = __spreadArray(__spreadArray([], __read(slatePath)), [pathOffset]);
441
- if (!slate.Text.isText(child)) {
442
- // Ignore attribute updates on non-text nodes (which are backed by Y.XmlText)
443
- // to be consistent with deltaInsertToSlateNode. Y.XmlText attributes don't show
444
- // up in deltas but in key changes (YEvent.changes.keys).
445
- continue;
446
- }
447
- var newProperties = change.attributes;
448
- var properties = pick.apply(void 0, __spreadArray([node], __read(Object.keys(change.attributes))));
449
- if (pathOffset === startPathOffset || pathOffset === endPathOffset) {
450
- var start = pathOffset === startPathOffset ? startTextOffset : 0;
451
- var end = pathOffset === endPathOffset ? endTextOffset : child.text.length;
452
- if (end !== child.text.length) {
453
- ops.push({
454
- type: 'split_node',
455
- path: childPath,
456
- position: end,
457
- properties: getProperties(child),
458
- });
459
- }
460
- if (start !== 0) {
461
- ops.push({
462
- type: 'split_node',
463
- path: childPath,
464
- position: start,
465
- properties: omitNullEntries(__assign(__assign({}, getProperties(child)), newProperties)),
466
- });
467
- continue;
468
- }
469
- }
470
- ops.push({
471
- type: 'set_node',
472
- newProperties: newProperties,
473
- path: childPath,
474
- properties: properties,
475
- });
476
- }
477
- }
478
- if ('retain' in change) {
479
- yOffset -= change.retain;
480
- }
481
- if ('delete' in change) {
482
- var _d = __read(yOffsetToSlateOffsets(node, yOffset - change.delete), 2), startPathOffset = _d[0], startTextOffset = _d[1];
483
- var _e = __read(yOffsetToSlateOffsets(node, yOffset, { assoc: -1 }), 2), endPathOffset = _e[0], endTextOffset = _e[1];
484
- for (var pathOffset = endTextOffset === 0 ? endPathOffset - 1 : endPathOffset; pathOffset >= startPathOffset; pathOffset--) {
485
- var child = node.children[pathOffset];
486
- var childPath = __spreadArray(__spreadArray([], __read(slatePath)), [pathOffset]);
487
- if (slate.Text.isText(child) &&
488
- (pathOffset === startPathOffset || pathOffset === endPathOffset)) {
489
- var start = pathOffset === startPathOffset ? startTextOffset : 0;
490
- var end = pathOffset === endPathOffset ? endTextOffset : child.text.length;
491
- ops.push({
492
- type: 'remove_text',
493
- offset: start,
494
- text: child.text.slice(start, end),
495
- path: childPath,
496
- });
497
- yOffset -= end - start;
498
- continue;
499
- }
500
- ops.push({
501
- type: 'remove_node',
502
- node: child,
503
- path: childPath,
504
- });
505
- yOffset -= getSlateNodeYLength(child);
506
- }
507
- return;
508
- }
509
- if ('insert' in change) {
510
- var _f = __read(yOffsetToSlateOffsets(node, yOffset, {
511
- insert: true,
512
- }), 2), pathOffset = _f[0], textOffset = _f[1];
513
- var child = node.children[pathOffset];
514
- var childPath = __spreadArray(__spreadArray([], __read(slatePath)), [pathOffset]);
515
- if (slate.Text.isText(child)) {
516
- var lastOp = ops[ops.length - 1];
517
- /**
518
- * The props that exist at the current path
519
- * Since we're not actually using slate to update the node
520
- * this is a simulation
521
- */
522
- var currentProps = lastOp != null && lastOp.type === 'insert_node' ? lastOp.node : getProperties(child);
523
- var lastPath = [];
524
- if (lastOp != null &&
525
- (lastOp.type === 'insert_node' ||
526
- lastOp.type === 'insert_text' ||
527
- lastOp.type === 'split_node' ||
528
- lastOp.type === 'set_node')) {
529
- lastPath = lastOp.path;
530
- }
531
- /**
532
- * If the insert is a string and the attributes are the same as the
533
- * props at the current path, we can just insert a text node
534
- */
535
- if (typeof change.insert === 'string' &&
536
- deepEquals((_a = change.attributes) !== null && _a !== void 0 ? _a : {}, currentProps) &&
537
- slate.Path.equals(childPath, lastPath)) {
538
- return ops.push({
539
- type: 'insert_text',
540
- offset: textOffset,
541
- text: change.insert,
542
- path: childPath,
543
- });
544
- }
545
- var toInsert = deltaInsertToSlateNode(change);
546
- if (textOffset === 0) {
547
- return ops.push({
548
- type: 'insert_node',
549
- path: childPath,
550
- node: toInsert,
551
- });
552
- }
553
- if (textOffset < child.text.length) {
554
- ops.push({
555
- type: 'split_node',
556
- path: childPath,
557
- position: textOffset,
558
- properties: getProperties(child),
559
- });
560
- }
561
- return ops.push({
562
- type: 'insert_node',
563
- path: slate.Path.next(childPath),
564
- node: toInsert,
565
- });
566
- }
567
- return ops.push({
568
- type: 'insert_node',
569
- path: childPath,
570
- node: deltaInsertToSlateNode(change),
571
- });
572
- }
573
- });
574
- return ops;
575
- }
576
- function translateYTextEvent(sharedRoot, editor, event) {
577
- var target = event.target, changes = event.changes;
578
- var delta = event.delta;
579
- if (!(target instanceof Y__namespace.XmlText)) {
580
- throw new Error('Unexpected target node type');
581
- }
582
- var ops = [];
583
- var slatePath = getSlatePath(sharedRoot, editor, target);
584
- var targetElement = slate.Node.get(editor, slatePath);
585
- if (slate.Text.isText(targetElement)) {
586
- throw new Error('Cannot apply yTextEvent to text node');
587
- }
588
- var keyChanges = Array.from(changes.keys.entries());
589
- if (slatePath.length > 0 && keyChanges.length > 0) {
590
- var newProperties = Object.fromEntries(keyChanges.map(function (_a) {
591
- var _b = __read(_a, 2), key = _b[0], info = _b[1];
592
- return [
593
- key,
594
- info.action === 'delete' ? null : target.getAttribute(key),
595
- ];
596
- }));
597
- var properties = Object.fromEntries(keyChanges.map(function (_a) {
598
- var _b = __read(_a, 1), key = _b[0];
599
- return [key, targetElement[key]];
600
- }));
601
- ops.push({ type: 'set_node', newProperties: newProperties, properties: properties, path: slatePath });
602
- }
603
- if (delta.length > 0) {
604
- ops.push.apply(ops, __spreadArray([], __read(applyDelta(targetElement, slatePath, delta))));
605
- }
606
- return ops;
607
- }
608
-
609
- /**
610
- * Translate a yjs event into slate operations. The editor state has to match the
611
- * yText state before the event occurred.
612
- *
613
- * @param sharedType
614
- * @param op
615
- */
616
- function translateYjsEvent(sharedRoot, editor, event) {
617
- if (event instanceof Y__namespace.YTextEvent) {
618
- return translateYTextEvent(sharedRoot, editor, event);
619
- }
620
- throw new Error('Unexpected Y event type');
621
- }
622
- /**
623
- * Translates yjs events into slate operations and applies them to the editor. The
624
- * editor state has to match the yText state before the events occurred.
625
- *
626
- * @param sharedRoot
627
- * @param editor
628
- * @param events
629
- */
630
- function applyYjsEvents(sharedRoot, editor, events) {
631
- slate.Editor.withoutNormalizing(editor, function () {
632
- events.forEach(function (event) {
633
- translateYjsEvent(sharedRoot, editor, event).forEach(function (op) {
634
- editor.apply(op);
635
- });
636
- });
637
- });
638
- }
639
-
640
- function insertNode(sharedRoot, slateRoot, op) {
641
- var _a = getYTarget(sharedRoot, slateRoot, op.path), yParent = _a.yParent, textRange = _a.textRange;
642
- if (slate.Text.isText(op.node)) {
643
- return yParent.insert(textRange.start, op.node.text, getProperties(op.node));
644
- }
645
- yParent.insertEmbed(textRange.start, slateElementToYText(op.node));
646
- }
647
-
648
- function cloneInsertDeltaDeep(delta) {
649
- return delta.map(function (element) {
650
- if (typeof element.insert === 'string') {
651
- return element;
652
- }
653
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
654
- return __assign(__assign({}, element), { insert: cloneDeep(element.insert) });
655
- });
656
- }
657
- function cloneDeep(yText) {
658
- var clone = new Y__namespace.XmlText();
659
- var attributes = yText.getAttributes();
660
- Object.entries(attributes).forEach(function (_a) {
661
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
662
- clone.setAttribute(key, value);
663
- });
664
- clone.applyDelta(cloneInsertDeltaDeep(yTextToInsertDelta(yText)), {
665
- sanitize: false,
666
- });
667
- return clone;
668
- }
669
-
670
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
671
- function assertDocumentAttachment(sharedType) {
672
- if (!sharedType.doc) {
673
- throw new Error("shared type isn't attached to a document");
674
- }
675
- }
676
-
677
- var STORED_POSITION_PREFIX = '__slateYjsStoredPosition_';
678
- function slatePointToRelativePosition(sharedRoot, slateRoot, point) {
679
- var _a = getYTarget(sharedRoot, slateRoot, point.path), yTarget = _a.yTarget, yParent = _a.yParent, textRange = _a.textRange;
680
- if (yTarget) {
681
- throw new Error('Slate point points to a non-text element inside sharedRoot');
682
- }
683
- var index = textRange.start + point.offset;
684
- return Y__namespace.createRelativePositionFromTypeIndex(yParent, index, index === textRange.end ? -1 : 0);
685
- }
686
- function absolutePositionToSlatePoint(sharedRoot, slateRoot, _a) {
687
- var type = _a.type, index = _a.index, assoc = _a.assoc;
688
- if (!(type instanceof Y__namespace.XmlText)) {
689
- throw new Error('Absolute position points to a non-XMLText');
690
- }
691
- var parentPath = getSlatePath(sharedRoot, slateRoot, type);
692
- var parent = slate.Node.get(slateRoot, parentPath);
693
- if (slate.Text.isText(parent)) {
694
- throw new Error("Absolute position doesn't match slateRoot, cannot descent into text");
695
- }
696
- var _b = __read(yOffsetToSlateOffsets(parent, index, {
697
- assoc: assoc,
698
- }), 2), pathOffset = _b[0], textOffset = _b[1];
699
- var target = parent.children[pathOffset];
700
- if (!slate.Text.isText(target)) {
701
- return null;
702
- }
703
- return { path: __spreadArray(__spreadArray([], __read(parentPath)), [pathOffset]), offset: textOffset };
704
- }
705
- function relativePositionToSlatePoint(sharedRoot, slateRoot, pos) {
706
- if (!sharedRoot.doc) {
707
- throw new Error("sharedRoot isn't attach to a yDoc");
708
- }
709
- var absPos = Y__namespace.createAbsolutePositionFromRelativePosition(pos, sharedRoot.doc);
710
- return absPos && absolutePositionToSlatePoint(sharedRoot, slateRoot, absPos);
711
- }
712
- function getStoredPosition(sharedRoot, key) {
713
- var rawPosition = sharedRoot.getAttribute(STORED_POSITION_PREFIX + key);
714
- if (!rawPosition) {
715
- return null;
716
- }
717
- return Y__namespace.decodeRelativePosition(rawPosition);
718
- }
719
- function getStoredPositions(sharedRoot) {
720
- return Object.fromEntries(Object.entries(sharedRoot.getAttributes())
721
- .filter(function (_a) {
722
- var _b = __read(_a, 1), key = _b[0];
723
- return key.startsWith(STORED_POSITION_PREFIX);
724
- })
725
- .map(function (_a) {
726
- var _b = __read(_a, 2), key = _b[0], position = _b[1];
727
- return [
728
- key.slice(STORED_POSITION_PREFIX.length),
729
- Y__namespace.createRelativePositionFromJSON(position),
730
- ];
731
- }));
732
- }
733
- function getStoredPositionsAbsolute(sharedRoot) {
734
- assertDocumentAttachment(sharedRoot);
735
- return Object.fromEntries(Object.entries(sharedRoot.getAttributes())
736
- .filter(function (_a) {
737
- var _b = __read(_a, 1), key = _b[0];
738
- return key.startsWith(STORED_POSITION_PREFIX);
739
- })
740
- .map(function (_a) {
741
- var _b = __read(_a, 2), key = _b[0], position = _b[1];
742
- return [
743
- key.slice(STORED_POSITION_PREFIX.length),
744
- Y__namespace.createAbsolutePositionFromRelativePosition(Y__namespace.decodeRelativePosition(position), sharedRoot.doc),
745
- ];
746
- })
747
- .filter(function (_a) {
748
- var _b = __read(_a, 2), position = _b[1];
749
- return position;
750
- }));
751
- }
752
- function removeStoredPosition(sharedRoot, key) {
753
- sharedRoot.removeAttribute(STORED_POSITION_PREFIX + key);
754
- }
755
- function setStoredPosition(sharedRoot, key, position) {
756
- sharedRoot.setAttribute(STORED_POSITION_PREFIX + key, Y__namespace.encodeRelativePosition(position));
757
- }
758
- function getAbsolutePositionsInTextRange(absolutePositions, yTarget, textRange) {
759
- return Object.fromEntries(Object.entries(absolutePositions).filter(function (_a) {
760
- var _b = __read(_a, 2), position = _b[1];
761
- if (position.type !== yTarget) {
762
- return false;
763
- }
764
- if (!textRange) {
765
- return true;
766
- }
767
- return position.assoc >= 0
768
- ? position.index >= textRange.start && position.index < textRange.end
769
- : position.index > textRange.start && position.index >= textRange.end;
770
- }));
771
- }
772
- function getAbsolutePositionsInYText(absolutePositions, yText, parentPath) {
773
- var _a;
774
- if (parentPath === void 0) { parentPath = ''; }
775
- var positions = (_a = {},
776
- _a[parentPath] = getAbsolutePositionsInTextRange(absolutePositions, yText),
777
- _a);
778
- var insertDelta = yTextToInsertDelta(yText);
779
- insertDelta.forEach(function (_a, i) {
780
- var insert = _a.insert;
781
- if (insert instanceof Y__namespace.XmlText) {
782
- Object.assign(positions, getAbsolutePositionsInYText(absolutePositions, insert, parentPath ? parentPath + "." + i : i.toString()));
783
- }
784
- });
785
- return positions;
786
- }
787
- function getStoredPositionsInDeltaAbsolute(sharedRoot, yText, delta, deltaOffset) {
788
- if (deltaOffset === void 0) { deltaOffset = 0; }
789
- var absolutePositions = getStoredPositionsAbsolute(sharedRoot);
790
- var positions = {
791
- '': getAbsolutePositionsInTextRange(absolutePositions, yText, {
792
- start: deltaOffset,
793
- end: deltaOffset + getInsertDeltaLength(delta),
794
- }),
795
- };
796
- delta.forEach(function (_a, i) {
797
- var insert = _a.insert;
798
- if (insert instanceof Y__namespace.XmlText) {
799
- Object.assign(positions, getAbsolutePositionsInYText(absolutePositions, insert, i.toString()));
800
- }
801
- });
802
- return positions;
803
- }
804
- function restoreStoredPositionsWithDeltaAbsolute(sharedRoot, yText, absolutePositions, delta, newDeltaOffset, previousDeltaOffset, path) {
805
- if (newDeltaOffset === void 0) { newDeltaOffset = 0; }
806
- if (previousDeltaOffset === void 0) { previousDeltaOffset = 0; }
807
- if (path === void 0) { path = ''; }
808
- var toRestore = absolutePositions[path];
809
- if (toRestore) {
810
- Object.entries(toRestore).forEach(function (_a) {
811
- var _b = __read(_a, 2), key = _b[0], position = _b[1];
812
- setStoredPosition(sharedRoot, key, Y__namespace.createRelativePositionFromTypeIndex(yText, position.index - previousDeltaOffset + newDeltaOffset, position.assoc));
813
- });
814
- }
815
- delta.forEach(function (_a, i) {
816
- var insert = _a.insert;
817
- if (insert instanceof Y__namespace.XmlText) {
818
- restoreStoredPositionsWithDeltaAbsolute(sharedRoot, insert, absolutePositions, yTextToInsertDelta(insert), 0, 0, path ? path + "." + i : i.toString());
819
- }
820
- });
821
- }
822
- function slateRangeToRelativeRange(sharedRoot, slateRoot, range) {
823
- return {
824
- anchor: slatePointToRelativePosition(sharedRoot, slateRoot, range.anchor),
825
- focus: slatePointToRelativePosition(sharedRoot, slateRoot, range.focus),
826
- };
827
- }
828
- function relativeRangeToSlateRange(sharedRoot, slateRoot, range) {
829
- var anchor = relativePositionToSlatePoint(sharedRoot, slateRoot, range.anchor);
830
- if (!anchor) {
831
- return null;
832
- }
833
- var focus = relativePositionToSlatePoint(sharedRoot, slateRoot, range.focus);
834
- if (!focus) {
835
- return null;
836
- }
837
- return { anchor: anchor, focus: focus };
838
- }
839
-
840
- function mergeNode(sharedRoot, slateRoot, op) {
841
- var target = getYTarget(sharedRoot, slateRoot, op.path);
842
- var prev = getYTarget(target.yParent, target.slateParent, slate.Path.previous(op.path.slice(-1)));
843
- if (!target.yTarget !== !prev.yTarget) {
844
- throw new Error('Cannot merge y text with y element');
845
- }
846
- if (!prev.yTarget || !target.yTarget) {
847
- var parent_1 = target.yParent, textRange = target.textRange, slateTarget = target.slateTarget;
848
- if (!slateTarget) {
849
- throw new Error('Expected Slate target node for merge op.');
850
- }
851
- var prevSibling = slate.Node.get(slateRoot, slate.Path.previous(op.path));
852
- if (!slate.Text.isText(prevSibling)) {
853
- throw new Error('Path points to Y.Text but not a Slate text node.');
854
- }
855
- var targetProps = getProperties(slateTarget);
856
- var prevSiblingProps_1 = getProperties(prevSibling);
857
- var unsetProps = Object.keys(targetProps).reduce(function (acc, key) {
858
- var _a;
859
- var prevSiblingHasProp = key in prevSiblingProps_1;
860
- return prevSiblingHasProp ? acc : __assign(__assign({}, acc), (_a = {}, _a[key] = null, _a));
861
- }, {});
862
- return parent_1.format(textRange.start, textRange.end - textRange.start, __assign(__assign({}, unsetProps), prevSiblingProps_1));
863
- }
864
- var deltaApplyYOffset = prev.yTarget.length;
865
- var targetDelta = yTextToInsertDelta(target.yTarget);
866
- var clonedDelta = cloneInsertDeltaDeep(targetDelta);
867
- var storedPositions = getStoredPositionsInDeltaAbsolute(sharedRoot, target.yTarget, targetDelta, deltaApplyYOffset);
868
- var applyDelta = __spreadArray([{ retain: deltaApplyYOffset }], __read(clonedDelta));
869
- prev.yTarget.applyDelta(applyDelta, {
870
- sanitize: false,
871
- });
872
- target.yParent.delete(target.textRange.start, target.textRange.end - target.textRange.start);
873
- restoreStoredPositionsWithDeltaAbsolute(sharedRoot, prev.yTarget, storedPositions, clonedDelta, deltaApplyYOffset);
874
- }
875
-
876
- function moveNode(sharedRoot, slateRoot, op) {
877
- var newParentPath = slate.Path.parent(op.newPath);
878
- var newPathOffset = op.newPath[op.newPath.length - 1];
879
- var parent = slate.Node.get(slateRoot, newParentPath);
880
- if (slate.Text.isText(parent)) {
881
- throw new Error('Cannot move slate node into text element');
882
- }
883
- var normalizedNewPath = __spreadArray(__spreadArray([], __read(newParentPath)), [Math.min(newPathOffset, parent.children.length)]);
884
- var origin = getYTarget(sharedRoot, slateRoot, op.path);
885
- var target = getYTarget(sharedRoot, slateRoot, normalizedNewPath);
886
- var insertDelta = cloneInsertDeltaDeep(origin.targetDelta);
887
- var storedPositions = getStoredPositionsInDeltaAbsolute(sharedRoot, origin.yParent, origin.targetDelta);
888
- origin.yParent.delete(origin.textRange.start, origin.textRange.end - origin.textRange.start);
889
- var targetLength = getInsertDeltaLength(yTextToInsertDelta(target.yParent));
890
- var deltaApplyYOffset = Math.min(target.textRange.start, targetLength);
891
- var applyDelta = __spreadArray([{ retain: deltaApplyYOffset }], __read(insertDelta));
892
- target.yParent.applyDelta(applyDelta, { sanitize: false });
893
- restoreStoredPositionsWithDeltaAbsolute(sharedRoot, target.yParent, storedPositions, insertDelta, deltaApplyYOffset, origin.textRange.start);
894
- }
895
-
896
- function removeNode(sharedRoot, slateRoot, op) {
897
- var _a = getYTarget(sharedRoot, slateRoot, op.path), parent = _a.yParent, textRange = _a.textRange;
898
- parent.delete(textRange.start, textRange.end - textRange.start);
899
- }
900
-
901
- function setNode(sharedRoot, slateRoot, op) {
902
- var _a = getYTarget(sharedRoot, slateRoot, op.path), yTarget = _a.yTarget, textRange = _a.textRange, yParent = _a.yParent;
903
- if (yTarget) {
904
- Object.entries(op.newProperties).forEach(function (_a) {
905
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
906
- if (value === null) {
907
- return yTarget.removeAttribute(key);
908
- }
909
- yTarget.setAttribute(key, value);
910
- });
911
- return Object.entries(op.properties).forEach(function (_a) {
912
- var _b = __read(_a, 1), key = _b[0];
913
- if (!Object.prototype.hasOwnProperty.call(op.newProperties, key)) {
914
- yTarget.removeAttribute(key);
915
- }
916
- });
917
- }
918
- var unset = Object.fromEntries(Object.keys(op.properties).map(function (key) { return [key, null]; }));
919
- var newProperties = __assign(__assign({}, unset), op.newProperties);
920
- yParent.format(textRange.start, textRange.end - textRange.start, newProperties);
921
- }
922
-
923
- function splitNode(sharedRoot, slateRoot, op) {
924
- var target = getYTarget(sharedRoot, slateRoot, op.path);
925
- if (!target.slateTarget) {
926
- throw new Error('Y target without corresponding slate node');
927
- }
928
- if (!target.yTarget) {
929
- if (!slate.Text.isText(target.slateTarget)) {
930
- throw new Error('Mismatch node type between y target and slate node');
931
- }
932
- var unset_1 = {};
933
- target.targetDelta.forEach(function (element) {
934
- if (element.attributes) {
935
- Object.keys(element.attributes).forEach(function (key) {
936
- unset_1[key] = null;
937
- });
938
- }
939
- });
940
- return target.yParent.format(target.textRange.start, target.textRange.end - target.textRange.start, __assign(__assign({}, unset_1), op.properties));
941
- }
942
- if (slate.Text.isText(target.slateTarget)) {
943
- throw new Error('Mismatch node type between y target and slate node');
944
- }
945
- var splitTarget = getYTarget(target.yTarget, target.slateTarget, [op.position]);
946
- var ySplitOffset = target.slateTarget.children
947
- .slice(0, op.position)
948
- .reduce(function (length, child) { return length + getSlateNodeYLength(child); }, 0);
949
- var length = target.slateTarget.children.reduce(function (current, child) { return current + getSlateNodeYLength(child); }, 0);
950
- var splitDelta = sliceInsertDelta(yTextToInsertDelta(target.yTarget), ySplitOffset, length - ySplitOffset);
951
- var clonedDelta = cloneInsertDeltaDeep(splitDelta);
952
- var storedPositions = getStoredPositionsInDeltaAbsolute(sharedRoot, target.yTarget, splitDelta, ySplitOffset);
953
- var toInsert = new Y__namespace.XmlText();
954
- toInsert.applyDelta(clonedDelta, {
955
- sanitize: false,
956
- });
957
- Object.entries(op.properties).forEach(function (_a) {
958
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
959
- toInsert.setAttribute(key, value);
960
- });
961
- target.yTarget.delete(splitTarget.textRange.start, target.yTarget.length - splitTarget.textRange.start);
962
- target.yParent.insertEmbed(target.textRange.end, toInsert);
963
- restoreStoredPositionsWithDeltaAbsolute(sharedRoot, toInsert, storedPositions, clonedDelta, 0, ySplitOffset);
964
- }
965
-
966
- var NODE_MAPPER = {
967
- insert_node: insertNode,
968
- remove_node: removeNode,
969
- set_node: setNode,
970
- merge_node: mergeNode,
971
- move_node: moveNode,
972
- split_node: splitNode,
973
- };
974
-
975
- function insertText(sharedRoot, slateRoot, op) {
976
- var _a = getYTarget(sharedRoot, slateRoot, op.path), target = _a.yParent, textRange = _a.textRange;
977
- var targetNode = slate.Node.get(slateRoot, op.path);
978
- if (!slate.Text.isText(targetNode)) {
979
- throw new Error('Cannot insert text into non-text node');
980
- }
981
- target.insert(textRange.start + op.offset, op.text, getProperties(targetNode));
982
- }
983
-
984
- function removeText(sharedRoot, slateRoot, op) {
985
- var _a = getYTarget(sharedRoot, slateRoot, op.path), target = _a.yParent, textRange = _a.textRange;
986
- target.delete(textRange.start + op.offset, op.text.length);
987
- }
988
-
989
- var TEXT_MAPPER = {
990
- insert_text: insertText,
991
- remove_text: removeText,
992
- };
993
-
994
- // eslint-disable-next-line @typescript-eslint/no-empty-function
995
- var NOOP = function () { };
996
- var opMappers = __assign(__assign(__assign({}, TEXT_MAPPER), NODE_MAPPER), { set_selection: NOOP });
997
- function applySlateOp(sharedRoot, slateRoot, op) {
998
- var apply = opMappers[op.type];
999
- if (!apply) {
1000
- throw new Error("Unknown operation: " + op.type);
1001
- }
1002
- apply(sharedRoot, slateRoot, op);
1003
- }
1004
-
1005
- var DEFAULT_LOCAL_ORIGIN = Symbol('slate-yjs-operation');
1006
- var DEFAULT_POSITION_STORAGE_ORIGIN = Symbol('slate-yjs-position-storage');
1007
- var ORIGIN = new WeakMap();
1008
- var LOCAL_CHANGES = new WeakMap();
1009
- var CONNECTED = new WeakSet();
1010
- var YjsEditor = {
1011
- isYjsEditor: function (value) {
1012
- return (slate.Editor.isEditor(value) &&
1013
- value.sharedRoot instanceof Y__namespace.XmlText &&
1014
- 'localOrigin' in value &&
1015
- 'positionStorageOrigin' in value &&
1016
- typeof value.applyRemoteEvents === 'function' &&
1017
- typeof value.storeLocalChange === 'function' &&
1018
- typeof value.flushLocalChanges === 'function' &&
1019
- typeof value.isLocalOrigin === 'function' &&
1020
- typeof value.connect === 'function' &&
1021
- typeof value.disconnect === 'function');
1022
- },
1023
- localChanges: function (editor) {
1024
- var _a;
1025
- return (_a = LOCAL_CHANGES.get(editor)) !== null && _a !== void 0 ? _a : [];
1026
- },
1027
- applyRemoteEvents: function (editor, events, origin) {
1028
- editor.applyRemoteEvents(events, origin);
1029
- },
1030
- storeLocalChange: function (editor, op) {
1031
- editor.storeLocalChange(op);
1032
- },
1033
- flushLocalChanges: function (editor) {
1034
- editor.flushLocalChanges();
1035
- },
1036
- connected: function (editor) {
1037
- return CONNECTED.has(editor);
1038
- },
1039
- connect: function (editor) {
1040
- editor.connect();
1041
- },
1042
- disconnect: function (editor) {
1043
- editor.disconnect();
1044
- },
1045
- isLocal: function (editor) {
1046
- return editor.isLocalOrigin(YjsEditor.origin(editor));
1047
- },
1048
- origin: function (editor) {
1049
- var origin = ORIGIN.get(editor);
1050
- return origin !== undefined ? origin : editor.localOrigin;
1051
- },
1052
- withOrigin: function (editor, origin, fn) {
1053
- var prev = YjsEditor.origin(editor);
1054
- ORIGIN.set(editor, origin);
1055
- fn();
1056
- ORIGIN.set(editor, prev);
1057
- },
1058
- storePosition: function (editor, key, point) {
1059
- var sharedRoot = editor.sharedRoot, locationStorageOrigin = editor.positionStorageOrigin;
1060
- assertDocumentAttachment(sharedRoot);
1061
- var position = slatePointToRelativePosition(sharedRoot, editor, point);
1062
- sharedRoot.doc.transact(function () {
1063
- setStoredPosition(sharedRoot, key, position);
1064
- }, locationStorageOrigin);
1065
- },
1066
- removeStoredPosition: function (editor, key) {
1067
- var sharedRoot = editor.sharedRoot, locationStorageOrigin = editor.positionStorageOrigin;
1068
- assertDocumentAttachment(sharedRoot);
1069
- sharedRoot.doc.transact(function () {
1070
- removeStoredPosition(sharedRoot, key);
1071
- }, locationStorageOrigin);
1072
- },
1073
- position: function (editor, key) {
1074
- var position = getStoredPosition(editor.sharedRoot, key);
1075
- if (!position) {
1076
- return undefined;
1077
- }
1078
- return relativePositionToSlatePoint(editor.sharedRoot, editor, position);
1079
- },
1080
- storedPositionsRelative: function (editor) {
1081
- return getStoredPositions(editor.sharedRoot);
1082
- },
1083
- };
1084
- function withYjs(sharedRoot, options) {
1085
- if (options === void 0) { options = {}; }
1086
- return function (editor) {
1087
- var _a, _b;
1088
- var e = editor;
1089
- e.sharedRoot = sharedRoot;
1090
- e.localOrigin = (_a = options.localOrigin) !== null && _a !== void 0 ? _a : DEFAULT_LOCAL_ORIGIN;
1091
- e.positionStorageOrigin = (_b = options.positionStorageOrigin) !== null && _b !== void 0 ? _b : DEFAULT_POSITION_STORAGE_ORIGIN;
1092
- e.applyRemoteEvents = function (events, origin) {
1093
- YjsEditor.flushLocalChanges(e);
1094
- slate.Editor.withoutNormalizing(e, function () {
1095
- YjsEditor.withOrigin(e, origin, function () {
1096
- applyYjsEvents(e.sharedRoot, e, events);
1097
- });
1098
- });
1099
- };
1100
- e.isLocalOrigin = function (origin) { return origin === e.localOrigin; };
1101
- var handleYEvents = function (events, transaction) {
1102
- if (e.isLocalOrigin(transaction.origin)) {
1103
- return;
1104
- }
1105
- YjsEditor.applyRemoteEvents(e, events, transaction.origin);
1106
- };
1107
- var autoConnectTimeoutId = null;
1108
- if (options.autoConnect) {
1109
- autoConnectTimeoutId = setTimeout(function () {
1110
- autoConnectTimeoutId = null;
1111
- YjsEditor.connect(e);
1112
- });
1113
- }
1114
- e.connect = function () {
1115
- if (YjsEditor.connected(e)) {
1116
- throw new Error('already connected');
1117
- }
1118
- e.sharedRoot.observeDeep(handleYEvents);
1119
- var content = yTextToSlateElement(e.sharedRoot);
1120
- e.children = content.children;
1121
- CONNECTED.add(e);
1122
- slate.Editor.normalize(editor, { force: true });
1123
- if (!editor.operations.length) {
1124
- editor.onChange();
1125
- }
1126
- };
1127
- e.disconnect = function () {
1128
- if (autoConnectTimeoutId) {
1129
- clearTimeout(autoConnectTimeoutId);
1130
- }
1131
- YjsEditor.flushLocalChanges(e);
1132
- e.sharedRoot.unobserveDeep(handleYEvents);
1133
- CONNECTED.delete(e);
1134
- };
1135
- e.storeLocalChange = function (op) {
1136
- LOCAL_CHANGES.set(e, __spreadArray(__spreadArray([], __read(YjsEditor.localChanges(e))), [
1137
- { op: op, doc: editor.children, origin: YjsEditor.origin(e) },
1138
- ]));
1139
- };
1140
- e.flushLocalChanges = function () {
1141
- assertDocumentAttachment(e.sharedRoot);
1142
- var localChanges = YjsEditor.localChanges(e);
1143
- LOCAL_CHANGES.delete(e);
1144
- var txGroups = [];
1145
- localChanges.forEach(function (change) {
1146
- var currentGroup = txGroups[txGroups.length - 1];
1147
- if (currentGroup && currentGroup[0].origin === change.origin) {
1148
- return currentGroup.push(change);
1149
- }
1150
- txGroups.push([change]);
1151
- });
1152
- txGroups.forEach(function (txGroup) {
1153
- assertDocumentAttachment(e.sharedRoot);
1154
- e.sharedRoot.doc.transact(function () {
1155
- txGroup.forEach(function (change) {
1156
- assertDocumentAttachment(e.sharedRoot);
1157
- applySlateOp(e.sharedRoot, { children: change.doc }, change.op);
1158
- });
1159
- }, txGroup[0].origin);
1160
- });
1161
- };
1162
- var apply = e.apply, onChange = e.onChange;
1163
- e.apply = function (op) {
1164
- if (YjsEditor.connected(e) && YjsEditor.isLocal(e)) {
1165
- YjsEditor.storeLocalChange(e, op);
1166
- }
1167
- apply(op);
1168
- };
1169
- e.onChange = function () {
1170
- if (YjsEditor.connected(e)) {
1171
- YjsEditor.flushLocalChanges(e);
1172
- }
1173
- onChange();
1174
- };
1175
- return e;
1176
- };
1177
- }
1178
-
1179
- var LAST_SELECTION = new WeakMap();
1180
- var DEFAULT_WITHOUT_SAVING_ORIGIN = Symbol('slate-yjs-history-without-saving');
1181
- var YHistoryEditor = {
1182
- isYHistoryEditor: function (value) {
1183
- return (YjsEditor.isYjsEditor(value) &&
1184
- value.undoManager instanceof Y__namespace.UndoManager &&
1185
- typeof value.undo === 'function' &&
1186
- typeof value.redo === 'function' &&
1187
- 'withoutSavingOrigin' in value);
1188
- },
1189
- canUndo: function (editor) {
1190
- return editor.undoManager.undoStack.length > 0;
1191
- },
1192
- canRedo: function (editor) {
1193
- return editor.undoManager.redoStack.length > 0;
1194
- },
1195
- isSaving: function (editor) {
1196
- return editor.undoManager.trackedOrigins.has(YjsEditor.origin(editor));
1197
- },
1198
- withoutSaving: function (editor, fn) {
1199
- YjsEditor.withOrigin(editor, editor.withoutSavingOrigin, fn);
1200
- },
1201
- };
1202
- function withYHistory(options) {
1203
- if (options === void 0) { options = {}; }
1204
- return function (editor) {
1205
- var e = editor;
1206
- // 将 trackedOrigins 的初始化放到 editor 被传入之后
1207
- var _a = options.withoutSavingOrigin, withoutSavingOrigin = _a === void 0 ? DEFAULT_WITHOUT_SAVING_ORIGIN : _a, _b = options.trackedOrigins, trackedOrigins = _b === void 0 ? new Set([e.localOrigin]) : _b, restOptions = __rest(options, ["withoutSavingOrigin", "trackedOrigins"]);
1208
- var undoManager = new Y__namespace.UndoManager(e.sharedRoot, __assign({ trackedOrigins: trackedOrigins }, restOptions));
1209
- e.undoManager = undoManager;
1210
- e.withoutSavingOrigin = withoutSavingOrigin;
1211
- var onChange = e.onChange, isLocalOrigin = e.isLocalOrigin;
1212
- e.onChange = function () {
1213
- onChange();
1214
- LAST_SELECTION.set(e, e.selection && slateRangeToRelativeRange(e.sharedRoot, e, e.selection));
1215
- };
1216
- e.isLocalOrigin = function (origin) { return origin === e.withoutSavingOrigin || isLocalOrigin(origin); };
1217
- var handleStackItemAdded = function (_a) {
1218
- var stackItem = _a.stackItem;
1219
- stackItem.meta.set('selection', e.selection && slateRangeToRelativeRange(e.sharedRoot, e, e.selection));
1220
- stackItem.meta.set('selectionBefore', LAST_SELECTION.get(e));
1221
- };
1222
- var handleStackItemUpdated = function (_a) {
1223
- var stackItem = _a.stackItem;
1224
- stackItem.meta.set('selection', e.selection && slateRangeToRelativeRange(e.sharedRoot, e, e.selection));
1225
- };
1226
- var handleStackItemPopped = function (_a) {
1227
- var stackItem = _a.stackItem, type = _a.type;
1228
- // TODO: Change once https://github.com/yjs/yjs/issues/353 is resolved
1229
- var inverseStack = type === 'undo' ? e.undoManager.redoStack : e.undoManager.undoStack;
1230
- var inverseItem = inverseStack[inverseStack.length - 1];
1231
- if (inverseItem) {
1232
- inverseItem.meta.set('selection', stackItem.meta.get('selectionBefore'));
1233
- inverseItem.meta.set('selectionBefore', stackItem.meta.get('selection'));
1234
- }
1235
- var relativeSelection = stackItem.meta.get('selectionBefore');
1236
- if (!relativeSelection) {
1237
- return;
1238
- }
1239
- var selection = relativeRangeToSlateRange(e.sharedRoot, e, relativeSelection);
1240
- if (!selection) {
1241
- return;
1242
- }
1243
- slate.Transforms.select(e, selection);
1244
- };
1245
- var connect = e.connect, disconnect = e.disconnect;
1246
- e.connect = function () {
1247
- connect();
1248
- e.undoManager.on('stack-item-added', handleStackItemAdded);
1249
- e.undoManager.on('stack-item-popped', handleStackItemPopped);
1250
- e.undoManager.on('stack-item-updated', handleStackItemUpdated);
1251
- };
1252
- e.disconnect = function () {
1253
- e.undoManager.off('stack-item-added', handleStackItemAdded);
1254
- e.undoManager.off('stack-item-popped', handleStackItemPopped);
1255
- e.undoManager.off('stack-item-updated', handleStackItemUpdated);
1256
- disconnect();
1257
- };
1258
- e.undo = function () {
1259
- if (YjsEditor.connected(e)) {
1260
- YjsEditor.flushLocalChanges(e);
1261
- e.undoManager.undo();
1262
- }
1263
- };
1264
- e.redo = function () {
1265
- if (YjsEditor.connected(e)) {
1266
- YjsEditor.flushLocalChanges(e);
1267
- e.undoManager.redo();
1268
- }
1269
- };
1270
- return e;
1271
- };
1272
- }
1273
-
1274
- var CURSOR_CHANGE_EVENT_LISTENERS = new WeakMap();
1275
- var CursorEditor = {
1276
- isCursorEditor: function (value) {
1277
- return (YjsEditor.isYjsEditor(value) &&
1278
- value.awareness &&
1279
- typeof value.cursorDataField === 'string' &&
1280
- typeof value.selectionStateField === 'string' &&
1281
- typeof value.sendCursorPosition === 'function' &&
1282
- typeof value.sendCursorData === 'function');
1283
- },
1284
- sendCursorPosition: function (editor, range) {
1285
- if (range === void 0) { range = editor.selection; }
1286
- editor.sendCursorPosition(range);
1287
- },
1288
- sendCursorData: function (editor, data) {
1289
- editor.sendCursorData(data);
1290
- },
1291
- on: function (editor, event, handler) {
1292
- var _a;
1293
- if (event !== 'change') {
1294
- return;
1295
- }
1296
- if (!editor)
1297
- return;
1298
- var listeners = (_a = CURSOR_CHANGE_EVENT_LISTENERS.get(editor)) !== null && _a !== void 0 ? _a : new Set();
1299
- listeners.add(handler);
1300
- CURSOR_CHANGE_EVENT_LISTENERS.set(editor, listeners);
1301
- },
1302
- off: function (editor, event, listener) {
1303
- if (event !== 'change') {
1304
- return;
1305
- }
1306
- var listeners = CURSOR_CHANGE_EVENT_LISTENERS.get(editor);
1307
- if (listeners) {
1308
- listeners.delete(listener);
1309
- }
1310
- },
1311
- cursorState: function (editor, clientId) {
1312
- var _a;
1313
- if (clientId === editor.awareness.clientID || !YjsEditor.connected(editor)) {
1314
- return null;
1315
- }
1316
- var state = editor.awareness.getStates().get(clientId);
1317
- if (!state) {
1318
- return null;
1319
- }
1320
- return {
1321
- relativeSelection: (_a = state[editor.selectionStateField]) !== null && _a !== void 0 ? _a : null,
1322
- data: state[editor.cursorDataField],
1323
- clientId: clientId,
1324
- };
1325
- },
1326
- cursorStates: function (editor) {
1327
- if (!YjsEditor.connected(editor)) {
1328
- return {};
1329
- }
1330
- return Object.fromEntries(Array.from(editor.awareness.getStates().entries(), function (_a) {
1331
- var _b = __read(_a, 2), id = _b[0], state = _b[1];
1332
- // Ignore own state
1333
- if (id === editor.awareness.clientID || !state) {
1334
- return null;
1335
- }
1336
- return [
1337
- id,
1338
- {
1339
- relativeSelection: state[editor.selectionStateField],
1340
- data: state[editor.cursorDataField],
1341
- },
1342
- ];
1343
- }).filter(Array.isArray));
1344
- },
1345
- };
1346
- function withCursors(awareness, options) {
1347
- if (options === void 0) { options = {}; }
1348
- return function (editor) {
1349
- var _a = options.cursorStateField, selectionStateField = _a === void 0 ? 'selection' : _a, _b = options.cursorDataField, cursorDataField = _b === void 0 ? 'data' : _b, _c = options.autoSend, autoSend = _c === void 0 ? true : _c, data = options.data;
1350
- var e = editor;
1351
- e.awareness = awareness;
1352
- e.cursorDataField = cursorDataField;
1353
- e.selectionStateField = selectionStateField;
1354
- e.sendCursorData = function (cursorData) {
1355
- e.awareness.setLocalStateField(e.cursorDataField, cursorData);
1356
- };
1357
- e.sendCursorPosition = function (range) {
1358
- var localState = e.awareness.getLocalState();
1359
- var currentRange = localState === null || localState === void 0 ? void 0 : localState[selectionStateField];
1360
- if (!range) {
1361
- if (currentRange) {
1362
- e.awareness.setLocalStateField(e.selectionStateField, null);
1363
- }
1364
- return;
1365
- }
1366
- var _a = slateRangeToRelativeRange(e.sharedRoot, e, range), anchor = _a.anchor, focus = _a.focus;
1367
- if (!currentRange ||
1368
- !Y__namespace.compareRelativePositions(anchor, currentRange) ||
1369
- !Y__namespace.compareRelativePositions(focus, currentRange)) {
1370
- e.awareness.setLocalStateField(e.selectionStateField, { anchor: anchor, focus: focus });
1371
- }
1372
- };
1373
- var awarenessChangeListener = function (yEvent) {
1374
- var listeners = CURSOR_CHANGE_EVENT_LISTENERS.get(e);
1375
- if (!listeners) {
1376
- return;
1377
- }
1378
- var localId = e.awareness.clientID;
1379
- var event = {
1380
- added: yEvent.added.filter(function (id) { return id !== localId; }),
1381
- removed: yEvent.removed.filter(function (id) { return id !== localId; }),
1382
- updated: yEvent.updated.filter(function (id) { return id !== localId; }),
1383
- };
1384
- if (event.added.length > 0 || event.removed.length > 0 || event.updated.length > 0) {
1385
- listeners.forEach(function (listener) { return listener(event); });
1386
- }
1387
- };
1388
- var connect = e.connect, disconnect = e.disconnect;
1389
- e.connect = function () {
1390
- connect();
1391
- e.awareness.on('change', awarenessChangeListener);
1392
- awarenessChangeListener({
1393
- removed: [],
1394
- added: Array.from(e.awareness.getStates().keys()),
1395
- updated: [],
1396
- });
1397
- if (autoSend) {
1398
- if (data) {
1399
- CursorEditor.sendCursorData(e, data);
1400
- }
1401
- var onChange_1 = e.onChange;
1402
- e.onChange = function () {
1403
- onChange_1();
1404
- if (YjsEditor.connected(e)) {
1405
- CursorEditor.sendCursorPosition(e);
1406
- }
1407
- };
1408
- }
1409
- };
1410
- e.disconnect = function () {
1411
- e.awareness.off('change', awarenessChangeListener);
1412
- awarenessChangeListener({
1413
- removed: Array.from(e.awareness.getStates().keys()),
1414
- added: [],
1415
- updated: [],
1416
- });
1417
- disconnect();
1418
- };
1419
- return e;
1420
- };
1421
- }
1422
-
1423
- exports.CursorEditor = CursorEditor;
1424
- exports.YHistoryEditor = YHistoryEditor;
1425
- exports.YjsEditor = YjsEditor;
1426
- exports.relativePositionToSlatePoint = relativePositionToSlatePoint;
1427
- exports.relativeRangeToSlateRange = relativeRangeToSlateRange;
1428
- exports.slateNodesToInsertDelta = slateNodesToInsertDelta;
1429
- exports.slatePointToRelativePosition = slatePointToRelativePosition;
1430
- exports.slateRangeToRelativeRange = slateRangeToRelativeRange;
1431
- exports.withCursors = withCursors;
1432
- exports.withYHistory = withYHistory;
1433
- exports.withYjs = withYjs;
1434
- exports.yTextToSlateElement = yTextToSlateElement;
1435
-
1436
- Object.defineProperty(exports, '__esModule', { value: true });
1437
-
1438
- }));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("slate"),require("yjs")):"function"==typeof define&&define.amd?define(["exports","slate","yjs"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).WangEditorYjsModule={},t.slate,t.Y)}(this,(function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var o=r(n),i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function a(t){var e={exports:{}};return t(e,e.exports),e.exports}var u,c,s=function(t){return t&&t.Math===Math&&t},f=s("object"==typeof globalThis&&globalThis)||s("object"==typeof window&&window)||s("object"==typeof self&&self)||s("object"==typeof i&&i)||s("object"==typeof i&&i)||function(){return this}()||Function("return this")(),l=function(t){try{return!!t()}catch(t){return!0}},d=!l((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),h=!l((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),p=Function.prototype.call,v=h?p.bind(p):function(){return p.apply(p,arguments)},g={}.propertyIsEnumerable,y=Object.getOwnPropertyDescriptor,b=y&&!g.call({1:2},1)?function(t){var e=y(this,t);return!!e&&e.enumerable}:g,m={f:b},w=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},O=Function.prototype,x=O.call,S=h&&O.bind.bind(x,x),E=h?S:function(t){return function(){return x.apply(t,arguments)}},T=E({}.toString),j=E("".slice),P=function(t){return j(T(t),8,-1)},R=Object,A=E("".split),C=l((function(){return!R("z").propertyIsEnumerable(0)}))?function(t){return"String"===P(t)?A(t,""):R(t)}:R,k=function(t){return null==t},L=TypeError,F=function(t){if(k(t))throw new L("Can't call method on "+t);return t},_=function(t){return C(F(t))},M="object"==typeof document&&document.all,D=void 0===M&&void 0!==M?function(t){return"function"==typeof t||t===M}:function(t){return"function"==typeof t},I=function(t){return"object"==typeof t?null!==t:D(t)},z=function(t,e){return arguments.length<2?(n=f[t],D(n)?n:void 0):f[t]&&f[t][e];var n},N=E({}.isPrototypeOf),W=f.navigator,Y=W&&W.userAgent,X=Y?String(Y):"",G=f.process,B=f.Deno,U=G&&G.versions||B&&B.version,V=U&&U.v8;V&&(c=(u=V.split("."))[0]>0&&u[0]<4?1:+(u[0]+u[1])),!c&&X&&(!(u=X.match(/Edge\/(\d+)/))||u[1]>=74)&&(u=X.match(/Chrome\/(\d+)/))&&(c=+u[1]);var q=c,H=f.String,$=!!Object.getOwnPropertySymbols&&!l((function(){var t=Symbol("symbol detection");return!H(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&q&&q<41})),J=$&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,K=Object,Q=J?function(t){return"symbol"==typeof t}:function(t){var e=z("Symbol");return D(e)&&N(e.prototype,K(t))},Z=String,tt=function(t){try{return Z(t)}catch(t){return"Object"}},et=TypeError,nt=function(t){if(D(t))return t;throw new et(tt(t)+" is not a function")},rt=function(t,e){var n=t[e];return k(n)?void 0:nt(n)},ot=TypeError,it=Object.defineProperty,at=function(t,e){try{it(f,t,{value:e,configurable:!0,writable:!0})}catch(n){f[t]=e}return e},ut=a((function(t){var e="__core-js_shared__",n=t.exports=f[e]||at(e,{});(n.versions||(n.versions=[])).push({version:"3.38.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"})})),ct=function(t,e){return ut[t]||(ut[t]=e||{})},st=Object,ft=function(t){return st(F(t))},lt=E({}.hasOwnProperty),dt=Object.hasOwn||function(t,e){return lt(ft(t),e)},ht=0,pt=Math.random(),vt=E(1..toString),gt=function(t){return"Symbol("+(void 0===t?"":t)+")_"+vt(++ht+pt,36)},yt=f.Symbol,bt=ct("wks"),mt=J?yt.for||yt:yt&&yt.withoutSetter||gt,wt=function(t){return dt(bt,t)||(bt[t]=$&&dt(yt,t)?yt[t]:mt("Symbol."+t)),bt[t]},Ot=TypeError,xt=wt("toPrimitive"),St=function(t,e){if(!I(t)||Q(t))return t;var n,r=rt(t,xt);if(r){if(void 0===e&&(e="default"),n=v(r,t,e),!I(n)||Q(n))return n;throw new Ot("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(t,e){var n,r;if("string"===e&&D(n=t.toString)&&!I(r=v(n,t)))return r;if(D(n=t.valueOf)&&!I(r=v(n,t)))return r;if("string"!==e&&D(n=t.toString)&&!I(r=v(n,t)))return r;throw new ot("Can't convert object to primitive value")}(t,e)},Et=function(t){var e=St(t,"string");return Q(e)?e:e+""},Tt=f.document,jt=I(Tt)&&I(Tt.createElement),Pt=function(t){return jt?Tt.createElement(t):{}},Rt=!d&&!l((function(){return 7!==Object.defineProperty(Pt("div"),"a",{get:function(){return 7}}).a})),At=Object.getOwnPropertyDescriptor,Ct={f:d?At:function(t,e){if(t=_(t),e=Et(e),Rt)try{return At(t,e)}catch(t){}if(dt(t,e))return w(!v(m.f,t,e),t[e])}},kt=d&&l((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Lt=String,Ft=TypeError,_t=function(t){if(I(t))return t;throw new Ft(Lt(t)+" is not an object")},Mt=TypeError,Dt=Object.defineProperty,It=Object.getOwnPropertyDescriptor,zt="enumerable",Nt="configurable",Wt="writable",Yt={f:d?kt?function(t,e,n){if(_t(t),e=Et(e),_t(n),"function"==typeof t&&"prototype"===e&&"value"in n&&Wt in n&&!n[Wt]){var r=It(t,e);r&&r[Wt]&&(t[e]=n.value,n={configurable:Nt in n?n[Nt]:r[Nt],enumerable:zt in n?n[zt]:r[zt],writable:!1})}return Dt(t,e,n)}:Dt:function(t,e,n){if(_t(t),e=Et(e),_t(n),Rt)try{return Dt(t,e,n)}catch(t){}if("get"in n||"set"in n)throw new Mt("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},Xt=d?function(t,e,n){return Yt.f(t,e,w(1,n))}:function(t,e,n){return t[e]=n,t},Gt=Function.prototype,Bt=d&&Object.getOwnPropertyDescriptor,Ut=dt(Gt,"name"),Vt={EXISTS:Ut,PROPER:Ut&&"something"===function(){}.name,CONFIGURABLE:Ut&&(!d||d&&Bt(Gt,"name").configurable)},qt=E(Function.toString);D(ut.inspectSource)||(ut.inspectSource=function(t){return qt(t)});var Ht,$t,Jt,Kt=ut.inspectSource,Qt=f.WeakMap,Zt=D(Qt)&&/native code/.test(String(Qt)),te=ct("keys"),ee=function(t){return te[t]||(te[t]=gt(t))},ne={},re="Object already initialized",oe=f.TypeError,ie=f.WeakMap;if(Zt||ut.state){var ae=ut.state||(ut.state=new ie);ae.get=ae.get,ae.has=ae.has,ae.set=ae.set,Ht=function(t,e){if(ae.has(t))throw new oe(re);return e.facade=t,ae.set(t,e),e},$t=function(t){return ae.get(t)||{}},Jt=function(t){return ae.has(t)}}else{var ue=ee("state");ne[ue]=!0,Ht=function(t,e){if(dt(t,ue))throw new oe(re);return e.facade=t,Xt(t,ue,e),e},$t=function(t){return dt(t,ue)?t[ue]:{}},Jt=function(t){return dt(t,ue)}}var ce={set:Ht,get:$t,has:Jt,enforce:function(t){return Jt(t)?$t(t):Ht(t,{})},getterFor:function(t){return function(e){var n;if(!I(e)||(n=$t(e)).type!==t)throw new oe("Incompatible receiver, "+t+" required");return n}}},se=a((function(t){var e=Vt.CONFIGURABLE,n=ce.enforce,r=ce.get,o=String,i=Object.defineProperty,a=E("".slice),u=E("".replace),c=E([].join),s=d&&!l((function(){return 8!==i((function(){}),"length",{value:8}).length})),f=String(String).split("String"),h=t.exports=function(t,r,l){"Symbol("===a(o(r),0,7)&&(r="["+u(o(r),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),l&&l.getter&&(r="get "+r),l&&l.setter&&(r="set "+r),(!dt(t,"name")||e&&t.name!==r)&&(d?i(t,"name",{value:r,configurable:!0}):t.name=r),s&&l&&dt(l,"arity")&&t.length!==l.arity&&i(t,"length",{value:l.arity});try{l&&dt(l,"constructor")&&l.constructor?d&&i(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var h=n(t);return dt(h,"source")||(h.source=c(f,"string"==typeof r?r:"")),t};Function.prototype.toString=h((function(){return D(this)&&r(this).source||Kt(this)}),"toString")})),fe=function(t,e,n,r){r||(r={});var o=r.enumerable,i=void 0!==r.name?r.name:e;if(D(n)&&se(n,i,r),r.global)o?t[e]=n:at(e,n);else{try{r.unsafe?t[e]&&(o=!0):delete t[e]}catch(t){}o?t[e]=n:Yt.f(t,e,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t},le=Math.ceil,de=Math.floor,he=Math.trunc||function(t){var e=+t;return(e>0?de:le)(e)},pe=function(t){var e=+t;return e!=e||0===e?0:he(e)},ve=Math.max,ge=Math.min,ye=function(t,e){var n=pe(t);return n<0?ve(n+e,0):ge(n,e)},be=Math.min,me=function(t){var e=pe(t);return e>0?be(e,9007199254740991):0},we=function(t){return me(t.length)},Oe=function(t){return function(e,n,r){var o=_(e),i=we(o);if(0===i)return!t&&-1;var a,u=ye(r,i);if(t&&n!=n){for(;i>u;)if((a=o[u++])!=a)return!0}else for(;i>u;u++)if((t||u in o)&&o[u]===n)return t||u||0;return!t&&-1}},xe={includes:Oe(!0),indexOf:Oe(!1)},Se=xe.indexOf,Ee=E([].push),Te=function(t,e){var n,r=_(t),o=0,i=[];for(n in r)!dt(ne,n)&&dt(r,n)&&Ee(i,n);for(;e.length>o;)dt(r,n=e[o++])&&(~Se(i,n)||Ee(i,n));return i},je=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Pe=je.concat("length","prototype"),Re={f:Object.getOwnPropertyNames||function(t){return Te(t,Pe)}},Ae={f:Object.getOwnPropertySymbols},Ce=E([].concat),ke=z("Reflect","ownKeys")||function(t){var e=Re.f(_t(t)),n=Ae.f;return n?Ce(e,n(t)):e},Le=function(t,e,n){for(var r=ke(e),o=Yt.f,i=Ct.f,a=0;a<r.length;a++){var u=r[a];dt(t,u)||n&&dt(n,u)||o(t,u,i(e,u))}},Fe=/#|\.prototype\./,_e=function(t,e){var n=De[Me(t)];return n===ze||n!==Ie&&(D(e)?l(e):!!e)},Me=_e.normalize=function(t){return String(t).replace(Fe,".").toLowerCase()},De=_e.data={},Ie=_e.NATIVE="N",ze=_e.POLYFILL="P",Ne=_e,We=Ct.f,Ye=function(t,e){var n,r,o,i,a,u=t.target,c=t.global,s=t.stat;if(n=c?f:s?f[u]||at(u,{}):f[u]&&f[u].prototype)for(r in e){if(i=e[r],o=t.dontCallGetSet?(a=We(n,r))&&a.value:n[r],!Ne(c?r:u+(s?".":"#")+r,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Le(i,o)}(t.sham||o&&o.sham)&&Xt(i,"sham",!0),fe(n,r,i,t)}},Xe={};Xe[wt("toStringTag")]="z";var Ge,Be="[object z]"===String(Xe),Ue=wt("toStringTag"),Ve=Object,qe="Arguments"===P(function(){return arguments}()),He=Be?P:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Ve(t),Ue))?n:qe?P(e):"Object"===(r=P(e))&&D(e.callee)?"Arguments":r},$e=String,Je=function(t){if("Symbol"===He(t))throw new TypeError("Cannot convert a Symbol value to a string");return $e(t)},Ke=Object.keys||function(t){return Te(t,je)},Qe=d&&!kt?Object.defineProperties:function(t,e){_t(t);for(var n,r=_(e),o=Ke(e),i=o.length,a=0;i>a;)Yt.f(t,n=o[a++],r[n]);return t},Ze={f:Qe},tn=z("document","documentElement"),en="prototype",nn="script",rn=ee("IE_PROTO"),on=function(){},an=function(t){return"<"+nn+">"+t+"</"+nn+">"},un=function(t){t.write(an("")),t.close();var e=t.parentWindow.Object;return t=null,e},cn=function(){try{Ge=new ActiveXObject("htmlfile")}catch(t){}var t,e,n;cn="undefined"!=typeof document?document.domain&&Ge?un(Ge):(e=Pt("iframe"),n="java"+nn+":",e.style.display="none",tn.appendChild(e),e.src=String(n),(t=e.contentWindow.document).open(),t.write(an("document.F=Object")),t.close(),t.F):un(Ge);for(var r=je.length;r--;)delete cn[en][je[r]];return cn()};ne[rn]=!0;var sn=Object.create||function(t,e){var n;return null!==t?(on[en]=_t(t),n=new on,on[en]=null,n[rn]=t):n=cn(),void 0===e?n:Ze.f(n,e)},fn=E([].slice),ln=Re.f,dn="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],hn={f:function(t){return dn&&"Window"===P(t)?function(t){try{return ln(t)}catch(t){return fn(dn)}}(t):ln(_(t))}},pn=function(t,e,n){return n.get&&se(n.get,e,{getter:!0}),n.set&&se(n.set,e,{setter:!0}),Yt.f(t,e,n)},vn={f:wt},gn=f,yn=Yt.f,bn=Yt.f,mn=wt("toStringTag"),wn=function(t,e,n){t&&!n&&(t=t.prototype),t&&!dt(t,mn)&&bn(t,mn,{configurable:!0,value:e})},On=function(t){if("Function"===P(t))return E(t)},xn=On(On.bind),Sn=function(t,e){return nt(t),void 0===e?t:h?xn(t,e):function(){return t.apply(e,arguments)}},En=Array.isArray||function(t){return"Array"===P(t)},Tn=function(){},jn=z("Reflect","construct"),Pn=/^\s*(?:class|function)\b/,Rn=E(Pn.exec),An=!Pn.test(Tn),Cn=function(t){if(!D(t))return!1;try{return jn(Tn,[],t),!0}catch(t){return!1}},kn=function(t){if(!D(t))return!1;switch(He(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return An||!!Rn(Pn,Kt(t))}catch(t){return!0}};kn.sham=!0;var Ln=!jn||l((function(){var t;return Cn(Cn.call)||!Cn(Object)||!Cn((function(){t=!0}))||t}))?kn:Cn,Fn=wt("species"),_n=Array,Mn=function(t,e){return new(function(t){var e;return En(t)&&(e=t.constructor,(Ln(e)&&(e===_n||En(e.prototype))||I(e)&&null===(e=e[Fn]))&&(e=void 0)),void 0===e?_n:e}(t))(0===e?0:e)},Dn=E([].push),In=function(t){var e=1===t,n=2===t,r=3===t,o=4===t,i=6===t,a=7===t,u=5===t||i;return function(c,s,f,l){for(var d,h,p=ft(c),v=C(p),g=we(v),y=Sn(s,f),b=0,m=l||Mn,w=e?m(c,g):n||a?m(c,0):void 0;g>b;b++)if((u||b in v)&&(h=y(d=v[b],b,p),t))if(e)w[b]=h;else if(h)switch(t){case 3:return!0;case 5:return d;case 6:return b;case 2:Dn(w,d)}else switch(t){case 4:return!1;case 7:Dn(w,d)}return i?-1:r||o?o:w}},zn={forEach:In(0),map:In(1),filter:In(2),some:In(3),every:In(4),find:In(5),findIndex:In(6),filterReject:In(7)},Nn=zn.forEach,Wn=ee("hidden"),Yn="Symbol",Xn="prototype",Gn=ce.set,Bn=ce.getterFor(Yn),Un=Object[Xn],Vn=f.Symbol,qn=Vn&&Vn[Xn],Hn=f.RangeError,$n=f.TypeError,Jn=f.QObject,Kn=Ct.f,Qn=Yt.f,Zn=hn.f,tr=m.f,er=E([].push),nr=ct("symbols"),rr=ct("op-symbols"),or=ct("wks"),ir=!Jn||!Jn[Xn]||!Jn[Xn].findChild,ar=function(t,e,n){var r=Kn(Un,e);r&&delete Un[e],Qn(t,e,n),r&&t!==Un&&Qn(Un,e,r)},ur=d&&l((function(){return 7!==sn(Qn({},"a",{get:function(){return Qn(this,"a",{value:7}).a}})).a}))?ar:Qn,cr=function(t,e){var n=nr[t]=sn(qn);return Gn(n,{type:Yn,tag:t,description:e}),d||(n.description=e),n},sr=function(t,e,n){t===Un&&sr(rr,e,n),_t(t);var r=Et(e);return _t(n),dt(nr,r)?(n.enumerable?(dt(t,Wn)&&t[Wn][r]&&(t[Wn][r]=!1),n=sn(n,{enumerable:w(0,!1)})):(dt(t,Wn)||Qn(t,Wn,w(1,sn(null))),t[Wn][r]=!0),ur(t,r,n)):Qn(t,r,n)},fr=function(t,e){_t(t);var n=_(e),r=Ke(n).concat(pr(n));return Nn(r,(function(e){d&&!v(lr,n,e)||sr(t,e,n[e])})),t},lr=function(t){var e=Et(t),n=v(tr,this,e);return!(this===Un&&dt(nr,e)&&!dt(rr,e))&&(!(n||!dt(this,e)||!dt(nr,e)||dt(this,Wn)&&this[Wn][e])||n)},dr=function(t,e){var n=_(t),r=Et(e);if(n!==Un||!dt(nr,r)||dt(rr,r)){var o=Kn(n,r);return!o||!dt(nr,r)||dt(n,Wn)&&n[Wn][r]||(o.enumerable=!0),o}},hr=function(t){var e=Zn(_(t)),n=[];return Nn(e,(function(t){dt(nr,t)||dt(ne,t)||er(n,t)})),n},pr=function(t){var e=t===Un,n=Zn(e?rr:_(t)),r=[];return Nn(n,(function(t){!dt(nr,t)||e&&!dt(Un,t)||er(r,nr[t])})),r};$||(Vn=function(){if(N(qn,this))throw new $n("Symbol is not a constructor");var t=arguments.length&&void 0!==arguments[0]?Je(arguments[0]):void 0,e=gt(t),n=function(t){var r=void 0===this?f:this;r===Un&&v(n,rr,t),dt(r,Wn)&&dt(r[Wn],e)&&(r[Wn][e]=!1);var o=w(1,t);try{ur(r,e,o)}catch(t){if(!(t instanceof Hn))throw t;ar(r,e,o)}};return d&&ir&&ur(Un,e,{configurable:!0,set:n}),cr(e,t)},qn=Vn[Xn],fe(qn,"toString",(function(){return Bn(this).tag})),fe(Vn,"withoutSetter",(function(t){return cr(gt(t),t)})),m.f=lr,Yt.f=sr,Ze.f=fr,Ct.f=dr,Re.f=hn.f=hr,Ae.f=pr,vn.f=function(t){return cr(wt(t),t)},d&&(pn(qn,"description",{configurable:!0,get:function(){return Bn(this).description}}),fe(Un,"propertyIsEnumerable",lr,{unsafe:!0}))),Ye({global:!0,constructor:!0,wrap:!0,forced:!$,sham:!$},{Symbol:Vn}),Nn(Ke(or),(function(t){!function(t){var e=gn.Symbol||(gn.Symbol={});dt(e,t)||yn(e,t,{value:vn.f(t)})}(t)})),Ye({target:Yn,stat:!0,forced:!$},{useSetter:function(){ir=!0},useSimple:function(){ir=!1}}),Ye({target:"Object",stat:!0,forced:!$,sham:!d},{create:function(t,e){return void 0===e?sn(t):fr(sn(t),e)},defineProperty:sr,defineProperties:fr,getOwnPropertyDescriptor:dr}),Ye({target:"Object",stat:!0,forced:!$},{getOwnPropertyNames:hr}),function(){var t=z("Symbol"),e=t&&t.prototype,n=e&&e.valueOf,r=wt("toPrimitive");e&&!e[r]&&fe(e,r,(function(t){return v(n,this)}),{arity:1})}(),wn(Vn,Yn),ne[Wn]=!0;var vr=$&&!!Symbol.for&&!!Symbol.keyFor,gr=ct("string-to-symbol-registry"),yr=ct("symbol-to-string-registry");Ye({target:"Symbol",stat:!0,forced:!vr},{for:function(t){var e=Je(t);if(dt(gr,e))return gr[e];var n=z("Symbol")(e);return gr[e]=n,yr[n]=e,n}});var br=ct("symbol-to-string-registry");Ye({target:"Symbol",stat:!0,forced:!vr},{keyFor:function(t){if(!Q(t))throw new TypeError(tt(t)+" is not a symbol");if(dt(br,t))return br[t]}});var mr=Function.prototype,wr=mr.apply,Or=mr.call,xr="object"==typeof Reflect&&Reflect.apply||(h?Or.bind(wr):function(){return Or.apply(wr,arguments)}),Sr=E([].push),Er=String,Tr=z("JSON","stringify"),jr=E(/./.exec),Pr=E("".charAt),Rr=E("".charCodeAt),Ar=E("".replace),Cr=E(1..toString),kr=/[\uD800-\uDFFF]/g,Lr=/^[\uD800-\uDBFF]$/,Fr=/^[\uDC00-\uDFFF]$/,_r=!$||l((function(){var t=z("Symbol")("stringify detection");return"[null]"!==Tr([t])||"{}"!==Tr({a:t})||"{}"!==Tr(Object(t))})),Mr=l((function(){return'"\\udf06\\ud834"'!==Tr("\udf06\ud834")||'"\\udead"'!==Tr("\udead")})),Dr=function(t,e){var n=fn(arguments),r=function(t){if(D(t))return t;if(En(t)){for(var e=t.length,n=[],r=0;r<e;r++){var o=t[r];"string"==typeof o?Sr(n,o):"number"!=typeof o&&"Number"!==P(o)&&"String"!==P(o)||Sr(n,Je(o))}var i=n.length,a=!0;return function(t,e){if(a)return a=!1,e;if(En(this))return e;for(var r=0;r<i;r++)if(n[r]===t)return e}}}(e);if(D(r)||void 0!==t&&!Q(t))return n[1]=function(t,e){if(D(r)&&(e=v(r,this,Er(t),e)),!Q(e))return e},xr(Tr,null,n)},Ir=function(t,e,n){var r=Pr(n,e-1),o=Pr(n,e+1);return jr(Lr,t)&&!jr(Fr,o)||jr(Fr,t)&&!jr(Lr,r)?"\\u"+Cr(Rr(t,0),16):t};Tr&&Ye({target:"JSON",stat:!0,arity:3,forced:_r||Mr},{stringify:function(t,e,n){var r=fn(arguments),o=xr(_r?Dr:Tr,null,r);return Mr&&"string"==typeof o?Ar(o,kr,Ir):o}});var zr=!$||l((function(){Ae.f(1)}));Ye({target:"Object",stat:!0,forced:zr},{getOwnPropertySymbols:function(t){var e=Ae.f;return e?e(ft(t)):[]}});var Nr=f.Symbol,Wr=Nr&&Nr.prototype;if(d&&D(Nr)&&(!("description"in Wr)||void 0!==Nr().description)){var Yr={},Xr=function(){var t=arguments.length<1||void 0===arguments[0]?void 0:Je(arguments[0]),e=N(Wr,this)?new Nr(t):void 0===t?Nr():Nr(t);return""===t&&(Yr[e]=!0),e};Le(Xr,Nr),Xr.prototype=Wr,Wr.constructor=Xr;var Gr="Symbol(description detection)"===String(Nr("description detection")),Br=E(Wr.valueOf),Ur=E(Wr.toString),Vr=/^Symbol\((.*)\)[^)]+$/,qr=E("".replace),Hr=E("".slice);pn(Wr,"description",{configurable:!0,get:function(){var t=Br(this);if(dt(Yr,t))return"";var e=Ur(t),n=Gr?Hr(e,7,-1):qr(e,Vr,"$1");return""===n?void 0:n}}),Ye({global:!0,constructor:!0,forced:!0},{Symbol:Xr})}var $r=Yt.f,Jr=wt("unscopables"),Kr=Array.prototype;void 0===Kr[Jr]&&$r(Kr,Jr,{configurable:!0,value:sn(null)});var Qr,Zr,to,eo=function(t){Kr[Jr][t]=!0},no={},ro=!l((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),oo=ee("IE_PROTO"),io=Object,ao=io.prototype,uo=ro?io.getPrototypeOf:function(t){var e=ft(t);if(dt(e,oo))return e[oo];var n=e.constructor;return D(n)&&e instanceof n?n.prototype:e instanceof io?ao:null},co=wt("iterator"),so=!1;[].keys&&("next"in(to=[].keys())?(Zr=uo(uo(to)))!==Object.prototype&&(Qr=Zr):so=!0);var fo=!I(Qr)||l((function(){var t={};return Qr[co].call(t)!==t}));fo&&(Qr={}),D(Qr[co])||fe(Qr,co,(function(){return this}));var lo={IteratorPrototype:Qr,BUGGY_SAFARI_ITERATORS:so},ho=lo.IteratorPrototype,po=function(){return this},vo=String,go=TypeError,yo=function(t){if(function(t){return I(t)||null===t}(t))return t;throw new go("Can't set "+vo(t)+" as a prototype")},bo=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=function(t,e,n){try{return E(nt(Object.getOwnPropertyDescriptor(t,e)[n]))}catch(t){}}(Object.prototype,"__proto__","set"))(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return F(n),yo(r),I(n)?(e?t(n,r):n.__proto__=r,n):n}}():void 0),mo=Vt.PROPER,wo=Vt.CONFIGURABLE,Oo=lo.IteratorPrototype,xo=lo.BUGGY_SAFARI_ITERATORS,So=wt("iterator"),Eo="keys",To="values",jo="entries",Po=function(){return this},Ro=function(t,e,n,r,o,i,a){!function(t,e,n,r){var o=e+" Iterator";t.prototype=sn(ho,{next:w(+!r,n)}),wn(t,o,!1),no[o]=po}(n,e,r);var u,c,s,f=function(t){if(t===o&&g)return g;if(!xo&&t&&t in h)return h[t];switch(t){case Eo:case To:case jo:return function(){return new n(this,t)}}return function(){return new n(this)}},l=e+" Iterator",d=!1,h=t.prototype,p=h[So]||h["@@iterator"]||o&&h[o],g=!xo&&p||f(o),y="Array"===e&&h.entries||p;if(y&&(u=uo(y.call(new t)))!==Object.prototype&&u.next&&(uo(u)!==Oo&&(bo?bo(u,Oo):D(u[So])||fe(u,So,Po)),wn(u,l,!0)),mo&&o===To&&p&&p.name!==To&&(wo?Xt(h,"name",To):(d=!0,g=function(){return v(p,this)})),o)if(c={values:f(To),keys:i?g:f(Eo),entries:f(jo)},a)for(s in c)(xo||d||!(s in h))&&fe(h,s,c[s]);else Ye({target:e,proto:!0,forced:xo||d},c);return h[So]!==g&&fe(h,So,g,{name:o}),no[e]=g,c},Ao=function(t,e){return{value:t,done:e}},Co=Yt.f,ko="Array Iterator",Lo=ce.set,Fo=ce.getterFor(ko),_o=Ro(Array,"Array",(function(t,e){Lo(this,{type:ko,target:_(t),index:0,kind:e})}),(function(){var t=Fo(this),e=t.target,n=t.index++;if(!e||n>=e.length)return t.target=null,Ao(void 0,!0);switch(t.kind){case"keys":return Ao(n,!1);case"values":return Ao(e[n],!1)}return Ao([n,e[n]],!1)}),"values"),Mo=no.Arguments=no.Array;if(eo("keys"),eo("values"),eo("entries"),d&&"values"!==Mo.name)try{Co(Mo,"name",{value:"values"})}catch(t){}var Do=Be?{}.toString:function(){return"[object "+He(this)+"]"};Be||fe(Object.prototype,"toString",Do,{unsafe:!0});var Io=E("".charAt),zo=E("".charCodeAt),No=E("".slice),Wo=function(t){return function(e,n){var r,o,i=Je(F(e)),a=pe(n),u=i.length;return a<0||a>=u?t?"":void 0:(r=zo(i,a))<55296||r>56319||a+1===u||(o=zo(i,a+1))<56320||o>57343?t?Io(i,a):r:t?No(i,a,a+2):o-56320+(r-55296<<10)+65536}},Yo={codeAt:Wo(!1),charAt:Wo(!0)}.charAt,Xo="String Iterator",Go=ce.set,Bo=ce.getterFor(Xo);Ro(String,"String",(function(t){Go(this,{type:Xo,string:Je(t),index:0})}),(function(){var t,e=Bo(this),n=e.string,r=e.index;return r>=n.length?Ao(void 0,!0):(t=Yo(n,r),e.index+=t.length,Ao(t,!1))}));var Uo=!l((function(){return Object.isExtensible(Object.preventExtensions({}))})),Vo=function(t,e,n){for(var r in e)fe(t,r,e[r],n);return t},qo=l((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})),Ho=Object.isExtensible,$o=l((function(){Ho(1)}))||qo?function(t){return!!I(t)&&((!qo||"ArrayBuffer"!==P(t))&&(!Ho||Ho(t)))}:Ho,Jo=a((function(t){var e=Yt.f,n=!1,r=gt("meta"),o=0,i=function(t){e(t,r,{value:{objectID:"O"+o++,weakData:{}}})},a=t.exports={enable:function(){a.enable=function(){},n=!0;var t=Re.f,e=E([].splice),o={};o[r]=1,t(o).length&&(Re.f=function(n){for(var o=t(n),i=0,a=o.length;i<a;i++)if(o[i]===r){e(o,i,1);break}return o},Ye({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:hn.f}))},fastKey:function(t,e){if(!I(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!dt(t,r)){if(!$o(t))return"F";if(!e)return"E";i(t)}return t[r].objectID},getWeakData:function(t,e){if(!dt(t,r)){if(!$o(t))return!0;if(!e)return!1;i(t)}return t[r].weakData},onFreeze:function(t){return Uo&&n&&$o(t)&&!dt(t,r)&&i(t),t}};ne[r]=!0})),Ko=wt("iterator"),Qo=Array.prototype,Zo=function(t){return void 0!==t&&(no.Array===t||Qo[Ko]===t)},ti=wt("iterator"),ei=function(t){if(!k(t))return rt(t,ti)||rt(t,"@@iterator")||no[He(t)]},ni=TypeError,ri=function(t,e){var n=arguments.length<2?ei(t):e;if(nt(n))return _t(v(n,t));throw new ni(tt(t)+" is not iterable")},oi=function(t,e,n){var r,o;_t(t);try{if(!(r=rt(t,"return"))){if("throw"===e)throw n;return n}r=v(r,t)}catch(t){o=!0,r=t}if("throw"===e)throw n;if(o)throw r;return _t(r),n},ii=TypeError,ai=function(t,e){this.stopped=t,this.result=e},ui=ai.prototype,ci=function(t,e,n){var r,o,i,a,u,c,s,f=n&&n.that,l=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_RECORD),h=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),g=Sn(e,f),y=function(t){return r&&oi(r,"normal",t),new ai(!0,t)},b=function(t){return l?(_t(t),p?g(t[0],t[1],y):g(t[0],t[1])):p?g(t,y):g(t)};if(d)r=t.iterator;else if(h)r=t;else{if(!(o=ei(t)))throw new ii(tt(t)+" is not iterable");if(Zo(o)){for(i=0,a=we(t);a>i;i++)if((u=b(t[i]))&&N(ui,u))return u;return new ai(!1)}r=ri(t,o)}for(c=d?t.next:r.next;!(s=v(c,r)).done;){try{u=b(s.value)}catch(t){oi(r,"throw",t)}if("object"==typeof u&&u&&N(ui,u))return u}return new ai(!1)},si=TypeError,fi=function(t,e){if(N(e,t))return t;throw new si("Incorrect invocation")},li=wt("iterator"),di=!1;try{var hi=0,pi={next:function(){return{done:!!hi++}},return:function(){di=!0}};pi[li]=function(){return this},Array.from(pi,(function(){throw 2}))}catch(t){}var vi=function(t,e){try{if(!e&&!di)return!1}catch(t){return!1}var n=!1;try{var r={};r[li]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n},gi=function(t,e,n){var r=-1!==t.indexOf("Map"),o=-1!==t.indexOf("Weak"),i=r?"set":"add",a=f[t],u=a&&a.prototype,c=a,s={},d=function(t){var e=E(u[t]);fe(u,t,"add"===t?function(t){return e(this,0===t?0:t),this}:"delete"===t?function(t){return!(o&&!I(t))&&e(this,0===t?0:t)}:"get"===t?function(t){return o&&!I(t)?void 0:e(this,0===t?0:t)}:"has"===t?function(t){return!(o&&!I(t))&&e(this,0===t?0:t)}:function(t,n){return e(this,0===t?0:t,n),this})};if(Ne(t,!D(a)||!(o||u.forEach&&!l((function(){(new a).entries().next()})))))c=n.getConstructor(e,t,r,i),Jo.enable();else if(Ne(t,!0)){var h=new c,p=h[i](o?{}:-0,1)!==h,v=l((function(){h.has(1)})),g=vi((function(t){new a(t)})),y=!o&&l((function(){for(var t=new a,e=5;e--;)t[i](e,e);return!t.has(-0)}));g||((c=e((function(t,e){fi(t,u);var n=function(t,e,n){var r,o;return bo&&D(r=e.constructor)&&r!==n&&I(o=r.prototype)&&o!==n.prototype&&bo(t,o),t}(new a,t,c);return k(e)||ci(e,n[i],{that:n,AS_ENTRIES:r}),n}))).prototype=u,u.constructor=c),(v||y)&&(d("delete"),d("has"),r&&d("get")),(y||p)&&d(i),o&&u.clear&&delete u.clear}return s[t]=c,Ye({global:!0,constructor:!0,forced:c!==a},s),wn(c,t),o||n.setStrong(c,t,r),c},yi=Jo.getWeakData,bi=ce.set,mi=ce.getterFor,wi=zn.find,Oi=zn.findIndex,xi=E([].splice),Si=0,Ei=function(t){return t.frozen||(t.frozen=new Ti)},Ti=function(){this.entries=[]},ji=function(t,e){return wi(t.entries,(function(t){return t[0]===e}))};Ti.prototype={get:function(t){var e=ji(this,t);if(e)return e[1]},has:function(t){return!!ji(this,t)},set:function(t,e){var n=ji(this,t);n?n[1]=e:this.entries.push([t,e])},delete:function(t){var e=Oi(this.entries,(function(e){return e[0]===t}));return~e&&xi(this.entries,e,1),!!~e}};var Pi,Ri={getConstructor:function(t,e,n,r){var o=t((function(t,o){fi(t,i),bi(t,{type:e,id:Si++,frozen:null}),k(o)||ci(o,t[r],{that:t,AS_ENTRIES:n})})),i=o.prototype,a=mi(e),u=function(t,e,n){var r=a(t),o=yi(_t(e),!0);return!0===o?Ei(r).set(e,n):o[r.id]=n,t};return Vo(i,{delete:function(t){var e=a(this);if(!I(t))return!1;var n=yi(t);return!0===n?Ei(e).delete(t):n&&dt(n,e.id)&&delete n[e.id]},has:function(t){var e=a(this);if(!I(t))return!1;var n=yi(t);return!0===n?Ei(e).has(t):n&&dt(n,e.id)}}),Vo(i,n?{get:function(t){var e=a(this);if(I(t)){var n=yi(t);if(!0===n)return Ei(e).get(t);if(n)return n[e.id]}},set:function(t,e){return u(this,t,e)}}:{add:function(t){return u(this,t,!0)}}),o}},Ai=ce.enforce,Ci=Object,ki=Array.isArray,Li=Ci.isExtensible,Fi=Ci.isFrozen,_i=Ci.isSealed,Mi=Ci.freeze,Di=Ci.seal,Ii=!f.ActiveXObject&&"ActiveXObject"in f,zi=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Ni=gi("WeakMap",zi,Ri),Wi=Ni.prototype,Yi=E(Wi.set);if(Zt)if(Ii){Pi=Ri.getConstructor(zi,"WeakMap",!0),Jo.enable();var Xi=E(Wi.delete),Gi=E(Wi.has),Bi=E(Wi.get);Vo(Wi,{delete:function(t){if(I(t)&&!Li(t)){var e=Ai(this);return e.frozen||(e.frozen=new Pi),Xi(this,t)||e.frozen.delete(t)}return Xi(this,t)},has:function(t){if(I(t)&&!Li(t)){var e=Ai(this);return e.frozen||(e.frozen=new Pi),Gi(this,t)||e.frozen.has(t)}return Gi(this,t)},get:function(t){if(I(t)&&!Li(t)){var e=Ai(this);return e.frozen||(e.frozen=new Pi),Gi(this,t)?Bi(this,t):e.frozen.get(t)}return Bi(this,t)},set:function(t,e){if(I(t)&&!Li(t)){var n=Ai(this);n.frozen||(n.frozen=new Pi),Gi(this,t)?Yi(this,t,e):n.frozen.set(t,e)}else Yi(this,t,e);return this}})}else Uo&&l((function(){var t=Mi([]);return Yi(new Ni,t,1),!Fi(t)}))&&Vo(Wi,{set:function(t,e){var n;return ki(t)&&(Fi(t)?n=Mi:_i(t)&&(n=Di)),Yi(this,t,e),n&&n(t),this}});gi("WeakSet",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),Ri);var Ui,Vi,qi={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Hi=Pt("span").classList,$i=Hi&&Hi.constructor&&Hi.constructor.prototype,Ji=$i===Object.prototype?void 0:$i,Ki=zn.forEach,Qi=!!(Vi=[]["forEach"])&&l((function(){Vi.call(null,Ui||function(){return 1},1)}))?[].forEach:function(t){return Ki(this,t,arguments.length>1?arguments[1]:void 0)},Zi=function(t){if(t&&t.forEach!==Qi)try{Xt(t,"forEach",Qi)}catch(e){t.forEach=Qi}};for(var ta in qi)qi[ta]&&Zi(f[ta]&&f[ta].prototype);Zi(Ji);var ea=wt("iterator"),na=_o.values,ra=function(t,e){if(t){if(t[ea]!==na)try{Xt(t,ea,na)}catch(e){t[ea]=na}if(wn(t,e,!0),qi[e])for(var n in _o)if(t[n]!==_o[n])try{Xt(t,n,_o[n])}catch(e){t[n]=_o[n]}}};for(var oa in qi)ra(f[oa]&&f[oa].prototype,oa);ra(Ji,"DOMTokenList");var ia=function(){return ia=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ia.apply(this,arguments)};function aa(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function ua(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ca(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function sa(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var fa=function(t,e,n,r){try{return r?e(_t(n)[0],n[1]):e(n)}catch(e){oi(t,"throw",e)}},la=function(t,e,n){d?Yt.f(t,e,w(0,n)):t[e]=n},da=Array,ha=!vi((function(t){Array.from(t)}));Ye({target:"Array",stat:!0,forced:ha},{from:function(t){var e=ft(t),n=Ln(this),r=arguments.length,o=r>1?arguments[1]:void 0,i=void 0!==o;i&&(o=Sn(o,r>2?arguments[2]:void 0));var a,u,c,s,f,l,d=ei(e),h=0;if(!d||this===da&&Zo(d))for(a=we(e),u=n?new this(a):da(a);a>h;h++)l=i?o(e[h],h):e[h],la(u,h,l);else for(u=n?new this:[],f=(s=ri(e,d)).next;!(c=v(f,s)).done;h++)l=i?fa(s,o,[c.value,h],!0):c.value,la(u,h,l);return u.length=h,u}});var pa=wt("species"),va=function(t){return q>=51||!l((function(){var e=[];return(e.constructor={})[pa]=function(){return{foo:1}},1!==e[t](Boolean).foo}))},ga=zn.map,ya=va("map");Ye({target:"Array",proto:!0,forced:!ya},{map:function(t){return ga(this,t,arguments.length>1?arguments[1]:void 0)}});var ba=va("slice"),ma=wt("species"),wa=Array,Oa=Math.max;Ye({target:"Array",proto:!0,forced:!ba},{slice:function(t,e){var n,r,o,i=_(this),a=we(i),u=ye(t,a),c=ye(void 0===e?a:e,a);if(En(i)&&(n=i.constructor,(Ln(n)&&(n===wa||En(n.prototype))||I(n)&&null===(n=n[ma]))&&(n=void 0),n===wa||void 0===n))return fn(i,u,c);for(r=new(void 0===n?wa:n)(Oa(c-u,0)),o=0;u<c;u++,o++)u in i&&la(r,o,i[u]);return r.length=o,r}}),Ye({target:"Object",stat:!0},{fromEntries:function(t){var e={};return ci(t,(function(t,n){la(e,t,n)}),{AS_ENTRIES:!0}),e}});var xa=l((function(){Ke(1)}));Ye({target:"Object",stat:!0,forced:xa},{keys:function(t){return Ke(ft(t))}});var Sa=m.f,Ea=E(Sa),Ta=E([].push),ja=d&&l((function(){var t=Object.create(null);return t[2]=2,!Ea(t,2)})),Pa=function(t){return function(e){for(var n,r=_(e),o=Ke(r),i=ja&&null===uo(r),a=o.length,u=0,c=[];a>u;)n=o[u++],d&&!(i?n in r:Ea(r,n))||Ta(c,t?[n,r[n]]:r[n]);return c}},Ra={entries:Pa(!0),values:Pa(!1)}.entries;Ye({target:"Object",stat:!0},{entries:function(t){return Ra(t)}});var Aa=zn.filter,Ca=va("filter");Ye({target:"Array",proto:!0,forced:!Ca},{filter:function(t){return Aa(this,t,arguments.length>1?arguments[1]:void 0)}});var ka=xe.includes,La=l((function(){return!Array(1).includes()}));Ye({target:"Array",proto:!0,forced:La},{includes:function(t){return ka(this,t,arguments.length>1?arguments[1]:void 0)}}),eo("includes");var Fa=function(){var t=_t(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e},_a=RegExp.prototype,Ma=Vt.PROPER,Da="toString",Ia=RegExp.prototype,za=Ia[Da],Na=l((function(){return"/a/b"!==za.call({source:"a",flags:"b"})})),Wa=Ma&&za.name!==Da;function Ya(t){return"[object Object]"===Object.prototype.toString.call(t)}function Xa(t){if(!Ya(t))return!1;var e=t.constructor;if(void 0===e)return!0;var n=e.prototype;return!1!==Ya(n)&&!Object.prototype.hasOwnProperty.call(n,"isPrototypeOfOf")}function Ga(t,e){for(var n in t){var r=t[n],o=e[n];if(Xa(r)&&Xa(o)){if(!Ga(r,o))return!1}else if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return!1;for(var i=0;i<r.length;i+=1)if(r[i]!==o[i])return!1}else if(r!==o)return!1}for(var n in e)if(void 0===t[n]&&void 0!==e[n])return!1;return!0}function Ba(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return Object.fromEntries(Object.entries(t).filter((function(t){var n=ca(t,1)[0];return e.includes(n)})))}function Ua(t){return function(t){var e,n,r,o,i=[];try{for(var a=ua(t),u=a.next();!u.done;u=a.next()){var c=u.value;if("string"!=typeof c.insert||0!==c.insert.length){var s=i[i.length-1];s&&"string"==typeof s.insert&&"string"==typeof c.insert&&(s.attributes===c.attributes||!s.attributes==!c.attributes&&Ga(null!==(r=s.attributes)&&void 0!==r?r:{},null!==(o=c.attributes)&&void 0!==o?o:{}))?s.insert+=c.insert:i.push(c)}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return i}(t.toDelta())}function Va(t){var e=t.insert;return"string"==typeof e?e.length:1}function qa(t){return t.reduce((function(t,e){return t+Va(e)}),0)}function Ha(t,e,n){if(n<1)return[];for(var r=0,o=[],i=e+n,a=0;a<t.length&&!(r>=i);a++){var u=t[a],c=Va(u);if(r+c<=e)r+=c;else if("string"==typeof u.insert){var s=Math.max(0,e-r),f=Math.min(c,c-(r+c-i));o.push(ia(ia({},u),{insert:u.insert.slice(s,f)})),r+=c}else r+=c,o.push(u)}return o}function $a(t){return function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return Object.fromEntries(Object.entries(t).filter((function(t){var n=ca(t,1)[0];return!e.includes(n)})))}(t,e.Text.isText(t)?"text":"children")}function Ja(t){var e=Ua(t),n=e.length>0?e.map(Ka):[{text:""}];return ia(ia({},t.getAttributes()),{children:n})}function Ka(t){return"string"==typeof t.insert?ia(ia({},t.attributes),{text:t.insert}):Ja(t.insert)}function Qa(t){return t.map((function(t){return e.Text.isText(t)?{insert:t.text,attributes:$a(t)}:{insert:Za(t)}}))}function Za(t){var e=t.children,n=aa(t,["children"]),r=new o.XmlText;return Object.entries(n).forEach((function(t){var e=ca(t,2),n=e[0],o=e[1];r.setAttribute(n,o)})),r.applyDelta(Qa(e),{sanitize:!1}),r}(Na||Wa)&&fe(Ia,Da,(function(){var t=_t(this),e=Je(t.source),n=Je(function(t){var e=t.flags;return void 0!==e||"flags"in _a||dt(t,"flags")||!N(_a,t)?e:v(Fa,t)}(t));return"/"+e+"/"+n}),{unsafe:!0});var tu=TypeError,eu=function(t){if(t>9007199254740991)throw tu("Maximum allowed index exceeded");return t},nu=wt("isConcatSpreadable"),ru=q>=51||!l((function(){var t=[];return t[nu]=!1,t.concat()[0]!==t})),ou=function(t){if(!I(t))return!1;var e=t[nu];return void 0!==e?!!e:En(t)},iu=!ru||!va("concat");function au(t){return t?e.Text.isText(t)?t.text.length:1:0}function uu(t,n,r){var i;if(0===r.length)throw new Error("Path has to a have a length >= 1");if(e.Text.isText(n))throw new Error("Cannot descent into slate text");var a=ca(r),u=a[0],c=a.slice(1),s=function(t,e){return t.children.slice(0,e).reduce((function(t,e){return t+au(e)}),0)}(n,u),f=n.children[u],l=Ua(t),d=au(f),h=Ha(l,s,d);if(h.length>1)throw new Error("Path doesn't match yText, yTarget spans multiple nodes");var p=null===(i=h[0])||void 0===i?void 0:i.insert;if(c.length>0){if(!(p instanceof o.XmlText))throw new Error("Path doesn't match yText, cannot descent into non-yText");return uu(p,f,c)}return{yParent:t,textRange:{start:s,end:s+d},yTarget:p instanceof o.XmlText?p:void 0,slateParent:n,slateTarget:f,targetDelta:h}}function cu(t,n,r){void 0===r&&(r={});for(var o=r.assoc,i=void 0===o?0:o,a=r.insert,u=void 0!==a&&a,c=0,s=0,f=0;f<t.children.length;f++){var l=t.children[f],d=e.Text.isText(l)?l.text.length:1;d>0&&(s=f);var h=c+d;if(d>0&&(i>=0?h>n:h>=n))return[f,n-c];c+=d}if(n>c+(u?1:0))throw new Error("yOffset out of bounds");if(u)return[t.children.length,0];var p=t.children[s];return[s,e.Text.isText(p)?p.text.length:1]}function su(t,n,r){for(var i=[r];i[0]!==t;){var a=i[0].parent;if(!a)throw new Error("yText isn't a descendant of root element");if(!(a instanceof o.XmlText))throw new Error("Unexpected y parent type");i.unshift(a)}if(i.length<2)return[];var u=n;return i.reduce((function(t,n,r){var o,a,c=i[r+1];if(!c)return t;var s=0,f=Ua(n);try{for(var l=ua(f),d=l.next();!d.done;d=l.next()){var h=d.value;if(h.insert===c)break;s+="string"==typeof h.insert?h.insert.length:1}}catch(t){o={error:t}}finally{try{d&&!d.done&&(a=l.return)&&a.call(l)}finally{if(o)throw o.error}}if(e.Text.isText(u))throw new Error("Cannot descent into slate text");var p=ca(cu(u,s),1)[0];return u=u.children[p],t.concat(p)}),[])}function fu(t,n,r){var i=r.target,a=r.changes,u=r.delta;if(!(i instanceof o.XmlText))throw new Error("Unexpected target node type");var c=[],s=su(t,n,i),f=e.Node.get(n,s);if(e.Text.isText(f))throw new Error("Cannot apply yTextEvent to text node");var l=Array.from(a.keys.entries());if(s.length>0&&l.length>0){var d=Object.fromEntries(l.map((function(t){var e=ca(t,2),n=e[0];return[n,"delete"===e[1].action?null:i.getAttribute(n)]}))),h=Object.fromEntries(l.map((function(t){var e=ca(t,1)[0];return[e,f[e]]})));c.push({type:"set_node",newProperties:d,properties:h,path:s})}return u.length>0&&c.push.apply(c,sa([],ca(function(t,n,r){var o=[],i=r.reduce((function(t,e){return"retain"in e?t+e.retain:"delete"in e?t+e.delete:t}),0);return r.reverse().forEach((function(r){var a,u;if("attributes"in r&&"retain"in r)for(var c=ca(cu(t,i-r.retain),2),s=c[0],f=c[1],l=ca(cu(t,i,{assoc:-1}),2),d=l[0],h=l[1],p=d;p>=s;p--){var v=t.children[p],g=sa(sa([],ca(n),!1),[p],!1);if(e.Text.isText(v)){var y=r.attributes,b=Ba.apply(void 0,sa([t],ca(Object.keys(r.attributes)),!1));if(p===s||p===d){var m=p===s?f:0;if((x=p===d?h:v.text.length)!==v.text.length&&o.push({type:"split_node",path:g,position:x,properties:$a(v)}),0!==m){o.push({type:"split_node",path:g,position:m,properties:(u=ia(ia({},$a(v)),y),Object.fromEntries(Object.entries(u).filter((function(t){return null!==ca(t,2)[1]}))))});continue}}o.push({type:"set_node",newProperties:y,path:g,properties:b})}}if("retain"in r&&(i-=r.retain),"delete"in r){var w=ca(cu(t,i-r.delete),2),O=(s=w[0],f=w[1],ca(cu(t,i,{assoc:-1}),2));for(d=O[0],p=0===(h=O[1])?d-1:d;p>=s;p--)if(v=t.children[p],g=sa(sa([],ca(n),!1),[p],!1),!e.Text.isText(v)||p!==s&&p!==d)o.push({type:"remove_node",node:v,path:g}),i-=au(v);else{m=p===s?f:0;var x=p===d?h:v.text.length;o.push({type:"remove_text",offset:m,text:v.text.slice(m,x),path:g}),i-=x-m}}else if("insert"in r){var S=ca(cu(t,i,{insert:!0}),2),E=(p=S[0],S[1]);if(v=t.children[p],g=sa(sa([],ca(n),!1),[p],!1),e.Text.isText(v)){var T=o[o.length-1],j=null!=T&&"insert_node"===T.type?T.node:$a(v),P=[];if(null==T||"insert_node"!==T.type&&"insert_text"!==T.type&&"split_node"!==T.type&&"set_node"!==T.type||(P=T.path),"string"==typeof r.insert&&Ga(null!==(a=r.attributes)&&void 0!==a?a:{},j)&&e.Path.equals(g,P))return o.push({type:"insert_text",offset:E,text:r.insert,path:g});var R=Ka(r);return 0===E?o.push({type:"insert_node",path:g,node:R}):(E<v.text.length&&o.push({type:"split_node",path:g,position:E,properties:$a(v)}),o.push({type:"insert_node",path:e.Path.next(g),node:R}))}return o.push({type:"insert_node",path:g,node:Ka(r)})}})),o}(f,s,u)),!1)),c}function lu(t,n,r){e.Editor.withoutNormalizing(n,(function(){r.forEach((function(e){(function(t,e,n){if(n instanceof o.YTextEvent)return fu(t,e,n);throw new Error("Unexpected Y event type")})(t,n,e).forEach((function(t){n.apply(t)}))}))}))}function du(t){return t.map((function(t){return"string"==typeof t.insert?t:ia(ia({},t),{insert:hu(t.insert)})}))}function hu(t){var e=new o.XmlText,n=t.getAttributes();return Object.entries(n).forEach((function(t){var n=ca(t,2),r=n[0],o=n[1];e.setAttribute(r,o)})),e.applyDelta(du(Ua(t)),{sanitize:!1}),e}Ye({target:"Array",proto:!0,arity:1,forced:iu},{concat:function(t){var e,n,r,o,i,a=ft(this),u=Mn(a,0),c=0;for(e=-1,r=arguments.length;e<r;e++)if(ou(i=-1===e?a:arguments[e]))for(o=we(i),eu(c+o),n=0;n<o;n++,c++)n in i&&la(u,c,i[n]);else eu(c+1),la(u,c++,i);return u.length=c,u}});var pu=Object.assign,vu=Object.defineProperty,gu=E([].concat),yu=!pu||l((function(){if(d&&1!==pu({b:1},pu(vu({},"a",{enumerable:!0,get:function(){vu(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol("assign detection"),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach((function(t){e[t]=t})),7!==pu({},t)[n]||Ke(pu({},e)).join("")!==r}))?function(t,e){for(var n=ft(t),r=arguments.length,o=1,i=Ae.f,a=m.f;r>o;)for(var u,c=C(arguments[o++]),s=i?gu(Ke(c),i(c)):Ke(c),f=s.length,l=0;f>l;)u=s[l++],d&&!v(a,c,u)||(n[u]=c[u]);return n}:pu;Ye({target:"Object",stat:!0,arity:2,forced:Object.assign!==yu},{assign:yu});var bu,mu=wt("match"),wu=TypeError,Ou=function(t){if(function(t){var e;return I(t)&&(void 0!==(e=t[mu])?!!e:"RegExp"===P(t))}(t))throw new wu("The method doesn't accept regular expressions");return t},xu=wt("match"),Su=Ct.f,Eu=On("".slice),Tu=Math.min,ju=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[xu]=!1,"/./"[t](e)}catch(t){}}return!1}("startsWith"),Pu=!(ju||(bu=Su(String.prototype,"startsWith"),!bu||bu.writable));Ye({target:"String",proto:!0,forced:!Pu&&!ju},{startsWith:function(t){var e=Je(F(this));Ou(t);var n=me(Tu(arguments.length>1?arguments[1]:void 0,e.length)),r=Je(t);return Eu(e,n,n+r.length)===r}});var Ru=/"/g,Au=E("".replace);function Cu(t){if(!t.doc)throw new Error("shared type isn't attached to a document")}Ye({target:"String",proto:!0,forced:function(t){return l((function(){var e=""[t]('"');return e!==e.toLowerCase()||e.split('"').length>3}))}("anchor")},{anchor:function(t){return e="a",n="name",r=t,o=Je(F(this)),i="<"+e,""!==n&&(i+=" "+n+'="'+Au(Je(r),Ru,"&quot;")+'"'),i+">"+o+"</"+e+">";var e,n,r,o,i}});var ku="__slateYjsStoredPosition_";function Lu(t,e,n){var r=uu(t,e,n.path),i=r.yTarget,a=r.yParent,u=r.textRange;if(i)throw new Error("Slate point points to a non-text element inside sharedRoot");var c=u.start+n.offset;return o.createRelativePositionFromTypeIndex(a,c,c===u.end?-1:0)}function Fu(t,n,r){if(!t.doc)throw new Error("sharedRoot isn't attach to a yDoc");var i=o.createAbsolutePositionFromRelativePosition(r,t.doc);return i&&function(t,n,r){var i=r.type,a=r.index,u=r.assoc;if(!(i instanceof o.XmlText))throw new Error("Absolute position points to a non-XMLText");var c=su(t,n,i),s=e.Node.get(n,c);if(e.Text.isText(s))throw new Error("Absolute position doesn't match slateRoot, cannot descent into text");var f=ca(cu(s,a,{assoc:u}),2),l=f[0],d=f[1],h=s.children[l];return e.Text.isText(h)?{path:sa(sa([],ca(c),!1),[l],!1),offset:d}:null}(t,n,i)}function _u(t,e,n){t.setAttribute(ku+e,o.encodeRelativePosition(n))}function Mu(t,e,n){return Object.fromEntries(Object.entries(t).filter((function(t){var r=ca(t,2)[1];return r.type===e&&(!n||(r.assoc>=0?r.index>=n.start&&r.index<n.end:r.index>n.start&&r.index>=n.end))})))}function Du(t,e,n){var r;void 0===n&&(n="");var i=((r={})[n]=Mu(t,e),r);return Ua(e).forEach((function(e,r){var a=e.insert;a instanceof o.XmlText&&Object.assign(i,Du(t,a,n?"".concat(n,".").concat(r):r.toString()))})),i}function Iu(t,e,n,r){void 0===r&&(r=0);var i=function(t){return Cu(t),Object.fromEntries(Object.entries(t.getAttributes()).filter((function(t){return ca(t,1)[0].startsWith(ku)})).map((function(e){var n=ca(e,2),r=n[0],i=n[1];return[r.slice(ku.length),o.createAbsolutePositionFromRelativePosition(o.decodeRelativePosition(i),t.doc)]})).filter((function(t){return ca(t,2)[1]})))}(t),a={"":Mu(i,e,{start:r,end:r+qa(n)})};return n.forEach((function(t,e){var n=t.insert;n instanceof o.XmlText&&Object.assign(a,Du(i,n,e.toString()))})),a}function zu(t,e,n,r,i,a,u){void 0===i&&(i=0),void 0===a&&(a=0),void 0===u&&(u="");var c=n[u];c&&Object.entries(c).forEach((function(n){var r=ca(n,2),u=r[0],c=r[1];_u(t,u,o.createRelativePositionFromTypeIndex(e,c.index-a+i,c.assoc))})),r.forEach((function(e,r){var i=e.insert;i instanceof o.XmlText&&zu(t,i,n,Ua(i),0,0,u?"".concat(u,".").concat(r):r.toString())}))}function Nu(t,e,n){return{anchor:Lu(t,e,n.anchor),focus:Lu(t,e,n.focus)}}function Wu(t,e,n){var r=Fu(t,e,n.anchor);if(!r)return null;var o=Fu(t,e,n.focus);return o?{anchor:r,focus:o}:null}var Yu={insert_node:function(t,n,r){var o=uu(t,n,r.path),i=o.yParent,a=o.textRange;if(e.Text.isText(r.node))return i.insert(a.start,r.node.text,$a(r.node));i.insertEmbed(a.start,Za(r.node))},remove_node:function(t,e,n){var r=uu(t,e,n.path),o=r.yParent,i=r.textRange;o.delete(i.start,i.end-i.start)},set_node:function(t,e,n){var r=uu(t,e,n.path),o=r.yTarget,i=r.textRange,a=r.yParent;if(o)return Object.entries(n.newProperties).forEach((function(t){var e=ca(t,2),n=e[0],r=e[1];if(null===r)return o.removeAttribute(n);o.setAttribute(n,r)})),Object.entries(n.properties).forEach((function(t){var e=ca(t,1)[0];Object.prototype.hasOwnProperty.call(n.newProperties,e)||o.removeAttribute(e)}));var u=Object.fromEntries(Object.keys(n.properties).map((function(t){return[t,null]}))),c=ia(ia({},u),n.newProperties);a.format(i.start,i.end-i.start,c)},merge_node:function(t,n,r){var o=uu(t,n,r.path),i=uu(o.yParent,o.slateParent,e.Path.previous(r.path.slice(-1)));if(!o.yTarget!=!i.yTarget)throw new Error("Cannot merge y text with y element");if(!i.yTarget||!o.yTarget){var a=o.yParent,u=o.textRange,c=o.slateTarget;if(!c)throw new Error("Expected Slate target node for merge op.");var s=e.Node.get(n,e.Path.previous(r.path));if(!e.Text.isText(s))throw new Error("Path points to Y.Text but not a Slate text node.");var f=$a(c),l=$a(s),d=Object.keys(f).reduce((function(t,e){var n;return e in l?t:ia(ia({},t),((n={})[e]=null,n))}),{});return a.format(u.start,u.end-u.start,ia(ia({},d),l))}var h=i.yTarget.length,p=Ua(o.yTarget),v=du(p),g=Iu(t,o.yTarget,p,h),y=sa([{retain:h}],ca(v),!1);i.yTarget.applyDelta(y,{sanitize:!1}),o.yParent.delete(o.textRange.start,o.textRange.end-o.textRange.start),zu(t,i.yTarget,g,v,h)},move_node:function(t,n,r){var o=e.Path.parent(r.newPath),i=r.newPath[r.newPath.length-1],a=e.Node.get(n,o);if(e.Text.isText(a))throw new Error("Cannot move slate node into text element");var u=sa(sa([],ca(o),!1),[Math.min(i,a.children.length)],!1),c=uu(t,n,r.path),s=uu(t,n,u),f=du(c.targetDelta),l=Iu(t,c.yParent,c.targetDelta);c.yParent.delete(c.textRange.start,c.textRange.end-c.textRange.start);var d=qa(Ua(s.yParent)),h=Math.min(s.textRange.start,d),p=sa([{retain:h}],ca(f),!1);s.yParent.applyDelta(p,{sanitize:!1}),zu(t,s.yParent,l,f,h,c.textRange.start)},split_node:function(t,n,r){var i=uu(t,n,r.path);if(!i.slateTarget)throw new Error("Y target without corresponding slate node");if(!i.yTarget){if(!e.Text.isText(i.slateTarget))throw new Error("Mismatch node type between y target and slate node");var a={};return i.targetDelta.forEach((function(t){t.attributes&&Object.keys(t.attributes).forEach((function(t){a[t]=null}))})),i.yParent.format(i.textRange.start,i.textRange.end-i.textRange.start,ia(ia({},a),r.properties))}if(e.Text.isText(i.slateTarget))throw new Error("Mismatch node type between y target and slate node");var u=uu(i.yTarget,i.slateTarget,[r.position]),c=i.slateTarget.children.slice(0,r.position).reduce((function(t,e){return t+au(e)}),0),s=i.slateTarget.children.reduce((function(t,e){return t+au(e)}),0),f=Ha(Ua(i.yTarget),c,s-c),l=du(f),d=Iu(t,i.yTarget,f,c),h=new o.XmlText;h.applyDelta(l,{sanitize:!1}),Object.entries(r.properties).forEach((function(t){var e=ca(t,2),n=e[0],r=e[1];h.setAttribute(n,r)})),i.yTarget.delete(u.textRange.start,i.yTarget.length-u.textRange.start),i.yParent.insertEmbed(i.textRange.end,h),zu(t,h,d,l,0,c)}};var Xu=ia(ia(ia({},{insert_text:function(t,n,r){var o=uu(t,n,r.path),i=o.yParent,a=o.textRange,u=e.Node.get(n,r.path);if(!e.Text.isText(u))throw new Error("Cannot insert text into non-text node");i.insert(a.start+r.offset,r.text,$a(u))},remove_text:function(t,e,n){var r=uu(t,e,n.path),o=r.yParent,i=r.textRange;o.delete(i.start+n.offset,n.text.length)}}),Yu),{set_selection:function(){}});var Gu=Symbol("slate-yjs-operation"),Bu=Symbol("slate-yjs-position-storage"),Uu=new WeakMap,Vu=new WeakMap,qu=new WeakSet,Hu={isYjsEditor:function(t){return e.Editor.isEditor(t)&&t.sharedRoot instanceof o.XmlText&&"localOrigin"in t&&"positionStorageOrigin"in t&&"function"==typeof t.applyRemoteEvents&&"function"==typeof t.storeLocalChange&&"function"==typeof t.flushLocalChanges&&"function"==typeof t.isLocalOrigin&&"function"==typeof t.connect&&"function"==typeof t.disconnect},localChanges:function(t){var e;return null!==(e=Vu.get(t))&&void 0!==e?e:[]},applyRemoteEvents:function(t,e,n){t.applyRemoteEvents(e,n)},storeLocalChange:function(t,e){t.storeLocalChange(e)},flushLocalChanges:function(t){t.flushLocalChanges()},connected:function(t){return qu.has(t)},connect:function(t){t.connect()},disconnect:function(t){t.disconnect()},isLocal:function(t){return t.isLocalOrigin(Hu.origin(t))},origin:function(t){var e=Uu.get(t);return void 0!==e?e:t.localOrigin},withOrigin:function(t,e,n){var r=Hu.origin(t);Uu.set(t,e),n(),Uu.set(t,r)},storePosition:function(t,e,n){var r=t.sharedRoot,o=t.positionStorageOrigin;Cu(r);var i=Lu(r,t,n);r.doc.transact((function(){_u(r,e,i)}),o)},removeStoredPosition:function(t,e){var n=t.sharedRoot,r=t.positionStorageOrigin;Cu(n),n.doc.transact((function(){!function(t,e){t.removeAttribute(ku+e)}(n,e)}),r)},position:function(t,e){var n=function(t,e){var n=t.getAttribute(ku+e);return n?o.decodeRelativePosition(n):null}(t.sharedRoot,e);if(n)return Fu(t.sharedRoot,t,n)},storedPositionsRelative:function(t){return e=t.sharedRoot,Object.fromEntries(Object.entries(e.getAttributes()).filter((function(t){return ca(t,1)[0].startsWith(ku)})).map((function(t){var e=ca(t,2),n=e[0],r=e[1];return[n.slice(ku.length),o.createRelativePositionFromJSON(r)]})));var e}};var $u=wt("species"),Ju=Jo.fastKey,Ku=ce.set,Qu=ce.getterFor,Zu={getConstructor:function(t,e,n,r){var o=t((function(t,o){fi(t,i),Ku(t,{type:e,index:sn(null),first:null,last:null,size:0}),d||(t.size=0),k(o)||ci(o,t[r],{that:t,AS_ENTRIES:n})})),i=o.prototype,a=Qu(e),u=function(t,e,n){var r,o,i=a(t),u=c(t,e);return u?u.value=n:(i.last=u={index:o=Ju(e,!0),key:e,value:n,previous:r=i.last,next:null,removed:!1},i.first||(i.first=u),r&&(r.next=u),d?i.size++:t.size++,"F"!==o&&(i.index[o]=u)),t},c=function(t,e){var n,r=a(t),o=Ju(e);if("F"!==o)return r.index[o];for(n=r.first;n;n=n.next)if(n.key===e)return n};return Vo(i,{clear:function(){for(var t=a(this),e=t.first;e;)e.removed=!0,e.previous&&(e.previous=e.previous.next=null),e=e.next;t.first=t.last=null,t.index=sn(null),d?t.size=0:this.size=0},delete:function(t){var e=this,n=a(e),r=c(e,t);if(r){var o=r.next,i=r.previous;delete n.index[r.index],r.removed=!0,i&&(i.next=o),o&&(o.previous=i),n.first===r&&(n.first=o),n.last===r&&(n.last=i),d?n.size--:e.size--}return!!r},forEach:function(t){for(var e,n=a(this),r=Sn(t,arguments.length>1?arguments[1]:void 0);e=e?e.next:n.first;)for(r(e.value,e.key,this);e&&e.removed;)e=e.previous},has:function(t){return!!c(this,t)}}),Vo(i,n?{get:function(t){var e=c(this,t);return e&&e.value},set:function(t,e){return u(this,0===t?0:t,e)}}:{add:function(t){return u(this,t=0===t?0:t,t)}}),d&&pn(i,"size",{configurable:!0,get:function(){return a(this).size}}),o},setStrong:function(t,e,n){var r=e+" Iterator",o=Qu(e),i=Qu(r);Ro(t,e,(function(t,e){Ku(this,{type:r,target:t,state:o(t),kind:e,last:null})}),(function(){for(var t=i(this),e=t.kind,n=t.last;n&&n.removed;)n=n.previous;return t.target&&(t.last=n=n?n.next:t.state.first)?Ao("keys"===e?n.key:"values"===e?n.value:[n.key,n.value],!1):(t.target=null,Ao(void 0,!0))}),n?"entries":"values",!n,!0),function(t){var e=z(t);d&&e&&!e[$u]&&pn(e,$u,{configurable:!0,get:function(){return this}})}(e)}};gi("Set",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),Zu);var tc=new WeakMap,ec=Symbol("slate-yjs-history-without-saving"),nc={isYHistoryEditor:function(t){return Hu.isYjsEditor(t)&&t.undoManager instanceof o.UndoManager&&"function"==typeof t.undo&&"function"==typeof t.redo&&"withoutSavingOrigin"in t},canUndo:function(t){return t.undoManager.undoStack.length>0},canRedo:function(t){return t.undoManager.redoStack.length>0},isSaving:function(t){return t.undoManager.trackedOrigins.has(Hu.origin(t))},withoutSaving:function(t,e){Hu.withOrigin(t,t.withoutSavingOrigin,e)}};var rc=new WeakMap,oc={isCursorEditor:function(t){return Hu.isYjsEditor(t)&&t.awareness&&"string"==typeof t.cursorDataField&&"string"==typeof t.selectionStateField&&"function"==typeof t.sendCursorPosition&&"function"==typeof t.sendCursorData},sendCursorPosition:function(t,e){void 0===e&&(e=t.selection),t.sendCursorPosition(e)},sendCursorData:function(t,e){t.sendCursorData(e)},on:function(t,e,n){var r;if("change"===e){var o=null!==(r=rc.get(t))&&void 0!==r?r:new Set;o.add(n),t&&rc.set(t,o)}},off:function(t,e,n){if("change"===e){var r=rc.get(t);r&&r.delete(n)}},cursorState:function(t,e){var n;if(e===t.awareness.clientID||!Hu.connected(t))return null;var r=t.awareness.getStates().get(e);return r?{relativeSelection:null!==(n=r[t.selectionStateField])&&void 0!==n?n:null,data:r[t.cursorDataField],clientId:e}:null},cursorStates:function(t){return Hu.connected(t)?Object.fromEntries(Array.from(t.awareness.getStates().entries(),(function(e){var n=ca(e,2),r=n[0],o=n[1];return r!==t.awareness.clientID&&o?[r,{relativeSelection:o[t.selectionStateField],data:o[t.cursorDataField]}]:null})).filter(Array.isArray)):{}}};t.CursorEditor=oc,t.YHistoryEditor=nc,t.YjsEditor=Hu,t.relativePositionToSlatePoint=Fu,t.relativeRangeToSlateRange=Wu,t.slateNodesToInsertDelta=Qa,t.slatePointToRelativePosition=Lu,t.slateRangeToRelativeRange=Nu,t.withCursors=function(t,e){return void 0===e&&(e={}),function(n){var r=e.cursorStateField,i=void 0===r?"selection":r,a=e.cursorDataField,u=void 0===a?"data":a,c=e.autoSend,s=void 0===c||c,f=e.data,l=n;l.awareness=t,l.cursorDataField=u,l.selectionStateField=i,l.sendCursorData=function(t){l.awareness.setLocalStateField(l.cursorDataField,t)},l.sendCursorPosition=function(t){var e=l.awareness.getLocalState(),n=null==e?void 0:e[i];if(t){var r=Nu(l.sharedRoot,l,t),a=r.anchor,u=r.focus;n&&o.compareRelativePositions(a,n)&&o.compareRelativePositions(u,n)||l.awareness.setLocalStateField(l.selectionStateField,{anchor:a,focus:u})}else n&&l.awareness.setLocalStateField(l.selectionStateField,null)};var d=function(t){var e=rc.get(l);if(e){var n=l.awareness.clientID,r={added:t.added.filter((function(t){return t!==n})),removed:t.removed.filter((function(t){return t!==n})),updated:t.updated.filter((function(t){return t!==n}))};(r.added.length>0||r.removed.length>0||r.updated.length>0)&&e.forEach((function(t){return t(r)}))}},h=l.connect,p=l.disconnect;return l.connect=function(){if(h(),l.awareness.on("change",d),d({removed:[],added:Array.from(l.awareness.getStates().keys()),updated:[]}),s){f&&oc.sendCursorData(l,f);var t=l.onChange;l.onChange=function(){t(),Hu.connected(l)&&oc.sendCursorPosition(l)}}},l.disconnect=function(){l.awareness.off("change",d),d({removed:Array.from(l.awareness.getStates().keys()),added:[],updated:[]}),p()},l}},t.withYHistory=function(t){return void 0===t&&(t={}),function(n){var r=n,i=t.withoutSavingOrigin,a=void 0===i?ec:i,u=t.trackedOrigins,c=void 0===u?new Set([r.localOrigin]):u,s=aa(t,["withoutSavingOrigin","trackedOrigins"]),f=new o.UndoManager(r.sharedRoot,ia({trackedOrigins:c},s));r.undoManager=f,r.withoutSavingOrigin=a;var l=r.onChange,d=r.isLocalOrigin;r.onChange=function(){l(),tc.set(r,r.selection&&Nu(r.sharedRoot,r,r.selection))},r.isLocalOrigin=function(t){return t===r.withoutSavingOrigin||d(t)};var h=function(t){var e=t.stackItem;e.meta.set("selection",r.selection&&Nu(r.sharedRoot,r,r.selection)),e.meta.set("selectionBefore",tc.get(r))},p=function(t){t.stackItem.meta.set("selection",r.selection&&Nu(r.sharedRoot,r,r.selection))},v=function(t){var n=t.stackItem,o="undo"===t.type?r.undoManager.redoStack:r.undoManager.undoStack,i=o[o.length-1];i&&(i.meta.set("selection",n.meta.get("selectionBefore")),i.meta.set("selectionBefore",n.meta.get("selection")));var a=n.meta.get("selectionBefore");if(a){var u=Wu(r.sharedRoot,r,a);u&&e.Transforms.select(r,u)}},g=r.connect,y=r.disconnect;return r.connect=function(){g(),r.undoManager.on("stack-item-added",h),r.undoManager.on("stack-item-popped",v),r.undoManager.on("stack-item-updated",p)},r.disconnect=function(){r.undoManager.off("stack-item-added",h),r.undoManager.off("stack-item-popped",v),r.undoManager.off("stack-item-updated",p),y()},r.undo=function(){Hu.connected(r)&&(Hu.flushLocalChanges(r),r.undoManager.undo())},r.redo=function(){Hu.connected(r)&&(Hu.flushLocalChanges(r),r.undoManager.redo())},r}},t.withYjs=function(t,n){return void 0===n&&(n={}),function(r){var o,i,a=r;a.sharedRoot=t,a.localOrigin=null!==(o=n.localOrigin)&&void 0!==o?o:Gu,a.positionStorageOrigin=null!==(i=n.positionStorageOrigin)&&void 0!==i?i:Bu,a.applyRemoteEvents=function(t,n){Hu.flushLocalChanges(a),e.Editor.withoutNormalizing(a,(function(){Hu.withOrigin(a,n,(function(){lu(a.sharedRoot,a,t)}))}))},a.isLocalOrigin=function(t){return t===a.localOrigin};var u=function(t,e){a.isLocalOrigin(e.origin)||Hu.applyRemoteEvents(a,t,e.origin)},c=null;n.autoConnect&&(c=setTimeout((function(){c=null,Hu.connect(a)}))),a.connect=function(){if(Hu.connected(a))throw new Error("already connected");a.sharedRoot.observeDeep(u);var t=Ja(a.sharedRoot);a.children=t.children,qu.add(a),e.Editor.normalize(r,{force:!0}),r.operations.length||r.onChange()},a.disconnect=function(){c&&clearTimeout(c),Hu.flushLocalChanges(a),a.sharedRoot.unobserveDeep(u),qu.delete(a)},a.storeLocalChange=function(t){Vu.set(a,sa(sa([],ca(Hu.localChanges(a)),!1),[{op:t,doc:r.children,origin:Hu.origin(a)}],!1))},a.flushLocalChanges=function(){Cu(a.sharedRoot);var t=Hu.localChanges(a);Vu.delete(a);var e=[];t.forEach((function(t){var n=e[e.length-1];if(n&&n[0].origin===t.origin)return n.push(t);e.push([t])})),e.forEach((function(t){Cu(a.sharedRoot),a.sharedRoot.doc.transact((function(){t.forEach((function(t){Cu(a.sharedRoot),function(t,e,n){var r=Xu[n.type];if(!r)throw new Error("Unknown operation: ".concat(n.type));r(t,e,n)}(a.sharedRoot,{children:t.doc},t.op)}))}),t[0].origin)}))};var s=a.apply,f=a.onChange;return a.apply=function(t){Hu.connected(a)&&Hu.isLocal(a)&&Hu.storeLocalChange(a,t),s(t)},a.onChange=function(){Hu.connected(a)&&Hu.flushLocalChanges(a),f()},a}},t.yTextToSlateElement=Ja,Object.defineProperty(t,"__esModule",{value:!0})}));
2
+ //# sourceMappingURL=index.js.map