@wangeditor-next/yjs-for-react 0.1.0 → 0.1.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +794 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +812 -10
- package/dist/index.js.map +1 -1
- package/package.json +25 -13
- package/CHANGELOG.md +0 -0
- package/rollup.config.js +0 -28
- package/src/hooks/use-editor-static.tsx +0 -18
- package/src/hooks/useRemoteCursorEditor.ts +0 -14
- package/src/hooks/useRemoteCursorOverlayPositions.tsx +0 -131
- package/src/hooks/useRemoteCursorStateStore.ts +0 -85
- package/src/hooks/useRemoteCursorStates.ts +0 -22
- package/src/hooks/utils.ts +0 -54
- package/src/index.ts +0 -11
- package/src/types.ts +0 -1
- package/src/utils/getCursorRange.ts +0 -34
- package/src/utils/getOverlayPosition.ts +0 -107
- package/src/utils/react-editor-to-dom-range-safe.ts +0 -10
- package/tsconfig.json +0 -8
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,97 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e, { createContext, useContext, useReducer, useRef, useEffect, useCallback, useState, useLayoutEffect, useMemo } from 'react';
|
|
2
|
+
import { CursorEditor, relativeRangeToSlateRange } from '@wangeditor-next/yjs';
|
|
3
|
+
import { Range, Editor, Text, Path } from 'slate';
|
|
4
|
+
import { DomEditor } from '@wangeditor-next/editor';
|
|
5
|
+
|
|
6
|
+
var EditorContext = createContext(null);
|
|
7
|
+
var useEditorStatic = function () {
|
|
8
|
+
var editor = useContext(EditorContext);
|
|
9
|
+
if (!editor) {
|
|
10
|
+
// throw new Error(
|
|
11
|
+
// `The \`useEditorStatic\` hook must be used inside the <EditorContext> component's context.`
|
|
12
|
+
// )
|
|
13
|
+
console.warn("The `useEditorStatic` hook must be used inside the <EditorContext> component's context.");
|
|
14
|
+
}
|
|
15
|
+
return editor;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/******************************************************************************
|
|
19
|
+
Copyright (c) Microsoft Corporation.
|
|
20
|
+
|
|
21
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
22
|
+
purpose with or without fee is hereby granted.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
25
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
26
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
27
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
28
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
29
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
30
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
31
|
+
***************************************************************************** */
|
|
32
|
+
|
|
33
|
+
var __assign = function() {
|
|
34
|
+
__assign = Object.assign || function __assign(t) {
|
|
35
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
36
|
+
s = arguments[i];
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
return __assign.apply(this, arguments);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function __rest(s, e) {
|
|
45
|
+
var t = {};
|
|
46
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
|
+
t[p] = s[p];
|
|
48
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
49
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
50
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
51
|
+
t[p[i]] = s[p[i]];
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function __values(o) {
|
|
57
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
58
|
+
if (m) return m.call(o);
|
|
59
|
+
if (o && typeof o.length === "number") return {
|
|
60
|
+
next: function () {
|
|
61
|
+
if (o && i >= o.length) o = void 0;
|
|
62
|
+
return { value: o && o[i++], done: !o };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function __read(o, n) {
|
|
69
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
70
|
+
if (!m) return o;
|
|
71
|
+
var i = m.call(o), r, ar = [], e;
|
|
72
|
+
try {
|
|
73
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
74
|
+
}
|
|
75
|
+
catch (error) { e = { error: error }; }
|
|
76
|
+
finally {
|
|
77
|
+
try {
|
|
78
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
79
|
+
}
|
|
80
|
+
finally { if (e) throw e.error; }
|
|
81
|
+
}
|
|
82
|
+
return ar;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
86
|
+
var e = new Error(message);
|
|
87
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
function createCommonjsModule(fn) {
|
|
91
|
+
var module = { exports: {} };
|
|
92
|
+
return fn(module, module.exports), module.exports;
|
|
93
|
+
}
|
|
94
|
+
|
|
2
95
|
/**
|
|
3
96
|
* @license React
|
|
4
97
|
* use-sync-external-store-shim.production.min.js
|
|
@@ -7,7 +100,10 @@ import t,{createContext as e,useContext as r,useReducer as n,useRef as o,useEffe
|
|
|
7
100
|
*
|
|
8
101
|
* This source code is licensed under the MIT license found in the
|
|
9
102
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/
|
|
103
|
+
*/
|
|
104
|
+
function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c});},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c});})},[a]);p(d);return d}
|
|
105
|
+
function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f){return !0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;
|
|
106
|
+
|
|
11
107
|
/**
|
|
12
108
|
* @license React
|
|
13
109
|
* use-sync-external-store-shim.development.js
|
|
@@ -17,7 +113,243 @@ import t,{createContext as e,useContext as r,useReducer as n,useRef as o,useEffe
|
|
|
17
113
|
* This source code is licensed under the MIT license found in the
|
|
18
114
|
* LICENSE file in the root directory of this source tree.
|
|
19
115
|
*/
|
|
20
|
-
|
|
116
|
+
|
|
117
|
+
var useSyncExternalStoreShim_development = createCommonjsModule(function (module, exports) {
|
|
118
|
+
|
|
119
|
+
{
|
|
120
|
+
(function() {
|
|
121
|
+
|
|
122
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
123
|
+
if (
|
|
124
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
125
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
126
|
+
'function'
|
|
127
|
+
) {
|
|
128
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
129
|
+
}
|
|
130
|
+
var React = e;
|
|
131
|
+
|
|
132
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
133
|
+
|
|
134
|
+
function error(format) {
|
|
135
|
+
{
|
|
136
|
+
{
|
|
137
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
138
|
+
args[_key2 - 1] = arguments[_key2];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
printWarning('error', format, args);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function printWarning(level, format, args) {
|
|
147
|
+
// When changing this logic, you might want to also
|
|
148
|
+
// update consoleWithStackDev.www.js as well.
|
|
149
|
+
{
|
|
150
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
151
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
152
|
+
|
|
153
|
+
if (stack !== '') {
|
|
154
|
+
format += '%s';
|
|
155
|
+
args = args.concat([stack]);
|
|
156
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
var argsWithFormat = args.map(function (item) {
|
|
160
|
+
return String(item);
|
|
161
|
+
}); // Careful: RN currently depends on this prefix
|
|
162
|
+
|
|
163
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
164
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
165
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
166
|
+
|
|
167
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
173
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
174
|
+
*/
|
|
175
|
+
function is(x, y) {
|
|
176
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
177
|
+
;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
181
|
+
|
|
182
|
+
// dispatch for CommonJS interop named imports.
|
|
183
|
+
|
|
184
|
+
var useState = React.useState,
|
|
185
|
+
useEffect = React.useEffect,
|
|
186
|
+
useLayoutEffect = React.useLayoutEffect,
|
|
187
|
+
useDebugValue = React.useDebugValue;
|
|
188
|
+
var didWarnOld18Alpha = false;
|
|
189
|
+
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
|
|
190
|
+
// because of a very particular set of implementation details and assumptions
|
|
191
|
+
// -- change any one of them and it will break. The most important assumption
|
|
192
|
+
// is that updates are always synchronous, because concurrent rendering is
|
|
193
|
+
// only available in versions of React that also have a built-in
|
|
194
|
+
// useSyncExternalStore API. And we only use this shim when the built-in API
|
|
195
|
+
// does not exist.
|
|
196
|
+
//
|
|
197
|
+
// Do not assume that the clever hacks used by this hook also work in general.
|
|
198
|
+
// The point of this shim is to replace the need for hacks by other libraries.
|
|
199
|
+
|
|
200
|
+
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
201
|
+
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
202
|
+
// will need to track that themselves and return the correct value
|
|
203
|
+
// from `getSnapshot`.
|
|
204
|
+
getServerSnapshot) {
|
|
205
|
+
{
|
|
206
|
+
if (!didWarnOld18Alpha) {
|
|
207
|
+
if (React.startTransition !== undefined) {
|
|
208
|
+
didWarnOld18Alpha = true;
|
|
209
|
+
|
|
210
|
+
error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} // Read the current snapshot from the store on every render. Again, this
|
|
214
|
+
// breaks the rules of React, and only works here because of specific
|
|
215
|
+
// implementation details, most importantly that updates are
|
|
216
|
+
// always synchronous.
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
var value = getSnapshot();
|
|
220
|
+
|
|
221
|
+
{
|
|
222
|
+
if (!didWarnUncachedGetSnapshot) {
|
|
223
|
+
var cachedValue = getSnapshot();
|
|
224
|
+
|
|
225
|
+
if (!objectIs(value, cachedValue)) {
|
|
226
|
+
error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
227
|
+
|
|
228
|
+
didWarnUncachedGetSnapshot = true;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
} // Because updates are synchronous, we don't queue them. Instead we force a
|
|
232
|
+
// re-render whenever the subscribed state changes by updating an some
|
|
233
|
+
// arbitrary useState hook. Then, during render, we call getSnapshot to read
|
|
234
|
+
// the current value.
|
|
235
|
+
//
|
|
236
|
+
// Because we don't actually use the state returned by the useState hook, we
|
|
237
|
+
// can save a bit of memory by storing other stuff in that slot.
|
|
238
|
+
//
|
|
239
|
+
// To implement the early bailout, we need to track some things on a mutable
|
|
240
|
+
// object. Usually, we would put that in a useRef hook, but we can stash it in
|
|
241
|
+
// our useState hook instead.
|
|
242
|
+
//
|
|
243
|
+
// To force a re-render, we call forceUpdate({inst}). That works because the
|
|
244
|
+
// new object always fails an equality check.
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
var _useState = useState({
|
|
248
|
+
inst: {
|
|
249
|
+
value: value,
|
|
250
|
+
getSnapshot: getSnapshot
|
|
251
|
+
}
|
|
252
|
+
}),
|
|
253
|
+
inst = _useState[0].inst,
|
|
254
|
+
forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
|
|
255
|
+
// in the layout phase so we can access it during the tearing check that
|
|
256
|
+
// happens on subscribe.
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
useLayoutEffect(function () {
|
|
260
|
+
inst.value = value;
|
|
261
|
+
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
|
|
262
|
+
// commit phase if there was an interleaved mutation. In concurrent mode
|
|
263
|
+
// this can happen all the time, but even in synchronous mode, an earlier
|
|
264
|
+
// effect may have mutated the store.
|
|
265
|
+
|
|
266
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
267
|
+
// Force a re-render.
|
|
268
|
+
forceUpdate({
|
|
269
|
+
inst: inst
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}, [subscribe, value, getSnapshot]);
|
|
273
|
+
useEffect(function () {
|
|
274
|
+
// Check for changes right before subscribing. Subsequent changes will be
|
|
275
|
+
// detected in the subscription handler.
|
|
276
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
277
|
+
// Force a re-render.
|
|
278
|
+
forceUpdate({
|
|
279
|
+
inst: inst
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
var handleStoreChange = function () {
|
|
284
|
+
// TODO: Because there is no cross-renderer API for batching updates, it's
|
|
285
|
+
// up to the consumer of this library to wrap their subscription event
|
|
286
|
+
// with unstable_batchedUpdates. Should we try to detect when this isn't
|
|
287
|
+
// the case and print a warning in development?
|
|
288
|
+
// The store changed. Check if the snapshot changed since the last time we
|
|
289
|
+
// read from the store.
|
|
290
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
291
|
+
// Force a re-render.
|
|
292
|
+
forceUpdate({
|
|
293
|
+
inst: inst
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}; // Subscribe to the store and return a clean-up function.
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
return subscribe(handleStoreChange);
|
|
300
|
+
}, [subscribe]);
|
|
301
|
+
useDebugValue(value);
|
|
302
|
+
return value;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function checkIfSnapshotChanged(inst) {
|
|
306
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
307
|
+
var prevValue = inst.value;
|
|
308
|
+
|
|
309
|
+
try {
|
|
310
|
+
var nextValue = latestGetSnapshot();
|
|
311
|
+
return !objectIs(prevValue, nextValue);
|
|
312
|
+
} catch (error) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
|
|
318
|
+
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
319
|
+
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
320
|
+
// will need to track that themselves and return the correct value
|
|
321
|
+
// from `getSnapshot`.
|
|
322
|
+
return getSnapshot();
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
|
|
326
|
+
|
|
327
|
+
var isServerEnvironment = !canUseDOM;
|
|
328
|
+
|
|
329
|
+
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
330
|
+
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
|
|
331
|
+
|
|
332
|
+
exports.useSyncExternalStore = useSyncExternalStore$2;
|
|
333
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
334
|
+
if (
|
|
335
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
336
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
337
|
+
'function'
|
|
338
|
+
) {
|
|
339
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
})();
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
var shim = createCommonjsModule(function (module) {
|
|
347
|
+
|
|
348
|
+
{
|
|
349
|
+
module.exports = useSyncExternalStoreShim_development;
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
|
|
21
353
|
/**
|
|
22
354
|
* @license React
|
|
23
355
|
* use-sync-external-store-shim/with-selector.production.min.js
|
|
@@ -26,7 +358,9 @@ x((function(t,e){}));var C=x((function(t){t.exports=k}));
|
|
|
26
358
|
*
|
|
27
359
|
* This source code is licensed under the MIT license found in the
|
|
28
360
|
* LICENSE file in the root directory of this source tree.
|
|
29
|
-
*/
|
|
361
|
+
*/
|
|
362
|
+
shim.useSyncExternalStore;e.useRef;e.useEffect;e.useMemo;e.useDebugValue;
|
|
363
|
+
|
|
30
364
|
/**
|
|
31
365
|
* @license React
|
|
32
366
|
* use-sync-external-store-shim/with-selector.development.js
|
|
@@ -36,5 +370,459 @@ x((function(t,e){}));var C=x((function(t){t.exports=k}));
|
|
|
36
370
|
* This source code is licensed under the MIT license found in the
|
|
37
371
|
* LICENSE file in the root directory of this source tree.
|
|
38
372
|
*/
|
|
39
|
-
x((function(t,e){}));var W,N,G=x((function(t){t.exports=_})),X=function(t){return t&&t.Math==Math&&t},V=X("object"==typeof globalThis&&globalThis)||X("object"==typeof window&&window)||X("object"==typeof self&&self)||X("object"==typeof O&&O)||function(){return this}()||Function("return this")(),B=Function.prototype,U=B.bind,Y=B.call,q=U&&U.bind(Y),H=U?function(t){return t&&q(Y,t)}:function(t){return t&&function(){return Y.apply(t,arguments)}},K=function(t){try{return!!t()}catch(t){return!0}},J=H({}.toString),$=H("".slice),Q=function(t){return $(J(t),8,-1)},Z=V.Object,tt=H("".split),et=K((function(){return!Z("z").propertyIsEnumerable(0)}))?function(t){return"String"==Q(t)?tt(t,""):Z(t)}:Z,rt=V.TypeError,nt=function(t){if(null==t)throw rt("Can't call method on "+t);return t},ot=function(t){return et(nt(t))},it=Object.defineProperty,at=function(t,e){try{it(V,t,{value:e,configurable:!0,writable:!0})}catch(r){V[t]=e}return e},ut="__core-js_shared__",ct=V[ut]||at(ut,{}),ft=x((function(t){(t.exports=function(t,e){return ct[t]||(ct[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.19.3",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),st=V.Object,lt=function(t){return st(nt(t))},vt=H({}.hasOwnProperty),dt=Object.hasOwn||function(t,e){return vt(lt(t),e)},ht=0,pt=Math.random(),yt=H(1..toString),gt=function(t){return"Symbol("+(void 0===t?"":t)+")_"+yt(++ht+pt,36)},bt=function(t){return"function"==typeof t},mt=function(t,e){return arguments.length<2?(r=V[t],bt(r)?r:void 0):V[t]&&V[t][e];var r},wt=mt("navigator","userAgent")||"",Ot=V.process,xt=V.Deno,St=Ot&&Ot.versions||xt&&xt.version,Et=St&&St.v8;Et&&(N=(W=Et.split("."))[0]>0&&W[0]<4?1:+(W[0]+W[1])),!N&&wt&&(!(W=wt.match(/Edge\/(\d+)/))||W[1]>=74)&&(W=wt.match(/Chrome\/(\d+)/))&&(N=+W[1]);var jt,Tt=N,Pt=!!Object.getOwnPropertySymbols&&!K((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Tt&&Tt<41})),Rt=Pt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,At=ft("wks"),kt=V.Symbol,Ct=kt&&kt.for,Lt=Rt?kt:kt&&kt.withoutSetter||gt,zt=function(t){if(!dt(At,t)||!Pt&&"string"!=typeof At[t]){var e="Symbol."+t;Pt&&dt(kt,t)?At[t]=kt[t]:At[t]=Rt&&Ct?Ct(e):Lt(e)}return At[t]},It=function(t){return"object"==typeof t?null!==t:bt(t)},Mt=V.String,Dt=V.TypeError,Ft=function(t){if(It(t))return t;throw Dt(Mt(t)+" is not an object")},_t=!K((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),Wt=V.document,Nt=It(Wt)&&It(Wt.createElement),Gt=function(t){return Nt?Wt.createElement(t):{}},Xt=!_t&&!K((function(){return 7!=Object.defineProperty(Gt("div"),"a",{get:function(){return 7}}).a})),Vt=Function.prototype.call,Bt=Vt.bind?Vt.bind(Vt):function(){return Vt.apply(Vt,arguments)},Ut=H({}.isPrototypeOf),Yt=V.Object,qt=Rt?function(t){return"symbol"==typeof t}:function(t){var e=mt("Symbol");return bt(e)&&Ut(e.prototype,Yt(t))},Ht=V.String,Kt=function(t){try{return Ht(t)}catch(t){return"Object"}},Jt=V.TypeError,$t=function(t){if(bt(t))return t;throw Jt(Kt(t)+" is not a function")},Qt=function(t,e){var r=t[e];return null==r?void 0:$t(r)},Zt=V.TypeError,te=V.TypeError,ee=zt("toPrimitive"),re=function(t,e){if(!It(t)||qt(t))return t;var r,n=Qt(t,ee);if(n){if(void 0===e&&(e="default"),r=Bt(n,t,e),!It(r)||qt(r))return r;throw te("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(t,e){var r,n;if("string"===e&&bt(r=t.toString)&&!It(n=Bt(r,t)))return n;if(bt(r=t.valueOf)&&!It(n=Bt(r,t)))return n;if("string"!==e&&bt(r=t.toString)&&!It(n=Bt(r,t)))return n;throw Zt("Can't convert object to primitive value")}(t,e)},ne=function(t){var e=re(t,"string");return qt(e)?e:e+""},oe=V.TypeError,ie=Object.defineProperty,ae={f:_t?ie:function(t,e,r){if(Ft(t),e=ne(e),Ft(r),Xt)try{return ie(t,e,r)}catch(t){}if("get"in r||"set"in r)throw oe("Accessors not supported");return"value"in r&&(t[e]=r.value),t}},ue=Math.ceil,ce=Math.floor,fe=function(t){var e=+t;return e!=e||0===e?0:(e>0?ce:ue)(e)},se=Math.max,le=Math.min,ve=function(t,e){var r=fe(t);return r<0?se(r+e,0):le(r,e)},de=Math.min,he=function(t){return(e=t.length)>0?de(fe(e),9007199254740991):0;var e},pe=function(t){return function(e,r,n){var o,i=ot(e),a=he(i),u=ve(n,a);if(t&&r!=r){for(;a>u;)if((o=i[u++])!=o)return!0}else for(;a>u;u++)if((t||u in i)&&i[u]===r)return t||u||0;return!t&&-1}},ye={includes:pe(!0),indexOf:pe(!1)},ge={},be=ye.indexOf,me=H([].push),we=function(t,e){var r,n=ot(t),o=0,i=[];for(r in n)!dt(ge,r)&&dt(n,r)&&me(i,r);for(;e.length>o;)dt(n,r=e[o++])&&(~be(i,r)||me(i,r));return i},Oe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],xe=Object.keys||function(t){return we(t,Oe)},Se=_t?Object.defineProperties:function(t,e){Ft(t);for(var r,n=ot(e),o=xe(e),i=o.length,a=0;i>a;)ae.f(t,r=o[a++],n[r]);return t},Ee=mt("document","documentElement"),je=ft("keys"),Te=function(t){return je[t]||(je[t]=gt(t))},Pe="prototype",Re="script",Ae=Te("IE_PROTO"),ke=function(){},Ce=function(t){return"<"+Re+">"+t+"</"+Re+">"},Le=function(t){t.write(Ce("")),t.close();var e=t.parentWindow.Object;return t=null,e},ze=function(){try{jt=new ActiveXObject("htmlfile")}catch(t){}var t,e,r;ze="undefined"!=typeof document?document.domain&&jt?Le(jt):(e=Gt("iframe"),r="java"+Re+":",e.style.display="none",Ee.appendChild(e),e.src=String(r),(t=e.contentWindow.document).open(),t.write(Ce("document.F=Object")),t.close(),t.F):Le(jt);for(var n=Oe.length;n--;)delete ze[Pe][Oe[n]];return ze()};ge[Ae]=!0;var Ie=Object.create||function(t,e){var r;return null!==t?(ke[Pe]=Ft(t),r=new ke,ke[Pe]=null,r[Ae]=t):r=ze(),void 0===e?r:Se(r,e)},Me=zt("unscopables"),De=Array.prototype;null==De[Me]&&ae.f(De,Me,{configurable:!0,value:Ie(null)});var Fe=function(t){De[Me][t]=!0},_e={},We=H(Function.toString);bt(ct.inspectSource)||(ct.inspectSource=function(t){return We(t)});var Ne,Ge,Xe,Ve=ct.inspectSource,Be=V.WeakMap,Ue=bt(Be)&&/native code/.test(Ve(Be)),Ye=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},qe=_t?function(t,e,r){return ae.f(t,e,Ye(1,r))}:function(t,e,r){return t[e]=r,t},He="Object already initialized",Ke=V.TypeError,Je=V.WeakMap;if(Ue||ct.state){var $e=ct.state||(ct.state=new Je),Qe=H($e.get),Ze=H($e.has),tr=H($e.set);Ne=function(t,e){if(Ze($e,t))throw new Ke(He);return e.facade=t,tr($e,t,e),e},Ge=function(t){return Qe($e,t)||{}},Xe=function(t){return Ze($e,t)}}else{var er=Te("state");ge[er]=!0,Ne=function(t,e){if(dt(t,er))throw new Ke(He);return e.facade=t,qe(t,er,e),e},Ge=function(t){return dt(t,er)?t[er]:{}},Xe=function(t){return dt(t,er)}}var rr,nr,or,ir={set:Ne,get:Ge,has:Xe,enforce:function(t){return Xe(t)?Ge(t):Ne(t,{})},getterFor:function(t){return function(e){var r;if(!It(e)||(r=Ge(e)).type!==t)throw Ke("Incompatible receiver, "+t+" required");return r}}},ar={}.propertyIsEnumerable,ur=Object.getOwnPropertyDescriptor,cr={f:ur&&!ar.call({1:2},1)?function(t){var e=ur(this,t);return!!e&&e.enumerable}:ar},fr=Object.getOwnPropertyDescriptor,sr={f:_t?fr:function(t,e){if(t=ot(t),e=ne(e),Xt)try{return fr(t,e)}catch(t){}if(dt(t,e))return Ye(!Bt(cr.f,t,e),t[e])}},lr=Function.prototype,vr=_t&&Object.getOwnPropertyDescriptor,dr=dt(lr,"name"),hr={EXISTS:dr,PROPER:dr&&"something"===function(){}.name,CONFIGURABLE:dr&&(!_t||_t&&vr(lr,"name").configurable)},pr=x((function(t){var e=hr.CONFIGURABLE,r=ir.get,n=ir.enforce,o=String(String).split("String");(t.exports=function(t,r,i,a){var u,c=!!a&&!!a.unsafe,f=!!a&&!!a.enumerable,s=!!a&&!!a.noTargetGet,l=a&&void 0!==a.name?a.name:r;bt(i)&&("Symbol("===String(l).slice(0,7)&&(l="["+String(l).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!dt(i,"name")||e&&i.name!==l)&&qe(i,"name",l),(u=n(i)).source||(u.source=o.join("string"==typeof l?l:""))),t!==V?(c?!s&&t[r]&&(f=!0):delete t[r],f?t[r]=i:qe(t,r,i)):f?t[r]=i:at(r,i)})(Function.prototype,"toString",(function(){return bt(this)&&r(this).source||Ve(this)}))})),yr=Oe.concat("length","prototype"),gr={f:Object.getOwnPropertyNames||function(t){return we(t,yr)}},br={f:Object.getOwnPropertySymbols},mr=H([].concat),wr=mt("Reflect","ownKeys")||function(t){var e=gr.f(Ft(t)),r=br.f;return r?mr(e,r(t)):e},Or=function(t,e){for(var r=wr(e),n=ae.f,o=sr.f,i=0;i<r.length;i++){var a=r[i];dt(t,a)||n(t,a,o(e,a))}},xr=/#|\.prototype\./,Sr=function(t,e){var r=jr[Er(t)];return r==Pr||r!=Tr&&(bt(e)?K(e):!!e)},Er=Sr.normalize=function(t){return String(t).replace(xr,".").toLowerCase()},jr=Sr.data={},Tr=Sr.NATIVE="N",Pr=Sr.POLYFILL="P",Rr=Sr,Ar=sr.f,kr=function(t,e){var r,n,o,i,a,u=t.target,c=t.global,f=t.stat;if(r=c?V:f?V[u]||at(u,{}):(V[u]||{}).prototype)for(n in e){if(i=e[n],o=t.noTargetGet?(a=Ar(r,n))&&a.value:r[n],!Rr(c?n:u+(f?".":"#")+n,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Or(i,o)}(t.sham||o&&o.sham)&&qe(i,"sham",!0),pr(r,n,i,t)}},Cr=!K((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),Lr=Te("IE_PROTO"),zr=V.Object,Ir=zr.prototype,Mr=Cr?zr.getPrototypeOf:function(t){var e=lt(t);if(dt(e,Lr))return e[Lr];var r=e.constructor;return bt(r)&&e instanceof r?r.prototype:e instanceof zr?Ir:null},Dr=zt("iterator"),Fr=!1;[].keys&&("next"in(or=[].keys())?(nr=Mr(Mr(or)))!==Object.prototype&&(rr=nr):Fr=!0);var _r=null==rr||K((function(){var t={};return rr[Dr].call(t)!==t}));_r&&(rr={}),bt(rr[Dr])||pr(rr,Dr,(function(){return this}));var Wr={IteratorPrototype:rr,BUGGY_SAFARI_ITERATORS:Fr},Nr=ae.f,Gr=zt("toStringTag"),Xr=function(t,e,r){t&&!dt(t=r?t:t.prototype,Gr)&&Nr(t,Gr,{configurable:!0,value:e})},Vr=Wr.IteratorPrototype,Br=function(){return this},Ur=V.String,Yr=V.TypeError,qr=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,r={};try{(t=H(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),e=r instanceof Array}catch(t){}return function(r,n){return Ft(r),function(t){if("object"==typeof t||bt(t))return t;throw Yr("Can't set "+Ur(t)+" as a prototype")}(n),e?t(r,n):r.__proto__=n,r}}():void 0),Hr=hr.PROPER,Kr=hr.CONFIGURABLE,Jr=Wr.IteratorPrototype,$r=Wr.BUGGY_SAFARI_ITERATORS,Qr=zt("iterator"),Zr="keys",tn="values",en="entries",rn=function(){return this},nn=function(t,e,r,n,o,i,a){!function(t,e,r,n){var o=e+" Iterator";t.prototype=Ie(Vr,{next:Ye(+!n,r)}),Xr(t,o,!1),_e[o]=Br}(r,e,n);var u,c,f,s=function(t){if(t===o&&p)return p;if(!$r&&t in d)return d[t];switch(t){case Zr:case tn:case en:return function(){return new r(this,t)}}return function(){return new r(this)}},l=e+" Iterator",v=!1,d=t.prototype,h=d[Qr]||d["@@iterator"]||o&&d[o],p=!$r&&h||s(o),y="Array"==e&&d.entries||h;if(y&&(u=Mr(y.call(new t)))!==Object.prototype&&u.next&&(Mr(u)!==Jr&&(qr?qr(u,Jr):bt(u[Qr])||pr(u,Qr,rn)),Xr(u,l,!0)),Hr&&o==tn&&h&&h.name!==tn&&(Kr?qe(d,"name",tn):(v=!0,p=function(){return Bt(h,this)})),o)if(c={values:s(tn),keys:i?p:s(Zr),entries:s(en)},a)for(f in c)($r||v||!(f in d))&&pr(d,f,c[f]);else kr({target:e,proto:!0,forced:$r||v},c);return d[Qr]!==p&&pr(d,Qr,p,{name:o}),_e[e]=p,c},on="Array Iterator",an=ir.set,un=ir.getterFor(on),cn=nn(Array,"Array",(function(t,e){an(this,{type:on,target:ot(t),index:0,kind:e})}),(function(){var t=un(this),e=t.target,r=t.kind,n=t.index++;return!e||n>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==r?{value:n,done:!1}:"values"==r?{value:e[n],done:!1}:{value:[n,e[n]],done:!1}}),"values");_e.Arguments=_e.Array,Fe("keys"),Fe("values"),Fe("entries");var fn={};fn[zt("toStringTag")]="z";var sn="[object z]"===String(fn),ln=zt("toStringTag"),vn=V.Object,dn="Arguments"==Q(function(){return arguments}()),hn=sn?Q:function(t){var e,r,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=vn(t),ln))?r:dn?Q(e):"Object"==(n=Q(e))&&bt(e.callee)?"Arguments":n},pn=sn?{}.toString:function(){return"[object "+hn(this)+"]"};sn||pr(Object.prototype,"toString",pn,{unsafe:!0});var yn=V.String,gn=function(t){if("Symbol"===hn(t))throw TypeError("Cannot convert a Symbol value to a string");return yn(t)},bn=hr.PROPER,mn="toString",wn=RegExp.prototype,On=wn[mn],xn=H((function(){var t=Ft(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e})),Sn=K((function(){return"/a/b"!=On.call({source:"a",flags:"b"})})),En=bn&&On.name!=mn;(Sn||En)&&pr(RegExp.prototype,mn,(function(){var t=Ft(this),e=gn(t.source),r=t.flags;return"/"+e+"/"+gn(void 0===r&&Ut(wn,t)&&!("flags"in wn)?xn(t):r)}),{unsafe:!0});var jn=function(t,e,r){var n=ne(e);n in t?ae.f(t,n,Ye(0,r)):t[n]=r},Tn=V.Array,Pn=Math.max,Rn=gr.f,An="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],kn=function(t){try{return Rn(t)}catch(t){return function(t,e,r){for(var n=he(t),o=ve(e,n),i=ve(void 0===r?n:r,n),a=Tn(Pn(i-o,0)),u=0;o<i;o++,u++)jn(a,u,t[o]);return a.length=u,a}(An)}},Cn={f:function(t){return An&&"Window"==Q(t)?kn(t):Rn(ot(t))}},Ln=K((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})),zn=Object.isExtensible,In=K((function(){zn(1)}))||Ln?function(t){return!!It(t)&&((!Ln||"ArrayBuffer"!=Q(t))&&(!zn||zn(t)))}:zn,Mn=!K((function(){return Object.isExtensible(Object.preventExtensions({}))})),Dn=x((function(t){var e=ae.f,r=!1,n=gt("meta"),o=0,i=function(t){e(t,n,{value:{objectID:"O"+o++,weakData:{}}})},a=t.exports={enable:function(){a.enable=function(){},r=!0;var t=gr.f,e=H([].splice),o={};o[n]=1,t(o).length&&(gr.f=function(r){for(var o=t(r),i=0,a=o.length;i<a;i++)if(o[i]===n){e(o,i,1);break}return o},kr({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Cn.f}))},fastKey:function(t,e){if(!It(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!dt(t,n)){if(!In(t))return"F";if(!e)return"E";i(t)}return t[n].objectID},getWeakData:function(t,e){if(!dt(t,n)){if(!In(t))return!0;if(!e)return!1;i(t)}return t[n].weakData},onFreeze:function(t){return Mn&&r&&In(t)&&!dt(t,n)&&i(t),t}};ge[n]=!0})),Fn=H(H.bind),_n=function(t,e){return $t(t),void 0===e?t:Fn?Fn(t,e):function(){return t.apply(e,arguments)}},Wn=zt("iterator"),Nn=Array.prototype,Gn=zt("iterator"),Xn=function(t){if(null!=t)return Qt(t,Gn)||Qt(t,"@@iterator")||_e[hn(t)]},Vn=V.TypeError,Bn=function(t,e,r){var n,o;Ft(t);try{if(!(n=Qt(t,"return"))){if("throw"===e)throw r;return r}n=Bt(n,t)}catch(t){o=!0,n=t}if("throw"===e)throw r;if(o)throw n;return Ft(n),r},Un=V.TypeError,Yn=function(t,e){this.stopped=t,this.result=e},qn=Yn.prototype,Hn=function(t,e,r){var n,o,i,a,u,c,f,s,l=r&&r.that,v=!(!r||!r.AS_ENTRIES),d=!(!r||!r.IS_ITERATOR),h=!(!r||!r.INTERRUPTED),p=_n(e,l),y=function(t){return n&&Bn(n,"normal",t),new Yn(!0,t)},g=function(t){return v?(Ft(t),h?p(t[0],t[1],y):p(t[0],t[1])):h?p(t,y):p(t)};if(d)n=t;else{if(!(o=Xn(t)))throw Un(Kt(t)+" is not iterable");if(void 0!==(s=o)&&(_e.Array===s||Nn[Wn]===s)){for(i=0,a=he(t);a>i;i++)if((u=g(t[i]))&&Ut(qn,u))return u;return new Yn(!1)}n=function(t,e){var r=arguments.length<2?Xn(t):e;if($t(r))return Ft(Bt(r,t));throw Vn(Kt(t)+" is not iterable")}(t,o)}for(c=n.next;!(f=Bt(c,n)).done;){try{u=g(f.value)}catch(t){Bn(n,"throw",t)}if("object"==typeof u&&u&&Ut(qn,u))return u}return new Yn(!1)},Kn=V.TypeError,Jn=function(t,e){if(Ut(e,t))return t;throw Kn("Incorrect invocation")},$n=zt("iterator"),Qn=!1;try{var Zn=0,to={next:function(){return{done:!!Zn++}},return:function(){Qn=!0}};to[$n]=function(){return this},Array.from(to,(function(){throw 2}))}catch(t){}var eo=function(t,e,r){var n=-1!==t.indexOf("Map"),o=-1!==t.indexOf("Weak"),i=n?"set":"add",a=V[t],u=a&&a.prototype,c=a,f={},s=function(t){var e=H(u[t]);pr(u,t,"add"==t?function(t){return e(this,0===t?0:t),this}:"delete"==t?function(t){return!(o&&!It(t))&&e(this,0===t?0:t)}:"get"==t?function(t){return o&&!It(t)?void 0:e(this,0===t?0:t)}:"has"==t?function(t){return!(o&&!It(t))&&e(this,0===t?0:t)}:function(t,r){return e(this,0===t?0:t,r),this})};if(Rr(t,!bt(a)||!(o||u.forEach&&!K((function(){(new a).entries().next()})))))c=r.getConstructor(e,t,n,i),Dn.enable();else if(Rr(t,!0)){var l=new c,v=l[i](o?{}:-0,1)!=l,d=K((function(){l.has(1)})),h=function(t,e){if(!e&&!Qn)return!1;var r=!1;try{var n={};n[$n]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r}((function(t){new a(t)})),p=!o&&K((function(){for(var t=new a,e=5;e--;)t[i](e,e);return!t.has(-0)}));h||((c=e((function(t,e){Jn(t,u);var r=function(t,e,r){var n,o;return qr&&bt(n=e.constructor)&&n!==r&&It(o=n.prototype)&&o!==r.prototype&&qr(t,o),t}(new a,t,c);return null!=e&&Hn(e,r[i],{that:r,AS_ENTRIES:n}),r}))).prototype=u,u.constructor=c),(d||p)&&(s("delete"),s("has"),n&&s("get")),(p||v)&&s(i),o&&u.clear&&delete u.clear}return f[t]=c,kr({global:!0,forced:c!=a},f),Xr(c,t),o||r.setStrong(c,t,n),c},ro=function(t,e,r){for(var n in e)pr(t,n,e[n],r);return t},no=zt("species"),oo=ae.f,io=Dn.fastKey,ao=ir.set,uo=ir.getterFor,co={getConstructor:function(t,e,r,n){var o=t((function(t,o){Jn(t,i),ao(t,{type:e,index:Ie(null),first:void 0,last:void 0,size:0}),_t||(t.size=0),null!=o&&Hn(o,t[n],{that:t,AS_ENTRIES:r})})),i=o.prototype,a=uo(e),u=function(t,e,r){var n,o,i=a(t),u=c(t,e);return u?u.value=r:(i.last=u={index:o=io(e,!0),key:e,value:r,previous:n=i.last,next:void 0,removed:!1},i.first||(i.first=u),n&&(n.next=u),_t?i.size++:t.size++,"F"!==o&&(i.index[o]=u)),t},c=function(t,e){var r,n=a(t),o=io(e);if("F"!==o)return n.index[o];for(r=n.first;r;r=r.next)if(r.key==e)return r};return ro(i,{clear:function(){for(var t=a(this),e=t.index,r=t.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete e[r.index],r=r.next;t.first=t.last=void 0,_t?t.size=0:this.size=0},delete:function(t){var e=this,r=a(e),n=c(e,t);if(n){var o=n.next,i=n.previous;delete r.index[n.index],n.removed=!0,i&&(i.next=o),o&&(o.previous=i),r.first==n&&(r.first=o),r.last==n&&(r.last=i),_t?r.size--:e.size--}return!!n},forEach:function(t){for(var e,r=a(this),n=_n(t,arguments.length>1?arguments[1]:void 0);e=e?e.next:r.first;)for(n(e.value,e.key,this);e&&e.removed;)e=e.previous},has:function(t){return!!c(this,t)}}),ro(i,r?{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)}}),_t&&oo(i,"size",{get:function(){return a(this).size}}),o},setStrong:function(t,e,r){var n=e+" Iterator",o=uo(e),i=uo(n);nn(t,e,(function(t,e){ao(this,{type:n,target:t,state:o(t),kind:e,last:void 0})}),(function(){for(var t=i(this),e=t.kind,r=t.last;r&&r.removed;)r=r.previous;return t.target&&(t.last=r=r?r.next:t.state.first)?"keys"==e?{value:r.key,done:!1}:"values"==e?{value:r.value,done:!1}:{value:[r.key,r.value],done:!1}:(t.target=void 0,{value:void 0,done:!0})}),r?"entries":"values",!r,!0),function(t){var e=mt(t),r=ae.f;_t&&e&&!e[no]&&r(e,no,{configurable:!0,get:function(){return this}})}(e)}};eo("Set",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),co);var fo=H("".charAt),so=H("".charCodeAt),lo=H("".slice),vo=function(t){return function(e,r){var n,o,i=gn(nt(e)),a=fe(r),u=i.length;return a<0||a>=u?t?"":void 0:(n=so(i,a))<55296||n>56319||a+1===u||(o=so(i,a+1))<56320||o>57343?t?fo(i,a):n:t?lo(i,a,a+2):o-56320+(n-55296<<10)+65536}},ho={codeAt:vo(!1),charAt:vo(!0)}.charAt,po="String Iterator",yo=ir.set,go=ir.getterFor(po);nn(String,"String",(function(t){yo(this,{type:po,string:gn(t),index:0})}),(function(){var t,e=go(this),r=e.string,n=e.index;return n>=r.length?{value:void 0,done:!0}:(t=ho(r,n),e.index+=t.length,{value:t,done:!1})}));var bo=Array.isArray||function(t){return"Array"==Q(t)},mo=function(){},wo=[],Oo=mt("Reflect","construct"),xo=/^\s*(?:class|function)\b/,So=H(xo.exec),Eo=!xo.exec(mo),jo=function(t){if(!bt(t))return!1;try{return Oo(mo,wo,t),!0}catch(t){return!1}},To=!Oo||K((function(){var t;return jo(jo.call)||!jo(Object)||!jo((function(){t=!0}))||t}))?function(t){if(!bt(t))return!1;switch(hn(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}return Eo||!!So(xo,Ve(t))}:jo,Po=zt("species"),Ro=V.Array,Ao=function(t,e){return new(function(t){var e;return bo(t)&&(e=t.constructor,(To(e)&&(e===Ro||bo(e.prototype))||It(e)&&null===(e=e[Po]))&&(e=void 0)),void 0===e?Ro:e}(t))(0===e?0:e)},ko=H([].push),Co=function(t){var e=1==t,r=2==t,n=3==t,o=4==t,i=6==t,a=7==t,u=5==t||i;return function(c,f,s,l){for(var v,d,h=lt(c),p=et(h),y=_n(f,s),g=he(p),b=0,m=l||Ao,w=e?m(c,g):r||a?m(c,0):void 0;g>b;b++)if((u||b in p)&&(d=y(v=p[b],b,h),t))if(e)w[b]=d;else if(d)switch(t){case 3:return!0;case 5:return v;case 6:return b;case 2:ko(w,v)}else switch(t){case 4:return!1;case 7:ko(w,v)}return i?-1:n||o?o:w}},Lo={forEach:Co(0),map:Co(1),filter:Co(2),some:Co(3),every:Co(4),find:Co(5),findIndex:Co(6),filterReject:Co(7)},zo=Dn.getWeakData,Io=ir.set,Mo=ir.getterFor,Do=Lo.find,Fo=Lo.findIndex,_o=H([].splice),Wo=0,No=function(t){return t.frozen||(t.frozen=new Go)},Go=function(){this.entries=[]},Xo=function(t,e){return Do(t.entries,(function(t){return t[0]===e}))};Go.prototype={get:function(t){var e=Xo(this,t);if(e)return e[1]},has:function(t){return!!Xo(this,t)},set:function(t,e){var r=Xo(this,t);r?r[1]=e:this.entries.push([t,e])},delete:function(t){var e=Fo(this.entries,(function(e){return e[0]===t}));return~e&&_o(this.entries,e,1),!!~e}};var Vo,Bo={getConstructor:function(t,e,r,n){var o=t((function(t,o){Jn(t,i),Io(t,{type:e,id:Wo++,frozen:void 0}),null!=o&&Hn(o,t[n],{that:t,AS_ENTRIES:r})})),i=o.prototype,a=Mo(e),u=function(t,e,r){var n=a(t),o=zo(Ft(e),!0);return!0===o?No(n).set(e,r):o[n.id]=r,t};return ro(i,{delete:function(t){var e=a(this);if(!It(t))return!1;var r=zo(t);return!0===r?No(e).delete(t):r&&dt(r,e.id)&&delete r[e.id]},has:function(t){var e=a(this);if(!It(t))return!1;var r=zo(t);return!0===r?No(e).has(t):r&&dt(r,e.id)}}),ro(i,r?{get:function(t){var e=a(this);if(It(t)){var r=zo(t);return!0===r?No(e).get(t):r?r[e.id]:void 0}},set:function(t,e){return u(this,t,e)}}:{add:function(t){return u(this,t,!0)}}),o}},Uo=ir.enforce,Yo=!V.ActiveXObject&&"ActiveXObject"in V,qo=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Ho=eo("WeakMap",qo,Bo);if(Ue&&Yo){Vo=Bo.getConstructor(qo,"WeakMap",!0),Dn.enable();var Ko=Ho.prototype,Jo=H(Ko.delete),$o=H(Ko.has),Qo=H(Ko.get),Zo=H(Ko.set);ro(Ko,{delete:function(t){if(It(t)&&!In(t)){var e=Uo(this);return e.frozen||(e.frozen=new Vo),Jo(this,t)||e.frozen.delete(t)}return Jo(this,t)},has:function(t){if(It(t)&&!In(t)){var e=Uo(this);return e.frozen||(e.frozen=new Vo),$o(this,t)||e.frozen.has(t)}return $o(this,t)},get:function(t){if(It(t)&&!In(t)){var e=Uo(this);return e.frozen||(e.frozen=new Vo),$o(this,t)?Qo(this,t):e.frozen.get(t)}return Qo(this,t)},set:function(t,e){if(It(t)&&!In(t)){var r=Uo(this);r.frozen||(r.frozen=new Vo),$o(this,t)?Zo(this,t,e):r.frozen.set(t,e)}else Zo(this,t,e);return this}})}var ti,ei,ri={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},ni=Gt("span").classList,oi=ni&&ni.constructor&&ni.constructor.prototype,ii=oi===Object.prototype?void 0:oi,ai=Lo.forEach,ui=!!(ei=[]["forEach"])&&K((function(){ei.call(null,ti||function(){throw 1},1)}))?[].forEach:function(t){return ai(this,t,arguments.length>1?arguments[1]:void 0)},ci=function(t){if(t&&t.forEach!==ui)try{qe(t,"forEach",ui)}catch(e){t.forEach=ui}};for(var fi in ri)ri[fi]&&ci(V[fi]&&V[fi].prototype);ci(ii);var si=zt("iterator"),li=zt("toStringTag"),vi=cn.values,di=function(t,e){if(t){if(t[si]!==vi)try{qe(t,si,vi)}catch(e){t[si]=vi}if(t[li]||qe(t,li,e),ri[e])for(var r in cn)if(t[r]!==cn[r])try{qe(t,r,cn[r])}catch(e){t[r]=cn[r]}}};for(var hi in ri)di(V[hi]&&V[hi].prototype,hi);di(ii,"DOMTokenList");var pi=function(){return pi=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},pi.apply(this,arguments)};function yi(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function gi(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function bi(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function mi(t){return"[object Object]"===Object.prototype.toString.call(t)}function wi(t){if(!mi(t))return!1;var e=t.constructor;if(void 0===e)return!0;var r=e.prototype;return!1!==mi(r)&&!Object.prototype.hasOwnProperty.call(r,"isPrototypeOfOf")}function Oi(t,e){for(var r in t){var n=t[r],o=e[r];if(wi(n)&&wi(o)){if(!Oi(n,o))return!1}else if(Array.isArray(n)&&Array.isArray(o)){if(n.length!==o.length)return!1;for(var i=0;i<n.length;i++)if(n[i]!==o[i])return!1}else if(n!==o)return!1}for(var r in e)if(void 0===t[r]&&void 0!==e[r])return!1;return!0}function xi(t){return function(t){var e,r,n,o,i=[];try{for(var a=yi(t),u=a.next();!u.done;u=a.next()){var c=u.value;if("string"!=typeof c.insert||0!==c.insert.length){var f=i[i.length-1];f&&"string"==typeof f.insert&&"string"==typeof c.insert&&(f.attributes===c.attributes||!f.attributes==!c.attributes&&Oi(null!==(n=f.attributes)&&void 0!==n?n:{},null!==(o=c.attributes)&&void 0!==o?o:{}))?f.insert+=c.insert:i.push(c)}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return i}(t.toDelta())}function Si(t){var e=t.insert;return"string"==typeof e?e.length:1}function Ei(t){return t.reduce((function(t,e){return t+Si(e)}),0)}function ji(t,e,r){if(r<1)return[];for(var n=0,o=[],i=e+r,a=0;a<t.length&&!(n>=i);a++){var u=t[a],c=Si(u);if(n+c<=e)n+=c;else if("string"==typeof u.insert){var f=Math.max(0,e-n),s=Math.min(c,c-(n+c-i));o.push(pi(pi({},u),{insert:u.insert.slice(f,s)})),n+=c}else n+=c,o.push(u)}return o}function Ti(t){return function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return Object.fromEntries(Object.entries(t).filter((function(t){var r=gi(t,1)[0];return!e.includes(r)})))}(t,s.isText(t)?"text":"children")}function Pi(t){var e=t.children,r=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(t,["children"]),n=new p.XmlText;return Object.entries(r).forEach((function(t){var e=gi(t,2),r=e[0],o=e[1];n.setAttribute(r,o)})),n.applyDelta(e.map((function(t){return s.isText(t)?{insert:t.text,attributes:Ti(t)}:{insert:Pi(t)}})),{sanitize:!1}),n}function Ri(t){return t?s.isText(t)?t.text.length:1:0}function Ai(t,e,r){var n;if(0===r.length)throw new Error("Path has to a have a length >= 1");if(s.isText(e))throw new Error("Cannot descent into slate text");var o=gi(r),i=o[0],a=o.slice(1),u=function(t,e){return t.children.slice(0,e).reduce((function(t,e){return t+Ri(e)}),0)}(e,i),c=e.children[i],f=xi(t),l=Ri(c),v=ji(f,u,l);if(v.length>1)throw new Error("Path doesn't match yText, yTarget spans multiple nodes");var d=null===(n=v[0])||void 0===n?void 0:n.insert;if(a.length>0){if(!(d instanceof p.XmlText))throw new Error("Path doesn't match yText, cannot descent into non-yText");return Ai(d,c,a)}return{yParent:t,textRange:{start:u,end:u+l},yTarget:d instanceof p.XmlText?d:void 0,slateParent:e,slateTarget:c,targetDelta:v}}function ki(t,e,r){void 0===r&&(r={});for(var n=r.assoc,o=void 0===n?0:n,i=r.insert,a=void 0!==i&&i,u=0,c=0,f=0;f<t.children.length;f++){var l=t.children[f],v=s.isText(l)?l.text.length:1;v>0&&(c=f);var d=u+v;if(v>0&&(o>=0?d>e:d>=e))return[f,e-u];u+=v}if(e>u+(a?1:0))throw new Error("yOffset out of bounds");if(a)return[t.children.length,0];var h=t.children[c];return[c,s.isText(h)?h.text.length:1]}function Ci(t){return t.map((function(t){return"string"==typeof t.insert?t:pi(pi({},t),{insert:Li(t.insert)})}))}function Li(t){var e=new p.XmlText,r=t.getAttributes();return Object.entries(r).forEach((function(t){var r=gi(t,2),n=r[0],o=r[1];e.setAttribute(n,o)})),e.applyDelta(Ci(xi(t)),{sanitize:!1}),e}function zi(t){if(!t.doc)throw new Error("shared type isn't attached to a document")}"function"==typeof SuppressedError&&SuppressedError;var Ii="__slateYjsStoredPosition_";function Mi(t,e,r){var n=r.type,o=r.index,i=r.assoc;if(!(n instanceof p.XmlText))throw new Error("Absolute position points to a non-XMLText");var a=function(t,e,r){for(var n=[r];n[0]!==t;){var o=n[0].parent;if(!o)throw new Error("yText isn't a descendant of root element");if(!(o instanceof p.XmlText))throw new Error("Unexpected y parent type");n.unshift(o)}if(n.length<2)return[];var i=e;return n.reduce((function(t,e,r){var o,a,u=n[r+1];if(!u)return t;var c=0,f=xi(e);try{for(var l=yi(f),v=l.next();!v.done;v=l.next()){var d=v.value;if(d.insert===u)break;c+="string"==typeof d.insert?d.insert.length:1}}catch(t){o={error:t}}finally{try{v&&!v.done&&(a=l.return)&&a.call(l)}finally{if(o)throw o.error}}if(s.isText(i))throw new Error("Cannot descent into slate text");var h=gi(ki(i,c),1)[0];return i=i.children[h],t.concat(h)}),[])}(t,e,n),u=l.get(e,a);if(s.isText(u))throw new Error("Absolute position doesn't match slateRoot, cannot descent into text");var c=gi(ki(u,o,{assoc:i}),2),f=c[0],v=c[1],d=u.children[f];return s.isText(d)?{path:bi(bi([],gi(a)),[f]),offset:v}:null}function Di(t,e,r){if(!t.doc)throw new Error("sharedRoot isn't attach to a yDoc");var n=p.createAbsolutePositionFromRelativePosition(r,t.doc);return n&&Mi(t,e,n)}function Fi(t,e,r){t.setAttribute(Ii+e,p.encodeRelativePosition(r))}function _i(t,e,r){return Object.fromEntries(Object.entries(t).filter((function(t){var n=gi(t,2)[1];return n.type===e&&(!r||(n.assoc>=0?n.index>=r.start&&n.index<r.end:n.index>r.start&&n.index>=r.end))})))}function Wi(t,e,r){var n;void 0===r&&(r="");var o=((n={})[r]=_i(t,e),n);return xi(e).forEach((function(e,n){var i=e.insert;i instanceof p.XmlText&&Object.assign(o,Wi(t,i,r?r+"."+n:n.toString()))})),o}function Ni(t,e,r,n){void 0===n&&(n=0);var o=function(t){return zi(t),Object.fromEntries(Object.entries(t.getAttributes()).filter((function(t){return gi(t,1)[0].startsWith(Ii)})).map((function(e){var r=gi(e,2),n=r[0],o=r[1];return[n.slice(Ii.length),p.createAbsolutePositionFromRelativePosition(p.decodeRelativePosition(o),t.doc)]})).filter((function(t){return gi(t,2)[1]})))}(t),i={"":_i(o,e,{start:n,end:n+Ei(r)})};return r.forEach((function(t,e){var r=t.insert;r instanceof p.XmlText&&Object.assign(i,Wi(o,r,e.toString()))})),i}function Gi(t,e,r,n,o,i,a){void 0===o&&(o=0),void 0===i&&(i=0),void 0===a&&(a="");var u=r[a];u&&Object.entries(u).forEach((function(r){var n=gi(r,2),a=n[0],u=n[1];Fi(t,a,p.createRelativePositionFromTypeIndex(e,u.index-i+o,u.assoc))})),n.forEach((function(e,n){var o=e.insert;o instanceof p.XmlText&&Gi(t,o,r,xi(o),0,0,a?a+"."+n:n.toString())}))}var Xi={insert_node:function(t,e,r){var n=Ai(t,e,r.path),o=n.yParent,i=n.textRange;if(s.isText(r.node))return o.insert(i.start,r.node.text,Ti(r.node));o.insertEmbed(i.start,Pi(r.node))},remove_node:function(t,e,r){var n=Ai(t,e,r.path),o=n.yParent,i=n.textRange;o.delete(i.start,i.end-i.start)},set_node:function(t,e,r){var n=Ai(t,e,r.path),o=n.yTarget,i=n.textRange,a=n.yParent;if(o)return Object.entries(r.newProperties).forEach((function(t){var e=gi(t,2),r=e[0],n=e[1];if(null===n)return o.removeAttribute(r);o.setAttribute(r,n)})),Object.entries(r.properties).forEach((function(t){var e=gi(t,1)[0];Object.prototype.hasOwnProperty.call(r.newProperties,e)||o.removeAttribute(e)}));var u=Object.fromEntries(Object.keys(r.properties).map((function(t){return[t,null]}))),c=pi(pi({},u),r.newProperties);a.format(i.start,i.end-i.start,c)},merge_node:function(t,e,r){var n=Ai(t,e,r.path),o=Ai(n.yParent,n.slateParent,v.previous(r.path.slice(-1)));if(!n.yTarget!=!o.yTarget)throw new Error("Cannot merge y text with y element");if(!o.yTarget||!n.yTarget){var i=n.yParent,a=n.textRange,u=n.slateTarget;if(!u)throw new Error("Expected Slate target node for merge op.");var c=l.get(e,v.previous(r.path));if(!s.isText(c))throw new Error("Path points to Y.Text but not a Slate text node.");var f=Ti(u),d=Ti(c),h=Object.keys(f).reduce((function(t,e){var r;return e in d?t:pi(pi({},t),((r={})[e]=null,r))}),{});return i.format(a.start,a.end-a.start,pi(pi({},h),d))}var p=o.yTarget.length,y=xi(n.yTarget),g=Ci(y),b=Ni(t,n.yTarget,y,p),m=bi([{retain:p}],gi(g));o.yTarget.applyDelta(m,{sanitize:!1}),n.yParent.delete(n.textRange.start,n.textRange.end-n.textRange.start),Gi(t,o.yTarget,b,g,p)},move_node:function(t,e,r){var n=v.parent(r.newPath),o=r.newPath[r.newPath.length-1],i=l.get(e,n);if(s.isText(i))throw new Error("Cannot move slate node into text element");var a=bi(bi([],gi(n)),[Math.min(o,i.children.length)]),u=Ai(t,e,r.path),c=Ai(t,e,a),f=Ci(u.targetDelta),d=Ni(t,u.yParent,u.targetDelta);u.yParent.delete(u.textRange.start,u.textRange.end-u.textRange.start);var h=Ei(xi(c.yParent)),p=Math.min(c.textRange.start,h),y=bi([{retain:p}],gi(f));c.yParent.applyDelta(y,{sanitize:!1}),Gi(t,c.yParent,d,f,p,u.textRange.start)},split_node:function(t,e,r){var n=Ai(t,e,r.path);if(!n.slateTarget)throw new Error("Y target without corresponding slate node");if(!n.yTarget){if(!s.isText(n.slateTarget))throw new Error("Mismatch node type between y target and slate node");var o={};return n.targetDelta.forEach((function(t){t.attributes&&Object.keys(t.attributes).forEach((function(t){o[t]=null}))})),n.yParent.format(n.textRange.start,n.textRange.end-n.textRange.start,pi(pi({},o),r.properties))}if(s.isText(n.slateTarget))throw new Error("Mismatch node type between y target and slate node");var i=Ai(n.yTarget,n.slateTarget,[r.position]),a=n.slateTarget.children.slice(0,r.position).reduce((function(t,e){return t+Ri(e)}),0),u=n.slateTarget.children.reduce((function(t,e){return t+Ri(e)}),0),c=ji(xi(n.yTarget),a,u-a),f=Ci(c),l=Ni(t,n.yTarget,c,a),v=new p.XmlText;v.applyDelta(f,{sanitize:!1}),Object.entries(r.properties).forEach((function(t){var e=gi(t,2),r=e[0],n=e[1];v.setAttribute(r,n)})),n.yTarget.delete(i.textRange.start,n.yTarget.length-i.textRange.start),n.yParent.insertEmbed(n.textRange.end,v),Gi(t,v,l,f,0,a)}};pi(pi(pi({},{insert_text:function(t,e,r){var n=Ai(t,e,r.path),o=n.yParent,i=n.textRange,a=l.get(e,r.path);if(!s.isText(a))throw new Error("Cannot insert text into non-text node");o.insert(i.start+r.offset,r.text,Ti(a))},remove_text:function(t,e,r){var n=Ai(t,e,r.path),o=n.yParent,i=n.textRange;o.delete(i.start+r.offset,r.text.length)}}),Xi),{set_selection:function(){}});var Vi=new WeakMap,Bi=new WeakMap,Ui=new WeakSet,Yi={isYjsEditor:function(t){return d.isEditor(t)&&t.sharedRoot instanceof p.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=Bi.get(t))&&void 0!==e?e:[]},applyRemoteEvents:function(t,e,r){t.applyRemoteEvents(e,r)},storeLocalChange:function(t,e){t.storeLocalChange(e)},flushLocalChanges:function(t){t.flushLocalChanges()},connected:function(t){return Ui.has(t)},connect:function(t){t.connect()},disconnect:function(t){t.disconnect()},isLocal:function(t){return t.isLocalOrigin(Yi.origin(t))},origin:function(t){var e=Vi.get(t);return void 0!==e?e:t.localOrigin},withOrigin:function(t,e,r){var n=Yi.origin(t);Vi.set(t,e),r(),Vi.set(t,n)},storePosition:function(t,e,r){var n=t.sharedRoot,o=t.positionStorageOrigin;zi(n);var i=function(t,e,r){var n=Ai(t,e,r.path),o=n.yTarget,i=n.yParent,a=n.textRange;if(o)throw new Error("Slate point points to a non-text element inside sharedRoot");var u=a.start+r.offset;return p.createRelativePositionFromTypeIndex(i,u,u===a.end?-1:0)}(n,t,r);n.doc.transact((function(){Fi(n,e,i)}),o)},removeStoredPosition:function(t,e){var r=t.sharedRoot,n=t.positionStorageOrigin;zi(r),r.doc.transact((function(){!function(t,e){t.removeAttribute(Ii+e)}(r,e)}),n)},position:function(t,e){var r=function(t,e){var r=t.getAttribute(Ii+e);return r?p.decodeRelativePosition(r):null}(t.sharedRoot,e);if(r)return Di(t.sharedRoot,t,r)},storedPositionsRelative:function(t){return e=t.sharedRoot,Object.fromEntries(Object.entries(e.getAttributes()).filter((function(t){return gi(t,1)[0].startsWith(Ii)})).map((function(t){var e=gi(t,2),r=e[0],n=e[1];return[r.slice(Ii.length),p.createRelativePositionFromJSON(n)]})));var e}},qi=new WeakMap,Hi={isCursorEditor:function(t){return Yi.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,r){var n;if("change"===e){var o=null!==(n=qi.get(t))&&void 0!==n?n:new Set;o.add(r),qi.set(t,o)}},off:function(t,e,r){if("change"===e){var n=qi.get(t);n&&n.delete(r)}},cursorState:function(t,e){var r;if(e===t.awareness.clientID||!Yi.connected(t))return null;var n=t.awareness.getStates().get(e);return n?{relativeSelection:null!==(r=n[t.selectionStateField])&&void 0!==r?r:null,data:n[t.cursorDataField],clientId:e}:null},cursorStates:function(t){return Yi.connected(t)?Object.fromEntries(Array.from(t.awareness.getStates().entries(),(function(e){var r=gi(e,2),n=r[0],o=r[1];return n!==t.awareness.clientID&&o?[n,{relativeSelection:o[t.selectionStateField],data:o[t.cursorDataField]}]:null})).filter(Array.isArray)):{}}};function Ki(){var t=b();return Hi.isCursorEditor(t)||console.warn("Cannot use useSyncExternalStore outside the context of a RemoteCursorEditor"),t}var Ji=new WeakMap;function $i(t){var e=Ji.get(t);if(e)return e;var r=function(t){var e={},r=new Set,n=r.add.bind(r),o=new Set,i=null;return[function(e){return o.add(e),i||(i=function(t){t.added.forEach(n),t.removed.forEach(n),t.updated.forEach(n),o.forEach((function(t){return t()}))},Hi.on(t,"change",i)),function(){o.delete(e),i&&0===o.size&&(Hi.off(t,"change",i),i=null)}},function(){return 0===r.size?e:(r.forEach((function(r){var n=Hi.cursorState(t,r);null!==n?e[r]=n:delete e[r.toString()]})),r.clear(),e=m({},e))}]}(t);return t&&Ji.set(t,r),r}function Qi(){return $i(Ki())}function Zi(){var t=w(Qi(),2),e=t[0],r=t[1];return C.useSyncExternalStore(e,r)}function ta(t,e){var r=w(Qi(),2),n=r[0],o=r[1];return G.useSyncExternalStoreWithSelector(n,o,null,t,e)}var ea=new WeakMap;function ra(t,e){if(!e.relativeSelection)return null;var r=ea.get(t.children);r||(r=new WeakMap,ea.set(t.children,r));var n=r.get(e);if(void 0===n)try{n=function(t,e,r){var n=Di(t,e,r.anchor);if(!n)return null;var o=Di(t,e,r.focus);return o?{anchor:n,focus:o}:null}(t.sharedRoot,t,e.relativeSelection),r.set(e,n)}catch(t){return null}return n}var na=zt("species"),oa=Lo.map,ia=function(t){return Tt>=51||!K((function(){var e=[];return(e.constructor={})[na]=function(){return{foo:1}},1!==e[t](Boolean).foo}))}("map");kr({target:"Array",proto:!0,forced:!ia},{map:function(t){return oa(this,t,arguments.length>1?arguments[1]:void 0)}});var aa=H(cr.f),ua=H([].push),ca=function(t){return function(e){for(var r,n=ot(e),o=xe(n),i=o.length,a=0,u=[];i>a;)r=o[a++],_t&&!aa(n,r)||ua(u,t?[r,n[r]]:n[r]);return u}},fa={entries:ca(!0),values:ca(!1)}.entries;kr({target:"Object",stat:!0},{entries:function(t){return fa(t)}});var sa=Dn.onFreeze,la=Object.freeze,va=K((function(){la(1)}));kr({target:"Object",stat:!0,forced:va,sham:!Mn},{freeze:function(t){return la&&It(t)?la(sa(t)):t}}),kr({target:"Object",stat:!0},{fromEntries:function(t){var e={};return Hn(t,(function(t,r){jn(e,t,r)}),{AS_ENTRIES:!0}),e}});var da=K((function(){xe(1)}));function ha(t,e,r){var n,o,i=r.yOffset,a=r.xOffset,u=r.shouldGenerateOverlay,c=w(h.edges(e),2),f=c[0],l=c[1],p=function(t,e){try{return y.toDOMRange(t,e)}catch(t){return null}}(t,e);if(!p)return{caretPosition:null,selectionRects:[]};var g=[],b=d.nodes(t,{at:e,match:function(t,e){return s.isText(t)&&(!u||u(t,e))}}),m=null,O=h.isBackward(e);try{for(var x=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(b),S=x.next();!S.done;S=x.next()){var E=w(S.value,2),j=E[0],T=E[1],P=y.toDOMNode(t,j),R=v.equals(T,f.path),A=v.equals(T,l.path),k=null;if(R||A){var C=document.createRange();C.selectNode(P),R&&C.setStart(p.startContainer,p.startOffset),A&&C.setEnd(p.endContainer,p.endOffset),k=C.getClientRects()}else k=P.getClientRects();for(var L=O?R:A,z=0;z<k.length;z++){var I=k.item(z);if(I){var M=L&&(O?0===z:z===k.length-1),D=I.top-i,F=I.left-a;M&&(m={height:I.height,top:D,left:F+(O||h.isCollapsed(e)?0:I.width)}),g.push({width:I.width,height:I.height,top:D,left:F})}}}}catch(t){n={error:t}}finally{try{S&&!S.done&&(o=x.return)&&o.call(x)}finally{if(n)throw n.error}}return{selectionRects:g,caretPosition:m}}kr({target:"Object",stat:!0,forced:da},{keys:function(t){return xe(lt(t))}});var pa=Object.freeze([]);function ya(t){var e;void 0===t&&(t={});var r,s,l,v=t.containerRef,d=t.shouldGenerateOverlay,h=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(t,["containerRef","shouldGenerateOverlay"]),p=Ki(),y=Zi(),g=(r=w(n((function(t){return t+1}),0),2)[1],s=o(null),i(l=function(){s.current&&(cancelAnimationFrame(s.current),s.current=0)}),i((function(){return l}),[]),a((function(t){void 0===t&&(t=!1),t?r():s.current||(s.current=requestAnimationFrame(r))}),[])),b=o(new WeakMap),O=w(u({}),2),x=O[0],S=O[1],E=!("refreshOnResize"in h)||(null===(e=h.refreshOnResize)||void 0===e||e);!function(t,e){var r=o(e);r.current=e;var n=w(u((function(){return new ResizeObserver((function(){r.current()}))})),1)[0];i((function(){if(null==t?void 0:t.current){var e=t.current;return n.observe(e),function(){return n.unobserve(e)}}}),[n,t])}(E?v:void 0,(function(){b.current=new WeakMap,g("debounced"!==E)})),c((function(){var t,e,r;if(!v||v.current){var n=null===(t=null==v?void 0:v.current)||void 0===t?void 0:t.getBoundingClientRect(),o=null!==(e=null==n?void 0:n.x)&&void 0!==e?e:0,i=null!==(r=null==n?void 0:n.y)&&void 0!==r?r:0,a=Object.keys(x).length!==Object.keys(y).length,u=Object.fromEntries(Object.entries(y).map((function(t){var e=w(t,2),r=e[0],n=e[1],u=n.relativeSelection&&ra(p,n);if(!u)return[r,pa];var c=b.current.get(u);if(c)return[r,c];var f=ha(p,u,{xOffset:o,yOffset:i,shouldGenerateOverlay:d});return a=!0,b.current.set(u,f),[r,f]})));a&&S(u)}}));var j=f((function(){return Object.entries(y).map((function(t){var e,r,n=w(t,2),o=n[0],i=n[1],a=i.relativeSelection&&ra(p,i),u=x[o];return m(m({},i),{range:a,caretPosition:null!==(e=null==u?void 0:u.caretPosition)&&void 0!==e?e:null,selectionRects:null!==(r=null==u?void 0:u.selectionRects)&&void 0!==r?r:pa})}))}),[y,p,x]);return[j,a((function(){b.current=new WeakMap,g(!0)}),[g])]}export{g as EditorContext,ra as getCursorRange,b as useEditorStatic,ya as useRemoteCursorOverlayPositions,Zi as useRemoteCursorStates,ta as useRemoteCursorStatesSelector};
|
|
40
|
-
|
|
373
|
+
|
|
374
|
+
var withSelector_development = createCommonjsModule(function (module, exports) {
|
|
375
|
+
|
|
376
|
+
{
|
|
377
|
+
(function() {
|
|
378
|
+
|
|
379
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
380
|
+
if (
|
|
381
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
382
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
383
|
+
'function'
|
|
384
|
+
) {
|
|
385
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
386
|
+
}
|
|
387
|
+
var React = e;
|
|
388
|
+
var shim$1 = shim;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
392
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
393
|
+
*/
|
|
394
|
+
function is(x, y) {
|
|
395
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
396
|
+
;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
400
|
+
|
|
401
|
+
var useSyncExternalStore = shim$1.useSyncExternalStore;
|
|
402
|
+
|
|
403
|
+
// for CommonJS interop.
|
|
404
|
+
|
|
405
|
+
var useRef = React.useRef,
|
|
406
|
+
useEffect = React.useEffect,
|
|
407
|
+
useMemo = React.useMemo,
|
|
408
|
+
useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
|
|
409
|
+
|
|
410
|
+
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
411
|
+
// Use this to track the rendered snapshot.
|
|
412
|
+
var instRef = useRef(null);
|
|
413
|
+
var inst;
|
|
414
|
+
|
|
415
|
+
if (instRef.current === null) {
|
|
416
|
+
inst = {
|
|
417
|
+
hasValue: false,
|
|
418
|
+
value: null
|
|
419
|
+
};
|
|
420
|
+
instRef.current = inst;
|
|
421
|
+
} else {
|
|
422
|
+
inst = instRef.current;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
var _useMemo = useMemo(function () {
|
|
426
|
+
// Track the memoized state using closure variables that are local to this
|
|
427
|
+
// memoized instance of a getSnapshot function. Intentionally not using a
|
|
428
|
+
// useRef hook, because that state would be shared across all concurrent
|
|
429
|
+
// copies of the hook/component.
|
|
430
|
+
var hasMemo = false;
|
|
431
|
+
var memoizedSnapshot;
|
|
432
|
+
var memoizedSelection;
|
|
433
|
+
|
|
434
|
+
var memoizedSelector = function (nextSnapshot) {
|
|
435
|
+
if (!hasMemo) {
|
|
436
|
+
// The first time the hook is called, there is no memoized result.
|
|
437
|
+
hasMemo = true;
|
|
438
|
+
memoizedSnapshot = nextSnapshot;
|
|
439
|
+
|
|
440
|
+
var _nextSelection = selector(nextSnapshot);
|
|
441
|
+
|
|
442
|
+
if (isEqual !== undefined) {
|
|
443
|
+
// Even if the selector has changed, the currently rendered selection
|
|
444
|
+
// may be equal to the new selection. We should attempt to reuse the
|
|
445
|
+
// current value if possible, to preserve downstream memoizations.
|
|
446
|
+
if (inst.hasValue) {
|
|
447
|
+
var currentSelection = inst.value;
|
|
448
|
+
|
|
449
|
+
if (isEqual(currentSelection, _nextSelection)) {
|
|
450
|
+
memoizedSelection = currentSelection;
|
|
451
|
+
return currentSelection;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
memoizedSelection = _nextSelection;
|
|
457
|
+
return _nextSelection;
|
|
458
|
+
} // We may be able to reuse the previous invocation's result.
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
// We may be able to reuse the previous invocation's result.
|
|
462
|
+
var prevSnapshot = memoizedSnapshot;
|
|
463
|
+
var prevSelection = memoizedSelection;
|
|
464
|
+
|
|
465
|
+
if (objectIs(prevSnapshot, nextSnapshot)) {
|
|
466
|
+
// The snapshot is the same as last time. Reuse the previous selection.
|
|
467
|
+
return prevSelection;
|
|
468
|
+
} // The snapshot has changed, so we need to compute a new selection.
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
// The snapshot has changed, so we need to compute a new selection.
|
|
472
|
+
var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
|
|
473
|
+
// has changed. If it hasn't, return the previous selection. That signals
|
|
474
|
+
// to React that the selections are conceptually equal, and we can bail
|
|
475
|
+
// out of rendering.
|
|
476
|
+
|
|
477
|
+
// If a custom isEqual function is provided, use that to check if the data
|
|
478
|
+
// has changed. If it hasn't, return the previous selection. That signals
|
|
479
|
+
// to React that the selections are conceptually equal, and we can bail
|
|
480
|
+
// out of rendering.
|
|
481
|
+
if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
|
|
482
|
+
return prevSelection;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
memoizedSnapshot = nextSnapshot;
|
|
486
|
+
memoizedSelection = nextSelection;
|
|
487
|
+
return nextSelection;
|
|
488
|
+
}; // Assigning this to a constant so that Flow knows it can't change.
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
// Assigning this to a constant so that Flow knows it can't change.
|
|
492
|
+
var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
|
|
493
|
+
|
|
494
|
+
var getSnapshotWithSelector = function () {
|
|
495
|
+
return memoizedSelector(getSnapshot());
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
|
|
499
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
500
|
+
};
|
|
501
|
+
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
502
|
+
}, [getSnapshot, getServerSnapshot, selector, isEqual]),
|
|
503
|
+
getSelection = _useMemo[0],
|
|
504
|
+
getServerSelection = _useMemo[1];
|
|
505
|
+
|
|
506
|
+
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
507
|
+
useEffect(function () {
|
|
508
|
+
inst.hasValue = true;
|
|
509
|
+
inst.value = value;
|
|
510
|
+
}, [value]);
|
|
511
|
+
useDebugValue(value);
|
|
512
|
+
return value;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
|
|
516
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
517
|
+
if (
|
|
518
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
519
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
520
|
+
'function'
|
|
521
|
+
) {
|
|
522
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
})();
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
var withSelector = createCommonjsModule(function (module) {
|
|
530
|
+
|
|
531
|
+
{
|
|
532
|
+
module.exports = withSelector_development;
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
function useRemoteCursorEditor() {
|
|
537
|
+
var editor = useEditorStatic();
|
|
538
|
+
if (!CursorEditor.isCursorEditor(editor)) {
|
|
539
|
+
console.warn('Cannot use useSyncExternalStore outside the context of a RemoteCursorEditor');
|
|
540
|
+
}
|
|
541
|
+
return editor;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
var EDITOR_TO_CURSOR_STORE = new WeakMap();
|
|
545
|
+
function createRemoteCursorStateStore(editor) {
|
|
546
|
+
var cursors = {};
|
|
547
|
+
var changed = new Set();
|
|
548
|
+
var addChanged = changed.add.bind(changed);
|
|
549
|
+
var onStoreChangeListeners = new Set();
|
|
550
|
+
var changeHandler = null;
|
|
551
|
+
var subscribe = function (onStoreChange) {
|
|
552
|
+
onStoreChangeListeners.add(onStoreChange);
|
|
553
|
+
if (!changeHandler) {
|
|
554
|
+
changeHandler = function (event) {
|
|
555
|
+
event.added.forEach(addChanged);
|
|
556
|
+
event.removed.forEach(addChanged);
|
|
557
|
+
event.updated.forEach(addChanged);
|
|
558
|
+
onStoreChangeListeners.forEach(function (listener) { return listener(); });
|
|
559
|
+
};
|
|
560
|
+
CursorEditor.on(editor, 'change', changeHandler);
|
|
561
|
+
}
|
|
562
|
+
return function () {
|
|
563
|
+
onStoreChangeListeners.delete(onStoreChange);
|
|
564
|
+
if (changeHandler && onStoreChangeListeners.size === 0) {
|
|
565
|
+
CursorEditor.off(editor, 'change', changeHandler);
|
|
566
|
+
changeHandler = null;
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
};
|
|
570
|
+
var getSnapshot = function () {
|
|
571
|
+
if (changed.size === 0) {
|
|
572
|
+
return cursors;
|
|
573
|
+
}
|
|
574
|
+
changed.forEach(function (clientId) {
|
|
575
|
+
var state = CursorEditor.cursorState(editor, clientId);
|
|
576
|
+
if (state === null) {
|
|
577
|
+
delete cursors[clientId.toString()];
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
cursors[clientId] = state;
|
|
581
|
+
});
|
|
582
|
+
changed.clear();
|
|
583
|
+
cursors = __assign({}, cursors);
|
|
584
|
+
return cursors;
|
|
585
|
+
};
|
|
586
|
+
return [subscribe, getSnapshot];
|
|
587
|
+
}
|
|
588
|
+
function getCursorStateStore(editor) {
|
|
589
|
+
var existing = EDITOR_TO_CURSOR_STORE.get(editor);
|
|
590
|
+
if (existing) {
|
|
591
|
+
return existing;
|
|
592
|
+
}
|
|
593
|
+
var store = createRemoteCursorStateStore(editor);
|
|
594
|
+
if (editor)
|
|
595
|
+
EDITOR_TO_CURSOR_STORE.set(editor, store);
|
|
596
|
+
return store;
|
|
597
|
+
}
|
|
598
|
+
function useRemoteCursorStateStore() {
|
|
599
|
+
var editor = useRemoteCursorEditor();
|
|
600
|
+
return getCursorStateStore(editor);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function useRemoteCursorStates() {
|
|
604
|
+
var _a = __read(useRemoteCursorStateStore(), 2), subscribe = _a[0], getSnapshot = _a[1];
|
|
605
|
+
return shim.useSyncExternalStore(subscribe, getSnapshot);
|
|
606
|
+
}
|
|
607
|
+
function useRemoteCursorStatesSelector(selector, isEqual) {
|
|
608
|
+
var _a = __read(useRemoteCursorStateStore(), 2), subscribe = _a[0], getSnapshot = _a[1];
|
|
609
|
+
return withSelector.useSyncExternalStoreWithSelector(subscribe, getSnapshot, null, selector, isEqual);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
var CHILDREN_TO_CURSOR_STATE_TO_RANGE = new WeakMap();
|
|
613
|
+
function getCursorRange(editor, cursorState) {
|
|
614
|
+
if (!cursorState.relativeSelection) {
|
|
615
|
+
return null;
|
|
616
|
+
}
|
|
617
|
+
var cursorStates = CHILDREN_TO_CURSOR_STATE_TO_RANGE.get(editor.children);
|
|
618
|
+
if (!cursorStates) {
|
|
619
|
+
cursorStates = new WeakMap();
|
|
620
|
+
CHILDREN_TO_CURSOR_STATE_TO_RANGE.set(editor.children, cursorStates);
|
|
621
|
+
}
|
|
622
|
+
var range = cursorStates.get(cursorState);
|
|
623
|
+
if (range === undefined) {
|
|
624
|
+
try {
|
|
625
|
+
range = relativeRangeToSlateRange(editor.sharedRoot, editor, cursorState.relativeSelection);
|
|
626
|
+
cursorStates.set(cursorState, range);
|
|
627
|
+
}
|
|
628
|
+
catch (e) {
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return range;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
function reactEditorToDomRangeSafe(editor, range) {
|
|
636
|
+
try {
|
|
637
|
+
return DomEditor.toDOMRange(editor, range);
|
|
638
|
+
}
|
|
639
|
+
catch (e) {
|
|
640
|
+
return null;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function getOverlayPosition(editor, range, _a) {
|
|
645
|
+
var e_1, _b;
|
|
646
|
+
var yOffset = _a.yOffset, xOffset = _a.xOffset, shouldGenerateOverlay = _a.shouldGenerateOverlay;
|
|
647
|
+
var _c = __read(Range.edges(range), 2), start = _c[0], end = _c[1];
|
|
648
|
+
var domRange = reactEditorToDomRangeSafe(editor, range);
|
|
649
|
+
if (!domRange) {
|
|
650
|
+
return {
|
|
651
|
+
caretPosition: null,
|
|
652
|
+
selectionRects: [],
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
var selectionRects = [];
|
|
656
|
+
var nodeIterator = Editor.nodes(editor, {
|
|
657
|
+
at: range,
|
|
658
|
+
match: function (n, p) { return Text.isText(n) && (!shouldGenerateOverlay || shouldGenerateOverlay(n, p)); },
|
|
659
|
+
});
|
|
660
|
+
var caretPosition = null;
|
|
661
|
+
var isBackward = Range.isBackward(range);
|
|
662
|
+
try {
|
|
663
|
+
for (var nodeIterator_1 = __values(nodeIterator), nodeIterator_1_1 = nodeIterator_1.next(); !nodeIterator_1_1.done; nodeIterator_1_1 = nodeIterator_1.next()) {
|
|
664
|
+
var _d = __read(nodeIterator_1_1.value, 2), node = _d[0], path = _d[1];
|
|
665
|
+
var domNode = DomEditor.toDOMNode(editor, node);
|
|
666
|
+
var isStartNode = Path.equals(path, start.path);
|
|
667
|
+
var isEndNode = Path.equals(path, end.path);
|
|
668
|
+
var clientRects = null;
|
|
669
|
+
if (isStartNode || isEndNode) {
|
|
670
|
+
var nodeRange = document.createRange();
|
|
671
|
+
nodeRange.selectNode(domNode);
|
|
672
|
+
if (isStartNode) {
|
|
673
|
+
nodeRange.setStart(domRange.startContainer, domRange.startOffset);
|
|
674
|
+
}
|
|
675
|
+
if (isEndNode) {
|
|
676
|
+
nodeRange.setEnd(domRange.endContainer, domRange.endOffset);
|
|
677
|
+
}
|
|
678
|
+
clientRects = nodeRange.getClientRects();
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
clientRects = domNode.getClientRects();
|
|
682
|
+
}
|
|
683
|
+
var isCaret = isBackward ? isStartNode : isEndNode;
|
|
684
|
+
for (var i = 0; i < clientRects.length; i++) {
|
|
685
|
+
var clientRect = clientRects.item(i);
|
|
686
|
+
if (!clientRect) {
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
var isCaretRect = isCaret && (isBackward ? i === 0 : i === clientRects.length - 1);
|
|
690
|
+
var top_1 = clientRect.top - yOffset;
|
|
691
|
+
var left = clientRect.left - xOffset;
|
|
692
|
+
if (isCaretRect) {
|
|
693
|
+
caretPosition = {
|
|
694
|
+
height: clientRect.height,
|
|
695
|
+
top: top_1,
|
|
696
|
+
left: left + (isBackward || Range.isCollapsed(range) ? 0 : clientRect.width),
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
selectionRects.push({
|
|
700
|
+
width: clientRect.width,
|
|
701
|
+
height: clientRect.height,
|
|
702
|
+
top: top_1,
|
|
703
|
+
left: left,
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
709
|
+
finally {
|
|
710
|
+
try {
|
|
711
|
+
if (nodeIterator_1_1 && !nodeIterator_1_1.done && (_b = nodeIterator_1.return)) _b.call(nodeIterator_1);
|
|
712
|
+
}
|
|
713
|
+
finally { if (e_1) throw e_1.error; }
|
|
714
|
+
}
|
|
715
|
+
return {
|
|
716
|
+
selectionRects: selectionRects,
|
|
717
|
+
caretPosition: caretPosition,
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function useRequestRerender() {
|
|
722
|
+
var _a = __read(useReducer(function (s) { return s + 1; }, 0), 2), rerender = _a[1];
|
|
723
|
+
var animationFrameIdRef = useRef(null);
|
|
724
|
+
var clearAnimationFrame = function () {
|
|
725
|
+
if (animationFrameIdRef.current) {
|
|
726
|
+
cancelAnimationFrame(animationFrameIdRef.current);
|
|
727
|
+
animationFrameIdRef.current = 0;
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
useEffect(clearAnimationFrame);
|
|
731
|
+
useEffect(function () { return clearAnimationFrame; }, []);
|
|
732
|
+
return useCallback(function (immediately) {
|
|
733
|
+
if (immediately === void 0) { immediately = false; }
|
|
734
|
+
if (immediately) {
|
|
735
|
+
rerender();
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
if (animationFrameIdRef.current) {
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
animationFrameIdRef.current = requestAnimationFrame(rerender);
|
|
742
|
+
}, []);
|
|
743
|
+
}
|
|
744
|
+
function useOnResize(ref, onResize) {
|
|
745
|
+
var onResizeRef = useRef(onResize);
|
|
746
|
+
onResizeRef.current = onResize;
|
|
747
|
+
var _a = __read(useState(function () {
|
|
748
|
+
return new ResizeObserver(function () {
|
|
749
|
+
onResizeRef.current();
|
|
750
|
+
});
|
|
751
|
+
}), 1), observer = _a[0];
|
|
752
|
+
useEffect(function () {
|
|
753
|
+
if (!(ref === null || ref === void 0 ? void 0 : ref.current)) {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
var element = ref.current;
|
|
757
|
+
observer.observe(element);
|
|
758
|
+
return function () { return observer.unobserve(element); };
|
|
759
|
+
}, [observer, ref]);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
var FROZEN_EMPTY_ARRAY = Object.freeze([]);
|
|
763
|
+
function useRemoteCursorOverlayPositions(_a) {
|
|
764
|
+
var _b;
|
|
765
|
+
if (_a === void 0) { _a = {}; }
|
|
766
|
+
var containerRef = _a.containerRef, shouldGenerateOverlay = _a.shouldGenerateOverlay, opts = __rest(_a, ["containerRef", "shouldGenerateOverlay"]);
|
|
767
|
+
var editor = useRemoteCursorEditor();
|
|
768
|
+
var cursorStates = useRemoteCursorStates();
|
|
769
|
+
var requestRerender = useRequestRerender();
|
|
770
|
+
var overlayPositionCache = useRef(new WeakMap());
|
|
771
|
+
var _c = __read(useState({}), 2), overlayPositions = _c[0], setOverlayPositions = _c[1];
|
|
772
|
+
var refreshOnResize = 'refreshOnResize' in opts ? (_b = opts.refreshOnResize) !== null && _b !== void 0 ? _b : true : true;
|
|
773
|
+
useOnResize(refreshOnResize ? containerRef : undefined, function () {
|
|
774
|
+
overlayPositionCache.current = new WeakMap();
|
|
775
|
+
requestRerender(refreshOnResize !== 'debounced');
|
|
776
|
+
});
|
|
777
|
+
// Update selection rects after paint
|
|
778
|
+
useLayoutEffect(function () {
|
|
779
|
+
var _a, _b, _c;
|
|
780
|
+
// We have a container ref but the ref is null => container
|
|
781
|
+
// isn't mounted to we can't calculate the selection rects.
|
|
782
|
+
if (containerRef && !containerRef.current) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
var containerRect = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
786
|
+
var xOffset = (_b = containerRect === null || containerRect === void 0 ? void 0 : containerRect.x) !== null && _b !== void 0 ? _b : 0;
|
|
787
|
+
var yOffset = (_c = containerRect === null || containerRect === void 0 ? void 0 : containerRect.y) !== null && _c !== void 0 ? _c : 0;
|
|
788
|
+
var overlayPositionsChanged = Object.keys(overlayPositions).length !== Object.keys(cursorStates).length;
|
|
789
|
+
var updated = Object.fromEntries(Object.entries(cursorStates).map(function (_a) {
|
|
790
|
+
var _b = __read(_a, 2), key = _b[0], state = _b[1];
|
|
791
|
+
var range = state.relativeSelection && getCursorRange(editor, state);
|
|
792
|
+
if (!range) {
|
|
793
|
+
return [key, FROZEN_EMPTY_ARRAY];
|
|
794
|
+
}
|
|
795
|
+
var cached = overlayPositionCache.current.get(range);
|
|
796
|
+
if (cached) {
|
|
797
|
+
return [key, cached];
|
|
798
|
+
}
|
|
799
|
+
var overlayPosition = getOverlayPosition(editor, range, {
|
|
800
|
+
xOffset: xOffset,
|
|
801
|
+
yOffset: yOffset,
|
|
802
|
+
shouldGenerateOverlay: shouldGenerateOverlay,
|
|
803
|
+
});
|
|
804
|
+
overlayPositionsChanged = true;
|
|
805
|
+
overlayPositionCache.current.set(range, overlayPosition);
|
|
806
|
+
return [key, overlayPosition];
|
|
807
|
+
}));
|
|
808
|
+
if (overlayPositionsChanged) {
|
|
809
|
+
setOverlayPositions(updated);
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
var overlayData = useMemo(function () {
|
|
813
|
+
return Object.entries(cursorStates).map(function (_a) {
|
|
814
|
+
var _b, _c;
|
|
815
|
+
var _d = __read(_a, 2), clientId = _d[0], state = _d[1];
|
|
816
|
+
var range = state.relativeSelection && getCursorRange(editor, state);
|
|
817
|
+
var overlayPosition = overlayPositions[clientId];
|
|
818
|
+
return __assign(__assign({}, state), { range: range, caretPosition: (_b = overlayPosition === null || overlayPosition === void 0 ? void 0 : overlayPosition.caretPosition) !== null && _b !== void 0 ? _b : null, selectionRects: (_c = overlayPosition === null || overlayPosition === void 0 ? void 0 : overlayPosition.selectionRects) !== null && _c !== void 0 ? _c : FROZEN_EMPTY_ARRAY });
|
|
819
|
+
});
|
|
820
|
+
}, [cursorStates, editor, overlayPositions]);
|
|
821
|
+
var refresh = useCallback(function () {
|
|
822
|
+
overlayPositionCache.current = new WeakMap();
|
|
823
|
+
requestRerender(true);
|
|
824
|
+
}, [requestRerender]);
|
|
825
|
+
return [overlayData, refresh];
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
export { EditorContext, getCursorRange, useEditorStatic, useRemoteCursorOverlayPositions, useRemoteCursorStates, useRemoteCursorStatesSelector };
|