@univerjs/drawing 0.5.3 → 0.5.4

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,14 +1,14 @@
1
- var $t = Object.defineProperty;
2
- var Nt = (a, e, n) => e in a ? $t(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
3
- var F = (a, e, n) => Nt(a, typeof e != "symbol" ? e + "" : e, n);
4
- import { sortRules as Rt, sortRulesByDesc as xt, createIdentifier as Bt, ImageSourceType as at, ImageUploadStatusType as Qe, Tools as Wt, Inject as Gt, Injector as Lt, Plugin as qt, merge as Kt, mergeOverrideWithDependencies as Ft, IConfigService as Vt, IImageIoService as Ht } from "@univerjs/core";
5
- import { IImageIoService as bn, ImageSourceType as Cn, ImageUploadStatusType as In } from "@univerjs/core";
6
- import { Subject as be } from "rxjs";
7
- const gn = 500, yn = 500, _n = 10, zt = 5 * 1024 * 1024, Xt = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp"];
8
- var Ye = {}, et = {}, tt = {}, _t;
9
- function Jt() {
10
- if (_t) return tt;
11
- _t = 1, Object.defineProperty(tt, "__esModule", { value: !0 });
1
+ var Nt = Object.defineProperty;
2
+ var Rt = (a, e, n) => e in a ? Nt(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
3
+ var F = (a, e, n) => Rt(a, typeof e != "symbol" ? e + "" : e, n);
4
+ import { sortRules as xt, sortRulesByDesc as Bt, createIdentifier as Wt, CommandType as Gt, ImageSourceType as at, ImageUploadStatusType as Qe, Tools as Lt, Inject as qt, Injector as Kt, Plugin as Ft, merge as Vt, mergeOverrideWithDependencies as Ht, IConfigService as zt, ICommandService as Xt, IImageIoService as Jt } from "@univerjs/core";
5
+ import { IImageIoService as En, ImageSourceType as Dn, ImageUploadStatusType as Pn } from "@univerjs/core";
6
+ import { Subject as ve } from "rxjs";
7
+ const mn = 500, On = 500, wn = 10, Yt = 5 * 1024 * 1024, Zt = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp"];
8
+ var Ye = {}, et = {}, tt = {}, mt;
9
+ function Qt() {
10
+ if (mt) return tt;
11
+ mt = 1, Object.defineProperty(tt, "__esModule", { value: !0 });
12
12
  function a(t, r) {
13
13
  if (Array.isArray(r))
14
14
  return !1;
@@ -33,10 +33,10 @@ function Jt() {
33
33
  }
34
34
  return tt.default = n, tt;
35
35
  }
36
- var nt = {}, vt;
37
- function Yt() {
38
- if (vt) return nt;
39
- vt = 1, Object.defineProperty(nt, "__esModule", { value: !0 });
36
+ var nt = {}, Ot;
37
+ function en() {
38
+ if (Ot) return nt;
39
+ Ot = 1, Object.defineProperty(nt, "__esModule", { value: !0 });
40
40
  function a(e) {
41
41
  if (e === null)
42
42
  return null;
@@ -52,9 +52,9 @@ function Yt() {
52
52
  }
53
53
  return nt.default = a, nt;
54
54
  }
55
- var lt = {}, mt;
55
+ var lt = {}, wt;
56
56
  function Mt() {
57
- return mt || (mt = 1, function(a) {
57
+ return wt || (wt = 1, function(a) {
58
58
  Object.defineProperty(a, "__esModule", { value: !0 }), a.eachChildOf = a.advancer = a.readCursor = a.writeCursor = a.WriteCursor = a.ReadCursor = a.isValidPathItem = void 0;
59
59
  function e(_, s) {
60
60
  if (!_)
@@ -65,8 +65,8 @@ function Mt() {
65
65
  typeof _ == typeof s ? _ > s : typeof _ == "string" && typeof s == "number"
66
66
  );
67
67
  function r(_, s) {
68
- for (let c in _) {
69
- const h = c;
68
+ for (let d in _) {
69
+ const h = d;
70
70
  s.write(h, _[h]);
71
71
  }
72
72
  }
@@ -80,9 +80,9 @@ function Mt() {
80
80
  }
81
81
  getPath() {
82
82
  const s = [];
83
- let c = this.container, h = this.parents.length - 1, S = this.idx;
84
- for (; S >= 0; )
85
- s.unshift(c[S]), S === 0 ? (S = this.indexes[h * 2], c = this.parents[h--]) : S -= n(c[S - 1]) ? 2 : 1;
83
+ let d = this.container, h = this.parents.length - 1, k = this.idx;
84
+ for (; k >= 0; )
85
+ s.unshift(d[k]), k === 0 ? (k = this.indexes[h * 2], d = this.parents[h--]) : k -= n(d[k - 1]) ? 2 : 1;
86
86
  return s;
87
87
  }
88
88
  }
@@ -103,17 +103,17 @@ function Mt() {
103
103
  if (!this.container || s >= this.container.length || n(this.container[s]) && s + 1 >= this.container.length)
104
104
  return !1;
105
105
  n(this.container[s]) && s++;
106
- const c = this.container[s];
107
- 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;
106
+ const d = this.container[s];
107
+ return Array.isArray(d) ? (this.indexes.push(this.idx), this.parents.push(this.container), this.indexes.push(s), this.idx = 0, this.container = d) : this.idx = s, !0;
108
108
  }
109
109
  nextSibling() {
110
110
  if (e(this.parents.length === this.indexes.length / 2), this.idx > 0 || this.parents.length === 0)
111
111
  return !1;
112
- const s = this.indexes[this.indexes.length - 1] + 1, c = this.parents[this.parents.length - 1];
113
- return s >= c.length ? !1 : (e(!isNaN(s)), this.indexes[this.indexes.length - 1] = s, this.container = c[s], !0);
112
+ const s = this.indexes[this.indexes.length - 1] + 1, d = this.parents[this.parents.length - 1];
113
+ return s >= d.length ? !1 : (e(!isNaN(s)), this.indexes[this.indexes.length - 1] = s, this.container = d[s], !0);
114
114
  }
115
- _init(s, c, h, S) {
116
- this.container = s, this.idx = c, this.parents = h.slice(), this.indexes = S.slice();
115
+ _init(s, d, h, k) {
116
+ this.container = s, this.idx = d, this.parents = h.slice(), this.indexes = k.slice();
117
117
  }
118
118
  clone() {
119
119
  const s = new o();
@@ -130,20 +130,20 @@ function Mt() {
130
130
  // TODO(cleanup): Consider moving these functions out of cursor, since
131
131
  // they're really just helper methods.
132
132
  // It'd be really nice to do this using generators.
133
- traverse(s, c) {
133
+ traverse(s, d) {
134
134
  const h = this.getComponent();
135
- h && c(h, s);
136
- for (const S of this)
137
- s && s.descend(S), this.traverse(s, c), s && s.ascend();
135
+ h && d(h, s);
136
+ for (const k of this)
137
+ s && s.descend(k), this.traverse(s, d), s && s.ascend();
138
138
  }
139
- eachPick(s, c) {
140
- this.traverse(s, (h, S) => {
141
- h.p != null && c(h.p, S);
139
+ eachPick(s, d) {
140
+ this.traverse(s, (h, k) => {
141
+ h.p != null && d(h.p, k);
142
142
  });
143
143
  }
144
- eachDrop(s, c) {
145
- this.traverse(s, (h, S) => {
146
- h.d != null && c(h.d, S);
144
+ eachDrop(s, d) {
145
+ this.traverse(s, (h, k) => {
146
+ h.d != null && d(h.d, k);
147
147
  });
148
148
  }
149
149
  }
@@ -155,24 +155,24 @@ function Mt() {
155
155
  flushDescent() {
156
156
  e(this.parents.length === this.indexes.length / 2), this.container === null && (this._op = this.container = []);
157
157
  for (let s = 0; s < this.pendingDescent.length; s++) {
158
- const c = this.pendingDescent[s];
158
+ const d = this.pendingDescent[s];
159
159
  let h = this.idx + 1;
160
160
  if (h < this.container.length && n(this.container[h]) && h++, e(h === this.container.length || !n(this.container[h])), h === this.container.length)
161
- this.container.push(c), this.idx = h;
162
- else if (this.container[h] === c)
161
+ this.container.push(d), this.idx = h;
162
+ else if (this.container[h] === d)
163
163
  this.idx = h;
164
164
  else {
165
165
  if (!Array.isArray(this.container[h])) {
166
- const S = this.container.splice(h, this.container.length - h);
167
- this.container.push(S), this.lcIdx > -1 && (this.lcIdx = h);
166
+ const k = this.container.splice(h, this.container.length - h);
167
+ this.container.push(k), this.lcIdx > -1 && (this.lcIdx = h);
168
168
  }
169
- 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]); )
169
+ for (this.indexes.push(this.idx), this.parents.push(this.container), this.lcIdx !== -1 && (e(t(d, this.container[this.lcIdx][0])), h = this.lcIdx + 1, this.lcIdx = -1); h < this.container.length && t(d, this.container[h][0]); )
170
170
  h++;
171
- if (this.indexes.push(h), this.idx = 0, h < this.container.length && this.container[h][0] === c)
171
+ if (this.indexes.push(h), this.idx = 0, h < this.container.length && this.container[h][0] === d)
172
172
  this.container = this.container[h];
173
173
  else {
174
- const S = [c];
175
- this.container.splice(h, 0, S), this.container = S;
174
+ const k = [d];
175
+ this.container.splice(h, 0, k), this.container = k;
176
176
  }
177
177
  }
178
178
  }
@@ -190,13 +190,13 @@ function Mt() {
190
190
  if (s < this.container.length && n(this.container[s]))
191
191
  return this.container[s];
192
192
  {
193
- const c = {};
194
- return this.container.splice(s, 0, c), c;
193
+ const d = {};
194
+ return this.container.splice(s, 0, d), d;
195
195
  }
196
196
  }
197
- write(s, c) {
197
+ write(s, d) {
198
198
  const h = this.getComponent();
199
- e(h[s] == null || h[s] === c, "Internal consistency error: Overwritten component. File a bug"), h[s] = c;
199
+ e(h[s] == null || h[s] === d, "Internal consistency error: Overwritten component. File a bug"), h[s] = d;
200
200
  }
201
201
  get() {
202
202
  return this._op;
@@ -212,34 +212,34 @@ function Mt() {
212
212
  ascend() {
213
213
  this.pendingDescent.length ? this.pendingDescent.pop() : super.ascend();
214
214
  }
215
- mergeTree(s, c = r) {
215
+ mergeTree(s, d = r) {
216
216
  if (s === null)
217
217
  return;
218
218
  if (e(Array.isArray(s)), s === this._op)
219
219
  throw Error("Cannot merge into my own tree");
220
- const h = this.lcIdx, S = this.parents.length;
220
+ const h = this.lcIdx, k = this.parents.length;
221
221
  let Y = 0;
222
222
  for (let pe = 0; pe < s.length; pe++) {
223
223
  const Z = s[pe];
224
- typeof Z == "string" || typeof Z == "number" ? (Y++, this.descend(Z)) : Array.isArray(Z) ? this.mergeTree(Z, c) : typeof Z == "object" && c(Z, this);
224
+ typeof Z == "string" || typeof Z == "number" ? (Y++, this.descend(Z)) : Array.isArray(Z) ? this.mergeTree(Z, d) : typeof Z == "object" && d(Z, this);
225
225
  }
226
226
  for (; Y--; )
227
227
  this.ascend();
228
- this.lcIdx = this.parents.length === S ? h : -1;
228
+ this.lcIdx = this.parents.length === k ? h : -1;
229
229
  }
230
- at(s, c) {
231
- this.descendPath(s), c(this);
230
+ at(s, d) {
231
+ this.descendPath(s), d(this);
232
232
  for (let h = 0; h < s.length; h++)
233
233
  this.ascend();
234
234
  return this;
235
235
  }
236
236
  // This is used by helpers, so the strict ordering guarantees are
237
237
  // relaxed.
238
- writeAtPath(s, c, h) {
239
- return this.at(s, () => this.write(c, h)), this.reset(), this;
238
+ writeAtPath(s, d, h) {
239
+ return this.at(s, () => this.write(d, h)), this.reset(), this;
240
240
  }
241
- writeMove(s, c, h = 0) {
242
- return this.writeAtPath(s, "p", h).writeAtPath(c, "d", h);
241
+ writeMove(s, d, h = 0) {
242
+ return this.writeAtPath(s, "p", h).writeAtPath(d, "d", h);
243
243
  }
244
244
  getPath() {
245
245
  const s = super.getPath();
@@ -247,12 +247,12 @@ function Mt() {
247
247
  }
248
248
  }
249
249
  a.WriteCursor = l, a.writeCursor = () => new l(), a.readCursor = (_) => new o(_);
250
- function E(_, s, c) {
251
- let h, S;
252
- S = h = _ ? _.descendFirst() : !1;
250
+ function E(_, s, d) {
251
+ let h, k;
252
+ k = h = _ ? _.descendFirst() : !1;
253
253
  function Y(pe) {
254
254
  let Z;
255
- for (; S; ) {
255
+ for (; k; ) {
256
256
  const Ce = Z = _.getKey();
257
257
  if (pe != null) {
258
258
  let Ge = !1;
@@ -261,7 +261,7 @@ function Mt() {
261
261
  if (Z === pe && !Ge)
262
262
  return _;
263
263
  }
264
- c && typeof Z == "number" && c(Z, _.getComponent()), S = _.nextSibling();
264
+ d && typeof Z == "number" && d(Z, _.getComponent()), k = _.nextSibling();
265
265
  }
266
266
  return null;
267
267
  }
@@ -270,28 +270,28 @@ function Mt() {
270
270
  }, Y;
271
271
  }
272
272
  a.advancer = E;
273
- function x(_, s, c) {
274
- let h, S, Y, pe;
275
- for (h = S = _ && _.descendFirst(), Y = pe = s && s.descendFirst(); h || Y; ) {
273
+ function x(_, s, d) {
274
+ let h, k, Y, pe;
275
+ for (h = k = _ && _.descendFirst(), Y = pe = s && s.descendFirst(); h || Y; ) {
276
276
  let Z = h ? _.getKey() : null, Ce = Y ? s.getKey() : null;
277
- 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());
277
+ Z !== null && Ce !== null && (t(Ce, Z) ? Ce = null : Z !== Ce && (Z = null)), d(Z == null ? Ce : Z, Z != null ? _ : null, Ce != null ? s : null), Z != null && h && (h = _.nextSibling()), Ce != null && Y && (Y = s.nextSibling());
278
278
  }
279
- S && _.ascend(), pe && s.ascend();
279
+ k && _.ascend(), pe && s.ascend();
280
280
  }
281
281
  a.eachChildOf = x;
282
282
  }(lt)), lt;
283
283
  }
284
- var ut = {}, Ot;
285
- function Ut() {
286
- return Ot || (Ot = 1, function(a) {
284
+ var ut = {}, bt;
285
+ function St() {
286
+ return bt || (bt = 1, function(a) {
287
287
  Object.defineProperty(a, "__esModule", { value: !0 }), a.ConflictType = void 0, function(e) {
288
288
  e[e.RM_UNEXPECTED_CONTENT = 1] = "RM_UNEXPECTED_CONTENT", e[e.DROP_COLLISION = 2] = "DROP_COLLISION", e[e.BLACKHOLE = 3] = "BLACKHOLE";
289
289
  }(a.ConflictType || (a.ConflictType = {}));
290
290
  }(ut)), ut;
291
291
  }
292
- var Fe = {}, Ve = {}, wt;
293
- function ht() {
294
- return wt || (wt = 1, Object.defineProperty(Ve, "__esModule", { value: !0 }), Ve.uniToStrPos = Ve.strPosToUni = void 0, Ve.strPosToUni = (a, e = a.length) => {
292
+ var Fe = {}, Ve = {}, vt;
293
+ function pt() {
294
+ return vt || (vt = 1, Object.defineProperty(Ve, "__esModule", { value: !0 }), Ve.uniToStrPos = Ve.strPosToUni = void 0, Ve.strPosToUni = (a, e = a.length) => {
295
295
  let n = 0, t = 0;
296
296
  for (; t < e; t++) {
297
297
  const r = a.charCodeAt(t);
@@ -309,16 +309,16 @@ function ht() {
309
309
  return n;
310
310
  }), Ve;
311
311
  }
312
- var ct = {}, bt;
313
- function ft() {
314
- return bt || (bt = 1, function(a) {
312
+ var dt = {}, Ct;
313
+ function ht() {
314
+ return Ct || (Ct = 1, function(a) {
315
315
  Object.defineProperty(a, "__esModule", { value: !0 }), a.uniSlice = a.dlen = a.eachOp = void 0;
316
- const e = ht(), n = (f) => {
316
+ const e = pt(), n = (f) => {
317
317
  if (!Array.isArray(f))
318
318
  throw Error("Op must be an array of components");
319
319
  let y = null;
320
- for (let b = 0; b < f.length; b++) {
321
- const L = f[b];
320
+ for (let v = 0; v < f.length; v++) {
321
+ const L = f[v];
322
322
  switch (typeof L) {
323
323
  case "object":
324
324
  if (typeof L.d != "number" && typeof L.d != "string")
@@ -343,28 +343,28 @@ function ft() {
343
343
  throw Error("Op has a trailing skip");
344
344
  };
345
345
  function t(f, y) {
346
- let b = 0, L = 0;
346
+ let v = 0, L = 0;
347
347
  for (let z = 0; z < f.length; z++) {
348
348
  const q = f[z];
349
- switch (y(q, b, L), typeof q) {
349
+ switch (y(q, v, L), typeof q) {
350
350
  case "object":
351
- b += a.dlen(q.d);
351
+ v += a.dlen(q.d);
352
352
  break;
353
353
  case "string":
354
354
  L += e.strPosToUni(q);
355
355
  break;
356
356
  case "number":
357
- b += q, L += q;
357
+ v += q, L += q;
358
358
  break;
359
359
  }
360
360
  }
361
361
  }
362
362
  a.eachOp = t;
363
363
  function r(f, y) {
364
- const b = [], L = l(b);
364
+ const v = [], L = l(v);
365
365
  return t(f, (z, q, Ee) => {
366
366
  L(y(z, q, Ee));
367
- }), s(b);
367
+ }), s(v);
368
368
  }
369
369
  const u = (f) => f, o = (f) => r(f, u);
370
370
  a.dlen = (f) => typeof f == "number" ? f : e.strPosToUni(f);
@@ -373,46 +373,46 @@ function ft() {
373
373
  f.push(y);
374
374
  else if (typeof y == typeof f[f.length - 1])
375
375
  if (typeof y == "object") {
376
- const b = f[f.length - 1];
377
- b.d = typeof b.d == "string" && typeof y.d == "string" ? b.d + y.d : a.dlen(b.d) + a.dlen(y.d);
376
+ const v = f[f.length - 1];
377
+ v.d = typeof v.d == "string" && typeof y.d == "string" ? v.d + y.d : a.dlen(v.d) + a.dlen(y.d);
378
378
  } else
379
379
  f[f.length - 1] += y;
380
380
  else
381
381
  f.push(y);
382
382
  }, E = (f) => typeof f == "number" ? f : typeof f == "string" ? e.strPosToUni(f) : typeof f.d == "number" ? f.d : e.strPosToUni(f.d);
383
- a.uniSlice = (f, y, b) => {
384
- const L = e.uniToStrPos(f, y), z = b == null ? 1 / 0 : e.uniToStrPos(f, b);
383
+ a.uniSlice = (f, y, v) => {
384
+ const L = e.uniToStrPos(f, y), z = v == null ? 1 / 0 : e.uniToStrPos(f, v);
385
385
  return f.slice(L, z);
386
386
  };
387
- const x = (f, y, b) => typeof f == "number" ? b == null ? f - y : Math.min(f, b) - y : a.uniSlice(f, y, b), _ = (f) => {
388
- let y = 0, b = 0;
387
+ const x = (f, y, v) => typeof f == "number" ? v == null ? f - y : Math.min(f, v) - y : a.uniSlice(f, y, v), _ = (f) => {
388
+ let y = 0, v = 0;
389
389
  return { take: (q, Ee) => {
390
390
  if (y === f.length)
391
391
  return q === -1 ? null : q;
392
- const ce = f[y];
392
+ const de = f[y];
393
393
  let ne;
394
- if (typeof ce == "number")
395
- return q === -1 || ce - b <= q ? (ne = ce - b, ++y, b = 0, ne) : (b += q, q);
396
- if (typeof ce == "string") {
397
- if (q === -1 || Ee === "i" || e.strPosToUni(ce.slice(b)) <= q)
398
- return ne = ce.slice(b), ++y, b = 0, ne;
394
+ if (typeof de == "number")
395
+ return q === -1 || de - v <= q ? (ne = de - v, ++y, v = 0, ne) : (v += q, q);
396
+ if (typeof de == "string") {
397
+ if (q === -1 || Ee === "i" || e.strPosToUni(de.slice(v)) <= q)
398
+ return ne = de.slice(v), ++y, v = 0, ne;
399
399
  {
400
- const le = b + e.uniToStrPos(ce.slice(b), q);
401
- return ne = ce.slice(b, le), b = le, ne;
400
+ const le = v + e.uniToStrPos(de.slice(v), q);
401
+ return ne = de.slice(v, le), v = le, ne;
402
402
  }
403
403
  } else {
404
- if (q === -1 || Ee === "d" || a.dlen(ce.d) - b <= q)
405
- return ne = { d: x(ce.d, b) }, ++y, b = 0, ne;
404
+ if (q === -1 || Ee === "d" || a.dlen(de.d) - v <= q)
405
+ return ne = { d: x(de.d, v) }, ++y, v = 0, ne;
406
406
  {
407
- let le = x(ce.d, b, b + q);
408
- return b += q, { d: le };
407
+ let le = x(de.d, v, v + q);
408
+ return v += q, { d: le };
409
409
  }
410
410
  }
411
411
  }, peek: () => f[y] };
412
412
  }, s = (f) => (f.length > 0 && typeof f[f.length - 1] == "number" && f.pop(), f);
413
- function c(f, y, b) {
414
- if (b !== "left" && b !== "right")
415
- throw Error("side (" + b + ") must be 'left' or 'right'");
413
+ function d(f, y, v) {
414
+ if (v !== "left" && v !== "right")
415
+ throw Error("side (" + v + ") must be 'left' or 'right'");
416
416
  n(f), n(y);
417
417
  const L = [], z = l(L), { take: q, peek: Ee } = _(f);
418
418
  for (let ne = 0; ne < y.length; ne++) {
@@ -424,7 +424,7 @@ function ft() {
424
424
  De = q(ge, "i"), z(De), typeof De != "string" && (ge -= E(De));
425
425
  break;
426
426
  case "string":
427
- b === "left" && typeof Ee() == "string" && z(q(-1)), z(e.strPosToUni(le));
427
+ v === "left" && typeof Ee() == "string" && z(q(-1)), z(e.strPosToUni(le));
428
428
  break;
429
429
  case "object":
430
430
  for (ge = a.dlen(le.d); ge > 0; )
@@ -441,32 +441,32 @@ function ft() {
441
441
  break;
442
442
  }
443
443
  }
444
- let ce;
445
- for (; ce = q(-1); )
446
- z(ce);
444
+ let de;
445
+ for (; de = q(-1); )
446
+ z(de);
447
447
  return s(L);
448
448
  }
449
449
  function h(f, y) {
450
450
  n(f), n(y);
451
- const b = [], L = l(b), { take: z } = _(f);
451
+ const v = [], L = l(v), { take: z } = _(f);
452
452
  for (let Ee = 0; Ee < y.length; Ee++) {
453
- const ce = y[Ee];
453
+ const de = y[Ee];
454
454
  let ne, le;
455
- switch (typeof ce) {
455
+ switch (typeof de) {
456
456
  case "number":
457
- for (ne = ce; ne > 0; )
457
+ for (ne = de; ne > 0; )
458
458
  le = z(ne, "d"), L(le), typeof le != "object" && (ne -= E(le));
459
459
  break;
460
460
  case "string":
461
- L(ce);
461
+ L(de);
462
462
  break;
463
463
  case "object":
464
- ne = a.dlen(ce.d);
464
+ ne = a.dlen(de.d);
465
465
  let ge = 0;
466
466
  for (; ge < ne; )
467
467
  switch (le = z(ne - ge, "d"), typeof le) {
468
468
  case "number":
469
- L({ d: x(ce.d, ge, ge + le) }), ge += le;
469
+ L({ d: x(de.d, ge, ge + le) }), ge += le;
470
470
  break;
471
471
  case "string":
472
472
  ge += e.strPosToUni(le);
@@ -480,30 +480,30 @@ function ft() {
480
480
  let q;
481
481
  for (; q = z(-1); )
482
482
  L(q);
483
- return s(b);
483
+ return s(v);
484
484
  }
485
- const S = (f, y) => {
486
- let b = 0;
487
- for (let L = 0; L < y.length && f > b; L++) {
485
+ const k = (f, y) => {
486
+ let v = 0;
487
+ for (let L = 0; L < y.length && f > v; L++) {
488
488
  const z = y[L];
489
489
  switch (typeof z) {
490
490
  case "number": {
491
- b += z;
491
+ v += z;
492
492
  break;
493
493
  }
494
494
  case "string":
495
495
  const q = e.strPosToUni(z);
496
- b += q, f += q;
496
+ v += q, f += q;
497
497
  break;
498
498
  case "object":
499
- f -= Math.min(a.dlen(z.d), f - b);
499
+ f -= Math.min(a.dlen(z.d), f - v);
500
500
  break;
501
501
  }
502
502
  }
503
503
  return f;
504
- }, Y = (f, y) => typeof f == "number" ? S(f, y) : f.map((b) => S(b, y));
505
- function pe(f, y, b) {
506
- return r(f, (L, z) => typeof L == "object" && typeof L.d == "number" ? { d: b.slice(y, z, z + L.d) } : L);
504
+ }, Y = (f, y) => typeof f == "number" ? k(f, y) : f.map((v) => k(v, y));
505
+ function pe(f, y, v) {
506
+ return r(f, (L, z) => typeof L == "object" && typeof L.d == "number" ? { d: v.slice(y, z, z + L.d) } : L);
507
507
  }
508
508
  function Z(f) {
509
509
  return r(f, (y) => {
@@ -526,11 +526,11 @@ function ft() {
526
526
  }
527
527
  function Ge(f) {
528
528
  let y = !0;
529
- return t(f, (b) => {
530
- typeof b == "object" && typeof b.d == "number" && (y = !1);
529
+ return t(f, (v) => {
530
+ typeof v == "object" && typeof v.d == "number" && (y = !1);
531
531
  }), y;
532
532
  }
533
- function ve(f) {
533
+ function me(f) {
534
534
  return {
535
535
  name: "text-unicode",
536
536
  uri: "http://sharejs.org/types/text-unicode",
@@ -549,11 +549,11 @@ function ft() {
549
549
  },
550
550
  /** Apply an operation to a document snapshot
551
551
  */
552
- apply(y, b) {
553
- n(b);
552
+ apply(y, v) {
553
+ n(v);
554
554
  const L = f.builder(y);
555
- for (let z = 0; z < b.length; z++) {
556
- const q = b[z];
555
+ for (let z = 0; z < v.length; z++) {
556
+ const q = v[z];
557
557
  switch (typeof q) {
558
558
  case "number":
559
559
  L.skip(q);
@@ -568,30 +568,30 @@ function ft() {
568
568
  }
569
569
  return L.build();
570
570
  },
571
- transform: c,
571
+ transform: d,
572
572
  compose: h,
573
- transformPosition: S,
573
+ transformPosition: k,
574
574
  transformSelection: Y,
575
575
  isInvertible: Ge,
576
- makeInvertible(y, b) {
577
- return pe(y, b, f);
576
+ makeInvertible(y, v) {
577
+ return pe(y, v, f);
578
578
  },
579
579
  stripInvertible: Ce,
580
580
  invert: Z,
581
- invertWithDoc(y, b) {
582
- return Z(pe(y, b, f));
581
+ invertWithDoc(y, v) {
582
+ return Z(pe(y, v, f));
583
583
  },
584
584
  isNoop: (y) => y.length === 0
585
585
  };
586
586
  }
587
- a.default = ve;
588
- }(ct)), ct;
587
+ a.default = me;
588
+ }(dt)), dt;
589
589
  }
590
- var rt = {}, Ct;
591
- function Zt() {
592
- if (Ct) return rt;
593
- Ct = 1, Object.defineProperty(rt, "__esModule", { value: !0 });
594
- const a = ft(), e = ht();
590
+ var rt = {}, It;
591
+ function tn() {
592
+ if (It) return rt;
593
+ It = 1, Object.defineProperty(rt, "__esModule", { value: !0 });
594
+ const a = ht(), e = pt();
595
595
  function n(t, r) {
596
596
  return {
597
597
  // Returns the text content of the document
@@ -631,69 +631,69 @@ function Zt() {
631
631
  }
632
632
  return rt.default = n, n.provides = { text: !0 }, rt;
633
633
  }
634
- var It;
635
- function Qt() {
636
- return It || (It = 1, function(a) {
637
- var e = Fe.__createBinding || (Object.create ? function(c, h, S, Y) {
638
- Y === void 0 && (Y = S), Object.defineProperty(c, Y, { enumerable: !0, get: function() {
639
- return h[S];
634
+ var Et;
635
+ function nn() {
636
+ return Et || (Et = 1, function(a) {
637
+ var e = Fe.__createBinding || (Object.create ? function(d, h, k, Y) {
638
+ Y === void 0 && (Y = k), Object.defineProperty(d, Y, { enumerable: !0, get: function() {
639
+ return h[k];
640
640
  } });
641
- } : function(c, h, S, Y) {
642
- Y === void 0 && (Y = S), c[Y] = h[S];
643
- }), n = Fe.__setModuleDefault || (Object.create ? function(c, h) {
644
- Object.defineProperty(c, "default", { enumerable: !0, value: h });
645
- } : function(c, h) {
646
- c.default = h;
647
- }), t = Fe.__importStar || function(c) {
648
- if (c && c.__esModule) return c;
641
+ } : function(d, h, k, Y) {
642
+ Y === void 0 && (Y = k), d[Y] = h[k];
643
+ }), n = Fe.__setModuleDefault || (Object.create ? function(d, h) {
644
+ Object.defineProperty(d, "default", { enumerable: !0, value: h });
645
+ } : function(d, h) {
646
+ d.default = h;
647
+ }), t = Fe.__importStar || function(d) {
648
+ if (d && d.__esModule) return d;
649
649
  var h = {};
650
- if (c != null) for (var S in c) Object.hasOwnProperty.call(c, S) && e(h, c, S);
651
- return n(h, c), h;
652
- }, r = Fe.__importDefault || function(c) {
653
- return c && c.__esModule ? c : { default: c };
650
+ if (d != null) for (var k in d) Object.hasOwnProperty.call(d, k) && e(h, d, k);
651
+ return n(h, d), h;
652
+ }, r = Fe.__importDefault || function(d) {
653
+ return d && d.__esModule ? d : { default: d };
654
654
  };
655
655
  Object.defineProperty(a, "__esModule", { value: !0 }), a.type = a.remove = a.insert = void 0;
656
- const u = ht(), o = t(ft()), l = r(Zt()), E = {
657
- create(c) {
658
- return c;
656
+ const u = pt(), o = t(ht()), l = r(tn()), E = {
657
+ create(d) {
658
+ return d;
659
659
  },
660
- toString(c) {
661
- return c;
660
+ toString(d) {
661
+ return d;
662
662
  },
663
- builder(c) {
664
- if (typeof c != "string")
665
- throw Error("Invalid document snapshot: " + c);
663
+ builder(d) {
664
+ if (typeof d != "string")
665
+ throw Error("Invalid document snapshot: " + d);
666
666
  const h = [];
667
667
  return {
668
- skip(S) {
669
- let Y = u.uniToStrPos(c, S);
670
- if (Y > c.length)
668
+ skip(k) {
669
+ let Y = u.uniToStrPos(d, k);
670
+ if (Y > d.length)
671
671
  throw Error("The op is too long for this document");
672
- h.push(c.slice(0, Y)), c = c.slice(Y);
672
+ h.push(d.slice(0, Y)), d = d.slice(Y);
673
673
  },
674
- append(S) {
675
- h.push(S);
674
+ append(k) {
675
+ h.push(k);
676
676
  },
677
- del(S) {
678
- c = c.slice(u.uniToStrPos(c, S));
677
+ del(k) {
678
+ d = d.slice(u.uniToStrPos(d, k));
679
679
  },
680
680
  build() {
681
- return h.join("") + c;
681
+ return h.join("") + d;
682
682
  }
683
683
  };
684
684
  },
685
685
  slice: o.uniSlice
686
686
  }, x = o.default(E), _ = Object.assign(Object.assign({}, x), { api: l.default });
687
- a.type = _, a.insert = (c, h) => h.length === 0 ? [] : c === 0 ? [h] : [c, h], a.remove = (c, h) => o.dlen(h) === 0 ? [] : c === 0 ? [{ d: h }] : [c, { d: h }];
688
- var s = ft();
687
+ a.type = _, a.insert = (d, h) => h.length === 0 ? [] : d === 0 ? [h] : [d, h], a.remove = (d, h) => o.dlen(h) === 0 ? [] : d === 0 ? [{ d: h }] : [d, { d: h }];
688
+ var s = ht();
689
689
  Object.defineProperty(a, "makeType", { enumerable: !0, get: function() {
690
690
  return s.default;
691
691
  } });
692
692
  }(Fe)), Fe;
693
693
  }
694
- var Et;
695
- function en() {
696
- return Et || (Et = 1, function(a) {
694
+ var Dt;
695
+ function rn() {
696
+ return Dt || (Dt = 1, function(a) {
697
697
  var e = et.__importDefault || function(i) {
698
698
  return i && i.__esModule ? i : {
699
699
  default: i
@@ -702,9 +702,9 @@ function en() {
702
702
  Object.defineProperty(a, "__esModule", {
703
703
  value: !0
704
704
  }), a.editOp = a.replaceOp = a.insertOp = a.moveOp = a.removeOp = a.type = void 0;
705
- const n = e(Jt()), t = e(Yt()), r = Mt(), u = Ut();
706
- function o(i, d) {
707
- if (!i) throw new Error(d);
705
+ const n = e(Qt()), t = e(en()), r = Mt(), u = St();
706
+ function o(i, c) {
707
+ if (!i) throw new Error(c);
708
708
  }
709
709
  a.type = {
710
710
  name: "json1",
@@ -719,19 +719,19 @@ function en() {
719
719
  checkValidOp: z,
720
720
  normalize: q,
721
721
  apply: Ee,
722
- transformPosition: ce,
722
+ transformPosition: de,
723
723
  compose: ne,
724
724
  tryTransform: st,
725
- transform: St,
725
+ transform: jt,
726
726
  makeInvertible: De,
727
727
  invert: le,
728
728
  invertWithDoc: kt,
729
729
  RM_UNEXPECTED_CONTENT: u.ConflictType.RM_UNEXPECTED_CONTENT,
730
730
  DROP_COLLISION: u.ConflictType.DROP_COLLISION,
731
731
  BLACKHOLE: u.ConflictType.BLACKHOLE,
732
- transformNoConflict: (i, d, m) => gt(() => !0, i, d, m),
732
+ transformNoConflict: (i, c, O) => yt(() => !0, i, c, O),
733
733
  typeAllowingConflictsPred: (i) => Object.assign(Object.assign({}, a.type), {
734
- transform: (d, m, D) => gt(i, d, m, D)
734
+ transform: (c, O, D) => yt(i, c, O, D)
735
735
  })
736
736
  };
737
737
  const l = (i) => i ? i.getComponent() : null;
@@ -739,27 +739,27 @@ function en() {
739
739
  return i && typeof i == "object" && !Array.isArray(i);
740
740
  }
741
741
  const x = (i) => Array.isArray(i) ? i.slice() : i !== null && typeof i == "object" ? Object.assign({}, i) : i, _ = (i) => i && (i.p != null || i.r !== void 0), s = (i) => i && (i.d != null || i.i !== void 0);
742
- function c(i, d) {
743
- 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;
742
+ function d(i, c) {
743
+ return o(i != null), typeof c == "number" ? (o(Array.isArray(i), "Invalid key - child is not an array"), (i = i.slice()).splice(c, 1)) : (o(E(i), "Invalid key - child is not an object"), delete (i = Object.assign({}, i))[c]), i;
744
744
  }
745
- function h(i, d, m) {
746
- 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;
745
+ function h(i, c, O) {
746
+ return typeof c == "number" ? (o(i != null, "Container is missing for key"), o(Array.isArray(i), "Cannot use numerical key for object container"), o(i.length >= c, "Cannot insert into out of bounds index"), i.splice(c, 0, O)) : (o(E(i), "Cannot insert into missing item"), o(i[c] === void 0, "Trying to overwrite value at key. Your op needs to remove it first"), i[c] = O), O;
747
747
  }
748
- 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) => {
749
- D.write("r", d), D.write("i", m);
750
- }).get(), a.editOp = (i, d, m, D = !1) => r.writeCursor().at(i, (O) => y(O, d, m, D)).get();
751
- const S = (i, d) => i != null && (typeof d == "number" ? Array.isArray(i) : typeof i == "object"), Y = (i, d) => S(i, d) ? i[d] : void 0, pe = {};
748
+ a.removeOp = (i, c = !0) => r.writeCursor().writeAtPath(i, "r", c).get(), a.moveOp = (i, c) => r.writeCursor().writeMove(i, c).get(), a.insertOp = (i, c) => r.writeCursor().writeAtPath(i, "i", c).get(), a.replaceOp = (i, c, O) => r.writeCursor().at(i, (D) => {
749
+ D.write("r", c), D.write("i", O);
750
+ }).get(), a.editOp = (i, c, O, D = !1) => r.writeCursor().at(i, (w) => y(w, c, O, D)).get();
751
+ const k = (i, c) => i != null && (typeof c == "number" ? Array.isArray(i) : typeof i == "object"), Y = (i, c) => k(i, c) ? i[c] : void 0, pe = {};
752
752
  function Z(i) {
753
- let d = i.type ? i.type : i;
754
- d.name && (pe[d.name] = d), d.uri && (pe[d.uri] = d);
753
+ let c = i.type ? i.type : i;
754
+ c.name && (pe[c.name] = c), c.uri && (pe[c.uri] = c);
755
755
  }
756
756
  const Ce = (i) => {
757
- const d = pe[i];
758
- if (d) return d;
757
+ const c = pe[i];
758
+ if (c) return c;
759
759
  throw Error("Missing type: " + i);
760
760
  };
761
- Z(Qt());
762
- const Ge = (i, d) => i + d;
761
+ Z(nn());
762
+ const Ge = (i, c) => i + c;
763
763
  Z({
764
764
  name: "number",
765
765
  apply: Ge,
@@ -767,453 +767,453 @@ function en() {
767
767
  invert: (i) => -i,
768
768
  transform: (i) => i
769
769
  });
770
- 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) => {
771
- const [O, I] = typeof d == "string" ? [Ce(d), d] : [d, d.name];
772
- !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)));
770
+ const me = (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, c, O, D = !1) => {
771
+ const [w, I] = typeof c == "string" ? [Ce(c), c] : [c, c.name];
772
+ !D && w.isNoop && w.isNoop(O) || (I === "number" ? i.write("ena", O) : I === "text-unicode" ? i.write("es", O) : (i.write("et", I), i.write("e", O)));
773
773
  };
774
- function b(i) {
774
+ function v(i) {
775
775
  o(typeof i == "number"), o(i >= 0), o(i === (0 | i));
776
776
  }
777
777
  function L(i) {
778
- typeof i == "number" ? b(i) : o(typeof i == "string");
778
+ typeof i == "number" ? v(i) : o(typeof i == "string");
779
779
  }
780
780
  function z(i) {
781
781
  if (i === null) return;
782
- const d = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), D = (I) => {
782
+ const c = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set(), D = (I) => {
783
783
  let R = !0, $ = !1;
784
784
  for (let p in I) {
785
- const v = I[p];
786
- if (R = !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);
787
- else if (p === "d") b(v), o(!m.has(v)), m.add(v), o(I.i === void 0);
785
+ const m = I[p];
786
+ if (R = !1, o(p === "p" || p === "r" || p === "d" || p === "i" || p === "e" || p === "es" || p === "ena" || p === "et", "Invalid component item '" + p + "'"), p === "p") v(m), o(!c.has(m)), c.add(m), o(I.r === void 0);
787
+ else if (p === "d") v(m), o(!O.has(m)), O.add(m), o(I.i === void 0);
788
788
  else if (p === "e" || p === "es" || p === "ena") {
789
789
  o(!$), $ = !0;
790
- const w = ve(I);
791
- o(w, "Missing type in edit"), w.checkValidOp && w.checkValidOp(f(I));
790
+ const b = me(I);
791
+ o(b, "Missing type in edit"), b.checkValidOp && b.checkValidOp(f(I));
792
792
  }
793
793
  }
794
794
  o(!R);
795
- }, O = (I, R, $) => {
795
+ }, w = (I, R, $) => {
796
796
  if (!Array.isArray(I)) throw Error("Op must be null or a list");
797
797
  if (I.length === 0) throw Error("Empty descent");
798
798
  R || L(I[0]);
799
- let p = 1, v = 0, w = 0;
799
+ let p = 1, m = 0, b = 0;
800
800
  for (let C = 0; C < I.length; C++) {
801
801
  const N = I[C];
802
802
  if (o(N != null), Array.isArray(N)) {
803
- const B = O(N, !1);
804
- if (v) {
805
- const g = typeof w, U = typeof B;
806
- g === U ? o(w < B, "descent keys are not in order") : o(g === "number" && U === "string");
803
+ const B = w(N, !1);
804
+ if (m) {
805
+ const g = typeof b, S = typeof B;
806
+ g === S ? o(b < B, "descent keys are not in order") : o(g === "number" && S === "string");
807
807
  }
808
- w = B, v++, p = 3;
808
+ b = B, m++, p = 3;
809
809
  } else typeof N == "object" ? (o(p === 1, `Prev not scalar - instead ${p}`), D(N), p = 2) : (o(p !== 3), L(N), o(r.isValidPathItem(N), "Invalid path key"), p = 1);
810
810
  }
811
- return o(v !== 1, "Operation makes multiple descents. Remove some []"), o(p === 2 || p === 3), I[0];
811
+ return o(m !== 1, "Operation makes multiple descents. Remove some []"), o(p === 2 || p === 3), I[0];
812
812
  };
813
- O(i, !0), o(d.size === m.size, "Mismatched picks and drops in op");
814
- for (let I = 0; I < d.size; I++) o(d.has(I)), o(m.has(I));
813
+ w(i, !0), o(c.size === O.size, "Mismatched picks and drops in op");
814
+ for (let I = 0; I < c.size; I++) o(c.has(I)), o(O.has(I));
815
815
  }
816
816
  function q(i) {
817
- let d = 0, m = [];
817
+ let c = 0, O = [];
818
818
  const D = r.writeCursor();
819
- return D.mergeTree(i, (O, I) => {
820
- const R = ve(O);
819
+ return D.mergeTree(i, (w, I) => {
820
+ const R = me(w);
821
821
  if (R) {
822
- const p = f(O);
822
+ const p = f(w);
823
823
  y(I, R, R.normalize ? R.normalize(p) : p);
824
824
  }
825
- for (const p of ["r", "p", "i", "d"]) if (O[p] !== void 0) {
826
- const v = p === "p" || p === "d" ? ($ = O[p], m[$] == null && (m[$] = d++), m[$]) : O[p];
827
- I.write(p, v);
825
+ for (const p of ["r", "p", "i", "d"]) if (w[p] !== void 0) {
826
+ const m = p === "p" || p === "d" ? ($ = w[p], O[$] == null && (O[$] = c++), O[$]) : w[p];
827
+ I.write(p, m);
828
828
  }
829
829
  var $;
830
830
  }), D.get();
831
831
  }
832
- function Ee(i, d) {
833
- if (z(d), d === null) return i;
834
- const m = [];
835
- return function D(O, I) {
836
- let R = O, $ = 0, p = {
837
- root: O
838
- }, v = 0, w = p, C = "root";
832
+ function Ee(i, c) {
833
+ if (z(c), c === null) return i;
834
+ const O = [];
835
+ return function D(w, I) {
836
+ let R = w, $ = 0, p = {
837
+ root: w
838
+ }, m = 0, b = p, C = "root";
839
839
  function N() {
840
- for (; v < $; v++) {
841
- let B = I[v];
842
- typeof B != "object" && (o(S(w, C)), w = w[C] = x(w[C]), C = B);
840
+ for (; m < $; m++) {
841
+ let B = I[m];
842
+ typeof B != "object" && (o(k(b, C)), b = b[C] = x(b[C]), C = B);
843
843
  }
844
844
  }
845
845
  for (; $ < I.length; $++) {
846
846
  const B = I[$];
847
847
  if (Array.isArray(B)) {
848
848
  const g = D(R, B);
849
- g !== R && g !== void 0 && (N(), R = w[C] = g);
849
+ g !== R && g !== void 0 && (N(), R = b[C] = g);
850
850
  } else if (typeof B == "object") {
851
- B.d != null ? (N(), R = h(w, C, m[B.d])) : B.i !== void 0 && (N(), R = h(w, C, B.i));
852
- const g = ve(B);
853
- if (g) N(), R = w[C] = g.apply(R, f(B));
851
+ B.d != null ? (N(), R = h(b, C, O[B.d])) : B.i !== void 0 && (N(), R = h(b, C, B.i));
852
+ const g = me(B);
853
+ if (g) N(), R = b[C] = g.apply(R, f(B));
854
854
  else if (B.e !== void 0) throw Error("Subtype " + B.et + " undefined");
855
855
  } else R = Y(R, B);
856
856
  }
857
857
  return p.root;
858
- }(i = function D(O, I) {
858
+ }(i = function D(w, I) {
859
859
  const R = [];
860
860
  let $ = 0;
861
861
  for (; $ < I.length; $++) {
862
862
  const C = I[$];
863
863
  if (Array.isArray(C)) break;
864
- typeof C != "object" && (R.push(O), O = Y(O, C));
864
+ typeof C != "object" && (R.push(w), w = Y(w, C));
865
865
  }
866
- for (let C = I.length - 1; C >= $; C--) O = D(O, I[C]);
866
+ for (let C = I.length - 1; C >= $; C--) w = D(w, I[C]);
867
867
  for (--$; $ >= 0; $--) {
868
868
  const C = I[$];
869
869
  if (typeof C != "object") {
870
870
  const N = R.pop();
871
- O = O === Y(N, C) ? N : O === void 0 ? c(N, C) : (v = C, w = O, (p = x(p = N))[v] = w, p);
872
- } else _(C) && (o(O !== void 0, "Cannot pick up or remove undefined"), C.p != null && (m[C.p] = O), O = void 0);
871
+ w = w === Y(N, C) ? N : w === void 0 ? d(N, C) : (m = C, b = w, (p = x(p = N))[m] = b, p);
872
+ } else _(C) && (o(w !== void 0, "Cannot pick up or remove undefined"), C.p != null && (O[C.p] = w), w = void 0);
873
873
  }
874
- var p, v, w;
875
- return O;
876
- }(i, d), d);
874
+ var p, m, b;
875
+ return w;
876
+ }(i, c), c);
877
877
  }
878
- function ce(i, d) {
879
- i = i.slice(), z(d);
880
- const m = r.readCursor(d);
881
- let D, O, I = !1;
878
+ function de(i, c) {
879
+ i = i.slice(), z(c);
880
+ const O = r.readCursor(c);
881
+ let D, w, I = !1;
882
882
  const R = [];
883
883
  for (let p = 0; ; p++) {
884
- const v = i[p], w = m.getComponent();
885
- if (w && (w.r !== void 0 ? I = !0 : w.p != null && (I = !1, D = w.p, O = p)), p >= i.length) break;
884
+ const m = i[p], b = O.getComponent();
885
+ if (b && (b.r !== void 0 ? I = !0 : b.p != null && (I = !1, D = b.p, w = p)), p >= i.length) break;
886
886
  let C = 0;
887
- const N = r.advancer(m, void 0, (g, U) => {
888
- _(U) && C++;
887
+ const N = r.advancer(O, void 0, (g, S) => {
888
+ _(S) && C++;
889
889
  });
890
890
  R.unshift(N);
891
- const B = N(v);
892
- if (typeof v == "number" && (i[p] -= C), !B) break;
891
+ const B = N(m);
892
+ if (typeof m == "number" && (i[p] -= C), !B) break;
893
893
  }
894
894
  if (R.forEach((p) => p.end()), I) return null;
895
895
  const $ = () => {
896
896
  let p = 0;
897
897
  if (D != null) {
898
- const v = m.getPath();
899
- p = v.length, i = v.concat(i.slice(O));
898
+ const m = O.getPath();
899
+ p = m.length, i = m.concat(i.slice(w));
900
900
  }
901
901
  for (; p < i.length; p++) {
902
- const v = i[p], w = l(m), C = ve(w);
902
+ const m = i[p], b = l(O), C = me(b);
903
903
  if (C) {
904
- const g = f(w);
904
+ const g = f(b);
905
905
  C.transformPosition && (i[p] = C.transformPosition(i[p], g));
906
906
  break;
907
907
  }
908
908
  let N = 0;
909
- const B = r.advancer(m, (g, U) => s(U) ? ~(g - N) : g - N, (g, U) => {
910
- s(U) && N++;
911
- })(v);
912
- if (typeof v == "number" && (i[p] += N), !B) break;
909
+ const B = r.advancer(O, (g, S) => s(S) ? ~(g - N) : g - N, (g, S) => {
910
+ s(S) && N++;
911
+ })(m);
912
+ if (typeof m == "number" && (i[p] += N), !B) break;
913
913
  }
914
914
  };
915
- return D != null ? m.eachDrop(null, (p) => {
915
+ return D != null ? O.eachDrop(null, (p) => {
916
916
  p === D && $();
917
917
  }) : $(), i;
918
918
  }
919
- function ne(i, d) {
920
- if (z(i), z(d), i == null) return d;
921
- if (d == null) return i;
922
- let m = 0;
923
- const D = r.readCursor(i), O = r.readCursor(d), I = r.writeCursor(), R = [], $ = [], p = [], v = [], w = [], C = [], N = /* @__PURE__ */ new Set();
919
+ function ne(i, c) {
920
+ if (z(i), z(c), i == null) return c;
921
+ if (c == null) return i;
922
+ let O = 0;
923
+ const D = r.readCursor(i), w = r.readCursor(c), I = r.writeCursor(), R = [], $ = [], p = [], m = [], b = [], C = [], N = /* @__PURE__ */ new Set();
924
924
  D.traverse(null, (g) => {
925
925
  g.p != null && (p[g.p] = D.clone());
926
- }), O.traverse(null, (g) => {
927
- g.d != null && (v[g.d] = O.clone());
926
+ }), w.traverse(null, (g) => {
927
+ g.d != null && (m[g.d] = w.clone());
928
928
  });
929
929
  const B = r.writeCursor();
930
- return function g(U, re, te, K, se, $e, Oe, ye) {
930
+ return function g(S, re, te, K, se, $e, we, ye) {
931
931
  o(re || te);
932
932
  const oe = l(re), Pe = l(te), Ae = !!Pe && Pe.r !== void 0, Le = !!oe && oe.i !== void 0, Te = oe ? oe.d : null, Ie = Pe ? Pe.p : null, Ne = ($e || Ae) && Ie == null;
933
- if (Ie != null) K = v[Ie], Oe = $[Ie] = new r.WriteCursor();
933
+ if (Ie != null) K = m[Ie], we = $[Ie] = new r.WriteCursor();
934
934
  else if (Pe && Pe.r !== void 0) K = null;
935
935
  else {
936
936
  const T = l(K);
937
937
  T && T.d != null && (K = null);
938
938
  }
939
939
  const Q = l(K);
940
- if (Te != null) if (U = p[Te], ye = R[Te] = new r.WriteCursor(), Ne) $e && !Ae && ye.write("r", !0);
940
+ if (Te != null) if (S = p[Te], ye = R[Te] = new r.WriteCursor(), Ne) $e && !Ae && ye.write("r", !0);
941
941
  else {
942
- const T = w[Te] = m++;
943
- Oe.write("d", T);
942
+ const T = b[Te] = O++;
943
+ we.write("d", T);
944
944
  }
945
- else if (oe && oe.i !== void 0) U = null;
945
+ else if (oe && oe.i !== void 0) S = null;
946
946
  else {
947
- const T = l(U);
948
- T && T.p != null && (U = null);
947
+ const T = l(S);
948
+ T && T.p != null && (S = null);
949
949
  }
950
950
  let A;
951
951
  Le ? (o(se === void 0), A = oe.i) : A = se;
952
- const W = (Ie == null ? !Le || $e || Ae : A === void 0) ? null : Oe.getComponent();
952
+ const W = (Ie == null ? !Le || $e || Ae : A === void 0) ? null : we.getComponent();
953
953
  if (Ie != null) {
954
954
  if (!(se !== void 0 || Le)) {
955
- const T = Te != null ? w[Te] : m++;
955
+ const T = Te != null ? b[Te] : O++;
956
956
  C[Ie] = T, ye.write("p", T);
957
957
  }
958
958
  } else Ae && (Le || se !== void 0 || (Pe.r, ye.write("r", Pe.r)));
959
- const M = Ne ? null : ve(oe), P = ve(Q);
959
+ const M = Ne ? null : me(oe), P = me(Q);
960
960
  if ((M || P) && (M && M.name, P && P.name), M && P) {
961
961
  o(M === P);
962
962
  const T = f(oe), G = f(Q), he = M.compose(T, G);
963
- y(Oe, M, he), N.add(Q);
964
- } else M ? y(Oe, M, f(oe)) : P && (y(Oe, P, f(Q)), N.add(Q));
965
- const k = typeof A == "object" && A != null;
966
- let J = !1, X = 0, ee = 0, fe = 0, de = 0, ae = 0;
967
- const me = r.advancer(K, (T, G) => s(G) ? de - T - 1 : T - de, (T, G) => {
968
- s(G) && de++;
969
- }), H = r.advancer(U, (T, G) => _(G) ? X - T - 1 : T - X, (T, G) => {
963
+ y(we, M, he), N.add(Q);
964
+ } else M ? y(we, M, f(oe)) : P && (y(we, P, f(Q)), N.add(Q));
965
+ const U = typeof A == "object" && A != null;
966
+ let J = !1, X = 0, ee = 0, fe = 0, ce = 0, ae = 0;
967
+ const Oe = r.advancer(K, (T, G) => s(G) ? ce - T - 1 : T - ce, (T, G) => {
968
+ s(G) && ce++;
969
+ }), H = r.advancer(S, (T, G) => _(G) ? X - T - 1 : T - X, (T, G) => {
970
970
  _(G) && X++;
971
971
  });
972
972
  if (r.eachChildOf(re, te, (T, G, he) => {
973
- let we, Re, qe = T, Me = T, Je = T;
973
+ let be, Re, qe = T, Me = T, Je = T;
974
974
  if (typeof T == "number") {
975
975
  let _e = T + fe;
976
- Re = me(_e), Me = _e + de;
976
+ Re = Oe(_e), Me = _e + ce;
977
977
  let ue = T + ee;
978
- we = H(ue), s(l(Re)) && (we = null), qe = ue + X, Je = T + ae, o(qe >= 0, "p1PickKey is negative"), o(Me >= 0, "p2DropKey is negative");
979
- const Ue = s(l(G)), xe = _(l(he));
980
- (Ue || xe && !Ne) && ae--, Ue && ee--, xe && fe--;
981
- } else we = H(T), Re = me(T);
982
- ye.descend(qe), Oe.descend(Me);
983
- const ze = k && !s(l(G)) ? A[Je] : void 0, Se = g(we, G, he, Re, ze, Ne, Oe, ye);
978
+ be = H(ue), s(l(Re)) && (be = null), qe = ue + X, Je = T + ae, o(qe >= 0, "p1PickKey is negative"), o(Me >= 0, "p2DropKey is negative");
979
+ const Se = s(l(G)), xe = _(l(he));
980
+ (Se || xe && !Ne) && ae--, Se && ee--, xe && fe--;
981
+ } else be = H(T), Re = Oe(T);
982
+ ye.descend(qe), we.descend(Me);
983
+ const ze = U && !s(l(G)) ? A[Je] : void 0, ke = g(be, G, he, Re, ze, Ne, we, ye);
984
984
  var je, j, ie;
985
- k && !Ne ? ze !== Se && (J || (A = Array.isArray(A) ? A.slice() : Object.assign({}, A), J = !0), je = A, ie = Se, typeof (j = Je) == "number" ? (o(Array.isArray(je)), o(j < je.length)) : (o(!Array.isArray(je)), o(je[j] !== void 0)), ie === void 0 ? typeof j == "number" ? je.splice(j, 1) : delete je[j] : je[j] = ie) : o(Se === void 0), Oe.ascend(), ye.ascend();
986
- }), H.end(), me.end(), W != null) W.i = A;
985
+ U && !Ne ? ze !== ke && (J || (A = Array.isArray(A) ? A.slice() : Object.assign({}, A), J = !0), je = A, ie = ke, typeof (j = Je) == "number" ? (o(Array.isArray(je)), o(j < je.length)) : (o(!Array.isArray(je)), o(je[j] !== void 0)), ie === void 0 ? typeof j == "number" ? je.splice(j, 1) : delete je[j] : je[j] = ie) : o(ke === void 0), we.ascend(), ye.ascend();
986
+ }), H.end(), Oe.end(), W != null) W.i = A;
987
987
  else if (!$e && !Ae && Ie == null) return A;
988
- }(D, D.clone(), O, O.clone(), void 0, !1, I, B), I.reset(), I.mergeTree(B.get()), I.reset(), I.get(), R.map((g) => g.get()), $.map((g) => g.get()), D.traverse(I, (g, U) => {
988
+ }(D, D.clone(), w, w.clone(), void 0, !1, I, B), I.reset(), I.mergeTree(B.get()), I.reset(), I.get(), R.map((g) => g.get()), $.map((g) => g.get()), D.traverse(I, (g, S) => {
989
989
  const re = g.p;
990
990
  if (re != null) {
991
- const te = w[re];
992
- te != null && U.write("p", te);
991
+ const te = b[re];
992
+ te != null && S.write("p", te);
993
993
  const K = R[re];
994
- K && K.get(), K && U.mergeTree(K.get());
995
- } else g.r !== void 0 && U.write("r", g.r);
996
- }), I.reset(), I.get(), O.traverse(I, (g, U) => {
994
+ K && K.get(), K && S.mergeTree(K.get());
995
+ } else g.r !== void 0 && S.write("r", g.r);
996
+ }), I.reset(), I.get(), w.traverse(I, (g, S) => {
997
997
  const re = g.d;
998
998
  if (re != null) {
999
999
  const K = C[re];
1000
- K != null && U.write("d", K);
1000
+ K != null && S.write("d", K);
1001
1001
  const se = $[re];
1002
- se && U.mergeTree(se.get());
1003
- } else g.i !== void 0 && U.write("i", g.i);
1004
- const te = ve(g);
1005
- te && !N.has(g) && y(U, te, f(g));
1002
+ se && S.mergeTree(se.get());
1003
+ } else g.i !== void 0 && S.write("i", g.i);
1004
+ const te = me(g);
1005
+ te && !N.has(g) && y(S, te, f(g));
1006
1006
  }), I.get();
1007
1007
  }
1008
1008
  function le(i) {
1009
1009
  if (i == null) return null;
1010
- const d = new r.ReadCursor(i), m = new r.WriteCursor();
1010
+ const c = new r.ReadCursor(i), O = new r.WriteCursor();
1011
1011
  let D;
1012
- const O = [], I = [];
1013
- return function R($, p, v) {
1014
- const w = $.getComponent();
1012
+ const w = [], I = [];
1013
+ return function R($, p, m) {
1014
+ const b = $.getComponent();
1015
1015
  let C, N = !1;
1016
- if (w) {
1017
- w.p != null && (p.write("d", w.p), O[w.p] = $.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);
1018
- const g = ve(w);
1019
- g && (v === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(w)) : (f(w), v = g.apply(v, f(w)), N = !0));
1016
+ if (b) {
1017
+ b.p != null && (p.write("d", b.p), w[b.p] = $.clone()), b.r !== void 0 && p.write("i", b.r), b.d != null && (p.write("p", b.d), m = void 0), b.i !== void 0 && (m = C = b.i);
1018
+ const g = me(b);
1019
+ g && (m === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(b)) : (f(b), m = g.apply(m, f(b)), N = !0));
1020
1020
  }
1021
1021
  let B = 0;
1022
1022
  for (const g of $) {
1023
1023
  p.descend(g);
1024
- const U = typeof g == "number" ? g - B : g, re = Y(v, U);
1024
+ const S = typeof g == "number" ? g - B : g, re = Y(m, S);
1025
1025
  s($.getComponent()) && B++;
1026
1026
  const te = R($, p, re);
1027
- if (v !== void 0 && te !== void 0) {
1028
- if (N || (N = !0, v = x(v)), !S(v, U)) throw Error("Cannot modify child - invalid operation");
1029
- v[U] = te;
1027
+ if (m !== void 0 && te !== void 0) {
1028
+ if (N || (N = !0, m = x(m)), !k(m, S)) throw Error("Cannot modify child - invalid operation");
1029
+ m[S] = te;
1030
1030
  }
1031
1031
  p.ascend();
1032
1032
  }
1033
- if (C === void 0) return N ? v : void 0;
1034
- p.write("r", v);
1035
- }(d, m, void 0), D && (m.reset(), function R($, p, v) {
1036
- const w = p.getComponent();
1037
- if (w) {
1038
- const g = w.d;
1039
- if (g != null && ($ = O[g], v = I[g] = r.writeCursor()), D.has(w)) {
1040
- const U = ve(w);
1041
- if (!U.invert) throw Error(`Cannot invert subtype ${U.name}`);
1042
- y(v, U, U.invert(f(w)));
1033
+ if (C === void 0) return N ? m : void 0;
1034
+ p.write("r", m);
1035
+ }(c, O, void 0), D && (O.reset(), function R($, p, m) {
1036
+ const b = p.getComponent();
1037
+ if (b) {
1038
+ const g = b.d;
1039
+ if (g != null && ($ = w[g], m = I[g] = r.writeCursor()), D.has(b)) {
1040
+ const S = me(b);
1041
+ if (!S.invert) throw Error(`Cannot invert subtype ${S.name}`);
1042
+ y(m, S, S.invert(f(b)));
1043
1043
  }
1044
1044
  }
1045
1045
  let C = 0, N = 0;
1046
- const B = r.advancer($, (g, U) => _(U) ? C - g - 1 : g - C, (g, U) => {
1047
- _(U) && C++;
1046
+ const B = r.advancer($, (g, S) => _(S) ? C - g - 1 : g - C, (g, S) => {
1047
+ _(S) && C++;
1048
1048
  });
1049
1049
  for (const g of p) if (typeof g == "number") {
1050
- const U = g - N, re = B(U), te = U + C;
1051
- v.descend(te), R(re, p, v), s(p.getComponent()) && N++, v.ascend();
1052
- } else v.descend(g), R(B(g), p, v), v.ascend();
1050
+ const S = g - N, re = B(S), te = S + C;
1051
+ m.descend(te), R(re, p, m), s(p.getComponent()) && N++, m.ascend();
1052
+ } else m.descend(g), R(B(g), p, m), m.ascend();
1053
1053
  B.end();
1054
- }(d.clone(), d, m), I.length && (m.reset(), d.traverse(m, (R, $) => {
1054
+ }(c.clone(), c, O), I.length && (O.reset(), c.traverse(O, (R, $) => {
1055
1055
  const p = R.p;
1056
1056
  if (p != null) {
1057
- const v = I[p];
1058
- v && v.get(), v && $.mergeTree(v.get());
1057
+ const m = I[p];
1058
+ m && m.get(), m && $.mergeTree(m.get());
1059
1059
  }
1060
- }))), m.get();
1060
+ }))), O.get();
1061
1061
  }
1062
- const ge = (i, d) => i.some((m) => typeof m == "object" && (Array.isArray(m) ? ge(m, d) : d(m)));
1063
- function De(i, d) {
1062
+ const ge = (i, c) => i.some((O) => typeof O == "object" && (Array.isArray(O) ? ge(O, c) : c(O)));
1063
+ function De(i, c) {
1064
1064
  if (i == null || !ge(i, (p) => {
1065
- var v;
1066
- return p.r !== void 0 || ((v = ve(p)) === null || v === void 0 ? void 0 : v.makeInvertible) != null;
1065
+ var m;
1066
+ return p.r !== void 0 || ((m = me(p)) === null || m === void 0 ? void 0 : m.makeInvertible) != null;
1067
1067
  })) return i;
1068
- const m = new r.ReadCursor(i), D = new r.WriteCursor();
1069
- let O = !1;
1070
- const I = [], R = [], $ = (p, v, w) => {
1068
+ const O = new r.ReadCursor(i), D = new r.WriteCursor();
1069
+ let w = !1;
1070
+ const I = [], R = [], $ = (p, m, b) => {
1071
1071
  const C = p.getComponent();
1072
1072
  let N = !1;
1073
1073
  if (C) {
1074
- C.d != null && v.write("d", C.d), C.i !== void 0 && v.write("i", C.i);
1074
+ C.d != null && m.write("d", C.d), C.i !== void 0 && m.write("i", C.i);
1075
1075
  const g = C.p;
1076
- if (g != null && (I[g] = p.clone(), o(w !== void 0, "Operation picks up at an invalid key"), R[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");
1077
- const U = ve(C);
1078
- U && (U.makeInvertible ? O = !0 : y(v, U, f(C), !0));
1076
+ if (g != null && (I[g] = p.clone(), o(b !== void 0, "Operation picks up at an invalid key"), R[g] = b, m.write("p", C.p)), C.r !== void 0 && b === void 0) throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");
1077
+ const S = me(C);
1078
+ S && (S.makeInvertible ? w = !0 : y(m, S, f(C), !0));
1079
1079
  }
1080
1080
  let B = 0;
1081
1081
  for (const g of p) {
1082
- v.descend(g);
1083
- const U = typeof g == "number" ? g - B : g, re = Y(w, U), te = $(p, v, re);
1084
- re !== te && (N || (N = !0, w = x(w)), te === void 0 ? (w = c(w, U), typeof g == "number" && B++) : w[U] = te), v.ascend();
1082
+ m.descend(g);
1083
+ const S = typeof g == "number" ? g - B : g, re = Y(b, S), te = $(p, m, re);
1084
+ re !== te && (N || (N = !0, b = x(b)), te === void 0 ? (b = d(b, S), typeof g == "number" && B++) : b[S] = te), m.ascend();
1085
1085
  }
1086
- return C && (C.r !== void 0 ? (v.write("r", t.default(w)), w = void 0) : C.p != null && (w = void 0)), w;
1086
+ return C && (C.r !== void 0 ? (m.write("r", t.default(b)), b = void 0) : C.p != null && (b = void 0)), b;
1087
1087
  };
1088
- return $(m, D, d), D.get(), O && (D.reset(), function p(v, w, C, N, B) {
1089
- const g = w.getComponent();
1088
+ return $(O, D, c), D.get(), w && (D.reset(), function p(m, b, C, N, B) {
1089
+ const g = b.getComponent();
1090
1090
  if (g) {
1091
- g.i !== void 0 ? (N = g.i, B = !0) : g.d != null && (N = R[g.d], v = I[g.d], B = !1, g.d);
1092
- let K = ve(g);
1091
+ g.i !== void 0 ? (N = g.i, B = !0) : g.d != null && (N = R[g.d], m = I[g.d], B = !1, g.d);
1092
+ let K = me(g);
1093
1093
  if (K && K.makeInvertible) {
1094
1094
  const se = f(g);
1095
1095
  y(C, K, K.makeInvertible(se, N), !0);
1096
1096
  }
1097
1097
  }
1098
- let U = 0, re = 0;
1099
- const te = r.advancer(v, (K, se) => _(se) ? U - K - 1 : K - U, (K, se) => {
1100
- _(se) && U++;
1098
+ let S = 0, re = 0;
1099
+ const te = r.advancer(m, (K, se) => _(se) ? S - K - 1 : K - S, (K, se) => {
1100
+ _(se) && S++;
1101
1101
  });
1102
- for (const K of w) if (typeof K == "number") {
1103
- const se = K - re, $e = te(se), Oe = se + U, ye = Y(N, B ? se : Oe);
1104
- C.descend(K), p($e, w, C, ye, B), s(w.getComponent()) && re++, C.ascend();
1102
+ for (const K of b) if (typeof K == "number") {
1103
+ const se = K - re, $e = te(se), we = se + S, ye = Y(N, B ? se : we);
1104
+ C.descend(K), p($e, b, C, ye, B), s(b.getComponent()) && re++, C.ascend();
1105
1105
  } else {
1106
1106
  const se = Y(N, K);
1107
- C.descend(K), p(te(K), w, C, se, B), C.ascend();
1107
+ C.descend(K), p(te(K), b, C, se, B), C.ascend();
1108
1108
  }
1109
1109
  te.end();
1110
- }(m.clone(), m, D, d, !1)), D.get();
1110
+ }(O.clone(), O, D, c, !1)), D.get();
1111
1111
  }
1112
- function kt(i, d) {
1113
- return le(De(i, d));
1112
+ function kt(i, c) {
1113
+ return le(De(i, c));
1114
1114
  }
1115
1115
  const it = (i) => {
1116
1116
  if (i == null) return null;
1117
- const d = i.slice();
1118
- for (let m = 0; m < i.length; m++) {
1119
- const D = d[m];
1120
- Array.isArray(D) && (d[m] = it(D));
1117
+ const c = i.slice();
1118
+ for (let O = 0; O < i.length; O++) {
1119
+ const D = c[O];
1120
+ Array.isArray(D) && (c[O] = it(D));
1121
1121
  }
1122
- return d;
1122
+ return c;
1123
1123
  };
1124
- function st(i, d, m) {
1125
- o(m === "left" || m === "right", "Direction must be left or right");
1126
- const D = m === "left" ? 0 : 1;
1127
- if (d == null) return {
1124
+ function st(i, c, O) {
1125
+ o(O === "left" || O === "right", "Direction must be left or right");
1126
+ const D = O === "left" ? 0 : 1;
1127
+ if (c == null) return {
1128
1128
  ok: !0,
1129
1129
  result: i
1130
1130
  };
1131
- z(i), z(d);
1132
- let O = null;
1133
- const I = [], R = [], $ = [], p = [], v = [], w = [], C = [], N = [], B = [], g = [], U = [], re = [], te = [], K = [], se = [];
1131
+ z(i), z(c);
1132
+ let w = null;
1133
+ const I = [], R = [], $ = [], p = [], m = [], b = [], C = [], N = [], B = [], g = [], S = [], re = [], te = [], K = [], se = [];
1134
1134
  let $e = 0;
1135
- const Oe = r.readCursor(i), ye = r.readCursor(d), oe = r.writeCursor();
1135
+ const we = r.readCursor(i), ye = r.readCursor(c), oe = r.writeCursor();
1136
1136
  if (function Q(A, W = null, M) {
1137
1137
  const P = l(W);
1138
- P && (P.r !== void 0 ? M = W.clone() : P.p != null && (M = null, w[P.p] = A.clone()));
1139
- const k = A.getComponent();
1138
+ P && (P.r !== void 0 ? M = W.clone() : P.p != null && (M = null, b[P.p] = A.clone()));
1139
+ const U = A.getComponent();
1140
1140
  let J;
1141
- k && (J = k.p) != null && (v[J] = W ? W.clone() : null, $[J] = A.clone(), M && (g[J] = !0, B[J] = M), P && P.p != null && (K[J] = P.p));
1141
+ U && (J = U.p) != null && (m[J] = W ? W.clone() : null, $[J] = A.clone(), M && (g[J] = !0, B[J] = M), P && P.p != null && (K[J] = P.p));
1142
1142
  const X = r.advancer(W);
1143
1143
  for (const ee of A) Q(A, X(ee), M);
1144
1144
  X.end();
1145
- }(ye, Oe, null), function Q(A, W, M, P, k) {
1145
+ }(ye, we, null), function Q(A, W, M, P, U) {
1146
1146
  const J = M.getComponent();
1147
1147
  let X, ee = !1;
1148
- 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, W = $[X] || null, g[X] ? (k && (U[X] = !0), k = B[X] || null) : !k || D !== 1 && K[X] != null || O == null && (O = {
1148
+ J && ((X = J.d) != null ? (p[X] = M.clone(), P != null && (se[P] == null && (se[P] = []), se[P].push(X)), g[X], A = m[X] || null, W = $[X] || null, g[X] ? (U && (S[X] = !0), U = B[X] || null) : !U || D !== 1 && K[X] != null || w == null && (w = {
1149
1149
  type: u.ConflictType.RM_UNEXPECTED_CONTENT,
1150
- op1: a.removeOp(k.getPath()),
1150
+ op1: a.removeOp(U.getPath()),
1151
1151
  op2: a.moveOp(W.getPath(), M.getPath())
1152
- }), ee = !0) : J.i !== void 0 && (A = W = null, ee = !0, k && O == null && (O = {
1152
+ }), ee = !0) : J.i !== void 0 && (A = W = null, ee = !0, U && w == null && (w = {
1153
1153
  type: u.ConflictType.RM_UNEXPECTED_CONTENT,
1154
- op1: a.removeOp(k.getPath()),
1154
+ op1: a.removeOp(U.getPath()),
1155
1155
  op2: a.insertOp(M.getPath(), J.i)
1156
1156
  })));
1157
1157
  const fe = l(A);
1158
- fe && (fe.r !== void 0 ? k = A.clone() : fe.p != null && (fe.p, P = fe.p, k = null));
1159
- const de = ve(J);
1160
- de && k && O == null && (O = {
1158
+ fe && (fe.r !== void 0 ? U = A.clone() : fe.p != null && (fe.p, P = fe.p, U = null));
1159
+ const ce = me(J);
1160
+ ce && U && w == null && (w = {
1161
1161
  type: u.ConflictType.RM_UNEXPECTED_CONTENT,
1162
- op1: a.removeOp(k.getPath()),
1163
- op2: a.editOp(M.getPath(), de, f(J), !0)
1162
+ op1: a.removeOp(U.getPath()),
1163
+ op2: a.editOp(M.getPath(), ce, f(J), !0)
1164
1164
  });
1165
- let ae = 0, me = 0;
1165
+ let ae = 0, Oe = 0;
1166
1166
  const H = r.advancer(W, (G, he) => _(he) ? ae - G - 1 : G - ae, (G, he) => {
1167
1167
  _(he) && ae++;
1168
1168
  }), T = r.advancer(A);
1169
1169
  for (const G of M) if (typeof G == "number") {
1170
- const he = G - me, we = H(he);
1171
- me += +Q(T(he + ae), we, M, P, k);
1170
+ const he = G - Oe, be = H(he);
1171
+ Oe += +Q(T(he + ae), be, M, P, U);
1172
1172
  } else {
1173
1173
  const he = H(G);
1174
- Q(T(G), he, M, P, k);
1174
+ Q(T(G), he, M, P, U);
1175
1175
  }
1176
1176
  return H.end(), T.end(), ee;
1177
- }(Oe, ye, ye.clone(), null, null), p.map((Q) => Q && Q.get()), O) return {
1177
+ }(we, ye, ye.clone(), null, null), p.map((Q) => Q && Q.get()), w) return {
1178
1178
  ok: !1,
1179
- conflict: O
1179
+ conflict: w
1180
1180
  };
1181
- U.map((Q) => !!Q);
1181
+ S.map((Q) => !!Q);
1182
1182
  const Pe = [];
1183
1183
  let Ae = null;
1184
- (function Q(A, W, M, P, k) {
1184
+ (function Q(A, W, M, P, U) {
1185
1185
  let J = !1;
1186
1186
  const X = l(W);
1187
1187
  if (_(X)) {
1188
1188
  const H = X.p;
1189
- H != null ? (M = p[H], P = re[H] = r.writeCursor(), J = !0, k = null) : (M = null, k = W.clone());
1189
+ H != null ? (M = p[H], P = re[H] = r.writeCursor(), J = !0, U = null) : (M = null, U = W.clone());
1190
1190
  } else s(l(M)) && (M = null);
1191
1191
  const ee = A.getComponent();
1192
1192
  if (ee) {
1193
1193
  const H = ee.p;
1194
- H != null ? (k && (N[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)));
1194
+ H != null ? (U && (N[H] = U), Pe[H] = U || D === 1 && J ? null : P.getComponent(), I[H] = A.clone(), M && (C[H] = M.clone())) : ee.r !== void 0 && (U || P.write("r", !0), (U || J) && (Ae == null && (Ae = /* @__PURE__ */ new Set()), Ae.add(ee)));
1195
1195
  }
1196
- let fe = 0, de = 0;
1196
+ let fe = 0, ce = 0;
1197
1197
  const ae = r.advancer(W, void 0, (H, T) => {
1198
1198
  _(T) && fe++;
1199
- }), me = r.advancer(M, (H, T) => s(T) ? ~(H - de) : H - de, (H, T) => {
1200
- s(T) && de++;
1199
+ }), Oe = r.advancer(M, (H, T) => s(T) ? ~(H - ce) : H - ce, (H, T) => {
1200
+ s(T) && ce++;
1201
1201
  });
1202
1202
  if (A) for (const H of A) if (typeof H == "string") {
1203
- const T = ae(H), G = me(H);
1204
- P.descend(H), Q(A, T, G, P, k), P.ascend();
1203
+ const T = ae(H), G = Oe(H);
1204
+ P.descend(H), Q(A, T, G, P, U), P.ascend();
1205
1205
  } else {
1206
- const T = ae(H), G = H - fe, he = _(l(T)) ? null : me(G), we = G + de;
1207
- o(we >= 0), P.descend(we), Q(A, T, he, P, k), P.ascend();
1206
+ const T = ae(H), G = H - fe, he = _(l(T)) ? null : Oe(G), be = G + ce;
1207
+ o(be >= 0), P.descend(be), Q(A, T, he, P, U), P.ascend();
1208
1208
  }
1209
- ae.end(), me.end();
1210
- })(Oe, ye, ye.clone(), oe, null), oe.reset();
1209
+ ae.end(), Oe.end();
1210
+ })(we, ye, ye.clone(), oe, null), oe.reset();
1211
1211
  let Le = [];
1212
- if (function Q(A, W, M, P, k, J) {
1212
+ if (function Q(A, W, M, P, U, J) {
1213
1213
  o(W);
1214
1214
  const X = W.getComponent();
1215
1215
  let ee = l(P), fe = !1;
1216
- const de = (j, ie, _e) => j ? a.moveOp(j.getPath(), ie.getPath()) : a.insertOp(ie.getPath(), _e.i);
1216
+ const ce = (j, ie, _e) => j ? a.moveOp(j.getPath(), ie.getPath()) : a.insertOp(ie.getPath(), _e.i);
1217
1217
  if (s(X)) {
1218
1218
  const j = X.d;
1219
1219
  j != null && (R[j] = W.clone());
@@ -1221,51 +1221,51 @@ function en() {
1221
1221
  let _e = !1;
1222
1222
  if (X.i !== void 0 || j != null && ie) {
1223
1223
  let ue;
1224
- ee && (ee.i !== void 0 || (ue = ee.d) != null && !g[ue]) && (_e = ue != null ? j != null && j === K[ue] : n.default(ee.i, X.i), _e || ue != null && D !== 1 && K[ue] != null || O == null && (O = {
1224
+ ee && (ee.i !== void 0 || (ue = ee.d) != null && !g[ue]) && (_e = ue != null ? j != null && j === K[ue] : n.default(ee.i, X.i), _e || ue != null && D !== 1 && K[ue] != null || w == null && (w = {
1225
1225
  type: u.ConflictType.DROP_COLLISION,
1226
- op1: de(j != null ? I[j] : null, W, X),
1227
- op2: de(ue != null ? $[ue] : null, P, ee)
1228
- })), _e || (J ? O == null && (O = {
1226
+ op1: ce(j != null ? I[j] : null, W, X),
1227
+ op2: ce(ue != null ? $[ue] : null, P, ee)
1228
+ })), _e || (J ? w == null && (w = {
1229
1229
  type: u.ConflictType.RM_UNEXPECTED_CONTENT,
1230
- op1: de(j != null ? I[j] : null, W, X),
1230
+ op1: ce(j != null ? I[j] : null, W, X),
1231
1231
  op2: a.removeOp(J.getPath())
1232
- }) : (j != null ? (Le[$e] = j, k.write("d", ie.p = $e++)) : k.write("i", t.default(X.i)), fe = !0));
1232
+ }) : (j != null ? (Le[$e] = j, U.write("d", ie.p = $e++)) : U.write("i", t.default(X.i)), fe = !0));
1233
1233
  } else if (j != null && !ie) {
1234
1234
  const ue = N[j];
1235
1235
  ue && (J = ue.clone());
1236
1236
  }
1237
- j != null ? (A = I[j], M = w[j], P = C[j]) : X.i !== void 0 && (A = M = null, _e || (P = null));
1237
+ j != null ? (A = I[j], M = b[j], P = C[j]) : X.i !== void 0 && (A = M = null, _e || (P = null));
1238
1238
  } else _(l(A)) && (A = M = P = null);
1239
- const ae = l(A), me = l(M);
1240
- if (_(me)) {
1241
- const j = me.p;
1242
- me.r !== void 0 && (!ae || ae.r === void 0) || g[j] ? (P = null, J = M.clone()) : j != null && (P = p[j], D !== 1 && K[j] != null || ((k = te[j]) || (k = te[j] = r.writeCursor()), k.reset(), J = null));
1239
+ const ae = l(A), Oe = l(M);
1240
+ if (_(Oe)) {
1241
+ const j = Oe.p;
1242
+ Oe.r !== void 0 && (!ae || ae.r === void 0) || g[j] ? (P = null, J = M.clone()) : j != null && (P = p[j], D !== 1 && K[j] != null || ((U = te[j]) || (U = te[j] = r.writeCursor()), U.reset(), J = null));
1243
1243
  } else !s(X) && s(ee) && (P = null);
1244
1244
  ee = P != null ? P.getComponent() : null;
1245
- const H = ve(X);
1245
+ const H = me(X);
1246
1246
  if (H) {
1247
1247
  const j = f(X);
1248
- if (J) O == null && (O = {
1248
+ if (J) w == null && (w = {
1249
1249
  type: u.ConflictType.RM_UNEXPECTED_CONTENT,
1250
1250
  op1: a.editOp(W.getPath(), H, j, !0),
1251
1251
  op2: a.removeOp(J.getPath())
1252
1252
  });
1253
1253
  else {
1254
- const ie = ve(ee);
1254
+ const ie = me(ee);
1255
1255
  let _e;
1256
1256
  if (ie) {
1257
1257
  if (H !== ie) throw Error("Transforming incompatible types");
1258
1258
  const ue = f(ee);
1259
- _e = H.transform(j, ue, m);
1259
+ _e = H.transform(j, ue, O);
1260
1260
  } else _e = t.default(j);
1261
- y(k, H, _e);
1261
+ y(U, H, _e);
1262
1262
  }
1263
1263
  }
1264
- let T = 0, G = 0, he = 0, we = 0, Re = 0, qe = 0, Me = A != null && A.descendFirst(), Je = Me;
1264
+ let T = 0, G = 0, he = 0, be = 0, Re = 0, qe = 0, Me = A != null && A.descendFirst(), Je = Me;
1265
1265
  const ze = r.advancer(M, void 0, (j, ie) => {
1266
1266
  _(ie) && he++;
1267
1267
  });
1268
- let Se = P != null && P.descendFirst(), je = Se;
1268
+ let ke = P != null && P.descendFirst(), je = ke;
1269
1269
  for (const j of W) if (typeof j == "number") {
1270
1270
  let ie;
1271
1271
  const _e = s(W.getComponent()), ue = j - G;
@@ -1273,28 +1273,28 @@ function en() {
1273
1273
  let Be;
1274
1274
  for (; Me && typeof (Be = A.getKey()) == "number"; ) {
1275
1275
  Be += T;
1276
- const ke = A.getComponent(), Xe = _(ke);
1276
+ const Ue = A.getComponent(), Xe = _(Ue);
1277
1277
  if (Be > ue || Be === ue && (!Xe || D === 0 && _e)) break;
1278
1278
  if (Xe) {
1279
1279
  T--;
1280
- const Ke = ke.p;
1281
- K.includes(Ke), ke.d, l(te[ke.d]), _(l(te[ke.d])), (ke.r === void 0 || Ae && Ae.has(ke)) && (Ke == null || !Pe[Ke] || D !== 1 && K.includes(Ke)) || Re--;
1280
+ const Ke = Ue.p;
1281
+ K.includes(Ke), Ue.d, l(te[Ue.d]), _(l(te[Ue.d])), (Ue.r === void 0 || Ae && Ae.has(Ue)) && (Ke == null || !Pe[Ke] || D !== 1 && K.includes(Ke)) || Re--;
1282
1282
  }
1283
1283
  Me = A.nextSibling();
1284
1284
  }
1285
1285
  ie = Me && Be === ue ? A : null;
1286
1286
  }
1287
- const Ue = ue - T;
1288
- let xe = ze(Ue);
1289
- const ot = Ue - he;
1287
+ const Se = ue - T;
1288
+ let xe = ze(Se);
1289
+ const ot = Se - he;
1290
1290
  let Ze = null;
1291
1291
  {
1292
- let Be, ke;
1293
- for (; Se && typeof (Be = P.getKey()) == "number"; ) {
1294
- ke = Be - we;
1292
+ let Be, Ue;
1293
+ for (; ke && typeof (Be = P.getKey()) == "number"; ) {
1294
+ Ue = Be - be;
1295
1295
  const Xe = P.getComponent(), Ke = s(Xe);
1296
- if (ke > ot) break;
1297
- if (ke === ot) {
1296
+ if (Ue > ot) break;
1297
+ if (Ue === ot) {
1298
1298
  if (!Ke) {
1299
1299
  Ze = P;
1300
1300
  break;
@@ -1310,36 +1310,36 @@ function en() {
1310
1310
  }
1311
1311
  if (Ke) {
1312
1312
  const We = Xe.d;
1313
- g[We], K[We], Xe.i === void 0 && (g[We] || K[We] != null && D !== 1) ? (g[We] || K[We] != null && D === 0) && (we++, qe--) : we++;
1313
+ g[We], K[We], Xe.i === void 0 && (g[We] || K[We] != null && D !== 1) ? (g[We] || K[We] != null && D === 0) && (be++, qe--) : be++;
1314
1314
  }
1315
- Se = P.nextSibling();
1315
+ ke = P.nextSibling();
1316
1316
  }
1317
1317
  }
1318
- const yt = ot + we + Re + qe;
1319
- o(yt >= 0, "trying to descend to a negative index"), k.descend(yt), _e && (ie = xe = Ze = null, G++), Q(ie, W, xe, Ze, k, J) && qe++, k.ascend();
1318
+ const _t = ot + be + Re + qe;
1319
+ o(_t >= 0, "trying to descend to a negative index"), U.descend(_t), _e && (ie = xe = Ze = null, G++), Q(ie, W, xe, Ze, U, J) && qe++, U.ascend();
1320
1320
  } else {
1321
1321
  let ie;
1322
1322
  for (; Me && (ie = A.getKey(), typeof ie != "string" || !(ie > j || ie === j)); ) Me = A.nextSibling();
1323
1323
  const _e = Me && ie === j ? A : null, ue = ze(j);
1324
- let Ue;
1325
- for (; Se && (Ue = P.getKey(), typeof Ue != "string" || !(Ue > j || Ue === j)); ) Se = P.nextSibling();
1326
- const xe = Se && Ue === j ? P : null;
1327
- k.descend(j), Q(_e, W, ue, xe, k, J), k.ascend();
1324
+ let Se;
1325
+ for (; ke && (Se = P.getKey(), typeof Se != "string" || !(Se > j || Se === j)); ) ke = P.nextSibling();
1326
+ const xe = ke && Se === j ? P : null;
1327
+ U.descend(j), Q(_e, W, ue, xe, U, J), U.ascend();
1328
1328
  }
1329
1329
  return ze.end(), Je && A.ascend(), je && P.ascend(), fe;
1330
- }(Oe, Oe.clone(), ye, ye.clone(), oe, null), O) return {
1330
+ }(we, we.clone(), ye, ye.clone(), oe, null), w) return {
1331
1331
  ok: !1,
1332
- conflict: O
1332
+ conflict: w
1333
1333
  };
1334
1334
  oe.reset();
1335
1335
  const Te = (Q, A, W) => Q.traverse(A, (M, P) => {
1336
1336
  M.d != null && W(M.d, Q, P);
1337
1337
  });
1338
1338
  (g.length || re.length) && (Te(ye, oe, (Q, A, W) => {
1339
- g[Q] && !U[Q] && W.write("r", !0), re[Q] && W.mergeTree(re[Q].get());
1339
+ g[Q] && !S[Q] && W.write("r", !0), re[Q] && W.mergeTree(re[Q].get());
1340
1340
  }), oe.reset());
1341
1341
  const Ie = [], Ne = [];
1342
- if ((te.length || g.length) && !O) {
1342
+ if ((te.length || g.length) && !w) {
1343
1343
  const Q = r.readCursor(it(oe.get()));
1344
1344
  if (Te(Q, null, (A, W) => {
1345
1345
  Ie[A] = W.clone();
@@ -1347,11 +1347,11 @@ function en() {
1347
1347
  A && Te(r.readCursor(A.get()), null, (W, M) => {
1348
1348
  Ie[W] = M.clone();
1349
1349
  });
1350
- }), function A(W, M, P, k, J, X) {
1350
+ }), function A(W, M, P, U, J, X) {
1351
1351
  const ee = l(M);
1352
1352
  if (ee && _(ee)) if (ee.p != null) {
1353
1353
  const T = ee.p;
1354
- Ie[T].getPath(), P = Ie[T], k = Ne[T] = r.writeCursor();
1354
+ Ie[T].getPath(), P = Ie[T], U = Ne[T] = r.writeCursor();
1355
1355
  } else ee.r !== void 0 && (P = null);
1356
1356
  else s(l(P)) && (P = null);
1357
1357
  const fe = W.getComponent();
@@ -1359,42 +1359,42 @@ function en() {
1359
1359
  let T;
1360
1360
  if ((T = fe.d) != null) {
1361
1361
  const G = te[T];
1362
- G && (G.get(), k.mergeTree(G.get()), P = r.readCursor(G.get()));
1362
+ G && (G.get(), U.mergeTree(G.get()), P = r.readCursor(G.get()));
1363
1363
  }
1364
1364
  }
1365
- let de = 0, ae = 0;
1366
- const me = r.advancer(M, void 0, (T, G) => {
1367
- _(G) && de--;
1365
+ let ce = 0, ae = 0;
1366
+ const Oe = r.advancer(M, void 0, (T, G) => {
1367
+ _(G) && ce--;
1368
1368
  }), H = r.advancer(P, (T, G) => s(G) ? -(T - ae) - 1 : T - ae, (T, G) => {
1369
1369
  s(G) && ae++;
1370
1370
  });
1371
1371
  for (const T of W) if (typeof T == "number") {
1372
- const G = me(T), he = T + de, we = H(he), Re = he + ae;
1373
- k.descend(Re), A(W, G, we, k), k.ascend();
1374
- } else k.descend(T), A(W, me(T), H(T), k), k.ascend();
1375
- me.end(), H.end();
1376
- }(ye, Q, Q.clone(), oe), oe.reset(), O) return {
1372
+ const G = Oe(T), he = T + ce, be = H(he), Re = he + ae;
1373
+ U.descend(Re), A(W, G, be, U), U.ascend();
1374
+ } else U.descend(T), A(W, Oe(T), H(T), U), U.ascend();
1375
+ Oe.end(), H.end();
1376
+ }(ye, Q, Q.clone(), oe), oe.reset(), w) return {
1377
1377
  ok: !1,
1378
- conflict: O
1378
+ conflict: w
1379
1379
  };
1380
1380
  if (oe.get(), Ne.length) {
1381
1381
  const A = Ne.map((M) => M ? M.get() : null), W = r.readCursor(it(oe.get()));
1382
- if (Te(W, oe, (M, P, k) => {
1382
+ if (Te(W, oe, (M, P, U) => {
1383
1383
  const J = A[M];
1384
- J && (k.mergeTree(J), A[M] = null);
1384
+ J && (U.mergeTree(J), A[M] = null);
1385
1385
  }), A.find((M) => M)) {
1386
1386
  const M = r.writeCursor(), P = r.writeCursor();
1387
- let k = 0, J = 0;
1387
+ let U = 0, J = 0;
1388
1388
  A.forEach((X) => {
1389
1389
  X != null && Te(r.readCursor(X), null, (ee) => {
1390
1390
  const fe = Le[ee];
1391
- M.writeMove(I[fe].getPath(), R[fe].getPath(), k++);
1392
- const de = se[fe];
1393
- de && de.forEach((ae) => {
1391
+ M.writeMove(I[fe].getPath(), R[fe].getPath(), U++);
1392
+ const ce = se[fe];
1393
+ ce && ce.forEach((ae) => {
1394
1394
  g[ae] || D !== 1 && K[ae] != null || P.writeMove($[ae].getPath(), p[ae].getPath(), J++);
1395
1395
  });
1396
1396
  });
1397
- }), O = {
1397
+ }), w = {
1398
1398
  type: u.ConflictType.BLACKHOLE,
1399
1399
  op1: M.get(),
1400
1400
  op2: P.get()
@@ -1402,62 +1402,62 @@ function en() {
1402
1402
  }
1403
1403
  }
1404
1404
  }
1405
- return O ? {
1405
+ return w ? {
1406
1406
  ok: !1,
1407
- conflict: O
1407
+ conflict: w
1408
1408
  } : {
1409
1409
  ok: !0,
1410
1410
  result: oe.get()
1411
1411
  };
1412
1412
  }
1413
- const pt = (i) => {
1414
- const d = new Error("Transform detected write conflict");
1415
- throw d.conflict = i, d.type = d.name = "writeConflict", d;
1413
+ const gt = (i) => {
1414
+ const c = new Error("Transform detected write conflict");
1415
+ throw c.conflict = i, c.type = c.name = "writeConflict", c;
1416
1416
  };
1417
- function St(i, d, m) {
1418
- const D = st(i, d, m);
1417
+ function jt(i, c, O) {
1418
+ const D = st(i, c, O);
1419
1419
  if (D.ok) return D.result;
1420
- pt(D.conflict);
1420
+ gt(D.conflict);
1421
1421
  }
1422
1422
  const He = (i) => {
1423
- const d = r.writeCursor();
1424
- return r.readCursor(i).traverse(d, (m, D) => {
1425
- (s(m) || ve(m)) && D.write("r", !0);
1426
- }), d.get();
1427
- }, jt = (i, d) => {
1428
- const { type: m, op1: D, op2: O } = i;
1429
- switch (m) {
1423
+ const c = r.writeCursor();
1424
+ return r.readCursor(i).traverse(c, (O, D) => {
1425
+ (s(O) || me(O)) && D.write("r", !0);
1426
+ }), c.get();
1427
+ }, $t = (i, c) => {
1428
+ const { type: O, op1: D, op2: w } = i;
1429
+ switch (O) {
1430
1430
  case u.ConflictType.DROP_COLLISION:
1431
- return d === "left" ? [null, He(O)] : [He(D), null];
1431
+ return c === "left" ? [null, He(w)] : [He(D), null];
1432
1432
  case u.ConflictType.RM_UNEXPECTED_CONTENT:
1433
1433
  let I = !1;
1434
1434
  return r.readCursor(D).traverse(null, (R) => {
1435
1435
  R.r !== void 0 && (I = !0);
1436
- }), I ? [null, He(O)] : [He(D), null];
1436
+ }), I ? [null, He(w)] : [He(D), null];
1437
1437
  case u.ConflictType.BLACKHOLE:
1438
- return [He(D), He(O)];
1438
+ return [He(D), He(w)];
1439
1439
  default:
1440
- throw Error("Unrecognised conflict: " + m);
1440
+ throw Error("Unrecognised conflict: " + O);
1441
1441
  }
1442
1442
  };
1443
- function gt(i, d, m, D) {
1444
- let O = null;
1443
+ function yt(i, c, O, D) {
1444
+ let w = null;
1445
1445
  for (; ; ) {
1446
- const I = st(d, m, D);
1447
- if (I.ok) return ne(O, I.result);
1446
+ const I = st(c, O, D);
1447
+ if (I.ok) return ne(w, I.result);
1448
1448
  {
1449
1449
  const { conflict: R } = I;
1450
- i(R) || pt(R);
1451
- const [$, p] = jt(R, D);
1452
- d = ne(q(d), $), m = ne(q(m), p), O = ne(O, p);
1450
+ i(R) || gt(R);
1451
+ const [$, p] = $t(R, D);
1452
+ c = ne(q(c), $), O = ne(q(O), p), w = ne(w, p);
1453
1453
  }
1454
1454
  }
1455
1455
  }
1456
1456
  }(et)), et;
1457
1457
  }
1458
- var Dt;
1459
- function tn() {
1460
- return Dt || (Dt = 1, function(a) {
1458
+ var Pt;
1459
+ function sn() {
1460
+ return Pt || (Pt = 1, function(a) {
1461
1461
  var e = Ye.__createBinding || (Object.create ? function(u, o, l, E) {
1462
1462
  E === void 0 && (E = l), Object.defineProperty(u, E, { enumerable: !0, get: function() {
1463
1463
  return o[l];
@@ -1467,56 +1467,56 @@ function tn() {
1467
1467
  }), n = Ye.__exportStar || function(u, o) {
1468
1468
  for (var l in u) l !== "default" && !o.hasOwnProperty(l) && e(o, u, l);
1469
1469
  };
1470
- Object.defineProperty(a, "__esModule", { value: !0 }), n(en(), a);
1470
+ Object.defineProperty(a, "__esModule", { value: !0 }), n(rn(), a);
1471
1471
  var t = Mt();
1472
1472
  Object.defineProperty(a, "ReadCursor", { enumerable: !0, get: function() {
1473
1473
  return t.ReadCursor;
1474
1474
  } }), Object.defineProperty(a, "WriteCursor", { enumerable: !0, get: function() {
1475
1475
  return t.WriteCursor;
1476
1476
  } });
1477
- var r = Ut();
1477
+ var r = St();
1478
1478
  Object.defineProperty(a, "ConflictType", { enumerable: !0, get: function() {
1479
1479
  return r.ConflictType;
1480
1480
  } });
1481
1481
  }(Ye)), Ye;
1482
1482
  }
1483
- var V = tn();
1484
- class nn {
1483
+ var V = sn();
1484
+ class on {
1485
1485
  constructor() {
1486
1486
  F(this, "drawingManagerData", {});
1487
1487
  F(this, "_oldDrawingManagerData", {});
1488
1488
  F(this, "_focusDrawings", []);
1489
- F(this, "_remove$", new be());
1489
+ F(this, "_remove$", new ve());
1490
1490
  F(this, "remove$", this._remove$.asObservable());
1491
- F(this, "_add$", new be());
1491
+ F(this, "_add$", new ve());
1492
1492
  F(this, "add$", this._add$.asObservable());
1493
- F(this, "_update$", new be());
1493
+ F(this, "_update$", new ve());
1494
1494
  F(this, "update$", this._update$.asObservable());
1495
- F(this, "_order$", new be());
1495
+ F(this, "_order$", new ve());
1496
1496
  F(this, "order$", this._order$.asObservable());
1497
- F(this, "_group$", new be());
1497
+ F(this, "_group$", new ve());
1498
1498
  F(this, "group$", this._group$.asObservable());
1499
- F(this, "_ungroup$", new be());
1499
+ F(this, "_ungroup$", new ve());
1500
1500
  F(this, "ungroup$", this._ungroup$.asObservable());
1501
- F(this, "_refreshTransform$", new be());
1501
+ F(this, "_refreshTransform$", new ve());
1502
1502
  F(this, "refreshTransform$", this._refreshTransform$.asObservable());
1503
- F(this, "_visible$", new be());
1503
+ F(this, "_visible$", new ve());
1504
1504
  F(this, "visible$", this._visible$.asObservable());
1505
1505
  // private readonly _externalUpdate$ = new Subject<T[]>();
1506
1506
  // readonly externalUpdate$ = this._externalUpdate$.asObservable();
1507
- F(this, "_focus$", new be());
1507
+ F(this, "_focus$", new ve());
1508
1508
  F(this, "focus$", this._focus$.asObservable());
1509
- F(this, "_featurePluginUpdate$", new be());
1509
+ F(this, "_featurePluginUpdate$", new ve());
1510
1510
  F(this, "featurePluginUpdate$", this._featurePluginUpdate$.asObservable());
1511
- F(this, "_featurePluginAdd$", new be());
1511
+ F(this, "_featurePluginAdd$", new ve());
1512
1512
  F(this, "featurePluginAdd$", this._featurePluginAdd$.asObservable());
1513
- F(this, "_featurePluginRemove$", new be());
1513
+ F(this, "_featurePluginRemove$", new ve());
1514
1514
  F(this, "featurePluginRemove$", this._featurePluginRemove$.asObservable());
1515
- F(this, "_featurePluginOrderUpdate$", new be());
1515
+ F(this, "_featurePluginOrderUpdate$", new ve());
1516
1516
  F(this, "featurePluginOrderUpdate$", this._featurePluginOrderUpdate$.asObservable());
1517
- F(this, "_featurePluginGroupUpdate$", new be());
1517
+ F(this, "_featurePluginGroupUpdate$", new ve());
1518
1518
  F(this, "featurePluginGroupUpdate$", this._featurePluginGroupUpdate$.asObservable());
1519
- F(this, "_featurePluginUngroupUpdate$", new be());
1519
+ F(this, "_featurePluginUngroupUpdate$", new ve());
1520
1520
  F(this, "featurePluginUngroupUpdate$", this._featurePluginUngroupUpdate$.asObservable());
1521
1521
  F(this, "_visible", !0);
1522
1522
  F(this, "_editable", !0);
@@ -1651,9 +1651,9 @@ class nn {
1651
1651
  );
1652
1652
  let E = Number.NEGATIVE_INFINITY;
1653
1653
  return t.forEach((x) => {
1654
- const { unitId: _, subUnitId: s, drawingId: c } = x, h = this._hasDrawingOrder({ unitId: _, subUnitId: s, drawingId: c });
1654
+ const { unitId: _, subUnitId: s, drawingId: d } = x, h = this._hasDrawingOrder({ unitId: _, subUnitId: s, drawingId: d });
1655
1655
  E = Math.max(E, h), l.push(
1656
- ...this._getUpdateParamCompareOp(x, this.getDrawingByParam({ unitId: _, subUnitId: s, drawingId: c }))
1656
+ ...this._getUpdateParamCompareOp(x, this.getDrawingByParam({ unitId: _, subUnitId: s, drawingId: d }))
1657
1657
  );
1658
1658
  }), E === Number.NEGATIVE_INFINITY && (E = this._getDrawingOrder(r, u).length), l.push(
1659
1659
  V.insertOp([r, u, "order", E], o)
@@ -1724,7 +1724,7 @@ class nn {
1724
1724
  return this._getCurrentBySearch({ unitId: n, subUnitId: t, drawingId: r });
1725
1725
  }
1726
1726
  focusDrawing(e) {
1727
- if (e == null) {
1727
+ if (e == null || e.length === 0) {
1728
1728
  this._focusDrawings = [], this._focus$.next([]);
1729
1729
  return;
1730
1730
  }
@@ -1759,8 +1759,8 @@ class nn {
1759
1759
  const s = this._hasDrawingOrder({ unitId: n, subUnitId: t, drawingId: _ });
1760
1760
  if (s === -1 || s === o.length - 1)
1761
1761
  return;
1762
- const c = V.moveOp([n, t, "order", s], [n, t, "order", s + 1]);
1763
- u.push(c), l.includes(o[s + 1]) || l.push(o[s + 1]);
1762
+ const d = V.moveOp([n, t, "order", s], [n, t, "order", s + 1]);
1763
+ u.push(d), l.includes(o[s + 1]) || l.push(o[s + 1]);
1764
1764
  });
1765
1765
  const E = u.reduce(V.type.compose, null);
1766
1766
  return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: n, subUnitId: t, objects: { ...e, drawingIds: l } };
@@ -1771,8 +1771,8 @@ class nn {
1771
1771
  const s = this._hasDrawingOrder({ unitId: n, subUnitId: t, drawingId: _ });
1772
1772
  if (s === -1 || s === 0)
1773
1773
  return;
1774
- const c = V.moveOp([n, t, "order", s], [n, t, "order", s - 1]);
1775
- u.push(c), l.includes(o[s - 1]) || l.push(o[s - 1]);
1774
+ const d = V.moveOp([n, t, "order", s], [n, t, "order", s - 1]);
1775
+ u.push(d), l.includes(o[s - 1]) || l.push(o[s - 1]);
1776
1776
  });
1777
1777
  const E = u.reduce(V.type.compose, null);
1778
1778
  return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: n, subUnitId: t, objects: { ...e, drawingIds: l } };
@@ -1780,8 +1780,8 @@ class nn {
1780
1780
  getFrontDrawingsOp(e) {
1781
1781
  const { unitId: n, subUnitId: t, drawingIds: r } = e, u = this._getOrderFromSearchParams(n, t, r), o = [...r], l = this.getDrawingOrder(n, t), E = [];
1782
1782
  u.forEach((s) => {
1783
- const { drawingId: c } = s, h = this._getDrawingCount(n, t) - 1, S = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(c)], [n, t, "order", h]);
1784
- E.push(S), o.includes(l[h]) || o.push(l[h]);
1783
+ const { drawingId: d } = s, h = this._getDrawingCount(n, t) - 1, k = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(d)], [n, t, "order", h]);
1784
+ E.push(k), o.includes(l[h]) || o.push(l[h]);
1785
1785
  });
1786
1786
  const x = E.reduce(V.type.compose, null);
1787
1787
  return { undo: V.type.invertWithDoc(x, this.drawingManagerData), redo: x, unitId: n, subUnitId: t, objects: { ...e, drawingIds: o } };
@@ -1789,7 +1789,7 @@ class nn {
1789
1789
  getBackDrawingsOp(e) {
1790
1790
  const { unitId: n, subUnitId: t, drawingIds: r } = e, u = this._getOrderFromSearchParams(n, t, r, !0), o = [...r], l = this.getDrawingOrder(n, t), E = [];
1791
1791
  u.forEach((s) => {
1792
- const { drawingId: c } = s, h = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(c)], [n, t, "order", 0]);
1792
+ const { drawingId: d } = s, h = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(d)], [n, t, "order", 0]);
1793
1793
  E.push(h), o.includes(l[0]) || o.push(l[0]);
1794
1794
  });
1795
1795
  const x = E.reduce(V.type.compose, null);
@@ -1802,7 +1802,7 @@ class nn {
1802
1802
  return t.map((u) => {
1803
1803
  const o = this._hasDrawingOrder({ unitId: e, subUnitId: n, drawingId: u });
1804
1804
  return { drawingId: u, zIndex: o };
1805
- }).sort(r === !1 ? Rt : xt);
1805
+ }).sort(r === !1 ? xt : Bt);
1806
1806
  }
1807
1807
  _hasDrawingOrder(e) {
1808
1808
  if (e == null)
@@ -1890,12 +1890,12 @@ class nn {
1890
1890
  this._editable = e;
1891
1891
  }
1892
1892
  }
1893
- class rn extends nn {
1893
+ class an extends on {
1894
1894
  }
1895
- function vn({ unitId: a, subUnitId: e, drawingId: n }, t) {
1895
+ function bn({ unitId: a, subUnitId: e, drawingId: n }, t) {
1896
1896
  return typeof t == "number" ? `${a}#-#${e}#-#${n}#-#${t}` : `${a}#-#${e}#-#${n}`;
1897
1897
  }
1898
- const mn = async (a) => new Promise((e, n) => {
1898
+ const vn = async (a) => new Promise((e, n) => {
1899
1899
  const t = new Image();
1900
1900
  t.src = a, t.onload = () => {
1901
1901
  e({
@@ -1906,11 +1906,18 @@ const mn = async (a) => new Promise((e, n) => {
1906
1906
  }, t.onerror = (r) => {
1907
1907
  n(r);
1908
1908
  };
1909
- }), sn = "drawing.config", Pt = {}, on = Bt("univer.drawing-manager.service");
1910
- class an {
1909
+ }), Ut = Wt("univer.drawing-manager.service"), ln = {
1910
+ id: "drawing.operation.set-drawing-selected",
1911
+ type: Gt.OPERATION,
1912
+ handler: (a, e) => {
1913
+ const n = a.get(Ut);
1914
+ return e == null ? !1 : (n.focusDrawing(e), !0);
1915
+ }
1916
+ }, un = "drawing.config", Tt = {};
1917
+ class dn {
1911
1918
  constructor() {
1912
1919
  F(this, "_waitCount", 0);
1913
- F(this, "_change$", new be());
1920
+ F(this, "_change$", new ve());
1914
1921
  F(this, "change$", this._change$);
1915
1922
  F(this, "_imageSourceCache", /* @__PURE__ */ new Map());
1916
1923
  }
@@ -1932,11 +1939,11 @@ class an {
1932
1939
  }
1933
1940
  async saveImage(e) {
1934
1941
  return new Promise((n, t) => {
1935
- if (!Xt.includes(e.type)) {
1942
+ if (!Zt.includes(e.type)) {
1936
1943
  t(new Error(Qe.ERROR_IMAGE_TYPE)), this._decreaseWaiting();
1937
1944
  return;
1938
1945
  }
1939
- if (e.size > zt) {
1946
+ if (e.size > Yt) {
1940
1947
  t(new Error(Qe.ERROR_EXCEED_SIZE)), this._decreaseWaiting();
1941
1948
  return;
1942
1949
  }
@@ -1948,7 +1955,7 @@ class an {
1948
1955
  t(new Error(Qe.ERROR_IMAGE)), this._decreaseWaiting();
1949
1956
  return;
1950
1957
  }
1951
- const l = Wt.generateRandomId(6);
1958
+ const l = Lt.generateRandomId(6);
1952
1959
  n({
1953
1960
  imageId: l,
1954
1961
  imageSourceType: at.BASE64,
@@ -1963,52 +1970,59 @@ class an {
1963
1970
  this._waitCount -= 1, this._change$.next(this._waitCount);
1964
1971
  }
1965
1972
  }
1966
- var ln = Object.defineProperty, un = Object.getOwnPropertyDescriptor, cn = (a, e, n, t) => {
1967
- for (var r = t > 1 ? void 0 : t ? un(e, n) : e, u = a.length - 1, o; u >= 0; u--)
1973
+ var cn = Object.defineProperty, fn = Object.getOwnPropertyDescriptor, hn = (a, e, n, t) => {
1974
+ for (var r = t > 1 ? void 0 : t ? fn(e, n) : e, u = a.length - 1, o; u >= 0; u--)
1968
1975
  (o = a[u]) && (r = (t ? o(e, n, r) : o(r)) || r);
1969
- return t && r && ln(e, n, r), r;
1970
- }, Tt = (a, e) => (n, t) => e(n, t, a);
1971
- const dn = "UNIVER_DRAWING_PLUGIN";
1972
- var dt;
1973
- let At = (dt = class extends qt {
1974
- constructor(a = Pt, e, n) {
1975
- super(), this._config = a, this._injector = e, this._configService = n;
1976
- const { ...t } = Kt(
1976
+ return t && r && cn(e, n, r), r;
1977
+ }, ct = (a, e) => (n, t) => e(n, t, a);
1978
+ const pn = "UNIVER_DRAWING_PLUGIN";
1979
+ var ft;
1980
+ let At = (ft = class extends Ft {
1981
+ constructor(a = Tt, e, n, t) {
1982
+ super(), this._config = a, this._injector = e, this._configService = n, this._commandService = t;
1983
+ const { ...r } = Vt(
1977
1984
  {},
1978
- Pt,
1985
+ Tt,
1979
1986
  this._config
1980
1987
  );
1981
- this._configService.setConfig(sn, t);
1988
+ this._configService.setConfig(un, r);
1982
1989
  }
1983
1990
  onStarting() {
1984
- this._initDependencies();
1991
+ this._initCommands(), this._initDependencies();
1985
1992
  }
1986
1993
  _initDependencies() {
1987
1994
  var n;
1988
- Ft([
1989
- [Ht, { useClass: an }],
1990
- [on, { useClass: rn }]
1995
+ Ht([
1996
+ [Jt, { useClass: dn }],
1997
+ [Ut, { useClass: an }]
1991
1998
  ], (n = this._config) == null ? void 0 : n.override).forEach((t) => this._injector.add(t));
1992
1999
  }
1993
- }, F(dt, "pluginName", dn), dt);
1994
- At = cn([
1995
- Tt(1, Gt(Lt)),
1996
- Tt(2, Vt)
2000
+ _initCommands() {
2001
+ [
2002
+ ln
2003
+ ].forEach((a) => this.disposeWithMe(this._commandService.registerCommand(a)));
2004
+ }
2005
+ }, F(ft, "pluginName", pn), ft);
2006
+ At = hn([
2007
+ ct(1, qt(Kt)),
2008
+ ct(2, zt),
2009
+ ct(3, Xt)
1997
2010
  ], At);
1998
2011
  export {
1999
- Xt as DRAWING_IMAGE_ALLOW_IMAGE_LIST,
2000
- zt as DRAWING_IMAGE_ALLOW_SIZE,
2001
- _n as DRAWING_IMAGE_COUNT_LIMIT,
2002
- yn as DRAWING_IMAGE_HEIGHT_LIMIT,
2003
- gn as DRAWING_IMAGE_WIDTH_LIMIT,
2004
- rn as DrawingManagerService,
2005
- on as IDrawingManagerService,
2006
- bn as IImageIoService,
2007
- an as ImageIoService,
2008
- Cn as ImageSourceType,
2009
- In as ImageUploadStatusType,
2010
- nn as UnitDrawingService,
2012
+ Zt as DRAWING_IMAGE_ALLOW_IMAGE_LIST,
2013
+ Yt as DRAWING_IMAGE_ALLOW_SIZE,
2014
+ wn as DRAWING_IMAGE_COUNT_LIMIT,
2015
+ On as DRAWING_IMAGE_HEIGHT_LIMIT,
2016
+ mn as DRAWING_IMAGE_WIDTH_LIMIT,
2017
+ an as DrawingManagerService,
2018
+ Ut as IDrawingManagerService,
2019
+ En as IImageIoService,
2020
+ dn as ImageIoService,
2021
+ Dn as ImageSourceType,
2022
+ Pn as ImageUploadStatusType,
2023
+ ln as SetDrawingSelectedOperation,
2024
+ on as UnitDrawingService,
2011
2025
  At as UniverDrawingPlugin,
2012
- vn as getDrawingShapeKeyByDrawingSearch,
2013
- mn as getImageSize
2026
+ bn as getDrawingShapeKeyByDrawingSearch,
2027
+ vn as getImageSize
2014
2028
  };