@netless/forge-imagery-doc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/build.mjs +34 -0
  2. package/dist/Cont.d.ts +1 -0
  3. package/dist/Cont.d.ts.map +1 -0
  4. package/dist/Container.d.ts +16 -0
  5. package/dist/Container.d.ts.map +1 -0
  6. package/dist/ContinuousContainer.d.ts +31 -0
  7. package/dist/ContinuousContainer.d.ts.map +1 -0
  8. package/dist/FooterView.d.ts +18 -0
  9. package/dist/FooterView.d.ts.map +1 -0
  10. package/dist/ImageryDoc.d.ts +57 -0
  11. package/dist/ImageryDoc.d.ts.map +1 -0
  12. package/dist/ImageryDocApplication.d.ts +38 -0
  13. package/dist/ImageryDocApplication.d.ts.map +1 -0
  14. package/dist/ImageryDocPermissions.d.ts +80 -0
  15. package/dist/ImageryDocPermissions.d.ts.map +1 -0
  16. package/dist/InfinityScroll.d.ts +15 -0
  17. package/dist/InfinityScroll.d.ts.map +1 -0
  18. package/dist/LazyImage.d.ts +11 -0
  19. package/dist/LazyImage.d.ts.map +1 -0
  20. package/dist/SideBarView.d.ts +4 -0
  21. package/dist/SideBarView.d.ts.map +1 -0
  22. package/dist/SingleContainer.d.ts +36 -0
  23. package/dist/SingleContainer.d.ts.map +1 -0
  24. package/dist/icons.d.ts +6 -0
  25. package/dist/icons.d.ts.map +1 -0
  26. package/dist/imagery-doc.esm.js +1031 -0
  27. package/dist/imagery-doc.esm.js.map +7 -0
  28. package/dist/imagery-doc.js +1064 -0
  29. package/dist/imagery-doc.js.map +7 -0
  30. package/dist/index.d.ts +5 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/infinityScrollor.d.ts +5 -0
  33. package/dist/infinityScrollor.d.ts.map +1 -0
  34. package/package.json +23 -0
  35. package/src/Container.ts +17 -0
  36. package/src/ContinuousContainer.ts +157 -0
  37. package/src/FooterView.ts +139 -0
  38. package/src/ImageryDoc.ts +64 -0
  39. package/src/ImageryDocApplication.ts +225 -0
  40. package/src/ImageryDocPermissions.ts +159 -0
  41. package/src/InfinityScroll.ts +55 -0
  42. package/src/LazyImage.ts +66 -0
  43. package/src/SingleContainer.ts +248 -0
  44. package/src/icons.ts +9 -0
  45. package/src/index.ts +5 -0
  46. package/tsconfig.json +7 -0
