@idraw/core 0.4.0-beta.5 → 0.4.0-beta.6

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,5 +1,5 @@
1
1
  import type { Data, PointSize, CoreOptions, BoardMiddleware, ViewSizeInfo, CoreEvent, ViewScaleInfo, LoadItemMap } from '@idraw/types';
2
- export { MiddlewareSelector, middlewareEventSelect } from './middleware/selector';
2
+ export { MiddlewareSelector, middlewareEventSelect, middlewareEventSelectClear } from './middleware/selector';
3
3
  export { MiddlewareScroller } from './middleware/scroller';
4
4
  export { MiddlewareScaler, middlewareEventScale } from './middleware/scaler';
5
5
  export { MiddlewareRuler, middlewareEventRuler } from './middleware/ruler';
package/dist/esm/index.js CHANGED
@@ -13,7 +13,7 @@ var _Core_instances, _Core_board, _Core_container, _Core_initContainer;
13
13
  import { Board } from '@idraw/board';
14
14
  import { createBoardContent, validateElements } from '@idraw/util';
15
15
  import { Cursor } from './lib/cursor';
16
- export { MiddlewareSelector, middlewareEventSelect } from './middleware/selector';
16
+ export { MiddlewareSelector, middlewareEventSelect, middlewareEventSelectClear } from './middleware/selector';
17
17
  export { MiddlewareScroller } from './middleware/scroller';
18
18
  export { MiddlewareScaler, middlewareEventScale } from './middleware/scaler';
19
19
  export { MiddlewareRuler, middlewareEventRuler } from './middleware/ruler';
@@ -1,4 +1,5 @@
1
1
  import type { CoreEvent } from '@idraw/types';
2
2
  import type { BoardMiddleware, DeepSelectorSharedStorage } from './types';
3
3
  export declare const middlewareEventSelect: string;
4
+ export declare const middlewareEventSelectClear: string;
4
5
  export declare const MiddlewareSelector: BoardMiddleware<DeepSelectorSharedStorage, CoreEvent>;
