@idraw/core 0.4.0-beta.0 → 0.4.0-beta.10

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.
@@ -22,11 +22,11 @@ var __privateMethod = (obj, member, method) => {
22
22
  return method;
23
23
  };
24
24
 
25
- var _board, _container, _initContainer, initContainer_fn;
25
+ var _board, _canvas, _container, _initContainer, initContainer_fn;
26
26
  function throttle(fn, timeout) {
27
27
  let timer = -1;
28
28
  return function(...args) {
29
- if (timer > 0) {
29
+ if (timer >= 0) {
30
30
  return;
31
31
  }
32
32
  timer = setTimeout(() => {
@@ -358,7 +358,7 @@ var __privateMethod = (obj, member, method) => {
358
358
  fontWeight: fontWeight$1,
359
359
  strokeWidth
360
360
  };
361
- var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
361
+ var __classPrivateFieldSet$9 = function(receiver, state, value, kind, f) {
362
362
  if (kind === "m")
363
363
  throw new TypeError("Private method is not writable");
364
364
  if (kind === "a" && !f)
@@ -367,7 +367,7 @@ var __privateMethod = (obj, member, method) => {
367
367
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
368
368
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
369
369
  };
370
- var __classPrivateFieldGet = function(receiver, state, kind, f) {
370
+ var __classPrivateFieldGet$9 = function(receiver, state, kind, f) {
371
371
  if (kind === "a" && !f)
372
372
  throw new TypeError("Private accessor was defined without a getter");
373
373
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -379,17 +379,20 @@ var __privateMethod = (obj, member, method) => {
379
379
  constructor(ctx, opts) {
380
380
  _Context2D_ctx.set(this, void 0);
381
381
  _Context2D_opts.set(this, void 0);
382
- __classPrivateFieldSet(this, _Context2D_ctx, ctx, "f");
383
- __classPrivateFieldSet(this, _Context2D_opts, Object.assign({ devicePixelRatio: 1, offscreenCanvas: null }, opts), "f");
382
+ __classPrivateFieldSet$9(this, _Context2D_ctx, ctx, "f");
383
+ __classPrivateFieldSet$9(this, _Context2D_opts, Object.assign({ devicePixelRatio: 1, offscreenCanvas: null }, opts), "f");
384
384
  }
385
385
  $undoPixelRatio(num) {
386
- return num / __classPrivateFieldGet(this, _Context2D_opts, "f").devicePixelRatio;
386
+ return num / __classPrivateFieldGet$9(this, _Context2D_opts, "f").devicePixelRatio;
387
387
  }
388
388
  $doPixelRatio(num) {
389
- return __classPrivateFieldGet(this, _Context2D_opts, "f").devicePixelRatio * num;
389
+ return __classPrivateFieldGet$9(this, _Context2D_opts, "f").devicePixelRatio * num;
390
390
  }
391
391
  $getContext() {
392
- return __classPrivateFieldGet(this, _Context2D_ctx, "f");
392
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f");
393
+ }
394
+ $setContext(ctx) {
395
+ __classPrivateFieldSet$9(this, _Context2D_ctx, ctx, "f");
393
396
  }
394
397
  $setFont(opts) {
395
398
  const strList = [];
@@ -398,17 +401,17 @@ var __privateMethod = (obj, member, method) => {
398
401
  }
399
402
  strList.push(`${this.$doPixelRatio(opts.fontSize || 12)}px`);
400
403
  strList.push(`${opts.fontFamily || "sans-serif"}`);
401
- __classPrivateFieldGet(this, _Context2D_ctx, "f").font = `${strList.join(" ")}`;
404
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").font = `${strList.join(" ")}`;
402
405
  }
403
406
  $getOffscreenCanvas() {
404
- return __classPrivateFieldGet(this, _Context2D_opts, "f").offscreenCanvas;
407
+ return __classPrivateFieldGet$9(this, _Context2D_opts, "f").offscreenCanvas;
405
408
  }
406
409
  $resize(opts) {
407
410
  const { width, height, devicePixelRatio, resetStyle } = opts;
408
- const { canvas } = __classPrivateFieldGet(this, _Context2D_ctx, "f");
411
+ const { canvas } = __classPrivateFieldGet$9(this, _Context2D_ctx, "f");
409
412
  canvas.width = width * devicePixelRatio;
410
413
  canvas.height = height * devicePixelRatio;
411
- __classPrivateFieldSet(this, _Context2D_opts, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Context2D_opts, "f")), {
414
+ __classPrivateFieldSet$9(this, _Context2D_opts, Object.assign(Object.assign({}, __classPrivateFieldGet$9(this, _Context2D_opts, "f")), {
412
415
  devicePixelRatio
413
416
  }), "f");
414
417
  if (resetStyle === true) {
@@ -417,8 +420,8 @@ var __privateMethod = (obj, member, method) => {
417
420
  }
418
421
  }
419
422
  $getSize() {
420
- const { devicePixelRatio } = __classPrivateFieldGet(this, _Context2D_opts, "f");
421
- const { width, height } = __classPrivateFieldGet(this, _Context2D_ctx, "f").canvas;
423
+ const { devicePixelRatio } = __classPrivateFieldGet$9(this, _Context2D_opts, "f");
424
+ const { width, height } = __classPrivateFieldGet$9(this, _Context2D_ctx, "f").canvas;
422
425
  return {
423
426
  width: width / devicePixelRatio,
424
427
  height: height / devicePixelRatio,
@@ -426,125 +429,125 @@ var __privateMethod = (obj, member, method) => {
426
429
  };
427
430
  }
428
431
  get canvas() {
429
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").canvas;
432
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").canvas;
430
433
  }
431
434
  get fillStyle() {
432
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillStyle;
435
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillStyle;
433
436
  }
434
437
  set fillStyle(value) {
435
- __classPrivateFieldGet(this, _Context2D_ctx, "f").fillStyle = value;
438
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillStyle = value;
436
439
  }
437
440
  get strokeStyle() {
438
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeStyle;
441
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeStyle;
439
442
  }
440
443
  set strokeStyle(color2) {
441
- __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeStyle = color2;
444
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeStyle = color2;
442
445
  }
443
446
  get lineWidth() {
444
- return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").lineWidth);
447
+ return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineWidth);
445
448
  }
446
449
  set lineWidth(w2) {
447
- __classPrivateFieldGet(this, _Context2D_ctx, "f").lineWidth = this.$doPixelRatio(w2);
450
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineWidth = this.$doPixelRatio(w2);
448
451
  }
449
452
  get textAlign() {
450
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").textAlign;
453
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").textAlign;
451
454
  }
452
455
  set textAlign(align) {
453
- __classPrivateFieldGet(this, _Context2D_ctx, "f").textAlign = align;
456
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").textAlign = align;
454
457
  }
455
458
  get textBaseline() {
456
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").textBaseline;
459
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").textBaseline;
457
460
  }
458
461
  set textBaseline(baseline) {
459
- __classPrivateFieldGet(this, _Context2D_ctx, "f").textBaseline = baseline;
462
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").textBaseline = baseline;
460
463
  }
461
464
  get globalAlpha() {
462
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").globalAlpha;
465
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalAlpha;
463
466
  }
464
467
  set globalAlpha(alpha) {
465
- __classPrivateFieldGet(this, _Context2D_ctx, "f").globalAlpha = alpha;
468
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalAlpha = alpha;
466
469
  }
467
470
  get shadowColor() {
468
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowColor;
471
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowColor;
469
472
  }
470
473
  set shadowColor(color2) {
471
- __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowColor = color2;
474
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowColor = color2;
472
475
  }
473
476
  get shadowOffsetX() {
474
- return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetX);
477
+ return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetX);
475
478
  }
476
479
  set shadowOffsetX(offsetX) {
477
- __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetX = this.$doPixelRatio(offsetX);
480
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetX = this.$doPixelRatio(offsetX);
478
481
  }
479
482
  get shadowOffsetY() {
480
- return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetY);
483
+ return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetY);
481
484
  }
482
485
  set shadowOffsetY(offsetY) {
483
- __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetY = this.$doPixelRatio(offsetY);
486
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetY = this.$doPixelRatio(offsetY);
484
487
  }
485
488
  get shadowBlur() {
486
- return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowBlur);
489
+ return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowBlur);
487
490
  }
488
491
  set shadowBlur(blur) {
489
- __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowBlur = this.$doPixelRatio(blur);
492
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowBlur = this.$doPixelRatio(blur);
490
493
  }
491
494
  get lineCap() {
492
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").lineCap;
495
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineCap;
493
496
  }
494
497
  set lineCap(lineCap) {
495
- __classPrivateFieldGet(this, _Context2D_ctx, "f").lineCap = lineCap;
498
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineCap = lineCap;
496
499
  }
497
500
  get globalCompositeOperation() {
498
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").globalCompositeOperation;
501
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalCompositeOperation;
499
502
  }
500
503
  set globalCompositeOperation(operations) {
501
- __classPrivateFieldGet(this, _Context2D_ctx, "f").globalCompositeOperation = operations;
504
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalCompositeOperation = operations;
502
505
  }
503
506
  fill(...args) {
504
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").fill(...args);
507
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fill(...args);
505
508
  }
506
509
  arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
507
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").arc(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
510
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").arc(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
508
511
  }
509
512
  rect(x2, y2, w2, h2) {
510
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
513
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
511
514
  }
512
515
  fillRect(x2, y2, w2, h2) {
513
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
516
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
514
517
  }
515
518
  clearRect(x2, y2, w2, h2) {
516
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").clearRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
519
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").clearRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
517
520
  }
518
521
  beginPath() {
519
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").beginPath();
522
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").beginPath();
520
523
  }
521
524
  closePath() {
522
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").closePath();
525
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").closePath();
523
526
  }
524
527
  lineTo(x2, y2) {
525
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").lineTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
528
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
526
529
  }
527
530
  moveTo(x2, y2) {
528
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
531
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
529
532
  }
530
533
  arcTo(x1, y1, x2, y2, radius) {
531
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").arcTo(this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius));
534
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").arcTo(this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius));
532
535
  }
533
536
  getLineDash() {
534
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").getLineDash();
537
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").getLineDash();
535
538
  }
536
539
  setLineDash(nums) {
537
540
  const dash = nums.map((n) => this.$doPixelRatio(n));
538
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").setLineDash(dash);
541
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").setLineDash(dash);
539
542
  }
540
543
  stroke(path) {
541
- return path ? __classPrivateFieldGet(this, _Context2D_ctx, "f").stroke(path) : __classPrivateFieldGet(this, _Context2D_ctx, "f").stroke();
544
+ return path ? __classPrivateFieldGet$9(this, _Context2D_ctx, "f").stroke(path) : __classPrivateFieldGet$9(this, _Context2D_ctx, "f").stroke();
542
545
  }
543
546
  translate(x2, y2) {
544
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").translate(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
547
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").translate(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
545
548
  }
546
549
  rotate(angle2) {
547
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").rotate(angle2);
550
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").rotate(angle2);
548
551
  }
549
552
  drawImage(...args) {
550
553
  const image = args[0];
@@ -557,64 +560,64 @@ var __privateMethod = (obj, member, method) => {
557
560
  const dw = args[args.length - 2];
558
561
  const dh = args[args.length - 1];
559
562
  if (args.length === 9) {
560
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(sx), this.$doPixelRatio(sy), this.$doPixelRatio(sw), this.$doPixelRatio(sh), this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
563
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(sx), this.$doPixelRatio(sy), this.$doPixelRatio(sw), this.$doPixelRatio(sh), this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
561
564
  } else {
562
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
565
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
563
566
  }
564
567
  }
565
568
  createPattern(image, repetition) {
566
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").createPattern(image, repetition);
569
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createPattern(image, repetition);
567
570
  }
568
571
  measureText(text2) {
569
- const textMetrics = __classPrivateFieldGet(this, _Context2D_ctx, "f").measureText(text2);
572
+ const textMetrics = __classPrivateFieldGet$9(this, _Context2D_ctx, "f").measureText(text2);
570
573
  return textMetrics;
571
574
  }
572
575
  fillText(text2, x2, y2, maxWidth) {
573
576
  if (maxWidth !== void 0) {
574
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
577
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
575
578
  } else {
576
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
579
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
577
580
  }
578
581
  }
579
582
  strokeText(text2, x2, y2, maxWidth) {
580
583
  if (maxWidth !== void 0) {
581
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
584
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
582
585
  } else {
583
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
586
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
584
587
  }
585
588
  }
586
589
  save() {
587
- __classPrivateFieldGet(this, _Context2D_ctx, "f").save();
590
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").save();
588
591
  }
589
592
  restore() {
590
- __classPrivateFieldGet(this, _Context2D_ctx, "f").restore();
593
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").restore();
591
594
  }
592
595
  scale(ratioX, ratioY) {
593
- __classPrivateFieldGet(this, _Context2D_ctx, "f").scale(ratioX, ratioY);
596
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").scale(ratioX, ratioY);
594
597
  }
595
598
  circle(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
596
- __classPrivateFieldGet(this, _Context2D_ctx, "f").ellipse(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radiusX), this.$doPixelRatio(radiusY), rotation, startAngle, endAngle, counterclockwise);
599
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").ellipse(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radiusX), this.$doPixelRatio(radiusY), rotation, startAngle, endAngle, counterclockwise);
597
600
  }
598
601
  isPointInPath(x2, y2) {
599
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").isPointInPath(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
602
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").isPointInPath(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
600
603
  }
601
604
  clip(...args) {
602
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").clip(...args);
605
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").clip(...args);
603
606
  }
604
607
  setTransform(a, b, c, d, e, f) {
605
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").setTransform(a, b, c, d, e, f);
608
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").setTransform(a, b, c, d, e, f);
606
609
  }
607
610
  getTransform() {
608
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").getTransform();
611
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").getTransform();
609
612
  }
610
613
  createLinearGradient(x0, y0, x1, y1) {
611
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").createLinearGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(x1), this.$doPixelRatio(y1));
614
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createLinearGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(x1), this.$doPixelRatio(y1));
612
615
  }
613
616
  createRadialGradient(x0, y0, r0, x1, y1, r1) {
614
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").createRadialGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(r0), this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(r1));
617
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createRadialGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(r0), this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(r1));
615
618
  }
616
619
  createConicGradient(startAngle, x2, y2) {
617
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").createConicGradient(startAngle, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
620
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createConicGradient(startAngle, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
618
621
  }
619
622
  }
620
623
  _Context2D_ctx = /* @__PURE__ */ new WeakMap(), _Context2D_opts = /* @__PURE__ */ new WeakMap();
@@ -641,15 +644,39 @@ var __privateMethod = (obj, member, method) => {
641
644
  });
642
645
  return context2d;
643
646
  }