@@ -0,0 +1,1031 @@
1
+ // src/ImageryDoc.ts
2
+ import EventEmitter from "eventemitter3";
3
+ function _defineProperty(e, r, t) {
4
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
5
+ }
6
+ function _toPropertyKey(t) {
7
+ var i = _toPrimitive(t, "string");
8
+ return "symbol" == typeof i ? i : i + "";
9
+ }
10
+ function _toPrimitive(t, r) {
11
+ if ("object" != typeof t || !t) return t;
12
+ var e = t[Symbol.toPrimitive];
13
+ if (void 0 !== e) {
14
+ var i = e.call(t, r || "default");
15
+ if ("object" != typeof i) return i;
16
+ throw new TypeError("@@toPrimitive must return a primitive value.");
17
+ }
18
+ return ("string" === r ? String : Number)(t);
19
+ }
20
+ var ImageryDoc = class extends EventEmitter {
21
+ constructor() {
22
+ super(...arguments);
23
+ _defineProperty(this, "view", void 0);
24
+ _defineProperty(this, "footView", void 0);
25
+ _defineProperty(this, "permissions", void 0);
26
+ _defineProperty(this, "pageIndex", void 0);
27
+ _defineProperty(this, "pageCount", void 0);
28
+ _defineProperty(this, "goto", void 0);
29
+ _defineProperty(this, "imgContent", void 0);
30
+ _defineProperty(this, "imgSize", void 0);
31
+ }
32
+ };
33
+
34
+ // src/ImageryDocApplication.ts
35
+ import { AbstractApplication } from "@netless/forge-room";
36
+ import { WhiteboardApplication, WhiteboardPermissionFlag } from "@netless/forge-whiteboard";
37
+
38
+ // src/LazyImage.ts
39
+ import { kvStore } from "@netless/forge-room";
40
+ function _defineProperty2(e, r, t) {
41
+ return (r = _toPropertyKey2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
42
+ }
43
+ function _toPropertyKey2(t) {
44
+ var i = _toPrimitive2(t, "string");
45
+ return "symbol" == typeof i ? i : i + "";
46
+ }
47
+ function _toPrimitive2(t, r) {
48
+ if ("object" != typeof t || !t) return t;
49
+ var e = t[Symbol.toPrimitive];
50
+ if (void 0 !== e) {
51
+ var i = e.call(t, r || "default");
52
+ if ("object" != typeof i) return i;
53
+ throw new TypeError("@@toPrimitive must return a primitive value.");
54
+ }
55
+ return ("string" === r ? String : Number)(t);
56
+ }
57
+ var LazyImage = class {
58
+ constructor(src, width, height) {
59
+ _defineProperty2(this, "view", void 0);
60
+ _defineProperty2(this, "width", void 0);
61
+ _defineProperty2(this, "height", void 0);
62
+ _defineProperty2(this, "src", void 0);
63
+ this.src = src;
64
+ this.width = width;
65
+ this.height = height;
66
+ this.view = document.createElement("div");
67
+ this.view.setAttribute("data-forge-src", src);
68
+ this.view.style.width = `${width}px`;
69
+ this.view.style.height = `${height}px`;
70
+ this.view.style.transformOrigin = "0 0";
71
+ }
72
+ scale(scale) {
73
+ this.view.style.width = `${this.width * scale}px`;
74
+ this.view.style.height = `${this.height * scale}px`;
75
+ }
76
+ async getImgContent() {
77
+ let base64Data = null;
78
+ try {
79
+ base64Data = await kvStore.getItem(this.src);
80
+ } catch {
81
+ }
82
+ if (base64Data) {
83
+ return base64Data;
84
+ }
85
+ const response = await fetch(this.src);
86
+ const blob = await response.blob();
87
+ return new Promise((resolve, reject) => {
88
+ const reader = new FileReader();
89
+ reader.onload = (e) => {
90
+ kvStore.setItem(this.src, reader.result);
91
+ resolve(reader.result);
92
+ };
93
+ reader.onerror = () => {
94
+ reject(reader.error);
95
+ };
96
+ reader.readAsDataURL(blob);
97
+ });
98
+ }
99
+ async prepare() {
100
+ if (this.view.children.length > 0) {
101
+ return;
102
+ }
103
+ const base64Data = await this.getImgContent();
104
+ const img = document.createElement("img");
105
+ img.src = base64Data;
106
+ img.style.width = "100%";
107
+ if (this.view.children.length === 0) {
108
+ this.view.appendChild(img);
109
+ }
110
+ }
111
+ };
112
+
113
+ // src/ImageryDocPermissions.ts
114
+ import EventEmitter2 from "eventemitter3";
115
+ function _defineProperty3(e, r, t) {
116
+ return (r = _toPropertyKey3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
117
+ }
118
+ function _toPropertyKey3(t) {
119
+ var i = _toPrimitive3(t, "string");
120
+ return "symbol" == typeof i ? i : i + "";
121
+ }
122
+ function _toPrimitive3(t, r) {
123
+ if ("object" != typeof t || !t) return t;
124
+ var e = t[Symbol.toPrimitive];
125
+ if (void 0 !== e) {
126
+ var i = e.call(t, r || "default");
127
+ if ("object" != typeof i) return i;
128
+ throw new TypeError("@@toPrimitive must return a primitive value.");
129
+ }
130
+ return ("string" === r ? String : Number)(t);
131
+ }
132
+ var ImageryDocPermissionFlag = function(ImageryDocPermissionFlag2) {
133
+ ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["none"] = 0] = "none";
134
+ ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["switchPage"] = 1] = "switchPage";
135
+ ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["camera"] = 2] = "camera";
136
+ ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["sideBar"] = 4] = "sideBar";
137
+ ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["all"] = ImageryDocPermissionFlag2.switchPage | ImageryDocPermissionFlag2.camera | ImageryDocPermissionFlag2.sideBar] = "all";
138
+ return ImageryDocPermissionFlag2;
139
+ }({});
140
+ var ImageryDocPermissions = class extends EventEmitter2 {
141
+ constructor(userManager, requestUserMap) {
142
+ super();
143
+ _defineProperty3(this, "requestUserMap", void 0);
144
+ _defineProperty3(this, "userManager", void 0);
145
+ _defineProperty3(this, "observers", /* @__PURE__ */ new Map());
146
+ _defineProperty3(this, "handleUserLeave", (user) => {
147
+ const cb = this.observers.get(user.id);
148
+ if (cb) {
149
+ this.requestUserMap(user.id).unobserve(cb);
150
+ }
151
+ });
152
+ _defineProperty3(this, "handleUserJoin", (user) => {
153
+ this.addObserve(user.id);
154
+ });
155
+ this.userManager = userManager;
156
+ this.requestUserMap = requestUserMap;
157
+ this.createModel(this.userManager.selfId);
158
+ this.userManager.userIdList().forEach((userId) => {
159
+ this.addObserve(userId);
160
+ });
161
+ this.userManager.on("join", this.handleUserJoin);
162
+ this.userManager.on("leave", this.handleUserLeave);
163
+ }
164
+ addObserve(userId) {
165
+ const observer = (evt) => {
166
+ this.handleUserPermissionChange(userId, evt);
167
+ };
168
+ this.observers.set(userId, observer);
169
+ this.requestUserMap(userId).observe(observer);
170
+ }
171
+ createModel(userId) {
172
+ const userMap = this.requestUserMap(userId);
173
+ if (!userMap.has("permission")) {
174
+ userMap.set("permission", 0);
175
+ }
176
+ }
177
+ handleUserPermissionChange(userId, evt) {
178
+ for (const [key, value] of evt.changes.keys.entries()) {
179
+ if (key === "permission") {
180
+ if (value.action === "add" || value.action === "update") {
181
+ const newValue = this.requestUserMap(userId).get("permission");
182
+ this.emit("change", userId, this.resolveFlags(newValue), newValue);
183
+ }
184
+ }
185
+ }
186
+ }
187
+ /**
188
+ * 解析权限列表组合
189
+ * @param {number} value - 权限数字值
190
+ * @return {WhiteboardPermissionFlag[]} - 权限列表
191
+ */
192
+ resolveFlags(value) {
193
+ return [ImageryDocPermissionFlag.switchPage, ImageryDocPermissionFlag.sideBar, ImageryDocPermissionFlag.camera].filter((v) => (v & value) !== 0);
194
+ }
195
+ /**
196
+ * 获取权限列表组合对应的数值
197
+ * @param { string } userId 不传表示获取自己
198
+ */
199
+ getPermissionValue(userId) {
200
+ return this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
201
+ }
202
+ /**
203
+ * 获取权限列表
204
+ * @param {string=} userId 可选, 不传表示获取自己
205
+ */
206
+ getPermissionFlags(userId) {
207
+ const value = this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
208
+ return this.resolveFlags(value);
209
+ }
210
+ /**
211
+ * 返回对应 userId 是否有相应权限
212
+ * @param {string=} userId 可选, 不传表示返回自己是否有相应权限
213
+ * @param {WhiteboardPermissionFlag} flag
214
+ */
215
+ hasPermission(flag, userId) {
216
+ return ((this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0) & flag) !== 0;
217
+ }
218
+ /**
219
+ * 添加权限
220
+ * @param {WhiteboardPermissionFlag} flag 权限标记
221
+ * @param {string=} userId 可选, 为 userId 添加权限, 不传表示为自己添加权限
222
+ */
223
+ addPermission(flag, userId) {
224
+ const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
225
+ const oldValue = userMap.get("permission") ?? 0;
226
+ this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue | flag);
227
+ }
228
+ /**
229
+ * 移除权限
230
+ * @param {WhiteboardPermissionFlag} flag 权限标记
231
+ * @param {string=} userId 可选, 为 userId 移除权限, 不传表示为自己移除权限
232
+ */
233
+ removePermission(flag, userId) {
234
+ const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
235
+ const oldValue = userMap.get("permission") ?? 0;
236
+ this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue & ~flag);
237
+ }
238
+ };
239
+
240
+ // src/icons.ts
241
+ var chevronLeft = (color) => `<svg style="width:100%;height:100%;padding:2px;box-sizing:border-box;" viewBox="0 0 12.3926 16.9629"><g><rect height="16.9629" opacity="0" width="12.3926" x="0" y="0"/><path d="M0 8.47656C0 8.7207 0.0878906 8.93555 0.273438 9.12109L8.01758 16.6895C8.18359 16.8652 8.39844 16.9531 8.65234 16.9531C9.16016 16.9531 9.55078 16.5723 9.55078 16.0645C9.55078 15.8105 9.44336 15.5957 9.28711 15.4297L2.17773 8.47656L9.28711 1.52344C9.44336 1.35742 9.55078 1.13281 9.55078 0.888672C9.55078 0.380859 9.16016 0 8.65234 0C8.39844 0 8.18359 0.0878906 8.01758 0.253906L0.273438 7.83203C0.0878906 8.00781 0 8.23242 0 8.47656Z" fill="${color}"/></g></svg>`;
242
+ var chevronRight = (color) => `<svg style="width:100%;height:100%;padding:2px;box-sizing:border-box;" viewBox="0 0 11.6895 16.9629"><g><rect height="16.9629" opacity="0" width="11.6895" x="0" y="0"/><path d="M11.6895 8.47656C11.6895 8.23242 11.5918 8.00781 11.4062 7.83203L3.67188 0.253906C3.49609 0.0878906 3.28125 0 3.02734 0C2.5293 0 2.13867 0.380859 2.13867 0.888672C2.13867 1.13281 2.23633 1.35742 2.39258 1.52344L9.50195 8.47656L2.39258 15.4297C2.23633 15.5957 2.13867 15.8105 2.13867 16.0645C2.13867 16.5723 2.5293 16.9531 3.02734 16.9531C3.28125 16.9531 3.49609 16.8652 3.67188 16.6895L11.4062 9.12109C11.5918 8.93555 11.6895 8.7207 11.6895 8.47656Z" fill="${color}"/></g></svg>`;
243
+ var sideBar = (color) => `<svg style="width:100%;height:100%;padding:2px;box-sizing:border-box;" viewBox="0 0 23.3887 17.998"><g><rect height="17.998" opacity="0" width="23.3887" x="0" y="0"/><path d="M3.06641 17.998L19.9609 17.998C22.0117 17.998 23.0273 16.9824 23.0273 14.9707L23.0273 3.04688C23.0273 1.03516 22.0117 0.0195312 19.9609 0.0195312L3.06641 0.0195312C1.02539 0.0195312 0 1.02539 0 3.04688L0 14.9707C0 16.9922 1.02539 17.998 3.06641 17.998ZM3.08594 16.4258C2.10938 16.4258 1.57227 15.9082 1.57227 14.8926L1.57227 3.125C1.57227 2.10938 2.10938 1.5918 3.08594 1.5918L19.9414 1.5918C20.9082 1.5918 21.4551 2.10938 21.4551 3.125L21.4551 14.8926C21.4551 15.9082 20.9082 16.4258 19.9414 16.4258ZM7.44141 16.7285L8.97461 16.7285L8.97461 1.29883L7.44141 1.29883ZM5.56641 5.21484C5.85938 5.21484 6.12305 4.95117 6.12305 4.66797C6.12305 4.375 5.85938 4.12109 5.56641 4.12109L3.4668 4.12109C3.17383 4.12109 2.91992 4.375 2.91992 4.66797C2.91992 4.95117 3.17383 5.21484 3.4668 5.21484ZM5.56641 7.74414C5.85938 7.74414 6.12305 7.48047 6.12305 7.1875C6.12305 6.89453 5.85938 6.65039 5.56641 6.65039L3.4668 6.65039C3.17383 6.65039 2.91992 6.89453 2.91992 7.1875C2.91992 7.48047 3.17383 7.74414 3.4668 7.74414ZM5.56641 10.2637C5.85938 10.2637 6.12305 10.0195 6.12305 9.72656C6.12305 9.43359 5.85938 9.17969 5.56641 9.17969L3.4668 9.17969C3.17383 9.17969 2.91992 9.43359 2.91992 9.72656C2.91992 10.0195 3.17383 10.2637 3.4668 10.2637Z" fill="${color}"/></g></svg>`;
244
+ var Icons = {
245
+ chevronLeft,
246
+ chevronRight,
247
+ sideBar
248
+ };
249
+
250
+ // src/FooterView.ts
251
+ function _defineProperty4(e, r, t) {
252
+ return (r = _toPropertyKey4(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
253
+ }
254
+ function _toPropertyKey4(t) {
255
+ var i = _toPrimitive4(t, "string");
256
+ return "symbol" == typeof i ? i : i + "";
257
+ }
258
+ function _toPrimitive4(t, r) {
259
+ if ("object" != typeof t || !t) return t;
260
+ var e = t[Symbol.toPrimitive];
261
+ if (void 0 !== e) {
262
+ var i = e.call(t, r || "default");
263
+ if ("object" != typeof i) return i;
264
+ throw new TypeError("@@toPrimitive must return a primitive value.");
265
+ }
266
+ return ("string" === r ? String : Number)(t);
267
+ }
268
+ var EM_COLOR = "#8C8C8C";
269
+ var FooterView = class {
270
+ constructor(imageryDoc) {
271
+ _defineProperty4(this, "root", void 0);
272
+ _defineProperty4(this, "prevPage", void 0);
273
+ _defineProperty4(this, "nextPage", void 0);
274
+ _defineProperty4(this, "sideBarToggle", void 0);
275
+ _defineProperty4(this, "sideBarContainer", document.createElement("div"));
276
+ _defineProperty4(this, "isSlideBarVisible", false);
277
+ _defineProperty4(this, "imageryDoc", void 0);
278
+ _defineProperty4(this, "handleSideBarClick", (evt) => {
279
+ const target = evt.target;
280
+ const targetIndex = target.getAttribute("data-doc-index");
281
+ if (targetIndex) {
282
+ this.imageryDoc.goto(parseInt(targetIndex, 10));
283
+ }
284
+ });
285
+ this.imageryDoc = imageryDoc;
286
+ this.root = document.createElement("div");
287
+ this.root.style.height = "24px";
288
+ this.root.style.zIndex = "2";
289
+ this.root.style.display = "flex";
290
+ this.root.style.alignItems = "center";
291
+ this.root.style.backgroundColor = "#fff";
292
+ this.root.style.borderTop = "1px solid #f0f0f0";
293
+ this.prevPage = this.createIcon(Icons.chevronLeft(EM_COLOR), "18px", () => {
294
+ this.imageryDoc.goto(this.imageryDoc.pageIndex - 1);
295
+ });
296
+ this.nextPage = this.createIcon(Icons.chevronRight(EM_COLOR), "18px", () => {
297
+ this.imageryDoc.goto(this.imageryDoc.pageIndex + 1);
298
+ });
299
+ this.sideBarToggle = this.createIcon(Icons.sideBar(EM_COLOR), "20px", () => {
300
+ this.createSideBar();
301
+ this.isSlideBarVisible = !this.isSlideBarVisible;
302
+ if (this.isSlideBarVisible) {
303
+ this.sideBarContainer.style.display = "block";
304
+ } else {
305
+ this.sideBarContainer.style.display = "none";
306
+ }
307
+ });
308
+ this.root.appendChild(this.sideBarToggle);
309
+ this.root.appendChild(this.createSpacer());
310
+ this.root.appendChild(this.prevPage);
311
+ this.root.appendChild(this.nextPage);
312
+ this.root.appendChild(this.createSpacer());
313
+ }
314
+ prevPageState(enable) {
315
+ if (enable) {
316
+ this.prevPage.style.pointerEvents = "all";
317
+ this.prevPage.style.opacity = "1";
318
+ } else {
319
+ this.prevPage.style.pointerEvents = "none";
320
+ this.prevPage.style.opacity = "0.5";
321
+ }
322
+ }
323
+ nextPageState(enable) {
324
+ if (enable) {
325
+ this.nextPage.style.pointerEvents = "all";
326
+ this.nextPage.style.opacity = "1";
327
+ } else {
328
+ this.nextPage.style.pointerEvents = "none";
329
+ this.nextPage.style.opacity = "0.5";
330
+ }
331
+ }
332
+ createSpacer() {
333
+ const div = document.createElement("div");
334
+ div.style.flex = "1 1 auto";
335
+ return div;
336
+ }
337
+ createIcon(svgContent, size, action) {
338
+ const icon = document.createElement("div");
339
+ icon.style.width = size;
340
+ icon.style.height = size;
341
+ icon.style.borderRadius = "2px";
342
+ icon.style.margin = "6px";
343
+ icon.innerHTML = svgContent;
344
+ icon.addEventListener("click", () => {
345
+ action();
346
+ });
347
+ icon.addEventListener("mouseover", () => {
348
+ icon.style.backgroundColor = "#f0f0f0";
349
+ });
350
+ icon.addEventListener("mouseout", () => {
351
+ icon.style.backgroundColor = "transparent";
352
+ });
353
+ return icon;
354
+ }
355
+ createSideBar() {
356
+ if (this.imageryDoc.pageCount === 0) {
357
+ return;
358
+ }
359
+ if (this.root.contains(this.sideBarContainer)) {
360
+ return;
361
+ }
362
+ this.sideBarContainer.style.width = "24%";
363
+ this.sideBarContainer.style.maxWidth = "180px";
364
+ this.sideBarContainer.style.height = "calc(100% - 24px)";
365
+ this.sideBarContainer.style.position = "absolute";
366
+ this.sideBarContainer.style.bottom = "24px";
367
+ this.sideBarContainer.style.left = "0";
368
+ this.sideBarContainer.style.fontSize = "0px";
369
+ this.sideBarContainer.style.overflow = "auto";
370
+ this.sideBarContainer.style.backgroundColor = "#EFEFEF";
371
+ this.root.appendChild(this.sideBarContainer);
372
+ for (let i = 0, l = this.imageryDoc.pageCount; i < l; i++) {
373
+ const reviewPage = document.createElement("div");
374
+ reviewPage.style.width = "100%";
375
+ reviewPage.style.marginTop = "12px";
376
+ const reviewIndex = document.createElement("div");
377
+ reviewIndex.style.cssText = "font-size:12px;width:100%;text-align:center;height:24px;line-height:24px;color:#585858";
378
+ reviewIndex.textContent = `${i + 1}`;
379
+ const reviewImg = document.createElement("img");
380
+ reviewImg.setAttribute("data-doc-index", `${i}`);
381
+ reviewImg.style.cssText = "width:80%;margin:0 10%;box-shadow:1px 1px 5px #9e9e9e";
382
+ this.imageryDoc.imgContent(i).then((base64Data) => {
383
+ reviewImg.src = base64Data;
384
+ });
385
+ reviewPage.appendChild(reviewImg);
386
+ reviewPage.appendChild(reviewIndex);
387
+ this.sideBarContainer.appendChild(reviewPage);
388
+ }
389
+ this.sideBarContainer.addEventListener("click", this.handleSideBarClick);
390
+ }
391
+ };
392
+
393
+ // src/InfinityScroll.ts
394
+ import EventEmitter3 from "eventemitter3";
395
+ function _defineProperty5(e, r, t) {
396
+ return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
397
+ }
398
+ function _toPropertyKey5(t) {
399
+ var i = _toPrimitive5(t, "string");
400
+ return "symbol" == typeof i ? i : i + "";
401
+ }
402
+ function _toPrimitive5(t, r) {
403
+ if ("object" != typeof t || !t) return t;
404
+ var e = t[Symbol.toPrimitive];
405
+ if (void 0 !== e) {
406
+ var i = e.call(t, r || "default");
407
+ if ("object" != typeof i) return i;
408
+ throw new TypeError("@@toPrimitive must return a primitive value.");
409
+ }
410
+ return ("string" === r ? String : Number)(t);
411
+ }
412
+ var InfinityScroll = class extends EventEmitter3 {
413
+ constructor(view) {
414
+ super();
415
+ _defineProperty5(this, "view", void 0);
416
+ _defineProperty5(this, "lastDelta", {
417
+ x: 0,
418
+ y: 0
419
+ });
420
+ _defineProperty5(this, "lastTriggerTime", 0);
421
+ _defineProperty5(this, "handleWheel", (evt) => {
422
+ evt.preventDefault();
423
+ evt.stopImmediatePropagation();
424
+ evt.stopPropagation();
425
+ if (Date.now() - this.lastTriggerTime < 32) {
426
+ this.lastDelta.y += evt.deltaY;
427
+ this.lastDelta.x += evt.deltaX;
428
+ return;
429
+ }
430
+ if (evt.ctrlKey) {
431
+ const wheelDelta = Math.sign(evt.wheelDelta || 100) * 120;
432
+ const deltaY = evt.deltaY + this.lastDelta.y;
433
+ let scale;
434
+ if (deltaY > 0) {
435
+ scale = Math.max(1 - Math.abs(deltaY / wheelDelta), 1e-8);
436
+ } else {
437
+ scale = 1 + Math.abs(deltaY / wheelDelta);
438
+ }
439
+ scale = Math.max(0.9, scale);
440
+ scale = Math.min(1.1, scale);
441
+ this.emit("scale", scale);
442
+ } else {
443
+ const deltaX = this.lastDelta.x + evt.deltaX;
444
+ const deltaY = this.lastDelta.y + evt.deltaY;
445
+ this.emit("translate", deltaX, deltaY);
446
+ }
447
+ this.lastTriggerTime = Date.now();
448
+ this.lastDelta = {
449
+ x: 0,
450
+ y: 0
451
+ };
452
+ });
453
+ this.view = view;
454
+ this.view.addEventListener("wheel", this.handleWheel, {
455
+ passive: false,
456
+ capture: true
457
+ });
458
+ }
459
+ dispose() {
460
+ this.view.removeEventListener("wheel", this.handleWheel);
461
+ }
462
+ };
463
+
464
+ // src/Container.ts
465
+ var ContainerKeys = {
466
+ scale: "scale",
467
+ translateX: "translateX",
468
+ translateY: "translateY",
469
+ pageIndex: "pageIndex"
470
+ };
471
+
472
+ // src/ContinuousContainer.ts
473
+ function _defineProperty6(e, r, t) {
474
+ return (r = _toPropertyKey6(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
475
+ }
476
+ function _toPropertyKey6(t) {
477
+ var i = _toPrimitive6(t, "string");
478
+ return "symbol" == typeof i ? i : i + "";
479
+ }
480
+ function _toPrimitive6(t, r) {
481
+ if ("object" != typeof t || !t) return t;
482
+ var e = t[Symbol.toPrimitive];
483
+ if (void 0 !== e) {
484
+ var i = e.call(t, r || "default");
485
+ if ("object" != typeof i) return i;
486
+ throw new TypeError("@@toPrimitive must return a primitive value.");
487
+ }
488
+ return ("string" === r ? String : Number)(t);
489
+ }
490
+ var ContinuousContainer = class {
491
+ get translateY() {
492
+ return this.map.get(ContainerKeys.translateY);
493
+ }
494
+ set translateY(value) {
495
+ this.map.set(ContainerKeys.translateY, value);
496
+ }
497
+ get pageIndex() {
498
+ const step = 1 / this.images.length;
499
+ for (let i = 0; i < this.images.length; i++) {
500
+ if (this.translateY < step * i && Math.abs(this.translateY - step * i) >= 1e-4) {
501
+ return i - 1;
502
+ }
503
+ }
504
+ return this.images.length - 1;
505
+ }
506
+ constructor(map, whiteboardApp, parentView, imageDoc) {
507
+ _defineProperty6(this, "view", void 0);
508
+ _defineProperty6(this, "parentView", void 0);
509
+ _defineProperty6(this, "resizeObserver", void 0);
510
+ _defineProperty6(this, "images", []);
511
+ _defineProperty6(this, "scroll", void 0);
512
+ _defineProperty6(this, "map", void 0);
513
+ _defineProperty6(this, "whiteboardApp", void 0);
514
+ _defineProperty6(this, "imageDoc", void 0);
515
+ _defineProperty6(this, "totalHeight", 0);
516
+ _defineProperty6(this, "localScale", 1);
517
+ _defineProperty6(this, "handleMapChange", (event) => {
518
+ if (event.keysChanged.has(ContainerKeys.translateY)) {
519
+ this.updateSyncedTransform();
520
+ }
521
+ });
522
+ _defineProperty6(this, "handleResize", () => {
523
+ const bound = this.view.getBoundingClientRect();
524
+ let scaledHeight = 0;
525
+ for (const image of this.images) {
526
+ let scale = bound.width / image.width;
527
+ image.scale(scale);
528
+ scaledHeight += image.height * scale;
529
+ }
530
+ this.localScale = scaledHeight / this.totalHeight;
531
+ this.whiteboardApp.updateOptionSize(bound.width, bound.height);
532
+ this.whiteboardApp.adjustByOutFrame(bound.width, bound.height);
533
+ this.updateSyncedTransform();
534
+ });
535
+ _defineProperty6(this, "updateSyncedTransform", () => {
536
+ const bounds = this.view.getBoundingClientRect();
537
+ const maxTy = this.totalHeight * this.localScale - bounds.height;
538
+ let ty = this.translateY * this.totalHeight * this.localScale;
539
+ ty = Math.min(ty, maxTy);
540
+ ty = Math.max(ty, 0);
541
+ this.view.style.transform = `translate(0, ${-ty}px)`;
542
+ this.whiteboardApp.emitter.resetCamera();
543
+ this.whiteboardApp.emitter.translateCamera(0, -ty);
544
+ this.whiteboardApp.emitter.scaleCamera(this.localScale, "top-left");
545
+ console.log("localScale: ", this.localScale, this.translateY);
546
+ this.handleGoto(this.pageIndex);
547
+ });
548
+ this.imageDoc = imageDoc;
549
+ this.parentView = parentView;
550
+ this.map = map;
551
+ this.scroll = new InfinityScroll(this.parentView);
552
+ this.whiteboardApp = whiteboardApp;
553
+ this.view = document.createElement("div");
554
+ this.view.style.width = "100%";
555
+ this.view.style.height = "100%";
556
+ this.view.style.position = "absolute";
557
+ this.view.style.top = "0";
558
+ this.view.style.left = "0";
559
+ this.view.style.transformOrigin = "0, 0";
560
+ this.view.setAttribute("data-imagery-container", "continuous");
561
+ this.resizeObserver = new ResizeObserver(this.handleResize);
562
+ this.resizeObserver.observe(this.view);
563
+ this.whiteboardApp.updateInternalResizeObserverStatus(false);
564
+ this.map.observe(this.handleMapChange);
565
+ if (!this.map.has(ContainerKeys.scale)) {
566
+ this.map.set(ContainerKeys.scale, 1);
567
+ }
568
+ if (!this.map.has(ContainerKeys.translateX)) {
569
+ this.map.set(ContainerKeys.translateX, 0);
570
+ }
571
+ if (!this.map.has(ContainerKeys.translateY)) {
572
+ this.map.set(ContainerKeys.translateY, 0);
573
+ }
574
+ this.scroll.on("translate", (dx, dy) => {
575
+ this.handleTranslate(dx, dy);
576
+ });
577
+ }
578
+ init() {
579
+ this.updateSyncedTransform();
580
+ this.totalHeight = this.images.reduce((prev, curr) => prev + curr.height, 0);
581
+ }
582
+ handleTranslate(dx, dy) {
583
+ const dyNormalized = dy / this.totalHeight;
584
+ let nextTy = this.translateY + dyNormalized;
585
+ nextTy = Math.max(0, nextTy);
586
+ nextTy = Math.min(1, nextTy);
587
+ this.translateY = nextTy;
588
+ }
589
+ goto(index) {
590
+ let nextIndex = Math.max(0, index);
591
+ nextIndex = Math.min(this.images.length - 1, nextIndex);
592
+ this.translateY = nextIndex / this.images.length;
593
+ }
594
+ append(image) {
595
+ this.images.push(image);
596
+ this.view.appendChild(image.view);
597
+ }
598
+ async handleGoto(index) {
599
+ if (index < 0 || index >= this.images.length) {
600
+ return;
601
+ }
602
+ this.imageDoc.emit("renderStart", index);
603
+ const target = this.images[index];
604
+ if (target) {
605
+ await target.prepare();
606
+ }
607
+ this.imageDoc.emit("renderEnd", index);
608
+ for (let i = index - 3; i <= index + 3; i++) {
609
+ const img = this.images[i];
610
+ if (img) {
611
+ img.prepare();
612
+ }
613
+ }
614
+ }
615
+ dispose() {
616
+ this.resizeObserver.disconnect();
617
+ this.scroll.dispose();
618
+ }
619
+ };
620
+
621
+ // src/SingleContainer.ts
622
+ function _defineProperty7(e, r, t) {
623
+ return (r = _toPropertyKey7(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
624
+ }
625
+ function _toPropertyKey7(t) {
626
+ var i = _toPrimitive7(t, "string");
627
+ return "symbol" == typeof i ? i : i + "";
628
+ }
629
+ function _toPrimitive7(t, r) {
630
+ if ("object" != typeof t || !t) return t;
631
+ var e = t[Symbol.toPrimitive];
632
+ if (void 0 !== e) {
633
+ var i = e.call(t, r || "default");
634
+ if ("object" != typeof i) return i;
635
+ throw new TypeError("@@toPrimitive must return a primitive value.");
636
+ }
637
+ return ("string" === r ? String : Number)(t);
638
+ }
639
+ var delay = (value) => new Promise((resolve) => setTimeout(resolve, value));
640
+ async function waitUntil(fn, timeout) {
641
+ let start = Date.now();
642
+ while (!fn() && Date.now() - start < timeout) {
643
+ await delay(50);
644
+ start = Date.now();
645
+ }
646
+ }
647
+ var SingleContainer = class {
648
+ get scale() {
649
+ return this.map.get(ContainerKeys.scale);
650
+ }
651
+ set scale(value) {
652
+ this.map.set(ContainerKeys.scale, value);
653
+ }
654
+ get translateX() {
655
+ return this.map.get(ContainerKeys.translateX);
656
+ }
657
+ set translateX(value) {
658
+ this.map.set(ContainerKeys.translateX, value);
659
+ }
660
+ get translateY() {
661
+ return this.map.get(ContainerKeys.translateY);
662
+ }
663
+ set translateY(value) {
664
+ this.map.set(ContainerKeys.translateY, value);
665
+ }
666
+ get pageIndex() {
667
+ return this.map.get(ContainerKeys.pageIndex);
668
+ }
669
+ constructor(map, whiteboardApp, parentView, imageDoc) {
670
+ _defineProperty7(this, "view", void 0);
671
+ _defineProperty7(this, "parentView", void 0);
672
+ _defineProperty7(this, "resizeObserver", void 0);
673
+ _defineProperty7(this, "images", []);
674
+ _defineProperty7(this, "currentImage", null);
675
+ _defineProperty7(this, "scroll", void 0);
676
+ _defineProperty7(this, "map", void 0);
677
+ _defineProperty7(this, "whiteboardApp", void 0);
678
+ _defineProperty7(this, "timeoutId", null);
679
+ _defineProperty7(this, "imageDoc", void 0);
680
+ _defineProperty7(this, "handleMapChange", (event) => {
681
+ if (event.keysChanged.has(ContainerKeys.scale) || event.keysChanged.has(ContainerKeys.translateX) || event.keysChanged.has(ContainerKeys.translateY)) {
682
+ this.updateSyncedTransform();
683
+ }
684
+ if (event.keysChanged.has(ContainerKeys.pageIndex)) {
685
+ this.handleGoto(this.pageIndex).catch((error) => {
686
+ });
687
+ }
688
+ });
689
+ _defineProperty7(this, "handleResize", () => {
690
+ const bound = this.parentView.getBoundingClientRect();
691
+ if (this.currentImage) {
692
+ let scale = bound.width / this.currentImage.width;
693
+ if (this.currentImage.height * scale > bound.height) {
694
+ scale = bound.height / this.currentImage.height;
695
+ }
696
+ const tx = Math.round((bound.width - this.currentImage.width * scale) / 2 / scale);
697
+ const ty = Math.round((bound.height - this.currentImage.height * scale) / 2 / scale);
698
+ this.currentImage.view.style.transform = `scale(${scale}) translate(${tx}px, ${ty}px)`;
699
+ this.updateSyncedTransform();
700
+ }
701
+ });
702
+ _defineProperty7(this, "updateSyncedTransform", () => {
703
+ if (!this.currentImage) {
704
+ return;
705
+ }
706
+ const parentBounds = this.parentView.getBoundingClientRect();
707
+ const tx = -this.translateX * parentBounds.width / this.scale;
708
+ const ty = -this.translateY * parentBounds.height / this.scale;
709
+ this.view.style.transform = `scale(${this.scale}) translate(${tx}px, ${ty}px)`;
710
+ const whiteboardView = this.whiteboardApp.emitter.view;
711
+ whiteboardView.style.width = `${parentBounds.width}px`;
712
+ whiteboardView.style.height = `${parentBounds.height}px`;
713
+ whiteboardView.style.top = "0";
714
+ whiteboardView.style.left = "0";
715
+ whiteboardView.style.transform = `scale(${this.scale}) translate(${tx}px, ${ty}px)`;
716
+ this.whiteboardApp.adjustByOutFrame(parentBounds.width, parentBounds.height);
717
+ window.clearTimeout(this.timeoutId);
718
+ this.timeoutId = window.setTimeout(() => {
719
+ whiteboardView.style.width = `${parentBounds.width * this.scale}px`;
720
+ whiteboardView.style.height = `${parentBounds.height * this.scale}px`;
721
+ whiteboardView.style.top = `${-(this.scale - 1) * parentBounds.height / 2 + ty * this.scale}px`;
722
+ whiteboardView.style.left = `${-(this.scale - 1) * parentBounds.width / 2 + tx * this.scale}px`;
723
+ whiteboardView.style.transform = `scale(1) translate(0px, 0px)`;
724
+ this.whiteboardApp.adjustByOutFrame(parentBounds.width * this.scale, parentBounds.height * this.scale);
725
+ }, 200);
726
+ });
727
+ this.imageDoc = imageDoc;
728
+ this.parentView = parentView;
729
+ this.map = map;
730
+ this.scroll = new InfinityScroll(this.parentView);
731
+ this.whiteboardApp = whiteboardApp;
732
+ this.view = document.createElement("div");
733
+ this.view.style.width = "100%";
734
+ this.view.style.height = "100%";
735
+ this.view.style.position = "absolute";
736
+ this.view.style.top = "0";
737
+ this.view.style.left = "0";
738
+ this.view.style.transformOrigin = "center";
739
+ this.view.setAttribute("data-imagery-container", "single");
740
+ this.resizeObserver = new ResizeObserver(this.handleResize);
741
+ this.resizeObserver.observe(this.view);
742
+ window.imageWhiteboard = this.whiteboardApp;
743
+ this.whiteboardApp.updateInternalResizeObserverStatus(false);
744
+ this.map.observe(this.handleMapChange);
745
+ if (!this.map.has(ContainerKeys.scale)) {
746
+ this.map.set(ContainerKeys.scale, 1);
747
+ }
748
+ if (!this.map.has(ContainerKeys.translateX)) {
749
+ this.map.set(ContainerKeys.translateX, 0);
750
+ }
751
+ if (!this.map.has(ContainerKeys.translateY)) {
752
+ this.map.set(ContainerKeys.translateY, 0);
753
+ }
754
+ if (!this.map.has(ContainerKeys.pageIndex)) {
755
+ this.map.set(ContainerKeys.pageIndex, 0);
756
+ }
757
+ this.scroll.on("translate", (dx, dy) => {
758
+ this.handleTranslate(dx, dy);
759
+ });
760
+ this.scroll.on("scale", (scale) => {
761
+ let nextScale = this.scale * scale;
762
+ nextScale = Math.max(1, nextScale);
763
+ nextScale = Math.min(2, nextScale);
764
+ this.scale = nextScale;
765
+ this.handleTranslate(0, 0);
766
+ });
767
+ }
768
+ init() {
769
+ this.handleGoto(this.pageIndex).catch((error) => {
770
+ });
771
+ this.updateSyncedTransform();
772
+ }
773
+ handleTranslate(dx, dy) {
774
+ const image = this.view.children[0];
775
+ if (!image) {
776
+ return;
777
+ }
778
+ const imageBounds = image.getBoundingClientRect();
779
+ const parentBounds = this.parentView.getBoundingClientRect();
780
+ const maxDx = (imageBounds.width - parentBounds.width) / 2;
781
+ const maxDy = (imageBounds.height - parentBounds.height) / 2;
782
+ if (maxDx > 0) {
783
+ let nextDx = this.translateX * parentBounds.width + dx;
784
+ if (nextDx >= 0) {
785
+ nextDx = Math.min(nextDx, maxDx);
786
+ } else {
787
+ nextDx = Math.max(nextDx, -maxDx);
788
+ }
789
+ this.translateX = nextDx / parentBounds.width;
790
+ } else {
791
+ this.translateX = 0;
792
+ }
793
+ if (maxDy > 0) {
794
+ let nextDy = this.translateY * parentBounds.height + dy;
795
+ if (nextDy >= 0) {
796
+ nextDy = Math.min(nextDy, maxDy);
797
+ } else {
798
+ nextDy = Math.max(nextDy, -maxDy);
799
+ }
800
+ this.translateY = nextDy / parentBounds.height;
801
+ } else {
802
+ this.translateY = 0;
803
+ }
804
+ }
805
+ goto(index) {
806
+ let nextIndex = Math.max(0, index);
807
+ nextIndex = Math.min(this.images.length - 1, nextIndex);
808
+ this.map.set(ContainerKeys.pageIndex, nextIndex);
809
+ }
810
+ append(image) {
811
+ this.images.push(image);
812
+ }
813
+ async handleGoto(index) {
814
+ await waitUntil(() => this.images.length > 0, 3e3);
815
+ if (index < 0 || index >= this.images.length) {
816
+ return;
817
+ }
818
+ this.imageDoc.emit("renderStart", index);
819
+ if (this.view.children[0]) {
820
+ this.view.removeChild(this.view.children[0]);
821
+ }
822
+ this.whiteboardApp.emitter.view.style.opacity = "0";
823
+ const target = this.images[index];
824
+ if (target) {
825
+ await target.prepare();
826
+ this.view.appendChild(target.view);
827
+ this.currentImage = target;
828
+ this.whiteboardApp.emitter.gotoPage(`doc_${index}`);
829
+ this.whiteboardApp.updateOptionSize(this.currentImage.width, this.currentImage.height);
830
+ this.whiteboardApp.emitter.view.style.opacity = "1";
831
+ this.handleResize();
832
+ }
833
+ this.imageDoc.emit("renderEnd", index);
834
+ for (let i = index - 3; i <= index + 3; i++) {
835
+ const img = this.images[i];
836
+ if (img) {
837
+ img.prepare();
838
+ }
839
+ }
840
+ }
841
+ dispose() {
842
+ this.resizeObserver.disconnect();
843
+ this.scroll.dispose();
844
+ window.clearTimeout(this.timeoutId);
845
+ }
846
+ };
847
+
848
+ // src/ImageryDocApplication.ts
849
+ function _defineProperty8(e, r, t) {
850
+ return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
851
+ }
852
+ function _toPropertyKey8(t) {
853
+ var i = _toPrimitive8(t, "string");
854
+ return "symbol" == typeof i ? i : i + "";
855
+ }
856
+ function _toPrimitive8(t, r) {
857
+ if ("object" != typeof t || !t) return t;
858
+ var e = t[Symbol.toPrimitive];
859
+ if (void 0 !== e) {
860
+ var i = e.call(t, r || "default");
861
+ if ("object" != typeof i) return i;
862
+ throw new TypeError("@@toPrimitive must return a primitive value.");
863
+ }
864
+ return ("string" === r ? String : Number)(t);
865
+ }
866
+ var IMAGERY_DOC_APP_NAME = "imagery_doc";
867
+ var ImageryDocApplication = class extends AbstractApplication {
868
+ constructor() {
869
+ super();
870
+ _defineProperty8(this, "name", IMAGERY_DOC_APP_NAME);
871
+ _defineProperty8(this, "emitter", new ImageryDoc());
872
+ _defineProperty8(this, "whiteboardApp", void 0);
873
+ _defineProperty8(this, "whiteboard", void 0);
874
+ _defineProperty8(this, "container", void 0);
875
+ _defineProperty8(this, "rootView", document.createElement("div"));
876
+ _defineProperty8(this, "contentContainer", document.createElement("div"));
877
+ _defineProperty8(this, "whiteboardContainer", document.createElement("div"));
878
+ _defineProperty8(this, "footerContainer", document.createElement("div"));
879
+ _defineProperty8(this, "permissions", void 0);
880
+ _defineProperty8(this, "footer", void 0);
881
+ _defineProperty8(this, "images", []);
882
+ this.rootView.setAttribute("data-forge-app", "imagery-doc");
883
+ this.rootView.style.background = "red";
884
+ this.rootView.style.overflow = "hidden";
885
+ this.contentContainer.style.width = "100%";
886
+ this.contentContainer.style.height = "100%";
887
+ this.contentContainer.style.display = "flex";
888
+ this.contentContainer.style.flexDirection = "column";
889
+ this.footer = new FooterView(this.emitter);
890
+ this.rootView.appendChild(this.contentContainer);
891
+ this.emitter.on("renderStart", (pageIndex) => {
892
+ this.footer.prevPageState(pageIndex !== 0);
893
+ this.footer.nextPageState(pageIndex !== this.images.length - 1);
894
+ });
895
+ const that = this;
896
+ Object.defineProperty(this.emitter, "footView", {
897
+ get() {
898
+ return that.footerContainer;
899
+ }
900
+ });
901
+ Object.defineProperty(this.emitter, "view", {
902
+ get() {
903
+ return that.rootView;
904
+ }
905
+ });
906
+ Object.defineProperty(this.emitter, "permissions", {
907
+ get() {
908
+ return that.permissions;
909
+ }
910
+ });
911
+ Object.defineProperty(this.emitter, "pageIndex", {
912
+ get() {
913
+ return that.container.pageIndex;
914
+ }
915
+ });
916
+ Object.defineProperty(this.emitter, "pageCount", {
917
+ get() {
918
+ return that.images.length;
919
+ }
920
+ });
921
+ Object.defineProperty(this.emitter, "goto", {
922
+ get() {
923
+ return (index) => {
924
+ if (that.permissions.hasPermission(ImageryDocPermissionFlag.switchPage)) {
925
+ that.container.goto(index);
926
+ }
927
+ };
928
+ }
929
+ });
930
+ Object.defineProperty(this.emitter, "imgContent", {
931
+ get() {
932
+ return (index) => {
933
+ return that.images[index].getImgContent();
934
+ };
935
+ }
936
+ });
937
+ Object.defineProperty(this.emitter, "imgSize", {
938
+ get() {
939
+ return (index) => {
940
+ return {
941
+ width: that.images[index].width,
942
+ height: that.images[index].height
943
+ };
944
+ };
945
+ }
946
+ });
947
+ }
948
+ async initialize(option) {
949
+ const whiteboardApp = new WhiteboardApplication();
950
+ whiteboardApp.roomDoc = this.roomDoc;
951
+ whiteboardApp.appId = `${this.appId}_wb`;
952
+ whiteboardApp.userId = this.userId;
953
+ whiteboardApp.userManager = this.userManager;
954
+ whiteboardApp.applicationManager = this.applicationManager;
955
+ await whiteboardApp.initialize({
956
+ width: -1,
957
+ height: -1
958
+ });
959
+ this.whiteboardApp = whiteboardApp;
960
+ this.whiteboard = whiteboardApp.emitter;
961
+ this.whiteboard.enableCameraByMouse = false;
962
+ this.whiteboard.enableCameraByTouch = false;
963
+ this.whiteboard.view.style.width = "100%";
964
+ this.whiteboard.view.style.height = "100%";
965
+ this.whiteboard.view.style.position = "absolute";
966
+ this.whiteboard.view.style.top = "0";
967
+ this.whiteboard.view.style.left = "0";
968
+ this.whiteboard.setCanvasBackgroundColor("#f0f0f000");
969
+ if (option.displayMode === "single") {
970
+ this.container = new SingleContainer(this.getMap("single-container"), whiteboardApp, this.whiteboardContainer, this.emitter);
971
+ } else {
972
+ this.container = new ContinuousContainer(this.getMap("continuous-container"), whiteboardApp, this.whiteboardContainer, this.emitter);
973
+ }
974
+ this.whiteboardContainer.style.position = "relative";
975
+ this.whiteboardContainer.style.flex = "1 1 auto";
976
+ this.whiteboardContainer.style.overflow = "hidden";
977
+ this.whiteboardContainer.appendChild(this.container.view);
978
+ this.whiteboardContainer.appendChild(this.whiteboard.view);
979
+ this.contentContainer.appendChild(this.whiteboardContainer);
980
+ this.contentContainer.appendChild(this.footerContainer);
981
+ this.footerContainer.appendChild(this.footer.root);
982
+ this.whiteboard.setViewModeToMain();
983
+ let i = 0;
984
+ this.whiteboard.permissions.addPermission(WhiteboardPermissionFlag.mainView);
985
+ while (i < option.images.length) {
986
+ const image = option.images[i];
987
+ this.images[i] = new LazyImage(image.src, image.width, image.height);
988
+ this.container.append(this.images[i]);
989
+ if (option.displayMode === "single") {
990
+ this.whiteboard.addPage(`doc_${i}`);
991
+ }
992
+ i += 1;
993
+ }
994
+ if (option.displayMode === "continuous") {
995
+ this.whiteboard.addPage("doc_continuous");
996
+ this.whiteboard.gotoPage("doc_continuous");
997
+ }
998
+ if (option.displayMode === "single") {
999
+ this.whiteboard.setViewModeToMain();
1000
+ } else {
1001
+ this.whiteboard.setViewModeToFree();
1002
+ }
1003
+ this.permissions = new ImageryDocPermissions(this.userManager, (userId) => {
1004
+ return this.userMap(userId);
1005
+ });
1006
+ this.permissions.addPermission(ImageryDocPermissionFlag.all);
1007
+ this.whiteboardApp.disableViewModel();
1008
+ this.container.init();
1009
+ this.whiteboard.permissions.removePermission(WhiteboardPermissionFlag.mainView);
1010
+ if (option.inheritWhiteboardId) {
1011
+ whiteboardApp.linkToWhiteboard(option.inheritWhiteboardId);
1012
+ }
1013
+ return Promise.resolve(void 0);
1014
+ }
1015
+ userMap(userId) {
1016
+ return this.getMap(`user/${userId}`);
1017
+ }
1018
+ async dispose() {
1019
+ await this.whiteboardApp.dispose();
1020
+ this.rootView.parentElement?.removeChild(this.rootView);
1021
+ this.container.dispose();
1022
+ return Promise.resolve(void 0);
1023
+ }
1024
+ };
1025
+ _defineProperty8(ImageryDocApplication, "applicationName", IMAGERY_DOC_APP_NAME);
1026
+ export {
1027
+ ImageryDoc,
1028
+ ImageryDocApplication,
1029
+ ImageryDocPermissionFlag
1030
+ };
1031
+ //# sourceMappingURL=imagery-doc.esm.js.map