@univerjs/drawing 0.15.0 → 0.15.1

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/lib/es/index.js CHANGED
@@ -1,47 +1,47 @@
1
1
  var Rt = Object.defineProperty;
2
- var xt = (a, e, n) => e in a ? Rt(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
3
- var F = (a, e, n) => xt(a, typeof e != "symbol" ? e + "" : e, n);
4
- import { createIdentifier as Bt, CommandType as Wt, sortRules as Gt, sortRulesByDesc as Lt, ImageSourceType as at, ImageUploadStatusType as et, generateRandomId as qt, Inject as Kt, Injector as $t, IConfigService as Ft, ICommandService as Vt, Plugin as Ht, merge as zt, mergeOverrideWithDependencies as Xt, IImageIoService as Jt } from "@univerjs/core";
5
- import { IImageIoService as In, ImageSourceType as En, ImageUploadStatusType as Dn } from "@univerjs/core";
2
+ var xt = (a, e, t) => e in a ? Rt(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
+ var F = (a, e, t) => xt(a, typeof e != "symbol" ? e + "" : e, t);
4
+ import { createIdentifier as Bt, CommandType as Wt, sortRules as Lt, sortRulesByDesc as Gt, ImageSourceType as at, ImageUploadStatusType as et, generateRandomId as qt, Disposable as $t, toDisposable as Kt, Inject as Ft, Injector as Vt, IConfigService as Ht, ICommandService as zt, Plugin as Xt, merge as Jt, mergeOverrideWithDependencies as Yt, IImageIoService as Zt, IURLImageService as Qt } from "@univerjs/core";
5
+ import { IImageIoService as Tn, ImageSourceType as Sn, ImageUploadStatusType as kn } from "@univerjs/core";
6
6
  import { Subject as be } from "rxjs";
7
- const _n = 500, vn = 500, mn = 10, Yt = 5 * 1024 * 1024, Zt = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp"], Mt = Bt("univer.drawing-manager.service"), Qt = {
7
+ const wn = 500, bn = 500, In = 10, en = 5 * 1024 * 1024, tn = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp"], kt = Bt("univer.drawing-manager.service"), nn = {
8
8
  id: "drawing.operation.set-drawing-selected",
9
9
  type: Wt.OPERATION,
10
10
  handler: (a, e) => {
11
- const n = a.get(Mt);
12
- return e == null ? !1 : (n.focusDrawing(e), !0);
13
- }
14
- }, en = "drawing.config", vt = {};
15
- var Ve = {}, Ze = {}, tt = {}, mt;
16
- function tn() {
17
- if (mt) return tt;
18
- mt = 1, Object.defineProperty(tt, "__esModule", { value: !0 });
19
- function a(t, r) {
11
+ const t = a.get(kt);
12
+ return e == null ? !1 : (t.focusDrawing(e), !0);
13
+ }
14
+ }, rn = "drawing.config", mt = {};
15
+ var Ve = {}, Ze = {}, tt = {}, vt;
16
+ function sn() {
17
+ if (vt) return tt;
18
+ vt = 1, Object.defineProperty(tt, "__esModule", { value: !0 });
19
+ function a(n, r) {
20
20
  if (Array.isArray(r))
21
21
  return !1;
22
- for (let u in t)
23
- if (!n(t[u], r[u]))
22
+ for (let u in n)
23
+ if (!t(n[u], r[u]))
24
24
  return !1;
25
25
  for (let u in r)
26
- if (t[u] === void 0)
26
+ if (n[u] === void 0)
27
27
  return !1;
28
28
  return !0;
29
29
  }
30
- function e(t, r) {
31
- if (!Array.isArray(r) || t.length !== r.length)
30
+ function e(n, r) {
31
+ if (!Array.isArray(r) || n.length !== r.length)
32
32
  return !1;
33
- for (let u = 0; u < t.length; u++)
34
- if (!n(t[u], r[u]))
33
+ for (let u = 0; u < n.length; u++)
34
+ if (!t(n[u], r[u]))
35
35
  return !1;
36
36
  return !0;
37
37
  }
38
- function n(t, r) {
39
- return t === r ? !0 : t === null || r === null || typeof t != "object" || typeof r != "object" ? !1 : Array.isArray(t) ? e(t, r) : a(t, r);
38
+ function t(n, r) {
39
+ return n === r ? !0 : n === null || r === null || typeof n != "object" || typeof r != "object" ? !1 : Array.isArray(n) ? e(n, r) : a(n, r);
40
40
  }
41
- return tt.default = n, tt;
41
+ return tt.default = t, tt;
42
42
  }
43
43
  var nt = {}, Ot;
44
- function nn() {
44
+ function on() {
45
45
  if (Ot) return nt;
46
46
  Ot = 1, Object.defineProperty(nt, "__esModule", { value: !0 });
47
47
  function a(e) {
@@ -50,24 +50,24 @@ function nn() {
50
50
  if (Array.isArray(e))
51
51
  return e.map(a);
52
52
  if (typeof e == "object") {
53
- const n = {};
54
- for (let t in e)
55
- n[t] = a(e[t]);
56
- return n;
53
+ const t = {};
54
+ for (let n in e)
55
+ t[n] = a(e[n]);
56
+ return t;
57
57
  } else
58
58
  return e;
59
59
  }
60
60
  return nt.default = a, nt;
61
61
  }
62
62
  var lt = {}, wt;
63
- function St() {
63
+ function Ut() {
64
64
  return wt || (wt = 1, (function(a) {
65
65
  Object.defineProperty(a, "__esModule", { value: !0 }), a.eachChildOf = a.advancer = a.readCursor = a.writeCursor = a.WriteCursor = a.ReadCursor = a.isValidPathItem = void 0;
66
66
  function e(_, s) {
67
67
  if (!_)
68
68
  throw new Error(s);
69
69
  }
70
- const n = (_) => _ != null && typeof _ == "object" && !Array.isArray(_), t = (_, s) => (
70
+ const t = (_) => _ != null && typeof _ == "object" && !Array.isArray(_), n = (_, s) => (
71
71
  // All the numbers, then all the letters. Just as the gods of ascii intended.
72
72
  typeof _ == typeof s ? _ > s : typeof _ == "string" && typeof s == "number"
73
73
  );
@@ -83,13 +83,13 @@ function St() {
83
83
  this.parents = [], this.indexes = [], this.lcIdx = -1, this.idx = -1, this.container = s;
84
84
  }
85
85
  ascend() {
86
- e(this.parents.length === this.indexes.length / 2), this.idx === 0 ? this.parents.length ? (this.lcIdx = this.indexes.pop(), this.container = this.parents.pop(), this.idx = this.indexes.pop()) : (this.lcIdx = 0, this.idx = -1) : (e(this.idx > 0), this.idx--, n(this.container[this.idx]) && this.idx--);
86
+ e(this.parents.length === this.indexes.length / 2), this.idx === 0 ? this.parents.length ? (this.lcIdx = this.indexes.pop(), this.container = this.parents.pop(), this.idx = this.indexes.pop()) : (this.lcIdx = 0, this.idx = -1) : (e(this.idx > 0), this.idx--, t(this.container[this.idx]) && this.idx--);
87
87
  }
88
88
  getPath() {
89
89
  const s = [];
90
- let c = this.container, h = this.parents.length - 1, U = this.idx;
91
- for (; U >= 0; )
92
- s.unshift(c[U]), U === 0 ? (U = this.indexes[h * 2], c = this.parents[h--]) : U -= n(c[U - 1]) ? 2 : 1;
90
+ let c = this.container, h = this.parents.length - 1, M = this.idx;
91
+ for (; M >= 0; )
92
+ s.unshift(c[M]), M === 0 ? (M = this.indexes[h * 2], c = this.parents[h--]) : M -= t(c[M - 1]) ? 2 : 1;
93
93
  return s;
94
94
  }
95
95
  }
@@ -103,13 +103,13 @@ function St() {
103
103
  }
104
104
  getComponent() {
105
105
  let s;
106
- return this.container && this.container.length > this.idx + 1 && n(s = this.container[this.idx + 1]) ? s : null;
106
+ return this.container && this.container.length > this.idx + 1 && t(s = this.container[this.idx + 1]) ? s : null;
107
107
  }
108
108
  descendFirst() {
109
109
  let s = this.idx + 1;
110
- if (!this.container || s >= this.container.length || n(this.container[s]) && s + 1 >= this.container.length)
110
+ if (!this.container || s >= this.container.length || t(this.container[s]) && s + 1 >= this.container.length)
111
111
  return !1;
112
- n(this.container[s]) && s++;
112
+ t(this.container[s]) && s++;
113
113
  const c = this.container[s];
114
114
  return Array.isArray(c) ? (this.indexes.push(this.idx), this.parents.push(this.container), this.indexes.push(s), this.idx = 0, this.container = c) : this.idx = s, !0;
115
115
  }
@@ -119,8 +119,8 @@ function St() {
119
119
  const s = this.indexes[this.indexes.length - 1] + 1, c = this.parents[this.parents.length - 1];
120
120
  return s >= c.length ? !1 : (e(!isNaN(s)), this.indexes[this.indexes.length - 1] = s, this.container = c[s], !0);
121
121
  }
122
- _init(s, c, h, U) {
123
- this.container = s, this.idx = c, this.parents = h.slice(), this.indexes = U.slice();
122
+ _init(s, c, h, M) {
123
+ this.container = s, this.idx = c, this.parents = h.slice(), this.indexes = M.slice();
124
124
  }
125
125
  clone() {
126
126
  const s = new o();
@@ -140,17 +140,17 @@ function St() {
140
140
  traverse(s, c) {
141
141
  const h = this.getComponent();
142
142
  h && c(h, s);
143
- for (const U of this)
144
- s && s.descend(U), this.traverse(s, c), s && s.ascend();
143
+ for (const M of this)
144
+ s && s.descend(M), this.traverse(s, c), s && s.ascend();
145
145
  }
146
146
  eachPick(s, c) {
147
- this.traverse(s, (h, U) => {
148
- h.p != null && c(h.p, U);
147
+ this.traverse(s, (h, M) => {
148
+ h.p != null && c(h.p, M);
149
149
  });
150
150
  }
151
151
  eachDrop(s, c) {
152
- this.traverse(s, (h, U) => {
153
- h.d != null && c(h.d, U);
152
+ this.traverse(s, (h, M) => {
153
+ h.d != null && c(h.d, M);
154
154
  });
155
155
  }
156
156
  }
@@ -164,22 +164,22 @@ function St() {
164
164
  for (let s = 0; s < this.pendingDescent.length; s++) {
165
165
  const c = this.pendingDescent[s];
166
166
  let h = this.idx + 1;
167
- if (h < this.container.length && n(this.container[h]) && h++, e(h === this.container.length || !n(this.container[h])), h === this.container.length)
167
+ if (h < this.container.length && t(this.container[h]) && h++, e(h === this.container.length || !t(this.container[h])), h === this.container.length)
168
168
  this.container.push(c), this.idx = h;
169
169
  else if (this.container[h] === c)
170
170
  this.idx = h;
171
171
  else {
172
172
  if (!Array.isArray(this.container[h])) {
173
- const U = this.container.splice(h, this.container.length - h);
174
- this.container.push(U), this.lcIdx > -1 && (this.lcIdx = h);
173
+ const M = this.container.splice(h, this.container.length - h);
174
+ this.container.push(M), this.lcIdx > -1 && (this.lcIdx = h);
175
175
  }
176
- for (this.indexes.push(this.idx), this.parents.push(this.container), this.lcIdx !== -1 && (e(t(c, this.container[this.lcIdx][0])), h = this.lcIdx + 1, this.lcIdx = -1); h < this.container.length && t(c, this.container[h][0]); )
176
+ for (this.indexes.push(this.idx), this.parents.push(this.container), this.lcIdx !== -1 && (e(n(c, this.container[this.lcIdx][0])), h = this.lcIdx + 1, this.lcIdx = -1); h < this.container.length && n(c, this.container[h][0]); )
177
177
  h++;
178
178
  if (this.indexes.push(h), this.idx = 0, h < this.container.length && this.container[h][0] === c)
179
179
  this.container = this.container[h];
180
180
  else {
181
- const U = [c];
182
- this.container.splice(h, 0, U), this.container = U;
181
+ const M = [c];
182
+ this.container.splice(h, 0, M), this.container = M;
183
183
  }
184
184
  }
185
185
  }
@@ -194,7 +194,7 @@ function St() {
194
194
  getComponent() {
195
195
  this.flushDescent();
196
196
  const s = this.idx + 1;
197
- if (s < this.container.length && n(this.container[s]))
197
+ if (s < this.container.length && t(this.container[s]))
198
198
  return this.container[s];
199
199
  {
200
200
  const c = {};
@@ -224,7 +224,7 @@ function St() {
224
224
  return;
225
225
  if (e(Array.isArray(s)), s === this._op)
226
226
  throw Error("Cannot merge into my own tree");
227
- const h = this.lcIdx, U = this.parents.length;
227
+ const h = this.lcIdx, M = this.parents.length;
228
228
  let Y = 0;
229
229
  for (let pe = 0; pe < s.length; pe++) {
230
230
  const Z = s[pe];
@@ -232,7 +232,7 @@ function St() {
232
232
  }
233
233
  for (; Y--; )
234
234
  this.ascend();
235
- this.lcIdx = this.parents.length === U ? h : -1;
235
+ this.lcIdx = this.parents.length === M ? h : -1;
236
236
  }
237
237
  at(s, c) {
238
238
  this.descendPath(s), c(this);
@@ -255,20 +255,20 @@ function St() {
255
255
  }
256
256
  a.WriteCursor = l, a.writeCursor = () => new l(), a.readCursor = (_) => new o(_);
257
257
  function E(_, s, c) {
258
- let h, U;
259
- U = h = _ ? _.descendFirst() : !1;
258
+ let h, M;
259
+ M = h = _ ? _.descendFirst() : !1;
260
260
  function Y(pe) {
261
261
  let Z;
262
- for (; U; ) {
263
- const Ce = Z = _.getKey();
262
+ for (; M; ) {
263
+ const Ie = Z = _.getKey();
264
264
  if (pe != null) {
265
265
  let qe = !1;
266
- if (s && typeof Ce == "number" && (Z = s(Ce, _.getComponent()), Z < 0 && (Z = ~Z, qe = !0)), t(Z, pe))
266
+ if (s && typeof Ie == "number" && (Z = s(Ie, _.getComponent()), Z < 0 && (Z = ~Z, qe = !0)), n(Z, pe))
267
267
  return null;
268
268
  if (Z === pe && !qe)
269
269
  return _;
270
270
  }
271
- c && typeof Z == "number" && c(Z, _.getComponent()), U = _.nextSibling();
271
+ c && typeof Z == "number" && c(Z, _.getComponent()), M = _.nextSibling();
272
272
  }
273
273
  return null;
274
274
  }
@@ -278,49 +278,49 @@ function St() {
278
278
  }
279
279
  a.advancer = E;
280
280
  function B(_, s, c) {
281
- let h, U, Y, pe;
282
- for (h = U = _ && _.descendFirst(), Y = pe = s && s.descendFirst(); h || Y; ) {
283
- let Z = h ? _.getKey() : null, Ce = Y ? s.getKey() : null;
284
- Z !== null && Ce !== null && (t(Ce, Z) ? Ce = null : Z !== Ce && (Z = null)), c(Z == null ? Ce : Z, Z != null ? _ : null, Ce != null ? s : null), Z != null && h && (h = _.nextSibling()), Ce != null && Y && (Y = s.nextSibling());
281
+ let h, M, Y, pe;
282
+ for (h = M = _ && _.descendFirst(), Y = pe = s && s.descendFirst(); h || Y; ) {
283
+ let Z = h ? _.getKey() : null, Ie = Y ? s.getKey() : null;
284
+ Z !== null && Ie !== null && (n(Ie, Z) ? Ie = null : Z !== Ie && (Z = null)), c(Z == null ? Ie : Z, Z != null ? _ : null, Ie != null ? s : null), Z != null && h && (h = _.nextSibling()), Ie != null && Y && (Y = s.nextSibling());
285
285
  }
286
- U && _.ascend(), pe && s.ascend();
286
+ M && _.ascend(), pe && s.ascend();
287
287
  }
288
288
  a.eachChildOf = B;
289
289
  })(lt)), lt;
290
290
  }
291
291
  var ut = {}, bt;
292
- function kt() {
292
+ function At() {
293
293
  return bt || (bt = 1, (function(a) {
294
294
  Object.defineProperty(a, "__esModule", { value: !0 }), a.ConflictType = void 0, (function(e) {
295
295
  e[e.RM_UNEXPECTED_CONTENT = 1] = "RM_UNEXPECTED_CONTENT", e[e.DROP_COLLISION = 2] = "DROP_COLLISION", e[e.BLACKHOLE = 3] = "BLACKHOLE";
296
296
  })(a.ConflictType || (a.ConflictType = {}));
297
297
  })(ut)), ut;
298
298
  }
299
- var Ue = {}, He = {}, Ct;
299
+ var Me = {}, He = {}, It;
300
300
  function pt() {
301
- return Ct || (Ct = 1, Object.defineProperty(He, "__esModule", { value: !0 }), He.uniToStrPos = He.strPosToUni = void 0, He.strPosToUni = (a, e = a.length) => {
302
- let n = 0, t = 0;
303
- for (; t < e; t++) {
304
- const r = a.charCodeAt(t);
305
- r >= 55296 && r <= 57343 && (n++, t++);
301
+ return It || (It = 1, Object.defineProperty(He, "__esModule", { value: !0 }), He.uniToStrPos = He.strPosToUni = void 0, He.strPosToUni = (a, e = a.length) => {
302
+ let t = 0, n = 0;
303
+ for (; n < e; n++) {
304
+ const r = a.charCodeAt(n);
305
+ r >= 55296 && r <= 57343 && (t++, n++);
306
306
  }
307
- if (t !== e)
307
+ if (n !== e)
308
308
  throw Error("Invalid offset - splits unicode bytes");
309
- return t - n;
309
+ return n - t;
310
310
  }, He.uniToStrPos = (a, e) => {
311
- let n = 0;
311
+ let t = 0;
312
312
  for (; e > 0; e--) {
313
- const t = a.charCodeAt(n);
314
- n += t >= 55296 && t <= 57343 ? 2 : 1;
313
+ const n = a.charCodeAt(t);
314
+ t += n >= 55296 && n <= 57343 ? 2 : 1;
315
315
  }
316
- return n;
316
+ return t;
317
317
  }), He;
318
318
  }
319
- var ct = {}, It;
319
+ var ct = {}, Ct;
320
320
  function ht() {
321
- return It || (It = 1, (function(a) {
321
+ return Ct || (Ct = 1, (function(a) {
322
322
  Object.defineProperty(a, "__esModule", { value: !0 }), a.uniSlice = a.dlen = a.eachOp = void 0;
323
- const e = pt(), n = (f) => {
323
+ const e = pt(), t = (f) => {
324
324
  if (!Array.isArray(f))
325
325
  throw Error("Op must be an array of components");
326
326
  let y = null;
@@ -349,28 +349,28 @@ function ht() {
349
349
  if (typeof y == "number")
350
350
  throw Error("Op has a trailing skip");
351
351
  };
352
- function t(f, y) {
352
+ function n(f, y) {
353
353
  let b = 0, q = 0;
354
354
  for (let z = 0; z < f.length; z++) {
355
- const K = f[z];
356
- switch (y(K, b, q), typeof K) {
355
+ const $ = f[z];
356
+ switch (y($, b, q), typeof $) {
357
357
  case "object":
358
- b += a.dlen(K.d);
358
+ b += a.dlen($.d);
359
359
  break;
360
360
  case "string":
361
- q += e.strPosToUni(K);
361
+ q += e.strPosToUni($);
362
362
  break;
363
363
  case "number":
364
- b += K, q += K;
364
+ b += $, q += $;
365
365
  break;
366
366
  }
367
367
  }
368
368
  }
369
- a.eachOp = t;
369
+ a.eachOp = n;
370
370
  function r(f, y) {
371
371
  const b = [], q = l(b);
372
- return t(f, (z, K, Ee) => {
373
- q(y(z, K, Ee));
372
+ return n(f, (z, $, Ee) => {
373
+ q(y(z, $, Ee));
374
374
  }), s(b);
375
375
  }
376
376
  const u = (f) => f, o = (f) => r(f, u);
@@ -393,26 +393,26 @@ function ht() {
393
393
  };
394
394
  const B = (f, y, b) => typeof f == "number" ? b == null ? f - y : Math.min(f, b) - y : a.uniSlice(f, y, b), _ = (f) => {
395
395
  let y = 0, b = 0;
396
- return { take: (K, Ee) => {
396
+ return { take: ($, Ee) => {
397
397
  if (y === f.length)
398
- return K === -1 ? null : K;
398
+ return $ === -1 ? null : $;
399
399
  const ce = f[y];
400
400
  let ne;
401
401
  if (typeof ce == "number")
402
- return K === -1 || ce - b <= K ? (ne = ce - b, ++y, b = 0, ne) : (b += K, K);
402
+ return $ === -1 || ce - b <= $ ? (ne = ce - b, ++y, b = 0, ne) : (b += $, $);
403
403
  if (typeof ce == "string") {
404
- if (K === -1 || Ee === "i" || e.strPosToUni(ce.slice(b)) <= K)
404
+ if ($ === -1 || Ee === "i" || e.strPosToUni(ce.slice(b)) <= $)
405
405
  return ne = ce.slice(b), ++y, b = 0, ne;
406
406
  {
407
- const le = b + e.uniToStrPos(ce.slice(b), K);
407
+ const le = b + e.uniToStrPos(ce.slice(b), $);
408
408
  return ne = ce.slice(b, le), b = le, ne;
409
409
  }
410
410
  } else {
411
- if (K === -1 || Ee === "d" || a.dlen(ce.d) - b <= K)
411
+ if ($ === -1 || Ee === "d" || a.dlen(ce.d) - b <= $)
412
412
  return ne = { d: B(ce.d, b) }, ++y, b = 0, ne;
413
413
  {
414
- let le = B(ce.d, b, b + K);
415
- return b += K, { d: le };
414
+ let le = B(ce.d, b, b + $);
415
+ return b += $, { d: le };
416
416
  }
417
417
  }
418
418
  }, peek: () => f[y] };
@@ -420,22 +420,22 @@ function ht() {
420
420
  function c(f, y, b) {
421
421
  if (b !== "left" && b !== "right")
422
422
  throw Error("side (" + b + ") must be 'left' or 'right'");
423
- n(f), n(y);
424
- const q = [], z = l(q), { take: K, peek: Ee } = _(f);
423
+ t(f), t(y);
424
+ const q = [], z = l(q), { take: $, peek: Ee } = _(f);
425
425
  for (let ne = 0; ne < y.length; ne++) {
426
426
  const le = y[ne];
427
427
  let ge, De;
428
428
  switch (typeof le) {
429
429
  case "number":
430
430
  for (ge = le; ge > 0; )
431
- De = K(ge, "i"), z(De), typeof De != "string" && (ge -= E(De));
431
+ De = $(ge, "i"), z(De), typeof De != "string" && (ge -= E(De));
432
432
  break;
433
433
  case "string":
434
- b === "left" && typeof Ee() == "string" && z(K(-1)), z(e.strPosToUni(le));
434
+ b === "left" && typeof Ee() == "string" && z($(-1)), z(e.strPosToUni(le));
435
435
  break;
436
436
  case "object":
437
437
  for (ge = a.dlen(le.d); ge > 0; )
438
- switch (De = K(ge, "i"), typeof De) {
438
+ switch (De = $(ge, "i"), typeof De) {
439
439
  case "number":
440
440
  ge -= De;
441
441
  break;
@@ -449,12 +449,12 @@ function ht() {
449
449
  }
450
450
  }
451
451
  let ce;
452
- for (; ce = K(-1); )
452
+ for (; ce = $(-1); )
453
453
  z(ce);
454
454
  return s(q);
455
455
  }
456
456
  function h(f, y) {
457
- n(f), n(y);
457
+ t(f), t(y);
458
458
  const b = [], q = l(b), { take: z } = _(f);
459
459
  for (let Ee = 0; Ee < y.length; Ee++) {
460
460
  const ce = y[Ee];
@@ -484,12 +484,12 @@ function ht() {
484
484
  break;
485
485
  }
486
486
  }
487
- let K;
488
- for (; K = z(-1); )
489
- q(K);
487
+ let $;
488
+ for (; $ = z(-1); )
489
+ q($);
490
490
  return s(b);
491
491
  }
492
- const U = (f, y) => {
492
+ const M = (f, y) => {
493
493
  let b = 0;
494
494
  for (let q = 0; q < y.length && f > b; q++) {
495
495
  const z = y[q];
@@ -499,8 +499,8 @@ function ht() {
499
499
  break;
500
500
  }
501
501
  case "string":
502
- const K = e.strPosToUni(z);
503
- b += K, f += K;
502
+ const $ = e.strPosToUni(z);
503
+ b += $, f += $;
504
504
  break;
505
505
  case "object":
506
506
  f -= Math.min(a.dlen(z.d), f - b);
@@ -508,7 +508,7 @@ function ht() {
508
508
  }
509
509
  }
510
510
  return f;
511
- }, Y = (f, y) => typeof f == "number" ? U(f, y) : f.map((b) => U(b, y));
511
+ }, Y = (f, y) => typeof f == "number" ? M(f, y) : f.map((b) => M(b, y));
512
512
  function pe(f, y, b) {
513
513
  return r(f, (q, z) => typeof q == "object" && typeof q.d == "number" ? { d: b.slice(y, z, z + q.d) } : q);
514
514
  }
@@ -528,22 +528,22 @@ function ht() {
528
528
  }
529
529
  });
530
530
  }
531
- function Ce(f) {
531
+ function Ie(f) {
532
532
  return r(f, (y) => typeof y == "object" && typeof y.d == "string" ? { d: e.strPosToUni(y.d) } : y);
533
533
  }
534
534
  function qe(f) {
535
535
  let y = !0;
536
- return t(f, (b) => {
536
+ return n(f, (b) => {
537
537
  typeof b == "object" && typeof b.d == "number" && (y = !1);
538
538
  }), y;
539
539
  }
540
- function ve(f) {
540
+ function me(f) {
541
541
  return {
542
542
  name: "text-unicode",
543
543
  uri: "http://sharejs.org/types/text-unicode",
544
544
  trim: s,
545
545
  normalize: o,
546
- checkOp: n,
546
+ checkOp: t,
547
547
  /** Create a new text snapshot.
548
548
  *
549
549
  * @param {string} initial - initial snapshot data. Optional. Defaults to ''.
@@ -557,19 +557,19 @@ function ht() {
557
557
  /** Apply an operation to a document snapshot
558
558
  */
559
559
  apply(y, b) {
560
- n(b);
560
+ t(b);
561
561
  const q = f.builder(y);
562
562
  for (let z = 0; z < b.length; z++) {
563
- const K = b[z];
564
- switch (typeof K) {
563
+ const $ = b[z];
564
+ switch (typeof $) {
565
565
  case "number":
566
- q.skip(K);
566
+ q.skip($);
567
567
  break;
568
568
  case "string":
569
- q.append(K);
569
+ q.append($);
570
570
  break;
571
571
  case "object":
572
- q.del(a.dlen(K.d));
572
+ q.del(a.dlen($.d));
573
573
  break;
574
574
  }
575
575
  }
@@ -577,13 +577,13 @@ function ht() {
577
577
  },
578
578
  transform: c,
579
579
  compose: h,
580
- transformPosition: U,
580
+ transformPosition: M,
581
581
  transformSelection: Y,
582
582
  isInvertible: qe,
583
583
  makeInvertible(y, b) {
584
584
  return pe(y, b, f);
585
585
  },
586
- stripInvertible: Ce,
586
+ stripInvertible: Ie,
587
587
  invert: Z,
588
588
  invertWithDoc(y, b) {
589
589
  return Z(pe(y, b, f));
@@ -591,29 +591,29 @@ function ht() {
591
591
  isNoop: (y) => y.length === 0
592
592
  };
593
593
  }
594
- a.default = ve;
594
+ a.default = me;
595
595
  })(ct)), ct;
596
596
  }
597
597
  var rt = {}, Et;
598
- function rn() {
598
+ function an() {
599
599
  if (Et) return rt;
600
600
  Et = 1, Object.defineProperty(rt, "__esModule", { value: !0 });
601
601
  const a = ht(), e = pt();
602
- function n(t, r) {
602
+ function t(n, r) {
603
603
  return {
604
604
  // Returns the text content of the document
605
- get: t,
605
+ get: n,
606
606
  // Returns the number of characters in the string
607
607
  getLength() {
608
- return t().length;
608
+ return n().length;
609
609
  },
610
610
  // Insert the specified text at the given position in the document
611
611
  insert(u, o, l) {
612
- const E = e.strPosToUni(t(), u);
612
+ const E = e.strPosToUni(n(), u);
613
613
  return r([E, o], l);
614
614
  },
615
615
  remove(u, o, l) {
616
- const E = e.strPosToUni(t(), u);
616
+ const E = e.strPosToUni(n(), u);
617
617
  return r([E, { d: o }], l);
618
618
  },
619
619
  // When you use this API, you should implement these two methods
@@ -636,31 +636,31 @@ function rn() {
636
636
  onRemove: null
637
637
  };
638
638
  }
639
- return rt.default = n, n.provides = { text: !0 }, rt;
639
+ return rt.default = t, t.provides = { text: !0 }, rt;
640
640
  }
641
641
  var Dt;
642
- function sn() {
642
+ function ln() {
643
643
  return Dt || (Dt = 1, (function(a) {
644
- var e = Ue && Ue.__createBinding || (Object.create ? (function(c, h, U, Y) {
645
- Y === void 0 && (Y = U), Object.defineProperty(c, Y, { enumerable: !0, get: function() {
646
- return h[U];
644
+ var e = Me && Me.__createBinding || (Object.create ? (function(c, h, M, Y) {
645
+ Y === void 0 && (Y = M), Object.defineProperty(c, Y, { enumerable: !0, get: function() {
646
+ return h[M];
647
647
  } });
648
- }) : (function(c, h, U, Y) {
649
- Y === void 0 && (Y = U), c[Y] = h[U];
650
- })), n = Ue && Ue.__setModuleDefault || (Object.create ? (function(c, h) {
648
+ }) : (function(c, h, M, Y) {
649
+ Y === void 0 && (Y = M), c[Y] = h[M];
650
+ })), t = Me && Me.__setModuleDefault || (Object.create ? (function(c, h) {
651
651
  Object.defineProperty(c, "default", { enumerable: !0, value: h });
652
652
  }) : function(c, h) {
653
653
  c.default = h;
654
- }), t = Ue && Ue.__importStar || function(c) {
654
+ }), n = Me && Me.__importStar || function(c) {
655
655
  if (c && c.__esModule) return c;
656
656
  var h = {};
657
- if (c != null) for (var U in c) Object.hasOwnProperty.call(c, U) && e(h, c, U);
658
- return n(h, c), h;
659
- }, r = Ue && Ue.__importDefault || function(c) {
657
+ if (c != null) for (var M in c) Object.hasOwnProperty.call(c, M) && e(h, c, M);
658
+ return t(h, c), h;
659
+ }, r = Me && Me.__importDefault || function(c) {
660
660
  return c && c.__esModule ? c : { default: c };
661
661
  };
662
662
  Object.defineProperty(a, "__esModule", { value: !0 }), a.type = a.remove = a.insert = void 0;
663
- const u = pt(), o = t(ht()), l = r(rn()), E = {
663
+ const u = pt(), o = n(ht()), l = r(an()), E = {
664
664
  create(c) {
665
665
  return c;
666
666
  },
@@ -672,17 +672,17 @@ function sn() {
672
672
  throw Error("Invalid document snapshot: " + c);
673
673
  const h = [];
674
674
  return {
675
- skip(U) {
676
- let Y = u.uniToStrPos(c, U);
675
+ skip(M) {
676
+ let Y = u.uniToStrPos(c, M);
677
677
  if (Y > c.length)
678
678
  throw Error("The op is too long for this document");
679
679
  h.push(c.slice(0, Y)), c = c.slice(Y);
680
680
  },
681
- append(U) {
682
- h.push(U);
681
+ append(M) {
682
+ h.push(M);
683
683
  },
684
- del(U) {
685
- c = c.slice(u.uniToStrPos(c, U));
684
+ del(M) {
685
+ c = c.slice(u.uniToStrPos(c, M));
686
686
  },
687
687
  build() {
688
688
  return h.join("") + c;
@@ -696,10 +696,10 @@ function sn() {
696
696
  Object.defineProperty(a, "makeType", { enumerable: !0, get: function() {
697
697
  return s.default;
698
698
  } });
699
- })(Ue)), Ue;
699
+ })(Me)), Me;
700
700
  }
701
701
  var Pt;
702
- function on() {
702
+ function un() {
703
703
  return Pt || (Pt = 1, (function(a) {
704
704
  var e = Ze && Ze.__importDefault || function(i) {
705
705
  return i && i.__esModule ? i : {
@@ -709,7 +709,7 @@ function on() {
709
709
  Object.defineProperty(a, "__esModule", {
710
710
  value: !0
711
711
  }), a.editOp = a.replaceOp = a.insertOp = a.moveOp = a.removeOp = a.type = void 0;
712
- const n = e(tn()), t = e(nn()), r = St(), u = kt();
712
+ const t = e(sn()), n = e(on()), r = Ut(), u = At();
713
713
  function o(i, d) {
714
714
  if (!i) throw new Error(d);
715
715
  }
@@ -724,7 +724,7 @@ function on() {
724
724
  },
725
725
  registerSubtype: Z,
726
726
  checkValidOp: z,
727
- normalize: K,
727
+ normalize: $,
728
728
  apply: Ee,
729
729
  transformPosition: ce,
730
730
  compose: ne,
@@ -732,13 +732,13 @@ function on() {
732
732
  transform: jt,
733
733
  makeInvertible: De,
734
734
  invert: le,
735
- invertWithDoc: Ut,
735
+ invertWithDoc: Mt,
736
736
  RM_UNEXPECTED_CONTENT: u.ConflictType.RM_UNEXPECTED_CONTENT,
737
737
  DROP_COLLISION: u.ConflictType.DROP_COLLISION,
738
738
  BLACKHOLE: u.ConflictType.BLACKHOLE,
739
- transformNoConflict: (i, d, m) => yt(() => !0, i, d, m),
739
+ transformNoConflict: (i, d, v) => yt(() => !0, i, d, v),
740
740
  typeAllowingConflictsPred: (i) => Object.assign(Object.assign({}, a.type), {
741
- transform: (d, m, D) => yt(i, d, m, D)
741
+ transform: (d, v, D) => yt(i, d, v, D)
742
742
  })
743
743
  };
744
744
  const l = (i) => i ? i.getComponent() : null;
@@ -749,23 +749,23 @@ function on() {
749
749
  function c(i, d) {
750
750
  return o(i != null), typeof d == "number" ? (o(Array.isArray(i), "Invalid key - child is not an array"), (i = i.slice()).splice(d, 1)) : (o(E(i), "Invalid key - child is not an object"), delete (i = Object.assign({}, i))[d]), i;
751
751
  }
752
- function h(i, d, m) {
753
- return typeof d == "number" ? (o(i != null, "Container is missing for key"), o(Array.isArray(i), "Cannot use numerical key for object container"), o(i.length >= d, "Cannot insert into out of bounds index"), i.splice(d, 0, m)) : (o(E(i), "Cannot insert into missing item"), o(i[d] === void 0, "Trying to overwrite value at key. Your op needs to remove it first"), i[d] = m), m;
752
+ function h(i, d, v) {
753
+ return typeof d == "number" ? (o(i != null, "Container is missing for key"), o(Array.isArray(i), "Cannot use numerical key for object container"), o(i.length >= d, "Cannot insert into out of bounds index"), i.splice(d, 0, v)) : (o(E(i), "Cannot insert into missing item"), o(i[d] === void 0, "Trying to overwrite value at key. Your op needs to remove it first"), i[d] = v), v;
754
754
  }
755
- a.removeOp = (i, d = !0) => r.writeCursor().writeAtPath(i, "r", d).get(), a.moveOp = (i, d) => r.writeCursor().writeMove(i, d).get(), a.insertOp = (i, d) => r.writeCursor().writeAtPath(i, "i", d).get(), a.replaceOp = (i, d, m) => r.writeCursor().at(i, (D) => {
756
- D.write("r", d), D.write("i", m);
757
- }).get(), a.editOp = (i, d, m, D = !1) => r.writeCursor().at(i, (O) => y(O, d, m, D)).get();
758
- const U = (i, d) => i != null && (typeof d == "number" ? Array.isArray(i) : typeof i == "object"), Y = (i, d) => U(i, d) ? i[d] : void 0, pe = {};
755
+ a.removeOp = (i, d = !0) => r.writeCursor().writeAtPath(i, "r", d).get(), a.moveOp = (i, d) => r.writeCursor().writeMove(i, d).get(), a.insertOp = (i, d) => r.writeCursor().writeAtPath(i, "i", d).get(), a.replaceOp = (i, d, v) => r.writeCursor().at(i, (D) => {
756
+ D.write("r", d), D.write("i", v);
757
+ }).get(), a.editOp = (i, d, v, D = !1) => r.writeCursor().at(i, (O) => y(O, d, v, D)).get();
758
+ const M = (i, d) => i != null && (typeof d == "number" ? Array.isArray(i) : typeof i == "object"), Y = (i, d) => M(i, d) ? i[d] : void 0, pe = {};
759
759
  function Z(i) {
760
760
  let d = i.type ? i.type : i;
761
761
  d.name && (pe[d.name] = d), d.uri && (pe[d.uri] = d);
762
762
  }
763
- const Ce = (i) => {
763
+ const Ie = (i) => {
764
764
  const d = pe[i];
765
765
  if (d) return d;
766
766
  throw Error("Missing type: " + i);
767
767
  };
768
- Z(sn());
768
+ Z(ln());
769
769
  const qe = (i, d) => i + d;
770
770
  Z({
771
771
  name: "number",
@@ -774,9 +774,9 @@ function on() {
774
774
  invert: (i) => -i,
775
775
  transform: (i) => i
776
776
  });
777
- const ve = (i) => i == null ? null : i.et ? Ce(i.et) : i.es ? pe["text-unicode"] : i.ena != null ? pe.number : null, f = (i) => i.es ? i.es : i.ena != null ? i.ena : i.e, y = (i, d, m, D = !1) => {
778
- const [O, I] = typeof d == "string" ? [Ce(d), d] : [d, d.name];
779
- !D && O.isNoop && O.isNoop(m) || (I === "number" ? i.write("ena", m) : I === "text-unicode" ? i.write("es", m) : (i.write("et", I), i.write("e", m)));
777
+ const me = (i) => i == null ? null : i.et ? Ie(i.et) : i.es ? pe["text-unicode"] : i.ena != null ? pe.number : null, f = (i) => i.es ? i.es : i.ena != null ? i.ena : i.e, y = (i, d, v, D = !1) => {
778
+ const [O, C] = typeof d == "string" ? [Ie(d), d] : [d, d.name];
779
+ !D && O.isNoop && O.isNoop(v) || (C === "number" ? i.write("ena", v) : C === "text-unicode" ? i.write("es", v) : (i.write("et", C), i.write("e", v)));
780
780
  };
781
781
  function b(i) {
782
782
  o(typeof i == "number"), o(i >= 0), o(i === (0 | i));
@@ -786,522 +786,522 @@ function on() {
786
786
  }
787
787
  function z(i) {
788
788
  if (i === null) return;
789
- const d = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), D = (I) => {
789
+ const d = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), D = (C) => {
790
790
  let x = !0, N = !1;
791
- for (let p in I) {
792
- const v = I[p];
793
- if (x = !1, o(p === "p" || p === "r" || p === "d" || p === "i" || p === "e" || p === "es" || p === "ena" || p === "et", "Invalid component item '" + p + "'"), p === "p") b(v), o(!d.has(v)), d.add(v), o(I.r === void 0);
794
- else if (p === "d") b(v), o(!m.has(v)), m.add(v), o(I.i === void 0);
791
+ for (let p in C) {
792
+ const m = C[p];
793
+ if (x = !1, o(p === "p" || p === "r" || p === "d" || p === "i" || p === "e" || p === "es" || p === "ena" || p === "et", "Invalid component item '" + p + "'"), p === "p") b(m), o(!d.has(m)), d.add(m), o(C.r === void 0);
794
+ else if (p === "d") b(m), o(!v.has(m)), v.add(m), o(C.i === void 0);
795
795
  else if (p === "e" || p === "es" || p === "ena") {
796
796
  o(!N), N = !0;
797
- const w = ve(I);
798
- o(w, "Missing type in edit"), w.checkValidOp && w.checkValidOp(f(I));
797
+ const w = me(C);
798
+ o(w, "Missing type in edit"), w.checkValidOp && w.checkValidOp(f(C));
799
799
  }
800
800
  }
801
801
  o(!x);
802
- }, O = (I, x, N) => {
803
- if (!Array.isArray(I)) throw Error("Op must be null or a list");
804
- if (I.length === 0) throw Error("Empty descent");
805
- x || q(I[0]);
806
- let p = 1, v = 0, w = 0;
807
- for (let C = 0; C < I.length; C++) {
808
- const R = I[C];
802
+ }, O = (C, x, N) => {
803
+ if (!Array.isArray(C)) throw Error("Op must be null or a list");
804
+ if (C.length === 0) throw Error("Empty descent");
805
+ x || q(C[0]);
806
+ let p = 1, m = 0, w = 0;
807
+ for (let I = 0; I < C.length; I++) {
808
+ const R = C[I];
809
809
  if (o(R != null), Array.isArray(R)) {
810
810
  const W = O(R, !1);
811
- if (v) {
812
- const g = typeof w, S = typeof W;
813
- g === S ? o(w < W, "descent keys are not in order") : o(g === "number" && S === "string");
811
+ if (m) {
812
+ const g = typeof w, U = typeof W;
813
+ g === U ? o(w < W, "descent keys are not in order") : o(g === "number" && U === "string");
814
814
  }
815
- w = W, v++, p = 3;
815
+ w = W, m++, p = 3;
816
816
  } else typeof R == "object" ? (o(p === 1, `Prev not scalar - instead ${p}`), D(R), p = 2) : (o(p !== 3), q(R), o(r.isValidPathItem(R), "Invalid path key"), p = 1);
817
817
  }
818
- return o(v !== 1, "Operation makes multiple descents. Remove some []"), o(p === 2 || p === 3), I[0];
818
+ return o(m !== 1, "Operation makes multiple descents. Remove some []"), o(p === 2 || p === 3), C[0];
819
819
  };
820
- O(i, !0), o(d.size === m.size, "Mismatched picks and drops in op");
821
- for (let I = 0; I < d.size; I++) o(d.has(I)), o(m.has(I));
820
+ O(i, !0), o(d.size === v.size, "Mismatched picks and drops in op");
821
+ for (let C = 0; C < d.size; C++) o(d.has(C)), o(v.has(C));
822
822
  }
823
- function K(i) {
824
- let d = 0, m = [];
823
+ function $(i) {
824
+ let d = 0, v = [];
825
825
  const D = r.writeCursor();
826
- return D.mergeTree(i, (O, I) => {
827
- const x = ve(O);
826
+ return D.mergeTree(i, (O, C) => {
827
+ const x = me(O);
828
828
  if (x) {
829
829
  const p = f(O);
830
- y(I, x, x.normalize ? x.normalize(p) : p);
830
+ y(C, x, x.normalize ? x.normalize(p) : p);
831
831
  }
832
832
  for (const p of ["r", "p", "i", "d"]) if (O[p] !== void 0) {
833
- const v = p === "p" || p === "d" ? (N = O[p], m[N] == null && (m[N] = d++), m[N]) : O[p];
834
- I.write(p, v);
833
+ const m = p === "p" || p === "d" ? (N = O[p], v[N] == null && (v[N] = d++), v[N]) : O[p];
834
+ C.write(p, m);
835
835
  }
836
836
  var N;
837
837
  }), D.get();
838
838
  }
839
839
  function Ee(i, d) {
840
840
  if (z(d), d === null) return i;
841
- const m = [];
842
- return (function D(O, I) {
841
+ const v = [];
842
+ return (function D(O, C) {
843
843
  let x = O, N = 0, p = {
844
844
  root: O
845
- }, v = 0, w = p, C = "root";
845
+ }, m = 0, w = p, I = "root";
846
846
  function R() {
847
- for (; v < N; v++) {
848
- let W = I[v];
849
- typeof W != "object" && (o(U(w, C)), w = w[C] = B(w[C]), C = W);
847
+ for (; m < N; m++) {
848
+ let W = C[m];
849
+ typeof W != "object" && (o(M(w, I)), w = w[I] = B(w[I]), I = W);
850
850
  }
851
851
  }
852
- for (; N < I.length; N++) {
853
- const W = I[N];
852
+ for (; N < C.length; N++) {
853
+ const W = C[N];
854
854
  if (Array.isArray(W)) {
855
855
  const g = D(x, W);
856
- g !== x && g !== void 0 && (R(), x = w[C] = g);
856
+ g !== x && g !== void 0 && (R(), x = w[I] = g);
857
857
  } else if (typeof W == "object") {
858
- W.d != null ? (R(), x = h(w, C, m[W.d])) : W.i !== void 0 && (R(), x = h(w, C, W.i));
859
- const g = ve(W);
860
- if (g) R(), x = w[C] = g.apply(x, f(W));
858
+ W.d != null ? (R(), x = h(w, I, v[W.d])) : W.i !== void 0 && (R(), x = h(w, I, W.i));
859
+ const g = me(W);
860
+ if (g) R(), x = w[I] = g.apply(x, f(W));
861
861
  else if (W.e !== void 0) throw Error("Subtype " + W.et + " undefined");
862
862
  } else x = Y(x, W);
863
863
  }
864
864
  return p.root;
865
- })(i = (function D(O, I) {
865
+ })(i = (function D(O, C) {
866
866
  const x = [];
867
867
  let N = 0;
868
- for (; N < I.length; N++) {
869
- const C = I[N];
870
- if (Array.isArray(C)) break;
871
- typeof C != "object" && (x.push(O), O = Y(O, C));
868
+ for (; N < C.length; N++) {
869
+ const I = C[N];
870
+ if (Array.isArray(I)) break;
871
+ typeof I != "object" && (x.push(O), O = Y(O, I));
872
872
  }
873
- for (let C = I.length - 1; C >= N; C--) O = D(O, I[C]);
873
+ for (let I = C.length - 1; I >= N; I--) O = D(O, C[I]);
874
874
  for (--N; N >= 0; N--) {
875
- const C = I[N];
876
- if (typeof C != "object") {
875
+ const I = C[N];
876
+ if (typeof I != "object") {
877
877
  const R = x.pop();
878
- O = O === Y(R, C) ? R : O === void 0 ? c(R, C) : (v = C, w = O, (p = B(p = R))[v] = w, p);
879
- } else _(C) && (o(O !== void 0, "Cannot pick up or remove undefined"), C.p != null && (m[C.p] = O), O = void 0);
878
+ O = O === Y(R, I) ? R : O === void 0 ? c(R, I) : (m = I, w = O, (p = B(p = R))[m] = w, p);
879
+ } else _(I) && (o(O !== void 0, "Cannot pick up or remove undefined"), I.p != null && (v[I.p] = O), O = void 0);
880
880
  }
881
- var p, v, w;
881
+ var p, m, w;
882
882
  return O;
883
883
  })(i, d), d);
884
884
  }
885
885
  function ce(i, d) {
886
886
  i = i.slice(), z(d);
887
- const m = r.readCursor(d);
888
- let D, O, I = !1;
887
+ const v = r.readCursor(d);
888
+ let D, O, C = !1;
889
889
  const x = [];
890
890
  for (let p = 0; ; p++) {
891
- const v = i[p], w = m.getComponent();
892
- if (w && (w.r !== void 0 ? I = !0 : w.p != null && (I = !1, D = w.p, O = p)), p >= i.length) break;
893
- let C = 0;
894
- const R = r.advancer(m, void 0, (g, S) => {
895
- _(S) && C++;
891
+ const m = i[p], w = v.getComponent();
892
+ if (w && (w.r !== void 0 ? C = !0 : w.p != null && (C = !1, D = w.p, O = p)), p >= i.length) break;
893
+ let I = 0;
894
+ const R = r.advancer(v, void 0, (g, U) => {
895
+ _(U) && I++;
896
896
  });
897
897
  x.unshift(R);
898
- const W = R(v);
899
- if (typeof v == "number" && (i[p] -= C), !W) break;
898
+ const W = R(m);
899
+ if (typeof m == "number" && (i[p] -= I), !W) break;
900
900
  }
901
- if (x.forEach((p) => p.end()), I) return null;
901
+ if (x.forEach((p) => p.end()), C) return null;
902
902
  const N = () => {
903
903
  let p = 0;
904
904
  if (D != null) {
905
- const v = m.getPath();
906
- p = v.length, i = v.concat(i.slice(O));
905
+ const m = v.getPath();
906
+ p = m.length, i = m.concat(i.slice(O));
907
907
  }
908
908
  for (; p < i.length; p++) {
909
- const v = i[p], w = l(m), C = ve(w);
910
- if (C) {
909
+ const m = i[p], w = l(v), I = me(w);
910
+ if (I) {
911
911
  const g = f(w);
912
- C.transformPosition && (i[p] = C.transformPosition(i[p], g));
912
+ I.transformPosition && (i[p] = I.transformPosition(i[p], g));
913
913
  break;
914
914
  }
915
915
  let R = 0;
916
- const W = r.advancer(m, (g, S) => s(S) ? ~(g - R) : g - R, (g, S) => {
917
- s(S) && R++;
918
- })(v);
919
- if (typeof v == "number" && (i[p] += R), !W) break;
916
+ const W = r.advancer(v, (g, U) => s(U) ? ~(g - R) : g - R, (g, U) => {
917
+ s(U) && R++;
918
+ })(m);
919
+ if (typeof m == "number" && (i[p] += R), !W) break;
920
920
  }
921
921
  };
922
- return D != null ? m.eachDrop(null, (p) => {
922
+ return D != null ? v.eachDrop(null, (p) => {
923
923
  p === D && N();
924
924
  }) : N(), i;
925
925
  }
926
926
  function ne(i, d) {
927
927
  if (z(i), z(d), i == null) return d;
928
928
  if (d == null) return i;
929
- let m = 0;
930
- const D = r.readCursor(i), O = r.readCursor(d), I = r.writeCursor(), x = [], N = [], p = [], v = [], w = [], C = [], R = /* @__PURE__ */ new Set();
929
+ let v = 0;
930
+ const D = r.readCursor(i), O = r.readCursor(d), C = r.writeCursor(), x = [], N = [], p = [], m = [], w = [], I = [], R = /* @__PURE__ */ new Set();
931
931
  D.traverse(null, (g) => {
932
932
  g.p != null && (p[g.p] = D.clone());
933
933
  }), O.traverse(null, (g) => {
934
- g.d != null && (v[g.d] = O.clone());
934
+ g.d != null && (m[g.d] = O.clone());
935
935
  });
936
936
  const W = r.writeCursor();
937
- return (function g(S, re, te, $, se, Re, Oe, ye) {
937
+ return (function g(U, re, te, K, se, Re, Oe, ye) {
938
938
  o(re || te);
939
- const oe = l(re), Pe = l(te), Ae = !!Pe && Pe.r !== void 0, Ke = !!oe && oe.i !== void 0, Te = oe ? oe.d : null, Ie = Pe ? Pe.p : null, xe = (Re || Ae) && Ie == null;
940
- if (Ie != null) $ = v[Ie], Oe = N[Ie] = new r.WriteCursor();
941
- else if (Pe && Pe.r !== void 0) $ = null;
939
+ const oe = l(re), Pe = l(te), Se = !!Pe && Pe.r !== void 0, $e = !!oe && oe.i !== void 0, Te = oe ? oe.d : null, Ce = Pe ? Pe.p : null, xe = (Re || Se) && Ce == null;
940
+ if (Ce != null) K = m[Ce], Oe = N[Ce] = new r.WriteCursor();
941
+ else if (Pe && Pe.r !== void 0) K = null;
942
942
  else {
943
- const T = l($);
944
- T && T.d != null && ($ = null);
943
+ const T = l(K);
944
+ T && T.d != null && (K = null);
945
945
  }
946
- const Q = l($);
947
- if (Te != null) if (S = p[Te], ye = x[Te] = new r.WriteCursor(), xe) Re && !Ae && ye.write("r", !0);
946
+ const Q = l(K);
947
+ if (Te != null) if (U = p[Te], ye = x[Te] = new r.WriteCursor(), xe) Re && !Se && ye.write("r", !0);
948
948
  else {
949
- const T = w[Te] = m++;
949
+ const T = w[Te] = v++;
950
950
  Oe.write("d", T);
951
951
  }
952
- else if (oe && oe.i !== void 0) S = null;
952
+ else if (oe && oe.i !== void 0) U = null;
953
953
  else {
954
- const T = l(S);
955
- T && T.p != null && (S = null);
954
+ const T = l(U);
955
+ T && T.p != null && (U = null);
956
956
  }
957
- let A;
958
- Ke ? (o(se === void 0), A = oe.i) : A = se;
959
- const G = (Ie == null ? !Ke || Re || Ae : A === void 0) ? null : Oe.getComponent();
960
- if (Ie != null) {
961
- if (!(se !== void 0 || Ke)) {
962
- const T = Te != null ? w[Te] : m++;
963
- C[Ie] = T, ye.write("p", T);
957
+ let S;
958
+ $e ? (o(se === void 0), S = oe.i) : S = se;
959
+ const L = (Ce == null ? !$e || Re || Se : S === void 0) ? null : Oe.getComponent();
960
+ if (Ce != null) {
961
+ if (!(se !== void 0 || $e)) {
962
+ const T = Te != null ? w[Te] : v++;
963
+ I[Ce] = T, ye.write("p", T);
964
964
  }
965
- } else Ae && (Ke || se !== void 0 || (Pe.r, ye.write("r", Pe.r)));
966
- const M = xe ? null : ve(oe), P = ve(Q);
967
- if ((M || P) && (M && M.name, P && P.name), M && P) {
968
- o(M === P);
969
- const T = f(oe), L = f(Q), he = M.compose(T, L);
970
- y(Oe, M, he), R.add(Q);
971
- } else M ? y(Oe, M, f(oe)) : P && (y(Oe, P, f(Q)), R.add(Q));
972
- const k = typeof A == "object" && A != null;
965
+ } else Se && ($e || se !== void 0 || (Pe.r, ye.write("r", Pe.r)));
966
+ const k = xe ? null : me(oe), P = me(Q);
967
+ if ((k || P) && (k && k.name, P && P.name), k && P) {
968
+ o(k === P);
969
+ const T = f(oe), G = f(Q), he = k.compose(T, G);
970
+ y(Oe, k, he), R.add(Q);
971
+ } else k ? y(Oe, k, f(oe)) : P && (y(Oe, P, f(Q)), R.add(Q));
972
+ const A = typeof S == "object" && S != null;
973
973
  let J = !1, X = 0, ee = 0, fe = 0, de = 0, ae = 0;
974
- const me = r.advancer($, (T, L) => s(L) ? de - T - 1 : T - de, (T, L) => {
975
- s(L) && de++;
976
- }), H = r.advancer(S, (T, L) => _(L) ? X - T - 1 : T - X, (T, L) => {
977
- _(L) && X++;
974
+ const ve = r.advancer(K, (T, G) => s(G) ? de - T - 1 : T - de, (T, G) => {
975
+ s(G) && de++;
976
+ }), H = r.advancer(U, (T, G) => _(G) ? X - T - 1 : T - X, (T, G) => {
977
+ _(G) && X++;
978
978
  });
979
- if (r.eachChildOf(re, te, (T, L, he) => {
980
- let we, Be, $e = T, Me = T, Ye = T;
979
+ if (r.eachChildOf(re, te, (T, G, he) => {
980
+ let we, Be, Ke = T, ke = T, Ye = T;
981
981
  if (typeof T == "number") {
982
982
  let _e = T + fe;
983
- Be = me(_e), Me = _e + de;
983
+ Be = ve(_e), ke = _e + de;
984
984
  let ue = T + ee;
985
- we = H(ue), s(l(Be)) && (we = null), $e = ue + X, Ye = T + ae, o($e >= 0, "p1PickKey is negative"), o(Me >= 0, "p2DropKey is negative");
986
- const Se = s(l(L)), We = _(l(he));
987
- (Se || We && !xe) && ae--, Se && ee--, We && fe--;
988
- } else we = H(T), Be = me(T);
989
- ye.descend($e), Oe.descend(Me);
990
- const Xe = k && !s(l(L)) ? A[Ye] : void 0, je = g(we, L, he, Be, Xe, xe, Oe, ye);
985
+ we = H(ue), s(l(Be)) && (we = null), Ke = ue + X, Ye = T + ae, o(Ke >= 0, "p1PickKey is negative"), o(ke >= 0, "p2DropKey is negative");
986
+ const Ue = s(l(G)), We = _(l(he));
987
+ (Ue || We && !xe) && ae--, Ue && ee--, We && fe--;
988
+ } else we = H(T), Be = ve(T);
989
+ ye.descend(Ke), Oe.descend(ke);
990
+ const Xe = A && !s(l(G)) ? S[Ye] : void 0, je = g(we, G, he, Be, Xe, xe, Oe, ye);
991
991
  var Ne, j, ie;
992
- k && !xe ? Xe !== je && (J || (A = Array.isArray(A) ? A.slice() : Object.assign({}, A), J = !0), Ne = A, ie = je, typeof (j = Ye) == "number" ? (o(Array.isArray(Ne)), o(j < Ne.length)) : (o(!Array.isArray(Ne)), o(Ne[j] !== void 0)), ie === void 0 ? typeof j == "number" ? Ne.splice(j, 1) : delete Ne[j] : Ne[j] = ie) : o(je === void 0), Oe.ascend(), ye.ascend();
993
- }), H.end(), me.end(), G != null) G.i = A;
994
- else if (!Re && !Ae && Ie == null) return A;
995
- })(D, D.clone(), O, O.clone(), void 0, !1, I, W), I.reset(), I.mergeTree(W.get()), I.reset(), I.get(), x.map((g) => g.get()), N.map((g) => g.get()), D.traverse(I, (g, S) => {
992
+ A && !xe ? Xe !== je && (J || (S = Array.isArray(S) ? S.slice() : Object.assign({}, S), J = !0), Ne = S, ie = je, typeof (j = Ye) == "number" ? (o(Array.isArray(Ne)), o(j < Ne.length)) : (o(!Array.isArray(Ne)), o(Ne[j] !== void 0)), ie === void 0 ? typeof j == "number" ? Ne.splice(j, 1) : delete Ne[j] : Ne[j] = ie) : o(je === void 0), Oe.ascend(), ye.ascend();
993
+ }), H.end(), ve.end(), L != null) L.i = S;
994
+ else if (!Re && !Se && Ce == null) return S;
995
+ })(D, D.clone(), O, O.clone(), void 0, !1, C, W), C.reset(), C.mergeTree(W.get()), C.reset(), C.get(), x.map((g) => g.get()), N.map((g) => g.get()), D.traverse(C, (g, U) => {
996
996
  const re = g.p;
997
997
  if (re != null) {
998
998
  const te = w[re];
999
- te != null && S.write("p", te);
1000
- const $ = x[re];
1001
- $ && $.get(), $ && S.mergeTree($.get());
1002
- } else g.r !== void 0 && S.write("r", g.r);
1003
- }), I.reset(), I.get(), O.traverse(I, (g, S) => {
999
+ te != null && U.write("p", te);
1000
+ const K = x[re];
1001
+ K && K.get(), K && U.mergeTree(K.get());
1002
+ } else g.r !== void 0 && U.write("r", g.r);
1003
+ }), C.reset(), C.get(), O.traverse(C, (g, U) => {
1004
1004
  const re = g.d;
1005
1005
  if (re != null) {
1006
- const $ = C[re];
1007
- $ != null && S.write("d", $);
1006
+ const K = I[re];
1007
+ K != null && U.write("d", K);
1008
1008
  const se = N[re];
1009
- se && S.mergeTree(se.get());
1010
- } else g.i !== void 0 && S.write("i", g.i);
1011
- const te = ve(g);
1012
- te && !R.has(g) && y(S, te, f(g));
1013
- }), I.get();
1009
+ se && U.mergeTree(se.get());
1010
+ } else g.i !== void 0 && U.write("i", g.i);
1011
+ const te = me(g);
1012
+ te && !R.has(g) && y(U, te, f(g));
1013
+ }), C.get();
1014
1014
  }
1015
1015
  function le(i) {
1016
1016
  if (i == null) return null;
1017
- const d = new r.ReadCursor(i), m = new r.WriteCursor();
1017
+ const d = new r.ReadCursor(i), v = new r.WriteCursor();
1018
1018
  let D;
1019
- const O = [], I = [];
1020
- return (function x(N, p, v) {
1019
+ const O = [], C = [];
1020
+ return (function x(N, p, m) {
1021
1021
  const w = N.getComponent();
1022
- let C, R = !1;
1022
+ let I, R = !1;
1023
1023
  if (w) {
1024
- w.p != null && (p.write("d", w.p), O[w.p] = N.clone()), w.r !== void 0 && p.write("i", w.r), w.d != null && (p.write("p", w.d), v = void 0), w.i !== void 0 && (v = C = w.i);
1025
- const g = ve(w);
1026
- g && (v === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(w)) : (f(w), v = g.apply(v, f(w)), R = !0));
1024
+ w.p != null && (p.write("d", w.p), O[w.p] = N.clone()), w.r !== void 0 && p.write("i", w.r), w.d != null && (p.write("p", w.d), m = void 0), w.i !== void 0 && (m = I = w.i);
1025
+ const g = me(w);
1026
+ g && (m === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(w)) : (f(w), m = g.apply(m, f(w)), R = !0));
1027
1027
  }
1028
1028
  let W = 0;
1029
1029
  for (const g of N) {
1030
1030
  p.descend(g);
1031
- const S = typeof g == "number" ? g - W : g, re = Y(v, S);
1031
+ const U = typeof g == "number" ? g - W : g, re = Y(m, U);
1032
1032
  s(N.getComponent()) && W++;
1033
1033
  const te = x(N, p, re);
1034
- if (v !== void 0 && te !== void 0) {
1035
- if (R || (R = !0, v = B(v)), !U(v, S)) throw Error("Cannot modify child - invalid operation");
1036
- v[S] = te;
1034
+ if (m !== void 0 && te !== void 0) {
1035
+ if (R || (R = !0, m = B(m)), !M(m, U)) throw Error("Cannot modify child - invalid operation");
1036
+ m[U] = te;
1037
1037
  }
1038
1038
  p.ascend();
1039
1039
  }
1040
- if (C === void 0) return R ? v : void 0;
1041
- p.write("r", v);
1042
- })(d, m, void 0), D && (m.reset(), (function x(N, p, v) {
1040
+ if (I === void 0) return R ? m : void 0;
1041
+ p.write("r", m);
1042
+ })(d, v, void 0), D && (v.reset(), (function x(N, p, m) {
1043
1043
  const w = p.getComponent();
1044
1044
  if (w) {
1045
1045
  const g = w.d;
1046
- if (g != null && (N = O[g], v = I[g] = r.writeCursor()), D.has(w)) {
1047
- const S = ve(w);
1048
- if (!S.invert) throw Error(`Cannot invert subtype ${S.name}`);
1049
- y(v, S, S.invert(f(w)));
1046
+ if (g != null && (N = O[g], m = C[g] = r.writeCursor()), D.has(w)) {
1047
+ const U = me(w);
1048
+ if (!U.invert) throw Error(`Cannot invert subtype ${U.name}`);
1049
+ y(m, U, U.invert(f(w)));
1050
1050
  }
1051
1051
  }
1052
- let C = 0, R = 0;
1053
- const W = r.advancer(N, (g, S) => _(S) ? C - g - 1 : g - C, (g, S) => {
1054
- _(S) && C++;
1052
+ let I = 0, R = 0;
1053
+ const W = r.advancer(N, (g, U) => _(U) ? I - g - 1 : g - I, (g, U) => {
1054
+ _(U) && I++;
1055
1055
  });
1056
1056
  for (const g of p) if (typeof g == "number") {
1057
- const S = g - R, re = W(S), te = S + C;
1058
- v.descend(te), x(re, p, v), s(p.getComponent()) && R++, v.ascend();
1059
- } else v.descend(g), x(W(g), p, v), v.ascend();
1057
+ const U = g - R, re = W(U), te = U + I;
1058
+ m.descend(te), x(re, p, m), s(p.getComponent()) && R++, m.ascend();
1059
+ } else m.descend(g), x(W(g), p, m), m.ascend();
1060
1060
  W.end();
1061
- })(d.clone(), d, m), I.length && (m.reset(), d.traverse(m, (x, N) => {
1061
+ })(d.clone(), d, v), C.length && (v.reset(), d.traverse(v, (x, N) => {
1062
1062
  const p = x.p;
1063
1063
  if (p != null) {
1064
- const v = I[p];
1065
- v && v.get(), v && N.mergeTree(v.get());
1064
+ const m = C[p];
1065
+ m && m.get(), m && N.mergeTree(m.get());
1066
1066
  }
1067
- }))), m.get();
1067
+ }))), v.get();
1068
1068
  }
1069
- const ge = (i, d) => i.some((m) => typeof m == "object" && (Array.isArray(m) ? ge(m, d) : d(m)));
1069
+ const ge = (i, d) => i.some((v) => typeof v == "object" && (Array.isArray(v) ? ge(v, d) : d(v)));
1070
1070
  function De(i, d) {
1071
1071
  if (i == null || !ge(i, (p) => {
1072
- var v;
1073
- return p.r !== void 0 || ((v = ve(p)) === null || v === void 0 ? void 0 : v.makeInvertible) != null;
1072
+ var m;
1073
+ return p.r !== void 0 || ((m = me(p)) === null || m === void 0 ? void 0 : m.makeInvertible) != null;
1074
1074
  })) return i;
1075
- const m = new r.ReadCursor(i), D = new r.WriteCursor();
1075
+ const v = new r.ReadCursor(i), D = new r.WriteCursor();
1076
1076
  let O = !1;
1077
- const I = [], x = [], N = (p, v, w) => {
1078
- const C = p.getComponent();
1077
+ const C = [], x = [], N = (p, m, w) => {
1078
+ const I = p.getComponent();
1079
1079
  let R = !1;
1080
- if (C) {
1081
- C.d != null && v.write("d", C.d), C.i !== void 0 && v.write("i", C.i);
1082
- const g = C.p;
1083
- if (g != null && (I[g] = p.clone(), o(w !== void 0, "Operation picks up at an invalid key"), x[g] = w, v.write("p", C.p)), C.r !== void 0 && w === void 0) throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");
1084
- const S = ve(C);
1085
- S && (S.makeInvertible ? O = !0 : y(v, S, f(C), !0));
1080
+ if (I) {
1081
+ I.d != null && m.write("d", I.d), I.i !== void 0 && m.write("i", I.i);
1082
+ const g = I.p;
1083
+ if (g != null && (C[g] = p.clone(), o(w !== void 0, "Operation picks up at an invalid key"), x[g] = w, m.write("p", I.p)), I.r !== void 0 && w === void 0) throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");
1084
+ const U = me(I);
1085
+ U && (U.makeInvertible ? O = !0 : y(m, U, f(I), !0));
1086
1086
  }
1087
1087
  let W = 0;
1088
1088
  for (const g of p) {
1089
- v.descend(g);
1090
- const S = typeof g == "number" ? g - W : g, re = Y(w, S), te = N(p, v, re);
1091
- re !== te && (R || (R = !0, w = B(w)), te === void 0 ? (w = c(w, S), typeof g == "number" && W++) : w[S] = te), v.ascend();
1089
+ m.descend(g);
1090
+ const U = typeof g == "number" ? g - W : g, re = Y(w, U), te = N(p, m, re);
1091
+ re !== te && (R || (R = !0, w = B(w)), te === void 0 ? (w = c(w, U), typeof g == "number" && W++) : w[U] = te), m.ascend();
1092
1092
  }
1093
- return C && (C.r !== void 0 ? (v.write("r", t.default(w)), w = void 0) : C.p != null && (w = void 0)), w;
1093
+ return I && (I.r !== void 0 ? (m.write("r", n.default(w)), w = void 0) : I.p != null && (w = void 0)), w;
1094
1094
  };
1095
- return N(m, D, d), D.get(), O && (D.reset(), (function p(v, w, C, R, W) {
1095
+ return N(v, D, d), D.get(), O && (D.reset(), (function p(m, w, I, R, W) {
1096
1096
  const g = w.getComponent();
1097
1097
  if (g) {
1098
- g.i !== void 0 ? (R = g.i, W = !0) : g.d != null && (R = x[g.d], v = I[g.d], W = !1, g.d);
1099
- let $ = ve(g);
1100
- if ($ && $.makeInvertible) {
1098
+ g.i !== void 0 ? (R = g.i, W = !0) : g.d != null && (R = x[g.d], m = C[g.d], W = !1, g.d);
1099
+ let K = me(g);
1100
+ if (K && K.makeInvertible) {
1101
1101
  const se = f(g);
1102
- y(C, $, $.makeInvertible(se, R), !0);
1102
+ y(I, K, K.makeInvertible(se, R), !0);
1103
1103
  }
1104
1104
  }
1105
- let S = 0, re = 0;
1106
- const te = r.advancer(v, ($, se) => _(se) ? S - $ - 1 : $ - S, ($, se) => {
1107
- _(se) && S++;
1105
+ let U = 0, re = 0;
1106
+ const te = r.advancer(m, (K, se) => _(se) ? U - K - 1 : K - U, (K, se) => {
1107
+ _(se) && U++;
1108
1108
  });
1109
- for (const $ of w) if (typeof $ == "number") {
1110
- const se = $ - re, Re = te(se), Oe = se + S, ye = Y(R, W ? se : Oe);
1111
- C.descend($), p(Re, w, C, ye, W), s(w.getComponent()) && re++, C.ascend();
1109
+ for (const K of w) if (typeof K == "number") {
1110
+ const se = K - re, Re = te(se), Oe = se + U, ye = Y(R, W ? se : Oe);
1111
+ I.descend(K), p(Re, w, I, ye, W), s(w.getComponent()) && re++, I.ascend();
1112
1112
  } else {
1113
- const se = Y(R, $);
1114
- C.descend($), p(te($), w, C, se, W), C.ascend();
1113
+ const se = Y(R, K);
1114
+ I.descend(K), p(te(K), w, I, se, W), I.ascend();
1115
1115
  }
1116
1116
  te.end();
1117
- })(m.clone(), m, D, d, !1)), D.get();
1117
+ })(v.clone(), v, D, d, !1)), D.get();
1118
1118
  }
1119
- function Ut(i, d) {
1119
+ function Mt(i, d) {
1120
1120
  return le(De(i, d));
1121
1121
  }
1122
1122
  const it = (i) => {
1123
1123
  if (i == null) return null;
1124
1124
  const d = i.slice();
1125
- for (let m = 0; m < i.length; m++) {
1126
- const D = d[m];
1127
- Array.isArray(D) && (d[m] = it(D));
1125
+ for (let v = 0; v < i.length; v++) {
1126
+ const D = d[v];
1127
+ Array.isArray(D) && (d[v] = it(D));
1128
1128
  }
1129
1129
  return d;
1130
1130
  };
1131
- function st(i, d, m) {
1132
- o(m === "left" || m === "right", "Direction must be left or right");
1133
- const D = m === "left" ? 0 : 1;
1131
+ function st(i, d, v) {
1132
+ o(v === "left" || v === "right", "Direction must be left or right");
1133
+ const D = v === "left" ? 0 : 1;
1134
1134
  if (d == null) return {
1135
1135
  ok: !0,
1136
1136
  result: i
1137
1137
  };
1138
1138
  z(i), z(d);
1139
1139
  let O = null;
1140
- const I = [], x = [], N = [], p = [], v = [], w = [], C = [], R = [], W = [], g = [], S = [], re = [], te = [], $ = [], se = [];
1140
+ const C = [], x = [], N = [], p = [], m = [], w = [], I = [], R = [], W = [], g = [], U = [], re = [], te = [], K = [], se = [];
1141
1141
  let Re = 0;
1142
1142
  const Oe = r.readCursor(i), ye = r.readCursor(d), oe = r.writeCursor();
1143
- if ((function Q(A, G = null, M) {
1144
- const P = l(G);
1145
- P && (P.r !== void 0 ? M = G.clone() : P.p != null && (M = null, w[P.p] = A.clone()));
1146
- const k = A.getComponent();
1143
+ if ((function Q(S, L = null, k) {
1144
+ const P = l(L);
1145
+ P && (P.r !== void 0 ? k = L.clone() : P.p != null && (k = null, w[P.p] = S.clone()));
1146
+ const A = S.getComponent();
1147
1147
  let J;
1148
- k && (J = k.p) != null && (v[J] = G ? G.clone() : null, N[J] = A.clone(), M && (g[J] = !0, W[J] = M), P && P.p != null && ($[J] = P.p));
1149
- const X = r.advancer(G);
1150
- for (const ee of A) Q(A, X(ee), M);
1148
+ A && (J = A.p) != null && (m[J] = L ? L.clone() : null, N[J] = S.clone(), k && (g[J] = !0, W[J] = k), P && P.p != null && (K[J] = P.p));
1149
+ const X = r.advancer(L);
1150
+ for (const ee of S) Q(S, X(ee), k);
1151
1151
  X.end();
1152
- })(ye, Oe, null), (function Q(A, G, M, P, k) {
1153
- const J = M.getComponent();
1152
+ })(ye, Oe, null), (function Q(S, L, k, P, A) {
1153
+ const J = k.getComponent();
1154
1154
  let X, ee = !1;
1155
- J && ((X = J.d) != null ? (p[X] = M.clone(), P != null && (se[P] == null && (se[P] = []), se[P].push(X)), g[X], A = v[X] || null, G = N[X] || null, g[X] ? (k && (S[X] = !0), k = W[X] || null) : !k || D !== 1 && $[X] != null || O == null && (O = {
1155
+ J && ((X = J.d) != null ? (p[X] = k.clone(), P != null && (se[P] == null && (se[P] = []), se[P].push(X)), g[X], S = m[X] || null, L = N[X] || null, g[X] ? (A && (U[X] = !0), A = W[X] || null) : !A || D !== 1 && K[X] != null || O == null && (O = {
1156
1156
  type: u.ConflictType.RM_UNEXPECTED_CONTENT,
1157
- op1: a.removeOp(k.getPath()),
1158
- op2: a.moveOp(G.getPath(), M.getPath())
1159
- }), ee = !0) : J.i !== void 0 && (A = G = null, ee = !0, k && O == null && (O = {
1157
+ op1: a.removeOp(A.getPath()),
1158
+ op2: a.moveOp(L.getPath(), k.getPath())
1159
+ }), ee = !0) : J.i !== void 0 && (S = L = null, ee = !0, A && O == null && (O = {
1160
1160
  type: u.ConflictType.RM_UNEXPECTED_CONTENT,
1161
- op1: a.removeOp(k.getPath()),
1162
- op2: a.insertOp(M.getPath(), J.i)
1161
+ op1: a.removeOp(A.getPath()),
1162
+ op2: a.insertOp(k.getPath(), J.i)
1163
1163
  })));
1164
- const fe = l(A);
1165
- fe && (fe.r !== void 0 ? k = A.clone() : fe.p != null && (fe.p, P = fe.p, k = null));
1166
- const de = ve(J);
1167
- de && k && O == null && (O = {
1164
+ const fe = l(S);
1165
+ fe && (fe.r !== void 0 ? A = S.clone() : fe.p != null && (fe.p, P = fe.p, A = null));
1166
+ const de = me(J);
1167
+ de && A && O == null && (O = {
1168
1168
  type: u.ConflictType.RM_UNEXPECTED_CONTENT,
1169
- op1: a.removeOp(k.getPath()),
1170
- op2: a.editOp(M.getPath(), de, f(J), !0)
1169
+ op1: a.removeOp(A.getPath()),
1170
+ op2: a.editOp(k.getPath(), de, f(J), !0)
1171
1171
  });
1172
- let ae = 0, me = 0;
1173
- const H = r.advancer(G, (L, he) => _(he) ? ae - L - 1 : L - ae, (L, he) => {
1172
+ let ae = 0, ve = 0;
1173
+ const H = r.advancer(L, (G, he) => _(he) ? ae - G - 1 : G - ae, (G, he) => {
1174
1174
  _(he) && ae++;
1175
- }), T = r.advancer(A);
1176
- for (const L of M) if (typeof L == "number") {
1177
- const he = L - me, we = H(he);
1178
- me += +Q(T(he + ae), we, M, P, k);
1175
+ }), T = r.advancer(S);
1176
+ for (const G of k) if (typeof G == "number") {
1177
+ const he = G - ve, we = H(he);
1178
+ ve += +Q(T(he + ae), we, k, P, A);
1179
1179
  } else {
1180
- const he = H(L);
1181
- Q(T(L), he, M, P, k);
1180
+ const he = H(G);
1181
+ Q(T(G), he, k, P, A);
1182
1182
  }
1183
1183
  return H.end(), T.end(), ee;
1184
1184
  })(Oe, ye, ye.clone(), null, null), p.map((Q) => Q && Q.get()), O) return {
1185
1185
  ok: !1,
1186
1186
  conflict: O
1187
1187
  };
1188
- S.map((Q) => !!Q);
1188
+ U.map((Q) => !!Q);
1189
1189
  const Pe = [];
1190
- let Ae = null;
1191
- (function Q(A, G, M, P, k) {
1190
+ let Se = null;
1191
+ (function Q(S, L, k, P, A) {
1192
1192
  let J = !1;
1193
- const X = l(G);
1193
+ const X = l(L);
1194
1194
  if (_(X)) {
1195
1195
  const H = X.p;
1196
- H != null ? (M = p[H], P = re[H] = r.writeCursor(), J = !0, k = null) : (M = null, k = G.clone());
1197
- } else s(l(M)) && (M = null);
1198
- const ee = A.getComponent();
1196
+ H != null ? (k = p[H], P = re[H] = r.writeCursor(), J = !0, A = null) : (k = null, A = L.clone());
1197
+ } else s(l(k)) && (k = null);
1198
+ const ee = S.getComponent();
1199
1199
  if (ee) {
1200
1200
  const H = ee.p;
1201
- H != null ? (k && (R[H] = k), Pe[H] = k || D === 1 && J ? null : P.getComponent(), I[H] = A.clone(), M && (C[H] = M.clone())) : ee.r !== void 0 && (k || P.write("r", !0), (k || J) && (Ae == null && (Ae = /* @__PURE__ */ new Set()), Ae.add(ee)));
1201
+ H != null ? (A && (R[H] = A), Pe[H] = A || D === 1 && J ? null : P.getComponent(), C[H] = S.clone(), k && (I[H] = k.clone())) : ee.r !== void 0 && (A || P.write("r", !0), (A || J) && (Se == null && (Se = /* @__PURE__ */ new Set()), Se.add(ee)));
1202
1202
  }
1203
1203
  let fe = 0, de = 0;
1204
- const ae = r.advancer(G, void 0, (H, T) => {
1204
+ const ae = r.advancer(L, void 0, (H, T) => {
1205
1205
  _(T) && fe++;
1206
- }), me = r.advancer(M, (H, T) => s(T) ? ~(H - de) : H - de, (H, T) => {
1206
+ }), ve = r.advancer(k, (H, T) => s(T) ? ~(H - de) : H - de, (H, T) => {
1207
1207
  s(T) && de++;
1208
1208
  });
1209
- if (A) for (const H of A) if (typeof H == "string") {
1210
- const T = ae(H), L = me(H);
1211
- P.descend(H), Q(A, T, L, P, k), P.ascend();
1209
+ if (S) for (const H of S) if (typeof H == "string") {
1210
+ const T = ae(H), G = ve(H);
1211
+ P.descend(H), Q(S, T, G, P, A), P.ascend();
1212
1212
  } else {
1213
- const T = ae(H), L = H - fe, he = _(l(T)) ? null : me(L), we = L + de;
1214
- o(we >= 0), P.descend(we), Q(A, T, he, P, k), P.ascend();
1213
+ const T = ae(H), G = H - fe, he = _(l(T)) ? null : ve(G), we = G + de;
1214
+ o(we >= 0), P.descend(we), Q(S, T, he, P, A), P.ascend();
1215
1215
  }
1216
- ae.end(), me.end();
1216
+ ae.end(), ve.end();
1217
1217
  })(Oe, ye, ye.clone(), oe, null), oe.reset();
1218
- let Ke = [];
1219
- if ((function Q(A, G, M, P, k, J) {
1220
- o(G);
1221
- const X = G.getComponent();
1218
+ let $e = [];
1219
+ if ((function Q(S, L, k, P, A, J) {
1220
+ o(L);
1221
+ const X = L.getComponent();
1222
1222
  let ee = l(P), fe = !1;
1223
1223
  const de = (j, ie, _e) => j ? a.moveOp(j.getPath(), ie.getPath()) : a.insertOp(ie.getPath(), _e.i);
1224
1224
  if (s(X)) {
1225
1225
  const j = X.d;
1226
- j != null && (x[j] = G.clone());
1226
+ j != null && (x[j] = L.clone());
1227
1227
  const ie = j != null ? Pe[j] : null;
1228
1228
  let _e = !1;
1229
1229
  if (X.i !== void 0 || j != null && ie) {
1230
1230
  let ue;
1231
- ee && (ee.i !== void 0 || (ue = ee.d) != null && !g[ue]) && (_e = ue != null ? j != null && j === $[ue] : n.default(ee.i, X.i), _e || ue != null && D !== 1 && $[ue] != null || O == null && (O = {
1231
+ ee && (ee.i !== void 0 || (ue = ee.d) != null && !g[ue]) && (_e = ue != null ? j != null && j === K[ue] : t.default(ee.i, X.i), _e || ue != null && D !== 1 && K[ue] != null || O == null && (O = {
1232
1232
  type: u.ConflictType.DROP_COLLISION,
1233
- op1: de(j != null ? I[j] : null, G, X),
1233
+ op1: de(j != null ? C[j] : null, L, X),
1234
1234
  op2: de(ue != null ? N[ue] : null, P, ee)
1235
1235
  })), _e || (J ? O == null && (O = {
1236
1236
  type: u.ConflictType.RM_UNEXPECTED_CONTENT,
1237
- op1: de(j != null ? I[j] : null, G, X),
1237
+ op1: de(j != null ? C[j] : null, L, X),
1238
1238
  op2: a.removeOp(J.getPath())
1239
- }) : (j != null ? (Ke[Re] = j, k.write("d", ie.p = Re++)) : k.write("i", t.default(X.i)), fe = !0));
1239
+ }) : (j != null ? ($e[Re] = j, A.write("d", ie.p = Re++)) : A.write("i", n.default(X.i)), fe = !0));
1240
1240
  } else if (j != null && !ie) {
1241
1241
  const ue = R[j];
1242
1242
  ue && (J = ue.clone());
1243
1243
  }
1244
- j != null ? (A = I[j], M = w[j], P = C[j]) : X.i !== void 0 && (A = M = null, _e || (P = null));
1245
- } else _(l(A)) && (A = M = P = null);
1246
- const ae = l(A), me = l(M);
1247
- if (_(me)) {
1248
- const j = me.p;
1249
- me.r !== void 0 && (!ae || ae.r === void 0) || g[j] ? (P = null, J = M.clone()) : j != null && (P = p[j], D !== 1 && $[j] != null || ((k = te[j]) || (k = te[j] = r.writeCursor()), k.reset(), J = null));
1244
+ j != null ? (S = C[j], k = w[j], P = I[j]) : X.i !== void 0 && (S = k = null, _e || (P = null));
1245
+ } else _(l(S)) && (S = k = P = null);
1246
+ const ae = l(S), ve = l(k);
1247
+ if (_(ve)) {
1248
+ const j = ve.p;
1249
+ ve.r !== void 0 && (!ae || ae.r === void 0) || g[j] ? (P = null, J = k.clone()) : j != null && (P = p[j], D !== 1 && K[j] != null || ((A = te[j]) || (A = te[j] = r.writeCursor()), A.reset(), J = null));
1250
1250
  } else !s(X) && s(ee) && (P = null);
1251
1251
  ee = P != null ? P.getComponent() : null;
1252
- const H = ve(X);
1252
+ const H = me(X);
1253
1253
  if (H) {
1254
1254
  const j = f(X);
1255
1255
  if (J) O == null && (O = {
1256
1256
  type: u.ConflictType.RM_UNEXPECTED_CONTENT,
1257
- op1: a.editOp(G.getPath(), H, j, !0),
1257
+ op1: a.editOp(L.getPath(), H, j, !0),
1258
1258
  op2: a.removeOp(J.getPath())
1259
1259
  });
1260
1260
  else {
1261
- const ie = ve(ee);
1261
+ const ie = me(ee);
1262
1262
  let _e;
1263
1263
  if (ie) {
1264
1264
  if (H !== ie) throw Error("Transforming incompatible types");
1265
1265
  const ue = f(ee);
1266
- _e = H.transform(j, ue, m);
1267
- } else _e = t.default(j);
1268
- y(k, H, _e);
1266
+ _e = H.transform(j, ue, v);
1267
+ } else _e = n.default(j);
1268
+ y(A, H, _e);
1269
1269
  }
1270
1270
  }
1271
- let T = 0, L = 0, he = 0, we = 0, Be = 0, $e = 0, Me = A != null && A.descendFirst(), Ye = Me;
1272
- const Xe = r.advancer(M, void 0, (j, ie) => {
1271
+ let T = 0, G = 0, he = 0, we = 0, Be = 0, Ke = 0, ke = S != null && S.descendFirst(), Ye = ke;
1272
+ const Xe = r.advancer(k, void 0, (j, ie) => {
1273
1273
  _(ie) && he++;
1274
1274
  });
1275
1275
  let je = P != null && P.descendFirst(), Ne = je;
1276
- for (const j of G) if (typeof j == "number") {
1276
+ for (const j of L) if (typeof j == "number") {
1277
1277
  let ie;
1278
- const _e = s(G.getComponent()), ue = j - L;
1278
+ const _e = s(L.getComponent()), ue = j - G;
1279
1279
  {
1280
- let Ge;
1281
- for (; Me && typeof (Ge = A.getKey()) == "number"; ) {
1282
- Ge += T;
1283
- const ke = A.getComponent(), Je = _(ke);
1284
- if (Ge > ue || Ge === ue && (!Je || D === 0 && _e)) break;
1280
+ let Le;
1281
+ for (; ke && typeof (Le = S.getKey()) == "number"; ) {
1282
+ Le += T;
1283
+ const Ae = S.getComponent(), Je = _(Ae);
1284
+ if (Le > ue || Le === ue && (!Je || D === 0 && _e)) break;
1285
1285
  if (Je) {
1286
1286
  T--;
1287
- const Fe = ke.p;
1288
- $.includes(Fe), ke.d, l(te[ke.d]), _(l(te[ke.d])), (ke.r === void 0 || Ae && Ae.has(ke)) && (Fe == null || !Pe[Fe] || D !== 1 && $.includes(Fe)) || Be--;
1287
+ const Fe = Ae.p;
1288
+ K.includes(Fe), Ae.d, l(te[Ae.d]), _(l(te[Ae.d])), (Ae.r === void 0 || Se && Se.has(Ae)) && (Fe == null || !Pe[Fe] || D !== 1 && K.includes(Fe)) || Be--;
1289
1289
  }
1290
- Me = A.nextSibling();
1290
+ ke = S.nextSibling();
1291
1291
  }
1292
- ie = Me && Ge === ue ? A : null;
1292
+ ie = ke && Le === ue ? S : null;
1293
1293
  }
1294
- const Se = ue - T;
1295
- let We = Xe(Se);
1296
- const ot = Se - he;
1294
+ const Ue = ue - T;
1295
+ let We = Xe(Ue);
1296
+ const ot = Ue - he;
1297
1297
  let Qe = null;
1298
1298
  {
1299
- let Ge, ke;
1300
- for (; je && typeof (Ge = P.getKey()) == "number"; ) {
1301
- ke = Ge - we;
1299
+ let Le, Ae;
1300
+ for (; je && typeof (Le = P.getKey()) == "number"; ) {
1301
+ Ae = Le - we;
1302
1302
  const Je = P.getComponent(), Fe = s(Je);
1303
- if (ke > ot) break;
1304
- if (ke === ot) {
1303
+ if (Ae > ot) break;
1304
+ if (Ae === ot) {
1305
1305
  if (!Fe) {
1306
1306
  Qe = P;
1307
1307
  break;
@@ -1311,99 +1311,99 @@ function on() {
1311
1311
  Qe = P;
1312
1312
  break;
1313
1313
  }
1314
- const Le = We && _(We.getComponent());
1315
- if (D === 0 && Le) break;
1314
+ const Ge = We && _(We.getComponent());
1315
+ if (D === 0 && Ge) break;
1316
1316
  }
1317
1317
  }
1318
1318
  if (Fe) {
1319
- const Le = Je.d;
1320
- g[Le], $[Le], Je.i === void 0 && (g[Le] || $[Le] != null && D !== 1) ? (g[Le] || $[Le] != null && D === 0) && (we++, $e--) : we++;
1319
+ const Ge = Je.d;
1320
+ g[Ge], K[Ge], Je.i === void 0 && (g[Ge] || K[Ge] != null && D !== 1) ? (g[Ge] || K[Ge] != null && D === 0) && (we++, Ke--) : we++;
1321
1321
  }
1322
1322
  je = P.nextSibling();
1323
1323
  }
1324
1324
  }
1325
- const _t = ot + we + Be + $e;
1326
- o(_t >= 0, "trying to descend to a negative index"), k.descend(_t), _e && (ie = We = Qe = null, L++), Q(ie, G, We, Qe, k, J) && $e++, k.ascend();
1325
+ const _t = ot + we + Be + Ke;
1326
+ o(_t >= 0, "trying to descend to a negative index"), A.descend(_t), _e && (ie = We = Qe = null, G++), Q(ie, L, We, Qe, A, J) && Ke++, A.ascend();
1327
1327
  } else {
1328
1328
  let ie;
1329
- for (; Me && (ie = A.getKey(), typeof ie != "string" || !(ie > j || ie === j)); ) Me = A.nextSibling();
1330
- const _e = Me && ie === j ? A : null, ue = Xe(j);
1331
- let Se;
1332
- for (; je && (Se = P.getKey(), typeof Se != "string" || !(Se > j || Se === j)); ) je = P.nextSibling();
1333
- const We = je && Se === j ? P : null;
1334
- k.descend(j), Q(_e, G, ue, We, k, J), k.ascend();
1329
+ for (; ke && (ie = S.getKey(), typeof ie != "string" || !(ie > j || ie === j)); ) ke = S.nextSibling();
1330
+ const _e = ke && ie === j ? S : null, ue = Xe(j);
1331
+ let Ue;
1332
+ for (; je && (Ue = P.getKey(), typeof Ue != "string" || !(Ue > j || Ue === j)); ) je = P.nextSibling();
1333
+ const We = je && Ue === j ? P : null;
1334
+ A.descend(j), Q(_e, L, ue, We, A, J), A.ascend();
1335
1335
  }
1336
- return Xe.end(), Ye && A.ascend(), Ne && P.ascend(), fe;
1336
+ return Xe.end(), Ye && S.ascend(), Ne && P.ascend(), fe;
1337
1337
  })(Oe, Oe.clone(), ye, ye.clone(), oe, null), O) return {
1338
1338
  ok: !1,
1339
1339
  conflict: O
1340
1340
  };
1341
1341
  oe.reset();
1342
- const Te = (Q, A, G) => Q.traverse(A, (M, P) => {
1343
- M.d != null && G(M.d, Q, P);
1342
+ const Te = (Q, S, L) => Q.traverse(S, (k, P) => {
1343
+ k.d != null && L(k.d, Q, P);
1344
1344
  });
1345
- (g.length || re.length) && (Te(ye, oe, (Q, A, G) => {
1346
- g[Q] && !S[Q] && G.write("r", !0), re[Q] && G.mergeTree(re[Q].get());
1345
+ (g.length || re.length) && (Te(ye, oe, (Q, S, L) => {
1346
+ g[Q] && !U[Q] && L.write("r", !0), re[Q] && L.mergeTree(re[Q].get());
1347
1347
  }), oe.reset());
1348
- const Ie = [], xe = [];
1348
+ const Ce = [], xe = [];
1349
1349
  if ((te.length || g.length) && !O) {
1350
1350
  const Q = r.readCursor(it(oe.get()));
1351
- if (Te(Q, null, (A, G) => {
1352
- Ie[A] = G.clone();
1353
- }), te.forEach((A) => {
1354
- A && Te(r.readCursor(A.get()), null, (G, M) => {
1355
- Ie[G] = M.clone();
1351
+ if (Te(Q, null, (S, L) => {
1352
+ Ce[S] = L.clone();
1353
+ }), te.forEach((S) => {
1354
+ S && Te(r.readCursor(S.get()), null, (L, k) => {
1355
+ Ce[L] = k.clone();
1356
1356
  });
1357
- }), (function A(G, M, P, k, J, X) {
1358
- const ee = l(M);
1357
+ }), (function S(L, k, P, A, J, X) {
1358
+ const ee = l(k);
1359
1359
  if (ee && _(ee)) if (ee.p != null) {
1360
1360
  const T = ee.p;
1361
- Ie[T].getPath(), P = Ie[T], k = xe[T] = r.writeCursor();
1361
+ Ce[T].getPath(), P = Ce[T], A = xe[T] = r.writeCursor();
1362
1362
  } else ee.r !== void 0 && (P = null);
1363
1363
  else s(l(P)) && (P = null);
1364
- const fe = G.getComponent();
1364
+ const fe = L.getComponent();
1365
1365
  if (fe) {
1366
1366
  let T;
1367
1367
  if ((T = fe.d) != null) {
1368
- const L = te[T];
1369
- L && (L.get(), k.mergeTree(L.get()), P = r.readCursor(L.get()));
1368
+ const G = te[T];
1369
+ G && (G.get(), A.mergeTree(G.get()), P = r.readCursor(G.get()));
1370
1370
  }
1371
1371
  }
1372
1372
  let de = 0, ae = 0;
1373
- const me = r.advancer(M, void 0, (T, L) => {
1374
- _(L) && de--;
1375
- }), H = r.advancer(P, (T, L) => s(L) ? -(T - ae) - 1 : T - ae, (T, L) => {
1376
- s(L) && ae++;
1373
+ const ve = r.advancer(k, void 0, (T, G) => {
1374
+ _(G) && de--;
1375
+ }), H = r.advancer(P, (T, G) => s(G) ? -(T - ae) - 1 : T - ae, (T, G) => {
1376
+ s(G) && ae++;
1377
1377
  });
1378
- for (const T of G) if (typeof T == "number") {
1379
- const L = me(T), he = T + de, we = H(he), Be = he + ae;
1380
- k.descend(Be), A(G, L, we, k), k.ascend();
1381
- } else k.descend(T), A(G, me(T), H(T), k), k.ascend();
1382
- me.end(), H.end();
1378
+ for (const T of L) if (typeof T == "number") {
1379
+ const G = ve(T), he = T + de, we = H(he), Be = he + ae;
1380
+ A.descend(Be), S(L, G, we, A), A.ascend();
1381
+ } else A.descend(T), S(L, ve(T), H(T), A), A.ascend();
1382
+ ve.end(), H.end();
1383
1383
  })(ye, Q, Q.clone(), oe), oe.reset(), O) return {
1384
1384
  ok: !1,
1385
1385
  conflict: O
1386
1386
  };
1387
1387
  if (oe.get(), xe.length) {
1388
- const A = xe.map((M) => M ? M.get() : null), G = r.readCursor(it(oe.get()));
1389
- if (Te(G, oe, (M, P, k) => {
1390
- const J = A[M];
1391
- J && (k.mergeTree(J), A[M] = null);
1392
- }), A.find((M) => M)) {
1393
- const M = r.writeCursor(), P = r.writeCursor();
1394
- let k = 0, J = 0;
1395
- A.forEach((X) => {
1388
+ const S = xe.map((k) => k ? k.get() : null), L = r.readCursor(it(oe.get()));
1389
+ if (Te(L, oe, (k, P, A) => {
1390
+ const J = S[k];
1391
+ J && (A.mergeTree(J), S[k] = null);
1392
+ }), S.find((k) => k)) {
1393
+ const k = r.writeCursor(), P = r.writeCursor();
1394
+ let A = 0, J = 0;
1395
+ S.forEach((X) => {
1396
1396
  X != null && Te(r.readCursor(X), null, (ee) => {
1397
- const fe = Ke[ee];
1398
- M.writeMove(I[fe].getPath(), x[fe].getPath(), k++);
1397
+ const fe = $e[ee];
1398
+ k.writeMove(C[fe].getPath(), x[fe].getPath(), A++);
1399
1399
  const de = se[fe];
1400
1400
  de && de.forEach((ae) => {
1401
- g[ae] || D !== 1 && $[ae] != null || P.writeMove(N[ae].getPath(), p[ae].getPath(), J++);
1401
+ g[ae] || D !== 1 && K[ae] != null || P.writeMove(N[ae].getPath(), p[ae].getPath(), J++);
1402
1402
  });
1403
1403
  });
1404
1404
  }), O = {
1405
1405
  type: u.ConflictType.BLACKHOLE,
1406
- op1: M.get(),
1406
+ op1: k.get(),
1407
1407
  op2: P.get()
1408
1408
  };
1409
1409
  }
@@ -1421,49 +1421,49 @@ function on() {
1421
1421
  const d = new Error("Transform detected write conflict");
1422
1422
  throw d.conflict = i, d.type = d.name = "writeConflict", d;
1423
1423
  };
1424
- function jt(i, d, m) {
1425
- const D = st(i, d, m);
1424
+ function jt(i, d, v) {
1425
+ const D = st(i, d, v);
1426
1426
  if (D.ok) return D.result;
1427
1427
  gt(D.conflict);
1428
1428
  }
1429
1429
  const ze = (i) => {
1430
1430
  const d = r.writeCursor();
1431
- return r.readCursor(i).traverse(d, (m, D) => {
1432
- (s(m) || ve(m)) && D.write("r", !0);
1431
+ return r.readCursor(i).traverse(d, (v, D) => {
1432
+ (s(v) || me(v)) && D.write("r", !0);
1433
1433
  }), d.get();
1434
1434
  }, Nt = (i, d) => {
1435
- const { type: m, op1: D, op2: O } = i;
1436
- switch (m) {
1435
+ const { type: v, op1: D, op2: O } = i;
1436
+ switch (v) {
1437
1437
  case u.ConflictType.DROP_COLLISION:
1438
1438
  return d === "left" ? [null, ze(O)] : [ze(D), null];
1439
1439
  case u.ConflictType.RM_UNEXPECTED_CONTENT:
1440
- let I = !1;
1440
+ let C = !1;
1441
1441
  return r.readCursor(D).traverse(null, (x) => {
1442
- x.r !== void 0 && (I = !0);
1443
- }), I ? [null, ze(O)] : [ze(D), null];
1442
+ x.r !== void 0 && (C = !0);
1443
+ }), C ? [null, ze(O)] : [ze(D), null];
1444
1444
  case u.ConflictType.BLACKHOLE:
1445
1445
  return [ze(D), ze(O)];
1446
1446
  default:
1447
- throw Error("Unrecognised conflict: " + m);
1447
+ throw Error("Unrecognised conflict: " + v);
1448
1448
  }
1449
1449
  };
1450
- function yt(i, d, m, D) {
1450
+ function yt(i, d, v, D) {
1451
1451
  let O = null;
1452
1452
  for (; ; ) {
1453
- const I = st(d, m, D);
1454
- if (I.ok) return ne(O, I.result);
1453
+ const C = st(d, v, D);
1454
+ if (C.ok) return ne(O, C.result);
1455
1455
  {
1456
- const { conflict: x } = I;
1456
+ const { conflict: x } = C;
1457
1457
  i(x) || gt(x);
1458
1458
  const [N, p] = Nt(x, D);
1459
- d = ne(K(d), N), m = ne(K(m), p), O = ne(O, p);
1459
+ d = ne($(d), N), v = ne($(v), p), O = ne(O, p);
1460
1460
  }
1461
1461
  }
1462
1462
  }
1463
1463
  })(Ze)), Ze;
1464
1464
  }
1465
1465
  var Tt;
1466
- function an() {
1466
+ function cn() {
1467
1467
  return Tt || (Tt = 1, (function(a) {
1468
1468
  var e = Ve && Ve.__createBinding || (Object.create ? (function(u, o, l, E) {
1469
1469
  E === void 0 && (E = l), Object.defineProperty(u, E, { enumerable: !0, get: function() {
@@ -1471,24 +1471,24 @@ function an() {
1471
1471
  } });
1472
1472
  }) : (function(u, o, l, E) {
1473
1473
  E === void 0 && (E = l), u[E] = o[l];
1474
- })), n = Ve && Ve.__exportStar || function(u, o) {
1474
+ })), t = Ve && Ve.__exportStar || function(u, o) {
1475
1475
  for (var l in u) l !== "default" && !o.hasOwnProperty(l) && e(o, u, l);
1476
1476
  };
1477
- Object.defineProperty(a, "__esModule", { value: !0 }), n(on(), a);
1478
- var t = St();
1477
+ Object.defineProperty(a, "__esModule", { value: !0 }), t(un(), a);
1478
+ var n = Ut();
1479
1479
  Object.defineProperty(a, "ReadCursor", { enumerable: !0, get: function() {
1480
- return t.ReadCursor;
1480
+ return n.ReadCursor;
1481
1481
  } }), Object.defineProperty(a, "WriteCursor", { enumerable: !0, get: function() {
1482
- return t.WriteCursor;
1482
+ return n.WriteCursor;
1483
1483
  } });
1484
- var r = kt();
1484
+ var r = At();
1485
1485
  Object.defineProperty(a, "ConflictType", { enumerable: !0, get: function() {
1486
1486
  return r.ConflictType;
1487
1487
  } });
1488
1488
  })(Ve)), Ve;
1489
1489
  }
1490
- var V = an();
1491
- class ln {
1490
+ var V = cn();
1491
+ class dn {
1492
1492
  constructor() {
1493
1493
  F(this, "drawingManagerData", {});
1494
1494
  F(this, "_oldDrawingManagerData", {});
@@ -1535,74 +1535,74 @@ class ln {
1535
1535
  this._visible$.next(e);
1536
1536
  }
1537
1537
  refreshTransform(e) {
1538
- e.forEach((n) => {
1539
- const t = this._getCurrentBySearch(n);
1540
- t != null && (t.transform = n.transform, t.transforms = n.transforms, t.isMultiTransform = n.isMultiTransform);
1538
+ e.forEach((t) => {
1539
+ const n = this._getCurrentBySearch(t);
1540
+ n != null && (n.transform = t.transform, n.transforms = t.transforms, n.isMultiTransform = t.isMultiTransform);
1541
1541
  }), this.refreshTransformNotification(e);
1542
1542
  }
1543
1543
  getDrawingDataForUnit(e) {
1544
1544
  return this.drawingManagerData[e] || {};
1545
1545
  }
1546
1546
  removeDrawingDataForUnit(e) {
1547
- const n = this.drawingManagerData[e];
1548
- if (n == null)
1547
+ const t = this.drawingManagerData[e];
1548
+ if (t == null)
1549
1549
  return;
1550
1550
  delete this.drawingManagerData[e];
1551
- const t = [];
1552
- Object.keys(n).forEach((r) => {
1553
- const u = n[r];
1551
+ const n = [];
1552
+ Object.keys(t).forEach((r) => {
1553
+ const u = t[r];
1554
1554
  (u == null ? void 0 : u.data) != null && Object.keys(u.data).forEach((o) => {
1555
- t.push({ unitId: e, subUnitId: r, drawingId: o });
1555
+ n.push({ unitId: e, subUnitId: r, drawingId: o });
1556
1556
  });
1557
- }), t.length > 0 && this.removeNotification(t);
1557
+ }), n.length > 0 && this.removeNotification(n);
1558
1558
  }
1559
- registerDrawingData(e, n) {
1560
- this.drawingManagerData[e] = n;
1559
+ registerDrawingData(e, t) {
1560
+ this.drawingManagerData[e] = t;
1561
1561
  }
1562
1562
  initializeNotification(e) {
1563
- const n = [], t = this.drawingManagerData[e];
1564
- t != null && (Object.keys(t).forEach((r) => {
1563
+ const t = [], n = this.drawingManagerData[e];
1564
+ n != null && (Object.keys(n).forEach((r) => {
1565
1565
  this._establishDrawingMap(e, r);
1566
- const u = t[r];
1566
+ const u = n[r];
1567
1567
  Object.keys(u.data).forEach((o) => {
1568
1568
  const l = u.data[o];
1569
- l.unitId = e, l.subUnitId = r, n.push(l);
1569
+ l.unitId = e, l.subUnitId = r, t.push(l);
1570
1570
  });
1571
- }), n.length > 0 && this.addNotification(n));
1571
+ }), t.length > 0 && this.addNotification(t));
1572
1572
  }
1573
- getDrawingData(e, n) {
1574
- return this._getDrawingData(e, n);
1573
+ getDrawingData(e, t) {
1574
+ return this._getDrawingData(e, t);
1575
1575
  }
1576
1576
  // Use in doc only.
1577
- setDrawingData(e, n, t) {
1578
- this.drawingManagerData[e][n].data = t;
1577
+ setDrawingData(e, t, n) {
1578
+ this.drawingManagerData[e][t].data = n;
1579
1579
  }
1580
1580
  getBatchAddOp(e) {
1581
- const n = [], t = [], r = [];
1581
+ const t = [], n = [], r = [];
1582
1582
  e.forEach((B) => {
1583
1583
  const { op: _, invertOp: s } = this._addByParam(B);
1584
- n.push({ unitId: B.unitId, subUnitId: B.subUnitId, drawingId: B.drawingId }), t.push(_), r.push(s);
1584
+ t.push({ unitId: B.unitId, subUnitId: B.subUnitId, drawingId: B.drawingId }), n.push(_), r.push(s);
1585
1585
  });
1586
- const u = t.reduce(V.type.compose, null), o = r.reduce(V.type.compose, null), { unitId: l, subUnitId: E } = e[0];
1587
- return { undo: o, redo: u, unitId: l, subUnitId: E, objects: n };
1586
+ const u = n.reduce(V.type.compose, null), o = r.reduce(V.type.compose, null), { unitId: l, subUnitId: E } = e[0];
1587
+ return { undo: o, redo: u, unitId: l, subUnitId: E, objects: t };
1588
1588
  }
1589
1589
  getBatchRemoveOp(e) {
1590
- const n = [], t = [];
1590
+ const t = [], n = [];
1591
1591
  e.forEach((E) => {
1592
1592
  const { op: B, invertOp: _ } = this._removeByParam(E);
1593
- n.unshift(B), t.push(_);
1593
+ t.unshift(B), n.push(_);
1594
1594
  });
1595
- const r = n.reduce(V.type.compose, null), u = t.reduce(V.type.compose, null), { unitId: o, subUnitId: l } = e[0];
1595
+ const r = t.reduce(V.type.compose, null), u = n.reduce(V.type.compose, null), { unitId: o, subUnitId: l } = e[0];
1596
1596
  return { undo: u, redo: r, unitId: o, subUnitId: l, objects: e };
1597
1597
  }
1598
1598
  getBatchUpdateOp(e) {
1599
- const n = [], t = [], r = [];
1599
+ const t = [], n = [], r = [];
1600
1600
  e.forEach((B) => {
1601
1601
  const { op: _, invertOp: s } = this._updateByParam(B);
1602
- n.push({ unitId: B.unitId, subUnitId: B.subUnitId, drawingId: B.drawingId }), t.push(_), r.push(s);
1602
+ t.push({ unitId: B.unitId, subUnitId: B.subUnitId, drawingId: B.drawingId }), n.push(_), r.push(s);
1603
1603
  });
1604
- const u = t.reduce(V.type.compose, null), o = r.reduce(V.type.compose, null), { unitId: l, subUnitId: E } = e[0];
1605
- return { undo: o, redo: u, unitId: l, subUnitId: E, objects: n };
1604
+ const u = n.reduce(V.type.compose, null), o = r.reduce(V.type.compose, null), { unitId: l, subUnitId: E } = e[0];
1605
+ return { undo: o, redo: u, unitId: l, subUnitId: E, objects: t };
1606
1606
  }
1607
1607
  removeNotification(e) {
1608
1608
  this._remove$.next(e);
@@ -1626,38 +1626,38 @@ class ln {
1626
1626
  this._refreshTransform$.next(e);
1627
1627
  }
1628
1628
  getGroupDrawingOp(e) {
1629
- const n = [], { unitId: t, subUnitId: r } = e[0].parent;
1629
+ const t = [], { unitId: n, subUnitId: r } = e[0].parent;
1630
1630
  e.forEach((l) => {
1631
- n.push(this._getGroupDrawingOp(l));
1631
+ t.push(this._getGroupDrawingOp(l));
1632
1632
  });
1633
- const u = n.reduce(V.type.compose, null);
1634
- return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId: t, subUnitId: r, objects: e };
1633
+ const u = t.reduce(V.type.compose, null);
1634
+ return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId: n, subUnitId: r, objects: e };
1635
1635
  }
1636
1636
  getUngroupDrawingOp(e) {
1637
- const n = [], { unitId: t, subUnitId: r } = e[0].parent;
1637
+ const t = [], { unitId: n, subUnitId: r } = e[0].parent;
1638
1638
  e.forEach((l) => {
1639
- n.push(this._getUngroupDrawingOp(l));
1639
+ t.push(this._getUngroupDrawingOp(l));
1640
1640
  });
1641
- const u = n.reduce(V.type.compose, null);
1642
- return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId: t, subUnitId: r, objects: e };
1641
+ const u = t.reduce(V.type.compose, null);
1642
+ return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId: n, subUnitId: r, objects: e };
1643
1643
  }
1644
1644
  getDrawingsByGroup(e) {
1645
- const { unitId: n, subUnitId: t, drawingId: r } = e;
1646
- if (this.getDrawingByParam({ unitId: n, subUnitId: t, drawingId: r }) == null)
1645
+ const { unitId: t, subUnitId: n, drawingId: r } = e;
1646
+ if (this.getDrawingByParam({ unitId: t, subUnitId: n, drawingId: r }) == null)
1647
1647
  return [];
1648
- const o = this._getDrawingData(n, t), l = [];
1648
+ const o = this._getDrawingData(t, n), l = [];
1649
1649
  return Object.keys(o).forEach((E) => {
1650
1650
  const B = o[E];
1651
1651
  B.groupId === r && l.push(B);
1652
1652
  }), l;
1653
1653
  }
1654
1654
  _getGroupDrawingOp(e) {
1655
- const { parent: n, children: t } = e, { unitId: r, subUnitId: u, drawingId: o } = n, l = [];
1655
+ const { parent: t, children: n } = e, { unitId: r, subUnitId: u, drawingId: o } = t, l = [];
1656
1656
  l.push(
1657
- V.insertOp([r, u, "data", o], n)
1657
+ V.insertOp([r, u, "data", o], t)
1658
1658
  );
1659
1659
  let E = Number.NEGATIVE_INFINITY;
1660
- return t.forEach((B) => {
1660
+ return n.forEach((B) => {
1661
1661
  const { unitId: _, subUnitId: s, drawingId: c } = B, h = this._hasDrawingOrder({ unitId: _, subUnitId: s, drawingId: c });
1662
1662
  E = Math.max(E, h), l.push(
1663
1663
  ...this._getUpdateParamCompareOp(B, this.getDrawingByParam({ unitId: _, subUnitId: s, drawingId: c }))
@@ -1667,8 +1667,8 @@ class ln {
1667
1667
  ), l.reduce(V.type.compose, null);
1668
1668
  }
1669
1669
  _getUngroupDrawingOp(e) {
1670
- const { parent: n, children: t } = e, { unitId: r, subUnitId: u, drawingId: o } = n, l = [];
1671
- return t.forEach((E) => {
1670
+ const { parent: t, children: n } = e, { unitId: r, subUnitId: u, drawingId: o } = t, l = [];
1671
+ return n.forEach((E) => {
1672
1672
  const { unitId: B, subUnitId: _, drawingId: s } = E;
1673
1673
  l.push(
1674
1674
  ...this._getUpdateParamCompareOp(E, this.getDrawingByParam({ unitId: B, subUnitId: _, drawingId: s }))
@@ -1679,8 +1679,8 @@ class ln {
1679
1679
  V.removeOp([r, u, "order", this._getDrawingOrder(r, u).indexOf(o)], !0)
1680
1680
  ), l.reduce(V.type.compose, null);
1681
1681
  }
1682
- applyJson1(e, n, t) {
1683
- this._establishDrawingMap(e, n), this._oldDrawingManagerData = { ...this.drawingManagerData }, this.drawingManagerData = V.type.apply(this.drawingManagerData, t);
1682
+ applyJson1(e, t, n) {
1683
+ this._establishDrawingMap(e, t), this._oldDrawingManagerData = { ...this.drawingManagerData }, this.drawingManagerData = V.type.apply(this.drawingManagerData, n);
1684
1684
  }
1685
1685
  // private _fillMissingFields(jsonOp: JSONOp) {
1686
1686
  // if (jsonOp == null) {
@@ -1727,134 +1727,134 @@ class ln {
1727
1727
  return this._getOldBySearch(e);
1728
1728
  }
1729
1729
  getDrawingOKey(e) {
1730
- const [n, t, r] = e.split("#-#");
1731
- return this._getCurrentBySearch({ unitId: n, subUnitId: t, drawingId: r });
1730
+ const [t, n, r] = e.split("#-#");
1731
+ return this._getCurrentBySearch({ unitId: t, subUnitId: n, drawingId: r });
1732
1732
  }
1733
1733
  focusDrawing(e) {
1734
1734
  if (e == null || e.length === 0) {
1735
1735
  this._focusDrawings = [], this._focus$.next([]);
1736
1736
  return;
1737
1737
  }
1738
- const n = [];
1739
- e.forEach((t) => {
1738
+ const t = [];
1739
+ e.forEach((n) => {
1740
1740
  var E;
1741
- const { unitId: r, subUnitId: u, drawingId: o } = t, l = (E = this._getDrawingData(r, u)) == null ? void 0 : E[o];
1742
- l != null && n.push(l);
1743
- }), n.length > 0 && (this._focusDrawings = n, this._focus$.next(n));
1741
+ const { unitId: r, subUnitId: u, drawingId: o } = n, l = (E = this._getDrawingData(r, u)) == null ? void 0 : E[o];
1742
+ l != null && t.push(l);
1743
+ }), t.length > 0 && (this._focusDrawings = t, this._focus$.next(t));
1744
1744
  }
1745
1745
  getFocusDrawings() {
1746
1746
  const e = [];
1747
- return this._focusDrawings.forEach((n) => {
1747
+ return this._focusDrawings.forEach((t) => {
1748
1748
  var l;
1749
- const { unitId: t, subUnitId: r, drawingId: u } = n, o = (l = this._getDrawingData(t, r)) == null ? void 0 : l[u];
1749
+ const { unitId: n, subUnitId: r, drawingId: u } = t, o = (l = this._getDrawingData(n, r)) == null ? void 0 : l[u];
1750
1750
  o != null && e.push(o);
1751
1751
  }), e;
1752
1752
  }
1753
- getDrawingOrder(e, n) {
1754
- return this._getDrawingOrder(e, n);
1753
+ getDrawingOrder(e, t) {
1754
+ return this._getDrawingOrder(e, t);
1755
1755
  }
1756
1756
  // Use in doc only.
1757
- setDrawingOrder(e, n, t) {
1758
- this.drawingManagerData[e][n].order = t;
1757
+ setDrawingOrder(e, t, n) {
1758
+ this.drawingManagerData[e][t].order = n;
1759
1759
  }
1760
1760
  orderUpdateNotification(e) {
1761
1761
  this._order$.next(e);
1762
1762
  }
1763
1763
  getForwardDrawingsOp(e) {
1764
- const { unitId: n, subUnitId: t, drawingIds: r } = e, u = [], o = this.getDrawingOrder(n, t), l = [...r];
1764
+ const { unitId: t, subUnitId: n, drawingIds: r } = e, u = [], o = this.getDrawingOrder(t, n), l = [...r];
1765
1765
  r.forEach((_) => {
1766
- const s = this._hasDrawingOrder({ unitId: n, subUnitId: t, drawingId: _ });
1766
+ const s = this._hasDrawingOrder({ unitId: t, subUnitId: n, drawingId: _ });
1767
1767
  if (s === -1 || s === o.length - 1)
1768
1768
  return;
1769
- const c = V.moveOp([n, t, "order", s], [n, t, "order", s + 1]);
1769
+ const c = V.moveOp([t, n, "order", s], [t, n, "order", s + 1]);
1770
1770
  u.push(c), l.includes(o[s + 1]) || l.push(o[s + 1]);
1771
1771
  });
1772
1772
  const E = u.reduce(V.type.compose, null);
1773
- return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: n, subUnitId: t, objects: { ...e, drawingIds: l } };
1773
+ return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: t, subUnitId: n, objects: { ...e, drawingIds: l } };
1774
1774
  }
1775
1775
  getBackwardDrawingOp(e) {
1776
- const { unitId: n, subUnitId: t, drawingIds: r } = e, u = [], o = this.getDrawingOrder(n, t), l = [...r];
1776
+ const { unitId: t, subUnitId: n, drawingIds: r } = e, u = [], o = this.getDrawingOrder(t, n), l = [...r];
1777
1777
  r.forEach((_) => {
1778
- const s = this._hasDrawingOrder({ unitId: n, subUnitId: t, drawingId: _ });
1778
+ const s = this._hasDrawingOrder({ unitId: t, subUnitId: n, drawingId: _ });
1779
1779
  if (s === -1 || s === 0)
1780
1780
  return;
1781
- const c = V.moveOp([n, t, "order", s], [n, t, "order", s - 1]);
1781
+ const c = V.moveOp([t, n, "order", s], [t, n, "order", s - 1]);
1782
1782
  u.push(c), l.includes(o[s - 1]) || l.push(o[s - 1]);
1783
1783
  });
1784
1784
  const E = u.reduce(V.type.compose, null);
1785
- return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: n, subUnitId: t, objects: { ...e, drawingIds: l } };
1785
+ return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: t, subUnitId: n, objects: { ...e, drawingIds: l } };
1786
1786
  }
1787
1787
  getFrontDrawingsOp(e) {
1788
- const { unitId: n, subUnitId: t, drawingIds: r } = e, u = this._getOrderFromSearchParams(n, t, r), o = [...r], l = this.getDrawingOrder(n, t), E = [];
1788
+ const { unitId: t, subUnitId: n, drawingIds: r } = e, u = this._getOrderFromSearchParams(t, n, r), o = [...r], l = this.getDrawingOrder(t, n), E = [];
1789
1789
  u.forEach((s) => {
1790
- const { drawingId: c } = s, h = this._getDrawingCount(n, t) - 1, U = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(c)], [n, t, "order", h]);
1791
- E.push(U), o.includes(l[h]) || o.push(l[h]);
1790
+ const { drawingId: c } = s, h = this._getDrawingCount(t, n) - 1, M = V.moveOp([t, n, "order", this._getDrawingOrder(t, n).indexOf(c)], [t, n, "order", h]);
1791
+ E.push(M), o.includes(l[h]) || o.push(l[h]);
1792
1792
  });
1793
1793
  const B = E.reduce(V.type.compose, null);
1794
- return { undo: V.type.invertWithDoc(B, this.drawingManagerData), redo: B, unitId: n, subUnitId: t, objects: { ...e, drawingIds: o } };
1794
+ return { undo: V.type.invertWithDoc(B, this.drawingManagerData), redo: B, unitId: t, subUnitId: n, objects: { ...e, drawingIds: o } };
1795
1795
  }
1796
1796
  getBackDrawingsOp(e) {
1797
- const { unitId: n, subUnitId: t, drawingIds: r } = e, u = this._getOrderFromSearchParams(n, t, r, !0), o = [...r], l = this.getDrawingOrder(n, t), E = [];
1797
+ const { unitId: t, subUnitId: n, drawingIds: r } = e, u = this._getOrderFromSearchParams(t, n, r, !0), o = [...r], l = this.getDrawingOrder(t, n), E = [];
1798
1798
  u.forEach((s) => {
1799
- const { drawingId: c } = s, h = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(c)], [n, t, "order", 0]);
1799
+ const { drawingId: c } = s, h = V.moveOp([t, n, "order", this._getDrawingOrder(t, n).indexOf(c)], [t, n, "order", 0]);
1800
1800
  E.push(h), o.includes(l[0]) || o.push(l[0]);
1801
1801
  });
1802
1802
  const B = E.reduce(V.type.compose, null);
1803
- return { undo: V.type.invertWithDoc(B, this.drawingManagerData), redo: B, unitId: n, subUnitId: t, objects: { ...e, drawingIds: o } };
1803
+ return { undo: V.type.invertWithDoc(B, this.drawingManagerData), redo: B, unitId: t, subUnitId: n, objects: { ...e, drawingIds: o } };
1804
1804
  }
1805
- _getDrawingCount(e, n) {
1806
- return this.getDrawingOrder(e, n).length || 0;
1805
+ _getDrawingCount(e, t) {
1806
+ return this.getDrawingOrder(e, t).length || 0;
1807
1807
  }
1808
- _getOrderFromSearchParams(e, n, t, r = !1) {
1809
- return t.map((u) => {
1810
- const o = this._hasDrawingOrder({ unitId: e, subUnitId: n, drawingId: u });
1808
+ _getOrderFromSearchParams(e, t, n, r = !1) {
1809
+ return n.map((u) => {
1810
+ const o = this._hasDrawingOrder({ unitId: e, subUnitId: t, drawingId: u });
1811
1811
  return { drawingId: u, zIndex: o };
1812
- }).sort(r === !1 ? Gt : Lt);
1812
+ }).sort(r === !1 ? Lt : Gt);
1813
1813
  }
1814
1814
  _hasDrawingOrder(e) {
1815
1815
  if (e == null)
1816
1816
  return -1;
1817
- const { unitId: n, subUnitId: t, drawingId: r } = e;
1818
- return this._establishDrawingMap(n, t), this._getDrawingOrder(n, t).indexOf(r);
1817
+ const { unitId: t, subUnitId: n, drawingId: r } = e;
1818
+ return this._establishDrawingMap(t, n), this._getDrawingOrder(t, n).indexOf(r);
1819
1819
  }
1820
1820
  _getCurrentBySearch(e) {
1821
1821
  var u, o, l;
1822
1822
  if (e == null)
1823
1823
  return;
1824
- const { unitId: n, subUnitId: t, drawingId: r } = e;
1825
- return (l = (o = (u = this.drawingManagerData[n]) == null ? void 0 : u[t]) == null ? void 0 : o.data) == null ? void 0 : l[r];
1824
+ const { unitId: t, subUnitId: n, drawingId: r } = e;
1825
+ return (l = (o = (u = this.drawingManagerData[t]) == null ? void 0 : u[n]) == null ? void 0 : o.data) == null ? void 0 : l[r];
1826
1826
  }
1827
1827
  _getOldBySearch(e) {
1828
1828
  var u, o, l;
1829
1829
  if (e == null)
1830
1830
  return;
1831
- const { unitId: n, subUnitId: t, drawingId: r } = e;
1832
- return (l = (o = (u = this._oldDrawingManagerData[n]) == null ? void 0 : u[t]) == null ? void 0 : o.data) == null ? void 0 : l[r];
1831
+ const { unitId: t, subUnitId: n, drawingId: r } = e;
1832
+ return (l = (o = (u = this._oldDrawingManagerData[t]) == null ? void 0 : u[n]) == null ? void 0 : o.data) == null ? void 0 : l[r];
1833
1833
  }
1834
- _establishDrawingMap(e, n, t) {
1834
+ _establishDrawingMap(e, t, n) {
1835
1835
  var r;
1836
- return this.drawingManagerData[e] || (this.drawingManagerData[e] = {}), this.drawingManagerData[e][n] || (this.drawingManagerData[e][n] = {
1836
+ return this.drawingManagerData[e] || (this.drawingManagerData[e] = {}), this.drawingManagerData[e][t] || (this.drawingManagerData[e][t] = {
1837
1837
  data: {},
1838
1838
  order: []
1839
- }), t == null ? null : (r = this.drawingManagerData[e][n].data) == null ? void 0 : r[t];
1839
+ }), n == null ? null : (r = this.drawingManagerData[e][t].data) == null ? void 0 : r[n];
1840
1840
  }
1841
1841
  _addByParam(e) {
1842
- const { unitId: n, subUnitId: t, drawingId: r } = e;
1843
- this._establishDrawingMap(n, t, r);
1844
- const u = V.insertOp([n, t, "data", r], e), o = V.insertOp([n, t, "order", this._getDrawingOrder(n, t).length], r), l = [u, o].reduce(V.type.compose, null), E = V.type.invertWithDoc(l, this.drawingManagerData);
1842
+ const { unitId: t, subUnitId: n, drawingId: r } = e;
1843
+ this._establishDrawingMap(t, n, r);
1844
+ const u = V.insertOp([t, n, "data", r], e), o = V.insertOp([t, n, "order", this._getDrawingOrder(t, n).length], r), l = [u, o].reduce(V.type.compose, null), E = V.type.invertWithDoc(l, this.drawingManagerData);
1845
1845
  return { op: l, invertOp: E };
1846
1846
  }
1847
1847
  _removeByParam(e) {
1848
1848
  if (e == null)
1849
1849
  return { op: [], invertOp: [] };
1850
- const { unitId: n, subUnitId: t, drawingId: r } = e;
1851
- if (this._establishDrawingMap(n, t, r) == null)
1850
+ const { unitId: t, subUnitId: n, drawingId: r } = e;
1851
+ if (this._establishDrawingMap(t, n, r) == null)
1852
1852
  return { op: [], invertOp: [] };
1853
- const o = V.removeOp([n, t, "data", r], !0), l = V.removeOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(r)], !0), E = [o, l].reduce(V.type.compose, null), B = V.type.invertWithDoc(E, this.drawingManagerData);
1853
+ const o = V.removeOp([t, n, "data", r], !0), l = V.removeOp([t, n, "order", this._getDrawingOrder(t, n).indexOf(r)], !0), E = [o, l].reduce(V.type.compose, null), B = V.type.invertWithDoc(E, this.drawingManagerData);
1854
1854
  return { op: E, invertOp: B };
1855
1855
  }
1856
1856
  _updateByParam(e) {
1857
- const { unitId: n, subUnitId: t, drawingId: r } = e, u = this._establishDrawingMap(n, t, r);
1857
+ const { unitId: t, subUnitId: n, drawingId: r } = e, u = this._establishDrawingMap(t, n, r);
1858
1858
  if (u == null)
1859
1859
  return { op: [], invertOp: [] };
1860
1860
  const l = this._getUpdateParamCompareOp(e, u).reduce(V.type.compose, null), E = V.type.invertWithDoc(l, this.drawingManagerData);
@@ -1867,22 +1867,22 @@ class ln {
1867
1867
  // }
1868
1868
  // });
1869
1869
  // }
1870
- _getUpdateParamCompareOp(e, n) {
1871
- const { unitId: t, subUnitId: r, drawingId: u } = e, o = [];
1870
+ _getUpdateParamCompareOp(e, t) {
1871
+ const { unitId: n, subUnitId: r, drawingId: u } = e, o = [];
1872
1872
  return Object.keys(e).forEach((l) => {
1873
- const E = e[l], B = n[l];
1873
+ const E = e[l], B = t[l];
1874
1874
  B !== E && o.push(
1875
- V.replaceOp([t, r, "data", u, l], B, E)
1875
+ V.replaceOp([n, r, "data", u, l], B, E)
1876
1876
  );
1877
1877
  }), o;
1878
1878
  }
1879
- _getDrawingData(e, n) {
1880
- var t, r;
1881
- return ((r = (t = this.drawingManagerData[e]) == null ? void 0 : t[n]) == null ? void 0 : r.data) || {};
1879
+ _getDrawingData(e, t) {
1880
+ var n, r;
1881
+ return ((r = (n = this.drawingManagerData[e]) == null ? void 0 : n[t]) == null ? void 0 : r.data) || {};
1882
1882
  }
1883
- _getDrawingOrder(e, n) {
1884
- var t, r;
1885
- return ((r = (t = this.drawingManagerData[e]) == null ? void 0 : t[n]) == null ? void 0 : r.order) || [];
1883
+ _getDrawingOrder(e, t) {
1884
+ var n, r;
1885
+ return ((r = (n = this.drawingManagerData[e]) == null ? void 0 : n[t]) == null ? void 0 : r.order) || [];
1886
1886
  }
1887
1887
  getDrawingVisible() {
1888
1888
  return this._visible;
@@ -1897,9 +1897,9 @@ class ln {
1897
1897
  this._editable = e;
1898
1898
  }
1899
1899
  }
1900
- class un extends ln {
1900
+ class fn extends dn {
1901
1901
  }
1902
- class cn {
1902
+ class hn {
1903
1903
  constructor() {
1904
1904
  F(this, "_waitCount", 0);
1905
1905
  F(this, "_change$", new be());
@@ -1909,27 +1909,27 @@ class cn {
1909
1909
  setWaitCount(e) {
1910
1910
  this._waitCount = e, this._change$.next(e);
1911
1911
  }
1912
- getImageSourceCache(e, n) {
1913
- if (n === at.BASE64) {
1914
- const t = new Image();
1915
- return t.src = e, t;
1912
+ getImageSourceCache(e, t) {
1913
+ if (t === at.BASE64) {
1914
+ const n = new Image();
1915
+ return n.src = e, n;
1916
1916
  }
1917
1917
  return this._imageSourceCache.get(e);
1918
1918
  }
1919
- addImageSourceCache(e, n, t) {
1920
- n === at.BASE64 || t == null || this._imageSourceCache.set(e, t);
1919
+ addImageSourceCache(e, t, n) {
1920
+ t === at.BASE64 || n == null || this._imageSourceCache.set(e, n);
1921
1921
  }
1922
1922
  async getImage(e) {
1923
1923
  return Promise.resolve(e);
1924
1924
  }
1925
1925
  async saveImage(e) {
1926
- return new Promise((n, t) => {
1927
- if (!Zt.includes(e.type)) {
1928
- t(new Error(et.ERROR_IMAGE_TYPE)), this._decreaseWaiting();
1926
+ return new Promise((t, n) => {
1927
+ if (!tn.includes(e.type)) {
1928
+ n(new Error(et.ERROR_IMAGE_TYPE)), this._decreaseWaiting();
1929
1929
  return;
1930
1930
  }
1931
- if (e.size > Yt) {
1932
- t(new Error(et.ERROR_EXCEED_SIZE)), this._decreaseWaiting();
1931
+ if (e.size > en) {
1932
+ n(new Error(et.ERROR_EXCEED_SIZE)), this._decreaseWaiting();
1933
1933
  return;
1934
1934
  }
1935
1935
  const r = new FileReader();
@@ -1937,11 +1937,11 @@ class cn {
1937
1937
  var E;
1938
1938
  const o = (E = u.target) == null ? void 0 : E.result;
1939
1939
  if (o == null) {
1940
- t(new Error(et.ERROR_IMAGE)), this._decreaseWaiting();
1940
+ n(new Error(et.ERROR_IMAGE)), this._decreaseWaiting();
1941
1941
  return;
1942
1942
  }
1943
1943
  const l = qt(6);
1944
- n({
1944
+ t({
1945
1945
  imageId: l,
1946
1946
  imageSourceType: at.BASE64,
1947
1947
  source: o,
@@ -1955,74 +1955,106 @@ class cn {
1955
1955
  this._waitCount -= 1, this._change$.next(this._waitCount);
1956
1956
  }
1957
1957
  }
1958
- var dn = Object.getOwnPropertyDescriptor, fn = (a, e, n, t) => {
1959
- for (var r = t > 1 ? void 0 : t ? dn(e, n) : e, u = a.length - 1, o; u >= 0; u--)
1958
+ class pn extends $t {
1959
+ constructor() {
1960
+ super(...arguments);
1961
+ F(this, "_urlImageDownloader", null);
1962
+ }
1963
+ registerURLImageDownloader(t) {
1964
+ return this._urlImageDownloader = t, Kt(() => {
1965
+ this._urlImageDownloader = null;
1966
+ });
1967
+ }
1968
+ async getImage(t) {
1969
+ if (this._urlImageDownloader)
1970
+ try {
1971
+ return await this._urlImageDownloader(t);
1972
+ } catch (n) {
1973
+ console.error(`Custom downloader failed for ${t}, falling back to default behavior:`, n);
1974
+ }
1975
+ return t;
1976
+ }
1977
+ async downloadImage(t) {
1978
+ if (this._urlImageDownloader)
1979
+ try {
1980
+ const r = await this._urlImageDownloader(t);
1981
+ return await (await fetch(r)).blob();
1982
+ } catch (r) {
1983
+ console.error(`Custom downloader failed for ${t}, falling back to default fetch:`, r);
1984
+ }
1985
+ return await (await fetch(t)).blob();
1986
+ }
1987
+ }
1988
+ var gn = Object.getOwnPropertyDescriptor, yn = (a, e, t, n) => {
1989
+ for (var r = n > 1 ? void 0 : n ? gn(e, t) : e, u = a.length - 1, o; u >= 0; u--)
1960
1990
  (o = a[u]) && (r = o(r) || r);
1961
1991
  return r;
1962
- }, dt = (a, e) => (n, t) => e(n, t, a);
1963
- const hn = "UNIVER_DRAWING_PLUGIN";
1992
+ }, dt = (a, e) => (t, n) => e(t, n, a);
1993
+ const _n = "UNIVER_DRAWING_PLUGIN";
1964
1994
  var ft;
1965
- let At = (ft = class extends Ht {
1966
- constructor(a = vt, e, n, t) {
1967
- super(), this._config = a, this._injector = e, this._configService = n, this._commandService = t;
1968
- const { ...r } = zt(
1995
+ let St = (ft = class extends Xt {
1996
+ constructor(a = mt, e, t, n) {
1997
+ super(), this._config = a, this._injector = e, this._configService = t, this._commandService = n;
1998
+ const { ...r } = Jt(
1969
1999
  {},
1970
- vt,
2000
+ mt,
1971
2001
  this._config
1972
2002
  );
1973
- this._configService.setConfig(en, r);
2003
+ this._configService.setConfig(rn, r);
1974
2004
  }
1975
2005
  onStarting() {
1976
2006
  this._initCommands(), this._initDependencies();
1977
2007
  }
1978
2008
  _initDependencies() {
1979
- var n;
1980
- Xt([
1981
- [Jt, { useClass: cn }],
1982
- [Mt, { useClass: un }]
1983
- ], (n = this._config) == null ? void 0 : n.override).forEach((t) => this._injector.add(t));
2009
+ var t;
2010
+ Yt([
2011
+ [Zt, { useClass: hn }],
2012
+ [Qt, { useClass: pn }],
2013
+ [kt, { useClass: fn }]
2014
+ ], (t = this._config) == null ? void 0 : t.override).forEach((n) => this._injector.add(n));
1984
2015
  }
1985
2016
  _initCommands() {
1986
2017
  [
1987
- Qt
2018
+ nn
1988
2019
  ].forEach((a) => this.disposeWithMe(this._commandService.registerCommand(a)));
1989
2020
  }
1990
- }, F(ft, "pluginName", hn), ft);
1991
- At = fn([
1992
- dt(1, Kt($t)),
1993
- dt(2, Ft),
1994
- dt(3, Vt)
1995
- ], At);
1996
- function On({ unitId: a, subUnitId: e, drawingId: n }, t) {
1997
- return typeof t == "number" ? `${a}#-#${e}#-#${n}#-#${t}` : `${a}#-#${e}#-#${n}`;
2021
+ }, F(ft, "pluginName", _n), ft);
2022
+ St = yn([
2023
+ dt(1, Ft(Vt)),
2024
+ dt(2, Ht),
2025
+ dt(3, zt)
2026
+ ], St);
2027
+ function Cn({ unitId: a, subUnitId: e, drawingId: t }, n) {
2028
+ return typeof n == "number" ? `${a}#-#${e}#-#${t}#-#${n}` : `${a}#-#${e}#-#${t}`;
1998
2029
  }
1999
- const wn = async (a) => new Promise((e, n) => {
2000
- const t = new Image();
2001
- t.src = a, t.onload = () => {
2030
+ const En = async (a) => new Promise((e, t) => {
2031
+ const n = new Image();
2032
+ n.src = a, n.onload = () => {
2002
2033
  e({
2003
- width: t.width,
2004
- height: t.height,
2005
- image: t
2034
+ width: n.width,
2035
+ height: n.height,
2036
+ image: n
2006
2037
  });
2007
- }, t.onerror = (r) => {
2008
- n(r);
2038
+ }, n.onerror = (r) => {
2039
+ t(r);
2009
2040
  };
2010
2041
  });
2011
2042
  export {
2012
- Zt as DRAWING_IMAGE_ALLOW_IMAGE_LIST,
2013
- Yt as DRAWING_IMAGE_ALLOW_SIZE,
2014
- mn as DRAWING_IMAGE_COUNT_LIMIT,
2015
- vn as DRAWING_IMAGE_HEIGHT_LIMIT,
2016
- _n as DRAWING_IMAGE_WIDTH_LIMIT,
2017
- un as DrawingManagerService,
2018
- Mt as IDrawingManagerService,
2019
- In as IImageIoService,
2020
- cn as ImageIoService,
2021
- En as ImageSourceType,
2022
- Dn as ImageUploadStatusType,
2023
- Qt as SetDrawingSelectedOperation,
2024
- ln as UnitDrawingService,
2025
- At as UniverDrawingPlugin,
2026
- On as getDrawingShapeKeyByDrawingSearch,
2027
- wn as getImageSize
2043
+ tn as DRAWING_IMAGE_ALLOW_IMAGE_LIST,
2044
+ en as DRAWING_IMAGE_ALLOW_SIZE,
2045
+ In as DRAWING_IMAGE_COUNT_LIMIT,
2046
+ bn as DRAWING_IMAGE_HEIGHT_LIMIT,
2047
+ wn as DRAWING_IMAGE_WIDTH_LIMIT,
2048
+ fn as DrawingManagerService,
2049
+ kt as IDrawingManagerService,
2050
+ Tn as IImageIoService,
2051
+ hn as ImageIoService,
2052
+ Sn as ImageSourceType,
2053
+ kn as ImageUploadStatusType,
2054
+ nn as SetDrawingSelectedOperation,
2055
+ pn as URLImageService,
2056
+ dn as UnitDrawingService,
2057
+ St as UniverDrawingPlugin,
2058
+ Cn as getDrawingShapeKeyByDrawingSearch,
2059
+ En as getImageSize
2028
2060
  };