644
- function createViewContent(canvas, opts) {
645
- const { width, height, devicePixelRatio, offscreen } = opts;
647
+ function createBoardContent(canvas, opts) {
648
+ const { width, height, devicePixelRatio, offscreen, createCustomContext2D } = opts;
646
649
  const ctxOpts = {
647
650
  width,
648
651
  height,
649
652
  devicePixelRatio
650
653
  };
654
+ const ctx = canvas.getContext("2d");
655
+ if (createCustomContext2D) {
656
+ const viewContext = createCustomContext2D(ctxOpts);
657
+ const helperContext = createCustomContext2D(ctxOpts);
658
+ const underContext = createCustomContext2D(ctxOpts);
659
+ const boardContext = createContext2D(Object.assign({ ctx }, ctxOpts));
660
+ const drawView = () => {
661
+ const { width: w2, height: h2 } = viewContext.$getSize();
662
+ boardContext.clearRect(0, 0, w2, h2);
663
+ boardContext.drawImage(underContext.canvas, 0, 0, w2, h2);
664
+ boardContext.drawImage(viewContext.canvas, 0, 0, w2, h2);
665
+ boardContext.drawImage(helperContext.canvas, 0, 0, w2, h2);
666
+ underContext.clearRect(0, 0, w2, h2);
667
+ viewContext.clearRect(0, 0, w2, h2);
668
+ helperContext.clearRect(0, 0, w2, h2);
669
+ };
670
+ const content = {
671
+ underContext,
672
+ viewContext,
673
+ helperContext,
674
+ boardContext,
675
+ drawView
676
+ };
677
+ return content;
678
+ }
651
679
  if (offscreen === true) {
652
- const ctx = canvas.getContext("2d");
653
680
  const viewContext = createOffscreenContext2D(ctxOpts);
654
681
  const helperContext = createOffscreenContext2D(ctxOpts);
655
682
  const underContext = createOffscreenContext2D(ctxOpts);
@@ -673,7 +700,6 @@ var __privateMethod = (obj, member, method) => {
673
700
  };
674
701
  return content;
675
702
  } else {
676
- const ctx = canvas.getContext("2d");
677
703
  const viewContext = createContext2D(ctxOpts);
678
704
  const helperContext = createContext2D(ctxOpts);
679
705
  const underContext = createContext2D(ctxOpts);
@@ -697,22 +723,40 @@ var __privateMethod = (obj, member, method) => {
697
723
  return content;
698
724
  }
699
725
  }
726
+ var __classPrivateFieldSet$8 = function(receiver, state, value, kind, f) {
727
+ if (kind === "m")
728
+ throw new TypeError("Private method is not writable");
729
+ if (kind === "a" && !f)
730
+ throw new TypeError("Private accessor was defined without a setter");
731
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
732
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
733
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
734
+ };
735
+ var __classPrivateFieldGet$8 = function(receiver, state, kind, f) {
736
+ if (kind === "a" && !f)
737
+ throw new TypeError("Private accessor was defined without a getter");
738
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
739
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
740
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
741
+ };
742
+ var _EventEmitter_listeners;
700
743
  class EventEmitter {
701
744
  constructor() {
702
- this._listeners = /* @__PURE__ */ new Map();
745
+ _EventEmitter_listeners.set(this, void 0);
746
+ __classPrivateFieldSet$8(this, _EventEmitter_listeners, /* @__PURE__ */ new Map(), "f");
703
747
  }
704
748
  on(eventKey, callback) {
705
- if (this._listeners.has(eventKey)) {
706
- const callbacks = this._listeners.get(eventKey) || [];
749
+ if (__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").has(eventKey)) {
750
+ const callbacks = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(eventKey) || [];
707
751
  callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
708
- this._listeners.set(eventKey, callbacks);
752
+ __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").set(eventKey, callbacks);
709
753
  } else {
710
- this._listeners.set(eventKey, [callback]);
754
+ __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").set(eventKey, [callback]);
711
755
  }
712
756
  }
713
757
  off(eventKey, callback) {
714
- if (this._listeners.has(eventKey)) {
715
- const callbacks = this._listeners.get(eventKey);
758
+ if (__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").has(eventKey)) {
759
+ const callbacks = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(eventKey);
716
760
  if (Array.isArray(callbacks)) {
717
761
  for (let i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
718
762
  if (callbacks[i] === callback) {
@@ -721,11 +765,11 @@ var __privateMethod = (obj, member, method) => {
721
765
  }
722
766
  }
723
767
  }
724
- this._listeners.set(eventKey, callbacks || []);
768
+ __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").set(eventKey, callbacks || []);
725
769
  }
726
770
  }
727
771
  trigger(eventKey, e) {
728
- const callbacks = this._listeners.get(eventKey);
772
+ const callbacks = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(eventKey);
729
773
  if (Array.isArray(callbacks)) {
730
774
  callbacks.forEach((cb) => {
731
775
  cb(e);
@@ -736,15 +780,19 @@ var __privateMethod = (obj, member, method) => {
736
780
  }
737
781
  }
738
782
  has(name) {
739
- if (this._listeners.has(name)) {
740
- const list = this._listeners.get(name);
783
+ if (__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").has(name)) {
784
+ const list = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(name);
741
785
  if (Array.isArray(list) && list.length > 0) {
742
786
  return true;
743
787
  }
744
788
  }
745
789
  return false;
746
790
  }
791
+ destroy() {
792
+ __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").clear();
793
+ }
747
794
  }
795
+ _EventEmitter_listeners = /* @__PURE__ */ new WeakMap();
748
796
  function calcDistance(start, end) {
749
797
  const distance = (start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y);
750
798
  return distance === 0 ? distance : Math.sqrt(distance);
@@ -755,27 +803,50 @@ var __privateMethod = (obj, member, method) => {
755
803
  y: p1.y + (p2.y - p1.y) / 2
756
804
  };
757
805
  }
806
+ var __classPrivateFieldSet$7 = function(receiver, state, value, kind, f) {
807
+ if (kind === "m")
808
+ throw new TypeError("Private method is not writable");
809
+ if (kind === "a" && !f)
810
+ throw new TypeError("Private accessor was defined without a setter");
811
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
812
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
813
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
814
+ };
815
+ var __classPrivateFieldGet$7 = function(receiver, state, kind, f) {
816
+ if (kind === "a" && !f)
817
+ throw new TypeError("Private accessor was defined without a getter");
818
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
819
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
820
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
821
+ };
822
+ var _Store_instances, _Store_temp, _Store_backUpDefaultStorage, _Store_createTempStorage;
758
823
  class Store {
759
824
  constructor(opts) {
760
- this._backUpDefaultStorage = deepClone(opts.defaultStorage);
761
- this._temp = this._createTempStorage();
825
+ _Store_instances.add(this);
826
+ _Store_temp.set(this, void 0);
827
+ _Store_backUpDefaultStorage.set(this, void 0);
828
+ __classPrivateFieldSet$7(this, _Store_backUpDefaultStorage, deepClone(opts.defaultStorage), "f");
829
+ __classPrivateFieldSet$7(this, _Store_temp, __classPrivateFieldGet$7(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
762
830
  }
763
831
  set(name, value) {
764
- this._temp[name] = value;
832
+ __classPrivateFieldGet$7(this, _Store_temp, "f")[name] = value;
765
833
  }
766
834
  get(name) {
767
- return this._temp[name];
835
+ return __classPrivateFieldGet$7(this, _Store_temp, "f")[name];
768
836
  }
769
837
  getSnapshot() {
770
- return deepClone(this._temp);
838
+ return deepClone(__classPrivateFieldGet$7(this, _Store_temp, "f"));
771
839
  }
772
840
  clear() {
773
- this._temp = this._createTempStorage();
841
+ __classPrivateFieldSet$7(this, _Store_temp, __classPrivateFieldGet$7(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
774
842
  }
775
- _createTempStorage() {
776
- return deepClone(this._backUpDefaultStorage);
843
+ destroy() {
844
+ __classPrivateFieldSet$7(this, _Store_temp, null, "f");
777
845
  }
778
846
  }
847
+ _Store_temp = /* @__PURE__ */ new WeakMap(), _Store_backUpDefaultStorage = /* @__PURE__ */ new WeakMap(), _Store_instances = /* @__PURE__ */ new WeakSet(), _Store_createTempStorage = function _Store_createTempStorage2() {
848
+ return deepClone(__classPrivateFieldGet$7(this, _Store_backUpDefaultStorage, "f"));
849
+ };
779
850
  function getViewScaleInfoFromSnapshot(snapshot) {
780
851
  const { activeStore } = snapshot;
781
852
  const sacelInfo = {
@@ -1428,6 +1499,10 @@ var __privateMethod = (obj, member, method) => {
1428
1499
  const topRightCenter = vertexes[1];
1429
1500
  const bottomRightCenter = vertexes[2];
1430
1501
  const bottomLeftCenter = vertexes[3];
1502
+ const topMiddleSize = createControllerElementSizeFromCenter(topCenter, { size: ctrlSize, angle: totalAngle });
1503
+ const rightMiddleSize = createControllerElementSizeFromCenter(rightCenter, { size: ctrlSize, angle: totalAngle });
1504
+ const bottomMiddleSize = createControllerElementSizeFromCenter(bottomCenter, { size: ctrlSize, angle: totalAngle });
1505
+ const leftMiddleSize = createControllerElementSizeFromCenter(leftCenter, { size: ctrlSize, angle: totalAngle });
1431
1506
  const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: totalAngle });
1432
1507
  const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: totalAngle });
1433
1508
  const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: totalAngle });
@@ -1440,6 +1515,10 @@ var __privateMethod = (obj, member, method) => {
1440
1515
  const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
1441
1516
  const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
1442
1517
  const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
1518
+ const topMiddleVertexes = calcElementVertexes(topMiddleSize);
1519
+ const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
1520
+ const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
1521
+ const leftMiddleVertexes = calcElementVertexes(leftMiddleSize);
1443
1522
  const sizeController = {
1444
1523
  elementWrapper: vertexes,
1445
1524
  left: {
@@ -1481,6 +1560,26 @@ var __privateMethod = (obj, member, method) => {
1481
1560
  type: "bottom-right",
1482
1561
  vertexes: bottomRightVertexes,
1483
1562
  center: bottomRightCenter
1563
+ },
1564
+ leftMiddle: {
1565
+ type: "left-middle",
1566
+ vertexes: leftMiddleVertexes,
1567
+ center: leftCenter
1568
+ },
1569
+ rightMiddle: {
1570
+ type: "right-middle",
1571
+ vertexes: rightMiddleVertexes,
1572
+ center: rightCenter
1573
+ },
1574
+ topMiddle: {
1575
+ type: "top-middle",
1576
+ vertexes: topMiddleVertexes,
1577
+ center: topCenter
1578
+ },
1579
+ bottomMiddle: {
1580
+ type: "bottom-middle",
1581
+ vertexes: bottomMiddleVertexes,
1582
+ center: bottomCenter
1484
1583
  }
1485
1584
  };
1486
1585
  return sizeController;
@@ -1526,8 +1625,9 @@ var __privateMethod = (obj, member, method) => {
1526
1625
  function calcViewBoxSize(viewElem, opts) {
1527
1626
  const { viewScaleInfo } = opts;
1528
1627
  const { scale } = viewScaleInfo;
1529
- let { borderRadius: borderRadius2, boxSizing = defaultElemConfig$1.boxSizing, borderWidth: borderWidth2 } = viewElem.detail;
1530
- if (typeof borderWidth2 !== "number") {
1628
+ let { borderRadius: borderRadius2 } = viewElem.detail;
1629
+ const { boxSizing = defaultElemConfig$1.boxSizing, borderWidth: borderWidth2 } = viewElem.detail;
1630
+ if (Array.isArray(borderWidth2)) {
1531
1631
  borderRadius2 = 0;
1532
1632
  }
1533
1633
  let { x: x2, y: y2, w: w2, h: h2 } = viewElem;
@@ -1571,6 +1671,103 @@ var __privateMethod = (obj, member, method) => {
1571
1671
  radiusList
1572
1672
  };
1573
1673
  }
1674
+ const doNum = (n) => {
1675
+ return formatNumber(n, { decimalPlaces: 4 });
1676
+ };
1677
+ function resizeElementBaseDetail(elem, opts) {
1678
+ const { detail } = elem;
1679
+ const { xRatio, yRatio, maxRatio } = opts;
1680
+ const middleRatio = (xRatio + yRatio) / 2;
1681
+ const { borderWidth: borderWidth2, borderRadius: borderRadius2, borderDash, shadowOffsetX, shadowOffsetY, shadowBlur } = detail;
1682
+ if (typeof borderWidth2 === "number") {
1683
+ detail.borderWidth = doNum(borderWidth2 * middleRatio);
1684
+ } else if (Array.isArray(detail.borderWidth)) {
1685
+ const bw = borderWidth2;
1686
+ detail.borderWidth = [doNum(bw[0] * yRatio), doNum(bw[1] * xRatio), doNum(bw[2] * yRatio), doNum(bw[3] * xRatio)];
1687
+ }
1688
+ if (typeof borderRadius2 === "number") {
1689
+ detail.borderRadius = doNum(borderRadius2 * middleRatio);
1690
+ } else if (Array.isArray(detail.borderRadius)) {
1691
+ const br = borderRadius2;
1692
+ detail.borderRadius = [br[0] * xRatio, br[1] * xRatio, br[2] * yRatio, br[3] * yRatio];
1693
+ }
1694
+ if (Array.isArray(borderDash)) {
1695
+ borderDash.forEach((dash, i) => {
1696
+ detail.borderDash[i] = doNum(dash * maxRatio);
1697
+ });
1698
+ }
1699
+ if (typeof shadowOffsetX === "number") {
1700
+ detail.shadowOffsetX = doNum(shadowOffsetX * maxRatio);
1701
+ }
1702
+ if (typeof shadowOffsetY === "number") {
1703
+ detail.shadowOffsetX = doNum(shadowOffsetY * maxRatio);
1704
+ }
1705
+ if (typeof shadowBlur === "number") {
1706
+ detail.shadowOffsetX = doNum(shadowBlur * maxRatio);
1707
+ }
1708
+ }
1709
+ function resizeElementBase(elem, opts) {
1710
+ const { xRatio, yRatio } = opts;
1711
+ const { x: x2, y: y2, w: w2, h: h2 } = elem;
1712
+ elem.x = doNum(x2 * xRatio);
1713
+ elem.y = doNum(y2 * yRatio);
1714
+ elem.w = doNum(w2 * xRatio);
1715
+ elem.h = doNum(h2 * yRatio);
1716
+ resizeElementBaseDetail(elem, opts);
1717
+ }
1718
+ function resizeTextElementDetail(elem, opts) {
1719
+ const { minRatio, maxRatio } = opts;
1720
+ const { fontSize: fontSize2, lineHeight: lineHeight2 } = elem.detail;
1721
+ const ratio = (minRatio + maxRatio) / 2;
1722
+ if (fontSize2 && fontSize2 > 0) {
1723
+ elem.detail.fontSize = doNum(fontSize2 * ratio);
1724
+ }
1725
+ if (lineHeight2 && lineHeight2 > 0) {
1726
+ elem.detail.lineHeight = doNum(lineHeight2 * ratio);
1727
+ }
1728
+ }
1729
+ function resizeElement$1(elem, opts) {
1730
+ const { type } = elem;
1731
+ resizeElementBase(elem, opts);
1732
+ if (type === "circle")
1733
+ ;
1734
+ else if (type === "text") {
1735
+ resizeTextElementDetail(elem, opts);
1736
+ } else if (type === "image")
1737
+ ;
1738
+ else if (type === "svg")
1739
+ ;
1740
+ else if (type === "html")
1741
+ ;
1742
+ else if (type === "path")
1743
+ ;
1744
+ else if (type === "group" && Array.isArray(elem.detail.children)) {
1745
+ elem.detail.children.forEach((child) => {
1746
+ resizeElement$1(child, opts);
1747
+ });
1748
+ }
1749
+ }
1750
+ function deepResizeGroupElement(elem, size) {
1751
+ const resizeW = size.w && size.w > 0 ? size.w : elem.w;
1752
+ const resizeH = size.h && size.h > 0 ? size.h : elem.h;
1753
+ const xRatio = resizeW / elem.w;
1754
+ const yRatio = resizeH / elem.h;
1755
+ if (xRatio === yRatio && xRatio === 1) {
1756
+ return elem;
1757
+ }
1758
+ const minRatio = Math.min(xRatio, yRatio);
1759
+ const maxRatio = Math.max(xRatio, yRatio);
1760
+ elem.w = resizeW;
1761
+ elem.h = resizeH;
1762
+ const opts = { xRatio, yRatio, minRatio, maxRatio };
1763
+ if (elem.type === "group" && Array.isArray(elem.detail.children)) {
1764
+ elem.detail.children.forEach((child) => {
1765
+ resizeElement$1(child, opts);
1766
+ });
1767
+ }
1768
+ resizeElementBaseDetail(elem, opts);
1769
+ return elem;
1770
+ }
1574
1771
  function createColorStyle(ctx, color2, opts) {
1575
1772
  if (typeof color2 === "string") {
1576
1773
  return color2;
@@ -1615,30 +1812,35 @@ var __privateMethod = (obj, member, method) => {
1615
1812
  return "#000000";
1616
1813
  }
1617
1814
  const defaultElemConfig = getDefaultElementDetailConfig();
1815
+ function getOpacity(elem) {
1816
+ var _a, _b, _c, _d;
1817
+ let opacity = 1;
1818
+ if (((_a = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _a === void 0 ? void 0 : _a.opacity) !== void 0 && ((_b = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _b === void 0 ? void 0 : _b.opacity) >= 0 && ((_c = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _c === void 0 ? void 0 : _c.opacity) <= 1) {
1819
+ opacity = (_d = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _d === void 0 ? void 0 : _d.opacity;
1820
+ }
1821
+ return opacity;
1822
+ }
1618
1823
  function drawBox(ctx, viewElem, opts) {
1619
1824
  const { pattern, renderContent, originElem, calcElemSize, viewScaleInfo, viewSizeInfo } = opts || {};
1825
+ const { parentOpacity } = opts;
1826
+ const opacity = getOpacity(originElem) * parentOpacity;
1620
1827
  drawClipPath(ctx, viewElem, {
1621
1828
  originElem,
1622
1829
  calcElemSize,
1623
1830
  viewScaleInfo,
1624
1831
  viewSizeInfo,
1625
1832
  renderContent: () => {
1626
- var _a, _b;
1627
- if (((_a = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _a === void 0 ? void 0 : _a.opacity) !== void 0 && ((_b = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _b === void 0 ? void 0 : _b.opacity) >= 0) {
1628
- ctx.globalAlpha = viewElem.detail.opacity;
1629
- } else {
1630
- ctx.globalAlpha = 1;
1631
- }
1833
+ ctx.globalAlpha = opacity;
1632
1834
  drawBoxBackground(ctx, viewElem, { pattern, viewScaleInfo, viewSizeInfo });
1633
1835
  renderContent === null || renderContent === void 0 ? void 0 : renderContent();
1634
1836
  drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
1635
- ctx.globalAlpha = 1;
1837
+ ctx.globalAlpha = parentOpacity;
1636
1838
  }
1637
1839
  });
1638
1840
  }
1639
1841
  function drawClipPath(ctx, viewElem, opts) {
1640
- const { renderContent, originElem, calcElemSize, viewScaleInfo, viewSizeInfo } = opts;
1641
- const totalScale = viewScaleInfo.scale * viewSizeInfo.devicePixelRatio;
1842
+ const { renderContent, originElem, calcElemSize, viewSizeInfo } = opts;
1843
+ const totalScale = viewSizeInfo.devicePixelRatio;
1642
1844
  const { clipPath } = (originElem === null || originElem === void 0 ? void 0 : originElem.detail) || {};
1643
1845
  if (clipPath && calcElemSize && clipPath.commands) {
1644
1846
  const { x: x2, y: y2, w: w2, h: h2 } = calcElemSize;
@@ -1647,8 +1849,8 @@ var __privateMethod = (obj, member, method) => {
1647
1849
  const scaleH = h2 / originH;
1648
1850
  const viewOriginX = originX * scaleW;
1649
1851
  const viewOriginY = originY * scaleH;
1650
- let internalX = x2 - viewOriginX;
1651
- let internalY = y2 - viewOriginY;
1852
+ const internalX = x2 - viewOriginX;
1853
+ const internalY = y2 - viewOriginY;
1652
1854
  ctx.save();
1653
1855
  ctx.translate(internalX, internalY);
1654
1856
  ctx.scale(totalScale * scaleW, totalScale * scaleH);
@@ -1668,8 +1870,7 @@ var __privateMethod = (obj, member, method) => {
1668
1870
  function drawBoxBackground(ctx, viewElem, opts) {
1669
1871
  var _a, _b;
1670
1872
  const { pattern, viewScaleInfo, viewSizeInfo } = opts;
1671
- let transform = [];
1672
- viewElem.detail;
1873
+ const transform = [];
1673
1874
  if (viewElem.detail.background || pattern) {
1674
1875
  const { x: x2, y: y2, w: w2, h: h2, radiusList } = calcViewBoxSize(viewElem, {
1675
1876
  viewScaleInfo,
@@ -1722,18 +1923,12 @@ var __privateMethod = (obj, member, method) => {
1722
1923
  }
1723
1924
  }
1724
1925
  function drawBoxBorder(ctx, viewElem, opts) {
1725
- var _a, _b;
1726
1926
  if (viewElem.detail.borderWidth === 0) {
1727
1927
  return;
1728
1928
  }
1729
1929
  if (!isColorStr(viewElem.detail.borderColor)) {
1730
1930
  return;
1731
1931
  }
1732
- if (((_a = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _a === void 0 ? void 0 : _a.opacity) !== void 0 && ((_b = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _b === void 0 ? void 0 : _b.opacity) >= 0) {
1733
- ctx.globalAlpha = viewElem.detail.opacity;
1734
- } else {
1735
- ctx.globalAlpha = 1;
1736
- }
1737
1932
  const { viewScaleInfo } = opts;
1738
1933
  const { scale } = viewScaleInfo;
1739
1934
  let borderColor2 = defaultElemConfig.borderColor;
@@ -1857,7 +2052,6 @@ var __privateMethod = (obj, member, method) => {
1857
2052
  ctx.arcTo(x2, y2, x2 + w2, y2, radiusList[0]);
1858
2053
  ctx.closePath();
1859
2054
  ctx.stroke();
1860
- ctx.globalAlpha = 1;
1861
2055
  }
1862
2056
  ctx.setLineDash([]);
1863
2057
  }
@@ -1879,53 +2073,69 @@ var __privateMethod = (obj, member, method) => {
1879
2073
  }
1880
2074
  function drawCircle(ctx, elem, opts) {
1881
2075
  const { detail, angle: angle2 } = elem;
1882
- const { background: background2 = "#000000", borderColor: borderColor2 = "#000000", borderWidth: borderWidth2 = 0 } = detail;
1883
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
1884
- const { x: x2, y: y2, w: w2, h: h2 } = calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, viewScaleInfo, viewSizeInfo);
2076
+ const { background: background2 = "#000000", borderColor: borderColor2 = "#000000", boxSizing, borderWidth: borderWidth2 = 0 } = detail;
2077
+ let bw = 0;
2078
+ if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
2079
+ bw = borderWidth2;
2080
+ } else if (Array.isArray(borderWidth2) && typeof borderWidth2[0] === "number" && borderWidth2[0] > 0) {
2081
+ bw = borderWidth2[0];
2082
+ }
2083
+ const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
2084
+ const { x: x2, y: y2, w: w2, h: h2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, viewScaleInfo, viewSizeInfo)) || elem;
1885
2085
  const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
1886
2086
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
1887
2087
  drawBoxShadow(ctx, viewElem, {
1888
2088
  viewScaleInfo,
1889
2089
  viewSizeInfo,
1890
2090
  renderContent: () => {
1891
- var _a, _b;
1892
- const a = w2 / 2;
1893
- const b = h2 / 2;
2091
+ let a = w2 / 2;
2092
+ let b = h2 / 2;
1894
2093
  const centerX = x2 + a;
1895
2094
  const centerY = y2 + b;
1896
- if (((_a = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _a === void 0 ? void 0 : _a.opacity) !== void 0 && ((_b = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _b === void 0 ? void 0 : _b.opacity) >= 0) {
1897
- ctx.globalAlpha = elem.detail.opacity;
1898
- } else {
1899
- ctx.globalAlpha = 1;
2095
+ if (bw > 0) {
2096
+ if (boxSizing === "border-box") {
2097
+ a = a - bw;
2098
+ b = b - bw;
2099
+ } else if (boxSizing === "center-line") {
2100
+ a = a - bw / 2;
2101
+ b = b - bw / 2;
2102
+ } else {
2103
+ a = a - bw;
2104
+ b = b - bw;
2105
+ }
1900
2106
  }
1901
- if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
1902
- const ba = borderWidth2 / 2 + a;
1903
- const bb = borderWidth2 / 2 + b;
2107
+ if (a >= 0 && b >= 0) {
2108
+ const opacity = getOpacity(viewElem) * parentOpacity;
2109
+ ctx.globalAlpha = opacity;
2110
+ if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
2111
+ const ba = borderWidth2 / 2 + a;
2112
+ const bb = borderWidth2 / 2 + b;
2113
+ ctx.beginPath();
2114
+ ctx.strokeStyle = borderColor2;
2115
+ ctx.lineWidth = borderWidth2;
2116
+ ctx.circle(centerX, centerY, ba, bb, 0, 0, 2 * Math.PI);
2117
+ ctx.closePath();
2118
+ ctx.stroke();
2119
+ }
1904
2120
  ctx.beginPath();
1905
- ctx.strokeStyle = borderColor2;
1906
- ctx.lineWidth = borderWidth2;
1907
- ctx.circle(centerX, centerY, ba, bb, 0, 0, 2 * Math.PI);
2121
+ const fillStyle = createColorStyle(ctx, background2, {
2122
+ viewElementSize: { x: x2, y: y2, w: w2, h: h2 },
2123
+ viewScaleInfo,
2124
+ opacity: ctx.globalAlpha
2125
+ });
2126
+ ctx.fillStyle = fillStyle;
2127
+ ctx.circle(centerX, centerY, a, b, 0, 0, 2 * Math.PI);
1908
2128
  ctx.closePath();
1909
- ctx.stroke();
2129
+ ctx.fill();
2130
+ ctx.globalAlpha = parentOpacity;
1910
2131
  }
1911
- ctx.beginPath();
1912
- const fillStyle = createColorStyle(ctx, background2, {
1913
- viewElementSize: { x: x2, y: y2, w: w2, h: h2 },
1914
- viewScaleInfo,
1915
- opacity: ctx.globalAlpha
1916
- });
1917
- ctx.fillStyle = fillStyle;
1918
- ctx.circle(centerX, centerY, a, b, 0, 0, 2 * Math.PI);
1919
- ctx.closePath();
1920
- ctx.fill();
1921
- ctx.globalAlpha = 1;
1922
2132
  }
1923
2133
  });
1924
2134
  });
1925
2135
  }
1926
2136
  function drawRect(ctx, elem, opts) {
1927
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
1928
- let { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
2137
+ const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
2138
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1929
2139
  const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
1930
2140
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
1931
2141
  drawBoxShadow(ctx, viewElem, {
@@ -1937,6 +2147,7 @@ var __privateMethod = (obj, member, method) => {
1937
2147
  calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
1938
2148
  viewScaleInfo,
1939
2149
  viewSizeInfo,
2150
+ parentOpacity,
1940
2151
  renderContent: () => {
1941
2152
  }
1942
2153
  });
@@ -1946,8 +2157,8 @@ var __privateMethod = (obj, member, method) => {
1946
2157
  }
1947
2158
  function drawImage(ctx, elem, opts) {
1948
2159
  const content = opts.loader.getContent(elem);
1949
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
1950
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
2160
+ const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
2161
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1951
2162
  const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
1952
2163
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
1953
2164
  drawBoxShadow(ctx, viewElem, {
@@ -1959,13 +2170,13 @@ var __privateMethod = (obj, member, method) => {
1959
2170
  calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
1960
2171
  viewScaleInfo,
1961
2172
  viewSizeInfo,
2173
+ parentOpacity,
1962
2174
  renderContent: () => {
1963
2175
  if (!content) {
1964
2176
  opts.loader.load(elem, opts.elementAssets || {});
1965
2177
  }
1966
2178
  if (elem.type === "image" && content) {
1967
- const { opacity } = elem.detail;
1968
- ctx.globalAlpha = opacity ? opacity : 1;
2179
+ ctx.globalAlpha = getOpacity(elem) * parentOpacity;
1969
2180
  const { x: x3, y: y3, w: w3, h: h3, radiusList } = calcViewBoxSize(viewElem, {
1970
2181
  viewScaleInfo,
1971
2182
  viewSizeInfo
@@ -1982,7 +2193,7 @@ var __privateMethod = (obj, member, method) => {
1982
2193
  ctx.fill();
1983
2194
  ctx.clip();
1984
2195
  ctx.drawImage(content, x3, y3, w3, h3);
1985
- ctx.globalAlpha = 1;
2196
+ ctx.globalAlpha = parentOpacity;
1986
2197
  ctx.restore();
1987
2198
  }
1988
2199
  }
@@ -1993,40 +2204,38 @@ var __privateMethod = (obj, member, method) => {
1993
2204
  }
1994
2205
  function drawSVG(ctx, elem, opts) {
1995
2206
  const content = opts.loader.getContent(elem);
1996
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
1997
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
2207
+ const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
2208
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1998
2209
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
1999
2210
  if (!content) {
2000
2211
  opts.loader.load(elem, opts.elementAssets || {});
2001
2212
  }
2002
2213
  if (elem.type === "svg" && content) {
2003
- const { opacity } = elem.detail;
2004
- ctx.globalAlpha = opacity ? opacity : 1;
2214
+ ctx.globalAlpha = getOpacity(elem) * parentOpacity;
2005
2215
  ctx.drawImage(content, x2, y2, w2, h2);
2006
- ctx.globalAlpha = 1;
2216
+ ctx.globalAlpha = parentOpacity;
2007
2217
  }
2008
2218
  });
2009
2219
  }
2010
2220
  function drawHTML(ctx, elem, opts) {
2011
2221
  const content = opts.loader.getContent(elem);
2012
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
2013
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
2222
+ const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
2223
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
2014
2224
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
2015
2225
  if (!content) {
2016
2226
  opts.loader.load(elem, opts.elementAssets || {});
2017
2227
  }
2018
2228
  if (elem.type === "html" && content) {
2019
- const { opacity } = elem.detail;
2020
- ctx.globalAlpha = opacity ? opacity : 1;
2229
+ ctx.globalAlpha = getOpacity(elem) * parentOpacity;
2021
2230
  ctx.drawImage(content, x2, y2, w2, h2);
2022
- ctx.globalAlpha = 1;
2231
+ ctx.globalAlpha = parentOpacity;
2023
2232
  }
2024
2233
  });
2025
2234
  }
2026
2235
  const detailConfig = getDefaultElementDetailConfig();
2027
2236
  function drawText(ctx, elem, opts) {
2028
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
2029
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
2237
+ const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
2238
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
2030
2239
  const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
2031
2240
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
2032
2241
  drawBox(ctx, viewElem, {
@@ -2034,6 +2243,7 @@ var __privateMethod = (obj, member, method) => {
2034
2243
  calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
2035
2244
  viewScaleInfo,
2036
2245
  viewSizeInfo,
2246
+ parentOpacity,
2037
2247
  renderContent: () => {
2038
2248
  const detail = Object.assign(Object.assign({}, detailConfig), elem.detail);
2039
2249
  const fontSize2 = (detail.fontSize || detailConfig.fontSize) * viewScaleInfo.scale;
@@ -2128,8 +2338,8 @@ var __privateMethod = (obj, member, method) => {
2128
2338
  function drawPath(ctx, elem, opts) {
2129
2339
  const { detail } = elem;
2130
2340
  const { originX, originY, originW, originH } = detail;
2131
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
2132
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
2341
+ const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
2342
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
2133
2343
  const scaleW = w2 / originW;
2134
2344
  const scaleH = h2 / originH;
2135
2345
  const viewOriginX = originX * scaleW;
@@ -2144,6 +2354,7 @@ var __privateMethod = (obj, member, method) => {
2144
2354
  calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
2145
2355
  viewScaleInfo,
2146
2356
  viewSizeInfo,
2357
+ parentOpacity,
2147
2358
  renderContent: () => {
2148
2359
  drawBoxShadow(ctx, viewElem, {
2149
2360
  viewScaleInfo,
@@ -2177,6 +2388,11 @@ var __privateMethod = (obj, member, method) => {
2177
2388
  if (((_a = elem === null || elem === void 0 ? void 0 : elem.operations) === null || _a === void 0 ? void 0 : _a.invisible) === true) {
2178
2389
  return;
2179
2390
  }
2391
+ const { w: w2, h: h2 } = elem;
2392
+ const { scale } = opts.viewScaleInfo;
2393
+ if (scale < 1 && (w2 * scale < 1 || h2 * scale < 1) || opts.parentOpacity === 0) {
2394
+ return;
2395
+ }
2180
2396
  try {
2181
2397
  switch (elem.type) {
2182
2398
  case "rect": {
@@ -2221,10 +2437,11 @@ var __privateMethod = (obj, member, method) => {
2221
2437
  }
2222
2438
  }
2223
2439
  function drawGroup(ctx, elem, opts) {
2224
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
2225
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, viewScaleInfo, viewSizeInfo);
2440
+ const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
2441
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, viewScaleInfo, viewSizeInfo)) || elem;
2226
2442
  const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
2227
2443
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
2444
+ ctx.globalAlpha = getOpacity(elem) * parentOpacity;
2228
2445
  drawBoxShadow(ctx, viewElem, {
2229
2446
  viewScaleInfo,
2230
2447
  viewSizeInfo,
@@ -2234,6 +2451,7 @@ var __privateMethod = (obj, member, method) => {
2234
2451
  calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
2235
2452
  viewScaleInfo,
2236
2453
  viewSizeInfo,
2454
+ parentOpacity,
2237
2455
  renderContent: () => {
2238
2456
  const { x: x3, y: y3, w: w3, h: h3, radiusList } = calcViewBoxSize(viewElem, {
2239
2457
  viewScaleInfo,
@@ -2268,44 +2486,74 @@ var __privateMethod = (obj, member, method) => {
2268
2486
  x: newParentSize.x + child.x,
2269
2487
  y: newParentSize.y + child.y
2270
2488
  });
2271
- if (!calculator2.isElementInView(child, opts.viewScaleInfo, opts.viewSizeInfo)) {
2272
- continue;
2489
+ if (opts.forceDrawAll !== true) {
2490
+ if (!(calculator2 === null || calculator2 === void 0 ? void 0 : calculator2.isElementInView(child, opts.viewScaleInfo, opts.viewSizeInfo))) {
2491
+ continue;
2492
+ }
2273
2493
  }
2274
2494
  try {
2275
- drawElement(ctx, child, Object.assign({}, opts));
2495
+ drawElement(ctx, child, Object.assign(Object.assign({}, opts), { parentOpacity: parentOpacity * getOpacity(elem) }));
2276
2496
  } catch (err) {
2277
2497
  console.error(err);
2278
2498
  }
2279
2499
  }
2280
2500
  }
2281
2501
  if (elem.detail.overflow === "hidden") {
2282
- ctx.globalAlpha = 1;
2283
2502
  ctx.restore();
2284
2503
  }
2285
2504
  }
2286
2505
  });
2287
2506
  }
2288
2507
  });
2508
+ ctx.globalAlpha = parentOpacity;
2289
2509
  });
2290
2510
  }
2291
2511
  const defaultDetail = getDefaultElementDetailConfig();
2292
2512
  function drawElementList(ctx, data, opts) {
2513
+ var _a;
2293
2514
  const { elements = [] } = data;
2515
+ const { parentOpacity } = opts;
2294
2516
  for (let i = 0; i < elements.length; i++) {
2295
2517
  const element = elements[i];
2296
2518
  const elem = Object.assign(Object.assign({}, element), {
2297
2519
  detail: Object.assign(Object.assign({}, defaultDetail), element === null || element === void 0 ? void 0 : element.detail)
2298
2520
  });
2299
- if (!opts.calculator.isElementInView(elem, opts.viewScaleInfo, opts.viewSizeInfo)) {
2300
- continue;
2521
+ if (opts.forceDrawAll !== true) {
2522
+ if (!((_a = opts.calculator) === null || _a === void 0 ? void 0 : _a.isElementInView(elem, opts.viewScaleInfo, opts.viewSizeInfo))) {
2523
+ continue;
2524
+ }
2301
2525
  }
2302
2526
  try {
2303
- drawElement(ctx, elem, opts);
2527
+ drawElement(ctx, elem, Object.assign(Object.assign({}, opts), {
2528
+ parentOpacity
2529
+ }));
2304
2530
  } catch (err) {
2305
2531
  console.error(err);
2306
2532
  }
2307
2533
  }
2308
2534
  }
2535
+ function drawUnderlay(ctx, underlay, opts) {
2536
+ const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
2537
+ const elem = Object.assign({ uuid: "underlay" }, underlay);
2538
+ const { x: x2, y: y2, w: w2, h: h2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
2539
+ const angle2 = 0;
2540
+ const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
2541
+ drawBoxShadow(ctx, viewElem, {
2542
+ viewScaleInfo,
2543
+ viewSizeInfo,
2544
+ renderContent: () => {
2545
+ drawBox(ctx, viewElem, {
2546
+ originElem: elem,
2547
+ calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
2548
+ viewScaleInfo,
2549
+ viewSizeInfo,
2550
+ parentOpacity,
2551
+ renderContent: () => {
2552
+ }
2553
+ });
2554
+ }
2555
+ });
2556
+ }
2309
2557
  var __awaiter = function(thisArg, _arguments, P, generator) {
2310
2558
  function adopt(value) {
2311
2559
  return value instanceof P ? value : new P(function(resolve) {
@@ -2333,6 +2581,23 @@ var __privateMethod = (obj, member, method) => {
2333
2581
  step((generator = generator.apply(thisArg, _arguments || [])).next());
2334
2582
  });
2335
2583
  };
2584
+ var __classPrivateFieldGet$6 = function(receiver, state, kind, f) {
2585
+ if (kind === "a" && !f)
2586
+ throw new TypeError("Private accessor was defined without a getter");
2587
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2588
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
2589
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2590
+ };
2591
+ var __classPrivateFieldSet$6 = function(receiver, state, value, kind, f) {
2592
+ if (kind === "m")
2593
+ throw new TypeError("Private method is not writable");
2594
+ if (kind === "a" && !f)
2595
+ throw new TypeError("Private accessor was defined without a setter");
2596
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2597
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
2598
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2599
+ };
2600
+ var _Loader_instances, _Loader_loadFuncMap, _Loader_currentLoadItemMap, _Loader_storageLoadItemMap, _Loader_registerLoadFunc, _Loader_getLoadElementSource, _Loader_createLoadItem, _Loader_emitLoad, _Loader_emitError, _Loader_loadResource, _Loader_isExistingErrorStorage;
2336
2601
  const supportElementTypes = ["image", "svg", "html"];
2337
2602
  const getAssetIdFromElement = (element) => {
2338
2603
  var _a, _b, _c;
@@ -2355,10 +2620,11 @@ var __privateMethod = (obj, member, method) => {
2355
2620
  class Loader extends EventEmitter {
2356
2621
  constructor() {
2357
2622
  super();
2358
- this._loadFuncMap = {};
2359
- this._currentLoadItemMap = {};
2360
- this._storageLoadItemMap = {};
2361
- this._registerLoadFunc("image", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2623
+ _Loader_instances.add(this);
2624
+ _Loader_loadFuncMap.set(this, {});
2625
+ _Loader_currentLoadItemMap.set(this, {});
2626
+ _Loader_storageLoadItemMap.set(this, {});
2627
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "image", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2362
2628
  var _a;
2363
2629
  const src = ((_a = assets[elem.detail.src]) === null || _a === void 0 ? void 0 : _a.value) || elem.detail.src;
2364
2630
  const content = yield loadImage(src);
@@ -2368,12 +2634,12 @@ var __privateMethod = (obj, member, method) => {
2368
2634
  content
2369
2635
  };
2370
2636
  }));
2371
- this._registerLoadFunc("html", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2637
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "html", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2372
2638
  var _b;
2373
2639
  const html2 = ((_b = assets[elem.detail.html]) === null || _b === void 0 ? void 0 : _b.value) || elem.detail.html;
2374
2640
  const content = yield loadHTML(html2, {
2375
- width: elem.detail.width || elem.w,
2376
- height: elem.detail.height || elem.h
2641
+ width: elem.detail.originW || elem.w,
2642
+ height: elem.detail.originH || elem.h
2377
2643
  });
2378
2644
  return {
2379
2645
  uuid: elem.uuid,
@@ -2381,7 +2647,7 @@ var __privateMethod = (obj, member, method) => {
2381
2647
  content
2382
2648
  };
2383
2649
  }));
2384
- this._registerLoadFunc("svg", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2650
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "svg", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2385
2651
  var _c;
2386
2652
  const svg2 = ((_c = assets[elem.detail.svg]) === null || _c === void 0 ? void 0 : _c.value) || elem.detail.svg;
2387
2653
  const content = yield loadSVG(svg2);
@@ -2392,124 +2658,146 @@ var __privateMethod = (obj, member, method) => {
2392
2658
  };
2393
2659
  }));
2394
2660
  }
2395
- _registerLoadFunc(type, func) {
2396
- this._loadFuncMap[type] = func;
2397
- }
2398
- _getLoadElementSource(element) {
2399
- var _a, _b, _c;
2400
- let source = null;
2401
- if (element.type === "image") {
2402
- source = ((_a = element === null || element === void 0 ? void 0 : element.detail) === null || _a === void 0 ? void 0 : _a.src) || null;
2403
- } else if (element.type === "svg") {
2404
- source = ((_b = element === null || element === void 0 ? void 0 : element.detail) === null || _b === void 0 ? void 0 : _b.svg) || null;
2405
- } else if (element.type === "html") {
2406
- source = ((_c = element === null || element === void 0 ? void 0 : element.detail) === null || _c === void 0 ? void 0 : _c.html) || null;
2407
- }
2408
- return source;
2409
- }
2410
- _createLoadItem(element) {
2411
- return {
2412
- element,
2413
- status: "null",
2414
- content: null,
2415
- error: null,
2416
- startTime: -1,
2417
- endTime: -1,
2418
- source: this._getLoadElementSource(element)
2419
- };
2420
- }
2421
- _emitLoad(item) {
2422
- const assetId = getAssetIdFromElement(item.element);
2423
- const storageItem = this._storageLoadItemMap[assetId];
2424
- if (storageItem) {
2425
- if (storageItem.startTime < item.startTime) {
2426
- this._storageLoadItemMap[assetId] = item;
2427
- this.trigger("load", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2428
- }
2429
- } else {
2430
- this._storageLoadItemMap[assetId] = item;
2431
- this.trigger("load", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2432
- }
2433
- }
2434
- _emitError(item) {
2435
- const assetId = getAssetIdFromElement(item.element);
2436
- const storageItem = this._storageLoadItemMap[assetId];
2437
- if (storageItem) {
2438
- if (storageItem.startTime < item.startTime) {
2439
- this._storageLoadItemMap[assetId] = item;
2440
- this.trigger("error", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2441
- }
2442
- } else {
2443
- this._storageLoadItemMap[assetId] = item;
2444
- this.trigger("error", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2445
- }
2446
- }
2447
- _loadResource(element, assets) {
2448
- const item = this._createLoadItem(element);
2449
- const assetId = getAssetIdFromElement(element);
2450
- this._currentLoadItemMap[assetId] = item;
2451
- const loadFunc = this._loadFuncMap[element.type];
2452
- if (typeof loadFunc === "function") {
2453
- item.startTime = Date.now();
2454
- loadFunc(element, assets).then((result) => {
2455
- item.content = result.content;
2456
- item.endTime = Date.now();
2457
- item.status = "load";
2458
- this._emitLoad(item);
2459
- }).catch((err) => {
2460
- console.warn(`Load element source "${item.source}" fail`, err, element);
2461
- item.endTime = Date.now();
2462
- item.status = "error";
2463
- item.error = err;
2464
- this._emitError(item);
2465
- });
2466
- }
2467
- }
2468
- _isExistingErrorStorage(element) {
2469
- var _a;
2470
- const assetId = getAssetIdFromElement(element);
2471
- const existItem = (_a = this._currentLoadItemMap) === null || _a === void 0 ? void 0 : _a[assetId];
2472
- if (existItem && existItem.status === "error" && existItem.source && existItem.source === this._getLoadElementSource(element)) {
2473
- return true;
2474
- }
2475
- return false;
2661
+ destroy() {
2662
+ __classPrivateFieldSet$6(this, _Loader_loadFuncMap, null, "f");
2663
+ __classPrivateFieldSet$6(this, _Loader_currentLoadItemMap, null, "f");
2664
+ __classPrivateFieldSet$6(this, _Loader_storageLoadItemMap, null, "f");
2476
2665
  }
2477
2666
  load(element, assets) {
2478
- if (this._isExistingErrorStorage(element)) {
2667
+ if (__classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_isExistingErrorStorage).call(this, element)) {
2479
2668
  return;
2480
2669
  }
2481
2670
  if (supportElementTypes.includes(element.type)) {
2482
- this._loadResource(element, assets);
2671
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_loadResource).call(this, element, assets);
2483
2672
  }
2484
2673
  }
2485
2674
  getContent(element) {
2486
2675
  var _a, _b;
2487
2676
  const assetId = getAssetIdFromElement(element);
2488
- return ((_b = (_a = this._storageLoadItemMap) === null || _a === void 0 ? void 0 : _a[assetId]) === null || _b === void 0 ? void 0 : _b.content) || null;
2677
+ return ((_b = (_a = __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")) === null || _a === void 0 ? void 0 : _a[assetId]) === null || _b === void 0 ? void 0 : _b.content) || null;
2678
+ }
2679
+ getLoadItemMap() {
2680
+ return __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f");
2681
+ }
2682
+ setLoadItemMap(itemMap) {
2683
+ __classPrivateFieldSet$6(this, _Loader_storageLoadItemMap, itemMap, "f");
2489
2684
  }
2490
2685
  }
2686
+ _Loader_loadFuncMap = /* @__PURE__ */ new WeakMap(), _Loader_currentLoadItemMap = /* @__PURE__ */ new WeakMap(), _Loader_storageLoadItemMap = /* @__PURE__ */ new WeakMap(), _Loader_instances = /* @__PURE__ */ new WeakSet(), _Loader_registerLoadFunc = function _Loader_registerLoadFunc2(type, func) {
2687
+ __classPrivateFieldGet$6(this, _Loader_loadFuncMap, "f")[type] = func;
2688
+ }, _Loader_getLoadElementSource = function _Loader_getLoadElementSource2(element) {
2689
+ var _a, _b, _c;
2690
+ let source = null;
2691
+ if (element.type === "image") {
2692
+ source = ((_a = element === null || element === void 0 ? void 0 : element.detail) === null || _a === void 0 ? void 0 : _a.src) || null;
2693
+ } else if (element.type === "svg") {
2694
+ source = ((_b = element === null || element === void 0 ? void 0 : element.detail) === null || _b === void 0 ? void 0 : _b.svg) || null;
2695
+ } else if (element.type === "html") {
2696
+ source = ((_c = element === null || element === void 0 ? void 0 : element.detail) === null || _c === void 0 ? void 0 : _c.html) || null;
2697
+ }
2698
+ return source;
2699
+ }, _Loader_createLoadItem = function _Loader_createLoadItem2(element) {
2700
+ return {
2701
+ element,
2702
+ status: "null",
2703
+ content: null,
2704
+ error: null,
2705
+ startTime: -1,
2706
+ endTime: -1,
2707
+ source: __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_getLoadElementSource).call(this, element)
2708
+ };
2709
+ }, _Loader_emitLoad = function _Loader_emitLoad2(item) {
2710
+ const assetId = getAssetIdFromElement(item.element);
2711
+ const storageItem = __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId];
2712
+ if (storageItem) {
2713
+ if (storageItem.startTime < item.startTime) {
2714
+ __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2715
+ this.trigger("load", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2716
+ }
2717
+ } else {
2718
+ __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2719
+ this.trigger("load", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2720
+ }
2721
+ }, _Loader_emitError = function _Loader_emitError2(item) {
2722
+ var _a;
2723
+ const assetId = getAssetIdFromElement(item.element);
2724
+ const storageItem = (_a = __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")) === null || _a === void 0 ? void 0 : _a[assetId];
2725
+ if (storageItem) {
2726
+ if (storageItem.startTime < item.startTime) {
2727
+ __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2728
+ this.trigger("error", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2729
+ }
2730
+ } else {
2731
+ __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2732
+ this.trigger("error", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2733
+ }
2734
+ }, _Loader_loadResource = function _Loader_loadResource2(element, assets) {
2735
+ const item = __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_createLoadItem).call(this, element);
2736
+ const assetId = getAssetIdFromElement(element);
2737
+ __classPrivateFieldGet$6(this, _Loader_currentLoadItemMap, "f")[assetId] = item;
2738
+ const loadFunc = __classPrivateFieldGet$6(this, _Loader_loadFuncMap, "f")[element.type];
2739
+ if (typeof loadFunc === "function") {
2740
+ item.startTime = Date.now();
2741
+ loadFunc(element, assets).then((result) => {
2742
+ item.content = result.content;
2743
+ item.endTime = Date.now();
2744
+ item.status = "load";
2745
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_emitLoad).call(this, item);
2746
+ }).catch((err) => {
2747
+ console.warn(`Load element source "${item.source}" fail`, err, element);
2748
+ item.endTime = Date.now();
2749
+ item.status = "error";
2750
+ item.error = err;
2751
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_emitError).call(this, item);
2752
+ });
2753
+ }
2754
+ }, _Loader_isExistingErrorStorage = function _Loader_isExistingErrorStorage2(element) {
2755
+ var _a;
2756
+ const assetId = getAssetIdFromElement(element);
2757
+ const existItem = (_a = __classPrivateFieldGet$6(this, _Loader_currentLoadItemMap, "f")) === null || _a === void 0 ? void 0 : _a[assetId];
2758
+ if (existItem && existItem.status === "error" && existItem.source && existItem.source === __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_getLoadElementSource).call(this, element)) {
2759
+ return true;
2760
+ }
2761
+ return false;
2762
+ };
2763
+ var __classPrivateFieldSet$5 = function(receiver, state, value, kind, f) {
2764
+ if (kind === "m")
2765
+ throw new TypeError("Private method is not writable");
2766
+ if (kind === "a" && !f)
2767
+ throw new TypeError("Private accessor was defined without a setter");
2768
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2769
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
2770
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2771
+ };
2772
+ var __classPrivateFieldGet$5 = function(receiver, state, kind, f) {
2773
+ if (kind === "a" && !f)
2774
+ throw new TypeError("Private accessor was defined without a getter");
2775
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2776
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
2777
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2778
+ };
2779
+ var _Renderer_instances, _Renderer_opts, _Renderer_loader, _Renderer_init;
2491
2780
  class Renderer extends EventEmitter {
2492
2781
  constructor(opts) {
2493
2782
  super();
2494
- this._loader = new Loader();
2495
- this._opts = opts;
2496
- this._init();
2783
+ _Renderer_instances.add(this);
2784
+ _Renderer_opts.set(this, void 0);
2785
+ _Renderer_loader.set(this, new Loader());
2786
+ __classPrivateFieldSet$5(this, _Renderer_opts, opts, "f");
2787
+ __classPrivateFieldGet$5(this, _Renderer_instances, "m", _Renderer_init).call(this);
2497
2788
  }
2498
- _init() {
2499
- const { _loader: loader } = this;
2500
- loader.on("load", (e) => {
2501
- this.trigger("load", e);
2502
- });
2503
- loader.on("error", () => {
2504
- });
2789
+ destroy() {
2790
+ __classPrivateFieldSet$5(this, _Renderer_opts, null, "f");
2791
+ __classPrivateFieldGet$5(this, _Renderer_loader, "f").destroy();
2792
+ __classPrivateFieldSet$5(this, _Renderer_loader, null, "f");
2505
2793
  }
2506
2794
  updateOptions(opts) {
2507
- this._opts = opts;
2795
+ __classPrivateFieldSet$5(this, _Renderer_opts, opts, "f");
2508
2796
  }
2509
2797
  drawData(data, opts) {
2510
- const { _loader: loader } = this;
2511
- const { calculator } = this._opts;
2512
- const { viewContext } = this._opts.viewContent;
2798
+ const loader = __classPrivateFieldGet$5(this, _Renderer_loader, "f");
2799
+ const { calculator } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
2800
+ const viewContext = __classPrivateFieldGet$5(this, _Renderer_opts, "f").viewContext;
2513
2801
  viewContext.clearRect(0, 0, viewContext.canvas.width, viewContext.canvas.height);
2514
2802
  const parentElementSize = {
2515
2803
  x: 0,
@@ -2517,15 +2805,27 @@ var __privateMethod = (obj, member, method) => {
2517
2805
  w: opts.viewSizeInfo.width,
2518
2806
  h: opts.viewSizeInfo.height
2519
2807
  };
2808
+ if (data.underlay) {
2809
+ drawUnderlay(viewContext, data.underlay, Object.assign({
2810
+ loader,
2811
+ calculator,
2812
+ parentElementSize,
2813
+ parentOpacity: 1
2814
+ }, opts));
2815
+ }
2520
2816
  drawElementList(viewContext, data, Object.assign({
2521
2817
  loader,
2522
2818
  calculator,
2523
2819
  parentElementSize,
2524
- elementAssets: data.assets
2820
+ elementAssets: data.assets,
2821
+ parentOpacity: 1
2525
2822
  }, opts));
2526
2823
  }
2527
2824
  scale(num) {
2528
- const { sharer } = this._opts;
2825
+ const { sharer } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
2826
+ if (!sharer) {
2827
+ return;
2828
+ }
2529
2829
  const { data, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = sharer.getActiveStoreSnapshot();
2530
2830
  if (data) {
2531
2831
  this.drawData(data, {
@@ -2546,10 +2846,48 @@ var __privateMethod = (obj, member, method) => {
2546
2846
  });
2547
2847
  }
2548
2848
  }
2849
+ setLoadItemMap(itemMap) {
2850
+ __classPrivateFieldGet$5(this, _Renderer_loader, "f").setLoadItemMap(itemMap);
2851
+ }
2852
+ getLoadItemMap() {
2853
+ return __classPrivateFieldGet$5(this, _Renderer_loader, "f").getLoadItemMap();
2854
+ }
2855
+ getLoader() {
2856
+ return __classPrivateFieldGet$5(this, _Renderer_loader, "f");
2857
+ }
2549
2858
  }
2859
+ _Renderer_opts = /* @__PURE__ */ new WeakMap(), _Renderer_loader = /* @__PURE__ */ new WeakMap(), _Renderer_instances = /* @__PURE__ */ new WeakSet(), _Renderer_init = function _Renderer_init2() {
2860
+ const loader = __classPrivateFieldGet$5(this, _Renderer_loader, "f");
2861
+ loader.on("load", (e) => {
2862
+ this.trigger("load", e);
2863
+ });
2864
+ loader.on("error", () => {
2865
+ });
2866
+ };
2867
+ var __classPrivateFieldSet$4 = function(receiver, state, value, kind, f) {
2868
+ if (kind === "m")
2869
+ throw new TypeError("Private method is not writable");
2870
+ if (kind === "a" && !f)
2871
+ throw new TypeError("Private accessor was defined without a setter");
2872
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2873
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
2874
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2875
+ };
2876
+ var __classPrivateFieldGet$4 = function(receiver, state, kind, f) {
2877
+ if (kind === "a" && !f)
2878
+ throw new TypeError("Private accessor was defined without a getter");
2879
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2880
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
2881
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2882
+ };
2883
+ var _Calculator_opts;
2550
2884
  class Calculator {
2551
2885
  constructor(opts) {
2552
- this._opts = opts;
2886
+ _Calculator_opts.set(this, void 0);
2887
+ __classPrivateFieldSet$4(this, _Calculator_opts, opts, "f");
2888
+ }
2889
+ destroy() {
2890
+ __classPrivateFieldSet$4(this, _Calculator_opts, null, "f");
2553
2891
  }
2554
2892
  elementSize(size, viewScaleInfo, viewSizeInfo) {
2555
2893
  return calcViewElementSize(size, { viewScaleInfo, viewSizeInfo });
@@ -2558,7 +2896,7 @@ var __privateMethod = (obj, member, method) => {
2558
2896
  return isElementInView(elem, { viewScaleInfo, viewSizeInfo });
2559
2897
  }
2560
2898
  isPointInElement(p, elem, viewScaleInfo, viewSizeInfo) {
2561
- const context2d = this._opts.viewContent.boardContext;
2899
+ const context2d = __classPrivateFieldGet$4(this, _Calculator_opts, "f").viewContext;
2562
2900
  return isViewPointInElement(p, {
2563
2901
  context2d,
2564
2902
  element: elem,
@@ -2567,151 +2905,206 @@ var __privateMethod = (obj, member, method) => {
2567
2905
  });
2568
2906
  }
2569
2907
  getPointElement(p, opts) {
2570
- const context2d = this._opts.viewContent.boardContext;
2908
+ const context2d = __classPrivateFieldGet$4(this, _Calculator_opts, "f").viewContext;
2571
2909
  return getViewPointAtElement(p, Object.assign(Object.assign({}, opts), { context2d }));
2572
2910
  }
2573
2911
  }
2912
+ _Calculator_opts = /* @__PURE__ */ new WeakMap();
2913
+ var __classPrivateFieldSet$3 = function(receiver, state, value, kind, f) {
2914
+ if (kind === "m")
2915
+ throw new TypeError("Private method is not writable");
2916
+ if (kind === "a" && !f)
2917
+ throw new TypeError("Private accessor was defined without a setter");
2918
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2919
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
2920
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2921
+ };
2922
+ var __classPrivateFieldGet$3 = function(receiver, state, kind, f) {
2923
+ if (kind === "a" && !f)
2924
+ throw new TypeError("Private accessor was defined without a getter");
2925
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2926
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
2927
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2928
+ };
2929
+ var _BoardWatcher_instances, _BoardWatcher_opts, _BoardWatcher_store, _BoardWatcher_init, _BoardWatcher_onWheel, _BoardWatcher_onContextMenu, _BoardWatcher_onClick, _BoardWatcher_onPointLeave, _BoardWatcher_onPointEnd, _BoardWatcher_onPointMove, _BoardWatcher_onPointStart, _BoardWatcher_onHover, _BoardWatcher_isInTarget, _BoardWatcher_getPoint, _BoardWatcher_isVaildPoint;
2574
2930
  function isBoardAvailableNum(num) {
2575
2931
  return num > 0 || num < 0 || num === 0;
2576
2932
  }
2577
2933
  class BoardWatcher extends EventEmitter {
2578
2934
  constructor(opts) {
2579
2935
  super();
2580
- const store = new Store({ defaultStorage: { hasPointDown: false, prevClickPoint: null } });
2581
- this._store = store;
2582
- this._opts = opts;
2583
- this._init();
2584
- }
2585
- _init() {
2586
- const container = window;
2587
- container.addEventListener("mousemove", (e) => {
2588
- if (!this._isInTarget(e)) {
2936
+ _BoardWatcher_instances.add(this);
2937
+ _BoardWatcher_opts.set(this, void 0);
2938
+ _BoardWatcher_store.set(this, void 0);
2939
+ _BoardWatcher_onWheel.set(this, (e) => {
2940
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2589
2941
  return;
2590
2942
  }
2591
- e.preventDefault();
2592
- const point = this._getPoint(e);
2593
- if (!this._isVaildPoint(point)) {
2943
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2944
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2594
2945
  return;
2595
2946
  }
2596
- this.trigger("hover", { point });
2947
+ e.preventDefault();
2948
+ e.stopPropagation();
2949
+ const deltaX = e.deltaX > 0 || e.deltaX < 0 ? e.deltaX : 0;
2950
+ const deltaY = e.deltaY > 0 || e.deltaY < 0 ? e.deltaY : 0;
2951
+ if (e.ctrlKey === true && this.has("wheelScale")) {
2952
+ this.trigger("wheelScale", { deltaX, deltaY, point });
2953
+ } else if (this.has("wheel")) {
2954
+ this.trigger("wheel", { deltaX, deltaY, point });
2955
+ }
2597
2956
  });
2598
- container.addEventListener("mousedown", (e) => {
2599
- if (!this._isInTarget(e)) {
2957
+ _BoardWatcher_onContextMenu.set(this, (e) => {
2958
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2600
2959
  return;
2601
2960
  }
2602
2961
  e.preventDefault();
2603
- const point = this._getPoint(e);
2604
- if (!this._isVaildPoint(point)) {
2962
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2963
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2605
2964
  return;
2606
2965
  }
2607
- this._store.set("hasPointDown", true);
2608
- this.trigger("pointStart", { point });
2609
2966
  });
2610
- container.addEventListener("mousemove", (e) => {
2611
- if (!this._isInTarget(e)) {
2967
+ _BoardWatcher_onClick.set(this, (e) => {
2968
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2612
2969
  return;
2613
2970
  }
2614
2971
  e.preventDefault();
2615
- e.stopPropagation();
2616
- const point = this._getPoint(e);
2617
- if (!this._isVaildPoint(point)) {
2618
- if (this._store.get("hasPointDown")) {
2619
- this.trigger("pointLeave", { point });
2620
- this._store.set("hasPointDown", false);
2621
- }
2972
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2973
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2622
2974
  return;
2623
2975
  }
2624
- if (this._store.get("hasPointDown") !== true) {
2625
- return;
2976
+ const maxLimitTime = 500;
2977
+ const t = Date.now();
2978
+ const preClickPoint = __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").get("prevClickPoint");
2979
+ if (preClickPoint && t - preClickPoint.t <= maxLimitTime && Math.abs(preClickPoint.x - point.x) <= 5 && Math.abs(preClickPoint.y - point.y) <= 5) {
2980
+ this.trigger("doubleClick", { point });
2981
+ } else {
2982
+ __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("prevClickPoint", point);
2626
2983
  }
2627
- this.trigger("pointMove", { point });
2628
2984
  });
2629
- container.addEventListener("mouseup", (e) => {
2630
- this._store.set("hasPointDown", false);
2631
- if (!this._isInTarget(e)) {
2985
+ _BoardWatcher_onPointLeave.set(this, (e) => {
2986
+ __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", false);
2987
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2632
2988
  return;
2633
2989
  }
2634
2990
  e.preventDefault();
2635
- const point = this._getPoint(e);
2636
- this.trigger("pointEnd", { point });
2991
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2992
+ this.trigger("pointLeave", { point });
2637
2993
  });
2638
- container.addEventListener("mouseleave", (e) => {
2639
- this._store.set("hasPointDown", false);
2640
- if (!this._isInTarget(e)) {
2994
+ _BoardWatcher_onPointEnd.set(this, (e) => {
2995
+ __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", false);
2996
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2641
2997
  return;
2642
2998
  }
2643
2999
  e.preventDefault();
2644
- const point = this._getPoint(e);
2645
- this.trigger("pointLeave", { point });
3000
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
3001
+ this.trigger("pointEnd", { point });
2646
3002
  });
2647
- container.addEventListener("wheel", (e) => {
2648
- if (!this._isInTarget(e)) {
3003
+ _BoardWatcher_onPointMove.set(this, (e) => {
3004
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2649
3005
  return;
2650
3006
  }
2651
- const point = this._getPoint(e);
2652
- if (!this._isVaildPoint(point)) {
3007
+ e.preventDefault();
3008
+ e.stopPropagation();
3009
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
3010
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
3011
+ if (__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").get("hasPointDown")) {
3012
+ this.trigger("pointLeave", { point });
3013
+ __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", false);
3014
+ }
2653
3015
  return;
2654
3016
  }
2655
- e.preventDefault();
2656
- const deltaX = e.deltaX > 0 || e.deltaX < 0 ? e.deltaX : 0;
2657
- const deltaY = e.deltaY > 0 || e.deltaY < 0 ? e.deltaY : 0;
2658
- if (e.ctrlKey === true && this.has("wheelScale")) {
2659
- this.trigger("wheelScale", { deltaX, deltaY, point });
2660
- } else if (this.has("wheel")) {
2661
- this.trigger("wheel", { deltaX, deltaY, point });
3017
+ if (__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").get("hasPointDown") !== true) {
3018
+ return;
2662
3019
  }
2663
- }, { passive: false });
2664
- container.addEventListener("click", (e) => {
2665
- if (!this._isInTarget(e)) {
3020
+ this.trigger("pointMove", { point });
3021
+ });
3022
+ _BoardWatcher_onPointStart.set(this, (e) => {
3023
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2666
3024
  return;
2667
3025
  }
2668
3026
  e.preventDefault();
2669
- const point = this._getPoint(e);
2670
- if (!this._isVaildPoint(point)) {
3027
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
3028
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2671
3029
  return;
2672
3030
  }
2673
- const maxLimitTime = 500;
2674
- const t = Date.now();
2675
- const preClickPoint = this._store.get("prevClickPoint");
2676
- if (preClickPoint && t - preClickPoint.t <= maxLimitTime && Math.abs(preClickPoint.x - point.x) <= 5 && Math.abs(preClickPoint.y - point.y) <= 5) {
2677
- this.trigger("doubleClick", { point });
2678
- } else {
2679
- this._store.set("prevClickPoint", point);
2680
- }
3031
+ __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", true);
3032
+ this.trigger("pointStart", { point });
2681
3033
  });
2682
- container.addEventListener("contextmenu", (e) => {
2683
- if (!this._isInTarget(e)) {
3034
+ _BoardWatcher_onHover.set(this, (e) => {
3035
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2684
3036
  return;
2685
3037
  }
2686
3038
  e.preventDefault();
2687
- const point = this._getPoint(e);
2688
- if (!this._isVaildPoint(point)) {
3039
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
3040
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2689
3041
  return;
2690
3042
  }
3043
+ this.trigger("hover", { point });
2691
3044
  });
3045
+ const store = new Store({ defaultStorage: { hasPointDown: false, prevClickPoint: null } });
3046
+ __classPrivateFieldSet$3(this, _BoardWatcher_store, store, "f");
3047
+ __classPrivateFieldSet$3(this, _BoardWatcher_opts, opts, "f");
3048
+ __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_init).call(this);
2692
3049
  }
2693
- _isInTarget(e) {
2694
- return e.target === this._opts.viewContent.boardContext.canvas;
2695
- }
2696
- _getPoint(e) {
2697
- const boardCanvas = this._opts.viewContent.boardContext.canvas;
2698
- const rect = boardCanvas.getBoundingClientRect();
2699
- const p = {
2700
- x: e.clientX - rect.left,
2701
- y: e.clientY - rect.top,
2702
- t: Date.now()
2703
- };
2704
- return p;
2705
- }
2706
- _isVaildPoint(p) {
2707
- const viewSize = this._opts.sharer.getActiveViewSizeInfo();
2708
- const { width, height } = viewSize;
2709
- if (isBoardAvailableNum(p.x) && isBoardAvailableNum(p.y) && p.x <= width && p.y <= height) {
2710
- return true;
2711
- }
2712
- return false;
3050
+ destroy() {
3051
+ const container = window;
3052
+ container.removeEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onHover, "f"));
3053
+ container.removeEventListener("mousedown", __classPrivateFieldGet$3(this, _BoardWatcher_onPointStart, "f"));
3054
+ container.removeEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onPointMove, "f"));
3055
+ container.removeEventListener("mouseup", __classPrivateFieldGet$3(this, _BoardWatcher_onPointEnd, "f"));
3056
+ container.removeEventListener("mouseleave", __classPrivateFieldGet$3(this, _BoardWatcher_onPointLeave, "f"));
3057
+ container.removeEventListener("wheel", __classPrivateFieldGet$3(this, _BoardWatcher_onWheel, "f"));
3058
+ container.removeEventListener("click", __classPrivateFieldGet$3(this, _BoardWatcher_onClick, "f"));
3059
+ container.removeEventListener("contextmenu", __classPrivateFieldGet$3(this, _BoardWatcher_onContextMenu, "f"));
3060
+ }
3061
+ }
3062
+ _BoardWatcher_opts = /* @__PURE__ */ new WeakMap(), _BoardWatcher_store = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onWheel = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onContextMenu = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onClick = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onPointLeave = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onPointEnd = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onPointMove = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onPointStart = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onHover = /* @__PURE__ */ new WeakMap(), _BoardWatcher_instances = /* @__PURE__ */ new WeakSet(), _BoardWatcher_init = function _BoardWatcher_init2() {
3063
+ const container = window;
3064
+ container.addEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onHover, "f"));
3065
+ container.addEventListener("mousedown", __classPrivateFieldGet$3(this, _BoardWatcher_onPointStart, "f"));
3066
+ container.addEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onPointMove, "f"));
3067
+ container.addEventListener("mouseup", __classPrivateFieldGet$3(this, _BoardWatcher_onPointEnd, "f"));
3068
+ container.addEventListener("mouseleave", __classPrivateFieldGet$3(this, _BoardWatcher_onPointLeave, "f"));
3069
+ container.addEventListener("wheel", __classPrivateFieldGet$3(this, _BoardWatcher_onWheel, "f"), { passive: false });
3070
+ container.addEventListener("click", __classPrivateFieldGet$3(this, _BoardWatcher_onClick, "f"));
3071
+ container.addEventListener("contextmenu", __classPrivateFieldGet$3(this, _BoardWatcher_onContextMenu, "f"));
3072
+ }, _BoardWatcher_isInTarget = function _BoardWatcher_isInTarget2(e) {
3073
+ return e.target === __classPrivateFieldGet$3(this, _BoardWatcher_opts, "f").boardContent.boardContext.canvas;
3074
+ }, _BoardWatcher_getPoint = function _BoardWatcher_getPoint2(e) {
3075
+ const boardCanvas = __classPrivateFieldGet$3(this, _BoardWatcher_opts, "f").boardContent.boardContext.canvas;
3076
+ const rect = boardCanvas.getBoundingClientRect();
3077
+ const p = {
3078
+ x: e.clientX - rect.left,
3079
+ y: e.clientY - rect.top,
3080
+ t: Date.now()
3081
+ };
3082
+ return p;
3083
+ }, _BoardWatcher_isVaildPoint = function _BoardWatcher_isVaildPoint2(p) {
3084
+ const viewSize = __classPrivateFieldGet$3(this, _BoardWatcher_opts, "f").sharer.getActiveViewSizeInfo();
3085
+ const { width, height } = viewSize;
3086
+ if (isBoardAvailableNum(p.x) && isBoardAvailableNum(p.y) && p.x <= width && p.y <= height) {
3087
+ return true;
2713
3088
  }
2714
- }
3089
+ return false;
3090
+ };
3091
+ var __classPrivateFieldSet$2 = function(receiver, state, value, kind, f) {
3092
+ if (kind === "m")
3093
+ throw new TypeError("Private method is not writable");
3094
+ if (kind === "a" && !f)
3095
+ throw new TypeError("Private accessor was defined without a setter");
3096
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3097
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
3098
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3099
+ };
3100
+ var __classPrivateFieldGet$2 = function(receiver, state, kind, f) {
3101
+ if (kind === "a" && !f)
3102
+ throw new TypeError("Private accessor was defined without a getter");
3103
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3104
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
3105
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3106
+ };
3107
+ var _Sharer_activeStore, _Sharer_sharedStore;
2715
3108
  const defaultActiveStorage = {
2716
3109
  width: 0,
2717
3110
  height: 0,
@@ -2727,139 +3120,113 @@ var __privateMethod = (obj, member, method) => {
2727
3120
  };
2728
3121
  class Sharer {
2729
3122
  constructor() {
3123
+ _Sharer_activeStore.set(this, void 0);
3124
+ _Sharer_sharedStore.set(this, void 0);
2730
3125
  const activeStore = new Store({
2731
3126
  defaultStorage: defaultActiveStorage
2732
3127
  });
2733
3128
  const sharedStore = new Store({
2734
3129
  defaultStorage: {}
2735
3130
  });
2736
- this._activeStore = activeStore;
2737
- this._sharedStore = sharedStore;
3131
+ __classPrivateFieldSet$2(this, _Sharer_activeStore, activeStore, "f");
3132
+ __classPrivateFieldSet$2(this, _Sharer_sharedStore, sharedStore, "f");
2738
3133
  }
2739
3134
  getActiveStorage(key2) {
2740
- return this._activeStore.get(key2);
3135
+ return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get(key2);
2741
3136
  }
2742
3137
  setActiveStorage(key2, storage) {
2743
- return this._activeStore.set(key2, storage);
3138
+ return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set(key2, storage);
2744
3139
  }
2745
3140
  getActiveStoreSnapshot() {
2746
- return this._activeStore.getSnapshot();
3141
+ return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").getSnapshot();
2747
3142
  }
2748
3143
  getSharedStorage(key2) {
2749
- return this._sharedStore.get(key2);
3144
+ return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").get(key2);
2750
3145
  }
2751
3146
  setSharedStorage(key2, storage) {
2752
- return this._sharedStore.set(key2, storage);
3147
+ return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").set(key2, storage);
2753
3148
  }
2754
3149
  getSharedStoreSnapshot() {
2755
- return this._sharedStore.getSnapshot();
3150
+ return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").getSnapshot();
2756
3151
  }
2757
3152
  getActiveViewScaleInfo() {
2758
3153
  const viewScaleInfo = {
2759
- scale: this._activeStore.get("scale"),
2760
- offsetTop: this._activeStore.get("offsetTop"),
2761
- offsetBottom: this._activeStore.get("offsetBottom"),
2762
- offsetLeft: this._activeStore.get("offsetLeft"),
2763
- offsetRight: this._activeStore.get("offsetRight")
3154
+ scale: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("scale"),
3155
+ offsetTop: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetTop"),
3156
+ offsetBottom: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetBottom"),
3157
+ offsetLeft: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetLeft"),
3158
+ offsetRight: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetRight")
2764
3159
  };
2765
3160
  return viewScaleInfo;
2766
3161
  }
2767
3162
  setActiveViewScaleInfo(viewScaleInfo) {
2768
3163
  const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight } = viewScaleInfo;
2769
- this._activeStore.set("scale", scale);
2770
- this._activeStore.set("offsetTop", offsetTop);
2771
- this._activeStore.set("offsetBottom", offsetBottom);
2772
- this._activeStore.set("offsetLeft", offsetLeft);
2773
- this._activeStore.set("offsetRight", offsetRight);
3164
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("scale", scale);
3165
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetTop", offsetTop);
3166
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetBottom", offsetBottom);
3167
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetLeft", offsetLeft);
3168
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetRight", offsetRight);
2774
3169
  }
2775
3170
  setActiveViewSizeInfo(size) {
2776
- this._activeStore.set("width", size.width);
2777
- this._activeStore.set("height", size.height);
2778
- this._activeStore.set("devicePixelRatio", size.devicePixelRatio);
2779
- this._activeStore.set("contextWidth", size.contextWidth);
2780
- this._activeStore.set("contextHeight", size.contextHeight);
3171
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("width", size.width);
3172
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("height", size.height);
3173
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("devicePixelRatio", size.devicePixelRatio);
3174
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("contextWidth", size.contextWidth);
3175
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("contextHeight", size.contextHeight);
2781
3176
  }
2782
3177
  getActiveViewSizeInfo() {
2783
3178
  const sizeInfo = {
2784
- width: this._activeStore.get("width"),
2785
- height: this._activeStore.get("height"),
2786
- devicePixelRatio: this._activeStore.get("devicePixelRatio"),
2787
- contextWidth: this._activeStore.get("contextWidth"),
2788
- contextHeight: this._activeStore.get("contextHeight")
3179
+ width: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("width"),
3180
+ height: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("height"),
3181
+ devicePixelRatio: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("devicePixelRatio"),
3182
+ contextWidth: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("contextWidth"),
3183
+ contextHeight: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("contextHeight")
2789
3184
  };
2790
3185
  return sizeInfo;
2791
3186
  }
2792
3187
  }
3188
+ _Sharer_activeStore = /* @__PURE__ */ new WeakMap(), _Sharer_sharedStore = /* @__PURE__ */ new WeakMap();
3189
+ var __classPrivateFieldSet$1 = function(receiver, state, value, kind, f) {
3190
+ if (kind === "m")
3191
+ throw new TypeError("Private method is not writable");
3192
+ if (kind === "a" && !f)
3193
+ throw new TypeError("Private accessor was defined without a setter");
3194
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3195
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
3196
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3197
+ };
3198
+ var __classPrivateFieldGet$1 = function(receiver, state, kind, f) {
3199
+ if (kind === "a" && !f)
3200
+ throw new TypeError("Private accessor was defined without a getter");
3201
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3202
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
3203
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3204
+ };
3205
+ var _Viewer_instances, _Viewer_opts, _Viewer_drawFrameSnapshotQueue, _Viewer_drawFrameStatus, _Viewer_init, _Viewer_drawAnimationFrame;
2793
3206
  const { requestAnimationFrame } = window;
2794
3207
  class Viewer extends EventEmitter {
2795
3208
  constructor(opts) {
2796
3209
  super();
2797
- this._drawFrameSnapshotQueue = [];
2798
- this._drawFrameStatus = "FREE";
2799
- this._opts = opts;
2800
- this._init();
2801
- }
2802
- _init() {
2803
- const { renderer } = this._opts;
2804
- renderer.on("load", () => {
2805
- this.drawFrame();
2806
- });
2807
- }
2808
- _drawAnimationFrame() {
2809
- if (this._drawFrameStatus === "DRAWING" || this._drawFrameSnapshotQueue.length === 0) {
2810
- return;
2811
- } else {
2812
- this._drawFrameStatus = "DRAWING";
2813
- }
2814
- const snapshot = this._drawFrameSnapshotQueue.shift();
2815
- const { renderer, viewContent, beforeDrawFrame, afterDrawFrame } = this._opts;
2816
- if (snapshot) {
2817
- const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = snapshot.activeStore;
2818
- if (snapshot === null || snapshot === void 0 ? void 0 : snapshot.activeStore.data) {
2819
- renderer.drawData(snapshot.activeStore.data, {
2820
- viewScaleInfo: {
2821
- scale,
2822
- offsetTop,
2823
- offsetBottom,
2824
- offsetLeft,
2825
- offsetRight
2826
- },
2827
- viewSizeInfo: {
2828
- width,
2829
- height,
2830
- contextHeight,
2831
- contextWidth,
2832
- devicePixelRatio
2833
- }
2834
- });
2835
- }
2836
- beforeDrawFrame({ snapshot });
2837
- viewContent.drawView();
2838
- afterDrawFrame({ snapshot });
2839
- }
2840
- if (this._drawFrameSnapshotQueue.length === 0) {
2841
- this._drawFrameStatus = "COMPLETE";
2842
- return;
2843
- }
2844
- if (this._drawFrameStatus = "DRAWING") {
2845
- requestAnimationFrame(() => {
2846
- this._drawAnimationFrame();
2847
- });
2848
- }
3210
+ _Viewer_instances.add(this);
3211
+ _Viewer_opts.set(this, void 0);
3212
+ _Viewer_drawFrameSnapshotQueue.set(this, []);
3213
+ _Viewer_drawFrameStatus.set(this, "FREE");
3214
+ __classPrivateFieldSet$1(this, _Viewer_opts, opts, "f");
3215
+ __classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_init).call(this);
2849
3216
  }
2850
3217
  drawFrame() {
2851
- const { sharer } = this._opts;
3218
+ const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
2852
3219
  const activeStore = sharer.getActiveStoreSnapshot();
2853
3220
  const sharedStore = sharer.getSharedStoreSnapshot();
2854
- this._drawFrameSnapshotQueue.push({
3221
+ __classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").push({
2855
3222
  activeStore,
2856
3223
  sharedStore
2857
3224
  });
2858
- this._drawAnimationFrame();
3225
+ __classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_drawAnimationFrame).call(this);
2859
3226
  }
2860
3227
  scale(opts) {
2861
3228
  const { scale, point } = opts;
2862
- const { sharer } = this._opts;
3229
+ const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
2863
3230
  const { moveX, moveY } = viewScale({
2864
3231
  scale,
2865
3232
  point,
@@ -2870,7 +3237,7 @@ var __privateMethod = (obj, member, method) => {
2870
3237
  return { moveX, moveY };
2871
3238
  }
2872
3239
  scroll(opts) {
2873
- const { sharer } = this._opts;
3240
+ const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
2874
3241
  const prevViewScaleInfo = sharer.getActiveViewScaleInfo();
2875
3242
  const { moveX, moveY } = opts;
2876
3243
  const viewSizeInfo = sharer.getActiveViewSizeInfo();
@@ -2884,7 +3251,7 @@ var __privateMethod = (obj, member, method) => {
2884
3251
  return viewScaleInfo;
2885
3252
  }
2886
3253
  updateViewScaleInfo(opts) {
2887
- const { sharer } = this._opts;
3254
+ const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
2888
3255
  const viewScaleInfo = calcViewScaleInfo(opts, {
2889
3256
  viewSizeInfo: sharer.getActiveViewSizeInfo()
2890
3257
  });
@@ -2892,11 +3259,11 @@ var __privateMethod = (obj, member, method) => {
2892
3259
  return viewScaleInfo;
2893
3260
  }
2894
3261
  resize(viewSize = {}) {
2895
- const { sharer } = this._opts;
3262
+ const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
2896
3263
  const originViewSize = sharer.getActiveViewSizeInfo();
2897
3264
  const newViewSize = Object.assign(Object.assign({}, originViewSize), viewSize);
2898
3265
  const { width, height, devicePixelRatio } = newViewSize;
2899
- const { underContext, boardContext, helperContext, viewContext } = this._opts.viewContent;
3266
+ const { underContext, boardContext, helperContext, viewContext } = __classPrivateFieldGet$1(this, _Viewer_opts, "f").boardContent;
2900
3267
  boardContext.canvas.width = width * devicePixelRatio;
2901
3268
  boardContext.canvas.height = height * devicePixelRatio;
2902
3269
  boardContext.canvas.style.width = `${width}px`;
@@ -2911,283 +3278,383 @@ var __privateMethod = (obj, member, method) => {
2911
3278
  return newViewSize;
2912
3279
  }
2913
3280
  }
2914
- const throttleTime = 10;
2915
- const LOCK_MODES = ["RULER"];
2916
- class Board {
2917
- constructor(opts) {
2918
- this._middlewares = [];
2919
- this._middlewareObjs = [];
2920
- this._activeMiddlewareObjs = [];
2921
- this._eventHub = new EventEmitter();
2922
- this._activeMode = "SELECT";
2923
- const { viewContent } = opts;
2924
- const sharer = new Sharer();
2925
- const calculator = new Calculator({ viewContent });
2926
- const watcher = new BoardWatcher({
2927
- viewContent,
2928
- sharer
2929
- });
2930
- const renderer = new Renderer({
2931
- viewContent,
2932
- sharer,
2933
- calculator
2934
- });
2935
- this._opts = opts;
2936
- this._sharer = sharer;
2937
- this._watcher = watcher;
2938
- this._calculator = calculator;
2939
- this._viewer = new Viewer({
2940
- viewContent: opts.viewContent,
2941
- sharer,
2942
- renderer,
2943
- calculator,
2944
- beforeDrawFrame: (e) => {
2945
- this._handleBeforeDrawFrame(e);
2946
- },
2947
- afterDrawFrame: (e) => {
2948
- this._handleAfterDrawFrame(e);
2949
- }
2950
- });
2951
- this._init();
2952
- this._resetActiveMiddlewareObjs();
2953
- }
2954
- _init() {
2955
- this._watcher.on("pointStart", this._handlePointStart.bind(this));
2956
- this._watcher.on("pointEnd", this._handlePointEnd.bind(this));
2957
- this._watcher.on("pointMove", throttle((e) => {
2958
- this._handlePointMove(e);
2959
- }, throttleTime));
2960
- this._watcher.on("hover", throttle((e) => {
2961
- this._handleHover(e);
2962
- }, throttleTime));
2963
- this._watcher.on("wheel", throttle((e) => {
2964
- this._handleWheel(e);
2965
- }, throttleTime));
2966
- this._watcher.on("wheelScale", throttle((e) => {
2967
- this._handleWheelScale(e);
2968
- }, throttleTime));
2969
- this._watcher.on("scrollX", this._handleScrollX.bind(this));
2970
- this._watcher.on("scrollY", this._handleScrollY.bind(this));
2971
- this._watcher.on("resize", this._handleResize.bind(this));
2972
- this._watcher.on("doubleClick", this._handleDoubleClick.bind(this));
2973
- }
2974
- _handlePointStart(e) {
2975
- var _a;
2976
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
2977
- const obj = this._activeMiddlewareObjs[i];
2978
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointStart) === null || _a === void 0 ? void 0 : _a.call(obj, e);
2979
- if (result === false) {
2980
- return;
2981
- }
2982
- }
2983
- }
2984
- _handlePointEnd(e) {
2985
- var _a;
2986
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
2987
- const obj = this._activeMiddlewareObjs[i];
2988
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointEnd) === null || _a === void 0 ? void 0 : _a.call(obj, e);
2989
- if (result === false) {
2990
- return;
2991
- }
2992
- }
2993
- }
2994
- _handlePointMove(e) {
2995
- var _a;
2996
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
2997
- const obj = this._activeMiddlewareObjs[i];
2998
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointMove) === null || _a === void 0 ? void 0 : _a.call(obj, e);
2999
- if (result === false) {
3000
- return;
3001
- }
3002
- }
3003
- }
3004
- _handleHover(e) {
3005
- var _a;
3006
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
3007
- const obj = this._activeMiddlewareObjs[i];
3008
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.hover) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3009
- if (result === false) {
3010
- return;
3011
- }
3012
- }
3013
- }
3014
- _handleDoubleClick(e) {
3015
- var _a;
3016
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
3017
- const obj = this._activeMiddlewareObjs[i];
3018
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.doubleClick) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3019
- if (result === false) {
3020
- return;
3021
- }
3022
- }
3023
- }
3024
- _handleWheel(e) {
3025
- var _a;
3026
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
3027
- const obj = this._activeMiddlewareObjs[i];
3028
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheel) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3029
- if (result === false) {
3030
- return;
3031
- }
3032
- }
3033
- }
3034
- _handleWheelScale(e) {
3035
- var _a;
3036
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
3037
- const obj = this._activeMiddlewareObjs[i];
3038
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheelScale) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3039
- if (result === false) {
3040
- return;
3041
- }
3042
- }
3043
- }
3044
- _handleScrollX(e) {
3045
- var _a;
3046
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
3047
- const obj = this._activeMiddlewareObjs[i];
3048
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.scrollX) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3049
- if (result === false) {
3050
- return;
3051
- }
3052
- }
3053
- }
3054
- _handleScrollY(e) {
3055
- var _a;
3056
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
3057
- const obj = this._activeMiddlewareObjs[i];
3058
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.scrollY) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3059
- if (result === false) {
3060
- return;
3061
- }
3062
- }
3063
- }
3064
- _handleResize(e) {
3065
- var _a;
3066
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
3067
- const obj = this._activeMiddlewareObjs[i];
3068
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.resize) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3069
- if (result === false) {
3070
- return;
3071
- }
3072
- }
3281
+ _Viewer_opts = /* @__PURE__ */ new WeakMap(), _Viewer_drawFrameSnapshotQueue = /* @__PURE__ */ new WeakMap(), _Viewer_drawFrameStatus = /* @__PURE__ */ new WeakMap(), _Viewer_instances = /* @__PURE__ */ new WeakSet(), _Viewer_init = function _Viewer_init2() {
3282
+ const { renderer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
3283
+ renderer.on("load", () => {
3284
+ this.drawFrame();
3285
+ });
3286
+ }, _Viewer_drawAnimationFrame = function _Viewer_drawAnimationFrame2() {
3287
+ if (__classPrivateFieldGet$1(this, _Viewer_drawFrameStatus, "f") === "DRAWING" || __classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").length === 0) {
3288
+ return;
3289
+ } else {
3290
+ __classPrivateFieldSet$1(this, _Viewer_drawFrameStatus, "DRAWING", "f");
3073
3291
  }
3074
- _handleClear(e) {
3075
- var _a;
3076
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
3077
- const obj = this._activeMiddlewareObjs[i];
3078
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.clear) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3079
- if (result === false) {
3080
- return;
3081
- }
3292
+ const snapshot = __classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").shift();
3293
+ const { renderer, boardContent, beforeDrawFrame, afterDrawFrame } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
3294
+ if (snapshot) {
3295
+ const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = snapshot.activeStore;
3296
+ const viewScaleInfo = {
3297
+ scale,
3298
+ offsetTop,
3299
+ offsetBottom,
3300
+ offsetLeft,
3301
+ offsetRight
3302
+ };
3303
+ const viewSizeInfo = {
3304
+ width,
3305
+ height,
3306
+ contextHeight,
3307
+ contextWidth,
3308
+ devicePixelRatio
3309
+ };
3310
+ if (snapshot === null || snapshot === void 0 ? void 0 : snapshot.activeStore.data) {
3311
+ renderer.drawData(snapshot.activeStore.data, {
3312
+ viewScaleInfo,
3313
+ viewSizeInfo
3314
+ });
3082
3315
  }
3316
+ beforeDrawFrame({ snapshot });
3317
+ boardContent.drawView();
3318
+ afterDrawFrame({ snapshot });
3083
3319
  }
3084
- _handleBeforeDrawFrame(e) {
3085
- var _a;
3086
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
3087
- const obj = this._activeMiddlewareObjs[i];
3088
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.beforeDrawFrame) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3089
- if (result === false) {
3090
- return;
3091
- }
3092
- }
3320
+ if (__classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").length === 0) {
3321
+ __classPrivateFieldSet$1(this, _Viewer_drawFrameStatus, "COMPLETE", "f");
3322
+ return;
3093
3323
  }
3094
- _handleAfterDrawFrame(e) {
3095
- var _a;
3096
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
3097
- const obj = this._activeMiddlewareObjs[i];
3098
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.afterDrawFrame) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3099
- if (result === false) {
3100
- return;
3101
- }
3102
- }
3324
+ if (__classPrivateFieldSet$1(this, _Viewer_drawFrameStatus, "DRAWING", "f")) {
3325
+ requestAnimationFrame(() => {
3326
+ __classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_drawAnimationFrame2).call(this);
3327
+ });
3103
3328
  }
3104
- _resetActiveMiddlewareObjs() {
3105
- const { _activeMode: activeMode } = this;
3106
- const modes = [...LOCK_MODES, activeMode];
3107
- const activeMiddlewareObjs = [];
3108
- this._middlewareObjs.forEach((m) => {
3109
- if (m.isDefault === true) {
3110
- activeMiddlewareObjs.push(m);
3111
- } else if (modes.includes(m.mode)) {
3112
- activeMiddlewareObjs.push(m);
3113
- }
3329
+ };
3330
+ var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
3331
+ if (kind === "m")
3332
+ throw new TypeError("Private method is not writable");
3333
+ if (kind === "a" && !f)
3334
+ throw new TypeError("Private accessor was defined without a setter");
3335
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3336
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
3337
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3338
+ };
3339
+ var __classPrivateFieldGet = function(receiver, state, kind, f) {
3340
+ if (kind === "a" && !f)
3341
+ throw new TypeError("Private accessor was defined without a getter");
3342
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3343
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
3344
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3345
+ };
3346
+ var _Board_instances, _Board_opts, _Board_middlewareMap, _Board_middlewares, _Board_activeMiddlewareObjs, _Board_watcher, _Board_renderer, _Board_sharer, _Board_viewer, _Board_calculator, _Board_eventHub, _Board_init, _Board_handlePointStart, _Board_handlePointEnd, _Board_handlePointMove, _Board_handleHover, _Board_handleDoubleClick, _Board_handleWheel, _Board_handleWheelScale, _Board_handleScrollX, _Board_handleScrollY, _Board_handleResize, _Board_handleClear, _Board_handleBeforeDrawFrame, _Board_handleAfterDrawFrame, _Board_resetActiveMiddlewareObjs;
3347
+ const throttleTime = 10;
3348
+ class Board {
3349
+ constructor(opts) {
3350
+ _Board_instances.add(this);
3351
+ _Board_opts.set(this, void 0);
3352
+ _Board_middlewareMap.set(this, /* @__PURE__ */ new WeakMap());
3353
+ _Board_middlewares.set(this, []);
3354
+ _Board_activeMiddlewareObjs.set(this, []);
3355
+ _Board_watcher.set(this, void 0);
3356
+ _Board_renderer.set(this, void 0);
3357
+ _Board_sharer.set(this, void 0);
3358
+ _Board_viewer.set(this, void 0);
3359
+ _Board_calculator.set(this, void 0);
3360
+ _Board_eventHub.set(this, new EventEmitter());
3361
+ const { boardContent } = opts;
3362
+ const sharer = new Sharer();
3363
+ const calculator = new Calculator({ viewContext: boardContent.viewContext });
3364
+ const watcher = new BoardWatcher({
3365
+ boardContent,
3366
+ sharer
3367
+ });
3368
+ const renderer = new Renderer({
3369
+ viewContext: boardContent.viewContext,
3370
+ sharer,
3371
+ calculator
3114
3372
  });
3115
- this._activeMiddlewareObjs = activeMiddlewareObjs;
3373
+ __classPrivateFieldSet(this, _Board_opts, opts, "f");
3374
+ __classPrivateFieldSet(this, _Board_sharer, sharer, "f");
3375
+ __classPrivateFieldSet(this, _Board_watcher, watcher, "f");
3376
+ __classPrivateFieldSet(this, _Board_renderer, renderer, "f");
3377
+ __classPrivateFieldSet(this, _Board_calculator, calculator, "f");
3378
+ __classPrivateFieldSet(this, _Board_viewer, new Viewer({
3379
+ boardContent: opts.boardContent,
3380
+ sharer,
3381
+ renderer,
3382
+ calculator: __classPrivateFieldGet(this, _Board_calculator, "f"),
3383
+ beforeDrawFrame: (e) => {
3384
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleBeforeDrawFrame).call(this, e);
3385
+ },
3386
+ afterDrawFrame: (e) => {
3387
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleAfterDrawFrame).call(this, e);
3388
+ }
3389
+ }), "f");
3390
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_init).call(this);
3391
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_resetActiveMiddlewareObjs).call(this);
3392
+ }
3393
+ destroy() {
3394
+ __classPrivateFieldGet(this, _Board_watcher, "f").destroy();
3395
+ __classPrivateFieldGet(this, _Board_renderer, "f").destroy();
3396
+ __classPrivateFieldGet(this, _Board_calculator, "f").destroy();
3397
+ __classPrivateFieldGet(this, _Board_eventHub, "f").destroy();
3116
3398
  }
3117
3399
  getSharer() {
3118
- return this._sharer;
3400
+ return __classPrivateFieldGet(this, _Board_sharer, "f");
3119
3401
  }
3120
3402
  getViewer() {
3121
- return this._viewer;
3403
+ return __classPrivateFieldGet(this, _Board_viewer, "f");
3404
+ }
3405
+ getRenderer() {
3406
+ return __classPrivateFieldGet(this, _Board_renderer, "f");
3122
3407
  }
3123
3408
  setData(data) {
3124
- const sharer = this._sharer;
3125
- this._sharer.setActiveStorage("data", data);
3409
+ const sharer = __classPrivateFieldGet(this, _Board_sharer, "f");
3410
+ __classPrivateFieldGet(this, _Board_sharer, "f").setActiveStorage("data", data);
3126
3411
  const viewSizeInfo = sharer.getActiveViewSizeInfo();
3127
3412
  const newViewContextSize = calcElementsContextSize(data.elements, {
3128
3413
  viewWidth: viewSizeInfo.width,
3129
3414
  viewHeight: viewSizeInfo.height,
3130
3415
  extend: true
3131
3416
  });
3132
- this._viewer.drawFrame();
3417
+ __classPrivateFieldGet(this, _Board_viewer, "f").drawFrame();
3133
3418
  const newViewSizeInfo = Object.assign(Object.assign({}, viewSizeInfo), newViewContextSize);
3134
- this._sharer.setActiveViewSizeInfo(newViewSizeInfo);
3419
+ __classPrivateFieldGet(this, _Board_sharer, "f").setActiveViewSizeInfo(newViewSizeInfo);
3135
3420
  return { viewSizeInfo: newViewSizeInfo };
3136
3421
  }
3137
3422
  getData() {
3138
- const { data } = this._sharer.getActiveStoreSnapshot();
3423
+ const { data } = __classPrivateFieldGet(this, _Board_sharer, "f").getActiveStoreSnapshot();
3139
3424
  return data;
3140
3425
  }
3141
3426
  use(middleware) {
3142
- const { viewContent, container } = this._opts;
3143
- const { _sharer: sharer, _viewer: viewer, _calculator: calculator, _eventHub: eventHub } = this;
3144
- const obj = middleware({ viewContent, sharer, viewer, calculator, eventHub, container });
3145
- this._middlewares.push(middleware);
3146
- this._activeMiddlewareObjs.push(obj);
3427
+ var _a, _b, _c;
3428
+ if (__classPrivateFieldGet(this, _Board_middlewareMap, "f").has(middleware)) {
3429
+ const item = __classPrivateFieldGet(this, _Board_middlewareMap, "f").get(middleware);
3430
+ if (item) {
3431
+ (_b = (_a = item.middlewareObject).use) === null || _b === void 0 ? void 0 : _b.call(_a);
3432
+ item.status = "enable";
3433
+ __classPrivateFieldGet(this, _Board_middlewareMap, "f").set(middleware, item);
3434
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_resetActiveMiddlewareObjs).call(this);
3435
+ return;
3436
+ }
3437
+ }
3438
+ const { boardContent, container } = __classPrivateFieldGet(this, _Board_opts, "f");
3439
+ const sharer = __classPrivateFieldGet(this, _Board_sharer, "f");
3440
+ const viewer = __classPrivateFieldGet(this, _Board_viewer, "f");
3441
+ const calculator = __classPrivateFieldGet(this, _Board_calculator, "f");
3442
+ const eventHub = __classPrivateFieldGet(this, _Board_eventHub, "f");
3443
+ const obj = middleware({ boardContent, sharer, viewer, calculator, eventHub, container });
3444
+ (_c = obj.use) === null || _c === void 0 ? void 0 : _c.call(obj);
3445
+ __classPrivateFieldGet(this, _Board_middlewares, "f").push(middleware);
3446
+ __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").push(obj);
3447
+ __classPrivateFieldGet(this, _Board_middlewareMap, "f").set(middleware, {
3448
+ status: "enable",
3449
+ middlewareObject: obj
3450
+ });
3451
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_resetActiveMiddlewareObjs).call(this);
3452
+ }
3453
+ disuse(middleware) {
3454
+ var _a, _b;
3455
+ const item = __classPrivateFieldGet(this, _Board_middlewareMap, "f").get(middleware);
3456
+ if (item) {
3457
+ (_b = (_a = item.middlewareObject).disuse) === null || _b === void 0 ? void 0 : _b.call(_a);
3458
+ item.status = "disable";
3459
+ __classPrivateFieldGet(this, _Board_middlewareMap, "f").set(middleware, item);
3460
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_resetActiveMiddlewareObjs).call(this);
3461
+ }
3147
3462
  }
3148
3463
  scale(opts) {
3149
- const { _viewer: viewer } = this;
3464
+ const viewer = __classPrivateFieldGet(this, _Board_viewer, "f");
3150
3465
  const { moveX, moveY } = viewer.scale(opts);
3151
3466
  viewer.scroll({ moveX, moveY });
3152
3467
  }
3153
3468
  scroll(opts) {
3154
- return this._viewer.scroll(opts);
3469
+ return __classPrivateFieldGet(this, _Board_viewer, "f").scroll(opts);
3155
3470
  }
3156
3471
  updateViewScaleInfo(opts) {
3157
- return this._viewer.updateViewScaleInfo(opts);
3472
+ return __classPrivateFieldGet(this, _Board_viewer, "f").updateViewScaleInfo(opts);
3158
3473
  }
3159
3474
  resize(newViewSize) {
3160
- const viewSize = this._viewer.resize(newViewSize);
3475
+ const viewSize = __classPrivateFieldGet(this, _Board_viewer, "f").resize(newViewSize);
3161
3476
  const { width, height, devicePixelRatio } = newViewSize;
3162
- const { viewContent } = this._opts;
3163
- viewContent.viewContext.$resize({ width, height, devicePixelRatio });
3164
- viewContent.helperContext.$resize({ width, height, devicePixelRatio });
3165
- viewContent.boardContext.$resize({ width, height, devicePixelRatio });
3166
- this._viewer.drawFrame();
3167
- this._watcher.trigger("resize", viewSize);
3168
- this._sharer.setActiveViewSizeInfo(newViewSize);
3477
+ const { boardContent } = __classPrivateFieldGet(this, _Board_opts, "f");
3478
+ boardContent.viewContext.$resize({ width, height, devicePixelRatio });
3479
+ boardContent.helperContext.$resize({ width, height, devicePixelRatio });
3480
+ boardContent.boardContext.$resize({ width, height, devicePixelRatio });
3481
+ boardContent.underContext.$resize({ width, height, devicePixelRatio });
3482
+ __classPrivateFieldGet(this, _Board_viewer, "f").drawFrame();
3483
+ __classPrivateFieldGet(this, _Board_watcher, "f").trigger("resize", viewSize);
3484
+ __classPrivateFieldGet(this, _Board_sharer, "f").setActiveViewSizeInfo(newViewSize);
3169
3485
  }
3170
3486
  clear() {
3171
- const { viewContent } = this._opts;
3172
- const { underContext, helperContext, viewContext, boardContext } = viewContent;
3487
+ const { boardContent } = __classPrivateFieldGet(this, _Board_opts, "f");
3488
+ const { underContext, helperContext, viewContext, boardContext } = boardContent;
3173
3489
  underContext.clearRect(0, 0, underContext.canvas.width, underContext.canvas.height);
3174
3490
  helperContext.clearRect(0, 0, helperContext.canvas.width, helperContext.canvas.height);
3175
3491
  viewContext.clearRect(0, 0, viewContext.canvas.width, viewContext.canvas.height);
3176
3492
  boardContext.clearRect(0, 0, boardContext.canvas.width, boardContext.canvas.height);
3177
- this._handleClear();
3493
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleClear).call(this);
3178
3494
  }
3179
3495
  getEventHub() {
3180
- return this._eventHub;
3496
+ return __classPrivateFieldGet(this, _Board_eventHub, "f");
3497
+ }
3498
+ }
3499
+ _Board_opts = /* @__PURE__ */ new WeakMap(), _Board_middlewareMap = /* @__PURE__ */ new WeakMap(), _Board_middlewares = /* @__PURE__ */ new WeakMap(), _Board_activeMiddlewareObjs = /* @__PURE__ */ new WeakMap(), _Board_watcher = /* @__PURE__ */ new WeakMap(), _Board_renderer = /* @__PURE__ */ new WeakMap(), _Board_sharer = /* @__PURE__ */ new WeakMap(), _Board_viewer = /* @__PURE__ */ new WeakMap(), _Board_calculator = /* @__PURE__ */ new WeakMap(), _Board_eventHub = /* @__PURE__ */ new WeakMap(), _Board_instances = /* @__PURE__ */ new WeakSet(), _Board_init = function _Board_init2() {
3500
+ __classPrivateFieldGet(this, _Board_watcher, "f").on("pointStart", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointStart).bind(this));
3501
+ __classPrivateFieldGet(this, _Board_watcher, "f").on("pointEnd", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointEnd).bind(this));
3502
+ __classPrivateFieldGet(this, _Board_watcher, "f").on("pointMove", throttle((e) => {
3503
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointMove).call(this, e);
3504
+ }, throttleTime));
3505
+ __classPrivateFieldGet(this, _Board_watcher, "f").on("hover", throttle((e) => {
3506
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleHover).call(this, e);
3507
+ }, throttleTime));
3508
+ __classPrivateFieldGet(this, _Board_watcher, "f").on("wheel", throttle((e) => {
3509
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleWheel).call(this, e);
3510
+ }, throttleTime));
3511
+ __classPrivateFieldGet(this, _Board_watcher, "f").on("wheelScale", throttle((e) => {
3512
+ __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleWheelScale).call(this, e);
3513
+ }, throttleTime));
3514
+ __classPrivateFieldGet(this, _Board_watcher, "f").on("scrollX", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleScrollX).bind(this));
3515
+ __classPrivateFieldGet(this, _Board_watcher, "f").on("scrollY", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleScrollY).bind(this));
3516
+ __classPrivateFieldGet(this, _Board_watcher, "f").on("resize", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleResize).bind(this));
3517
+ __classPrivateFieldGet(this, _Board_watcher, "f").on("doubleClick", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleDoubleClick).bind(this));
3518
+ }, _Board_handlePointStart = function _Board_handlePointStart2(e) {
3519
+ var _a;
3520
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3521
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3522
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointStart) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3523
+ if (result === false) {
3524
+ return;
3525
+ }
3181
3526
  }
3182
- }
3527
+ }, _Board_handlePointEnd = function _Board_handlePointEnd2(e) {
3528
+ var _a;
3529
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3530
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3531
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointEnd) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3532
+ if (result === false) {
3533
+ return;
3534
+ }
3535
+ }
3536
+ }, _Board_handlePointMove = function _Board_handlePointMove2(e) {
3537
+ var _a;
3538
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3539
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3540
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointMove) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3541
+ if (result === false) {
3542
+ return;
3543
+ }
3544
+ }
3545
+ }, _Board_handleHover = function _Board_handleHover2(e) {
3546
+ var _a;
3547
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3548
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3549
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.hover) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3550
+ if (result === false) {
3551
+ return;
3552
+ }
3553
+ }
3554
+ }, _Board_handleDoubleClick = function _Board_handleDoubleClick2(e) {
3555
+ var _a;
3556
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3557
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3558
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.doubleClick) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3559
+ if (result === false) {
3560
+ return;
3561
+ }
3562
+ }
3563
+ }, _Board_handleWheel = function _Board_handleWheel2(e) {
3564
+ var _a;
3565
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3566
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3567
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheel) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3568
+ if (result === false) {
3569
+ return;
3570
+ }
3571
+ }
3572
+ }, _Board_handleWheelScale = function _Board_handleWheelScale2(e) {
3573
+ var _a;
3574
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3575
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3576
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheelScale) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3577
+ if (result === false) {
3578
+ return;
3579
+ }
3580
+ }
3581
+ }, _Board_handleScrollX = function _Board_handleScrollX2(e) {
3582
+ var _a;
3583
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3584
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3585
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.scrollX) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3586
+ if (result === false) {
3587
+ return;
3588
+ }
3589
+ }
3590
+ }, _Board_handleScrollY = function _Board_handleScrollY2(e) {
3591
+ var _a;
3592
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3593
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3594
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.scrollY) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3595
+ if (result === false) {
3596
+ return;
3597
+ }
3598
+ }
3599
+ }, _Board_handleResize = function _Board_handleResize2(e) {
3600
+ var _a;
3601
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3602
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3603
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.resize) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3604
+ if (result === false) {
3605
+ return;
3606
+ }
3607
+ }
3608
+ }, _Board_handleClear = function _Board_handleClear2(e) {
3609
+ var _a;
3610
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3611
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3612
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.clear) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3613
+ if (result === false) {
3614
+ return;
3615
+ }
3616
+ }
3617
+ }, _Board_handleBeforeDrawFrame = function _Board_handleBeforeDrawFrame2(e) {
3618
+ var _a;
3619
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3620
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3621
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.beforeDrawFrame) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3622
+ if (result === false) {
3623
+ return;
3624
+ }
3625
+ }
3626
+ }, _Board_handleAfterDrawFrame = function _Board_handleAfterDrawFrame2(e) {
3627
+ var _a;
3628
+ for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
3629
+ const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
3630
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.afterDrawFrame) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3631
+ if (result === false) {
3632
+ return;
3633
+ }
3634
+ }
3635
+ }, _Board_resetActiveMiddlewareObjs = function _Board_resetActiveMiddlewareObjs2() {
3636
+ const activeMiddlewareObjs = [];
3637
+ const middlewareMap = __classPrivateFieldGet(this, _Board_middlewareMap, "f");
3638
+ __classPrivateFieldGet(this, _Board_middlewares, "f").forEach((middleware) => {
3639
+ const item = middlewareMap.get(middleware);
3640
+ if ((item === null || item === void 0 ? void 0 : item.status) === "enable" && (item === null || item === void 0 ? void 0 : item.middlewareObject)) {
3641
+ activeMiddlewareObjs.push(item.middlewareObject);
3642
+ }
3643
+ });
3644
+ __classPrivateFieldSet(this, _Board_activeMiddlewareObjs, activeMiddlewareObjs, "f");
3645
+ };
3183
3646
  const CURSOR = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMjMtMDktMTdUMTY6MDc6MjYrMDg6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDIzLTA5LTE3VDE2OjEyOjUwKzA4OjAwIiB4bXA6TWV0YWRhdGFEYXRlPSIyMDIzLTA5LTE3VDE2OjEyOjUwKzA4OjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgcGhvdG9zaG9wOkNvbG9yTW9kZT0iMyIgcGhvdG9zaG9wOklDQ1Byb2ZpbGU9InNSR0IgSUVDNjE5NjYtMi4xIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjliMGM0MzI2LWU4ZTQtNDlkNy04MmUzLTgxODkwYTE2ZmU1YSIgeG1wTU06RG9jdW1lbnRJRD0iYWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOjMzOGFhZDBmLWZkZjMtODE0MS1iMTZmLWNiZWIzNTQyYTJhMCIgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOjUwODAxNzc1LWZlNGEtNDQyMy05NDQ3LThkYWRhNzZhYTllOSI+IDx4bXBNTTpIaXN0b3J5PiA8cmRmOlNlcT4gPHJkZjpsaSBzdEV2dDphY3Rpb249ImNyZWF0ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6NTA4MDE3NzUtZmU0YS00NDIzLTk0NDctOGRhZGE3NmFhOWU5IiBzdEV2dDp3aGVuPSIyMDIzLTA5LTE3VDE2OjA3OjI2KzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6OWIwYzQzMjYtZThlNC00OWQ3LTgyZTMtODE4OTBhMTZmZTVhIiBzdEV2dDp3aGVuPSIyMDIzLTA5LTE3VDE2OjEyOjUwKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7W6XrzAAAGLklEQVRYhb2Xf2iUdRzHX/txtfXLplZ6Wblm6fzRmG6r7Uou1AxKRjQKYUqgaLBACFogppcK1h8aLRkMSYaJIA5hYMomZpskEfPOufCaDpZ6t7rbre263U3vzn3643meu+eu3XNzvz7w4bbdc/e89nl/Pu/v50HUCAQCx1tbW0uAx4CHgSwggxkKERkziUQif2mQ0WjU53a7vwSeBB4BTEDmTICmBBwYGDivVlDjlFAo9KvT6dwIPAHkANkq6MwDXr169bCISENDg9TX14s+BgcHf2hubi5mBmRPCXj06NFPREQ6OjoEkPLycrl06VIMMhKJeFwu1xdMs+wpAYuLi9eIiIyOjkpeXp4AAsj27dvF7/fHQIPB4C9dXV0fME2ypwQEXvX7/bdFRNauXRsDBMRkMsnhw4cTZB8YGGhsamp6hSmW3Qhw1Y0bN86LiNTW1iYAallWViZtbW162ftcLtdO/i/7tAAWtba2ficicvLkyTEBtdy6dasMDg7GQIeHh9s7OzvfBx5nkrIbAS7du3fvxyIiPT09hoBa1tXVJcv+fWNj4zLgUeAhJiC7EeDLwOsiMioisnDhwnFBrlixQi5evKiX/c6tW7c+R5E9lweU3QjwReDV/v7+bhGRqqqqcQFquWnTJvH5fHrZLzocjkoSZU9bTSPA54GV165daxYROXDgwAMBannw4MFk2RsaGhqWME7ZjQDNwIrTp09/JSLS0tIyIUBACgoK5MKFCzHIcDj85+3btz8FZpFGdiPAZ4DCmpqaTSIiPp9vwoBaVlVVidfr1ct+/sqVK+9iILsR4FzgJcASDoeHRUSKioomDQnI/v37E2T3+Xz1hw4dWjSW7EaAeUA+UNbX12cXEdmyZcuUAAJiNpvlzJkzetl73G53rVrN2EmUCjATuA9EgYjL5eoGKCkpGatNHijmz5/Pxo0b2blzJ2azOfZ3k8lUYDabv45Go/Y7d+6sIY0VZQOjGqDT6bxeWlrKqlWrJgRlsVhYv349FRUVWCwWcnJyEt4PBoOuoaEhu9frvdzR0fHTtm3buolvRpLqe3OBp4EllZWV74mIRKNRyc3NTSvf7Nmzpbq6Wk6cOCFut1uSY2RkJOB0Ou3Nzc3Ha2trPwPWAGXAEuBZFFPPAbKMevBhYA6wCKgIBoP9IiKrV682hLPZbP8DEpH7vb29N1paWn602WwHFyxYsAX4EKgE3gIsQBFQgOIeT6j3z0wFqEkc60OPx9Odn58/t6SkhPb29jFLbrVa2bNnDwBer7fv5s2bPQ6Ho7upqcnZ1tbmASJq3gPC6utdYESXYfWeo6mkBaUHRQ/odrv/yM/Pt5SWlqb8kAbncDh+W7lyZYN683u6DOvAwipsOOnniA4wZf9lqhdoVYzY7fbrQMpBsdlsWK1WRkZGAtXV1d8D/wA+wKNLr5o+YEC9ZggIAEHiFbyfDhCUCcoFngIWFxYWrtMaat68eQl9V15eHmu2+vr6OuAd4A2gGFgMLERp/mdQ+noWyuadi9Jr2aQ4k42GBPXDs1Ga97WhoaFbIiIbNmxIANTWq87Ozp9VuApgGfACihPkoRjwI+p3mlSgtA9ZRkYNYwwKJBr2rl27sFqthEKhwZqamqOAX5f/AsPE5btLvM/GJWO6yFb/82eBonPnztWJiJw9e1YAWb58eUzaI0eOfAO8CbwCPIfiZZN+eEoncSaKLPOApbt3794uIuL1ehOktdvtF4C3gRKURXcOSn9lTRRsvIAZKI4+l/gjQFREZMeOHSIiEggE+tetW/cRitkuRhmERxnnxjxZQFDWnzzURwCv1+vUHxHHjh37lri0C1Am9KGpgDMC1G8SQnxxCHs8Hqf2RldX10+bN28+i+JjwyT62KSaP13oAfWTHO7t7f0dIBQK/b1v375GlEnVjPYuyoQaHlNTDahVMALca29vdwBcvnz5+KlTp26OATft1UuODBS7yEOxj0K/329HOSWWopjxlE1tchhtM7FriPfgXSDDbrfXo0gbJr4QzIi0WiRPYBbKZJrUV23b0dYn7XSYcsBkS9EiO/k6lApq1cwiPjzaAM1Y9cYC1G6uAWrPCtrvMwoHqU02Q5caIEzj1KaS+D+vIjxtLug31gAAAABJRU5ErkJggg==";
3184
3647
  const CURSOR_RESIZE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMjMtMDktMTdUMTY6MzE6MjMrMDg6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDIzLTA5LTE3VDE2OjQ0OjIyKzA4OjAwIiB4bXA6TWV0YWRhdGFEYXRlPSIyMDIzLTA5LTE3VDE2OjQ0OjIyKzA4OjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgcGhvdG9zaG9wOkNvbG9yTW9kZT0iMyIgcGhvdG9zaG9wOklDQ1Byb2ZpbGU9InNSR0IgSUVDNjE5NjYtMi4xIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjY0MTBhYjUzLWM0ZjEtNDVhNS04MjhkLTIxOTczOWFjOTk3MSIgeG1wTU06RG9jdW1lbnRJRD0iYWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOjBkMDNmNjM5LTE5MzctY2Y0MC1hMTg0LTIyMjg0NzczNWNmYSIgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOjgyYjQwZGRmLWE0ZGEtNDY3MC1iYzc2LTBhYjY3ZmI5M2I0ZSI+IDx4bXBNTTpIaXN0b3J5PiA8cmRmOlNlcT4gPHJkZjpsaSBzdEV2dDphY3Rpb249ImNyZWF0ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6ODJiNDBkZGYtYTRkYS00NjcwLWJjNzYtMGFiNjdmYjkzYjRlIiBzdEV2dDp3aGVuPSIyMDIzLTA5LTE3VDE2OjMxOjIzKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6NjQxMGFiNTMtYzRmMS00NWE1LTgyOGQtMjE5NzM5YWM5OTcxIiBzdEV2dDp3aGVuPSIyMDIzLTA5LTE3VDE2OjQ0OjIyKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz57vRudAAAEk0lEQVRYhe3ZW0jbVxzA8e8/MX+NYnG9uI4xE3bvoLt0FzradRfGBtsYo32YdAhb6WQyBqV7KOylpYjzZShDGfjmyxgbgjjwyRm16SYMhgiNKDhbL3VtNF4xJOnf3x7+59i/Wf4aTbInf3AwJMdzPjnnf/n9/jFEhGzDMIxMb3uAIsDs6ek5urS05Dtz5syE+uwekAQS6u89YD19gC0NIpJ1c8GZQHlXV9fJRCIxGo/HxxoaGj4CngWOAEGgEihXfT07MeQC3MB1dna+lkgkRkXF6urq3xcuXPgUOAE8DzwGPOiGLARwEy4ej4+JiITD4elr167NiIgsLi7eqq2trQPeBI4Bj7sh8w10xZmmeds0zdn+/v5/RERisdjUuXPnvgLeAl50Q+YTaAA+oKy7u/uE3laNAwSQ4uLiu6FQ6G4G5DG13YeAMjWWkU+gBygJhULHNe769etTTpwDGXUiz58//yXwujp5qoAHgBLAk0+gNxKJHEulUiMKN2ma5gwgPp/vjhOXjlxYWJisq6urBV5RW30IKAW8eQPGYrGjlmXdEBEZHBy8aZrmFCCmac729fVtAHt7e6MO5N2+vr47IiJLS0s3L126dBZ4Sh2LZUBRwVdwYGBgVuwOYh/zsoF0bnPBVzDTMRgOh6dFhROokSIi8/Pz0+pEeaPQx+DGWdzV1XVSX2LcgCIic3NzMzU1NV8D7wIvq9WrLNRZvOk62NHRccqJTAdGo9Hb1dXV3wAfYt9VjgAPFfI66EQWAxU9PT0fuwEvXrzYBJwF3gFeAAJAhfrfrO4k/7lxZxnr2JlJqry8POnWyePx6H4JR0vhktVkHGOXQI20SkpKLLcOhmGsA5YCaZiVLS5XoADi9XpdkznDMERhnE0fCgUHZhvOW+CO4/8A5hR7wFxjD5hr7AFzjZyBlmVlrOYdYaS1HUUuQA/gWV9fd51URDyqn1c1j6MVFGjoidfW1oq2ABrYj0V82OmVzwHNajVdB88C5wOKTdM87NaxsrKyQsFKHC2BnTDo+/TWt8Bd5INeVC44NDT0xXYZdXNz8w/AaeyS8yjwCPdzQu92ht2m/OUjIyOfS1pkAoqItLS0fA+8D7wKPA0cxs6qC1O4T0xMfKYnb21tnXEDNjc3z+nXbW1t3wFvYz9dCAL7KUThHovFPtGTNjU1jQFSX18/lg68cuXKLUAaGxs3vkB7e/u3wHHgCQpUdnpTqdQvesJgMDisUVevXh3Xry9fvnxTv66qqprQ/cfHx/vVNj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==";
3648
+ const CURSOR_DRAG_DEFAULT = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAEvUlEQVRYhc2Y20/cVRDHP8v+uKzAWkpDCtZq8BYhJkq8PBoJxgj7I2m0ryaSyFN9IT74pI8+8WJiggRj/APApFkSTGRJ+qKGUiyxbGPEWsUSuVhYC12Wy8+HmeMeYPe3d3WSye/k/M7le+bMzJkZ+J9ToEJreGVYN+vihcytstjQocUlAw0WCSoIVCv3Ae8CXwIt+u8XHVeOG8qLqgAHqAFCQCNwGugCthBJGd7S/tM6LqTzHI5KuqzgaoAHgEvAtwrkG2AG8FzXvep5nue67lX9N6P/PR1/SefXlBtkFXKNDUA/RyX1D9uUbYzOb9D1ygbSQU7eDMxhSSsSiVz3AxiJRK57nuf19/fPad8coqONFCBJPyUOIKc1OvcbgiY9ICDT8+0DHge2gR0gBeyTtviM5HeKAGlrrfMZVwhdAVaAr4F3KNF4gkA9cBbowOc68+3LwDn1Mhdy4/OcYk54nPr6+m54nofruvPa9SFQ6wfQTweNgTwInAGuQWk6mEUvHwb+Au4Dexx7ffK9+0q+CHWIBIOZ9skHYKWfK9tQ8gZoLDjIyWCg3ORY+2T8aYOyg4EaRIFrkCs4QU1NTSvabC20zyIDzuyfkYzEahHX8jHwE/LwXwHeJ4P7KIVIu5ouxFDC+HgLAy4MfEF2v1UpgOezATSiNVf6EvAWsD01NXVtdnb2bk9Pz81sp/q3KIi8t83Ae4DX0tJy0z7t8PDwD4FAYIX/WILVwKMAzc3Nu/agoaGhzmg0ugcsV0hIvlSNoH8IuIiebHJycrls4sotwaxGYvueAPAjEg3jum79yMjIr5WUjFLOxMpBIopWoBN4GfhOJ+4NDg4ulVt6i4uLm7r+BvAscA4fCXrAAfJQJ5Fg8gPgMuCMjo62d3V1LW1sbKRKlpXSxMTEmjZ/5qQrOwHwUAGmkIjiHhJdfKrM/Pz8Y+3t7RvT09Ob5QAYi8X2tbmke2cEZwAaCdoAt5QvIzEbiUSitbe3tyoej++UCnBhYSGkzdu6d1aQxkgOkfwgieQMCeCu8iwSnpNKpcIdHR3BZDJ5UCy4SCSyvL6+/giiSou67wE+eYmhAKKkIaAJUdynkdflNcQF3dFTpooxjmg0aozDAz4DXkB8bxPy1OYM7QzIOuAU0AY8pQu9CrwJ3AK8UCj0RyHgZmZmli1w3wOvAM/oHo1kiZiygbSDh7PAE8DzQA/wBqKnnuM4a2NjY7dygbtw4cICRy31deBFJA09o7eWsU7kJ1KTLJmyRyOSn5zS70fAkwBtbW2/DwwMHHR3d9d3dnY2rK6u7o2Pj2/GYrH9eDzurK2tndM1vwI+QXT7T2BTD5skQz6SCyAcLRoZkGEFGQbeRqpbubK+BPA5MI14h00L3I6Cy2h4+eQbJsKuRa6iQcGFFfB5oBt4DpFsI+Ky7iDBxW3gBhBH/GtC+R7i1lKk3UxRAG2QpvxWr0AbtB3SA5jkx36djH/dVlDbyibN3M8GDvJPyI2PSulixm/u6kZ1OQCaJ/S+tndJX6tvsFBIxcCUdA3vW5ubxMrObc0hDMhd/Rqp5QQHxeW8dubnHGM7tzVv/IECMlxQ/bpcRfRMqaNRheNcUGG9XFWDACfzWs/6Fl3t/xtO//8gpbCORQAAAABJRU5ErkJggg==`;
3649
+ const CURSOR_DRAG_ACTIVE = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAER0lEQVRYhe2YT2hjRRjAf8lL22xsNsm6EWKrSKvuIkIh+O9QRFxEW18KUsoe7FHoRaWCN1FPetOrIHgVKS0q9P5OxaJbodkalgVrtVZjS7Ntd02z6abPw3yzmaT585q+elj2g2HmvZn35jffN/PNNwP35R6XgM/fuif4n+dO2klQvgsaZRc4NJJvoJbHdhrIAkJAN2ADHwFfAw9J3ZoB/b9I0AA6A0SBc0Aa2EVpSqddeZ+QdmfkO+u0gIPSQQR4HfhRQH4AHMDNZDJXXNd1M5nMFalzdB3wJTAOPAD0yEB9066G6wXepVZTd5MpTdporZ6jVqsatmMJoTR3HvgJQ1u2bS+3ArRte9l1XXdsbGyJo1pdBN6Wf3d3ChlAmSQO9LeC8fquQRpDWaerHWSjSr1iu4BkJyOsF9u2s67rkslkluTVxygltAVsJBZqdCngEj5osIlW+4EYytRNF04jeu3vulCT+7QkLH20dEOhumft97pQI4s3+iiRSPwtxVSbd39J8eEGvzFXc1NAs8KSFAZeBt4AHgNeBFDWObkEAne7HAK2gT2gCFQatdca1GbtBj4E3veFprVYVLXXcg4GqM6588BbAMlkcm1qamqzr6/v6ikBet5RgiizJoDPAXdgYGDZXHkzMzPrrk9CdRWngUeAsxxdCzVwpgZ/BigWiz1mo4mJif7jqMajeJrU5hywgGvAej6fvzA0NLThN1Eul9uT4g5VTbYFNKUIfAbsZ7PZvuHh4Wt+As7Ozu5IcY2j219TQB0NV4A7qODgO4CFhYWLg4ODOb8AHccpG4A68m6pRQ1YAQ6A28A+8BXwBcDq6upTqVTquh+AuVyuW4q/opRRaQdZD1gCbgE3ge+BT4HdfD7/ZDwe/z2bzRY6hRsfH1/e3Nx8FDX/sgbgoZfvg6jo4ixqW7oIPA+8CrwHrAJuJBLJd+JaHMf5k6qmPgGeQe1SCenXk0/U21xcIC8AzwGvAJPAEuAmEon1xcXFba9w8/Pz5oqdB14CnpY+oij35km0qwmjwqAU8ISM9hIwBeQA17KsG9PT07+1gxsZGdmgdqW+BjwLDAAPoo4ALU+W9arVwWoIpXp9kouKZpPAO8AwQCwW+2d0dLQ0OTkZSafT0UKhUJ6bm9t2HKeysrIS3tra0g7+KvABUJC0g5rrJdRcbLpImtleRzYashc1P2OSXwbebDVykX3gW+Ab1AHqhuQ3pe6AJlFMO0CoPROHDcio5I8DL1A9C8dQbmod+APYAK4DvwjQnsDdErgyVTfTEaCG1GFYGHXG7TVSo2OkdvhlAflXoHSuNdfStFqaRhEi2kfdprrj6M5LAt0I8EDaaMdflPal48CB95hMr3Bt8h4jD0kyL5E0pN6dysZzW7N2AqjbmhdIZjJvufTOpE19x3g+9s1XJ/ck5tVbfdhu+rxDfLiSO+lFToCjZwrXyH2/0Lwv95z8B1jAqXmDnj4YAAAAAElFTkSuQmCC`;
3185
3650
  class Cursor {
3186
3651
  constructor(container, opts) {
3187
3652
  this._cursorType = null;
3188
3653
  this._resizeCursorBaseImage = null;
3189
3654
  this._cursorImageMap = {
3190
3655
  auto: CURSOR,
3656
+ "drag-default": CURSOR_DRAG_DEFAULT,
3657
+ "drag-active": CURSOR_DRAG_ACTIVE,
3191
3658
  "rotate-0": CURSOR_RESIZE
3192
3659
  };
3193
3660
  this._container = container;
@@ -3204,6 +3671,10 @@ var __privateMethod = (obj, member, method) => {
3204
3671
  this._resetCursor("auto");
3205
3672
  } else if (typeof e.type === "string" && ((_a = e.type) == null ? void 0 : _a.startsWith("resize-"))) {
3206
3673
  this._setCursorResize(e);
3674
+ } else if (e.type === "drag-default") {
3675
+ this._resetCursor("drag-default");
3676
+ } else if (e.type === "drag-active") {
3677
+ this._resetCursor("drag-active");
3207
3678
  } else {
3208
3679
  this._resetCursor("auto");
3209
3680
  }
@@ -3290,22 +3761,23 @@ var __privateMethod = (obj, member, method) => {
3290
3761
  return key2;
3291
3762
  }
3292
3763
  }
3293
- const key$1 = "SELECT";
3294
- const keyActionType = Symbol(`${key$1}_actionType`);
3295
- const keyResizeType = Symbol(`${key$1}_resizeType`);
3296
- const keyAreaStart = Symbol(`${key$1}_areaStart`);
3297
- const keyAreaEnd = Symbol(`${key$1}_areaEnd`);
3298
- const keyHoverElement = Symbol(`${key$1}_hoverElement`);
3299
- const keyHoverElementVertexes = Symbol(`${key$1}_hoverElementVertexes`);
3300
- const keySelectedElementList = Symbol(`${key$1}_selectedElementList`);
3301
- const keySelectedElementListVertexes = Symbol(`${key$1}_selectedElementListVertexes`);
3302
- const keySelectedElementController = Symbol(`${key$1}_selectedElementController`);
3303
- const keyGroupQueue = Symbol(`${key$1}_groupQueue`);
3304
- const keyGroupQueueVertexesList = Symbol(`${key$1}_groupQueueVertexesList`);
3764
+ const key$2 = "SELECT";
3765
+ const keyActionType = Symbol(`${key$2}_actionType`);
3766
+ const keyResizeType = Symbol(`${key$2}_resizeType`);
3767
+ const keyAreaStart = Symbol(`${key$2}_areaStart`);
3768
+ const keyAreaEnd = Symbol(`${key$2}_areaEnd`);
3769
+ const keyHoverElement = Symbol(`${key$2}_hoverElement`);
3770
+ const keyHoverElementVertexes = Symbol(`${key$2}_hoverElementVertexes`);
3771
+ const keySelectedElementList = Symbol(`${key$2}_selectedElementList`);
3772
+ const keySelectedElementListVertexes = Symbol(`${key$2}_selectedElementListVertexes`);
3773
+ const keySelectedElementController = Symbol(`${key$2}_selectedElementController`);
3774
+ const keyGroupQueue = Symbol(`${key$2}_groupQueue`);
3775
+ const keyGroupQueueVertexesList = Symbol(`${key$2}_groupQueueVertexesList`);
3305
3776
  const selectWrapperBorderWidth = 2;
3306
3777
  const resizeControllerBorderWidth = 4;
3307
3778
  const areaBorderWidth = 1;
3308
3779
  const wrapperColor = "#1973ba";
3780
+ const lockColor = "#5b5959b5";
3309
3781
  function drawVertexes(ctx, vertexes, opts) {
3310
3782
  const { borderColor: borderColor2, borderWidth: borderWidth2, background: background2, lineDash } = opts;
3311
3783
  ctx.setLineDash([]);
@@ -3330,6 +3802,44 @@ var __privateMethod = (obj, member, method) => {
3330
3802
  const wrapperOpts = { borderColor: wrapperColor, borderWidth: 1, background: "transparent", lineDash: [] };
3331
3803
  drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
3332
3804
  }
3805
+ function drawCrossVertexes(ctx, vertexes, opts) {
3806
+ const { borderColor: borderColor2, borderWidth: borderWidth2, background: background2, lineDash } = opts;
3807
+ ctx.setLineDash([]);
3808
+ ctx.lineWidth = borderWidth2;
3809
+ ctx.strokeStyle = borderColor2;
3810
+ ctx.fillStyle = background2;
3811
+ ctx.setLineDash(lineDash);
3812
+ ctx.beginPath();
3813
+ ctx.moveTo(vertexes[0].x, vertexes[0].y);
3814
+ ctx.lineTo(vertexes[2].x, vertexes[2].y);
3815
+ ctx.closePath();
3816
+ ctx.stroke();
3817
+ ctx.beginPath();
3818
+ ctx.moveTo(vertexes[1].x, vertexes[1].y);
3819
+ ctx.lineTo(vertexes[3].x, vertexes[3].y);
3820
+ ctx.closePath();
3821
+ ctx.stroke();
3822
+ }
3823
+ function drawLockVertexesWrapper(ctx, vertexes, opts) {
3824
+ if (!vertexes) {
3825
+ return;
3826
+ }
3827
+ const wrapperOpts = { borderColor: lockColor, borderWidth: 1, background: "transparent", lineDash: [] };
3828
+ drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
3829
+ const { controller } = opts;
3830
+ if (controller) {
3831
+ const { topLeft, topRight, bottomLeft, bottomRight, topMiddle, bottomMiddle, leftMiddle, rightMiddle } = controller;
3832
+ const ctrlOpts = { ...wrapperOpts, borderWidth: 1, background: lockColor };
3833
+ drawCrossVertexes(ctx, calcViewVertexes(topMiddle.vertexes, opts), ctrlOpts);
3834
+ drawCrossVertexes(ctx, calcViewVertexes(bottomMiddle.vertexes, opts), ctrlOpts);
3835
+ drawCrossVertexes(ctx, calcViewVertexes(leftMiddle.vertexes, opts), ctrlOpts);
3836
+ drawCrossVertexes(ctx, calcViewVertexes(rightMiddle.vertexes, opts), ctrlOpts);
3837
+ drawCrossVertexes(ctx, calcViewVertexes(topLeft.vertexes, opts), ctrlOpts);
3838
+ drawCrossVertexes(ctx, calcViewVertexes(topRight.vertexes, opts), ctrlOpts);
3839
+ drawCrossVertexes(ctx, calcViewVertexes(bottomLeft.vertexes, opts), ctrlOpts);
3840
+ drawCrossVertexes(ctx, calcViewVertexes(bottomRight.vertexes, opts), ctrlOpts);
3841
+ }
3842
+ }
3333
3843
  function drawSelectedElementControllersVertexes(ctx, controller, opts) {
3334
3844
  if (!controller) {
3335
3845
  return;
@@ -4013,6 +4523,7 @@ var __privateMethod = (obj, member, method) => {
4013
4523
  return { x: x2, y: y2, w: w2, h: h2, angle: elem.angle };
4014
4524
  }
4015
4525
  function getSelectedListArea(data, opts) {
4526
+ var _a;
4016
4527
  const indexes = [];
4017
4528
  const uuids = [];
4018
4529
  const elements = [];
@@ -4024,7 +4535,11 @@ var __privateMethod = (obj, member, method) => {
4024
4535
  const endX = Math.max(start.x, end.x);
4025
4536
  const startY = Math.min(start.y, end.y);
4026
4537
  const endY = Math.max(start.y, end.y);
4027
- data.elements.forEach((elem, idx) => {
4538
+ for (let idx = 0; idx < data.elements.length; idx++) {
4539
+ const elem = data.elements[idx];
4540
+ if (((_a = elem == null ? void 0 : elem.operations) == null ? void 0 : _a.lock) === true) {
4541
+ continue;
4542
+ }
4028
4543
  const elemSize = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
4029
4544
  const center = calcElementCenter(elemSize);
4030
4545
  if (center.x >= startX && center.x <= endX && center.y >= startY && center.y <= endY) {
@@ -4043,7 +4558,7 @@ var __privateMethod = (obj, member, method) => {
4043
4558
  }
4044
4559
  }
4045
4560
  }
4046
- });
4561
+ }
4047
4562
  return { indexes, uuids, elements };
4048
4563
  }
4049
4564
  function calcSelectedElementsArea(elements, opts) {
@@ -4130,9 +4645,8 @@ var __privateMethod = (obj, member, method) => {
4130
4645
  const middlewareEventTextEdit = "@middleware/text-edit";
4131
4646
  const defaultElementDetail = getDefaultElementDetailConfig();
4132
4647
  const MiddlewareTextEditor = (opts) => {
4133
- const key2 = "SELECT";
4134
- const { eventHub, viewContent, viewer } = opts;
4135
- const canvas = viewContent.boardContext.canvas;
4648
+ const { eventHub, boardContent, viewer } = opts;
4649
+ const canvas = boardContent.boardContext.canvas;
4136
4650
  const textarea = document.createElement("textarea");
4137
4651
  const canvasWrapper = document.createElement("div");
4138
4652
  const container = opts.container || document.body;
@@ -4260,48 +4774,30 @@ var __privateMethod = (obj, member, method) => {
4260
4774
  textarea.addEventListener("blur", () => {
4261
4775
  hideTextArea();
4262
4776
  });
4263
- eventHub.on(middlewareEventTextEdit, (e) => {
4777
+ const textEditCallback = (e) => {
4264
4778
  var _a;
4265
4779
  if ((e == null ? void 0 : e.element) && ((_a = e == null ? void 0 : e.element) == null ? void 0 : _a.type) === "text") {
4266
4780
  activeElem = e.element;
4267
4781
  }
4268
4782
  showTextArea(e);
4269
- });
4783
+ };
4270
4784
  return {
4271
- mode: key2,
4272
- isDefault: true
4785
+ name: "@middleware/text-editor",
4786
+ use() {
4787
+ eventHub.on(middlewareEventTextEdit, textEditCallback);
4788
+ },
4789
+ disuse() {
4790
+ eventHub.off(middlewareEventTextEdit, textEditCallback);
4791
+ }
4273
4792
  };
4274
4793
  };
4275
4794
  const middlewareEventSelect = "@middleware/select";
4795
+ const middlewareEventSelectClear = "@middleware/select-clear";
4276
4796
  const MiddlewareSelector = (opts) => {
4277
- const { viewer, sharer, viewContent, calculator, eventHub } = opts;
4278
- const { helperContext } = viewContent;
4797
+ const { viewer, sharer, boardContent, calculator, eventHub } = opts;
4798
+ const { helperContext } = boardContent;
4279
4799
  let prevPoint = null;
4280
4800
  let inBusyMode = null;
4281
- eventHub.on(middlewareEventSelect, ({ uuids, positions }) => {
4282
- let elements = [];
4283
- const actionType = sharer.getSharedStorage(keyActionType);
4284
- const data = sharer.getActiveStorage("data");
4285
- if (positions && Array.isArray(positions)) {
4286
- elements = findElementsFromListByPositions(positions, (data == null ? void 0 : data.elements) || []);
4287
- } else {
4288
- elements = findElementsFromList(uuids, (data == null ? void 0 : data.elements) || []);
4289
- }
4290
- let needRefresh = false;
4291
- if (!actionType && elements.length === 1) {
4292
- sharer.setSharedStorage(keyActionType, "select");
4293
- needRefresh = true;
4294
- } else if (actionType === "select" && elements.length === 1) {
4295
- needRefresh = true;
4296
- }
4297
- if (needRefresh) {
4298
- const elem = elements[0];
4299
- const groupQueue = getGroupQueueFromList(elem.uuid, (data == null ? void 0 : data.elements) || []);
4300
- sharer.setSharedStorage(keyGroupQueue, groupQueue);
4301
- updateSelectedElementList(elements);
4302
- viewer.drawFrame();
4303
- }
4304
- });
4305
4801
  sharer.setSharedStorage(keyActionType, null);
4306
4802
  const getActiveElements = () => {
4307
4803
  return sharer.getSharedStorage(keySelectedElementList);
@@ -4378,15 +4874,51 @@ var __privateMethod = (obj, member, method) => {
4378
4874
  sharer.setSharedStorage(keySelectedElementController, null);
4379
4875
  };
4380
4876
  clear();
4877
+ const selectCallback = ({ uuids, positions }) => {
4878
+ let elements = [];
4879
+ const actionType = sharer.getSharedStorage(keyActionType);
4880
+ const data = sharer.getActiveStorage("data");
4881
+ if (positions && Array.isArray(positions)) {
4882
+ elements = findElementsFromListByPositions(positions, (data == null ? void 0 : data.elements) || []);
4883
+ } else {
4884
+ elements = findElementsFromList(uuids, (data == null ? void 0 : data.elements) || []);
4885
+ }
4886
+ let needRefresh = false;
4887
+ if (!actionType && elements.length === 1) {
4888
+ sharer.setSharedStorage(keyActionType, "select");
4889
+ needRefresh = true;
4890
+ } else if (actionType === "select" && elements.length === 1) {
4891
+ needRefresh = true;
4892
+ }
4893
+ if (needRefresh) {
4894
+ const elem = elements[0];
4895
+ const groupQueue = getGroupQueueFromList(elem.uuid, (data == null ? void 0 : data.elements) || []);
4896
+ sharer.setSharedStorage(keyGroupQueue, groupQueue);
4897
+ updateSelectedElementList(elements);
4898
+ viewer.drawFrame();
4899
+ }
4900
+ };
4901
+ const selectClearCallback = () => {
4902
+ clear();
4903
+ viewer.drawFrame();
4904
+ };
4381
4905
  return {
4382
- mode: key$1,
4906
+ name: "@middleware/selector",
4907
+ use() {
4908
+ eventHub.on(middlewareEventSelect, selectCallback);
4909
+ eventHub.on(middlewareEventSelectClear, selectClearCallback);
4910
+ },
4911
+ disuse() {
4912
+ eventHub.off(middlewareEventSelect, selectCallback);
4913
+ eventHub.off(middlewareEventSelectClear, selectClearCallback);
4914
+ },
4383
4915
  hover: (e) => {
4384
- var _a, _b;
4916
+ var _a, _b, _c, _d, _e;
4385
4917
  const resizeType = sharer.getSharedStorage(keyResizeType);
4386
4918
  const actionType = sharer.getSharedStorage(keyActionType);
4387
4919
  const groupQueue = sharer.getSharedStorage(keyGroupQueue);
4388
4920
  const triggerCursor = (target2) => {
4389
- let cursor = target2.type;
4921
+ const cursor = target2.type;
4390
4922
  if (inBusyMode === null) {
4391
4923
  eventHub.trigger("cursor", {
4392
4924
  type: cursor,
@@ -4443,8 +4975,16 @@ var __privateMethod = (obj, member, method) => {
4443
4975
  })
4444
4976
  });
4445
4977
  triggerCursor(target);
4446
- if (target.type === "over-element" && ((_b = target == null ? void 0 : target.elements) == null ? void 0 : _b.length) === 1) {
4447
- sharer.setSharedStorage(keyHoverElement, target.elements[0]);
4978
+ if (target.type === null) {
4979
+ return;
4980
+ }
4981
+ if (target.type === "over-element" && sharer.getSharedStorage(keyActionType) === "select" && target.elements.length === 1 && target.elements[0].uuid === ((_c = (_b = getActiveElements()) == null ? void 0 : _b[0]) == null ? void 0 : _c.uuid)) {
4982
+ return;
4983
+ }
4984
+ if (target.type === "over-element" && sharer.getSharedStorage(keyActionType) === null && target.elements.length === 1 && target.elements[0].uuid === ((_d = sharer.getSharedStorage(keyHoverElement)) == null ? void 0 : _d.uuid)) {
4985
+ return;
4986
+ }
4987
+ if (target.type === "over-element" && ((_e = target == null ? void 0 : target.elements) == null ? void 0 : _e.length) === 1) {
4448
4988
  updateHoverElement(target.elements[0]);
4449
4989
  viewer.drawFrame();
4450
4990
  return;
@@ -4456,9 +4996,8 @@ var __privateMethod = (obj, member, method) => {
4456
4996
  }
4457
4997
  },
4458
4998
  pointStart: (e) => {
4459
- var _a, _b, _c, _d;
4999
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4460
5000
  prevPoint = e.point;
4461
- updateHoverElement(null);
4462
5001
  const groupQueue = sharer.getSharedStorage(keyGroupQueue);
4463
5002
  if ((groupQueue == null ? void 0 : groupQueue.length) > 0) {
4464
5003
  if (isPointInViewActiveGroup(e.point, {
@@ -4468,11 +5007,15 @@ var __privateMethod = (obj, member, method) => {
4468
5007
  groupQueue
4469
5008
  })) {
4470
5009
  const target2 = getPointTarget(e.point, pointTargetBaseOptions());
4471
- updateHoverElement(null);
4472
- if (target2.type === "over-element" && ((_a = target2 == null ? void 0 : target2.elements) == null ? void 0 : _a.length) === 1) {
5010
+ if (((_a = target2 == null ? void 0 : target2.elements) == null ? void 0 : _a.length) === 1 && ((_c = (_b = target2.elements[0]) == null ? void 0 : _b.operations) == null ? void 0 : _c.lock) === true) {
5011
+ return;
5012
+ } else {
5013
+ updateHoverElement(null);
5014
+ }
5015
+ if (target2.type === "over-element" && ((_d = target2 == null ? void 0 : target2.elements) == null ? void 0 : _d.length) === 1) {
4473
5016
  updateSelectedElementList([target2.elements[0]], { triggerEvent: true });
4474
5017
  sharer.setSharedStorage(keyActionType, "drag");
4475
- } else if ((_b = target2.type) == null ? void 0 : _b.startsWith("resize-")) {
5018
+ } else if ((_e = target2.type) == null ? void 0 : _e.startsWith("resize-")) {
4476
5019
  sharer.setSharedStorage(keyResizeType, target2.type);
4477
5020
  sharer.setSharedStorage(keyActionType, "resize");
4478
5021
  } else {
@@ -4494,12 +5037,17 @@ var __privateMethod = (obj, member, method) => {
4494
5037
  areaSize: listAreaSize,
4495
5038
  groupQueue: []
4496
5039
  });
5040
+ if (((_f = target == null ? void 0 : target.elements) == null ? void 0 : _f.length) === 1 && ((_h = (_g = target.elements[0]) == null ? void 0 : _g.operations) == null ? void 0 : _h.lock) === true) {
5041
+ return;
5042
+ } else {
5043
+ updateHoverElement(null);
5044
+ }
4497
5045
  if (target.type === "list-area") {
4498
5046
  sharer.setSharedStorage(keyActionType, "drag-list");
4499
- } else if (target.type === "over-element" && ((_c = target == null ? void 0 : target.elements) == null ? void 0 : _c.length) === 1) {
5047
+ } else if (target.type === "over-element" && ((_i = target == null ? void 0 : target.elements) == null ? void 0 : _i.length) === 1) {
4500
5048
  updateSelectedElementList([target.elements[0]], { triggerEvent: true });
4501
5049
  sharer.setSharedStorage(keyActionType, "drag");
4502
- } else if ((_d = target.type) == null ? void 0 : _d.startsWith("resize-")) {
5050
+ } else if ((_j = target.type) == null ? void 0 : _j.startsWith("resize-")) {
4503
5051
  sharer.setSharedStorage(keyResizeType, target.type);
4504
5052
  sharer.setSharedStorage(keyActionType, "resize");
4505
5053
  } else {
@@ -4511,6 +5059,7 @@ var __privateMethod = (obj, member, method) => {
4511
5059
  viewer.drawFrame();
4512
5060
  },
4513
5061
  pointMove: (e) => {
5062
+ var _a, _b, _c;
4514
5063
  const data = sharer.getActiveStorage("data");
4515
5064
  const elems = getActiveElements();
4516
5065
  const scale = sharer.getActiveStorage("scale") || 1;
@@ -4521,7 +5070,7 @@ var __privateMethod = (obj, member, method) => {
4521
5070
  const groupQueue = sharer.getSharedStorage(keyGroupQueue);
4522
5071
  if (actionType === "drag") {
4523
5072
  inBusyMode = "drag";
4524
- if (data && (elems == null ? void 0 : elems.length) === 1 && start && end) {
5073
+ if (data && (elems == null ? void 0 : elems.length) === 1 && start && end && ((_b = (_a = elems[0]) == null ? void 0 : _a.operations) == null ? void 0 : _b.lock) !== true) {
4525
5074
  const { moveX, moveY } = calcMoveInGroup(start, end, groupQueue);
4526
5075
  elems[0].x += moveX / scale;
4527
5076
  elems[0].y += moveY / scale;
@@ -4534,7 +5083,8 @@ var __privateMethod = (obj, member, method) => {
4534
5083
  const moveX = (end.x - start.x) / scale;
4535
5084
  const moveY = (end.y - start.y) / scale;
4536
5085
  elems.forEach((elem) => {
4537
- if (elem) {
5086
+ var _a2;
5087
+ if (elem && ((_a2 = elem == null ? void 0 : elem.operations) == null ? void 0 : _a2.lock) !== true) {
4538
5088
  elem.x += moveX;
4539
5089
  elem.y += moveY;
4540
5090
  }
@@ -4565,8 +5115,15 @@ var __privateMethod = (obj, member, method) => {
4565
5115
  const resizedElemSize = resizeElement(elems[0], { scale, start: resizeStart, end: resizeEnd, resizeType, sharer });
4566
5116
  elems[0].x = resizedElemSize.x;
4567
5117
  elems[0].y = resizedElemSize.y;
4568
- elems[0].w = resizedElemSize.w;
4569
- elems[0].h = resizedElemSize.h;
5118
+ if (elems[0].type === "group" && ((_c = elems[0].operations) == null ? void 0 : _c.deepResize) === true) {
5119
+ deepResizeGroupElement(elems[0], {
5120
+ w: resizedElemSize.w,
5121
+ h: resizedElemSize.h
5122
+ });
5123
+ } else {
5124
+ elems[0].w = resizedElemSize.w;
5125
+ elems[0].h = resizedElemSize.h;
5126
+ }
4570
5127
  updateSelectedElementList([elems[0]]);
4571
5128
  viewer.drawFrame();
4572
5129
  }
@@ -4638,7 +5195,8 @@ var __privateMethod = (obj, member, method) => {
4638
5195
  sharer.setActiveStorage("contextWidth", viewInfo.contextSize.contextWidth);
4639
5196
  }
4640
5197
  if (data && ["drag", "drag-list", "drag-list-end", "resize"].includes(actionType)) {
4641
- eventHub.trigger("change", { data });
5198
+ let type = "drag-element";
5199
+ eventHub.trigger("change", { data, type });
4642
5200
  }
4643
5201
  viewer.drawFrame();
4644
5202
  };
@@ -4650,16 +5208,21 @@ var __privateMethod = (obj, member, method) => {
4650
5208
  viewer.drawFrame();
4651
5209
  },
4652
5210
  doubleClick(e) {
4653
- var _a, _b;
5211
+ var _a, _b, _c, _d;
4654
5212
  const target = getPointTarget(e.point, pointTargetBaseOptions());
4655
- if (target.elements.length === 1 && ((_a = target.elements[0]) == null ? void 0 : _a.type) === "group") {
5213
+ sharer.setSharedStorage(keySelectedElementController, null);
5214
+ sharer.setSharedStorage(keySelectedElementList, []);
5215
+ if (target.elements.length === 1 && ((_b = (_a = target.elements[0]) == null ? void 0 : _a.operations) == null ? void 0 : _b.lock) === true) {
5216
+ return;
5217
+ }
5218
+ if (target.elements.length === 1 && ((_c = target.elements[0]) == null ? void 0 : _c.type) === "group") {
4656
5219
  const pushResult = pushGroupQueue(target.elements[0]);
4657
5220
  if (pushResult === true) {
4658
5221
  sharer.setSharedStorage(keyActionType, null);
4659
5222
  viewer.drawFrame();
4660
5223
  return;
4661
5224
  }
4662
- } else if (target.elements.length === 1 && ((_b = target.elements[0]) == null ? void 0 : _b.type) === "text") {
5225
+ } else if (target.elements.length === 1 && ((_d = target.elements[0]) == null ? void 0 : _d.type) === "text") {
4663
5226
  eventHub.trigger(middlewareEventTextEdit, {
4664
5227
  element: target.elements[0],
4665
5228
  groupQueue: sharer.getSharedStorage(keyGroupQueue) || [],
@@ -4669,6 +5232,7 @@ var __privateMethod = (obj, member, method) => {
4669
5232
  sharer.setSharedStorage(keyActionType, null);
4670
5233
  },
4671
5234
  beforeDrawFrame({ snapshot }) {
5235
+ var _a;
4672
5236
  const { activeStore, sharedStore } = snapshot;
4673
5237
  const { scale, offsetLeft, offsetTop, offsetRight, offsetBottom, width, height, contextHeight, contextWidth, devicePixelRatio } = activeStore;
4674
5238
  const sharer2 = opts.sharer;
@@ -4689,19 +5253,42 @@ var __privateMethod = (obj, member, method) => {
4689
5253
  controllerSize: 10,
4690
5254
  viewScaleInfo
4691
5255
  }) : null;
5256
+ const isLock = !!((_a = hoverElement == null ? void 0 : hoverElement.operations) == null ? void 0 : _a.lock);
4692
5257
  if ((groupQueue == null ? void 0 : groupQueue.length) > 0) {
4693
5258
  drawGroupQueueVertexesWrappers(helperContext, groupQueueVertexesList, drawBaseOpts);
4694
5259
  if (hoverElement && actionType !== "drag") {
4695
- drawHoverVertexesWrapper(helperContext, hoverElementVertexes, drawBaseOpts);
5260
+ if (isLock) {
5261
+ drawLockVertexesWrapper(helperContext, hoverElementVertexes, {
5262
+ ...drawBaseOpts,
5263
+ controller: calcElementSizeController(hoverElement, {
5264
+ groupQueue,
5265
+ controllerSize: 10,
5266
+ viewScaleInfo
5267
+ })
5268
+ });
5269
+ } else {
5270
+ drawHoverVertexesWrapper(helperContext, hoverElementVertexes, drawBaseOpts);
5271
+ }
4696
5272
  }
4697
- if (elem && ["select", "drag", "resize"].includes(actionType)) {
5273
+ if (!isLock && elem && ["select", "drag", "resize"].includes(actionType)) {
4698
5274
  drawSelectedElementControllersVertexes(helperContext, selectedElementController, { ...drawBaseOpts });
4699
5275
  }
4700
5276
  } else {
4701
5277
  if (hoverElement && actionType !== "drag") {
4702
- drawHoverVertexesWrapper(helperContext, hoverElementVertexes, drawBaseOpts);
5278
+ if (isLock) {
5279
+ drawLockVertexesWrapper(helperContext, hoverElementVertexes, {
5280
+ ...drawBaseOpts,
5281
+ controller: calcElementSizeController(hoverElement, {
5282
+ groupQueue,
5283
+ controllerSize: 10,
5284
+ viewScaleInfo
5285
+ })
5286
+ });
5287
+ } else {
5288
+ drawHoverVertexesWrapper(helperContext, hoverElementVertexes, drawBaseOpts);
5289
+ }
4703
5290
  }
4704
- if (elem && ["select", "drag", "resize"].includes(actionType)) {
5291
+ if (!isLock && elem && ["select", "drag", "resize"].includes(actionType)) {
4705
5292
  drawSelectedElementControllersVertexes(helperContext, selectedElementController, { ...drawBaseOpts });
4706
5293
  } else if (actionType === "area" && areaStart && areaEnd) {
4707
5294
  drawArea(helperContext, { start: areaStart, end: areaEnd });
@@ -4719,12 +5306,12 @@ var __privateMethod = (obj, member, method) => {
4719
5306
  }
4720
5307
  };
4721
5308
  };
4722
- const key = "SCROLL";
4723
- const keyXThumbRect = Symbol(`${key}_xThumbRect`);
4724
- const keyYThumbRect = Symbol(`${key}_yThumbRect`);
4725
- const keyPrevPoint = Symbol(`${key}_prevPoint`);
4726
- const keyActivePoint = Symbol(`${key}_activePoint`);
4727
- const keyActiveThumbType = Symbol(`${key}_activeThumbType`);
5309
+ const key$1 = "SCROLL";
5310
+ const keyXThumbRect = Symbol(`${key$1}_xThumbRect`);
5311
+ const keyYThumbRect = Symbol(`${key$1}_yThumbRect`);
5312
+ const keyPrevPoint$1 = Symbol(`${key$1}_prevPoint`);
5313
+ const keyActivePoint = Symbol(`${key$1}_activePoint`);
5314
+ const keyActiveThumbType = Symbol(`${key$1}_activeThumbType`);
4728
5315
  const minScrollerWidth = 12;
4729
5316
  const scrollerLineWidth = 16;
4730
5317
  const scrollerThumbAlpha = 0.36;
@@ -4759,7 +5346,7 @@ var __privateMethod = (obj, member, method) => {
4759
5346
  const { sharedStore } = snapshot;
4760
5347
  const info = {
4761
5348
  activePoint: sharedStore[keyActivePoint] || null,
4762
- prevPoint: sharedStore[keyPrevPoint] || null,
5349
+ prevPoint: sharedStore[keyPrevPoint$1] || null,
4763
5350
  activeThumbType: sharedStore[keyActiveThumbType] || null,
4764
5351
  xThumbRect: sharedStore[keyXThumbRect] || null,
4765
5352
  yThumbRect: sharedStore[keyYThumbRect] || null
@@ -4917,18 +5504,18 @@ var __privateMethod = (obj, member, method) => {
4917
5504
  return { xThumbRect, yThumbRect };
4918
5505
  }
4919
5506
  const MiddlewareScroller = (opts) => {
4920
- const { viewer, viewContent, sharer } = opts;
4921
- const { helperContext } = viewContent;
5507
+ const { viewer, boardContent, sharer } = opts;
5508
+ const { helperContext } = boardContent;
4922
5509
  sharer.setSharedStorage(keyXThumbRect, null);
4923
5510
  sharer.setSharedStorage(keyYThumbRect, null);
4924
5511
  const clear = () => {
4925
- sharer.setSharedStorage(keyPrevPoint, null);
5512
+ sharer.setSharedStorage(keyPrevPoint$1, null);
4926
5513
  sharer.setSharedStorage(keyActivePoint, null);
4927
5514
  sharer.setSharedStorage(keyActiveThumbType, null);
4928
5515
  };
4929
5516
  clear();
4930
5517
  const scrollX = (p) => {
4931
- const prevPoint = sharer.getSharedStorage(keyPrevPoint);
5518
+ const prevPoint = sharer.getSharedStorage(keyPrevPoint$1);
4932
5519
  if (prevPoint) {
4933
5520
  const { offsetLeft, offsetRight } = sharer.getActiveViewScaleInfo();
4934
5521
  const { width } = sharer.getActiveViewSizeInfo();
@@ -4940,7 +5527,7 @@ var __privateMethod = (obj, member, method) => {
4940
5527
  }
4941
5528
  };
4942
5529
  const scrollY = (p) => {
4943
- const prevPoint = sharer.getSharedStorage(keyPrevPoint);
5530
+ const prevPoint = sharer.getSharedStorage(keyPrevPoint$1);
4944
5531
  if (prevPoint) {
4945
5532
  const { offsetTop, offsetBottom } = sharer.getActiveViewScaleInfo();
4946
5533
  const { height } = sharer.getActiveViewSizeInfo();
@@ -4958,7 +5545,7 @@ var __privateMethod = (obj, member, method) => {
4958
5545
  });
4959
5546
  };
4960
5547
  return {
4961
- mode: key,
5548
+ name: "@middleware/scroller",
4962
5549
  wheel: (e) => {
4963
5550
  viewer.scroll({
4964
5551
  moveX: 0 - e.deltaX,
@@ -4971,7 +5558,7 @@ var __privateMethod = (obj, member, method) => {
4971
5558
  const thumbType = getThumbType(point);
4972
5559
  if (thumbType === "X" || thumbType === "Y") {
4973
5560
  sharer.setSharedStorage(keyActiveThumbType, thumbType);
4974
- sharer.setSharedStorage(keyPrevPoint, point);
5561
+ sharer.setSharedStorage(keyPrevPoint$1, point);
4975
5562
  return false;
4976
5563
  }
4977
5564
  },
@@ -4985,11 +5572,11 @@ var __privateMethod = (obj, member, method) => {
4985
5572
  } else if (activeThumbType === "Y") {
4986
5573
  scrollY(point);
4987
5574
  }
4988
- sharer.setSharedStorage(keyPrevPoint, point);
5575
+ sharer.setSharedStorage(keyPrevPoint$1, point);
4989
5576
  return false;
4990
5577
  }
4991
5578
  },
4992
- pointEnd: (e) => {
5579
+ pointEnd: () => {
4993
5580
  const activeThumbType = sharer.getSharedStorage(keyActiveThumbType);
4994
5581
  clear();
4995
5582
  if (activeThumbType === "X" || activeThumbType === "Y") {
@@ -5007,13 +5594,11 @@ var __privateMethod = (obj, member, method) => {
5007
5594
  };
5008
5595
  const middlewareEventScale = "@middleware/scale";
5009
5596
  const MiddlewareScaler = (opts) => {
5010
- const key2 = "SCALE";
5011
5597
  const { viewer, sharer, eventHub } = opts;
5012
5598
  const maxScale = 50;
5013
5599
  const minScale = 0.05;
5014
5600
  return {
5015
- mode: key2,
5016
- isDefault: true,
5601
+ name: "@middleware/scaler",
5017
5602
  wheelScale(e) {
5018
5603
  const { deltaY, point } = e;
5019
5604
  const { scale } = sharer.getActiveViewScaleInfo();
@@ -5220,12 +5805,11 @@ var __privateMethod = (obj, member, method) => {
5220
5805
  }
5221
5806
  const middlewareEventRuler = "@middleware/show-ruler";
5222
5807
  const MiddlewareRuler = (opts) => {
5223
- const key2 = "RULE";
5224
- const { viewContent, viewer, eventHub } = opts;
5225
- const { helperContext, underContext } = viewContent;
5808
+ const { boardContent, viewer, eventHub } = opts;
5809
+ const { helperContext, underContext } = boardContent;
5226
5810
  let show = true;
5227
5811
  let showGrid = true;
5228
- eventHub.on(middlewareEventRuler, (e) => {
5812
+ const rulerCallback = (e) => {
5229
5813
  if (typeof (e == null ? void 0 : e.show) === "boolean") {
5230
5814
  show = e.show;
5231
5815
  }
@@ -5235,10 +5819,15 @@ var __privateMethod = (obj, member, method) => {
5235
5819
  if (typeof (e == null ? void 0 : e.show) === "boolean" || typeof (e == null ? void 0 : e.showGrid) === "boolean") {
5236
5820
  viewer.drawFrame();
5237
5821
  }
5238
- });
5822
+ };
5239
5823
  return {
5240
- mode: key2,
5241
- isDefault: true,
5824
+ name: "@middleware/ruler",
5825
+ use() {
5826
+ eventHub.on(middlewareEventRuler, rulerCallback);
5827
+ },
5828
+ disuse() {
5829
+ eventHub.off(middlewareEventRuler, rulerCallback);
5830
+ },
5242
5831
  beforeDrawFrame: ({ snapshot }) => {
5243
5832
  if (show === true) {
5244
5833
  const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
@@ -5260,20 +5849,64 @@ var __privateMethod = (obj, member, method) => {
5260
5849
  }
5261
5850
  };
5262
5851
  };
5852
+ const key = "DRAG";
5853
+ const keyPrevPoint = Symbol(`${key}_prevPoint`);
5854
+ const MiddlewareDragger = (opts) => {
5855
+ const { eventHub, sharer, viewer } = opts;
5856
+ let isDragging = false;
5857
+ return {
5858
+ name: "@middleware/dragger",
5859
+ hover() {
5860
+ if (isDragging === true) {
5861
+ return;
5862
+ }
5863
+ eventHub.trigger("cursor", {
5864
+ type: "drag-default"
5865
+ });
5866
+ },
5867
+ pointStart(e) {
5868
+ const { point } = e;
5869
+ sharer.setSharedStorage(keyPrevPoint, point);
5870
+ isDragging = true;
5871
+ eventHub.trigger("cursor", {
5872
+ type: "drag-active"
5873
+ });
5874
+ },
5875
+ pointMove(e) {
5876
+ const { point } = e;
5877
+ const prevPoint = sharer.getSharedStorage(keyPrevPoint);
5878
+ if (point && prevPoint) {
5879
+ const moveX = point.x - prevPoint.x;
5880
+ const moveY = point.y - prevPoint.y;
5881
+ viewer.scroll({ moveX, moveY });
5882
+ viewer.drawFrame();
5883
+ }
5884
+ sharer.setSharedStorage(keyPrevPoint, point);
5885
+ },
5886
+ pointEnd() {
5887
+ isDragging = false;
5888
+ sharer.setSharedStorage(keyPrevPoint, null);
5889
+ eventHub.trigger("cursor", {
5890
+ type: "drag-default"
5891
+ });
5892
+ }
5893
+ };
5894
+ };
5263
5895
  class Core {
5264
5896
  constructor(container, opts) {
5265
5897
  __privateAdd(this, _initContainer);
5266
5898
  __privateAdd(this, _board, void 0);
5267
5899
  // #opts: CoreOptions;
5268
- // #canvas: HTMLCanvasElement;
5900
+ __privateAdd(this, _canvas, void 0);
5269
5901
  __privateAdd(this, _container, void 0);
5270
- const { devicePixelRatio = 1, width, height } = opts;
5902
+ const { devicePixelRatio = 1, width, height, createCustomContext2D } = opts;
5271
5903
  __privateSet(this, _container, container);
5272
5904
  const canvas = document.createElement("canvas");
5905
+ __privateSet(this, _canvas, canvas);
5273
5906
  __privateMethod(this, _initContainer, initContainer_fn).call(this);
5274
5907
  container.appendChild(canvas);
5275
- const viewContent = createViewContent(canvas, { width, height, devicePixelRatio, offscreen: true });
5276
- const board = new Board({ viewContent, container });
5908
+ const boardContent = createBoardContent(canvas, { width, height, devicePixelRatio, offscreen: true, createCustomContext2D });
5909
+ const board = new Board({ boardContent, container });
5277
5910
  const sharer = board.getSharer();
5278
5911
  sharer.setActiveViewSizeInfo({
5279
5912
  width,
@@ -5289,9 +5922,16 @@ var __privateMethod = (obj, member, method) => {
5289
5922
  eventHub
5290
5923
  });
5291
5924
  }
5925
+ destroy() {
5926
+ __privateGet(this, _board).destroy();
5927
+ __privateGet(this, _canvas).remove();
5928
+ }
5292
5929
  use(middleware) {
5293
5930
  __privateGet(this, _board).use(middleware);
5294
5931
  }
5932
+ disuse(middleware) {
5933
+ __privateGet(this, _board).disuse(middleware);
5934
+ }
5295
5935
  setData(data) {
5296
5936
  validateElements((data == null ? void 0 : data.elements) || []);
5297
5937
  __privateGet(this, _board).setData(data);
@@ -5344,8 +5984,12 @@ var __privateMethod = (obj, member, method) => {
5344
5984
  setViewScale(opts) {
5345
5985
  __privateGet(this, _board).updateViewScaleInfo(opts);
5346
5986
  }
5987
+ getLoadItemMap() {
5988
+ return __privateGet(this, _board).getRenderer().getLoadItemMap();
5989
+ }
5347
5990
  }
5348
5991
  _board = new WeakMap();
5992
+ _canvas = new WeakMap();
5349
5993
  _container = new WeakMap();
5350
5994
  _initContainer = new WeakSet();
5351
5995
  initContainer_fn = function() {
@@ -5353,6 +5997,7 @@ var __privateMethod = (obj, member, method) => {
5353
5997
  container.style.position = "relative";
5354
5998
  };
5355
5999
  exports.Core = Core;
6000
+ exports.MiddlewareDragger = MiddlewareDragger;
5356
6001
  exports.MiddlewareRuler = MiddlewareRuler;
5357
6002
  exports.MiddlewareScaler = MiddlewareScaler;
5358
6003
  exports.MiddlewareScroller = MiddlewareScroller;
@@ -5361,6 +6006,7 @@ var __privateMethod = (obj, member, method) => {
5361
6006
  exports.middlewareEventRuler = middlewareEventRuler;
5362
6007
  exports.middlewareEventScale = middlewareEventScale;
5363
6008
  exports.middlewareEventSelect = middlewareEventSelect;
6009
+ exports.middlewareEventSelectClear = middlewareEventSelectClear;
5364
6010
  exports.middlewareEventTextEdit = middlewareEventTextEdit;
5365
6011
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5366
6012
  return exports;