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