@@ -4,6 +4,7 @@ import { getPointTarget, resizeElement, getSelectedListArea, calcSelectedElement
4
4
  import { keyActionType, keyResizeType, keyAreaStart, keyAreaEnd, keyGroupQueue, keyGroupQueueVertexesList, keyHoverElement, keyHoverElementVertexes, keySelectedElementList, keySelectedElementListVertexes, keySelectedElementController } from './config';
5
5
  import { middlewareEventTextEdit } from '../text-editor';
6
6
  export const middlewareEventSelect = '@middleware/select';
7
+ export const middlewareEventSelectClear = '@middleware/select-clear';
7
8
  export const MiddlewareSelector = (opts) => {
8
9
  const { viewer, sharer, boardContent, calculator, eventHub } = opts;
9
10
  const { helperContext } = boardContent;
@@ -114,12 +115,18 @@ export const MiddlewareSelector = (opts) => {
114
115
  viewer.drawFrame();
115
116
  }
116
117
  };
118
+ const selectClearCallback = () => {
119
+ clear();
120
+ viewer.drawFrame();
121
+ };
117
122
  return {
118
123
  use() {
119
124
  eventHub.on(middlewareEventSelect, selectCallback);
125
+ eventHub.on(middlewareEventSelectClear, selectClearCallback);
120
126
  },
121
127
  disuse() {
122
128
  eventHub.off(middlewareEventSelect, selectCallback);
129
+ eventHub.off(middlewareEventSelectClear, selectClearCallback);
123
130
  },
124
131
  hover: (e) => {
125
132
  var _a, _b;
@@ -4493,6 +4493,7 @@ var __privateMethod = (obj, member, method) => {
4493
4493
  };
4494
4494
  };
4495
4495
  const middlewareEventSelect = "@middleware/select";
4496
+ const middlewareEventSelectClear = "@middleware/select-clear";
4496
4497
  const MiddlewareSelector = (opts) => {
4497
4498
  const { viewer, sharer, boardContent, calculator, eventHub } = opts;
4498
4499
  const { helperContext } = boardContent;
@@ -4598,12 +4599,18 @@ var __privateMethod = (obj, member, method) => {
4598
4599
  viewer.drawFrame();
4599
4600
  }
4600
4601
  };
4602
+ const selectClearCallback = () => {
4603
+ clear();
4604
+ viewer.drawFrame();
4605
+ };
4601
4606
  return {
4602
4607
  use() {
4603
4608
  eventHub.on(middlewareEventSelect, selectCallback);
4609
+ eventHub.on(middlewareEventSelectClear, selectClearCallback);
4604
4610
  },
4605
4611
  disuse() {
4606
4612
  eventHub.off(middlewareEventSelect, selectCallback);
4613
+ eventHub.off(middlewareEventSelectClear, selectClearCallback);
4607
4614
  },
4608
4615
  hover: (e) => {
4609
4616
  var _a, _b;
@@ -5643,6 +5650,7 @@ var __privateMethod = (obj, member, method) => {
5643
5650
  exports.middlewareEventRuler = middlewareEventRuler;
5644
5651
  exports.middlewareEventScale = middlewareEventScale;
5645
5652
  exports.middlewareEventSelect = middlewareEventSelect;
5653
+ exports.middlewareEventSelectClear = middlewareEventSelectClear;
5646
5654
  exports.middlewareEventTextEdit = middlewareEventTextEdit;
5647
5655
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5648
5656
  return exports;
@@ -1 +1 @@
1
- var iDrawCore=function(e){"use strict";var t,i,o,n,a=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},r=(e,t,i)=>(a(e,t,"read from private field"),i?i.call(e):t.get(e)),s=(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)},l=(e,t,i,o)=>(a(e,t,"write to private field"),o?o.call(e,i):t.set(e,i),i);function h(e,t){let i=-1;return function(...o){i>0||(i=setTimeout((()=>{e(...o),i=-1}),t))}}function c(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 d(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 f(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function u(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 g(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/${u(t.toString(16).padEnd(4,o))}${u(e.substring(i-4,i).padEnd(4,o)).padEnd(4,"f")}-${u(e.substring(i-8,i-4).padEnd(4,o)).padEnd(4,"f")}-${u(e.substring(i-12,i-8).padEnd(4,o)).padEnd(4,"f")}-${u(e.substring(i-16,i-12).padEnd(4,n)).padEnd(4,"f")}-${u(e.substring(i,i+4).padEnd(4,n)).padEnd(4,"f")}${u(e.substring(i+4,i+8).padEnd(4,n)).padEnd(4,"f")}${u(n.padEnd(4,o).padEnd(4,n))}`}function v(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 y={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),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 m=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{l(o.next(e))}catch(e){a(e)}}function s(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))};const{Image:p}=window;function x(e){return new Promise(((t,i)=>{const o=new p;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function S(e){return m(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 x(t)}))}function b(e,t){return m(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&amp;");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 x(i)}))}function A(e){return"number"==typeof e&&(e>0||e<=0)}function I(e){return"number"==typeof e&&e>=0}function M(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function z(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const R={x:function(e){return A(e)},y:function(e){return A(e)},w:I,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:A,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return I(e)},borderRadius:function(e){return A(e)&&e>=0},color:function(e){return c(e)},imageSrc:function(e){return z(e)||M(e)},imageURL:M,imageBase64:z,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 A(e)&&e>0},lineHeight:function(e){return A(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 A(e)&&e>0}};var P,T,C=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},E=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 W{constructor(e,t){P.set(this,void 0),T.set(this,void 0),C(this,P,e,"f"),C(this,T,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f")}$undoPixelRatio(e){return e/E(this,T,"f").devicePixelRatio}$doPixelRatio(e){return E(this,T,"f").devicePixelRatio*e}$getContext(){return E(this,P,"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"}`),E(this,P,"f").font=`${t.join(" ")}`}$getOffscreenCanvas(){return E(this,T,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:a}=E(this,P,"f");a.width=t*o,a.height=i*o,C(this,T,Object.assign(Object.assign({},E(this,T,"f")),{devicePixelRatio:o}),"f"),!0===n&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=E(this,T,"f"),{width:t,height:i}=E(this,P,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return E(this,P,"f").canvas}get fillStyle(){return E(this,P,"f").fillStyle}set fillStyle(e){E(this,P,"f").fillStyle=e}get strokeStyle(){return E(this,P,"f").strokeStyle}set strokeStyle(e){E(this,P,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(E(this,P,"f").lineWidth)}set lineWidth(e){E(this,P,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return E(this,P,"f").textAlign}set textAlign(e){E(this,P,"f").textAlign=e}get textBaseline(){return E(this,P,"f").textBaseline}set textBaseline(e){E(this,P,"f").textBaseline=e}get globalAlpha(){return E(this,P,"f").globalAlpha}set globalAlpha(e){E(this,P,"f").globalAlpha=e}get shadowColor(){return E(this,P,"f").shadowColor}set shadowColor(e){E(this,P,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(E(this,P,"f").shadowOffsetX)}set shadowOffsetX(e){E(this,P,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(E(this,P,"f").shadowOffsetY)}set shadowOffsetY(e){E(this,P,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(E(this,P,"f").shadowBlur)}set shadowBlur(e){E(this,P,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return E(this,P,"f").lineCap}set lineCap(e){E(this,P,"f").lineCap=e}get globalCompositeOperation(){return E(this,P,"f").globalCompositeOperation}set globalCompositeOperation(e){E(this,P,"f").globalCompositeOperation=e}fill(...e){return E(this,P,"f").fill(...e)}arc(e,t,i,o,n,a){return E(this,P,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,a)}rect(e,t,i,o){return E(this,P,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return E(this,P,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return E(this,P,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return E(this,P,"f").beginPath()}closePath(){return E(this,P,"f").closePath()}lineTo(e,t){return E(this,P,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return E(this,P,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return E(this,P,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}getLineDash(){return E(this,P,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return E(this,P,"f").setLineDash(t)}stroke(e){return e?E(this,P,"f").stroke(e):E(this,P,"f").stroke()}translate(e,t){return E(this,P,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return E(this,P,"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],s=e[e.length-3],l=e[e.length-2],h=e[e.length-1];return 9===e.length?E(this,P,"f").drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a),this.$doPixelRatio(r),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(h)):E(this,P,"f").drawImage(t,this.$doPixelRatio(r),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(h))}createPattern(e,t){return E(this,P,"f").createPattern(e,t)}measureText(e){return E(this,P,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?E(this,P,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):E(this,P,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?E(this,P,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):E(this,P,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){E(this,P,"f").save()}restore(){E(this,P,"f").restore()}scale(e,t){E(this,P,"f").scale(e,t)}circle(e,t,i,o,n,a,r,s){E(this,P,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,a,r,s)}isPointInPath(e,t){return E(this,P,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return E(this,P,"f").clip(...e)}setTransform(e,t,i,o,n,a){return E(this,P,"f").setTransform(e,t,i,o,n,a)}getTransform(){return E(this,P,"f").getTransform()}createLinearGradient(e,t,i,o){return E(this,P,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,a){return E(this,P,"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 E(this,P,"f").createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function O(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 W(a,e)}function j(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 W(a,{devicePixelRatio:o,offscreenCanvas:n})}P=new WeakMap,T=new WeakMap;class D{constructor(){this._listeners=new Map}on(e,t){if(this._listeners.has(e)){const i=this._listeners.get(e)||[];null==i||i.push(t),this._listeners.set(e,i)}else this._listeners.set(e,[t])}off(e,t){if(this._listeners.has(e)){const i=this._listeners.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}this._listeners.set(e,i||[])}}trigger(e,t){const i=this._listeners.get(e);return!!Array.isArray(i)&&(i.forEach((e=>{e(t)})),!0)}has(e){if(this._listeners.has(e)){const t=this._listeners.get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}}function k(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}class L{constructor(e){this._backUpDefaultStorage=v(e.defaultStorage),this._temp=this._createTempStorage()}set(e,t){this._temp[e]=t}get(e){return this._temp[e]}getSnapshot(){return v(this._temp)}clear(){this._temp=this._createTempStorage()}_createTempStorage(){return v(this._backUpDefaultStorage)}}function F(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 Y(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 B(e){return e/180*Math.PI}function G(e,t,i,o){const n=B(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 N(e,t,i){const o=V(t);G(e,t.angle||0,o,(()=>{i(e)}))}function V(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function X(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 V({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 H(e,t,i){const o=function(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}(e,t);let n=o+i;n>2*Math.PI?n-=2*Math.PI:n<0-2*Math.PI&&(n+=2*Math.PI),n<0&&(n+=2*Math.PI);const a=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 r=0,s=0;return 0===n?(r=0,s=0-a):n>0&&n<Math.PI/2?(r=Math.sin(n)*a,s=0-Math.cos(n)*a):n===Math.PI/2?(r=a,s=0):n>Math.PI/2&&n<Math.PI?(r=Math.sin(Math.PI-n)*a,s=Math.cos(Math.PI-n)*a):n===Math.PI?(r=0,s=a):n>Math.PI&&n<1.5*Math.PI?(r=0-Math.sin(n-Math.PI)*a,s=Math.cos(n-Math.PI)*a):n===1.5*Math.PI?(r=0-a,s=0):n>1.5*Math.PI&&n<2*Math.PI?(r=0-Math.sin(2*Math.PI-n)*a,s=0-Math.cos(2*Math.PI-n)*a):n===2*Math.PI&&(r=0,s=0-a),r+=e.x,s+=e.y,{x:r,y:s}}function Z(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:s=0}=e,l=H(V({x:t,y:n,w:a,h:r,angle:s}),{x:i,y:o},B(s));i=l.x,o=l.y})),{x:i,y:o}}return e}function Q(e,t,i){const{x:o,y:n,w:a,h:r}=e;let s={x:o,y:n},l={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=B(U(i));s=H(t,s,e),l=H(t,l,e),h=H(t,h,e),c=H(t,c,e)}return[s,l,h,c]}function $(e){const{angle:t=0}=e;return Q(e,V(e),t)}function _(e,t,i){return[H(e,{x:t[0].x,y:t[0].y},i),H(e,{x:t[1].x,y:t[1].y},i),H(e,{x:t[2].x,y:t[2].y},i),H(e,{x:t[3].x,y:t[3].y},i)]}function U(e){if(!(e>0||e<0)||0===e)return 0;let t=e%360;return t<0&&(t+=360),t}function J(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=J(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.children))}))}return t}function K(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=$(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 q(e,t){const{viewScaleInfo:i}=t,{x:o,y:n,w:a,h:r,angle:s}=e,{scale:l,offsetTop:h,offsetLeft:c}=i;return{x:o*l+c,y:n*l+h,w:a*l,h:r*l,angle:s}}function ee(e,t){const{viewScaleInfo:i}=t,{x:o,y:n}=e,{scale:a,offsetTop:r,offsetLeft:s}=i;return{x:o*a+s,y:n*a+r}}function te(e,t){return[ee(e[0],t),ee(e[1],t),ee(e[2],t),ee(e[3],t)]}function ie(e,t){const{context2d:i,element:o,viewScaleInfo:n,viewSizeInfo:a}=t,{angle:r=0}=o,{x:s,y:l,w:h,h:c}=q(o,{viewScaleInfo:n,viewSizeInfo:a}),d=$({x:s,y:l,w:h,h:c,angle:r});if(d.length>=2){i.beginPath(),i.moveTo(d[0].x,d[0].y);for(let e=1;e<d.length;e++)i.lineTo(d[e].x,d[e].y);i.closePath()}return!!i.isPointInPath(e.x,e.y)}function oe(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 ne(e){const{x:t,y:i,w:o,h:n,angle:a=0}=e;return 0===a?oe(e):Q(e,V({x:t,y:i,w:o,h:n,angle:a}),a)}function ae(e){const t=[];let i=0,o=0;const n=[],a=[...e];for(let e=0;e<a.length;e++){const{x:r,y:s,w:l,h:h,angle:c=0}=a[e];let d;if(i+=r,o+=s,0===e){const e={x:i,y:o,w:l,h:h,angle:c};d=ne({x:r,y:s,w:l,h:h,angle:c}),n.push({center:V(e),angle:c,radian:B(c)})}else{d=oe({x:i,y:o,w:l,h:h,angle:c});for(let e=0;e<n.length;e++){const{center:t,radian:i}=n[e];d=_(t,d,i)}const e=X(d);if(c>0||c<0){d=_(e,d,B(c))}n.push({center:e,angle:c,radian:B(c)})}t.push(d)}return t}function re(e,t){const i=function(e,t){const{groupQueue:i}=t;return i.length>0?ae([...i,e]):[ne(e)]}(e,t);return i.pop()||null}function se(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 le(e,t){const{groupQueue:i,controllerSize:o,viewScaleInfo:n}=t,a=(o&&o>0?o:8)/n.scale,{x:r,y:s,w:l,h:h,angle:c=0}=e,d=[{uuid:f(),x:r,y:s,w:l,h:h,angle:c,type:"group",detail:{children:[]}},...i];let u=0;d.forEach((({angle:e=0})=>{u+=e}));const g=re(e,{groupQueue:i}),v=k(g[0],g[1]),w=k(g[1],g[2]),y=k(g[2],g[3]),m=k(g[3],g[0]),p=g[0],x=g[1],S=g[2],b=g[3],A=se(p,{size:a,angle:u}),I=se(x,{size:a,angle:u}),M=se(b,{size:a,angle:u}),z=se(S,{size:a,angle:u}),R=ne(A),P=ne(I),T=ne(M),C=ne(z),E=[R[1],P[0],P[3],R[2]],W=[P[3],P[2],C[1],C[0]],O=[T[1],C[0],C[3],T[2]];return{elementWrapper:g,left:{type:"left",vertexes:[R[3],R[2],T[1],T[0]],center:m},right:{type:"right",vertexes:W,center:w},top:{type:"top",vertexes:E,center:v},bottom:{type:"bottom",vertexes:O,center:y},topLeft:{type:"top-left",vertexes:R,center:p},topRight:{type:"top-right",vertexes:P,center:x},bottomLeft:{type:"bottom-left",vertexes:T,center:b},bottomRight:{type:"bottom-right",vertexes:C,center:S}}}function he(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}function ce(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))}const de={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function fe(e,t){const{viewScaleInfo:i}=t,{scale:o}=i;let{borderRadius:n}=e.detail;const{boxSizing:a=de.boxSizing,borderWidth:r}=e.detail;Array.isArray(r)&&(n=0);let{x:s,y:l,w:h,h:c}=e,d=[0,0,0,0];if("number"==typeof n){const e=n*o;d=[e,e,e,e]}else Array.isArray(n)&&4===(null==n?void 0:n.length)&&(d=[n[0]*o,n[1]*o,n[2]*o,n[3]*o]);let f=0;return"number"==typeof r&&(f=(r||0)*o),"border-box"===a?(s=e.x+f/2,l=e.y+f/2,h=e.w-f,c=e.h-f):"content-box"===a?(s=e.x-f/2,l=e.y-f/2,h=e.w+f,c=e.h+f):(s=e.x,l=e.y,h=e.w,c=e.h),h=Math.max(h,1),c=Math.max(c,1),d=d.map((e=>Math.min(e,h/2,c/2))),{x:s,y:l,w:h,h:c,radiusList:d}}const ue=e=>ce(e,{decimalPlaces:4});function ge(e,t){const{detail:i}=e,{xRatio:o,yRatio:n,maxRatio:a}=t,r=(o+n)/2,{borderWidth:s,borderRadius:l,borderDash:h,shadowOffsetX:c,shadowOffsetY:d,shadowBlur:f}=i;if("number"==typeof s)i.borderWidth=ue(s*r);else if(Array.isArray(i.borderWidth)){const e=s;i.borderWidth=[ue(e[0]*n),ue(e[1]*o),ue(e[2]*n),ue(e[3]*o)]}if("number"==typeof l)i.borderRadius=ue(l*r);else if(Array.isArray(i.borderRadius)){const e=l;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 ve(e,t){const{type:i}=e;!function(e,t){const{xRatio:i,yRatio:o}=t,{x:n,y:a,w:r,h:s}=e;e.x=ue(n*i),e.y=ue(a*o),e.w=ue(r*i),e.h=ue(s*o),ge(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=>{ve(e,t)})))}function we(e,t,i){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:n,opacity:a=1}=i,{x:r,y:s}=o,{scale:l}=n;if("linear-gradient"===(null==t?void 0:t.type)){const{start:i,end:o,stops:n}=t,h={x:r+i.x*l,y:s+i.y*l},c={x:r+o.x*l,y:s+o.y*l},f=e.createLinearGradient(h.x,h.y,c.x,c.y);return n.forEach((e=>{f.addColorStop(e.offset,d(e.color,a))})),f}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:i,outer:o,stops:n}=t,h={x:r+i.x*l,y:s+i.y*l,radius:i.radius*l},c={x:r+o.x*l,y:s+o.y*l,radius:o.radius*l},f=e.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return n.forEach((e=>{f.addColorStop(e.offset,d(e.color,a))})),f}return"#000000"}const ye={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function me(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 pe(e,t,i){const{pattern:o,renderContent:n,originElem:a,calcElemSize:r,viewScaleInfo:s,viewSizeInfo:l}=i||{},{parentOpacity:h}=i,d=me(a)*h;!function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewScaleInfo:r,viewSizeInfo:s}=i,l=r.scale*s.devicePixelRatio,{clipPath:h}=(null==n?void 0:n.detail)||{};if(h&&a&&h.commands){const{x:i,y:n,w:r,h:s}=a,{originW:c,originH:d,originX:f,originY:u}=h,g=r/c,v=s/d,w=i-f*g,y=n-u*v;e.save(),e.translate(w,y),e.scale(l*g,l*v);const m=he(h.commands||[]),p=new Path2D(m);e.clip(p),e.translate(0-w,0-y),e.setTransform(1,0,0,1,0,0),N(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:s,viewSizeInfo:l,renderContent:()=>{e.globalAlpha=d,function(e,t,i){var o,n;const{pattern:a,viewScaleInfo:r,viewSizeInfo:s}=i,l=[];if(t.detail.background||a){const{x:i,y:h,w:c,h:d,radiusList:f}=fe(t,{viewScaleInfo:r,viewSizeInfo:s});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(y.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=we(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=we(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=o,l&&l.length>0)for(let t=0;t<(null==l?void 0:l.length);t++){const o=l[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(),l&&l.length>0&&e.setTransform(1,0,0,1,0,0)}}(e,t,{pattern:o,viewScaleInfo:s,viewSizeInfo:l}),null==n||n(),function(e,t,i){if(0===t.detail.borderWidth)return;if(!c(t.detail.borderColor))return;const{viewScaleInfo:o}=i,{scale:n}=o;let a=ye.borderColor;!0===c(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:s,borderDash:l,boxSizing:h=ye.boxSizing}=t.detail;let d=0;"number"==typeof r&&(d=r||1);d*=n;let f=[0,0,0,0];if("number"==typeof s){const e=s*n;f=[e,e,e,e]}else Array.isArray(s)&&4===(null==s?void 0:s.length)&&(f=[s[0]*n,s[1]*n,s[2]*n,s[3]*n]);e.strokeStyle=a;let u=[];Array.isArray(l)&&l.length>0&&(u=l.map((e=>Math.ceil(e*n))));let g=0,v=0,w=0,y=0;Array.isArray(r)&&(g=(r[0]||0)*n,v=(r[1]||0)*n,w=(r[2]||0)*n,y=(r[3]||0)*n);if(y||v||g||w){e.lineCap="butt";let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i+=y/2,o+=g/2,n=n-y/2-v/2,a=a-g/2-w/2):"content-box"===h?(i-=y/2,o-=g/2,n=n+y/2+v/2,a=a+g/2+w/2):(i=t.x,o=t.y,n=t.w,a=t.h),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(i-y/2,o),e.lineTo(i+n+v/2,o),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(i+n,o-g/2),e.lineTo(i+n,o+a+w/2),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(i-y/2,o+a),e.lineTo(i+n+v/2,o+a),e.closePath(),e.stroke()),y&&(e.beginPath(),e.lineWidth=y,e.moveTo(i,o-g/2),e.lineTo(i,o+a+w/2),e.closePath(),e.stroke())}else{let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i=t.x+d/2,o=t.y+d/2,n=t.w-d,a=t.h-d):"content-box"===h?(i=t.x-d/2,o=t.y-d/2,n=t.w+d,a=t.h+d):(i=t.x,o=t.y,n=t.w,a=t.h),u.length>0?e.lineCap="butt":e.lineCap="square",n=Math.max(n,1),a=Math.max(a,1),f=f.map((e=>Math.min(e,n/2,a/2))),e.setLineDash(u),e.lineWidth=d,e.beginPath(),e.moveTo(i+f[0],o),e.arcTo(i+n,o,i+n,o+a,f[1]),e.arcTo(i+n,o+a,i,o+a,f[2]),e.arcTo(i,o+a,i,o,f[3]),e.arcTo(i,o,i+n,o,f[0]),e.closePath(),e.stroke()}e.setLineDash([])}(e,t,{viewScaleInfo:s,viewSizeInfo:l}),e.globalAlpha=h}})}function xe(e,t,i){const{detail:o}=t,{viewScaleInfo:n,renderContent:a}=i,{shadowColor:r,shadowOffsetX:s,shadowOffsetY:l,shadowBlur:h}=o;R.number(h)?(e.save(),e.shadowColor=r||ye.shadowColor,e.shadowOffsetX=(s||0)*n.scale,e.shadowOffsetY=(l||0)*n.scale,e.shadowBlur=(h||0)*n.scale,a(),e.restore()):a()}const Se={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function be(e,t,i){var o;if(!0!==(null===(o=null==t?void 0:t.operations)||void 0===o?void 0:o.invisible))try{switch(t.type){case"rect":!function(e,t,i){const{calculator:o,viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:s,y:l,w:h,h:c,angle:d}=(null==o?void 0:o.elementSize(t,n,a))||t,f=Object.assign(Object.assign({},t),{x:s,y:l,w:h,h:c,angle:d});N(e,{x:s,y:l,w:h,h:c,angle:d},(()=>{xe(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{pe(e,f,{originElem:t,calcElemSize:{x:s,y:l,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{}})}})}))}(e,t,i);break;case"circle":!function(e,t,i){const{detail:o,angle:n}=t,{background:a="#000000",borderColor:r="#000000",boxSizing:s,borderWidth:l=0}=o;let h=0;"number"==typeof l&&l>0?h=l:Array.isArray(l)&&"number"==typeof l[0]&&l[0]>0&&(h=l[0]);const{calculator:c,viewScaleInfo:d,viewSizeInfo:f,parentOpacity:u}=i,{x:g,y:v,w:w,h:y}=(null==c?void 0:c.elementSize({x:t.x,y:t.y,w:t.w,h:t.h},d,f))||t,m=Object.assign(Object.assign({},t),{x:g,y:v,w:w,h:y,angle:n});N(e,{x:g,y:v,w:w,h:y,angle:n},(()=>{xe(e,m,{viewScaleInfo:d,viewSizeInfo:f,renderContent:()=>{let t=w/2,i=y/2;const o=g+t,n=v+i;h>0&&("border-box"===s?(t-=h,i-=h):"center-line"===s?(t-=h/2,i-=h/2):(t-=h,i-=h));const c=me(m)*u;if(e.globalAlpha=c,"number"==typeof l&&l>0){const a=l/2+t,s=l/2+i;e.beginPath(),e.strokeStyle=r,e.lineWidth=l,e.circle(o,n,a,s,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath();const f=we(e,a,{viewElementSize:{x:g,y:v,w:w,h:y},viewScaleInfo:d,opacity:e.globalAlpha});e.fillStyle=f,e.circle(o,n,t,i,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=u}})}))}(e,t,i);break;case"text":!function(e,t,i){const{calculator:o,viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:s,y:l,w:h,h:d,angle:f}=(null==o?void 0:o.elementSize(t,n,a))||t,u=Object.assign(Object.assign({},t),{x:s,y:l,w:h,h:d,angle:f});N(e,{x:s,y:l,w:h,h:d,angle:f},(()=>{pe(e,u,{originElem:t,calcElemSize:{x:s,y:l,w:h,h:d,angle:f},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const i=Object.assign(Object.assign({},Se),t.detail),o=(i.fontSize||Se.fontSize)*n.scale,a=i.lineHeight?i.lineHeight*n.scale:o;e.fillStyle=t.detail.color||Se.color,e.textBaseline="top",e.$setFont({fontWeight:i.fontWeight,fontSize:o,fontFamily:i.fontFamily});const r=i.text.replace(/\r\n/gi,"\n"),f=a,u=r.split("\n"),g=[];let v=0;u.forEach(((t,i)=>{let o="";if(t.length>0){for(let n=0;n<t.length&&(e.measureText(o+(t[n]||"")).width<e.$doPixelRatio(h)?o+=t[n]||"":(g.push({text:o,width:e.$undoPixelRatio(e.measureText(o).width)}),o=t[n]||"",v++),!((v+1)*f>d));n++)if(t.length-1===n&&(v+1)*f<d){g.push({text:o,width:e.$undoPixelRatio(e.measureText(o).width)}),i<u.length-1&&v++;break}}else g.push({text:"",width:0})}));let w=0;g.length*f<d&&("top"===t.detail.verticalAlign?w=0:"bottom"===t.detail.verticalAlign?w+=d-g.length*f:w+=(d-g.length*f)/2);{const t=l+w;void 0!==i.textShadowColor&&c(i.textShadowColor)&&(e.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&R.number(i.textShadowOffsetX)&&(e.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&R.number(i.textShadowOffsetY)&&(e.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&R.number(i.textShadowBlur)&&(e.shadowBlur=i.textShadowBlur),g.forEach(((o,n)=>{let a=s;"center"===i.textAlign?a=s+(h-o.width)/2:"right"===i.textAlign&&(a=s+(h-o.width)),e.fillText(o.text,a,t+f*n)}))}}})}))}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{calculator:n,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:s}=i,{x:l,y:h,w:c,h:d,angle:f}=(null==n?void 0:n.elementSize(t,a,r))||t,u=Object.assign(Object.assign({},t),{x:l,y:h,w:c,h:d,angle:f});N(e,{x:l,y:h,w:c,h:d,angle:f},(()=>{xe(e,u,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{pe(e,u,{originElem:t,calcElemSize:{x:l,y:h,w:c,h:d,angle:f},viewScaleInfo:a,viewSizeInfo:r,parentOpacity:s,renderContent:()=>{if(o||i.loader.load(t,i.elementAssets||{}),"image"===t.type&&o){e.globalAlpha=me(t)*s;const{x:i,y:n,w:l,h:h,radiusList:c}=fe(u,{viewScaleInfo:a,viewSizeInfo:r});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+c[0],n),e.arcTo(i+l,n,i+l,n+h,c[1]),e.arcTo(i+l,n+h,i,n+h,c[2]),e.arcTo(i,n+h,i,n,c[3]),e.arcTo(i,n,i+l,n,c[0]),e.closePath(),e.fill(),e.clip(),e.drawImage(o,i,n,l,h),e.globalAlpha=s,e.restore()}}})}})}))}(e,t,i);break;case"svg":!function(e,t,i){const o=i.loader.getContent(t),{calculator:n,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:s}=i,{x:l,y:h,w:c,h:d,angle:f}=(null==n?void 0:n.elementSize(t,a,r))||t;N(e,{x:l,y:h,w:c,h:d,angle:f},(()=>{o||i.loader.load(t,i.elementAssets||{}),"svg"===t.type&&o&&(e.globalAlpha=me(t)*s,e.drawImage(o,l,h,c,d),e.globalAlpha=s)}))}(e,t,i);break;case"html":!function(e,t,i){const o=i.loader.getContent(t),{calculator:n,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:s}=i,{x:l,y:h,w:c,h:d,angle:f}=(null==n?void 0:n.elementSize(t,a,r))||t;N(e,{x:l,y:h,w:c,h:d,angle:f},(()=>{o||i.loader.load(t,i.elementAssets||{}),"html"===t.type&&o&&(e.globalAlpha=me(t)*s,e.drawImage(o,l,h,c,d),e.globalAlpha=s)}))}(e,t,i);break;case"path":!function(e,t,i){const{detail:o}=t,{originX:n,originY:a,originW:r,originH:s}=o,{calculator:l,viewScaleInfo:h,viewSizeInfo:c,parentOpacity:d}=i,{x:f,y:u,w:g,h:v,angle:w}=(null==l?void 0:l.elementSize(t,h,c))||t,y=g/r,m=v/s,p=f-n*y,x=u-a*m,S=h.scale*c.devicePixelRatio,b=Object.assign(Object.assign({},t),{x:f,y:u,w:g,h:v,angle:w});N(e,{x:f,y:u,w:g,h:v,angle:w},(()=>{pe(e,b,{originElem:t,calcElemSize:{x:f,y:u,w:g,h:v,angle:w},viewScaleInfo:h,viewSizeInfo:c,parentOpacity:d,renderContent:()=>{xe(e,b,{viewScaleInfo:h,viewSizeInfo:c,renderContent:()=>{e.save(),e.translate(p,x),e.scale(S*y/h.scale,S*m/h.scale);const t=he(o.commands||[]),i=new Path2D(t);o.fill&&(e.fillStyle=o.fill,e.fill(i)),o.stroke&&0!==o.strokeWidth&&(e.strokeStyle=o.stroke,e.lineWidth=(o.strokeWidth||1)/c.devicePixelRatio,e.lineCap=o.strokeLineCap||"square",e.stroke(i)),e.translate(-p,-x),e.restore()}})}})}))}(e,t,i);break;case"group":{const o=Object.assign(Object.assign({},i.elementAssets||{}),t.detail.assets||{});!function(e,t,i){const{calculator:o,viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:s,y:l,w:h,h:c,angle:d}=(null==o?void 0:o.elementSize({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},n,a))||t,f=Object.assign(Object.assign({},t),{x:s,y:l,w:h,h:c,angle:d});N(e,{x:s,y:l,w:h,h:c,angle:d},(()=>{e.globalAlpha=me(t)*r,xe(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{pe(e,f,{originElem:t,calcElemSize:{x:s,y:l,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const{x:o,y:s,w:l,h:h,radiusList:c}=fe(f,{viewScaleInfo:n,viewSizeInfo:a});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(o+c[0],s),e.arcTo(o+l,s,o+l,s+h,c[1]),e.arcTo(o+l,s+h,o,s+h,c[2]),e.arcTo(o,s+h,o,s,c[3]),e.arcTo(o,s,o+l,s,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:a}=i;for(let o=0;o<t.detail.children.length;o++){let s=t.detail.children[o];if(s=Object.assign(Object.assign({},s),{x:n.x+s.x,y:n.y+s.y}),!0===i.forceDrawAll||(null==a?void 0:a.isElementInView(s,i.viewScaleInfo,i.viewSizeInfo)))try{be(e,s,Object.assign(Object.assign({},i),{parentOpacity:r*me(t)}))}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=r}))}(e,t,Object.assign(Object.assign({},i),{elementAssets:o}));break}}}catch(e){console.error(e)}}const Ae={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};var Ie,Me,ze,Re,Pe,Te,Ce,Ee,We,Oe,je,De=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{l(o.next(e))}catch(e){a(e)}}function s(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))},ke=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 Le=["image","svg","html"],Fe=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:g(n):g(`${f()}-${e.uuid}-${f()}-${f()}`)};class Ye extends D{constructor(){super(),Ie.add(this),Me.set(this,{}),ze.set(this,{}),Re.set(this,{}),ke(this,Ie,"m",Pe).call(this,"image",((e,t)=>De(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 x(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),ke(this,Ie,"m",Pe).call(this,"html",((e,t)=>De(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 b(o,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),ke(this,Ie,"m",Pe).call(this,"svg",((e,t)=>De(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 S(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}}))))}load(e,t){ke(this,Ie,"m",je).call(this,e)||Le.includes(e.type)&&ke(this,Ie,"m",Oe).call(this,e,t)}getContent(e){var t,i;const o=Fe(e);return(null===(i=null===(t=ke(this,Re,"f"))||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return ke(this,Re,"f")}setLoadItemMap(e){!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,Re,e,"f")}}Me=new WeakMap,ze=new WeakMap,Re=new WeakMap,Ie=new WeakSet,Pe=function(e,t){ke(this,Me,"f")[e]=t},Te=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},Ce=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:ke(this,Ie,"m",Te).call(this,e)}},Ee=function(e){const t=Fe(e.element),i=ke(this,Re,"f")[t];i?i.startTime<e.startTime&&(ke(this,Re,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(ke(this,Re,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime})))},We=function(e){const t=Fe(e.element),i=ke(this,Re,"f")[t];i?i.startTime<e.startTime&&(ke(this,Re,"f")[t]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(ke(this,Re,"f")[t]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime})))},Oe=function(e,t){const i=ke(this,Ie,"m",Ce).call(this,e),o=Fe(e);ke(this,ze,"f")[o]=i;const n=ke(this,Me,"f")[e.type];"function"==typeof n&&(i.startTime=Date.now(),n(e,t).then((e=>{i.content=e.content,i.endTime=Date.now(),i.status="load",ke(this,Ie,"m",Ee).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,ke(this,Ie,"m",We).call(this,i)})))},je=function(e){var t;const i=Fe(e),o=null===(t=ke(this,ze,"f"))||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==ke(this,Ie,"m",Te).call(this,e))};var Be,Ge,Ne,Ve,Xe=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},He=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 Ze extends D{constructor(e){super(),Be.add(this),Ge.set(this,void 0),Ne.set(this,new Ye),Xe(this,Ge,e,"f"),He(this,Be,"m",Ve).call(this)}updateOptions(e){Xe(this,Ge,e,"f")}drawData(e,t){const i=He(this,Ne,"f"),{calculator:o}=He(this,Ge,"f"),n=He(this,Ge,"f").viewContext;n.clearRect(0,0,n.canvas.width,n.canvas.height);const a={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height};!function(e,t,i){var o;const{elements:n=[]}=t,{parentOpacity:a}=i;for(let t=0;t<n.length;t++){const r=n[t],s=Object.assign(Object.assign({},r),{detail:Object.assign(Object.assign({},Ae),null==r?void 0:r.detail)});if(!0===i.forceDrawAll||(null===(o=i.calculator)||void 0===o?void 0:o.isElementInView(s,i.viewScaleInfo,i.viewSizeInfo)))try{be(e,s,Object.assign(Object.assign({},i),{parentOpacity:a}))}catch(e){console.error(e)}}}(n,e,Object.assign({loader:i,calculator:o,parentElementSize:a,elementAssets:e.assets,parentOpacity:1},t))}scale(e){const{sharer:t}=He(this,Ge,"f");if(!t)return;const{data:i,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r,width:s,height:l,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:s,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){He(this,Ne,"f").setLoadItemMap(e)}getLoadItemMap(){return He(this,Ne,"f").getLoadItemMap()}}Ge=new WeakMap,Ne=new WeakMap,Be=new WeakSet,Ve=function(){const e=He(this,Ne,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(()=>{}))};class Qe{constructor(e){this._opts=e}elementSize(e,t,i){return q(e,{viewScaleInfo:t,viewSizeInfo:i})}isElementInView(e,t,i){return function(e,t){const{viewSizeInfo:i,viewScaleInfo:o}=t,{width:n,height:a}=i,{angle:r}=e,{x:s,y:l,w:h,h:c}=q(e,{viewScaleInfo:o,viewSizeInfo:i}),d=$({x:s,y:l,w:h,h:c,angle:r}),f={x:0,y:0,w:n,h:a},u=Math.min(d[0].x,d[1].x,d[2].x,d[3].x),g=Math.min(d[0].y,d[1].y,d[2].y,d[3].y);return function(e,t){const i=e.x,o=e.y,n=e.x+e.w,a=e.y+e.h,r=t.x,s=t.y,l=t.x+t.w,h=t.y+t.h;return i<=l&&n>=r&&o<=h&&a>=s}(f,{x:u,y:g,w:Math.max(d[0].x,d[1].x,d[2].x,d[3].x)-u,h:Math.max(d[0].y,d[1].y,d[2].y,d[3].y)-g})}(e,{viewScaleInfo:t,viewSizeInfo:i})}isPointInElement(e,t,i,o){return ie(e,{context2d:this._opts.viewContext,element:t,viewScaleInfo:i,viewSizeInfo:o})}getPointElement(e,t){const i=this._opts.viewContext;return function(e,t){var i,o,n;const{context2d:a,data:r,viewScaleInfo:s,viewSizeInfo:l,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(ie(e,{context2d:a,element:{x:n+u.x,y:r+u.y,w:u.w,h:u.h,angle:d+(u.angle||0)},viewScaleInfo:s,viewSizeInfo:l})){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)&&ie(e,{context2d:a,element:i,viewScaleInfo:s,viewSizeInfo:l})){c.index=t,c.element=i;break}}return c}(e,Object.assign(Object.assign({},t),{context2d:i}))}}function $e(e){return e>0||e<0||0===e}class _e extends D{constructor(e){super();const t=new L({defaultStorage:{hasPointDown:!1,prevClickPoint:null}});this._store=t,this._opts=e,this._init()}_init(){const e=window;e.addEventListener("mousemove",(e=>{if(!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this._isVaildPoint(t)&&this.trigger("hover",{point:t})})),e.addEventListener("mousedown",(e=>{if(!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this._isVaildPoint(t)&&(this._store.set("hasPointDown",!0),this.trigger("pointStart",{point:t}))})),e.addEventListener("mousemove",(e=>{if(!this._isInTarget(e))return;e.preventDefault(),e.stopPropagation();const t=this._getPoint(e);this._isVaildPoint(t)?!0===this._store.get("hasPointDown")&&this.trigger("pointMove",{point:t}):this._store.get("hasPointDown")&&(this.trigger("pointLeave",{point:t}),this._store.set("hasPointDown",!1))})),e.addEventListener("mouseup",(e=>{if(this._store.set("hasPointDown",!1),!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this.trigger("pointEnd",{point:t})})),e.addEventListener("mouseleave",(e=>{if(this._store.set("hasPointDown",!1),!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this.trigger("pointLeave",{point:t})})),e.addEventListener("wheel",(e=>{if(!this._isInTarget(e))return;const t=this._getPoint(e);if(!this._isVaildPoint(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})}),{passive:!1}),e.addEventListener("click",(e=>{if(!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);if(!this._isVaildPoint(t))return;const i=Date.now(),o=this._store.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}):this._store.set("prevClickPoint",t)})),e.addEventListener("contextmenu",(e=>{if(!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this._isVaildPoint(t)}))}_isInTarget(e){return e.target===this._opts.boardContent.boardContext.canvas}_getPoint(e){const t=this._opts.boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top,t:Date.now()}}_isVaildPoint(e){const t=this._opts.sharer.getActiveViewSizeInfo(),{width:i,height:o}=t;return!!($e(e.x)&&$e(e.y)&&e.x<=i&&e.y<=o)}}const Ue={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0};class Je{constructor(){const e=new L({defaultStorage:Ue}),t=new L({defaultStorage:{}});this._activeStore=e,this._sharedStore=t}getActiveStorage(e){return this._activeStore.get(e)}setActiveStorage(e,t){return this._activeStore.set(e,t)}getActiveStoreSnapshot(){return this._activeStore.getSnapshot()}getSharedStorage(e){return this._sharedStore.get(e)}setSharedStorage(e,t){return this._sharedStore.set(e,t)}getSharedStoreSnapshot(){return this._sharedStore.getSnapshot()}getActiveViewScaleInfo(){return{scale:this._activeStore.get("scale"),offsetTop:this._activeStore.get("offsetTop"),offsetBottom:this._activeStore.get("offsetBottom"),offsetLeft:this._activeStore.get("offsetLeft"),offsetRight:this._activeStore.get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:n,offsetRight:a}=e;this._activeStore.set("scale",t),this._activeStore.set("offsetTop",i),this._activeStore.set("offsetBottom",o),this._activeStore.set("offsetLeft",n),this._activeStore.set("offsetRight",a)}setActiveViewSizeInfo(e){this._activeStore.set("width",e.width),this._activeStore.set("height",e.height),this._activeStore.set("devicePixelRatio",e.devicePixelRatio),this._activeStore.set("contextWidth",e.contextWidth),this._activeStore.set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:this._activeStore.get("width"),height:this._activeStore.get("height"),devicePixelRatio:this._activeStore.get("devicePixelRatio"),contextWidth:this._activeStore.get("contextWidth"),contextHeight:this._activeStore.get("contextHeight")}}}const{requestAnimationFrame:Ke}=window;class qe extends D{constructor(e){super(),this._drawFrameSnapshotQueue=[],this._drawFrameStatus="FREE",this._opts=e,this._init()}_init(){const{renderer:e}=this._opts;e.on("load",(()=>{this.drawFrame()}))}_drawAnimationFrame(){if("DRAWING"===this._drawFrameStatus||0===this._drawFrameSnapshotQueue.length)return;this._drawFrameStatus="DRAWING";const e=this._drawFrameSnapshotQueue.shift(),{renderer:t,boardContent:i,beforeDrawFrame:o,afterDrawFrame:n}=this._opts;if(e){const{scale:a,offsetTop:r,offsetBottom:s,offsetLeft:l,offsetRight:h,width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g}=e.activeStore;(null==e?void 0:e.activeStore.data)&&t.drawData(e.activeStore.data,{viewScaleInfo:{scale:a,offsetTop:r,offsetBottom:s,offsetLeft:l,offsetRight:h},viewSizeInfo:{width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g}}),o({snapshot:e}),i.drawView(),n({snapshot:e})}0!==this._drawFrameSnapshotQueue.length?(this._drawFrameStatus="DRAWING")&&Ke((()=>{this._drawAnimationFrame()})):this._drawFrameStatus="COMPLETE"}drawFrame(){const{sharer:e}=this._opts,t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();this._drawFrameSnapshotQueue.push({activeStore:t,sharedStore:i}),this._drawAnimationFrame()}scale(e){const{scale:t,point:i}=e,{sharer:o}=this._opts,{moveX:n,moveY:a}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:n,offsetTop:a}=o,r=t/o.scale,s=i.x,l=i.y;return{moveX:s-s*r+(n*r-n),moveY:l-l*r+(a*r-a)}}({scale:t,point:i,viewScaleInfo:o.getActiveViewScaleInfo(),viewSizeInfo:o.getActiveViewSizeInfo()});return o.setActiveStorage("scale",t),{moveX:n,moveY:a}}scroll(e){const{sharer:t}=this._opts,i=t.getActiveViewScaleInfo(),{moveX:o,moveY:n}=e,a=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:n}=e,{scale:a}=o,{width:r,height:s,contextWidth:l,contextHeight:h}=n;let c=o.offsetLeft,d=o.offsetRight,f=o.offsetTop,u=o.offsetBottom;return c+=t,f+=i,d=r-(l*a+c),u=s-(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(a),a}updateViewScaleInfo(e){const{sharer:t}=this._opts,i=function(e,t){const{scale:i,offsetX:o,offsetY:n}=e,{viewSizeInfo:a}=t,{width:r,height:s,contextWidth:l,contextHeight:h}=a,c=0-o*i,d=0-n*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:r-(l*i+c/i),offsetBottom:s-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),i}resize(e={}){const{sharer:t}=this._opts,i=t.getActiveViewSizeInfo(),o=Object.assign(Object.assign({},i),e),{width:n,height:a,devicePixelRatio:r}=o,{underContext:s,boardContext:l,helperContext:h,viewContext:c}=this._opts.boardContent;return l.canvas.width=n*r,l.canvas.height=a*r,l.canvas.style.width=`${n}px`,l.canvas.style.height=`${a}px`,s.canvas.width=n*r,s.canvas.height=a*r,h.canvas.width=n*r,h.canvas.height=a*r,c.canvas.width=n*r,c.canvas.height=a*r,t.setActiveViewSizeInfo(o),o}}var et,tt,it,ot,nt,at,rt,st,lt,ht,ct,dt,ft,ut,gt,vt,wt,yt,mt,pt,xt,St,bt,At,It,Mt,zt=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},Rt=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 Pt{constructor(e){et.add(this),tt.set(this,void 0),it.set(this,new WeakMap),ot.set(this,[]),nt.set(this,[]),at.set(this,void 0),rt.set(this,void 0),st.set(this,void 0),lt.set(this,void 0),ht.set(this,void 0),ct.set(this,new D);const{boardContent:t}=e,i=new Je,o=new Qe({viewContext:t.viewContext}),n=new _e({boardContent:t,sharer:i}),a=new Ze({viewContext:t.viewContext,sharer:i,calculator:o});zt(this,tt,e,"f"),zt(this,st,i,"f"),zt(this,at,n,"f"),zt(this,rt,a,"f"),zt(this,ht,o,"f"),zt(this,lt,new qe({boardContent:e.boardContent,sharer:i,renderer:a,calculator:Rt(this,ht,"f"),beforeDrawFrame:e=>{Rt(this,et,"m",At).call(this,e)},afterDrawFrame:e=>{Rt(this,et,"m",It).call(this,e)}}),"f"),Rt(this,et,"m",dt).call(this),Rt(this,et,"m",Mt).call(this)}getSharer(){return Rt(this,st,"f")}getViewer(){return Rt(this,lt,"f")}getRenderer(){return Rt(this,rt,"f")}setData(e){const t=Rt(this,st,"f");Rt(this,st,"f").setActiveStorage("data",e);const i=t.getActiveViewSizeInfo(),o=K(e.elements,{viewWidth:i.width,viewHeight:i.height,extend:!0});Rt(this,lt,"f").drawFrame();const n=Object.assign(Object.assign({},i),o);return Rt(this,st,"f").setActiveViewSizeInfo(n),{viewSizeInfo:n}}getData(){const{data:e}=Rt(this,st,"f").getActiveStoreSnapshot();return e}use(e){var t,i,o;if(Rt(this,it,"f").has(e)){const o=Rt(this,it,"f").get(e);if(o)return null===(i=(t=o.middlewareObject).use)||void 0===i||i.call(t),o.status="enable",Rt(this,it,"f").set(e,o),void Rt(this,et,"m",Mt).call(this)}const{boardContent:n,container:a}=Rt(this,tt,"f"),r=e({boardContent:n,sharer:Rt(this,st,"f"),viewer:Rt(this,lt,"f"),calculator:Rt(this,ht,"f"),eventHub:Rt(this,ct,"f"),container:a});null===(o=r.use)||void 0===o||o.call(r),Rt(this,ot,"f").push(e),Rt(this,nt,"f").push(r),Rt(this,it,"f").set(e,{status:"enable",middlewareObject:r}),Rt(this,et,"m",Mt).call(this)}disuse(e){var t,i;const o=Rt(this,it,"f").get(e);o&&(null===(i=(t=o.middlewareObject).disuse)||void 0===i||i.call(t),o.status="disable",Rt(this,it,"f").set(e,o),Rt(this,et,"m",Mt).call(this))}scale(e){const t=Rt(this,lt,"f"),{moveX:i,moveY:o}=t.scale(e);t.scroll({moveX:i,moveY:o})}scroll(e){return Rt(this,lt,"f").scroll(e)}updateViewScaleInfo(e){return Rt(this,lt,"f").updateViewScaleInfo(e)}resize(e){const t=Rt(this,lt,"f").resize(e),{width:i,height:o,devicePixelRatio:n}=e,{boardContent:a}=Rt(this,tt,"f");a.viewContext.$resize({width:i,height:o,devicePixelRatio:n}),a.helperContext.$resize({width:i,height:o,devicePixelRatio:n}),a.boardContext.$resize({width:i,height:o,devicePixelRatio:n}),a.underContext.$resize({width:i,height:o,devicePixelRatio:n}),Rt(this,lt,"f").drawFrame(),Rt(this,at,"f").trigger("resize",t),Rt(this,st,"f").setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=Rt(this,tt,"f"),{underContext:t,helperContext: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),Rt(this,et,"m",bt).call(this)}getEventHub(){return Rt(this,ct,"f")}}tt=new WeakMap,it=new WeakMap,ot=new WeakMap,nt=new WeakMap,at=new WeakMap,rt=new WeakMap,st=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,et=new WeakSet,dt=function(){Rt(this,at,"f").on("pointStart",Rt(this,et,"m",ft).bind(this)),Rt(this,at,"f").on("pointEnd",Rt(this,et,"m",ut).bind(this)),Rt(this,at,"f").on("pointMove",h((e=>{Rt(this,et,"m",gt).call(this,e)}),10)),Rt(this,at,"f").on("hover",h((e=>{Rt(this,et,"m",vt).call(this,e)}),10)),Rt(this,at,"f").on("wheel",h((e=>{Rt(this,et,"m",yt).call(this,e)}),10)),Rt(this,at,"f").on("wheelScale",h((e=>{Rt(this,et,"m",mt).call(this,e)}),10)),Rt(this,at,"f").on("scrollX",Rt(this,et,"m",pt).bind(this)),Rt(this,at,"f").on("scrollY",Rt(this,et,"m",xt).bind(this)),Rt(this,at,"f").on("resize",Rt(this,et,"m",St).bind(this)),Rt(this,at,"f").on("doubleClick",Rt(this,et,"m",wt).bind(this))},ft=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointStart)||void 0===t?void 0:t.call(o,e)))return}},ut=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointEnd)||void 0===t?void 0:t.call(o,e)))return}},gt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointMove)||void 0===t?void 0:t.call(o,e)))return}},vt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.hover)||void 0===t?void 0:t.call(o,e)))return}},wt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.doubleClick)||void 0===t?void 0:t.call(o,e)))return}},yt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheel)||void 0===t?void 0:t.call(o,e)))return}},mt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheelScale)||void 0===t?void 0:t.call(o,e)))return}},pt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollX)||void 0===t?void 0:t.call(o,e)))return}},xt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollY)||void 0===t?void 0:t.call(o,e)))return}},St=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.resize)||void 0===t?void 0:t.call(o,e)))return}},bt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.clear)||void 0===t?void 0:t.call(o,e)))return}},At=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.beforeDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},It=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.afterDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},Mt=function(){const e=[],t=Rt(this,it,"f");Rt(this,ot,"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)})),zt(this,nt,e,"f")};const Tt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJl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FSX18/lg68cuXKLUAaGxs3vkB7e/u3wHHgCQpUdnpTqdQvesJgMDisUVevXh3Xry9fvnxTv66qqprQ/cfHx/vVNj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==";class Ct{constructor(e,t){this._cursorType=null,this._resizeCursorBaseImage=null,this._cursorImageMap={auto:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbn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npY+oij35km0qwmjwqAU8ISM9hIwBeQA17KsG9PT07+1gxsZGdmgdqW+BjwLDAAPoo4ALU+W9arVwWoIpXp9kouKZpPAO8AwQCwW+2d0dLQ0OTkZSafT0UKhUJ6bm9t2HKeysrIS3tra0g7+KvABUJC0g5rrJdRcbLpImtleRzYashc1P2OSXwbebDVykX3gW+Ab1AHqhuQ3pe6AJlFMO0CoPROHDcio5I8DL1A9C8dQbmod+APYAK4DvwjQnsDdErgyVTfTEaCG1GFYGHXG7TVSo2OkdvhlAflXoHSuNdfStFqaRhEi2kfdprrj6M5LAt0I8EDaaMdflPal48CB95hMr3Bt8h4jD0kyL5E0pN6dysZzW7N2AqjbmhdIZjJvufTOpE19x3g+9s1XJ/ck5tVbfdhu+rxDfLiSO+lFToCjZwrXyH2/0Lwv95z8B1jAqXmDnj4YAAAAAElFTkSuQmCC","rotate-0":Tt},this._container=e,this._eventHub=t.eventHub,this._init(),this._loadResizeCursorBaseImage()}_init(){const{_eventHub:e}=this;this._resetCursor("auto"),e.on("cursor",(e=>{var t;"over-element"!==e.type&&e.type?"string"==typeof e.type&&(null==(t=e.type)?void 0:t.startsWith("resize-"))?this._setCursorResize(e):"drag-default"===e.type?this._resetCursor("drag-default"):"drag-active"===e.type?this._resetCursor("drag-active"):this._resetCursor("auto"):this._resetCursor("auto")}))}_loadResizeCursorBaseImage(){x(Tt).then((e=>{this._resizeCursorBaseImage=e})).catch((e=>{console.error(e)}))}_resetCursor(e){if(this._cursorType===e)return;this._cursorType=e;const t=this._cursorImageMap[this._cursorType]||this._cursorImageMap.auto;let i=0,o=0;e.startsWith("rotate-")&&this._cursorImageMap[this._cursorType]&&(i=10,o=10),this._container.style.cursor=`image-set(url(${t})2x) ${i} ${o}, auto`}_setCursorResize(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+=U((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+=U(e.angle||0)})),i=U(i);const o=this._appendRotateResizeImage(i);this._resetCursor(o)}_appendRotateResizeImage(e){const t=`rotate-${e}`;if(!this._cursorImageMap[t]){const i=this._resizeCursorBaseImage;if(i){const o=document.createElement("canvas"),n=i.width,a=i.height,r={x:n/2,y:a/2};o.width=n,o.height=a;const s=o.getContext("2d"),l=B(e);s.translate(r.x,r.y),s.rotate(l),s.translate(-r.x,-r.y),s.drawImage(i,0,0,n,a),s.translate(r.x,r.y),s.rotate(-l),s.translate(-r.x,-r.y);const h=o.toDataURL("image/png");this._cursorImageMap[t]=h}}return t}}const Et="SELECT",Wt=Symbol(`${Et}_actionType`),Ot=Symbol(`${Et}_resizeType`),jt=Symbol(`${Et}_areaStart`),Dt=Symbol(`${Et}_areaEnd`),kt=Symbol(`${Et}_hoverElement`),Lt=Symbol(`${Et}_hoverElementVertexes`),Ft=Symbol(`${Et}_selectedElementList`),Yt=Symbol(`${Et}_selectedElementListVertexes`),Bt=Symbol(`${Et}_selectedElementController`),Gt=Symbol(`${Et}_groupQueue`),Nt=Symbol(`${Et}_groupQueueVertexesList`),Vt="#1973ba";function Xt(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 Ht(e,t,i){if(!t)return;const o={borderColor:Vt,borderWidth:1,background:"transparent",lineDash:[]};Xt(e,te(t,i),o)}function Zt(e,t,i){if(!t)return;const{elementWrapper:o,topLeft:n,topRight:a,bottomLeft:r,bottomRight:s}=t,l={borderColor:Vt,borderWidth:2,background:"transparent",lineDash:[]},h={...l,borderWidth:4,background:"#FFFFFF"};Xt(e,te(o,i),l),Xt(e,te(n.vertexes,i),h),Xt(e,te(a.vertexes,i),h),Xt(e,te(r.vertexes,i),h),Xt(e,te(s.vertexes,i),h)}function Qt(e){return e*Math.PI/180}function $t(e,t){return Math.sqrt(e*e+t*t)}function _t(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Ut(e,t){const{ctx:i,viewScaleInfo:o,viewSizeInfo:n,vertexes:a}=t,r=ee(a[0],{viewScaleInfo:o,viewSizeInfo:n}),s=ee(a[1],{viewScaleInfo:o,viewSizeInfo:n}),l=ee(a[2],{viewScaleInfo:o,viewSizeInfo:n}),h=ee(a[3],{viewScaleInfo:o,viewSizeInfo:n});return i.beginPath(),i.moveTo(r.x,r.y),i.lineTo(s.x,s.y),i.lineTo(l.x,l.y),i.lineTo(h.x,h.y),i.lineTo(r.x,r.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function Jt(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=ae(a),s=r[r.length-1];return!!s&&Ut(e,{ctx:i,vertexes:s,viewScaleInfo:o,viewSizeInfo:n})}function Kt(e,t){var i,o,n;const a={type:null,elements:[],elementVertexesList:[],groupQueue:[],groupQueueVertexesList:[]},{ctx:r,data:s,calculator:l,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:s,topRight:l,bottomLeft:f,bottomRight:v}=g,w=[t,i,o,n,s,l,f,v];for(let t=0;t<w.length;t++){const i=w[t];if(Ut(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=re(o,{groupQueue:u});if(n&&Ut(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(s){const{index:t,element:i}=l.getPointElement(e,{data:s,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 qt(e,t){var i;if(!Array.isArray(e))return null;const o={x:0,y:0,w:0,h:0},{calculator:n,viewScaleInfo:a,viewSizeInfo:r}=t;let s=null;for(let t=0;t<e.length;t++){const l=e[t];if(null==(i=null==l?void 0:l.operations)?void 0:i.invisible)continue;const h=n.elementSize(l,a,r);if(h.angle&&(h.angle>0||h.angle<0)){const e=$(h);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];h.x=Math.min(...t),h.y=Math.min(...i),h.w=Math.abs(Math.max(...t)-Math.min(...t)),h.h=Math.abs(Math.max(...i)-Math.min(...i))}}if(s){const e=Math.min(h.x,o.x),t=Math.min(h.y,o.y),i=Math.max(h.x+h.w,o.x+o.w),n=Math.max(h.y+h.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=h.x,o.y=h.y,o.w=h.w,o.h=h.h;s=h}return o}const ei="@middleware/text-edit",ti={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"},ii="@middleware/select",oi="SCROLL",ni=Symbol(`${oi}_xThumbRect`),ai=Symbol(`${oi}_yThumbRect`),ri=Symbol(`${oi}_prevPoint`),si=Symbol(`${oi}_activePoint`),li=Symbol(`${oi}_activeThumbType`),hi=16,ci=.36,di={width:12,thumbColor:"#000000AA",scrollBarColor:"#FFFFFF60",showScrollBar:!1};function fi(e,t,i){const o=e,{x:n,y:a,w:r,h:s}=i;return o.beginPath(),o.rect(n,a,r,s),o.closePath(),!!o.isPointInPath(t.x,t.y)}function ui(e,t){let{x:i,y:o,h:n,w:a}=t;e.save(),e.shadowColor="#FFFFFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=1;{const{color:r,axis:s}=t;"X"===s?(o=o+n/4+0,n/=2):"Y"===s&&(i=i+a/4+0,a/=2);let l=t.r;l=Math.min(l,a/2,n/2),(a<2*l||n<2*l)&&(l=0),e.globalAlpha=ci,e.beginPath(),e.moveTo(i+l,o),e.arcTo(i+a,o,i+a,o+n,l),e.arcTo(i+a,o+n,i,o+n,l),e.arcTo(i,o+n,i,o,l),e.arcTo(i,o,i+a,o,l),e.closePath(),e.fillStyle=r,e.fill(),e.globalAlpha=1,e.beginPath(),e.lineWidth=1,e.strokeStyle=r,e.setLineDash([]),e.moveTo(i+l,o),e.arcTo(i+a,o,i+a,o+n,l),e.arcTo(i+a,o+n,i,o+n,l),e.arcTo(i,o+n,i,o,l),e.arcTo(i,o,i+a,o,l),e.closePath(),e.stroke()}e.restore()}function gi(e,t){const i=e,{viewScaleInfo:o,viewSizeInfo:n,scrollInfo:a}=t,{activeThumbType:r,prevPoint:s,activePoint:l}=a,h=function(e,t){const{width:i,height:o}=t,{offsetTop:n,offsetBottom:a,offsetLeft:r,offsetRight:s}=e,l=2.5*hi,h=hi;let c=0,d=0;c=Math.max(l,i-2*h-(Math.abs(r)+Math.abs(s))),c>=i&&(c=i),d=Math.max(l,o-2*h-(Math.abs(n)+Math.abs(a))),d>=o&&(d=o);const f=h;let u=f;r>0?u=f:s>0?u=i-c-h:r<=0&&c>0&&(0!==r||0!==s)&&(u=f+(i-c)*Math.abs(r)/(Math.abs(r)+Math.abs(s)),u=Math.min(Math.max(0,u-f),i-c));const g=h;let v=g;n>0?v=g:a>0?v=o-d-h:n<=0&&d>0&&(0!==n||0!==a)&&(v=g+(o-d)*Math.abs(n)/(Math.abs(n)+Math.abs(a)),v=Math.min(Math.max(0,v-g),o-d));const w={x:u,y:o-h,w:c,h:h},y={x:i-h,y:v,w:h,h:d};return{lineSize:h,xSize:c,ySize:d,translateY:v,translateX:u,thumbColor:di.thumbColor,scrollBarColor:di.scrollBarColor,xThumbRect:w,yThumbRect:y}}(o,n);let c={...h.xThumbRect},d={...h.yThumbRect};return r&&s&&l&&("X"===r&&a.xThumbRect?(c={...a.xThumbRect},c.x=c.x+(l.x-s.x)):"Y"===r&&a.yThumbRect&&(d={...a.yThumbRect},d.y=d.y+(l.y-s.y))),ui(i,{axis:"X",...c,r:h.lineSize/2,color:h.thumbColor}),ui(i,{axis:"Y",...d,r:h.lineSize/2,color:h.thumbColor}),i.globalAlpha=1,{xThumbRect:c,yThumbRect:d}}function vi(e,t){const{snapshot:i}=t,o=Y(i),n=F(i),a=function(e){const{sharedStore:t}=e;return{activePoint:t[si]||null,prevPoint:t[ri]||null,activeThumbType:t[li]||null,xThumbRect:t[ni]||null,yThumbRect:t[ai]||null}}(i),{xThumbRect:r,yThumbRect:s}=gi(e,{viewSizeInfo:o,viewScaleInfo:n,scrollInfo:a});return{xThumbRect:r,yThumbRect:s}}const wi="@middleware/scale",yi=16,mi="#000000",pi="#00000080",xi="monospace",Si="#AAAAAA20",bi="#AAAAAA40";function Ai(e){const{scale:t,viewLength:i,viewOffset:o}=e,n=[];let a=10;a=ce(a/t,{decimalPlaces:0}),a=Math.max(10,Math.min(a,1e3));const r=10*a,s=5*a;let l=0;const h=a*t,c=0-o,d=c%h,f=(c-d+h)/t,u=h-d+0;for(;u+l*h<i;){const e=ce(f+l*a,{decimalPlaces:0}),t={num:e,position:ce(u+l*h,{decimalPlaces:0}),showNum:e%r==0,isKeyNum:e%r==0,isSubKeyNum:e%s==0};n.push(t),l++}return n}const Ii="@middleware/show-ruler",Mi=Symbol("DRAG_prevPoint");return t=new WeakMap,i=new WeakMap,o=new WeakSet,n=function(){r(this,i).style.position="relative"},e.Core=class{constructor(e,r){s(this,o),s(this,t,void 0),s(this,i,void 0);const{devicePixelRatio:h=1,width:c,height:d}=r;l(this,i,e);const f=document.createElement("canvas");var u,g,v;(u=this,g=o,v=n,a(u,g,"access private method"),v).call(this),e.appendChild(f);const w=function(e,t){const{width:i,height:o,devicePixelRatio:n,offscreen:a}=t,r={width:i,height:o,devicePixelRatio:n};if(!0===a){const t=e.getContext("2d"),i=j(r),o=j(r),n=j(r),a=O(Object.assign({ctx:t},r)),s=()=>{const{width:e,height:t}=i.$getSize();a.clearRect(0,0,e,t),a.drawImage(n.canvas,0,0,e,t),a.drawImage(i.canvas,0,0,e,t),a.drawImage(o.canvas,0,0,e,t),n.clearRect(0,0,e,t),i.clearRect(0,0,e,t),o.clearRect(0,0,e,t)};return{underContext:n,viewContext:i,helperContext:o,boardContext:a,drawView:s}}{const t=e.getContext("2d"),n=O(r),a=O(r),s=O(r),l=O(Object.assign({ctx:t},r)),h=()=>{l.clearRect(0,0,i,o),l.drawImage(s.canvas,0,0,i,o),l.drawImage(n.canvas,0,0,i,o),l.drawImage(a.canvas,0,0,i,o),s.clearRect(0,0,i,o),n.clearRect(0,0,i,o),a.clearRect(0,0,i,o)};return{underContext:s,viewContext:n,helperContext:a,boardContext:l,drawView:h}}}(f,{width:c,height:d,devicePixelRatio:h,offscreen:!0}),y=new Pt({boardContent:w,container:e}),m=y.getSharer();m.setActiveViewSizeInfo({width:c,height:d,devicePixelRatio:h,contextWidth:c,contextHeight:d}),l(this,t,y),this.resize(m.getActiveViewSizeInfo());const p=y.getEventHub();new Ct(e,{eventHub:p})}use(e){r(this,t).use(e)}disuse(e){r(this,t).disuse(e)}setData(e){J((null==e?void 0:e.elements)||[]),r(this,t).setData(e)}getData(){return r(this,t).getData()}scale(e){r(this,t).scale(e);r(this,t).getViewer().drawFrame()}resize(e){const i=r(this,t),o=i.getSharer().getActiveViewSizeInfo();i.resize({...o,...e})}clear(){r(this,t).clear()}on(e,i){r(this,t).getEventHub().on(e,i)}off(e,i){r(this,t).getEventHub().off(e,i)}trigger(e,i){r(this,t).getEventHub().trigger(e,i)}getViewInfo(){const e=r(this,t).getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){r(this,t).getViewer().drawFrame()}setViewScale(e){r(this,t).updateViewScaleInfo(e)}getLoadItemMap(){return r(this,t).getRenderer().getLoadItemMap()}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:o}=e;let n=!1;return{hover(){!0!==n&&t.trigger("cursor",{type:"drag-default"})},pointStart(e){const{point:o}=e;i.setSharedStorage(Mi,o),n=!0,t.trigger("cursor",{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(Mi);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(Mi,t)},pointEnd(){n=!1,i.setSharedStorage(Mi,null),t.trigger("cursor",{type:"drag-default"})}}},e.MiddlewareRuler=e=>{const{boardContent:t,viewer:i,eventHub:o}=e,{helperContext:n,underContext:a}=t;let r=!0,s=!0;const l=e=>{"boolean"==typeof(null==e?void 0:e.show)&&(r=e.show),"boolean"==typeof(null==e?void 0:e.showGrid)&&(s=e.showGrid),"boolean"!=typeof(null==e?void 0:e.show)&&"boolean"!=typeof(null==e?void 0:e.showGrid)||i.drawFrame()};return{use(){o.on(Ii,l)},disuse(){o.off(Ii,l)},beforeDrawFrame:({snapshot:e})=>{if(!0===r){const t=F(e),i=Y(e);!function(e,t){const{viewSizeInfo:i}=t,{width:o,height:n}=i;e.beginPath(),e.moveTo(0,0),e.lineTo(o+1,0),e.lineTo(o+1,yi),e.lineTo(yi,yi),e.lineTo(yi,n+1),e.lineTo(0,n+1),e.lineTo(0,0),e.closePath(),e.fillStyle="#FFFFFFA8",e.fill(),e.lineWidth=1,e.setLineDash([]),e.strokeStyle="#00000080",e.stroke()}(n,{viewScaleInfo:t,viewSizeInfo:i});const o=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:n}=t,{width:a}=i;return Ai({axis:"X",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i}=t;for(let t=0;t<i.length;t++){const o=i[t];o.position<yi||(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=mi,e.stroke(),o.isKeyNum&&(e.fillStyle=pi,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:xi}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(n,{scaleList:o});const r=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n}=t,{height:a}=i;return Ai({axis:"Y",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i}=t,o=3.2;for(let t=0;t<i.length;t++){const n=i[t];if(!(n.position<yi)&&(e.beginPath(),e.moveTo(16,n.position),e.lineTo(n.isKeyNum?3.2:n.isSubKeyNum?6.4:12.8,n.position),e.closePath(),e.fillStyle=mi,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===n.showNum)){const t=o,i=n.position+o,a=`${n.num}`;G(e,-90,{x:t,y:i},(()=>{e.fillStyle=pi,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:xi}),e.fillText(a,13.2,n.position+o)}))}}}(n,{scaleList:r}),!0===s&&function(e,t){const{xList:i,yList:o,viewSizeInfo:n}=t,{width:a,height:r}=n;for(let t=0;t<i.length;t++){const o=i[t];e.beginPath(),e.moveTo(o.position,0),e.lineTo(o.position,r),!0===o.isKeyNum||!0===o.isSubKeyNum?e.strokeStyle=bi:e.strokeStyle=Si,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(a,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=bi:e.strokeStyle=Si,e.lineWidth=1,e.closePath(),e.stroke()}}(a,{xList:o,yList:r,viewScaleInfo:t,viewSizeInfo:i})}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:o}=e;return{wheelScale(e){const{deltaY:n,point:a}=e,{scale:r}=i.getActiveViewScaleInfo();let s=r;if(n<0?s=1.1*r:n>0&&(s=.9*r),s<.05||s>50)return;const{moveX:l,moveY:h}=t.scale({scale:s,point:a});t.scroll({moveX:l,moveY:h}),t.drawFrame();const c=ce(r);o.trigger(wi,{scale:c})}}},e.MiddlewareScroller=e=>{const{viewer:t,boardContent:i,sharer:o}=e,{helperContext:n}=i;o.setSharedStorage(ni,null),o.setSharedStorage(ai,null);const a=()=>{o.setSharedStorage(ri,null),o.setSharedStorage(si,null),o.setSharedStorage(li,null)};a();const r=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:a}=i;return n&&fi(e,t,n)?o="X":a&&fi(e,t,a)&&(o="Y"),o}(n,e,{xThumbRect:o.getSharedStorage(ni),yThumbRect:o.getSharedStorage(ai)});return{wheel:e=>{t.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),t.drawFrame()},pointStart:e=>{const{point:t}=e,i=r(t);if("X"===i||"Y"===i)return o.setSharedStorage(li,i),o.setSharedStorage(ri,t),!1},pointMove:e=>{const{point:i}=e,n=o.getSharedStorage(li);if("X"===n||"Y"===n)return o.setSharedStorage(si,i),"X"===n?(e=>{const i=o.getSharedStorage(ri);if(i){const{offsetLeft:n,offsetRight:a}=o.getActiveViewScaleInfo(),{width:r}=o.getActiveViewSizeInfo(),s=-(e.x-i.x)*(r+Math.abs(n)+Math.abs(a))/r;t.scroll({moveX:s}),t.drawFrame()}})(i):"Y"===n&&(e=>{const i=o.getSharedStorage(ri);if(i){const{offsetTop:n,offsetBottom:a}=o.getActiveViewScaleInfo(),{height:r}=o.getActiveViewSizeInfo(),s=-(e.y-i.y)*(r+Math.abs(n)+Math.abs(a))/r;t.scroll({moveY:s}),t.drawFrame()}})(i),o.setSharedStorage(ri,i),!1},pointEnd:()=>{const e=o.getSharedStorage(li);if(a(),"X"===e||"Y"===e)return t.scroll({moveX:0,moveY:0}),t.drawFrame(),!1},beforeDrawFrame({snapshot:e}){const{xThumbRect:t,yThumbRect:i}=vi(n,{snapshot:e});o.setSharedStorage(ni,t),o.setSharedStorage(ai,i)}}},e.MiddlewareSelector=e=>{const{viewer:t,sharer:i,boardContent:o,calculator:n,eventHub:a}=e,{helperContext:r}=o;let s=null,l=null;i.setSharedStorage(Wt,null);const h=()=>i.getSharedStorage(Ft),c=e=>{let t=i.getSharedStorage(Gt);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 o=ae(t);return i.setSharedStorage(Gt,t),i.setSharedStorage(Nt,o),t.length>0},d=e=>{i.setSharedStorage(kt,e);let t=null;e&&(t=re(e,{groupQueue:i.getSharedStorage(Gt)})),i.setSharedStorage(Lt,t)},f=(e,t)=>{if(i.setSharedStorage(Ft,e),1===e.length){const t=le(e[0],{groupQueue:i.getSharedStorage(Gt),controllerSize:10,viewScaleInfo:i.getActiveViewScaleInfo()});i.setSharedStorage(Bt,t)}else i.setSharedStorage(Bt,null);!0===(null==t?void 0:t.triggerEvent)&&a.trigger(ii,{uuids:e.map((e=>e.uuid))})},u=()=>({ctx:r,calculator:n,data:i.getActiveStorage("data"),selectedElements:h(),viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:i.getSharedStorage(Gt),areaSize:null,selectedElementController:i.getSharedStorage(Bt)}),g=()=>{i.setSharedStorage(Wt,null),i.setSharedStorage(Ot,null),i.setSharedStorage(jt,null),i.setSharedStorage(Dt,null),i.setSharedStorage(Gt,[]),i.setSharedStorage(Nt,[]),i.setSharedStorage(kt,null),i.setSharedStorage(Lt,null),i.setSharedStorage(Ft,[]),i.setSharedStorage(Yt,null),i.setSharedStorage(Bt,null)};g();const v=({uuids:e,positions:o})=>{let n=[];const a=i.getSharedStorage(Wt),r=i.getActiveStorage("data");n=o&&Array.isArray(o)?function(e,t){const i=[];return e.forEach((e=>{const o=function(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}(e,t);o&&i.push(o)})),i}(o,(null==r?void 0:r.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==r?void 0:r.elements)||[]);let s=!1;if(a||1!==n.length?"select"===a&&1===n.length&&(s=!0):(i.setSharedStorage(Wt,"select"),s=!0),s){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 s=o[r];if(s.uuid===t){a=s;break}if(!a&&"group"===s.type){i.push(s);const o=e(t,(null===(n=null==s?void 0:s.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}(n[0].uuid,(null==r?void 0:r.elements)||[]);i.setSharedStorage(Gt,e),f(n),t.drawFrame()}};return{use(){a.on(ii,v)},disuse(){a.off(ii,v)},hover:e=>{var o,s;const c=i.getSharedStorage(Ot),f=i.getSharedStorage(Wt),g=i.getSharedStorage(Gt),v=e=>{const t=e.type;null===l&&a.trigger("cursor",{type:t,groupQueue:e.groupQueue,element:e.elements[0]})};if((null==g?void 0:g.length)>0){if(!Jt(e.point,{ctx:r,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:i.getSharedStorage(Gt)}))return d(null),void t.drawFrame();const n=Kt(e.point,u());return v(n),c||["area","drag","drag-list"].includes(f)?(d(null),void t.drawFrame()):1===(null==(o=null==n?void 0:n.elements)?void 0:o.length)?(d(n.elements[0]),void t.drawFrame()):(d(null),void t.drawFrame())}if(c||["area","drag","drag-list"].includes(f))return void d(null);if("drag"===f)return void d(null);const w=h(),y=i.getActiveViewScaleInfo(),m=i.getActiveViewSizeInfo(),p=Kt(e.point,{...u(),areaSize:qt(w,{viewScaleInfo:y,viewSizeInfo:m,calculator:n})});return v(p),"over-element"===p.type&&1===(null==(s=null==p?void 0:p.elements)?void 0:s.length)?(i.setSharedStorage(kt,p.elements[0]),d(p.elements[0]),void t.drawFrame()):i.getSharedStorage(kt)?(d(null),void t.drawFrame()):void 0},pointStart:e=>{var o,a,l,c;s=e.point,d(null);const v=i.getSharedStorage(Gt);if((null==v?void 0:v.length)>0){if(Jt(e.point,{ctx:r,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:v})){const t=Kt(e.point,u());d(null),"over-element"===t.type&&1===(null==(o=null==t?void 0:t.elements)?void 0:o.length)?(f([t.elements[0]],{triggerEvent:!0}),i.setSharedStorage(Wt,"drag")):(null==(a=t.type)?void 0:a.startsWith("resize-"))?(i.setSharedStorage(Ot,t.type),i.setSharedStorage(Wt,"resize")):f([],{triggerEvent:!0})}else g();return void t.drawFrame()}const w=qt(h(),{viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),calculator:n}),y=Kt(e.point,{...u(),areaSize:w,groupQueue:[]});"list-area"===y.type?i.setSharedStorage(Wt,"drag-list"):"over-element"===y.type&&1===(null==(l=null==y?void 0:y.elements)?void 0:l.length)?(f([y.elements[0]],{triggerEvent:!0}),i.setSharedStorage(Wt,"drag")):(null==(c=y.type)?void 0:c.startsWith("resize-"))?(i.setSharedStorage(Ot,y.type),i.setSharedStorage(Wt,"resize")):(g(),i.setSharedStorage(Wt,"area"),i.setSharedStorage(jt,e.point),f([],{triggerEvent:!0})),t.drawFrame()},pointMove:e=>{var o;const n=i.getActiveStorage("data"),a=h(),r=i.getActiveStorage("scale")||1,c=s,d=e.point,u=i.getSharedStorage(Ot),g=i.getSharedStorage(Wt),v=i.getSharedStorage(Gt);if("drag"===g){if(l="drag",n&&1===(null==a?void 0:a.length)&&c&&d){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=Z(e,a),r=Z(t,a);o=r.x-i.x,n=r.y-i.y}return{moveX:o,moveY:n}}(c,d,v);a[0].x+=e/r,a[0].y+=t/r,f([a[0]])}t.drawFrame()}else if("drag-list"===g){if(l="drag-list",n&&c&&d&&(null==a?void 0:a.length)>1){const e=(d.x-c.x)/r,t=(d.y-c.y)/r;a.forEach((i=>{i&&(i.x+=e,i.y+=t)})),i.setActiveStorage("data",n)}t.drawFrame()}else if("resize"===g){if(n&&1===(null==a?void 0:a.length)&&c&&(null==u?void 0:u.startsWith("resize-"))){l="resize";const e=[];v.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 n=c,s=d;v.length>0&&(n=Z(c,e),s=Z(d,e));const h=function(e,t){var i,o,n,a,r,s,l,h,c;let{x:d,y:f,w:u,h:g,angle:v=0}=e;const w=V({x:d,y:f,w:u,h:g,angle:v});v=U(v);const y=B(v),m=!!(null==(i=null==e?void 0:e.operations)?void 0:i.limitRatio),{start:p,end:x,resizeType:S,scale:b}=t;let A={...p},I={...x},M={x:A.x,y:w.y},z={x:I.x,y:w.y},R={...M},P={...z},T={x:w.x,y:A.y},C={x:w.x,y:I.y},E={...T},W={...C},O=(P.x-R.x)/b,j=(P.y-R.y)/b,D=$t(O,j),k=(W.x-E.x)/b,L=(W.y-E.y)/b,F=$t(k,L);(v>0||v<0)&&(A=H(w,p,0-y),I=H(w,x,0-y),M={x:A.x,y:w.y},z={x:I.x,y:w.y},R=H(w,M,y),P=H(w,z,y),T={x:w.x,y:A.y},C={x:w.x,y:I.y},E=H(w,T,y),W=H(w,C,y),O=(P.x-R.x)/b,j=(P.y-R.y)/b,D=$t(O,j),D=_t(D,j),k=(W.x-E.x)/b,L=(W.y-E.y)/b,F=$t(k,L),F=_t(F,L));let Y=(x.x-p.x)/b,G=(x.y-p.y)/b;if(!0===m)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(S)){const t=Math.max(Math.abs(Y),Math.abs(G));Y=(Y>=0?1:-1)*t,G=(G>=0?1:-1)*t/e.w*e.h;const i=Math.max(Math.abs(k),Math.abs(L));k=(k>=0?1:-1)*i,L=(L>=0?1:-1)*i/e.w*e.h;const o=Math.max(Math.abs(O),Math.abs(j));O=(O>=0?1:-1)*o,j=(j>=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(Y);Y=(Y>=0?1:-1)*t;const i=t/e.w*e.h;"resize-top-left"===S||"resize-bottom-right"===S?G=Y>0?i:-i:"resize-top-right"!==S&&"resize-bottom-left"!==S||(G=Y>0?-i:i)}D=Math.abs(D),F=D/e.w*e.h}switch(S){case"resize-top":if(0===v)g-G>0&&(f+=G,g-=G,!0===(null==(o=e.operations)?void 0:o.limitRatio)&&(d+=G/e.h*e.w/2,u-=G/e.h*e.w));else if(v>0||v<0){let t=w.x,i=w.y;if(v<90){F=0-_t(F,L);const e=Qt(v),o=F/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){F=_t(F,k);const e=Qt(v-90),o=F/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){F=_t(F,L);const e=Qt(v-180),o=F/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){F=0-_t(F,k);const e=Qt(v-270),o=F/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}g+F>0&&(!0===(null==(n=e.operations)?void 0:n.limitRatio)&&(u+=F/e.h*e.w),g+=F,d=t-u/2,f=i-g/2)}break;case"resize-bottom":if(0===v)e.h+G>0&&(g+=G,!0===(null==(a=e.operations)?void 0:a.limitRatio)&&(d-=G/e.h*e.w/2,u+=G/e.h*e.w));else if(v>0||v<0){let t=w.x,i=w.y;if(v<90){F=_t(F,L);const e=Qt(v),o=F/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){F=0-_t(F,k);const e=Qt(v-90),o=F/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){F=_t(F,k);const e=Qt(v-180),o=F/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){F=_t(F,k);const e=Qt(v-270),o=F/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}g+F>0&&(!0===(null==(r=e.operations)?void 0:r.limitRatio)&&(u+=F/e.h*e.w),g+=F,d=t-u/2,f=i-g/2)}break;case"resize-left":if(0===v)e.w-Y>0&&(d+=Y,u-=Y,!0===(null==(s=e.operations)?void 0:s.limitRatio)&&(g-=Y/e.w*e.h,f+=Y/e.w*e.h/2));else if(v>0||v<0){let t=w.x,i=w.y;if(v<90){D=0-_t(D,O);const e=Qt(v),o=D/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){D=_t(D,O);const e=Qt(v-90),o=D/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){D=_t(D,j);const e=Qt(v-180),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){D=_t(D,j);const e=Qt(v-270),o=D/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}u+D>0&&(!0===(null==(l=e.operations)?void 0:l.limitRatio)&&(g+=D/e.w*e.h),u+=D,d=t-u/2,f=i-g/2)}break;case"resize-right":if(0===v)e.w+Y>0&&(u+=Y,!0===(null==(h=e.operations)?void 0:h.limitRatio)&&(f-=Y*e.h/e.w/2,g+=Y*e.h/e.w));else if(v>0||v<0){let t=w.x,i=w.y;if(v<90){D=_t(D,j);const e=Qt(v),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){D=_t(D,G);const e=Qt(v-90),o=D/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){D=_t(D,G);const e=Qt(v-180),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e),D=0-D}else if(v<360){D=_t(D,Y);const e=Qt(v-270),o=D/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}u+D>0&&(!0===(null==(c=e.operations)?void 0:c.limitRatio)&&(g+=D/e.w*e.h),u+=D,d=t-u/2,f=i-g/2)}break;case"resize-top-left":if(0===v)u-Y>0&&(d+=Y,u-=Y),g-G>0&&(f+=G,g-=G);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){F=0-_t(F,L),D=0-_t(D,m?0-F:O);const i=F/2;e+=i*Math.sin(y),t-=i*Math.cos(y);const o=D/2;e-=o*Math.cos(y),t-=o*Math.sin(y)}else if(v<180){F=_t(F,k),D=_t(D,m?F:O);const i=Qt(v-90),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=D/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){F=_t(F,L),D=_t(D,m?F:j);const i=Qt(v-180),o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=D/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){F=0-_t(F,k),D=_t(D,m?F:j);const i=Qt(v-270),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=D/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+F>0&&(g+=F),u+D>0&&(u+=D),d=e-u/2,f=t-g/2}break;case"resize-top-right":if(0===v)u+Y>0&&(u+=Y),g-G>0&&(f+=G,g-=G);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){F=0-_t(F,L),D=_t(D,m?F:j);const i=Qt(v),o=F/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=D/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){F=_t(F,k),D=_t(D,m?F:j);const i=Qt(v-90),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=D/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){const i=Qt(v-180);F=_t(F,L),D=_t(D,m?F:0-O);const o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=D/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){F=0-_t(F,k),D=_t(D,m?F:O);const i=Qt(v-270),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=D/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+F>0&&(g+=F),u+D>0&&(u+=D),d=e-u/2,f=t-g/2}break;case"resize-bottom-left":if(0===v)e.h+G>0&&(g+=G),e.w-Y>0&&(d+=Y,u-=Y);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){F=_t(F,L),D=0-_t(D,m?0-F:O);const i=Qt(v),o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=D/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<180){F=0-_t(F,k),D=_t(D,m?F:O);const i=Qt(v-90),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=D/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){F=_t(F,k),D=_t(D,m?F:j);const i=Qt(v-180),o=F/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=D/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){F=_t(F,k),D=_t(D,m?F:j);const i=Qt(v-270),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=D/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+F>0&&(g+=F),u+D>0&&(u+=D),d=e-u/2,f=t-g/2}break;case"resize-bottom-right":if(0===v)e.h+G>0&&(g+=G),e.w+Y>0&&(u+=Y);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){F=_t(F,L),D=_t(D,m?F:j);const i=Qt(v),o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=D/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){F=0-_t(F,k),D=_t(D,m?F:G);const i=Qt(v-90),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=D/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){F=_t(F,k),D=_t(D,m?F:0-j);const i=Qt(v-180),o=F/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=D/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){F=_t(F,k),D=_t(D,m?F:O);const i=Qt(v-270),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=D/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+F>0&&(g+=F),u+D>0&&(u+=D),d=e-u/2,f=t-g/2}}return{x:d,y:f,w:u,h:g,angle:e.angle}}(a[0],{scale:r,start:n,end:s,resizeType:u,sharer:i});a[0].x=h.x,a[0].y=h.y,"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),s=Math.max(n,a);e.w=i,e.h=o;const l={xRatio:n,yRatio:a,minRatio:r,maxRatio:s};"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{ve(e,l)})),ge(e,l)}(a[0],{w:h.w,h:h.h}):(a[0].w=h.w,a[0].h=h.h),f([a[0]]),t.drawFrame()}}else"area"===g&&(l="area",i.setSharedStorage(Dt,e.point),t.drawFrame());s=e.point},pointEnd(e){l=null;const o=i.getActiveStorage("data"),r=i.getSharedStorage(Ot),h=i.getSharedStorage(Wt),c=i.getActiveViewSizeInfo();let d=!1;if(s=null,"resize"===h&&r)i.setSharedStorage(Ot,null),d=!0;else if("area"===h){if(i.setSharedStorage(Wt,null),o){const e=i.getSharedStorage(jt),t=i.getSharedStorage(Dt);if(e&&t){const{elements:a}=function(e,t){const i=[],o=[],n=[],{calculator:a,viewScaleInfo:r,viewSizeInfo:s,start:l,end:h}=t;if(!(Array.isArray(e.elements)&&l&&h))return{indexes:i,uuids:o,elements:n};const c=Math.min(l.x,h.x),d=Math.max(l.x,h.x),f=Math.min(l.y,h.y),u=Math.max(l.y,h.y);return e.elements.forEach(((e,t)=>{const l=a.elementSize(e,r,s),h=V(l);if(h.x>=c&&h.x<=d&&h.y>=f&&h.y<=u&&(i.push(t),o.push(e.uuid),n.push(e),l.angle&&(l.angle>0||l.angle<0))){const e=$(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))}}})),{indexes:i,uuids:o,elements:n}}(o,{start:e,end:t,calculator:n,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()});a.length>0&&(i.setSharedStorage(Wt,"drag-list"),f(a,{triggerEvent:!0}),d=!0)}}}else if("drag-list"===h)i.setSharedStorage(Wt,"drag-list-end"),d=!0;else if(o){n.getPointElement(e.point,{data:o,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}).element?(i.setSharedStorage(Wt,"select"),d=!0):i.setSharedStorage(Wt,null)}null===i.getSharedStorage(Wt)&&(g(),d=!0);(()=>{if(d){if(o&&Array.isArray(null==o?void 0:o.elements)&&["drag","drag-list"].includes(h)){const e=function(e,t,i){const o=K(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}}(o.elements,c,{extend:!0});i.setActiveStorage("contextHeight",e.contextSize.contextHeight),i.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(o&&["drag","drag-list","drag-list-end","resize"].includes(h)){let e="drag-element";a.trigger("change",{data:o,type:e})}t.drawFrame()}})()},pointLeave(){s=null,g(),t.drawFrame()},doubleClick(e){var o,n;const r=Kt(e.point,u());if(1===r.elements.length&&"group"===(null==(o=r.elements[0])?void 0:o.type)){if(!0===c(r.elements[0]))return i.setSharedStorage(Wt,null),void t.drawFrame()}else 1===r.elements.length&&"text"===(null==(n=r.elements[0])?void 0:n.type)&&a.trigger(ei,{element:r.elements[0],groupQueue:i.getSharedStorage(Gt)||[],viewScaleInfo:i.getActiveViewScaleInfo()});i.setSharedStorage(Wt,null)},beforeDrawFrame({snapshot:t}){const{activeStore:i,sharedStore:o}=t,{scale:a,offsetLeft:s,offsetTop:l,offsetRight:c,offsetBottom:d,width:f,height:u,contextHeight:g,contextWidth:v,devicePixelRatio:w}=i,y=e.sharer,m={scale:a,offsetLeft:s,offsetTop:l,offsetRight:c,offsetBottom:d},p={width:f,height:u,contextHeight:g,contextWidth:v,devicePixelRatio:w},x=o[Ft][0],S=o[kt],b=o[Lt],A=o[Wt],I=o[jt],M=o[Dt],z=o[Gt],R=o[Nt],P={calculator:n,viewScaleInfo:m,viewSizeInfo:p},T=x?le(x,{groupQueue:z,controllerSize:10,viewScaleInfo:m}):null;if((null==z?void 0:z.length)>0)!function(e,t,i){for(let o=0;o<t.length;o++){const n=t[o],a={borderColor:Vt,borderWidth:2,background:"transparent",lineDash:[4,4]};Xt(e,te(n,i),a)}}(r,R,P),S&&"drag"!==A&&Ht(r,b,P),x&&["select","drag","resize"].includes(A)&&Zt(r,T,{...P});else if(S&&"drag"!==A&&Ht(r,b,P),x&&["select","drag","resize"].includes(A))Zt(r,T,{...P});else if("area"===A&&I&&M)!function(e,t){const{start:i,end:o}=t;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=Vt,e.fillStyle="#1976d24f",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()}(r,{start:I,end:M});else if(["drag-list","drag-list-end"].includes(A)){const e=qt(h(),{viewScaleInfo:y.getActiveViewScaleInfo(),viewSizeInfo:y.getActiveViewSizeInfo(),calculator:n});e&&function(e,t){const{areaSize:i}=t,{x:o,y:n,w:a,h:r}=i;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=Vt,e.fillStyle="#1976d21c",e.beginPath(),e.moveTo(o,n),e.lineTo(o+a,n),e.lineTo(o+a,n+r),e.lineTo(o,n+r),e.closePath(),e.stroke(),e.fill()}(r,{areaSize:e})}}}},e.MiddlewareTextEditor=e=>{const{eventHub:t,boardContent:i,viewer:o}=e,n=i.boardContext.canvas,a=document.createElement("textarea"),r=document.createElement("div"),s=e.container||document.body,l=document.createElement("div");let h=null;r.appendChild(a),r.style.position="absolute",l.appendChild(r),l.style.position="fixed",l.style.top="0",l.style.bottom="0",l.style.left="0",l.style.right="0",l.style.display="none",s.appendChild(l);const c=()=>{l.style.display="none",h=null},d=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:n,y:a,w:r,h:s}=t,l=U(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=`${s}px`,o.style.transform=`rotate(${l}deg)`,i.appendChild(o),o},f=e=>{const{viewScaleInfo:t,element:i,groupQueue:o}=e,{scale:n,offsetTop:s,offsetLeft:l}=t;r.children&&Array.from(r.children).forEach((e=>{e.remove()}));let h=r;for(let e=0;e<o.length;e++){const t=o[e],{x:i,y:a,w:r,h:c}=t,f={x:i*n,y:a*n,w:r*n,h:c*n,angle:U(t.angle||0)};0===e&&(f.x+=l,f.y+=s),h=d({size:f,parent:h})}const c={...ti,...i.detail};let f=i.x*n+l,u=i.y*n+s,g=i.w*n,v=i.h*n;o.length>0&&(f=i.x*n,u=i.y*n,g=i.w*n,v=i.h*n),a.style.position="absolute",a.style.left=`${f}px`,a.style.top=`${u}px`,a.style.width=`${g}px`,a.style.height=`${v}px`,a.style.transform=`rotate(${U(i.angle||0)}deg)`,a.style.boxSizing="border-box",a.style.border="1px solid #1973ba",a.style.resize="none",a.style.overflow="hidden",a.style.wordBreak="break-all",a.style.background="#FFFFFF",a.style.color="#333333",a.style.fontSize=c.fontSize*n+"px",a.style.lineHeight=c.lineHeight*n+"px",a.style.fontFamily=c.fontFamily,a.style.fontWeight=`${c.fontWeight}`,a.value=c.text||"",h.appendChild(a)},u=()=>{const{left:e,top:t,width:i,height:o}=(()=>{const e=n.getBoundingClientRect(),{left:t,top:i,width:o,height:a}=e;return{left:t,top:i,width:o,height:a}})();r.style.position="absolute",r.style.overflow="hidden",r.style.top=`${t}px`,r.style.left=`${e}px`,r.style.width=`${i}px`,r.style.height=`${o}px`};l.addEventListener("click",(()=>{c()})),a.addEventListener("click",(e=>{e.stopPropagation()})),a.addEventListener("input",(e=>{h&&(h.detail.text=e.target.value||"",o.drawFrame())})),a.addEventListener("blur",(()=>{c()}));const g=e=>{var t;(null==e?void 0:e.element)&&"text"===(null==(t=null==e?void 0:e.element)?void 0:t.type)&&(h=e.element),(e=>{u(),f(e),l.style.display="block"})(e)};return{use(){t.on(ei,g)},disuse(){t.off(ei,g)}}},e.middlewareEventRuler=Ii,e.middlewareEventScale=wi,e.middlewareEventSelect=ii,e.middlewareEventTextEdit=ei,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
1
+ var iDrawCore=function(e){"use strict";var t,i,o,n,a=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},r=(e,t,i)=>(a(e,t,"read from private field"),i?i.call(e):t.get(e)),s=(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)},l=(e,t,i,o)=>(a(e,t,"write to private field"),o?o.call(e,i):t.set(e,i),i);function h(e,t){let i=-1;return function(...o){i>0||(i=setTimeout((()=>{e(...o),i=-1}),t))}}function c(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 d(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 f(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function u(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 g(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/${u(t.toString(16).padEnd(4,o))}${u(e.substring(i-4,i).padEnd(4,o)).padEnd(4,"f")}-${u(e.substring(i-8,i-4).padEnd(4,o)).padEnd(4,"f")}-${u(e.substring(i-12,i-8).padEnd(4,o)).padEnd(4,"f")}-${u(e.substring(i-16,i-12).padEnd(4,n)).padEnd(4,"f")}-${u(e.substring(i,i+4).padEnd(4,n)).padEnd(4,"f")}${u(e.substring(i+4,i+8).padEnd(4,n)).padEnd(4,"f")}${u(n.padEnd(4,o).padEnd(4,n))}`}function v(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 y={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),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 m=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{l(o.next(e))}catch(e){a(e)}}function s(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))};const{Image:p}=window;function x(e){return new Promise(((t,i)=>{const o=new p;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function S(e){return m(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 x(t)}))}function b(e,t){return m(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&amp;");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 x(i)}))}function A(e){return"number"==typeof e&&(e>0||e<=0)}function I(e){return"number"==typeof e&&e>=0}function M(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function z(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const R={x:function(e){return A(e)},y:function(e){return A(e)},w:I,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:A,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return I(e)},borderRadius:function(e){return A(e)&&e>=0},color:function(e){return c(e)},imageSrc:function(e){return z(e)||M(e)},imageURL:M,imageBase64:z,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 A(e)&&e>0},lineHeight:function(e){return A(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 A(e)&&e>0}};var P,T,C=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},E=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 W{constructor(e,t){P.set(this,void 0),T.set(this,void 0),C(this,P,e,"f"),C(this,T,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f")}$undoPixelRatio(e){return e/E(this,T,"f").devicePixelRatio}$doPixelRatio(e){return E(this,T,"f").devicePixelRatio*e}$getContext(){return E(this,P,"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"}`),E(this,P,"f").font=`${t.join(" ")}`}$getOffscreenCanvas(){return E(this,T,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:a}=E(this,P,"f");a.width=t*o,a.height=i*o,C(this,T,Object.assign(Object.assign({},E(this,T,"f")),{devicePixelRatio:o}),"f"),!0===n&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=E(this,T,"f"),{width:t,height:i}=E(this,P,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return E(this,P,"f").canvas}get fillStyle(){return E(this,P,"f").fillStyle}set fillStyle(e){E(this,P,"f").fillStyle=e}get strokeStyle(){return E(this,P,"f").strokeStyle}set strokeStyle(e){E(this,P,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(E(this,P,"f").lineWidth)}set lineWidth(e){E(this,P,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return E(this,P,"f").textAlign}set textAlign(e){E(this,P,"f").textAlign=e}get textBaseline(){return E(this,P,"f").textBaseline}set textBaseline(e){E(this,P,"f").textBaseline=e}get globalAlpha(){return E(this,P,"f").globalAlpha}set globalAlpha(e){E(this,P,"f").globalAlpha=e}get shadowColor(){return E(this,P,"f").shadowColor}set shadowColor(e){E(this,P,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(E(this,P,"f").shadowOffsetX)}set shadowOffsetX(e){E(this,P,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(E(this,P,"f").shadowOffsetY)}set shadowOffsetY(e){E(this,P,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(E(this,P,"f").shadowBlur)}set shadowBlur(e){E(this,P,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return E(this,P,"f").lineCap}set lineCap(e){E(this,P,"f").lineCap=e}get globalCompositeOperation(){return E(this,P,"f").globalCompositeOperation}set globalCompositeOperation(e){E(this,P,"f").globalCompositeOperation=e}fill(...e){return E(this,P,"f").fill(...e)}arc(e,t,i,o,n,a){return E(this,P,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,a)}rect(e,t,i,o){return E(this,P,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return E(this,P,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return E(this,P,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return E(this,P,"f").beginPath()}closePath(){return E(this,P,"f").closePath()}lineTo(e,t){return E(this,P,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return E(this,P,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return E(this,P,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}getLineDash(){return E(this,P,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return E(this,P,"f").setLineDash(t)}stroke(e){return e?E(this,P,"f").stroke(e):E(this,P,"f").stroke()}translate(e,t){return E(this,P,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return E(this,P,"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],s=e[e.length-3],l=e[e.length-2],h=e[e.length-1];return 9===e.length?E(this,P,"f").drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a),this.$doPixelRatio(r),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(h)):E(this,P,"f").drawImage(t,this.$doPixelRatio(r),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(h))}createPattern(e,t){return E(this,P,"f").createPattern(e,t)}measureText(e){return E(this,P,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?E(this,P,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):E(this,P,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?E(this,P,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):E(this,P,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){E(this,P,"f").save()}restore(){E(this,P,"f").restore()}scale(e,t){E(this,P,"f").scale(e,t)}circle(e,t,i,o,n,a,r,s){E(this,P,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,a,r,s)}isPointInPath(e,t){return E(this,P,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return E(this,P,"f").clip(...e)}setTransform(e,t,i,o,n,a){return E(this,P,"f").setTransform(e,t,i,o,n,a)}getTransform(){return E(this,P,"f").getTransform()}createLinearGradient(e,t,i,o){return E(this,P,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,a){return E(this,P,"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 E(this,P,"f").createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function O(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 W(a,e)}function j(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 W(a,{devicePixelRatio:o,offscreenCanvas:n})}P=new WeakMap,T=new WeakMap;class D{constructor(){this._listeners=new Map}on(e,t){if(this._listeners.has(e)){const i=this._listeners.get(e)||[];null==i||i.push(t),this._listeners.set(e,i)}else this._listeners.set(e,[t])}off(e,t){if(this._listeners.has(e)){const i=this._listeners.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}this._listeners.set(e,i||[])}}trigger(e,t){const i=this._listeners.get(e);return!!Array.isArray(i)&&(i.forEach((e=>{e(t)})),!0)}has(e){if(this._listeners.has(e)){const t=this._listeners.get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}}function k(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}class L{constructor(e){this._backUpDefaultStorage=v(e.defaultStorage),this._temp=this._createTempStorage()}set(e,t){this._temp[e]=t}get(e){return this._temp[e]}getSnapshot(){return v(this._temp)}clear(){this._temp=this._createTempStorage()}_createTempStorage(){return v(this._backUpDefaultStorage)}}function F(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 Y(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 B(e){return e/180*Math.PI}function G(e,t,i,o){const n=B(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 N(e,t,i){const o=V(t);G(e,t.angle||0,o,(()=>{i(e)}))}function V(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function X(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 V({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 H(e,t,i){const o=function(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}(e,t);let n=o+i;n>2*Math.PI?n-=2*Math.PI:n<0-2*Math.PI&&(n+=2*Math.PI),n<0&&(n+=2*Math.PI);const a=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 r=0,s=0;return 0===n?(r=0,s=0-a):n>0&&n<Math.PI/2?(r=Math.sin(n)*a,s=0-Math.cos(n)*a):n===Math.PI/2?(r=a,s=0):n>Math.PI/2&&n<Math.PI?(r=Math.sin(Math.PI-n)*a,s=Math.cos(Math.PI-n)*a):n===Math.PI?(r=0,s=a):n>Math.PI&&n<1.5*Math.PI?(r=0-Math.sin(n-Math.PI)*a,s=Math.cos(n-Math.PI)*a):n===1.5*Math.PI?(r=0-a,s=0):n>1.5*Math.PI&&n<2*Math.PI?(r=0-Math.sin(2*Math.PI-n)*a,s=0-Math.cos(2*Math.PI-n)*a):n===2*Math.PI&&(r=0,s=0-a),r+=e.x,s+=e.y,{x:r,y:s}}function Z(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:s=0}=e,l=H(V({x:t,y:n,w:a,h:r,angle:s}),{x:i,y:o},B(s));i=l.x,o=l.y})),{x:i,y:o}}return e}function Q(e,t,i){const{x:o,y:n,w:a,h:r}=e;let s={x:o,y:n},l={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=B(U(i));s=H(t,s,e),l=H(t,l,e),h=H(t,h,e),c=H(t,c,e)}return[s,l,h,c]}function $(e){const{angle:t=0}=e;return Q(e,V(e),t)}function _(e,t,i){return[H(e,{x:t[0].x,y:t[0].y},i),H(e,{x:t[1].x,y:t[1].y},i),H(e,{x:t[2].x,y:t[2].y},i),H(e,{x:t[3].x,y:t[3].y},i)]}function U(e){if(!(e>0||e<0)||0===e)return 0;let t=e%360;return t<0&&(t+=360),t}function J(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=J(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.children))}))}return t}function K(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=$(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 q(e,t){const{viewScaleInfo:i}=t,{x:o,y:n,w:a,h:r,angle:s}=e,{scale:l,offsetTop:h,offsetLeft:c}=i;return{x:o*l+c,y:n*l+h,w:a*l,h:r*l,angle:s}}function ee(e,t){const{viewScaleInfo:i}=t,{x:o,y:n}=e,{scale:a,offsetTop:r,offsetLeft:s}=i;return{x:o*a+s,y:n*a+r}}function te(e,t){return[ee(e[0],t),ee(e[1],t),ee(e[2],t),ee(e[3],t)]}function ie(e,t){const{context2d:i,element:o,viewScaleInfo:n,viewSizeInfo:a}=t,{angle:r=0}=o,{x:s,y:l,w:h,h:c}=q(o,{viewScaleInfo:n,viewSizeInfo:a}),d=$({x:s,y:l,w:h,h:c,angle:r});if(d.length>=2){i.beginPath(),i.moveTo(d[0].x,d[0].y);for(let e=1;e<d.length;e++)i.lineTo(d[e].x,d[e].y);i.closePath()}return!!i.isPointInPath(e.x,e.y)}function oe(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 ne(e){const{x:t,y:i,w:o,h:n,angle:a=0}=e;return 0===a?oe(e):Q(e,V({x:t,y:i,w:o,h:n,angle:a}),a)}function ae(e){const t=[];let i=0,o=0;const n=[],a=[...e];for(let e=0;e<a.length;e++){const{x:r,y:s,w:l,h:h,angle:c=0}=a[e];let d;if(i+=r,o+=s,0===e){const e={x:i,y:o,w:l,h:h,angle:c};d=ne({x:r,y:s,w:l,h:h,angle:c}),n.push({center:V(e),angle:c,radian:B(c)})}else{d=oe({x:i,y:o,w:l,h:h,angle:c});for(let e=0;e<n.length;e++){const{center:t,radian:i}=n[e];d=_(t,d,i)}const e=X(d);if(c>0||c<0){d=_(e,d,B(c))}n.push({center:e,angle:c,radian:B(c)})}t.push(d)}return t}function re(e,t){const i=function(e,t){const{groupQueue:i}=t;return i.length>0?ae([...i,e]):[ne(e)]}(e,t);return i.pop()||null}function se(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 le(e,t){const{groupQueue:i,controllerSize:o,viewScaleInfo:n}=t,a=(o&&o>0?o:8)/n.scale,{x:r,y:s,w:l,h:h,angle:c=0}=e,d=[{uuid:f(),x:r,y:s,w:l,h:h,angle:c,type:"group",detail:{children:[]}},...i];let u=0;d.forEach((({angle:e=0})=>{u+=e}));const g=re(e,{groupQueue:i}),v=k(g[0],g[1]),w=k(g[1],g[2]),y=k(g[2],g[3]),m=k(g[3],g[0]),p=g[0],x=g[1],S=g[2],b=g[3],A=se(p,{size:a,angle:u}),I=se(x,{size:a,angle:u}),M=se(b,{size:a,angle:u}),z=se(S,{size:a,angle:u}),R=ne(A),P=ne(I),T=ne(M),C=ne(z),E=[R[1],P[0],P[3],R[2]],W=[P[3],P[2],C[1],C[0]],O=[T[1],C[0],C[3],T[2]];return{elementWrapper:g,left:{type:"left",vertexes:[R[3],R[2],T[1],T[0]],center:m},right:{type:"right",vertexes:W,center:w},top:{type:"top",vertexes:E,center:v},bottom:{type:"bottom",vertexes:O,center:y},topLeft:{type:"top-left",vertexes:R,center:p},topRight:{type:"top-right",vertexes:P,center:x},bottomLeft:{type:"bottom-left",vertexes:T,center:b},bottomRight:{type:"bottom-right",vertexes:C,center:S}}}function he(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}function ce(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))}const de={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function fe(e,t){const{viewScaleInfo:i}=t,{scale:o}=i;let{borderRadius:n}=e.detail;const{boxSizing:a=de.boxSizing,borderWidth:r}=e.detail;Array.isArray(r)&&(n=0);let{x:s,y:l,w:h,h:c}=e,d=[0,0,0,0];if("number"==typeof n){const e=n*o;d=[e,e,e,e]}else Array.isArray(n)&&4===(null==n?void 0:n.length)&&(d=[n[0]*o,n[1]*o,n[2]*o,n[3]*o]);let f=0;return"number"==typeof r&&(f=(r||0)*o),"border-box"===a?(s=e.x+f/2,l=e.y+f/2,h=e.w-f,c=e.h-f):"content-box"===a?(s=e.x-f/2,l=e.y-f/2,h=e.w+f,c=e.h+f):(s=e.x,l=e.y,h=e.w,c=e.h),h=Math.max(h,1),c=Math.max(c,1),d=d.map((e=>Math.min(e,h/2,c/2))),{x:s,y:l,w:h,h:c,radiusList:d}}const ue=e=>ce(e,{decimalPlaces:4});function ge(e,t){const{detail:i}=e,{xRatio:o,yRatio:n,maxRatio:a}=t,r=(o+n)/2,{borderWidth:s,borderRadius:l,borderDash:h,shadowOffsetX:c,shadowOffsetY:d,shadowBlur:f}=i;if("number"==typeof s)i.borderWidth=ue(s*r);else if(Array.isArray(i.borderWidth)){const e=s;i.borderWidth=[ue(e[0]*n),ue(e[1]*o),ue(e[2]*n),ue(e[3]*o)]}if("number"==typeof l)i.borderRadius=ue(l*r);else if(Array.isArray(i.borderRadius)){const e=l;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 ve(e,t){const{type:i}=e;!function(e,t){const{xRatio:i,yRatio:o}=t,{x:n,y:a,w:r,h:s}=e;e.x=ue(n*i),e.y=ue(a*o),e.w=ue(r*i),e.h=ue(s*o),ge(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=>{ve(e,t)})))}function we(e,t,i){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:n,opacity:a=1}=i,{x:r,y:s}=o,{scale:l}=n;if("linear-gradient"===(null==t?void 0:t.type)){const{start:i,end:o,stops:n}=t,h={x:r+i.x*l,y:s+i.y*l},c={x:r+o.x*l,y:s+o.y*l},f=e.createLinearGradient(h.x,h.y,c.x,c.y);return n.forEach((e=>{f.addColorStop(e.offset,d(e.color,a))})),f}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:i,outer:o,stops:n}=t,h={x:r+i.x*l,y:s+i.y*l,radius:i.radius*l},c={x:r+o.x*l,y:s+o.y*l,radius:o.radius*l},f=e.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return n.forEach((e=>{f.addColorStop(e.offset,d(e.color,a))})),f}return"#000000"}const ye={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function me(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 pe(e,t,i){const{pattern:o,renderContent:n,originElem:a,calcElemSize:r,viewScaleInfo:s,viewSizeInfo:l}=i||{},{parentOpacity:h}=i,d=me(a)*h;!function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewScaleInfo:r,viewSizeInfo:s}=i,l=r.scale*s.devicePixelRatio,{clipPath:h}=(null==n?void 0:n.detail)||{};if(h&&a&&h.commands){const{x:i,y:n,w:r,h:s}=a,{originW:c,originH:d,originX:f,originY:u}=h,g=r/c,v=s/d,w=i-f*g,y=n-u*v;e.save(),e.translate(w,y),e.scale(l*g,l*v);const m=he(h.commands||[]),p=new Path2D(m);e.clip(p),e.translate(0-w,0-y),e.setTransform(1,0,0,1,0,0),N(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:s,viewSizeInfo:l,renderContent:()=>{e.globalAlpha=d,function(e,t,i){var o,n;const{pattern:a,viewScaleInfo:r,viewSizeInfo:s}=i,l=[];if(t.detail.background||a){const{x:i,y:h,w:c,h:d,radiusList:f}=fe(t,{viewScaleInfo:r,viewSizeInfo:s});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(y.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=we(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=we(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=o,l&&l.length>0)for(let t=0;t<(null==l?void 0:l.length);t++){const o=l[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(),l&&l.length>0&&e.setTransform(1,0,0,1,0,0)}}(e,t,{pattern:o,viewScaleInfo:s,viewSizeInfo:l}),null==n||n(),function(e,t,i){if(0===t.detail.borderWidth)return;if(!c(t.detail.borderColor))return;const{viewScaleInfo:o}=i,{scale:n}=o;let a=ye.borderColor;!0===c(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:s,borderDash:l,boxSizing:h=ye.boxSizing}=t.detail;let d=0;"number"==typeof r&&(d=r||1);d*=n;let f=[0,0,0,0];if("number"==typeof s){const e=s*n;f=[e,e,e,e]}else Array.isArray(s)&&4===(null==s?void 0:s.length)&&(f=[s[0]*n,s[1]*n,s[2]*n,s[3]*n]);e.strokeStyle=a;let u=[];Array.isArray(l)&&l.length>0&&(u=l.map((e=>Math.ceil(e*n))));let g=0,v=0,w=0,y=0;Array.isArray(r)&&(g=(r[0]||0)*n,v=(r[1]||0)*n,w=(r[2]||0)*n,y=(r[3]||0)*n);if(y||v||g||w){e.lineCap="butt";let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i+=y/2,o+=g/2,n=n-y/2-v/2,a=a-g/2-w/2):"content-box"===h?(i-=y/2,o-=g/2,n=n+y/2+v/2,a=a+g/2+w/2):(i=t.x,o=t.y,n=t.w,a=t.h),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(i-y/2,o),e.lineTo(i+n+v/2,o),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(i+n,o-g/2),e.lineTo(i+n,o+a+w/2),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(i-y/2,o+a),e.lineTo(i+n+v/2,o+a),e.closePath(),e.stroke()),y&&(e.beginPath(),e.lineWidth=y,e.moveTo(i,o-g/2),e.lineTo(i,o+a+w/2),e.closePath(),e.stroke())}else{let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i=t.x+d/2,o=t.y+d/2,n=t.w-d,a=t.h-d):"content-box"===h?(i=t.x-d/2,o=t.y-d/2,n=t.w+d,a=t.h+d):(i=t.x,o=t.y,n=t.w,a=t.h),u.length>0?e.lineCap="butt":e.lineCap="square",n=Math.max(n,1),a=Math.max(a,1),f=f.map((e=>Math.min(e,n/2,a/2))),e.setLineDash(u),e.lineWidth=d,e.beginPath(),e.moveTo(i+f[0],o),e.arcTo(i+n,o,i+n,o+a,f[1]),e.arcTo(i+n,o+a,i,o+a,f[2]),e.arcTo(i,o+a,i,o,f[3]),e.arcTo(i,o,i+n,o,f[0]),e.closePath(),e.stroke()}e.setLineDash([])}(e,t,{viewScaleInfo:s,viewSizeInfo:l}),e.globalAlpha=h}})}function xe(e,t,i){const{detail:o}=t,{viewScaleInfo:n,renderContent:a}=i,{shadowColor:r,shadowOffsetX:s,shadowOffsetY:l,shadowBlur:h}=o;R.number(h)?(e.save(),e.shadowColor=r||ye.shadowColor,e.shadowOffsetX=(s||0)*n.scale,e.shadowOffsetY=(l||0)*n.scale,e.shadowBlur=(h||0)*n.scale,a(),e.restore()):a()}const Se={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function be(e,t,i){var o;if(!0!==(null===(o=null==t?void 0:t.operations)||void 0===o?void 0:o.invisible))try{switch(t.type){case"rect":!function(e,t,i){const{calculator:o,viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:s,y:l,w:h,h:c,angle:d}=(null==o?void 0:o.elementSize(t,n,a))||t,f=Object.assign(Object.assign({},t),{x:s,y:l,w:h,h:c,angle:d});N(e,{x:s,y:l,w:h,h:c,angle:d},(()=>{xe(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{pe(e,f,{originElem:t,calcElemSize:{x:s,y:l,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{}})}})}))}(e,t,i);break;case"circle":!function(e,t,i){const{detail:o,angle:n}=t,{background:a="#000000",borderColor:r="#000000",boxSizing:s,borderWidth:l=0}=o;let h=0;"number"==typeof l&&l>0?h=l:Array.isArray(l)&&"number"==typeof l[0]&&l[0]>0&&(h=l[0]);const{calculator:c,viewScaleInfo:d,viewSizeInfo:f,parentOpacity:u}=i,{x:g,y:v,w:w,h:y}=(null==c?void 0:c.elementSize({x:t.x,y:t.y,w:t.w,h:t.h},d,f))||t,m=Object.assign(Object.assign({},t),{x:g,y:v,w:w,h:y,angle:n});N(e,{x:g,y:v,w:w,h:y,angle:n},(()=>{xe(e,m,{viewScaleInfo:d,viewSizeInfo:f,renderContent:()=>{let t=w/2,i=y/2;const o=g+t,n=v+i;h>0&&("border-box"===s?(t-=h,i-=h):"center-line"===s?(t-=h/2,i-=h/2):(t-=h,i-=h));const c=me(m)*u;if(e.globalAlpha=c,"number"==typeof l&&l>0){const a=l/2+t,s=l/2+i;e.beginPath(),e.strokeStyle=r,e.lineWidth=l,e.circle(o,n,a,s,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath();const f=we(e,a,{viewElementSize:{x:g,y:v,w:w,h:y},viewScaleInfo:d,opacity:e.globalAlpha});e.fillStyle=f,e.circle(o,n,t,i,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=u}})}))}(e,t,i);break;case"text":!function(e,t,i){const{calculator:o,viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:s,y:l,w:h,h:d,angle:f}=(null==o?void 0:o.elementSize(t,n,a))||t,u=Object.assign(Object.assign({},t),{x:s,y:l,w:h,h:d,angle:f});N(e,{x:s,y:l,w:h,h:d,angle:f},(()=>{pe(e,u,{originElem:t,calcElemSize:{x:s,y:l,w:h,h:d,angle:f},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const i=Object.assign(Object.assign({},Se),t.detail),o=(i.fontSize||Se.fontSize)*n.scale,a=i.lineHeight?i.lineHeight*n.scale:o;e.fillStyle=t.detail.color||Se.color,e.textBaseline="top",e.$setFont({fontWeight:i.fontWeight,fontSize:o,fontFamily:i.fontFamily});const r=i.text.replace(/\r\n/gi,"\n"),f=a,u=r.split("\n"),g=[];let v=0;u.forEach(((t,i)=>{let o="";if(t.length>0){for(let n=0;n<t.length&&(e.measureText(o+(t[n]||"")).width<e.$doPixelRatio(h)?o+=t[n]||"":(g.push({text:o,width:e.$undoPixelRatio(e.measureText(o).width)}),o=t[n]||"",v++),!((v+1)*f>d));n++)if(t.length-1===n&&(v+1)*f<d){g.push({text:o,width:e.$undoPixelRatio(e.measureText(o).width)}),i<u.length-1&&v++;break}}else g.push({text:"",width:0})}));let w=0;g.length*f<d&&("top"===t.detail.verticalAlign?w=0:"bottom"===t.detail.verticalAlign?w+=d-g.length*f:w+=(d-g.length*f)/2);{const t=l+w;void 0!==i.textShadowColor&&c(i.textShadowColor)&&(e.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&R.number(i.textShadowOffsetX)&&(e.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&R.number(i.textShadowOffsetY)&&(e.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&R.number(i.textShadowBlur)&&(e.shadowBlur=i.textShadowBlur),g.forEach(((o,n)=>{let a=s;"center"===i.textAlign?a=s+(h-o.width)/2:"right"===i.textAlign&&(a=s+(h-o.width)),e.fillText(o.text,a,t+f*n)}))}}})}))}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{calculator:n,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:s}=i,{x:l,y:h,w:c,h:d,angle:f}=(null==n?void 0:n.elementSize(t,a,r))||t,u=Object.assign(Object.assign({},t),{x:l,y:h,w:c,h:d,angle:f});N(e,{x:l,y:h,w:c,h:d,angle:f},(()=>{xe(e,u,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{pe(e,u,{originElem:t,calcElemSize:{x:l,y:h,w:c,h:d,angle:f},viewScaleInfo:a,viewSizeInfo:r,parentOpacity:s,renderContent:()=>{if(o||i.loader.load(t,i.elementAssets||{}),"image"===t.type&&o){e.globalAlpha=me(t)*s;const{x:i,y:n,w:l,h:h,radiusList:c}=fe(u,{viewScaleInfo:a,viewSizeInfo:r});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+c[0],n),e.arcTo(i+l,n,i+l,n+h,c[1]),e.arcTo(i+l,n+h,i,n+h,c[2]),e.arcTo(i,n+h,i,n,c[3]),e.arcTo(i,n,i+l,n,c[0]),e.closePath(),e.fill(),e.clip(),e.drawImage(o,i,n,l,h),e.globalAlpha=s,e.restore()}}})}})}))}(e,t,i);break;case"svg":!function(e,t,i){const o=i.loader.getContent(t),{calculator:n,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:s}=i,{x:l,y:h,w:c,h:d,angle:f}=(null==n?void 0:n.elementSize(t,a,r))||t;N(e,{x:l,y:h,w:c,h:d,angle:f},(()=>{o||i.loader.load(t,i.elementAssets||{}),"svg"===t.type&&o&&(e.globalAlpha=me(t)*s,e.drawImage(o,l,h,c,d),e.globalAlpha=s)}))}(e,t,i);break;case"html":!function(e,t,i){const o=i.loader.getContent(t),{calculator:n,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:s}=i,{x:l,y:h,w:c,h:d,angle:f}=(null==n?void 0:n.elementSize(t,a,r))||t;N(e,{x:l,y:h,w:c,h:d,angle:f},(()=>{o||i.loader.load(t,i.elementAssets||{}),"html"===t.type&&o&&(e.globalAlpha=me(t)*s,e.drawImage(o,l,h,c,d),e.globalAlpha=s)}))}(e,t,i);break;case"path":!function(e,t,i){const{detail:o}=t,{originX:n,originY:a,originW:r,originH:s}=o,{calculator:l,viewScaleInfo:h,viewSizeInfo:c,parentOpacity:d}=i,{x:f,y:u,w:g,h:v,angle:w}=(null==l?void 0:l.elementSize(t,h,c))||t,y=g/r,m=v/s,p=f-n*y,x=u-a*m,S=h.scale*c.devicePixelRatio,b=Object.assign(Object.assign({},t),{x:f,y:u,w:g,h:v,angle:w});N(e,{x:f,y:u,w:g,h:v,angle:w},(()=>{pe(e,b,{originElem:t,calcElemSize:{x:f,y:u,w:g,h:v,angle:w},viewScaleInfo:h,viewSizeInfo:c,parentOpacity:d,renderContent:()=>{xe(e,b,{viewScaleInfo:h,viewSizeInfo:c,renderContent:()=>{e.save(),e.translate(p,x),e.scale(S*y/h.scale,S*m/h.scale);const t=he(o.commands||[]),i=new Path2D(t);o.fill&&(e.fillStyle=o.fill,e.fill(i)),o.stroke&&0!==o.strokeWidth&&(e.strokeStyle=o.stroke,e.lineWidth=(o.strokeWidth||1)/c.devicePixelRatio,e.lineCap=o.strokeLineCap||"square",e.stroke(i)),e.translate(-p,-x),e.restore()}})}})}))}(e,t,i);break;case"group":{const o=Object.assign(Object.assign({},i.elementAssets||{}),t.detail.assets||{});!function(e,t,i){const{calculator:o,viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:s,y:l,w:h,h:c,angle:d}=(null==o?void 0:o.elementSize({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},n,a))||t,f=Object.assign(Object.assign({},t),{x:s,y:l,w:h,h:c,angle:d});N(e,{x:s,y:l,w:h,h:c,angle:d},(()=>{e.globalAlpha=me(t)*r,xe(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{pe(e,f,{originElem:t,calcElemSize:{x:s,y:l,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const{x:o,y:s,w:l,h:h,radiusList:c}=fe(f,{viewScaleInfo:n,viewSizeInfo:a});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(o+c[0],s),e.arcTo(o+l,s,o+l,s+h,c[1]),e.arcTo(o+l,s+h,o,s+h,c[2]),e.arcTo(o,s+h,o,s,c[3]),e.arcTo(o,s,o+l,s,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:a}=i;for(let o=0;o<t.detail.children.length;o++){let s=t.detail.children[o];if(s=Object.assign(Object.assign({},s),{x:n.x+s.x,y:n.y+s.y}),!0===i.forceDrawAll||(null==a?void 0:a.isElementInView(s,i.viewScaleInfo,i.viewSizeInfo)))try{be(e,s,Object.assign(Object.assign({},i),{parentOpacity:r*me(t)}))}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=r}))}(e,t,Object.assign(Object.assign({},i),{elementAssets:o}));break}}}catch(e){console.error(e)}}const Ae={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};var Ie,Me,ze,Re,Pe,Te,Ce,Ee,We,Oe,je,De=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{l(o.next(e))}catch(e){a(e)}}function s(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))},ke=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 Le=["image","svg","html"],Fe=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:g(n):g(`${f()}-${e.uuid}-${f()}-${f()}`)};class Ye extends D{constructor(){super(),Ie.add(this),Me.set(this,{}),ze.set(this,{}),Re.set(this,{}),ke(this,Ie,"m",Pe).call(this,"image",((e,t)=>De(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 x(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),ke(this,Ie,"m",Pe).call(this,"html",((e,t)=>De(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 b(o,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),ke(this,Ie,"m",Pe).call(this,"svg",((e,t)=>De(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 S(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}}))))}load(e,t){ke(this,Ie,"m",je).call(this,e)||Le.includes(e.type)&&ke(this,Ie,"m",Oe).call(this,e,t)}getContent(e){var t,i;const o=Fe(e);return(null===(i=null===(t=ke(this,Re,"f"))||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return ke(this,Re,"f")}setLoadItemMap(e){!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,Re,e,"f")}}Me=new WeakMap,ze=new WeakMap,Re=new WeakMap,Ie=new WeakSet,Pe=function(e,t){ke(this,Me,"f")[e]=t},Te=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},Ce=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:ke(this,Ie,"m",Te).call(this,e)}},Ee=function(e){const t=Fe(e.element),i=ke(this,Re,"f")[t];i?i.startTime<e.startTime&&(ke(this,Re,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(ke(this,Re,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime})))},We=function(e){const t=Fe(e.element),i=ke(this,Re,"f")[t];i?i.startTime<e.startTime&&(ke(this,Re,"f")[t]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(ke(this,Re,"f")[t]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime})))},Oe=function(e,t){const i=ke(this,Ie,"m",Ce).call(this,e),o=Fe(e);ke(this,ze,"f")[o]=i;const n=ke(this,Me,"f")[e.type];"function"==typeof n&&(i.startTime=Date.now(),n(e,t).then((e=>{i.content=e.content,i.endTime=Date.now(),i.status="load",ke(this,Ie,"m",Ee).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,ke(this,Ie,"m",We).call(this,i)})))},je=function(e){var t;const i=Fe(e),o=null===(t=ke(this,ze,"f"))||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==ke(this,Ie,"m",Te).call(this,e))};var Be,Ge,Ne,Ve,Xe=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},He=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 Ze extends D{constructor(e){super(),Be.add(this),Ge.set(this,void 0),Ne.set(this,new Ye),Xe(this,Ge,e,"f"),He(this,Be,"m",Ve).call(this)}updateOptions(e){Xe(this,Ge,e,"f")}drawData(e,t){const i=He(this,Ne,"f"),{calculator:o}=He(this,Ge,"f"),n=He(this,Ge,"f").viewContext;n.clearRect(0,0,n.canvas.width,n.canvas.height);const a={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height};!function(e,t,i){var o;const{elements:n=[]}=t,{parentOpacity:a}=i;for(let t=0;t<n.length;t++){const r=n[t],s=Object.assign(Object.assign({},r),{detail:Object.assign(Object.assign({},Ae),null==r?void 0:r.detail)});if(!0===i.forceDrawAll||(null===(o=i.calculator)||void 0===o?void 0:o.isElementInView(s,i.viewScaleInfo,i.viewSizeInfo)))try{be(e,s,Object.assign(Object.assign({},i),{parentOpacity:a}))}catch(e){console.error(e)}}}(n,e,Object.assign({loader:i,calculator:o,parentElementSize:a,elementAssets:e.assets,parentOpacity:1},t))}scale(e){const{sharer:t}=He(this,Ge,"f");if(!t)return;const{data:i,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r,width:s,height:l,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:s,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){He(this,Ne,"f").setLoadItemMap(e)}getLoadItemMap(){return He(this,Ne,"f").getLoadItemMap()}}Ge=new WeakMap,Ne=new WeakMap,Be=new WeakSet,Ve=function(){const e=He(this,Ne,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(()=>{}))};class Qe{constructor(e){this._opts=e}elementSize(e,t,i){return q(e,{viewScaleInfo:t,viewSizeInfo:i})}isElementInView(e,t,i){return function(e,t){const{viewSizeInfo:i,viewScaleInfo:o}=t,{width:n,height:a}=i,{angle:r}=e,{x:s,y:l,w:h,h:c}=q(e,{viewScaleInfo:o,viewSizeInfo:i}),d=$({x:s,y:l,w:h,h:c,angle:r}),f={x:0,y:0,w:n,h:a},u=Math.min(d[0].x,d[1].x,d[2].x,d[3].x),g=Math.min(d[0].y,d[1].y,d[2].y,d[3].y);return function(e,t){const i=e.x,o=e.y,n=e.x+e.w,a=e.y+e.h,r=t.x,s=t.y,l=t.x+t.w,h=t.y+t.h;return i<=l&&n>=r&&o<=h&&a>=s}(f,{x:u,y:g,w:Math.max(d[0].x,d[1].x,d[2].x,d[3].x)-u,h:Math.max(d[0].y,d[1].y,d[2].y,d[3].y)-g})}(e,{viewScaleInfo:t,viewSizeInfo:i})}isPointInElement(e,t,i,o){return ie(e,{context2d:this._opts.viewContext,element:t,viewScaleInfo:i,viewSizeInfo:o})}getPointElement(e,t){const i=this._opts.viewContext;return function(e,t){var i,o,n;const{context2d:a,data:r,viewScaleInfo:s,viewSizeInfo:l,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(ie(e,{context2d:a,element:{x:n+u.x,y:r+u.y,w:u.w,h:u.h,angle:d+(u.angle||0)},viewScaleInfo:s,viewSizeInfo:l})){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)&&ie(e,{context2d:a,element:i,viewScaleInfo:s,viewSizeInfo:l})){c.index=t,c.element=i;break}}return c}(e,Object.assign(Object.assign({},t),{context2d:i}))}}function $e(e){return e>0||e<0||0===e}class _e extends D{constructor(e){super();const t=new L({defaultStorage:{hasPointDown:!1,prevClickPoint:null}});this._store=t,this._opts=e,this._init()}_init(){const e=window;e.addEventListener("mousemove",(e=>{if(!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this._isVaildPoint(t)&&this.trigger("hover",{point:t})})),e.addEventListener("mousedown",(e=>{if(!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this._isVaildPoint(t)&&(this._store.set("hasPointDown",!0),this.trigger("pointStart",{point:t}))})),e.addEventListener("mousemove",(e=>{if(!this._isInTarget(e))return;e.preventDefault(),e.stopPropagation();const t=this._getPoint(e);this._isVaildPoint(t)?!0===this._store.get("hasPointDown")&&this.trigger("pointMove",{point:t}):this._store.get("hasPointDown")&&(this.trigger("pointLeave",{point:t}),this._store.set("hasPointDown",!1))})),e.addEventListener("mouseup",(e=>{if(this._store.set("hasPointDown",!1),!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this.trigger("pointEnd",{point:t})})),e.addEventListener("mouseleave",(e=>{if(this._store.set("hasPointDown",!1),!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this.trigger("pointLeave",{point:t})})),e.addEventListener("wheel",(e=>{if(!this._isInTarget(e))return;const t=this._getPoint(e);if(!this._isVaildPoint(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})}),{passive:!1}),e.addEventListener("click",(e=>{if(!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);if(!this._isVaildPoint(t))return;const i=Date.now(),o=this._store.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}):this._store.set("prevClickPoint",t)})),e.addEventListener("contextmenu",(e=>{if(!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this._isVaildPoint(t)}))}_isInTarget(e){return e.target===this._opts.boardContent.boardContext.canvas}_getPoint(e){const t=this._opts.boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top,t:Date.now()}}_isVaildPoint(e){const t=this._opts.sharer.getActiveViewSizeInfo(),{width:i,height:o}=t;return!!($e(e.x)&&$e(e.y)&&e.x<=i&&e.y<=o)}}const Ue={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0};class Je{constructor(){const e=new L({defaultStorage:Ue}),t=new L({defaultStorage:{}});this._activeStore=e,this._sharedStore=t}getActiveStorage(e){return this._activeStore.get(e)}setActiveStorage(e,t){return this._activeStore.set(e,t)}getActiveStoreSnapshot(){return this._activeStore.getSnapshot()}getSharedStorage(e){return this._sharedStore.get(e)}setSharedStorage(e,t){return this._sharedStore.set(e,t)}getSharedStoreSnapshot(){return this._sharedStore.getSnapshot()}getActiveViewScaleInfo(){return{scale:this._activeStore.get("scale"),offsetTop:this._activeStore.get("offsetTop"),offsetBottom:this._activeStore.get("offsetBottom"),offsetLeft:this._activeStore.get("offsetLeft"),offsetRight:this._activeStore.get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:n,offsetRight:a}=e;this._activeStore.set("scale",t),this._activeStore.set("offsetTop",i),this._activeStore.set("offsetBottom",o),this._activeStore.set("offsetLeft",n),this._activeStore.set("offsetRight",a)}setActiveViewSizeInfo(e){this._activeStore.set("width",e.width),this._activeStore.set("height",e.height),this._activeStore.set("devicePixelRatio",e.devicePixelRatio),this._activeStore.set("contextWidth",e.contextWidth),this._activeStore.set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:this._activeStore.get("width"),height:this._activeStore.get("height"),devicePixelRatio:this._activeStore.get("devicePixelRatio"),contextWidth:this._activeStore.get("contextWidth"),contextHeight:this._activeStore.get("contextHeight")}}}const{requestAnimationFrame:Ke}=window;class qe extends D{constructor(e){super(),this._drawFrameSnapshotQueue=[],this._drawFrameStatus="FREE",this._opts=e,this._init()}_init(){const{renderer:e}=this._opts;e.on("load",(()=>{this.drawFrame()}))}_drawAnimationFrame(){if("DRAWING"===this._drawFrameStatus||0===this._drawFrameSnapshotQueue.length)return;this._drawFrameStatus="DRAWING";const e=this._drawFrameSnapshotQueue.shift(),{renderer:t,boardContent:i,beforeDrawFrame:o,afterDrawFrame:n}=this._opts;if(e){const{scale:a,offsetTop:r,offsetBottom:s,offsetLeft:l,offsetRight:h,width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g}=e.activeStore;(null==e?void 0:e.activeStore.data)&&t.drawData(e.activeStore.data,{viewScaleInfo:{scale:a,offsetTop:r,offsetBottom:s,offsetLeft:l,offsetRight:h},viewSizeInfo:{width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g}}),o({snapshot:e}),i.drawView(),n({snapshot:e})}0!==this._drawFrameSnapshotQueue.length?(this._drawFrameStatus="DRAWING")&&Ke((()=>{this._drawAnimationFrame()})):this._drawFrameStatus="COMPLETE"}drawFrame(){const{sharer:e}=this._opts,t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();this._drawFrameSnapshotQueue.push({activeStore:t,sharedStore:i}),this._drawAnimationFrame()}scale(e){const{scale:t,point:i}=e,{sharer:o}=this._opts,{moveX:n,moveY:a}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:n,offsetTop:a}=o,r=t/o.scale,s=i.x,l=i.y;return{moveX:s-s*r+(n*r-n),moveY:l-l*r+(a*r-a)}}({scale:t,point:i,viewScaleInfo:o.getActiveViewScaleInfo(),viewSizeInfo:o.getActiveViewSizeInfo()});return o.setActiveStorage("scale",t),{moveX:n,moveY:a}}scroll(e){const{sharer:t}=this._opts,i=t.getActiveViewScaleInfo(),{moveX:o,moveY:n}=e,a=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:n}=e,{scale:a}=o,{width:r,height:s,contextWidth:l,contextHeight:h}=n;let c=o.offsetLeft,d=o.offsetRight,f=o.offsetTop,u=o.offsetBottom;return c+=t,f+=i,d=r-(l*a+c),u=s-(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(a),a}updateViewScaleInfo(e){const{sharer:t}=this._opts,i=function(e,t){const{scale:i,offsetX:o,offsetY:n}=e,{viewSizeInfo:a}=t,{width:r,height:s,contextWidth:l,contextHeight:h}=a,c=0-o*i,d=0-n*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:r-(l*i+c/i),offsetBottom:s-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),i}resize(e={}){const{sharer:t}=this._opts,i=t.getActiveViewSizeInfo(),o=Object.assign(Object.assign({},i),e),{width:n,height:a,devicePixelRatio:r}=o,{underContext:s,boardContext:l,helperContext:h,viewContext:c}=this._opts.boardContent;return l.canvas.width=n*r,l.canvas.height=a*r,l.canvas.style.width=`${n}px`,l.canvas.style.height=`${a}px`,s.canvas.width=n*r,s.canvas.height=a*r,h.canvas.width=n*r,h.canvas.height=a*r,c.canvas.width=n*r,c.canvas.height=a*r,t.setActiveViewSizeInfo(o),o}}var et,tt,it,ot,nt,at,rt,st,lt,ht,ct,dt,ft,ut,gt,vt,wt,yt,mt,pt,xt,St,bt,At,It,Mt,zt=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},Rt=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 Pt{constructor(e){et.add(this),tt.set(this,void 0),it.set(this,new WeakMap),ot.set(this,[]),nt.set(this,[]),at.set(this,void 0),rt.set(this,void 0),st.set(this,void 0),lt.set(this,void 0),ht.set(this,void 0),ct.set(this,new D);const{boardContent:t}=e,i=new Je,o=new Qe({viewContext:t.viewContext}),n=new _e({boardContent:t,sharer:i}),a=new Ze({viewContext:t.viewContext,sharer:i,calculator:o});zt(this,tt,e,"f"),zt(this,st,i,"f"),zt(this,at,n,"f"),zt(this,rt,a,"f"),zt(this,ht,o,"f"),zt(this,lt,new qe({boardContent:e.boardContent,sharer:i,renderer:a,calculator:Rt(this,ht,"f"),beforeDrawFrame:e=>{Rt(this,et,"m",At).call(this,e)},afterDrawFrame:e=>{Rt(this,et,"m",It).call(this,e)}}),"f"),Rt(this,et,"m",dt).call(this),Rt(this,et,"m",Mt).call(this)}getSharer(){return Rt(this,st,"f")}getViewer(){return Rt(this,lt,"f")}getRenderer(){return Rt(this,rt,"f")}setData(e){const t=Rt(this,st,"f");Rt(this,st,"f").setActiveStorage("data",e);const i=t.getActiveViewSizeInfo(),o=K(e.elements,{viewWidth:i.width,viewHeight:i.height,extend:!0});Rt(this,lt,"f").drawFrame();const n=Object.assign(Object.assign({},i),o);return Rt(this,st,"f").setActiveViewSizeInfo(n),{viewSizeInfo:n}}getData(){const{data:e}=Rt(this,st,"f").getActiveStoreSnapshot();return e}use(e){var t,i,o;if(Rt(this,it,"f").has(e)){const o=Rt(this,it,"f").get(e);if(o)return null===(i=(t=o.middlewareObject).use)||void 0===i||i.call(t),o.status="enable",Rt(this,it,"f").set(e,o),void Rt(this,et,"m",Mt).call(this)}const{boardContent:n,container:a}=Rt(this,tt,"f"),r=e({boardContent:n,sharer:Rt(this,st,"f"),viewer:Rt(this,lt,"f"),calculator:Rt(this,ht,"f"),eventHub:Rt(this,ct,"f"),container:a});null===(o=r.use)||void 0===o||o.call(r),Rt(this,ot,"f").push(e),Rt(this,nt,"f").push(r),Rt(this,it,"f").set(e,{status:"enable",middlewareObject:r}),Rt(this,et,"m",Mt).call(this)}disuse(e){var t,i;const o=Rt(this,it,"f").get(e);o&&(null===(i=(t=o.middlewareObject).disuse)||void 0===i||i.call(t),o.status="disable",Rt(this,it,"f").set(e,o),Rt(this,et,"m",Mt).call(this))}scale(e){const t=Rt(this,lt,"f"),{moveX:i,moveY:o}=t.scale(e);t.scroll({moveX:i,moveY:o})}scroll(e){return Rt(this,lt,"f").scroll(e)}updateViewScaleInfo(e){return Rt(this,lt,"f").updateViewScaleInfo(e)}resize(e){const t=Rt(this,lt,"f").resize(e),{width:i,height:o,devicePixelRatio:n}=e,{boardContent:a}=Rt(this,tt,"f");a.viewContext.$resize({width:i,height:o,devicePixelRatio:n}),a.helperContext.$resize({width:i,height:o,devicePixelRatio:n}),a.boardContext.$resize({width:i,height:o,devicePixelRatio:n}),a.underContext.$resize({width:i,height:o,devicePixelRatio:n}),Rt(this,lt,"f").drawFrame(),Rt(this,at,"f").trigger("resize",t),Rt(this,st,"f").setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=Rt(this,tt,"f"),{underContext:t,helperContext: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),Rt(this,et,"m",bt).call(this)}getEventHub(){return Rt(this,ct,"f")}}tt=new WeakMap,it=new WeakMap,ot=new WeakMap,nt=new WeakMap,at=new WeakMap,rt=new WeakMap,st=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,et=new WeakSet,dt=function(){Rt(this,at,"f").on("pointStart",Rt(this,et,"m",ft).bind(this)),Rt(this,at,"f").on("pointEnd",Rt(this,et,"m",ut).bind(this)),Rt(this,at,"f").on("pointMove",h((e=>{Rt(this,et,"m",gt).call(this,e)}),10)),Rt(this,at,"f").on("hover",h((e=>{Rt(this,et,"m",vt).call(this,e)}),10)),Rt(this,at,"f").on("wheel",h((e=>{Rt(this,et,"m",yt).call(this,e)}),10)),Rt(this,at,"f").on("wheelScale",h((e=>{Rt(this,et,"m",mt).call(this,e)}),10)),Rt(this,at,"f").on("scrollX",Rt(this,et,"m",pt).bind(this)),Rt(this,at,"f").on("scrollY",Rt(this,et,"m",xt).bind(this)),Rt(this,at,"f").on("resize",Rt(this,et,"m",St).bind(this)),Rt(this,at,"f").on("doubleClick",Rt(this,et,"m",wt).bind(this))},ft=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointStart)||void 0===t?void 0:t.call(o,e)))return}},ut=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointEnd)||void 0===t?void 0:t.call(o,e)))return}},gt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointMove)||void 0===t?void 0:t.call(o,e)))return}},vt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.hover)||void 0===t?void 0:t.call(o,e)))return}},wt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.doubleClick)||void 0===t?void 0:t.call(o,e)))return}},yt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheel)||void 0===t?void 0:t.call(o,e)))return}},mt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheelScale)||void 0===t?void 0:t.call(o,e)))return}},pt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollX)||void 0===t?void 0:t.call(o,e)))return}},xt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollY)||void 0===t?void 0:t.call(o,e)))return}},St=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.resize)||void 0===t?void 0:t.call(o,e)))return}},bt=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.clear)||void 0===t?void 0:t.call(o,e)))return}},At=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.beforeDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},It=function(e){var t;for(let i=0;i<Rt(this,nt,"f").length;i++){const o=Rt(this,nt,"f")[i];if(!1===(null===(t=null==o?void 0:o.afterDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},Mt=function(){const e=[],t=Rt(this,it,"f");Rt(this,ot,"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)})),zt(this,nt,e,"f")};const Tt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJ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Nj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==";class Ct{constructor(e,t){this._cursorType=null,this._resizeCursorBaseImage=null,this._cursorImageMap={auto:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YX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KZpPAO8AwQCwW+2d0dLQ0OTkZSafT0UKhUJ6bm9t2HKeysrIS3tra0g7+KvABUJC0g5rrJdRcbLpImtleRzYashc1P2OSXwbebDVykX3gW+Ab1AHqhuQ3pe6AJlFMO0CoPROHDcio5I8DL1A9C8dQbmod+APYAK4DvwjQnsDdErgyVTfTEaCG1GFYGHXG7TVSo2OkdvhlAflXoHSuNdfStFqaRhEi2kfdprrj6M5LAt0I8EDaaMdflPal48CB95hMr3Bt8h4jD0kyL5E0pN6dysZzW7N2AqjbmhdIZjJvufTOpE19x3g+9s1XJ/ck5tVbfdhu+rxDfLiSO+lFToCjZwrXyH2/0Lwv95z8B1jAqXmDnj4YAAAAAElFTkSuQmCC","rotate-0":Tt},this._container=e,this._eventHub=t.eventHub,this._init(),this._loadResizeCursorBaseImage()}_init(){const{_eventHub:e}=this;this._resetCursor("auto"),e.on("cursor",(e=>{var t;"over-element"!==e.type&&e.type?"string"==typeof e.type&&(null==(t=e.type)?void 0:t.startsWith("resize-"))?this._setCursorResize(e):"drag-default"===e.type?this._resetCursor("drag-default"):"drag-active"===e.type?this._resetCursor("drag-active"):this._resetCursor("auto"):this._resetCursor("auto")}))}_loadResizeCursorBaseImage(){x(Tt).then((e=>{this._resizeCursorBaseImage=e})).catch((e=>{console.error(e)}))}_resetCursor(e){if(this._cursorType===e)return;this._cursorType=e;const t=this._cursorImageMap[this._cursorType]||this._cursorImageMap.auto;let i=0,o=0;e.startsWith("rotate-")&&this._cursorImageMap[this._cursorType]&&(i=10,o=10),this._container.style.cursor=`image-set(url(${t})2x) ${i} ${o}, auto`}_setCursorResize(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+=U((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+=U(e.angle||0)})),i=U(i);const o=this._appendRotateResizeImage(i);this._resetCursor(o)}_appendRotateResizeImage(e){const t=`rotate-${e}`;if(!this._cursorImageMap[t]){const i=this._resizeCursorBaseImage;if(i){const o=document.createElement("canvas"),n=i.width,a=i.height,r={x:n/2,y:a/2};o.width=n,o.height=a;const s=o.getContext("2d"),l=B(e);s.translate(r.x,r.y),s.rotate(l),s.translate(-r.x,-r.y),s.drawImage(i,0,0,n,a),s.translate(r.x,r.y),s.rotate(-l),s.translate(-r.x,-r.y);const h=o.toDataURL("image/png");this._cursorImageMap[t]=h}}return t}}const Et="SELECT",Wt=Symbol(`${Et}_actionType`),Ot=Symbol(`${Et}_resizeType`),jt=Symbol(`${Et}_areaStart`),Dt=Symbol(`${Et}_areaEnd`),kt=Symbol(`${Et}_hoverElement`),Lt=Symbol(`${Et}_hoverElementVertexes`),Ft=Symbol(`${Et}_selectedElementList`),Yt=Symbol(`${Et}_selectedElementListVertexes`),Bt=Symbol(`${Et}_selectedElementController`),Gt=Symbol(`${Et}_groupQueue`),Nt=Symbol(`${Et}_groupQueueVertexesList`),Vt="#1973ba";function Xt(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 Ht(e,t,i){if(!t)return;const o={borderColor:Vt,borderWidth:1,background:"transparent",lineDash:[]};Xt(e,te(t,i),o)}function Zt(e,t,i){if(!t)return;const{elementWrapper:o,topLeft:n,topRight:a,bottomLeft:r,bottomRight:s}=t,l={borderColor:Vt,borderWidth:2,background:"transparent",lineDash:[]},h={...l,borderWidth:4,background:"#FFFFFF"};Xt(e,te(o,i),l),Xt(e,te(n.vertexes,i),h),Xt(e,te(a.vertexes,i),h),Xt(e,te(r.vertexes,i),h),Xt(e,te(s.vertexes,i),h)}function Qt(e){return e*Math.PI/180}function $t(e,t){return Math.sqrt(e*e+t*t)}function _t(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Ut(e,t){const{ctx:i,viewScaleInfo:o,viewSizeInfo:n,vertexes:a}=t,r=ee(a[0],{viewScaleInfo:o,viewSizeInfo:n}),s=ee(a[1],{viewScaleInfo:o,viewSizeInfo:n}),l=ee(a[2],{viewScaleInfo:o,viewSizeInfo:n}),h=ee(a[3],{viewScaleInfo:o,viewSizeInfo:n});return i.beginPath(),i.moveTo(r.x,r.y),i.lineTo(s.x,s.y),i.lineTo(l.x,l.y),i.lineTo(h.x,h.y),i.lineTo(r.x,r.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function Jt(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=ae(a),s=r[r.length-1];return!!s&&Ut(e,{ctx:i,vertexes:s,viewScaleInfo:o,viewSizeInfo:n})}function Kt(e,t){var i,o,n;const a={type:null,elements:[],elementVertexesList:[],groupQueue:[],groupQueueVertexesList:[]},{ctx:r,data:s,calculator:l,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:s,topRight:l,bottomLeft:f,bottomRight:v}=g,w=[t,i,o,n,s,l,f,v];for(let t=0;t<w.length;t++){const i=w[t];if(Ut(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=re(o,{groupQueue:u});if(n&&Ut(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(s){const{index:t,element:i}=l.getPointElement(e,{data:s,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 qt(e,t){var i;if(!Array.isArray(e))return null;const o={x:0,y:0,w:0,h:0},{calculator:n,viewScaleInfo:a,viewSizeInfo:r}=t;let s=null;for(let t=0;t<e.length;t++){const l=e[t];if(null==(i=null==l?void 0:l.operations)?void 0:i.invisible)continue;const h=n.elementSize(l,a,r);if(h.angle&&(h.angle>0||h.angle<0)){const e=$(h);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];h.x=Math.min(...t),h.y=Math.min(...i),h.w=Math.abs(Math.max(...t)-Math.min(...t)),h.h=Math.abs(Math.max(...i)-Math.min(...i))}}if(s){const e=Math.min(h.x,o.x),t=Math.min(h.y,o.y),i=Math.max(h.x+h.w,o.x+o.w),n=Math.max(h.y+h.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=h.x,o.y=h.y,o.w=h.w,o.h=h.h;s=h}return o}const ei="@middleware/text-edit",ti={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"},ii="@middleware/select",oi="@middleware/select-clear",ni="SCROLL",ai=Symbol(`${ni}_xThumbRect`),ri=Symbol(`${ni}_yThumbRect`),si=Symbol(`${ni}_prevPoint`),li=Symbol(`${ni}_activePoint`),hi=Symbol(`${ni}_activeThumbType`),ci=16,di=.36,fi={width:12,thumbColor:"#000000AA",scrollBarColor:"#FFFFFF60",showScrollBar:!1};function ui(e,t,i){const o=e,{x:n,y:a,w:r,h:s}=i;return o.beginPath(),o.rect(n,a,r,s),o.closePath(),!!o.isPointInPath(t.x,t.y)}function gi(e,t){let{x:i,y:o,h:n,w:a}=t;e.save(),e.shadowColor="#FFFFFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=1;{const{color:r,axis:s}=t;"X"===s?(o=o+n/4+0,n/=2):"Y"===s&&(i=i+a/4+0,a/=2);let l=t.r;l=Math.min(l,a/2,n/2),(a<2*l||n<2*l)&&(l=0),e.globalAlpha=di,e.beginPath(),e.moveTo(i+l,o),e.arcTo(i+a,o,i+a,o+n,l),e.arcTo(i+a,o+n,i,o+n,l),e.arcTo(i,o+n,i,o,l),e.arcTo(i,o,i+a,o,l),e.closePath(),e.fillStyle=r,e.fill(),e.globalAlpha=1,e.beginPath(),e.lineWidth=1,e.strokeStyle=r,e.setLineDash([]),e.moveTo(i+l,o),e.arcTo(i+a,o,i+a,o+n,l),e.arcTo(i+a,o+n,i,o+n,l),e.arcTo(i,o+n,i,o,l),e.arcTo(i,o,i+a,o,l),e.closePath(),e.stroke()}e.restore()}function vi(e,t){const i=e,{viewScaleInfo:o,viewSizeInfo:n,scrollInfo:a}=t,{activeThumbType:r,prevPoint:s,activePoint:l}=a,h=function(e,t){const{width:i,height:o}=t,{offsetTop:n,offsetBottom:a,offsetLeft:r,offsetRight:s}=e,l=2.5*ci,h=ci;let c=0,d=0;c=Math.max(l,i-2*h-(Math.abs(r)+Math.abs(s))),c>=i&&(c=i),d=Math.max(l,o-2*h-(Math.abs(n)+Math.abs(a))),d>=o&&(d=o);const f=h;let u=f;r>0?u=f:s>0?u=i-c-h:r<=0&&c>0&&(0!==r||0!==s)&&(u=f+(i-c)*Math.abs(r)/(Math.abs(r)+Math.abs(s)),u=Math.min(Math.max(0,u-f),i-c));const g=h;let v=g;n>0?v=g:a>0?v=o-d-h:n<=0&&d>0&&(0!==n||0!==a)&&(v=g+(o-d)*Math.abs(n)/(Math.abs(n)+Math.abs(a)),v=Math.min(Math.max(0,v-g),o-d));const w={x:u,y:o-h,w:c,h:h},y={x:i-h,y:v,w:h,h:d};return{lineSize:h,xSize:c,ySize:d,translateY:v,translateX:u,thumbColor:fi.thumbColor,scrollBarColor:fi.scrollBarColor,xThumbRect:w,yThumbRect:y}}(o,n);let c={...h.xThumbRect},d={...h.yThumbRect};return r&&s&&l&&("X"===r&&a.xThumbRect?(c={...a.xThumbRect},c.x=c.x+(l.x-s.x)):"Y"===r&&a.yThumbRect&&(d={...a.yThumbRect},d.y=d.y+(l.y-s.y))),gi(i,{axis:"X",...c,r:h.lineSize/2,color:h.thumbColor}),gi(i,{axis:"Y",...d,r:h.lineSize/2,color:h.thumbColor}),i.globalAlpha=1,{xThumbRect:c,yThumbRect:d}}function wi(e,t){const{snapshot:i}=t,o=Y(i),n=F(i),a=function(e){const{sharedStore:t}=e;return{activePoint:t[li]||null,prevPoint:t[si]||null,activeThumbType:t[hi]||null,xThumbRect:t[ai]||null,yThumbRect:t[ri]||null}}(i),{xThumbRect:r,yThumbRect:s}=vi(e,{viewSizeInfo:o,viewScaleInfo:n,scrollInfo:a});return{xThumbRect:r,yThumbRect:s}}const yi="@middleware/scale",mi=16,pi="#000000",xi="#00000080",Si="monospace",bi="#AAAAAA20",Ai="#AAAAAA40";function Ii(e){const{scale:t,viewLength:i,viewOffset:o}=e,n=[];let a=10;a=ce(a/t,{decimalPlaces:0}),a=Math.max(10,Math.min(a,1e3));const r=10*a,s=5*a;let l=0;const h=a*t,c=0-o,d=c%h,f=(c-d+h)/t,u=h-d+0;for(;u+l*h<i;){const e=ce(f+l*a,{decimalPlaces:0}),t={num:e,position:ce(u+l*h,{decimalPlaces:0}),showNum:e%r==0,isKeyNum:e%r==0,isSubKeyNum:e%s==0};n.push(t),l++}return n}const Mi="@middleware/show-ruler",zi=Symbol("DRAG_prevPoint");return t=new WeakMap,i=new WeakMap,o=new WeakSet,n=function(){r(this,i).style.position="relative"},e.Core=class{constructor(e,r){s(this,o),s(this,t,void 0),s(this,i,void 0);const{devicePixelRatio:h=1,width:c,height:d}=r;l(this,i,e);const f=document.createElement("canvas");var u,g,v;(u=this,g=o,v=n,a(u,g,"access private method"),v).call(this),e.appendChild(f);const w=function(e,t){const{width:i,height:o,devicePixelRatio:n,offscreen:a}=t,r={width:i,height:o,devicePixelRatio:n};if(!0===a){const t=e.getContext("2d"),i=j(r),o=j(r),n=j(r),a=O(Object.assign({ctx:t},r)),s=()=>{const{width:e,height:t}=i.$getSize();a.clearRect(0,0,e,t),a.drawImage(n.canvas,0,0,e,t),a.drawImage(i.canvas,0,0,e,t),a.drawImage(o.canvas,0,0,e,t),n.clearRect(0,0,e,t),i.clearRect(0,0,e,t),o.clearRect(0,0,e,t)};return{underContext:n,viewContext:i,helperContext:o,boardContext:a,drawView:s}}{const t=e.getContext("2d"),n=O(r),a=O(r),s=O(r),l=O(Object.assign({ctx:t},r)),h=()=>{l.clearRect(0,0,i,o),l.drawImage(s.canvas,0,0,i,o),l.drawImage(n.canvas,0,0,i,o),l.drawImage(a.canvas,0,0,i,o),s.clearRect(0,0,i,o),n.clearRect(0,0,i,o),a.clearRect(0,0,i,o)};return{underContext:s,viewContext:n,helperContext:a,boardContext:l,drawView:h}}}(f,{width:c,height:d,devicePixelRatio:h,offscreen:!0}),y=new Pt({boardContent:w,container:e}),m=y.getSharer();m.setActiveViewSizeInfo({width:c,height:d,devicePixelRatio:h,contextWidth:c,contextHeight:d}),l(this,t,y),this.resize(m.getActiveViewSizeInfo());const p=y.getEventHub();new Ct(e,{eventHub:p})}use(e){r(this,t).use(e)}disuse(e){r(this,t).disuse(e)}setData(e){J((null==e?void 0:e.elements)||[]),r(this,t).setData(e)}getData(){return r(this,t).getData()}scale(e){r(this,t).scale(e);r(this,t).getViewer().drawFrame()}resize(e){const i=r(this,t),o=i.getSharer().getActiveViewSizeInfo();i.resize({...o,...e})}clear(){r(this,t).clear()}on(e,i){r(this,t).getEventHub().on(e,i)}off(e,i){r(this,t).getEventHub().off(e,i)}trigger(e,i){r(this,t).getEventHub().trigger(e,i)}getViewInfo(){const e=r(this,t).getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){r(this,t).getViewer().drawFrame()}setViewScale(e){r(this,t).updateViewScaleInfo(e)}getLoadItemMap(){return r(this,t).getRenderer().getLoadItemMap()}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:o}=e;let n=!1;return{hover(){!0!==n&&t.trigger("cursor",{type:"drag-default"})},pointStart(e){const{point:o}=e;i.setSharedStorage(zi,o),n=!0,t.trigger("cursor",{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(zi);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(zi,t)},pointEnd(){n=!1,i.setSharedStorage(zi,null),t.trigger("cursor",{type:"drag-default"})}}},e.MiddlewareRuler=e=>{const{boardContent:t,viewer:i,eventHub:o}=e,{helperContext:n,underContext:a}=t;let r=!0,s=!0;const l=e=>{"boolean"==typeof(null==e?void 0:e.show)&&(r=e.show),"boolean"==typeof(null==e?void 0:e.showGrid)&&(s=e.showGrid),"boolean"!=typeof(null==e?void 0:e.show)&&"boolean"!=typeof(null==e?void 0:e.showGrid)||i.drawFrame()};return{use(){o.on(Mi,l)},disuse(){o.off(Mi,l)},beforeDrawFrame:({snapshot:e})=>{if(!0===r){const t=F(e),i=Y(e);!function(e,t){const{viewSizeInfo:i}=t,{width:o,height:n}=i;e.beginPath(),e.moveTo(0,0),e.lineTo(o+1,0),e.lineTo(o+1,mi),e.lineTo(mi,mi),e.lineTo(mi,n+1),e.lineTo(0,n+1),e.lineTo(0,0),e.closePath(),e.fillStyle="#FFFFFFA8",e.fill(),e.lineWidth=1,e.setLineDash([]),e.strokeStyle="#00000080",e.stroke()}(n,{viewScaleInfo:t,viewSizeInfo:i});const o=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:n}=t,{width:a}=i;return Ii({axis:"X",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i}=t;for(let t=0;t<i.length;t++){const o=i[t];o.position<mi||(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=pi,e.stroke(),o.isKeyNum&&(e.fillStyle=xi,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Si}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(n,{scaleList:o});const r=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n}=t,{height:a}=i;return Ii({axis:"Y",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i}=t,o=3.2;for(let t=0;t<i.length;t++){const n=i[t];if(!(n.position<mi)&&(e.beginPath(),e.moveTo(16,n.position),e.lineTo(n.isKeyNum?3.2:n.isSubKeyNum?6.4:12.8,n.position),e.closePath(),e.fillStyle=pi,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===n.showNum)){const t=o,i=n.position+o,a=`${n.num}`;G(e,-90,{x:t,y:i},(()=>{e.fillStyle=xi,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Si}),e.fillText(a,13.2,n.position+o)}))}}}(n,{scaleList:r}),!0===s&&function(e,t){const{xList:i,yList:o,viewSizeInfo:n}=t,{width:a,height:r}=n;for(let t=0;t<i.length;t++){const o=i[t];e.beginPath(),e.moveTo(o.position,0),e.lineTo(o.position,r),!0===o.isKeyNum||!0===o.isSubKeyNum?e.strokeStyle=Ai:e.strokeStyle=bi,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(a,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=Ai:e.strokeStyle=bi,e.lineWidth=1,e.closePath(),e.stroke()}}(a,{xList:o,yList:r,viewScaleInfo:t,viewSizeInfo:i})}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:o}=e;return{wheelScale(e){const{deltaY:n,point:a}=e,{scale:r}=i.getActiveViewScaleInfo();let s=r;if(n<0?s=1.1*r:n>0&&(s=.9*r),s<.05||s>50)return;const{moveX:l,moveY:h}=t.scale({scale:s,point:a});t.scroll({moveX:l,moveY:h}),t.drawFrame();const c=ce(r);o.trigger(yi,{scale:c})}}},e.MiddlewareScroller=e=>{const{viewer:t,boardContent:i,sharer:o}=e,{helperContext:n}=i;o.setSharedStorage(ai,null),o.setSharedStorage(ri,null);const a=()=>{o.setSharedStorage(si,null),o.setSharedStorage(li,null),o.setSharedStorage(hi,null)};a();const r=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:a}=i;return n&&ui(e,t,n)?o="X":a&&ui(e,t,a)&&(o="Y"),o}(n,e,{xThumbRect:o.getSharedStorage(ai),yThumbRect:o.getSharedStorage(ri)});return{wheel:e=>{t.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),t.drawFrame()},pointStart:e=>{const{point:t}=e,i=r(t);if("X"===i||"Y"===i)return o.setSharedStorage(hi,i),o.setSharedStorage(si,t),!1},pointMove:e=>{const{point:i}=e,n=o.getSharedStorage(hi);if("X"===n||"Y"===n)return o.setSharedStorage(li,i),"X"===n?(e=>{const i=o.getSharedStorage(si);if(i){const{offsetLeft:n,offsetRight:a}=o.getActiveViewScaleInfo(),{width:r}=o.getActiveViewSizeInfo(),s=-(e.x-i.x)*(r+Math.abs(n)+Math.abs(a))/r;t.scroll({moveX:s}),t.drawFrame()}})(i):"Y"===n&&(e=>{const i=o.getSharedStorage(si);if(i){const{offsetTop:n,offsetBottom:a}=o.getActiveViewScaleInfo(),{height:r}=o.getActiveViewSizeInfo(),s=-(e.y-i.y)*(r+Math.abs(n)+Math.abs(a))/r;t.scroll({moveY:s}),t.drawFrame()}})(i),o.setSharedStorage(si,i),!1},pointEnd:()=>{const e=o.getSharedStorage(hi);if(a(),"X"===e||"Y"===e)return t.scroll({moveX:0,moveY:0}),t.drawFrame(),!1},beforeDrawFrame({snapshot:e}){const{xThumbRect:t,yThumbRect:i}=wi(n,{snapshot:e});o.setSharedStorage(ai,t),o.setSharedStorage(ri,i)}}},e.MiddlewareSelector=e=>{const{viewer:t,sharer:i,boardContent:o,calculator:n,eventHub:a}=e,{helperContext:r}=o;let s=null,l=null;i.setSharedStorage(Wt,null);const h=()=>i.getSharedStorage(Ft),c=e=>{let t=i.getSharedStorage(Gt);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 o=ae(t);return i.setSharedStorage(Gt,t),i.setSharedStorage(Nt,o),t.length>0},d=e=>{i.setSharedStorage(kt,e);let t=null;e&&(t=re(e,{groupQueue:i.getSharedStorage(Gt)})),i.setSharedStorage(Lt,t)},f=(e,t)=>{if(i.setSharedStorage(Ft,e),1===e.length){const t=le(e[0],{groupQueue:i.getSharedStorage(Gt),controllerSize:10,viewScaleInfo:i.getActiveViewScaleInfo()});i.setSharedStorage(Bt,t)}else i.setSharedStorage(Bt,null);!0===(null==t?void 0:t.triggerEvent)&&a.trigger(ii,{uuids:e.map((e=>e.uuid))})},u=()=>({ctx:r,calculator:n,data:i.getActiveStorage("data"),selectedElements:h(),viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:i.getSharedStorage(Gt),areaSize:null,selectedElementController:i.getSharedStorage(Bt)}),g=()=>{i.setSharedStorage(Wt,null),i.setSharedStorage(Ot,null),i.setSharedStorage(jt,null),i.setSharedStorage(Dt,null),i.setSharedStorage(Gt,[]),i.setSharedStorage(Nt,[]),i.setSharedStorage(kt,null),i.setSharedStorage(Lt,null),i.setSharedStorage(Ft,[]),i.setSharedStorage(Yt,null),i.setSharedStorage(Bt,null)};g();const v=({uuids:e,positions:o})=>{let n=[];const a=i.getSharedStorage(Wt),r=i.getActiveStorage("data");n=o&&Array.isArray(o)?function(e,t){const i=[];return e.forEach((e=>{const o=function(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}(e,t);o&&i.push(o)})),i}(o,(null==r?void 0:r.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==r?void 0:r.elements)||[]);let s=!1;if(a||1!==n.length?"select"===a&&1===n.length&&(s=!0):(i.setSharedStorage(Wt,"select"),s=!0),s){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 s=o[r];if(s.uuid===t){a=s;break}if(!a&&"group"===s.type){i.push(s);const o=e(t,(null===(n=null==s?void 0:s.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}(n[0].uuid,(null==r?void 0:r.elements)||[]);i.setSharedStorage(Gt,e),f(n),t.drawFrame()}},w=()=>{g(),t.drawFrame()};return{use(){a.on(ii,v),a.on(oi,w)},disuse(){a.off(ii,v),a.off(oi,w)},hover:e=>{var o,s;const c=i.getSharedStorage(Ot),f=i.getSharedStorage(Wt),g=i.getSharedStorage(Gt),v=e=>{const t=e.type;null===l&&a.trigger("cursor",{type:t,groupQueue:e.groupQueue,element:e.elements[0]})};if((null==g?void 0:g.length)>0){if(!Jt(e.point,{ctx:r,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:i.getSharedStorage(Gt)}))return d(null),void t.drawFrame();const n=Kt(e.point,u());return v(n),c||["area","drag","drag-list"].includes(f)?(d(null),void t.drawFrame()):1===(null==(o=null==n?void 0:n.elements)?void 0:o.length)?(d(n.elements[0]),void t.drawFrame()):(d(null),void t.drawFrame())}if(c||["area","drag","drag-list"].includes(f))return void d(null);if("drag"===f)return void d(null);const w=h(),y=i.getActiveViewScaleInfo(),m=i.getActiveViewSizeInfo(),p=Kt(e.point,{...u(),areaSize:qt(w,{viewScaleInfo:y,viewSizeInfo:m,calculator:n})});return v(p),"over-element"===p.type&&1===(null==(s=null==p?void 0:p.elements)?void 0:s.length)?(i.setSharedStorage(kt,p.elements[0]),d(p.elements[0]),void t.drawFrame()):i.getSharedStorage(kt)?(d(null),void t.drawFrame()):void 0},pointStart:e=>{var o,a,l,c;s=e.point,d(null);const v=i.getSharedStorage(Gt);if((null==v?void 0:v.length)>0){if(Jt(e.point,{ctx:r,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:v})){const t=Kt(e.point,u());d(null),"over-element"===t.type&&1===(null==(o=null==t?void 0:t.elements)?void 0:o.length)?(f([t.elements[0]],{triggerEvent:!0}),i.setSharedStorage(Wt,"drag")):(null==(a=t.type)?void 0:a.startsWith("resize-"))?(i.setSharedStorage(Ot,t.type),i.setSharedStorage(Wt,"resize")):f([],{triggerEvent:!0})}else g();return void t.drawFrame()}const w=qt(h(),{viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),calculator:n}),y=Kt(e.point,{...u(),areaSize:w,groupQueue:[]});"list-area"===y.type?i.setSharedStorage(Wt,"drag-list"):"over-element"===y.type&&1===(null==(l=null==y?void 0:y.elements)?void 0:l.length)?(f([y.elements[0]],{triggerEvent:!0}),i.setSharedStorage(Wt,"drag")):(null==(c=y.type)?void 0:c.startsWith("resize-"))?(i.setSharedStorage(Ot,y.type),i.setSharedStorage(Wt,"resize")):(g(),i.setSharedStorage(Wt,"area"),i.setSharedStorage(jt,e.point),f([],{triggerEvent:!0})),t.drawFrame()},pointMove:e=>{var o;const n=i.getActiveStorage("data"),a=h(),r=i.getActiveStorage("scale")||1,c=s,d=e.point,u=i.getSharedStorage(Ot),g=i.getSharedStorage(Wt),v=i.getSharedStorage(Gt);if("drag"===g){if(l="drag",n&&1===(null==a?void 0:a.length)&&c&&d){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=Z(e,a),r=Z(t,a);o=r.x-i.x,n=r.y-i.y}return{moveX:o,moveY:n}}(c,d,v);a[0].x+=e/r,a[0].y+=t/r,f([a[0]])}t.drawFrame()}else if("drag-list"===g){if(l="drag-list",n&&c&&d&&(null==a?void 0:a.length)>1){const e=(d.x-c.x)/r,t=(d.y-c.y)/r;a.forEach((i=>{i&&(i.x+=e,i.y+=t)})),i.setActiveStorage("data",n)}t.drawFrame()}else if("resize"===g){if(n&&1===(null==a?void 0:a.length)&&c&&(null==u?void 0:u.startsWith("resize-"))){l="resize";const e=[];v.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 n=c,s=d;v.length>0&&(n=Z(c,e),s=Z(d,e));const h=function(e,t){var i,o,n,a,r,s,l,h,c;let{x:d,y:f,w:u,h:g,angle:v=0}=e;const w=V({x:d,y:f,w:u,h:g,angle:v});v=U(v);const y=B(v),m=!!(null==(i=null==e?void 0:e.operations)?void 0:i.limitRatio),{start:p,end:x,resizeType:S,scale:b}=t;let A={...p},I={...x},M={x:A.x,y:w.y},z={x:I.x,y:w.y},R={...M},P={...z},T={x:w.x,y:A.y},C={x:w.x,y:I.y},E={...T},W={...C},O=(P.x-R.x)/b,j=(P.y-R.y)/b,D=$t(O,j),k=(W.x-E.x)/b,L=(W.y-E.y)/b,F=$t(k,L);(v>0||v<0)&&(A=H(w,p,0-y),I=H(w,x,0-y),M={x:A.x,y:w.y},z={x:I.x,y:w.y},R=H(w,M,y),P=H(w,z,y),T={x:w.x,y:A.y},C={x:w.x,y:I.y},E=H(w,T,y),W=H(w,C,y),O=(P.x-R.x)/b,j=(P.y-R.y)/b,D=$t(O,j),D=_t(D,j),k=(W.x-E.x)/b,L=(W.y-E.y)/b,F=$t(k,L),F=_t(F,L));let Y=(x.x-p.x)/b,G=(x.y-p.y)/b;if(!0===m)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(S)){const t=Math.max(Math.abs(Y),Math.abs(G));Y=(Y>=0?1:-1)*t,G=(G>=0?1:-1)*t/e.w*e.h;const i=Math.max(Math.abs(k),Math.abs(L));k=(k>=0?1:-1)*i,L=(L>=0?1:-1)*i/e.w*e.h;const o=Math.max(Math.abs(O),Math.abs(j));O=(O>=0?1:-1)*o,j=(j>=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(Y);Y=(Y>=0?1:-1)*t;const i=t/e.w*e.h;"resize-top-left"===S||"resize-bottom-right"===S?G=Y>0?i:-i:"resize-top-right"!==S&&"resize-bottom-left"!==S||(G=Y>0?-i:i)}D=Math.abs(D),F=D/e.w*e.h}switch(S){case"resize-top":if(0===v)g-G>0&&(f+=G,g-=G,!0===(null==(o=e.operations)?void 0:o.limitRatio)&&(d+=G/e.h*e.w/2,u-=G/e.h*e.w));else if(v>0||v<0){let t=w.x,i=w.y;if(v<90){F=0-_t(F,L);const e=Qt(v),o=F/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){F=_t(F,k);const e=Qt(v-90),o=F/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){F=_t(F,L);const e=Qt(v-180),o=F/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){F=0-_t(F,k);const e=Qt(v-270),o=F/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}g+F>0&&(!0===(null==(n=e.operations)?void 0:n.limitRatio)&&(u+=F/e.h*e.w),g+=F,d=t-u/2,f=i-g/2)}break;case"resize-bottom":if(0===v)e.h+G>0&&(g+=G,!0===(null==(a=e.operations)?void 0:a.limitRatio)&&(d-=G/e.h*e.w/2,u+=G/e.h*e.w));else if(v>0||v<0){let t=w.x,i=w.y;if(v<90){F=_t(F,L);const e=Qt(v),o=F/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){F=0-_t(F,k);const e=Qt(v-90),o=F/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){F=_t(F,k);const e=Qt(v-180),o=F/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){F=_t(F,k);const e=Qt(v-270),o=F/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}g+F>0&&(!0===(null==(r=e.operations)?void 0:r.limitRatio)&&(u+=F/e.h*e.w),g+=F,d=t-u/2,f=i-g/2)}break;case"resize-left":if(0===v)e.w-Y>0&&(d+=Y,u-=Y,!0===(null==(s=e.operations)?void 0:s.limitRatio)&&(g-=Y/e.w*e.h,f+=Y/e.w*e.h/2));else if(v>0||v<0){let t=w.x,i=w.y;if(v<90){D=0-_t(D,O);const e=Qt(v),o=D/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){D=_t(D,O);const e=Qt(v-90),o=D/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){D=_t(D,j);const e=Qt(v-180),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){D=_t(D,j);const e=Qt(v-270),o=D/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}u+D>0&&(!0===(null==(l=e.operations)?void 0:l.limitRatio)&&(g+=D/e.w*e.h),u+=D,d=t-u/2,f=i-g/2)}break;case"resize-right":if(0===v)e.w+Y>0&&(u+=Y,!0===(null==(h=e.operations)?void 0:h.limitRatio)&&(f-=Y*e.h/e.w/2,g+=Y*e.h/e.w));else if(v>0||v<0){let t=w.x,i=w.y;if(v<90){D=_t(D,j);const e=Qt(v),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){D=_t(D,G);const e=Qt(v-90),o=D/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){D=_t(D,G);const e=Qt(v-180),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e),D=0-D}else if(v<360){D=_t(D,Y);const e=Qt(v-270),o=D/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}u+D>0&&(!0===(null==(c=e.operations)?void 0:c.limitRatio)&&(g+=D/e.w*e.h),u+=D,d=t-u/2,f=i-g/2)}break;case"resize-top-left":if(0===v)u-Y>0&&(d+=Y,u-=Y),g-G>0&&(f+=G,g-=G);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){F=0-_t(F,L),D=0-_t(D,m?0-F:O);const i=F/2;e+=i*Math.sin(y),t-=i*Math.cos(y);const o=D/2;e-=o*Math.cos(y),t-=o*Math.sin(y)}else if(v<180){F=_t(F,k),D=_t(D,m?F:O);const i=Qt(v-90),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=D/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){F=_t(F,L),D=_t(D,m?F:j);const i=Qt(v-180),o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=D/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){F=0-_t(F,k),D=_t(D,m?F:j);const i=Qt(v-270),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=D/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+F>0&&(g+=F),u+D>0&&(u+=D),d=e-u/2,f=t-g/2}break;case"resize-top-right":if(0===v)u+Y>0&&(u+=Y),g-G>0&&(f+=G,g-=G);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){F=0-_t(F,L),D=_t(D,m?F:j);const i=Qt(v),o=F/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=D/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){F=_t(F,k),D=_t(D,m?F:j);const i=Qt(v-90),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=D/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){const i=Qt(v-180);F=_t(F,L),D=_t(D,m?F:0-O);const o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=D/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){F=0-_t(F,k),D=_t(D,m?F:O);const i=Qt(v-270),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=D/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+F>0&&(g+=F),u+D>0&&(u+=D),d=e-u/2,f=t-g/2}break;case"resize-bottom-left":if(0===v)e.h+G>0&&(g+=G),e.w-Y>0&&(d+=Y,u-=Y);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){F=_t(F,L),D=0-_t(D,m?0-F:O);const i=Qt(v),o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=D/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<180){F=0-_t(F,k),D=_t(D,m?F:O);const i=Qt(v-90),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=D/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){F=_t(F,k),D=_t(D,m?F:j);const i=Qt(v-180),o=F/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=D/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){F=_t(F,k),D=_t(D,m?F:j);const i=Qt(v-270),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=D/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+F>0&&(g+=F),u+D>0&&(u+=D),d=e-u/2,f=t-g/2}break;case"resize-bottom-right":if(0===v)e.h+G>0&&(g+=G),e.w+Y>0&&(u+=Y);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){F=_t(F,L),D=_t(D,m?F:j);const i=Qt(v),o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=D/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){F=0-_t(F,k),D=_t(D,m?F:G);const i=Qt(v-90),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=D/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){F=_t(F,k),D=_t(D,m?F:0-j);const i=Qt(v-180),o=F/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=D/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){F=_t(F,k),D=_t(D,m?F:O);const i=Qt(v-270),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=D/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+F>0&&(g+=F),u+D>0&&(u+=D),d=e-u/2,f=t-g/2}}return{x:d,y:f,w:u,h:g,angle:e.angle}}(a[0],{scale:r,start:n,end:s,resizeType:u,sharer:i});a[0].x=h.x,a[0].y=h.y,"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),s=Math.max(n,a);e.w=i,e.h=o;const l={xRatio:n,yRatio:a,minRatio:r,maxRatio:s};"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{ve(e,l)})),ge(e,l)}(a[0],{w:h.w,h:h.h}):(a[0].w=h.w,a[0].h=h.h),f([a[0]]),t.drawFrame()}}else"area"===g&&(l="area",i.setSharedStorage(Dt,e.point),t.drawFrame());s=e.point},pointEnd(e){l=null;const o=i.getActiveStorage("data"),r=i.getSharedStorage(Ot),h=i.getSharedStorage(Wt),c=i.getActiveViewSizeInfo();let d=!1;if(s=null,"resize"===h&&r)i.setSharedStorage(Ot,null),d=!0;else if("area"===h){if(i.setSharedStorage(Wt,null),o){const e=i.getSharedStorage(jt),t=i.getSharedStorage(Dt);if(e&&t){const{elements:a}=function(e,t){const i=[],o=[],n=[],{calculator:a,viewScaleInfo:r,viewSizeInfo:s,start:l,end:h}=t;if(!(Array.isArray(e.elements)&&l&&h))return{indexes:i,uuids:o,elements:n};const c=Math.min(l.x,h.x),d=Math.max(l.x,h.x),f=Math.min(l.y,h.y),u=Math.max(l.y,h.y);return e.elements.forEach(((e,t)=>{const l=a.elementSize(e,r,s),h=V(l);if(h.x>=c&&h.x<=d&&h.y>=f&&h.y<=u&&(i.push(t),o.push(e.uuid),n.push(e),l.angle&&(l.angle>0||l.angle<0))){const e=$(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))}}})),{indexes:i,uuids:o,elements:n}}(o,{start:e,end:t,calculator:n,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()});a.length>0&&(i.setSharedStorage(Wt,"drag-list"),f(a,{triggerEvent:!0}),d=!0)}}}else if("drag-list"===h)i.setSharedStorage(Wt,"drag-list-end"),d=!0;else if(o){n.getPointElement(e.point,{data:o,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}).element?(i.setSharedStorage(Wt,"select"),d=!0):i.setSharedStorage(Wt,null)}null===i.getSharedStorage(Wt)&&(g(),d=!0);(()=>{if(d){if(o&&Array.isArray(null==o?void 0:o.elements)&&["drag","drag-list"].includes(h)){const e=function(e,t,i){const o=K(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}}(o.elements,c,{extend:!0});i.setActiveStorage("contextHeight",e.contextSize.contextHeight),i.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(o&&["drag","drag-list","drag-list-end","resize"].includes(h)){let e="drag-element";a.trigger("change",{data:o,type:e})}t.drawFrame()}})()},pointLeave(){s=null,g(),t.drawFrame()},doubleClick(e){var o,n;const r=Kt(e.point,u());if(1===r.elements.length&&"group"===(null==(o=r.elements[0])?void 0:o.type)){if(!0===c(r.elements[0]))return i.setSharedStorage(Wt,null),void t.drawFrame()}else 1===r.elements.length&&"text"===(null==(n=r.elements[0])?void 0:n.type)&&a.trigger(ei,{element:r.elements[0],groupQueue:i.getSharedStorage(Gt)||[],viewScaleInfo:i.getActiveViewScaleInfo()});i.setSharedStorage(Wt,null)},beforeDrawFrame({snapshot:t}){const{activeStore:i,sharedStore:o}=t,{scale:a,offsetLeft:s,offsetTop:l,offsetRight:c,offsetBottom:d,width:f,height:u,contextHeight:g,contextWidth:v,devicePixelRatio:w}=i,y=e.sharer,m={scale:a,offsetLeft:s,offsetTop:l,offsetRight:c,offsetBottom:d},p={width:f,height:u,contextHeight:g,contextWidth:v,devicePixelRatio:w},x=o[Ft][0],S=o[kt],b=o[Lt],A=o[Wt],I=o[jt],M=o[Dt],z=o[Gt],R=o[Nt],P={calculator:n,viewScaleInfo:m,viewSizeInfo:p},T=x?le(x,{groupQueue:z,controllerSize:10,viewScaleInfo:m}):null;if((null==z?void 0:z.length)>0)!function(e,t,i){for(let o=0;o<t.length;o++){const n=t[o],a={borderColor:Vt,borderWidth:2,background:"transparent",lineDash:[4,4]};Xt(e,te(n,i),a)}}(r,R,P),S&&"drag"!==A&&Ht(r,b,P),x&&["select","drag","resize"].includes(A)&&Zt(r,T,{...P});else if(S&&"drag"!==A&&Ht(r,b,P),x&&["select","drag","resize"].includes(A))Zt(r,T,{...P});else if("area"===A&&I&&M)!function(e,t){const{start:i,end:o}=t;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=Vt,e.fillStyle="#1976d24f",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()}(r,{start:I,end:M});else if(["drag-list","drag-list-end"].includes(A)){const e=qt(h(),{viewScaleInfo:y.getActiveViewScaleInfo(),viewSizeInfo:y.getActiveViewSizeInfo(),calculator:n});e&&function(e,t){const{areaSize:i}=t,{x:o,y:n,w:a,h:r}=i;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=Vt,e.fillStyle="#1976d21c",e.beginPath(),e.moveTo(o,n),e.lineTo(o+a,n),e.lineTo(o+a,n+r),e.lineTo(o,n+r),e.closePath(),e.stroke(),e.fill()}(r,{areaSize:e})}}}},e.MiddlewareTextEditor=e=>{const{eventHub:t,boardContent:i,viewer:o}=e,n=i.boardContext.canvas,a=document.createElement("textarea"),r=document.createElement("div"),s=e.container||document.body,l=document.createElement("div");let h=null;r.appendChild(a),r.style.position="absolute",l.appendChild(r),l.style.position="fixed",l.style.top="0",l.style.bottom="0",l.style.left="0",l.style.right="0",l.style.display="none",s.appendChild(l);const c=()=>{l.style.display="none",h=null},d=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:n,y:a,w:r,h:s}=t,l=U(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=`${s}px`,o.style.transform=`rotate(${l}deg)`,i.appendChild(o),o},f=e=>{const{viewScaleInfo:t,element:i,groupQueue:o}=e,{scale:n,offsetTop:s,offsetLeft:l}=t;r.children&&Array.from(r.children).forEach((e=>{e.remove()}));let h=r;for(let e=0;e<o.length;e++){const t=o[e],{x:i,y:a,w:r,h:c}=t,f={x:i*n,y:a*n,w:r*n,h:c*n,angle:U(t.angle||0)};0===e&&(f.x+=l,f.y+=s),h=d({size:f,parent:h})}const c={...ti,...i.detail};let f=i.x*n+l,u=i.y*n+s,g=i.w*n,v=i.h*n;o.length>0&&(f=i.x*n,u=i.y*n,g=i.w*n,v=i.h*n),a.style.position="absolute",a.style.left=`${f}px`,a.style.top=`${u}px`,a.style.width=`${g}px`,a.style.height=`${v}px`,a.style.transform=`rotate(${U(i.angle||0)}deg)`,a.style.boxSizing="border-box",a.style.border="1px solid #1973ba",a.style.resize="none",a.style.overflow="hidden",a.style.wordBreak="break-all",a.style.background="#FFFFFF",a.style.color="#333333",a.style.fontSize=c.fontSize*n+"px",a.style.lineHeight=c.lineHeight*n+"px",a.style.fontFamily=c.fontFamily,a.style.fontWeight=`${c.fontWeight}`,a.value=c.text||"",h.appendChild(a)},u=()=>{const{left:e,top:t,width:i,height:o}=(()=>{const e=n.getBoundingClientRect(),{left:t,top:i,width:o,height:a}=e;return{left:t,top:i,width:o,height:a}})();r.style.position="absolute",r.style.overflow="hidden",r.style.top=`${t}px`,r.style.left=`${e}px`,r.style.width=`${i}px`,r.style.height=`${o}px`};l.addEventListener("click",(()=>{c()})),a.addEventListener("click",(e=>{e.stopPropagation()})),a.addEventListener("input",(e=>{h&&(h.detail.text=e.target.value||"",o.drawFrame())})),a.addEventListener("blur",(()=>{c()}));const g=e=>{var t;(null==e?void 0:e.element)&&"text"===(null==(t=null==e?void 0:e.element)?void 0:t.type)&&(h=e.element),(e=>{u(),f(e),l.style.display="block"})(e)};return{use(){t.on(ei,g)},disuse(){t.off(ei,g)}}},e.middlewareEventRuler=Mi,e.middlewareEventScale=yi,e.middlewareEventSelect=ii,e.middlewareEventSelectClear=oi,e.middlewareEventTextEdit=ei,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.5",
3
+ "version": "0.4.0-beta.6",
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.5"
24
+ "@idraw/types": "^0.4.0-beta.6"
25
25
  },
26
26
  "dependencies": {},
27
27
  "peerDependencies": {
28
- "@idraw/board": "^0.4.0-beta.5",
29
- "@idraw/renderer": "^0.4.0-beta.5",
30
- "@idraw/util": "^0.4.0-beta.5"
28
+ "@idraw/board": "^0.4.0-beta.6",
29
+ "@idraw/renderer": "^0.4.0-beta.6",
30
+ "@idraw/util": "^0.4.0-beta.6"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public",