@idraw/core 0.4.0-beta.34 → 0.4.0-beta.35
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { is, calcElementsViewInfo, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcElementSizeController, calcElementCenterFromVertexes, rotatePointInGroup, getGroupQueueFromList, findElementsFromList, findElementsFromListByPositions, getElementPositionFromList, deepResizeGroupElement, getElementSize } from '@idraw/util';
|
|
1
|
+
import { is, calcElementsViewInfo, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcElementSizeController, calcElementCenterFromVertexes, rotatePointInGroup, getGroupQueueFromList, findElementsFromList, findElementsFromListByPositions, getElementPositionFromList, getElementPositionMapFromList, deepResizeGroupElement, getElementSize } from '@idraw/util';
|
|
2
2
|
import { drawHoverVertexesWrapper, drawLockedVertexesWrapper, drawArea, drawListArea, drawGroupQueueVertexesWrappers, drawSelectedElementControllersVertexes } from './draw-wrapper';
|
|
3
3
|
import { drawReferenceLines } from './draw-reference';
|
|
4
4
|
import { getPointTarget, resizeElement, rotateElement, getSelectedListArea, calcSelectedElementsArea, isElementInGroup, isPointInViewActiveGroup, calcMoveInGroup } from './util';
|
|
@@ -17,6 +17,7 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
17
17
|
let moveOriginalStartPoint = null;
|
|
18
18
|
let moveOriginalStartElementSize = null;
|
|
19
19
|
let inBusyMode = null;
|
|
20
|
+
let hasChangedData = null;
|
|
20
21
|
sharer.setSharedStorage(keyActionType, null);
|
|
21
22
|
sharer.setSharedStorage(keyEnableSnapToGrid, true);
|
|
22
23
|
const getActiveElements = () => {
|
|
@@ -70,7 +71,10 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
70
71
|
sharer.setSharedStorage(keySelectedElementPosition, []);
|
|
71
72
|
}
|
|
72
73
|
if ((opts === null || opts === void 0 ? void 0 : opts.triggerEvent) === true) {
|
|
73
|
-
|
|
74
|
+
const uuids = list.map((elem) => elem.uuid);
|
|
75
|
+
const data = sharer.getActiveStorage('data');
|
|
76
|
+
const positionMap = getElementPositionMapFromList(uuids, (data === null || data === void 0 ? void 0 : data.elements) || []);
|
|
77
|
+
eventHub.trigger(coreEventKeys.SELECT, { uuids, positions: list.map((elem) => [...positionMap[elem.uuid]]) });
|
|
74
78
|
}
|
|
75
79
|
};
|
|
76
80
|
const pointTargetBaseOptions = () => {
|
|
@@ -339,6 +343,7 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
339
343
|
const groupQueue = sharer.getSharedStorage(keyGroupQueue);
|
|
340
344
|
const enableSnapToGrid = sharer.getSharedStorage(keyEnableSnapToGrid);
|
|
341
345
|
if (actionType === 'drag') {
|
|
346
|
+
hasChangedData = true;
|
|
342
347
|
inBusyMode = 'drag';
|
|
343
348
|
if (data && (elems === null || elems === void 0 ? void 0 : elems.length) === 1 && moveOriginalStartElementSize && originalStart && end && ((_b = (_a = elems[0]) === null || _a === void 0 ? void 0 : _a.operations) === null || _b === void 0 ? void 0 : _b.locked) !== true) {
|
|
344
349
|
const { moveX, moveY } = calcMoveInGroup(originalStart, end, groupQueue);
|
|
@@ -384,6 +389,7 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
384
389
|
viewer.drawFrame();
|
|
385
390
|
}
|
|
386
391
|
else if (actionType === 'drag-list') {
|
|
392
|
+
hasChangedData = true;
|
|
387
393
|
inBusyMode = 'drag-list';
|
|
388
394
|
if (data && originalStart && start && end && (elems === null || elems === void 0 ? void 0 : elems.length) > 1) {
|
|
389
395
|
const moveX = (end.x - start.x) / scale;
|
|
@@ -412,6 +418,7 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
412
418
|
}
|
|
413
419
|
else if (actionType === 'resize') {
|
|
414
420
|
if (data && (elems === null || elems === void 0 ? void 0 : elems.length) === 1 && originalStart && moveOriginalStartElementSize && (resizeType === null || resizeType === void 0 ? void 0 : resizeType.startsWith('resize-'))) {
|
|
421
|
+
hasChangedData = true;
|
|
415
422
|
inBusyMode = 'resize';
|
|
416
423
|
const pointGroupQueue = [];
|
|
417
424
|
groupQueue.forEach((group) => {
|
|
@@ -562,7 +569,10 @@ export const MiddlewareSelector = (opts, config) => {
|
|
|
562
569
|
if (type === 'resize') {
|
|
563
570
|
type = 'resizeElement';
|
|
564
571
|
}
|
|
565
|
-
|
|
572
|
+
if (hasChangedData) {
|
|
573
|
+
eventHub.trigger(coreEventKeys.CHANGE, { data, type, selectedElements, hoverElement });
|
|
574
|
+
hasChangedData = false;
|
|
575
|
+
}
|
|
566
576
|
}
|
|
567
577
|
viewer.drawFrame();
|
|
568
578
|
};
|
package/dist/index.global.js
CHANGED
|
@@ -824,14 +824,16 @@ var __privateMethod = (obj, member, method) => {
|
|
|
824
824
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
825
825
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
826
826
|
};
|
|
827
|
-
var _Store_instances, _Store_temp, _Store_backUpDefaultStorage, _Store_createTempStorage;
|
|
827
|
+
var _Store_instances, _Store_temp, _Store_backUpDefaultStorage, _Store_static, _Store_createTempStorage;
|
|
828
828
|
class Store {
|
|
829
829
|
constructor(opts) {
|
|
830
830
|
_Store_instances.add(this);
|
|
831
831
|
_Store_temp.set(this, void 0);
|
|
832
832
|
_Store_backUpDefaultStorage.set(this, void 0);
|
|
833
|
+
_Store_static.set(this, void 0);
|
|
833
834
|
__classPrivateFieldSet$7(this, _Store_backUpDefaultStorage, deepClone(opts.defaultStorage), "f");
|
|
834
835
|
__classPrivateFieldSet$7(this, _Store_temp, __classPrivateFieldGet$7(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
|
|
836
|
+
__classPrivateFieldSet$7(this, _Store_static, opts.defaultStatic || {}, "f");
|
|
835
837
|
}
|
|
836
838
|
set(name, value) {
|
|
837
839
|
__classPrivateFieldGet$7(this, _Store_temp, "f")[name] = value;
|
|
@@ -839,6 +841,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
839
841
|
get(name) {
|
|
840
842
|
return __classPrivateFieldGet$7(this, _Store_temp, "f")[name];
|
|
841
843
|
}
|
|
844
|
+
setStatic(name, value) {
|
|
845
|
+
__classPrivateFieldGet$7(this, _Store_static, "f")[name] = value;
|
|
846
|
+
}
|
|
847
|
+
getStatic(name) {
|
|
848
|
+
return __classPrivateFieldGet$7(this, _Store_static, "f")[name];
|
|
849
|
+
}
|
|
842
850
|
getSnapshot(opts) {
|
|
843
851
|
if ((opts === null || opts === void 0 ? void 0 : opts.deepClone) === true) {
|
|
844
852
|
return deepClone(__classPrivateFieldGet$7(this, _Store_temp, "f"));
|
|
@@ -850,9 +858,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
850
858
|
}
|
|
851
859
|
destroy() {
|
|
852
860
|
__classPrivateFieldSet$7(this, _Store_temp, null, "f");
|
|
861
|
+
__classPrivateFieldSet$7(this, _Store_static, null, "f");
|
|
853
862
|
}
|
|
854
863
|
}
|
|
855
|
-
_Store_temp = /* @__PURE__ */ new WeakMap(), _Store_backUpDefaultStorage = /* @__PURE__ */ new WeakMap(), _Store_instances = /* @__PURE__ */ new WeakSet(), _Store_createTempStorage = function _Store_createTempStorage2() {
|
|
864
|
+
_Store_temp = /* @__PURE__ */ new WeakMap(), _Store_backUpDefaultStorage = /* @__PURE__ */ new WeakMap(), _Store_static = /* @__PURE__ */ new WeakMap(), _Store_instances = /* @__PURE__ */ new WeakSet(), _Store_createTempStorage = function _Store_createTempStorage2() {
|
|
856
865
|
return deepClone(__classPrivateFieldGet$7(this, _Store_backUpDefaultStorage, "f"));
|
|
857
866
|
};
|
|
858
867
|
function getViewScaleInfoFromSnapshot(snapshot) {
|
|
@@ -1266,6 +1275,36 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1266
1275
|
_loop(elements);
|
|
1267
1276
|
return result;
|
|
1268
1277
|
}
|
|
1278
|
+
function getElementPositionMapFromList(uuids, elements) {
|
|
1279
|
+
const currentPosition = [];
|
|
1280
|
+
const positionMap = {};
|
|
1281
|
+
let over = false;
|
|
1282
|
+
const _loop = (list) => {
|
|
1283
|
+
var _a;
|
|
1284
|
+
for (let i = 0; i < list.length; i++) {
|
|
1285
|
+
if (over === true) {
|
|
1286
|
+
break;
|
|
1287
|
+
}
|
|
1288
|
+
currentPosition.push(i);
|
|
1289
|
+
const elem = list[i];
|
|
1290
|
+
if (uuids.includes(elem.uuid)) {
|
|
1291
|
+
positionMap[elem.uuid] = [...currentPosition];
|
|
1292
|
+
if (Object.keys(positionMap).length === uuids.length) {
|
|
1293
|
+
over = true;
|
|
1294
|
+
break;
|
|
1295
|
+
}
|
|
1296
|
+
} else if (elem.type === "group") {
|
|
1297
|
+
_loop(((_a = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _a === void 0 ? void 0 : _a.children) || []);
|
|
1298
|
+
}
|
|
1299
|
+
if (over) {
|
|
1300
|
+
break;
|
|
1301
|
+
}
|
|
1302
|
+
currentPosition.pop();
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
_loop(elements);
|
|
1306
|
+
return positionMap;
|
|
1307
|
+
}
|
|
1269
1308
|
function getElementVertexes(elemSize) {
|
|
1270
1309
|
const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
|
|
1271
1310
|
return [
|
|
@@ -6318,6 +6357,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6318
6357
|
let moveOriginalStartPoint = null;
|
|
6319
6358
|
let moveOriginalStartElementSize = null;
|
|
6320
6359
|
let inBusyMode = null;
|
|
6360
|
+
let hasChangedData = null;
|
|
6321
6361
|
sharer.setSharedStorage(keyActionType, null);
|
|
6322
6362
|
sharer.setSharedStorage(keyEnableSnapToGrid, true);
|
|
6323
6363
|
const getActiveElements = () => {
|
|
@@ -6368,7 +6408,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6368
6408
|
sharer.setSharedStorage(keySelectedElementPosition, []);
|
|
6369
6409
|
}
|
|
6370
6410
|
if ((opts2 == null ? void 0 : opts2.triggerEvent) === true) {
|
|
6371
|
-
|
|
6411
|
+
const uuids = list.map((elem) => elem.uuid);
|
|
6412
|
+
const data = sharer.getActiveStorage("data");
|
|
6413
|
+
const positionMap = getElementPositionMapFromList(uuids, (data == null ? void 0 : data.elements) || []);
|
|
6414
|
+
eventHub.trigger(coreEventKeys.SELECT, { uuids, positions: list.map((elem) => [...positionMap[elem.uuid]]) });
|
|
6372
6415
|
}
|
|
6373
6416
|
};
|
|
6374
6417
|
const pointTargetBaseOptions = () => {
|
|
@@ -6628,6 +6671,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6628
6671
|
const groupQueue = sharer.getSharedStorage(keyGroupQueue);
|
|
6629
6672
|
const enableSnapToGrid = sharer.getSharedStorage(keyEnableSnapToGrid);
|
|
6630
6673
|
if (actionType === "drag") {
|
|
6674
|
+
hasChangedData = true;
|
|
6631
6675
|
inBusyMode = "drag";
|
|
6632
6676
|
if (data && (elems == null ? void 0 : elems.length) === 1 && moveOriginalStartElementSize && originalStart && end && ((_b = (_a = elems[0]) == null ? void 0 : _a.operations) == null ? void 0 : _b.locked) !== true) {
|
|
6633
6677
|
const { moveX, moveY } = calcMoveInGroup(originalStart, end, groupQueue);
|
|
@@ -6671,6 +6715,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6671
6715
|
}
|
|
6672
6716
|
viewer.drawFrame();
|
|
6673
6717
|
} else if (actionType === "drag-list") {
|
|
6718
|
+
hasChangedData = true;
|
|
6674
6719
|
inBusyMode = "drag-list";
|
|
6675
6720
|
if (data && originalStart && start && end && (elems == null ? void 0 : elems.length) > 1) {
|
|
6676
6721
|
const moveX = (end.x - start.x) / scale;
|
|
@@ -6698,6 +6743,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6698
6743
|
viewer.drawFrame();
|
|
6699
6744
|
} else if (actionType === "resize") {
|
|
6700
6745
|
if (data && (elems == null ? void 0 : elems.length) === 1 && originalStart && moveOriginalStartElementSize && (resizeType == null ? void 0 : resizeType.startsWith("resize-"))) {
|
|
6746
|
+
hasChangedData = true;
|
|
6701
6747
|
inBusyMode = "resize";
|
|
6702
6748
|
const pointGroupQueue = [];
|
|
6703
6749
|
groupQueue.forEach((group) => {
|
|
@@ -6838,7 +6884,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
6838
6884
|
}
|
|
6839
6885
|
if (data && ["drag", "drag-list", "drag-list-end", "resize"].includes(actionType)) {
|
|
6840
6886
|
let type = "dragElement";
|
|
6841
|
-
|
|
6887
|
+
if (hasChangedData) {
|
|
6888
|
+
eventHub.trigger(coreEventKeys.CHANGE, { data, type, selectedElements, hoverElement });
|
|
6889
|
+
hasChangedData = false;
|
|
6890
|
+
}
|
|
6842
6891
|
}
|
|
6843
6892
|
viewer.drawFrame();
|
|
6844
6893
|
};
|
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawCore=function(e){"use strict";var t,i,o,n,a,r,l,s,h,c,d,f,u,g,v,m,w,y,p,x,S=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},b=(e,t,i)=>(S(e,t,"read from private field"),i?i.call(e):t.get(e)),I=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},A=(e,t,i,o)=>(S(e,t,"write to private field"),o?o.call(e,i):t.set(e,i),i),M=(e,t,i)=>(S(e,t,"access private method"),i);function R(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function T(e,t){if(1===t)return e;let i=1;const o=/^\#[0-9a-f]{6,6}$/i;let n=e;if(o.test(e)?i=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(i=parseInt(e.substring(7,9).replace(/^\#/,"0x")),n=e.substring(0,7)),i*=t,o.test(n)&&i>0&&i<1){const e=Math.max(0,Math.min(255,Math.ceil(256*i)));n=`${n.toUpperCase()}${e.toString(16).toUpperCase()}`}return n}function z(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function P(e){let t=0;for(let i=0;i<e.length;i++)t+=e.charCodeAt(i)*e.charCodeAt(i)*i*i;return t.toString(16).substring(0,4)}function C(e){const t=e.length,i=Math.floor(t/2),o=e.substring(0,4).padEnd(4,"0"),n=e.substring(0,4).padEnd(4,"0");return`@assets/${P(t.toString(16).padEnd(4,o))}${P(e.substring(i-4,i).padEnd(4,o)).padEnd(4,"f")}-${P(e.substring(i-8,i-4).padEnd(4,o)).padEnd(4,"f")}-${P(e.substring(i-12,i-8).padEnd(4,o)).padEnd(4,"f")}-${P(e.substring(i-16,i-12).padEnd(4,n)).padEnd(4,"f")}-${P(e.substring(i,i+4).padEnd(4,n)).padEnd(4,"f")}${P(e.substring(i+4,i+8).padEnd(4,n)).padEnd(4,"f")}${P(n.padEnd(4,o).padEnd(4,n))}`}function E(e){return function e(t){const i=function(e){return Object.prototype.toString.call(e).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(t);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return t;if("Array"===i){const i=[];return t.forEach((t=>{i.push(e(t))})),i}if("Object"===i){const i={};Object.keys(t).forEach((o=>{i[o]=e(t[o])}));return Object.getOwnPropertySymbols(t).forEach((o=>{i[o]=e(t[o])})),i}}(e)}function W(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const k={type(e,t){const i=W(e);return!0===t?i.toLocaleLowerCase():i},array:e=>"Array"===W(e),json:e=>"Object"===W(e),function:e=>"Function"===W(e),asyncFunction:e=>"AsyncFunction"===W(e),boolean:e=>"Boolean"===W(e),string:e=>"String"===W(e),number:e=>"Number"===W(e),undefined:e=>"Undefined"===W(e),null:e=>"Null"===W(e),promise:e=>"Promise"===W(e)};var L=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))};const{Image:O}=window;function j(e){return new Promise(((t,i)=>{const o=new O;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function D(e){return L(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,i)=>{const o=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n=new FileReader;n.readAsDataURL(o),n.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},n.onerror=function(e){i(e)}}))}(e);return yield j(t)}))}function Y(e,t){return L(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&");const i=yield function(e,t){const{width:i,height:o}=t;return new Promise(((t,n)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${o||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},r.onerror=function(e){n(e)}}))}(e,t);return yield j(i)}))}function V(e){return"number"==typeof e&&(e>0||e<=0)}function B(e){return"number"==typeof e&&e>=0}function G(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function X(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const N={x:function(e){return V(e)},y:function(e){return V(e)},w:B,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:V,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return B(e)},borderRadius:function(e){return V(e)&&e>=0},color:function(e){return R(e)},imageSrc:function(e){return X(e)||G(e)},imageURL:G,imageBase64:X,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let i=document.createElement("div");i.innerHTML=e,i.children.length>0&&(t=!0),i=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return V(e)&&e>0},lineHeight:function(e){return V(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return V(e)&&e>0}};var F,H,Z=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Q=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class U{constructor(e,t){F.set(this,void 0),H.set(this,void 0),Z(this,F,e,"f"),Z(this,H,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f"),this.$resetFont()}$undoPixelRatio(e){return e/Q(this,H,"f").devicePixelRatio}$doPixelRatio(e){return Q(this,H,"f").devicePixelRatio*e}$getContext(){return Q(this,F,"f")}$setContext(e){Z(this,F,e,"f")}$setFont(e){const t=[];e.fontWeight&&t.push(`${e.fontWeight}`),t.push(`${this.$doPixelRatio(e.fontSize||12)}px`),t.push(`${e.fontFamily||"sans-serif"}`),Q(this,F,"f").font=`${t.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return Q(this,H,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:a}=Q(this,F,"f");a.width=t*o,a.height=i*o,Z(this,H,Object.assign(Object.assign({},Q(this,H,"f")),{devicePixelRatio:o}),"f"),!0===n&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=Q(this,H,"f"),{width:t,height:i}=Q(this,F,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return Q(this,F,"f").canvas}get fillStyle(){return Q(this,F,"f").fillStyle}set fillStyle(e){Q(this,F,"f").fillStyle=e}get strokeStyle(){return Q(this,F,"f").strokeStyle}set strokeStyle(e){Q(this,F,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(Q(this,F,"f").lineWidth)}set lineWidth(e){Q(this,F,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return Q(this,F,"f").textAlign}set textAlign(e){Q(this,F,"f").textAlign=e}get textBaseline(){return Q(this,F,"f").textBaseline}set textBaseline(e){Q(this,F,"f").textBaseline=e}get globalAlpha(){return Q(this,F,"f").globalAlpha}set globalAlpha(e){Q(this,F,"f").globalAlpha=e}get shadowColor(){return Q(this,F,"f").shadowColor}set shadowColor(e){Q(this,F,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(Q(this,F,"f").shadowOffsetX)}set shadowOffsetX(e){Q(this,F,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(Q(this,F,"f").shadowOffsetY)}set shadowOffsetY(e){Q(this,F,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(Q(this,F,"f").shadowBlur)}set shadowBlur(e){Q(this,F,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return Q(this,F,"f").lineCap}set lineCap(e){Q(this,F,"f").lineCap=e}get globalCompositeOperation(){return Q(this,F,"f").globalCompositeOperation}set globalCompositeOperation(e){Q(this,F,"f").globalCompositeOperation=e}fill(...e){return Q(this,F,"f").fill(...e)}arc(e,t,i,o,n,a){return Q(this,F,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,a)}rect(e,t,i,o){return Q(this,F,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return Q(this,F,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return Q(this,F,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return Q(this,F,"f").beginPath()}closePath(){return Q(this,F,"f").closePath()}lineTo(e,t){return Q(this,F,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return Q(this,F,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return Q(this,F,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}getLineDash(){return Q(this,F,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return Q(this,F,"f").setLineDash(t)}stroke(e){return e?Q(this,F,"f").stroke(e):Q(this,F,"f").stroke()}translate(e,t){return Q(this,F,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return Q(this,F,"f").rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],n=e[3],a=e[4],r=e[e.length-4],l=e[e.length-3],s=e[e.length-2],h=e[e.length-1];return 9===e.length?Q(this,F,"f").drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h)):Q(this,F,"f").drawImage(t,this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h))}createPattern(e,t){return Q(this,F,"f").createPattern(e,t)}measureText(e){return Q(this,F,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?Q(this,F,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):Q(this,F,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?Q(this,F,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):Q(this,F,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){Q(this,F,"f").save()}restore(){Q(this,F,"f").restore()}scale(e,t){Q(this,F,"f").scale(e,t)}circle(e,t,i,o,n,a,r,l){Q(this,F,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,a,r,l)}isPointInPath(e,t){return Q(this,F,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return Q(this,F,"f").clip(...e)}setTransform(e,t,i,o,n,a){return Q(this,F,"f").setTransform(e,t,i,o,n,a)}getTransform(){return Q(this,F,"f").getTransform()}createLinearGradient(e,t,i,o){return Q(this,F,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,a){return Q(this,F,"f").createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a))}createConicGradient(e,t,i){return Q(this,F,"f").createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function J(e){const{width:t,height:i,ctx:o,devicePixelRatio:n}=e;let a=o;if(!a){const e=document.createElement("canvas");e.width=t*n,e.height=i*n,a=e.getContext("2d")}return new U(a,e)}function $(e){const{width:t,height:i,devicePixelRatio:o}=e,n=new OffscreenCanvas(t*o,i*o),a=n.getContext("2d").canvas.getContext("2d");return new U(a,{devicePixelRatio:o,offscreenCanvas:n})}F=new WeakMap,H=new WeakMap;var K,q=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class _{constructor(){K.set(this,void 0),function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(e,i):n?n.value=i:t.set(e,i)}(this,K,new Map,"f")}on(e,t){if(q(this,K,"f").has(e)){const i=q(this,K,"f").get(e)||[];null==i||i.push(t),q(this,K,"f").set(e,i)}else q(this,K,"f").set(e,[t])}off(e,t){if(q(this,K,"f").has(e)){const i=q(this,K,"f").get(e);if(Array.isArray(i))for(let e=0;e<(null==i?void 0:i.length);e++)if(i[e]===t){i.splice(e,1);break}q(this,K,"f").set(e,i||[])}}trigger(e,t){const i=q(this,K,"f").get(e);return!!Array.isArray(i)&&(i.forEach((e=>{e(t)})),!0)}has(e){if(q(this,K,"f").has(e)){const t=q(this,K,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){q(this,K,"f").clear()}}function ee(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}K=new WeakMap;var te,ie,oe,ne,ae=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},re=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class le{constructor(e){te.add(this),ie.set(this,void 0),oe.set(this,void 0),ae(this,oe,E(e.defaultStorage),"f"),ae(this,ie,re(this,te,"m",ne).call(this),"f")}set(e,t){re(this,ie,"f")[e]=t}get(e){return re(this,ie,"f")[e]}getSnapshot(e){return!0===(null==e?void 0:e.deepClone)?E(re(this,ie,"f")):Object.assign({},re(this,ie,"f"))}clear(){ae(this,ie,re(this,te,"m",ne).call(this),"f")}destroy(){ae(this,ie,null,"f")}}function se(e){const{activeStore:t}=e;return{scale:null==t?void 0:t.scale,offsetTop:null==t?void 0:t.offsetTop,offsetBottom:null==t?void 0:t.offsetBottom,offsetLeft:null==t?void 0:t.offsetLeft,offsetRight:null==t?void 0:t.offsetRight}}function he(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:null==t?void 0:t.width,height:null==t?void 0:t.height,contextWidth:null==t?void 0:t.contextWidth,contextHeight:null==t?void 0:t.contextHeight}}function ce(e){return e/180*Math.PI}function de(e,t,i,o){const n=ce(t||0);i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(n),e.translate(-i.x,-i.y)),o(e),i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(-n),e.translate(-i.x,-i.y))}function fe(e,t,i){const o=ue(t);de(e,t.angle||0,o,(()=>{i(e)}))}function ue(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function ge(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),i=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return ue({x:t,y:i,w:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,h:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-i})}function ve(e,t){const i=t.x-e.x,o=t.y-e.y;if(0===i){if(o<0)return 0;if(o>0)return Math.PI}else if(0===o){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&o<0?Math.atan(Math.abs(i)/Math.abs(o)):i>0&&o>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):0}function me(e,t,i){let o=ve(e,t)+i;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const n=function(e,t){const i=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y);return 0===i?i:Math.sqrt(i)}(e,t);let a=0,r=0;return 0===o?(a=0,r=0-n):o>0&&o<Math.PI/2?(a=Math.sin(o)*n,r=0-Math.cos(o)*n):o===Math.PI/2?(a=n,r=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*n,r=Math.cos(Math.PI-o)*n):o===Math.PI?(a=0,r=n):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*n,r=Math.cos(o-Math.PI)*n):o===1.5*Math.PI?(a=0-n,r=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*n,r=0-Math.cos(2*Math.PI-o)*n):o===2*Math.PI&&(a=0,r=0-n),a+=e.x,r+=e.y,{x:a,y:r}}function we(e,t){if((null==t?void 0:t.length)>0){let i=e.x,o=e.y;return t.forEach((e=>{const{x:t,y:n,w:a,h:r,angle:l=0}=e,s=me(ue({x:t,y:n,w:a,h:r,angle:l}),{x:i,y:o},ce(l));i=s.x,o=s.y})),{x:i,y:o}}return e}function ye(e,t,i){const{x:o,y:n,w:a,h:r}=e;let l={x:o,y:n},s={x:o+a,y:n},h={x:o+a,y:n+r},c={x:o,y:n+r};if(i&&(i>0||i<0)){const e=ce(Se(i));l=me(t,l,e),s=me(t,s,e),h=me(t,h,e),c=me(t,c,e)}return[l,s,h,c]}function pe(e){const{angle:t=0}=e;return ye(e,ue(e),t)}function xe(e,t,i){return[me(e,{x:t[0].x,y:t[0].y},i),me(e,{x:t[1].x,y:t[1].y},i),me(e,{x:t[2].x,y:t[2].y},i),me(e,{x:t[3].x,y:t[3].y},i)]}function Se(e){if(!(e>0||e<0)||0===e)return 0;let t=e%360;return t<0&&(t+=360),t}function be(e){let t=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(t=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(t=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(t=be(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.children))}))}return t}function Ie(e,t){const i={x:0,y:0,w:0,h:0};e.forEach((e=>{const t={x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=pe(t);if(4===e.length){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...i),t.y=Math.min(...o),t.w=Math.abs(Math.max(...i)-Math.min(...i)),t.h=Math.abs(Math.max(...o)-Math.min(...o))}}const o=Math.min(t.x,i.x),n=Math.min(t.y,i.y),a=Math.max(t.x+t.w,i.x+i.w),r=Math.max(t.y+t.h,i.y+i.h);i.x=o,i.y=n,i.w=Math.abs(a-o),i.h=Math.abs(r-n)})),(null==t?void 0:t.extend)&&(i.x=Math.min(i.x,0),i.y=Math.min(i.y,0));const o={contextWidth:i.w,contextHeight:i.h};return(null==t?void 0:t.viewWidth)&&(null==t?void 0:t.viewHeight)&&(null==t?void 0:t.viewWidth)>0&&(null==t?void 0:t.viewHeight)>0&&(t.viewWidth>i.x+i.w&&(o.contextWidth=t.viewWidth-i.x),t.viewHeight>i.y+i.h&&(o.contextHeight=t.viewHeight-i.y)),o}function Ae(e,t){var i;const o=[];let n=e;if(t.length>1)for(let e=0;e<t.length-1;e++){const a=n[t[e]];if("group"!==(null==a?void 0:a.type)||!Array.isArray(null===(i=null==a?void 0:a.detail)||void 0===i?void 0:i.children))return null;o.push(a),n=a.detail.children}return o}function Me(e){const{x:t,y:i,w:o,h:n,angle:a}=e;return{x:t,y:i,w:o,h:n,angle:a}}function Re(e,t){let i=null,o=t;for(let t=0;t<e.length;t++){const n=o[e[t]];if(t<e.length-1&&"group"===n.type)o=n.detail.children;else{if(t!==e.length-1)break;i=n}}return i}function Te(e,t){const i=[];let o=!1;const n=t=>{var a;for(let r=0;r<t.length&&!0!==o;r++){i.push(r);const l=t[r];if(l.uuid===e){o=!0;break}if("group"===l.type&&n((null===(a=null==l?void 0:l.detail)||void 0===a?void 0:a.children)||[]),o)break;i.pop()}};return n(t),i}function ze(e){const{x:t,y:i,h:o,w:n}=e;return[{x:t,y:i},{x:t+n,y:i},{x:t+n,y:i+o},{x:t,y:i+o}]}function Pe(e){const{x:t,y:i,w:o,h:n,angle:a=0}=e;return 0===a?ze(e):ye(e,ue({x:t,y:i,w:o,h:n,angle:a}),a)}function Ce(e){const t=[];let i=0,o=0;const n=[],a=[...e];for(let e=0;e<a.length;e++){const{x:r,y:l,w:s,h:h,angle:c=0}=a[e];let d;if(i+=r,o+=l,0===e){const e={x:i,y:o,w:s,h:h,angle:c};d=Pe({x:r,y:l,w:s,h:h,angle:c}),n.push({center:ue(e),angle:c,radian:ce(c)})}else{d=ze({x:i,y:o,w:s,h:h,angle:c});for(let e=0;e<n.length;e++){const{center:t,radian:i}=n[e];d=xe(t,d,i)}const e=ge(d);if(c>0||c<0){d=xe(e,d,ce(c))}n.push({center:e,angle:c,radian:ce(c)})}t.push(d)}return t}function Ee(e,t){const i=function(e,t){const{groupQueue:i}=t;return i.length>0?Ce([...i,e]):[Pe(e)]}(e,t);return i.pop()||null}function We(e,t){const{viewScaleInfo:i}=t,{x:o,y:n,w:a,h:r,angle:l}=e,{scale:s,offsetTop:h,offsetLeft:c}=i;return{x:o*s+c,y:n*s+h,w:a*s,h:r*s,angle:l}}function ke(e,t){const{viewScaleInfo:i}=t,{x:o,y:n}=e,{scale:a,offsetTop:r,offsetLeft:l}=i;return{x:o*a+l,y:n*a+r}}function Le(e,t){return[ke(e[0],t),ke(e[1],t),ke(e[2],t),ke(e[3],t)]}function Oe(e,t){const{context2d:i,element:o,viewScaleInfo:n}=t,{angle:a=0}=o,{x:r,y:l,w:s,h:h}=We(o,{viewScaleInfo:n}),c=pe({x:r,y:l,w:s,h:h,angle:a});if(c.length>=2){i.beginPath(),i.moveTo(c[0].x,c[0].y);for(let e=1;e<c.length;e++)i.lineTo(c[e].x,c[e].y);i.closePath()}return!!i.isPointInPath(e.x,e.y)}function je(e,t,i){const o=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y],a=Math.min(...o),r=Math.max(...o),l=Math.min(...n),s=Math.max(...n);return e.x>a&&e.x<r&&e.y>l&&e.y<s}function De(e,t){const{groupQueue:i}=t,o=Ee(e,{groupQueue:i}),n=ee(o[0],o[1]),a=ee(o[1],o[2]),r=ee(o[2],o[3]),l=ee(o[3],o[0]),s=o[0],h=o[1],c=o[2],d=o[3],f=Math.max(s.x,h.x,c.x,d.x),u=Math.max(s.y,h.y,c.y,d.y);return{center:{x:(f+Math.min(s.x,h.x,c.x,d.x))/2,y:(u+Math.min(s.y,h.y,c.y,d.y))/2},topLeft:s,topRight:h,bottomLeft:d,bottomRight:c,top:n,right:a,left:l,bottom:r}}function Ye(e){const t=Math.max(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),i=Math.max(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),o=Math.min(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),a={x:e.center.x,y:e.center.y},r={x:o,y:n},l={x:t,y:n},s={x:t,y:i},h={x:o,y:i},c=ee(r,l),d=ee(h,s),f=ee(r,h);return{center:a,topLeft:r,topRight:l,bottomLeft:h,bottomRight:s,top:c,right:ee(l,s),left:f,bottom:d}}function Ve(e,t){const i=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n,offsetLeft:a}=t,{width:r,height:l}=i,s=0-a/o,h=0-n/o,c=r/o,d=l/o,f=ue({x:s,y:h,w:c,h:d}),u={x:s,y:h},g={x:s+c,y:h},v={x:s,y:h+d},m={x:s+c,y:h+d},w={x:s,y:f.y},y={x:f.x,y:h},p={x:s+c,y:f.y},x={x:f.x,y:h+d};return{center:f,topLeft:u,topRight:g,bottomLeft:v,bottomRight:m,left:w,top:y,right:p,bottom:x}}(t);let o=0,n=0;return Object.keys(e).forEach((t=>{const a=e[t];a.isVisibleInView=function(e,t){const i=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),o=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),a=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),r=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),l=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),s=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),h=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y);return i<=l&&o>=r&&n<=h&&a>=s||l<=a&&l>=a&&l<=a&&l>=a}(a.rangeRectInfo,i),a.isVisibleInView?o++:n++})),{viewVisibleInfoMap:e,visibleCount:o,invisibleCount:n}}function Be(e,t){const{x:i,y:o}=e,{size:n,angle:a}=t;return{x:i-n/2,y:o-n/2,w:n,h:n,angle:a}}function Ge(e,t){const{groupQueue:i,controllerSize:o,viewScaleInfo:n}=t,a=(o&&o>0?o:8)/n.scale,{x:r,y:l,w:s,h:h,angle:c=0}=e,d=[{uuid:z(),x:r,y:l,w:s,h:h,angle:c,type:"group",detail:{children:[]}},...i];let f=0;d.forEach((({angle:e=0})=>{f+=e}));const u=Ee(e,{groupQueue:i}),g=Ee({x:r-2*a,y:l-2*a,h:h+4*a,w:s+4*a,angle:c},{groupQueue:[...i]}),v=ee(u[0],u[1]),m=ee(u[1],u[2]),w=ee(u[2],u[3]),y=ee(u[3],u[0]),p=u[0],x=u[1],S=u[2],b=u[3],I=Be(v,{size:a,angle:f}),A=Be(m,{size:a,angle:f}),M=Be(w,{size:a,angle:f}),R=Be(y,{size:a,angle:f}),T=Be(p,{size:a,angle:f}),P=Be(x,{size:a,angle:f}),C=Be(b,{size:a,angle:f}),E=Be(S,{size:a,angle:f}),W=Pe(T),k=Pe(P),L=Pe(C),O=Pe(E),j=[W[1],k[0],k[3],W[2]],D=[k[3],k[2],O[1],O[0]],Y=[L[1],O[0],O[3],L[2]],V=[W[3],W[2],L[1],L[0]],B=Pe(I),G=Pe(A),X=Pe(M),N=Pe(R),F=ee(g[0],g[1]);return{elementWrapper:u,left:{type:"left",vertexes:V,center:y},right:{type:"right",vertexes:D,center:m},top:{type:"top",vertexes:j,center:v},bottom:{type:"bottom",vertexes:Y,center:w},topLeft:{type:"top-left",vertexes:W,center:p},topRight:{type:"top-right",vertexes:k,center:x},bottomLeft:{type:"bottom-left",vertexes:L,center:b},bottomRight:{type:"bottom-right",vertexes:O,center:S},leftMiddle:{type:"left-middle",vertexes:N,center:y},rightMiddle:{type:"right-middle",vertexes:G,center:m},topMiddle:{type:"top-middle",vertexes:B,center:v},bottomMiddle:{type:"bottom-middle",vertexes:X,center:w},rotate:{type:"rotate",vertexes:Pe(Be(F,{size:a,angle:f})),center:F}}}function Xe(e,t){const{controllerSize:i,viewScaleInfo:o}=t,n=i&&i>0?i:8,{x:a,y:r,w:l,h:s}=We(e,{viewScaleInfo:o}),h=ue({x:a,y:r,w:l,h:s}),c={x:h.x,y:r},d={x:a+l,y:h.y},f={x:h.x,y:r+s},u={x:a,y:h.y},g={x:a,y:r},v={x:a+l,y:r},m={x:a+l,y:r+s},w={x:a,y:r+s},y=Be(c,{size:n,angle:0}),p=Be(d,{size:n,angle:0}),x=Be(f,{size:n,angle:0}),S=Be(u,{size:n,angle:0}),b=Be(g,{size:n,angle:0}),I=Be(v,{size:n,angle:0}),A=Be(w,{size:n,angle:0}),M=Be(m,{size:n,angle:0}),R=Pe(b),T=Pe(I),z=Pe(A),P=Pe(M),C=[R[1],T[0],T[3],R[2]],E=[T[3],T[2],P[1],P[0]],W=[z[1],P[0],P[3],z[2]],k=[R[3],R[2],z[1],z[0]],L=Pe(y),O=Pe(p),j=Pe(x);return{left:{type:"left",vertexes:k,center:u},right:{type:"right",vertexes:E,center:d},top:{type:"top",vertexes:C,center:c},bottom:{type:"bottom",vertexes:W,center:f},topLeft:{type:"top-left",vertexes:R,center:g},topRight:{type:"top-right",vertexes:T,center:v},bottomLeft:{type:"bottom-left",vertexes:z,center:w},bottomRight:{type:"bottom-right",vertexes:P,center:m},leftMiddle:{type:"left-middle",vertexes:Pe(S),center:u},rightMiddle:{type:"right-middle",vertexes:O,center:d},topMiddle:{type:"top-middle",vertexes:L,center:c},bottomMiddle:{type:"bottom-middle",vertexes:j,center:f}}}function Ne(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}function Fe(e,t){let i=2;return void 0!==(null==t?void 0:t.decimalPlaces)&&(null==t?void 0:t.decimalPlaces)>=0&&(i=t.decimalPlaces),parseFloat(e.toFixed(i))}ie=new WeakMap,oe=new WeakMap,te=new WeakSet,ne=function(){return E(re(this,oe,"f"))};const He={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function Ze(e,t){const{viewScaleInfo:i}=t,{scale:o}=i;let{borderRadius:n,borderDash:a}=e.detail;const r=Array.isArray(a)&&a.length>0,{boxSizing:l=He.boxSizing,borderWidth:s}=e.detail;Array.isArray(s)&&(n=0);let{x:h,y:c,w:d,h:f}=e,u=[0,0,0,0];if("number"==typeof n){const e=n*o;u=[e,e,e,e]}else Array.isArray(n)&&4===(null==n?void 0:n.length)&&(u=[n[0]*o,n[1]*o,n[2]*o,n[3]*o]);let g=0;return"number"==typeof s&&(g=(s||0)*o),"border-box"!==l||r?"content-box"===l?(h=e.x-g/2,c=e.y-g/2,d=e.w+g,f=e.h+g):(h=e.x,c=e.y,d=e.w,f=e.h):(h=e.x+g/2,c=e.y+g/2,d=e.w-g,f=e.h-g),d=Math.max(d,1),f=Math.max(f,1),u=u.map((e=>Math.min(e,d/2,f/2))),{x:h,y:c,w:d,h:f,radiusList:u}}const Qe=e=>Fe(e,{decimalPlaces:4});function Ue(e,t){const{detail:i}=e,{xRatio:o,yRatio:n,maxRatio:a}=t,r=(o+n)/2,{borderWidth:l,borderRadius:s,borderDash:h,shadowOffsetX:c,shadowOffsetY:d,shadowBlur:f}=i;if("number"==typeof l)i.borderWidth=Qe(l*r);else if(Array.isArray(i.borderWidth)){const e=l;i.borderWidth=[Qe(e[0]*n),Qe(e[1]*o),Qe(e[2]*n),Qe(e[3]*o)]}if("number"==typeof s)i.borderRadius=Qe(s*r);else if(Array.isArray(i.borderRadius)){const e=s;i.borderRadius=[e[0]*o,e[1]*o,e[2]*n,e[3]*n]}Array.isArray(h)&&h.forEach(((e,t)=>{i.borderDash[t]=Qe(e*a)})),"number"==typeof c&&(i.shadowOffsetX=Qe(c*a)),"number"==typeof d&&(i.shadowOffsetX=Qe(d*a)),"number"==typeof f&&(i.shadowOffsetX=Qe(f*a))}function Je(e,t){const{type:i}=e;!function(e,t){const{xRatio:i,yRatio:o}=t,{x:n,y:a,w:r,h:l}=e;e.x=Qe(n*i),e.y=Qe(a*o),e.w=Qe(r*i),e.h=Qe(l*o),Ue(e,t)}(e,t),"circle"===i||("text"===i?function(e,t){const{minRatio:i,maxRatio:o}=t,{fontSize:n,lineHeight:a}=e.detail,r=(i+o)/2;n&&n>0&&(e.detail.fontSize=Qe(n*r)),a&&a>0&&(e.detail.lineHeight=Qe(a*r))}(e,t):"image"===i||"svg"===i||"html"===i||"path"===i||"group"===i&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Je(e,t)})))}const $e=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function Ke(e){return[e,...$e].join(", ")}function qe(e,t,i){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:n,opacity:a=1}=i,{x:r,y:l}=o,{scale:s}=n;if("linear-gradient"===(null==t?void 0:t.type)){const{start:i,end:o,stops:n}=t,h={x:r+i.x*s,y:l+i.y*s},c={x:r+o.x*s,y:l+o.y*s},d=e.createLinearGradient(h.x,h.y,c.x,c.y);return n.forEach((e=>{d.addColorStop(e.offset,T(e.color,a))})),d}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:i,outer:o,stops:n}=t,h={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},c={x:r+o.x*s,y:l+o.y*s,radius:o.radius*s},d=e.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return n.forEach((e=>{d.addColorStop(e.offset,T(e.color,a))})),d}return"#000000"}const _e={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function et(e){var t,i,o,n;let a=1;return void 0!==(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.opacity)&&(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.opacity)>=0&&(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.opacity)<=1&&(a=null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.opacity),a}function tt(e,t,i){const{pattern:o,renderContent:n,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=i||{},{parentOpacity:h}=i,c=et(a)*h,{clipPath:d,clipPathStrokeColor:f,clipPathStrokeWidth:u}=a.detail,g=()=>{e.globalAlpha=c,it(e,t,{pattern:o,viewScaleInfo:l,viewSizeInfo:s}),null==n||n(),ot(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=h};d?(function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewSizeInfo:r}=i,l=r.devicePixelRatio,{clipPath:s}=(null==n?void 0:n.detail)||{};if(s&&a&&s.commands){const{x:i,y:n,w:r,h:h}=a,{originW:c,originH:d,originX:f,originY:u}=s,g=r/c,v=h/d,m=i-f*g,w=n-u*v;e.save(),e.translate(m,w),e.scale(l*g,l*v);const y=Ne(s.commands||[]),p=new Path2D(y);e.clip(p),e.translate(0-m,0-w),e.setTransform(1,0,0,1,0,0),fe(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{g()}}),"number"==typeof u&&u>0&&f&&function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewSizeInfo:r,parentOpacity:l}=i,s=r.devicePixelRatio,{clipPath:h,clipPathStrokeColor:c,clipPathStrokeWidth:d}=(null==n?void 0:n.detail)||{};if(h&&a&&h.commands&&"number"==typeof d&&d>0&&c){const{x:i,y:n,w:r,h:f}=a,{originW:u,originH:g,originX:v,originY:m}=h,w=r/u,y=f/g,p=i-v*w,x=n-m*y;e.save(),e.globalAlpha=l,e.translate(p,x),e.scale(s*w,s*y);const S=Ne(h.commands||[]),b=new Path2D(S);e.strokeStyle=c,e.lineWidth=d,e.stroke(b),e.translate(0-p,0-x),e.setTransform(1,0,0,1,0,0),fe(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,parentOpacity:h})):g()}function it(e,t,i){var o,n;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=i,s=[];if(t.detail.background||a){const{x:i,y:h,w:c,h:d,radiusList:f}=Ze(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(i+f[0],h),e.arcTo(i+c,h,i+c,h+d,f[1]),e.arcTo(i+c,h+d,i,h+d,f[2]),e.arcTo(i,h+d,i,h,f[3]),e.arcTo(i,h,i+c,h,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(k.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null===(o=t.detail.background)||void 0===o?void 0:o.type)){const o=qe(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=o}else if("radial-gradient"===(null===(n=t.detail.background)||void 0===n?void 0:n.type)){const o=qe(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=o,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const o=s[t];"translate"===o.method?e.translate(o.args[0]+i,o.args[1]+h):"rotate"===o.method?e.rotate(...o.args):"scale"===o.method&&e.scale(...o.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function ot(e,t,i){if(0===t.detail.borderWidth)return;if(!R(t.detail.borderColor))return;const{viewScaleInfo:o}=i,{scale:n}=o;let a=_e.borderColor;!0===R(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:h=_e.boxSizing}=t.detail;let c=0;"number"==typeof r&&(c=r||1),c*=n;let d=[0,0,0,0];if("number"==typeof l){const e=l*n;d=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(d=[l[0]*n,l[1]*n,l[2]*n,l[3]*n]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*n))));let u=0,g=0,v=0,m=0;if(Array.isArray(r)&&(u=(r[0]||0)*n,g=(r[1]||0)*n,v=(r[2]||0)*n,m=(r[3]||0)*n),m||g||u||v){e.lineCap="butt";let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i+=m/2,o+=u/2,n=n-m/2-g/2,a=a-u/2-v/2):"content-box"===h?(i-=m/2,o-=u/2,n=n+m/2+g/2,a=a+u/2+v/2):(i=t.x,o=t.y,n=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(i-m/2,o),e.lineTo(i+n+g/2,o),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(i+n,o-u/2),e.lineTo(i+n,o+a+v/2),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(i-m/2,o+a),e.lineTo(i+n+g/2,o+a),e.closePath(),e.stroke()),m&&(e.beginPath(),e.lineWidth=m,e.moveTo(i,o-u/2),e.lineTo(i,o+a+v/2),e.closePath(),e.stroke())}else{let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i=t.x+c/2,o=t.y+c/2,n=t.w-c,a=t.h-c):"content-box"===h?(i=t.x-c/2,o=t.y-c/2,n=t.w+c,a=t.h+c):(i=t.x,o=t.y,n=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",n=Math.max(n,1),a=Math.max(a,1),d=d.map((e=>Math.min(e,n/2,a/2))),e.setLineDash(f),e.lineWidth=c,e.beginPath(),e.moveTo(i+d[0],o),e.arcTo(i+n,o,i+n,o+a,d[1]),e.arcTo(i+n,o+a,i,o+a,d[2]),e.arcTo(i,o+a,i,o,d[3]),e.arcTo(i,o,i+n,o,d[0]),e.closePath(),e.stroke()}e.setLineDash([])}function nt(e,t,i){const{detail:o}=t,{viewScaleInfo:n,renderContent:a}=i,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:h}=o;N.number(h)?(e.save(),e.shadowColor=r||_e.shadowColor,e.shadowOffsetX=(l||0)*n.scale,e.shadowOffsetY=(s||0)*n.scale,e.shadowBlur=(h||0)*n.scale,a(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,a(),e.restore())}const at={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};var rt=function(e,t){var i={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(i[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(i[o[n]]=e[o[n]])}return i};const lt=.4;function st(e,t,i){var o,n,a;if(!0===(null===(o=null==t?void 0:t.operations)||void 0===o?void 0:o.invisible))return;const{w:r,h:l}=t,{scale:s}=i.viewScaleInfo;if(s<1&&(r*s<lt||l*s<lt)||0===i.parentOpacity)return;const{overrideElementMap:h}=i;if(!(null===(a=null===(n=null==h?void 0:h[t.uuid])||void 0===n?void 0:n.operations)||void 0===a?void 0:a.invisible))try{switch(t.type){case"rect":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=We(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});fe(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{nt(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{tt(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,renderContent:()=>{}})}})}))}(e,t,i);break;case"circle":!function(e,t,i){const{detail:o,angle:n}=t,{viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=i,{background:s="#000000",borderColor:h="#000000",boxSizing:c,borderWidth:d=0,borderDash:f}=o;let u=0;"number"==typeof d&&d>0?u=d:Array.isArray(d)&&"number"==typeof d[0]&&d[0]>0&&(u=d[0]),u*=a.scale;const{x:g,y:v,w:m,h:w}=We({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:a})||t,y=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:w,angle:n});fe(e,{x:g,y:v,w:m,h:w,angle:n},(()=>{nt(e,y,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{let t=m/2,i=w/2;const o=g+t,n=v+i,r=t,d=i;if(u>0&&("content-box"===c||("center-line"===c?(t-=u/2,i-=u/2):(t-=u,i-=u))),t>=0&&i>=0){const c=et(y)*l;e.globalAlpha=c,e.beginPath();const p=qe(e,s,{viewElementSize:{x:g,y:v,w:m,h:w},viewScaleInfo:a,opacity:e.globalAlpha});if(e.fillStyle=p,e.circle(o,n,r,d,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=l,"number"==typeof u&&u>0){const r=u/2+t,l=u/2+i;if(e.beginPath(),f){const t=f.map((e=>e*a.scale));e.setLineDash(t)}e.strokeStyle=h,e.lineWidth=u,e.circle(o,n,r,l,0,0,2*Math.PI),e.closePath(),e.stroke(),e.setLineDash([])}}}})}))}(e,t,i);break;case"text":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=We(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});fe(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{nt(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{tt(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a})}});{const i=Object.assign(Object.assign({},at),t.detail),n=i.fontSize||at.fontSize,a=n*o.scale;if(a<2)return;const c=(i.lineHeight||n)*o.scale;e.fillStyle=t.detail.color||at.color,e.textBaseline="top",e.$setFont({fontWeight:i.fontWeight,fontSize:a,fontFamily:Ke(i.fontFamily)});let d=i.text.replace(/\r\n/gi,"\n");"lowercase"===i.textTransform?d=d.toLowerCase():"uppercase"===i.textTransform&&(d=d.toUpperCase());const f=c,u=d.split("\n"),g=[];let v=0;u.forEach(((t,n)=>{if("maxContent"===i.minInlineSize)g.push({text:t,width:e.$undoPixelRatio(e.measureText(t).width)});else{let l="",c="",d=t.split(c);if("normal"===i.wordBreak){const e=" ",i=t.split(e);d=[],i.forEach(((t,o)=>{d.push(t),o<i.length-1&&d.push(e)}))}if(1===d.length&&"visible"===i.overflow)g.push({text:d[0],width:e.$undoPixelRatio(e.measureText(d[0]).width)});else if(d.length>0){for(let t=0;t<d.length&&(a=e.$doPixelRatio(s),r=e.measureText(l+d[t]).width,o.scale<.5&&a<r&&(a-r)/a>-.15||a>=r?l+=d[t]||"":(g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),l=d[t]||"",v++),!((v+1)*f>h&&"hidden"===i.overflow));t++)if(d.length-1===t&&(v+1)*f<=h){g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),n<u.length-1&&v++;break}}else g.push({text:"",width:0})}var a,r}));let m=0,w=0;f>a&&(w=(f-a)/2),g.length*f<h&&("top"===t.detail.verticalAlign?m=0:"bottom"===t.detail.verticalAlign?m+=h-g.length*f:m+=(h-g.length*f)/2);{const t=l+m;void 0!==i.textShadowColor&&R(i.textShadowColor)&&(e.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&N.number(i.textShadowOffsetX)&&(e.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&N.number(i.textShadowOffsetY)&&(e.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&N.number(i.textShadowBlur)&&(e.shadowBlur=i.textShadowBlur),g.forEach(((o,n)=>{let a=r;"center"===i.textAlign?a=r+(s-o.width)/2:"right"===i.textAlign&&(a=r+(s-o.width)),e.fillText(o.text,a,t+f*n+w)}))}}}))}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=We(t,{viewScaleInfo:n})||t,f=Object.assign(Object.assign({},t),{x:l,y:s,w:h,h:c,angle:d});fe(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{nt(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{tt(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{if(o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"image"===t.type&&o){e.globalAlpha=et(t)*r;const{x:i,y:l,w:s,h:h,radiusList:c}=Ze(f,{viewScaleInfo:n,viewSizeInfo:a}),{detail:d}=t,{scaleMode:u,originW:g=0,originH:v=0}=d,m=e.$undoPixelRatio(g),w=e.$undoPixelRatio(v);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+c[0],l),e.arcTo(i+s,l,i+s,l+h,c[1]),e.arcTo(i+s,l+h,i,l+h,c[2]),e.arcTo(i,l+h,i,l,c[3]),e.arcTo(i,l,i+s,l,c[0]),e.closePath(),e.fill(),e.clip(),u&&v&&g){let n=0,a=0,r=m,c=w;const d=i,f=l,g=s,v=h;if(m>t.w||w>t.h)if("fill"===u){const e=Math.max(t.w/m,t.h/w),i=w*e;n=(m*e-t.w)/2/e,a=(i-t.h)/2/e,r=t.w/e,c=t.h/e}else if("tile"===u)n=0,a=0,r=t.w,c=t.h;else if("fit"===u){const e=Math.min(t.w/m,t.h/w);n=(m-t.w/e)/2,a=(w-t.h/e)/2,r=t.w/e,c=t.h/e}e.drawImage(o,n,a,r,c,d,f,g,v)}else e.drawImage(o,i,l,s,h);e.globalAlpha=r,e.restore()}}})}})}))}(e,t,i);break;case"svg":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=We(t,{viewScaleInfo:n,viewSizeInfo:a})||t;fe(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"svg"===t.type&&o&&(e.globalAlpha=et(t)*r,e.drawImage(o,l,s,h,c),e.globalAlpha=r)}))}(e,t,i);break;case"html":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=We(t,{viewScaleInfo:n,viewSizeInfo:a})||t;fe(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"html"===t.type&&o&&(e.globalAlpha=et(t)*r,e.drawImage(o,l,s,h,c),e.globalAlpha=r)}))}(e,t,i);break;case"path":!function(e,t,i){var o,n;const{detail:a}=t,{originX:r,originY:l,originW:s,originH:h,fillRule:c}=a,{viewScaleInfo:d,viewSizeInfo:f,parentOpacity:u}=i,{x:g,y:v,w:m,h:w,angle:y}=We(t,{viewScaleInfo:d})||t,p=m/s,x=w/h,S=g-r*p,b=v-l*x,I=t.detail,A=rt(I,["clipPath","clipPathStrokeColor","clipPathStrokeWidth"]),M=d.scale*f.devicePixelRatio,R=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:w,angle:y});let T=Object.assign({},R);T.detail=A;let z=Object.assign({},t);z.detail=A,a.fill&&"string"!==a.fill&&(null===(n=null===(o=a.fill)||void 0===o?void 0:o.type)||void 0===n?void 0:n.includes("gradient"))&&(T=Object.assign(Object.assign({},R),{detail:Object.assign(Object.assign({},R.detail),{background:a.fill,clipPath:{commands:a.commands,originX:r,originY:l,originW:s,originH:h}})}),z.detail=Object.assign({},T.detail)),fe(e,{x:g,y:v,w:m,h:w,angle:y},(()=>{tt(e,T,{originElem:z,calcElemSize:{x:g,y:v,w:m,h:w,angle:y},viewScaleInfo:d,viewSizeInfo:f,parentOpacity:u,renderContent:()=>{nt(e,R,{viewScaleInfo:d,viewSizeInfo:f,renderContent:()=>{e.save(),e.translate(S,b),e.scale(M*p/d.scale,M*x/d.scale);const t=Ne(a.commands||[]),i=new Path2D(t);a.fill&&("string"==typeof a.fill?e.fillStyle=a.fill:e.fillStyle="transparent"),a.fill&&e.fill(i,c),a.stroke&&0!==a.strokeWidth&&(e.strokeStyle=a.stroke,e.lineWidth=(a.strokeWidth||1)/f.devicePixelRatio,e.lineCap=a.strokeLineCap||"square",e.stroke(i)),e.translate(-S,-b),e.restore()}})}})}))}(e,t,i);break;case"group":{const o=Object.assign(Object.assign({},i.elementAssets||{}),t.detail.assets||{});!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=We({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});fe(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{e.globalAlpha=et(t)*a,nt(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{tt(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,renderContent:()=>{const{x:r,y:l,w:s,h:h,radiusList:c}=Ze(d,{viewScaleInfo:o,viewSizeInfo:n});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(r+c[0],l),e.arcTo(r+s,l,r+s,l+h,c[1]),e.arcTo(r+s,l+h,r,l+h,c[2]),e.arcTo(r,l+h,r,l,c[3]),e.arcTo(r,l,r+s,l,c[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:o}=i,n={x:o.x+t.x,y:o.y+t.y,w:t.w||o.w,h:t.h||o.h,angle:t.angle},{calculator:r}=i;for(let o=0;o<t.detail.children.length;o++){let l=t.detail.children[o];if(l=Object.assign(Object.assign({},l),{x:n.x+l.x,y:n.y+l.y}),!0===i.forceDrawAll||(null==r?void 0:r.needRender(l)))try{st(e,l,Object.assign(Object.assign({},i),{parentOpacity:a*et(t)}))}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=a}))}(e,t,Object.assign(Object.assign({},i),{elementAssets:o}));break}}}catch(e){console.error(e)}}const ht={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function ct(e,t,i){var o;const{elements:n=[]}=t,{parentOpacity:a}=i;for(let t=0;t<n.length;t++){const r=n[t],l=Object.assign(Object.assign({},r),{detail:Object.assign(Object.assign({},ht),null==r?void 0:r.detail)});if(!0===i.forceDrawAll||(null===(o=i.calculator)||void 0===o?void 0:o.needRender(l)))try{st(e,l,Object.assign(Object.assign({},i),{parentOpacity:a}))}catch(e){console.error(e)}}}var dt,ft,ut,gt,vt,mt,wt,yt,pt,xt,St,bt,It=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))},At=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)},Mt=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i};const Rt=["image","svg","html"],Tt=e=>{var t,i,o;let n=null;return"image"===e.type?n=(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)||null:"svg"===e.type?n=(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)||null:"html"===e.type&&(n=(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)||null),"string"==typeof n&&n?/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${n}`)?n:C(n):C(`${z()}-${e.uuid}-${z()}-${z()}`)};class zt extends _{constructor(){super(),dt.add(this),ft.set(this,{}),ut.set(this,{}),gt.set(this,{}),vt.set(this,!1),At(this,dt,"m",mt).call(this,"image",((e,t)=>It(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.src])||void 0===i?void 0:i.value)||e.detail.src,n=yield j(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),At(this,dt,"m",mt).call(this,"html",((e,t)=>It(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.html])||void 0===i?void 0:i.value)||e.detail.html,n=yield Y(o,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),At(this,dt,"m",mt).call(this,"svg",((e,t)=>It(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.svg])||void 0===i?void 0:i.value)||e.detail.svg,n=yield D(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}}))))}isDestroyed(){return At(this,vt,"f")}destroy(){Mt(this,vt,!0,"f"),this.clear(),Mt(this,ft,null,"f"),Mt(this,ut,null,"f"),Mt(this,gt,null,"f")}load(e,t){!0!==At(this,vt,"f")&&(At(this,dt,"m",bt).call(this,e)||Rt.includes(e.type)&&At(this,dt,"m",St).call(this,e,t))}getContent(e){var t,i;const o=Tt(e);return(null===(i=null===(t=At(this,gt,"f"))||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return At(this,gt,"f")}setLoadItemMap(e){Mt(this,gt,e,"f")}}ft=new WeakMap,ut=new WeakMap,gt=new WeakMap,vt=new WeakMap,dt=new WeakSet,mt=function(e,t){At(this,ft,"f")[e]=t},wt=function(e){var t,i,o;let n=null;return"image"===e.type?n=(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)||null:"svg"===e.type?n=(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)||null:"html"===e.type&&(n=(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)||null),n},yt=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:At(this,dt,"m",wt).call(this,e)}},pt=function(e){const t=Tt(e.element),i=At(this,gt,"f")[t];At(this,vt,"f")||(i?i.startTime<e.startTime&&(At(this,gt,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(At(this,gt,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},xt=function(e){var t;const i=Tt(e.element),o=null===(t=At(this,gt,"f"))||void 0===t?void 0:t[i];At(this,vt,"f")||(o?o.startTime<e.startTime&&(At(this,gt,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(At(this,gt,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},St=function(e,t){const i=At(this,dt,"m",yt).call(this,e),o=Tt(e);if(At(this,ut,"f")[o])return;At(this,ut,"f")[o]=i;const n=At(this,ft,"f")[e.type];"function"!=typeof n||At(this,vt,"f")||(i.startTime=Date.now(),n(e,t).then((e=>{At(this,vt,"f")||(i.content=e.content,i.endTime=Date.now(),i.status="load",At(this,dt,"m",pt).call(this,i))})).catch((t=>{console.warn(`Load element source "${i.source}" fail`,t,e),i.endTime=Date.now(),i.status="error",i.error=t,At(this,dt,"m",xt).call(this,i)})))},bt=function(e){var t;const i=Tt(e),o=null===(t=At(this,ut,"f"))||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==At(this,dt,"m",wt).call(this,e))};var Pt,Ct,Et,Wt,kt,Lt=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Ot=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class jt extends _{constructor(e){super(),Pt.add(this),Ct.set(this,void 0),Et.set(this,new zt),Wt.set(this,!1),Lt(this,Ct,e,"f"),Ot(this,Pt,"m",kt).call(this)}isDestroyed(){return Ot(this,Wt,"f")}destroy(){this.clear(),Lt(this,Ct,null,"f"),Ot(this,Et,"f").destroy(),Lt(this,Et,null,"f"),Lt(this,Wt,!0,"f")}updateOptions(e){Lt(this,Ct,e,"f")}drawData(e,t){const i=Ot(this,Et,"f"),{calculator:o,sharer:n}=Ot(this,Ct,"f"),a=Ot(this,Ct,"f").viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const r={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},l=Object.assign({loader:i,calculator:o,parentElementSize:r,elementAssets:e.assets,parentOpacity:1,overrideElementMap:null==n?void 0:n.getActiveOverrideElemenentMap()},t);!function(e,t,i){if("string"==typeof(null==t?void 0:t.background)){const{viewSizeInfo:o}=i,{width:n,height:a}=o;e.globalAlpha=1,e.fillStyle=t.background,e.fillRect(0,0,n,a)}}(a,e.global,l),e.layout?function(e,t,i,o){const{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,l=Object.assign({uuid:"layout",type:"group"},t),{x:s,y:h,w:c,h:d}=We(l,{viewScaleInfo:n})||l,f=Object.assign(Object.assign({},l),{x:s,y:h,w:c,h:d,angle:0});if(e.globalAlpha=1,nt(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{it(e,f,{viewScaleInfo:n,viewSizeInfo:a})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:o,viewSizeInfo:n}=i,a=Object.assign({uuid:"layout",type:"group"},t),r=We(a,{viewScaleInfo:o})||a,l=Object.assign(Object.assign({},a),r),{x:s,y:h,w:c,h:d,radiusList:f}=Ze(l,{viewScaleInfo:o,viewSizeInfo:n});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(s+f[0],h),e.arcTo(s+c,h,s+c,h+d,f[1]),e.arcTo(s+c,h+d,s,h+d,f[2]),e.arcTo(s,h+d,s,h,f[3]),e.arcTo(s,h,s+c,h,f[0]),e.closePath(),e.fill(),e.clip()}o(e),"hidden"===t.detail.overflow&&e.restore(),ot(e,f,{viewScaleInfo:n,viewSizeInfo:a}),e.globalAlpha=r}(a,e.layout,l,(()=>{ct(a,e,l)})):ct(a,e,l)}scale(e){const{sharer:t}=Ot(this,Ct,"f");if(!t)return;const{data:i,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){Ot(this,Et,"f").setLoadItemMap(e)}getLoadItemMap(){return Ot(this,Et,"f").getLoadItemMap()}getLoader(){return Ot(this,Et,"f")}}Ct=new WeakMap,Et=new WeakMap,Wt=new WeakMap,Pt=new WeakSet,kt=function(){const e=Ot(this,Et,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))};var Dt,Yt,Vt=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Bt=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class Gt{constructor(e){Dt.set(this,void 0),Yt.set(this,void 0),Vt(this,Dt,e,"f"),Vt(this,Yt,new le({defaultStorage:{viewVisibleInfoMap:{},visibleCount:0,invisibleCount:0}}),"f")}toGridNum(e,t){return!0===(null==t?void 0:t.ignore)?e:Math.round(e)}destroy(){Vt(this,Dt,null,"f")}needRender(e){const t=Bt(this,Yt,"f").get("viewVisibleInfoMap")[e.uuid];return!t||t.isVisibleInView}isPointInElement(e,t,i,o){return Oe(e,{context2d:Bt(this,Dt,"f").viewContext,element:t,viewScaleInfo:i,viewSizeInfo:o})}getPointElement(e,t){const i=Bt(this,Dt,"f").viewContext;return function(e,t){var i,o,n;const{context2d:a,data:r,viewScaleInfo:l,viewSizeInfo:s,groupQueue:h}=t,c={index:-1,element:null,groupQueueIndex:-1};if(h&&Array.isArray(h)&&(null==h?void 0:h.length)>0)for(let t=h.length-1;t>=0;t--){let n=0,r=0,d=0;for(let e=0;e<=t;e++)n+=h[e].x,r+=h[e].y,d+=h[e].angle||0;const f=h[t];if(f&&"group"===f.type&&Array.isArray(null===(i=f.detail)||void 0===i?void 0:i.children))for(let i=0;i<f.detail.children.length;i++){const u=f.detail.children[i];if(!0!==(null===(o=null==u?void 0:u.operations)||void 0===o?void 0:o.invisible)){if(!u)break;if(Oe(e,{context2d:a,element:{x:n+u.x,y:r+u.y,w:u.w,h:u.h,angle:d+(u.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){c.element=u,(t<h.length-1||"group"!==u.type)&&(c.groupQueueIndex=t);break}}}if(c.element)break}if(c.element)return c;for(let t=r.elements.length-1;t>=0;t--){const i=r.elements[t];if(!0!==(null===(n=null==i?void 0:i.operations)||void 0===n?void 0:n.invisible)&&Oe(e,{context2d:a,element:i,viewScaleInfo:l,viewSizeInfo:s})){c.index=t,c.element=i;break}}return c}(e,Object.assign(Object.assign({},t),{context2d:i}))}resetViewVisibleInfoMap(e,t){if(e){const{viewVisibleInfoMap:i,invisibleCount:o,visibleCount:n}=function(e,t){const i={},o=[],n=t=>{const a={isVisibleInView:!0,isGroup:"group"===t.type,position:[...o]};let r=null;r=De(t,{groupQueue:Ae(e,o)||[]}),i[t.uuid]=Object.assign(Object.assign({},a),{originRectInfo:r,rangeRectInfo:N.angle(t.angle)?Ye(r):r}),"group"===t.type&&t.detail.children.forEach(((e,t)=>{o.push(t),n(e),o.pop()}))};return e.forEach(((e,t)=>{o.push(t),n(e),o.pop()})),Ve(i,t)}(e.elements,t);Bt(this,Yt,"f").set("viewVisibleInfoMap",i),Bt(this,Yt,"f").set("invisibleCount",o),Bt(this,Yt,"f").set("visibleCount",n)}}updateVisiableStatus(e){const{viewVisibleInfoMap:t,invisibleCount:i,visibleCount:o}=Ve(Bt(this,Yt,"f").get("viewVisibleInfoMap"),e);Bt(this,Yt,"f").set("viewVisibleInfoMap",t),Bt(this,Yt,"f").set("invisibleCount",i),Bt(this,Yt,"f").set("visibleCount",o)}calcViewRectInfoFromOrigin(e,t){const i=Bt(this,Yt,"f").get("viewVisibleInfoMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:a}=t,{center:r,left:l,right:s,bottom:h,top:c,topLeft:d,topRight:f,bottomLeft:u,bottomRight:g}=i.originRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n,viewSizeInfo:a};return{center:ke(r,v),left:ke(l,v),right:ke(s,v),bottom:ke(h,v),top:ke(c,v),topLeft:ke(d,v),topRight:ke(f,v),bottomLeft:ke(u,v),bottomRight:ke(g,v)}}calcViewRectInfoFromRange(e,t){const i=Bt(this,Yt,"f").get("viewVisibleInfoMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:a}=t,{center:r,left:l,right:s,bottom:h,top:c,topLeft:d,topRight:f,bottomLeft:u,bottomRight:g}=i.rangeRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n,viewSizeInfo:a};return{center:ke(r,v),left:ke(l,v),right:ke(s,v),bottom:ke(h,v),top:ke(c,v),topLeft:ke(d,v),topRight:ke(f,v),bottomLeft:ke(u,v),bottomRight:ke(g,v)}}modifyViewVisibleInfoMap(e,t){const{modifyOptions:i,viewScaleInfo:o,viewSizeInfo:n}=t,{type:a,content:r}=i,l=e.elements,s=Bt(this,Yt,"f").get("viewVisibleInfoMap");if("deleteElement"===a){const{element:e}=r,t=[],i=e=>{t.push(e.uuid),"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{i(e)}))};i(e),t.forEach((e=>{delete s[e]})),Bt(this,Yt,"f").set("viewVisibleInfoMap",s)}else if("addElement"===a||"updateElement"===a){const{position:t}=r,i=Re(t,e.elements),h=Ae(l,t);if(i)if("updateElement"===a&&"group"===i.type)this.resetViewVisibleInfoMap(e,{viewScaleInfo:o,viewSizeInfo:n});else{const e=De(i,{groupQueue:h||[]}),r={originRectInfo:e,rangeRectInfo:N.angle(i.angle)?Ye(e):e,isVisibleInView:!0,isGroup:"group"===(null==i?void 0:i.type),position:[...t]};s[i.uuid]=r,Bt(this,Yt,"f").set("viewVisibleInfoMap",s),"updateElement"===a&&this.updateVisiableStatus({viewScaleInfo:o,viewSizeInfo:n})}}else"moveElement"===a&&this.resetViewVisibleInfoMap(e,{viewScaleInfo:o,viewSizeInfo:n})}}Dt=new WeakMap,Yt=new WeakMap;var Xt,Nt,Ft,Ht,Zt,Qt,Ut,Jt,$t,Kt,qt,_t,ei,ti,ii,oi,ni=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},ai=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};function ri(e){return e>0||e<0||0===e}class li extends _{constructor(e){super(),Xt.add(this),Nt.set(this,void 0),Ft.set(this,void 0),Ht.set(this,!1),Qt.set(this,(e=>{if(!ai(this,Xt,"m",ti).call(this,e))return;const t=ai(this,Xt,"m",ii).call(this,e);if(!ai(this,Xt,"m",oi).call(this,t))return;e.preventDefault(),e.stopPropagation();const i=e.deltaX>0||e.deltaX<0?e.deltaX:0,o=e.deltaY>0||e.deltaY<0?e.deltaY:0;!0===e.ctrlKey&&this.has("wheelScale")?this.trigger("wheelScale",{deltaX:i,deltaY:o,point:t}):this.has("wheel")&&this.trigger("wheel",{deltaX:i,deltaY:o,point:t})})),Ut.set(this,(e=>{if(2!==e.button)return;if(!ai(this,Xt,"m",ti).call(this,e))return;e.preventDefault();const t=ai(this,Xt,"m",ii).call(this,e);ai(this,Xt,"m",oi).call(this,t)&&this.trigger("contextMenu",{point:t})})),Jt.set(this,(e=>{if(!ai(this,Xt,"m",ti).call(this,e))return;e.preventDefault();const t=ai(this,Xt,"m",ii).call(this,e);if(!ai(this,Xt,"m",oi).call(this,t))return;const i=Date.now(),o=ai(this,Ft,"f").get("prevClickPoint");o&&i-o.t<=500&&Math.abs(o.x-t.x)<=5&&Math.abs(o.y-t.y)<=5?this.trigger("doubleClick",{point:t}):ai(this,Ft,"f").set("prevClickPoint",t)})),$t.set(this,(e=>{if(ai(this,Ft,"f").set("hasPointDown",!1),!ai(this,Xt,"m",ti).call(this,e))return;e.preventDefault();const t=ai(this,Xt,"m",ii).call(this,e);this.trigger("pointLeave",{point:t})})),Kt.set(this,(e=>{if(ai(this,Ft,"f").set("hasPointDown",!1),!ai(this,Xt,"m",ti).call(this,e))return;e.preventDefault();const t=ai(this,Xt,"m",ii).call(this,e);this.trigger("pointEnd",{point:t})})),qt.set(this,(e=>{if(!ai(this,Xt,"m",ti).call(this,e))return;e.preventDefault(),e.stopPropagation();const t=ai(this,Xt,"m",ii).call(this,e);ai(this,Xt,"m",oi).call(this,t)?!0===ai(this,Ft,"f").get("hasPointDown")&&this.trigger("pointMove",{point:t}):ai(this,Ft,"f").get("hasPointDown")&&(this.trigger("pointLeave",{point:t}),ai(this,Ft,"f").set("hasPointDown",!1))})),_t.set(this,(e=>{if(0!==e.button)return;if(!ai(this,Xt,"m",ti).call(this,e))return;e.preventDefault();const t=ai(this,Xt,"m",ii).call(this,e);ai(this,Xt,"m",oi).call(this,t)&&(ai(this,Ft,"f").set("hasPointDown",!0),this.trigger("pointStart",{point:t}))})),ei.set(this,(e=>{if(!ai(this,Xt,"m",ti).call(this,e))return;e.preventDefault();const t=ai(this,Xt,"m",ii).call(this,e);ai(this,Xt,"m",oi).call(this,t)&&this.trigger("hover",{point:t})}));const t=new le({defaultStorage:{hasPointDown:!1,prevClickPoint:null}});ni(this,Ft,t,"f"),ni(this,Nt,e,"f"),ai(this,Xt,"m",Zt).call(this)}onEvents(){if(ai(this,Ht,"f"))return;const e=window;e.addEventListener("mousemove",ai(this,ei,"f")),e.addEventListener("mousedown",ai(this,_t,"f")),e.addEventListener("mousemove",ai(this,qt,"f")),e.addEventListener("mouseup",ai(this,Kt,"f")),e.addEventListener("mouseleave",ai(this,$t,"f")),e.addEventListener("wheel",ai(this,Qt,"f"),{passive:!1}),e.addEventListener("click",ai(this,Jt,"f")),e.addEventListener("contextmenu",ai(this,Ut,"f"))}offEvents(){const e=window;e.removeEventListener("mousemove",ai(this,ei,"f")),e.removeEventListener("mousedown",ai(this,_t,"f")),e.removeEventListener("mousemove",ai(this,qt,"f")),e.removeEventListener("mouseup",ai(this,Kt,"f")),e.removeEventListener("mouseleave",ai(this,$t,"f")),e.removeEventListener("wheel",ai(this,Qt,"f")),e.removeEventListener("click",ai(this,Jt,"f")),e.removeEventListener("contextmenu",ai(this,Ut,"f"))}destroy(){this.offEvents(),ai(this,Ft,"f").destroy(),ni(this,Ht,!0,"f")}}Nt=new WeakMap,Ft=new WeakMap,Ht=new WeakMap,Qt=new WeakMap,Ut=new WeakMap,Jt=new WeakMap,$t=new WeakMap,Kt=new WeakMap,qt=new WeakMap,_t=new WeakMap,ei=new WeakMap,Xt=new WeakSet,Zt=function(){this.onEvents()},ti=function(e){return e.target===ai(this,Nt,"f").boardContent.boardContext.canvas},ii=function(e){const t=ai(this,Nt,"f").boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top,t:Date.now()}},oi=function(e){const t=ai(this,Nt,"f").sharer.getActiveViewSizeInfo(),{width:i,height:o}=t;return!!(ri(e.x)&&ri(e.y)&&e.x<=i&&e.y<=o)};var si,hi,ci=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},di=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};const fi={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0,overrideElementMap:null};class ui{constructor(){si.set(this,void 0),hi.set(this,void 0);const e=new le({defaultStorage:fi}),t=new le({defaultStorage:{}});ci(this,si,e,"f"),ci(this,hi,t,"f")}getActiveStorage(e){return di(this,si,"f").get(e)}setActiveStorage(e,t){return di(this,si,"f").set(e,t)}getActiveStoreSnapshot(e){return di(this,si,"f").getSnapshot(e)}getSharedStorage(e){return di(this,hi,"f").get(e)}setSharedStorage(e,t){return di(this,hi,"f").set(e,t)}getSharedStoreSnapshot(e){return di(this,hi,"f").getSnapshot(e)}getActiveViewScaleInfo(){return{scale:di(this,si,"f").get("scale"),offsetTop:di(this,si,"f").get("offsetTop"),offsetBottom:di(this,si,"f").get("offsetBottom"),offsetLeft:di(this,si,"f").get("offsetLeft"),offsetRight:di(this,si,"f").get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:n,offsetRight:a}=e;di(this,si,"f").set("scale",t),di(this,si,"f").set("offsetTop",i),di(this,si,"f").set("offsetBottom",o),di(this,si,"f").set("offsetLeft",n),di(this,si,"f").set("offsetRight",a)}setActiveViewSizeInfo(e){di(this,si,"f").set("width",e.width),di(this,si,"f").set("height",e.height),di(this,si,"f").set("devicePixelRatio",e.devicePixelRatio),di(this,si,"f").set("contextWidth",e.contextWidth),di(this,si,"f").set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:di(this,si,"f").get("width"),height:di(this,si,"f").get("height"),devicePixelRatio:di(this,si,"f").get("devicePixelRatio"),contextWidth:di(this,si,"f").get("contextWidth"),contextHeight:di(this,si,"f").get("contextHeight")}}getActiveOverrideElemenentMap(){return di(this,si,"f").get("overrideElementMap")}setActiveOverrideElemenentMap(e){di(this,si,"f").set("overrideElementMap",e)}}si=new WeakMap,hi=new WeakMap;var gi,vi,mi,wi,yi,pi,xi=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Si=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};const{requestAnimationFrame:bi}=window;class Ii extends _{constructor(e){super(),gi.add(this),vi.set(this,void 0),mi.set(this,[]),wi.set(this,"FREE"),xi(this,vi,e,"f"),Si(this,gi,"m",yi).call(this)}resetViewVisibleInfoMap(e,t){e&&Si(this,vi,"f").calculator.resetViewVisibleInfoMap(e,t)}drawFrame(){const{sharer:e}=Si(this,vi,"f"),t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();Si(this,mi,"f").push({activeStore:t,sharedStore:i}),Si(this,gi,"m",pi).call(this)}scale(e){const{scale:t,point:i,ignoreUpdateVisibleStatus:o}=e,{sharer:n}=Si(this,vi,"f"),{moveX:a,moveY:r}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:n,offsetTop:a}=o,r=t/o.scale,l=i.x,s=i.y;return{moveX:l-l*r+(n*r-n),moveY:s-s*r+(a*r-a)}}({scale:t,point:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});return n.setActiveStorage("scale",t),o||Si(this,vi,"f").calculator.updateVisiableStatus({viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),{moveX:a,moveY:r}}scroll(e){const{sharer:t}=Si(this,vi,"f"),i=t.getActiveViewScaleInfo(),{moveX:o,moveY:n,ignoreUpdateVisibleStatus:a}=e,r=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:n}=e,{scale:a}=o,{width:r,height:l,contextWidth:s,contextHeight:h}=n;let c=o.offsetLeft,d=o.offsetRight,f=o.offsetTop,u=o.offsetBottom;return c+=t,f+=i,d=r-(s*a+c),u=l-(h*a+f),{scale:a,offsetTop:f,offsetLeft:c,offsetRight:d,offsetBottom:u}}({moveX:o,moveY:n,viewScaleInfo:i,viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(r),a||Si(this,vi,"f").calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),r}updateViewScaleInfo(e){const{sharer:t}=Si(this,vi,"f"),i=function(e,t){const{scale:i,offsetX:o,offsetY:n}=e,{viewSizeInfo:a}=t,{width:r,height:l,contextWidth:s,contextHeight:h}=a,c=0-o*i,d=0-n*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:r-(s*i+c/i),offsetBottom:l-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),Si(this,vi,"f").calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),i}resize(e={},t){const{sharer:i}=Si(this,vi,"f"),o=i.getActiveViewSizeInfo(),n=Object.assign(Object.assign({},o),e),{width:a,height:r,devicePixelRatio:l}=n,{underlayContext:s,boardContext:h,overlayContext:c,viewContext:d}=Si(this,vi,"f").boardContent;return h.canvas.width=a*l,h.canvas.height=r*l,h.canvas.style.width=`${a}px`,h.canvas.style.height=`${r}px`,s.canvas.width=a*l,s.canvas.height=r*l,c.canvas.width=a*l,c.canvas.height=r*l,d.canvas.width=a*l,d.canvas.height=r*l,i.setActiveViewSizeInfo(n),(null==t?void 0:t.ignoreUpdateVisibleStatus)||Si(this,vi,"f").calculator.updateVisiableStatus({viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}),n}}vi=new WeakMap,mi=new WeakMap,wi=new WeakMap,gi=new WeakSet,yi=function(){const{renderer:e}=Si(this,vi,"f");e.on("load",(()=>{this.drawFrame()}))},pi=function e(){if("DRAWING"===Si(this,wi,"f")||0===Si(this,mi,"f").length)return;xi(this,wi,"DRAWING","f");const t=Si(this,mi,"f").shift(),{renderer:i,boardContent:o,beforeDrawFrame:n,afterDrawFrame:a}=Si(this,vi,"f");if(t){const{scale:e,offsetTop:r,offsetBottom:l,offsetLeft:s,offsetRight:h,width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g}=t.activeStore,v={scale:e,offsetTop:r,offsetBottom:l,offsetLeft:s,offsetRight:h},m={width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g};(null==t?void 0:t.activeStore.data)&&i.drawData(t.activeStore.data,{viewScaleInfo:v,viewSizeInfo:m}),n({snapshot:t}),o.drawView(),a({snapshot:t})}0!==Si(this,mi,"f").length?xi(this,wi,"DRAWING","f")&&bi((()=>{Si(this,gi,"m",e).call(this)})):xi(this,wi,"COMPLETE","f")};var Ai,Mi,Ri,Ti,zi,Pi,Ci,Ei,Wi,ki,Li,Oi,ji,Di,Yi,Vi,Bi,Gi,Xi,Ni,Fi,Hi,Zi,Qi,Ui,Ji,$i,Ki,qi=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},_i=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class eo{constructor(e){Ai.add(this),Mi.set(this,void 0),Ri.set(this,new WeakMap),Ti.set(this,[]),zi.set(this,[]),Pi.set(this,void 0),Ci.set(this,void 0),Ei.set(this,void 0),Wi.set(this,void 0),ki.set(this,void 0),Li.set(this,new _),Oi.set(this,!1);const{boardContent:t}=e,i=new ui,o=new Gt({viewContext:t.viewContext}),n=new li({boardContent:t,sharer:i}),a=new jt({viewContext:t.viewContext,sharer:i,calculator:o});qi(this,Mi,e,"f"),qi(this,Ei,i,"f"),qi(this,Pi,n,"f"),qi(this,Ci,a,"f"),qi(this,ki,o,"f"),qi(this,Wi,new Ii({boardContent:e.boardContent,sharer:i,renderer:a,calculator:_i(this,ki,"f"),beforeDrawFrame:e=>{_i(this,Ai,"m",Ji).call(this,e)},afterDrawFrame:e=>{_i(this,Ai,"m",$i).call(this,e)}}),"f"),_i(this,Ai,"m",ji).call(this),_i(this,Ai,"m",Ki).call(this)}isDestroyed(){return _i(this,Oi,"f")}destroy(){_i(this,Pi,"f").destroy(),_i(this,Ci,"f").destroy(),_i(this,ki,"f").destroy(),_i(this,Li,"f").destroy(),qi(this,Oi,!0,"f")}getSharer(){return _i(this,Ei,"f")}getViewer(){return _i(this,Wi,"f")}getRenderer(){return _i(this,Ci,"f")}setData(e,t){const{modifiedOptions:i}=t||{},o=_i(this,Ei,"f");_i(this,Ei,"f").setActiveStorage("data",e);const n=o.getActiveViewSizeInfo(),a=o.getActiveViewScaleInfo(),r=Ie(e.elements,{viewWidth:n.width,viewHeight:n.height,extend:!0});_i(this,Wi,"f").resetViewVisibleInfoMap(e,{viewSizeInfo:n,viewScaleInfo:a}),_i(this,Wi,"f").drawFrame();const l=Object.assign(Object.assign({},n),r);return _i(this,Ei,"f").setActiveViewSizeInfo(l),{viewSizeInfo:l}}getData(){const{data:e}=_i(this,Ei,"f").getActiveStoreSnapshot();return e}use(e,t){var i,o,n;if(_i(this,Ri,"f").has(e)){const t=_i(this,Ri,"f").get(e);if(t)return null===(o=(i=t.middlewareObject).use)||void 0===o||o.call(i),t.status="enable",_i(this,Ri,"f").set(e,t),void _i(this,Ai,"m",Ki).call(this)}const{boardContent:a,container:r}=_i(this,Mi,"f"),l=e({boardContent:a,sharer:_i(this,Ei,"f"),viewer:_i(this,Wi,"f"),calculator:_i(this,ki,"f"),eventHub:_i(this,Li,"f"),container:r},t);null===(n=l.use)||void 0===n||n.call(l),_i(this,Ti,"f").push(e),_i(this,zi,"f").push(l),_i(this,Ri,"f").set(e,{status:"enable",middlewareObject:l,config:t}),_i(this,Ai,"m",Ki).call(this)}disuse(e){var t,i;const o=_i(this,Ri,"f").get(e);o&&(null===(i=(t=o.middlewareObject).disuse)||void 0===i||i.call(t),o.status="disable",_i(this,Ri,"f").set(e,o),_i(this,Ai,"m",Ki).call(this))}scale(e){const t=_i(this,Wi,"f"),{ignoreUpdateVisibleStatus:i}=e,{moveX:o,moveY:n}=t.scale(Object.assign(Object.assign({},e),{ignoreUpdateVisibleStatus:!0}));t.scroll({moveX:o,moveY:n,ignoreUpdateVisibleStatus:i})}scroll(e){return _i(this,Wi,"f").scroll(e)}updateViewScaleInfo(e){return _i(this,Wi,"f").updateViewScaleInfo(e)}resize(e,t){const i=_i(this,Wi,"f").resize(e,t),{width:o,height:n,devicePixelRatio:a}=e,{boardContent:r}=_i(this,Mi,"f");r.viewContext.$resize({width:o,height:n,devicePixelRatio:a}),r.overlayContext.$resize({width:o,height:n,devicePixelRatio:a}),r.boardContext.$resize({width:o,height:n,devicePixelRatio:a}),r.underlayContext.$resize({width:o,height:n,devicePixelRatio:a}),_i(this,Wi,"f").drawFrame(),_i(this,Pi,"f").trigger("resize",i),_i(this,Ei,"f").setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=_i(this,Mi,"f"),{underlayContext:t,overlayContext:i,viewContext:o,boardContext:n}=e;t.clearRect(0,0,t.canvas.width,t.canvas.height),i.clearRect(0,0,i.canvas.width,i.canvas.height),o.clearRect(0,0,o.canvas.width,o.canvas.height),n.clearRect(0,0,n.canvas.width,n.canvas.height),_i(this,Ai,"m",Ui).call(this)}getEventHub(){return _i(this,Li,"f")}onWatcherEvents(){_i(this,Pi,"f").onEvents()}offWatcherEvents(){_i(this,Pi,"f").offEvents()}}Mi=new WeakMap,Ri=new WeakMap,Ti=new WeakMap,zi=new WeakMap,Pi=new WeakMap,Ci=new WeakMap,Ei=new WeakMap,Wi=new WeakMap,ki=new WeakMap,Li=new WeakMap,Oi=new WeakMap,Ai=new WeakSet,ji=function(){_i(this,Pi,"f").on("pointStart",_i(this,Ai,"m",Di).bind(this)),_i(this,Pi,"f").on("pointEnd",_i(this,Ai,"m",Yi).bind(this)),_i(this,Pi,"f").on("pointMove",_i(this,Ai,"m",Vi).bind(this)),_i(this,Pi,"f").on("hover",_i(this,Ai,"m",Bi).bind(this)),_i(this,Pi,"f").on("wheel",_i(this,Ai,"m",Ni).bind(this)),_i(this,Pi,"f").on("wheelScale",_i(this,Ai,"m",Fi).bind(this)),_i(this,Pi,"f").on("scrollX",_i(this,Ai,"m",Hi).bind(this)),_i(this,Pi,"f").on("scrollY",_i(this,Ai,"m",Zi).bind(this)),_i(this,Pi,"f").on("resize",_i(this,Ai,"m",Qi).bind(this)),_i(this,Pi,"f").on("doubleClick",_i(this,Ai,"m",Gi).bind(this)),_i(this,Pi,"f").on("contextMenu",_i(this,Ai,"m",Xi).bind(this)),_i(this,Ci,"f").on("load",(()=>{_i(this,Li,"f").trigger("loadResource")}))},Di=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointStart)||void 0===t?void 0:t.call(o,e)))return}},Yi=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointEnd)||void 0===t?void 0:t.call(o,e)))return}},Vi=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointMove)||void 0===t?void 0:t.call(o,e)))return}},Bi=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.hover)||void 0===t?void 0:t.call(o,e)))return}},Gi=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.doubleClick)||void 0===t?void 0:t.call(o,e)))return}},Xi=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.contextMenu)||void 0===t?void 0:t.call(o,e)))return}},Ni=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheel)||void 0===t?void 0:t.call(o,e)))return}},Fi=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheelScale)||void 0===t?void 0:t.call(o,e)))return}},Hi=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollX)||void 0===t?void 0:t.call(o,e)))return}},Zi=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollY)||void 0===t?void 0:t.call(o,e)))return}},Qi=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.resize)||void 0===t?void 0:t.call(o,e)))return}},Ui=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.clear)||void 0===t?void 0:t.call(o,e)))return}},Ji=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.beforeDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},$i=function(e){var t;for(let i=0;i<_i(this,zi,"f").length;i++){const o=_i(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.afterDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},Ki=function(){const e=[],t=_i(this,Ri,"f");_i(this,Ti,"f").forEach((i=>{const o=t.get(i);"enable"===(null==o?void 0:o.status)&&(null==o?void 0:o.middlewareObject)&&e.push(o.middlewareObject)})),qi(this,zi,e,"f")};const to="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZG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",oo={CURSOR:"cursor",CHANGE:"change",RULER:"ruler",SCALE:"scale",SELECT:"select",CLEAR_SELECT:"clearSelect",TEXT_EDIT:"textEdit",TEXT_CHANGE:"textChange",CONTEXT_MENU:"contextMenu",SELECT_IN_GROUP:io,SNAP_TO_GRID:io},no={};Object.keys(oo).forEach((e=>{Object.defineProperty(no,e,{value:oo[e],writable:!1})}));class ao{constructor(e,d){I(this,r),I(this,s),I(this,c),I(this,f),I(this,g),I(this,t,void 0),I(this,i,void 0),I(this,o,null),I(this,n,null),I(this,a,{auto:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZ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y8ekAQuZc2W8P8nEei9p9mMmPgAfJHO0O27e0lHppw9MEDJo//A4eoE91iB48SJ80lFMB/t/+V/sPGZfTmtMFR4EAAAAASUVORK5CYII="}),A(this,i,e),A(this,t,d.eventHub),M(this,r,l).call(this),M(this,s,h).call(this)}}t=new WeakMap,i=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,l=function(){const e=b(this,t);M(this,c,d).call(this,"default"),e.on(no.CURSOR,(e=>{var t;"over-element"!==e.type&&e.type?"resize-rotate"===e.type?M(this,c,d).call(this,"rotate"):"string"==typeof e.type&&(null==(t=e.type)?void 0:t.startsWith("resize-"))?M(this,f,u).call(this,e):"drag-default"===e.type?M(this,c,d).call(this,"drag-default"):"drag-active"===e.type?M(this,c,d).call(this,"drag-active"):M(this,c,d).call(this,"auto"):M(this,c,d).call(this,"auto")}))},s=new WeakSet,h=function(){j(to).then((e=>{A(this,n,e)})).catch((e=>{console.error(e)}))},c=new WeakSet,d=function(e){if(b(this,o)===e)return;A(this,o,e);const t=b(this,a)[b(this,o)]||b(this,a).auto;let n=0,r=0;(e.startsWith("rotate-")&&b(this,a)[b(this,o)]||"rotate"===e)&&(n=10,r=10),b(this,i).style.cursor="default"===e?"default":`image-set(url(${t})2x) ${n} ${r}, auto`},f=new WeakSet,u=function(e){var t;let i=0;"resize-top"===e.type?i+=0:"resize-top-right"===e.type?i+=45:"resize-right"===e.type?i+=90:"resize-bottom-right"===e.type?i+=135:"resize-bottom"===e.type?i+=180:"resize-bottom-left"===e.type?i+=225:"resize-left"===e.type?i+=270:"resize-top-left"===e.type&&(i+=315),i+=Se((null==(t=null==e?void 0:e.element)?void 0:t.angle)||0),Array.isArray(e.groupQueue)&&e.groupQueue.length>0&&e.groupQueue.forEach((e=>{i+=Se(e.angle||0)})),i=Se(i);const o=M(this,g,v).call(this,i);M(this,c,d).call(this,o)},g=new WeakSet,v=function(e){const t=`rotate-${e}`;if(!b(this,a)[t]){const i=b(this,n);if(i){const o=document.createElement("canvas"),n=i.width,r=i.height,l={x:n/2,y:r/2};o.width=n,o.height=r;const s=o.getContext("2d"),h=ce(e);s.translate(l.x,l.y),s.rotate(h),s.translate(-l.x,-l.y),s.drawImage(i,0,0,n,r),s.translate(l.x,l.y),s.rotate(-h),s.translate(-l.x,-l.y);const c=o.toDataURL("image/png");b(this,a)[t]=c}}return t};const ro="SELECT",lo=Symbol(`${ro}_actionType`),so=Symbol(`${ro}_resizeType`),ho=Symbol(`${ro}_areaStart`),co=Symbol(`${ro}_areaEnd`),fo=Symbol(`${ro}_hoverElement`),uo=Symbol(`${ro}_hoverElementVertexes`),go=Symbol(`${ro}_selectedElementList`),vo=Symbol(`${ro}_selectedElementListVertexes`),mo=Symbol(`${ro}_selectedElementController`),wo=Symbol(`${ro}_selectedElementPosition`),yo=Symbol(`${ro}_groupQueue`),po=Symbol(`${ro}_groupQueueVertexesList`),xo=Symbol(`${ro}_isMoving`),So=Symbol(`${ro}_enableSelectInGroup`),bo=Symbol(`${ro}_enableSnapToGrid`),Io={activeColor:"#1973ba",activeAreaColor:"#1976d21c",lockedColor:"#5b5959b5",referenceColor:"#f7276e"};function Ao(e,t,i){const{borderColor:o,borderWidth:n,background:a,lineDash:r}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.fillStyle=a,e.setLineDash(r),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.lineTo(t[0].x,t[0].y),e.closePath(),e.stroke(),e.fill()}function Mo(e,t,i,o){const{borderColor:n,borderWidth:a,lineDash:r}=o;e.setLineDash([]),e.lineWidth=a,e.strokeStyle=n,e.setLineDash(r),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke()}function Ro(e,t,i){const{borderColor:o,borderWidth:n,lineDash:a}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.setLineDash(a),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[2].x,t[2].y),e.closePath(),e.stroke(),e.beginPath(),e.moveTo(t[1].x,t[1].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function To(e,t,i){const{size:o,borderColor:n,borderWidth:a,lineDash:r}=i,l=t.x-o/2,s=t.x+o/2,h=t.y-o/2,c=t.y+o/2;Ro(e,[{x:l,y:h},{x:s,y:h},{x:s,y:c},{x:l,y:c}],{borderColor:n,borderWidth:a,lineDash:r})}function zo(e,t,i){if(!t)return;const{style:o}=i,{activeColor:n}=o,a={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};Ao(e,Le(t,i),a)}function Po(e,t,i){if(!t)return;const{style:o}=i,{lockedColor:n}=o,a={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};Ao(e,Le(t,i),a);const{controller:r}=i;if(r){const{topLeft:t,topRight:o,bottomLeft:l,bottomRight:s,topMiddle:h,bottomMiddle:c,leftMiddle:d,rightMiddle:f}=r,u={...a,borderWidth:1,background:n};Ro(e,Le(h.vertexes,i),u),Ro(e,Le(c.vertexes,i),u),Ro(e,Le(d.vertexes,i),u),Ro(e,Le(f.vertexes,i),u),Ro(e,Le(t.vertexes,i),u),Ro(e,Le(o.vertexes,i),u),Ro(e,Le(l.vertexes,i),u),Ro(e,Le(s.vertexes,i),u)}}function Co(e,t,i){if(!t)return;const{hideControllers:o,style:n}=i,{activeColor:a}=n,{elementWrapper:r,topLeft:l,topRight:s,bottomLeft:h,bottomRight:c,top:d,rotate:f}=t,u={borderColor:a,borderWidth:2,background:"transparent",lineDash:[]},g={...u,borderWidth:4,background:"#FFFFFF"};Ao(e,Le(r,i),u),o||(Mo(e,ke(d.center,i),ke(f.center,i),{...g,borderWidth:2}),Ao(e,Le(l.vertexes,i),g),Ao(e,Le(s.vertexes,i),g),Ao(e,Le(h.vertexes,i),g),Ao(e,Le(c.vertexes,i),g),function(e,t,i){const{size:o,borderColor:n,borderWidth:a,background:r}=i,l=t,s=o/2,h=s,c=s;if(h>=0&&c>=0){if("number"==typeof a&&a>0){const t=a/2+h,i=a/2+c;e.beginPath(),e.strokeStyle=n,e.lineWidth=a,e.circle(l.x,l.y,t,i,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath(),e.fillStyle=r,e.circle(l.x,l.y,h,c,0,0,2*Math.PI),e.closePath(),e.fill()}}(e,ke(f.center,i),{...g,size:10,borderWidth:2}))}function Eo(e,t){const{xLines:i,yLines:o,style:n}=t,{referenceColor:a}=n,r={borderColor:a,borderWidth:1,lineDash:[]},l={...r,size:6};i&&i.forEach((t=>{t.forEach(((i,o)=>{To(e,i,l),t[o+1]&&Mo(e,t[o],t[o+1],r)}))})),o&&o.forEach((t=>{t.forEach(((i,o)=>{To(e,i,l),t[o+1]&&Mo(e,t[o],t[o+1],r)}))}))}function Wo(e){return e*Math.PI/180}function ko(e,t){return Math.sqrt(e*e+t*t)}function Lo(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Oo(e,t){const{ctx:i,viewScaleInfo:o,vertexes:n}=t,a=ke(n[0],{viewScaleInfo:o}),r=ke(n[1],{viewScaleInfo:o}),l=ke(n[2],{viewScaleInfo:o}),s=ke(n[3],{viewScaleInfo:o});return i.beginPath(),i.moveTo(a.x,a.y),i.lineTo(r.x,r.y),i.lineTo(l.x,l.y),i.lineTo(s.x,s.y),i.lineTo(a.x,a.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function jo(e,t){const{ctx:i,viewScaleInfo:o,viewSizeInfo:n,groupQueue:a}=t;if(!(a&&(null==a?void 0:a.length)>0))return!1;const r=Ce(a),l=r[r.length-1];return!!l&&Oo(e,{ctx:i,vertexes:l,viewScaleInfo:o,viewSizeInfo:n})}function Do(e,t){var i,o,n;const a={type:null,elements:[],elementVertexesList:[],groupQueue:[],groupQueueVertexesList:[]},{ctx:r,data:l,calculator:s,selectedElements:h,viewScaleInfo:c,viewSizeInfo:d,areaSize:f,groupQueue:u,selectedElementController:g}=t;if(g){const{left:t,right:i,top:o,bottom:n,topLeft:l,topRight:s,bottomLeft:f,bottomRight:v,rotate:m}=g,w=[t,i,o,n,l,s,f,v,m];for(let t=0;t<w.length;t++){const i=w[t];if(Oo(e,{ctx:r,vertexes:i.vertexes,viewSizeInfo:d,viewScaleInfo:c})){a.type=`resize-${i.type}`,h&&(null==h?void 0:h.length)>0&&(a.groupQueue=u||[],a.elements=[h[0]]);break}}}if(u&&Array.isArray(u)&&u.length>0){const t=u[u.length-1];if((null==(i=null==t?void 0:t.detail)?void 0:i.children)&&Array.isArray(null==(o=null==t?void 0:t.detail)?void 0:o.children))for(let i=t.detail.children.length-1;i>=0;i--){const o=t.detail.children[i],n=Ee(o,{groupQueue:u});if(n&&Oo(e,{ctx:r,vertexes:n,viewScaleInfo:c,viewSizeInfo:d}))return a.type||(a.type="over-element"),a.groupQueue=u,a.elements=[o],a}return a}if(null!==a.type)return a;if(f&&Array.isArray(h)&&(null==h?void 0:h.length)>1){const{x:t,y:i,w:o,h:n}=f;if(e.x>=t&&e.x<=t+o&&e.y>=i&&e.y<=i+n)return a.type="list-area",a.elements=h,a}if(l){const{index:t,element:i}=s.getPointElement(e,{data:l,viewScaleInfo:c,viewSizeInfo:d});if(t>=0&&i&&!0!==(null==(n=null==i?void 0:i.operations)?void 0:n.invisible))return a.elements=[i],a.type="over-element",a}return a}function Yo(e,t){const{x:i,y:o,w:n,h:a,angle:r=0}=e,{center:l,start:s,end:h,viewScaleInfo:c}=t,d=ke(l,{viewScaleInfo:c}),f=Se(r),u=function(e,t,i){const o=ve(e,t),n=ve(e,i);return null!==n&&null!==o?o>3*Math.PI/2&&n<Math.PI/2?n+(2*Math.PI-o):n>3*Math.PI/2&&o<Math.PI/2?o+(2*Math.PI-n):n-o:0}(d,s,h);return{x:i,y:o,w:n,h:a,angle:f+u/Math.PI*180}}function Vo(e,t){var i;if(!Array.isArray(e))return null;const o={x:0,y:0,w:0,h:0},{viewScaleInfo:n}=t;let a=null;for(let t=0;t<e.length;t++){const r=e[t];if(null==(i=null==r?void 0:r.operations)?void 0:i.invisible)continue;const l=We(r,{viewScaleInfo:n});if(l.angle&&(l.angle>0||l.angle<0)){const e=pe(l);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];l.x=Math.min(...t),l.y=Math.min(...i),l.w=Math.abs(Math.max(...t)-Math.min(...t)),l.h=Math.abs(Math.max(...i)-Math.min(...i))}}if(a){const e=Math.min(l.x,o.x),t=Math.min(l.y,o.y),i=Math.max(l.x+l.w,o.x+o.w),n=Math.max(l.y+l.h,o.y+o.h);o.x=e,o.y=t,o.w=Math.abs(i-e),o.h=Math.abs(n-t)}else o.x=l.x,o.y=l.y,o.w=l.w,o.h=l.h;a=l}return o}function Bo(e){return{minX:e.topLeft.x,minY:e.topLeft.y,maxX:e.bottomRight.x,maxY:e.bottomRight.y,midX:e.center.x,midY:e.center.y}}const Go=(e,t)=>{if(0===e.length)throw null;if(1===e.length)return e[0];let i=0,o=e.length-1;for(;i<=o;){const n=Math.floor((i+o)/2);if(e[n]===t)return e[n];e[n]<t?i=n+1:o=n-1}return i>=e.length?e[o]:o<0?e[i]:Math.abs(e[o]-t)<=Math.abs(e[i]-t)?e[o]:e[i]},Xo=(e,t)=>Math.abs(e-t)<1e-5;function No(e,t){var i,o;const{data:n,groupQueue:a,calculator:r,viewScaleInfo:l,viewSizeInfo:s}=t;let h=n.elements||[];(null==a?void 0:a.length)>0&&(h=(null==(o=null==(i=a[a.length-1])?void 0:i.detail)?void 0:o.children)||[]);const c=[];h.forEach((t=>{if(t.uuid!==e){const e=r.calcViewRectInfoFromRange(t.uuid,{checkVisible:!0,viewScaleInfo:l,viewSizeInfo:s});e&&c.push(e)}}));const d=r.calcViewRectInfoFromRange(e,{viewScaleInfo:l,viewSizeInfo:s});if(!d)return null;const f={},u={},g={},v={},m=[],w=[];let y=[],p=[];const x=Bo(d);f[x.minX]=[x.minY,x.midY,x.maxY],f[x.midX]=[x.minY,x.midY,x.maxY],f[x.maxX]=[x.minY,x.midY,x.maxY],u[x.minY]=[x.minX,x.midX,x.maxX],u[x.midY]=[x.minX,x.midX,x.maxX],u[x.maxY]=[x.minX,x.midX,x.maxX],c.forEach((e=>{const t=Bo(e);g[t.minX]||(g[t.minX]=[]),g[t.midX]||(g[t.midX]=[]),g[t.maxX]||(g[t.maxX]=[]),v[t.minY]||(v[t.minY]=[]),v[t.midY]||(v[t.midY]=[]),v[t.maxY]||(v[t.maxY]=[]),g[t.minX]=[t.minY,t.midY,t.maxY],g[t.midX]=[t.minY,t.midY,t.maxY],g[t.maxX]=[t.minY,t.midY,t.maxY],y.push(t.minX),y.push(t.midX),y.push(t.maxX),v[t.minY]=[t.minX,t.midX,t.maxX],v[t.midY]=[t.minX,t.midX,t.maxX],v[t.maxY]=[t.minX,t.midX,t.maxX],p.push(t.minY),p.push(t.midY),p.push(t.maxY)})),y=y.sort(((e,t)=>e-t)),p=p.sort(((e,t)=>e-t));let S=null,b=null,I=null,A=null,M=null,R=null,T=null,z=null;if(y.length>0){I=Go(y,x.minX),A=Go(y,x.midX),M=Go(y,x.maxX);const e=Math.abs(I-x.minX),t=Math.abs(A-x.midX),i=Math.abs(M-x.maxX),o=Math.min(e,t,i);o<=2/l.scale&&(Xo(o,e)?S=I-x.minX:Xo(o,t)?S=A-x.midX:Xo(o,i)&&(S=M-x.maxX))}if(p.length>0){R=Go(p,x.minY),T=Go(p,x.midY),z=Go(p,x.maxY);const e=Math.abs(R-x.minY),t=Math.abs(T-x.midY),i=Math.abs(z-x.maxY),o=Math.min(e,t,i);o<=2/l.scale&&(Xo(o,e)?b=R-x.minY:Xo(o,t)?b=T-x.midY:Xo(o,i)&&(b=z-x.maxY))}const P={...x};if(null!==S&&(P.minX+=S,P.midX+=S,P.maxX+=S),null!==b&&(P.minY+=b,P.midY+=b,P.maxY+=b),N.x(S)&&null!==S&&null!==I&&null!==A&&null!==M){if(Xo(S,I-x.minX)){const e={x:I,yList:[]};e.yList.push(P.minY),e.yList.push(P.maxY),e.yList.push(...(null==v?void 0:v[I])||[]),m.push(e)}if(Xo(S,A-x.minX)){const e={x:A,yList:[]};e.yList.push(P.minY),e.yList.push(P.maxY),e.yList.push(...(null==v?void 0:v[A])||[]),m.push(e)}if(Xo(S,M-x.minX)){const e={x:M,yList:[]};e.yList.push(P.minY),e.yList.push(P.maxY),e.yList.push(...(null==v?void 0:v[M])||[]),m.push(e)}}if(N.y(b)&&null!==b&&null!==R&&null!==T&&null!==z){if(Xo(b,R-x.minY)){const e={y:R,xList:[]};e.xList.push(P.minX),e.xList.push(P.maxX),e.xList.push(...(null==g?void 0:g[R])||[]),w.push(e)}if(Xo(b,T-x.midY)){const e={y:T,xList:[]};e.xList.push(P.minX),e.xList.push(P.maxX),e.xList.push(...(null==g?void 0:g[R])||[]),w.push(e)}if(Xo(b,z-x.maxY)){const e={y:z,xList:[]};e.xList.push(P.minX),e.xList.push(P.maxX),e.xList.push(...(null==g?void 0:g[z])||[]),w.push(e)}}const C=[];(null==m?void 0:m.length)>0&&m.forEach(((e,t)=>{C.push([]),e.yList.forEach((i=>{C[t].push({x:e.x,y:i})}))}));const E=[];return(null==w?void 0:w.length)>0&&w.forEach(((e,t)=>{E.push([]),e.xList.forEach((i=>{E[t].push({x:i,y:e.y})}))})),{offsetX:S,offsetY:b,yLines:C,xLines:E}}const Fo="LAYOUT_SELECT",Ho=Symbol(`${Fo}_layoutActionType`),Zo=Symbol(`${Fo}_layoutControlType`),Qo=Symbol(`${Fo}_layoutController`),Uo=Symbol(`${Fo}_layoutIsHover`),Jo=Symbol(`${Fo}_layoutIsSelected`),$o={activeColor:"#b331c9"};function Ko(e,t,i){const{activeColor:o}=i;e.setLineDash([]),e.fillStyle="#FFFFFF",e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.fill(),e.strokeStyle=o,e.lineWidth=2,e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function qo(e,t){const{start:i,end:o,style:n}=t,{activeColor:a}=n,r=a;e.setLineDash([]),e.strokeStyle=r,e.lineWidth=2,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,o.y),e.closePath(),e.stroke()}const _o="SCROLL",en=Symbol(`${_o}_xThumbRect`),tn=Symbol(`${_o}_yThumbRect`),on=Symbol(`${_o}_hoverXThumbRect`),nn=Symbol(`${_o}_hoverYThumbRect`),an=Symbol(`${_o}_prevPoint`),rn=Symbol(`${_o}_activePoint`),ln=Symbol(`${_o}_activeThumbType`),sn={thumbBackground:"#0000003A",thumbBorderColor:"#0000008A",hoverThumbBackground:"#0000005F",hoverThumbBorderColor:"#000000EE",activeThumbBackground:"#0000005E",activeThumbBorderColor:"#000000F0"},hn=16,cn=2.5*hn;function dn(e,t,i){const o=e,{x:n,y:a,w:r,h:l}=i;return o.beginPath(),o.rect(n,a,r,l),o.closePath(),!!o.isPointInPath(t.x,t.y)}function fn(e,t){let{x:i,y:o,h:n,w:a,background:r,borderColor:l}=t;e.save(),e.shadowColor="#FFFFFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=1;{const{axis:s}=t;"X"===s?(o=o+n/4+0,n/=2):"Y"===s&&(i=i+a/4+0,a/=2);let h=t.r;h=Math.min(h,a/2,n/2),(a<2*h||n<2*h)&&(h=0),e.globalAlpha=1,e.beginPath(),e.moveTo(i+h,o),e.arcTo(i+a,o,i+a,o+n,h),e.arcTo(i+a,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+a,o,h),e.closePath(),e.fillStyle=r,e.fill(),e.beginPath(),e.lineWidth=1,e.strokeStyle=l,e.setLineDash([]),e.moveTo(i+h,o),e.arcTo(i+a,o,i+a,o+n,h),e.arcTo(i+a,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+a,o,h),e.closePath(),e.stroke()}e.restore()}function un(e,t){const i=e,{viewScaleInfo:o,viewSizeInfo:n,scrollInfo:a,style:r}=t,{activeThumbType:l,prevPoint:s,activePoint:h,hoverXThumb:c,hoverYThumb:d}=a,f=function(e){const{viewScaleInfo:t,viewSizeInfo:i,hoverXThumb:o,hoverYThumb:n,style:a}=e,{width:r,height:l}=i,{offsetTop:s,offsetBottom:h,offsetLeft:c,offsetRight:d}=t,f=cn,u=hn,{thumbBackground:g,thumbBorderColor:v,hoverThumbBackground:m,hoverThumbBorderColor:w}=a;let y=0,p=0;y=Math.max(f,r-2*u-(Math.abs(c)+Math.abs(d))),y>=r&&(y=r),p=Math.max(f,l-2*u-(Math.abs(s)+Math.abs(h))),p>=l&&(p=l);const x=u;let S=x;c>0?S=x:d>0?S=r-y-u:c<=0&&y>0&&(0!==c||0!==d)&&(S=x+(r-y)*Math.abs(c)/(Math.abs(c)+Math.abs(d)),S=Math.min(Math.max(0,S-x),r-y));const b=u;let I=b;return s>0?I=b:h>0?I=l-p-u:s<=0&&p>0&&(0!==s||0!==h)&&(I=b+(l-p)*Math.abs(s)/(Math.abs(s)+Math.abs(h)),I=Math.min(Math.max(0,I-b),l-p)),{lineSize:u,xSize:y,ySize:p,translateY:I,translateX:S,xThumbBackground:o?m:g,yThumbBackground:n?m:g,xThumbBorderColor:o?w:v,yThumbBorderColor:n?w:v,xThumbRect:{x:S,y:l-u,w:y,h:u},yThumbRect:{x:r-u,y:I,w:u,h:p}}}({viewScaleInfo:o,viewSizeInfo:n,hoverXThumb:c,hoverYThumb:d,style:r});let u={...f.xThumbRect},g={...f.yThumbRect};return l&&s&&h&&("X"===l&&a.xThumbRect?(u={...a.xThumbRect},u.x=u.x+(h.x-s.x)):"Y"===l&&a.yThumbRect&&(g={...a.yThumbRect},g.y=g.y+(h.y-s.y))),fn(i,{axis:"X",...u,r:f.lineSize/2,background:f.xThumbBackground,borderColor:f.xThumbBorderColor}),fn(i,{axis:"Y",...g,r:f.lineSize/2,background:f.yThumbBackground,borderColor:f.yThumbBorderColor}),{xThumbRect:u,yThumbRect:g}}function gn(e,t){const{snapshot:i,style:o}=t,n=he(i),a=se(i),r=function(e){const{sharedStore:t}=e;return{activePoint:t[rn]||null,prevPoint:t[an]||null,activeThumbType:t[ln]||null,xThumbRect:t[en]||null,yThumbRect:t[tn]||null,hoverXThumb:t[on],hoverYThumb:t[nn]}}(i),{xThumbRect:l,yThumbRect:s}=un(e,{viewSizeInfo:n,viewScaleInfo:a,scrollInfo:r,style:o});return{xThumbRect:l,yThumbRect:s}}const vn=16,mn="monospace",wn={background:"#FFFFFFA8",borderColor:"#00000080",scaleColor:"#000000",textColor:"#00000080",gridColor:"#AAAAAA20",gridPrimaryColor:"#AAAAAA40",selectedAreaColor:"#196097"},yn=[1,2,5,10,20,50,100,200,500];function pn(e){const{scale:t,viewLength:i,viewOffset:o}=e,n=[];let a=10;a=Fe(a/t,{decimalPlaces:0}),a=function(e){e=Math.max(yn[0],Math.min(e,yn[yn.length-1]));for(let t=0;t<yn.length-1;t++){const i=yn[t],o=yn[t+1];if(!(e>o))return e===i||e===o?e:e<=(i+o)/2?i:o}return e}(a);const r=10*a,l=5*a;let s=0;const h=a*t,c=0-o,d=c%h,f=(c-d+h)/t,u=h-d+0;for(;u+s*h<i;){const e=Fe(f+s*a,{decimalPlaces:0}),t={num:e,position:Fe(u+s*h,{decimalPlaces:0}),showNum:e%r==0,isKeyNum:e%r==0,isSubKeyNum:e%l==0};n.push(t),s++}return{list:n,rulerUnit:a}}const xn={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"},Sn=Symbol("DRAG_prevPoint"),bn="monospace";const In={textBackground:"#1973bac6",textColor:"#ffffff"},An=10;return m=new WeakMap,w=new WeakMap,y=new WeakMap,p=new WeakSet,x=function(){b(this,y).style.position="relative"},e.Core=class{constructor(e,t){I(this,p),I(this,m,void 0),I(this,w,void 0),I(this,y,void 0);const{devicePixelRatio:i=1,width:o,height:n,createCustomContext2D:a}=t;A(this,y,e);const r=document.createElement("canvas");A(this,w,r),M(this,p,x).call(this),e.appendChild(r);const l=function(e,t){const{width:i,height:o,devicePixelRatio:n,offscreen:a,createCustomContext2D:r}=t,l={width:i,height:o,devicePixelRatio:n},s=e.getContext("2d");if(r){const e=r(l),t=r(l),i=r(l),o=J(Object.assign({ctx:s},l)),n=()=>{const{width:n,height:a}=e.$getSize();o.clearRect(0,0,n,a),o.drawImage(i.canvas,0,0,n,a),o.drawImage(e.canvas,0,0,n,a),o.drawImage(t.canvas,0,0,n,a),i.clearRect(0,0,n,a),e.clearRect(0,0,n,a),t.clearRect(0,0,n,a)};return{underlayContext:i,viewContext:e,overlayContext:t,boardContext:o,drawView:n}}if(!0===a){const e=$(l),t=$(l),i=$(l),o=J(Object.assign({ctx:s},l)),n=()=>{const{width:n,height:a}=e.$getSize();o.clearRect(0,0,n,a),o.drawImage(i.canvas,0,0,n,a),o.drawImage(e.canvas,0,0,n,a),o.drawImage(t.canvas,0,0,n,a),i.clearRect(0,0,n,a),e.clearRect(0,0,n,a),t.clearRect(0,0,n,a)};return{underlayContext:i,viewContext:e,overlayContext:t,boardContext:o,drawView:n}}{const e=J(l),t=J(l),n=J(l),a=J(Object.assign({ctx:s},l)),r=()=>{a.clearRect(0,0,i,o),a.drawImage(n.canvas,0,0,i,o),a.drawImage(e.canvas,0,0,i,o),a.drawImage(t.canvas,0,0,i,o),n.clearRect(0,0,i,o),e.clearRect(0,0,i,o),t.clearRect(0,0,i,o)};return{underlayContext:n,viewContext:e,overlayContext:t,boardContext:a,drawView:r}}}(r,{width:o,height:n,devicePixelRatio:i,offscreen:!0,createCustomContext2D:a}),s=new eo({boardContent:l,container:e}),h=s.getSharer();h.setActiveViewSizeInfo({width:o,height:n,devicePixelRatio:i,contextWidth:o,contextHeight:n}),A(this,m,s),this.resize(h.getActiveViewSizeInfo());const c=s.getEventHub();new ao(e,{eventHub:c})}isDestroyed(){return b(this,m).isDestroyed()}destroy(){b(this,m).destroy(),b(this,w).remove()}use(e,t){b(this,m).use(e,t)}disuse(e){b(this,m).disuse(e)}setData(e,t){be((null==e?void 0:e.elements)||[]),b(this,m).setData(e,t)}getData(){return b(this,m).getData()}scale(e){b(this,m).scale(e);b(this,m).getViewer().drawFrame()}resize(e){const t=b(this,m),i=t.getSharer().getActiveViewSizeInfo();t.resize({...i,...e})}clear(){b(this,m).clear()}on(e,t){b(this,m).getEventHub().on(e,t)}off(e,t){b(this,m).getEventHub().off(e,t)}trigger(e,t){b(this,m).getEventHub().trigger(e,t)}getViewInfo(){const e=b(this,m).getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){b(this,m).getViewer().drawFrame()}setViewScale(e){b(this,m).updateViewScaleInfo(e)}getLoadItemMap(){return b(this,m).getRenderer().getLoadItemMap()}onBoardWatcherEvents(){b(this,m).onWatcherEvents()}offBoardWatcherEvents(){b(this,m).offWatcherEvents()}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:o}=e;let n=!1;return{name:"@middleware/dragger",hover(){!0!==n&&t.trigger(no.CURSOR,{type:"drag-default"})},pointStart(e){const{point:o}=e;i.setSharedStorage(Sn,o),n=!0,t.trigger(no.CURSOR,{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(Sn);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(Sn,t)},pointEnd(){n=!1,i.setSharedStorage(Sn,null),t.trigger(no.CURSOR,{type:"drag-default"})}}},e.MiddlewareInfo=(e,t)=>{const{boardContent:i,calculator:o}=e,{overlayContext:n}=i,a={...In,...t},{textBackground:r,textColor:l}=a,s={textBackground:r,textColor:l};return{name:"@middleware/info",beforeDrawFrame({snapshot:e}){const{sharedStore:t}=e,i=t[go],a=t[lo],r=t[yo]||[];if(1===i.length){const t=i[0];if(t&&["select","drag","resize"].includes(a)){const i=se(e),a=he(e),{x:l,y:h,w:c,h:d,angle:f}=t,u=[...r,{uuid:z(),x:l,y:h,w:c,h:d,angle:f,type:"group",detail:{children:[]}}],g={viewScaleInfo:i,viewSizeInfo:a},v=o.calcViewRectInfoFromOrigin(t.uuid,g);let m=0;u.forEach((e=>{m+=e.angle||0}));const w=ce(Se(0-m));if(v){const e=null==v?void 0:v.center,i={topLeft:me(e,v.topLeft,w),topRight:me(e,v.topRight,w),bottomRight:me(e,v.bottomRight,w),bottomLeft:me(e,v.bottomLeft,w),center:me(e,v.center,w),top:me(e,v.top,w),right:me(e,v.right,w),bottom:me(e,v.bottom,w),left:me(e,v.left,w)},o=Fe(t.x,{decimalPlaces:2}),a=Fe(t.y,{decimalPlaces:2}),r=Fe(t.w,{decimalPlaces:2}),l=Fe(t.h,{decimalPlaces:2}),h=`${Fe(o,{decimalPlaces:0})},${Fe(a,{decimalPlaces:0})}`,c=`${Fe(r,{decimalPlaces:0})}x${Fe(l,{decimalPlaces:0})}`,d=`${Fe(t.angle||0,{decimalPlaces:0})}°`;!function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textColor:h,textBackground:c}=r;de(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:bn});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x-o/2-t,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x-o/2,y:i.y};e.setLineDash([]),e.fillStyle=c,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=h,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(n,{point:{x:i.bottom.x,y:i.bottom.y+An},rotateCenter:i.center,angle:m,text:c,fontSize:An,lineHeight:16,style:s}),function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textBackground:h,textColor:c}=r;de(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:bn});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(n,{point:{x:i.topLeft.x,y:i.topLeft.y-20},rotateCenter:i.center,angle:m,text:h,fontSize:An,lineHeight:16,style:s}),function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textBackground:h,textColor:c}=r;de(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:bn});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(n,{point:{x:i.top.x+An,y:i.top.y-20},rotateCenter:i.center,angle:m,text:d,fontSize:An,lineHeight:16,style:s})}}}}}},e.MiddlewareLayoutSelector=(e,t)=>{const{sharer:i,boardContent:o,calculator:n,viewer:a,eventHub:r}=e,{overlayContext:l}=o,s={...$o,...t},{activeColor:h}=s,c={activeColor:h};let d=null,f=null,u=null,g=null;const v=()=>{d=null,i.setSharedStorage(Ho,null),i.setSharedStorage(Zo,null),i.setSharedStorage(Qo,null),i.setSharedStorage(Uo,null),i.setSharedStorage(Jo,null),f=null,u=null,g=null},m=()=>{const e=i.getSharedStorage(lo);return!(!e||"area"===e)&&(v(),!0)},w=()=>{const e=i.getActiveStorage("data");if(null==e?void 0:e.layout){const{x:t,y:i,w:o,h:n}=e.layout;return{x:t,y:i,w:o,h:n}}return null},y=e=>{const t=w();if(t){const{x:o,y:n,w:a,h:r}=t;return function(e,t,i){return je(e,Pe(t))}(e,We({x:o-5,y:n-5,w:a+10,h:r+10},{viewScaleInfo:i.getActiveViewScaleInfo()}))}return!1},p=()=>{const e=i.getActiveViewScaleInfo(),t=w();if(t){const o=Xe(t,{viewScaleInfo:e,controllerSize:10});i.setSharedStorage(Qo,o)}else i.setSharedStorage(Qo,null)},x=e=>{const t=i.getActiveStorage("data"),o=i.getSharedStorage(Qo);if(o&&(null==t?void 0:t.layout)&&(null==e?void 0:e.point)){let t=null;if(o){const{topLeft:n,top:a,topRight:l,right:s,bottomRight:h,bottom:c,bottomLeft:d,left:f}=o,u=[n,a,l,s,h,c,d,f];for(let i=0;i<u.length;i++){const o=u[i];if(je(e.point,o.vertexes)){t=`${o.type}`;break}}if(t)return i.setSharedStorage(Zo,t),r.trigger(no.CLEAR_SELECT),t}}return null},S=e=>{!0!==g&&r.trigger(no.CURSOR,{type:e?`resize-${e}`:e,groupQueue:[],element:w()})};return{name:"@middleware/layout-selector",use:()=>{v(),p()},hover:e=>{if(!0!==g&&!m()&&(!i.getSharedStorage(fo)||(v(),0)))if(y(e.point)?i.setSharedStorage(Uo,!0):(i.setSharedStorage(Uo,!1),!0===f&&(a.drawFrame(),f=!1)),!0!==i.getSharedStorage(Jo))i.getSharedStorage(Uo)&&!f&&a.drawFrame(),f=i.getSharedStorage(Uo);else{const t=i.getSharedStorage(Ho),o=i.getActiveStorage("data");if(null==o?void 0:o.layout)if("resize"!==t){p();const t=x(e);t?S(t):(S(),i.setSharedStorage(Ho,null))}else{const t=x(e);S(t)}}},pointStart:e=>{if(m())return;y(e.point)?i.setSharedStorage(Jo,!0):(!0===u&&(v(),a.drawFrame()),i.setSharedStorage(Jo,!1)),p();const t=x(e);d=e.point,t&&i.setSharedStorage(Ho,"resize"),!0!==i.getSharedStorage(Jo)||u||a.drawFrame(),u=i.getSharedStorage(Jo)},pointMove:e=>{if(!i.getSharedStorage(Jo)&&m())return;const t=i.getSharedStorage(Ho),o=i.getSharedStorage(Zo),r=i.getActiveStorage("data");if("resize"===t&&o&&(null==r?void 0:r.layout)){if(d){g=!0;const t=i.getActiveStorage("scale"),l=e.point.x-d.x,s=e.point.y-d.y,h=l/t,c=s/t,{x:f,y:u,w:v,h:m,operations:w={}}=r.layout,{position:y="absolute"}=w;"top"===o?"relative"===y?(r.layout.h=n.toGridNum(m-c),a.scroll({moveY:s})):(r.layout.y=n.toGridNum(u+c),r.layout.h=n.toGridNum(m-c)):"right"===o?r.layout.w=n.toGridNum(v+h):"bottom"===o?r.layout.h=n.toGridNum(m+c):"left"===o?"relative"===y?(r.layout.w=n.toGridNum(v-h),a.scroll({moveX:l})):(r.layout.x=n.toGridNum(f+h),r.layout.w=n.toGridNum(v-h)):"top-left"===o?"relative"===y?(r.layout.w=n.toGridNum(v-h),r.layout.h=n.toGridNum(m-c),a.scroll({moveX:l,moveY:s})):(r.layout.x=n.toGridNum(f+h),r.layout.y=n.toGridNum(u+c),r.layout.w=n.toGridNum(v-h),r.layout.h=n.toGridNum(m-c)):"top-right"===o?"relative"===y?(a.scroll({moveY:s}),r.layout.w=n.toGridNum(v+h),r.layout.h=n.toGridNum(m-c)):(r.layout.y=n.toGridNum(u+c),r.layout.w=n.toGridNum(v+h),r.layout.h=n.toGridNum(m-c)):"bottom-right"===o?(r.layout.w=n.toGridNum(v+h),r.layout.h=n.toGridNum(m+c)):"bottom-left"===o&&("relative"===y?(a.scroll({moveX:l}),r.layout.w=n.toGridNum(v-h),r.layout.h=n.toGridNum(m+c)):(r.layout.x=n.toGridNum(f+h),r.layout.w=n.toGridNum(v-h),r.layout.h=n.toGridNum(m+c)))}return d=e.point,p(),a.drawFrame(),!1}return!["resize"].includes(t)&&void 0},pointEnd:()=>{g=!1;const e=i.getSharedStorage(Ho),t=i.getSharedStorage(Zo),o=i.getActiveStorage("data");o&&"resize"===e&&t&&r.trigger(no.CHANGE,{type:"changeLayout",data:o})},beforeDrawFrame:({snapshot:e})=>{var t;if(m())return;const{sharedStore:i,activeStore:o}=e,n=i[Ho],a=i[Uo],r=i[Jo];if(null==(t=o.data)?void 0:t.layout){const{x:t,y:i,w:s,h:h}=o.data.layout,d=se(e),f={x:t,y:i,w:s,h:h},u=Xe(f,{viewScaleInfo:d,controllerSize:10});if(!0===a){const e=We(f,{viewScaleInfo:d});!function(e,t){const{layoutSize:i,style:o}=t,{activeColor:n}=o,{x:a,y:r,w:l,h:s}=i;e.setLineDash([]),e.strokeStyle=n,e.lineWidth=1,e.beginPath(),e.moveTo(a,r),e.lineTo(a+l,r),e.lineTo(a+l,r+s),e.lineTo(a,r+s),e.lineTo(a,r),e.closePath(),e.stroke()}(l,{layoutSize:e,style:c})}(n&&["resize"].includes(n)||!0===r)&&function(e,t){const{controller:i,style:o}=t,{topLeft:n,topRight:a,bottomLeft:r,bottomRight:l,topMiddle:s,rightMiddle:h,bottomMiddle:c,leftMiddle:d}=i;qo(e,{start:n.center,end:a.center,centerVertexes:s.vertexes,style:o}),qo(e,{start:a.center,end:l.center,centerVertexes:h.vertexes,style:o}),qo(e,{start:l.center,end:r.center,centerVertexes:c.vertexes,style:o}),qo(e,{start:r.center,end:n.center,centerVertexes:d.vertexes,style:o}),Ko(e,n.vertexes,o),Ko(e,a.vertexes,o),Ko(e,l.vertexes,o),Ko(e,r.vertexes,o)}(l,{controller:u,style:c})}},scrollX:()=>{v()},scrollY:()=>{v()},wheelScale:()=>{v()}}},e.MiddlewarePointer=e=>{const{boardContent:t,eventHub:i,sharer:o}=e,n=t.boardContext.canvas,a=e.container||document.body,r=`idraw-middleware-pointer-${Math.random().toString(26).substring(2)}`,l=document.createElement("div");return l.setAttribute("id",r),l.style.position="fixed",l.style.top="0",l.style.bottom="unset",l.style.left="0",l.style.right="unset",a.appendChild(l),{name:"@middleware/pointer",use(){},disuse(){},pointStart(e){},pointEnd(){},contextMenu(e){const{point:t}=e,{left:a,top:r}=(()=>{const e=n.getBoundingClientRect(),{left:t,top:i,width:o,height:a}=e;return{left:t,top:i,width:o,height:a}})();l.style.left=`${a+t.x}px`,l.style.top=`${r+t.y}px`;const s=o.getSharedStorage(go);i.trigger(no.CONTEXT_MENU,{pointerContainer:l,selectedElements:s||[]})}}},e.MiddlewareRuler=(e,t)=>{const{boardContent:i,viewer:o,eventHub:n,calculator:a}=e,{overlayContext:r,underlayContext:l}=i,s={...wn,...t},{background:h,borderColor:c,scaleColor:d,textColor:f,gridColor:u,gridPrimaryColor:g,selectedAreaColor:v}=s,m={background:h,borderColor:c,scaleColor:d,textColor:f,gridColor:u,gridPrimaryColor:g,selectedAreaColor:v};let w=!0,y=!0;const p=e=>{"boolean"==typeof(null==e?void 0:e.show)&&(w=e.show),"boolean"==typeof(null==e?void 0:e.showGrid)&&(y=e.showGrid),"boolean"!=typeof(null==e?void 0:e.show)&&"boolean"!=typeof(null==e?void 0:e.showGrid)||o.drawFrame()};return{name:"@middleware/ruler",use(){n.on(no.RULER,p)},disuse(){n.off(no.RULER,p)},beforeDrawFrame:({snapshot:e})=>{if(!0===w){const t=se(e),i=he(e);!function(e,t){const{snapshot:i,calculator:o,style:n}=t,{sharedStore:a}=i,{selectedAreaColor:r}=n,l=a[go],s=a[lo];if(["select","drag","drag-list","drag-list-end"].includes(s)&&l.length>0){const t=se(i),n=he(i),a=[],s=[],h=[],c=[],d=[];if(l.forEach((e=>{const i=o.calcViewRectInfoFromRange(e.uuid,{viewScaleInfo:t,viewSizeInfo:n});i&&(a.push(i),s.push(i.left.x),h.push(i.right.x),c.push(i.top.y),d.push(i.bottom.y))})),!(a.length>0))return;const f=Math.min(...s),u=Math.max(...h),g=Math.min(...c),v=Math.max(...d);e.globalAlpha=1,e.beginPath(),e.moveTo(f,0),e.lineTo(u,0),e.lineTo(u,vn),e.lineTo(f,vn),e.fillStyle=r,e.closePath(),e.fill(),e.beginPath(),e.moveTo(0,g),e.lineTo(vn,g),e.lineTo(vn,v),e.lineTo(0,v),e.fillStyle=r,e.closePath(),e.fill()}}(r,{snapshot:e,calculator:a,style:m}),function(e,t){const{viewSizeInfo:i,style:o}=t,{width:n,height:a}=i,{background:r,borderColor:l}=o;e.beginPath(),e.moveTo(0,0),e.lineTo(n+1,0),e.lineTo(n+1,vn),e.lineTo(vn,vn),e.lineTo(vn,a+1),e.lineTo(0,a+1),e.lineTo(0,0),e.closePath(),e.fillStyle=r,e.fill(),e.lineWidth=1,e.setLineDash([]),e.strokeStyle=l,e.stroke()}(r,{viewScaleInfo:t,viewSizeInfo:i,style:m});const{list:o,rulerUnit:n}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:n}=t,{width:a}=i;return pn({axis:"X",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:a}=o;for(let t=0;t<i.length;t++){const o=i[t];o.position<vn||(e.beginPath(),e.moveTo(o.position,16),e.lineTo(o.position,o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8),e.closePath(),e.lineWidth=1,e.setLineDash([]),e.fillStyle=n,e.stroke(),o.isKeyNum&&(e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:mn}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(r,{scaleList:o,style:m});const{list:s}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n}=t,{height:a}=i;return pn({axis:"Y",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});if(function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:a}=o,r=3.2;for(let t=0;t<i.length;t++){const o=i[t];if(!(o.position<vn)&&(e.beginPath(),e.moveTo(16,o.position),e.lineTo(o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8,o.position),e.closePath(),e.fillStyle=n,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===o.showNum)){const t=r,i=o.position+r,n=`${o.num}`;de(e,-90,{x:t,y:i},(()=>{e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:mn}),e.fillText(n,13.2,o.position+r)}))}}}(r,{scaleList:s,style:m}),!0===y){!function(e,t){const{xList:i,yList:o,viewSizeInfo:n,style:a}=t,{width:r,height:l}=n,{gridColor:s,gridPrimaryColor:h}=a;for(let t=0;t<i.length;t++){const o=i[t];e.beginPath(),e.moveTo(o.position,0),e.lineTo(o.position,l),!0===o.isKeyNum||!0===o.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=s,e.closePath(),e.lineWidth=1,e.setLineDash([]),e.stroke()}for(let t=0;t<o.length;t++){const i=o[t];e.beginPath(),e.moveTo(0,i.position),e.lineTo(r,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=s,e.lineWidth=1,e.closePath(),e.stroke()}}(1===n?r:l,{xList:o,yList:s,viewScaleInfo:t,viewSizeInfo:i,style:m})}}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:o}=e;return{name:"@middleware/scaler",wheelScale(e){const{deltaY:n,point:a}=e,{scale:r}=i.getActiveViewScaleInfo();let l=r;if(n<0?l=1.1*r:n>0&&(l=.9*r),l<.05||l>50)return;const{moveX:s,moveY:h}=t.scale({scale:l,point:a});t.scroll({moveX:s,moveY:h}),t.drawFrame();const c=Fe(r);o.trigger(no.SCALE,{scale:c})}}},e.MiddlewareScroller=(e,t)=>{const{viewer:i,boardContent:o,sharer:n,eventHub:a}=e,{overlayContext:r}=o;n.setSharedStorage(en,null),n.setSharedStorage(tn,null);let l=!1;const s={...sn,...t},{thumbBackground:h,thumbBorderColor:c,hoverThumbBackground:d,hoverThumbBorderColor:f,activeThumbBackground:u,activeThumbBorderColor:g}=s,v={thumbBackground:h,thumbBorderColor:c,hoverThumbBackground:d,hoverThumbBorderColor:f,activeThumbBackground:u,activeThumbBorderColor:g},m=()=>{n.setSharedStorage(an,null),n.setSharedStorage(rn,null),n.setSharedStorage(ln,null),n.setSharedStorage(on,null),n.setSharedStorage(nn,null),l=!1};m();const w=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:a}=i;return n&&dn(e,t,n)?o="X":a&&dn(e,t,a)&&(o="Y"),o}(r,e,{xThumbRect:n.getSharedStorage(en),yThumbRect:n.getSharedStorage(tn)});return{name:"@middleware/scroller",wheel:e=>{i.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),i.drawFrame()},hover:e=>{if(!0===l)return!1;const{point:t}=e,i=w(t);if("X"===i||"Y"===i)return"X"===i?(n.setSharedStorage(on,!0),n.setSharedStorage(nn,!1)):(n.setSharedStorage(on,!1),n.setSharedStorage(nn,!0)),a.trigger(no.CURSOR,{type:"default"}),!1;n.setSharedStorage(on,!1),n.setSharedStorage(nn,!1)},pointStart:e=>{const{point:t}=e,i=w(t);if("X"===i||"Y"===i)return l=!0,n.setSharedStorage(ln,i),n.setSharedStorage(an,t),!1},pointMove:e=>{const{point:t}=e,o=n.getSharedStorage(ln);if("X"===o||"Y"===o)return n.setSharedStorage(rn,t),"X"===o?(e=>{const t=n.getSharedStorage(an);if(t){const{offsetLeft:o,offsetRight:a}=n.getActiveViewScaleInfo(),{width:r}=n.getActiveViewSizeInfo(),l=-(e.x-t.x)*(r+Math.abs(o)+Math.abs(a))/r;i.scroll({moveX:l}),i.drawFrame()}})(t):"Y"===o&&(e=>{const t=n.getSharedStorage(an);if(t){const{offsetTop:o,offsetBottom:a}=n.getActiveViewScaleInfo(),{height:r}=n.getActiveViewSizeInfo(),l=-(e.y-t.y)*(r+Math.abs(o)+Math.abs(a))/r;i.scroll({moveY:l}),i.drawFrame()}})(t),n.setSharedStorage(an,t),!1},pointEnd:()=>{l=!1;const e=n.getSharedStorage(ln);if(m(),"X"===e||"Y"===e)return i.scroll({moveX:0,moveY:0}),i.drawFrame(),!1},beforeDrawFrame({snapshot:e}){const{xThumbRect:t,yThumbRect:i}=gn(r,{snapshot:e,style:v});n.setSharedStorage(en,t),n.setSharedStorage(tn,i)}}},e.MiddlewareSelector=(e,t)=>{const i={...Io,...t},{activeColor:o,activeAreaColor:n,lockedColor:a,referenceColor:r}=i,l={activeColor:o,activeAreaColor:n,lockedColor:a,referenceColor:r},{viewer:s,sharer:h,boardContent:c,calculator:d,eventHub:f}=e,{overlayContext:u}=c;let g=null,v=null,m=null,w=null;h.setSharedStorage(lo,null),h.setSharedStorage(bo,!0);const y=()=>h.getSharedStorage(go),p=e=>{let t=h.getSharedStorage(yo);Array.isArray(t)||(t=[]),t.length>0?!function(e,t){var i;if("group"===(null==t?void 0:t.type)&&Array.isArray(null==(i=null==t?void 0:t.detail)?void 0:i.children))for(let i=0;i<t.detail.children.length;i++){const o=t.detail.children[i];if(e.uuid===o.uuid)return!0}return!1}(e,t[t.length-1])?t=[]:t.push(e):0===t.length&&t.push(e);const i=Ce(t);return h.setSharedStorage(yo,t),h.setSharedStorage(po,i),t.length>0},x=e=>{h.setSharedStorage(fo,e);let t=null;e&&(t=Ee(e,{groupQueue:h.getSharedStorage(yo)})),h.setSharedStorage(uo,t)},S=(e,t)=>{var i;if(h.setSharedStorage(go,e),1===e.length){const t=Ge(e[0],{groupQueue:h.getSharedStorage(yo),controllerSize:10,viewScaleInfo:h.getActiveViewScaleInfo()});h.setSharedStorage(mo,t),h.setSharedStorage(wo,Te(e[0].uuid,(null==(i=h.getActiveStorage("data"))?void 0:i.elements)||[]))}else h.setSharedStorage(mo,null),h.setSharedStorage(wo,[]);!0===(null==t?void 0:t.triggerEvent)&&f.trigger(no.SELECT,{uuids:e.map((e=>e.uuid)),positions:[]})},b=()=>({ctx:u,calculator:d,data:h.getActiveStorage("data"),selectedElements:y(),viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),groupQueue:h.getSharedStorage(yo),areaSize:null,selectedElementController:h.getSharedStorage(mo),selectedElementPosition:h.getSharedStorage(wo)}),I=()=>{h.setSharedStorage(lo,null),h.setSharedStorage(so,null),h.setSharedStorage(ho,null),h.setSharedStorage(co,null),h.setSharedStorage(yo,[]),h.setSharedStorage(po,[]),h.setSharedStorage(fo,null),h.setSharedStorage(uo,null),h.setSharedStorage(go,[]),h.setSharedStorage(vo,null),h.setSharedStorage(mo,null),h.setSharedStorage(wo,[]),h.setSharedStorage(xo,null)};I();const A=({uuids:e=[],positions:t})=>{let i=[];const o=h.getSharedStorage(lo),n=h.getActiveStorage("data");i=t&&Array.isArray(t)?function(e,t){const i=[];return e.forEach((e=>{const o=Re(e,t);o&&i.push(o)})),i}(t,(null==n?void 0:n.elements)||[]):function(e,t){const i=[];return function t(o){var n;for(let a=0;a<o.length;a++){const r=o[a];e.includes(r.uuid)?i.push(r):"group"===r.type&&t((null===(n=null==r?void 0:r.detail)||void 0===n?void 0:n.children)||[])}}(t),i}(e,(null==n?void 0:n.elements)||[]);let a=!1;if(o||1!==i.length?"select"===o&&1===i.length&&(a=!0):(h.setSharedStorage(lo,"select"),a=!0),a){const e=function(e,t){const i=[];return function e(t,o){var n;let a=null;for(let r=0;r<o.length;r++){const l=o[r];if(l.uuid===t){a=l;break}if(!a&&"group"===l.type){i.push(l);const o=e(t,(null===(n=null==l?void 0:l.detail)||void 0===n?void 0:n.children)||[]);if((null==o?void 0:o.uuid)===t){a=o;break}i.pop()}}return a}(e,t),i}(i[0].uuid,(null==n?void 0:n.elements)||[]);h.setSharedStorage(yo,e),S(i),s.drawFrame()}},M=()=>{I(),s.drawFrame()},R=e=>{h.setSharedStorage(bo,!!e.enable)},T=e=>{h.setSharedStorage(So,!!e.enable)};return{name:"@middleware/selector",use(){f.on(no.SELECT,A),f.on(no.CLEAR_SELECT,M),f.on(no.SELECT_IN_GROUP,T),f.on(no.SNAP_TO_GRID,R)},disuse(){f.off(no.SELECT,A),f.off(no.CLEAR_SELECT,M),f.off(no.SELECT_IN_GROUP,T),f.off(no.SNAP_TO_GRID,R)},hover:e=>{var t,i,o,n,a;const r=h.getSharedStorage(Jo),l=h.getSharedStorage(so),c=h.getSharedStorage(lo),g=h.getSharedStorage(yo),v=e=>{if(!0===r)return;const t=e.type;null===w&&f.trigger(no.CURSOR,{type:t,groupQueue:e.groupQueue,element:e.elements[0]})};if((null==g?void 0:g.length)>0){if(!jo(e.point,{ctx:u,viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),groupQueue:h.getSharedStorage(yo)}))return x(null),void s.drawFrame();const i=Do(e.point,b());return v(i),l||["area","drag","drag-list"].includes(c)?(x(null),void s.drawFrame()):1===(null==(t=null==i?void 0:i.elements)?void 0:t.length)?(x(i.elements[0]),void s.drawFrame()):(x(null),void s.drawFrame())}if(l||["area","drag","drag-list"].includes(c))return void x(null);if("drag"===c)return void x(null);const m=y(),p=h.getActiveViewScaleInfo(),S=h.getActiveViewSizeInfo(),I=Do(e.point,{...b(),areaSize:Vo(m,{viewScaleInfo:p,viewSizeInfo:S,calculator:d})});if(v(I),null!==I.type){if(!("over-element"===I.type&&"select"===h.getSharedStorage(lo)&&1===I.elements.length&&I.elements[0].uuid===(null==(o=null==(i=y())?void 0:i[0])?void 0:o.uuid)||"over-element"===I.type&&null===h.getSharedStorage(lo)&&1===I.elements.length&&I.elements[0].uuid===(null==(n=h.getSharedStorage(fo))?void 0:n.uuid)))return"over-element"===I.type&&1===(null==(a=null==I?void 0:I.elements)?void 0:a.length)?(x(I.elements[0]),void s.drawFrame()):h.getSharedStorage(fo)?(x(null),void s.drawFrame()):void 0}else(h.getSharedStorage(fo)||h.getSharedStorage(uo))&&(h.setSharedStorage(fo,null),h.setSharedStorage(uo,null),s.drawFrame())},pointStart:e=>{var t,i,o,n,a,r,l,c,f,w,p,A;g=e.point,v=e.point;const M=h.getSharedStorage(yo);if((null==M?void 0:M.length)>0){if(jo(e.point,{ctx:u,viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),groupQueue:M})){const l=Do(e.point,b()),s=1===(null==(t=null==l?void 0:l.elements)?void 0:t.length)&&!0===(null==(o=null==(i=l.elements[0])?void 0:i.operations)?void 0:o.locked);x(null),1===(null==(n=null==l?void 0:l.elements)?void 0:n.length)&&(m=Me(null==l?void 0:l.elements[0])),!0===s?I():"over-element"===l.type&&1===(null==(a=null==l?void 0:l.elements)?void 0:a.length)?(S([l.elements[0]],{triggerEvent:!0}),h.setSharedStorage(lo,"drag")):(null==(r=l.type)?void 0:r.startsWith("resize-"))?(h.setSharedStorage(so,l.type),h.setSharedStorage(lo,"resize")):S([],{triggerEvent:!0})}else I();return void s.drawFrame()}const R=Vo(y(),{viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),calculator:d}),T=Do(e.point,{...b(),areaSize:R,groupQueue:[]}),z=1===(null==(l=null==T?void 0:T.elements)?void 0:l.length)&&!0===(null==(f=null==(c=T.elements[0])?void 0:c.operations)?void 0:f.locked);x(null),1===(null==(w=null==T?void 0:T.elements)?void 0:w.length)&&(m=Me(null==T?void 0:T.elements[0])),!0===z?(I(),h.setSharedStorage(lo,"area"),h.setSharedStorage(ho,e.point),S([],{triggerEvent:!0})):"list-area"===T.type?h.setSharedStorage(lo,"drag-list"):"over-element"===T.type&&1===(null==(p=null==T?void 0:T.elements)?void 0:p.length)?(S([T.elements[0]],{triggerEvent:!0}),h.setSharedStorage(lo,"drag")):(null==(A=T.type)?void 0:A.startsWith("resize-"))?(h.setSharedStorage(so,T.type),h.setSharedStorage(lo,"resize")):(I(),h.setSharedStorage(lo,"area"),h.setSharedStorage(ho,e.point),S([],{triggerEvent:!0})),s.drawFrame()},pointMove:e=>{var t,i,o;h.setSharedStorage(xo,!0);const n=h.getActiveStorage("data"),a=y(),r=h.getActiveStorage("scale")||1,l=h.getActiveViewScaleInfo(),c=h.getActiveViewSizeInfo(),f=g,u=v,p=e.point,x=h.getSharedStorage(so),b=h.getSharedStorage(lo),I=h.getSharedStorage(yo),A=h.getSharedStorage(bo);if("drag"===b){if(w="drag",n&&1===(null==a?void 0:a.length)&&m&&u&&p&&!0!==(null==(i=null==(t=a[0])?void 0:t.operations)?void 0:i.locked)){const{moveX:e,moveY:t}=function(e,t,i){let o=t.x-e.x,n=t.y-e.y;const a=[];if(i.forEach((e=>{const{x:t,y:i,w:o,h:n,angle:r=0}=e;a.push({x:t,y:i,w:o,h:n,angle:0-r})})),(null==i?void 0:i.length)>0){const i=we(e,a),r=we(t,a);o=r.x-i.x,n=r.y-i.y}return{moveX:o,moveY:n}}(u,p,I);let i=d.toGridNum(e/r),o=d.toGridNum(t/r);if(!0===A){const e=No(a[0].uuid,{calculator:d,data:n,groupQueue:I,viewScaleInfo:l,viewSizeInfo:c});try{e&&(N.x(e.offsetX)&&null!==e.offsetX&&(i=d.toGridNum(i+e.offsetX)),N.y(e.offsetY)&&null!==e.offsetY&&(o=d.toGridNum(o+e.offsetY)))}catch(e){console.error(e)}}a[0].x=d.toGridNum(m.x+i),a[0].y=d.toGridNum(m.y+o),S([a[0]]),d.modifyViewVisibleInfoMap(n,{modifyOptions:{type:"updateElement",content:{element:a[0],position:h.getSharedStorage(wo)||[]}},viewSizeInfo:c,viewScaleInfo:l})}s.drawFrame()}else if("drag-list"===b){if(w="drag-list",n&&u&&f&&p&&(null==a?void 0:a.length)>1){const e=(p.x-f.x)/r,t=(p.y-f.y)/r;a.forEach((i=>{var o;i&&!0!==(null==(o=null==i?void 0:i.operations)?void 0:o.locked)&&(i.x=d.toGridNum(i.x+e),i.y=d.toGridNum(i.y+t),d.modifyViewVisibleInfoMap(n,{modifyOptions:{type:"updateElement",content:{element:i,position:Te(i.uuid,n.elements)||[]}},viewSizeInfo:c,viewScaleInfo:l}))})),h.setActiveStorage("data",n)}s.drawFrame()}else if("resize"===b){if(n&&1===(null==a?void 0:a.length)&&u&&m&&(null==x?void 0:x.startsWith("resize-"))){w="resize";const e=[];I.forEach((t=>{const{x:i,y:o,w:n,h:a,angle:r=0}=t;e.push({x:i,y:o,w:n,h:a,angle:0-r})}));let t=u,i=p;if(I.length>0&&(t=we(u,e),i=we(p,e)),"resize-rotate"===x){const e=h.getSharedStorage(mo),t=ge([e.topLeft.center,e.topRight.center,e.bottomLeft.center,e.bottomRight.center]),i=Yo(m,{center:t,viewScaleInfo:l,viewSizeInfo:c,start:u,end:p,resizeType:x,sharer:h});a[0].angle=d.toGridNum(i.angle||0)}else{const e=function(e,t){var i,o,n,a,r,l,s,h,c;let{x:d,y:f,w:u,h:g,angle:v=0}=e;const m=ue({x:d,y:f,w:u,h:g,angle:v});v=Se(v);const w=ce(v),y=!!(null==(i=null==e?void 0:e.operations)?void 0:i.limitRatio),{start:p,end:x,resizeType:S,scale:b}=t;let I={...p},A={...x},M={x:I.x,y:m.y},R={x:A.x,y:m.y},T={...M},z={...R},P={x:m.x,y:I.y},C={x:m.x,y:A.y},E={...P},W={...C},k=(z.x-T.x)/b,L=(z.y-T.y)/b,O=ko(k,L),j=(W.x-E.x)/b,D=(W.y-E.y)/b,Y=ko(j,D);(v>0||v<0)&&(I=me(m,p,0-w),A=me(m,x,0-w),M={x:I.x,y:m.y},R={x:A.x,y:m.y},T=me(m,M,w),z=me(m,R,w),P={x:m.x,y:I.y},C={x:m.x,y:A.y},E=me(m,P,w),W=me(m,C,w),k=(z.x-T.x)/b,L=(z.y-T.y)/b,O=ko(k,L),O=Lo(O,L),j=(W.x-E.x)/b,D=(W.y-E.y)/b,Y=ko(j,D),Y=Lo(Y,D));let V=(x.x-p.x)/b,B=(x.y-p.y)/b;if(!0===y)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(S)){const t=Math.max(Math.abs(V),Math.abs(B));V=(V>=0?1:-1)*t,B=(B>=0?1:-1)*t/e.w*e.h;const i=Math.max(Math.abs(j),Math.abs(D));j=(j>=0?1:-1)*i,D=(D>=0?1:-1)*i/e.w*e.h;const o=Math.max(Math.abs(k),Math.abs(L));k=(k>=0?1:-1)*o,L=(L>=0?1:-1)*o/e.w*e.h}else if(["resize-top-left","resize-top-right","resize-bottom-left","resize-bottom-right"].includes(S)){{const t=Math.abs(V);V=(V>=0?1:-1)*t;const i=t/e.w*e.h;"resize-top-left"===S||"resize-bottom-right"===S?B=V>0?i:-i:"resize-top-right"!==S&&"resize-bottom-left"!==S||(B=V>0?-i:i)}O=Math.abs(O),Y=O/e.w*e.h}switch(S){case"resize-top":if(0===v)g-B>0&&(f+=B,g-=B,!0===(null==(o=e.operations)?void 0:o.limitRatio)&&(d+=B/e.h*e.w/2,u-=B/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=0-Lo(Y,D);const e=Wo(v),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){Y=Lo(Y,j);const e=Wo(v-90),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){Y=Lo(Y,D);const e=Wo(v-180),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){Y=0-Lo(Y,j);const e=Wo(v-270),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}g+Y>0&&(!0===(null==(n=e.operations)?void 0:n.limitRatio)&&(u+=Y/e.h*e.w),g+=Y,d=t-u/2,f=i-g/2)}break;case"resize-bottom":if(0===v)e.h+B>0&&(g+=B,!0===(null==(a=e.operations)?void 0:a.limitRatio)&&(d-=B/e.h*e.w/2,u+=B/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=Lo(Y,D);const e=Wo(v),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){Y=0-Lo(Y,j);const e=Wo(v-90),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){Y=Lo(Y,j);const e=Wo(v-180),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){Y=Lo(Y,j);const e=Wo(v-270),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}g+Y>0&&(!0===(null==(r=e.operations)?void 0:r.limitRatio)&&(u+=Y/e.h*e.w),g+=Y,d=t-u/2,f=i-g/2)}break;case"resize-left":if(0===v)e.w-V>0&&(d+=V,u-=V,!0===(null==(l=e.operations)?void 0:l.limitRatio)&&(g-=V/e.w*e.h,f+=V/e.w*e.h/2));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){O=0-Lo(O,k);const e=Wo(v),o=O/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){O=Lo(O,k);const e=Wo(v-90),o=O/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){O=Lo(O,L);const e=Wo(v-180),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){O=Lo(O,L);const e=Wo(v-270),o=O/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}u+O>0&&(!0===(null==(s=e.operations)?void 0:s.limitRatio)&&(g+=O/e.w*e.h),u+=O,d=t-u/2,f=i-g/2)}break;case"resize-right":if(0===v)e.w+V>0&&(u+=V,!0===(null==(h=e.operations)?void 0:h.limitRatio)&&(f-=V*e.h/e.w/2,g+=V*e.h/e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){O=Lo(O,L);const e=Wo(v),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){O=Lo(O,B);const e=Wo(v-90),o=O/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){O=Lo(O,B);const e=Wo(v-180),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e),O=0-O}else if(v<360){O=Lo(O,V);const e=Wo(v-270),o=O/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}u+O>0&&(!0===(null==(c=e.operations)?void 0:c.limitRatio)&&(g+=O/e.w*e.h),u+=O,d=t-u/2,f=i-g/2)}break;case"resize-top-left":if(0===v)u-V>0&&(d+=V,u-=V),g-B>0&&(f+=B,g-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-Lo(Y,D),O=0-Lo(O,y?0-Y:k);const i=Y/2;e+=i*Math.sin(w),t-=i*Math.cos(w);const o=O/2;e-=o*Math.cos(w),t-=o*Math.sin(w)}else if(v<180){Y=Lo(Y,j),O=Lo(O,y?Y:k);const i=Wo(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=Lo(Y,D),O=Lo(O,y?Y:L);const i=Wo(v-180),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=0-Lo(Y,j),O=Lo(O,y?Y:L);const i=Wo(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-top-right":if(0===v)u+V>0&&(u+=V),g-B>0&&(f+=B,g-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-Lo(Y,D),O=Lo(O,y?Y:L);const i=Wo(v),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=Lo(Y,j),O=Lo(O,y?Y:L);const i=Wo(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){const i=Wo(v-180);Y=Lo(Y,D),O=Lo(O,y?Y:0-k);const o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=0-Lo(Y,j),O=Lo(O,y?Y:k);const i=Wo(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-bottom-left":if(0===v)e.h+B>0&&(g+=B),e.w-V>0&&(d+=V,u-=V);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=Lo(Y,D),O=0-Lo(O,y?0-Y:k);const i=Wo(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<180){Y=0-Lo(Y,j),O=Lo(O,y?Y:k);const i=Wo(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=Lo(Y,j),O=Lo(O,y?Y:L);const i=Wo(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=Lo(Y,j),O=Lo(O,y?Y:L);const i=Wo(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-bottom-right":if(0===v)e.h+B>0&&(g+=B),e.w+V>0&&(u+=V);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=Lo(Y,D),O=Lo(O,y?Y:L);const i=Wo(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=0-Lo(Y,j),O=Lo(O,y?Y:B);const i=Wo(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){Y=Lo(Y,j),O=Lo(O,y?Y:0-L);const i=Wo(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=Lo(Y,j),O=Lo(O,y?Y:k);const i=Wo(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}}return{x:d,y:f,w:u,h:g,angle:e.angle}}(m,{scale:r,start:t,end:i,resizeType:x,sharer:h}),n={ignore:!!m.angle};a[0].x=d.toGridNum(e.x,n),a[0].y=d.toGridNum(e.y,n),"group"===a[0].type&&!0===(null==(o=a[0].operations)?void 0:o.deepResize)?function(e,t){const i=t.w&&t.w>0?t.w:e.w,o=t.h&&t.h>0?t.h:e.h,n=i/e.w,a=o/e.h;if(n===a&&1===n)return e;const r=Math.min(n,a),l=Math.max(n,a);e.w=i,e.h=o;const s={xRatio:n,yRatio:a,minRatio:r,maxRatio:l};"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Je(e,s)})),Ue(e,s)}(a[0],{w:d.toGridNum(e.w,n),h:d.toGridNum(e.h,n)}):(a[0].w=d.toGridNum(e.w,n),a[0].h=d.toGridNum(e.h,n))}S([a[0]]),d.modifyViewVisibleInfoMap(n,{modifyOptions:{type:"updateElement",content:{element:a[0],position:h.getSharedStorage(wo)||[]}},viewSizeInfo:c,viewScaleInfo:l}),s.drawFrame()}}else"area"===b&&(w="area",h.setSharedStorage(co,e.point),s.drawFrame());g=e.point},pointEnd(e){w=null,h.setSharedStorage(xo,!1);const t=h.getActiveStorage("data"),i=h.getSharedStorage(go),o=h.getSharedStorage(fo),n=h.getSharedStorage(so),a=h.getSharedStorage(lo),r=h.getActiveViewSizeInfo();let l=!1;if(g=null,v=null,m=null,"resize"===a&&n)h.setSharedStorage(so,null),l=!0;else if("area"===a){if(h.setSharedStorage(lo,null),t){const e=h.getSharedStorage(ho),i=h.getSharedStorage(co);if(e&&i){const{elements:o}=function(e,t){var i;const o=[],n=[],a=[],{viewScaleInfo:r,viewSizeInfo:l,start:s,end:h}=t;if(!(Array.isArray(e.elements)&&s&&h))return{indexes:o,uuids:n,elements:a};const c=Math.min(s.x,h.x),d=Math.max(s.x,h.x),f=Math.min(s.y,h.y),u=Math.max(s.y,h.y);for(let t=0;t<e.elements.length;t++){const l=e.elements[t];if(!0===(null==(i=null==l?void 0:l.operations)?void 0:i.locked))continue;const s=We(l,{viewScaleInfo:r}),h=ue(s);if(h.x>=c&&h.x<=d&&h.y>=f&&h.y<=u&&(o.push(t),n.push(l.uuid),a.push(l),s.angle&&(s.angle>0||s.angle<0))){const e=pe(s);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];s.x=Math.min(...t),s.y=Math.min(...i),s.w=Math.abs(Math.max(...t)-Math.min(...t)),s.h=Math.abs(Math.max(...i)-Math.min(...i))}}}return{indexes:o,uuids:n,elements:a}}(t,{start:e,end:i,calculator:d,viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo()});o.length>0&&(h.setSharedStorage(lo,"drag-list"),S(o,{triggerEvent:!0}),l=!0)}}}else if("drag-list"===a)h.setSharedStorage(lo,"drag-list-end"),l=!0;else if(t){d.getPointElement(e.point,{data:t,viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo()}).element?(h.setSharedStorage(lo,"select"),l=!0):h.setSharedStorage(lo,null)}null===h.getSharedStorage(lo)&&(I(),l=!0);(()=>{if(l){if(t&&Array.isArray(null==t?void 0:t.elements)&&["drag","drag-list"].includes(a)){const e=function(e,t,i){const o=Ie(e,{viewWidth:t.width,viewHeight:t.height,extend:null==i?void 0:i.extend});return!0===(null==i?void 0:i.extend)&&(o.contextWidth=Math.max(o.contextWidth,t.contextWidth),o.contextHeight=Math.max(o.contextHeight,t.contextHeight)),{contextSize:o}}(t.elements,r,{extend:!0});h.setActiveStorage("contextHeight",e.contextSize.contextHeight),h.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(t&&["drag","drag-list","drag-list-end","resize"].includes(a)){let e="dragElement";f.trigger(no.CHANGE,{data:t,type:e,selectedElements:i,hoverElement:o})}s.drawFrame()}})()},pointLeave(){g=null,v=null,m=null,I(),s.drawFrame()},doubleClick(e){var t,i,o,n,a,r,l,c;if(!1===h.getSharedStorage(So))return;const d=Do(e.point,b());if(h.setSharedStorage(mo,null),h.setSharedStorage(go,[]),1!==d.elements.length||!0!==(null==(i=null==(t=d.elements[0])?void 0:t.operations)?void 0:i.locked)){if(1===d.elements.length&&"group"===(null==(o=d.elements[0])?void 0:o.type)){if(!0===p(d.elements[0]))return h.setSharedStorage(lo,null),void s.drawFrame()}else 1!==d.elements.length||"text"!==(null==(n=d.elements[0])?void 0:n.type)||(null==(r=null==(a=d.elements[0])?void 0:a.operations)?void 0:r.invisible)||f.trigger(no.TEXT_EDIT,{element:d.elements[0],groupQueue:h.getSharedStorage(yo)||[],position:Te(null==(l=d.elements[0])?void 0:l.uuid,(null==(c=h.getActiveStorage("data"))?void 0:c.elements)||[]),viewScaleInfo:h.getActiveViewScaleInfo()});h.setSharedStorage(lo,null)}},contextMenu:e=>{var t,i,o,n,a,r,l,c;const f=h.getSharedStorage(yo);if((null==f?void 0:f.length)>0){if(jo(e.point,{ctx:u,viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),groupQueue:f})){const a=Do(e.point,b());1===(null==(t=null==a?void 0:a.elements)?void 0:t.length)&&!0!==(null==(o=null==(i=a.elements[0])?void 0:i.operations)?void 0:o.locked)?(I(),S([a.elements[0]],{triggerEvent:!0}),s.drawFrame()):(null==(n=null==a?void 0:a.elements)?void 0:n.length)||I()}return}const g=Vo(y(),{viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),calculator:d}),v=Do(e.point,{...b(),areaSize:g,groupQueue:[]});if(1===(null==(a=null==v?void 0:v.elements)?void 0:a.length)&&!0!==(null==(l=null==(r=v.elements[0])?void 0:r.operations)?void 0:l.locked))return I(),S([v.elements[0]],{triggerEvent:!0}),void s.drawFrame();(null==(c=null==v?void 0:v.elements)?void 0:c.length)||I()},beforeDrawFrame({snapshot:t}){var i;const{activeStore:o,sharedStore:n}=t,{scale:a,offsetLeft:r,offsetTop:s,offsetRight:h,offsetBottom:c,width:f,height:g,contextHeight:v,contextWidth:m,devicePixelRatio:w}=o,p=e.sharer,x={scale:a,offsetLeft:r,offsetTop:s,offsetRight:h,offsetBottom:c},S={width:f,height:g,contextHeight:v,contextWidth:m,devicePixelRatio:w},b=n[go][0],I=n[fo],A=n[uo],M=n[lo],R=n[ho],T=n[co],z=n[yo],P=n[po],C=n[xo],E=n[bo],W={calculator:d,viewScaleInfo:x,viewSizeInfo:S,style:l},k=b?Ge(b,{groupQueue:z,controllerSize:10,viewScaleInfo:x}):null,L=!!(null==(i=null==I?void 0:I.operations)?void 0:i.locked);if((null==z?void 0:z.length)>0){if(function(e,t,i){const{style:o}=i,{activeColor:n}=o;for(let o=0;o<t.length;o++){const a={borderColor:n,borderWidth:2,background:"transparent",lineDash:[4,4]};Ao(e,Le(t[o],i),a)}}(u,P,W),I&&"drag"!==M&&(L?Po(u,A,{...W,controller:Ge(I,{groupQueue:z,controllerSize:10,viewScaleInfo:x}),style:l}):zo(u,A,W)),b&&["select","drag","resize"].includes(M)&&(Co(u,k,{...W,element:b,calculator:d,hideControllers:!!C&&"drag"===M,style:l}),"drag"===M&&!0===E)){const e=No(b.uuid,{calculator:d,data:o.data,groupQueue:z,viewScaleInfo:x,viewSizeInfo:S});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Eo(u,{xLines:o,yLines:n,style:l})}}}else if(I&&"drag"!==M&&(L?Po(u,A,{...W,controller:Ge(I,{groupQueue:z,controllerSize:10,viewScaleInfo:x}),style:l}):zo(u,A,W)),b&&["select","drag","resize"].includes(M)){if(Co(u,k,{...W,element:b,calculator:d,hideControllers:!!C&&"drag"===M,style:l}),"drag"===M&&!0===E){const e=No(b.uuid,{calculator:d,data:o.data,groupQueue:z,viewScaleInfo:x,viewSizeInfo:S});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Eo(u,{xLines:o,yLines:n,style:l})}}}else if("area"===M&&R&&T)!function(e,t){const{start:i,end:o,style:n}=t,{activeColor:a,activeAreaColor:r}=n;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=a,e.fillStyle=r,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,i.y),e.lineTo(o.x,o.y),e.lineTo(i.x,o.y),e.closePath(),e.stroke(),e.fill()}(u,{start:R,end:T,style:l});else if(["drag-list","drag-list-end"].includes(M)){const e=Vo(y(),{viewScaleInfo:p.getActiveViewScaleInfo(),viewSizeInfo:p.getActiveViewSizeInfo(),calculator:d});e&&function(e,t){const{areaSize:i,style:o}=t,{activeColor:n,activeAreaColor:a}=o,{x:r,y:l,w:s,h:h}=i;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=n,e.fillStyle=a,e.beginPath(),e.moveTo(r,l),e.lineTo(r+s,l),e.lineTo(r+s,l+h),e.lineTo(r,l+h),e.closePath(),e.stroke(),e.fill()}(u,{areaSize:e,style:l})}}}},e.MiddlewareTextEditor=e=>{const{eventHub:t,boardContent:i,viewer:o,sharer:n}=e,a=i.boardContext.canvas,r=document.createElement("div");r.setAttribute("contenteditable","true");const l=document.createElement("div"),s=e.container||document.body,h=document.createElement("div");let c=null,d=[];const f=`idraw-middleware-text-editor-${Math.random().toString(26).substring(2)}`;h.setAttribute("id",f),l.appendChild(r),l.style.position="absolute",h.appendChild(l),h.style.position="fixed",h.style.top="0",h.style.bottom="0",h.style.left="0",h.style.right="0",h.style.display="none",s.appendChild(h);const u=()=>{if(null==c?void 0:c.uuid){const e=n.getActiveOverrideElemenentMap();e&&delete e[c.uuid],n.setActiveOverrideElemenentMap(e),o.drawFrame()}h.style.display="none",c=null,d=[]},g=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:n,y:a,w:r,h:l}=t,s=Se(t.angle||0);return o.style.position="absolute",o.style.left=`${n}px`,o.style.top=`${a}px`,o.style.width=`${r}px`,o.style.height=`${l}px`,o.style.transform=`rotate(${s}deg)`,i.appendChild(o),o},v=e=>{const{viewScaleInfo:t,element:i,groupQueue:o}=e,{scale:n,offsetTop:a,offsetLeft:s}=t;l.children&&Array.from(l.children).forEach((e=>{e.remove()}));let h=l;for(let e=0;e<o.length;e++){const t=o[e],{x:i,y:r,w:l,h:c}=t,d={x:i*n,y:r*n,w:l*n,h:c*n,angle:Se(t.angle||0)};0===e&&(d.x+=s,d.y+=a),h=g({size:d,parent:h})}const c={...xn,...i.detail};let d=i.x*n+s,f=i.y*n+a,u=i.w*n,v=i.h*n;o.length>0&&(d=i.x*n,f=i.y*n,u=i.w*n,v=i.h*n);let m="center",w="center";"left"===c.textAlign?m="start":"right"===c.textAlign&&(m="end"),"top"===c.verticalAlign?w="start":"bottom"===c.verticalAlign&&(w="end"),r.style.display="inline-flex",r.style.justifyContent=m,r.style.alignItems=w,r.style.position="absolute",r.style.left=d-1+"px",r.style.top=f-1+"px",r.style.width=`${u+2}px`,r.style.height=`${v+2}px`,r.style.transform=`rotate(${Se(i.angle||0)}deg)`,r.style.boxSizing="border-box",r.style.border="1px solid #1973ba",r.style.resize="none",r.style.overflow="hidden",r.style.wordBreak="break-all",r.style.borderRadius=("number"==typeof c.borderRadius?c.borderRadius:0)*n+"px",r.style.background=`${c.background||"transparent"}`,r.style.color=`${c.color||"#333333"}`,r.style.fontSize=c.fontSize*n+"px",r.style.lineHeight=(c.lineHeight||c.fontSize)*n+"px",r.style.fontFamily=Ke(c.fontFamily),r.style.fontWeight=`${c.fontWeight}`,r.style.padding="0",r.style.margin="0",r.style.outline="none",r.innerText=c.text||"",h.appendChild(r)},m=()=>{const{left:e,top:t,width:i,height:o}=(()=>{const e=a.getBoundingClientRect(),{left:t,top:i,width:o,height:n}=e;return{left:t,top:i,width:o,height:n}})();l.style.position="absolute",l.style.overflow="hidden",l.style.top=`${t}px`,l.style.left=`${e}px`,l.style.width=`${i}px`,l.style.height=`${o}px`};h.addEventListener("click",(()=>{u()})),r.addEventListener("click",(e=>{e.stopPropagation()})),r.addEventListener("input",(()=>{c&&d&&(c.detail.text=r.innerText||"",t.trigger(no.TEXT_CHANGE,{element:{uuid:c.uuid,detail:{text:c.detail.text}},position:[...d||[]]}),o.drawFrame())})),r.addEventListener("blur",(()=>{c&&d&&t.trigger(no.TEXT_CHANGE,{element:{uuid:c.uuid,detail:{text:c.detail.text}},position:[...d]}),u()})),r.addEventListener("keydown",(e=>{e.stopPropagation()})),r.addEventListener("keypress",(e=>{e.stopPropagation()})),r.addEventListener("keyup",(e=>{e.stopPropagation()})),r.addEventListener("wheel",(e=>{e.stopPropagation(),e.preventDefault()}));const w=e=>{var t;(null==e?void 0:e.position)&&(null==e?void 0:e.element)&&"text"===(null==(t=null==e?void 0:e.element)?void 0:t.type)&&(c=e.element,d=e.position),(e=>{m(),v(e),h.style.display="block",(null==c?void 0:c.uuid)&&(n.setActiveOverrideElemenentMap({[c.uuid]:{operations:{invisible:!0}}}),o.drawFrame())})(e)};return{name:"@middleware/text-editor",use(){t.on(no.TEXT_EDIT,w)},disuse(){t.off(no.TEXT_EDIT,w)}}},e.coreEventKeys=no,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
|
1
|
+
var iDrawCore=function(e){"use strict";var t,i,o,n,a,r,l,s,h,c,d,f,u,g,v,m,w,y,p,x,S=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},b=(e,t,i)=>(S(e,t,"read from private field"),i?i.call(e):t.get(e)),I=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},A=(e,t,i,o)=>(S(e,t,"write to private field"),o?o.call(e,i):t.set(e,i),i),M=(e,t,i)=>(S(e,t,"access private method"),i);function R(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function T(e,t){if(1===t)return e;let i=1;const o=/^\#[0-9a-f]{6,6}$/i;let n=e;if(o.test(e)?i=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(i=parseInt(e.substring(7,9).replace(/^\#/,"0x")),n=e.substring(0,7)),i*=t,o.test(n)&&i>0&&i<1){const e=Math.max(0,Math.min(255,Math.ceil(256*i)));n=`${n.toUpperCase()}${e.toString(16).toUpperCase()}`}return n}function z(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function P(e){let t=0;for(let i=0;i<e.length;i++)t+=e.charCodeAt(i)*e.charCodeAt(i)*i*i;return t.toString(16).substring(0,4)}function C(e){const t=e.length,i=Math.floor(t/2),o=e.substring(0,4).padEnd(4,"0"),n=e.substring(0,4).padEnd(4,"0");return`@assets/${P(t.toString(16).padEnd(4,o))}${P(e.substring(i-4,i).padEnd(4,o)).padEnd(4,"f")}-${P(e.substring(i-8,i-4).padEnd(4,o)).padEnd(4,"f")}-${P(e.substring(i-12,i-8).padEnd(4,o)).padEnd(4,"f")}-${P(e.substring(i-16,i-12).padEnd(4,n)).padEnd(4,"f")}-${P(e.substring(i,i+4).padEnd(4,n)).padEnd(4,"f")}${P(e.substring(i+4,i+8).padEnd(4,n)).padEnd(4,"f")}${P(n.padEnd(4,o).padEnd(4,n))}`}function E(e){return function e(t){const i=function(e){return Object.prototype.toString.call(e).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(t);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return t;if("Array"===i){const i=[];return t.forEach((t=>{i.push(e(t))})),i}if("Object"===i){const i={};Object.keys(t).forEach((o=>{i[o]=e(t[o])}));return Object.getOwnPropertySymbols(t).forEach((o=>{i[o]=e(t[o])})),i}}(e)}function k(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const W={type(e,t){const i=k(e);return!0===t?i.toLocaleLowerCase():i},array:e=>"Array"===k(e),json:e=>"Object"===k(e),function:e=>"Function"===k(e),asyncFunction:e=>"AsyncFunction"===k(e),boolean:e=>"Boolean"===k(e),string:e=>"String"===k(e),number:e=>"Number"===k(e),undefined:e=>"Undefined"===k(e),null:e=>"Null"===k(e),promise:e=>"Promise"===k(e)};var L=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))};const{Image:O}=window;function j(e){return new Promise(((t,i)=>{const o=new O;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function D(e){return L(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,i)=>{const o=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n=new FileReader;n.readAsDataURL(o),n.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},n.onerror=function(e){i(e)}}))}(e);return yield j(t)}))}function Y(e,t){return L(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&");const i=yield function(e,t){const{width:i,height:o}=t;return new Promise(((t,n)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${o||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},r.onerror=function(e){n(e)}}))}(e,t);return yield j(i)}))}function V(e){return"number"==typeof e&&(e>0||e<=0)}function B(e){return"number"==typeof e&&e>=0}function G(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function X(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const N={x:function(e){return V(e)},y:function(e){return V(e)},w:B,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:V,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return B(e)},borderRadius:function(e){return V(e)&&e>=0},color:function(e){return R(e)},imageSrc:function(e){return X(e)||G(e)},imageURL:G,imageBase64:X,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let i=document.createElement("div");i.innerHTML=e,i.children.length>0&&(t=!0),i=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return V(e)&&e>0},lineHeight:function(e){return V(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return V(e)&&e>0}};var F,H,Z=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Q=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class U{constructor(e,t){F.set(this,void 0),H.set(this,void 0),Z(this,F,e,"f"),Z(this,H,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f"),this.$resetFont()}$undoPixelRatio(e){return e/Q(this,H,"f").devicePixelRatio}$doPixelRatio(e){return Q(this,H,"f").devicePixelRatio*e}$getContext(){return Q(this,F,"f")}$setContext(e){Z(this,F,e,"f")}$setFont(e){const t=[];e.fontWeight&&t.push(`${e.fontWeight}`),t.push(`${this.$doPixelRatio(e.fontSize||12)}px`),t.push(`${e.fontFamily||"sans-serif"}`),Q(this,F,"f").font=`${t.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return Q(this,H,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:a}=Q(this,F,"f");a.width=t*o,a.height=i*o,Z(this,H,Object.assign(Object.assign({},Q(this,H,"f")),{devicePixelRatio:o}),"f"),!0===n&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=Q(this,H,"f"),{width:t,height:i}=Q(this,F,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return Q(this,F,"f").canvas}get fillStyle(){return Q(this,F,"f").fillStyle}set fillStyle(e){Q(this,F,"f").fillStyle=e}get strokeStyle(){return Q(this,F,"f").strokeStyle}set strokeStyle(e){Q(this,F,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(Q(this,F,"f").lineWidth)}set lineWidth(e){Q(this,F,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return Q(this,F,"f").textAlign}set textAlign(e){Q(this,F,"f").textAlign=e}get textBaseline(){return Q(this,F,"f").textBaseline}set textBaseline(e){Q(this,F,"f").textBaseline=e}get globalAlpha(){return Q(this,F,"f").globalAlpha}set globalAlpha(e){Q(this,F,"f").globalAlpha=e}get shadowColor(){return Q(this,F,"f").shadowColor}set shadowColor(e){Q(this,F,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(Q(this,F,"f").shadowOffsetX)}set shadowOffsetX(e){Q(this,F,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(Q(this,F,"f").shadowOffsetY)}set shadowOffsetY(e){Q(this,F,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(Q(this,F,"f").shadowBlur)}set shadowBlur(e){Q(this,F,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return Q(this,F,"f").lineCap}set lineCap(e){Q(this,F,"f").lineCap=e}get globalCompositeOperation(){return Q(this,F,"f").globalCompositeOperation}set globalCompositeOperation(e){Q(this,F,"f").globalCompositeOperation=e}fill(...e){return Q(this,F,"f").fill(...e)}arc(e,t,i,o,n,a){return Q(this,F,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,a)}rect(e,t,i,o){return Q(this,F,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return Q(this,F,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return Q(this,F,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return Q(this,F,"f").beginPath()}closePath(){return Q(this,F,"f").closePath()}lineTo(e,t){return Q(this,F,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return Q(this,F,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return Q(this,F,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}getLineDash(){return Q(this,F,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return Q(this,F,"f").setLineDash(t)}stroke(e){return e?Q(this,F,"f").stroke(e):Q(this,F,"f").stroke()}translate(e,t){return Q(this,F,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return Q(this,F,"f").rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],n=e[3],a=e[4],r=e[e.length-4],l=e[e.length-3],s=e[e.length-2],h=e[e.length-1];return 9===e.length?Q(this,F,"f").drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h)):Q(this,F,"f").drawImage(t,this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h))}createPattern(e,t){return Q(this,F,"f").createPattern(e,t)}measureText(e){return Q(this,F,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?Q(this,F,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):Q(this,F,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?Q(this,F,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):Q(this,F,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){Q(this,F,"f").save()}restore(){Q(this,F,"f").restore()}scale(e,t){Q(this,F,"f").scale(e,t)}circle(e,t,i,o,n,a,r,l){Q(this,F,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,a,r,l)}isPointInPath(e,t){return Q(this,F,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return Q(this,F,"f").clip(...e)}setTransform(e,t,i,o,n,a){return Q(this,F,"f").setTransform(e,t,i,o,n,a)}getTransform(){return Q(this,F,"f").getTransform()}createLinearGradient(e,t,i,o){return Q(this,F,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,a){return Q(this,F,"f").createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a))}createConicGradient(e,t,i){return Q(this,F,"f").createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function J(e){const{width:t,height:i,ctx:o,devicePixelRatio:n}=e;let a=o;if(!a){const e=document.createElement("canvas");e.width=t*n,e.height=i*n,a=e.getContext("2d")}return new U(a,e)}function $(e){const{width:t,height:i,devicePixelRatio:o}=e,n=new OffscreenCanvas(t*o,i*o),a=n.getContext("2d").canvas.getContext("2d");return new U(a,{devicePixelRatio:o,offscreenCanvas:n})}F=new WeakMap,H=new WeakMap;var K,q=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class _{constructor(){K.set(this,void 0),function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(e,i):n?n.value=i:t.set(e,i)}(this,K,new Map,"f")}on(e,t){if(q(this,K,"f").has(e)){const i=q(this,K,"f").get(e)||[];null==i||i.push(t),q(this,K,"f").set(e,i)}else q(this,K,"f").set(e,[t])}off(e,t){if(q(this,K,"f").has(e)){const i=q(this,K,"f").get(e);if(Array.isArray(i))for(let e=0;e<(null==i?void 0:i.length);e++)if(i[e]===t){i.splice(e,1);break}q(this,K,"f").set(e,i||[])}}trigger(e,t){const i=q(this,K,"f").get(e);return!!Array.isArray(i)&&(i.forEach((e=>{e(t)})),!0)}has(e){if(q(this,K,"f").has(e)){const t=q(this,K,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){q(this,K,"f").clear()}}function ee(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}K=new WeakMap;var te,ie,oe,ne,ae,re=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},le=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class se{constructor(e){te.add(this),ie.set(this,void 0),oe.set(this,void 0),ne.set(this,void 0),re(this,oe,E(e.defaultStorage),"f"),re(this,ie,le(this,te,"m",ae).call(this),"f"),re(this,ne,e.defaultStatic||{},"f")}set(e,t){le(this,ie,"f")[e]=t}get(e){return le(this,ie,"f")[e]}setStatic(e,t){le(this,ne,"f")[e]=t}getStatic(e){return le(this,ne,"f")[e]}getSnapshot(e){return!0===(null==e?void 0:e.deepClone)?E(le(this,ie,"f")):Object.assign({},le(this,ie,"f"))}clear(){re(this,ie,le(this,te,"m",ae).call(this),"f")}destroy(){re(this,ie,null,"f"),re(this,ne,null,"f")}}function he(e){const{activeStore:t}=e;return{scale:null==t?void 0:t.scale,offsetTop:null==t?void 0:t.offsetTop,offsetBottom:null==t?void 0:t.offsetBottom,offsetLeft:null==t?void 0:t.offsetLeft,offsetRight:null==t?void 0:t.offsetRight}}function ce(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:null==t?void 0:t.width,height:null==t?void 0:t.height,contextWidth:null==t?void 0:t.contextWidth,contextHeight:null==t?void 0:t.contextHeight}}function de(e){return e/180*Math.PI}function fe(e,t,i,o){const n=de(t||0);i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(n),e.translate(-i.x,-i.y)),o(e),i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(-n),e.translate(-i.x,-i.y))}function ue(e,t,i){const o=ge(t);fe(e,t.angle||0,o,(()=>{i(e)}))}function ge(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function ve(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),i=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return ge({x:t,y:i,w:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,h:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-i})}function me(e,t){const i=t.x-e.x,o=t.y-e.y;if(0===i){if(o<0)return 0;if(o>0)return Math.PI}else if(0===o){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&o<0?Math.atan(Math.abs(i)/Math.abs(o)):i>0&&o>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):0}function we(e,t,i){let o=me(e,t)+i;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const n=function(e,t){const i=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y);return 0===i?i:Math.sqrt(i)}(e,t);let a=0,r=0;return 0===o?(a=0,r=0-n):o>0&&o<Math.PI/2?(a=Math.sin(o)*n,r=0-Math.cos(o)*n):o===Math.PI/2?(a=n,r=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*n,r=Math.cos(Math.PI-o)*n):o===Math.PI?(a=0,r=n):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*n,r=Math.cos(o-Math.PI)*n):o===1.5*Math.PI?(a=0-n,r=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*n,r=0-Math.cos(2*Math.PI-o)*n):o===2*Math.PI&&(a=0,r=0-n),a+=e.x,r+=e.y,{x:a,y:r}}function ye(e,t){if((null==t?void 0:t.length)>0){let i=e.x,o=e.y;return t.forEach((e=>{const{x:t,y:n,w:a,h:r,angle:l=0}=e,s=we(ge({x:t,y:n,w:a,h:r,angle:l}),{x:i,y:o},de(l));i=s.x,o=s.y})),{x:i,y:o}}return e}function pe(e,t,i){const{x:o,y:n,w:a,h:r}=e;let l={x:o,y:n},s={x:o+a,y:n},h={x:o+a,y:n+r},c={x:o,y:n+r};if(i&&(i>0||i<0)){const e=de(be(i));l=we(t,l,e),s=we(t,s,e),h=we(t,h,e),c=we(t,c,e)}return[l,s,h,c]}function xe(e){const{angle:t=0}=e;return pe(e,ge(e),t)}function Se(e,t,i){return[we(e,{x:t[0].x,y:t[0].y},i),we(e,{x:t[1].x,y:t[1].y},i),we(e,{x:t[2].x,y:t[2].y},i),we(e,{x:t[3].x,y:t[3].y},i)]}function be(e){if(!(e>0||e<0)||0===e)return 0;let t=e%360;return t<0&&(t+=360),t}function Ie(e){let t=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(t=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(t=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(t=Ie(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.children))}))}return t}function Ae(e,t){const i={x:0,y:0,w:0,h:0};e.forEach((e=>{const t={x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=xe(t);if(4===e.length){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...i),t.y=Math.min(...o),t.w=Math.abs(Math.max(...i)-Math.min(...i)),t.h=Math.abs(Math.max(...o)-Math.min(...o))}}const o=Math.min(t.x,i.x),n=Math.min(t.y,i.y),a=Math.max(t.x+t.w,i.x+i.w),r=Math.max(t.y+t.h,i.y+i.h);i.x=o,i.y=n,i.w=Math.abs(a-o),i.h=Math.abs(r-n)})),(null==t?void 0:t.extend)&&(i.x=Math.min(i.x,0),i.y=Math.min(i.y,0));const o={contextWidth:i.w,contextHeight:i.h};return(null==t?void 0:t.viewWidth)&&(null==t?void 0:t.viewHeight)&&(null==t?void 0:t.viewWidth)>0&&(null==t?void 0:t.viewHeight)>0&&(t.viewWidth>i.x+i.w&&(o.contextWidth=t.viewWidth-i.x),t.viewHeight>i.y+i.h&&(o.contextHeight=t.viewHeight-i.y)),o}function Me(e,t){var i;const o=[];let n=e;if(t.length>1)for(let e=0;e<t.length-1;e++){const a=n[t[e]];if("group"!==(null==a?void 0:a.type)||!Array.isArray(null===(i=null==a?void 0:a.detail)||void 0===i?void 0:i.children))return null;o.push(a),n=a.detail.children}return o}function Re(e){const{x:t,y:i,w:o,h:n,angle:a}=e;return{x:t,y:i,w:o,h:n,angle:a}}function Te(e,t){let i=null,o=t;for(let t=0;t<e.length;t++){const n=o[e[t]];if(t<e.length-1&&"group"===n.type)o=n.detail.children;else{if(t!==e.length-1)break;i=n}}return i}function ze(e,t){const i=[];let o=!1;const n=t=>{var a;for(let r=0;r<t.length&&!0!==o;r++){i.push(r);const l=t[r];if(l.uuid===e){o=!0;break}if("group"===l.type&&n((null===(a=null==l?void 0:l.detail)||void 0===a?void 0:a.children)||[]),o)break;i.pop()}};return n(t),i}function Pe(e){const{x:t,y:i,h:o,w:n}=e;return[{x:t,y:i},{x:t+n,y:i},{x:t+n,y:i+o},{x:t,y:i+o}]}function Ce(e){const{x:t,y:i,w:o,h:n,angle:a=0}=e;return 0===a?Pe(e):pe(e,ge({x:t,y:i,w:o,h:n,angle:a}),a)}function Ee(e){const t=[];let i=0,o=0;const n=[],a=[...e];for(let e=0;e<a.length;e++){const{x:r,y:l,w:s,h:h,angle:c=0}=a[e];let d;if(i+=r,o+=l,0===e){const e={x:i,y:o,w:s,h:h,angle:c};d=Ce({x:r,y:l,w:s,h:h,angle:c}),n.push({center:ge(e),angle:c,radian:de(c)})}else{d=Pe({x:i,y:o,w:s,h:h,angle:c});for(let e=0;e<n.length;e++){const{center:t,radian:i}=n[e];d=Se(t,d,i)}const e=ve(d);if(c>0||c<0){d=Se(e,d,de(c))}n.push({center:e,angle:c,radian:de(c)})}t.push(d)}return t}function ke(e,t){const i=function(e,t){const{groupQueue:i}=t;return i.length>0?Ee([...i,e]):[Ce(e)]}(e,t);return i.pop()||null}function We(e,t){const{viewScaleInfo:i}=t,{x:o,y:n,w:a,h:r,angle:l}=e,{scale:s,offsetTop:h,offsetLeft:c}=i;return{x:o*s+c,y:n*s+h,w:a*s,h:r*s,angle:l}}function Le(e,t){const{viewScaleInfo:i}=t,{x:o,y:n}=e,{scale:a,offsetTop:r,offsetLeft:l}=i;return{x:o*a+l,y:n*a+r}}function Oe(e,t){return[Le(e[0],t),Le(e[1],t),Le(e[2],t),Le(e[3],t)]}function je(e,t){const{context2d:i,element:o,viewScaleInfo:n}=t,{angle:a=0}=o,{x:r,y:l,w:s,h:h}=We(o,{viewScaleInfo:n}),c=xe({x:r,y:l,w:s,h:h,angle:a});if(c.length>=2){i.beginPath(),i.moveTo(c[0].x,c[0].y);for(let e=1;e<c.length;e++)i.lineTo(c[e].x,c[e].y);i.closePath()}return!!i.isPointInPath(e.x,e.y)}function De(e,t,i){const o=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y],a=Math.min(...o),r=Math.max(...o),l=Math.min(...n),s=Math.max(...n);return e.x>a&&e.x<r&&e.y>l&&e.y<s}function Ye(e,t){const{groupQueue:i}=t,o=ke(e,{groupQueue:i}),n=ee(o[0],o[1]),a=ee(o[1],o[2]),r=ee(o[2],o[3]),l=ee(o[3],o[0]),s=o[0],h=o[1],c=o[2],d=o[3],f=Math.max(s.x,h.x,c.x,d.x),u=Math.max(s.y,h.y,c.y,d.y);return{center:{x:(f+Math.min(s.x,h.x,c.x,d.x))/2,y:(u+Math.min(s.y,h.y,c.y,d.y))/2},topLeft:s,topRight:h,bottomLeft:d,bottomRight:c,top:n,right:a,left:l,bottom:r}}function Ve(e){const t=Math.max(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),i=Math.max(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),o=Math.min(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),a={x:e.center.x,y:e.center.y},r={x:o,y:n},l={x:t,y:n},s={x:t,y:i},h={x:o,y:i},c=ee(r,l),d=ee(h,s),f=ee(r,h);return{center:a,topLeft:r,topRight:l,bottomLeft:h,bottomRight:s,top:c,right:ee(l,s),left:f,bottom:d}}function Be(e,t){const i=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n,offsetLeft:a}=t,{width:r,height:l}=i,s=0-a/o,h=0-n/o,c=r/o,d=l/o,f=ge({x:s,y:h,w:c,h:d}),u={x:s,y:h},g={x:s+c,y:h},v={x:s,y:h+d},m={x:s+c,y:h+d},w={x:s,y:f.y},y={x:f.x,y:h},p={x:s+c,y:f.y},x={x:f.x,y:h+d};return{center:f,topLeft:u,topRight:g,bottomLeft:v,bottomRight:m,left:w,top:y,right:p,bottom:x}}(t);let o=0,n=0;return Object.keys(e).forEach((t=>{const a=e[t];a.isVisibleInView=function(e,t){const i=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),o=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),a=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),r=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),l=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),s=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),h=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y);return i<=l&&o>=r&&n<=h&&a>=s||l<=a&&l>=a&&l<=a&&l>=a}(a.rangeRectInfo,i),a.isVisibleInView?o++:n++})),{viewVisibleInfoMap:e,visibleCount:o,invisibleCount:n}}function Ge(e,t){const{x:i,y:o}=e,{size:n,angle:a}=t;return{x:i-n/2,y:o-n/2,w:n,h:n,angle:a}}function Xe(e,t){const{groupQueue:i,controllerSize:o,viewScaleInfo:n}=t,a=(o&&o>0?o:8)/n.scale,{x:r,y:l,w:s,h:h,angle:c=0}=e,d=[{uuid:z(),x:r,y:l,w:s,h:h,angle:c,type:"group",detail:{children:[]}},...i];let f=0;d.forEach((({angle:e=0})=>{f+=e}));const u=ke(e,{groupQueue:i}),g=ke({x:r-2*a,y:l-2*a,h:h+4*a,w:s+4*a,angle:c},{groupQueue:[...i]}),v=ee(u[0],u[1]),m=ee(u[1],u[2]),w=ee(u[2],u[3]),y=ee(u[3],u[0]),p=u[0],x=u[1],S=u[2],b=u[3],I=Ge(v,{size:a,angle:f}),A=Ge(m,{size:a,angle:f}),M=Ge(w,{size:a,angle:f}),R=Ge(y,{size:a,angle:f}),T=Ge(p,{size:a,angle:f}),P=Ge(x,{size:a,angle:f}),C=Ge(b,{size:a,angle:f}),E=Ge(S,{size:a,angle:f}),k=Ce(T),W=Ce(P),L=Ce(C),O=Ce(E),j=[k[1],W[0],W[3],k[2]],D=[W[3],W[2],O[1],O[0]],Y=[L[1],O[0],O[3],L[2]],V=[k[3],k[2],L[1],L[0]],B=Ce(I),G=Ce(A),X=Ce(M),N=Ce(R),F=ee(g[0],g[1]);return{elementWrapper:u,left:{type:"left",vertexes:V,center:y},right:{type:"right",vertexes:D,center:m},top:{type:"top",vertexes:j,center:v},bottom:{type:"bottom",vertexes:Y,center:w},topLeft:{type:"top-left",vertexes:k,center:p},topRight:{type:"top-right",vertexes:W,center:x},bottomLeft:{type:"bottom-left",vertexes:L,center:b},bottomRight:{type:"bottom-right",vertexes:O,center:S},leftMiddle:{type:"left-middle",vertexes:N,center:y},rightMiddle:{type:"right-middle",vertexes:G,center:m},topMiddle:{type:"top-middle",vertexes:B,center:v},bottomMiddle:{type:"bottom-middle",vertexes:X,center:w},rotate:{type:"rotate",vertexes:Ce(Ge(F,{size:a,angle:f})),center:F}}}function Ne(e,t){const{controllerSize:i,viewScaleInfo:o}=t,n=i&&i>0?i:8,{x:a,y:r,w:l,h:s}=We(e,{viewScaleInfo:o}),h=ge({x:a,y:r,w:l,h:s}),c={x:h.x,y:r},d={x:a+l,y:h.y},f={x:h.x,y:r+s},u={x:a,y:h.y},g={x:a,y:r},v={x:a+l,y:r},m={x:a+l,y:r+s},w={x:a,y:r+s},y=Ge(c,{size:n,angle:0}),p=Ge(d,{size:n,angle:0}),x=Ge(f,{size:n,angle:0}),S=Ge(u,{size:n,angle:0}),b=Ge(g,{size:n,angle:0}),I=Ge(v,{size:n,angle:0}),A=Ge(w,{size:n,angle:0}),M=Ge(m,{size:n,angle:0}),R=Ce(b),T=Ce(I),z=Ce(A),P=Ce(M),C=[R[1],T[0],T[3],R[2]],E=[T[3],T[2],P[1],P[0]],k=[z[1],P[0],P[3],z[2]],W=[R[3],R[2],z[1],z[0]],L=Ce(y),O=Ce(p),j=Ce(x);return{left:{type:"left",vertexes:W,center:u},right:{type:"right",vertexes:E,center:d},top:{type:"top",vertexes:C,center:c},bottom:{type:"bottom",vertexes:k,center:f},topLeft:{type:"top-left",vertexes:R,center:g},topRight:{type:"top-right",vertexes:T,center:v},bottomLeft:{type:"bottom-left",vertexes:z,center:w},bottomRight:{type:"bottom-right",vertexes:P,center:m},leftMiddle:{type:"left-middle",vertexes:Ce(S),center:u},rightMiddle:{type:"right-middle",vertexes:O,center:d},topMiddle:{type:"top-middle",vertexes:L,center:c},bottomMiddle:{type:"bottom-middle",vertexes:j,center:f}}}function Fe(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}function He(e,t){let i=2;return void 0!==(null==t?void 0:t.decimalPlaces)&&(null==t?void 0:t.decimalPlaces)>=0&&(i=t.decimalPlaces),parseFloat(e.toFixed(i))}ie=new WeakMap,oe=new WeakMap,ne=new WeakMap,te=new WeakSet,ae=function(){return E(le(this,oe,"f"))};const Ze={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function Qe(e,t){const{viewScaleInfo:i}=t,{scale:o}=i;let{borderRadius:n,borderDash:a}=e.detail;const r=Array.isArray(a)&&a.length>0,{boxSizing:l=Ze.boxSizing,borderWidth:s}=e.detail;Array.isArray(s)&&(n=0);let{x:h,y:c,w:d,h:f}=e,u=[0,0,0,0];if("number"==typeof n){const e=n*o;u=[e,e,e,e]}else Array.isArray(n)&&4===(null==n?void 0:n.length)&&(u=[n[0]*o,n[1]*o,n[2]*o,n[3]*o]);let g=0;return"number"==typeof s&&(g=(s||0)*o),"border-box"!==l||r?"content-box"===l?(h=e.x-g/2,c=e.y-g/2,d=e.w+g,f=e.h+g):(h=e.x,c=e.y,d=e.w,f=e.h):(h=e.x+g/2,c=e.y+g/2,d=e.w-g,f=e.h-g),d=Math.max(d,1),f=Math.max(f,1),u=u.map((e=>Math.min(e,d/2,f/2))),{x:h,y:c,w:d,h:f,radiusList:u}}const Ue=e=>He(e,{decimalPlaces:4});function Je(e,t){const{detail:i}=e,{xRatio:o,yRatio:n,maxRatio:a}=t,r=(o+n)/2,{borderWidth:l,borderRadius:s,borderDash:h,shadowOffsetX:c,shadowOffsetY:d,shadowBlur:f}=i;if("number"==typeof l)i.borderWidth=Ue(l*r);else if(Array.isArray(i.borderWidth)){const e=l;i.borderWidth=[Ue(e[0]*n),Ue(e[1]*o),Ue(e[2]*n),Ue(e[3]*o)]}if("number"==typeof s)i.borderRadius=Ue(s*r);else if(Array.isArray(i.borderRadius)){const e=s;i.borderRadius=[e[0]*o,e[1]*o,e[2]*n,e[3]*n]}Array.isArray(h)&&h.forEach(((e,t)=>{i.borderDash[t]=Ue(e*a)})),"number"==typeof c&&(i.shadowOffsetX=Ue(c*a)),"number"==typeof d&&(i.shadowOffsetX=Ue(d*a)),"number"==typeof f&&(i.shadowOffsetX=Ue(f*a))}function $e(e,t){const{type:i}=e;!function(e,t){const{xRatio:i,yRatio:o}=t,{x:n,y:a,w:r,h:l}=e;e.x=Ue(n*i),e.y=Ue(a*o),e.w=Ue(r*i),e.h=Ue(l*o),Je(e,t)}(e,t),"circle"===i||("text"===i?function(e,t){const{minRatio:i,maxRatio:o}=t,{fontSize:n,lineHeight:a}=e.detail,r=(i+o)/2;n&&n>0&&(e.detail.fontSize=Ue(n*r)),a&&a>0&&(e.detail.lineHeight=Ue(a*r))}(e,t):"image"===i||"svg"===i||"html"===i||"path"===i||"group"===i&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{$e(e,t)})))}const Ke=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function qe(e){return[e,...Ke].join(", ")}function _e(e,t,i){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:n,opacity:a=1}=i,{x:r,y:l}=o,{scale:s}=n;if("linear-gradient"===(null==t?void 0:t.type)){const{start:i,end:o,stops:n}=t,h={x:r+i.x*s,y:l+i.y*s},c={x:r+o.x*s,y:l+o.y*s},d=e.createLinearGradient(h.x,h.y,c.x,c.y);return n.forEach((e=>{d.addColorStop(e.offset,T(e.color,a))})),d}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:i,outer:o,stops:n}=t,h={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},c={x:r+o.x*s,y:l+o.y*s,radius:o.radius*s},d=e.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return n.forEach((e=>{d.addColorStop(e.offset,T(e.color,a))})),d}return"#000000"}const et={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function tt(e){var t,i,o,n;let a=1;return void 0!==(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.opacity)&&(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.opacity)>=0&&(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.opacity)<=1&&(a=null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.opacity),a}function it(e,t,i){const{pattern:o,renderContent:n,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=i||{},{parentOpacity:h}=i,c=tt(a)*h,{clipPath:d,clipPathStrokeColor:f,clipPathStrokeWidth:u}=a.detail,g=()=>{e.globalAlpha=c,ot(e,t,{pattern:o,viewScaleInfo:l,viewSizeInfo:s}),null==n||n(),nt(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=h};d?(function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewSizeInfo:r}=i,l=r.devicePixelRatio,{clipPath:s}=(null==n?void 0:n.detail)||{};if(s&&a&&s.commands){const{x:i,y:n,w:r,h:h}=a,{originW:c,originH:d,originX:f,originY:u}=s,g=r/c,v=h/d,m=i-f*g,w=n-u*v;e.save(),e.translate(m,w),e.scale(l*g,l*v);const y=Fe(s.commands||[]),p=new Path2D(y);e.clip(p),e.translate(0-m,0-w),e.setTransform(1,0,0,1,0,0),ue(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{g()}}),"number"==typeof u&&u>0&&f&&function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewSizeInfo:r,parentOpacity:l}=i,s=r.devicePixelRatio,{clipPath:h,clipPathStrokeColor:c,clipPathStrokeWidth:d}=(null==n?void 0:n.detail)||{};if(h&&a&&h.commands&&"number"==typeof d&&d>0&&c){const{x:i,y:n,w:r,h:f}=a,{originW:u,originH:g,originX:v,originY:m}=h,w=r/u,y=f/g,p=i-v*w,x=n-m*y;e.save(),e.globalAlpha=l,e.translate(p,x),e.scale(s*w,s*y);const S=Fe(h.commands||[]),b=new Path2D(S);e.strokeStyle=c,e.lineWidth=d,e.stroke(b),e.translate(0-p,0-x),e.setTransform(1,0,0,1,0,0),ue(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,parentOpacity:h})):g()}function ot(e,t,i){var o,n;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=i,s=[];if(t.detail.background||a){const{x:i,y:h,w:c,h:d,radiusList:f}=Qe(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(i+f[0],h),e.arcTo(i+c,h,i+c,h+d,f[1]),e.arcTo(i+c,h+d,i,h+d,f[2]),e.arcTo(i,h+d,i,h,f[3]),e.arcTo(i,h,i+c,h,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(W.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null===(o=t.detail.background)||void 0===o?void 0:o.type)){const o=_e(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=o}else if("radial-gradient"===(null===(n=t.detail.background)||void 0===n?void 0:n.type)){const o=_e(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=o,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const o=s[t];"translate"===o.method?e.translate(o.args[0]+i,o.args[1]+h):"rotate"===o.method?e.rotate(...o.args):"scale"===o.method&&e.scale(...o.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function nt(e,t,i){if(0===t.detail.borderWidth)return;if(!R(t.detail.borderColor))return;const{viewScaleInfo:o}=i,{scale:n}=o;let a=et.borderColor;!0===R(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:h=et.boxSizing}=t.detail;let c=0;"number"==typeof r&&(c=r||1),c*=n;let d=[0,0,0,0];if("number"==typeof l){const e=l*n;d=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(d=[l[0]*n,l[1]*n,l[2]*n,l[3]*n]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*n))));let u=0,g=0,v=0,m=0;if(Array.isArray(r)&&(u=(r[0]||0)*n,g=(r[1]||0)*n,v=(r[2]||0)*n,m=(r[3]||0)*n),m||g||u||v){e.lineCap="butt";let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i+=m/2,o+=u/2,n=n-m/2-g/2,a=a-u/2-v/2):"content-box"===h?(i-=m/2,o-=u/2,n=n+m/2+g/2,a=a+u/2+v/2):(i=t.x,o=t.y,n=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(i-m/2,o),e.lineTo(i+n+g/2,o),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(i+n,o-u/2),e.lineTo(i+n,o+a+v/2),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(i-m/2,o+a),e.lineTo(i+n+g/2,o+a),e.closePath(),e.stroke()),m&&(e.beginPath(),e.lineWidth=m,e.moveTo(i,o-u/2),e.lineTo(i,o+a+v/2),e.closePath(),e.stroke())}else{let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i=t.x+c/2,o=t.y+c/2,n=t.w-c,a=t.h-c):"content-box"===h?(i=t.x-c/2,o=t.y-c/2,n=t.w+c,a=t.h+c):(i=t.x,o=t.y,n=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",n=Math.max(n,1),a=Math.max(a,1),d=d.map((e=>Math.min(e,n/2,a/2))),e.setLineDash(f),e.lineWidth=c,e.beginPath(),e.moveTo(i+d[0],o),e.arcTo(i+n,o,i+n,o+a,d[1]),e.arcTo(i+n,o+a,i,o+a,d[2]),e.arcTo(i,o+a,i,o,d[3]),e.arcTo(i,o,i+n,o,d[0]),e.closePath(),e.stroke()}e.setLineDash([])}function at(e,t,i){const{detail:o}=t,{viewScaleInfo:n,renderContent:a}=i,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:h}=o;N.number(h)?(e.save(),e.shadowColor=r||et.shadowColor,e.shadowOffsetX=(l||0)*n.scale,e.shadowOffsetY=(s||0)*n.scale,e.shadowBlur=(h||0)*n.scale,a(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,a(),e.restore())}const rt={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};var lt=function(e,t){var i={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(i[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(i[o[n]]=e[o[n]])}return i};const st=.4;function ht(e,t,i){var o,n,a;if(!0===(null===(o=null==t?void 0:t.operations)||void 0===o?void 0:o.invisible))return;const{w:r,h:l}=t,{scale:s}=i.viewScaleInfo;if(s<1&&(r*s<st||l*s<st)||0===i.parentOpacity)return;const{overrideElementMap:h}=i;if(!(null===(a=null===(n=null==h?void 0:h[t.uuid])||void 0===n?void 0:n.operations)||void 0===a?void 0:a.invisible))try{switch(t.type){case"rect":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=We(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});ue(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{at(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{it(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,renderContent:()=>{}})}})}))}(e,t,i);break;case"circle":!function(e,t,i){const{detail:o,angle:n}=t,{viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=i,{background:s="#000000",borderColor:h="#000000",boxSizing:c,borderWidth:d=0,borderDash:f}=o;let u=0;"number"==typeof d&&d>0?u=d:Array.isArray(d)&&"number"==typeof d[0]&&d[0]>0&&(u=d[0]),u*=a.scale;const{x:g,y:v,w:m,h:w}=We({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:a})||t,y=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:w,angle:n});ue(e,{x:g,y:v,w:m,h:w,angle:n},(()=>{at(e,y,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{let t=m/2,i=w/2;const o=g+t,n=v+i,r=t,d=i;if(u>0&&("content-box"===c||("center-line"===c?(t-=u/2,i-=u/2):(t-=u,i-=u))),t>=0&&i>=0){const c=tt(y)*l;e.globalAlpha=c,e.beginPath();const p=_e(e,s,{viewElementSize:{x:g,y:v,w:m,h:w},viewScaleInfo:a,opacity:e.globalAlpha});if(e.fillStyle=p,e.circle(o,n,r,d,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=l,"number"==typeof u&&u>0){const r=u/2+t,l=u/2+i;if(e.beginPath(),f){const t=f.map((e=>e*a.scale));e.setLineDash(t)}e.strokeStyle=h,e.lineWidth=u,e.circle(o,n,r,l,0,0,2*Math.PI),e.closePath(),e.stroke(),e.setLineDash([])}}}})}))}(e,t,i);break;case"text":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=We(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});ue(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{at(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{it(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a})}});{const i=Object.assign(Object.assign({},rt),t.detail),n=i.fontSize||rt.fontSize,a=n*o.scale;if(a<2)return;const c=(i.lineHeight||n)*o.scale;e.fillStyle=t.detail.color||rt.color,e.textBaseline="top",e.$setFont({fontWeight:i.fontWeight,fontSize:a,fontFamily:qe(i.fontFamily)});let d=i.text.replace(/\r\n/gi,"\n");"lowercase"===i.textTransform?d=d.toLowerCase():"uppercase"===i.textTransform&&(d=d.toUpperCase());const f=c,u=d.split("\n"),g=[];let v=0;u.forEach(((t,n)=>{if("maxContent"===i.minInlineSize)g.push({text:t,width:e.$undoPixelRatio(e.measureText(t).width)});else{let l="",c="",d=t.split(c);if("normal"===i.wordBreak){const e=" ",i=t.split(e);d=[],i.forEach(((t,o)=>{d.push(t),o<i.length-1&&d.push(e)}))}if(1===d.length&&"visible"===i.overflow)g.push({text:d[0],width:e.$undoPixelRatio(e.measureText(d[0]).width)});else if(d.length>0){for(let t=0;t<d.length&&(a=e.$doPixelRatio(s),r=e.measureText(l+d[t]).width,o.scale<.5&&a<r&&(a-r)/a>-.15||a>=r?l+=d[t]||"":(g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),l=d[t]||"",v++),!((v+1)*f>h&&"hidden"===i.overflow));t++)if(d.length-1===t&&(v+1)*f<=h){g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),n<u.length-1&&v++;break}}else g.push({text:"",width:0})}var a,r}));let m=0,w=0;f>a&&(w=(f-a)/2),g.length*f<h&&("top"===t.detail.verticalAlign?m=0:"bottom"===t.detail.verticalAlign?m+=h-g.length*f:m+=(h-g.length*f)/2);{const t=l+m;void 0!==i.textShadowColor&&R(i.textShadowColor)&&(e.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&N.number(i.textShadowOffsetX)&&(e.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&N.number(i.textShadowOffsetY)&&(e.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&N.number(i.textShadowBlur)&&(e.shadowBlur=i.textShadowBlur),g.forEach(((o,n)=>{let a=r;"center"===i.textAlign?a=r+(s-o.width)/2:"right"===i.textAlign&&(a=r+(s-o.width)),e.fillText(o.text,a,t+f*n+w)}))}}}))}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=We(t,{viewScaleInfo:n})||t,f=Object.assign(Object.assign({},t),{x:l,y:s,w:h,h:c,angle:d});ue(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{at(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{it(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{if(o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"image"===t.type&&o){e.globalAlpha=tt(t)*r;const{x:i,y:l,w:s,h:h,radiusList:c}=Qe(f,{viewScaleInfo:n,viewSizeInfo:a}),{detail:d}=t,{scaleMode:u,originW:g=0,originH:v=0}=d,m=e.$undoPixelRatio(g),w=e.$undoPixelRatio(v);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+c[0],l),e.arcTo(i+s,l,i+s,l+h,c[1]),e.arcTo(i+s,l+h,i,l+h,c[2]),e.arcTo(i,l+h,i,l,c[3]),e.arcTo(i,l,i+s,l,c[0]),e.closePath(),e.fill(),e.clip(),u&&v&&g){let n=0,a=0,r=m,c=w;const d=i,f=l,g=s,v=h;if(m>t.w||w>t.h)if("fill"===u){const e=Math.max(t.w/m,t.h/w),i=w*e;n=(m*e-t.w)/2/e,a=(i-t.h)/2/e,r=t.w/e,c=t.h/e}else if("tile"===u)n=0,a=0,r=t.w,c=t.h;else if("fit"===u){const e=Math.min(t.w/m,t.h/w);n=(m-t.w/e)/2,a=(w-t.h/e)/2,r=t.w/e,c=t.h/e}e.drawImage(o,n,a,r,c,d,f,g,v)}else e.drawImage(o,i,l,s,h);e.globalAlpha=r,e.restore()}}})}})}))}(e,t,i);break;case"svg":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=We(t,{viewScaleInfo:n,viewSizeInfo:a})||t;ue(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"svg"===t.type&&o&&(e.globalAlpha=tt(t)*r,e.drawImage(o,l,s,h,c),e.globalAlpha=r)}))}(e,t,i);break;case"html":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=We(t,{viewScaleInfo:n,viewSizeInfo:a})||t;ue(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"html"===t.type&&o&&(e.globalAlpha=tt(t)*r,e.drawImage(o,l,s,h,c),e.globalAlpha=r)}))}(e,t,i);break;case"path":!function(e,t,i){var o,n;const{detail:a}=t,{originX:r,originY:l,originW:s,originH:h,fillRule:c}=a,{viewScaleInfo:d,viewSizeInfo:f,parentOpacity:u}=i,{x:g,y:v,w:m,h:w,angle:y}=We(t,{viewScaleInfo:d})||t,p=m/s,x=w/h,S=g-r*p,b=v-l*x,I=t.detail,A=lt(I,["clipPath","clipPathStrokeColor","clipPathStrokeWidth"]),M=d.scale*f.devicePixelRatio,R=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:w,angle:y});let T=Object.assign({},R);T.detail=A;let z=Object.assign({},t);z.detail=A,a.fill&&"string"!==a.fill&&(null===(n=null===(o=a.fill)||void 0===o?void 0:o.type)||void 0===n?void 0:n.includes("gradient"))&&(T=Object.assign(Object.assign({},R),{detail:Object.assign(Object.assign({},R.detail),{background:a.fill,clipPath:{commands:a.commands,originX:r,originY:l,originW:s,originH:h}})}),z.detail=Object.assign({},T.detail)),ue(e,{x:g,y:v,w:m,h:w,angle:y},(()=>{it(e,T,{originElem:z,calcElemSize:{x:g,y:v,w:m,h:w,angle:y},viewScaleInfo:d,viewSizeInfo:f,parentOpacity:u,renderContent:()=>{at(e,R,{viewScaleInfo:d,viewSizeInfo:f,renderContent:()=>{e.save(),e.translate(S,b),e.scale(M*p/d.scale,M*x/d.scale);const t=Fe(a.commands||[]),i=new Path2D(t);a.fill&&("string"==typeof a.fill?e.fillStyle=a.fill:e.fillStyle="transparent"),a.fill&&e.fill(i,c),a.stroke&&0!==a.strokeWidth&&(e.strokeStyle=a.stroke,e.lineWidth=(a.strokeWidth||1)/f.devicePixelRatio,e.lineCap=a.strokeLineCap||"square",e.stroke(i)),e.translate(-S,-b),e.restore()}})}})}))}(e,t,i);break;case"group":{const o=Object.assign(Object.assign({},i.elementAssets||{}),t.detail.assets||{});!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=We({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});ue(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{e.globalAlpha=tt(t)*a,at(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{it(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,renderContent:()=>{const{x:r,y:l,w:s,h:h,radiusList:c}=Qe(d,{viewScaleInfo:o,viewSizeInfo:n});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(r+c[0],l),e.arcTo(r+s,l,r+s,l+h,c[1]),e.arcTo(r+s,l+h,r,l+h,c[2]),e.arcTo(r,l+h,r,l,c[3]),e.arcTo(r,l,r+s,l,c[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:o}=i,n={x:o.x+t.x,y:o.y+t.y,w:t.w||o.w,h:t.h||o.h,angle:t.angle},{calculator:r}=i;for(let o=0;o<t.detail.children.length;o++){let l=t.detail.children[o];if(l=Object.assign(Object.assign({},l),{x:n.x+l.x,y:n.y+l.y}),!0===i.forceDrawAll||(null==r?void 0:r.needRender(l)))try{ht(e,l,Object.assign(Object.assign({},i),{parentOpacity:a*tt(t)}))}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=a}))}(e,t,Object.assign(Object.assign({},i),{elementAssets:o}));break}}}catch(e){console.error(e)}}const ct={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function dt(e,t,i){var o;const{elements:n=[]}=t,{parentOpacity:a}=i;for(let t=0;t<n.length;t++){const r=n[t],l=Object.assign(Object.assign({},r),{detail:Object.assign(Object.assign({},ct),null==r?void 0:r.detail)});if(!0===i.forceDrawAll||(null===(o=i.calculator)||void 0===o?void 0:o.needRender(l)))try{ht(e,l,Object.assign(Object.assign({},i),{parentOpacity:a}))}catch(e){console.error(e)}}}var ft,ut,gt,vt,mt,wt,yt,pt,xt,St,bt,It,At=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))},Mt=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)},Rt=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i};const Tt=["image","svg","html"],zt=e=>{var t,i,o;let n=null;return"image"===e.type?n=(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)||null:"svg"===e.type?n=(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)||null:"html"===e.type&&(n=(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)||null),"string"==typeof n&&n?/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${n}`)?n:C(n):C(`${z()}-${e.uuid}-${z()}-${z()}`)};class Pt extends _{constructor(){super(),ft.add(this),ut.set(this,{}),gt.set(this,{}),vt.set(this,{}),mt.set(this,!1),Mt(this,ft,"m",wt).call(this,"image",((e,t)=>At(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.src])||void 0===i?void 0:i.value)||e.detail.src,n=yield j(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),Mt(this,ft,"m",wt).call(this,"html",((e,t)=>At(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.html])||void 0===i?void 0:i.value)||e.detail.html,n=yield Y(o,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),Mt(this,ft,"m",wt).call(this,"svg",((e,t)=>At(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.svg])||void 0===i?void 0:i.value)||e.detail.svg,n=yield D(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}}))))}isDestroyed(){return Mt(this,mt,"f")}destroy(){Rt(this,mt,!0,"f"),this.clear(),Rt(this,ut,null,"f"),Rt(this,gt,null,"f"),Rt(this,vt,null,"f")}load(e,t){!0!==Mt(this,mt,"f")&&(Mt(this,ft,"m",It).call(this,e)||Tt.includes(e.type)&&Mt(this,ft,"m",bt).call(this,e,t))}getContent(e){var t,i;const o=zt(e);return(null===(i=null===(t=Mt(this,vt,"f"))||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return Mt(this,vt,"f")}setLoadItemMap(e){Rt(this,vt,e,"f")}}ut=new WeakMap,gt=new WeakMap,vt=new WeakMap,mt=new WeakMap,ft=new WeakSet,wt=function(e,t){Mt(this,ut,"f")[e]=t},yt=function(e){var t,i,o;let n=null;return"image"===e.type?n=(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)||null:"svg"===e.type?n=(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)||null:"html"===e.type&&(n=(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)||null),n},pt=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:Mt(this,ft,"m",yt).call(this,e)}},xt=function(e){const t=zt(e.element),i=Mt(this,vt,"f")[t];Mt(this,mt,"f")||(i?i.startTime<e.startTime&&(Mt(this,vt,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(Mt(this,vt,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},St=function(e){var t;const i=zt(e.element),o=null===(t=Mt(this,vt,"f"))||void 0===t?void 0:t[i];Mt(this,mt,"f")||(o?o.startTime<e.startTime&&(Mt(this,vt,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(Mt(this,vt,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},bt=function(e,t){const i=Mt(this,ft,"m",pt).call(this,e),o=zt(e);if(Mt(this,gt,"f")[o])return;Mt(this,gt,"f")[o]=i;const n=Mt(this,ut,"f")[e.type];"function"!=typeof n||Mt(this,mt,"f")||(i.startTime=Date.now(),n(e,t).then((e=>{Mt(this,mt,"f")||(i.content=e.content,i.endTime=Date.now(),i.status="load",Mt(this,ft,"m",xt).call(this,i))})).catch((t=>{console.warn(`Load element source "${i.source}" fail`,t,e),i.endTime=Date.now(),i.status="error",i.error=t,Mt(this,ft,"m",St).call(this,i)})))},It=function(e){var t;const i=zt(e),o=null===(t=Mt(this,gt,"f"))||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==Mt(this,ft,"m",yt).call(this,e))};var Ct,Et,kt,Wt,Lt,Ot=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},jt=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class Dt extends _{constructor(e){super(),Ct.add(this),Et.set(this,void 0),kt.set(this,new Pt),Wt.set(this,!1),Ot(this,Et,e,"f"),jt(this,Ct,"m",Lt).call(this)}isDestroyed(){return jt(this,Wt,"f")}destroy(){this.clear(),Ot(this,Et,null,"f"),jt(this,kt,"f").destroy(),Ot(this,kt,null,"f"),Ot(this,Wt,!0,"f")}updateOptions(e){Ot(this,Et,e,"f")}drawData(e,t){const i=jt(this,kt,"f"),{calculator:o,sharer:n}=jt(this,Et,"f"),a=jt(this,Et,"f").viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const r={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},l=Object.assign({loader:i,calculator:o,parentElementSize:r,elementAssets:e.assets,parentOpacity:1,overrideElementMap:null==n?void 0:n.getActiveOverrideElemenentMap()},t);!function(e,t,i){if("string"==typeof(null==t?void 0:t.background)){const{viewSizeInfo:o}=i,{width:n,height:a}=o;e.globalAlpha=1,e.fillStyle=t.background,e.fillRect(0,0,n,a)}}(a,e.global,l),e.layout?function(e,t,i,o){const{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,l=Object.assign({uuid:"layout",type:"group"},t),{x:s,y:h,w:c,h:d}=We(l,{viewScaleInfo:n})||l,f=Object.assign(Object.assign({},l),{x:s,y:h,w:c,h:d,angle:0});if(e.globalAlpha=1,at(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{ot(e,f,{viewScaleInfo:n,viewSizeInfo:a})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:o,viewSizeInfo:n}=i,a=Object.assign({uuid:"layout",type:"group"},t),r=We(a,{viewScaleInfo:o})||a,l=Object.assign(Object.assign({},a),r),{x:s,y:h,w:c,h:d,radiusList:f}=Qe(l,{viewScaleInfo:o,viewSizeInfo:n});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(s+f[0],h),e.arcTo(s+c,h,s+c,h+d,f[1]),e.arcTo(s+c,h+d,s,h+d,f[2]),e.arcTo(s,h+d,s,h,f[3]),e.arcTo(s,h,s+c,h,f[0]),e.closePath(),e.fill(),e.clip()}o(e),"hidden"===t.detail.overflow&&e.restore(),nt(e,f,{viewScaleInfo:n,viewSizeInfo:a}),e.globalAlpha=r}(a,e.layout,l,(()=>{dt(a,e,l)})):dt(a,e,l)}scale(e){const{sharer:t}=jt(this,Et,"f");if(!t)return;const{data:i,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){jt(this,kt,"f").setLoadItemMap(e)}getLoadItemMap(){return jt(this,kt,"f").getLoadItemMap()}getLoader(){return jt(this,kt,"f")}}Et=new WeakMap,kt=new WeakMap,Wt=new WeakMap,Ct=new WeakSet,Lt=function(){const e=jt(this,kt,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))};var Yt,Vt,Bt=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Gt=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class Xt{constructor(e){Yt.set(this,void 0),Vt.set(this,void 0),Bt(this,Yt,e,"f"),Bt(this,Vt,new se({defaultStorage:{viewVisibleInfoMap:{},visibleCount:0,invisibleCount:0}}),"f")}toGridNum(e,t){return!0===(null==t?void 0:t.ignore)?e:Math.round(e)}destroy(){Bt(this,Yt,null,"f")}needRender(e){const t=Gt(this,Vt,"f").get("viewVisibleInfoMap")[e.uuid];return!t||t.isVisibleInView}isPointInElement(e,t,i,o){return je(e,{context2d:Gt(this,Yt,"f").viewContext,element:t,viewScaleInfo:i,viewSizeInfo:o})}getPointElement(e,t){const i=Gt(this,Yt,"f").viewContext;return function(e,t){var i,o,n;const{context2d:a,data:r,viewScaleInfo:l,viewSizeInfo:s,groupQueue:h}=t,c={index:-1,element:null,groupQueueIndex:-1};if(h&&Array.isArray(h)&&(null==h?void 0:h.length)>0)for(let t=h.length-1;t>=0;t--){let n=0,r=0,d=0;for(let e=0;e<=t;e++)n+=h[e].x,r+=h[e].y,d+=h[e].angle||0;const f=h[t];if(f&&"group"===f.type&&Array.isArray(null===(i=f.detail)||void 0===i?void 0:i.children))for(let i=0;i<f.detail.children.length;i++){const u=f.detail.children[i];if(!0!==(null===(o=null==u?void 0:u.operations)||void 0===o?void 0:o.invisible)){if(!u)break;if(je(e,{context2d:a,element:{x:n+u.x,y:r+u.y,w:u.w,h:u.h,angle:d+(u.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){c.element=u,(t<h.length-1||"group"!==u.type)&&(c.groupQueueIndex=t);break}}}if(c.element)break}if(c.element)return c;for(let t=r.elements.length-1;t>=0;t--){const i=r.elements[t];if(!0!==(null===(n=null==i?void 0:i.operations)||void 0===n?void 0:n.invisible)&&je(e,{context2d:a,element:i,viewScaleInfo:l,viewSizeInfo:s})){c.index=t,c.element=i;break}}return c}(e,Object.assign(Object.assign({},t),{context2d:i}))}resetViewVisibleInfoMap(e,t){if(e){const{viewVisibleInfoMap:i,invisibleCount:o,visibleCount:n}=function(e,t){const i={},o=[],n=t=>{const a={isVisibleInView:!0,isGroup:"group"===t.type,position:[...o]};let r=null;r=Ye(t,{groupQueue:Me(e,o)||[]}),i[t.uuid]=Object.assign(Object.assign({},a),{originRectInfo:r,rangeRectInfo:N.angle(t.angle)?Ve(r):r}),"group"===t.type&&t.detail.children.forEach(((e,t)=>{o.push(t),n(e),o.pop()}))};return e.forEach(((e,t)=>{o.push(t),n(e),o.pop()})),Be(i,t)}(e.elements,t);Gt(this,Vt,"f").set("viewVisibleInfoMap",i),Gt(this,Vt,"f").set("invisibleCount",o),Gt(this,Vt,"f").set("visibleCount",n)}}updateVisiableStatus(e){const{viewVisibleInfoMap:t,invisibleCount:i,visibleCount:o}=Be(Gt(this,Vt,"f").get("viewVisibleInfoMap"),e);Gt(this,Vt,"f").set("viewVisibleInfoMap",t),Gt(this,Vt,"f").set("invisibleCount",i),Gt(this,Vt,"f").set("visibleCount",o)}calcViewRectInfoFromOrigin(e,t){const i=Gt(this,Vt,"f").get("viewVisibleInfoMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:a}=t,{center:r,left:l,right:s,bottom:h,top:c,topLeft:d,topRight:f,bottomLeft:u,bottomRight:g}=i.originRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n,viewSizeInfo:a};return{center:Le(r,v),left:Le(l,v),right:Le(s,v),bottom:Le(h,v),top:Le(c,v),topLeft:Le(d,v),topRight:Le(f,v),bottomLeft:Le(u,v),bottomRight:Le(g,v)}}calcViewRectInfoFromRange(e,t){const i=Gt(this,Vt,"f").get("viewVisibleInfoMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:a}=t,{center:r,left:l,right:s,bottom:h,top:c,topLeft:d,topRight:f,bottomLeft:u,bottomRight:g}=i.rangeRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n,viewSizeInfo:a};return{center:Le(r,v),left:Le(l,v),right:Le(s,v),bottom:Le(h,v),top:Le(c,v),topLeft:Le(d,v),topRight:Le(f,v),bottomLeft:Le(u,v),bottomRight:Le(g,v)}}modifyViewVisibleInfoMap(e,t){const{modifyOptions:i,viewScaleInfo:o,viewSizeInfo:n}=t,{type:a,content:r}=i,l=e.elements,s=Gt(this,Vt,"f").get("viewVisibleInfoMap");if("deleteElement"===a){const{element:e}=r,t=[],i=e=>{t.push(e.uuid),"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{i(e)}))};i(e),t.forEach((e=>{delete s[e]})),Gt(this,Vt,"f").set("viewVisibleInfoMap",s)}else if("addElement"===a||"updateElement"===a){const{position:t}=r,i=Te(t,e.elements),h=Me(l,t);if(i)if("updateElement"===a&&"group"===i.type)this.resetViewVisibleInfoMap(e,{viewScaleInfo:o,viewSizeInfo:n});else{const e=Ye(i,{groupQueue:h||[]}),r={originRectInfo:e,rangeRectInfo:N.angle(i.angle)?Ve(e):e,isVisibleInView:!0,isGroup:"group"===(null==i?void 0:i.type),position:[...t]};s[i.uuid]=r,Gt(this,Vt,"f").set("viewVisibleInfoMap",s),"updateElement"===a&&this.updateVisiableStatus({viewScaleInfo:o,viewSizeInfo:n})}}else"moveElement"===a&&this.resetViewVisibleInfoMap(e,{viewScaleInfo:o,viewSizeInfo:n})}}Yt=new WeakMap,Vt=new WeakMap;var Nt,Ft,Ht,Zt,Qt,Ut,Jt,$t,Kt,qt,_t,ei,ti,ii,oi,ni,ai=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},ri=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};function li(e){return e>0||e<0||0===e}class si extends _{constructor(e){super(),Nt.add(this),Ft.set(this,void 0),Ht.set(this,void 0),Zt.set(this,!1),Ut.set(this,(e=>{if(!ri(this,Nt,"m",ii).call(this,e))return;const t=ri(this,Nt,"m",oi).call(this,e);if(!ri(this,Nt,"m",ni).call(this,t))return;e.preventDefault(),e.stopPropagation();const i=e.deltaX>0||e.deltaX<0?e.deltaX:0,o=e.deltaY>0||e.deltaY<0?e.deltaY:0;!0===e.ctrlKey&&this.has("wheelScale")?this.trigger("wheelScale",{deltaX:i,deltaY:o,point:t}):this.has("wheel")&&this.trigger("wheel",{deltaX:i,deltaY:o,point:t})})),Jt.set(this,(e=>{if(2!==e.button)return;if(!ri(this,Nt,"m",ii).call(this,e))return;e.preventDefault();const t=ri(this,Nt,"m",oi).call(this,e);ri(this,Nt,"m",ni).call(this,t)&&this.trigger("contextMenu",{point:t})})),$t.set(this,(e=>{if(!ri(this,Nt,"m",ii).call(this,e))return;e.preventDefault();const t=ri(this,Nt,"m",oi).call(this,e);if(!ri(this,Nt,"m",ni).call(this,t))return;const i=Date.now(),o=ri(this,Ht,"f").get("prevClickPoint");o&&i-o.t<=500&&Math.abs(o.x-t.x)<=5&&Math.abs(o.y-t.y)<=5?this.trigger("doubleClick",{point:t}):ri(this,Ht,"f").set("prevClickPoint",t)})),Kt.set(this,(e=>{if(ri(this,Ht,"f").set("hasPointDown",!1),!ri(this,Nt,"m",ii).call(this,e))return;e.preventDefault();const t=ri(this,Nt,"m",oi).call(this,e);this.trigger("pointLeave",{point:t})})),qt.set(this,(e=>{if(ri(this,Ht,"f").set("hasPointDown",!1),!ri(this,Nt,"m",ii).call(this,e))return;e.preventDefault();const t=ri(this,Nt,"m",oi).call(this,e);this.trigger("pointEnd",{point:t})})),_t.set(this,(e=>{if(!ri(this,Nt,"m",ii).call(this,e))return;e.preventDefault(),e.stopPropagation();const t=ri(this,Nt,"m",oi).call(this,e);ri(this,Nt,"m",ni).call(this,t)?!0===ri(this,Ht,"f").get("hasPointDown")&&this.trigger("pointMove",{point:t}):ri(this,Ht,"f").get("hasPointDown")&&(this.trigger("pointLeave",{point:t}),ri(this,Ht,"f").set("hasPointDown",!1))})),ei.set(this,(e=>{if(0!==e.button)return;if(!ri(this,Nt,"m",ii).call(this,e))return;e.preventDefault();const t=ri(this,Nt,"m",oi).call(this,e);ri(this,Nt,"m",ni).call(this,t)&&(ri(this,Ht,"f").set("hasPointDown",!0),this.trigger("pointStart",{point:t}))})),ti.set(this,(e=>{if(!ri(this,Nt,"m",ii).call(this,e))return;e.preventDefault();const t=ri(this,Nt,"m",oi).call(this,e);ri(this,Nt,"m",ni).call(this,t)&&this.trigger("hover",{point:t})}));const t=new se({defaultStorage:{hasPointDown:!1,prevClickPoint:null}});ai(this,Ht,t,"f"),ai(this,Ft,e,"f"),ri(this,Nt,"m",Qt).call(this)}onEvents(){if(ri(this,Zt,"f"))return;const e=window;e.addEventListener("mousemove",ri(this,ti,"f")),e.addEventListener("mousedown",ri(this,ei,"f")),e.addEventListener("mousemove",ri(this,_t,"f")),e.addEventListener("mouseup",ri(this,qt,"f")),e.addEventListener("mouseleave",ri(this,Kt,"f")),e.addEventListener("wheel",ri(this,Ut,"f"),{passive:!1}),e.addEventListener("click",ri(this,$t,"f")),e.addEventListener("contextmenu",ri(this,Jt,"f"))}offEvents(){const e=window;e.removeEventListener("mousemove",ri(this,ti,"f")),e.removeEventListener("mousedown",ri(this,ei,"f")),e.removeEventListener("mousemove",ri(this,_t,"f")),e.removeEventListener("mouseup",ri(this,qt,"f")),e.removeEventListener("mouseleave",ri(this,Kt,"f")),e.removeEventListener("wheel",ri(this,Ut,"f")),e.removeEventListener("click",ri(this,$t,"f")),e.removeEventListener("contextmenu",ri(this,Jt,"f"))}destroy(){this.offEvents(),ri(this,Ht,"f").destroy(),ai(this,Zt,!0,"f")}}Ft=new WeakMap,Ht=new WeakMap,Zt=new WeakMap,Ut=new WeakMap,Jt=new WeakMap,$t=new WeakMap,Kt=new WeakMap,qt=new WeakMap,_t=new WeakMap,ei=new WeakMap,ti=new WeakMap,Nt=new WeakSet,Qt=function(){this.onEvents()},ii=function(e){return e.target===ri(this,Ft,"f").boardContent.boardContext.canvas},oi=function(e){const t=ri(this,Ft,"f").boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top,t:Date.now()}},ni=function(e){const t=ri(this,Ft,"f").sharer.getActiveViewSizeInfo(),{width:i,height:o}=t;return!!(li(e.x)&&li(e.y)&&e.x<=i&&e.y<=o)};var hi,ci,di=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},fi=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};const ui={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0,overrideElementMap:null};class gi{constructor(){hi.set(this,void 0),ci.set(this,void 0);const e=new se({defaultStorage:ui}),t=new se({defaultStorage:{}});di(this,hi,e,"f"),di(this,ci,t,"f")}getActiveStorage(e){return fi(this,hi,"f").get(e)}setActiveStorage(e,t){return fi(this,hi,"f").set(e,t)}getActiveStoreSnapshot(e){return fi(this,hi,"f").getSnapshot(e)}getSharedStorage(e){return fi(this,ci,"f").get(e)}setSharedStorage(e,t){return fi(this,ci,"f").set(e,t)}getSharedStoreSnapshot(e){return fi(this,ci,"f").getSnapshot(e)}getActiveViewScaleInfo(){return{scale:fi(this,hi,"f").get("scale"),offsetTop:fi(this,hi,"f").get("offsetTop"),offsetBottom:fi(this,hi,"f").get("offsetBottom"),offsetLeft:fi(this,hi,"f").get("offsetLeft"),offsetRight:fi(this,hi,"f").get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:n,offsetRight:a}=e;fi(this,hi,"f").set("scale",t),fi(this,hi,"f").set("offsetTop",i),fi(this,hi,"f").set("offsetBottom",o),fi(this,hi,"f").set("offsetLeft",n),fi(this,hi,"f").set("offsetRight",a)}setActiveViewSizeInfo(e){fi(this,hi,"f").set("width",e.width),fi(this,hi,"f").set("height",e.height),fi(this,hi,"f").set("devicePixelRatio",e.devicePixelRatio),fi(this,hi,"f").set("contextWidth",e.contextWidth),fi(this,hi,"f").set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:fi(this,hi,"f").get("width"),height:fi(this,hi,"f").get("height"),devicePixelRatio:fi(this,hi,"f").get("devicePixelRatio"),contextWidth:fi(this,hi,"f").get("contextWidth"),contextHeight:fi(this,hi,"f").get("contextHeight")}}getActiveOverrideElemenentMap(){return fi(this,hi,"f").get("overrideElementMap")}setActiveOverrideElemenentMap(e){fi(this,hi,"f").set("overrideElementMap",e)}}hi=new WeakMap,ci=new WeakMap;var vi,mi,wi,yi,pi,xi,Si=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},bi=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};const{requestAnimationFrame:Ii}=window;class Ai extends _{constructor(e){super(),vi.add(this),mi.set(this,void 0),wi.set(this,[]),yi.set(this,"FREE"),Si(this,mi,e,"f"),bi(this,vi,"m",pi).call(this)}resetViewVisibleInfoMap(e,t){e&&bi(this,mi,"f").calculator.resetViewVisibleInfoMap(e,t)}drawFrame(){const{sharer:e}=bi(this,mi,"f"),t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();bi(this,wi,"f").push({activeStore:t,sharedStore:i}),bi(this,vi,"m",xi).call(this)}scale(e){const{scale:t,point:i,ignoreUpdateVisibleStatus:o}=e,{sharer:n}=bi(this,mi,"f"),{moveX:a,moveY:r}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:n,offsetTop:a}=o,r=t/o.scale,l=i.x,s=i.y;return{moveX:l-l*r+(n*r-n),moveY:s-s*r+(a*r-a)}}({scale:t,point:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});return n.setActiveStorage("scale",t),o||bi(this,mi,"f").calculator.updateVisiableStatus({viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),{moveX:a,moveY:r}}scroll(e){const{sharer:t}=bi(this,mi,"f"),i=t.getActiveViewScaleInfo(),{moveX:o,moveY:n,ignoreUpdateVisibleStatus:a}=e,r=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:n}=e,{scale:a}=o,{width:r,height:l,contextWidth:s,contextHeight:h}=n;let c=o.offsetLeft,d=o.offsetRight,f=o.offsetTop,u=o.offsetBottom;return c+=t,f+=i,d=r-(s*a+c),u=l-(h*a+f),{scale:a,offsetTop:f,offsetLeft:c,offsetRight:d,offsetBottom:u}}({moveX:o,moveY:n,viewScaleInfo:i,viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(r),a||bi(this,mi,"f").calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),r}updateViewScaleInfo(e){const{sharer:t}=bi(this,mi,"f"),i=function(e,t){const{scale:i,offsetX:o,offsetY:n}=e,{viewSizeInfo:a}=t,{width:r,height:l,contextWidth:s,contextHeight:h}=a,c=0-o*i,d=0-n*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:r-(s*i+c/i),offsetBottom:l-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),bi(this,mi,"f").calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),i}resize(e={},t){const{sharer:i}=bi(this,mi,"f"),o=i.getActiveViewSizeInfo(),n=Object.assign(Object.assign({},o),e),{width:a,height:r,devicePixelRatio:l}=n,{underlayContext:s,boardContext:h,overlayContext:c,viewContext:d}=bi(this,mi,"f").boardContent;return h.canvas.width=a*l,h.canvas.height=r*l,h.canvas.style.width=`${a}px`,h.canvas.style.height=`${r}px`,s.canvas.width=a*l,s.canvas.height=r*l,c.canvas.width=a*l,c.canvas.height=r*l,d.canvas.width=a*l,d.canvas.height=r*l,i.setActiveViewSizeInfo(n),(null==t?void 0:t.ignoreUpdateVisibleStatus)||bi(this,mi,"f").calculator.updateVisiableStatus({viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}),n}}mi=new WeakMap,wi=new WeakMap,yi=new WeakMap,vi=new WeakSet,pi=function(){const{renderer:e}=bi(this,mi,"f");e.on("load",(()=>{this.drawFrame()}))},xi=function e(){if("DRAWING"===bi(this,yi,"f")||0===bi(this,wi,"f").length)return;Si(this,yi,"DRAWING","f");const t=bi(this,wi,"f").shift(),{renderer:i,boardContent:o,beforeDrawFrame:n,afterDrawFrame:a}=bi(this,mi,"f");if(t){const{scale:e,offsetTop:r,offsetBottom:l,offsetLeft:s,offsetRight:h,width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g}=t.activeStore,v={scale:e,offsetTop:r,offsetBottom:l,offsetLeft:s,offsetRight:h},m={width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g};(null==t?void 0:t.activeStore.data)&&i.drawData(t.activeStore.data,{viewScaleInfo:v,viewSizeInfo:m}),n({snapshot:t}),o.drawView(),a({snapshot:t})}0!==bi(this,wi,"f").length?Si(this,yi,"DRAWING","f")&&Ii((()=>{bi(this,vi,"m",e).call(this)})):Si(this,yi,"COMPLETE","f")};var Mi,Ri,Ti,zi,Pi,Ci,Ei,ki,Wi,Li,Oi,ji,Di,Yi,Vi,Bi,Gi,Xi,Ni,Fi,Hi,Zi,Qi,Ui,Ji,$i,Ki,qi,_i=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},eo=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class to{constructor(e){Mi.add(this),Ri.set(this,void 0),Ti.set(this,new WeakMap),zi.set(this,[]),Pi.set(this,[]),Ci.set(this,void 0),Ei.set(this,void 0),ki.set(this,void 0),Wi.set(this,void 0),Li.set(this,void 0),Oi.set(this,new _),ji.set(this,!1);const{boardContent:t}=e,i=new gi,o=new Xt({viewContext:t.viewContext}),n=new si({boardContent:t,sharer:i}),a=new Dt({viewContext:t.viewContext,sharer:i,calculator:o});_i(this,Ri,e,"f"),_i(this,ki,i,"f"),_i(this,Ci,n,"f"),_i(this,Ei,a,"f"),_i(this,Li,o,"f"),_i(this,Wi,new Ai({boardContent:e.boardContent,sharer:i,renderer:a,calculator:eo(this,Li,"f"),beforeDrawFrame:e=>{eo(this,Mi,"m",$i).call(this,e)},afterDrawFrame:e=>{eo(this,Mi,"m",Ki).call(this,e)}}),"f"),eo(this,Mi,"m",Di).call(this),eo(this,Mi,"m",qi).call(this)}isDestroyed(){return eo(this,ji,"f")}destroy(){eo(this,Ci,"f").destroy(),eo(this,Ei,"f").destroy(),eo(this,Li,"f").destroy(),eo(this,Oi,"f").destroy(),_i(this,ji,!0,"f")}getSharer(){return eo(this,ki,"f")}getViewer(){return eo(this,Wi,"f")}getRenderer(){return eo(this,Ei,"f")}setData(e,t){const{modifiedOptions:i}=t||{},o=eo(this,ki,"f");eo(this,ki,"f").setActiveStorage("data",e);const n=o.getActiveViewSizeInfo(),a=o.getActiveViewScaleInfo(),r=Ae(e.elements,{viewWidth:n.width,viewHeight:n.height,extend:!0});eo(this,Wi,"f").resetViewVisibleInfoMap(e,{viewSizeInfo:n,viewScaleInfo:a}),eo(this,Wi,"f").drawFrame();const l=Object.assign(Object.assign({},n),r);return eo(this,ki,"f").setActiveViewSizeInfo(l),{viewSizeInfo:l}}getData(){const{data:e}=eo(this,ki,"f").getActiveStoreSnapshot();return e}use(e,t){var i,o,n;if(eo(this,Ti,"f").has(e)){const t=eo(this,Ti,"f").get(e);if(t)return null===(o=(i=t.middlewareObject).use)||void 0===o||o.call(i),t.status="enable",eo(this,Ti,"f").set(e,t),void eo(this,Mi,"m",qi).call(this)}const{boardContent:a,container:r}=eo(this,Ri,"f"),l=e({boardContent:a,sharer:eo(this,ki,"f"),viewer:eo(this,Wi,"f"),calculator:eo(this,Li,"f"),eventHub:eo(this,Oi,"f"),container:r},t);null===(n=l.use)||void 0===n||n.call(l),eo(this,zi,"f").push(e),eo(this,Pi,"f").push(l),eo(this,Ti,"f").set(e,{status:"enable",middlewareObject:l,config:t}),eo(this,Mi,"m",qi).call(this)}disuse(e){var t,i;const o=eo(this,Ti,"f").get(e);o&&(null===(i=(t=o.middlewareObject).disuse)||void 0===i||i.call(t),o.status="disable",eo(this,Ti,"f").set(e,o),eo(this,Mi,"m",qi).call(this))}scale(e){const t=eo(this,Wi,"f"),{ignoreUpdateVisibleStatus:i}=e,{moveX:o,moveY:n}=t.scale(Object.assign(Object.assign({},e),{ignoreUpdateVisibleStatus:!0}));t.scroll({moveX:o,moveY:n,ignoreUpdateVisibleStatus:i})}scroll(e){return eo(this,Wi,"f").scroll(e)}updateViewScaleInfo(e){return eo(this,Wi,"f").updateViewScaleInfo(e)}resize(e,t){const i=eo(this,Wi,"f").resize(e,t),{width:o,height:n,devicePixelRatio:a}=e,{boardContent:r}=eo(this,Ri,"f");r.viewContext.$resize({width:o,height:n,devicePixelRatio:a}),r.overlayContext.$resize({width:o,height:n,devicePixelRatio:a}),r.boardContext.$resize({width:o,height:n,devicePixelRatio:a}),r.underlayContext.$resize({width:o,height:n,devicePixelRatio:a}),eo(this,Wi,"f").drawFrame(),eo(this,Ci,"f").trigger("resize",i),eo(this,ki,"f").setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=eo(this,Ri,"f"),{underlayContext:t,overlayContext:i,viewContext:o,boardContext:n}=e;t.clearRect(0,0,t.canvas.width,t.canvas.height),i.clearRect(0,0,i.canvas.width,i.canvas.height),o.clearRect(0,0,o.canvas.width,o.canvas.height),n.clearRect(0,0,n.canvas.width,n.canvas.height),eo(this,Mi,"m",Ji).call(this)}getEventHub(){return eo(this,Oi,"f")}onWatcherEvents(){eo(this,Ci,"f").onEvents()}offWatcherEvents(){eo(this,Ci,"f").offEvents()}}Ri=new WeakMap,Ti=new WeakMap,zi=new WeakMap,Pi=new WeakMap,Ci=new WeakMap,Ei=new WeakMap,ki=new WeakMap,Wi=new WeakMap,Li=new WeakMap,Oi=new WeakMap,ji=new WeakMap,Mi=new WeakSet,Di=function(){eo(this,Ci,"f").on("pointStart",eo(this,Mi,"m",Yi).bind(this)),eo(this,Ci,"f").on("pointEnd",eo(this,Mi,"m",Vi).bind(this)),eo(this,Ci,"f").on("pointMove",eo(this,Mi,"m",Bi).bind(this)),eo(this,Ci,"f").on("hover",eo(this,Mi,"m",Gi).bind(this)),eo(this,Ci,"f").on("wheel",eo(this,Mi,"m",Fi).bind(this)),eo(this,Ci,"f").on("wheelScale",eo(this,Mi,"m",Hi).bind(this)),eo(this,Ci,"f").on("scrollX",eo(this,Mi,"m",Zi).bind(this)),eo(this,Ci,"f").on("scrollY",eo(this,Mi,"m",Qi).bind(this)),eo(this,Ci,"f").on("resize",eo(this,Mi,"m",Ui).bind(this)),eo(this,Ci,"f").on("doubleClick",eo(this,Mi,"m",Xi).bind(this)),eo(this,Ci,"f").on("contextMenu",eo(this,Mi,"m",Ni).bind(this)),eo(this,Ei,"f").on("load",(()=>{eo(this,Oi,"f").trigger("loadResource")}))},Yi=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointStart)||void 0===t?void 0:t.call(o,e)))return}},Vi=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointEnd)||void 0===t?void 0:t.call(o,e)))return}},Bi=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointMove)||void 0===t?void 0:t.call(o,e)))return}},Gi=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.hover)||void 0===t?void 0:t.call(o,e)))return}},Xi=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.doubleClick)||void 0===t?void 0:t.call(o,e)))return}},Ni=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.contextMenu)||void 0===t?void 0:t.call(o,e)))return}},Fi=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheel)||void 0===t?void 0:t.call(o,e)))return}},Hi=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheelScale)||void 0===t?void 0:t.call(o,e)))return}},Zi=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollX)||void 0===t?void 0:t.call(o,e)))return}},Qi=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollY)||void 0===t?void 0:t.call(o,e)))return}},Ui=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.resize)||void 0===t?void 0:t.call(o,e)))return}},Ji=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.clear)||void 0===t?void 0:t.call(o,e)))return}},$i=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.beforeDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},Ki=function(e){var t;for(let i=0;i<eo(this,Pi,"f").length;i++){const o=eo(this,Pi,"f")[i];if(!1===(null===(t=null==o?void 0:o.afterDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},qi=function(){const e=[],t=eo(this,Ti,"f");eo(this,zi,"f").forEach((i=>{const o=t.get(i);"enable"===(null==o?void 0:o.status)&&(null==o?void 0:o.middlewareObject)&&e.push(o.middlewareObject)})),_i(this,Pi,e,"f")};const io="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMjMtMDktMTdUMTY6MzE6MjMrMDg6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDIzLTA5LTE3VDE2OjQ0OjIyKzA4OjAwIiB4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yqn1c1j6MVFGjoidfW1oq2ABrYj0V82OmVzwHNajVdB88C5wOKTdM87NaxsrKyQsFKHC2BnTDo+/TWt8Bd5INeVC44NDT0xXYZdXNz8w/AaeyS8yjwCPdzQu92ht2m/OUjIyOfS1pkAoqItLS0fA+8D7wKPA0cxs6qC1O4T0xMfKYnb21tnXEDNjc3z+nXbW1t3wFvYz9dCAL7KUThHovFPtGTNjU1jQFSX18/lg68cuXKLUAaGxs3vkB7e/u3wHHgCQpUdnpTqdQvesJgMDisUVevXh3Xry9fvnxTv66qqprQ/cfHx/vVNj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==",oo="selectInGroup",no={CURSOR:"cursor",CHANGE:"change",RULER:"ruler",SCALE:"scale",SELECT:"select",CLEAR_SELECT:"clearSelect",TEXT_EDIT:"textEdit",TEXT_CHANGE:"textChange",CONTEXT_MENU:"contextMenu",SELECT_IN_GROUP:oo,SNAP_TO_GRID:oo},ao={};Object.keys(no).forEach((e=>{Object.defineProperty(ao,e,{value:no[e],writable:!1})}));class ro{constructor(e,d){I(this,r),I(this,s),I(this,c),I(this,f),I(this,g),I(this,t,void 0),I(this,i,void 0),I(this,o,null),I(this,n,null),I(this,a,{auto:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0I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7zp5J+LmmNpFcl5U8GmCupWFKtpO9K+qWkG76W3bt3j4OMRqNqaWnRhQsXNDQ0lAWVTCZ169YtHThwQFVVVePKtrS0+Kw3pgsYso+Vkuol7ZD0W0ldvsHW1tZJZXxtba0aGxvV1NSkdevWaenSpYpGoxPmXb9+vXp6ejzgx5J+ZiGeLSk8GaD34ky5Hd23JP1I0h8kPQmGu7y8/L/aNEUiEe3fv1/Dw8Pp6Es6KqlZ0puSXpHbVU4KiPVglqQFkr4j6aeSfi/pvq/13r172rVrlyorK6cFFo1GtXnzZl25ciU4Ch5J+qOkH0v6tqTXzDk5EwGGlNFjOWQOd8px4vUN4E3cpn2pz/jgwQPef/99Ll68yJ07d+jt7WVwcJBIJEJJSQlz586loaGBTZs2UVdXF5w0OoDLwFWcbPsct6r04+bRLHEYCoWyAD1kBDfHleHmsxrccccS3NFHNV/eenBy6iZwCycMOnHz5wBuDh2nyyY6H0zhFmoF7vtxk+l9q3ieQfrDo8msF7cy3cN56g7ZWnKcep7IxnrQmz+wHKu2K3EKJWbPpWSUTQ4ZtRJc23sC6ZGB9ZM52JwcboIQjzUvZvNxYfeHlyVkZFcBbux6wKA6ShjoM5yM8uH0Xpuy8ekAQuZc2W8P8nEei9p9mMmPgAfJHO0O27e0lHppw9MEDJo//A4eoE91iB48SJ80lFMB/t/+V/sPGZfTmtMFR4EAAAAASUVORK5CYII="}),A(this,i,e),A(this,t,d.eventHub),M(this,r,l).call(this),M(this,s,h).call(this)}}t=new WeakMap,i=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,l=function(){const e=b(this,t);M(this,c,d).call(this,"default"),e.on(ao.CURSOR,(e=>{var t;"over-element"!==e.type&&e.type?"resize-rotate"===e.type?M(this,c,d).call(this,"rotate"):"string"==typeof e.type&&(null==(t=e.type)?void 0:t.startsWith("resize-"))?M(this,f,u).call(this,e):"drag-default"===e.type?M(this,c,d).call(this,"drag-default"):"drag-active"===e.type?M(this,c,d).call(this,"drag-active"):M(this,c,d).call(this,"auto"):M(this,c,d).call(this,"auto")}))},s=new WeakSet,h=function(){j(io).then((e=>{A(this,n,e)})).catch((e=>{console.error(e)}))},c=new WeakSet,d=function(e){if(b(this,o)===e)return;A(this,o,e);const t=b(this,a)[b(this,o)]||b(this,a).auto;let n=0,r=0;(e.startsWith("rotate-")&&b(this,a)[b(this,o)]||"rotate"===e)&&(n=10,r=10),b(this,i).style.cursor="default"===e?"default":`image-set(url(${t})2x) ${n} ${r}, auto`},f=new WeakSet,u=function(e){var t;let i=0;"resize-top"===e.type?i+=0:"resize-top-right"===e.type?i+=45:"resize-right"===e.type?i+=90:"resize-bottom-right"===e.type?i+=135:"resize-bottom"===e.type?i+=180:"resize-bottom-left"===e.type?i+=225:"resize-left"===e.type?i+=270:"resize-top-left"===e.type&&(i+=315),i+=be((null==(t=null==e?void 0:e.element)?void 0:t.angle)||0),Array.isArray(e.groupQueue)&&e.groupQueue.length>0&&e.groupQueue.forEach((e=>{i+=be(e.angle||0)})),i=be(i);const o=M(this,g,v).call(this,i);M(this,c,d).call(this,o)},g=new WeakSet,v=function(e){const t=`rotate-${e}`;if(!b(this,a)[t]){const i=b(this,n);if(i){const o=document.createElement("canvas"),n=i.width,r=i.height,l={x:n/2,y:r/2};o.width=n,o.height=r;const s=o.getContext("2d"),h=de(e);s.translate(l.x,l.y),s.rotate(h),s.translate(-l.x,-l.y),s.drawImage(i,0,0,n,r),s.translate(l.x,l.y),s.rotate(-h),s.translate(-l.x,-l.y);const c=o.toDataURL("image/png");b(this,a)[t]=c}}return t};const lo="SELECT",so=Symbol(`${lo}_actionType`),ho=Symbol(`${lo}_resizeType`),co=Symbol(`${lo}_areaStart`),fo=Symbol(`${lo}_areaEnd`),uo=Symbol(`${lo}_hoverElement`),go=Symbol(`${lo}_hoverElementVertexes`),vo=Symbol(`${lo}_selectedElementList`),mo=Symbol(`${lo}_selectedElementListVertexes`),wo=Symbol(`${lo}_selectedElementController`),yo=Symbol(`${lo}_selectedElementPosition`),po=Symbol(`${lo}_groupQueue`),xo=Symbol(`${lo}_groupQueueVertexesList`),So=Symbol(`${lo}_isMoving`),bo=Symbol(`${lo}_enableSelectInGroup`),Io=Symbol(`${lo}_enableSnapToGrid`),Ao={activeColor:"#1973ba",activeAreaColor:"#1976d21c",lockedColor:"#5b5959b5",referenceColor:"#f7276e"};function Mo(e,t,i){const{borderColor:o,borderWidth:n,background:a,lineDash:r}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.fillStyle=a,e.setLineDash(r),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.lineTo(t[0].x,t[0].y),e.closePath(),e.stroke(),e.fill()}function Ro(e,t,i,o){const{borderColor:n,borderWidth:a,lineDash:r}=o;e.setLineDash([]),e.lineWidth=a,e.strokeStyle=n,e.setLineDash(r),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke()}function To(e,t,i){const{borderColor:o,borderWidth:n,lineDash:a}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.setLineDash(a),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[2].x,t[2].y),e.closePath(),e.stroke(),e.beginPath(),e.moveTo(t[1].x,t[1].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function zo(e,t,i){const{size:o,borderColor:n,borderWidth:a,lineDash:r}=i,l=t.x-o/2,s=t.x+o/2,h=t.y-o/2,c=t.y+o/2;To(e,[{x:l,y:h},{x:s,y:h},{x:s,y:c},{x:l,y:c}],{borderColor:n,borderWidth:a,lineDash:r})}function Po(e,t,i){if(!t)return;const{style:o}=i,{activeColor:n}=o,a={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};Mo(e,Oe(t,i),a)}function Co(e,t,i){if(!t)return;const{style:o}=i,{lockedColor:n}=o,a={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};Mo(e,Oe(t,i),a);const{controller:r}=i;if(r){const{topLeft:t,topRight:o,bottomLeft:l,bottomRight:s,topMiddle:h,bottomMiddle:c,leftMiddle:d,rightMiddle:f}=r,u={...a,borderWidth:1,background:n};To(e,Oe(h.vertexes,i),u),To(e,Oe(c.vertexes,i),u),To(e,Oe(d.vertexes,i),u),To(e,Oe(f.vertexes,i),u),To(e,Oe(t.vertexes,i),u),To(e,Oe(o.vertexes,i),u),To(e,Oe(l.vertexes,i),u),To(e,Oe(s.vertexes,i),u)}}function Eo(e,t,i){if(!t)return;const{hideControllers:o,style:n}=i,{activeColor:a}=n,{elementWrapper:r,topLeft:l,topRight:s,bottomLeft:h,bottomRight:c,top:d,rotate:f}=t,u={borderColor:a,borderWidth:2,background:"transparent",lineDash:[]},g={...u,borderWidth:4,background:"#FFFFFF"};Mo(e,Oe(r,i),u),o||(Ro(e,Le(d.center,i),Le(f.center,i),{...g,borderWidth:2}),Mo(e,Oe(l.vertexes,i),g),Mo(e,Oe(s.vertexes,i),g),Mo(e,Oe(h.vertexes,i),g),Mo(e,Oe(c.vertexes,i),g),function(e,t,i){const{size:o,borderColor:n,borderWidth:a,background:r}=i,l=t,s=o/2,h=s,c=s;if(h>=0&&c>=0){if("number"==typeof a&&a>0){const t=a/2+h,i=a/2+c;e.beginPath(),e.strokeStyle=n,e.lineWidth=a,e.circle(l.x,l.y,t,i,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath(),e.fillStyle=r,e.circle(l.x,l.y,h,c,0,0,2*Math.PI),e.closePath(),e.fill()}}(e,Le(f.center,i),{...g,size:10,borderWidth:2}))}function ko(e,t){const{xLines:i,yLines:o,style:n}=t,{referenceColor:a}=n,r={borderColor:a,borderWidth:1,lineDash:[]},l={...r,size:6};i&&i.forEach((t=>{t.forEach(((i,o)=>{zo(e,i,l),t[o+1]&&Ro(e,t[o],t[o+1],r)}))})),o&&o.forEach((t=>{t.forEach(((i,o)=>{zo(e,i,l),t[o+1]&&Ro(e,t[o],t[o+1],r)}))}))}function Wo(e){return e*Math.PI/180}function Lo(e,t){return Math.sqrt(e*e+t*t)}function Oo(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function jo(e,t){const{ctx:i,viewScaleInfo:o,vertexes:n}=t,a=Le(n[0],{viewScaleInfo:o}),r=Le(n[1],{viewScaleInfo:o}),l=Le(n[2],{viewScaleInfo:o}),s=Le(n[3],{viewScaleInfo:o});return i.beginPath(),i.moveTo(a.x,a.y),i.lineTo(r.x,r.y),i.lineTo(l.x,l.y),i.lineTo(s.x,s.y),i.lineTo(a.x,a.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function Do(e,t){const{ctx:i,viewScaleInfo:o,viewSizeInfo:n,groupQueue:a}=t;if(!(a&&(null==a?void 0:a.length)>0))return!1;const r=Ee(a),l=r[r.length-1];return!!l&&jo(e,{ctx:i,vertexes:l,viewScaleInfo:o,viewSizeInfo:n})}function Yo(e,t){var i,o,n;const a={type:null,elements:[],elementVertexesList:[],groupQueue:[],groupQueueVertexesList:[]},{ctx:r,data:l,calculator:s,selectedElements:h,viewScaleInfo:c,viewSizeInfo:d,areaSize:f,groupQueue:u,selectedElementController:g}=t;if(g){const{left:t,right:i,top:o,bottom:n,topLeft:l,topRight:s,bottomLeft:f,bottomRight:v,rotate:m}=g,w=[t,i,o,n,l,s,f,v,m];for(let t=0;t<w.length;t++){const i=w[t];if(jo(e,{ctx:r,vertexes:i.vertexes,viewSizeInfo:d,viewScaleInfo:c})){a.type=`resize-${i.type}`,h&&(null==h?void 0:h.length)>0&&(a.groupQueue=u||[],a.elements=[h[0]]);break}}}if(u&&Array.isArray(u)&&u.length>0){const t=u[u.length-1];if((null==(i=null==t?void 0:t.detail)?void 0:i.children)&&Array.isArray(null==(o=null==t?void 0:t.detail)?void 0:o.children))for(let i=t.detail.children.length-1;i>=0;i--){const o=t.detail.children[i],n=ke(o,{groupQueue:u});if(n&&jo(e,{ctx:r,vertexes:n,viewScaleInfo:c,viewSizeInfo:d}))return a.type||(a.type="over-element"),a.groupQueue=u,a.elements=[o],a}return a}if(null!==a.type)return a;if(f&&Array.isArray(h)&&(null==h?void 0:h.length)>1){const{x:t,y:i,w:o,h:n}=f;if(e.x>=t&&e.x<=t+o&&e.y>=i&&e.y<=i+n)return a.type="list-area",a.elements=h,a}if(l){const{index:t,element:i}=s.getPointElement(e,{data:l,viewScaleInfo:c,viewSizeInfo:d});if(t>=0&&i&&!0!==(null==(n=null==i?void 0:i.operations)?void 0:n.invisible))return a.elements=[i],a.type="over-element",a}return a}function Vo(e,t){const{x:i,y:o,w:n,h:a,angle:r=0}=e,{center:l,start:s,end:h,viewScaleInfo:c}=t,d=Le(l,{viewScaleInfo:c}),f=be(r),u=function(e,t,i){const o=me(e,t),n=me(e,i);return null!==n&&null!==o?o>3*Math.PI/2&&n<Math.PI/2?n+(2*Math.PI-o):n>3*Math.PI/2&&o<Math.PI/2?o+(2*Math.PI-n):n-o:0}(d,s,h);return{x:i,y:o,w:n,h:a,angle:f+u/Math.PI*180}}function Bo(e,t){var i;if(!Array.isArray(e))return null;const o={x:0,y:0,w:0,h:0},{viewScaleInfo:n}=t;let a=null;for(let t=0;t<e.length;t++){const r=e[t];if(null==(i=null==r?void 0:r.operations)?void 0:i.invisible)continue;const l=We(r,{viewScaleInfo:n});if(l.angle&&(l.angle>0||l.angle<0)){const e=xe(l);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];l.x=Math.min(...t),l.y=Math.min(...i),l.w=Math.abs(Math.max(...t)-Math.min(...t)),l.h=Math.abs(Math.max(...i)-Math.min(...i))}}if(a){const e=Math.min(l.x,o.x),t=Math.min(l.y,o.y),i=Math.max(l.x+l.w,o.x+o.w),n=Math.max(l.y+l.h,o.y+o.h);o.x=e,o.y=t,o.w=Math.abs(i-e),o.h=Math.abs(n-t)}else o.x=l.x,o.y=l.y,o.w=l.w,o.h=l.h;a=l}return o}function Go(e){return{minX:e.topLeft.x,minY:e.topLeft.y,maxX:e.bottomRight.x,maxY:e.bottomRight.y,midX:e.center.x,midY:e.center.y}}const Xo=(e,t)=>{if(0===e.length)throw null;if(1===e.length)return e[0];let i=0,o=e.length-1;for(;i<=o;){const n=Math.floor((i+o)/2);if(e[n]===t)return e[n];e[n]<t?i=n+1:o=n-1}return i>=e.length?e[o]:o<0?e[i]:Math.abs(e[o]-t)<=Math.abs(e[i]-t)?e[o]:e[i]},No=(e,t)=>Math.abs(e-t)<1e-5;function Fo(e,t){var i,o;const{data:n,groupQueue:a,calculator:r,viewScaleInfo:l,viewSizeInfo:s}=t;let h=n.elements||[];(null==a?void 0:a.length)>0&&(h=(null==(o=null==(i=a[a.length-1])?void 0:i.detail)?void 0:o.children)||[]);const c=[];h.forEach((t=>{if(t.uuid!==e){const e=r.calcViewRectInfoFromRange(t.uuid,{checkVisible:!0,viewScaleInfo:l,viewSizeInfo:s});e&&c.push(e)}}));const d=r.calcViewRectInfoFromRange(e,{viewScaleInfo:l,viewSizeInfo:s});if(!d)return null;const f={},u={},g={},v={},m=[],w=[];let y=[],p=[];const x=Go(d);f[x.minX]=[x.minY,x.midY,x.maxY],f[x.midX]=[x.minY,x.midY,x.maxY],f[x.maxX]=[x.minY,x.midY,x.maxY],u[x.minY]=[x.minX,x.midX,x.maxX],u[x.midY]=[x.minX,x.midX,x.maxX],u[x.maxY]=[x.minX,x.midX,x.maxX],c.forEach((e=>{const t=Go(e);g[t.minX]||(g[t.minX]=[]),g[t.midX]||(g[t.midX]=[]),g[t.maxX]||(g[t.maxX]=[]),v[t.minY]||(v[t.minY]=[]),v[t.midY]||(v[t.midY]=[]),v[t.maxY]||(v[t.maxY]=[]),g[t.minX]=[t.minY,t.midY,t.maxY],g[t.midX]=[t.minY,t.midY,t.maxY],g[t.maxX]=[t.minY,t.midY,t.maxY],y.push(t.minX),y.push(t.midX),y.push(t.maxX),v[t.minY]=[t.minX,t.midX,t.maxX],v[t.midY]=[t.minX,t.midX,t.maxX],v[t.maxY]=[t.minX,t.midX,t.maxX],p.push(t.minY),p.push(t.midY),p.push(t.maxY)})),y=y.sort(((e,t)=>e-t)),p=p.sort(((e,t)=>e-t));let S=null,b=null,I=null,A=null,M=null,R=null,T=null,z=null;if(y.length>0){I=Xo(y,x.minX),A=Xo(y,x.midX),M=Xo(y,x.maxX);const e=Math.abs(I-x.minX),t=Math.abs(A-x.midX),i=Math.abs(M-x.maxX),o=Math.min(e,t,i);o<=2/l.scale&&(No(o,e)?S=I-x.minX:No(o,t)?S=A-x.midX:No(o,i)&&(S=M-x.maxX))}if(p.length>0){R=Xo(p,x.minY),T=Xo(p,x.midY),z=Xo(p,x.maxY);const e=Math.abs(R-x.minY),t=Math.abs(T-x.midY),i=Math.abs(z-x.maxY),o=Math.min(e,t,i);o<=2/l.scale&&(No(o,e)?b=R-x.minY:No(o,t)?b=T-x.midY:No(o,i)&&(b=z-x.maxY))}const P={...x};if(null!==S&&(P.minX+=S,P.midX+=S,P.maxX+=S),null!==b&&(P.minY+=b,P.midY+=b,P.maxY+=b),N.x(S)&&null!==S&&null!==I&&null!==A&&null!==M){if(No(S,I-x.minX)){const e={x:I,yList:[]};e.yList.push(P.minY),e.yList.push(P.maxY),e.yList.push(...(null==v?void 0:v[I])||[]),m.push(e)}if(No(S,A-x.minX)){const e={x:A,yList:[]};e.yList.push(P.minY),e.yList.push(P.maxY),e.yList.push(...(null==v?void 0:v[A])||[]),m.push(e)}if(No(S,M-x.minX)){const e={x:M,yList:[]};e.yList.push(P.minY),e.yList.push(P.maxY),e.yList.push(...(null==v?void 0:v[M])||[]),m.push(e)}}if(N.y(b)&&null!==b&&null!==R&&null!==T&&null!==z){if(No(b,R-x.minY)){const e={y:R,xList:[]};e.xList.push(P.minX),e.xList.push(P.maxX),e.xList.push(...(null==g?void 0:g[R])||[]),w.push(e)}if(No(b,T-x.midY)){const e={y:T,xList:[]};e.xList.push(P.minX),e.xList.push(P.maxX),e.xList.push(...(null==g?void 0:g[R])||[]),w.push(e)}if(No(b,z-x.maxY)){const e={y:z,xList:[]};e.xList.push(P.minX),e.xList.push(P.maxX),e.xList.push(...(null==g?void 0:g[z])||[]),w.push(e)}}const C=[];(null==m?void 0:m.length)>0&&m.forEach(((e,t)=>{C.push([]),e.yList.forEach((i=>{C[t].push({x:e.x,y:i})}))}));const E=[];return(null==w?void 0:w.length)>0&&w.forEach(((e,t)=>{E.push([]),e.xList.forEach((i=>{E[t].push({x:i,y:e.y})}))})),{offsetX:S,offsetY:b,yLines:C,xLines:E}}const Ho="LAYOUT_SELECT",Zo=Symbol(`${Ho}_layoutActionType`),Qo=Symbol(`${Ho}_layoutControlType`),Uo=Symbol(`${Ho}_layoutController`),Jo=Symbol(`${Ho}_layoutIsHover`),$o=Symbol(`${Ho}_layoutIsSelected`),Ko={activeColor:"#b331c9"};function qo(e,t,i){const{activeColor:o}=i;e.setLineDash([]),e.fillStyle="#FFFFFF",e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.fill(),e.strokeStyle=o,e.lineWidth=2,e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function _o(e,t){const{start:i,end:o,style:n}=t,{activeColor:a}=n,r=a;e.setLineDash([]),e.strokeStyle=r,e.lineWidth=2,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,o.y),e.closePath(),e.stroke()}const en="SCROLL",tn=Symbol(`${en}_xThumbRect`),on=Symbol(`${en}_yThumbRect`),nn=Symbol(`${en}_hoverXThumbRect`),an=Symbol(`${en}_hoverYThumbRect`),rn=Symbol(`${en}_prevPoint`),ln=Symbol(`${en}_activePoint`),sn=Symbol(`${en}_activeThumbType`),hn={thumbBackground:"#0000003A",thumbBorderColor:"#0000008A",hoverThumbBackground:"#0000005F",hoverThumbBorderColor:"#000000EE",activeThumbBackground:"#0000005E",activeThumbBorderColor:"#000000F0"},cn=16,dn=2.5*cn;function fn(e,t,i){const o=e,{x:n,y:a,w:r,h:l}=i;return o.beginPath(),o.rect(n,a,r,l),o.closePath(),!!o.isPointInPath(t.x,t.y)}function un(e,t){let{x:i,y:o,h:n,w:a,background:r,borderColor:l}=t;e.save(),e.shadowColor="#FFFFFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=1;{const{axis:s}=t;"X"===s?(o=o+n/4+0,n/=2):"Y"===s&&(i=i+a/4+0,a/=2);let h=t.r;h=Math.min(h,a/2,n/2),(a<2*h||n<2*h)&&(h=0),e.globalAlpha=1,e.beginPath(),e.moveTo(i+h,o),e.arcTo(i+a,o,i+a,o+n,h),e.arcTo(i+a,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+a,o,h),e.closePath(),e.fillStyle=r,e.fill(),e.beginPath(),e.lineWidth=1,e.strokeStyle=l,e.setLineDash([]),e.moveTo(i+h,o),e.arcTo(i+a,o,i+a,o+n,h),e.arcTo(i+a,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+a,o,h),e.closePath(),e.stroke()}e.restore()}function gn(e,t){const i=e,{viewScaleInfo:o,viewSizeInfo:n,scrollInfo:a,style:r}=t,{activeThumbType:l,prevPoint:s,activePoint:h,hoverXThumb:c,hoverYThumb:d}=a,f=function(e){const{viewScaleInfo:t,viewSizeInfo:i,hoverXThumb:o,hoverYThumb:n,style:a}=e,{width:r,height:l}=i,{offsetTop:s,offsetBottom:h,offsetLeft:c,offsetRight:d}=t,f=dn,u=cn,{thumbBackground:g,thumbBorderColor:v,hoverThumbBackground:m,hoverThumbBorderColor:w}=a;let y=0,p=0;y=Math.max(f,r-2*u-(Math.abs(c)+Math.abs(d))),y>=r&&(y=r),p=Math.max(f,l-2*u-(Math.abs(s)+Math.abs(h))),p>=l&&(p=l);const x=u;let S=x;c>0?S=x:d>0?S=r-y-u:c<=0&&y>0&&(0!==c||0!==d)&&(S=x+(r-y)*Math.abs(c)/(Math.abs(c)+Math.abs(d)),S=Math.min(Math.max(0,S-x),r-y));const b=u;let I=b;return s>0?I=b:h>0?I=l-p-u:s<=0&&p>0&&(0!==s||0!==h)&&(I=b+(l-p)*Math.abs(s)/(Math.abs(s)+Math.abs(h)),I=Math.min(Math.max(0,I-b),l-p)),{lineSize:u,xSize:y,ySize:p,translateY:I,translateX:S,xThumbBackground:o?m:g,yThumbBackground:n?m:g,xThumbBorderColor:o?w:v,yThumbBorderColor:n?w:v,xThumbRect:{x:S,y:l-u,w:y,h:u},yThumbRect:{x:r-u,y:I,w:u,h:p}}}({viewScaleInfo:o,viewSizeInfo:n,hoverXThumb:c,hoverYThumb:d,style:r});let u={...f.xThumbRect},g={...f.yThumbRect};return l&&s&&h&&("X"===l&&a.xThumbRect?(u={...a.xThumbRect},u.x=u.x+(h.x-s.x)):"Y"===l&&a.yThumbRect&&(g={...a.yThumbRect},g.y=g.y+(h.y-s.y))),un(i,{axis:"X",...u,r:f.lineSize/2,background:f.xThumbBackground,borderColor:f.xThumbBorderColor}),un(i,{axis:"Y",...g,r:f.lineSize/2,background:f.yThumbBackground,borderColor:f.yThumbBorderColor}),{xThumbRect:u,yThumbRect:g}}function vn(e,t){const{snapshot:i,style:o}=t,n=ce(i),a=he(i),r=function(e){const{sharedStore:t}=e;return{activePoint:t[ln]||null,prevPoint:t[rn]||null,activeThumbType:t[sn]||null,xThumbRect:t[tn]||null,yThumbRect:t[on]||null,hoverXThumb:t[nn],hoverYThumb:t[an]}}(i),{xThumbRect:l,yThumbRect:s}=gn(e,{viewSizeInfo:n,viewScaleInfo:a,scrollInfo:r,style:o});return{xThumbRect:l,yThumbRect:s}}const mn=16,wn="monospace",yn={background:"#FFFFFFA8",borderColor:"#00000080",scaleColor:"#000000",textColor:"#00000080",gridColor:"#AAAAAA20",gridPrimaryColor:"#AAAAAA40",selectedAreaColor:"#196097"},pn=[1,2,5,10,20,50,100,200,500];function xn(e){const{scale:t,viewLength:i,viewOffset:o}=e,n=[];let a=10;a=He(a/t,{decimalPlaces:0}),a=function(e){e=Math.max(pn[0],Math.min(e,pn[pn.length-1]));for(let t=0;t<pn.length-1;t++){const i=pn[t],o=pn[t+1];if(!(e>o))return e===i||e===o?e:e<=(i+o)/2?i:o}return e}(a);const r=10*a,l=5*a;let s=0;const h=a*t,c=0-o,d=c%h,f=(c-d+h)/t,u=h-d+0;for(;u+s*h<i;){const e=He(f+s*a,{decimalPlaces:0}),t={num:e,position:He(u+s*h,{decimalPlaces:0}),showNum:e%r==0,isKeyNum:e%r==0,isSubKeyNum:e%l==0};n.push(t),s++}return{list:n,rulerUnit:a}}const Sn={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"},bn=Symbol("DRAG_prevPoint"),In="monospace";const An={textBackground:"#1973bac6",textColor:"#ffffff"},Mn=10;return m=new WeakMap,w=new WeakMap,y=new WeakMap,p=new WeakSet,x=function(){b(this,y).style.position="relative"},e.Core=class{constructor(e,t){I(this,p),I(this,m,void 0),I(this,w,void 0),I(this,y,void 0);const{devicePixelRatio:i=1,width:o,height:n,createCustomContext2D:a}=t;A(this,y,e);const r=document.createElement("canvas");A(this,w,r),M(this,p,x).call(this),e.appendChild(r);const l=function(e,t){const{width:i,height:o,devicePixelRatio:n,offscreen:a,createCustomContext2D:r}=t,l={width:i,height:o,devicePixelRatio:n},s=e.getContext("2d");if(r){const e=r(l),t=r(l),i=r(l),o=J(Object.assign({ctx:s},l)),n=()=>{const{width:n,height:a}=e.$getSize();o.clearRect(0,0,n,a),o.drawImage(i.canvas,0,0,n,a),o.drawImage(e.canvas,0,0,n,a),o.drawImage(t.canvas,0,0,n,a),i.clearRect(0,0,n,a),e.clearRect(0,0,n,a),t.clearRect(0,0,n,a)};return{underlayContext:i,viewContext:e,overlayContext:t,boardContext:o,drawView:n}}if(!0===a){const e=$(l),t=$(l),i=$(l),o=J(Object.assign({ctx:s},l)),n=()=>{const{width:n,height:a}=e.$getSize();o.clearRect(0,0,n,a),o.drawImage(i.canvas,0,0,n,a),o.drawImage(e.canvas,0,0,n,a),o.drawImage(t.canvas,0,0,n,a),i.clearRect(0,0,n,a),e.clearRect(0,0,n,a),t.clearRect(0,0,n,a)};return{underlayContext:i,viewContext:e,overlayContext:t,boardContext:o,drawView:n}}{const e=J(l),t=J(l),n=J(l),a=J(Object.assign({ctx:s},l)),r=()=>{a.clearRect(0,0,i,o),a.drawImage(n.canvas,0,0,i,o),a.drawImage(e.canvas,0,0,i,o),a.drawImage(t.canvas,0,0,i,o),n.clearRect(0,0,i,o),e.clearRect(0,0,i,o),t.clearRect(0,0,i,o)};return{underlayContext:n,viewContext:e,overlayContext:t,boardContext:a,drawView:r}}}(r,{width:o,height:n,devicePixelRatio:i,offscreen:!0,createCustomContext2D:a}),s=new to({boardContent:l,container:e}),h=s.getSharer();h.setActiveViewSizeInfo({width:o,height:n,devicePixelRatio:i,contextWidth:o,contextHeight:n}),A(this,m,s),this.resize(h.getActiveViewSizeInfo());const c=s.getEventHub();new ro(e,{eventHub:c})}isDestroyed(){return b(this,m).isDestroyed()}destroy(){b(this,m).destroy(),b(this,w).remove()}use(e,t){b(this,m).use(e,t)}disuse(e){b(this,m).disuse(e)}setData(e,t){Ie((null==e?void 0:e.elements)||[]),b(this,m).setData(e,t)}getData(){return b(this,m).getData()}scale(e){b(this,m).scale(e);b(this,m).getViewer().drawFrame()}resize(e){const t=b(this,m),i=t.getSharer().getActiveViewSizeInfo();t.resize({...i,...e})}clear(){b(this,m).clear()}on(e,t){b(this,m).getEventHub().on(e,t)}off(e,t){b(this,m).getEventHub().off(e,t)}trigger(e,t){b(this,m).getEventHub().trigger(e,t)}getViewInfo(){const e=b(this,m).getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){b(this,m).getViewer().drawFrame()}setViewScale(e){b(this,m).updateViewScaleInfo(e)}getLoadItemMap(){return b(this,m).getRenderer().getLoadItemMap()}onBoardWatcherEvents(){b(this,m).onWatcherEvents()}offBoardWatcherEvents(){b(this,m).offWatcherEvents()}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:o}=e;let n=!1;return{name:"@middleware/dragger",hover(){!0!==n&&t.trigger(ao.CURSOR,{type:"drag-default"})},pointStart(e){const{point:o}=e;i.setSharedStorage(bn,o),n=!0,t.trigger(ao.CURSOR,{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(bn);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(bn,t)},pointEnd(){n=!1,i.setSharedStorage(bn,null),t.trigger(ao.CURSOR,{type:"drag-default"})}}},e.MiddlewareInfo=(e,t)=>{const{boardContent:i,calculator:o}=e,{overlayContext:n}=i,a={...An,...t},{textBackground:r,textColor:l}=a,s={textBackground:r,textColor:l};return{name:"@middleware/info",beforeDrawFrame({snapshot:e}){const{sharedStore:t}=e,i=t[vo],a=t[so],r=t[po]||[];if(1===i.length){const t=i[0];if(t&&["select","drag","resize"].includes(a)){const i=he(e),a=ce(e),{x:l,y:h,w:c,h:d,angle:f}=t,u=[...r,{uuid:z(),x:l,y:h,w:c,h:d,angle:f,type:"group",detail:{children:[]}}],g={viewScaleInfo:i,viewSizeInfo:a},v=o.calcViewRectInfoFromOrigin(t.uuid,g);let m=0;u.forEach((e=>{m+=e.angle||0}));const w=de(be(0-m));if(v){const e=null==v?void 0:v.center,i={topLeft:we(e,v.topLeft,w),topRight:we(e,v.topRight,w),bottomRight:we(e,v.bottomRight,w),bottomLeft:we(e,v.bottomLeft,w),center:we(e,v.center,w),top:we(e,v.top,w),right:we(e,v.right,w),bottom:we(e,v.bottom,w),left:we(e,v.left,w)},o=He(t.x,{decimalPlaces:2}),a=He(t.y,{decimalPlaces:2}),r=He(t.w,{decimalPlaces:2}),l=He(t.h,{decimalPlaces:2}),h=`${He(o,{decimalPlaces:0})},${He(a,{decimalPlaces:0})}`,c=`${He(r,{decimalPlaces:0})}x${He(l,{decimalPlaces:0})}`,d=`${He(t.angle||0,{decimalPlaces:0})}°`;!function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textColor:h,textBackground:c}=r;fe(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:In});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x-o/2-t,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x-o/2,y:i.y};e.setLineDash([]),e.fillStyle=c,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=h,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(n,{point:{x:i.bottom.x,y:i.bottom.y+Mn},rotateCenter:i.center,angle:m,text:c,fontSize:Mn,lineHeight:16,style:s}),function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textBackground:h,textColor:c}=r;fe(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:In});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(n,{point:{x:i.topLeft.x,y:i.topLeft.y-20},rotateCenter:i.center,angle:m,text:h,fontSize:Mn,lineHeight:16,style:s}),function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textBackground:h,textColor:c}=r;fe(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:In});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(n,{point:{x:i.top.x+Mn,y:i.top.y-20},rotateCenter:i.center,angle:m,text:d,fontSize:Mn,lineHeight:16,style:s})}}}}}},e.MiddlewareLayoutSelector=(e,t)=>{const{sharer:i,boardContent:o,calculator:n,viewer:a,eventHub:r}=e,{overlayContext:l}=o,s={...Ko,...t},{activeColor:h}=s,c={activeColor:h};let d=null,f=null,u=null,g=null;const v=()=>{d=null,i.setSharedStorage(Zo,null),i.setSharedStorage(Qo,null),i.setSharedStorage(Uo,null),i.setSharedStorage(Jo,null),i.setSharedStorage($o,null),f=null,u=null,g=null},m=()=>{const e=i.getSharedStorage(so);return!(!e||"area"===e)&&(v(),!0)},w=()=>{const e=i.getActiveStorage("data");if(null==e?void 0:e.layout){const{x:t,y:i,w:o,h:n}=e.layout;return{x:t,y:i,w:o,h:n}}return null},y=e=>{const t=w();if(t){const{x:o,y:n,w:a,h:r}=t;return function(e,t,i){return De(e,Ce(t))}(e,We({x:o-5,y:n-5,w:a+10,h:r+10},{viewScaleInfo:i.getActiveViewScaleInfo()}))}return!1},p=()=>{const e=i.getActiveViewScaleInfo(),t=w();if(t){const o=Ne(t,{viewScaleInfo:e,controllerSize:10});i.setSharedStorage(Uo,o)}else i.setSharedStorage(Uo,null)},x=e=>{const t=i.getActiveStorage("data"),o=i.getSharedStorage(Uo);if(o&&(null==t?void 0:t.layout)&&(null==e?void 0:e.point)){let t=null;if(o){const{topLeft:n,top:a,topRight:l,right:s,bottomRight:h,bottom:c,bottomLeft:d,left:f}=o,u=[n,a,l,s,h,c,d,f];for(let i=0;i<u.length;i++){const o=u[i];if(De(e.point,o.vertexes)){t=`${o.type}`;break}}if(t)return i.setSharedStorage(Qo,t),r.trigger(ao.CLEAR_SELECT),t}}return null},S=e=>{!0!==g&&r.trigger(ao.CURSOR,{type:e?`resize-${e}`:e,groupQueue:[],element:w()})};return{name:"@middleware/layout-selector",use:()=>{v(),p()},hover:e=>{if(!0!==g&&!m()&&(!i.getSharedStorage(uo)||(v(),0)))if(y(e.point)?i.setSharedStorage(Jo,!0):(i.setSharedStorage(Jo,!1),!0===f&&(a.drawFrame(),f=!1)),!0!==i.getSharedStorage($o))i.getSharedStorage(Jo)&&!f&&a.drawFrame(),f=i.getSharedStorage(Jo);else{const t=i.getSharedStorage(Zo),o=i.getActiveStorage("data");if(null==o?void 0:o.layout)if("resize"!==t){p();const t=x(e);t?S(t):(S(),i.setSharedStorage(Zo,null))}else{const t=x(e);S(t)}}},pointStart:e=>{if(m())return;y(e.point)?i.setSharedStorage($o,!0):(!0===u&&(v(),a.drawFrame()),i.setSharedStorage($o,!1)),p();const t=x(e);d=e.point,t&&i.setSharedStorage(Zo,"resize"),!0!==i.getSharedStorage($o)||u||a.drawFrame(),u=i.getSharedStorage($o)},pointMove:e=>{if(!i.getSharedStorage($o)&&m())return;const t=i.getSharedStorage(Zo),o=i.getSharedStorage(Qo),r=i.getActiveStorage("data");if("resize"===t&&o&&(null==r?void 0:r.layout)){if(d){g=!0;const t=i.getActiveStorage("scale"),l=e.point.x-d.x,s=e.point.y-d.y,h=l/t,c=s/t,{x:f,y:u,w:v,h:m,operations:w={}}=r.layout,{position:y="absolute"}=w;"top"===o?"relative"===y?(r.layout.h=n.toGridNum(m-c),a.scroll({moveY:s})):(r.layout.y=n.toGridNum(u+c),r.layout.h=n.toGridNum(m-c)):"right"===o?r.layout.w=n.toGridNum(v+h):"bottom"===o?r.layout.h=n.toGridNum(m+c):"left"===o?"relative"===y?(r.layout.w=n.toGridNum(v-h),a.scroll({moveX:l})):(r.layout.x=n.toGridNum(f+h),r.layout.w=n.toGridNum(v-h)):"top-left"===o?"relative"===y?(r.layout.w=n.toGridNum(v-h),r.layout.h=n.toGridNum(m-c),a.scroll({moveX:l,moveY:s})):(r.layout.x=n.toGridNum(f+h),r.layout.y=n.toGridNum(u+c),r.layout.w=n.toGridNum(v-h),r.layout.h=n.toGridNum(m-c)):"top-right"===o?"relative"===y?(a.scroll({moveY:s}),r.layout.w=n.toGridNum(v+h),r.layout.h=n.toGridNum(m-c)):(r.layout.y=n.toGridNum(u+c),r.layout.w=n.toGridNum(v+h),r.layout.h=n.toGridNum(m-c)):"bottom-right"===o?(r.layout.w=n.toGridNum(v+h),r.layout.h=n.toGridNum(m+c)):"bottom-left"===o&&("relative"===y?(a.scroll({moveX:l}),r.layout.w=n.toGridNum(v-h),r.layout.h=n.toGridNum(m+c)):(r.layout.x=n.toGridNum(f+h),r.layout.w=n.toGridNum(v-h),r.layout.h=n.toGridNum(m+c)))}return d=e.point,p(),a.drawFrame(),!1}return!["resize"].includes(t)&&void 0},pointEnd:()=>{g=!1;const e=i.getSharedStorage(Zo),t=i.getSharedStorage(Qo),o=i.getActiveStorage("data");o&&"resize"===e&&t&&r.trigger(ao.CHANGE,{type:"changeLayout",data:o})},beforeDrawFrame:({snapshot:e})=>{var t;if(m())return;const{sharedStore:i,activeStore:o}=e,n=i[Zo],a=i[Jo],r=i[$o];if(null==(t=o.data)?void 0:t.layout){const{x:t,y:i,w:s,h:h}=o.data.layout,d=he(e),f={x:t,y:i,w:s,h:h},u=Ne(f,{viewScaleInfo:d,controllerSize:10});if(!0===a){const e=We(f,{viewScaleInfo:d});!function(e,t){const{layoutSize:i,style:o}=t,{activeColor:n}=o,{x:a,y:r,w:l,h:s}=i;e.setLineDash([]),e.strokeStyle=n,e.lineWidth=1,e.beginPath(),e.moveTo(a,r),e.lineTo(a+l,r),e.lineTo(a+l,r+s),e.lineTo(a,r+s),e.lineTo(a,r),e.closePath(),e.stroke()}(l,{layoutSize:e,style:c})}(n&&["resize"].includes(n)||!0===r)&&function(e,t){const{controller:i,style:o}=t,{topLeft:n,topRight:a,bottomLeft:r,bottomRight:l,topMiddle:s,rightMiddle:h,bottomMiddle:c,leftMiddle:d}=i;_o(e,{start:n.center,end:a.center,centerVertexes:s.vertexes,style:o}),_o(e,{start:a.center,end:l.center,centerVertexes:h.vertexes,style:o}),_o(e,{start:l.center,end:r.center,centerVertexes:c.vertexes,style:o}),_o(e,{start:r.center,end:n.center,centerVertexes:d.vertexes,style:o}),qo(e,n.vertexes,o),qo(e,a.vertexes,o),qo(e,l.vertexes,o),qo(e,r.vertexes,o)}(l,{controller:u,style:c})}},scrollX:()=>{v()},scrollY:()=>{v()},wheelScale:()=>{v()}}},e.MiddlewarePointer=e=>{const{boardContent:t,eventHub:i,sharer:o}=e,n=t.boardContext.canvas,a=e.container||document.body,r=`idraw-middleware-pointer-${Math.random().toString(26).substring(2)}`,l=document.createElement("div");return l.setAttribute("id",r),l.style.position="fixed",l.style.top="0",l.style.bottom="unset",l.style.left="0",l.style.right="unset",a.appendChild(l),{name:"@middleware/pointer",use(){},disuse(){},pointStart(e){},pointEnd(){},contextMenu(e){const{point:t}=e,{left:a,top:r}=(()=>{const e=n.getBoundingClientRect(),{left:t,top:i,width:o,height:a}=e;return{left:t,top:i,width:o,height:a}})();l.style.left=`${a+t.x}px`,l.style.top=`${r+t.y}px`;const s=o.getSharedStorage(vo);i.trigger(ao.CONTEXT_MENU,{pointerContainer:l,selectedElements:s||[]})}}},e.MiddlewareRuler=(e,t)=>{const{boardContent:i,viewer:o,eventHub:n,calculator:a}=e,{overlayContext:r,underlayContext:l}=i,s={...yn,...t},{background:h,borderColor:c,scaleColor:d,textColor:f,gridColor:u,gridPrimaryColor:g,selectedAreaColor:v}=s,m={background:h,borderColor:c,scaleColor:d,textColor:f,gridColor:u,gridPrimaryColor:g,selectedAreaColor:v};let w=!0,y=!0;const p=e=>{"boolean"==typeof(null==e?void 0:e.show)&&(w=e.show),"boolean"==typeof(null==e?void 0:e.showGrid)&&(y=e.showGrid),"boolean"!=typeof(null==e?void 0:e.show)&&"boolean"!=typeof(null==e?void 0:e.showGrid)||o.drawFrame()};return{name:"@middleware/ruler",use(){n.on(ao.RULER,p)},disuse(){n.off(ao.RULER,p)},beforeDrawFrame:({snapshot:e})=>{if(!0===w){const t=he(e),i=ce(e);!function(e,t){const{snapshot:i,calculator:o,style:n}=t,{sharedStore:a}=i,{selectedAreaColor:r}=n,l=a[vo],s=a[so];if(["select","drag","drag-list","drag-list-end"].includes(s)&&l.length>0){const t=he(i),n=ce(i),a=[],s=[],h=[],c=[],d=[];if(l.forEach((e=>{const i=o.calcViewRectInfoFromRange(e.uuid,{viewScaleInfo:t,viewSizeInfo:n});i&&(a.push(i),s.push(i.left.x),h.push(i.right.x),c.push(i.top.y),d.push(i.bottom.y))})),!(a.length>0))return;const f=Math.min(...s),u=Math.max(...h),g=Math.min(...c),v=Math.max(...d);e.globalAlpha=1,e.beginPath(),e.moveTo(f,0),e.lineTo(u,0),e.lineTo(u,mn),e.lineTo(f,mn),e.fillStyle=r,e.closePath(),e.fill(),e.beginPath(),e.moveTo(0,g),e.lineTo(mn,g),e.lineTo(mn,v),e.lineTo(0,v),e.fillStyle=r,e.closePath(),e.fill()}}(r,{snapshot:e,calculator:a,style:m}),function(e,t){const{viewSizeInfo:i,style:o}=t,{width:n,height:a}=i,{background:r,borderColor:l}=o;e.beginPath(),e.moveTo(0,0),e.lineTo(n+1,0),e.lineTo(n+1,mn),e.lineTo(mn,mn),e.lineTo(mn,a+1),e.lineTo(0,a+1),e.lineTo(0,0),e.closePath(),e.fillStyle=r,e.fill(),e.lineWidth=1,e.setLineDash([]),e.strokeStyle=l,e.stroke()}(r,{viewScaleInfo:t,viewSizeInfo:i,style:m});const{list:o,rulerUnit:n}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:n}=t,{width:a}=i;return xn({axis:"X",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:a}=o;for(let t=0;t<i.length;t++){const o=i[t];o.position<mn||(e.beginPath(),e.moveTo(o.position,16),e.lineTo(o.position,o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8),e.closePath(),e.lineWidth=1,e.setLineDash([]),e.fillStyle=n,e.stroke(),o.isKeyNum&&(e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:wn}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(r,{scaleList:o,style:m});const{list:s}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n}=t,{height:a}=i;return xn({axis:"Y",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});if(function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:a}=o,r=3.2;for(let t=0;t<i.length;t++){const o=i[t];if(!(o.position<mn)&&(e.beginPath(),e.moveTo(16,o.position),e.lineTo(o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8,o.position),e.closePath(),e.fillStyle=n,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===o.showNum)){const t=r,i=o.position+r,n=`${o.num}`;fe(e,-90,{x:t,y:i},(()=>{e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:wn}),e.fillText(n,13.2,o.position+r)}))}}}(r,{scaleList:s,style:m}),!0===y){!function(e,t){const{xList:i,yList:o,viewSizeInfo:n,style:a}=t,{width:r,height:l}=n,{gridColor:s,gridPrimaryColor:h}=a;for(let t=0;t<i.length;t++){const o=i[t];e.beginPath(),e.moveTo(o.position,0),e.lineTo(o.position,l),!0===o.isKeyNum||!0===o.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=s,e.closePath(),e.lineWidth=1,e.setLineDash([]),e.stroke()}for(let t=0;t<o.length;t++){const i=o[t];e.beginPath(),e.moveTo(0,i.position),e.lineTo(r,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=s,e.lineWidth=1,e.closePath(),e.stroke()}}(1===n?r:l,{xList:o,yList:s,viewScaleInfo:t,viewSizeInfo:i,style:m})}}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:o}=e;return{name:"@middleware/scaler",wheelScale(e){const{deltaY:n,point:a}=e,{scale:r}=i.getActiveViewScaleInfo();let l=r;if(n<0?l=1.1*r:n>0&&(l=.9*r),l<.05||l>50)return;const{moveX:s,moveY:h}=t.scale({scale:l,point:a});t.scroll({moveX:s,moveY:h}),t.drawFrame();const c=He(r);o.trigger(ao.SCALE,{scale:c})}}},e.MiddlewareScroller=(e,t)=>{const{viewer:i,boardContent:o,sharer:n,eventHub:a}=e,{overlayContext:r}=o;n.setSharedStorage(tn,null),n.setSharedStorage(on,null);let l=!1;const s={...hn,...t},{thumbBackground:h,thumbBorderColor:c,hoverThumbBackground:d,hoverThumbBorderColor:f,activeThumbBackground:u,activeThumbBorderColor:g}=s,v={thumbBackground:h,thumbBorderColor:c,hoverThumbBackground:d,hoverThumbBorderColor:f,activeThumbBackground:u,activeThumbBorderColor:g},m=()=>{n.setSharedStorage(rn,null),n.setSharedStorage(ln,null),n.setSharedStorage(sn,null),n.setSharedStorage(nn,null),n.setSharedStorage(an,null),l=!1};m();const w=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:a}=i;return n&&fn(e,t,n)?o="X":a&&fn(e,t,a)&&(o="Y"),o}(r,e,{xThumbRect:n.getSharedStorage(tn),yThumbRect:n.getSharedStorage(on)});return{name:"@middleware/scroller",wheel:e=>{i.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),i.drawFrame()},hover:e=>{if(!0===l)return!1;const{point:t}=e,i=w(t);if("X"===i||"Y"===i)return"X"===i?(n.setSharedStorage(nn,!0),n.setSharedStorage(an,!1)):(n.setSharedStorage(nn,!1),n.setSharedStorage(an,!0)),a.trigger(ao.CURSOR,{type:"default"}),!1;n.setSharedStorage(nn,!1),n.setSharedStorage(an,!1)},pointStart:e=>{const{point:t}=e,i=w(t);if("X"===i||"Y"===i)return l=!0,n.setSharedStorage(sn,i),n.setSharedStorage(rn,t),!1},pointMove:e=>{const{point:t}=e,o=n.getSharedStorage(sn);if("X"===o||"Y"===o)return n.setSharedStorage(ln,t),"X"===o?(e=>{const t=n.getSharedStorage(rn);if(t){const{offsetLeft:o,offsetRight:a}=n.getActiveViewScaleInfo(),{width:r}=n.getActiveViewSizeInfo(),l=-(e.x-t.x)*(r+Math.abs(o)+Math.abs(a))/r;i.scroll({moveX:l}),i.drawFrame()}})(t):"Y"===o&&(e=>{const t=n.getSharedStorage(rn);if(t){const{offsetTop:o,offsetBottom:a}=n.getActiveViewScaleInfo(),{height:r}=n.getActiveViewSizeInfo(),l=-(e.y-t.y)*(r+Math.abs(o)+Math.abs(a))/r;i.scroll({moveY:l}),i.drawFrame()}})(t),n.setSharedStorage(rn,t),!1},pointEnd:()=>{l=!1;const e=n.getSharedStorage(sn);if(m(),"X"===e||"Y"===e)return i.scroll({moveX:0,moveY:0}),i.drawFrame(),!1},beforeDrawFrame({snapshot:e}){const{xThumbRect:t,yThumbRect:i}=vn(r,{snapshot:e,style:v});n.setSharedStorage(tn,t),n.setSharedStorage(on,i)}}},e.MiddlewareSelector=(e,t)=>{const i={...Ao,...t},{activeColor:o,activeAreaColor:n,lockedColor:a,referenceColor:r}=i,l={activeColor:o,activeAreaColor:n,lockedColor:a,referenceColor:r},{viewer:s,sharer:h,boardContent:c,calculator:d,eventHub:f}=e,{overlayContext:u}=c;let g=null,v=null,m=null,w=null,y=null;h.setSharedStorage(so,null),h.setSharedStorage(Io,!0);const p=()=>h.getSharedStorage(vo),x=e=>{let t=h.getSharedStorage(po);Array.isArray(t)||(t=[]),t.length>0?!function(e,t){var i;if("group"===(null==t?void 0:t.type)&&Array.isArray(null==(i=null==t?void 0:t.detail)?void 0:i.children))for(let i=0;i<t.detail.children.length;i++){const o=t.detail.children[i];if(e.uuid===o.uuid)return!0}return!1}(e,t[t.length-1])?t=[]:t.push(e):0===t.length&&t.push(e);const i=Ee(t);return h.setSharedStorage(po,t),h.setSharedStorage(xo,i),t.length>0},S=e=>{h.setSharedStorage(uo,e);let t=null;e&&(t=ke(e,{groupQueue:h.getSharedStorage(po)})),h.setSharedStorage(go,t)},b=(e,t)=>{var i;if(h.setSharedStorage(vo,e),1===e.length){const t=Xe(e[0],{groupQueue:h.getSharedStorage(po),controllerSize:10,viewScaleInfo:h.getActiveViewScaleInfo()});h.setSharedStorage(wo,t),h.setSharedStorage(yo,ze(e[0].uuid,(null==(i=h.getActiveStorage("data"))?void 0:i.elements)||[]))}else h.setSharedStorage(wo,null),h.setSharedStorage(yo,[]);if(!0===(null==t?void 0:t.triggerEvent)){const t=e.map((e=>e.uuid)),i=h.getActiveStorage("data"),o=function(e,t){const i=[],o={};let n=!1;const a=t=>{var r;for(let l=0;l<t.length&&!0!==n;l++){i.push(l);const s=t[l];if(e.includes(s.uuid)){if(o[s.uuid]=[...i],Object.keys(o).length===e.length){n=!0;break}}else"group"===s.type&&a((null===(r=null==s?void 0:s.detail)||void 0===r?void 0:r.children)||[]);if(n)break;i.pop()}};return a(t),o}(t,(null==i?void 0:i.elements)||[]);f.trigger(ao.SELECT,{uuids:t,positions:e.map((e=>[...o[e.uuid]]))})}},I=()=>({ctx:u,calculator:d,data:h.getActiveStorage("data"),selectedElements:p(),viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),groupQueue:h.getSharedStorage(po),areaSize:null,selectedElementController:h.getSharedStorage(wo),selectedElementPosition:h.getSharedStorage(yo)}),A=()=>{h.setSharedStorage(so,null),h.setSharedStorage(ho,null),h.setSharedStorage(co,null),h.setSharedStorage(fo,null),h.setSharedStorage(po,[]),h.setSharedStorage(xo,[]),h.setSharedStorage(uo,null),h.setSharedStorage(go,null),h.setSharedStorage(vo,[]),h.setSharedStorage(mo,null),h.setSharedStorage(wo,null),h.setSharedStorage(yo,[]),h.setSharedStorage(So,null)};A();const M=({uuids:e=[],positions:t})=>{let i=[];const o=h.getSharedStorage(so),n=h.getActiveStorage("data");i=t&&Array.isArray(t)?function(e,t){const i=[];return e.forEach((e=>{const o=Te(e,t);o&&i.push(o)})),i}(t,(null==n?void 0:n.elements)||[]):function(e,t){const i=[];return function t(o){var n;for(let a=0;a<o.length;a++){const r=o[a];e.includes(r.uuid)?i.push(r):"group"===r.type&&t((null===(n=null==r?void 0:r.detail)||void 0===n?void 0:n.children)||[])}}(t),i}(e,(null==n?void 0:n.elements)||[]);let a=!1;if(o||1!==i.length?"select"===o&&1===i.length&&(a=!0):(h.setSharedStorage(so,"select"),a=!0),a){const e=function(e,t){const i=[];return function e(t,o){var n;let a=null;for(let r=0;r<o.length;r++){const l=o[r];if(l.uuid===t){a=l;break}if(!a&&"group"===l.type){i.push(l);const o=e(t,(null===(n=null==l?void 0:l.detail)||void 0===n?void 0:n.children)||[]);if((null==o?void 0:o.uuid)===t){a=o;break}i.pop()}}return a}(e,t),i}(i[0].uuid,(null==n?void 0:n.elements)||[]);h.setSharedStorage(po,e),b(i),s.drawFrame()}},R=()=>{A(),s.drawFrame()},T=e=>{h.setSharedStorage(Io,!!e.enable)},z=e=>{h.setSharedStorage(bo,!!e.enable)};return{name:"@middleware/selector",use(){f.on(ao.SELECT,M),f.on(ao.CLEAR_SELECT,R),f.on(ao.SELECT_IN_GROUP,z),f.on(ao.SNAP_TO_GRID,T)},disuse(){f.off(ao.SELECT,M),f.off(ao.CLEAR_SELECT,R),f.off(ao.SELECT_IN_GROUP,z),f.off(ao.SNAP_TO_GRID,T)},hover:e=>{var t,i,o,n,a;const r=h.getSharedStorage($o),l=h.getSharedStorage(ho),c=h.getSharedStorage(so),g=h.getSharedStorage(po),v=e=>{if(!0===r)return;const t=e.type;null===w&&f.trigger(ao.CURSOR,{type:t,groupQueue:e.groupQueue,element:e.elements[0]})};if((null==g?void 0:g.length)>0){if(!Do(e.point,{ctx:u,viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),groupQueue:h.getSharedStorage(po)}))return S(null),void s.drawFrame();const i=Yo(e.point,I());return v(i),l||["area","drag","drag-list"].includes(c)?(S(null),void s.drawFrame()):1===(null==(t=null==i?void 0:i.elements)?void 0:t.length)?(S(i.elements[0]),void s.drawFrame()):(S(null),void s.drawFrame())}if(l||["area","drag","drag-list"].includes(c))return void S(null);if("drag"===c)return void S(null);const m=p(),y=h.getActiveViewScaleInfo(),x=h.getActiveViewSizeInfo(),b=Yo(e.point,{...I(),areaSize:Bo(m,{viewScaleInfo:y,viewSizeInfo:x,calculator:d})});if(v(b),null!==b.type){if(!("over-element"===b.type&&"select"===h.getSharedStorage(so)&&1===b.elements.length&&b.elements[0].uuid===(null==(o=null==(i=p())?void 0:i[0])?void 0:o.uuid)||"over-element"===b.type&&null===h.getSharedStorage(so)&&1===b.elements.length&&b.elements[0].uuid===(null==(n=h.getSharedStorage(uo))?void 0:n.uuid)))return"over-element"===b.type&&1===(null==(a=null==b?void 0:b.elements)?void 0:a.length)?(S(b.elements[0]),void s.drawFrame()):h.getSharedStorage(uo)?(S(null),void s.drawFrame()):void 0}else(h.getSharedStorage(uo)||h.getSharedStorage(go))&&(h.setSharedStorage(uo,null),h.setSharedStorage(go,null),s.drawFrame())},pointStart:e=>{var t,i,o,n,a,r,l,c,f,w,y,x;g=e.point,v=e.point;const M=h.getSharedStorage(po);if((null==M?void 0:M.length)>0){if(Do(e.point,{ctx:u,viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),groupQueue:M})){const l=Yo(e.point,I()),s=1===(null==(t=null==l?void 0:l.elements)?void 0:t.length)&&!0===(null==(o=null==(i=l.elements[0])?void 0:i.operations)?void 0:o.locked);S(null),1===(null==(n=null==l?void 0:l.elements)?void 0:n.length)&&(m=Re(null==l?void 0:l.elements[0])),!0===s?A():"over-element"===l.type&&1===(null==(a=null==l?void 0:l.elements)?void 0:a.length)?(b([l.elements[0]],{triggerEvent:!0}),h.setSharedStorage(so,"drag")):(null==(r=l.type)?void 0:r.startsWith("resize-"))?(h.setSharedStorage(ho,l.type),h.setSharedStorage(so,"resize")):b([],{triggerEvent:!0})}else A();return void s.drawFrame()}const R=Bo(p(),{viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),calculator:d}),T=Yo(e.point,{...I(),areaSize:R,groupQueue:[]}),z=1===(null==(l=null==T?void 0:T.elements)?void 0:l.length)&&!0===(null==(f=null==(c=T.elements[0])?void 0:c.operations)?void 0:f.locked);S(null),1===(null==(w=null==T?void 0:T.elements)?void 0:w.length)&&(m=Re(null==T?void 0:T.elements[0])),!0===z?(A(),h.setSharedStorage(so,"area"),h.setSharedStorage(co,e.point),b([],{triggerEvent:!0})):"list-area"===T.type?h.setSharedStorage(so,"drag-list"):"over-element"===T.type&&1===(null==(y=null==T?void 0:T.elements)?void 0:y.length)?(b([T.elements[0]],{triggerEvent:!0}),h.setSharedStorage(so,"drag")):(null==(x=T.type)?void 0:x.startsWith("resize-"))?(h.setSharedStorage(ho,T.type),h.setSharedStorage(so,"resize")):(A(),h.setSharedStorage(so,"area"),h.setSharedStorage(co,e.point),b([],{triggerEvent:!0})),s.drawFrame()},pointMove:e=>{var t,i,o;h.setSharedStorage(So,!0);const n=h.getActiveStorage("data"),a=p(),r=h.getActiveStorage("scale")||1,l=h.getActiveViewScaleInfo(),c=h.getActiveViewSizeInfo(),f=g,u=v,x=e.point,S=h.getSharedStorage(ho),I=h.getSharedStorage(so),A=h.getSharedStorage(po),M=h.getSharedStorage(Io);if("drag"===I){if(y=!0,w="drag",n&&1===(null==a?void 0:a.length)&&m&&u&&x&&!0!==(null==(i=null==(t=a[0])?void 0:t.operations)?void 0:i.locked)){const{moveX:e,moveY:t}=function(e,t,i){let o=t.x-e.x,n=t.y-e.y;const a=[];if(i.forEach((e=>{const{x:t,y:i,w:o,h:n,angle:r=0}=e;a.push({x:t,y:i,w:o,h:n,angle:0-r})})),(null==i?void 0:i.length)>0){const i=ye(e,a),r=ye(t,a);o=r.x-i.x,n=r.y-i.y}return{moveX:o,moveY:n}}(u,x,A);let i=d.toGridNum(e/r),o=d.toGridNum(t/r);if(!0===M){const e=Fo(a[0].uuid,{calculator:d,data:n,groupQueue:A,viewScaleInfo:l,viewSizeInfo:c});try{e&&(N.x(e.offsetX)&&null!==e.offsetX&&(i=d.toGridNum(i+e.offsetX)),N.y(e.offsetY)&&null!==e.offsetY&&(o=d.toGridNum(o+e.offsetY)))}catch(e){console.error(e)}}a[0].x=d.toGridNum(m.x+i),a[0].y=d.toGridNum(m.y+o),b([a[0]]),d.modifyViewVisibleInfoMap(n,{modifyOptions:{type:"updateElement",content:{element:a[0],position:h.getSharedStorage(yo)||[]}},viewSizeInfo:c,viewScaleInfo:l})}s.drawFrame()}else if("drag-list"===I){if(y=!0,w="drag-list",n&&u&&f&&x&&(null==a?void 0:a.length)>1){const e=(x.x-f.x)/r,t=(x.y-f.y)/r;a.forEach((i=>{var o;i&&!0!==(null==(o=null==i?void 0:i.operations)?void 0:o.locked)&&(i.x=d.toGridNum(i.x+e),i.y=d.toGridNum(i.y+t),d.modifyViewVisibleInfoMap(n,{modifyOptions:{type:"updateElement",content:{element:i,position:ze(i.uuid,n.elements)||[]}},viewSizeInfo:c,viewScaleInfo:l}))})),h.setActiveStorage("data",n)}s.drawFrame()}else if("resize"===I){if(n&&1===(null==a?void 0:a.length)&&u&&m&&(null==S?void 0:S.startsWith("resize-"))){y=!0,w="resize";const e=[];A.forEach((t=>{const{x:i,y:o,w:n,h:a,angle:r=0}=t;e.push({x:i,y:o,w:n,h:a,angle:0-r})}));let t=u,i=x;if(A.length>0&&(t=ye(u,e),i=ye(x,e)),"resize-rotate"===S){const e=h.getSharedStorage(wo),t=ve([e.topLeft.center,e.topRight.center,e.bottomLeft.center,e.bottomRight.center]),i=Vo(m,{center:t,viewScaleInfo:l,viewSizeInfo:c,start:u,end:x,resizeType:S,sharer:h});a[0].angle=d.toGridNum(i.angle||0)}else{const e=function(e,t){var i,o,n,a,r,l,s,h,c;let{x:d,y:f,w:u,h:g,angle:v=0}=e;const m=ge({x:d,y:f,w:u,h:g,angle:v});v=be(v);const w=de(v),y=!!(null==(i=null==e?void 0:e.operations)?void 0:i.limitRatio),{start:p,end:x,resizeType:S,scale:b}=t;let I={...p},A={...x},M={x:I.x,y:m.y},R={x:A.x,y:m.y},T={...M},z={...R},P={x:m.x,y:I.y},C={x:m.x,y:A.y},E={...P},k={...C},W=(z.x-T.x)/b,L=(z.y-T.y)/b,O=Lo(W,L),j=(k.x-E.x)/b,D=(k.y-E.y)/b,Y=Lo(j,D);(v>0||v<0)&&(I=we(m,p,0-w),A=we(m,x,0-w),M={x:I.x,y:m.y},R={x:A.x,y:m.y},T=we(m,M,w),z=we(m,R,w),P={x:m.x,y:I.y},C={x:m.x,y:A.y},E=we(m,P,w),k=we(m,C,w),W=(z.x-T.x)/b,L=(z.y-T.y)/b,O=Lo(W,L),O=Oo(O,L),j=(k.x-E.x)/b,D=(k.y-E.y)/b,Y=Lo(j,D),Y=Oo(Y,D));let V=(x.x-p.x)/b,B=(x.y-p.y)/b;if(!0===y)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(S)){const t=Math.max(Math.abs(V),Math.abs(B));V=(V>=0?1:-1)*t,B=(B>=0?1:-1)*t/e.w*e.h;const i=Math.max(Math.abs(j),Math.abs(D));j=(j>=0?1:-1)*i,D=(D>=0?1:-1)*i/e.w*e.h;const o=Math.max(Math.abs(W),Math.abs(L));W=(W>=0?1:-1)*o,L=(L>=0?1:-1)*o/e.w*e.h}else if(["resize-top-left","resize-top-right","resize-bottom-left","resize-bottom-right"].includes(S)){{const t=Math.abs(V);V=(V>=0?1:-1)*t;const i=t/e.w*e.h;"resize-top-left"===S||"resize-bottom-right"===S?B=V>0?i:-i:"resize-top-right"!==S&&"resize-bottom-left"!==S||(B=V>0?-i:i)}O=Math.abs(O),Y=O/e.w*e.h}switch(S){case"resize-top":if(0===v)g-B>0&&(f+=B,g-=B,!0===(null==(o=e.operations)?void 0:o.limitRatio)&&(d+=B/e.h*e.w/2,u-=B/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=0-Oo(Y,D);const e=Wo(v),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){Y=Oo(Y,j);const e=Wo(v-90),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){Y=Oo(Y,D);const e=Wo(v-180),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){Y=0-Oo(Y,j);const e=Wo(v-270),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}g+Y>0&&(!0===(null==(n=e.operations)?void 0:n.limitRatio)&&(u+=Y/e.h*e.w),g+=Y,d=t-u/2,f=i-g/2)}break;case"resize-bottom":if(0===v)e.h+B>0&&(g+=B,!0===(null==(a=e.operations)?void 0:a.limitRatio)&&(d-=B/e.h*e.w/2,u+=B/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=Oo(Y,D);const e=Wo(v),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){Y=0-Oo(Y,j);const e=Wo(v-90),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){Y=Oo(Y,j);const e=Wo(v-180),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){Y=Oo(Y,j);const e=Wo(v-270),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}g+Y>0&&(!0===(null==(r=e.operations)?void 0:r.limitRatio)&&(u+=Y/e.h*e.w),g+=Y,d=t-u/2,f=i-g/2)}break;case"resize-left":if(0===v)e.w-V>0&&(d+=V,u-=V,!0===(null==(l=e.operations)?void 0:l.limitRatio)&&(g-=V/e.w*e.h,f+=V/e.w*e.h/2));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){O=0-Oo(O,W);const e=Wo(v),o=O/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){O=Oo(O,W);const e=Wo(v-90),o=O/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){O=Oo(O,L);const e=Wo(v-180),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){O=Oo(O,L);const e=Wo(v-270),o=O/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}u+O>0&&(!0===(null==(s=e.operations)?void 0:s.limitRatio)&&(g+=O/e.w*e.h),u+=O,d=t-u/2,f=i-g/2)}break;case"resize-right":if(0===v)e.w+V>0&&(u+=V,!0===(null==(h=e.operations)?void 0:h.limitRatio)&&(f-=V*e.h/e.w/2,g+=V*e.h/e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){O=Oo(O,L);const e=Wo(v),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){O=Oo(O,B);const e=Wo(v-90),o=O/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){O=Oo(O,B);const e=Wo(v-180),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e),O=0-O}else if(v<360){O=Oo(O,V);const e=Wo(v-270),o=O/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}u+O>0&&(!0===(null==(c=e.operations)?void 0:c.limitRatio)&&(g+=O/e.w*e.h),u+=O,d=t-u/2,f=i-g/2)}break;case"resize-top-left":if(0===v)u-V>0&&(d+=V,u-=V),g-B>0&&(f+=B,g-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-Oo(Y,D),O=0-Oo(O,y?0-Y:W);const i=Y/2;e+=i*Math.sin(w),t-=i*Math.cos(w);const o=O/2;e-=o*Math.cos(w),t-=o*Math.sin(w)}else if(v<180){Y=Oo(Y,j),O=Oo(O,y?Y:W);const i=Wo(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=Oo(Y,D),O=Oo(O,y?Y:L);const i=Wo(v-180),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=0-Oo(Y,j),O=Oo(O,y?Y:L);const i=Wo(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-top-right":if(0===v)u+V>0&&(u+=V),g-B>0&&(f+=B,g-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-Oo(Y,D),O=Oo(O,y?Y:L);const i=Wo(v),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=Oo(Y,j),O=Oo(O,y?Y:L);const i=Wo(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){const i=Wo(v-180);Y=Oo(Y,D),O=Oo(O,y?Y:0-W);const o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=0-Oo(Y,j),O=Oo(O,y?Y:W);const i=Wo(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-bottom-left":if(0===v)e.h+B>0&&(g+=B),e.w-V>0&&(d+=V,u-=V);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=Oo(Y,D),O=0-Oo(O,y?0-Y:W);const i=Wo(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<180){Y=0-Oo(Y,j),O=Oo(O,y?Y:W);const i=Wo(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=Oo(Y,j),O=Oo(O,y?Y:L);const i=Wo(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=Oo(Y,j),O=Oo(O,y?Y:L);const i=Wo(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-bottom-right":if(0===v)e.h+B>0&&(g+=B),e.w+V>0&&(u+=V);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=Oo(Y,D),O=Oo(O,y?Y:L);const i=Wo(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=0-Oo(Y,j),O=Oo(O,y?Y:B);const i=Wo(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){Y=Oo(Y,j),O=Oo(O,y?Y:0-L);const i=Wo(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=Oo(Y,j),O=Oo(O,y?Y:W);const i=Wo(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}}return{x:d,y:f,w:u,h:g,angle:e.angle}}(m,{scale:r,start:t,end:i,resizeType:S,sharer:h}),n={ignore:!!m.angle};a[0].x=d.toGridNum(e.x,n),a[0].y=d.toGridNum(e.y,n),"group"===a[0].type&&!0===(null==(o=a[0].operations)?void 0:o.deepResize)?function(e,t){const i=t.w&&t.w>0?t.w:e.w,o=t.h&&t.h>0?t.h:e.h,n=i/e.w,a=o/e.h;if(n===a&&1===n)return e;const r=Math.min(n,a),l=Math.max(n,a);e.w=i,e.h=o;const s={xRatio:n,yRatio:a,minRatio:r,maxRatio:l};"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{$e(e,s)})),Je(e,s)}(a[0],{w:d.toGridNum(e.w,n),h:d.toGridNum(e.h,n)}):(a[0].w=d.toGridNum(e.w,n),a[0].h=d.toGridNum(e.h,n))}b([a[0]]),d.modifyViewVisibleInfoMap(n,{modifyOptions:{type:"updateElement",content:{element:a[0],position:h.getSharedStorage(yo)||[]}},viewSizeInfo:c,viewScaleInfo:l}),s.drawFrame()}}else"area"===I&&(w="area",h.setSharedStorage(fo,e.point),s.drawFrame());g=e.point},pointEnd(e){w=null,h.setSharedStorage(So,!1);const t=h.getActiveStorage("data"),i=h.getSharedStorage(vo),o=h.getSharedStorage(uo),n=h.getSharedStorage(ho),a=h.getSharedStorage(so),r=h.getActiveViewSizeInfo();let l=!1;if(g=null,v=null,m=null,"resize"===a&&n)h.setSharedStorage(ho,null),l=!0;else if("area"===a){if(h.setSharedStorage(so,null),t){const e=h.getSharedStorage(co),i=h.getSharedStorage(fo);if(e&&i){const{elements:o}=function(e,t){var i;const o=[],n=[],a=[],{viewScaleInfo:r,viewSizeInfo:l,start:s,end:h}=t;if(!(Array.isArray(e.elements)&&s&&h))return{indexes:o,uuids:n,elements:a};const c=Math.min(s.x,h.x),d=Math.max(s.x,h.x),f=Math.min(s.y,h.y),u=Math.max(s.y,h.y);for(let t=0;t<e.elements.length;t++){const l=e.elements[t];if(!0===(null==(i=null==l?void 0:l.operations)?void 0:i.locked))continue;const s=We(l,{viewScaleInfo:r}),h=ge(s);if(h.x>=c&&h.x<=d&&h.y>=f&&h.y<=u&&(o.push(t),n.push(l.uuid),a.push(l),s.angle&&(s.angle>0||s.angle<0))){const e=xe(s);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];s.x=Math.min(...t),s.y=Math.min(...i),s.w=Math.abs(Math.max(...t)-Math.min(...t)),s.h=Math.abs(Math.max(...i)-Math.min(...i))}}}return{indexes:o,uuids:n,elements:a}}(t,{start:e,end:i,calculator:d,viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo()});o.length>0&&(h.setSharedStorage(so,"drag-list"),b(o,{triggerEvent:!0}),l=!0)}}}else if("drag-list"===a)h.setSharedStorage(so,"drag-list-end"),l=!0;else if(t){d.getPointElement(e.point,{data:t,viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo()}).element?(h.setSharedStorage(so,"select"),l=!0):h.setSharedStorage(so,null)}null===h.getSharedStorage(so)&&(A(),l=!0);(()=>{if(l){if(t&&Array.isArray(null==t?void 0:t.elements)&&["drag","drag-list"].includes(a)){const e=function(e,t,i){const o=Ae(e,{viewWidth:t.width,viewHeight:t.height,extend:null==i?void 0:i.extend});return!0===(null==i?void 0:i.extend)&&(o.contextWidth=Math.max(o.contextWidth,t.contextWidth),o.contextHeight=Math.max(o.contextHeight,t.contextHeight)),{contextSize:o}}(t.elements,r,{extend:!0});h.setActiveStorage("contextHeight",e.contextSize.contextHeight),h.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(t&&["drag","drag-list","drag-list-end","resize"].includes(a)){let e="dragElement";y&&(f.trigger(ao.CHANGE,{data:t,type:e,selectedElements:i,hoverElement:o}),y=!1)}s.drawFrame()}})()},pointLeave(){g=null,v=null,m=null,A(),s.drawFrame()},doubleClick(e){var t,i,o,n,a,r,l,c;if(!1===h.getSharedStorage(bo))return;const d=Yo(e.point,I());if(h.setSharedStorage(wo,null),h.setSharedStorage(vo,[]),1!==d.elements.length||!0!==(null==(i=null==(t=d.elements[0])?void 0:t.operations)?void 0:i.locked)){if(1===d.elements.length&&"group"===(null==(o=d.elements[0])?void 0:o.type)){if(!0===x(d.elements[0]))return h.setSharedStorage(so,null),void s.drawFrame()}else 1!==d.elements.length||"text"!==(null==(n=d.elements[0])?void 0:n.type)||(null==(r=null==(a=d.elements[0])?void 0:a.operations)?void 0:r.invisible)||f.trigger(ao.TEXT_EDIT,{element:d.elements[0],groupQueue:h.getSharedStorage(po)||[],position:ze(null==(l=d.elements[0])?void 0:l.uuid,(null==(c=h.getActiveStorage("data"))?void 0:c.elements)||[]),viewScaleInfo:h.getActiveViewScaleInfo()});h.setSharedStorage(so,null)}},contextMenu:e=>{var t,i,o,n,a,r,l,c;const f=h.getSharedStorage(po);if((null==f?void 0:f.length)>0){if(Do(e.point,{ctx:u,viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),groupQueue:f})){const a=Yo(e.point,I());1===(null==(t=null==a?void 0:a.elements)?void 0:t.length)&&!0!==(null==(o=null==(i=a.elements[0])?void 0:i.operations)?void 0:o.locked)?(A(),b([a.elements[0]],{triggerEvent:!0}),s.drawFrame()):(null==(n=null==a?void 0:a.elements)?void 0:n.length)||A()}return}const g=Bo(p(),{viewScaleInfo:h.getActiveViewScaleInfo(),viewSizeInfo:h.getActiveViewSizeInfo(),calculator:d}),v=Yo(e.point,{...I(),areaSize:g,groupQueue:[]});if(1===(null==(a=null==v?void 0:v.elements)?void 0:a.length)&&!0!==(null==(l=null==(r=v.elements[0])?void 0:r.operations)?void 0:l.locked))return A(),b([v.elements[0]],{triggerEvent:!0}),void s.drawFrame();(null==(c=null==v?void 0:v.elements)?void 0:c.length)||A()},beforeDrawFrame({snapshot:t}){var i;const{activeStore:o,sharedStore:n}=t,{scale:a,offsetLeft:r,offsetTop:s,offsetRight:h,offsetBottom:c,width:f,height:g,contextHeight:v,contextWidth:m,devicePixelRatio:w}=o,y=e.sharer,x={scale:a,offsetLeft:r,offsetTop:s,offsetRight:h,offsetBottom:c},S={width:f,height:g,contextHeight:v,contextWidth:m,devicePixelRatio:w},b=n[vo][0],I=n[uo],A=n[go],M=n[so],R=n[co],T=n[fo],z=n[po],P=n[xo],C=n[So],E=n[Io],k={calculator:d,viewScaleInfo:x,viewSizeInfo:S,style:l},W=b?Xe(b,{groupQueue:z,controllerSize:10,viewScaleInfo:x}):null,L=!!(null==(i=null==I?void 0:I.operations)?void 0:i.locked);if((null==z?void 0:z.length)>0){if(function(e,t,i){const{style:o}=i,{activeColor:n}=o;for(let o=0;o<t.length;o++){const a={borderColor:n,borderWidth:2,background:"transparent",lineDash:[4,4]};Mo(e,Oe(t[o],i),a)}}(u,P,k),I&&"drag"!==M&&(L?Co(u,A,{...k,controller:Xe(I,{groupQueue:z,controllerSize:10,viewScaleInfo:x}),style:l}):Po(u,A,k)),b&&["select","drag","resize"].includes(M)&&(Eo(u,W,{...k,element:b,calculator:d,hideControllers:!!C&&"drag"===M,style:l}),"drag"===M&&!0===E)){const e=Fo(b.uuid,{calculator:d,data:o.data,groupQueue:z,viewScaleInfo:x,viewSizeInfo:S});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||ko(u,{xLines:o,yLines:n,style:l})}}}else if(I&&"drag"!==M&&(L?Co(u,A,{...k,controller:Xe(I,{groupQueue:z,controllerSize:10,viewScaleInfo:x}),style:l}):Po(u,A,k)),b&&["select","drag","resize"].includes(M)){if(Eo(u,W,{...k,element:b,calculator:d,hideControllers:!!C&&"drag"===M,style:l}),"drag"===M&&!0===E){const e=Fo(b.uuid,{calculator:d,data:o.data,groupQueue:z,viewScaleInfo:x,viewSizeInfo:S});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||ko(u,{xLines:o,yLines:n,style:l})}}}else if("area"===M&&R&&T)!function(e,t){const{start:i,end:o,style:n}=t,{activeColor:a,activeAreaColor:r}=n;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=a,e.fillStyle=r,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,i.y),e.lineTo(o.x,o.y),e.lineTo(i.x,o.y),e.closePath(),e.stroke(),e.fill()}(u,{start:R,end:T,style:l});else if(["drag-list","drag-list-end"].includes(M)){const e=Bo(p(),{viewScaleInfo:y.getActiveViewScaleInfo(),viewSizeInfo:y.getActiveViewSizeInfo(),calculator:d});e&&function(e,t){const{areaSize:i,style:o}=t,{activeColor:n,activeAreaColor:a}=o,{x:r,y:l,w:s,h:h}=i;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=n,e.fillStyle=a,e.beginPath(),e.moveTo(r,l),e.lineTo(r+s,l),e.lineTo(r+s,l+h),e.lineTo(r,l+h),e.closePath(),e.stroke(),e.fill()}(u,{areaSize:e,style:l})}}}},e.MiddlewareTextEditor=e=>{const{eventHub:t,boardContent:i,viewer:o,sharer:n}=e,a=i.boardContext.canvas,r=document.createElement("div");r.setAttribute("contenteditable","true");const l=document.createElement("div"),s=e.container||document.body,h=document.createElement("div");let c=null,d=[];const f=`idraw-middleware-text-editor-${Math.random().toString(26).substring(2)}`;h.setAttribute("id",f),l.appendChild(r),l.style.position="absolute",h.appendChild(l),h.style.position="fixed",h.style.top="0",h.style.bottom="0",h.style.left="0",h.style.right="0",h.style.display="none",s.appendChild(h);const u=()=>{if(null==c?void 0:c.uuid){const e=n.getActiveOverrideElemenentMap();e&&delete e[c.uuid],n.setActiveOverrideElemenentMap(e),o.drawFrame()}h.style.display="none",c=null,d=[]},g=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:n,y:a,w:r,h:l}=t,s=be(t.angle||0);return o.style.position="absolute",o.style.left=`${n}px`,o.style.top=`${a}px`,o.style.width=`${r}px`,o.style.height=`${l}px`,o.style.transform=`rotate(${s}deg)`,i.appendChild(o),o},v=e=>{const{viewScaleInfo:t,element:i,groupQueue:o}=e,{scale:n,offsetTop:a,offsetLeft:s}=t;l.children&&Array.from(l.children).forEach((e=>{e.remove()}));let h=l;for(let e=0;e<o.length;e++){const t=o[e],{x:i,y:r,w:l,h:c}=t,d={x:i*n,y:r*n,w:l*n,h:c*n,angle:be(t.angle||0)};0===e&&(d.x+=s,d.y+=a),h=g({size:d,parent:h})}const c={...Sn,...i.detail};let d=i.x*n+s,f=i.y*n+a,u=i.w*n,v=i.h*n;o.length>0&&(d=i.x*n,f=i.y*n,u=i.w*n,v=i.h*n);let m="center",w="center";"left"===c.textAlign?m="start":"right"===c.textAlign&&(m="end"),"top"===c.verticalAlign?w="start":"bottom"===c.verticalAlign&&(w="end"),r.style.display="inline-flex",r.style.justifyContent=m,r.style.alignItems=w,r.style.position="absolute",r.style.left=d-1+"px",r.style.top=f-1+"px",r.style.width=`${u+2}px`,r.style.height=`${v+2}px`,r.style.transform=`rotate(${be(i.angle||0)}deg)`,r.style.boxSizing="border-box",r.style.border="1px solid #1973ba",r.style.resize="none",r.style.overflow="hidden",r.style.wordBreak="break-all",r.style.borderRadius=("number"==typeof c.borderRadius?c.borderRadius:0)*n+"px",r.style.background=`${c.background||"transparent"}`,r.style.color=`${c.color||"#333333"}`,r.style.fontSize=c.fontSize*n+"px",r.style.lineHeight=(c.lineHeight||c.fontSize)*n+"px",r.style.fontFamily=qe(c.fontFamily),r.style.fontWeight=`${c.fontWeight}`,r.style.padding="0",r.style.margin="0",r.style.outline="none",r.innerText=c.text||"",h.appendChild(r)},m=()=>{const{left:e,top:t,width:i,height:o}=(()=>{const e=a.getBoundingClientRect(),{left:t,top:i,width:o,height:n}=e;return{left:t,top:i,width:o,height:n}})();l.style.position="absolute",l.style.overflow="hidden",l.style.top=`${t}px`,l.style.left=`${e}px`,l.style.width=`${i}px`,l.style.height=`${o}px`};h.addEventListener("click",(()=>{u()})),r.addEventListener("click",(e=>{e.stopPropagation()})),r.addEventListener("input",(()=>{c&&d&&(c.detail.text=r.innerText||"",t.trigger(ao.TEXT_CHANGE,{element:{uuid:c.uuid,detail:{text:c.detail.text}},position:[...d||[]]}),o.drawFrame())})),r.addEventListener("blur",(()=>{c&&d&&t.trigger(ao.TEXT_CHANGE,{element:{uuid:c.uuid,detail:{text:c.detail.text}},position:[...d]}),u()})),r.addEventListener("keydown",(e=>{e.stopPropagation()})),r.addEventListener("keypress",(e=>{e.stopPropagation()})),r.addEventListener("keyup",(e=>{e.stopPropagation()})),r.addEventListener("wheel",(e=>{e.stopPropagation(),e.preventDefault()}));const w=e=>{var t;(null==e?void 0:e.position)&&(null==e?void 0:e.element)&&"text"===(null==(t=null==e?void 0:e.element)?void 0:t.type)&&(c=e.element,d=e.position),(e=>{m(),v(e),h.style.display="block",(null==c?void 0:c.uuid)&&(n.setActiveOverrideElemenentMap({[c.uuid]:{operations:{invisible:!0}}}),o.drawFrame())})(e)};return{name:"@middleware/text-editor",use(){t.on(ao.TEXT_EDIT,w)},disuse(){t.off(ao.TEXT_EDIT,w)}}},e.coreEventKeys=ao,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idraw/core",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"author": "chenshenhai",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@idraw/types": "^0.4.0-beta.
|
|
24
|
+
"@idraw/types": "^0.4.0-beta.35"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@idraw/board": "^0.4.0-beta.
|
|
29
|
-
"@idraw/renderer": "^0.4.0-beta.
|
|
30
|
-
"@idraw/util": "^0.4.0-beta.
|
|
28
|
+
"@idraw/board": "^0.4.0-beta.35",
|
|
29
|
+
"@idraw/renderer": "^0.4.0-beta.35",
|
|
30
|
+
"@idraw/util": "^0.4.0-beta.35"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public",
|