@univerjs/drawing 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -16
- package/lib/cjs/index.js +34 -32
- package/lib/es/index.js +34 -32
- package/lib/index.js +34 -32
- package/lib/types/basics/config.d.ts +2 -1
- package/lib/types/config/config.d.ts +5 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +14 -8
package/README.md
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
# @univerjs/drawing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://npmjs.com/package/@univerjs/drawing)
|
|
4
|
+
[](https://npmjs.com/package/@univerjs/drawing)
|
|
5
|
+
[](https://npmjs.com/package/@univerjs/drawing)
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
| --- | --- | --- | --- | --- | :---: | :---: |
|
|
7
|
-
| `@univerjs/drawing` | `UniverDrawing` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ❌ |
|
|
7
|
+
`@univerjs/drawing` provides the shared drawing data model, services, and commands used by Docs, Sheets, and other drawing-enabled surfaces.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Package Overview
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
| Package | UMD global | CSS | Locales | Facade entry |
|
|
12
|
+
| --- | --- | :---: | :---: | :---: |
|
|
13
|
+
| `@univerjs/drawing` | `UniverDrawing` | No | No | No |
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
## Installation
|
|
14
16
|
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
+
```sh
|
|
18
|
+
pnpm add @univerjs/drawing
|
|
19
|
+
# or
|
|
17
20
|
npm install @univerjs/drawing
|
|
21
|
+
```
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
Keep all `@univerjs/*` packages on the same version.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { UniverDrawingPlugin } from '@univerjs/drawing';
|
|
29
|
+
|
|
30
|
+
univer.registerPlugin(UniverDrawingPlugin);
|
|
21
31
|
```
|
|
22
32
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
33
|
+
## Resources
|
|
34
|
+
|
|
35
|
+
- [Documentation](https://docs.univer.ai)
|
|
36
|
+
- [NPM package](https://npmjs.com/package/@univerjs/drawing)
|
|
37
|
+
- [GitHub repository](https://github.com/dream-num/univer)
|
|
38
|
+
|
package/lib/cjs/index.js
CHANGED
|
@@ -50,7 +50,13 @@ let rxjs = require("rxjs");
|
|
|
50
50
|
const DRAWING_IMAGE_WIDTH_LIMIT = 500;
|
|
51
51
|
const DRAWING_IMAGE_HEIGHT_LIMIT = 500;
|
|
52
52
|
const DRAWING_IMAGE_COUNT_LIMIT = 10;
|
|
53
|
-
|
|
53
|
+
let DRAWING_IMAGE_ALLOW_SIZE = 5 * 1024 * 1024;
|
|
54
|
+
function setDrawingImageAllowSize(size) {
|
|
55
|
+
DRAWING_IMAGE_ALLOW_SIZE = size;
|
|
56
|
+
}
|
|
57
|
+
function getDrawingImageAllowSize() {
|
|
58
|
+
return DRAWING_IMAGE_ALLOW_SIZE;
|
|
59
|
+
}
|
|
54
60
|
const DRAWING_IMAGE_ALLOW_IMAGE_LIST = [
|
|
55
61
|
"image/png",
|
|
56
62
|
"image/jpeg",
|
|
@@ -79,7 +85,7 @@ const SetDrawingSelectedOperation = {
|
|
|
79
85
|
//#endregion
|
|
80
86
|
//#region package.json
|
|
81
87
|
var name = "@univerjs/drawing";
|
|
82
|
-
var version = "0.
|
|
88
|
+
var version = "0.22.0";
|
|
83
89
|
|
|
84
90
|
//#endregion
|
|
85
91
|
//#region src/config/config.ts
|
|
@@ -88,7 +94,7 @@ const configSymbol = Symbol(DRAWING_PLUGIN_CONFIG_KEY);
|
|
|
88
94
|
const defaultPluginConfig = {};
|
|
89
95
|
|
|
90
96
|
//#endregion
|
|
91
|
-
//#region \0@oxc-project+runtime@0.
|
|
97
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
92
98
|
function _typeof(o) {
|
|
93
99
|
"@babel/helpers - typeof";
|
|
94
100
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -99,7 +105,7 @@ function _typeof(o) {
|
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
//#endregion
|
|
102
|
-
//#region \0@oxc-project+runtime@0.
|
|
108
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
103
109
|
function toPrimitive(t, r) {
|
|
104
110
|
if ("object" != _typeof(t) || !t) return t;
|
|
105
111
|
var e = t[Symbol.toPrimitive];
|
|
@@ -112,14 +118,14 @@ function toPrimitive(t, r) {
|
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
//#endregion
|
|
115
|
-
//#region \0@oxc-project+runtime@0.
|
|
121
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
116
122
|
function toPropertyKey(t) {
|
|
117
123
|
var i = toPrimitive(t, "string");
|
|
118
124
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
//#endregion
|
|
122
|
-
//#region \0@oxc-project+runtime@0.
|
|
128
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
123
129
|
function _defineProperty(e, r, t) {
|
|
124
130
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
125
131
|
value: t,
|
|
@@ -131,11 +137,6 @@ function _defineProperty(e, r, t) {
|
|
|
131
137
|
|
|
132
138
|
//#endregion
|
|
133
139
|
//#region src/services/drawing-manager-impl.service.ts
|
|
134
|
-
var DrawingMapItemType = /* @__PURE__ */ function(DrawingMapItemType) {
|
|
135
|
-
DrawingMapItemType["data"] = "data";
|
|
136
|
-
DrawingMapItemType["order"] = "order";
|
|
137
|
-
return DrawingMapItemType;
|
|
138
|
-
}(DrawingMapItemType || {});
|
|
139
140
|
/**
|
|
140
141
|
* unitId -> subUnitId -> drawingId -> drawingParam
|
|
141
142
|
*/
|
|
@@ -493,7 +494,7 @@ var UnitDrawingService = class {
|
|
|
493
494
|
ops.push(ot_json1.insertOp([
|
|
494
495
|
groupUnitId,
|
|
495
496
|
groupSubUnitId,
|
|
496
|
-
|
|
497
|
+
"data",
|
|
497
498
|
groupDrawingId
|
|
498
499
|
], parent));
|
|
499
500
|
let maxChildIndex = Number.NEGATIVE_INFINITY;
|
|
@@ -515,7 +516,7 @@ var UnitDrawingService = class {
|
|
|
515
516
|
ops.push(ot_json1.insertOp([
|
|
516
517
|
groupUnitId,
|
|
517
518
|
groupSubUnitId,
|
|
518
|
-
|
|
519
|
+
"order",
|
|
519
520
|
maxChildIndex
|
|
520
521
|
], groupDrawingId));
|
|
521
522
|
return ops.reduce(ot_json1.type.compose, null);
|
|
@@ -535,13 +536,13 @@ var UnitDrawingService = class {
|
|
|
535
536
|
ops.push(ot_json1.removeOp([
|
|
536
537
|
groupUnitId,
|
|
537
538
|
groupSubUnitId,
|
|
538
|
-
|
|
539
|
+
"data",
|
|
539
540
|
groupDrawingId
|
|
540
541
|
], true));
|
|
541
542
|
ops.push(ot_json1.removeOp([
|
|
542
543
|
groupUnitId,
|
|
543
544
|
groupSubUnitId,
|
|
544
|
-
|
|
545
|
+
"order",
|
|
545
546
|
this._getDrawingOrder(groupUnitId, groupSubUnitId).indexOf(groupDrawingId)
|
|
546
547
|
], true));
|
|
547
548
|
return ops.reduce(ot_json1.type.compose, null);
|
|
@@ -635,12 +636,12 @@ var UnitDrawingService = class {
|
|
|
635
636
|
const op = ot_json1.moveOp([
|
|
636
637
|
unitId,
|
|
637
638
|
subUnitId,
|
|
638
|
-
|
|
639
|
+
"order",
|
|
639
640
|
index
|
|
640
641
|
], [
|
|
641
642
|
unitId,
|
|
642
643
|
subUnitId,
|
|
643
|
-
|
|
644
|
+
"order",
|
|
644
645
|
index + 1
|
|
645
646
|
]);
|
|
646
647
|
ops.push(op);
|
|
@@ -673,12 +674,12 @@ var UnitDrawingService = class {
|
|
|
673
674
|
const op = ot_json1.moveOp([
|
|
674
675
|
unitId,
|
|
675
676
|
subUnitId,
|
|
676
|
-
|
|
677
|
+
"order",
|
|
677
678
|
index
|
|
678
679
|
], [
|
|
679
680
|
unitId,
|
|
680
681
|
subUnitId,
|
|
681
|
-
|
|
682
|
+
"order",
|
|
682
683
|
index - 1
|
|
683
684
|
]);
|
|
684
685
|
ops.push(op);
|
|
@@ -708,12 +709,12 @@ var UnitDrawingService = class {
|
|
|
708
709
|
const op = ot_json1.moveOp([
|
|
709
710
|
unitId,
|
|
710
711
|
subUnitId,
|
|
711
|
-
|
|
712
|
+
"order",
|
|
712
713
|
this._getDrawingOrder(unitId, subUnitId).indexOf(drawingId)
|
|
713
714
|
], [
|
|
714
715
|
unitId,
|
|
715
716
|
subUnitId,
|
|
716
|
-
|
|
717
|
+
"order",
|
|
717
718
|
index
|
|
718
719
|
]);
|
|
719
720
|
ops.push(op);
|
|
@@ -742,12 +743,12 @@ var UnitDrawingService = class {
|
|
|
742
743
|
const op = ot_json1.moveOp([
|
|
743
744
|
unitId,
|
|
744
745
|
subUnitId,
|
|
745
|
-
|
|
746
|
+
"order",
|
|
746
747
|
this._getDrawingOrder(unitId, subUnitId).indexOf(drawingId)
|
|
747
748
|
], [
|
|
748
749
|
unitId,
|
|
749
750
|
subUnitId,
|
|
750
|
-
|
|
751
|
+
"order",
|
|
751
752
|
0
|
|
752
753
|
]);
|
|
753
754
|
ops.push(op);
|
|
@@ -814,12 +815,12 @@ var UnitDrawingService = class {
|
|
|
814
815
|
const op = [ot_json1.insertOp([
|
|
815
816
|
unitId,
|
|
816
817
|
subUnitId,
|
|
817
|
-
|
|
818
|
+
"data",
|
|
818
819
|
drawingId
|
|
819
820
|
], insertParam), ot_json1.insertOp([
|
|
820
821
|
unitId,
|
|
821
822
|
subUnitId,
|
|
822
|
-
|
|
823
|
+
"order",
|
|
823
824
|
this._getDrawingOrder(unitId, subUnitId).length
|
|
824
825
|
], drawingId)].reduce(ot_json1.type.compose, null);
|
|
825
826
|
return {
|
|
@@ -840,12 +841,12 @@ var UnitDrawingService = class {
|
|
|
840
841
|
const op = [ot_json1.removeOp([
|
|
841
842
|
unitId,
|
|
842
843
|
subUnitId,
|
|
843
|
-
|
|
844
|
+
"data",
|
|
844
845
|
drawingId
|
|
845
846
|
], true), ot_json1.removeOp([
|
|
846
847
|
unitId,
|
|
847
848
|
subUnitId,
|
|
848
|
-
|
|
849
|
+
"order",
|
|
849
850
|
this._getDrawingOrder(unitId, subUnitId).indexOf(drawingId)
|
|
850
851
|
], true)].reduce(ot_json1.type.compose, null);
|
|
851
852
|
return {
|
|
@@ -876,7 +877,7 @@ var UnitDrawingService = class {
|
|
|
876
877
|
ops.push(ot_json1.replaceOp([
|
|
877
878
|
unitId,
|
|
878
879
|
subUnitId,
|
|
879
|
-
|
|
880
|
+
"data",
|
|
880
881
|
drawingId,
|
|
881
882
|
key
|
|
882
883
|
], oldVal, newVal));
|
|
@@ -941,7 +942,7 @@ var ImageIoService = class {
|
|
|
941
942
|
this._decreaseWaiting();
|
|
942
943
|
return;
|
|
943
944
|
}
|
|
944
|
-
if (imageFile.size >
|
|
945
|
+
if (imageFile.size > getDrawingImageAllowSize()) {
|
|
945
946
|
reject(new Error(_univerjs_core.ImageUploadStatusType.ERROR_EXCEED_SIZE));
|
|
946
947
|
this._decreaseWaiting();
|
|
947
948
|
return;
|
|
@@ -1006,7 +1007,7 @@ var URLImageService = class extends _univerjs_core.Disposable {
|
|
|
1006
1007
|
};
|
|
1007
1008
|
|
|
1008
1009
|
//#endregion
|
|
1009
|
-
//#region \0@oxc-project+runtime@0.
|
|
1010
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
|
|
1010
1011
|
function __decorateParam(paramIndex, decorator) {
|
|
1011
1012
|
return function(target, key) {
|
|
1012
1013
|
decorator(target, key, paramIndex);
|
|
@@ -1014,7 +1015,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
1014
1015
|
}
|
|
1015
1016
|
|
|
1016
1017
|
//#endregion
|
|
1017
|
-
//#region \0@oxc-project+runtime@0.
|
|
1018
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
|
|
1018
1019
|
function __decorate(decorators, target, key, desc) {
|
|
1019
1020
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1020
1021
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1033,6 +1034,7 @@ let UniverDrawingPlugin = class UniverDrawingPlugin extends _univerjs_core.Plugi
|
|
|
1033
1034
|
this._commandService = _commandService;
|
|
1034
1035
|
const { ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
|
|
1035
1036
|
this._configService.setConfig(DRAWING_PLUGIN_CONFIG_KEY, rest);
|
|
1037
|
+
if (rest.allowImageSize !== void 0) setDrawingImageAllowSize(rest.allowImageSize);
|
|
1036
1038
|
}
|
|
1037
1039
|
onStarting() {
|
|
1038
1040
|
this._initCommands();
|
|
@@ -1086,7 +1088,6 @@ const getImageSize = async (src) => {
|
|
|
1086
1088
|
|
|
1087
1089
|
//#endregion
|
|
1088
1090
|
exports.DRAWING_IMAGE_ALLOW_IMAGE_LIST = DRAWING_IMAGE_ALLOW_IMAGE_LIST;
|
|
1089
|
-
exports.DRAWING_IMAGE_ALLOW_SIZE = DRAWING_IMAGE_ALLOW_SIZE;
|
|
1090
1091
|
exports.DRAWING_IMAGE_COUNT_LIMIT = DRAWING_IMAGE_COUNT_LIMIT;
|
|
1091
1092
|
exports.DRAWING_IMAGE_HEIGHT_LIMIT = DRAWING_IMAGE_HEIGHT_LIMIT;
|
|
1092
1093
|
exports.DRAWING_IMAGE_WIDTH_LIMIT = DRAWING_IMAGE_WIDTH_LIMIT;
|
|
@@ -1120,5 +1121,6 @@ Object.defineProperty(exports, 'UniverDrawingPlugin', {
|
|
|
1120
1121
|
return UniverDrawingPlugin;
|
|
1121
1122
|
}
|
|
1122
1123
|
});
|
|
1124
|
+
exports.getDrawingImageAllowSize = getDrawingImageAllowSize;
|
|
1123
1125
|
exports.getDrawingShapeKeyByDrawingSearch = getDrawingShapeKeyByDrawingSearch;
|
|
1124
1126
|
exports.getImageSize = getImageSize;
|
package/lib/es/index.js
CHANGED
|
@@ -21,7 +21,13 @@ import { Subject } from "rxjs";
|
|
|
21
21
|
const DRAWING_IMAGE_WIDTH_LIMIT = 500;
|
|
22
22
|
const DRAWING_IMAGE_HEIGHT_LIMIT = 500;
|
|
23
23
|
const DRAWING_IMAGE_COUNT_LIMIT = 10;
|
|
24
|
-
|
|
24
|
+
let DRAWING_IMAGE_ALLOW_SIZE = 5 * 1024 * 1024;
|
|
25
|
+
function setDrawingImageAllowSize(size) {
|
|
26
|
+
DRAWING_IMAGE_ALLOW_SIZE = size;
|
|
27
|
+
}
|
|
28
|
+
function getDrawingImageAllowSize() {
|
|
29
|
+
return DRAWING_IMAGE_ALLOW_SIZE;
|
|
30
|
+
}
|
|
25
31
|
const DRAWING_IMAGE_ALLOW_IMAGE_LIST = [
|
|
26
32
|
"image/png",
|
|
27
33
|
"image/jpeg",
|
|
@@ -50,7 +56,7 @@ const SetDrawingSelectedOperation = {
|
|
|
50
56
|
//#endregion
|
|
51
57
|
//#region package.json
|
|
52
58
|
var name = "@univerjs/drawing";
|
|
53
|
-
var version = "0.
|
|
59
|
+
var version = "0.22.0";
|
|
54
60
|
|
|
55
61
|
//#endregion
|
|
56
62
|
//#region src/config/config.ts
|
|
@@ -59,7 +65,7 @@ const configSymbol = Symbol(DRAWING_PLUGIN_CONFIG_KEY);
|
|
|
59
65
|
const defaultPluginConfig = {};
|
|
60
66
|
|
|
61
67
|
//#endregion
|
|
62
|
-
//#region \0@oxc-project+runtime@0.
|
|
68
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
63
69
|
function _typeof(o) {
|
|
64
70
|
"@babel/helpers - typeof";
|
|
65
71
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -70,7 +76,7 @@ function _typeof(o) {
|
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
//#endregion
|
|
73
|
-
//#region \0@oxc-project+runtime@0.
|
|
79
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
74
80
|
function toPrimitive(t, r) {
|
|
75
81
|
if ("object" != _typeof(t) || !t) return t;
|
|
76
82
|
var e = t[Symbol.toPrimitive];
|
|
@@ -83,14 +89,14 @@ function toPrimitive(t, r) {
|
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
//#endregion
|
|
86
|
-
//#region \0@oxc-project+runtime@0.
|
|
92
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
87
93
|
function toPropertyKey(t) {
|
|
88
94
|
var i = toPrimitive(t, "string");
|
|
89
95
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
//#endregion
|
|
93
|
-
//#region \0@oxc-project+runtime@0.
|
|
99
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
94
100
|
function _defineProperty(e, r, t) {
|
|
95
101
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
96
102
|
value: t,
|
|
@@ -102,11 +108,6 @@ function _defineProperty(e, r, t) {
|
|
|
102
108
|
|
|
103
109
|
//#endregion
|
|
104
110
|
//#region src/services/drawing-manager-impl.service.ts
|
|
105
|
-
var DrawingMapItemType = /* @__PURE__ */ function(DrawingMapItemType) {
|
|
106
|
-
DrawingMapItemType["data"] = "data";
|
|
107
|
-
DrawingMapItemType["order"] = "order";
|
|
108
|
-
return DrawingMapItemType;
|
|
109
|
-
}(DrawingMapItemType || {});
|
|
110
111
|
/**
|
|
111
112
|
* unitId -> subUnitId -> drawingId -> drawingParam
|
|
112
113
|
*/
|
|
@@ -464,7 +465,7 @@ var UnitDrawingService = class {
|
|
|
464
465
|
ops.push(json1.insertOp([
|
|
465
466
|
groupUnitId,
|
|
466
467
|
groupSubUnitId,
|
|
467
|
-
|
|
468
|
+
"data",
|
|
468
469
|
groupDrawingId
|
|
469
470
|
], parent));
|
|
470
471
|
let maxChildIndex = Number.NEGATIVE_INFINITY;
|
|
@@ -486,7 +487,7 @@ var UnitDrawingService = class {
|
|
|
486
487
|
ops.push(json1.insertOp([
|
|
487
488
|
groupUnitId,
|
|
488
489
|
groupSubUnitId,
|
|
489
|
-
|
|
490
|
+
"order",
|
|
490
491
|
maxChildIndex
|
|
491
492
|
], groupDrawingId));
|
|
492
493
|
return ops.reduce(json1.type.compose, null);
|
|
@@ -506,13 +507,13 @@ var UnitDrawingService = class {
|
|
|
506
507
|
ops.push(json1.removeOp([
|
|
507
508
|
groupUnitId,
|
|
508
509
|
groupSubUnitId,
|
|
509
|
-
|
|
510
|
+
"data",
|
|
510
511
|
groupDrawingId
|
|
511
512
|
], true));
|
|
512
513
|
ops.push(json1.removeOp([
|
|
513
514
|
groupUnitId,
|
|
514
515
|
groupSubUnitId,
|
|
515
|
-
|
|
516
|
+
"order",
|
|
516
517
|
this._getDrawingOrder(groupUnitId, groupSubUnitId).indexOf(groupDrawingId)
|
|
517
518
|
], true));
|
|
518
519
|
return ops.reduce(json1.type.compose, null);
|
|
@@ -606,12 +607,12 @@ var UnitDrawingService = class {
|
|
|
606
607
|
const op = json1.moveOp([
|
|
607
608
|
unitId,
|
|
608
609
|
subUnitId,
|
|
609
|
-
|
|
610
|
+
"order",
|
|
610
611
|
index
|
|
611
612
|
], [
|
|
612
613
|
unitId,
|
|
613
614
|
subUnitId,
|
|
614
|
-
|
|
615
|
+
"order",
|
|
615
616
|
index + 1
|
|
616
617
|
]);
|
|
617
618
|
ops.push(op);
|
|
@@ -644,12 +645,12 @@ var UnitDrawingService = class {
|
|
|
644
645
|
const op = json1.moveOp([
|
|
645
646
|
unitId,
|
|
646
647
|
subUnitId,
|
|
647
|
-
|
|
648
|
+
"order",
|
|
648
649
|
index
|
|
649
650
|
], [
|
|
650
651
|
unitId,
|
|
651
652
|
subUnitId,
|
|
652
|
-
|
|
653
|
+
"order",
|
|
653
654
|
index - 1
|
|
654
655
|
]);
|
|
655
656
|
ops.push(op);
|
|
@@ -679,12 +680,12 @@ var UnitDrawingService = class {
|
|
|
679
680
|
const op = json1.moveOp([
|
|
680
681
|
unitId,
|
|
681
682
|
subUnitId,
|
|
682
|
-
|
|
683
|
+
"order",
|
|
683
684
|
this._getDrawingOrder(unitId, subUnitId).indexOf(drawingId)
|
|
684
685
|
], [
|
|
685
686
|
unitId,
|
|
686
687
|
subUnitId,
|
|
687
|
-
|
|
688
|
+
"order",
|
|
688
689
|
index
|
|
689
690
|
]);
|
|
690
691
|
ops.push(op);
|
|
@@ -713,12 +714,12 @@ var UnitDrawingService = class {
|
|
|
713
714
|
const op = json1.moveOp([
|
|
714
715
|
unitId,
|
|
715
716
|
subUnitId,
|
|
716
|
-
|
|
717
|
+
"order",
|
|
717
718
|
this._getDrawingOrder(unitId, subUnitId).indexOf(drawingId)
|
|
718
719
|
], [
|
|
719
720
|
unitId,
|
|
720
721
|
subUnitId,
|
|
721
|
-
|
|
722
|
+
"order",
|
|
722
723
|
0
|
|
723
724
|
]);
|
|
724
725
|
ops.push(op);
|
|
@@ -785,12 +786,12 @@ var UnitDrawingService = class {
|
|
|
785
786
|
const op = [json1.insertOp([
|
|
786
787
|
unitId,
|
|
787
788
|
subUnitId,
|
|
788
|
-
|
|
789
|
+
"data",
|
|
789
790
|
drawingId
|
|
790
791
|
], insertParam), json1.insertOp([
|
|
791
792
|
unitId,
|
|
792
793
|
subUnitId,
|
|
793
|
-
|
|
794
|
+
"order",
|
|
794
795
|
this._getDrawingOrder(unitId, subUnitId).length
|
|
795
796
|
], drawingId)].reduce(json1.type.compose, null);
|
|
796
797
|
return {
|
|
@@ -811,12 +812,12 @@ var UnitDrawingService = class {
|
|
|
811
812
|
const op = [json1.removeOp([
|
|
812
813
|
unitId,
|
|
813
814
|
subUnitId,
|
|
814
|
-
|
|
815
|
+
"data",
|
|
815
816
|
drawingId
|
|
816
817
|
], true), json1.removeOp([
|
|
817
818
|
unitId,
|
|
818
819
|
subUnitId,
|
|
819
|
-
|
|
820
|
+
"order",
|
|
820
821
|
this._getDrawingOrder(unitId, subUnitId).indexOf(drawingId)
|
|
821
822
|
], true)].reduce(json1.type.compose, null);
|
|
822
823
|
return {
|
|
@@ -847,7 +848,7 @@ var UnitDrawingService = class {
|
|
|
847
848
|
ops.push(json1.replaceOp([
|
|
848
849
|
unitId,
|
|
849
850
|
subUnitId,
|
|
850
|
-
|
|
851
|
+
"data",
|
|
851
852
|
drawingId,
|
|
852
853
|
key
|
|
853
854
|
], oldVal, newVal));
|
|
@@ -912,7 +913,7 @@ var ImageIoService = class {
|
|
|
912
913
|
this._decreaseWaiting();
|
|
913
914
|
return;
|
|
914
915
|
}
|
|
915
|
-
if (imageFile.size >
|
|
916
|
+
if (imageFile.size > getDrawingImageAllowSize()) {
|
|
916
917
|
reject(new Error(ImageUploadStatusType.ERROR_EXCEED_SIZE));
|
|
917
918
|
this._decreaseWaiting();
|
|
918
919
|
return;
|
|
@@ -977,7 +978,7 @@ var URLImageService = class extends Disposable {
|
|
|
977
978
|
};
|
|
978
979
|
|
|
979
980
|
//#endregion
|
|
980
|
-
//#region \0@oxc-project+runtime@0.
|
|
981
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
|
|
981
982
|
function __decorateParam(paramIndex, decorator) {
|
|
982
983
|
return function(target, key) {
|
|
983
984
|
decorator(target, key, paramIndex);
|
|
@@ -985,7 +986,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
985
986
|
}
|
|
986
987
|
|
|
987
988
|
//#endregion
|
|
988
|
-
//#region \0@oxc-project+runtime@0.
|
|
989
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
|
|
989
990
|
function __decorate(decorators, target, key, desc) {
|
|
990
991
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
991
992
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1004,6 +1005,7 @@ let UniverDrawingPlugin = class UniverDrawingPlugin extends Plugin {
|
|
|
1004
1005
|
this._commandService = _commandService;
|
|
1005
1006
|
const { ...rest } = merge({}, defaultPluginConfig, this._config);
|
|
1006
1007
|
this._configService.setConfig(DRAWING_PLUGIN_CONFIG_KEY, rest);
|
|
1008
|
+
if (rest.allowImageSize !== void 0) setDrawingImageAllowSize(rest.allowImageSize);
|
|
1007
1009
|
}
|
|
1008
1010
|
onStarting() {
|
|
1009
1011
|
this._initCommands();
|
|
@@ -1056,4 +1058,4 @@ const getImageSize = async (src) => {
|
|
|
1056
1058
|
};
|
|
1057
1059
|
|
|
1058
1060
|
//#endregion
|
|
1059
|
-
export { DRAWING_IMAGE_ALLOW_IMAGE_LIST,
|
|
1061
|
+
export { DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, DrawingManagerService, IDrawingManagerService, IImageIoService, ImageIoService, ImageSourceType, ImageUploadStatusType, SetDrawingSelectedOperation, URLImageService, UnitDrawingService, UniverDrawingPlugin, getDrawingImageAllowSize, getDrawingShapeKeyByDrawingSearch, getImageSize };
|
package/lib/index.js
CHANGED
|
@@ -21,7 +21,13 @@ import { Subject } from "rxjs";
|
|
|
21
21
|
const DRAWING_IMAGE_WIDTH_LIMIT = 500;
|
|
22
22
|
const DRAWING_IMAGE_HEIGHT_LIMIT = 500;
|
|
23
23
|
const DRAWING_IMAGE_COUNT_LIMIT = 10;
|
|
24
|
-
|
|
24
|
+
let DRAWING_IMAGE_ALLOW_SIZE = 5 * 1024 * 1024;
|
|
25
|
+
function setDrawingImageAllowSize(size) {
|
|
26
|
+
DRAWING_IMAGE_ALLOW_SIZE = size;
|
|
27
|
+
}
|
|
28
|
+
function getDrawingImageAllowSize() {
|
|
29
|
+
return DRAWING_IMAGE_ALLOW_SIZE;
|
|
30
|
+
}
|
|
25
31
|
const DRAWING_IMAGE_ALLOW_IMAGE_LIST = [
|
|
26
32
|
"image/png",
|
|
27
33
|
"image/jpeg",
|
|
@@ -50,7 +56,7 @@ const SetDrawingSelectedOperation = {
|
|
|
50
56
|
//#endregion
|
|
51
57
|
//#region package.json
|
|
52
58
|
var name = "@univerjs/drawing";
|
|
53
|
-
var version = "0.
|
|
59
|
+
var version = "0.22.0";
|
|
54
60
|
|
|
55
61
|
//#endregion
|
|
56
62
|
//#region src/config/config.ts
|
|
@@ -59,7 +65,7 @@ const configSymbol = Symbol(DRAWING_PLUGIN_CONFIG_KEY);
|
|
|
59
65
|
const defaultPluginConfig = {};
|
|
60
66
|
|
|
61
67
|
//#endregion
|
|
62
|
-
//#region \0@oxc-project+runtime@0.
|
|
68
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
63
69
|
function _typeof(o) {
|
|
64
70
|
"@babel/helpers - typeof";
|
|
65
71
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -70,7 +76,7 @@ function _typeof(o) {
|
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
//#endregion
|
|
73
|
-
//#region \0@oxc-project+runtime@0.
|
|
79
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
74
80
|
function toPrimitive(t, r) {
|
|
75
81
|
if ("object" != _typeof(t) || !t) return t;
|
|
76
82
|
var e = t[Symbol.toPrimitive];
|
|
@@ -83,14 +89,14 @@ function toPrimitive(t, r) {
|
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
//#endregion
|
|
86
|
-
//#region \0@oxc-project+runtime@0.
|
|
92
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
87
93
|
function toPropertyKey(t) {
|
|
88
94
|
var i = toPrimitive(t, "string");
|
|
89
95
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
//#endregion
|
|
93
|
-
//#region \0@oxc-project+runtime@0.
|
|
99
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
94
100
|
function _defineProperty(e, r, t) {
|
|
95
101
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
96
102
|
value: t,
|
|
@@ -102,11 +108,6 @@ function _defineProperty(e, r, t) {
|
|
|
102
108
|
|
|
103
109
|
//#endregion
|
|
104
110
|
//#region src/services/drawing-manager-impl.service.ts
|
|
105
|
-
var DrawingMapItemType = /* @__PURE__ */ function(DrawingMapItemType) {
|
|
106
|
-
DrawingMapItemType["data"] = "data";
|
|
107
|
-
DrawingMapItemType["order"] = "order";
|
|
108
|
-
return DrawingMapItemType;
|
|
109
|
-
}(DrawingMapItemType || {});
|
|
110
111
|
/**
|
|
111
112
|
* unitId -> subUnitId -> drawingId -> drawingParam
|
|
112
113
|
*/
|
|
@@ -464,7 +465,7 @@ var UnitDrawingService = class {
|
|
|
464
465
|
ops.push(json1.insertOp([
|
|
465
466
|
groupUnitId,
|
|
466
467
|
groupSubUnitId,
|
|
467
|
-
|
|
468
|
+
"data",
|
|
468
469
|
groupDrawingId
|
|
469
470
|
], parent));
|
|
470
471
|
let maxChildIndex = Number.NEGATIVE_INFINITY;
|
|
@@ -486,7 +487,7 @@ var UnitDrawingService = class {
|
|
|
486
487
|
ops.push(json1.insertOp([
|
|
487
488
|
groupUnitId,
|
|
488
489
|
groupSubUnitId,
|
|
489
|
-
|
|
490
|
+
"order",
|
|
490
491
|
maxChildIndex
|
|
491
492
|
], groupDrawingId));
|
|
492
493
|
return ops.reduce(json1.type.compose, null);
|
|
@@ -506,13 +507,13 @@ var UnitDrawingService = class {
|
|
|
506
507
|
ops.push(json1.removeOp([
|
|
507
508
|
groupUnitId,
|
|
508
509
|
groupSubUnitId,
|
|
509
|
-
|
|
510
|
+
"data",
|
|
510
511
|
groupDrawingId
|
|
511
512
|
], true));
|
|
512
513
|
ops.push(json1.removeOp([
|
|
513
514
|
groupUnitId,
|
|
514
515
|
groupSubUnitId,
|
|
515
|
-
|
|
516
|
+
"order",
|
|
516
517
|
this._getDrawingOrder(groupUnitId, groupSubUnitId).indexOf(groupDrawingId)
|
|
517
518
|
], true));
|
|
518
519
|
return ops.reduce(json1.type.compose, null);
|
|
@@ -606,12 +607,12 @@ var UnitDrawingService = class {
|
|
|
606
607
|
const op = json1.moveOp([
|
|
607
608
|
unitId,
|
|
608
609
|
subUnitId,
|
|
609
|
-
|
|
610
|
+
"order",
|
|
610
611
|
index
|
|
611
612
|
], [
|
|
612
613
|
unitId,
|
|
613
614
|
subUnitId,
|
|
614
|
-
|
|
615
|
+
"order",
|
|
615
616
|
index + 1
|
|
616
617
|
]);
|
|
617
618
|
ops.push(op);
|
|
@@ -644,12 +645,12 @@ var UnitDrawingService = class {
|
|
|
644
645
|
const op = json1.moveOp([
|
|
645
646
|
unitId,
|
|
646
647
|
subUnitId,
|
|
647
|
-
|
|
648
|
+
"order",
|
|
648
649
|
index
|
|
649
650
|
], [
|
|
650
651
|
unitId,
|
|
651
652
|
subUnitId,
|
|
652
|
-
|
|
653
|
+
"order",
|
|
653
654
|
index - 1
|
|
654
655
|
]);
|
|
655
656
|
ops.push(op);
|
|
@@ -679,12 +680,12 @@ var UnitDrawingService = class {
|
|
|
679
680
|
const op = json1.moveOp([
|
|
680
681
|
unitId,
|
|
681
682
|
subUnitId,
|
|
682
|
-
|
|
683
|
+
"order",
|
|
683
684
|
this._getDrawingOrder(unitId, subUnitId).indexOf(drawingId)
|
|
684
685
|
], [
|
|
685
686
|
unitId,
|
|
686
687
|
subUnitId,
|
|
687
|
-
|
|
688
|
+
"order",
|
|
688
689
|
index
|
|
689
690
|
]);
|
|
690
691
|
ops.push(op);
|
|
@@ -713,12 +714,12 @@ var UnitDrawingService = class {
|
|
|
713
714
|
const op = json1.moveOp([
|
|
714
715
|
unitId,
|
|
715
716
|
subUnitId,
|
|
716
|
-
|
|
717
|
+
"order",
|
|
717
718
|
this._getDrawingOrder(unitId, subUnitId).indexOf(drawingId)
|
|
718
719
|
], [
|
|
719
720
|
unitId,
|
|
720
721
|
subUnitId,
|
|
721
|
-
|
|
722
|
+
"order",
|
|
722
723
|
0
|
|
723
724
|
]);
|
|
724
725
|
ops.push(op);
|
|
@@ -785,12 +786,12 @@ var UnitDrawingService = class {
|
|
|
785
786
|
const op = [json1.insertOp([
|
|
786
787
|
unitId,
|
|
787
788
|
subUnitId,
|
|
788
|
-
|
|
789
|
+
"data",
|
|
789
790
|
drawingId
|
|
790
791
|
], insertParam), json1.insertOp([
|
|
791
792
|
unitId,
|
|
792
793
|
subUnitId,
|
|
793
|
-
|
|
794
|
+
"order",
|
|
794
795
|
this._getDrawingOrder(unitId, subUnitId).length
|
|
795
796
|
], drawingId)].reduce(json1.type.compose, null);
|
|
796
797
|
return {
|
|
@@ -811,12 +812,12 @@ var UnitDrawingService = class {
|
|
|
811
812
|
const op = [json1.removeOp([
|
|
812
813
|
unitId,
|
|
813
814
|
subUnitId,
|
|
814
|
-
|
|
815
|
+
"data",
|
|
815
816
|
drawingId
|
|
816
817
|
], true), json1.removeOp([
|
|
817
818
|
unitId,
|
|
818
819
|
subUnitId,
|
|
819
|
-
|
|
820
|
+
"order",
|
|
820
821
|
this._getDrawingOrder(unitId, subUnitId).indexOf(drawingId)
|
|
821
822
|
], true)].reduce(json1.type.compose, null);
|
|
822
823
|
return {
|
|
@@ -847,7 +848,7 @@ var UnitDrawingService = class {
|
|
|
847
848
|
ops.push(json1.replaceOp([
|
|
848
849
|
unitId,
|
|
849
850
|
subUnitId,
|
|
850
|
-
|
|
851
|
+
"data",
|
|
851
852
|
drawingId,
|
|
852
853
|
key
|
|
853
854
|
], oldVal, newVal));
|
|
@@ -912,7 +913,7 @@ var ImageIoService = class {
|
|
|
912
913
|
this._decreaseWaiting();
|
|
913
914
|
return;
|
|
914
915
|
}
|
|
915
|
-
if (imageFile.size >
|
|
916
|
+
if (imageFile.size > getDrawingImageAllowSize()) {
|
|
916
917
|
reject(new Error(ImageUploadStatusType.ERROR_EXCEED_SIZE));
|
|
917
918
|
this._decreaseWaiting();
|
|
918
919
|
return;
|
|
@@ -977,7 +978,7 @@ var URLImageService = class extends Disposable {
|
|
|
977
978
|
};
|
|
978
979
|
|
|
979
980
|
//#endregion
|
|
980
|
-
//#region \0@oxc-project+runtime@0.
|
|
981
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
|
|
981
982
|
function __decorateParam(paramIndex, decorator) {
|
|
982
983
|
return function(target, key) {
|
|
983
984
|
decorator(target, key, paramIndex);
|
|
@@ -985,7 +986,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
985
986
|
}
|
|
986
987
|
|
|
987
988
|
//#endregion
|
|
988
|
-
//#region \0@oxc-project+runtime@0.
|
|
989
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
|
|
989
990
|
function __decorate(decorators, target, key, desc) {
|
|
990
991
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
991
992
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1004,6 +1005,7 @@ let UniverDrawingPlugin = class UniverDrawingPlugin extends Plugin {
|
|
|
1004
1005
|
this._commandService = _commandService;
|
|
1005
1006
|
const { ...rest } = merge({}, defaultPluginConfig, this._config);
|
|
1006
1007
|
this._configService.setConfig(DRAWING_PLUGIN_CONFIG_KEY, rest);
|
|
1008
|
+
if (rest.allowImageSize !== void 0) setDrawingImageAllowSize(rest.allowImageSize);
|
|
1007
1009
|
}
|
|
1008
1010
|
onStarting() {
|
|
1009
1011
|
this._initCommands();
|
|
@@ -1056,4 +1058,4 @@ const getImageSize = async (src) => {
|
|
|
1056
1058
|
};
|
|
1057
1059
|
|
|
1058
1060
|
//#endregion
|
|
1059
|
-
export { DRAWING_IMAGE_ALLOW_IMAGE_LIST,
|
|
1061
|
+
export { DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, DrawingManagerService, IDrawingManagerService, IImageIoService, ImageIoService, ImageSourceType, ImageUploadStatusType, SetDrawingSelectedOperation, URLImageService, UnitDrawingService, UniverDrawingPlugin, getDrawingImageAllowSize, getDrawingShapeKeyByDrawingSearch, getImageSize };
|
|
@@ -16,5 +16,6 @@
|
|
|
16
16
|
export declare const DRAWING_IMAGE_WIDTH_LIMIT = 500;
|
|
17
17
|
export declare const DRAWING_IMAGE_HEIGHT_LIMIT = 500;
|
|
18
18
|
export declare const DRAWING_IMAGE_COUNT_LIMIT = 10;
|
|
19
|
-
export declare
|
|
19
|
+
export declare function setDrawingImageAllowSize(size: number): void;
|
|
20
|
+
export declare function getDrawingImageAllowSize(): number;
|
|
20
21
|
export declare const DRAWING_IMAGE_ALLOW_IMAGE_LIST: string[];
|
|
@@ -18,5 +18,10 @@ export declare const DRAWING_PLUGIN_CONFIG_KEY = "drawing.config";
|
|
|
18
18
|
export declare const configSymbol: unique symbol;
|
|
19
19
|
export interface IUniverDrawingConfig {
|
|
20
20
|
override?: DependencyOverride;
|
|
21
|
+
/**
|
|
22
|
+
* The maximum allowed size of uploaded images in bytes.
|
|
23
|
+
* @default 5 * 1024 * 1024 (5MB)
|
|
24
|
+
*/
|
|
25
|
+
allowImageSize?: number;
|
|
21
26
|
}
|
|
22
27
|
export declare const defaultPluginConfig: IUniverDrawingConfig;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export { DRAWING_IMAGE_ALLOW_IMAGE_LIST,
|
|
16
|
+
export { DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, getDrawingImageAllowSize } from './basics/config';
|
|
17
17
|
export { SetDrawingSelectedOperation } from './commands/operations/set-drawing-selected.operation';
|
|
18
18
|
export type { IUniverDrawingConfig } from './config/config';
|
|
19
19
|
export type { IDocFloatDomData, IDocFloatDomDataBase, IImageData } from './models/image-model-interface';
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDrawing={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e));let f=[`image/png`,`image/jpeg`,`image/jpg`,`image/gif`,`image/bmp`],p=(0,t.createIdentifier)(`univer.drawing-manager.service`),m={id:`drawing.operation.set-drawing-selected`,type:t.CommandType.OPERATION,handler:(e,t)=>{let n=e.get(p);return t==null?!1:(n.focusDrawing(t),!0)}};var h=`@univerjs/drawing`,g=`0.21.1`;let _=`drawing.config`;Symbol(_);let v={};var y=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e,t){if(Array.isArray(t))return!1;for(let n in e)if(!r(e[n],t[n]))return!1;for(let n in t)if(e[n]===void 0)return!1;return!0}function n(e,t){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}function r(e,r){return e===r?!0:e===null||r===null||typeof e!=`object`||typeof r!=`object`?!1:Array.isArray(e)?n(e,r):t(e,r)}e.default=r})),b=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){if(e===null)return null;if(Array.isArray(e))return e.map(t);if(typeof e==`object`){let n={};for(let r in e)n[r]=t(e[r]);return n}else return e}e.default=t})),x=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function t(e,t){if(!e)throw Error(t)}let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=(e,t)=>typeof e==typeof t?e>t:typeof e==`string`&&typeof t==`number`;function i(e,t){for(let n in e){let r=n;t.write(r,e[r])}}e.isValidPathItem=e=>typeof e==`number`||typeof e==`string`&&e!==`__proto__`;var a=class{constructor(e=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=e}ascend(){t(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):(t(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){let e=[],t=this.container,r=this.parents.length-1,i=this.idx;for(;i>=0;)e.unshift(t[i]),i===0?(i=this.indexes[r*2],t=this.parents[r--]):i-=n(t[i-1])?2:1;return e}},o=class e extends a{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return t(this.container!=null,`Invalid call to getKey before cursor descended`),this.container[this.idx]}getComponent(){let e;return this.container&&this.container.length>this.idx+1&&n(e=this.container[this.idx+1])?e:null}descendFirst(){let e=this.idx+1;if(!this.container||e>=this.container.length||n(this.container[e])&&e+1>=this.container.length)return!1;n(this.container[e])&&e++;let t=this.container[e];return Array.isArray(t)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(e),this.idx=0,this.container=t):this.idx=e,!0}nextSibling(){if(t(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;let e=this.indexes[this.indexes.length-1]+1,n=this.parents[this.parents.length-1];return e>=n.length?!1:(t(!isNaN(e)),this.indexes[this.indexes.length-1]=e,this.container=n[e],!0)}_init(e,t,n,r){this.container=e,this.idx=t,this.parents=n.slice(),this.indexes=r.slice()}clone(){let t=new e;return t._init(this.container,this.idx,this.parents,this.indexes),t}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(e,t){let n=this.getComponent();n&&t(n,e);for(let n of this)e&&e.descend(n),this.traverse(e,t),e&&e.ascend()}eachPick(e,t){this.traverse(e,(e,n)=>{e.p!=null&&t(e.p,n)})}eachDrop(e,t){this.traverse(e,(e,n)=>{e.d!=null&&t(e.d,n)})}};e.ReadCursor=o;var s=class extends a{constructor(e=null){super(e),this.pendingDescent=[],this._op=e}flushDescent(){t(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let e=0;e<this.pendingDescent.length;e++){let i=this.pendingDescent[e],a=this.idx+1;if(a<this.container.length&&n(this.container[a])&&a++,t(a===this.container.length||!n(this.container[a])),a===this.container.length)this.container.push(i),this.idx=a;else if(this.container[a]===i)this.idx=a;else{if(!Array.isArray(this.container[a])){let e=this.container.splice(a,this.container.length-a);this.container.push(e),this.lcIdx>-1&&(this.lcIdx=a)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(i,this.container[this.lcIdx][0])),a=this.lcIdx+1,this.lcIdx=-1);a<this.container.length&&r(i,this.container[a][0]);)a++;if(this.indexes.push(a),this.idx=0,a<this.container.length&&this.container[a][0]===i)this.container=this.container[a];else{let e=[i];this.container.splice(a,0,e),this.container=e}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();let e=this.idx+1;if(e<this.container.length&&n(this.container[e]))return this.container[e];{let t={};return this.container.splice(e,0,t),t}}write(e,n){let r=this.getComponent();t(r[e]==null||r[e]===n,`Internal consistency error: Overwritten component. File a bug`),r[e]=n}get(){return this._op}descend(t){if(!e.isValidPathItem(t))throw Error(`Invalid JSON key`);this.pendingDescent.push(t)}descendPath(e){return this.pendingDescent.push(...e),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(e,n=i){if(e===null)return;if(t(Array.isArray(e)),e===this._op)throw Error(`Cannot merge into my own tree`);let r=this.lcIdx,a=this.parents.length,o=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`||typeof r==`number`?(o++,this.descend(r)):Array.isArray(r)?this.mergeTree(r,n):typeof r==`object`&&n(r,this)}for(;o--;)this.ascend();this.lcIdx=this.parents.length===a?r:-1}at(e,t){this.descendPath(e),t(this);for(let t=0;t<e.length;t++)this.ascend();return this}writeAtPath(e,t,n){return this.at(e,()=>this.write(t,n)),this.reset(),this}writeMove(e,t,n=0){return this.writeAtPath(e,`p`,n).writeAtPath(t,`d`,n)}getPath(){let e=super.getPath();return e.push(...this.pendingDescent),e}};e.WriteCursor=s,e.writeCursor=()=>new s,e.readCursor=e=>new o(e);function c(e,t,n){let i,a;a=i=e?e.descendFirst():!1;function o(i){let o;for(;a;){let s=o=e.getKey();if(i!=null){let n=!1;if(t&&typeof s==`number`&&(o=t(s,e.getComponent()),o<0&&(o=~o,n=!0)),r(o,i))return null;if(o===i&&!n)return e}n&&typeof o==`number`&&n(o,e.getComponent()),a=e.nextSibling()}return null}return o.end=()=>{i&&e.ascend()},o}e.advancer=c;function l(e,t,n){let i,a,o,s;for(i=a=e&&e.descendFirst(),o=s=t&&t.descendFirst();i||o;){let a=i?e.getKey():null,s=o?t.getKey():null;a!==null&&s!==null&&(r(s,a)?s=null:a!==s&&(a=null)),n(a==null?s:a,a==null?null:e,s==null?null:t),a!=null&&i&&(i=e.nextSibling()),s!=null&&o&&(o=t.nextSibling())}a&&e.ascend(),s&&t.ascend()}e.eachChildOf=l})),S=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ConflictType=void 0,(function(e){e[e.RM_UNEXPECTED_CONTENT=1]=`RM_UNEXPECTED_CONTENT`,e[e.DROP_COLLISION=2]=`DROP_COLLISION`,e[e.BLACKHOLE=3]=`BLACKHOLE`})(e.ConflictType||(e.ConflictType={}))})),C=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.uniToStrPos=e.strPosToUni=void 0,e.strPosToUni=(e,t=e.length)=>{let n=0,r=0;for(;r<t;r++){let t=e.charCodeAt(r);t>=55296&&t<=57343&&(n++,r++)}if(r!==t)throw Error(`Invalid offset - splits unicode bytes`);return r-n},e.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){let t=e.charCodeAt(n);n+=t>=55296&&t<=57343?2:1}return n}})),w=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;let t=C(),n=t=>{if(!Array.isArray(t))throw Error(`Op must be an array of components`);let n=null;for(let r=0;r<t.length;r++){let i=t[r];switch(typeof i){case`object`:if(typeof i.d!=`number`&&typeof i.d!=`string`)throw Error(`Delete must be number or string`);if(e.dlen(i.d)<=0)throw Error(`Deletes must not be empty`);break;case`string`:if(!(i.length>0))throw Error(`Inserts cannot be empty`);break;case`number`:if(!(i>0))throw Error(`Skip components must be >0`);if(typeof n==`number`)throw Error(`Adjacent skip components should be combined`);break}n=i}if(typeof n==`number`)throw Error(`Op has a trailing skip`)};function r(n,r){let i=0,a=0;for(let o=0;o<n.length;o++){let s=n[o];switch(r(s,i,a),typeof s){case`object`:i+=e.dlen(s.d);break;case`string`:a+=t.strPosToUni(s);break;case`number`:i+=s,a+=s;break}}}e.eachOp=r;function i(e,t){let n=[],i=s(n);return r(e,(e,n,r)=>{i(t(e,n,r))}),d(n)}let a=e=>e,o=e=>i(e,a);e.dlen=e=>typeof e==`number`?e:t.strPosToUni(e);let s=t=>n=>{if(!(!n||n.d===0||n.d===``))if(t.length===0)t.push(n);else if(typeof n==typeof t[t.length-1])if(typeof n==`object`){let r=t[t.length-1];r.d=typeof r.d==`string`&&typeof n.d==`string`?r.d+n.d:e.dlen(r.d)+e.dlen(n.d)}else t[t.length-1]+=n;else t.push(n)},c=e=>typeof e==`number`?e:typeof e==`string`?t.strPosToUni(e):typeof e.d==`number`?e.d:t.strPosToUni(e.d);e.uniSlice=(e,n,r)=>{let i=t.uniToStrPos(e,n),a=r==null?1/0:t.uniToStrPos(e,r);return e.slice(i,a)};let l=(t,n,r)=>typeof t==`number`?r==null?t-n:Math.min(t,r)-n:e.uniSlice(t,n,r),u=n=>{let r=0,i=0;return{take:(a,o)=>{if(r===n.length)return a===-1?null:a;let s=n[r],c;if(typeof s==`number`)return a===-1||s-i<=a?(c=s-i,++r,i=0,c):(i+=a,a);if(typeof s==`string`){if(a===-1||o===`i`||t.strPosToUni(s.slice(i))<=a)return c=s.slice(i),++r,i=0,c;{let e=i+t.uniToStrPos(s.slice(i),a);return c=s.slice(i,e),i=e,c}}else if(a===-1||o===`d`||e.dlen(s.d)-i<=a)return c={d:l(s.d,i)},++r,i=0,c;else{let e=l(s.d,i,i+a);return i+=a,{d:e}}},peek:()=>n[r]}},d=e=>(e.length>0&&typeof e[e.length-1]==`number`&&e.pop(),e);function f(r,i,a){if(a!==`left`&&a!==`right`)throw Error(`side (`+a+`) must be 'left' or 'right'`);n(r),n(i);let o=[],l=s(o),{take:f,peek:p}=u(r);for(let n=0;n<i.length;n++){let r=i[n],o,s;switch(typeof r){case`number`:for(o=r;o>0;)s=f(o,`i`),l(s),typeof s!=`string`&&(o-=c(s));break;case`string`:a===`left`&&typeof p()==`string`&&l(f(-1)),l(t.strPosToUni(r));break;case`object`:for(o=e.dlen(r.d);o>0;)switch(s=f(o,`i`),typeof s){case`number`:o-=s;break;case`string`:l(s);break;case`object`:o-=e.dlen(s.d)}break}}let m;for(;m=f(-1);)l(m);return d(o)}function p(r,i){n(r),n(i);let a=[],o=s(a),{take:f}=u(r);for(let n=0;n<i.length;n++){let r=i[n],a,s;switch(typeof r){case`number`:for(a=r;a>0;)s=f(a,`d`),o(s),typeof s!=`object`&&(a-=c(s));break;case`string`:o(r);break;case`object`:a=e.dlen(r.d);let n=0;for(;n<a;)switch(s=f(a-n,`d`),typeof s){case`number`:o({d:l(r.d,n,n+s)}),n+=s;break;case`string`:n+=t.strPosToUni(s);break;case`object`:o(s)}break}}let p;for(;p=f(-1);)o(p);return d(a)}let m=(n,r)=>{let i=0;for(let a=0;a<r.length&&n>i;a++){let o=r[a];switch(typeof o){case`number`:i+=o;break;case`string`:let r=t.strPosToUni(o);i+=r,n+=r;break;case`object`:n-=Math.min(e.dlen(o.d),n-i);break}}return n},h=(e,t)=>typeof e==`number`?m(e,t):e.map(e=>m(e,t));function g(e,t,n){return i(e,(e,r)=>typeof e==`object`&&typeof e.d==`number`?{d:n.slice(t,r,r+e.d)}:e)}function _(e){return i(e,e=>{switch(typeof e){case`object`:if(typeof e.d==`number`)throw Error(`Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.`);return e.d;case`string`:return{d:e};case`number`:return e}})}function v(e){return i(e,e=>typeof e==`object`&&typeof e.d==`string`?{d:t.strPosToUni(e.d)}:e)}function y(e){let t=!0;return r(e,e=>{typeof e==`object`&&typeof e.d==`number`&&(t=!1)}),t}function b(t){return{name:`text-unicode`,uri:`http://sharejs.org/types/text-unicode`,trim:d,normalize:o,checkOp:n,create(e=``){if(typeof e!=`string`)throw Error(`Initial data must be a string`);return t.create(e)},apply(r,i){n(i);let a=t.builder(r);for(let t=0;t<i.length;t++){let n=i[t];switch(typeof n){case`number`:a.skip(n);break;case`string`:a.append(n);break;case`object`:a.del(e.dlen(n.d));break}}return a.build()},transform:f,compose:p,transformPosition:m,transformSelection:h,isInvertible:y,makeInvertible(e,n){return g(e,n,t)},stripInvertible:v,invert:_,invertWithDoc(e,n){return _(g(e,n,t))},isNoop:e=>e.length===0}}e.default=b})),T=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(),n=C();function r(e,r){return{get:e,getLength(){return e().length},insert(t,i,a){return r([n.strPosToUni(e(),t),i],a)},remove(t,i,a){return r([n.strPosToUni(e(),t),{d:i}],a)},_onOp(e){t.eachOp(e,(e,n,r)=>{switch(typeof e){case`string`:this.onInsert&&this.onInsert(r,e);break;case`object`:let n=t.dlen(e.d);this.onRemove&&this.onRemove(r,n)}})},onInsert:null,onRemove:null}}e.default=r,r.provides={text:!0}})),E=l((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)Object.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.type=e.remove=e.insert=void 0;let a=C(),o=r(w()),s=i(T()),c={create(e){return e},toString(e){return e},builder(e){if(typeof e!=`string`)throw Error(`Invalid document snapshot: `+e);let t=[];return{skip(n){let r=a.uniToStrPos(e,n);if(r>e.length)throw Error(`The op is too long for this document`);t.push(e.slice(0,r)),e=e.slice(r)},append(e){t.push(e)},del(t){e=e.slice(a.uniToStrPos(e,t))},build(){return t.join(``)+e}}},slice:o.uniSlice},l=o.default(c);e.type=Object.assign(Object.assign({},l),{api:s.default}),e.insert=(e,t)=>t.length===0?[]:e===0?[t]:[e,t],e.remove=(e,t)=>o.dlen(t)===0?[]:e===0?[{d:t}]:[e,{d:t}];var u=w();Object.defineProperty(e,`makeType`,{enumerable:!0,get:function(){return u.default}})})),D=l((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;let n=t(y()),r=t(b()),i=x(),a=S(),o=()=>{};function s(e,t){if(!e)throw Error(t)}let c=!1;e.type={name:`json1`,uri:`http://sharejs.org/types/JSONv1`,readCursor:i.readCursor,writeCursor:i.writeCursor,create:e=>e,isNoop:e=>e==null,setDebug(e){c=e,o.quiet=!e},registerSubtype:C,checkValidOp:M,normalize:N,apply:P,transformPosition:F,compose:I,tryTransform:H,transform:W,makeInvertible:z,invert:L,invertWithDoc:B,RM_UNEXPECTED_CONTENT:a.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:a.ConflictType.DROP_COLLISION,BLACKHOLE:a.ConflictType.BLACKHOLE,transformNoConflict:(e,t,n)=>q(()=>!0,e,t,n),typeAllowingConflictsPred:t=>Object.assign(Object.assign({},e.type),{transform:(e,n,r)=>q(t,e,n,r)})};let l=e=>e?e.getComponent():null;function u(e){return e&&typeof e==`object`&&!Array.isArray(e)}let d=e=>Array.isArray(e)?e.slice():typeof e==`object`&&e?Object.assign({},e):e,f=e=>e&&(e.p!=null||e.r!==void 0),p=e=>e&&(e.d!=null||e.i!==void 0);function m(e,t){return s(e!=null),typeof t==`number`?(s(Array.isArray(e),`Invalid key - child is not an array`),(e=e.slice()).splice(t,1)):(s(u(e),`Invalid key - child is not an object`),delete(e=Object.assign({},e))[t]),e}function h(e,t,n){return typeof t==`number`?(s(e!=null,`Container is missing for key`),s(Array.isArray(e),`Cannot use numerical key for object container`),s(e.length>=t,`Cannot insert into out of bounds index`),e.splice(t,0,n)):(s(u(e),`Cannot insert into missing item`),s(e[t]===void 0,`Trying to overwrite value at key. Your op needs to remove it first`),e[t]=n),n}e.removeOp=(e,t=!0)=>i.writeCursor().writeAtPath(e,`r`,t).get(),e.moveOp=(e,t)=>i.writeCursor().writeMove(e,t).get(),e.insertOp=(e,t)=>i.writeCursor().writeAtPath(e,`i`,t).get(),e.replaceOp=(e,t,n)=>i.writeCursor().at(e,e=>{e.write(`r`,t),e.write(`i`,n)}).get(),e.editOp=(e,t,n,r=!1)=>i.writeCursor().at(e,e=>k(e,t,n,r)).get();let g=(e,t)=>e!=null&&(typeof t==`number`?Array.isArray(e):typeof e==`object`),_=(e,t)=>g(e,t)?e[t]:void 0,v={};function C(e){let t=e.type?e.type:e;t.name&&(v[t.name]=t),t.uri&&(v[t.uri]=t)}let w=e=>{let t=v[e];if(t)return t;throw Error(`Missing type: `+e)};C(E());let T=(e,t)=>e+t;C({name:`number`,apply:T,compose:T,invert:e=>-e,transform:e=>e});let D=e=>e==null?null:e.et?w(e.et):e.es?v[`text-unicode`]:e.ena==null?null:v.number,O=e=>e.es?e.es:e.ena==null?e.e:e.ena,k=(e,t,n,r=!1)=>{let[i,a]=typeof t==`string`?[w(t),t]:[t,t.name];!r&&i.isNoop&&i.isNoop(n)||(a===`number`?e.write(`ena`,n):a===`text-unicode`?e.write(`es`,n):(e.write(`et`,a),e.write(`e`,n)))};function A(e){s(typeof e==`number`),s(e>=0),s(e===(0|e))}function j(e){typeof e==`number`?A(e):s(typeof e==`string`)}function M(e){if(e===null)return;let t=new Set,n=new Set,r=e=>{let r=!0,i=!1;for(let a in e){let o=e[a];if(r=!1,s(a===`p`||a===`r`||a===`d`||a===`i`||a===`e`||a===`es`||a===`ena`||a===`et`,`Invalid component item '`+a+`'`),a===`p`)A(o),s(!t.has(o)),t.add(o),s(e.r===void 0);else if(a===`d`)A(o),s(!n.has(o)),n.add(o),s(e.i===void 0);else if(a===`e`||a===`es`||a===`ena`){s(!i),i=!0;let t=D(e);s(t,`Missing type in edit`),t.checkValidOp&&t.checkValidOp(O(e))}}s(!r)},a=(e,t,n)=>{if(!Array.isArray(e))throw Error(`Op must be null or a list`);if(e.length===0)throw Error(`Empty descent`);t||j(e[0]);let o=1,c=0,l=0;for(let t=0;t<e.length;t++){let u=e[t];if(s(u!=null),Array.isArray(u)){let e=a(u,!1,n);if(c){let t=typeof l,n=typeof e;t===n?s(l<e,`descent keys are not in order`):s(t===`number`&&n===`string`)}l=e,c++,o=3}else typeof u==`object`?(s(o===1,`Prev not scalar - instead ${o}`),r(u),o=2):(s(o!==3),j(u),s(i.isValidPathItem(u),`Invalid path key`),o=1)}return s(c!==1,`Operation makes multiple descents. Remove some []`),s(o===2||o===3),e[0]};a(e,!0,!1),s(t.size===n.size,`Mismatched picks and drops in op`);for(let e=0;e<t.size;e++)s(t.has(e)),s(n.has(e))}function N(e){let t=0,n=[],r=i.writeCursor();return r.mergeTree(e,(e,r)=>{let i=D(e);if(i){let t=O(e);k(r,i,i.normalize?i.normalize(t):t)}for(let i of[`r`,`p`,`i`,`d`])if(e[i]!==void 0){let o=i===`p`||i===`d`?(a=e[i],n[a]==null&&(n[a]=t++),n[a]):e[i];r.write(i,o)}var a}),r.get()}function P(e,t){if(o.quiet=!c,M(t),t===null)return e;let n=[];return function e(t,r){let i=t,a=0,o={root:t},c=0,l=o,u=`root`;function f(){for(;c<a;c++){let e=r[c];typeof e!=`object`&&(s(g(l,u)),l=l[u]=d(l[u]),u=e)}}for(;a<r.length;a++){let t=r[a];if(Array.isArray(t)){let n=e(i,t);n!==i&&n!==void 0&&(f(),i=l[u]=n)}else if(typeof t==`object`){t.d==null?t.i!==void 0&&(f(),i=h(l,u,t.i)):(f(),i=h(l,u,n[t.d]));let e=D(t);if(e)f(),i=l[u]=e.apply(i,O(t));else if(t.e!==void 0)throw Error(`Subtype `+t.et+` undefined`)}else i=_(i,t)}return o.root}(e=function e(t,r){let i=[],a=0;for(;a<r.length;a++){let e=r[a];if(Array.isArray(e))break;typeof e!=`object`&&(i.push(t),t=_(t,e))}for(let n=r.length-1;n>=a;n--)t=e(t,r[n]);for(--a;a>=0;a--){let e=r[a];if(typeof e!=`object`){let n=i.pop();t=t===_(n,e)?n:t===void 0?m(n,e):(c=e,l=t,(o=d(o=n))[c]=l,o)}else f(e)&&(s(t!==void 0,`Cannot pick up or remove undefined`),e.p!=null&&(n[e.p]=t),t=void 0)}var o,c,l;return t}(e,t),t)}function F(e,t){e=e.slice(),M(t);let n=i.readCursor(t),r,a,o=!1,s=[];for(let t=0;;t++){let c=e[t],l=n.getComponent();if(l&&(l.r===void 0?l.p!=null&&(o=!1,r=l.p,a=t):o=!0),t>=e.length)break;let u=0,d=i.advancer(n,void 0,(e,t)=>{f(t)&&u++});s.unshift(d);let p=d(c);if(typeof c==`number`&&(e[t]-=u),!p)break}if(s.forEach(e=>e.end()),o)return null;let c=()=>{let t=0;if(r!=null){let r=n.getPath();t=r.length,e=r.concat(e.slice(a))}for(;t<e.length;t++){let r=e[t],a=l(n),o=D(a);if(o){let n=O(a);o.transformPosition&&(e[t]=o.transformPosition(e[t],n));break}let s=0,c=i.advancer(n,(e,t)=>p(t)?~(e-s):e-s,(e,t)=>{p(t)&&s++})(r);if(typeof r==`number`&&(e[t]+=s),!c)break}};return r==null?c():n.eachDrop(null,e=>{e===r&&c()}),e}function I(e,t){if(M(e),M(t),e==null)return t;if(t==null)return e;let n=0,r=i.readCursor(e),a=i.readCursor(t),o=i.writeCursor(),c=[],u=[],d=[],m=[],h=[],g=[],_=new Set;r.traverse(null,e=>{e.p!=null&&(d[e.p]=r.clone())}),a.traverse(null,e=>{e.d!=null&&(m[e.d]=a.clone())});let v=i.writeCursor();return function e(t,r,a,o,v,y,b,x){s(r||a);let S=l(r),C=l(a),w=!!C&&C.r!==void 0,T=!!S&&S.i!==void 0,E=S?S.d:null,A=C?C.p:null,j=(y||w)&&A==null;if(A!=null)o=m[A],b=u[A]=new i.WriteCursor;else if(C&&C.r!==void 0)o=null;else{let e=l(o);e&&e.d!=null&&(o=null)}let M=l(o);if(E!=null)if(t=d[E],x=c[E]=new i.WriteCursor,j)y&&!w&&x.write(`r`,!0);else{let e=h[E]=n++;b.write(`d`,e)}else if(S&&S.i!==void 0)t=null;else{let e=l(t);e&&e.p!=null&&(t=null)}let N;T?(s(v===void 0),N=S.i):N=v;let P=(A==null?!T||y||w:N===void 0)?null:b.getComponent();if(A!=null){if(!(v!==void 0||T)){let e=E==null?n++:h[E];g[A]=e,x.write(`p`,e)}}else w&&(T||v!==void 0||(C.r,x.write(`r`,C.r)));let F=j?null:D(S),I=D(M);if((F||I)&&(F&&F.name,I&&I.name),F&&I){s(F===I);let e=O(S),t=O(M),n=F.compose(e,t);k(b,F,n),_.add(M)}else F?k(b,F,O(S)):I&&(k(b,I,O(M)),_.add(M));let L=typeof N==`object`&&!!N,R=!1,z=0,B=0,V=0,H=0,U=0,W=i.advancer(o,(e,t)=>p(t)?H-e-1:e-H,(e,t)=>{p(t)&&H++}),G=i.advancer(t,(e,t)=>f(t)?z-e-1:e-z,(e,t)=>{f(t)&&z++});if(i.eachChildOf(r,a,(t,n,r)=>{let i,a,o=t,c=t,u=t;if(typeof t==`number`){let e=t+V;a=W(e),c=e+H;let d=t+B;i=G(d),p(l(a))&&(i=null),o=d+z,u=t+U,s(o>=0,`p1PickKey is negative`),s(c>=0,`p2DropKey is negative`);let m=p(l(n)),h=f(l(r));(m||h&&!j)&&U--,m&&B--,h&&V--}else i=G(t),a=W(t);x.descend(o),b.descend(c);let d=L&&!p(l(n))?N[u]:void 0,m=e(i,n,r,a,d,j,b,x);var h,g,_;L&&!j?d!==m&&(R||(N=Array.isArray(N)?N.slice():Object.assign({},N),R=!0),h=N,_=m,typeof(g=u)==`number`?(s(Array.isArray(h)),s(g<h.length)):(s(!Array.isArray(h)),s(h[g]!==void 0)),_===void 0?typeof g==`number`?h.splice(g,1):delete h[g]:h[g]=_):s(m===void 0),b.ascend(),x.ascend()}),G.end(),W.end(),P!=null)P.i=N;else if(!y&&!w&&A==null)return N}(r,r.clone(),a,a.clone(),void 0,!1,o,v),o.reset(),o.mergeTree(v.get()),o.reset(),o.get(),c.map(e=>e.get()),u.map(e=>e.get()),r.traverse(o,(e,t)=>{let n=e.p;if(n!=null){let e=h[n];e!=null&&t.write(`p`,e);let r=c[n];r&&r.get(),r&&t.mergeTree(r.get())}else e.r!==void 0&&t.write(`r`,e.r)}),o.reset(),o.get(),a.traverse(o,(e,t)=>{let n=e.d;if(n!=null){let e=g[n];e!=null&&t.write(`d`,e);let r=u[n];r&&t.mergeTree(r.get())}else e.i!==void 0&&t.write(`i`,e.i);let r=D(e);r&&!_.has(e)&&k(t,r,O(e))}),o.get()}function L(e){if(e==null)return null;let t=new i.ReadCursor(e),n=new i.WriteCursor,r,a=[],o=[];return function e(t,n,i){let o=t.getComponent(),s,c=!1;if(o){o.p!=null&&(n.write(`d`,o.p),a[o.p]=t.clone()),o.r!==void 0&&n.write(`i`,o.r),o.d!=null&&(n.write(`p`,o.d),i=void 0),o.i!==void 0&&(i=s=o.i);let e=D(o);e&&(i===void 0?(r||(r=new Set),r.add(o)):(O(o),i=e.apply(i,O(o)),c=!0))}let l=0;for(let r of t){n.descend(r);let a=typeof r==`number`?r-l:r,o=_(i,a);p(t.getComponent())&&l++;let s=e(t,n,o);if(i!==void 0&&s!==void 0){if(c||(c=!0,i=d(i)),!g(i,a))throw Error(`Cannot modify child - invalid operation`);i[a]=s}n.ascend()}if(s===void 0)return c?i:void 0;n.write(`r`,i)}(t,n,void 0),r&&(n.reset(),function e(t,n,s){let c=n.getComponent();if(c){let e=c.d;if(e!=null&&(t=a[e],s=o[e]=i.writeCursor()),r.has(c)){let e=D(c);if(!e.invert)throw Error(`Cannot invert subtype ${e.name}`);k(s,e,e.invert(O(c)))}}let l=0,u=0,d=i.advancer(t,(e,t)=>f(t)?l-e-1:e-l,(e,t)=>{f(t)&&l++});for(let t of n)if(typeof t==`number`){let r=t-u,i=d(r),a=r+l;s.descend(a),e(i,n,s),p(n.getComponent())&&u++,s.ascend()}else s.descend(t),e(d(t),n,s),s.ascend();d.end()}(t.clone(),t,n),o.length&&(n.reset(),t.traverse(n,(e,t)=>{let n=e.p;if(n!=null){let e=o[n];e&&e.get(),e&&t.mergeTree(e.get())}}))),n.get()}let R=(e,t)=>e.some(e=>typeof e==`object`&&(Array.isArray(e)?R(e,t):t(e)));function z(e,t){if(e==null||!R(e,e=>{var t;return e.r!==void 0||((t=D(e))==null?void 0:t.makeInvertible)!=null}))return e;let n=new i.ReadCursor(e),a=new i.WriteCursor,o=!1,c=[],l=[],u=(e,t,n)=>{let i=e.getComponent(),a=!1;if(i){i.d!=null&&t.write(`d`,i.d),i.i!==void 0&&t.write(`i`,i.i);let r=i.p;if(r!=null&&(c[r]=e.clone(),s(n!==void 0,`Operation picks up at an invalid key`),l[r]=n,t.write(`p`,i.p)),i.r!==void 0&&n===void 0)throw Error(`Invalid doc / op in makeInvertible: removed item missing from doc`);let a=D(i);a&&(a.makeInvertible?o=!0:k(t,a,O(i),!0))}let f=0;for(let r of e){t.descend(r);let i=typeof r==`number`?r-f:r,o=_(n,i),s=u(e,t,o);o!==s&&(a||(a=!0,n=d(n)),s===void 0?(n=m(n,i),typeof r==`number`&&f++):n[i]=s),t.ascend()}return i&&(i.r===void 0?i.p!=null&&(n=void 0):(t.write(`r`,r.default(n)),n=void 0)),n};return u(n,a,t),a.get(),o&&(a.reset(),function e(t,n,r,a,o){let s=n.getComponent();if(s){s.i===void 0?s.d!=null&&(a=l[s.d],t=c[s.d],o=!1,s.d):(a=s.i,o=!0);let e=D(s);if(e&&e.makeInvertible){let t=O(s);k(r,e,e.makeInvertible(t,a),!0)}}let u=0,d=0,m=i.advancer(t,(e,t)=>f(t)?u-e-1:e-u,(e,t)=>{f(t)&&u++});for(let t of n)if(typeof t==`number`){let i=t-d,s=m(i),c=i+u,l=_(a,o?i:c);r.descend(t),e(s,n,r,l,o),p(n.getComponent())&&d++,r.ascend()}else{let i=_(a,t);r.descend(t),e(m(t),n,r,i,o),r.ascend()}m.end()}(n.clone(),n,a,t,!1)),a.get()}function B(e,t){return L(z(e,t))}let V=e=>{if(e==null)return null;let t=e.slice();for(let n=0;n<e.length;n++){let e=t[n];Array.isArray(e)&&(t[n]=V(e))}return t};function H(t,u,d){s(d===`left`||d===`right`,`Direction must be left or right`);let m=d===`left`?0:1;if(o.quiet=!c,o.prefix=0,u==null)return{ok:!0,result:t};M(t),M(u);let h=null,g=[],_=[],v=[],y=[],b=[],x=[],S=[],C=[],w=[],T=[],E=[],A=[],j=[],N=[],P=[],F=0,I=i.readCursor(t),L=i.readCursor(u),R=i.writeCursor();if(function e(t,n=null,r){let a=l(n);a&&(a.r===void 0?a.p!=null&&(r=null,x[a.p]=t.clone()):r=n.clone());let o=t.getComponent(),s;o&&(s=o.p)!=null&&(b[s]=n?n.clone():null,v[s]=t.clone(),r&&(T[s]=!0,w[s]=r),a&&a.p!=null&&(N[s]=a.p));let c=i.advancer(n);for(let n of t)e(t,c(n),r);c.end()}(L,I,null),function t(n,r,o,s,c){let u=o.getComponent(),d,p=!1;u&&((d=u.d)==null?u.i!==void 0&&(n=r=null,p=!0,c&&h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.insertOp(o.getPath(),u.i)})):(y[d]=o.clone(),s!=null&&(P[s]==null&&(P[s]=[]),P[s].push(d)),T[d],n=b[d]||null,r=v[d]||null,T[d]?(c&&(E[d]=!0),c=w[d]||null):!c||m!==1&&N[d]!=null||h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.moveOp(r.getPath(),o.getPath())}),p=!0));let g=l(n);g&&(g.r===void 0?g.p!=null&&(g.p,s=g.p,c=null):c=n.clone());let _=D(u);_&&c&&h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.editOp(o.getPath(),_,O(u),!0)});let x=0,S=0,C=i.advancer(r,(e,t)=>f(t)?x-e-1:e-x,(e,t)=>{f(t)&&x++}),k=i.advancer(n);for(let e of o)if(typeof e==`number`){let n=e-S,r=C(n);S+=+t(k(n+x),r,o,s,c)}else{let n=C(e);t(k(e),n,o,s,c)}return C.end(),k.end(),p}(I,L,L.clone(),null,null),y.map(e=>e&&e.get()),h)return{ok:!1,conflict:h};E.map(e=>!!e);let z=[],B=null;(function e(t,n,r,a,o){let c=!1,u=l(n);if(f(u)){let e=u.p;e==null?(r=null,o=n.clone()):(r=y[e],a=A[e]=i.writeCursor(),c=!0,o=null)}else p(l(r))&&(r=null);let d=t.getComponent();if(d){let e=d.p;e==null?d.r!==void 0&&(o||a.write(`r`,!0),(o||c)&&(B==null&&(B=new Set),B.add(d))):(o&&(C[e]=o),z[e]=o||m===1&&c?null:a.getComponent(),g[e]=t.clone(),r&&(S[e]=r.clone()))}let h=0,_=0,v=i.advancer(n,void 0,(e,t)=>{f(t)&&h++}),b=i.advancer(r,(e,t)=>p(t)?~(e-_):e-_,(e,t)=>{p(t)&&_++});if(t)for(let n of t)if(typeof n==`string`){let r=v(n),i=b(n);a.descend(n),e(t,r,i,a,o),a.ascend()}else{let r=v(n),i=n-h,c=f(l(r))?null:b(i),u=i+_;s(u>=0),a.descend(u),e(t,r,c,a,o),a.ascend()}v.end(),b.end()})(I,L,L.clone(),R,null),R.reset();let H=[];if(function t(o,c,u,b,w,E){s(c);let A=c.getComponent(),M=l(b),P=!1,I=(t,n,r)=>t?e.moveOp(t.getPath(),n.getPath()):e.insertOp(n.getPath(),r.i);if(p(A)){let t=A.d;t!=null&&(_[t]=c.clone());let i=t==null?null:z[t],s=!1;if(A.i!==void 0||t!=null&&i){let o;M&&(M.i!==void 0||(o=M.d)!=null&&!T[o])&&(s=o==null?n.default(M.i,A.i):t!=null&&t===N[o],s||o!=null&&m!==1&&N[o]!=null||h==null&&(h={type:a.ConflictType.DROP_COLLISION,op1:I(t==null?null:g[t],c,A),op2:I(o==null?null:v[o],b,M)})),s||(E?h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:I(t==null?null:g[t],c,A),op2:e.removeOp(E.getPath())}):(t==null?w.write(`i`,r.default(A.i)):(H[F]=t,w.write(`d`,i.p=F++)),P=!0))}else if(t!=null&&!i){let e=C[t];e&&(E=e.clone())}t==null?A.i!==void 0&&(o=u=null,s||(b=null)):(o=g[t],u=x[t],b=S[t])}else f(l(o))&&(o=u=b=null);let L=l(o),R=l(u);if(f(R)){let e=R.p;R.r!==void 0&&(!L||L.r===void 0)||T[e]?(b=null,E=u.clone()):e!=null&&(b=y[e],m!==1&&N[e]!=null||((w=j[e])||(w=j[e]=i.writeCursor()),w.reset(),E=null))}else !p(A)&&p(M)&&(b=null);M=b==null?null:b.getComponent();let V=D(A);if(V){let t=O(A);if(E)h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(c.getPath(),V,t,!0),op2:e.removeOp(E.getPath())});else{let e=D(M),n;if(e){if(V!==e)throw Error(`Transforming incompatible types`);let r=O(M);n=V.transform(t,r,d)}else n=r.default(t);k(w,V,n)}}let U=0,W=0,G=0,K=0,q=0,J=0,Y=o!=null&&o.descendFirst(),X=Y,Z=i.advancer(u,void 0,(e,t)=>{f(t)&&G++}),Q=b!=null&&b.descendFirst(),$=Q;for(let e of c)if(typeof e==`number`){let n,r=p(c.getComponent()),i=e-W;{let e;for(;Y&&typeof(e=o.getKey())==`number`;){e+=U;let t=o.getComponent(),n=f(t);if(e>i||e===i&&(!n||m===0&&r))break;if(n){U--;let e=t.p;z[e],N.includes(e),t.d,l(j[t.d]),f(l(j[t.d])),(t.r===void 0||B&&B.has(t))&&(e==null||!z[e]||m!==1&&N.includes(e))||q--}Y=o.nextSibling()}n=Y&&e===i?o:null}let a=i-U,u=Z(a),d=a-G,h=null;{let e,t;for(;Q&&typeof(e=b.getKey())==`number`;){t=e-K;let n=b.getComponent(),i=p(n);if(t>d)break;if(t===d){if(!i){h=b;break}{if(m===0&&r){h=b;break}let e=u&&f(u.getComponent());if(m===0&&e)break}}if(i){let e=n.d;T[e],N[e],n.i===void 0&&(T[e]||N[e]!=null&&m!==1)?(T[e]||N[e]!=null&&m===0)&&(K++,J--):K++}Q=b.nextSibling()}}let g=d+K+q+J;s(g>=0,`trying to descend to a negative index`),w.descend(g),r&&(n=u=h=null,W++),t(n,c,u,h,w,E)&&J++,w.ascend()}else{let n;for(;Y&&(n=o.getKey(),typeof n!=`string`||!(n>e||n===e));)Y=o.nextSibling();let r=Y&&n===e?o:null,i=Z(e),a;for(;Q&&(a=b.getKey(),typeof a!=`string`||!(a>e||a===e));)Q=b.nextSibling();let s=Q&&a===e?b:null;w.descend(e),t(r,c,i,s,w,E),w.ascend()}return Z.end(),X&&o.ascend(),$&&b.ascend(),P}(I,I.clone(),L,L.clone(),R,null),h)return{ok:!1,conflict:h};R.reset();let U=(e,t,n)=>e.traverse(t,(t,r)=>{t.d!=null&&n(t.d,e,r)});(T.length||A.length)&&(U(L,R,(e,t,n)=>{T[e]&&!E[e]&&n.write(`r`,!0),A[e]&&n.mergeTree(A[e].get())}),R.reset());let W=[],G=[];if((j.length||T.length)&&!h){let e=i.readCursor(V(R.get()));if(U(e,null,(e,t)=>{W[e]=t.clone()}),j.forEach(e=>{e&&U(i.readCursor(e.get()),null,(e,t)=>{W[e]=t.clone()})}),function e(t,n,r,a,s,c){o.prefix++;let u=l(n);if(u&&f(u))if(u.p!=null){s=u;let e=u.p;W[e].getPath(),r=W[e],a=G[e]=i.writeCursor()}else u.r!==void 0&&(r=null,c=!0);else p(l(r))&&(r=null);let d=t.getComponent();if(d){let e;if((e=d.d)!=null){let t=j[e];t&&(t.get(),a.mergeTree(t.get()),r=i.readCursor(t.get()))}}let m=0,h=0,g=i.advancer(n,void 0,(e,t)=>{f(t)&&m--}),_=i.advancer(r,(e,t)=>p(t)?-(e-h)-1:e-h,(e,t)=>{p(t)&&h++});for(let n of t)if(typeof n==`number`){let r=g(n),i=n+m,o=_(i),l=i+h;a.descend(l),e(t,r,o,a,s,c),a.ascend()}else a.descend(n),e(t,g(n),_(n),a,s,c),a.ascend();g.end(),_.end()}(L,e,e.clone(),R,null,!1),R.reset(),h)return{ok:!1,conflict:h};if(R.get(),G.length){let e=G.map(e=>e?e.get():null);if(U(i.readCursor(V(R.get())),R,(t,n,r)=>{let i=e[t];i&&(r.mergeTree(i),e[t]=null)}),e.find(e=>e)){let t=i.writeCursor(),n=i.writeCursor(),r=0,o=0;e.forEach(e=>{e!=null&&U(i.readCursor(e),null,e=>{let i=H[e];t.writeMove(g[i].getPath(),_[i].getPath(),r++);let a=P[i];a&&a.forEach(e=>{T[e]||m!==1&&N[e]!=null||n.writeMove(v[e].getPath(),y[e].getPath(),o++)})})}),h={type:a.ConflictType.BLACKHOLE,op1:t.get(),op2:n.get()}}}}return h?{ok:!1,conflict:h}:{ok:!0,result:R.get()}}let U=e=>{let t=Error(`Transform detected write conflict`);throw t.conflict=e,t.type=t.name=`writeConflict`,t};function W(e,t,n){let r=H(e,t,n);if(r.ok)return r.result;U(r.conflict)}let G=e=>{let t=i.writeCursor();return i.readCursor(e).traverse(t,(e,t)=>{(p(e)||D(e))&&t.write(`r`,!0)}),t.get()},K=(e,t)=>{let{type:n,op1:r,op2:o}=e;switch(n){case a.ConflictType.DROP_COLLISION:return t===`left`?[null,G(o)]:[G(r),null];case a.ConflictType.RM_UNEXPECTED_CONTENT:let e=!1;return i.readCursor(r).traverse(null,t=>{t.r!==void 0&&(e=!0)}),e?[null,G(o)]:[G(r),null];case a.ConflictType.BLACKHOLE:return[G(r),G(o)];default:throw Error(`Unrecognised conflict: `+n)}};function q(e,t,n,r){let i=null;for(;;){let a=H(t,n,r);if(a.ok)return I(i,a.result);{let{conflict:o}=a;e(o)||U(o);let[s,c]=K(o,r);t=I(N(t),s),n=I(N(n),c),i=I(i,c)}}}})),O=d(l((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!n.hasOwnProperty(r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(D(),e);var r=x();Object.defineProperty(e,`ReadCursor`,{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,`WriteCursor`,{enumerable:!0,get:function(){return r.WriteCursor}});var i=S();Object.defineProperty(e,`ConflictType`,{enumerable:!0,get:function(){return i.ConflictType}})}))());function k(e){"@babel/helpers - typeof";return k=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},k(e)}function A(e,t){if(k(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(k(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function j(e){var t=A(e,`string`);return k(t)==`symbol`?t:t+``}function M(e,t,n){return(t=j(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var N=function(e){return e.data=`data`,e.order=`order`,e}(N||{}),P=class{constructor(){M(this,`drawingManagerData`,{}),M(this,`_oldDrawingManagerData`,{}),M(this,`_focusDrawings`,[]),M(this,`_remove$`,new n.Subject),M(this,`remove$`,this._remove$.asObservable()),M(this,`_add$`,new n.Subject),M(this,`add$`,this._add$.asObservable()),M(this,`_update$`,new n.Subject),M(this,`update$`,this._update$.asObservable()),M(this,`_order$`,new n.Subject),M(this,`order$`,this._order$.asObservable()),M(this,`_group$`,new n.Subject),M(this,`group$`,this._group$.asObservable()),M(this,`_ungroup$`,new n.Subject),M(this,`ungroup$`,this._ungroup$.asObservable()),M(this,`_refreshTransform$`,new n.Subject),M(this,`refreshTransform$`,this._refreshTransform$.asObservable()),M(this,`_visible$`,new n.Subject),M(this,`visible$`,this._visible$.asObservable()),M(this,`_focus$`,new n.Subject),M(this,`focus$`,this._focus$.asObservable()),M(this,`_featurePluginUpdate$`,new n.Subject),M(this,`featurePluginUpdate$`,this._featurePluginUpdate$.asObservable()),M(this,`_featurePluginAdd$`,new n.Subject),M(this,`featurePluginAdd$`,this._featurePluginAdd$.asObservable()),M(this,`_featurePluginRemove$`,new n.Subject),M(this,`featurePluginRemove$`,this._featurePluginRemove$.asObservable()),M(this,`_featurePluginOrderUpdate$`,new n.Subject),M(this,`featurePluginOrderUpdate$`,this._featurePluginOrderUpdate$.asObservable()),M(this,`_featurePluginGroupUpdate$`,new n.Subject),M(this,`featurePluginGroupUpdate$`,this._featurePluginGroupUpdate$.asObservable()),M(this,`_featurePluginUngroupUpdate$`,new n.Subject),M(this,`featurePluginUngroupUpdate$`,this._featurePluginUngroupUpdate$.asObservable()),M(this,`_visible`,!0),M(this,`_editable`,!0)}dispose(){this._remove$.complete(),this._add$.complete(),this._update$.complete(),this._order$.complete(),this._focus$.complete(),this._featurePluginUpdate$.complete(),this._featurePluginAdd$.complete(),this._featurePluginRemove$.complete(),this._featurePluginOrderUpdate$.complete(),this.drawingManagerData={},this._oldDrawingManagerData={}}visibleNotification(e){this._visible$.next(e)}refreshTransform(e){e.forEach(e=>{let t=this._getCurrentBySearch(e);t!=null&&(t.transform=e.transform,t.transforms=e.transforms,t.isMultiTransform=e.isMultiTransform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]||{}}removeDrawingDataForUnit(e){let t=this.drawingManagerData[e];if(t==null)return;delete this.drawingManagerData[e];let n=[];Object.keys(t).forEach(r=>{let i=t[r];(i==null?void 0:i.data)!=null&&Object.keys(i.data).forEach(t=>{n.push({unitId:e,subUnitId:r,drawingId:t})})}),n.length>0&&this.removeNotification(n)}registerDrawingData(e,t){this.drawingManagerData[e]=t}initializeNotification(e){let t=[],n=this.drawingManagerData[e];n!=null&&(Object.keys(n).forEach(r=>{this._establishDrawingMap(e,r);let i=n[r];Object.keys(i.data).forEach(n=>{let a=i.data[n];a.unitId=e,a.subUnitId=r,t.push(a)})}),t.length>0&&this.addNotification(t))}getDrawingData(e,t){return this._getDrawingData(e,t)}setDrawingData(e,t,n){this.drawingManagerData[e][t].data=n}getBatchAddOp(e){let t=[],n=[],r=[];e.forEach(e=>{let{op:i,invertOp:a}=this._addByParam(e);t.push({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}),n.push(i),r.push(a)});let i=n.reduce(O.type.compose,null),a=r.reduce(O.type.compose,null),{unitId:o,subUnitId:s}=e[0];return{undo:a,redo:i,unitId:o,subUnitId:s,objects:t}}getBatchRemoveOpInOder(e){if(e.length===0)return{undo:null,redo:null,unitId:``,subUnitId:``,objects:[]};let t=this.getDrawingOrder(e[0].unitId,e[0].subUnitId),n=new Map;return t.forEach((e,t)=>{n.set(e,t)}),e.sort((e,t)=>{var r,i;return((r=n.get(e.drawingId))==null?-1/0:r)-((i=n.get(t.drawingId))==null?-1/0:i)}),this.getBatchRemoveOp(e)}getBatchRemoveOp(e){var n;let r=new Set,i=[];e.forEach(e=>{let n=this.getDrawingByParam(e);if((n==null?void 0:n.drawingType)===t.DrawingTypeEnum.DRAWING_GROUP){let t=this.getDrawingsByGroupNested(e);if(t){let{flatChildren:e,groups:n}=t;[...e==null?[]:e,...n].forEach(e=>{r.has(e.drawingId)||(r.add(e.drawingId),i.push({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}))})}else r.has(e.drawingId)||(r.add(e.drawingId),i.push(e))}else r.has(e.drawingId)||(r.add(e.drawingId),i.push(e))});let{unitId:a,subUnitId:o}=(n=i[0])==null?e[0]:n,s=this._getDrawingOrder(a,o),c=new Map;s.forEach((e,t)=>c.set(e,t)),i.sort((e,t)=>{var n,r;return((n=c.get(e.drawingId))==null?-1/0:n)-((r=c.get(t.drawingId))==null?-1/0:r)});let l=[],u=[];i.forEach(e=>{let{op:t,invertOp:n}=this._removeByParam(e);l.unshift(t),u.push(n)});let d=l.reduce(O.type.compose,null);return{undo:u.reduce(O.type.compose,null),redo:d,unitId:a,subUnitId:o,objects:i}}getBatchUpdateOp(e){let t=[],n=[],r=[];e.forEach(e=>{let{op:i,invertOp:a}=this._updateByParam(e);t.push({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}),n.push(i),r.push(a)});let i=n.reduce(O.type.compose,null),a=r.reduce(O.type.compose,null),{unitId:o,subUnitId:s}=e[0];return{undo:a,redo:i,unitId:o,subUnitId:s,objects:t}}removeNotification(e){this._remove$.next(e)}addNotification(e){this._add$.next(e)}updateNotification(e){this._update$.next(e)}orderNotification(e){this._order$.next(e)}groupUpdateNotification(e){this._group$.next(e)}ungroupUpdateNotification(e){this._ungroup$.next(e)}refreshTransformNotification(e){this._refreshTransform$.next(e)}getGroupDrawingOp(e){let t=[],{unitId:n,subUnitId:r}=e[0].parent;e.forEach(e=>{t.push(this._getGroupDrawingOp(e))});let i=t.reduce(O.type.compose,null);return{undo:O.type.invertWithDoc(i,this.drawingManagerData),redo:i,unitId:n,subUnitId:r,objects:e}}getUngroupDrawingOp(e){let t=[],{unitId:n,subUnitId:r}=e[0].parent;e.forEach(e=>{t.push(this._getUngroupDrawingOp(e))});let i=t.reduce(O.type.compose,null);return{undo:O.type.invertWithDoc(i,this.drawingManagerData),redo:i,unitId:n,subUnitId:r,objects:e}}getDrawingsByGroup(e){let{unitId:t,subUnitId:n,drawingId:r}=e;if(this.getDrawingByParam({unitId:t,subUnitId:n,drawingId:r})==null)return[];let i=this._getDrawingData(t,n),a=[];return Object.keys(i).forEach(e=>{let t=i[e];t.groupId===r&&a.push(t)}),a}getDrawingsByGroupNested(e){let{unitId:n,subUnitId:r}=e,i=this.getDrawingByParam(e);if(!i)return null;let a=this._getDrawingData(n,r),o=new Map;Object.values(a).forEach(e=>{e.groupId!=null&&(o.has(e.groupId)||o.set(e.groupId,[]),o.get(e.groupId).push(e.drawingId))});let s=[],c=[],l={},u=e=>{var n;let{drawingId:r}=e,i=(n=o.get(r))==null?[]:n;l[r]={drawingId:r,children:i},i.forEach(e=>{let n=a[e];n&&(n.drawingType===t.DrawingTypeEnum.DRAWING_GROUP?(u(n),c.push(n)):s.push(n))})};return u(i),c.push(i),{nestedIdRecord:l,flatChildren:s,groups:c}}_getGroupDrawingOp(e){let{parent:t,children:n}=e,{unitId:r,subUnitId:i,drawingId:a}=t,o=[];o.push(O.insertOp([r,i,N.data,a],t));let s=-1/0;return n.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._hasDrawingOrder({unitId:t,subUnitId:n,drawingId:r});s=Math.max(s,i),o.push(...this._getUpdateParamCompareOp(e,this.getDrawingByParam({unitId:t,subUnitId:n,drawingId:r})))}),s===-1/0&&(s=this._getDrawingOrder(r,i).length),o.push(O.insertOp([r,i,N.order,s],a)),o.reduce(O.type.compose,null)}_getUngroupDrawingOp(e){let{parent:t,children:n}=e,{unitId:r,subUnitId:i,drawingId:a}=t,o=[];return n.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e;o.push(...this._getUpdateParamCompareOp(e,this.getDrawingByParam({unitId:t,subUnitId:n,drawingId:r})))}),o.push(O.removeOp([r,i,N.data,a],!0)),o.push(O.removeOp([r,i,N.order,this._getDrawingOrder(r,i).indexOf(a)],!0)),o.reduce(O.type.compose,null)}applyJson1(e,t,n){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=O.type.apply(this.drawingManagerData,n)}featurePluginUpdateNotification(e){this._featurePluginUpdate$.next(e)}featurePluginOrderUpdateNotification(e){this._featurePluginOrderUpdate$.next(e)}featurePluginAddNotification(e){this._featurePluginAdd$.next(e)}featurePluginRemoveNotification(e){this._featurePluginRemove$.next(e)}featurePluginGroupUpdateNotification(e){this._featurePluginGroupUpdate$.next(e)}featurePluginUngroupUpdateNotification(e){this._featurePluginUngroupUpdate$.next(e)}getDrawingByParam(e){return this._getCurrentBySearch(e)}getOldDrawingByParam(e){return this._getOldBySearch(e)}getDrawingOKey(e){let[t,n,r]=e.split(`#-#`);return this._getCurrentBySearch({unitId:t,subUnitId:n,drawingId:r})}focusDrawing(e){if(e==null||e.length===0){this._focusDrawings=[],this._focus$.next([]);return}let t=[];e.forEach(e=>{var n;let{unitId:r,subUnitId:i,drawingId:a}=e,o=(n=this._getDrawingData(r,i))==null?void 0:n[a];o!=null&&t.push(o)}),t.length>0&&(this._focusDrawings=t,this._focus$.next(t))}getFocusDrawings(){let e=[];return this._focusDrawings.forEach(t=>{var n;let{unitId:r,subUnitId:i,drawingId:a}=t,o=(n=this._getDrawingData(r,i))==null?void 0:n[a];o!=null&&e.push(o)}),e}getDrawingOrder(e,t){return this._getDrawingOrder(e,t)}setDrawingOrder(e,t,n){this.drawingManagerData[e][t].order=n}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=[],a=this.getDrawingOrder(t,n),o=[...r];r.forEach(e=>{let r=this._hasDrawingOrder({unitId:t,subUnitId:n,drawingId:e});if(r===-1||r===a.length-1)return;let s=O.moveOp([t,n,N.order,r],[t,n,N.order,r+1]);i.push(s),o.includes(a[r+1])||o.push(a[r+1])});let s=i.reduce(O.type.compose,null);return{undo:O.type.invertWithDoc(s,this.drawingManagerData),redo:s,unitId:t,subUnitId:n,objects:{...e,drawingIds:o}}}getBackwardDrawingOp(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=[],a=this.getDrawingOrder(t,n),o=[...r];r.forEach(e=>{let r=this._hasDrawingOrder({unitId:t,subUnitId:n,drawingId:e});if(r===-1||r===0)return;let s=O.moveOp([t,n,N.order,r],[t,n,N.order,r-1]);i.push(s),o.includes(a[r-1])||o.push(a[r-1])});let s=i.reduce(O.type.compose,null);return{undo:O.type.invertWithDoc(s,this.drawingManagerData),redo:s,unitId:t,subUnitId:n,objects:{...e,drawingIds:o}}}getFrontDrawingsOp(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=this._getOrderFromSearchParams(t,n,r),a=[...r],o=this.getDrawingOrder(t,n),s=[];i.forEach(e=>{let{drawingId:r}=e,i=this._getDrawingCount(t,n)-1,c=O.moveOp([t,n,N.order,this._getDrawingOrder(t,n).indexOf(r)],[t,n,N.order,i]);s.push(c),a.includes(o[i])||a.push(o[i])});let c=s.reduce(O.type.compose,null);return{undo:O.type.invertWithDoc(c,this.drawingManagerData),redo:c,unitId:t,subUnitId:n,objects:{...e,drawingIds:a}}}getBackDrawingsOp(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=this._getOrderFromSearchParams(t,n,r,!0),a=[...r],o=this.getDrawingOrder(t,n),s=[];i.forEach(e=>{let{drawingId:r}=e,i=O.moveOp([t,n,N.order,this._getDrawingOrder(t,n).indexOf(r)],[t,n,N.order,0]);s.push(i),a.includes(o[0])||a.push(o[0])});let c=s.reduce(O.type.compose,null);return{undo:O.type.invertWithDoc(c,this.drawingManagerData),redo:c,unitId:t,subUnitId:n,objects:{...e,drawingIds:a}}}_getDrawingCount(e,t){return this.getDrawingOrder(e,t).length||0}_getOrderFromSearchParams(e,n,r,i=!1){return r.map(t=>({drawingId:t,zIndex:this._hasDrawingOrder({unitId:e,subUnitId:n,drawingId:t})})).sort(i===!1?t.sortRules:t.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;let{unitId:t,subUnitId:n,drawingId:r}=e;return this._establishDrawingMap(t,n),this._getDrawingOrder(t,n).indexOf(r)}_getCurrentBySearch(e){var t;if(e==null)return;let{unitId:n,subUnitId:r,drawingId:i}=e;return(t=this.drawingManagerData[n])==null||(t=t[r])==null||(t=t.data)==null?void 0:t[i]}_getOldBySearch(e){var t;if(e==null)return;let{unitId:n,subUnitId:r,drawingId:i}=e;return(t=this._oldDrawingManagerData[n])==null||(t=t[r])==null||(t=t.data)==null?void 0:t[i]}_establishDrawingMap(e,t,n){var r;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][t]||(this.drawingManagerData[e][t]={data:{},order:[]}),n==null?null:(r=this.drawingManagerData[e][t].data)==null?void 0:r[n]}_addByParam(e){let{unitId:t,subUnitId:n,drawingId:r}=e;this._establishDrawingMap(t,n,r);let i=[O.insertOp([t,n,N.data,r],e),O.insertOp([t,n,N.order,this._getDrawingOrder(t,n).length],r)].reduce(O.type.compose,null);return{op:i,invertOp:O.type.invertWithDoc(i,this.drawingManagerData)}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};let{unitId:t,subUnitId:n,drawingId:r}=e;if(this._establishDrawingMap(t,n,r)==null)return{op:[],invertOp:[]};let i=[O.removeOp([t,n,N.data,r],!0),O.removeOp([t,n,N.order,this._getDrawingOrder(t,n).indexOf(r)],!0)].reduce(O.type.compose,null);return{op:i,invertOp:O.type.invertWithDoc(i,this.drawingManagerData)}}_updateByParam(e){let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._establishDrawingMap(t,n,r);if(i==null)return{op:[],invertOp:[]};let a=this._getUpdateParamCompareOp(e,i).reduce(O.type.compose,null);return{op:a,invertOp:O.type.invertWithDoc(a,this.drawingManagerData)}}_getUpdateParamCompareOp(e,t){let{unitId:n,subUnitId:r,drawingId:i}=e,a=[];return Object.keys(e).forEach(o=>{let s=e[o],c=t[o];c!==s&&a.push(O.replaceOp([n,r,N.data,i,o],c,s))}),a}_getDrawingData(e,t){var n;return((n=this.drawingManagerData[e])==null||(n=n[t])==null?void 0:n.data)||{}}_getDrawingOrder(e,t){var n;return((n=this.drawingManagerData[e])==null||(n=n[t])==null?void 0:n.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}},F=class extends P{},I=class{constructor(){M(this,`_waitCount`,0),M(this,`_change$`,new n.Subject),M(this,`change$`,this._change$),M(this,`_imageSourceCache`,new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,n){if(n===t.ImageSourceType.BASE64){let t=new Image;return t.src=e,t}return this._imageSourceCache.get(e)}addImageSourceCache(e,n,r){n===t.ImageSourceType.BASE64||r==null||this._imageSourceCache.set(e,r)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((n,r)=>{if(!f.includes(e.type)){r(Error(t.ImageUploadStatusType.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>5242880){r(Error(t.ImageUploadStatusType.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}let i=new FileReader;i.readAsDataURL(e),i.onload=e=>{var i;let a=(i=e.target)==null?void 0:i.result;if(a==null){r(Error(t.ImageUploadStatusType.ERROR_IMAGE)),this._decreaseWaiting();return}n({imageId:(0,t.generateRandomId)(6),imageSourceType:t.ImageSourceType.BASE64,source:a,base64Cache:a,status:t.ImageUploadStatusType.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){--this._waitCount,this._change$.next(this._waitCount)}},L=class extends t.Disposable{constructor(...e){super(...e),M(this,`_urlImageDownloader`,null)}registerURLImageDownloader(e){return this._urlImageDownloader=e,(0,t.toDisposable)(()=>{this._urlImageDownloader=null})}async getImage(e){if(this._urlImageDownloader)try{return await this._urlImageDownloader(e)}catch(t){console.error(`Custom downloader failed for ${e}, falling back to default behavior:`,t)}return e}async downloadImage(e){if(this._urlImageDownloader)try{let t=await this._urlImageDownloader(e);return await(await fetch(t)).blob()}catch(t){console.error(`Custom downloader failed for ${e}, falling back to default fetch:`,t)}return await(await fetch(e)).blob()}};function R(e,t){return function(n,r){t(n,r,e)}}function z(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let B=class extends t.Plugin{constructor(e=v,n,r,i){super(),this._config=e,this._injector=n,this._configService=r,this._commandService=i;let{...a}=(0,t.merge)({},v,this._config);this._configService.setConfig(_,a)}onStarting(){this._initCommands(),this._initDependencies()}_initDependencies(){var e;(0,t.mergeOverrideWithDependencies)([[t.IImageIoService,{useClass:I}],[t.IURLImageService,{useClass:L}],[p,{useClass:F}]],(e=this._config)==null?void 0:e.override).forEach(e=>this._injector.add(e))}_initCommands(){[m].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};M(B,`pluginName`,`UNIVER_DRAWING_PLUGIN`),M(B,`packageName`,h),M(B,`version`,g),B=z([R(1,(0,t.Inject)(t.Injector)),R(2,t.IConfigService),R(3,t.ICommandService)],B);function V({unitId:e,subUnitId:t,drawingId:n},r){return typeof r==`number`?`${e}#-#${t}#-#${n}#-#${r}`:`${e}#-#${t}#-#${n}`}e.DRAWING_IMAGE_ALLOW_IMAGE_LIST=f,e.DRAWING_IMAGE_ALLOW_SIZE=5242880,e.DRAWING_IMAGE_COUNT_LIMIT=10,e.DRAWING_IMAGE_HEIGHT_LIMIT=500,e.DRAWING_IMAGE_WIDTH_LIMIT=500,e.DrawingManagerService=F,e.IDrawingManagerService=p,Object.defineProperty(e,`IImageIoService`,{enumerable:!0,get:function(){return t.IImageIoService}}),e.ImageIoService=I,Object.defineProperty(e,`ImageSourceType`,{enumerable:!0,get:function(){return t.ImageSourceType}}),Object.defineProperty(e,`ImageUploadStatusType`,{enumerable:!0,get:function(){return t.ImageUploadStatusType}}),e.SetDrawingSelectedOperation=m,e.URLImageService=L,e.UnitDrawingService=P,Object.defineProperty(e,`UniverDrawingPlugin`,{enumerable:!0,get:function(){return B}}),e.getDrawingShapeKeyByDrawingSearch=V,e.getImageSize=async e=>new Promise((t,n)=>{let r=new Image;r.src=e,r.onload=()=>{t({width:r.width,height:r.height,image:r})},r.onerror=e=>{n(e)}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDrawing={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e));let f=5*1024*1024;function p(e){f=e}function m(){return f}let h=[`image/png`,`image/jpeg`,`image/jpg`,`image/gif`,`image/bmp`],g=(0,t.createIdentifier)(`univer.drawing-manager.service`),_={id:`drawing.operation.set-drawing-selected`,type:t.CommandType.OPERATION,handler:(e,t)=>{let n=e.get(g);return t==null?!1:(n.focusDrawing(t),!0)}};var v=`@univerjs/drawing`,y=`0.22.0`;let b=`drawing.config`;Symbol(b);let x={};var S=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e,t){if(Array.isArray(t))return!1;for(let n in e)if(!r(e[n],t[n]))return!1;for(let n in t)if(e[n]===void 0)return!1;return!0}function n(e,t){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}function r(e,r){return e===r?!0:e===null||r===null||typeof e!=`object`||typeof r!=`object`?!1:Array.isArray(e)?n(e,r):t(e,r)}e.default=r})),C=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){if(e===null)return null;if(Array.isArray(e))return e.map(t);if(typeof e==`object`){let n={};for(let r in e)n[r]=t(e[r]);return n}else return e}e.default=t})),w=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function t(e,t){if(!e)throw Error(t)}let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=(e,t)=>typeof e==typeof t?e>t:typeof e==`string`&&typeof t==`number`;function i(e,t){for(let n in e){let r=n;t.write(r,e[r])}}e.isValidPathItem=e=>typeof e==`number`||typeof e==`string`&&e!==`__proto__`;var a=class{constructor(e=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=e}ascend(){t(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):(t(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){let e=[],t=this.container,r=this.parents.length-1,i=this.idx;for(;i>=0;)e.unshift(t[i]),i===0?(i=this.indexes[r*2],t=this.parents[r--]):i-=n(t[i-1])?2:1;return e}},o=class e extends a{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return t(this.container!=null,`Invalid call to getKey before cursor descended`),this.container[this.idx]}getComponent(){let e;return this.container&&this.container.length>this.idx+1&&n(e=this.container[this.idx+1])?e:null}descendFirst(){let e=this.idx+1;if(!this.container||e>=this.container.length||n(this.container[e])&&e+1>=this.container.length)return!1;n(this.container[e])&&e++;let t=this.container[e];return Array.isArray(t)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(e),this.idx=0,this.container=t):this.idx=e,!0}nextSibling(){if(t(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;let e=this.indexes[this.indexes.length-1]+1,n=this.parents[this.parents.length-1];return e>=n.length?!1:(t(!isNaN(e)),this.indexes[this.indexes.length-1]=e,this.container=n[e],!0)}_init(e,t,n,r){this.container=e,this.idx=t,this.parents=n.slice(),this.indexes=r.slice()}clone(){let t=new e;return t._init(this.container,this.idx,this.parents,this.indexes),t}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(e,t){let n=this.getComponent();n&&t(n,e);for(let n of this)e&&e.descend(n),this.traverse(e,t),e&&e.ascend()}eachPick(e,t){this.traverse(e,(e,n)=>{e.p!=null&&t(e.p,n)})}eachDrop(e,t){this.traverse(e,(e,n)=>{e.d!=null&&t(e.d,n)})}};e.ReadCursor=o;var s=class extends a{constructor(e=null){super(e),this.pendingDescent=[],this._op=e}flushDescent(){t(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let e=0;e<this.pendingDescent.length;e++){let i=this.pendingDescent[e],a=this.idx+1;if(a<this.container.length&&n(this.container[a])&&a++,t(a===this.container.length||!n(this.container[a])),a===this.container.length)this.container.push(i),this.idx=a;else if(this.container[a]===i)this.idx=a;else{if(!Array.isArray(this.container[a])){let e=this.container.splice(a,this.container.length-a);this.container.push(e),this.lcIdx>-1&&(this.lcIdx=a)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(i,this.container[this.lcIdx][0])),a=this.lcIdx+1,this.lcIdx=-1);a<this.container.length&&r(i,this.container[a][0]);)a++;if(this.indexes.push(a),this.idx=0,a<this.container.length&&this.container[a][0]===i)this.container=this.container[a];else{let e=[i];this.container.splice(a,0,e),this.container=e}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();let e=this.idx+1;if(e<this.container.length&&n(this.container[e]))return this.container[e];{let t={};return this.container.splice(e,0,t),t}}write(e,n){let r=this.getComponent();t(r[e]==null||r[e]===n,`Internal consistency error: Overwritten component. File a bug`),r[e]=n}get(){return this._op}descend(t){if(!e.isValidPathItem(t))throw Error(`Invalid JSON key`);this.pendingDescent.push(t)}descendPath(e){return this.pendingDescent.push(...e),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(e,n=i){if(e===null)return;if(t(Array.isArray(e)),e===this._op)throw Error(`Cannot merge into my own tree`);let r=this.lcIdx,a=this.parents.length,o=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`||typeof r==`number`?(o++,this.descend(r)):Array.isArray(r)?this.mergeTree(r,n):typeof r==`object`&&n(r,this)}for(;o--;)this.ascend();this.lcIdx=this.parents.length===a?r:-1}at(e,t){this.descendPath(e),t(this);for(let t=0;t<e.length;t++)this.ascend();return this}writeAtPath(e,t,n){return this.at(e,()=>this.write(t,n)),this.reset(),this}writeMove(e,t,n=0){return this.writeAtPath(e,`p`,n).writeAtPath(t,`d`,n)}getPath(){let e=super.getPath();return e.push(...this.pendingDescent),e}};e.WriteCursor=s,e.writeCursor=()=>new s,e.readCursor=e=>new o(e);function c(e,t,n){let i,a;a=i=e?e.descendFirst():!1;function o(i){let o;for(;a;){let s=o=e.getKey();if(i!=null){let n=!1;if(t&&typeof s==`number`&&(o=t(s,e.getComponent()),o<0&&(o=~o,n=!0)),r(o,i))return null;if(o===i&&!n)return e}n&&typeof o==`number`&&n(o,e.getComponent()),a=e.nextSibling()}return null}return o.end=()=>{i&&e.ascend()},o}e.advancer=c;function l(e,t,n){let i,a,o,s;for(i=a=e&&e.descendFirst(),o=s=t&&t.descendFirst();i||o;){let a=i?e.getKey():null,s=o?t.getKey():null;a!==null&&s!==null&&(r(s,a)?s=null:a!==s&&(a=null)),n(a==null?s:a,a==null?null:e,s==null?null:t),a!=null&&i&&(i=e.nextSibling()),s!=null&&o&&(o=t.nextSibling())}a&&e.ascend(),s&&t.ascend()}e.eachChildOf=l})),T=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ConflictType=void 0,(function(e){e[e.RM_UNEXPECTED_CONTENT=1]=`RM_UNEXPECTED_CONTENT`,e[e.DROP_COLLISION=2]=`DROP_COLLISION`,e[e.BLACKHOLE=3]=`BLACKHOLE`})(e.ConflictType||(e.ConflictType={}))})),E=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.uniToStrPos=e.strPosToUni=void 0,e.strPosToUni=(e,t=e.length)=>{let n=0,r=0;for(;r<t;r++){let t=e.charCodeAt(r);t>=55296&&t<=57343&&(n++,r++)}if(r!==t)throw Error(`Invalid offset - splits unicode bytes`);return r-n},e.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){let t=e.charCodeAt(n);n+=t>=55296&&t<=57343?2:1}return n}})),D=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;let t=E(),n=t=>{if(!Array.isArray(t))throw Error(`Op must be an array of components`);let n=null;for(let r=0;r<t.length;r++){let i=t[r];switch(typeof i){case`object`:if(typeof i.d!=`number`&&typeof i.d!=`string`)throw Error(`Delete must be number or string`);if(e.dlen(i.d)<=0)throw Error(`Deletes must not be empty`);break;case`string`:if(!(i.length>0))throw Error(`Inserts cannot be empty`);break;case`number`:if(!(i>0))throw Error(`Skip components must be >0`);if(typeof n==`number`)throw Error(`Adjacent skip components should be combined`);break}n=i}if(typeof n==`number`)throw Error(`Op has a trailing skip`)};function r(n,r){let i=0,a=0;for(let o=0;o<n.length;o++){let s=n[o];switch(r(s,i,a),typeof s){case`object`:i+=e.dlen(s.d);break;case`string`:a+=t.strPosToUni(s);break;case`number`:i+=s,a+=s;break}}}e.eachOp=r;function i(e,t){let n=[],i=s(n);return r(e,(e,n,r)=>{i(t(e,n,r))}),d(n)}let a=e=>e,o=e=>i(e,a);e.dlen=e=>typeof e==`number`?e:t.strPosToUni(e);let s=t=>n=>{if(!(!n||n.d===0||n.d===``))if(t.length===0)t.push(n);else if(typeof n==typeof t[t.length-1])if(typeof n==`object`){let r=t[t.length-1];r.d=typeof r.d==`string`&&typeof n.d==`string`?r.d+n.d:e.dlen(r.d)+e.dlen(n.d)}else t[t.length-1]+=n;else t.push(n)},c=e=>typeof e==`number`?e:typeof e==`string`?t.strPosToUni(e):typeof e.d==`number`?e.d:t.strPosToUni(e.d);e.uniSlice=(e,n,r)=>{let i=t.uniToStrPos(e,n),a=r==null?1/0:t.uniToStrPos(e,r);return e.slice(i,a)};let l=(t,n,r)=>typeof t==`number`?r==null?t-n:Math.min(t,r)-n:e.uniSlice(t,n,r),u=n=>{let r=0,i=0;return{take:(a,o)=>{if(r===n.length)return a===-1?null:a;let s=n[r],c;if(typeof s==`number`)return a===-1||s-i<=a?(c=s-i,++r,i=0,c):(i+=a,a);if(typeof s==`string`){if(a===-1||o===`i`||t.strPosToUni(s.slice(i))<=a)return c=s.slice(i),++r,i=0,c;{let e=i+t.uniToStrPos(s.slice(i),a);return c=s.slice(i,e),i=e,c}}else if(a===-1||o===`d`||e.dlen(s.d)-i<=a)return c={d:l(s.d,i)},++r,i=0,c;else{let e=l(s.d,i,i+a);return i+=a,{d:e}}},peek:()=>n[r]}},d=e=>(e.length>0&&typeof e[e.length-1]==`number`&&e.pop(),e);function f(r,i,a){if(a!==`left`&&a!==`right`)throw Error(`side (`+a+`) must be 'left' or 'right'`);n(r),n(i);let o=[],l=s(o),{take:f,peek:p}=u(r);for(let n=0;n<i.length;n++){let r=i[n],o,s;switch(typeof r){case`number`:for(o=r;o>0;)s=f(o,`i`),l(s),typeof s!=`string`&&(o-=c(s));break;case`string`:a===`left`&&typeof p()==`string`&&l(f(-1)),l(t.strPosToUni(r));break;case`object`:for(o=e.dlen(r.d);o>0;)switch(s=f(o,`i`),typeof s){case`number`:o-=s;break;case`string`:l(s);break;case`object`:o-=e.dlen(s.d)}break}}let m;for(;m=f(-1);)l(m);return d(o)}function p(r,i){n(r),n(i);let a=[],o=s(a),{take:f}=u(r);for(let n=0;n<i.length;n++){let r=i[n],a,s;switch(typeof r){case`number`:for(a=r;a>0;)s=f(a,`d`),o(s),typeof s!=`object`&&(a-=c(s));break;case`string`:o(r);break;case`object`:a=e.dlen(r.d);let n=0;for(;n<a;)switch(s=f(a-n,`d`),typeof s){case`number`:o({d:l(r.d,n,n+s)}),n+=s;break;case`string`:n+=t.strPosToUni(s);break;case`object`:o(s)}break}}let p;for(;p=f(-1);)o(p);return d(a)}let m=(n,r)=>{let i=0;for(let a=0;a<r.length&&n>i;a++){let o=r[a];switch(typeof o){case`number`:i+=o;break;case`string`:let r=t.strPosToUni(o);i+=r,n+=r;break;case`object`:n-=Math.min(e.dlen(o.d),n-i);break}}return n},h=(e,t)=>typeof e==`number`?m(e,t):e.map(e=>m(e,t));function g(e,t,n){return i(e,(e,r)=>typeof e==`object`&&typeof e.d==`number`?{d:n.slice(t,r,r+e.d)}:e)}function _(e){return i(e,e=>{switch(typeof e){case`object`:if(typeof e.d==`number`)throw Error(`Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.`);return e.d;case`string`:return{d:e};case`number`:return e}})}function v(e){return i(e,e=>typeof e==`object`&&typeof e.d==`string`?{d:t.strPosToUni(e.d)}:e)}function y(e){let t=!0;return r(e,e=>{typeof e==`object`&&typeof e.d==`number`&&(t=!1)}),t}function b(t){return{name:`text-unicode`,uri:`http://sharejs.org/types/text-unicode`,trim:d,normalize:o,checkOp:n,create(e=``){if(typeof e!=`string`)throw Error(`Initial data must be a string`);return t.create(e)},apply(r,i){n(i);let a=t.builder(r);for(let t=0;t<i.length;t++){let n=i[t];switch(typeof n){case`number`:a.skip(n);break;case`string`:a.append(n);break;case`object`:a.del(e.dlen(n.d));break}}return a.build()},transform:f,compose:p,transformPosition:m,transformSelection:h,isInvertible:y,makeInvertible(e,n){return g(e,n,t)},stripInvertible:v,invert:_,invertWithDoc(e,n){return _(g(e,n,t))},isNoop:e=>e.length===0}}e.default=b})),O=l((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=D(),n=E();function r(e,r){return{get:e,getLength(){return e().length},insert(t,i,a){return r([n.strPosToUni(e(),t),i],a)},remove(t,i,a){return r([n.strPosToUni(e(),t),{d:i}],a)},_onOp(e){t.eachOp(e,(e,n,r)=>{switch(typeof e){case`string`:this.onInsert&&this.onInsert(r,e);break;case`object`:let n=t.dlen(e.d);this.onRemove&&this.onRemove(r,n)}})},onInsert:null,onRemove:null}}e.default=r,r.provides={text:!0}})),k=l((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)Object.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.type=e.remove=e.insert=void 0;let a=E(),o=r(D()),s=i(O()),c={create(e){return e},toString(e){return e},builder(e){if(typeof e!=`string`)throw Error(`Invalid document snapshot: `+e);let t=[];return{skip(n){let r=a.uniToStrPos(e,n);if(r>e.length)throw Error(`The op is too long for this document`);t.push(e.slice(0,r)),e=e.slice(r)},append(e){t.push(e)},del(t){e=e.slice(a.uniToStrPos(e,t))},build(){return t.join(``)+e}}},slice:o.uniSlice},l=o.default(c);e.type=Object.assign(Object.assign({},l),{api:s.default}),e.insert=(e,t)=>t.length===0?[]:e===0?[t]:[e,t],e.remove=(e,t)=>o.dlen(t)===0?[]:e===0?[{d:t}]:[e,{d:t}];var u=D();Object.defineProperty(e,`makeType`,{enumerable:!0,get:function(){return u.default}})})),A=l((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;let n=t(S()),r=t(C()),i=w(),a=T(),o=()=>{};function s(e,t){if(!e)throw Error(t)}let c=!1;e.type={name:`json1`,uri:`http://sharejs.org/types/JSONv1`,readCursor:i.readCursor,writeCursor:i.writeCursor,create:e=>e,isNoop:e=>e==null,setDebug(e){c=e,o.quiet=!e},registerSubtype:y,checkValidOp:M,normalize:N,apply:P,transformPosition:F,compose:I,tryTransform:H,transform:W,makeInvertible:z,invert:L,invertWithDoc:B,RM_UNEXPECTED_CONTENT:a.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:a.ConflictType.DROP_COLLISION,BLACKHOLE:a.ConflictType.BLACKHOLE,transformNoConflict:(e,t,n)=>q(()=>!0,e,t,n),typeAllowingConflictsPred:t=>Object.assign(Object.assign({},e.type),{transform:(e,n,r)=>q(t,e,n,r)})};let l=e=>e?e.getComponent():null;function u(e){return e&&typeof e==`object`&&!Array.isArray(e)}let d=e=>Array.isArray(e)?e.slice():typeof e==`object`&&e?Object.assign({},e):e,f=e=>e&&(e.p!=null||e.r!==void 0),p=e=>e&&(e.d!=null||e.i!==void 0);function m(e,t){return s(e!=null),typeof t==`number`?(s(Array.isArray(e),`Invalid key - child is not an array`),(e=e.slice()).splice(t,1)):(s(u(e),`Invalid key - child is not an object`),delete(e=Object.assign({},e))[t]),e}function h(e,t,n){return typeof t==`number`?(s(e!=null,`Container is missing for key`),s(Array.isArray(e),`Cannot use numerical key for object container`),s(e.length>=t,`Cannot insert into out of bounds index`),e.splice(t,0,n)):(s(u(e),`Cannot insert into missing item`),s(e[t]===void 0,`Trying to overwrite value at key. Your op needs to remove it first`),e[t]=n),n}e.removeOp=(e,t=!0)=>i.writeCursor().writeAtPath(e,`r`,t).get(),e.moveOp=(e,t)=>i.writeCursor().writeMove(e,t).get(),e.insertOp=(e,t)=>i.writeCursor().writeAtPath(e,`i`,t).get(),e.replaceOp=(e,t,n)=>i.writeCursor().at(e,e=>{e.write(`r`,t),e.write(`i`,n)}).get(),e.editOp=(e,t,n,r=!1)=>i.writeCursor().at(e,e=>O(e,t,n,r)).get();let g=(e,t)=>e!=null&&(typeof t==`number`?Array.isArray(e):typeof e==`object`),_=(e,t)=>g(e,t)?e[t]:void 0,v={};function y(e){let t=e.type?e.type:e;t.name&&(v[t.name]=t),t.uri&&(v[t.uri]=t)}let b=e=>{let t=v[e];if(t)return t;throw Error(`Missing type: `+e)};y(k());let x=(e,t)=>e+t;y({name:`number`,apply:x,compose:x,invert:e=>-e,transform:e=>e});let E=e=>e==null?null:e.et?b(e.et):e.es?v[`text-unicode`]:e.ena==null?null:v.number,D=e=>e.es?e.es:e.ena==null?e.e:e.ena,O=(e,t,n,r=!1)=>{let[i,a]=typeof t==`string`?[b(t),t]:[t,t.name];!r&&i.isNoop&&i.isNoop(n)||(a===`number`?e.write(`ena`,n):a===`text-unicode`?e.write(`es`,n):(e.write(`et`,a),e.write(`e`,n)))};function A(e){s(typeof e==`number`),s(e>=0),s(e===(0|e))}function j(e){typeof e==`number`?A(e):s(typeof e==`string`)}function M(e){if(e===null)return;let t=new Set,n=new Set,r=e=>{let r=!0,i=!1;for(let a in e){let o=e[a];if(r=!1,s(a===`p`||a===`r`||a===`d`||a===`i`||a===`e`||a===`es`||a===`ena`||a===`et`,`Invalid component item '`+a+`'`),a===`p`)A(o),s(!t.has(o)),t.add(o),s(e.r===void 0);else if(a===`d`)A(o),s(!n.has(o)),n.add(o),s(e.i===void 0);else if(a===`e`||a===`es`||a===`ena`){s(!i),i=!0;let t=E(e);s(t,`Missing type in edit`),t.checkValidOp&&t.checkValidOp(D(e))}}s(!r)},a=(e,t,n)=>{if(!Array.isArray(e))throw Error(`Op must be null or a list`);if(e.length===0)throw Error(`Empty descent`);t||j(e[0]);let o=1,c=0,l=0;for(let t=0;t<e.length;t++){let u=e[t];if(s(u!=null),Array.isArray(u)){let e=a(u,!1,n);if(c){let t=typeof l,n=typeof e;t===n?s(l<e,`descent keys are not in order`):s(t===`number`&&n===`string`)}l=e,c++,o=3}else typeof u==`object`?(s(o===1,`Prev not scalar - instead ${o}`),r(u),o=2):(s(o!==3),j(u),s(i.isValidPathItem(u),`Invalid path key`),o=1)}return s(c!==1,`Operation makes multiple descents. Remove some []`),s(o===2||o===3),e[0]};a(e,!0,!1),s(t.size===n.size,`Mismatched picks and drops in op`);for(let e=0;e<t.size;e++)s(t.has(e)),s(n.has(e))}function N(e){let t=0,n=[],r=i.writeCursor();return r.mergeTree(e,(e,r)=>{let i=E(e);if(i){let t=D(e);O(r,i,i.normalize?i.normalize(t):t)}for(let i of[`r`,`p`,`i`,`d`])if(e[i]!==void 0){let o=i===`p`||i===`d`?(a=e[i],n[a]==null&&(n[a]=t++),n[a]):e[i];r.write(i,o)}var a}),r.get()}function P(e,t){if(o.quiet=!c,M(t),t===null)return e;let n=[];return function e(t,r){let i=t,a=0,o={root:t},c=0,l=o,u=`root`;function f(){for(;c<a;c++){let e=r[c];typeof e!=`object`&&(s(g(l,u)),l=l[u]=d(l[u]),u=e)}}for(;a<r.length;a++){let t=r[a];if(Array.isArray(t)){let n=e(i,t);n!==i&&n!==void 0&&(f(),i=l[u]=n)}else if(typeof t==`object`){t.d==null?t.i!==void 0&&(f(),i=h(l,u,t.i)):(f(),i=h(l,u,n[t.d]));let e=E(t);if(e)f(),i=l[u]=e.apply(i,D(t));else if(t.e!==void 0)throw Error(`Subtype `+t.et+` undefined`)}else i=_(i,t)}return o.root}(e=function e(t,r){let i=[],a=0;for(;a<r.length;a++){let e=r[a];if(Array.isArray(e))break;typeof e!=`object`&&(i.push(t),t=_(t,e))}for(let n=r.length-1;n>=a;n--)t=e(t,r[n]);for(--a;a>=0;a--){let e=r[a];if(typeof e!=`object`){let n=i.pop();t=t===_(n,e)?n:t===void 0?m(n,e):(c=e,l=t,(o=d(o=n))[c]=l,o)}else f(e)&&(s(t!==void 0,`Cannot pick up or remove undefined`),e.p!=null&&(n[e.p]=t),t=void 0)}var o,c,l;return t}(e,t),t)}function F(e,t){e=e.slice(),M(t);let n=i.readCursor(t),r,a,o=!1,s=[];for(let t=0;;t++){let c=e[t],l=n.getComponent();if(l&&(l.r===void 0?l.p!=null&&(o=!1,r=l.p,a=t):o=!0),t>=e.length)break;let u=0,d=i.advancer(n,void 0,(e,t)=>{f(t)&&u++});s.unshift(d);let p=d(c);if(typeof c==`number`&&(e[t]-=u),!p)break}if(s.forEach(e=>e.end()),o)return null;let c=()=>{let t=0;if(r!=null){let r=n.getPath();t=r.length,e=r.concat(e.slice(a))}for(;t<e.length;t++){let r=e[t],a=l(n),o=E(a);if(o){let n=D(a);o.transformPosition&&(e[t]=o.transformPosition(e[t],n));break}let s=0,c=i.advancer(n,(e,t)=>p(t)?~(e-s):e-s,(e,t)=>{p(t)&&s++})(r);if(typeof r==`number`&&(e[t]+=s),!c)break}};return r==null?c():n.eachDrop(null,e=>{e===r&&c()}),e}function I(e,t){if(M(e),M(t),e==null)return t;if(t==null)return e;let n=0,r=i.readCursor(e),a=i.readCursor(t),o=i.writeCursor(),c=[],u=[],d=[],m=[],h=[],g=[],_=new Set;r.traverse(null,e=>{e.p!=null&&(d[e.p]=r.clone())}),a.traverse(null,e=>{e.d!=null&&(m[e.d]=a.clone())});let v=i.writeCursor();return function e(t,r,a,o,v,y,b,x){s(r||a);let S=l(r),C=l(a),w=!!C&&C.r!==void 0,T=!!S&&S.i!==void 0,k=S?S.d:null,A=C?C.p:null,j=(y||w)&&A==null;if(A!=null)o=m[A],b=u[A]=new i.WriteCursor;else if(C&&C.r!==void 0)o=null;else{let e=l(o);e&&e.d!=null&&(o=null)}let M=l(o);if(k!=null)if(t=d[k],x=c[k]=new i.WriteCursor,j)y&&!w&&x.write(`r`,!0);else{let e=h[k]=n++;b.write(`d`,e)}else if(S&&S.i!==void 0)t=null;else{let e=l(t);e&&e.p!=null&&(t=null)}let N;T?(s(v===void 0),N=S.i):N=v;let P=(A==null?!T||y||w:N===void 0)?null:b.getComponent();if(A!=null){if(!(v!==void 0||T)){let e=k==null?n++:h[k];g[A]=e,x.write(`p`,e)}}else w&&(T||v!==void 0||(C.r,x.write(`r`,C.r)));let F=j?null:E(S),I=E(M);if((F||I)&&(F&&F.name,I&&I.name),F&&I){s(F===I);let e=D(S),t=D(M),n=F.compose(e,t);O(b,F,n),_.add(M)}else F?O(b,F,D(S)):I&&(O(b,I,D(M)),_.add(M));let L=typeof N==`object`&&!!N,R=!1,z=0,B=0,V=0,H=0,U=0,W=i.advancer(o,(e,t)=>p(t)?H-e-1:e-H,(e,t)=>{p(t)&&H++}),G=i.advancer(t,(e,t)=>f(t)?z-e-1:e-z,(e,t)=>{f(t)&&z++});if(i.eachChildOf(r,a,(t,n,r)=>{let i,a,o=t,c=t,u=t;if(typeof t==`number`){let e=t+V;a=W(e),c=e+H;let d=t+B;i=G(d),p(l(a))&&(i=null),o=d+z,u=t+U,s(o>=0,`p1PickKey is negative`),s(c>=0,`p2DropKey is negative`);let m=p(l(n)),h=f(l(r));(m||h&&!j)&&U--,m&&B--,h&&V--}else i=G(t),a=W(t);x.descend(o),b.descend(c);let d=L&&!p(l(n))?N[u]:void 0,m=e(i,n,r,a,d,j,b,x);var h,g,_;L&&!j?d!==m&&(R||(N=Array.isArray(N)?N.slice():Object.assign({},N),R=!0),h=N,_=m,typeof(g=u)==`number`?(s(Array.isArray(h)),s(g<h.length)):(s(!Array.isArray(h)),s(h[g]!==void 0)),_===void 0?typeof g==`number`?h.splice(g,1):delete h[g]:h[g]=_):s(m===void 0),b.ascend(),x.ascend()}),G.end(),W.end(),P!=null)P.i=N;else if(!y&&!w&&A==null)return N}(r,r.clone(),a,a.clone(),void 0,!1,o,v),o.reset(),o.mergeTree(v.get()),o.reset(),o.get(),c.map(e=>e.get()),u.map(e=>e.get()),r.traverse(o,(e,t)=>{let n=e.p;if(n!=null){let e=h[n];e!=null&&t.write(`p`,e);let r=c[n];r&&r.get(),r&&t.mergeTree(r.get())}else e.r!==void 0&&t.write(`r`,e.r)}),o.reset(),o.get(),a.traverse(o,(e,t)=>{let n=e.d;if(n!=null){let e=g[n];e!=null&&t.write(`d`,e);let r=u[n];r&&t.mergeTree(r.get())}else e.i!==void 0&&t.write(`i`,e.i);let r=E(e);r&&!_.has(e)&&O(t,r,D(e))}),o.get()}function L(e){if(e==null)return null;let t=new i.ReadCursor(e),n=new i.WriteCursor,r,a=[],o=[];return function e(t,n,i){let o=t.getComponent(),s,c=!1;if(o){o.p!=null&&(n.write(`d`,o.p),a[o.p]=t.clone()),o.r!==void 0&&n.write(`i`,o.r),o.d!=null&&(n.write(`p`,o.d),i=void 0),o.i!==void 0&&(i=s=o.i);let e=E(o);e&&(i===void 0?(r||(r=new Set),r.add(o)):(D(o),i=e.apply(i,D(o)),c=!0))}let l=0;for(let r of t){n.descend(r);let a=typeof r==`number`?r-l:r,o=_(i,a);p(t.getComponent())&&l++;let s=e(t,n,o);if(i!==void 0&&s!==void 0){if(c||(c=!0,i=d(i)),!g(i,a))throw Error(`Cannot modify child - invalid operation`);i[a]=s}n.ascend()}if(s===void 0)return c?i:void 0;n.write(`r`,i)}(t,n,void 0),r&&(n.reset(),function e(t,n,s){let c=n.getComponent();if(c){let e=c.d;if(e!=null&&(t=a[e],s=o[e]=i.writeCursor()),r.has(c)){let e=E(c);if(!e.invert)throw Error(`Cannot invert subtype ${e.name}`);O(s,e,e.invert(D(c)))}}let l=0,u=0,d=i.advancer(t,(e,t)=>f(t)?l-e-1:e-l,(e,t)=>{f(t)&&l++});for(let t of n)if(typeof t==`number`){let r=t-u,i=d(r),a=r+l;s.descend(a),e(i,n,s),p(n.getComponent())&&u++,s.ascend()}else s.descend(t),e(d(t),n,s),s.ascend();d.end()}(t.clone(),t,n),o.length&&(n.reset(),t.traverse(n,(e,t)=>{let n=e.p;if(n!=null){let e=o[n];e&&e.get(),e&&t.mergeTree(e.get())}}))),n.get()}let R=(e,t)=>e.some(e=>typeof e==`object`&&(Array.isArray(e)?R(e,t):t(e)));function z(e,t){if(e==null||!R(e,e=>{var t;return e.r!==void 0||((t=E(e))==null?void 0:t.makeInvertible)!=null}))return e;let n=new i.ReadCursor(e),a=new i.WriteCursor,o=!1,c=[],l=[],u=(e,t,n)=>{let i=e.getComponent(),a=!1;if(i){i.d!=null&&t.write(`d`,i.d),i.i!==void 0&&t.write(`i`,i.i);let r=i.p;if(r!=null&&(c[r]=e.clone(),s(n!==void 0,`Operation picks up at an invalid key`),l[r]=n,t.write(`p`,i.p)),i.r!==void 0&&n===void 0)throw Error(`Invalid doc / op in makeInvertible: removed item missing from doc`);let a=E(i);a&&(a.makeInvertible?o=!0:O(t,a,D(i),!0))}let f=0;for(let r of e){t.descend(r);let i=typeof r==`number`?r-f:r,o=_(n,i),s=u(e,t,o);o!==s&&(a||(a=!0,n=d(n)),s===void 0?(n=m(n,i),typeof r==`number`&&f++):n[i]=s),t.ascend()}return i&&(i.r===void 0?i.p!=null&&(n=void 0):(t.write(`r`,r.default(n)),n=void 0)),n};return u(n,a,t),a.get(),o&&(a.reset(),function e(t,n,r,a,o){let s=n.getComponent();if(s){s.i===void 0?s.d!=null&&(a=l[s.d],t=c[s.d],o=!1,s.d):(a=s.i,o=!0);let e=E(s);if(e&&e.makeInvertible){let t=D(s);O(r,e,e.makeInvertible(t,a),!0)}}let u=0,d=0,m=i.advancer(t,(e,t)=>f(t)?u-e-1:e-u,(e,t)=>{f(t)&&u++});for(let t of n)if(typeof t==`number`){let i=t-d,s=m(i),c=i+u,l=_(a,o?i:c);r.descend(t),e(s,n,r,l,o),p(n.getComponent())&&d++,r.ascend()}else{let i=_(a,t);r.descend(t),e(m(t),n,r,i,o),r.ascend()}m.end()}(n.clone(),n,a,t,!1)),a.get()}function B(e,t){return L(z(e,t))}let V=e=>{if(e==null)return null;let t=e.slice();for(let n=0;n<e.length;n++){let e=t[n];Array.isArray(e)&&(t[n]=V(e))}return t};function H(t,u,d){s(d===`left`||d===`right`,`Direction must be left or right`);let m=d===`left`?0:1;if(o.quiet=!c,o.prefix=0,u==null)return{ok:!0,result:t};M(t),M(u);let h=null,g=[],_=[],v=[],y=[],b=[],x=[],S=[],C=[],w=[],T=[],k=[],A=[],j=[],N=[],P=[],F=0,I=i.readCursor(t),L=i.readCursor(u),R=i.writeCursor();if(function e(t,n=null,r){let a=l(n);a&&(a.r===void 0?a.p!=null&&(r=null,x[a.p]=t.clone()):r=n.clone());let o=t.getComponent(),s;o&&(s=o.p)!=null&&(b[s]=n?n.clone():null,v[s]=t.clone(),r&&(T[s]=!0,w[s]=r),a&&a.p!=null&&(N[s]=a.p));let c=i.advancer(n);for(let n of t)e(t,c(n),r);c.end()}(L,I,null),function t(n,r,o,s,c){let u=o.getComponent(),d,p=!1;u&&((d=u.d)==null?u.i!==void 0&&(n=r=null,p=!0,c&&h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.insertOp(o.getPath(),u.i)})):(y[d]=o.clone(),s!=null&&(P[s]==null&&(P[s]=[]),P[s].push(d)),T[d],n=b[d]||null,r=v[d]||null,T[d]?(c&&(k[d]=!0),c=w[d]||null):!c||m!==1&&N[d]!=null||h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.moveOp(r.getPath(),o.getPath())}),p=!0));let g=l(n);g&&(g.r===void 0?g.p!=null&&(g.p,s=g.p,c=null):c=n.clone());let _=E(u);_&&c&&h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.editOp(o.getPath(),_,D(u),!0)});let x=0,S=0,C=i.advancer(r,(e,t)=>f(t)?x-e-1:e-x,(e,t)=>{f(t)&&x++}),O=i.advancer(n);for(let e of o)if(typeof e==`number`){let n=e-S,r=C(n);S+=+t(O(n+x),r,o,s,c)}else{let n=C(e);t(O(e),n,o,s,c)}return C.end(),O.end(),p}(I,L,L.clone(),null,null),y.map(e=>e&&e.get()),h)return{ok:!1,conflict:h};k.map(e=>!!e);let z=[],B=null;(function e(t,n,r,a,o){let c=!1,u=l(n);if(f(u)){let e=u.p;e==null?(r=null,o=n.clone()):(r=y[e],a=A[e]=i.writeCursor(),c=!0,o=null)}else p(l(r))&&(r=null);let d=t.getComponent();if(d){let e=d.p;e==null?d.r!==void 0&&(o||a.write(`r`,!0),(o||c)&&(B==null&&(B=new Set),B.add(d))):(o&&(C[e]=o),z[e]=o||m===1&&c?null:a.getComponent(),g[e]=t.clone(),r&&(S[e]=r.clone()))}let h=0,_=0,v=i.advancer(n,void 0,(e,t)=>{f(t)&&h++}),b=i.advancer(r,(e,t)=>p(t)?~(e-_):e-_,(e,t)=>{p(t)&&_++});if(t)for(let n of t)if(typeof n==`string`){let r=v(n),i=b(n);a.descend(n),e(t,r,i,a,o),a.ascend()}else{let r=v(n),i=n-h,c=f(l(r))?null:b(i),u=i+_;s(u>=0),a.descend(u),e(t,r,c,a,o),a.ascend()}v.end(),b.end()})(I,L,L.clone(),R,null),R.reset();let H=[];if(function t(o,c,u,b,w,k){s(c);let A=c.getComponent(),M=l(b),P=!1,I=(t,n,r)=>t?e.moveOp(t.getPath(),n.getPath()):e.insertOp(n.getPath(),r.i);if(p(A)){let t=A.d;t!=null&&(_[t]=c.clone());let i=t==null?null:z[t],s=!1;if(A.i!==void 0||t!=null&&i){let o;M&&(M.i!==void 0||(o=M.d)!=null&&!T[o])&&(s=o==null?n.default(M.i,A.i):t!=null&&t===N[o],s||o!=null&&m!==1&&N[o]!=null||h==null&&(h={type:a.ConflictType.DROP_COLLISION,op1:I(t==null?null:g[t],c,A),op2:I(o==null?null:v[o],b,M)})),s||(k?h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:I(t==null?null:g[t],c,A),op2:e.removeOp(k.getPath())}):(t==null?w.write(`i`,r.default(A.i)):(H[F]=t,w.write(`d`,i.p=F++)),P=!0))}else if(t!=null&&!i){let e=C[t];e&&(k=e.clone())}t==null?A.i!==void 0&&(o=u=null,s||(b=null)):(o=g[t],u=x[t],b=S[t])}else f(l(o))&&(o=u=b=null);let L=l(o),R=l(u);if(f(R)){let e=R.p;R.r!==void 0&&(!L||L.r===void 0)||T[e]?(b=null,k=u.clone()):e!=null&&(b=y[e],m!==1&&N[e]!=null||((w=j[e])||(w=j[e]=i.writeCursor()),w.reset(),k=null))}else !p(A)&&p(M)&&(b=null);M=b==null?null:b.getComponent();let V=E(A);if(V){let t=D(A);if(k)h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(c.getPath(),V,t,!0),op2:e.removeOp(k.getPath())});else{let e=E(M),n;if(e){if(V!==e)throw Error(`Transforming incompatible types`);let r=D(M);n=V.transform(t,r,d)}else n=r.default(t);O(w,V,n)}}let U=0,W=0,G=0,K=0,q=0,J=0,Y=o!=null&&o.descendFirst(),X=Y,Z=i.advancer(u,void 0,(e,t)=>{f(t)&&G++}),Q=b!=null&&b.descendFirst(),$=Q;for(let e of c)if(typeof e==`number`){let n,r=p(c.getComponent()),i=e-W;{let e;for(;Y&&typeof(e=o.getKey())==`number`;){e+=U;let t=o.getComponent(),n=f(t);if(e>i||e===i&&(!n||m===0&&r))break;if(n){U--;let e=t.p;z[e],N.includes(e),t.d,l(j[t.d]),f(l(j[t.d])),(t.r===void 0||B&&B.has(t))&&(e==null||!z[e]||m!==1&&N.includes(e))||q--}Y=o.nextSibling()}n=Y&&e===i?o:null}let a=i-U,u=Z(a),d=a-G,h=null;{let e,t;for(;Q&&typeof(e=b.getKey())==`number`;){t=e-K;let n=b.getComponent(),i=p(n);if(t>d)break;if(t===d){if(!i){h=b;break}{if(m===0&&r){h=b;break}let e=u&&f(u.getComponent());if(m===0&&e)break}}if(i){let e=n.d;T[e],N[e],n.i===void 0&&(T[e]||N[e]!=null&&m!==1)?(T[e]||N[e]!=null&&m===0)&&(K++,J--):K++}Q=b.nextSibling()}}let g=d+K+q+J;s(g>=0,`trying to descend to a negative index`),w.descend(g),r&&(n=u=h=null,W++),t(n,c,u,h,w,k)&&J++,w.ascend()}else{let n;for(;Y&&(n=o.getKey(),typeof n!=`string`||!(n>e||n===e));)Y=o.nextSibling();let r=Y&&n===e?o:null,i=Z(e),a;for(;Q&&(a=b.getKey(),typeof a!=`string`||!(a>e||a===e));)Q=b.nextSibling();let s=Q&&a===e?b:null;w.descend(e),t(r,c,i,s,w,k),w.ascend()}return Z.end(),X&&o.ascend(),$&&b.ascend(),P}(I,I.clone(),L,L.clone(),R,null),h)return{ok:!1,conflict:h};R.reset();let U=(e,t,n)=>e.traverse(t,(t,r)=>{t.d!=null&&n(t.d,e,r)});(T.length||A.length)&&(U(L,R,(e,t,n)=>{T[e]&&!k[e]&&n.write(`r`,!0),A[e]&&n.mergeTree(A[e].get())}),R.reset());let W=[],G=[];if((j.length||T.length)&&!h){let e=i.readCursor(V(R.get()));if(U(e,null,(e,t)=>{W[e]=t.clone()}),j.forEach(e=>{e&&U(i.readCursor(e.get()),null,(e,t)=>{W[e]=t.clone()})}),function e(t,n,r,a,s,c){o.prefix++;let u=l(n);if(u&&f(u))if(u.p!=null){s=u;let e=u.p;W[e].getPath(),r=W[e],a=G[e]=i.writeCursor()}else u.r!==void 0&&(r=null,c=!0);else p(l(r))&&(r=null);let d=t.getComponent();if(d){let e;if((e=d.d)!=null){let t=j[e];t&&(t.get(),a.mergeTree(t.get()),r=i.readCursor(t.get()))}}let m=0,h=0,g=i.advancer(n,void 0,(e,t)=>{f(t)&&m--}),_=i.advancer(r,(e,t)=>p(t)?-(e-h)-1:e-h,(e,t)=>{p(t)&&h++});for(let n of t)if(typeof n==`number`){let r=g(n),i=n+m,o=_(i),l=i+h;a.descend(l),e(t,r,o,a,s,c),a.ascend()}else a.descend(n),e(t,g(n),_(n),a,s,c),a.ascend();g.end(),_.end()}(L,e,e.clone(),R,null,!1),R.reset(),h)return{ok:!1,conflict:h};if(R.get(),G.length){let e=G.map(e=>e?e.get():null);if(U(i.readCursor(V(R.get())),R,(t,n,r)=>{let i=e[t];i&&(r.mergeTree(i),e[t]=null)}),e.find(e=>e)){let t=i.writeCursor(),n=i.writeCursor(),r=0,o=0;e.forEach(e=>{e!=null&&U(i.readCursor(e),null,e=>{let i=H[e];t.writeMove(g[i].getPath(),_[i].getPath(),r++);let a=P[i];a&&a.forEach(e=>{T[e]||m!==1&&N[e]!=null||n.writeMove(v[e].getPath(),y[e].getPath(),o++)})})}),h={type:a.ConflictType.BLACKHOLE,op1:t.get(),op2:n.get()}}}}return h?{ok:!1,conflict:h}:{ok:!0,result:R.get()}}let U=e=>{let t=Error(`Transform detected write conflict`);throw t.conflict=e,t.type=t.name=`writeConflict`,t};function W(e,t,n){let r=H(e,t,n);if(r.ok)return r.result;U(r.conflict)}let G=e=>{let t=i.writeCursor();return i.readCursor(e).traverse(t,(e,t)=>{(p(e)||E(e))&&t.write(`r`,!0)}),t.get()},K=(e,t)=>{let{type:n,op1:r,op2:o}=e;switch(n){case a.ConflictType.DROP_COLLISION:return t===`left`?[null,G(o)]:[G(r),null];case a.ConflictType.RM_UNEXPECTED_CONTENT:let e=!1;return i.readCursor(r).traverse(null,t=>{t.r!==void 0&&(e=!0)}),e?[null,G(o)]:[G(r),null];case a.ConflictType.BLACKHOLE:return[G(r),G(o)];default:throw Error(`Unrecognised conflict: `+n)}};function q(e,t,n,r){let i=null;for(;;){let a=H(t,n,r);if(a.ok)return I(i,a.result);{let{conflict:o}=a;e(o)||U(o);let[s,c]=K(o,r);t=I(N(t),s),n=I(N(n),c),i=I(i,c)}}}})),j=d(l((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!n.hasOwnProperty(r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(A(),e);var r=w();Object.defineProperty(e,`ReadCursor`,{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,`WriteCursor`,{enumerable:!0,get:function(){return r.WriteCursor}});var i=T();Object.defineProperty(e,`ConflictType`,{enumerable:!0,get:function(){return i.ConflictType}})}))());function M(e){"@babel/helpers - typeof";return M=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},M(e)}function N(e,t){if(M(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(M(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function P(e){var t=N(e,`string`);return M(t)==`symbol`?t:t+``}function F(e,t,n){return(t=P(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var I=class{constructor(){F(this,`drawingManagerData`,{}),F(this,`_oldDrawingManagerData`,{}),F(this,`_focusDrawings`,[]),F(this,`_remove$`,new n.Subject),F(this,`remove$`,this._remove$.asObservable()),F(this,`_add$`,new n.Subject),F(this,`add$`,this._add$.asObservable()),F(this,`_update$`,new n.Subject),F(this,`update$`,this._update$.asObservable()),F(this,`_order$`,new n.Subject),F(this,`order$`,this._order$.asObservable()),F(this,`_group$`,new n.Subject),F(this,`group$`,this._group$.asObservable()),F(this,`_ungroup$`,new n.Subject),F(this,`ungroup$`,this._ungroup$.asObservable()),F(this,`_refreshTransform$`,new n.Subject),F(this,`refreshTransform$`,this._refreshTransform$.asObservable()),F(this,`_visible$`,new n.Subject),F(this,`visible$`,this._visible$.asObservable()),F(this,`_focus$`,new n.Subject),F(this,`focus$`,this._focus$.asObservable()),F(this,`_featurePluginUpdate$`,new n.Subject),F(this,`featurePluginUpdate$`,this._featurePluginUpdate$.asObservable()),F(this,`_featurePluginAdd$`,new n.Subject),F(this,`featurePluginAdd$`,this._featurePluginAdd$.asObservable()),F(this,`_featurePluginRemove$`,new n.Subject),F(this,`featurePluginRemove$`,this._featurePluginRemove$.asObservable()),F(this,`_featurePluginOrderUpdate$`,new n.Subject),F(this,`featurePluginOrderUpdate$`,this._featurePluginOrderUpdate$.asObservable()),F(this,`_featurePluginGroupUpdate$`,new n.Subject),F(this,`featurePluginGroupUpdate$`,this._featurePluginGroupUpdate$.asObservable()),F(this,`_featurePluginUngroupUpdate$`,new n.Subject),F(this,`featurePluginUngroupUpdate$`,this._featurePluginUngroupUpdate$.asObservable()),F(this,`_visible`,!0),F(this,`_editable`,!0)}dispose(){this._remove$.complete(),this._add$.complete(),this._update$.complete(),this._order$.complete(),this._focus$.complete(),this._featurePluginUpdate$.complete(),this._featurePluginAdd$.complete(),this._featurePluginRemove$.complete(),this._featurePluginOrderUpdate$.complete(),this.drawingManagerData={},this._oldDrawingManagerData={}}visibleNotification(e){this._visible$.next(e)}refreshTransform(e){e.forEach(e=>{let t=this._getCurrentBySearch(e);t!=null&&(t.transform=e.transform,t.transforms=e.transforms,t.isMultiTransform=e.isMultiTransform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]||{}}removeDrawingDataForUnit(e){let t=this.drawingManagerData[e];if(t==null)return;delete this.drawingManagerData[e];let n=[];Object.keys(t).forEach(r=>{let i=t[r];(i==null?void 0:i.data)!=null&&Object.keys(i.data).forEach(t=>{n.push({unitId:e,subUnitId:r,drawingId:t})})}),n.length>0&&this.removeNotification(n)}registerDrawingData(e,t){this.drawingManagerData[e]=t}initializeNotification(e){let t=[],n=this.drawingManagerData[e];n!=null&&(Object.keys(n).forEach(r=>{this._establishDrawingMap(e,r);let i=n[r];Object.keys(i.data).forEach(n=>{let a=i.data[n];a.unitId=e,a.subUnitId=r,t.push(a)})}),t.length>0&&this.addNotification(t))}getDrawingData(e,t){return this._getDrawingData(e,t)}setDrawingData(e,t,n){this.drawingManagerData[e][t].data=n}getBatchAddOp(e){let t=[],n=[],r=[];e.forEach(e=>{let{op:i,invertOp:a}=this._addByParam(e);t.push({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}),n.push(i),r.push(a)});let i=n.reduce(j.type.compose,null),a=r.reduce(j.type.compose,null),{unitId:o,subUnitId:s}=e[0];return{undo:a,redo:i,unitId:o,subUnitId:s,objects:t}}getBatchRemoveOpInOder(e){if(e.length===0)return{undo:null,redo:null,unitId:``,subUnitId:``,objects:[]};let t=this.getDrawingOrder(e[0].unitId,e[0].subUnitId),n=new Map;return t.forEach((e,t)=>{n.set(e,t)}),e.sort((e,t)=>{var r,i;return((r=n.get(e.drawingId))==null?-1/0:r)-((i=n.get(t.drawingId))==null?-1/0:i)}),this.getBatchRemoveOp(e)}getBatchRemoveOp(e){var n;let r=new Set,i=[];e.forEach(e=>{let n=this.getDrawingByParam(e);if((n==null?void 0:n.drawingType)===t.DrawingTypeEnum.DRAWING_GROUP){let t=this.getDrawingsByGroupNested(e);if(t){let{flatChildren:e,groups:n}=t;[...e==null?[]:e,...n].forEach(e=>{r.has(e.drawingId)||(r.add(e.drawingId),i.push({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}))})}else r.has(e.drawingId)||(r.add(e.drawingId),i.push(e))}else r.has(e.drawingId)||(r.add(e.drawingId),i.push(e))});let{unitId:a,subUnitId:o}=(n=i[0])==null?e[0]:n,s=this._getDrawingOrder(a,o),c=new Map;s.forEach((e,t)=>c.set(e,t)),i.sort((e,t)=>{var n,r;return((n=c.get(e.drawingId))==null?-1/0:n)-((r=c.get(t.drawingId))==null?-1/0:r)});let l=[],u=[];i.forEach(e=>{let{op:t,invertOp:n}=this._removeByParam(e);l.unshift(t),u.push(n)});let d=l.reduce(j.type.compose,null);return{undo:u.reduce(j.type.compose,null),redo:d,unitId:a,subUnitId:o,objects:i}}getBatchUpdateOp(e){let t=[],n=[],r=[];e.forEach(e=>{let{op:i,invertOp:a}=this._updateByParam(e);t.push({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}),n.push(i),r.push(a)});let i=n.reduce(j.type.compose,null),a=r.reduce(j.type.compose,null),{unitId:o,subUnitId:s}=e[0];return{undo:a,redo:i,unitId:o,subUnitId:s,objects:t}}removeNotification(e){this._remove$.next(e)}addNotification(e){this._add$.next(e)}updateNotification(e){this._update$.next(e)}orderNotification(e){this._order$.next(e)}groupUpdateNotification(e){this._group$.next(e)}ungroupUpdateNotification(e){this._ungroup$.next(e)}refreshTransformNotification(e){this._refreshTransform$.next(e)}getGroupDrawingOp(e){let t=[],{unitId:n,subUnitId:r}=e[0].parent;e.forEach(e=>{t.push(this._getGroupDrawingOp(e))});let i=t.reduce(j.type.compose,null);return{undo:j.type.invertWithDoc(i,this.drawingManagerData),redo:i,unitId:n,subUnitId:r,objects:e}}getUngroupDrawingOp(e){let t=[],{unitId:n,subUnitId:r}=e[0].parent;e.forEach(e=>{t.push(this._getUngroupDrawingOp(e))});let i=t.reduce(j.type.compose,null);return{undo:j.type.invertWithDoc(i,this.drawingManagerData),redo:i,unitId:n,subUnitId:r,objects:e}}getDrawingsByGroup(e){let{unitId:t,subUnitId:n,drawingId:r}=e;if(this.getDrawingByParam({unitId:t,subUnitId:n,drawingId:r})==null)return[];let i=this._getDrawingData(t,n),a=[];return Object.keys(i).forEach(e=>{let t=i[e];t.groupId===r&&a.push(t)}),a}getDrawingsByGroupNested(e){let{unitId:n,subUnitId:r}=e,i=this.getDrawingByParam(e);if(!i)return null;let a=this._getDrawingData(n,r),o=new Map;Object.values(a).forEach(e=>{e.groupId!=null&&(o.has(e.groupId)||o.set(e.groupId,[]),o.get(e.groupId).push(e.drawingId))});let s=[],c=[],l={},u=e=>{var n;let{drawingId:r}=e,i=(n=o.get(r))==null?[]:n;l[r]={drawingId:r,children:i},i.forEach(e=>{let n=a[e];n&&(n.drawingType===t.DrawingTypeEnum.DRAWING_GROUP?(u(n),c.push(n)):s.push(n))})};return u(i),c.push(i),{nestedIdRecord:l,flatChildren:s,groups:c}}_getGroupDrawingOp(e){let{parent:t,children:n}=e,{unitId:r,subUnitId:i,drawingId:a}=t,o=[];o.push(j.insertOp([r,i,`data`,a],t));let s=-1/0;return n.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._hasDrawingOrder({unitId:t,subUnitId:n,drawingId:r});s=Math.max(s,i),o.push(...this._getUpdateParamCompareOp(e,this.getDrawingByParam({unitId:t,subUnitId:n,drawingId:r})))}),s===-1/0&&(s=this._getDrawingOrder(r,i).length),o.push(j.insertOp([r,i,`order`,s],a)),o.reduce(j.type.compose,null)}_getUngroupDrawingOp(e){let{parent:t,children:n}=e,{unitId:r,subUnitId:i,drawingId:a}=t,o=[];return n.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e;o.push(...this._getUpdateParamCompareOp(e,this.getDrawingByParam({unitId:t,subUnitId:n,drawingId:r})))}),o.push(j.removeOp([r,i,`data`,a],!0)),o.push(j.removeOp([r,i,`order`,this._getDrawingOrder(r,i).indexOf(a)],!0)),o.reduce(j.type.compose,null)}applyJson1(e,t,n){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=j.type.apply(this.drawingManagerData,n)}featurePluginUpdateNotification(e){this._featurePluginUpdate$.next(e)}featurePluginOrderUpdateNotification(e){this._featurePluginOrderUpdate$.next(e)}featurePluginAddNotification(e){this._featurePluginAdd$.next(e)}featurePluginRemoveNotification(e){this._featurePluginRemove$.next(e)}featurePluginGroupUpdateNotification(e){this._featurePluginGroupUpdate$.next(e)}featurePluginUngroupUpdateNotification(e){this._featurePluginUngroupUpdate$.next(e)}getDrawingByParam(e){return this._getCurrentBySearch(e)}getOldDrawingByParam(e){return this._getOldBySearch(e)}getDrawingOKey(e){let[t,n,r]=e.split(`#-#`);return this._getCurrentBySearch({unitId:t,subUnitId:n,drawingId:r})}focusDrawing(e){if(e==null||e.length===0){this._focusDrawings=[],this._focus$.next([]);return}let t=[];e.forEach(e=>{var n;let{unitId:r,subUnitId:i,drawingId:a}=e,o=(n=this._getDrawingData(r,i))==null?void 0:n[a];o!=null&&t.push(o)}),t.length>0&&(this._focusDrawings=t,this._focus$.next(t))}getFocusDrawings(){let e=[];return this._focusDrawings.forEach(t=>{var n;let{unitId:r,subUnitId:i,drawingId:a}=t,o=(n=this._getDrawingData(r,i))==null?void 0:n[a];o!=null&&e.push(o)}),e}getDrawingOrder(e,t){return this._getDrawingOrder(e,t)}setDrawingOrder(e,t,n){this.drawingManagerData[e][t].order=n}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=[],a=this.getDrawingOrder(t,n),o=[...r];r.forEach(e=>{let r=this._hasDrawingOrder({unitId:t,subUnitId:n,drawingId:e});if(r===-1||r===a.length-1)return;let s=j.moveOp([t,n,`order`,r],[t,n,`order`,r+1]);i.push(s),o.includes(a[r+1])||o.push(a[r+1])});let s=i.reduce(j.type.compose,null);return{undo:j.type.invertWithDoc(s,this.drawingManagerData),redo:s,unitId:t,subUnitId:n,objects:{...e,drawingIds:o}}}getBackwardDrawingOp(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=[],a=this.getDrawingOrder(t,n),o=[...r];r.forEach(e=>{let r=this._hasDrawingOrder({unitId:t,subUnitId:n,drawingId:e});if(r===-1||r===0)return;let s=j.moveOp([t,n,`order`,r],[t,n,`order`,r-1]);i.push(s),o.includes(a[r-1])||o.push(a[r-1])});let s=i.reduce(j.type.compose,null);return{undo:j.type.invertWithDoc(s,this.drawingManagerData),redo:s,unitId:t,subUnitId:n,objects:{...e,drawingIds:o}}}getFrontDrawingsOp(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=this._getOrderFromSearchParams(t,n,r),a=[...r],o=this.getDrawingOrder(t,n),s=[];i.forEach(e=>{let{drawingId:r}=e,i=this._getDrawingCount(t,n)-1,c=j.moveOp([t,n,`order`,this._getDrawingOrder(t,n).indexOf(r)],[t,n,`order`,i]);s.push(c),a.includes(o[i])||a.push(o[i])});let c=s.reduce(j.type.compose,null);return{undo:j.type.invertWithDoc(c,this.drawingManagerData),redo:c,unitId:t,subUnitId:n,objects:{...e,drawingIds:a}}}getBackDrawingsOp(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=this._getOrderFromSearchParams(t,n,r,!0),a=[...r],o=this.getDrawingOrder(t,n),s=[];i.forEach(e=>{let{drawingId:r}=e,i=j.moveOp([t,n,`order`,this._getDrawingOrder(t,n).indexOf(r)],[t,n,`order`,0]);s.push(i),a.includes(o[0])||a.push(o[0])});let c=s.reduce(j.type.compose,null);return{undo:j.type.invertWithDoc(c,this.drawingManagerData),redo:c,unitId:t,subUnitId:n,objects:{...e,drawingIds:a}}}_getDrawingCount(e,t){return this.getDrawingOrder(e,t).length||0}_getOrderFromSearchParams(e,n,r,i=!1){return r.map(t=>({drawingId:t,zIndex:this._hasDrawingOrder({unitId:e,subUnitId:n,drawingId:t})})).sort(i===!1?t.sortRules:t.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;let{unitId:t,subUnitId:n,drawingId:r}=e;return this._establishDrawingMap(t,n),this._getDrawingOrder(t,n).indexOf(r)}_getCurrentBySearch(e){var t;if(e==null)return;let{unitId:n,subUnitId:r,drawingId:i}=e;return(t=this.drawingManagerData[n])==null||(t=t[r])==null||(t=t.data)==null?void 0:t[i]}_getOldBySearch(e){var t;if(e==null)return;let{unitId:n,subUnitId:r,drawingId:i}=e;return(t=this._oldDrawingManagerData[n])==null||(t=t[r])==null||(t=t.data)==null?void 0:t[i]}_establishDrawingMap(e,t,n){var r;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][t]||(this.drawingManagerData[e][t]={data:{},order:[]}),n==null?null:(r=this.drawingManagerData[e][t].data)==null?void 0:r[n]}_addByParam(e){let{unitId:t,subUnitId:n,drawingId:r}=e;this._establishDrawingMap(t,n,r);let i=[j.insertOp([t,n,`data`,r],e),j.insertOp([t,n,`order`,this._getDrawingOrder(t,n).length],r)].reduce(j.type.compose,null);return{op:i,invertOp:j.type.invertWithDoc(i,this.drawingManagerData)}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};let{unitId:t,subUnitId:n,drawingId:r}=e;if(this._establishDrawingMap(t,n,r)==null)return{op:[],invertOp:[]};let i=[j.removeOp([t,n,`data`,r],!0),j.removeOp([t,n,`order`,this._getDrawingOrder(t,n).indexOf(r)],!0)].reduce(j.type.compose,null);return{op:i,invertOp:j.type.invertWithDoc(i,this.drawingManagerData)}}_updateByParam(e){let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._establishDrawingMap(t,n,r);if(i==null)return{op:[],invertOp:[]};let a=this._getUpdateParamCompareOp(e,i).reduce(j.type.compose,null);return{op:a,invertOp:j.type.invertWithDoc(a,this.drawingManagerData)}}_getUpdateParamCompareOp(e,t){let{unitId:n,subUnitId:r,drawingId:i}=e,a=[];return Object.keys(e).forEach(o=>{let s=e[o],c=t[o];c!==s&&a.push(j.replaceOp([n,r,`data`,i,o],c,s))}),a}_getDrawingData(e,t){var n;return((n=this.drawingManagerData[e])==null||(n=n[t])==null?void 0:n.data)||{}}_getDrawingOrder(e,t){var n;return((n=this.drawingManagerData[e])==null||(n=n[t])==null?void 0:n.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}},L=class extends I{},R=class{constructor(){F(this,`_waitCount`,0),F(this,`_change$`,new n.Subject),F(this,`change$`,this._change$),F(this,`_imageSourceCache`,new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,n){if(n===t.ImageSourceType.BASE64){let t=new Image;return t.src=e,t}return this._imageSourceCache.get(e)}addImageSourceCache(e,n,r){n===t.ImageSourceType.BASE64||r==null||this._imageSourceCache.set(e,r)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((n,r)=>{if(!h.includes(e.type)){r(Error(t.ImageUploadStatusType.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>m()){r(Error(t.ImageUploadStatusType.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}let i=new FileReader;i.readAsDataURL(e),i.onload=e=>{var i;let a=(i=e.target)==null?void 0:i.result;if(a==null){r(Error(t.ImageUploadStatusType.ERROR_IMAGE)),this._decreaseWaiting();return}n({imageId:(0,t.generateRandomId)(6),imageSourceType:t.ImageSourceType.BASE64,source:a,base64Cache:a,status:t.ImageUploadStatusType.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){--this._waitCount,this._change$.next(this._waitCount)}},z=class extends t.Disposable{constructor(...e){super(...e),F(this,`_urlImageDownloader`,null)}registerURLImageDownloader(e){return this._urlImageDownloader=e,(0,t.toDisposable)(()=>{this._urlImageDownloader=null})}async getImage(e){if(this._urlImageDownloader)try{return await this._urlImageDownloader(e)}catch(t){console.error(`Custom downloader failed for ${e}, falling back to default behavior:`,t)}return e}async downloadImage(e){if(this._urlImageDownloader)try{let t=await this._urlImageDownloader(e);return await(await fetch(t)).blob()}catch(t){console.error(`Custom downloader failed for ${e}, falling back to default fetch:`,t)}return await(await fetch(e)).blob()}};function B(e,t){return function(n,r){t(n,r,e)}}function V(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let H=class extends t.Plugin{constructor(e=x,n,r,i){super(),this._config=e,this._injector=n,this._configService=r,this._commandService=i;let{...a}=(0,t.merge)({},x,this._config);this._configService.setConfig(b,a),a.allowImageSize!==void 0&&p(a.allowImageSize)}onStarting(){this._initCommands(),this._initDependencies()}_initDependencies(){var e;(0,t.mergeOverrideWithDependencies)([[t.IImageIoService,{useClass:R}],[t.IURLImageService,{useClass:z}],[g,{useClass:L}]],(e=this._config)==null?void 0:e.override).forEach(e=>this._injector.add(e))}_initCommands(){[_].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};F(H,`pluginName`,`UNIVER_DRAWING_PLUGIN`),F(H,`packageName`,v),F(H,`version`,y),H=V([B(1,(0,t.Inject)(t.Injector)),B(2,t.IConfigService),B(3,t.ICommandService)],H);function U({unitId:e,subUnitId:t,drawingId:n},r){return typeof r==`number`?`${e}#-#${t}#-#${n}#-#${r}`:`${e}#-#${t}#-#${n}`}e.DRAWING_IMAGE_ALLOW_IMAGE_LIST=h,e.DRAWING_IMAGE_COUNT_LIMIT=10,e.DRAWING_IMAGE_HEIGHT_LIMIT=500,e.DRAWING_IMAGE_WIDTH_LIMIT=500,e.DrawingManagerService=L,e.IDrawingManagerService=g,Object.defineProperty(e,`IImageIoService`,{enumerable:!0,get:function(){return t.IImageIoService}}),e.ImageIoService=R,Object.defineProperty(e,`ImageSourceType`,{enumerable:!0,get:function(){return t.ImageSourceType}}),Object.defineProperty(e,`ImageUploadStatusType`,{enumerable:!0,get:function(){return t.ImageUploadStatusType}}),e.SetDrawingSelectedOperation=_,e.URLImageService=z,e.UnitDrawingService=I,Object.defineProperty(e,`UniverDrawingPlugin`,{enumerable:!0,get:function(){return H}}),e.getDrawingImageAllowSize=m,e.getDrawingShapeKeyByDrawingSearch=U,e.getImageSize=async e=>new Promise((t,n)=>{let r=new Image;r.src=e,r.onload=()=>{t({width:r.width,height:r.height,image:r})},r.onerror=e=>{n(e)}})});
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/drawing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "",
|
|
6
|
-
"author": "DreamNum <developer@univer.ai>",
|
|
5
|
+
"description": "Shared drawing models, commands, and services for Univer.",
|
|
6
|
+
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"funding": {
|
|
9
9
|
"type": "opencollective",
|
|
@@ -17,7 +17,13 @@
|
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/dream-num/univer/issues"
|
|
19
19
|
},
|
|
20
|
-
"keywords": [
|
|
20
|
+
"keywords": [
|
|
21
|
+
"univer",
|
|
22
|
+
"drawing",
|
|
23
|
+
"graphics",
|
|
24
|
+
"canvas",
|
|
25
|
+
"plugin"
|
|
26
|
+
],
|
|
21
27
|
"exports": {
|
|
22
28
|
".": {
|
|
23
29
|
"import": "./lib/es/index.js",
|
|
@@ -47,13 +53,13 @@
|
|
|
47
53
|
},
|
|
48
54
|
"dependencies": {
|
|
49
55
|
"ot-json1": "^1.0.2",
|
|
50
|
-
"@univerjs/core": "0.
|
|
56
|
+
"@univerjs/core": "0.22.0"
|
|
51
57
|
},
|
|
52
58
|
"devDependencies": {
|
|
53
59
|
"rxjs": "^7.8.2",
|
|
54
|
-
"typescript": "^6.0.
|
|
55
|
-
"vitest": "^4.1.
|
|
56
|
-
"@univerjs-infra/shared": "0.
|
|
60
|
+
"typescript": "^6.0.3",
|
|
61
|
+
"vitest": "^4.1.5",
|
|
62
|
+
"@univerjs-infra/shared": "0.22.0"
|
|
57
63
|
},
|
|
58
64
|
"scripts": {
|
|
59
65
|
"test": "vitest run",
|