@univerjs/drawing 0.25.0-insiders.20260623-012b5a8 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/lib/cjs/index.js CHANGED
@@ -85,7 +85,7 @@ const SetDrawingSelectedOperation = {
85
85
  //#endregion
86
86
  //#region package.json
87
87
  var name = "@univerjs/drawing";
88
- var version = "0.25.0-insiders.20260623-012b5a8";
88
+ var version = "0.25.1";
89
89
 
90
90
  //#endregion
91
91
  //#region src/config/config.ts
@@ -94,7 +94,7 @@ const configSymbol = Symbol(DRAWING_PLUGIN_CONFIG_KEY);
94
94
  const defaultPluginConfig = {};
95
95
 
96
96
  //#endregion
97
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
97
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
98
98
  function _typeof(o) {
99
99
  "@babel/helpers - typeof";
100
100
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -105,7 +105,7 @@ function _typeof(o) {
105
105
  }
106
106
 
107
107
  //#endregion
108
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
108
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
109
109
  function toPrimitive(t, r) {
110
110
  if ("object" != _typeof(t) || !t) return t;
111
111
  var e = t[Symbol.toPrimitive];
@@ -118,14 +118,14 @@ function toPrimitive(t, r) {
118
118
  }
119
119
 
120
120
  //#endregion
121
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
121
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
122
122
  function toPropertyKey(t) {
123
123
  var i = toPrimitive(t, "string");
124
124
  return "symbol" == _typeof(i) ? i : i + "";
125
125
  }
126
126
 
127
127
  //#endregion
128
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
128
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
129
129
  function _defineProperty(e, r, t) {
130
130
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
131
131
  value: t,
@@ -201,8 +201,6 @@ var UnitDrawingService = class {
201
201
  param.transform = updateParam.transform;
202
202
  param.transforms = updateParam.transforms;
203
203
  param.isMultiTransform = updateParam.isMultiTransform;
204
- if ("behindText" in updateParam) param.behindText = updateParam.behindText;
205
- if ("hidden" in updateParam) param.hidden = updateParam.hidden;
206
204
  });
207
205
  this.refreshTransformNotification(updateParams);
208
206
  }
@@ -923,16 +921,12 @@ var ImageIoService = class {
923
921
  this._change$.next(count);
924
922
  }
925
923
  getImageSourceCache(source, imageSourceType) {
926
- const cachedImage = this._imageSourceCache.get(source);
927
- if (cachedImage != null) return cachedImage;
928
924
  if (imageSourceType === _univerjs_core.ImageSourceType.BASE64) {
929
925
  const image = new Image();
930
- image.onload = () => this._change$.next(this._waitCount);
931
- image.onerror = () => this._change$.next(this._waitCount);
932
926
  image.src = source;
933
- this._imageSourceCache.set(source, image);
934
927
  return image;
935
928
  }
929
+ return this._imageSourceCache.get(source);
936
930
  }
937
931
  addImageSourceCache(source, imageSourceType, imageSource) {
938
932
  if (imageSourceType === _univerjs_core.ImageSourceType.BASE64 || imageSource == null) return;
@@ -1013,7 +1007,7 @@ var URLImageService = class extends _univerjs_core.Disposable {
1013
1007
  };
1014
1008
 
1015
1009
  //#endregion
1016
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
1010
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
1017
1011
  function __decorateParam(paramIndex, decorator) {
1018
1012
  return function(target, key) {
1019
1013
  decorator(target, key, paramIndex);
@@ -1021,7 +1015,7 @@ function __decorateParam(paramIndex, decorator) {
1021
1015
  }
1022
1016
 
1023
1017
  //#endregion
1024
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
1018
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
1025
1019
  function __decorate(decorators, target, key, desc) {
1026
1020
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1027
1021
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/lib/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CommandType, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IImageIoService, IImageIoService as IImageIoService$1, IURLImageService, ImageSourceType, ImageSourceType as ImageSourceType$1, ImageUploadStatusType, ImageUploadStatusType as ImageUploadStatusType$1, Inject, Injector, Plugin, createIdentifier, generateRandomId, merge, mergeOverrideWithDependencies, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
1
+ import { CommandType, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IImageIoService, IURLImageService, ImageSourceType, ImageUploadStatusType, Inject, Injector, Plugin, createIdentifier, generateRandomId, merge, mergeOverrideWithDependencies, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
2
2
  import * as json1 from "ot-json1";
3
3
  import { Subject } from "rxjs";
4
4
 
@@ -56,7 +56,7 @@ const SetDrawingSelectedOperation = {
56
56
  //#endregion
57
57
  //#region package.json
58
58
  var name = "@univerjs/drawing";
59
- var version = "0.25.0-insiders.20260623-012b5a8";
59
+ var version = "0.25.1";
60
60
 
61
61
  //#endregion
62
62
  //#region src/config/config.ts
@@ -65,7 +65,7 @@ const configSymbol = Symbol(DRAWING_PLUGIN_CONFIG_KEY);
65
65
  const defaultPluginConfig = {};
66
66
 
67
67
  //#endregion
68
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
68
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
69
69
  function _typeof(o) {
70
70
  "@babel/helpers - typeof";
71
71
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -76,7 +76,7 @@ function _typeof(o) {
76
76
  }
77
77
 
78
78
  //#endregion
79
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
79
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
80
80
  function toPrimitive(t, r) {
81
81
  if ("object" != _typeof(t) || !t) return t;
82
82
  var e = t[Symbol.toPrimitive];
@@ -89,14 +89,14 @@ function toPrimitive(t, r) {
89
89
  }
90
90
 
91
91
  //#endregion
92
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
92
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
93
93
  function toPropertyKey(t) {
94
94
  var i = toPrimitive(t, "string");
95
95
  return "symbol" == _typeof(i) ? i : i + "";
96
96
  }
97
97
 
98
98
  //#endregion
99
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
99
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
100
100
  function _defineProperty(e, r, t) {
101
101
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
102
102
  value: t,
@@ -172,8 +172,6 @@ var UnitDrawingService = class {
172
172
  param.transform = updateParam.transform;
173
173
  param.transforms = updateParam.transforms;
174
174
  param.isMultiTransform = updateParam.isMultiTransform;
175
- if ("behindText" in updateParam) param.behindText = updateParam.behindText;
176
- if ("hidden" in updateParam) param.hidden = updateParam.hidden;
177
175
  });
178
176
  this.refreshTransformNotification(updateParams);
179
177
  }
@@ -894,19 +892,15 @@ var ImageIoService = class {
894
892
  this._change$.next(count);
895
893
  }
896
894
  getImageSourceCache(source, imageSourceType) {
897
- const cachedImage = this._imageSourceCache.get(source);
898
- if (cachedImage != null) return cachedImage;
899
- if (imageSourceType === ImageSourceType$1.BASE64) {
895
+ if (imageSourceType === ImageSourceType.BASE64) {
900
896
  const image = new Image();
901
- image.onload = () => this._change$.next(this._waitCount);
902
- image.onerror = () => this._change$.next(this._waitCount);
903
897
  image.src = source;
904
- this._imageSourceCache.set(source, image);
905
898
  return image;
906
899
  }
900
+ return this._imageSourceCache.get(source);
907
901
  }
908
902
  addImageSourceCache(source, imageSourceType, imageSource) {
909
- if (imageSourceType === ImageSourceType$1.BASE64 || imageSource == null) return;
903
+ if (imageSourceType === ImageSourceType.BASE64 || imageSource == null) return;
910
904
  this._imageSourceCache.set(source, imageSource);
911
905
  }
912
906
  async getImage(imageId) {
@@ -915,12 +909,12 @@ var ImageIoService = class {
915
909
  async saveImage(imageFile) {
916
910
  return new Promise((resolve, reject) => {
917
911
  if (!DRAWING_IMAGE_ALLOW_IMAGE_LIST.includes(imageFile.type)) {
918
- reject(new Error(ImageUploadStatusType$1.ERROR_IMAGE_TYPE));
912
+ reject(new Error(ImageUploadStatusType.ERROR_IMAGE_TYPE));
919
913
  this._decreaseWaiting();
920
914
  return;
921
915
  }
922
916
  if (imageFile.size > getDrawingImageAllowSize()) {
923
- reject(new Error(ImageUploadStatusType$1.ERROR_EXCEED_SIZE));
917
+ reject(new Error(ImageUploadStatusType.ERROR_EXCEED_SIZE));
924
918
  this._decreaseWaiting();
925
919
  return;
926
920
  }
@@ -930,16 +924,16 @@ var ImageIoService = class {
930
924
  var _evt$target;
931
925
  const replaceSrc = (_evt$target = evt.target) === null || _evt$target === void 0 ? void 0 : _evt$target.result;
932
926
  if (replaceSrc == null) {
933
- reject(new Error(ImageUploadStatusType$1.ERROR_IMAGE));
927
+ reject(new Error(ImageUploadStatusType.ERROR_IMAGE));
934
928
  this._decreaseWaiting();
935
929
  return;
936
930
  }
937
931
  resolve({
938
932
  imageId: generateRandomId(6),
939
- imageSourceType: ImageSourceType$1.BASE64,
933
+ imageSourceType: ImageSourceType.BASE64,
940
934
  source: replaceSrc,
941
935
  base64Cache: replaceSrc,
942
- status: ImageUploadStatusType$1.SUCCUSS
936
+ status: ImageUploadStatusType.SUCCUSS
943
937
  });
944
938
  this._decreaseWaiting();
945
939
  };
@@ -984,7 +978,7 @@ var URLImageService = class extends Disposable {
984
978
  };
985
979
 
986
980
  //#endregion
987
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
981
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
988
982
  function __decorateParam(paramIndex, decorator) {
989
983
  return function(target, key) {
990
984
  decorator(target, key, paramIndex);
@@ -992,7 +986,7 @@ function __decorateParam(paramIndex, decorator) {
992
986
  }
993
987
 
994
988
  //#endregion
995
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
989
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
996
990
  function __decorate(decorators, target, key, desc) {
997
991
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
998
992
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1020,7 +1014,7 @@ let UniverDrawingPlugin = class UniverDrawingPlugin extends Plugin {
1020
1014
  _initDependencies() {
1021
1015
  var _this$_config;
1022
1016
  mergeOverrideWithDependencies([
1023
- [IImageIoService$1, { useClass: ImageIoService }],
1017
+ [IImageIoService, { useClass: ImageIoService }],
1024
1018
  [IURLImageService, { useClass: URLImageService }],
1025
1019
  [IDrawingManagerService, { useClass: DrawingManagerService }]
1026
1020
  ], (_this$_config = this._config) === null || _this$_config === void 0 ? void 0 : _this$_config.override).forEach((d) => this._injector.add(d));
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CommandType, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IImageIoService, IImageIoService as IImageIoService$1, IURLImageService, ImageSourceType, ImageSourceType as ImageSourceType$1, ImageUploadStatusType, ImageUploadStatusType as ImageUploadStatusType$1, Inject, Injector, Plugin, createIdentifier, generateRandomId, merge, mergeOverrideWithDependencies, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
1
+ import { CommandType, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IImageIoService, IURLImageService, ImageSourceType, ImageUploadStatusType, Inject, Injector, Plugin, createIdentifier, generateRandomId, merge, mergeOverrideWithDependencies, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
2
2
  import * as json1 from "ot-json1";
3
3
  import { Subject } from "rxjs";
4
4
 
@@ -56,7 +56,7 @@ const SetDrawingSelectedOperation = {
56
56
  //#endregion
57
57
  //#region package.json
58
58
  var name = "@univerjs/drawing";
59
- var version = "0.25.0-insiders.20260623-012b5a8";
59
+ var version = "0.25.1";
60
60
 
61
61
  //#endregion
62
62
  //#region src/config/config.ts
@@ -65,7 +65,7 @@ const configSymbol = Symbol(DRAWING_PLUGIN_CONFIG_KEY);
65
65
  const defaultPluginConfig = {};
66
66
 
67
67
  //#endregion
68
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
68
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
69
69
  function _typeof(o) {
70
70
  "@babel/helpers - typeof";
71
71
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -76,7 +76,7 @@ function _typeof(o) {
76
76
  }
77
77
 
78
78
  //#endregion
79
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
79
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
80
80
  function toPrimitive(t, r) {
81
81
  if ("object" != _typeof(t) || !t) return t;
82
82
  var e = t[Symbol.toPrimitive];
@@ -89,14 +89,14 @@ function toPrimitive(t, r) {
89
89
  }
90
90
 
91
91
  //#endregion
92
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
92
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
93
93
  function toPropertyKey(t) {
94
94
  var i = toPrimitive(t, "string");
95
95
  return "symbol" == _typeof(i) ? i : i + "";
96
96
  }
97
97
 
98
98
  //#endregion
99
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
99
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
100
100
  function _defineProperty(e, r, t) {
101
101
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
102
102
  value: t,
@@ -172,8 +172,6 @@ var UnitDrawingService = class {
172
172
  param.transform = updateParam.transform;
173
173
  param.transforms = updateParam.transforms;
174
174
  param.isMultiTransform = updateParam.isMultiTransform;
175
- if ("behindText" in updateParam) param.behindText = updateParam.behindText;
176
- if ("hidden" in updateParam) param.hidden = updateParam.hidden;
177
175
  });
178
176
  this.refreshTransformNotification(updateParams);
179
177
  }
@@ -894,19 +892,15 @@ var ImageIoService = class {
894
892
  this._change$.next(count);
895
893
  }
896
894
  getImageSourceCache(source, imageSourceType) {
897
- const cachedImage = this._imageSourceCache.get(source);
898
- if (cachedImage != null) return cachedImage;
899
- if (imageSourceType === ImageSourceType$1.BASE64) {
895
+ if (imageSourceType === ImageSourceType.BASE64) {
900
896
  const image = new Image();
901
- image.onload = () => this._change$.next(this._waitCount);
902
- image.onerror = () => this._change$.next(this._waitCount);
903
897
  image.src = source;
904
- this._imageSourceCache.set(source, image);
905
898
  return image;
906
899
  }
900
+ return this._imageSourceCache.get(source);
907
901
  }
908
902
  addImageSourceCache(source, imageSourceType, imageSource) {
909
- if (imageSourceType === ImageSourceType$1.BASE64 || imageSource == null) return;
903
+ if (imageSourceType === ImageSourceType.BASE64 || imageSource == null) return;
910
904
  this._imageSourceCache.set(source, imageSource);
911
905
  }
912
906
  async getImage(imageId) {
@@ -915,12 +909,12 @@ var ImageIoService = class {
915
909
  async saveImage(imageFile) {
916
910
  return new Promise((resolve, reject) => {
917
911
  if (!DRAWING_IMAGE_ALLOW_IMAGE_LIST.includes(imageFile.type)) {
918
- reject(new Error(ImageUploadStatusType$1.ERROR_IMAGE_TYPE));
912
+ reject(new Error(ImageUploadStatusType.ERROR_IMAGE_TYPE));
919
913
  this._decreaseWaiting();
920
914
  return;
921
915
  }
922
916
  if (imageFile.size > getDrawingImageAllowSize()) {
923
- reject(new Error(ImageUploadStatusType$1.ERROR_EXCEED_SIZE));
917
+ reject(new Error(ImageUploadStatusType.ERROR_EXCEED_SIZE));
924
918
  this._decreaseWaiting();
925
919
  return;
926
920
  }
@@ -930,16 +924,16 @@ var ImageIoService = class {
930
924
  var _evt$target;
931
925
  const replaceSrc = (_evt$target = evt.target) === null || _evt$target === void 0 ? void 0 : _evt$target.result;
932
926
  if (replaceSrc == null) {
933
- reject(new Error(ImageUploadStatusType$1.ERROR_IMAGE));
927
+ reject(new Error(ImageUploadStatusType.ERROR_IMAGE));
934
928
  this._decreaseWaiting();
935
929
  return;
936
930
  }
937
931
  resolve({
938
932
  imageId: generateRandomId(6),
939
- imageSourceType: ImageSourceType$1.BASE64,
933
+ imageSourceType: ImageSourceType.BASE64,
940
934
  source: replaceSrc,
941
935
  base64Cache: replaceSrc,
942
- status: ImageUploadStatusType$1.SUCCUSS
936
+ status: ImageUploadStatusType.SUCCUSS
943
937
  });
944
938
  this._decreaseWaiting();
945
939
  };
@@ -984,7 +978,7 @@ var URLImageService = class extends Disposable {
984
978
  };
985
979
 
986
980
  //#endregion
987
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
981
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
988
982
  function __decorateParam(paramIndex, decorator) {
989
983
  return function(target, key) {
990
984
  decorator(target, key, paramIndex);
@@ -992,7 +986,7 @@ function __decorateParam(paramIndex, decorator) {
992
986
  }
993
987
 
994
988
  //#endregion
995
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
989
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
996
990
  function __decorate(decorators, target, key, desc) {
997
991
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
998
992
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1020,7 +1014,7 @@ let UniverDrawingPlugin = class UniverDrawingPlugin extends Plugin {
1020
1014
  _initDependencies() {
1021
1015
  var _this$_config;
1022
1016
  mergeOverrideWithDependencies([
1023
- [IImageIoService$1, { useClass: ImageIoService }],
1017
+ [IImageIoService, { useClass: ImageIoService }],
1024
1018
  [IURLImageService, { useClass: URLImageService }],
1025
1019
  [IDrawingManagerService, { useClass: DrawingManagerService }]
1026
1020
  ], (_this$_config = this._config) === null || _this$_config === void 0 ? void 0 : _this$_config.override).forEach((d) => this._injector.add(d));
@@ -23,8 +23,8 @@ export type { IDrawingJson1Type, IDrawingJsonUndo1 } from './services/drawing-ma
23
23
  export type { IDrawingGroupUpdateParam, IDrawingMap, IDrawingMapItem, IDrawingMapItemData, IDrawingOrderMapParam, IDrawingOrderUpdateParam, IDrawingSubunitMap, IDrawingVisibleParam, IUnitDrawingService, } from './services/drawing-manager.service';
24
24
  export { IDrawingManagerService } from './services/drawing-manager.service';
25
25
  export { ImageIoService } from './services/image-io-impl.service';
26
+ export { IImageIoService, ImageSourceType, ImageUploadStatusType } from './services/image-io.service';
27
+ export type { IImageIoServiceParam } from './services/image-io.service';
26
28
  export { URLImageService } from './services/url-image.service';
27
29
  export { getDrawingShapeKeyByDrawingSearch } from './utils/get-image-shape-key';
28
30
  export { getImageSize } from './utils/get-image-size';
29
- export { IImageIoService, ImageSourceType, ImageUploadStatusType } from '@univerjs/core';
30
- export type { IImageIoServiceParam } from '@univerjs/core';
@@ -13,7 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IDrawingParam, ImageSourceType, ISrcRect, Nullable, Serializable } from '@univerjs/core';
16
+ import type { IDrawingParam, ISrcRect, Nullable, Serializable } from '@univerjs/core';
17
+ import type { ImageSourceType } from '../services/image-io.service';
17
18
  export interface IImageData extends IDrawingParam {
18
19
  imageSourceType: ImageSourceType;
19
20
  source: string;
@@ -13,9 +13,10 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IImageIoService, IImageIoServiceParam, Nullable } from '@univerjs/core';
16
+ import type { Nullable } from '@univerjs/core';
17
17
  import type { Observable } from 'rxjs';
18
- import { ImageSourceType } from '@univerjs/core';
18
+ import type { IImageIoService, IImageIoServiceParam } from './image-io.service';
19
+ import { ImageSourceType } from './image-io.service';
19
20
  export declare class ImageIoService implements IImageIoService {
20
21
  private _waitCount;
21
22
  private _change$;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { IImageIoService, type IImageIoServiceParam, ImageSourceType, ImageUploadStatusType } from '@univerjs/core';
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),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.25.0-insiders.20260623-012b5a8`;let b={};var x=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})),S=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})),C=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})),w=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={}))})),T=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}})),E=l((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;let t=T(),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})),D=l((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=E(),n=T();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}})),O=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=T(),o=r(E()),s=i(D()),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=E();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return u.default}})})),k=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(x()),r=t(S()),i=C(),a=w(),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=>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 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(O());let T=(e,t)=>e+t;y({name:`number`,apply:T,compose:T,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,k=(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);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=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,O=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(O!=null)if(t=d[O],x=c[O]=new i.WriteCursor,j)y&&!w&&x.write(`r`,!0);else{let e=h[O]=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=O==null?n++:h[O];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);k(b,F,n),_.add(M)}else F?k(b,F,D(S)):I&&(k(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)&&k(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}`);k(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:k(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);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=[],O=[],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&&(O[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++}),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};O.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,O){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||(O?h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:I(t==null?null:g[t],c,A),op2:e.removeOp(O.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&&(O=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,O=u.clone()):e!=null&&(b=y[e],m!==1&&N[e]!=null||((w=j[e])||(w=j[e]=i.writeCursor()),w.reset(),O=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(O)h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(c.getPath(),V,t,!0),op2:e.removeOp(O.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);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,O)&&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,O),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]&&!O[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)}}}})),A=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(k(),e);var r=C();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var i=w();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return i.ConflictType}})}))());function j(e){"@babel/helpers - typeof";return j=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},j(e)}function M(e,t){if(j(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(j(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function N(e){var t=M(e,`string`);return j(t)==`symbol`?t:t+``}function P(e,t,n){return(t=N(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=class{constructor(){P(this,`drawingManagerData`,{}),P(this,`_oldDrawingManagerData`,{}),P(this,`_focusDrawings`,[]),P(this,`_remove$`,new n.Subject),P(this,`remove$`,this._remove$.asObservable()),P(this,`_add$`,new n.Subject),P(this,`add$`,this._add$.asObservable()),P(this,`_update$`,new n.Subject),P(this,`update$`,this._update$.asObservable()),P(this,`_order$`,new n.Subject),P(this,`order$`,this._order$.asObservable()),P(this,`_group$`,new n.Subject),P(this,`group$`,this._group$.asObservable()),P(this,`_ungroup$`,new n.Subject),P(this,`ungroup$`,this._ungroup$.asObservable()),P(this,`_refreshTransform$`,new n.Subject),P(this,`refreshTransform$`,this._refreshTransform$.asObservable()),P(this,`_visible$`,new n.Subject),P(this,`visible$`,this._visible$.asObservable()),P(this,`_focus$`,new n.Subject),P(this,`focus$`,this._focus$.asObservable()),P(this,`_featurePluginUpdate$`,new n.Subject),P(this,`featurePluginUpdate$`,this._featurePluginUpdate$.asObservable()),P(this,`_featurePluginAdd$`,new n.Subject),P(this,`featurePluginAdd$`,this._featurePluginAdd$.asObservable()),P(this,`_featurePluginRemove$`,new n.Subject),P(this,`featurePluginRemove$`,this._featurePluginRemove$.asObservable()),P(this,`_featurePluginOrderUpdate$`,new n.Subject),P(this,`featurePluginOrderUpdate$`,this._featurePluginOrderUpdate$.asObservable()),P(this,`_featurePluginGroupUpdate$`,new n.Subject),P(this,`featurePluginGroupUpdate$`,this._featurePluginGroupUpdate$.asObservable()),P(this,`_featurePluginUngroupUpdate$`,new n.Subject),P(this,`featurePluginUngroupUpdate$`,this._featurePluginUngroupUpdate$.asObservable()),P(this,`_visible`,!0),P(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,`behindText`in e&&(t.behindText=e.behindText),`hidden`in e&&(t.hidden=e.hidden))}),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(A.type.compose,null),a=r.reduce(A.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(A.type.compose,null);return{undo:u.reduce(A.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(A.type.compose,null),a=r.reduce(A.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(A.type.compose,null);return{undo:A.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(A.type.compose,null);return{undo:A.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(A.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(A.insertOp([r,i,`order`,s],a)),o.reduce(A.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(A.removeOp([r,i,`data`,a],!0)),o.push(A.removeOp([r,i,`order`,this._getDrawingOrder(r,i).indexOf(a)],!0)),o.reduce(A.type.compose,null)}applyJson1(e,t,n){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=A.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=A.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(A.type.compose,null);return{undo:A.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=A.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(A.type.compose,null);return{undo:A.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=A.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(A.type.compose,null);return{undo:A.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=A.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(A.type.compose,null);return{undo:A.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=[A.insertOp([t,n,`data`,r],e),A.insertOp([t,n,`order`,this._getDrawingOrder(t,n).length],r)].reduce(A.type.compose,null);return{op:i,invertOp:A.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=[A.removeOp([t,n,`data`,r],!0),A.removeOp([t,n,`order`,this._getDrawingOrder(t,n).indexOf(r)],!0)].reduce(A.type.compose,null);return{op:i,invertOp:A.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(A.type.compose,null);return{op:a,invertOp:A.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(A.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}},I=class extends F{},L=class{constructor(){P(this,`_waitCount`,0),P(this,`_change$`,new n.Subject),P(this,`change$`,this._change$),P(this,`_imageSourceCache`,new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,n){let r=this._imageSourceCache.get(e);if(r!=null)return r;if(n===t.ImageSourceType.BASE64){let t=new Image;return t.onload=()=>this._change$.next(this._waitCount),t.onerror=()=>this._change$.next(this._waitCount),t.src=e,this._imageSourceCache.set(e,t),t}}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)}},R=class extends t.Disposable{constructor(...e){super(...e),P(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 z(e,t){return function(n,r){t(n,r,e)}}function B(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 V=class extends t.Plugin{constructor(e=b,n,r,i){super(),this._config=e,this._injector=n,this._configService=r,this._commandService=i;let{...a}=(0,t.merge)({},b,this._config);this._configService.setConfig(`drawing.config`,a),a.allowImageSize!==void 0&&p(a.allowImageSize)}onStarting(){this._initCommands(),this._initDependencies()}_initDependencies(){var e;(0,t.mergeOverrideWithDependencies)([[t.IImageIoService,{useClass:L}],[t.IURLImageService,{useClass:R}],[g,{useClass:I}]],(e=this._config)==null?void 0:e.override).forEach(e=>this._injector.add(e))}_initCommands(){[_].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};P(V,`pluginName`,`UNIVER_DRAWING_PLUGIN`),P(V,`packageName`,v),P(V,`version`,y),V=B([z(1,(0,t.Inject)(t.Injector)),z(2,t.IConfigService),z(3,t.ICommandService)],V);function H({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=I,e.IDrawingManagerService=g,Object.defineProperty(e,"IImageIoService",{enumerable:!0,get:function(){return t.IImageIoService}}),e.ImageIoService=L,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=R,e.UnitDrawingService=F,Object.defineProperty(e,"UniverDrawingPlugin",{enumerable:!0,get:function(){return V}}),e.getDrawingImageAllowSize=m,e.getDrawingShapeKeyByDrawingSearch=H,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.25.1`;let b={};var x=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})),S=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})),C=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})),w=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={}))})),T=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}})),E=l((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;let t=T(),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})),D=l((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=E(),n=T();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}})),O=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=T(),o=r(E()),s=i(D()),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=E();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return u.default}})})),k=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(x()),r=t(S()),i=C(),a=w(),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=>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 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(O());let T=(e,t)=>e+t;y({name:`number`,apply:T,compose:T,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,k=(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);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=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,O=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(O!=null)if(t=d[O],x=c[O]=new i.WriteCursor,j)y&&!w&&x.write(`r`,!0);else{let e=h[O]=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=O==null?n++:h[O];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);k(b,F,n),_.add(M)}else F?k(b,F,D(S)):I&&(k(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)&&k(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}`);k(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:k(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);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=[],O=[],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&&(O[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++}),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};O.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,O){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||(O?h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:I(t==null?null:g[t],c,A),op2:e.removeOp(O.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&&(O=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,O=u.clone()):e!=null&&(b=y[e],m!==1&&N[e]!=null||((w=j[e])||(w=j[e]=i.writeCursor()),w.reset(),O=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(O)h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(c.getPath(),V,t,!0),op2:e.removeOp(O.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);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,O)&&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,O),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]&&!O[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)}}}})),A=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(k(),e);var r=C();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var i=w();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return i.ConflictType}})}))());function j(e){"@babel/helpers - typeof";return j=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},j(e)}function M(e,t){if(j(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(j(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function N(e){var t=M(e,`string`);return j(t)==`symbol`?t:t+``}function P(e,t,n){return(t=N(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=class{constructor(){P(this,`drawingManagerData`,{}),P(this,`_oldDrawingManagerData`,{}),P(this,`_focusDrawings`,[]),P(this,`_remove$`,new n.Subject),P(this,`remove$`,this._remove$.asObservable()),P(this,`_add$`,new n.Subject),P(this,`add$`,this._add$.asObservable()),P(this,`_update$`,new n.Subject),P(this,`update$`,this._update$.asObservable()),P(this,`_order$`,new n.Subject),P(this,`order$`,this._order$.asObservable()),P(this,`_group$`,new n.Subject),P(this,`group$`,this._group$.asObservable()),P(this,`_ungroup$`,new n.Subject),P(this,`ungroup$`,this._ungroup$.asObservable()),P(this,`_refreshTransform$`,new n.Subject),P(this,`refreshTransform$`,this._refreshTransform$.asObservable()),P(this,`_visible$`,new n.Subject),P(this,`visible$`,this._visible$.asObservable()),P(this,`_focus$`,new n.Subject),P(this,`focus$`,this._focus$.asObservable()),P(this,`_featurePluginUpdate$`,new n.Subject),P(this,`featurePluginUpdate$`,this._featurePluginUpdate$.asObservable()),P(this,`_featurePluginAdd$`,new n.Subject),P(this,`featurePluginAdd$`,this._featurePluginAdd$.asObservable()),P(this,`_featurePluginRemove$`,new n.Subject),P(this,`featurePluginRemove$`,this._featurePluginRemove$.asObservable()),P(this,`_featurePluginOrderUpdate$`,new n.Subject),P(this,`featurePluginOrderUpdate$`,this._featurePluginOrderUpdate$.asObservable()),P(this,`_featurePluginGroupUpdate$`,new n.Subject),P(this,`featurePluginGroupUpdate$`,this._featurePluginGroupUpdate$.asObservable()),P(this,`_featurePluginUngroupUpdate$`,new n.Subject),P(this,`featurePluginUngroupUpdate$`,this._featurePluginUngroupUpdate$.asObservable()),P(this,`_visible`,!0),P(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(A.type.compose,null),a=r.reduce(A.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(A.type.compose,null);return{undo:u.reduce(A.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(A.type.compose,null),a=r.reduce(A.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(A.type.compose,null);return{undo:A.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(A.type.compose,null);return{undo:A.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(A.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(A.insertOp([r,i,`order`,s],a)),o.reduce(A.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(A.removeOp([r,i,`data`,a],!0)),o.push(A.removeOp([r,i,`order`,this._getDrawingOrder(r,i).indexOf(a)],!0)),o.reduce(A.type.compose,null)}applyJson1(e,t,n){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=A.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=A.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(A.type.compose,null);return{undo:A.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=A.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(A.type.compose,null);return{undo:A.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=A.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(A.type.compose,null);return{undo:A.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=A.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(A.type.compose,null);return{undo:A.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=[A.insertOp([t,n,`data`,r],e),A.insertOp([t,n,`order`,this._getDrawingOrder(t,n).length],r)].reduce(A.type.compose,null);return{op:i,invertOp:A.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=[A.removeOp([t,n,`data`,r],!0),A.removeOp([t,n,`order`,this._getDrawingOrder(t,n).indexOf(r)],!0)].reduce(A.type.compose,null);return{op:i,invertOp:A.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(A.type.compose,null);return{op:a,invertOp:A.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(A.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}},I=class extends F{},L=class{constructor(){P(this,`_waitCount`,0),P(this,`_change$`,new n.Subject),P(this,`change$`,this._change$),P(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)}},R=class extends t.Disposable{constructor(...e){super(...e),P(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 z(e,t){return function(n,r){t(n,r,e)}}function B(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 V=class extends t.Plugin{constructor(e=b,n,r,i){super(),this._config=e,this._injector=n,this._configService=r,this._commandService=i;let{...a}=(0,t.merge)({},b,this._config);this._configService.setConfig(`drawing.config`,a),a.allowImageSize!==void 0&&p(a.allowImageSize)}onStarting(){this._initCommands(),this._initDependencies()}_initDependencies(){var e;(0,t.mergeOverrideWithDependencies)([[t.IImageIoService,{useClass:L}],[t.IURLImageService,{useClass:R}],[g,{useClass:I}]],(e=this._config)==null?void 0:e.override).forEach(e=>this._injector.add(e))}_initCommands(){[_].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};P(V,`pluginName`,`UNIVER_DRAWING_PLUGIN`),P(V,`packageName`,v),P(V,`version`,y),V=B([z(1,(0,t.Inject)(t.Injector)),z(2,t.IConfigService),z(3,t.ICommandService)],V);function H({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=I,e.IDrawingManagerService=g,Object.defineProperty(e,"IImageIoService",{enumerable:!0,get:function(){return t.IImageIoService}}),e.ImageIoService=L,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=R,e.UnitDrawingService=F,Object.defineProperty(e,"UniverDrawingPlugin",{enumerable:!0,get:function(){return V}}),e.getDrawingImageAllowSize=m,e.getDrawingShapeKeyByDrawingSearch=H,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,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/drawing",
3
- "version": "0.25.0-insiders.20260623-012b5a8",
3
+ "version": "0.25.1",
4
4
  "private": false,
5
5
  "description": "Shared drawing models, commands, and services for Univer.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -53,13 +53,13 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "ot-json1": "^1.0.2",
56
- "@univerjs/core": "0.25.0-insiders.20260623-012b5a8"
56
+ "@univerjs/core": "0.25.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "rxjs": "^7.8.2",
60
60
  "typescript": "^6.0.3",
61
- "vitest": "^4.1.9",
62
- "@univerjs-infra/shared": "0.25.0"
61
+ "vitest": "^4.1.7",
62
+ "@univerjs-infra/shared": "0.25.1"
63
63
  },
64
64
  "scripts": {
65
65
  "test": "vitest run",