@idraw/core 0.4.0-beta.3 → 0.4.0-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/esm/config.d.ts +1 -0
  2. package/dist/esm/config.js +1 -0
  3. package/dist/esm/index.d.ts +15 -5
  4. package/dist/esm/index.js +29 -8
  5. package/dist/esm/lib/cursor-image.d.ts +1 -0
  6. package/dist/esm/lib/cursor-image.js +1 -0
  7. package/dist/esm/lib/cursor.d.ts +3 -12
  8. package/dist/esm/lib/cursor.js +136 -112
  9. package/dist/esm/middleware/dragger/index.d.ts +2 -2
  10. package/dist/esm/middleware/dragger/index.js +1 -0
  11. package/dist/esm/middleware/info/draw-info.d.ts +31 -0
  12. package/dist/esm/middleware/info/draw-info.js +110 -0
  13. package/dist/esm/middleware/info/index.d.ts +3 -0
  14. package/dist/esm/middleware/info/index.js +110 -0
  15. package/dist/esm/middleware/info/types.d.ts +3 -0
  16. package/dist/esm/middleware/info/types.js +1 -0
  17. package/dist/esm/middleware/layout-selector/config.d.ts +9 -0
  18. package/dist/esm/middleware/layout-selector/config.js +9 -0
  19. package/dist/esm/middleware/layout-selector/index.d.ts +5 -0
  20. package/dist/esm/middleware/layout-selector/index.js +332 -0
  21. package/dist/esm/middleware/layout-selector/types.d.ts +15 -0
  22. package/dist/esm/middleware/layout-selector/types.js +2 -0
  23. package/dist/esm/middleware/layout-selector/util.d.ts +8 -0
  24. package/dist/esm/middleware/layout-selector/util.js +108 -0
  25. package/dist/esm/middleware/ruler/index.d.ts +3 -2
  26. package/dist/esm/middleware/ruler/index.js +12 -9
  27. package/dist/esm/middleware/ruler/types.d.ts +3 -0
  28. package/dist/esm/middleware/ruler/types.js +1 -0
  29. package/dist/esm/middleware/ruler/util.d.ts +15 -4
  30. package/dist/esm/middleware/ruler/util.js +81 -4
  31. package/dist/esm/middleware/scaler/index.d.ts +2 -2
  32. package/dist/esm/middleware/scaler/index.js +1 -0
  33. package/dist/esm/middleware/scroller/config.d.ts +2 -0
  34. package/dist/esm/middleware/scroller/config.js +2 -0
  35. package/dist/esm/middleware/scroller/index.d.ts +2 -1
  36. package/dist/esm/middleware/scroller/index.js +33 -5
  37. package/dist/esm/middleware/scroller/types.d.ts +11 -0
  38. package/dist/esm/middleware/scroller/types.js +1 -0
  39. package/dist/esm/middleware/scroller/util.d.ts +1 -1
  40. package/dist/esm/middleware/scroller/util.js +22 -17
  41. package/dist/esm/middleware/selector/config.d.ts +12 -0
  42. package/dist/esm/middleware/selector/config.js +12 -0
  43. package/dist/esm/middleware/selector/draw-auxiliary.d.ts +7 -0
  44. package/dist/esm/middleware/selector/draw-auxiliary.js +46 -0
  45. package/dist/esm/middleware/selector/draw-base.d.ts +30 -0
  46. package/dist/esm/middleware/selector/draw-base.js +100 -0
  47. package/dist/esm/middleware/selector/draw-reference.d.ts +5 -0
  48. package/dist/esm/middleware/selector/draw-reference.js +31 -0
  49. package/dist/esm/middleware/selector/draw-wrapper.d.ts +9 -1
  50. package/dist/esm/middleware/selector/draw-wrapper.js +34 -26
  51. package/dist/esm/middleware/selector/index.d.ts +7 -4
  52. package/dist/esm/middleware/selector/index.js +280 -45
  53. package/dist/esm/middleware/selector/reference.d.ts +13 -0
  54. package/dist/esm/middleware/selector/reference.js +267 -0
  55. package/dist/esm/middleware/selector/types.d.ts +9 -4
  56. package/dist/esm/middleware/selector/types.js +2 -1
  57. package/dist/esm/middleware/selector/util.d.ts +11 -2
  58. package/dist/esm/middleware/selector/util.js +36 -14
  59. package/dist/esm/middleware/text-editor/index.d.ts +20 -2
  60. package/dist/esm/middleware/text-editor/index.js +92 -16
  61. package/dist/index.global.js +3685 -953
  62. package/dist/index.global.min.js +1 -1
  63. package/package.json +5 -5
@@ -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)},s=(e,t,i)=>(a(e,t,"read from private field"),i?i.call(e):t.get(e)),r=(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 m={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 x=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function s(e){try{l(o.next(e))}catch(e){a(e)}}function r(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(s,r)}l((o=o.apply(e,t||[])).next())}))};const{Image:S}=window;function y(e){return new Promise(((t,i)=>{const o=new S;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function p(e){return x(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 y(t)}))}function b(e,t){return x(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"}),s=new FileReader;s.readAsDataURL(a),s.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},s.onerror=function(e){n(e)}}))}(e,t);return yield y(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 P={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 R,T,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");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},C=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){R.set(this,void 0),T.set(this,void 0),E(this,R,e,"f"),E(this,T,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f")}$undoPixelRatio(e){return e/C(this,T,"f").devicePixelRatio}$doPixelRatio(e){return C(this,T,"f").devicePixelRatio*e}$getContext(){return C(this,R,"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"}`),C(this,R,"f").font=`${t.join(" ")}`}$getOffscreenCanvas(){return C(this,T,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:a}=C(this,R,"f");a.width=t*o,a.height=i*o,E(this,T,Object.assign(Object.assign({},C(this,T,"f")),{devicePixelRatio:o}),"f"),!0===n&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=C(this,T,"f"),{width:t,height:i}=C(this,R,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return C(this,R,"f").canvas}get fillStyle(){return C(this,R,"f").fillStyle}set fillStyle(e){C(this,R,"f").fillStyle=e}get strokeStyle(){return C(this,R,"f").strokeStyle}set strokeStyle(e){C(this,R,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(C(this,R,"f").lineWidth)}set lineWidth(e){C(this,R,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return C(this,R,"f").textAlign}set textAlign(e){C(this,R,"f").textAlign=e}get textBaseline(){return C(this,R,"f").textBaseline}set textBaseline(e){C(this,R,"f").textBaseline=e}get globalAlpha(){return C(this,R,"f").globalAlpha}set globalAlpha(e){C(this,R,"f").globalAlpha=e}get shadowColor(){return C(this,R,"f").shadowColor}set shadowColor(e){C(this,R,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(C(this,R,"f").shadowOffsetX)}set shadowOffsetX(e){C(this,R,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(C(this,R,"f").shadowOffsetY)}set shadowOffsetY(e){C(this,R,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(C(this,R,"f").shadowBlur)}set shadowBlur(e){C(this,R,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return C(this,R,"f").lineCap}set lineCap(e){C(this,R,"f").lineCap=e}get globalCompositeOperation(){return C(this,R,"f").globalCompositeOperation}set globalCompositeOperation(e){C(this,R,"f").globalCompositeOperation=e}fill(...e){return C(this,R,"f").fill(...e)}arc(e,t,i,o,n,a){return C(this,R,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,a)}rect(e,t,i,o){return C(this,R,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return C(this,R,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return C(this,R,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return C(this,R,"f").beginPath()}closePath(){return C(this,R,"f").closePath()}lineTo(e,t){return C(this,R,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return C(this,R,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return C(this,R,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}getLineDash(){return C(this,R,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return C(this,R,"f").setLineDash(t)}stroke(e){return e?C(this,R,"f").stroke(e):C(this,R,"f").stroke()}translate(e,t){return C(this,R,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return C(this,R,"f").rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],n=e[3],a=e[4],s=e[e.length-4],r=e[e.length-3],l=e[e.length-2],h=e[e.length-1];return 9===e.length?C(this,R,"f").drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(h)):C(this,R,"f").drawImage(t,this.$doPixelRatio(s),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(h))}createPattern(e,t){return C(this,R,"f").createPattern(e,t)}measureText(e){return C(this,R,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?C(this,R,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):C(this,R,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?C(this,R,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):C(this,R,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){C(this,R,"f").save()}restore(){C(this,R,"f").restore()}scale(e,t){C(this,R,"f").scale(e,t)}circle(e,t,i,o,n,a,s,r){C(this,R,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,a,s,r)}isPointInPath(e,t){return C(this,R,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return C(this,R,"f").clip(...e)}setTransform(e,t,i,o,n,a){return C(this,R,"f").setTransform(e,t,i,o,n,a)}getTransform(){return C(this,R,"f").getTransform()}createLinearGradient(e,t,i,o){return C(this,R,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,a){return C(this,R,"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 C(this,R,"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})}R=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 L(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}class k{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 Z(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 s=0,r=0;return 0===n?(s=0,r=0-a):n>0&&n<Math.PI/2?(s=Math.sin(n)*a,r=0-Math.cos(n)*a):n===Math.PI/2?(s=a,r=0):n>Math.PI/2&&n<Math.PI?(s=Math.sin(Math.PI-n)*a,r=Math.cos(Math.PI-n)*a):n===Math.PI?(s=0,r=a):n>Math.PI&&n<1.5*Math.PI?(s=0-Math.sin(n-Math.PI)*a,r=Math.cos(n-Math.PI)*a):n===1.5*Math.PI?(s=0-a,r=0):n>1.5*Math.PI&&n<2*Math.PI?(s=0-Math.sin(2*Math.PI-n)*a,r=0-Math.cos(2*Math.PI-n)*a):n===2*Math.PI&&(s=0,r=0-a),s+=e.x,r+=e.y,{x:s,y:r}}function H(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:s,angle:r=0}=e,l=Z(V({x:t,y:n,w:a,h:s,angle:r}),{x:i,y:o},B(r));i=l.x,o=l.y})),{x:i,y:o}}return e}function _(e,t,i){const{x:o,y:n,w:a,h:s}=e;let r={x:o,y:n},l={x:o+a,y:n},h={x:o+a,y:n+s},c={x:o,y:n+s};if(i&&(i>0||i<0)){const e=B(U(i));r=Z(t,r,e),l=Z(t,l,e),h=Z(t,h,e),c=Z(t,c,e)}return[r,l,h,c]}function Q(e){const{angle:t=0}=e;return _(e,V(e),t)}function $(e,t,i){return[Z(e,{x:t[0].x,y:t[0].y},i),Z(e,{x:t[1].x,y:t[1].y},i),Z(e,{x:t[2].x,y:t[2].y},i),Z(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=Q(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),s=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(s-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:s,angle:r}=e,{scale:l,offsetTop:h,offsetLeft:c}=i;return{x:o*l+c,y:n*l+h,w:a*l,h:s*l,angle:r}}function ee(e,t){const{viewScaleInfo:i}=t,{x:o,y:n}=e,{scale:a,offsetTop:s,offsetLeft:r}=i;return{x:o*a+r,y:n*a+s}}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:s=0}=o,{x:r,y:l,w:h,h:c}=q(o,{viewScaleInfo:n,viewSizeInfo:a}),d=Q({x:r,y:l,w:h,h:c,angle:s});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):_(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:s,y:r,w:l,h:h,angle:c=0}=a[e];let d;if(i+=s,o+=r,0===e){const e={x:i,y:o,w:l,h:h,angle:c};d=ne({x:s,y:r,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 se(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 re(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:s,y:r,w:l,h:h,angle:c=0}=e,d=[{uuid:f(),x:s,y:r,w:l,h:h,angle:c,type:"group",detail:{children:[]}},...i];let u=0;d.forEach((({angle:e=0})=>{u+=e}));const g=se(e,{groupQueue:i}),v=L(g[0],g[1]),w=L(g[1],g[2]),m=L(g[2],g[3]),x=L(g[3],g[0]),S=g[0],y=g[1],p=g[2],b=g[3],A=re(S,{size:a,angle:u}),I=re(y,{size:a,angle:u}),M=re(b,{size:a,angle:u}),z=re(p,{size:a,angle:u}),P=ne(A),R=ne(I),T=ne(M),E=ne(z),C=[P[1],R[0],R[3],P[2]],W=[R[3],R[2],E[1],E[0]],O=[T[1],E[0],E[3],T[2]];return{elementWrapper:g,left:{type:"left",vertexes:[P[3],P[2],T[1],T[0]],center:x},right:{type:"right",vertexes:W,center:w},top:{type:"top",vertexes:C,center:v},bottom:{type:"bottom",vertexes:O,center:m},topLeft:{type:"top-left",vertexes:P,center:S},topRight:{type:"top-right",vertexes:R,center:y},bottomLeft:{type:"bottom-left",vertexes:T,center:b},bottomRight:{type:"bottom-right",vertexes:E,center:p}}}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:s}=e.detail;"number"!=typeof s&&(n=0);let{x:r,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 s&&(f=(s||0)*o),"border-box"===a?(r=e.x+f/2,l=e.y+f/2,h=e.w-f,c=e.h-f):"content-box"===a?(r=e.x-f/2,l=e.y-f/2,h=e.w+f,c=e.h+f):(r=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:r,y:l,w:h,h:c,radiusList:d}}function ue(e,t,i){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:n,opacity:a=1}=i,{x:s,y:r}=o,{scale:l}=n;if("linear-gradient"===(null==t?void 0:t.type)){const{start:i,end:o,stops:n}=t,h={x:s+i.x*l,y:r+i.y*l},c={x:s+o.x*l,y:r+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:s+i.x*l,y:r+i.y*l,radius:i.radius*l},c={x:s+o.x*l,y:r+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 ge={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 ve(e,t,i){const{pattern:o,renderContent:n,originElem:a,calcElemSize:s,viewScaleInfo:r,viewSizeInfo:l}=i||{};!function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewScaleInfo:s,viewSizeInfo:r}=i,l=s.scale*r.devicePixelRatio,{clipPath:h}=(null==n?void 0:n.detail)||{};if(h&&a&&h.commands){const{x:i,y:n,w:s,h:r}=a,{originW:c,originH:d,originX:f,originY:u}=h,g=s/c,v=r/d,w=i-f*g,m=n-u*v;e.save(),e.translate(w,m),e.scale(l*g,l*v);const x=he(h.commands||[]),S=new Path2D(x);e.clip(S),e.translate(0-w,0-m),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:s,viewScaleInfo:r,viewSizeInfo:l,renderContent:()=>{var i,a;void 0!==(null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.opacity)&&(null===(a=null==t?void 0:t.detail)||void 0===a?void 0:a.opacity)>=0?e.globalAlpha=t.detail.opacity:e.globalAlpha=1,function(e,t,i){var o,n;const{pattern:a,viewScaleInfo:s,viewSizeInfo:r}=i,l=[];if(t.detail,t.detail,t.detail.background||a){const{x:i,y:h,w:c,h:d,radiusList:f}=fe(t,{viewScaleInfo:s,viewSizeInfo:r});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(m.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=ue(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:s,opacity:e.globalAlpha});e.fillStyle=o}else if("radial-gradient"===(null===(n=t.detail.background)||void 0===n?void 0:n.type)){const o=ue(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:s,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:r,viewSizeInfo:l}),null==n||n(),function(e,t,i){var o,n;if(0===t.detail.borderWidth)return;if(!c(t.detail.borderColor))return;void 0!==(null===(o=null==t?void 0:t.detail)||void 0===o?void 0:o.opacity)&&(null===(n=null==t?void 0:t.detail)||void 0===n?void 0:n.opacity)>=0?e.globalAlpha=t.detail.opacity:e.globalAlpha=1;const{viewScaleInfo:a}=i,{scale:s}=a;let r=ge.borderColor;!0===c(t.detail.borderColor)&&(r=t.detail.borderColor);const{borderWidth:l,borderRadius:h,borderDash:d,boxSizing:f=ge.boxSizing}=t.detail;let u=0;"number"==typeof l&&(u=l||1);u*=s;let g=[0,0,0,0];if("number"==typeof h){const e=h*s;g=[e,e,e,e]}else Array.isArray(h)&&4===(null==h?void 0:h.length)&&(g=[h[0]*s,h[1]*s,h[2]*s,h[3]*s]);e.strokeStyle=r;let v=[];Array.isArray(d)&&d.length>0&&(v=d.map((e=>Math.ceil(e*s))));let w=0,m=0,x=0,S=0;Array.isArray(l)&&(w=(l[0]||0)*s,m=(l[1]||0)*s,x=(l[2]||0)*s,S=(l[3]||0)*s);if(S||m||w||x){e.lineCap="butt";let{x:i,y:o,w:n,h:a}=t;"border-box"===f?(i+=S/2,o+=w/2,n=n-S/2-m/2,a=a-w/2-x/2):"content-box"===f?(i-=S/2,o-=w/2,n=n+S/2+m/2,a=a+w/2+x/2):(i=t.x,o=t.y,n=t.w,a=t.h),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(i-S/2,o),e.lineTo(i+n+m/2,o),e.closePath(),e.stroke()),m&&(e.beginPath(),e.lineWidth=m,e.moveTo(i+n,o-w/2),e.lineTo(i+n,o+a+x/2),e.closePath(),e.stroke()),x&&(e.beginPath(),e.lineWidth=x,e.moveTo(i-S/2,o+a),e.lineTo(i+n+m/2,o+a),e.closePath(),e.stroke()),S&&(e.beginPath(),e.lineWidth=S,e.moveTo(i,o-w/2),e.lineTo(i,o+a+x/2),e.closePath(),e.stroke())}else{let{x:i,y:o,w:n,h:a}=t;"border-box"===f?(i=t.x+u/2,o=t.y+u/2,n=t.w-u,a=t.h-u):"content-box"===f?(i=t.x-u/2,o=t.y-u/2,n=t.w+u,a=t.h+u):(i=t.x,o=t.y,n=t.w,a=t.h),v.length>0?e.lineCap="butt":e.lineCap="square",n=Math.max(n,1),a=Math.max(a,1),g=g.map((e=>Math.min(e,n/2,a/2))),e.setLineDash(v),e.lineWidth=u,e.beginPath(),e.moveTo(i+g[0],o),e.arcTo(i+n,o,i+n,o+a,g[1]),e.arcTo(i+n,o+a,i,o+a,g[2]),e.arcTo(i,o+a,i,o,g[3]),e.arcTo(i,o,i+n,o,g[0]),e.closePath(),e.stroke(),e.globalAlpha=1}e.setLineDash([])}(e,t,{viewScaleInfo:r,viewSizeInfo:l}),e.globalAlpha=1}})}function we(e,t,i){const{detail:o}=t,{viewScaleInfo:n,renderContent:a}=i,{shadowColor:s,shadowOffsetX:r,shadowOffsetY:l,shadowBlur:h}=o;P.number(h)?(e.save(),e.shadowColor=s||ge.shadowColor,e.shadowOffsetX=(r||0)*n.scale,e.shadowOffsetY=(l||0)*n.scale,e.shadowBlur=(h||0)*n.scale,a(),e.restore()):a()}const me={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 xe(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}=i,{x:s,y:r,w:l,h:h,angle:c}=(null==o?void 0:o.elementSize(t,n,a))||t,d=Object.assign(Object.assign({},t),{x:s,y:r,w:l,h:h,angle:c});N(e,{x:s,y:r,w:l,h:h,angle:c},(()=>{we(e,d,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{ve(e,d,{originElem:t,calcElemSize:{x:s,y:r,w:l,h:h,angle:c},viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{}})}})}))}(e,t,i);break;case"circle":!function(e,t,i){const{detail:o,angle:n}=t,{background:a="#000000",borderColor:s="#000000",borderWidth:r=0}=o,{calculator:l,viewScaleInfo:h,viewSizeInfo:c}=i,{x:d,y:f,w:u,h:g}=(null==l?void 0:l.elementSize({x:t.x,y:t.y,w:t.w,h:t.h},h,c))||t,v=Object.assign(Object.assign({},t),{x:d,y:f,w:u,h:g,angle:n});N(e,{x:d,y:f,w:u,h:g,angle:n},(()=>{we(e,v,{viewScaleInfo:h,viewSizeInfo:c,renderContent:()=>{var i,o;const n=u/2,l=g/2,c=d+n,v=f+l;if(void 0!==(null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.opacity)&&(null===(o=null==t?void 0:t.detail)||void 0===o?void 0:o.opacity)>=0?e.globalAlpha=t.detail.opacity:e.globalAlpha=1,"number"==typeof r&&r>0){const t=r/2+n,i=r/2+l;e.beginPath(),e.strokeStyle=s,e.lineWidth=r,e.circle(c,v,t,i,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath();const w=ue(e,a,{viewElementSize:{x:d,y:f,w:u,h:g},viewScaleInfo:h,opacity:e.globalAlpha});e.fillStyle=w,e.circle(c,v,n,l,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=1}})}))}(e,t,i);break;case"text":!function(e,t,i){const{calculator:o,viewScaleInfo:n,viewSizeInfo:a}=i,{x:s,y:r,w:l,h:h,angle:d}=(null==o?void 0:o.elementSize(t,n,a))||t,f=Object.assign(Object.assign({},t),{x:s,y:r,w:l,h:h,angle:d});N(e,{x:s,y:r,w:l,h:h,angle:d},(()=>{ve(e,f,{originElem:t,calcElemSize:{x:s,y:r,w:l,h:h,angle:d},viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{const i=Object.assign(Object.assign({},me),t.detail),o=(i.fontSize||me.fontSize)*n.scale,a=i.lineHeight?i.lineHeight*n.scale:o;e.fillStyle=t.detail.color||me.color,e.textBaseline="top",e.$setFont({fontWeight:i.fontWeight,fontSize:o,fontFamily:i.fontFamily});const d=i.text.replace(/\r\n/gi,"\n"),f=a,u=d.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(l)?o+=t[n]||"":(g.push({text:o,width:e.$undoPixelRatio(e.measureText(o).width)}),o=t[n]||"",v++),!((v+1)*f>h));n++)if(t.length-1===n&&(v+1)*f<h){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<h&&("top"===t.detail.verticalAlign?w=0:"bottom"===t.detail.verticalAlign?w+=h-g.length*f:w+=(h-g.length*f)/2);{const t=r+w;void 0!==i.textShadowColor&&c(i.textShadowColor)&&(e.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&P.number(i.textShadowOffsetX)&&(e.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&P.number(i.textShadowOffsetY)&&(e.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&P.number(i.textShadowBlur)&&(e.shadowBlur=i.textShadowBlur),g.forEach(((o,n)=>{let a=s;"center"===i.textAlign?a=s+(l-o.width)/2:"right"===i.textAlign&&(a=s+(l-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:s}=i,{x:r,y:l,w:h,h:c,angle:d}=(null==n?void 0:n.elementSize(t,a,s))||t,f=Object.assign(Object.assign({},t),{x:r,y:l,w:h,h:c,angle:d});N(e,{x:r,y:l,w:h,h:c,angle:d},(()=>{we(e,f,{viewScaleInfo:a,viewSizeInfo:s,renderContent:()=>{ve(e,f,{originElem:t,calcElemSize:{x:r,y:l,w:h,h:c,angle:d},viewScaleInfo:a,viewSizeInfo:s,renderContent:()=>{if(o||i.loader.load(t,i.elementAssets||{}),"image"===t.type&&o){const{opacity:i}=t.detail;e.globalAlpha=i||1;const{x:n,y:r,w:l,h:h,radiusList:c}=fe(f,{viewScaleInfo:a,viewSizeInfo:s});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+c[0],r),e.arcTo(n+l,r,n+l,r+h,c[1]),e.arcTo(n+l,r+h,n,r+h,c[2]),e.arcTo(n,r+h,n,r,c[3]),e.arcTo(n,r,n+l,r,c[0]),e.closePath(),e.fill(),e.clip(),e.drawImage(o,n,r,l,h),e.globalAlpha=1,e.restore()}}})}})}))}(e,t,i);break;case"svg":!function(e,t,i){const o=i.loader.getContent(t),{calculator:n,viewScaleInfo:a,viewSizeInfo:s}=i,{x:r,y:l,w:h,h:c,angle:d}=(null==n?void 0:n.elementSize(t,a,s))||t;N(e,{x:r,y:l,w:h,h:c,angle:d},(()=>{if(o||i.loader.load(t,i.elementAssets||{}),"svg"===t.type&&o){const{opacity:i}=t.detail;e.globalAlpha=i||1,e.drawImage(o,r,l,h,c),e.globalAlpha=1}}))}(e,t,i);break;case"html":!function(e,t,i){const o=i.loader.getContent(t),{calculator:n,viewScaleInfo:a,viewSizeInfo:s}=i,{x:r,y:l,w:h,h:c,angle:d}=(null==n?void 0:n.elementSize(t,a,s))||t;N(e,{x:r,y:l,w:h,h:c,angle:d},(()=>{if(o||i.loader.load(t,i.elementAssets||{}),"html"===t.type&&o){const{opacity:i}=t.detail;e.globalAlpha=i||1,e.drawImage(o,r,l,h,c),e.globalAlpha=1}}))}(e,t,i);break;case"path":!function(e,t,i){const{detail:o}=t,{originX:n,originY:a,originW:s,originH:r}=o,{calculator:l,viewScaleInfo:h,viewSizeInfo:c}=i,{x:d,y:f,w:u,h:g,angle:v}=(null==l?void 0:l.elementSize(t,h,c))||t,w=u/s,m=g/r,x=d-n*w,S=f-a*m,y=h.scale*c.devicePixelRatio,p=Object.assign(Object.assign({},t),{x:d,y:f,w:u,h:g,angle:v});N(e,{x:d,y:f,w:u,h:g,angle:v},(()=>{ve(e,p,{originElem:t,calcElemSize:{x:d,y:f,w:u,h:g,angle:v},viewScaleInfo:h,viewSizeInfo:c,renderContent:()=>{we(e,p,{viewScaleInfo:h,viewSizeInfo:c,renderContent:()=>{e.save(),e.translate(x,S),e.scale(y*w/h.scale,y*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(-x,-S),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}=i,{x:s,y:r,w:l,h:h,angle:c}=(null==o?void 0:o.elementSize({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},n,a))||t,d=Object.assign(Object.assign({},t),{x:s,y:r,w:l,h:h,angle:c});N(e,{x:s,y:r,w:l,h:h,angle:c},(()=>{we(e,d,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{ve(e,d,{originElem:t,calcElemSize:{x:s,y:r,w:l,h:h,angle:c},viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{const{x:o,y:s,w:r,h:l,radiusList:h}=fe(d,{viewScaleInfo:n,viewSizeInfo:a});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(o+h[0],s),e.arcTo(o+r,s,o+r,s+l,h[1]),e.arcTo(o+r,s+l,o,s+l,h[2]),e.arcTo(o,s+l,o,s,h[3]),e.arcTo(o,s,o+r,s,h[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{xe(e,s,Object.assign({},i))}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&(e.globalAlpha=1,e.restore())}})}})}))}(e,t,Object.assign(Object.assign({},i),{elementAssets:o}));break}}}catch(e){console.error(e)}}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"};var ye=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function s(e){try{l(o.next(e))}catch(e){a(e)}}function r(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(s,r)}l((o=o.apply(e,t||[])).next())}))};const pe=["image","svg","html"],be=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 Ae extends D{constructor(){super(),this._loadFuncMap={},this._currentLoadItemMap={},this._storageLoadItemMap={},this._registerLoadFunc("image",((e,t)=>ye(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 y(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),this._registerLoadFunc("html",((e,t)=>ye(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.width||e.w,height:e.detail.height||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),this._registerLoadFunc("svg",((e,t)=>ye(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 p(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}}))))}_registerLoadFunc(e,t){this._loadFuncMap[e]=t}_getLoadElementSource(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}_createLoadItem(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:this._getLoadElementSource(e)}}_emitLoad(e){const t=be(e.element),i=this._storageLoadItemMap[t];i?i.startTime<e.startTime&&(this._storageLoadItemMap[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(this._storageLoadItemMap[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime})))}_emitError(e){const t=be(e.element),i=this._storageLoadItemMap[t];i?i.startTime<e.startTime&&(this._storageLoadItemMap[t]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(this._storageLoadItemMap[t]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime})))}_loadResource(e,t){const i=this._createLoadItem(e),o=be(e);this._currentLoadItemMap[o]=i;const n=this._loadFuncMap[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",this._emitLoad(i)})).catch((t=>{console.warn(`Load element source "${i.source}" fail`,t,e),i.endTime=Date.now(),i.status="error",i.error=t,this._emitError(i)})))}_isExistingErrorStorage(e){var t;const i=be(e),o=null===(t=this._currentLoadItemMap)||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==this._getLoadElementSource(e))}load(e,t){this._isExistingErrorStorage(e)||pe.includes(e.type)&&this._loadResource(e,t)}getContent(e){var t,i;const o=be(e);return(null===(i=null===(t=this._storageLoadItemMap)||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}}var Ie,Me,ze,Pe,Re=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Te=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 Ee extends D{constructor(e){super(),Ie.add(this),Me.set(this,void 0),ze.set(this,new Ae),Re(this,Me,e,"f"),Te(this,Ie,"m",Pe).call(this)}updateOptions(e){Re(this,Me,e,"f")}drawData(e,t){const i=Te(this,ze,"f"),{calculator:o}=Te(this,Me,"f"),n=Te(this,Me,"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;for(let t=0;t<n.length;t++){const a=n[t],s=Object.assign(Object.assign({},a),{detail:Object.assign(Object.assign({},Se),null==a?void 0:a.detail)});if(!0===i.forceDrawAll||(null===(o=i.calculator)||void 0===o?void 0:o.isElementInView(s,i.viewScaleInfo,i.viewSizeInfo)))try{xe(e,s,i)}catch(e){console.error(e)}}}(n,e,Object.assign({loader:i,calculator:o,parentElementSize:a,elementAssets:e.assets},t))}scale(e){const{sharer:t}=Te(this,Me,"f");if(!t)return;const{data:i,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:s,width:r,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:s},viewSizeInfo:{width:r,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}}Me=new WeakMap,ze=new WeakMap,Ie=new WeakSet,Pe=function(){const e=Te(this,ze,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(()=>{}))};class Ce{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:s}=e,{x:r,y:l,w:h,h:c}=q(e,{viewScaleInfo:o,viewSizeInfo:i}),d=Q({x:r,y:l,w:h,h:c,angle:s}),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,s=t.x,r=t.y,l=t.x+t.w,h=t.y+t.h;return i<=l&&n>=s&&o<=h&&a>=r}(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:s,viewScaleInfo:r,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,s=0,d=0;for(let e=0;e<=t;e++)n+=h[e].x,s+=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:s+u.y,w:u.w,h:u.h,angle:d+(u.angle||0)},viewScaleInfo:r,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=s.elements.length-1;t>=0;t--){const i=s.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:r,viewSizeInfo:l})){c.index=t,c.element=i;break}}return c}(e,Object.assign(Object.assign({},t),{context2d:i}))}}function We(e){return e>0||e<0||0===e}class Oe extends D{constructor(e){super();const t=new k({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();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!!(We(e.x)&&We(e.y)&&e.x<=i&&e.y<=o)}}const je={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0};class De{constructor(){const e=new k({defaultStorage:je}),t=new k({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:Le}=window;class ke 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:s,offsetBottom:r,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:s,offsetBottom:r,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")&&Le((()=>{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,s=t/o.scale,r=i.x,l=i.y;return{moveX:r-r*s+(n*s-n),moveY:l-l*s+(a*s-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:s,height:r,contextWidth:l,contextHeight:h}=n;let c=o.offsetLeft,d=o.offsetRight,f=o.offsetTop,u=o.offsetBottom;return c+=t,f+=i,d=s-(l*a+c),u=r-(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:s,height:r,contextWidth:l,contextHeight:h}=a,c=0-o*i,d=0-n*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:s-(l*i+c/i),offsetBottom:r-(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:s}=o,{underContext:r,boardContext:l,helperContext:h,viewContext:c}=this._opts.boardContent;return l.canvas.width=n*s,l.canvas.height=a*s,l.canvas.style.width=`${n}px`,l.canvas.style.height=`${a}px`,r.canvas.width=n*s,r.canvas.height=a*s,h.canvas.width=n*s,h.canvas.height=a*s,c.canvas.width=n*s,c.canvas.height=a*s,t.setActiveViewSizeInfo(o),o}}var Fe,Ye,Be,Ge,Ne,Ve,Xe,Ze,He,_e,Qe,$e,Ue,Je,Ke,qe,et,tt,it,ot,nt,at,st,rt,lt,ht=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},ct=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class dt{constructor(e){Fe.add(this),Ye.set(this,void 0),Be.set(this,new WeakMap),Ge.set(this,[]),Ne.set(this,[]),Ve.set(this,void 0),Xe.set(this,void 0),Ze.set(this,void 0),He.set(this,void 0),_e.set(this,new D);const{boardContent:t}=e,i=new De,o=new Ce({viewContext:t.viewContext}),n=new Oe({boardContent:t,sharer:i}),a=new Ee({viewContext:t.viewContext,sharer:i,calculator:o});ht(this,Ye,e,"f"),ht(this,Xe,i,"f"),ht(this,Ve,n,"f"),ht(this,He,o,"f"),ht(this,Ze,new ke({boardContent:e.boardContent,sharer:i,renderer:a,calculator:ct(this,He,"f"),beforeDrawFrame:e=>{ct(this,Fe,"m",st).call(this,e)},afterDrawFrame:e=>{ct(this,Fe,"m",rt).call(this,e)}}),"f"),ct(this,Fe,"m",Qe).call(this),ct(this,Fe,"m",lt).call(this)}getSharer(){return ct(this,Xe,"f")}getViewer(){return ct(this,Ze,"f")}setData(e){const t=ct(this,Xe,"f");ct(this,Xe,"f").setActiveStorage("data",e);const i=t.getActiveViewSizeInfo(),o=K(e.elements,{viewWidth:i.width,viewHeight:i.height,extend:!0});ct(this,Ze,"f").drawFrame();const n=Object.assign(Object.assign({},i),o);return ct(this,Xe,"f").setActiveViewSizeInfo(n),{viewSizeInfo:n}}getData(){const{data:e}=ct(this,Xe,"f").getActiveStoreSnapshot();return e}use(e){var t,i,o;if(ct(this,Be,"f").has(e)){const o=ct(this,Be,"f").get(e);if(o)return null===(i=(t=o.middlewareObject).use)||void 0===i||i.call(t),o.status="enable",ct(this,Be,"f").set(e,o),void ct(this,Fe,"m",lt).call(this)}const{boardContent:n,container:a}=ct(this,Ye,"f"),s=e({boardContent:n,sharer:ct(this,Xe,"f"),viewer:ct(this,Ze,"f"),calculator:ct(this,He,"f"),eventHub:ct(this,_e,"f"),container:a});null===(o=s.use)||void 0===o||o.call(s),ct(this,Ge,"f").push(e),ct(this,Ne,"f").push(s),ct(this,Be,"f").set(e,{status:"enable",middlewareObject:s}),ct(this,Fe,"m",lt).call(this)}disuse(e){var t,i;const o=ct(this,Be,"f").get(e);o&&(null===(i=(t=o.middlewareObject).disuse)||void 0===i||i.call(t),o.status="disable",ct(this,Be,"f").set(e,o),ct(this,Fe,"m",lt).call(this))}scale(e){const t=ct(this,Ze,"f"),{moveX:i,moveY:o}=t.scale(e);t.scroll({moveX:i,moveY:o})}scroll(e){return ct(this,Ze,"f").scroll(e)}updateViewScaleInfo(e){return ct(this,Ze,"f").updateViewScaleInfo(e)}resize(e){const t=ct(this,Ze,"f").resize(e),{width:i,height:o,devicePixelRatio:n}=e,{boardContent:a}=ct(this,Ye,"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}),ct(this,Ze,"f").drawFrame(),ct(this,Ve,"f").trigger("resize",t),ct(this,Xe,"f").setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=ct(this,Ye,"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),ct(this,Fe,"m",at).call(this)}getEventHub(){return ct(this,_e,"f")}}Ye=new WeakMap,Be=new WeakMap,Ge=new WeakMap,Ne=new WeakMap,Ve=new WeakMap,Xe=new WeakMap,Ze=new WeakMap,He=new WeakMap,_e=new WeakMap,Fe=new WeakSet,Qe=function(){ct(this,Ve,"f").on("pointStart",ct(this,Fe,"m",$e).bind(this)),ct(this,Ve,"f").on("pointEnd",ct(this,Fe,"m",Ue).bind(this)),ct(this,Ve,"f").on("pointMove",h((e=>{ct(this,Fe,"m",Je).call(this,e)}),10)),ct(this,Ve,"f").on("hover",h((e=>{ct(this,Fe,"m",Ke).call(this,e)}),10)),ct(this,Ve,"f").on("wheel",h((e=>{ct(this,Fe,"m",et).call(this,e)}),10)),ct(this,Ve,"f").on("wheelScale",h((e=>{ct(this,Fe,"m",tt).call(this,e)}),10)),ct(this,Ve,"f").on("scrollX",ct(this,Fe,"m",it).bind(this)),ct(this,Ve,"f").on("scrollY",ct(this,Fe,"m",ot).bind(this)),ct(this,Ve,"f").on("resize",ct(this,Fe,"m",nt).bind(this)),ct(this,Ve,"f").on("doubleClick",ct(this,Fe,"m",qe).bind(this))},$e=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointStart)||void 0===t?void 0:t.call(o,e)))return}},Ue=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointEnd)||void 0===t?void 0:t.call(o,e)))return}},Je=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointMove)||void 0===t?void 0:t.call(o,e)))return}},Ke=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.hover)||void 0===t?void 0:t.call(o,e)))return}},qe=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.doubleClick)||void 0===t?void 0:t.call(o,e)))return}},et=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheel)||void 0===t?void 0:t.call(o,e)))return}},tt=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheelScale)||void 0===t?void 0:t.call(o,e)))return}},it=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollX)||void 0===t?void 0:t.call(o,e)))return}},ot=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollY)||void 0===t?void 0:t.call(o,e)))return}},nt=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.resize)||void 0===t?void 0:t.call(o,e)))return}},at=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.clear)||void 0===t?void 0:t.call(o,e)))return}},st=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.beforeDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},rt=function(e){var t;for(let i=0;i<ct(this,Ne,"f").length;i++){const o=ct(this,Ne,"f")[i];if(!1===(null===(t=null==o?void 0:o.afterDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},lt=function(){const e=[],t=ct(this,Be,"f");ct(this,Ge,"f").forEach((i=>{const o=t.get(i);"enable"===(null==o?void 0:o.status)&&(null==o?void 0:o.middlewareObject)&&e.push(o.middl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HC2BnTDo+/TWt8Bd5INeVC44NDT0xXYZdXNz8w/AaeyS8yjwCPdzQu92ht2m/OUjIyOfS1pkAoqItLS0fA+8D7wKPA0cxs6qC1O4T0xMfKYnb21tnXEDNjc3z+nXbW1t3wFvYz9dCAL7KUThHovFPtGTNjU1jQFSX18/lg68cuXKLUAaGxs3vkB7e/u3wHHgCQpUdnpTqdQvesJgMDisUVevXh3Xry9fvnxTv66qqprQ/cfHx/vVNj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==";class ut{constructor(e,t){this._cursorType=null,this._resizeCursorBaseImage=null,this._cursorImageMap={auto:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjph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CbgE3ge+BT4HdfD7/ZDwe/z2bzRY6hRsfH1/e3Nx8FDX/sgbgoZfvg6jo4ixqW7oIPA+8CrwHrAJuJBLJd+JaHMf5k6qmPgGeQe1SCenXk0/U21xcIC8AzwGvAJPAEuAmEon1xcXFba9w8/Pz5oqdB14CnpY+oij35km0qwmjwqAU8ISM9hIwBeQA17KsG9PT07+1gxsZGdmgdqW+BjwLDAAPoo4ALU+W9arVwWoIpXp9kouKZpPAO8AwQCwW+2d0dLQ0OTkZSafT0UKhUJ6bm9t2HKeysrIS3tra0g7+KvABUJC0g5rrJdRcbLpImtleRzYashc1P2OSXwbebDVykX3gW+Ab1AHqhuQ3pe6AJlFMO0CoPROHDcio5I8DL1A9C8dQbmod+APYAK4DvwjQnsDdErgyVTfTEaCG1GFYGHXG7TVSo2OkdvhlAflXoHSuNdfStFqaRhEi2kfdprrj6M5LAt0I8EDaaMdflPal48CB95hMr3Bt8h4jD0kyL5E0pN6dysZzW7N2AqjbmhdIZjJvufTOpE19x3g+9s1XJ/ck5tVbfdhu+rxDfLiSO+lFToCjZwrXyH2/0Lwv95z8B1jAqXmDnj4YAAAAAElFTkSuQmCC","rotate-0":ft},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(){y(ft).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,s={x:n/2,y:a/2};o.width=n,o.height=a;const r=o.getContext("2d"),l=B(e);r.translate(s.x,s.y),r.rotate(l),r.translate(-s.x,-s.y),r.drawImage(i,0,0,n,a),r.translate(s.x,s.y),r.rotate(-l),r.translate(-s.x,-s.y);const h=o.toDataURL("image/png");this._cursorImageMap[t]=h}}return t}}const gt="SELECT",vt=Symbol(`${gt}_actionType`),wt=Symbol(`${gt}_resizeType`),mt=Symbol(`${gt}_areaStart`),xt=Symbol(`${gt}_areaEnd`),St=Symbol(`${gt}_hoverElement`),yt=Symbol(`${gt}_hoverElementVertexes`),pt=Symbol(`${gt}_selectedElementList`),bt=Symbol(`${gt}_selectedElementListVertexes`),At=Symbol(`${gt}_selectedElementController`),It=Symbol(`${gt}_groupQueue`),Mt=Symbol(`${gt}_groupQueueVertexesList`),zt="#1973ba";function Pt(e,t,i){const{borderColor:o,borderWidth:n,background:a,lineDash:s}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.fillStyle=a,e.setLineDash(s),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 Rt(e,t,i){if(!t)return;const o={borderColor:zt,borderWidth:1,background:"transparent",lineDash:[]};Pt(e,te(t,i),o)}function Tt(e,t,i){if(!t)return;const{elementWrapper:o,topLeft:n,topRight:a,bottomLeft:s,bottomRight:r}=t,l={borderColor:zt,borderWidth:2,background:"transparent",lineDash:[]},h={...l,borderWidth:4,background:"#FFFFFF"};Pt(e,te(o,i),l),Pt(e,te(n.vertexes,i),h),Pt(e,te(a.vertexes,i),h),Pt(e,te(s.vertexes,i),h),Pt(e,te(r.vertexes,i),h)}function Et(e){return e*Math.PI/180}function Ct(e,t){return Math.sqrt(e*e+t*t)}function Wt(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Ot(e,t){const{ctx:i,viewScaleInfo:o,viewSizeInfo:n,vertexes:a}=t,s=ee(a[0],{viewScaleInfo:o,viewSizeInfo:n}),r=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(s.x,s.y),i.lineTo(r.x,r.y),i.lineTo(l.x,l.y),i.lineTo(h.x,h.y),i.lineTo(s.x,s.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 s=ae(a),r=s[s.length-1];return!!r&&Ot(e,{ctx:i,vertexes:r,viewScaleInfo:o,viewSizeInfo:n})}function Dt(e,t){var i,o,n;const a={type:null,elements:[],elementVertexesList:[],groupQueue:[],groupQueueVertexesList:[]},{ctx:s,data:r,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:r,topRight:l,bottomLeft:f,bottomRight:v}=g,w=[t,i,o,n,r,l,f,v];for(let t=0;t<w.length;t++){const i=w[t];if(Ot(e,{ctx:s,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=se(o,{groupQueue:u});if(n&&Ot(e,{ctx:s,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(r){const{index:t,element:i}=l.getPointElement(e,{data:r,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 Lt(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:s}=t;let r=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,s);if(h.angle&&(h.angle>0||h.angle<0)){const e=Q(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(r){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;r=h}return o}const kt="@middleware/text-edit",Ft={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"},Yt="@middleware/select",Bt="SCROLL",Gt=Symbol(`${Bt}_xThumbRect`),Nt=Symbol(`${Bt}_yThumbRect`),Vt=Symbol(`${Bt}_prevPoint`),Xt=Symbol(`${Bt}_activePoint`),Zt=Symbol(`${Bt}_activeThumbType`),Ht=16,_t=.36,Qt={width:12,thumbColor:"#000000AA",scrollBarColor:"#FFFFFF60",showScrollBar:!1};function $t(e,t,i){const o=e,{x:n,y:a,w:s,h:r}=i;return o.beginPath(),o.rect(n,a,s,r),o.closePath(),!!o.isPointInPath(t.x,t.y)}function Ut(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:s,axis:r}=t;"X"===r?(o=o+n/4+0,n/=2):"Y"===r&&(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=_t,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=s,e.fill(),e.globalAlpha=1,e.beginPath(),e.lineWidth=1,e.strokeStyle=s,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 Jt(e,t){const i=e,{viewScaleInfo:o,viewSizeInfo:n,scrollInfo:a}=t,{activeThumbType:s,prevPoint:r,activePoint:l}=a,h=function(e,t){const{width:i,height:o}=t,{offsetTop:n,offsetBottom:a,offsetLeft:s,offsetRight:r}=e,l=2.5*Ht,h=Ht;let c=0,d=0;c=Math.max(l,i-2*h-(Math.abs(s)+Math.abs(r))),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;s>0?u=f:r>0?u=i-c-h:s<=0&&c>0&&(0!==s||0!==r)&&(u=f+(i-c)*Math.abs(s)/(Math.abs(s)+Math.abs(r)),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},m={x:i-h,y:v,w:h,h:d};return{lineSize:h,xSize:c,ySize:d,translateY:v,translateX:u,thumbColor:Qt.thumbColor,scrollBarColor:Qt.scrollBarColor,xThumbRect:w,yThumbRect:m}}(o,n);let c={...h.xThumbRect},d={...h.yThumbRect};return s&&r&&l&&("X"===s&&a.xThumbRect?(c={...a.xThumbRect},c.x=c.x+(l.x-r.x)):"Y"===s&&a.yThumbRect&&(d={...a.yThumbRect},d.y=d.y+(l.y-r.y))),Ut(i,{axis:"X",...c,r:h.lineSize/2,color:h.thumbColor}),Ut(i,{axis:"Y",...d,r:h.lineSize/2,color:h.thumbColor}),i.globalAlpha=1,{xThumbRect:c,yThumbRect:d}}function Kt(e,t){const{snapshot:i}=t,o=Y(i),n=F(i),a=function(e){const{sharedStore:t}=e;return{activePoint:t[Xt]||null,prevPoint:t[Vt]||null,activeThumbType:t[Zt]||null,xThumbRect:t[Gt]||null,yThumbRect:t[Nt]||null}}(i),{xThumbRect:s,yThumbRect:r}=Jt(e,{viewSizeInfo:o,viewScaleInfo:n,scrollInfo:a});return{xThumbRect:s,yThumbRect:r}}const qt="@middleware/scale",ei=16,ti="#000000",ii="#00000080",oi="monospace",ni="#AAAAAA20",ai="#AAAAAA40";function si(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 s=10*a,r=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%s==0,isKeyNum:e%s==0,isSubKeyNum:e%r==0};n.push(t),l++}return n}const ri="@middleware/show-ruler",li=Symbol("DRAG_prevPoint");return t=new WeakMap,i=new WeakMap,o=new WeakSet,n=function(){s(this,i).style.position="relative"},e.Core=class{constructor(e,s){r(this,o),r(this,t,void 0),r(this,i,void 0);const{devicePixelRatio:h=1,width:c,height:d}=s;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,s={width:i,height:o,devicePixelRatio:n};if(!0===a){const t=e.getContext("2d"),i=j(s),o=j(s),n=j(s),a=O(Object.assign({ctx:t},s)),r=()=>{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:r}}{const t=e.getContext("2d"),n=O(s),a=O(s),r=O(s),l=O(Object.assign({ctx:t},s)),h=()=>{l.clearRect(0,0,i,o),l.drawImage(r.canvas,0,0,i,o),l.drawImage(n.canvas,0,0,i,o),l.drawImage(a.canvas,0,0,i,o),r.clearRect(0,0,i,o),n.clearRect(0,0,i,o),a.clearRect(0,0,i,o)};return{underContext:r,viewContext:n,helperContext:a,boardContext:l,drawView:h}}}(f,{width:c,height:d,devicePixelRatio:h,offscreen:!0}),m=new dt({boardContent:w,container:e}),x=m.getSharer();x.setActiveViewSizeInfo({width:c,height:d,devicePixelRatio:h,contextWidth:c,contextHeight:d}),l(this,t,m),this.resize(x.getActiveViewSizeInfo());const S=m.getEventHub();new ut(e,{eventHub:S})}use(e){s(this,t).use(e)}disuse(e){s(this,t).disuse(e)}setData(e){J((null==e?void 0:e.elements)||[]),s(this,t).setData(e)}getData(){return s(this,t).getData()}scale(e){s(this,t).scale(e);s(this,t).getViewer().drawFrame()}resize(e){const i=s(this,t),o=i.getSharer().getActiveViewSizeInfo();i.resize({...o,...e})}clear(){s(this,t).clear()}on(e,i){s(this,t).getEventHub().on(e,i)}off(e,i){s(this,t).getEventHub().off(e,i)}trigger(e,i){s(this,t).getEventHub().trigger(e,i)}getViewInfo(){const e=s(this,t).getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){s(this,t).getViewer().drawFrame()}setViewScale(e){s(this,t).updateViewScaleInfo(e)}},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(li,o),n=!0,t.trigger("cursor",{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(li);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(li,t)},pointEnd(){n=!1,i.setSharedStorage(li,null),t.trigger("cursor",{type:"drag-default"})}}},e.MiddlewareRuler=e=>{const{boardContent:t,viewer:i,eventHub:o}=e,{helperContext:n,underContext:a}=t;let s=!0,r=!0;const l=e=>{"boolean"==typeof(null==e?void 0:e.show)&&(s=e.show),"boolean"==typeof(null==e?void 0:e.showGrid)&&(r=e.showGrid),"boolean"!=typeof(null==e?void 0:e.show)&&"boolean"!=typeof(null==e?void 0:e.showGrid)||i.drawFrame()};return{use(){o.on(ri,l)},disuse(){o.off(ri,l)},beforeDrawFrame:({snapshot:e})=>{if(!0===s){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,ei),e.lineTo(ei,ei),e.lineTo(ei,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 si({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<ei||(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=ti,e.stroke(),o.isKeyNum&&(e.fillStyle=ii,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:oi}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(n,{scaleList:o});const s=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n}=t,{height:a}=i;return si({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<ei)&&(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=ti,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=ii,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:oi}),e.fillText(a,13.2,n.position+o)}))}}}(n,{scaleList:s}),!0===r&&function(e,t){const{xList:i,yList:o,viewSizeInfo:n}=t,{width:a,height:s}=n;for(let t=0;t<i.length;t++){const o=i[t];e.beginPath(),e.moveTo(o.position,0),e.lineTo(o.position,s),!0===o.isKeyNum||!0===o.isSubKeyNum?e.strokeStyle=ai:e.strokeStyle=ni,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=ni,e.lineWidth=1,e.closePath(),e.stroke()}}(a,{xList:o,yList:s,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:s}=i.getActiveViewScaleInfo();let r=s;if(n<0?r=1.1*s:n>0&&(r=.9*s),r<.05||r>50)return;const{moveX:l,moveY:h}=t.scale({scale:r,point:a});t.scroll({moveX:l,moveY:h}),t.drawFrame();const c=ce(s);o.trigger(qt,{scale:c})}}},e.MiddlewareScroller=e=>{const{viewer:t,boardContent:i,sharer:o}=e,{helperContext:n}=i;o.setSharedStorage(Gt,null),o.setSharedStorage(Nt,null);const a=()=>{o.setSharedStorage(Vt,null),o.setSharedStorage(Xt,null),o.setSharedStorage(Zt,null)};a();const s=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:a}=i;return n&&$t(e,t,n)?o="X":a&&$t(e,t,a)&&(o="Y"),o}(n,e,{xThumbRect:o.getSharedStorage(Gt),yThumbRect:o.getSharedStorage(Nt)});return{wheel:e=>{t.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),t.drawFrame()},pointStart:e=>{const{point:t}=e,i=s(t);if("X"===i||"Y"===i)return o.setSharedStorage(Zt,i),o.setSharedStorage(Vt,t),!1},pointMove:e=>{const{point:i}=e,n=o.getSharedStorage(Zt);if("X"===n||"Y"===n)return o.setSharedStorage(Xt,i),"X"===n?(e=>{const i=o.getSharedStorage(Vt);if(i){const{offsetLeft:n,offsetRight:a}=o.getActiveViewScaleInfo(),{width:s}=o.getActiveViewSizeInfo(),r=-(e.x-i.x)*(s+Math.abs(n)+Math.abs(a))/s;t.scroll({moveX:r}),t.drawFrame()}})(i):"Y"===n&&(e=>{const i=o.getSharedStorage(Vt);if(i){const{offsetTop:n,offsetBottom:a}=o.getActiveViewScaleInfo(),{height:s}=o.getActiveViewSizeInfo(),r=-(e.y-i.y)*(s+Math.abs(n)+Math.abs(a))/s;t.scroll({moveY:r}),t.drawFrame()}})(i),o.setSharedStorage(Vt,i),!1},pointEnd:()=>{const e=o.getSharedStorage(Zt);if(a(),"X"===e||"Y"===e)return t.scroll({moveX:0,moveY:0}),t.drawFrame(),!1},beforeDrawFrame({snapshot:e}){const{xThumbRect:t,yThumbRect:i}=Kt(n,{snapshot:e});o.setSharedStorage(Gt,t),o.setSharedStorage(Nt,i)}}},e.MiddlewareSelector=e=>{const{viewer:t,sharer:i,boardContent:o,calculator:n,eventHub:a}=e,{helperContext:s}=o;let r=null,l=null;i.setSharedStorage(vt,null);const h=()=>i.getSharedStorage(pt),c=e=>{let t=i.getSharedStorage(It);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(It,t),i.setSharedStorage(Mt,o),t.length>0},d=e=>{i.setSharedStorage(St,e);let t=null;e&&(t=se(e,{groupQueue:i.getSharedStorage(It)})),i.setSharedStorage(yt,t)},f=(e,t)=>{if(i.setSharedStorage(pt,e),1===e.length){const t=le(e[0],{groupQueue:i.getSharedStorage(It),controllerSize:10,viewScaleInfo:i.getActiveViewScaleInfo()});i.setSharedStorage(At,t)}else i.setSharedStorage(At,null);!0===(null==t?void 0:t.triggerEvent)&&a.trigger(Yt,{uuids:e.map((e=>e.uuid))})},u=()=>({ctx:s,calculator:n,data:i.getActiveStorage("data"),selectedElements:h(),viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:i.getSharedStorage(It),areaSize:null,selectedElementController:i.getSharedStorage(At)}),g=()=>{i.setSharedStorage(vt,null),i.setSharedStorage(wt,null),i.setSharedStorage(mt,null),i.setSharedStorage(xt,null),i.setSharedStorage(It,[]),i.setSharedStorage(Mt,[]),i.setSharedStorage(St,null),i.setSharedStorage(yt,null),i.setSharedStorage(pt,[]),i.setSharedStorage(bt,null),i.setSharedStorage(At,null)};g();const v=({uuids:e,positions:o})=>{let n=[];const a=i.getSharedStorage(vt),s=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==s?void 0:s.elements)||[]):function(e,t){const i=[];return function t(o){var n;for(let a=0;a<o.length;a++){const s=o[a];e.includes(s.uuid)?i.push(s):"group"===s.type&&t((null===(n=null==s?void 0:s.detail)||void 0===n?void 0:n.children)||[])}}(t),i}(e,(null==s?void 0:s.elements)||[]);let r=!1;if(a||1!==n.length?"select"===a&&1===n.length&&(r=!0):(i.setSharedStorage(vt,"select"),r=!0),r){const e=function(e,t){const i=[];return function e(t,o){var n;let a=null;for(let s=0;s<o.length;s++){const r=o[s];if(r.uuid===t){a=r;break}if(!a&&"group"===r.type){i.push(r);const o=e(t,(null===(n=null==r?void 0:r.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==s?void 0:s.elements)||[]);i.setSharedStorage(It,e),f(n),t.drawFrame()}};return{use(){a.on(Yt,v)},disuse(){a.off(Yt,v)},hover:e=>{var o,r;const c=i.getSharedStorage(wt),f=i.getSharedStorage(vt),g=i.getSharedStorage(It),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:s,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:i.getSharedStorage(It)}))return d(null),void t.drawFrame();const n=Dt(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(),m=i.getActiveViewScaleInfo(),x=i.getActiveViewSizeInfo(),S=Dt(e.point,{...u(),areaSize:Lt(w,{viewScaleInfo:m,viewSizeInfo:x,calculator:n})});return v(S),"over-element"===S.type&&1===(null==(r=null==S?void 0:S.elements)?void 0:r.length)?(i.setSharedStorage(St,S.elements[0]),d(S.elements[0]),void t.drawFrame()):i.getSharedStorage(St)?(d(null),void t.drawFrame()):void 0},pointStart:e=>{var o,a,l,c;r=e.point,d(null);const v=i.getSharedStorage(It);if((null==v?void 0:v.length)>0){if(jt(e.point,{ctx:s,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:v})){const t=Dt(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(vt,"drag")):(null==(a=t.type)?void 0:a.startsWith("resize-"))?(i.setSharedStorage(wt,t.type),i.setSharedStorage(vt,"resize")):f([],{triggerEvent:!0})}else g();return void t.drawFrame()}const w=Lt(h(),{viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),calculator:n}),m=Dt(e.point,{...u(),areaSize:w,groupQueue:[]});"list-area"===m.type?i.setSharedStorage(vt,"drag-list"):"over-element"===m.type&&1===(null==(l=null==m?void 0:m.elements)?void 0:l.length)?(f([m.elements[0]],{triggerEvent:!0}),i.setSharedStorage(vt,"drag")):(null==(c=m.type)?void 0:c.startsWith("resize-"))?(i.setSharedStorage(wt,m.type),i.setSharedStorage(vt,"resize")):(g(),i.setSharedStorage(vt,"area"),i.setSharedStorage(mt,e.point),f([],{triggerEvent:!0})),t.drawFrame()},pointMove:e=>{const o=i.getActiveStorage("data"),n=h(),a=i.getActiveStorage("scale")||1,s=r,c=e.point,d=i.getSharedStorage(wt),u=i.getSharedStorage(vt),g=i.getSharedStorage(It);if("drag"===u){if(l="drag",o&&1===(null==n?void 0:n.length)&&s&&c){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:s=0}=e;a.push({x:t,y:i,w:o,h:n,angle:0-s})})),(null==i?void 0:i.length)>0){const i=H(e,a),s=H(t,a);o=s.x-i.x,n=s.y-i.y}return{moveX:o,moveY:n}}(s,c,g);n[0].x+=e/a,n[0].y+=t/a,f([n[0]])}t.drawFrame()}else if("drag-list"===u){if(l="drag-list",o&&s&&c&&(null==n?void 0:n.length)>1){const e=(c.x-s.x)/a,t=(c.y-s.y)/a;n.forEach((i=>{i&&(i.x+=e,i.y+=t)})),i.setActiveStorage("data",o)}t.drawFrame()}else if("resize"===u){if(o&&1===(null==n?void 0:n.length)&&s&&(null==d?void 0:d.startsWith("resize-"))){l="resize";const e=[];g.forEach((t=>{const{x:i,y:o,w:n,h:a,angle:s=0}=t;e.push({x:i,y:o,w:n,h:a,angle:0-s})}));let o=s,r=c;g.length>0&&(o=H(s,e),r=H(c,e));const h=function(e,t){var i,o,n,a,s,r,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 m=B(v),x=!!(null==(i=null==e?void 0:e.operations)?void 0:i.limitRatio),{start:S,end:y,resizeType:p,scale:b}=t;let A={...S},I={...y},M={x:A.x,y:w.y},z={x:I.x,y:w.y},P={...M},R={...z},T={x:w.x,y:A.y},E={x:w.x,y:I.y},C={...T},W={...E},O=(R.x-P.x)/b,j=(R.y-P.y)/b,D=Ct(O,j),L=(W.x-C.x)/b,k=(W.y-C.y)/b,F=Ct(L,k);(v>0||v<0)&&(A=Z(w,S,0-m),I=Z(w,y,0-m),M={x:A.x,y:w.y},z={x:I.x,y:w.y},P=Z(w,M,m),R=Z(w,z,m),T={x:w.x,y:A.y},E={x:w.x,y:I.y},C=Z(w,T,m),W=Z(w,E,m),O=(R.x-P.x)/b,j=(R.y-P.y)/b,D=Ct(O,j),D=Wt(D,j),L=(W.x-C.x)/b,k=(W.y-C.y)/b,F=Ct(L,k),F=Wt(F,k));let Y=(y.x-S.x)/b,G=(y.y-S.y)/b;if(!0===x)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(p)){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(L),Math.abs(k));L=(L>=0?1:-1)*i,k=(k>=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(p)){{const t=Math.abs(Y);Y=(Y>=0?1:-1)*t;const i=t/e.w*e.h;"resize-top-left"===p||"resize-bottom-right"===p?G=Y>0?i:-i:"resize-top-right"!==p&&"resize-bottom-left"!==p||(G=Y>0?-i:i)}D=Math.abs(D),F=D/e.w*e.h}switch(p){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-Wt(F,k);const e=Et(v),o=F/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){F=Wt(F,L);const e=Et(v-90),o=F/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){F=Wt(F,k);const e=Et(v-180),o=F/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){F=0-Wt(F,L);const e=Et(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=Wt(F,k);const e=Et(v),o=F/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){F=0-Wt(F,L);const e=Et(v-90),o=F/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){F=Wt(F,L);const e=Et(v-180),o=F/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){F=Wt(F,L);const e=Et(v-270),o=F/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}g+F>0&&(!0===(null==(s=e.operations)?void 0:s.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==(r=e.operations)?void 0:r.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-Wt(D,O);const e=Et(v),o=D/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){D=Wt(D,O);const e=Et(v-90),o=D/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){D=Wt(D,j);const e=Et(v-180),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){D=Wt(D,j);const e=Et(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=Wt(D,j);const e=Et(v),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){D=Wt(D,G);const e=Et(v-90),o=D/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){D=Wt(D,G);const e=Et(v-180),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e),D=0-D}else if(v<360){D=Wt(D,Y);const e=Et(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-Wt(F,k),D=0-Wt(D,x?0-F:O);const i=F/2;e+=i*Math.sin(m),t-=i*Math.cos(m);const o=D/2;e-=o*Math.cos(m),t-=o*Math.sin(m)}else if(v<180){F=Wt(F,L),D=Wt(D,x?F:O);const i=Et(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=Wt(F,k),D=Wt(D,x?F:j);const i=Et(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-Wt(F,L),D=Wt(D,x?F:j);const i=Et(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-Wt(F,k),D=Wt(D,x?F:j);const i=Et(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=Wt(F,L),D=Wt(D,x?F:j);const i=Et(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=Et(v-180);F=Wt(F,k),D=Wt(D,x?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-Wt(F,L),D=Wt(D,x?F:O);const i=Et(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=Wt(F,k),D=0-Wt(D,x?0-F:O);const i=Et(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-Wt(F,L),D=Wt(D,x?F:O);const i=Et(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=Wt(F,L),D=Wt(D,x?F:j);const i=Et(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=Wt(F,L),D=Wt(D,x?F:j);const i=Et(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=Wt(F,k),D=Wt(D,x?F:j);const i=Et(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-Wt(F,L),D=Wt(D,x?F:G);const i=Et(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=Wt(F,L),D=Wt(D,x?F:0-j);const i=Et(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=Wt(F,L),D=Wt(D,x?F:O);const i=Et(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}}(n[0],{scale:a,start:o,end:r,resizeType:d,sharer:i});n[0].x=h.x,n[0].y=h.y,n[0].w=h.w,n[0].h=h.h,f([n[0]]),t.drawFrame()}}else"area"===u&&(l="area",i.setSharedStorage(xt,e.point),t.drawFrame());r=e.point},pointEnd(e){l=null;const o=i.getActiveStorage("data"),s=i.getSharedStorage(wt),h=i.getSharedStorage(vt),c=i.getActiveViewSizeInfo();let d=!1;if(r=null,"resize"===h&&s)i.setSharedStorage(wt,null),d=!0;else if("area"===h){if(i.setSharedStorage(vt,null),o){const e=i.getSharedStorage(mt),t=i.getSharedStorage(xt);if(e&&t){const{elements:a}=function(e,t){const i=[],o=[],n=[],{calculator:a,viewScaleInfo:s,viewSizeInfo:r,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,s,r),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=Q(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(vt,"drag-list"),f(a,{triggerEvent:!0}),d=!0)}}}else if("drag-list"===h)i.setSharedStorage(vt,"drag-list-end"),d=!0;else if(o){n.getPointElement(e.point,{data:o,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}).element?(i.setSharedStorage(vt,"select"),d=!0):i.setSharedStorage(vt,null)}null===i.getSharedStorage(vt)&&(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)}o&&["drag","drag-list","drag-list-end","resize"].includes(h)&&a.trigger("change",{data:o}),t.drawFrame()}})()},pointLeave(){r=null,g(),t.drawFrame()},doubleClick(e){var o,n;const s=Dt(e.point,u());if(1===s.elements.length&&"group"===(null==(o=s.elements[0])?void 0:o.type)){if(!0===c(s.elements[0]))return i.setSharedStorage(vt,null),void t.drawFrame()}else 1===s.elements.length&&"text"===(null==(n=s.elements[0])?void 0:n.type)&&a.trigger(kt,{element:s.elements[0],groupQueue:i.getSharedStorage(It)||[],viewScaleInfo:i.getActiveViewScaleInfo()});i.setSharedStorage(vt,null)},beforeDrawFrame({snapshot:t}){const{activeStore:i,sharedStore:o}=t,{scale:a,offsetLeft:r,offsetTop:l,offsetRight:c,offsetBottom:d,width:f,height:u,contextHeight:g,contextWidth:v,devicePixelRatio:w}=i,m=e.sharer,x={scale:a,offsetLeft:r,offsetTop:l,offsetRight:c,offsetBottom:d},S={width:f,height:u,contextHeight:g,contextWidth:v,devicePixelRatio:w},y=o[pt][0],p=o[St],b=o[yt],A=o[vt],I=o[mt],M=o[xt],z=o[It],P=o[Mt],R={calculator:n,viewScaleInfo:x,viewSizeInfo:S},T=y?le(y,{groupQueue:z,controllerSize:10,viewScaleInfo:x}):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:zt,borderWidth:2,background:"transparent",lineDash:[4,4]};Pt(e,te(n,i),a)}}(s,P,R),p&&"drag"!==A&&Rt(s,b,R),y&&["select","drag","resize"].includes(A)&&Tt(s,T,{...R});else if(p&&"drag"!==A&&Rt(s,b,R),y&&["select","drag","resize"].includes(A))Tt(s,T,{...R});else if("area"===A&&I&&M)!function(e,t){const{start:i,end:o}=t;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=zt,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()}(s,{start:I,end:M});else if(["drag-list","drag-list-end"].includes(A)){const e=Lt(h(),{viewScaleInfo:m.getActiveViewScaleInfo(),viewSizeInfo:m.getActiveViewSizeInfo(),calculator:n});e&&function(e,t){const{areaSize:i}=t,{x:o,y:n,w:a,h:s}=i;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=zt,e.fillStyle="#1976d21c",e.beginPath(),e.moveTo(o,n),e.lineTo(o+a,n),e.lineTo(o+a,n+s),e.lineTo(o,n+s),e.closePath(),e.stroke(),e.fill()}(s,{areaSize:e})}}}},e.MiddlewareTextEditor=e=>{const{eventHub:t,boardContent:i,viewer:o}=e,n=i.boardContext.canvas,a=document.createElement("textarea"),s=document.createElement("div"),r=e.container||document.body,l=document.createElement("div");let h=null;s.appendChild(a),s.style.position="absolute",l.appendChild(s),l.style.position="fixed",l.style.top="0",l.style.bottom="0",l.style.left="0",l.style.right="0",l.style.display="none",r.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:s,h:r}=t,l=U(t.angle||0);return o.style.position="absolute",o.style.left=`${n}px`,o.style.top=`${a}px`,o.style.width=`${s}px`,o.style.height=`${r}px`,o.style.transform=`rotate(${l}deg)`,i.appendChild(o),o},f=e=>{const{viewScaleInfo:t,element:i,groupQueue:o}=e,{scale:n,offsetTop:r,offsetLeft:l}=t;s.children&&Array.from(s.children).forEach((e=>{e.remove()}));let h=s;for(let e=0;e<o.length;e++){const t=o[e],{x:i,y:a,w:s,h:c}=t,f={x:i*n,y:a*n,w:s*n,h:c*n,angle:U(t.angle||0)};0===e&&(f.x+=l,f.y+=r),h=d({size:f,parent:h})}const c={...Ft,...i.detail};let f=i.x*n+l,u=i.y*n+r,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}})();s.style.position="absolute",s.style.overflow="hidden",s.style.top=`${t}px`,s.style.left=`${e}px`,s.style.width=`${i}px`,s.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(kt,g)},disuse(){t.off(kt,g)}}},e.middlewareEventRuler=ri,e.middlewareEventScale=qt,e.middlewareEventSelect=Yt,e.middlewareEventTextEdit=kt,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
1
+ var iDrawCore=function(e){"use strict";var t,i,o,n,a,r,l,s,h,c,d,f,u,g,v,w,m,y,p,x,S=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},b=(e,t,i)=>(S(e,t,"read from private field"),i?i.call(e):t.get(e)),I=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},A=(e,t,i,o)=>(S(e,t,"write to private field"),o?o.call(e,i):t.set(e,i),i),M=(e,t,i)=>(S(e,t,"access private method"),i);function z(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 R(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 P(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function T(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 E(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/${T(t.toString(16).padEnd(4,o))}${T(e.substring(i-4,i).padEnd(4,o)).padEnd(4,"f")}-${T(e.substring(i-8,i-4).padEnd(4,o)).padEnd(4,"f")}-${T(e.substring(i-12,i-8).padEnd(4,o)).padEnd(4,"f")}-${T(e.substring(i-16,i-12).padEnd(4,n)).padEnd(4,"f")}-${T(e.substring(i,i+4).padEnd(4,n)).padEnd(4,"f")}${T(e.substring(i+4,i+8).padEnd(4,n)).padEnd(4,"f")}${T(n.padEnd(4,o).padEnd(4,n))}`}function W(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 C(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const k={type(e,t){const i=C(e);return!0===t?i.toLocaleLowerCase():i},array:e=>"Array"===C(e),json:e=>"Object"===C(e),function:e=>"Function"===C(e),asyncFunction:e=>"AsyncFunction"===C(e),boolean:e=>"Boolean"===C(e),string:e=>"String"===C(e),number:e=>"Number"===C(e),undefined:e=>"Undefined"===C(e),null:e=>"Null"===C(e),promise:e=>"Promise"===C(e)};var L=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))};const{Image:O}=window;function j(e){return new Promise(((t,i)=>{const o=new O;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function Y(e){return L(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,i)=>{const o=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n=new FileReader;n.readAsDataURL(o),n.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},n.onerror=function(e){i(e)}}))}(e);return yield j(t)}))}function D(e,t){return L(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 j(i)}))}function V(e){return"number"==typeof e&&(e>0||e<=0)}function G(e){return"number"==typeof e&&e>=0}function X(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function N(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const B={x:function(e){return V(e)},y:function(e){return V(e)},w:G,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:V,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return G(e)},borderRadius:function(e){return V(e)&&e>=0},color:function(e){return z(e)},imageSrc:function(e){return N(e)||X(e)},imageURL:X,imageBase64:N,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let i=document.createElement("div");i.innerHTML=e,i.children.length>0&&(t=!0),i=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return V(e)&&e>0},lineHeight:function(e){return V(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return V(e)&&e>0}};var F,H,Z=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Q=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class U{constructor(e,t){F.set(this,void 0),H.set(this,void 0),Z(this,F,e,"f"),Z(this,H,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f"),this.$resetFont()}$undoPixelRatio(e){return e/Q(this,H,"f").devicePixelRatio}$doPixelRatio(e){return Q(this,H,"f").devicePixelRatio*e}$getContext(){return Q(this,F,"f")}$setContext(e){Z(this,F,e,"f")}$setFont(e){const t=[];e.fontWeight&&t.push(`${e.fontWeight}`),t.push(`${this.$doPixelRatio(e.fontSize||12)}px`),t.push(`${e.fontFamily||"sans-serif"}`),Q(this,F,"f").font=`${t.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return Q(this,H,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:a}=Q(this,F,"f");a.width=t*o,a.height=i*o,Z(this,H,Object.assign(Object.assign({},Q(this,H,"f")),{devicePixelRatio:o}),"f"),!0===n&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=Q(this,H,"f"),{width:t,height:i}=Q(this,F,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return Q(this,F,"f").canvas}get fillStyle(){return Q(this,F,"f").fillStyle}set fillStyle(e){Q(this,F,"f").fillStyle=e}get strokeStyle(){return Q(this,F,"f").strokeStyle}set strokeStyle(e){Q(this,F,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(Q(this,F,"f").lineWidth)}set lineWidth(e){Q(this,F,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return Q(this,F,"f").textAlign}set textAlign(e){Q(this,F,"f").textAlign=e}get textBaseline(){return Q(this,F,"f").textBaseline}set textBaseline(e){Q(this,F,"f").textBaseline=e}get globalAlpha(){return Q(this,F,"f").globalAlpha}set globalAlpha(e){Q(this,F,"f").globalAlpha=e}get shadowColor(){return Q(this,F,"f").shadowColor}set shadowColor(e){Q(this,F,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(Q(this,F,"f").shadowOffsetX)}set shadowOffsetX(e){Q(this,F,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(Q(this,F,"f").shadowOffsetY)}set shadowOffsetY(e){Q(this,F,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(Q(this,F,"f").shadowBlur)}set shadowBlur(e){Q(this,F,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return Q(this,F,"f").lineCap}set lineCap(e){Q(this,F,"f").lineCap=e}get globalCompositeOperation(){return Q(this,F,"f").globalCompositeOperation}set globalCompositeOperation(e){Q(this,F,"f").globalCompositeOperation=e}fill(...e){return Q(this,F,"f").fill(...e)}arc(e,t,i,o,n,a){return Q(this,F,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,a)}rect(e,t,i,o){return Q(this,F,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return Q(this,F,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return Q(this,F,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return Q(this,F,"f").beginPath()}closePath(){return Q(this,F,"f").closePath()}lineTo(e,t){return Q(this,F,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return Q(this,F,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return Q(this,F,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}getLineDash(){return Q(this,F,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return Q(this,F,"f").setLineDash(t)}stroke(e){return e?Q(this,F,"f").stroke(e):Q(this,F,"f").stroke()}translate(e,t){return Q(this,F,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return Q(this,F,"f").rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],n=e[3],a=e[4],r=e[e.length-4],l=e[e.length-3],s=e[e.length-2],h=e[e.length-1];return 9===e.length?Q(this,F,"f").drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h)):Q(this,F,"f").drawImage(t,this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h))}createPattern(e,t){return Q(this,F,"f").createPattern(e,t)}measureText(e){return Q(this,F,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?Q(this,F,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):Q(this,F,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?Q(this,F,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):Q(this,F,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){Q(this,F,"f").save()}restore(){Q(this,F,"f").restore()}scale(e,t){Q(this,F,"f").scale(e,t)}circle(e,t,i,o,n,a,r,l){Q(this,F,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,a,r,l)}isPointInPath(e,t){return Q(this,F,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return Q(this,F,"f").clip(...e)}setTransform(e,t,i,o,n,a){return Q(this,F,"f").setTransform(e,t,i,o,n,a)}getTransform(){return Q(this,F,"f").getTransform()}createLinearGradient(e,t,i,o){return Q(this,F,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,a){return Q(this,F,"f").createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a))}createConicGradient(e,t,i){return Q(this,F,"f").createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function J(e){const{width:t,height:i,ctx:o,devicePixelRatio:n}=e;let a=o;if(!a){const e=document.createElement("canvas");e.width=t*n,e.height=i*n,a=e.getContext("2d")}return new U(a,e)}function $(e){const{width:t,height:i,devicePixelRatio:o}=e,n=new OffscreenCanvas(t*o,i*o),a=n.getContext("2d").canvas.getContext("2d");return new U(a,{devicePixelRatio:o,offscreenCanvas:n})}F=new WeakMap,H=new WeakMap;var K,q=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class _{constructor(){K.set(this,void 0),function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(e,i):n?n.value=i:t.set(e,i)}(this,K,new Map,"f")}on(e,t){if(q(this,K,"f").has(e)){const i=q(this,K,"f").get(e)||[];null==i||i.push(t),q(this,K,"f").set(e,i)}else q(this,K,"f").set(e,[t])}off(e,t){if(q(this,K,"f").has(e)){const i=q(this,K,"f").get(e);if(Array.isArray(i))for(let e=0;e<(null==i?void 0:i.length);e++)if(i[e]===t){i.splice(e,1);break}q(this,K,"f").set(e,i||[])}}trigger(e,t){const i=q(this,K,"f").get(e);return!!Array.isArray(i)&&(i.forEach((e=>{e(t)})),!0)}has(e){if(q(this,K,"f").has(e)){const t=q(this,K,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){q(this,K,"f").clear()}}function ee(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}K=new WeakMap;var te,ie,oe,ne,ae=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},re=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class le{constructor(e){te.add(this),ie.set(this,void 0),oe.set(this,void 0),ae(this,oe,W(e.defaultStorage),"f"),ae(this,ie,re(this,te,"m",ne).call(this),"f")}set(e,t){re(this,ie,"f")[e]=t}get(e){return re(this,ie,"f")[e]}getSnapshot(e){return!0===(null==e?void 0:e.deepClone)?W(re(this,ie,"f")):Object.assign({},re(this,ie,"f"))}clear(){ae(this,ie,re(this,te,"m",ne).call(this),"f")}destroy(){ae(this,ie,null,"f")}}function se(e){const{activeStore:t}=e;return{scale:null==t?void 0:t.scale,offsetTop:null==t?void 0:t.offsetTop,offsetBottom:null==t?void 0:t.offsetBottom,offsetLeft:null==t?void 0:t.offsetLeft,offsetRight:null==t?void 0:t.offsetRight}}function he(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:null==t?void 0:t.width,height:null==t?void 0:t.height,contextWidth:null==t?void 0:t.contextWidth,contextHeight:null==t?void 0:t.contextHeight}}function ce(e){return e/180*Math.PI}function de(e,t,i,o){const n=ce(t||0);i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(n),e.translate(-i.x,-i.y)),o(e),i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(-n),e.translate(-i.x,-i.y))}function fe(e,t,i){const o=ue(t);de(e,t.angle||0,o,(()=>{i(e)}))}function ue(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function ge(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),i=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return ue({x:t,y:i,w:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,h:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-i})}function ve(e,t){const i=t.x-e.x,o=t.y-e.y;if(0===i){if(o<0)return 0;if(o>0)return Math.PI}else if(0===o){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&o<0?Math.atan(Math.abs(i)/Math.abs(o)):i>0&&o>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):0}function we(e,t,i){let o=ve(e,t)+i;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const n=function(e,t){const i=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y);return 0===i?i:Math.sqrt(i)}(e,t);let a=0,r=0;return 0===o?(a=0,r=0-n):o>0&&o<Math.PI/2?(a=Math.sin(o)*n,r=0-Math.cos(o)*n):o===Math.PI/2?(a=n,r=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*n,r=Math.cos(Math.PI-o)*n):o===Math.PI?(a=0,r=n):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*n,r=Math.cos(o-Math.PI)*n):o===1.5*Math.PI?(a=0-n,r=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*n,r=0-Math.cos(2*Math.PI-o)*n):o===2*Math.PI&&(a=0,r=0-n),a+=e.x,r+=e.y,{x:a,y:r}}function me(e,t){if((null==t?void 0:t.length)>0){let i=e.x,o=e.y;return t.forEach((e=>{const{x:t,y:n,w:a,h:r,angle:l=0}=e,s=we(ue({x:t,y:n,w:a,h:r,angle:l}),{x:i,y:o},ce(l));i=s.x,o=s.y})),{x:i,y:o}}return e}function ye(e,t,i){const{x:o,y:n,w:a,h:r}=e;let l={x:o,y:n},s={x:o+a,y:n},h={x:o+a,y:n+r},c={x:o,y:n+r};if(i&&(i>0||i<0)){const e=ce(Se(i));l=we(t,l,e),s=we(t,s,e),h=we(t,h,e),c=we(t,c,e)}return[l,s,h,c]}function pe(e){const{angle:t=0}=e;return ye(e,ue(e),t)}function xe(e,t,i){return[we(e,{x:t[0].x,y:t[0].y},i),we(e,{x:t[1].x,y:t[1].y},i),we(e,{x:t[2].x,y:t[2].y},i),we(e,{x:t[3].x,y:t[3].y},i)]}function Se(e){if(!(e>0||e<0)||0===e)return 0;let t=e%360;return t<0&&(t+=360),t}function be(e){let t=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(t=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(t=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(t=be(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.children))}))}return t}function Ie(e,t){const i={x:0,y:0,w:0,h:0};e.forEach((e=>{const t={x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=pe(t);if(4===e.length){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...i),t.y=Math.min(...o),t.w=Math.abs(Math.max(...i)-Math.min(...i)),t.h=Math.abs(Math.max(...o)-Math.min(...o))}}const o=Math.min(t.x,i.x),n=Math.min(t.y,i.y),a=Math.max(t.x+t.w,i.x+i.w),r=Math.max(t.y+t.h,i.y+i.h);i.x=o,i.y=n,i.w=Math.abs(a-o),i.h=Math.abs(r-n)})),(null==t?void 0:t.extend)&&(i.x=Math.min(i.x,0),i.y=Math.min(i.y,0));const o={contextWidth:i.w,contextHeight:i.h};return(null==t?void 0:t.viewWidth)&&(null==t?void 0:t.viewHeight)&&(null==t?void 0:t.viewWidth)>0&&(null==t?void 0:t.viewHeight)>0&&(t.viewWidth>i.x+i.w&&(o.contextWidth=t.viewWidth-i.x),t.viewHeight>i.y+i.h&&(o.contextHeight=t.viewHeight-i.y)),o}function Ae(e,t){var i;const o=[];let n=e;if(t.length>1)for(let e=0;e<t.length-1;e++){const a=n[t[e]];if("group"!==(null==a?void 0:a.type)||!Array.isArray(null===(i=null==a?void 0:a.detail)||void 0===i?void 0:i.children))return null;o.push(a),n=a.detail.children}return o}function Me(e,t){let i=null,o=t;for(let t=0;t<e.length;t++){const n=o[e[t]];if(t<e.length-1&&"group"===n.type)o=n.detail.children;else{if(t!==e.length-1)break;i=n}}return i}function ze(e,t){const i=[];let o=!1;const n=t=>{var a;for(let r=0;r<t.length&&!0!==o;r++){i.push(r);const l=t[r];if(l.uuid===e){o=!0;break}if("group"===l.type&&n((null===(a=null==l?void 0:l.detail)||void 0===a?void 0:a.children)||[]),o)break;i.pop()}};return n(t),i}function Re(e){const{x:t,y:i,h:o,w:n}=e;return[{x:t,y:i},{x:t+n,y:i},{x:t+n,y:i+o},{x:t,y:i+o}]}function Pe(e){const{x:t,y:i,w:o,h:n,angle:a=0}=e;return 0===a?Re(e):ye(e,ue({x:t,y:i,w:o,h:n,angle:a}),a)}function Te(e){const t=[];let i=0,o=0;const n=[],a=[...e];for(let e=0;e<a.length;e++){const{x:r,y:l,w:s,h:h,angle:c=0}=a[e];let d;if(i+=r,o+=l,0===e){const e={x:i,y:o,w:s,h:h,angle:c};d=Pe({x:r,y:l,w:s,h:h,angle:c}),n.push({center:ue(e),angle:c,radian:ce(c)})}else{d=Re({x:i,y:o,w:s,h:h,angle:c});for(let e=0;e<n.length;e++){const{center:t,radian:i}=n[e];d=xe(t,d,i)}const e=ge(d);if(c>0||c<0){d=xe(e,d,ce(c))}n.push({center:e,angle:c,radian:ce(c)})}t.push(d)}return t}function Ee(e,t){const i=function(e,t){const{groupQueue:i}=t;return i.length>0?Te([...i,e]):[Pe(e)]}(e,t);return i.pop()||null}function We(e,t){const{viewScaleInfo:i}=t,{x:o,y:n,w:a,h:r,angle:l}=e,{scale:s,offsetTop:h,offsetLeft:c}=i;return{x:o*s+c,y:n*s+h,w:a*s,h:r*s,angle:l}}function Ce(e,t){const{viewScaleInfo:i}=t,{x:o,y:n}=e,{scale:a,offsetTop:r,offsetLeft:l}=i;return{x:o*a+l,y:n*a+r}}function ke(e,t){return[Ce(e[0],t),Ce(e[1],t),Ce(e[2],t),Ce(e[3],t)]}function Le(e,t){const{context2d:i,element:o,viewScaleInfo:n}=t,{angle:a=0}=o,{x:r,y:l,w:s,h:h}=We(o,{viewScaleInfo:n}),c=pe({x:r,y:l,w:s,h:h,angle:a});if(c.length>=2){i.beginPath(),i.moveTo(c[0].x,c[0].y);for(let e=1;e<c.length;e++)i.lineTo(c[e].x,c[e].y);i.closePath()}return!!i.isPointInPath(e.x,e.y)}function Oe(e,t,i){const o=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y],a=Math.min(...o),r=Math.max(...o),l=Math.min(...n),s=Math.max(...n);return e.x>a&&e.x<r&&e.y>l&&e.y<s}function je(e,t){const{groupQueue:i}=t,o=Ee(e,{groupQueue:i}),n=ee(o[0],o[1]),a=ee(o[1],o[2]),r=ee(o[2],o[3]),l=ee(o[3],o[0]),s=o[0],h=o[1],c=o[2],d=o[3],f=Math.max(s.x,h.x,c.x,d.x),u=Math.max(s.y,h.y,c.y,d.y);return{center:{x:(f+Math.min(s.x,h.x,c.x,d.x))/2,y:(u+Math.min(s.y,h.y,c.y,d.y))/2},topLeft:s,topRight:h,bottomLeft:d,bottomRight:c,top:n,right:a,left:l,bottom:r}}function Ye(e){const t=Math.max(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),i=Math.max(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),o=Math.min(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),a={x:e.center.x,y:e.center.y},r={x:o,y:n},l={x:t,y:n},s={x:t,y:i},h={x:o,y:i},c=ee(r,l),d=ee(h,s),f=ee(r,h);return{center:a,topLeft:r,topRight:l,bottomLeft:h,bottomRight:s,top:c,right:ee(l,s),left:f,bottom:d}}function De(e,t){const i=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n,offsetLeft:a}=t,{width:r,height:l}=i,s=0-a/o,h=0-n/o,c=r/o,d=l/o,f=ue({x:s,y:h,w:c,h:d}),u={x:s,y:h},g={x:s+c,y:h},v={x:s,y:h+d},w={x:s+c,y:h+d},m={x:s,y:f.y},y={x:f.x,y:h},p={x:s+c,y:f.y},x={x:f.x,y:h+d};return{center:f,topLeft:u,topRight:g,bottomLeft:v,bottomRight:w,left:m,top:y,right:p,bottom:x}}(t);let o=0,n=0;return Object.keys(e).forEach((t=>{const a=e[t];a.isVisibleInView=function(e,t){const i=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),o=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),a=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),r=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),l=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),s=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),h=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y);return i<=l&&o>=r&&n<=h&&a>=s||l<=a&&l>=a&&l<=a&&l>=a}(a.rangeRectInfo,i),a.isVisibleInView?o++:n++})),{viewVisibleInfoMap:e,visibleCount:o,invisibleCount:n}}function Ve(e,t){const{x:i,y:o}=e,{size:n,angle:a}=t;return{x:i-n/2,y:o-n/2,w:n,h:n,angle:a}}function Ge(e,t){const{groupQueue:i,controllerSize:o,viewScaleInfo:n}=t,a=(o&&o>0?o:8)/n.scale,{x:r,y:l,w:s,h:h,angle:c=0}=e,d=[{uuid:P(),x:r,y:l,w:s,h:h,angle:c,type:"group",detail:{children:[]}},...i];let f=0;d.forEach((({angle:e=0})=>{f+=e}));const u=Ee(e,{groupQueue:i}),g=Ee({x:r-2*a,y:l-2*a,h:h+4*a,w:s+4*a,angle:c},{groupQueue:[...i]}),v=ee(u[0],u[1]),w=ee(u[1],u[2]),m=ee(u[2],u[3]),y=ee(u[3],u[0]),p=u[0],x=u[1],S=u[2],b=u[3],I=Ve(v,{size:a,angle:f}),A=Ve(w,{size:a,angle:f}),M=Ve(m,{size:a,angle:f}),z=Ve(y,{size:a,angle:f}),R=Ve(p,{size:a,angle:f}),T=Ve(x,{size:a,angle:f}),E=Ve(b,{size:a,angle:f}),W=Ve(S,{size:a,angle:f}),C=Pe(R),k=Pe(T),L=Pe(E),O=Pe(W),j=[C[1],k[0],k[3],C[2]],Y=[k[3],k[2],O[1],O[0]],D=[L[1],O[0],O[3],L[2]],V=[C[3],C[2],L[1],L[0]],G=Pe(I),X=Pe(A),N=Pe(M),B=Pe(z),F=ee(g[0],g[1]);return{elementWrapper:u,left:{type:"left",vertexes:V,center:y},right:{type:"right",vertexes:Y,center:w},top:{type:"top",vertexes:j,center:v},bottom:{type:"bottom",vertexes:D,center:m},topLeft:{type:"top-left",vertexes:C,center:p},topRight:{type:"top-right",vertexes:k,center:x},bottomLeft:{type:"bottom-left",vertexes:L,center:b},bottomRight:{type:"bottom-right",vertexes:O,center:S},leftMiddle:{type:"left-middle",vertexes:B,center:y},rightMiddle:{type:"right-middle",vertexes:X,center:w},topMiddle:{type:"top-middle",vertexes:G,center:v},bottomMiddle:{type:"bottom-middle",vertexes:N,center:m},rotate:{type:"rotate",vertexes:Pe(Ve(F,{size:a,angle:f})),center:F}}}function Xe(e,t){const{controllerSize:i,viewScaleInfo:o}=t,n=i&&i>0?i:8,{x:a,y:r,w:l,h:s}=We(e,{viewScaleInfo:o}),h=ue({x:a,y:r,w:l,h:s}),c={x:h.x,y:r},d={x:a+l,y:h.y},f={x:h.x,y:r+s},u={x:a,y:h.y},g={x:a,y:r},v={x:a+l,y:r},w={x:a+l,y:r+s},m={x:a,y:r+s},y=Ve(c,{size:n,angle:0}),p=Ve(d,{size:n,angle:0}),x=Ve(f,{size:n,angle:0}),S=Ve(u,{size:n,angle:0}),b=Ve(g,{size:n,angle:0}),I=Ve(v,{size:n,angle:0}),A=Ve(m,{size:n,angle:0}),M=Ve(w,{size:n,angle:0}),z=Pe(b),R=Pe(I),P=Pe(A),T=Pe(M),E=[z[1],R[0],R[3],z[2]],W=[R[3],R[2],T[1],T[0]],C=[P[1],T[0],T[3],P[2]],k=[z[3],z[2],P[1],P[0]],L=Pe(y),O=Pe(p),j=Pe(x);return{left:{type:"left",vertexes:k,center:u},right:{type:"right",vertexes:W,center:d},top:{type:"top",vertexes:E,center:c},bottom:{type:"bottom",vertexes:C,center:f},topLeft:{type:"top-left",vertexes:z,center:g},topRight:{type:"top-right",vertexes:R,center:v},bottomLeft:{type:"bottom-left",vertexes:P,center:m},bottomRight:{type:"bottom-right",vertexes:T,center:w},leftMiddle:{type:"left-middle",vertexes:Pe(S),center:u},rightMiddle:{type:"right-middle",vertexes:O,center:d},topMiddle:{type:"top-middle",vertexes:L,center:c},bottomMiddle:{type:"bottom-middle",vertexes:j,center:f}}}function Ne(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}function Be(e,t){let i=2;return void 0!==(null==t?void 0:t.decimalPlaces)&&(null==t?void 0:t.decimalPlaces)>=0&&(i=t.decimalPlaces),parseFloat(e.toFixed(i))}ie=new WeakMap,oe=new WeakMap,te=new WeakSet,ne=function(){return W(re(this,oe,"f"))};const Fe={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function He(e,t){const{viewScaleInfo:i}=t,{scale:o}=i;let{borderRadius:n,borderDash:a}=e.detail;const r=Array.isArray(a)&&a.length>0,{boxSizing:l=Fe.boxSizing,borderWidth:s}=e.detail;Array.isArray(s)&&(n=0);let{x:h,y:c,w:d,h:f}=e,u=[0,0,0,0];if("number"==typeof n){const e=n*o;u=[e,e,e,e]}else Array.isArray(n)&&4===(null==n?void 0:n.length)&&(u=[n[0]*o,n[1]*o,n[2]*o,n[3]*o]);let g=0;return"number"==typeof s&&(g=(s||0)*o),"border-box"!==l||r?"content-box"===l?(h=e.x-g/2,c=e.y-g/2,d=e.w+g,f=e.h+g):(h=e.x,c=e.y,d=e.w,f=e.h):(h=e.x+g/2,c=e.y+g/2,d=e.w-g,f=e.h-g),d=Math.max(d,1),f=Math.max(f,1),u=u.map((e=>Math.min(e,d/2,f/2))),{x:h,y:c,w:d,h:f,radiusList:u}}const Ze=e=>Be(e,{decimalPlaces:4});function Qe(e,t){const{detail:i}=e,{xRatio:o,yRatio:n,maxRatio:a}=t,r=(o+n)/2,{borderWidth:l,borderRadius:s,borderDash:h,shadowOffsetX:c,shadowOffsetY:d,shadowBlur:f}=i;if("number"==typeof l)i.borderWidth=Ze(l*r);else if(Array.isArray(i.borderWidth)){const e=l;i.borderWidth=[Ze(e[0]*n),Ze(e[1]*o),Ze(e[2]*n),Ze(e[3]*o)]}if("number"==typeof s)i.borderRadius=Ze(s*r);else if(Array.isArray(i.borderRadius)){const e=s;i.borderRadius=[e[0]*o,e[1]*o,e[2]*n,e[3]*n]}Array.isArray(h)&&h.forEach(((e,t)=>{i.borderDash[t]=Ze(e*a)})),"number"==typeof c&&(i.shadowOffsetX=Ze(c*a)),"number"==typeof d&&(i.shadowOffsetX=Ze(d*a)),"number"==typeof f&&(i.shadowOffsetX=Ze(f*a))}function Ue(e,t){const{type:i}=e;!function(e,t){const{xRatio:i,yRatio:o}=t,{x:n,y:a,w:r,h:l}=e;e.x=Ze(n*i),e.y=Ze(a*o),e.w=Ze(r*i),e.h=Ze(l*o),Qe(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=Ze(n*r)),a&&a>0&&(e.detail.lineHeight=Ze(a*r))}(e,t):"image"===i||"svg"===i||"html"===i||"path"===i||"group"===i&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Ue(e,t)})))}const Je=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function $e(e){return[e,...Je].join(", ")}function Ke(e,t,i){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:n,opacity:a=1}=i,{x:r,y:l}=o,{scale:s}=n;if("linear-gradient"===(null==t?void 0:t.type)){const{start:i,end:o,stops:n}=t,h={x:r+i.x*s,y:l+i.y*s},c={x:r+o.x*s,y:l+o.y*s},d=e.createLinearGradient(h.x,h.y,c.x,c.y);return n.forEach((e=>{d.addColorStop(e.offset,R(e.color,a))})),d}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:i,outer:o,stops:n}=t,h={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},c={x:r+o.x*s,y:l+o.y*s,radius:o.radius*s},d=e.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return n.forEach((e=>{d.addColorStop(e.offset,R(e.color,a))})),d}return"#000000"}const qe={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function _e(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 et(e,t,i){const{pattern:o,renderContent:n,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=i||{},{parentOpacity:h}=i,c=_e(a)*h,{clipPath:d,clipPathStrokeColor:f,clipPathStrokeWidth:u}=a.detail,g=()=>{e.globalAlpha=c,tt(e,t,{pattern:o,viewScaleInfo:l,viewSizeInfo:s}),null==n||n(),it(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=h};d?(function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewSizeInfo:r}=i,l=r.devicePixelRatio,{clipPath:s}=(null==n?void 0:n.detail)||{};if(s&&a&&s.commands){const{x:i,y:n,w:r,h:h}=a,{originW:c,originH:d,originX:f,originY:u}=s,g=r/c,v=h/d,w=i-f*g,m=n-u*v;e.save(),e.translate(w,m),e.scale(l*g,l*v);const y=Ne(s.commands||[]),p=new Path2D(y);e.clip(p),e.translate(0-w,0-m),e.setTransform(1,0,0,1,0,0),fe(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{g()}}),"number"==typeof u&&u>0&&f&&function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewSizeInfo:r,parentOpacity:l}=i,s=r.devicePixelRatio,{clipPath:h,clipPathStrokeColor:c,clipPathStrokeWidth:d}=(null==n?void 0:n.detail)||{};if(h&&a&&h.commands&&"number"==typeof d&&d>0&&c){const{x:i,y:n,w:r,h:f}=a,{originW:u,originH:g,originX:v,originY:w}=h,m=r/u,y=f/g,p=i-v*m,x=n-w*y;e.save(),e.globalAlpha=l,e.translate(p,x),e.scale(s*m,s*y);const S=Ne(h.commands||[]),b=new Path2D(S);e.strokeStyle=c,e.lineWidth=d,e.stroke(b),e.translate(0-p,0-x),e.setTransform(1,0,0,1,0,0),fe(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,parentOpacity:h})):g()}function tt(e,t,i){var o,n;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=i,s=[];if(t.detail.background||a){const{x:i,y:h,w:c,h:d,radiusList:f}=He(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(i+f[0],h),e.arcTo(i+c,h,i+c,h+d,f[1]),e.arcTo(i+c,h+d,i,h+d,f[2]),e.arcTo(i,h+d,i,h,f[3]),e.arcTo(i,h,i+c,h,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(k.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null===(o=t.detail.background)||void 0===o?void 0:o.type)){const o=Ke(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=Ke(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=o,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const o=s[t];"translate"===o.method?e.translate(o.args[0]+i,o.args[1]+h):"rotate"===o.method?e.rotate(...o.args):"scale"===o.method&&e.scale(...o.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function it(e,t,i){if(0===t.detail.borderWidth)return;if(!z(t.detail.borderColor))return;const{viewScaleInfo:o}=i,{scale:n}=o;let a=qe.borderColor;!0===z(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:h=qe.boxSizing}=t.detail;let c=0;"number"==typeof r&&(c=r||1),c*=n;let d=[0,0,0,0];if("number"==typeof l){const e=l*n;d=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(d=[l[0]*n,l[1]*n,l[2]*n,l[3]*n]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*n))));let u=0,g=0,v=0,w=0;if(Array.isArray(r)&&(u=(r[0]||0)*n,g=(r[1]||0)*n,v=(r[2]||0)*n,w=(r[3]||0)*n),w||g||u||v){e.lineCap="butt";let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i+=w/2,o+=u/2,n=n-w/2-g/2,a=a-u/2-v/2):"content-box"===h?(i-=w/2,o-=u/2,n=n+w/2+g/2,a=a+u/2+v/2):(i=t.x,o=t.y,n=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(i-w/2,o),e.lineTo(i+n+g/2,o),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(i+n,o-u/2),e.lineTo(i+n,o+a+v/2),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(i-w/2,o+a),e.lineTo(i+n+g/2,o+a),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(i,o-u/2),e.lineTo(i,o+a+v/2),e.closePath(),e.stroke())}else{let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i=t.x+c/2,o=t.y+c/2,n=t.w-c,a=t.h-c):"content-box"===h?(i=t.x-c/2,o=t.y-c/2,n=t.w+c,a=t.h+c):(i=t.x,o=t.y,n=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",n=Math.max(n,1),a=Math.max(a,1),d=d.map((e=>Math.min(e,n/2,a/2))),e.setLineDash(f),e.lineWidth=c,e.beginPath(),e.moveTo(i+d[0],o),e.arcTo(i+n,o,i+n,o+a,d[1]),e.arcTo(i+n,o+a,i,o+a,d[2]),e.arcTo(i,o+a,i,o,d[3]),e.arcTo(i,o,i+n,o,d[0]),e.closePath(),e.stroke()}e.setLineDash([])}function ot(e,t,i){const{detail:o}=t,{viewScaleInfo:n,renderContent:a}=i,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:h}=o;B.number(h)?(e.save(),e.shadowColor=r||qe.shadowColor,e.shadowOffsetX=(l||0)*n.scale,e.shadowOffsetY=(s||0)*n.scale,e.shadowBlur=(h||0)*n.scale,a(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,a(),e.restore())}const nt={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};var at=function(e,t){var i={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(i[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(i[o[n]]=e[o[n]])}return i};const rt=.4;function lt(e,t,i){var o,n,a;if(!0===(null===(o=null==t?void 0:t.operations)||void 0===o?void 0:o.invisible))return;const{w:r,h:l}=t,{scale:s}=i.viewScaleInfo;if(s<1&&(r*s<rt||l*s<rt)||0===i.parentOpacity)return;const{overrideElementMap:h}=i;if(!(null===(a=null===(n=null==h?void 0:h[t.uuid])||void 0===n?void 0:n.operations)||void 0===a?void 0:a.invisible))try{switch(t.type){case"rect":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=We(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});fe(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{ot(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{et(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,renderContent:()=>{}})}})}))}(e,t,i);break;case"circle":!function(e,t,i){const{detail:o,angle:n}=t,{viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=i,{background:s="#000000",borderColor:h="#000000",boxSizing:c,borderWidth:d=0,borderDash:f}=o;let u=0;"number"==typeof d&&d>0?u=d:Array.isArray(d)&&"number"==typeof d[0]&&d[0]>0&&(u=d[0]),u*=a.scale;const{x:g,y:v,w:w,h:m}=We({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:a})||t,y=Object.assign(Object.assign({},t),{x:g,y:v,w:w,h:m,angle:n});fe(e,{x:g,y:v,w:w,h:m,angle:n},(()=>{ot(e,y,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{let t=w/2,i=m/2;const o=g+t,n=v+i,r=t,d=i;if(u>0&&("content-box"===c||("center-line"===c?(t-=u/2,i-=u/2):(t-=u,i-=u))),t>=0&&i>=0){const c=_e(y)*l;e.globalAlpha=c,e.beginPath();const p=Ke(e,s,{viewElementSize:{x:g,y:v,w:w,h:m},viewScaleInfo:a,opacity:e.globalAlpha});if(e.fillStyle=p,e.circle(o,n,r,d,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=l,"number"==typeof u&&u>0){const r=u/2+t,l=u/2+i;if(e.beginPath(),f){const t=f.map((e=>e*a.scale));e.setLineDash(t)}e.strokeStyle=h,e.lineWidth=u,e.circle(o,n,r,l,0,0,2*Math.PI),e.closePath(),e.stroke(),e.setLineDash([])}}}})}))}(e,t,i);break;case"text":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=We(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});fe(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{ot(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{et(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a})}});{const i=Object.assign(Object.assign({},nt),t.detail),n=i.fontSize||nt.fontSize,a=n*o.scale;if(a<2)return;const c=(i.lineHeight||n)*o.scale;e.fillStyle=t.detail.color||nt.color,e.textBaseline="top",e.$setFont({fontWeight:i.fontWeight,fontSize:a,fontFamily:$e(i.fontFamily)});let d=i.text.replace(/\r\n/gi,"\n");"lowercase"===i.textTransform?d=d.toLowerCase():"uppercase"===i.textTransform&&(d=d.toUpperCase());const f=c,u=d.split("\n"),g=[];let v=0;u.forEach(((t,n)=>{if("maxContent"===i.minInlineSize)g.push({text:t,width:e.$undoPixelRatio(e.measureText(t).width)});else{let l="",c="",d=t.split(c);if("normal"===i.wordBreak){const e=" ",i=t.split(e);d=[],i.forEach(((t,o)=>{d.push(t),o<i.length-1&&d.push(e)}))}if(1===d.length&&"visible"===i.overflow)g.push({text:d[0],width:e.$undoPixelRatio(e.measureText(d[0]).width)});else if(d.length>0){for(let t=0;t<d.length&&(a=e.$doPixelRatio(s),r=e.measureText(l+d[t]).width,o.scale<.5&&a<r&&(a-r)/a>-.15||a>=r?l+=d[t]||"":(g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),l=d[t]||"",v++),!((v+1)*f>h&&"hidden"===i.overflow));t++)if(d.length-1===t&&(v+1)*f<=h){g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),n<u.length-1&&v++;break}}else g.push({text:"",width:0})}var a,r}));let w=0,m=0;f>a&&(m=(f-a)/2),g.length*f<h&&("top"===t.detail.verticalAlign?w=0:"bottom"===t.detail.verticalAlign?w+=h-g.length*f:w+=(h-g.length*f)/2);{const t=l+w;void 0!==i.textShadowColor&&z(i.textShadowColor)&&(e.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&B.number(i.textShadowOffsetX)&&(e.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&B.number(i.textShadowOffsetY)&&(e.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&B.number(i.textShadowBlur)&&(e.shadowBlur=i.textShadowBlur),g.forEach(((o,n)=>{let a=r;"center"===i.textAlign?a=r+(s-o.width)/2:"right"===i.textAlign&&(a=r+(s-o.width)),e.fillText(o.text,a,t+f*n+m)}))}}}))}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=We(t,{viewScaleInfo:n})||t,f=Object.assign(Object.assign({},t),{x:l,y:s,w:h,h:c,angle:d});fe(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{ot(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{et(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{if(o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"image"===t.type&&o){e.globalAlpha=_e(t)*r;const{x:i,y:l,w:s,h:h,radiusList:c}=He(f,{viewScaleInfo:n,viewSizeInfo:a}),{detail:d}=t,{scaleMode:u,originW:g=0,originH:v=0}=d,w=e.$undoPixelRatio(g),m=e.$undoPixelRatio(v);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+c[0],l),e.arcTo(i+s,l,i+s,l+h,c[1]),e.arcTo(i+s,l+h,i,l+h,c[2]),e.arcTo(i,l+h,i,l,c[3]),e.arcTo(i,l,i+s,l,c[0]),e.closePath(),e.fill(),e.clip(),u&&v&&g){let n=0,a=0,r=w,c=m;const d=i,f=l,g=s,v=h;if(w>t.w||m>t.h)if("fill"===u){const e=Math.max(t.w/w,t.h/m),i=m*e;n=(w*e-t.w)/2/e,a=(i-t.h)/2/e,r=t.w/e,c=t.h/e}else if("tile"===u)n=0,a=0,r=t.w,c=t.h;else if("fit"===u){const e=Math.min(t.w/w,t.h/m);n=(w-t.w/e)/2,a=(m-t.h/e)/2,r=t.w/e,c=t.h/e}e.drawImage(o,n,a,r,c,d,f,g,v)}else e.drawImage(o,i,l,s,h);e.globalAlpha=r,e.restore()}}})}})}))}(e,t,i);break;case"svg":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=We(t,{viewScaleInfo:n,viewSizeInfo:a})||t;fe(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"svg"===t.type&&o&&(e.globalAlpha=_e(t)*r,e.drawImage(o,l,s,h,c),e.globalAlpha=r)}))}(e,t,i);break;case"html":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=We(t,{viewScaleInfo:n,viewSizeInfo:a})||t;fe(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"html"===t.type&&o&&(e.globalAlpha=_e(t)*r,e.drawImage(o,l,s,h,c),e.globalAlpha=r)}))}(e,t,i);break;case"path":!function(e,t,i){var o,n;const{detail:a}=t,{originX:r,originY:l,originW:s,originH:h,fillRule:c}=a,{viewScaleInfo:d,viewSizeInfo:f,parentOpacity:u}=i,{x:g,y:v,w:w,h:m,angle:y}=We(t,{viewScaleInfo:d})||t,p=w/s,x=m/h,S=g-r*p,b=v-l*x,I=t.detail,A=at(I,["clipPath","clipPathStrokeColor","clipPathStrokeWidth"]),M=d.scale*f.devicePixelRatio,z=Object.assign(Object.assign({},t),{x:g,y:v,w:w,h:m,angle:y});let R=Object.assign({},z);R.detail=A;let P=Object.assign({},t);P.detail=A,a.fill&&"string"!==a.fill&&(null===(n=null===(o=a.fill)||void 0===o?void 0:o.type)||void 0===n?void 0:n.includes("gradient"))&&(R=Object.assign(Object.assign({},z),{detail:Object.assign(Object.assign({},z.detail),{background:a.fill,clipPath:{commands:a.commands,originX:r,originY:l,originW:s,originH:h}})}),P.detail=Object.assign({},R.detail)),fe(e,{x:g,y:v,w:w,h:m,angle:y},(()=>{et(e,R,{originElem:P,calcElemSize:{x:g,y:v,w:w,h:m,angle:y},viewScaleInfo:d,viewSizeInfo:f,parentOpacity:u,renderContent:()=>{ot(e,z,{viewScaleInfo:d,viewSizeInfo:f,renderContent:()=>{e.save(),e.translate(S,b),e.scale(M*p/d.scale,M*x/d.scale);const t=Ne(a.commands||[]),i=new Path2D(t);a.fill&&("string"==typeof a.fill?e.fillStyle=a.fill:e.fillStyle="transparent"),a.fill&&e.fill(i,c),a.stroke&&0!==a.strokeWidth&&(e.strokeStyle=a.stroke,e.lineWidth=(a.strokeWidth||1)/f.devicePixelRatio,e.lineCap=a.strokeLineCap||"square",e.stroke(i)),e.translate(-S,-b),e.restore()}})}})}))}(e,t,i);break;case"group":{const o=Object.assign(Object.assign({},i.elementAssets||{}),t.detail.assets||{});!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=We({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});fe(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{e.globalAlpha=_e(t)*a,ot(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{et(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,renderContent:()=>{const{x:r,y:l,w:s,h:h,radiusList:c}=He(d,{viewScaleInfo:o,viewSizeInfo:n});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(r+c[0],l),e.arcTo(r+s,l,r+s,l+h,c[1]),e.arcTo(r+s,l+h,r,l+h,c[2]),e.arcTo(r,l+h,r,l,c[3]),e.arcTo(r,l,r+s,l,c[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:o}=i,n={x:o.x+t.x,y:o.y+t.y,w:t.w||o.w,h:t.h||o.h,angle:t.angle},{calculator:r}=i;for(let o=0;o<t.detail.children.length;o++){let l=t.detail.children[o];if(l=Object.assign(Object.assign({},l),{x:n.x+l.x,y:n.y+l.y}),!0===i.forceDrawAll||(null==r?void 0:r.needRender(l)))try{lt(e,l,Object.assign(Object.assign({},i),{parentOpacity:a*_e(t)}))}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=a}))}(e,t,Object.assign(Object.assign({},i),{elementAssets:o}));break}}}catch(e){console.error(e)}}const st={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function ht(e,t,i){var o;const{elements:n=[]}=t,{parentOpacity:a}=i;for(let t=0;t<n.length;t++){const r=n[t],l=Object.assign(Object.assign({},r),{detail:Object.assign(Object.assign({},st),null==r?void 0:r.detail)});if(!0===i.forceDrawAll||(null===(o=i.calculator)||void 0===o?void 0:o.needRender(l)))try{lt(e,l,Object.assign(Object.assign({},i),{parentOpacity:a}))}catch(e){console.error(e)}}}var ct,dt,ft,ut,gt,vt,wt,mt,yt,pt,xt,St,bt=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))},It=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)},At=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i};const Mt=["image","svg","html"],zt=e=>{var t,i,o;let n=null;return"image"===e.type?n=(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)||null:"svg"===e.type?n=(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)||null:"html"===e.type&&(n=(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)||null),"string"==typeof n&&n?/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${n}`)?n:E(n):E(`${P()}-${e.uuid}-${P()}-${P()}`)};class Rt extends _{constructor(){super(),ct.add(this),dt.set(this,{}),ft.set(this,{}),ut.set(this,{}),gt.set(this,!1),It(this,ct,"m",vt).call(this,"image",((e,t)=>bt(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.src])||void 0===i?void 0:i.value)||e.detail.src,n=yield j(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),It(this,ct,"m",vt).call(this,"html",((e,t)=>bt(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 D(o,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),It(this,ct,"m",vt).call(this,"svg",((e,t)=>bt(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 Y(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}}))))}isDestroyed(){return It(this,gt,"f")}destroy(){At(this,gt,!0,"f"),this.clear(),At(this,dt,null,"f"),At(this,ft,null,"f"),At(this,ut,null,"f")}load(e,t){!0!==It(this,gt,"f")&&(It(this,ct,"m",St).call(this,e)||Mt.includes(e.type)&&It(this,ct,"m",xt).call(this,e,t))}getContent(e){var t,i;const o=zt(e);return(null===(i=null===(t=It(this,ut,"f"))||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return It(this,ut,"f")}setLoadItemMap(e){At(this,ut,e,"f")}}dt=new WeakMap,ft=new WeakMap,ut=new WeakMap,gt=new WeakMap,ct=new WeakSet,vt=function(e,t){It(this,dt,"f")[e]=t},wt=function(e){var t,i,o;let n=null;return"image"===e.type?n=(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)||null:"svg"===e.type?n=(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)||null:"html"===e.type&&(n=(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)||null),n},mt=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:It(this,ct,"m",wt).call(this,e)}},yt=function(e){const t=zt(e.element),i=It(this,ut,"f")[t];It(this,gt,"f")||(i?i.startTime<e.startTime&&(It(this,ut,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(It(this,ut,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},pt=function(e){var t;const i=zt(e.element),o=null===(t=It(this,ut,"f"))||void 0===t?void 0:t[i];It(this,gt,"f")||(o?o.startTime<e.startTime&&(It(this,ut,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(It(this,ut,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},xt=function(e,t){const i=It(this,ct,"m",mt).call(this,e),o=zt(e);if(It(this,ft,"f")[o])return;It(this,ft,"f")[o]=i;const n=It(this,dt,"f")[e.type];"function"!=typeof n||It(this,gt,"f")||(i.startTime=Date.now(),n(e,t).then((e=>{It(this,gt,"f")||(i.content=e.content,i.endTime=Date.now(),i.status="load",It(this,ct,"m",yt).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,It(this,ct,"m",pt).call(this,i)})))},St=function(e){var t;const i=zt(e),o=null===(t=It(this,ft,"f"))||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==It(this,ct,"m",wt).call(this,e))};var Pt,Tt,Et,Wt,Ct,kt=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},Lt=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 Ot extends _{constructor(e){super(),Pt.add(this),Tt.set(this,void 0),Et.set(this,new Rt),Wt.set(this,!1),kt(this,Tt,e,"f"),Lt(this,Pt,"m",Ct).call(this)}isDestroyed(){return Lt(this,Wt,"f")}destroy(){this.clear(),kt(this,Tt,null,"f"),Lt(this,Et,"f").destroy(),kt(this,Et,null,"f"),kt(this,Wt,!0,"f")}updateOptions(e){kt(this,Tt,e,"f")}drawData(e,t){const i=Lt(this,Et,"f"),{calculator:o,sharer:n}=Lt(this,Tt,"f"),a=Lt(this,Tt,"f").viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const r={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},l=Object.assign({loader:i,calculator:o,parentElementSize:r,elementAssets:e.assets,parentOpacity:1,overrideElementMap:null==n?void 0:n.getActiveOverrideElemenentMap()},t);!function(e,t,i){if("string"==typeof(null==t?void 0:t.background)){const{viewSizeInfo:o}=i,{width:n,height:a}=o;e.globalAlpha=1,e.fillStyle=t.background,e.fillRect(0,0,n,a)}}(a,e.global,l),e.layout?function(e,t,i,o){const{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,l=Object.assign({uuid:"layout",type:"group"},t),{x:s,y:h,w:c,h:d}=We(l,{viewScaleInfo:n})||l,f=Object.assign(Object.assign({},l),{x:s,y:h,w:c,h:d,angle:0});if(e.globalAlpha=1,ot(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{tt(e,f,{viewScaleInfo:n,viewSizeInfo:a})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:o,viewSizeInfo:n}=i,a=Object.assign({uuid:"layout",type:"group"},t),r=We(a,{viewScaleInfo:o})||a,l=Object.assign(Object.assign({},a),r),{x:s,y:h,w:c,h:d,radiusList:f}=He(l,{viewScaleInfo:o,viewSizeInfo:n});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(s+f[0],h),e.arcTo(s+c,h,s+c,h+d,f[1]),e.arcTo(s+c,h+d,s,h+d,f[2]),e.arcTo(s,h+d,s,h,f[3]),e.arcTo(s,h,s+c,h,f[0]),e.closePath(),e.fill(),e.clip()}o(e),"hidden"===t.detail.overflow&&e.restore(),it(e,f,{viewScaleInfo:n,viewSizeInfo:a}),e.globalAlpha=r}(a,e.layout,l,(()=>{ht(a,e,l)})):ht(a,e,l)}scale(e){const{sharer:t}=Lt(this,Tt,"f");if(!t)return;const{data:i,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){Lt(this,Et,"f").setLoadItemMap(e)}getLoadItemMap(){return Lt(this,Et,"f").getLoadItemMap()}getLoader(){return Lt(this,Et,"f")}}Tt=new WeakMap,Et=new WeakMap,Wt=new WeakMap,Pt=new WeakSet,Ct=function(){const e=Lt(this,Et,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))};var jt,Yt,Dt=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},Vt=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class Gt{constructor(e){jt.set(this,void 0),Yt.set(this,void 0),Dt(this,jt,e,"f"),Dt(this,Yt,new le({defaultStorage:{viewVisibleInfoMap:{},visibleCount:0,invisibleCount:0}}),"f")}toGridNum(e,t){return!0===(null==t?void 0:t.ignore)?e:Math.round(e)}destroy(){Dt(this,jt,null,"f")}needRender(e){const t=Vt(this,Yt,"f").get("viewVisibleInfoMap")[e.uuid];return!t||t.isVisibleInView}isPointInElement(e,t,i,o){return Le(e,{context2d:Vt(this,jt,"f").viewContext,element:t,viewScaleInfo:i,viewSizeInfo:o})}getPointElement(e,t){const i=Vt(this,jt,"f").viewContext;return function(e,t){var i,o,n;const{context2d:a,data:r,viewScaleInfo:l,viewSizeInfo:s,groupQueue:h}=t,c={index:-1,element:null,groupQueueIndex:-1};if(h&&Array.isArray(h)&&(null==h?void 0:h.length)>0)for(let t=h.length-1;t>=0;t--){let n=0,r=0,d=0;for(let e=0;e<=t;e++)n+=h[e].x,r+=h[e].y,d+=h[e].angle||0;const f=h[t];if(f&&"group"===f.type&&Array.isArray(null===(i=f.detail)||void 0===i?void 0:i.children))for(let i=0;i<f.detail.children.length;i++){const u=f.detail.children[i];if(!0!==(null===(o=null==u?void 0:u.operations)||void 0===o?void 0:o.invisible)){if(!u)break;if(Le(e,{context2d:a,element:{x:n+u.x,y:r+u.y,w:u.w,h:u.h,angle:d+(u.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){c.element=u,(t<h.length-1||"group"!==u.type)&&(c.groupQueueIndex=t);break}}}if(c.element)break}if(c.element)return c;for(let t=r.elements.length-1;t>=0;t--){const i=r.elements[t];if(!0!==(null===(n=null==i?void 0:i.operations)||void 0===n?void 0:n.invisible)&&Le(e,{context2d:a,element:i,viewScaleInfo:l,viewSizeInfo:s})){c.index=t,c.element=i;break}}return c}(e,Object.assign(Object.assign({},t),{context2d:i}))}resetViewVisibleInfoMap(e,t){if(e){const{viewVisibleInfoMap:i,invisibleCount:o,visibleCount:n}=function(e,t){const i={},o=[],n=t=>{const a={isVisibleInView:!0,isGroup:"group"===t.type,position:[...o]};let r=null;r=je(t,{groupQueue:Ae(e,o)||[]}),i[t.uuid]=Object.assign(Object.assign({},a),{originRectInfo:r,rangeRectInfo:B.angle(t.angle)?Ye(r):r}),"group"===t.type&&t.detail.children.forEach(((e,t)=>{o.push(t),n(e),o.pop()}))};return e.forEach(((e,t)=>{o.push(t),n(e),o.pop()})),De(i,t)}(e.elements,t);Vt(this,Yt,"f").set("viewVisibleInfoMap",i),Vt(this,Yt,"f").set("invisibleCount",o),Vt(this,Yt,"f").set("visibleCount",n)}}updateVisiableStatus(e){const{viewVisibleInfoMap:t,invisibleCount:i,visibleCount:o}=De(Vt(this,Yt,"f").get("viewVisibleInfoMap"),e);Vt(this,Yt,"f").set("viewVisibleInfoMap",t),Vt(this,Yt,"f").set("invisibleCount",i),Vt(this,Yt,"f").set("visibleCount",o)}calcViewRectInfoFromOrigin(e,t){const i=Vt(this,Yt,"f").get("viewVisibleInfoMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:a}=t,{center:r,left:l,right:s,bottom:h,top:c,topLeft:d,topRight:f,bottomLeft:u,bottomRight:g}=i.originRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n,viewSizeInfo:a};return{center:Ce(r,v),left:Ce(l,v),right:Ce(s,v),bottom:Ce(h,v),top:Ce(c,v),topLeft:Ce(d,v),topRight:Ce(f,v),bottomLeft:Ce(u,v),bottomRight:Ce(g,v)}}calcViewRectInfoFromRange(e,t){const i=Vt(this,Yt,"f").get("viewVisibleInfoMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:a}=t,{center:r,left:l,right:s,bottom:h,top:c,topLeft:d,topRight:f,bottomLeft:u,bottomRight:g}=i.rangeRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n,viewSizeInfo:a};return{center:Ce(r,v),left:Ce(l,v),right:Ce(s,v),bottom:Ce(h,v),top:Ce(c,v),topLeft:Ce(d,v),topRight:Ce(f,v),bottomLeft:Ce(u,v),bottomRight:Ce(g,v)}}modifyViewVisibleInfoMap(e,t){const{modifyOptions:i,viewScaleInfo:o,viewSizeInfo:n}=t,{type:a,content:r}=i,l=e.elements,s=Vt(this,Yt,"f").get("viewVisibleInfoMap");if("deleteElement"===a){const{element:e}=r,t=[],i=e=>{t.push(e.uuid),"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{i(e)}))};i(e),t.forEach((e=>{delete s[e]})),Vt(this,Yt,"f").set("viewVisibleInfoMap",s)}else if("addElement"===a||"updateElement"===a){const{position:t}=r,i=Me(t,e.elements),h=Ae(l,t);if(i)if("updateElement"===a&&"group"===i.type)this.resetViewVisibleInfoMap(e,{viewScaleInfo:o,viewSizeInfo:n});else{const e=je(i,{groupQueue:h||[]}),r={originRectInfo:e,rangeRectInfo:B.angle(i.angle)?Ye(e):e,isVisibleInView:!0,isGroup:"group"===(null==i?void 0:i.type),position:[...t]};s[i.uuid]=r,Vt(this,Yt,"f").set("viewVisibleInfoMap",s),"updateElement"===a&&this.updateVisiableStatus({viewScaleInfo:o,viewSizeInfo:n})}}else"moveElement"===a&&this.resetViewVisibleInfoMap(e,{viewScaleInfo:o,viewSizeInfo:n})}}jt=new WeakMap,Yt=new WeakMap;var Xt,Nt,Bt,Ft,Ht,Zt,Qt,Ut,Jt,$t,Kt,qt,_t,ei,ti,ii,oi=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},ni=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};function ai(e){return e>0||e<0||0===e}class ri extends _{constructor(e){super(),Xt.add(this),Nt.set(this,void 0),Bt.set(this,void 0),Ft.set(this,!1),Zt.set(this,(e=>{if(!ni(this,Xt,"m",ei).call(this,e))return;const t=ni(this,Xt,"m",ti).call(this,e);if(!ni(this,Xt,"m",ii).call(this,t))return;e.preventDefault(),e.stopPropagation();const i=e.deltaX>0||e.deltaX<0?e.deltaX:0,o=e.deltaY>0||e.deltaY<0?e.deltaY:0;!0===e.ctrlKey&&this.has("wheelScale")?this.trigger("wheelScale",{deltaX:i,deltaY:o,point:t}):this.has("wheel")&&this.trigger("wheel",{deltaX:i,deltaY:o,point:t})})),Qt.set(this,(e=>{if(!ni(this,Xt,"m",ei).call(this,e))return;e.preventDefault();const t=ni(this,Xt,"m",ti).call(this,e);ni(this,Xt,"m",ii).call(this,t)})),Ut.set(this,(e=>{if(!ni(this,Xt,"m",ei).call(this,e))return;e.preventDefault();const t=ni(this,Xt,"m",ti).call(this,e);if(!ni(this,Xt,"m",ii).call(this,t))return;const i=Date.now(),o=ni(this,Bt,"f").get("prevClickPoint");o&&i-o.t<=500&&Math.abs(o.x-t.x)<=5&&Math.abs(o.y-t.y)<=5?this.trigger("doubleClick",{point:t}):ni(this,Bt,"f").set("prevClickPoint",t)})),Jt.set(this,(e=>{if(ni(this,Bt,"f").set("hasPointDown",!1),!ni(this,Xt,"m",ei).call(this,e))return;e.preventDefault();const t=ni(this,Xt,"m",ti).call(this,e);this.trigger("pointLeave",{point:t})})),$t.set(this,(e=>{if(ni(this,Bt,"f").set("hasPointDown",!1),!ni(this,Xt,"m",ei).call(this,e))return;e.preventDefault();const t=ni(this,Xt,"m",ti).call(this,e);this.trigger("pointEnd",{point:t})})),Kt.set(this,(e=>{if(!ni(this,Xt,"m",ei).call(this,e))return;e.preventDefault(),e.stopPropagation();const t=ni(this,Xt,"m",ti).call(this,e);ni(this,Xt,"m",ii).call(this,t)?!0===ni(this,Bt,"f").get("hasPointDown")&&this.trigger("pointMove",{point:t}):ni(this,Bt,"f").get("hasPointDown")&&(this.trigger("pointLeave",{point:t}),ni(this,Bt,"f").set("hasPointDown",!1))})),qt.set(this,(e=>{if(!ni(this,Xt,"m",ei).call(this,e))return;e.preventDefault();const t=ni(this,Xt,"m",ti).call(this,e);ni(this,Xt,"m",ii).call(this,t)&&(ni(this,Bt,"f").set("hasPointDown",!0),this.trigger("pointStart",{point:t}))})),_t.set(this,(e=>{if(!ni(this,Xt,"m",ei).call(this,e))return;e.preventDefault();const t=ni(this,Xt,"m",ti).call(this,e);ni(this,Xt,"m",ii).call(this,t)&&this.trigger("hover",{point:t})}));const t=new le({defaultStorage:{hasPointDown:!1,prevClickPoint:null}});oi(this,Bt,t,"f"),oi(this,Nt,e,"f"),ni(this,Xt,"m",Ht).call(this)}onEvents(){if(ni(this,Ft,"f"))return;const e=window;e.addEventListener("mousemove",ni(this,_t,"f")),e.addEventListener("mousedown",ni(this,qt,"f")),e.addEventListener("mousemove",ni(this,Kt,"f")),e.addEventListener("mouseup",ni(this,$t,"f")),e.addEventListener("mouseleave",ni(this,Jt,"f")),e.addEventListener("wheel",ni(this,Zt,"f"),{passive:!1}),e.addEventListener("click",ni(this,Ut,"f")),e.addEventListener("contextmenu",ni(this,Qt,"f"))}offEvents(){const e=window;e.removeEventListener("mousemove",ni(this,_t,"f")),e.removeEventListener("mousedown",ni(this,qt,"f")),e.removeEventListener("mousemove",ni(this,Kt,"f")),e.removeEventListener("mouseup",ni(this,$t,"f")),e.removeEventListener("mouseleave",ni(this,Jt,"f")),e.removeEventListener("wheel",ni(this,Zt,"f")),e.removeEventListener("click",ni(this,Ut,"f")),e.removeEventListener("contextmenu",ni(this,Qt,"f"))}destroy(){this.offEvents(),ni(this,Bt,"f").destroy(),oi(this,Ft,!0,"f")}}Nt=new WeakMap,Bt=new WeakMap,Ft=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,Ut=new WeakMap,Jt=new WeakMap,$t=new WeakMap,Kt=new WeakMap,qt=new WeakMap,_t=new WeakMap,Xt=new WeakSet,Ht=function(){this.onEvents()},ei=function(e){return e.target===ni(this,Nt,"f").boardContent.boardContext.canvas},ti=function(e){const t=ni(this,Nt,"f").boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top,t:Date.now()}},ii=function(e){const t=ni(this,Nt,"f").sharer.getActiveViewSizeInfo(),{width:i,height:o}=t;return!!(ai(e.x)&&ai(e.y)&&e.x<=i&&e.y<=o)};var li,si,hi=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},ci=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 di={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0,overrideElementMap:null};class fi{constructor(){li.set(this,void 0),si.set(this,void 0);const e=new le({defaultStorage:di}),t=new le({defaultStorage:{}});hi(this,li,e,"f"),hi(this,si,t,"f")}getActiveStorage(e){return ci(this,li,"f").get(e)}setActiveStorage(e,t){return ci(this,li,"f").set(e,t)}getActiveStoreSnapshot(e){return ci(this,li,"f").getSnapshot(e)}getSharedStorage(e){return ci(this,si,"f").get(e)}setSharedStorage(e,t){return ci(this,si,"f").set(e,t)}getSharedStoreSnapshot(e){return ci(this,si,"f").getSnapshot(e)}getActiveViewScaleInfo(){return{scale:ci(this,li,"f").get("scale"),offsetTop:ci(this,li,"f").get("offsetTop"),offsetBottom:ci(this,li,"f").get("offsetBottom"),offsetLeft:ci(this,li,"f").get("offsetLeft"),offsetRight:ci(this,li,"f").get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:n,offsetRight:a}=e;ci(this,li,"f").set("scale",t),ci(this,li,"f").set("offsetTop",i),ci(this,li,"f").set("offsetBottom",o),ci(this,li,"f").set("offsetLeft",n),ci(this,li,"f").set("offsetRight",a)}setActiveViewSizeInfo(e){ci(this,li,"f").set("width",e.width),ci(this,li,"f").set("height",e.height),ci(this,li,"f").set("devicePixelRatio",e.devicePixelRatio),ci(this,li,"f").set("contextWidth",e.contextWidth),ci(this,li,"f").set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:ci(this,li,"f").get("width"),height:ci(this,li,"f").get("height"),devicePixelRatio:ci(this,li,"f").get("devicePixelRatio"),contextWidth:ci(this,li,"f").get("contextWidth"),contextHeight:ci(this,li,"f").get("contextHeight")}}getActiveOverrideElemenentMap(){return ci(this,li,"f").get("overrideElementMap")}setActiveOverrideElemenentMap(e){ci(this,li,"f").set("overrideElementMap",e)}}li=new WeakMap,si=new WeakMap;var ui,gi,vi,wi,mi,yi,pi=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},xi=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};const{requestAnimationFrame:Si}=window;class bi extends _{constructor(e){super(),ui.add(this),gi.set(this,void 0),vi.set(this,[]),wi.set(this,"FREE"),pi(this,gi,e,"f"),xi(this,ui,"m",mi).call(this)}resetViewVisibleInfoMap(e,t){e&&xi(this,gi,"f").calculator.resetViewVisibleInfoMap(e,t)}drawFrame(){const{sharer:e}=xi(this,gi,"f"),t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();xi(this,vi,"f").push({activeStore:t,sharedStore:i}),xi(this,ui,"m",yi).call(this)}scale(e){const{scale:t,point:i,ignoreUpdateVisibleStatus:o}=e,{sharer:n}=xi(this,gi,"f"),{moveX:a,moveY:r}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:n,offsetTop:a}=o,r=t/o.scale,l=i.x,s=i.y;return{moveX:l-l*r+(n*r-n),moveY:s-s*r+(a*r-a)}}({scale:t,point:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});return n.setActiveStorage("scale",t),o||xi(this,gi,"f").calculator.updateVisiableStatus({viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),{moveX:a,moveY:r}}scroll(e){const{sharer:t}=xi(this,gi,"f"),i=t.getActiveViewScaleInfo(),{moveX:o,moveY:n,ignoreUpdateVisibleStatus:a}=e,r=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:n}=e,{scale:a}=o,{width:r,height:l,contextWidth:s,contextHeight:h}=n;let c=o.offsetLeft,d=o.offsetRight,f=o.offsetTop,u=o.offsetBottom;return c+=t,f+=i,d=r-(s*a+c),u=l-(h*a+f),{scale:a,offsetTop:f,offsetLeft:c,offsetRight:d,offsetBottom:u}}({moveX:o,moveY:n,viewScaleInfo:i,viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(r),a||xi(this,gi,"f").calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),r}updateViewScaleInfo(e){const{sharer:t}=xi(this,gi,"f"),i=function(e,t){const{scale:i,offsetX:o,offsetY:n}=e,{viewSizeInfo:a}=t,{width:r,height:l,contextWidth:s,contextHeight:h}=a,c=0-o*i,d=0-n*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:r-(s*i+c/i),offsetBottom:l-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),xi(this,gi,"f").calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),i}resize(e={},t){const{sharer:i}=xi(this,gi,"f"),o=i.getActiveViewSizeInfo(),n=Object.assign(Object.assign({},o),e),{width:a,height:r,devicePixelRatio:l}=n,{underlayContext:s,boardContext:h,overlayContext:c,viewContext:d}=xi(this,gi,"f").boardContent;return h.canvas.width=a*l,h.canvas.height=r*l,h.canvas.style.width=`${a}px`,h.canvas.style.height=`${r}px`,s.canvas.width=a*l,s.canvas.height=r*l,c.canvas.width=a*l,c.canvas.height=r*l,d.canvas.width=a*l,d.canvas.height=r*l,i.setActiveViewSizeInfo(n),(null==t?void 0:t.ignoreUpdateVisibleStatus)||xi(this,gi,"f").calculator.updateVisiableStatus({viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}),n}}gi=new WeakMap,vi=new WeakMap,wi=new WeakMap,ui=new WeakSet,mi=function(){const{renderer:e}=xi(this,gi,"f");e.on("load",(()=>{this.drawFrame()}))},yi=function e(){if("DRAWING"===xi(this,wi,"f")||0===xi(this,vi,"f").length)return;pi(this,wi,"DRAWING","f");const t=xi(this,vi,"f").shift(),{renderer:i,boardContent:o,beforeDrawFrame:n,afterDrawFrame:a}=xi(this,gi,"f");if(t){const{scale:e,offsetTop:r,offsetBottom:l,offsetLeft:s,offsetRight:h,width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g}=t.activeStore,v={scale:e,offsetTop:r,offsetBottom:l,offsetLeft:s,offsetRight:h},w={width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g};(null==t?void 0:t.activeStore.data)&&i.drawData(t.activeStore.data,{viewScaleInfo:v,viewSizeInfo:w}),n({snapshot:t}),o.drawView(),a({snapshot:t})}0!==xi(this,vi,"f").length?pi(this,wi,"DRAWING","f")&&Si((()=>{xi(this,ui,"m",e).call(this)})):pi(this,wi,"COMPLETE","f")};var Ii,Ai,Mi,zi,Ri,Pi,Ti,Ei,Wi,Ci,ki,Li,Oi,ji,Yi,Di,Vi,Gi,Xi,Ni,Bi,Fi,Hi,Zi,Qi,Ui,Ji,$i=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Ki=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 qi{constructor(e){Ii.add(this),Ai.set(this,void 0),Mi.set(this,new WeakMap),zi.set(this,[]),Ri.set(this,[]),Pi.set(this,void 0),Ti.set(this,void 0),Ei.set(this,void 0),Wi.set(this,void 0),Ci.set(this,void 0),ki.set(this,new _),Li.set(this,!1);const{boardContent:t}=e,i=new fi,o=new Gt({viewContext:t.viewContext}),n=new ri({boardContent:t,sharer:i}),a=new Ot({viewContext:t.viewContext,sharer:i,calculator:o});$i(this,Ai,e,"f"),$i(this,Ei,i,"f"),$i(this,Pi,n,"f"),$i(this,Ti,a,"f"),$i(this,Ci,o,"f"),$i(this,Wi,new bi({boardContent:e.boardContent,sharer:i,renderer:a,calculator:Ki(this,Ci,"f"),beforeDrawFrame:e=>{Ki(this,Ii,"m",Qi).call(this,e)},afterDrawFrame:e=>{Ki(this,Ii,"m",Ui).call(this,e)}}),"f"),Ki(this,Ii,"m",Oi).call(this),Ki(this,Ii,"m",Ji).call(this)}isDestroyed(){return Ki(this,Li,"f")}destroy(){Ki(this,Pi,"f").destroy(),Ki(this,Ti,"f").destroy(),Ki(this,Ci,"f").destroy(),Ki(this,ki,"f").destroy(),$i(this,Li,!0,"f")}getSharer(){return Ki(this,Ei,"f")}getViewer(){return Ki(this,Wi,"f")}getRenderer(){return Ki(this,Ti,"f")}setData(e,t){const{modifiedOptions:i}=t||{},o=Ki(this,Ei,"f");Ki(this,Ei,"f").setActiveStorage("data",e);const n=o.getActiveViewSizeInfo(),a=o.getActiveViewScaleInfo(),r=Ie(e.elements,{viewWidth:n.width,viewHeight:n.height,extend:!0});Ki(this,Wi,"f").resetViewVisibleInfoMap(e,{viewSizeInfo:n,viewScaleInfo:a}),Ki(this,Wi,"f").drawFrame();const l=Object.assign(Object.assign({},n),r);return Ki(this,Ei,"f").setActiveViewSizeInfo(l),{viewSizeInfo:l}}getData(){const{data:e}=Ki(this,Ei,"f").getActiveStoreSnapshot();return e}use(e){var t,i,o;if(Ki(this,Mi,"f").has(e)){const o=Ki(this,Mi,"f").get(e);if(o)return null===(i=(t=o.middlewareObject).use)||void 0===i||i.call(t),o.status="enable",Ki(this,Mi,"f").set(e,o),void Ki(this,Ii,"m",Ji).call(this)}const{boardContent:n,container:a}=Ki(this,Ai,"f"),r=e({boardContent:n,sharer:Ki(this,Ei,"f"),viewer:Ki(this,Wi,"f"),calculator:Ki(this,Ci,"f"),eventHub:Ki(this,ki,"f"),container:a});null===(o=r.use)||void 0===o||o.call(r),Ki(this,zi,"f").push(e),Ki(this,Ri,"f").push(r),Ki(this,Mi,"f").set(e,{status:"enable",middlewareObject:r}),Ki(this,Ii,"m",Ji).call(this)}disuse(e){var t,i;const o=Ki(this,Mi,"f").get(e);o&&(null===(i=(t=o.middlewareObject).disuse)||void 0===i||i.call(t),o.status="disable",Ki(this,Mi,"f").set(e,o),Ki(this,Ii,"m",Ji).call(this))}scale(e){const t=Ki(this,Wi,"f"),{ignoreUpdateVisibleStatus:i}=e,{moveX:o,moveY:n}=t.scale(Object.assign(Object.assign({},e),{ignoreUpdateVisibleStatus:!0}));t.scroll({moveX:o,moveY:n,ignoreUpdateVisibleStatus:i})}scroll(e){return Ki(this,Wi,"f").scroll(e)}updateViewScaleInfo(e){return Ki(this,Wi,"f").updateViewScaleInfo(e)}resize(e,t){const i=Ki(this,Wi,"f").resize(e,t),{width:o,height:n,devicePixelRatio:a}=e,{boardContent:r}=Ki(this,Ai,"f");r.viewContext.$resize({width:o,height:n,devicePixelRatio:a}),r.overlayContext.$resize({width:o,height:n,devicePixelRatio:a}),r.boardContext.$resize({width:o,height:n,devicePixelRatio:a}),r.underlayContext.$resize({width:o,height:n,devicePixelRatio:a}),Ki(this,Wi,"f").drawFrame(),Ki(this,Pi,"f").trigger("resize",i),Ki(this,Ei,"f").setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=Ki(this,Ai,"f"),{underlayContext:t,overlayContext:i,viewContext:o,boardContext:n}=e;t.clearRect(0,0,t.canvas.width,t.canvas.height),i.clearRect(0,0,i.canvas.width,i.canvas.height),o.clearRect(0,0,o.canvas.width,o.canvas.height),n.clearRect(0,0,n.canvas.width,n.canvas.height),Ki(this,Ii,"m",Zi).call(this)}getEventHub(){return Ki(this,ki,"f")}onWatcherEvents(){Ki(this,Pi,"f").onEvents()}offWatcherEvents(){Ki(this,Pi,"f").offEvents()}}Ai=new WeakMap,Mi=new WeakMap,zi=new WeakMap,Ri=new WeakMap,Pi=new WeakMap,Ti=new WeakMap,Ei=new WeakMap,Wi=new WeakMap,Ci=new WeakMap,ki=new WeakMap,Li=new WeakMap,Ii=new WeakSet,Oi=function(){Ki(this,Pi,"f").on("pointStart",Ki(this,Ii,"m",ji).bind(this)),Ki(this,Pi,"f").on("pointEnd",Ki(this,Ii,"m",Yi).bind(this)),Ki(this,Pi,"f").on("pointMove",Ki(this,Ii,"m",Di).bind(this)),Ki(this,Pi,"f").on("hover",Ki(this,Ii,"m",Vi).bind(this)),Ki(this,Pi,"f").on("wheel",Ki(this,Ii,"m",Xi).bind(this)),Ki(this,Pi,"f").on("wheelScale",Ki(this,Ii,"m",Ni).bind(this)),Ki(this,Pi,"f").on("scrollX",Ki(this,Ii,"m",Bi).bind(this)),Ki(this,Pi,"f").on("scrollY",Ki(this,Ii,"m",Fi).bind(this)),Ki(this,Pi,"f").on("resize",Ki(this,Ii,"m",Hi).bind(this)),Ki(this,Pi,"f").on("doubleClick",Ki(this,Ii,"m",Gi).bind(this)),Ki(this,Ti,"f").on("load",(()=>{Ki(this,ki,"f").trigger("loadResource")}))},ji=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointStart)||void 0===t?void 0:t.call(o,e)))return}},Yi=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointEnd)||void 0===t?void 0:t.call(o,e)))return}},Di=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointMove)||void 0===t?void 0:t.call(o,e)))return}},Vi=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.hover)||void 0===t?void 0:t.call(o,e)))return}},Gi=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.doubleClick)||void 0===t?void 0:t.call(o,e)))return}},Xi=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheel)||void 0===t?void 0:t.call(o,e)))return}},Ni=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheelScale)||void 0===t?void 0:t.call(o,e)))return}},Bi=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollX)||void 0===t?void 0:t.call(o,e)))return}},Fi=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollY)||void 0===t?void 0:t.call(o,e)))return}},Hi=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.resize)||void 0===t?void 0:t.call(o,e)))return}},Zi=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.clear)||void 0===t?void 0:t.call(o,e)))return}},Qi=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.beforeDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},Ui=function(e){var t;for(let i=0;i<Ki(this,Ri,"f").length;i++){const o=Ki(this,Ri,"f")[i];if(!1===(null===(t=null==o?void 0:o.afterDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},Ji=function(){const e=[],t=Ki(this,Mi,"f");Ki(this,zi,"f").forEach((i=>{const o=t.get(i);"enable"===(null==o?void 0:o.status)&&(null==o?void 0:o.middlewareObject)&&e.push(o.middlewareObject)})),$i(this,Ri,e,"f")};const _i="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcA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CAL7KUThHovFPtGTNjU1jQFSX18/lg68cuXKLUAaGxs3vkB7e/u3wHHgCQpUdnpTqdQvesJgMDisUVevXh3Xry9fvnxTv66qqprQ/cfHx/vVNj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==";class eo{constructor(e,d){I(this,r),I(this,s),I(this,c),I(this,f),I(this,g),I(this,t,void 0),I(this,i,void 0),I(this,o,null),I(this,n,null),I(this,a,{auto:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmc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LwFWcbPsct6r04+bRLHEYCoWyAD1kBDfHleHmsxrccccS3NFHNV/eenBy6iZwCycMOnHz5wBuDh2nyyY6H0zhFmoF7vtxk+l9q3ieQfrDo8msF7cy3cN56g7ZWnKcep7IxnrQmz+wHKu2K3EKJWbPpWSUTQ4ZtRJc23sC6ZGB9ZM52JwcboIQjzUvZvNxYfeHlyVkZFcBbux6wKA6ShjoM5yM8uH0Xpuy8ekAQuZc2W8P8nEei9p9mMmPgAfJHO0O27e0lHppw9MEDJo//A4eoE91iB48SJ80lFMB/t/+V/sPGZfTmtMFR4EAAAAASUVORK5CYII="}),A(this,i,e),A(this,t,d.eventHub),M(this,r,l).call(this),M(this,s,h).call(this)}}t=new WeakMap,i=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,l=function(){const e=b(this,t);M(this,c,d).call(this,"default"),e.on("cursor",(e=>{var t;"over-element"!==e.type&&e.type?"resize-rotate"===e.type?M(this,c,d).call(this,"rotate"):"string"==typeof e.type&&(null==(t=e.type)?void 0:t.startsWith("resize-"))?M(this,f,u).call(this,e):"drag-default"===e.type?M(this,c,d).call(this,"drag-default"):"drag-active"===e.type?M(this,c,d).call(this,"drag-active"):M(this,c,d).call(this,"auto"):M(this,c,d).call(this,"auto")}))},s=new WeakSet,h=function(){j(_i).then((e=>{A(this,n,e)})).catch((e=>{console.error(e)}))},c=new WeakSet,d=function(e){if(b(this,o)===e)return;A(this,o,e);const t=b(this,a)[b(this,o)]||b(this,a).auto;let n=0,r=0;(e.startsWith("rotate-")&&b(this,a)[b(this,o)]||"rotate"===e)&&(n=10,r=10),b(this,i).style.cursor="default"===e?"default":`image-set(url(${t})2x) ${n} ${r}, auto`},f=new WeakSet,u=function(e){var t;let i=0;"resize-top"===e.type?i+=0:"resize-top-right"===e.type?i+=45:"resize-right"===e.type?i+=90:"resize-bottom-right"===e.type?i+=135:"resize-bottom"===e.type?i+=180:"resize-bottom-left"===e.type?i+=225:"resize-left"===e.type?i+=270:"resize-top-left"===e.type&&(i+=315),i+=Se((null==(t=null==e?void 0:e.element)?void 0:t.angle)||0),Array.isArray(e.groupQueue)&&e.groupQueue.length>0&&e.groupQueue.forEach((e=>{i+=Se(e.angle||0)})),i=Se(i);const o=M(this,g,v).call(this,i);M(this,c,d).call(this,o)},g=new WeakSet,v=function(e){const t=`rotate-${e}`;if(!b(this,a)[t]){const i=b(this,n);if(i){const o=document.createElement("canvas"),n=i.width,r=i.height,l={x:n/2,y:r/2};o.width=n,o.height=r;const s=o.getContext("2d"),h=ce(e);s.translate(l.x,l.y),s.rotate(h),s.translate(-l.x,-l.y),s.drawImage(i,0,0,n,r),s.translate(l.x,l.y),s.rotate(-h),s.translate(-l.x,-l.y);const c=o.toDataURL("image/png");b(this,a)[t]=c}}return t};const to="change",io="SELECT",oo=Symbol(`${io}_actionType`),no=Symbol(`${io}_resizeType`),ao=Symbol(`${io}_areaStart`),ro=Symbol(`${io}_areaEnd`),lo=Symbol(`${io}_hoverElement`),so=Symbol(`${io}_hoverElementVertexes`),ho=Symbol(`${io}_selectedElementList`),co=Symbol(`${io}_selectedElementListVertexes`),fo=Symbol(`${io}_selectedElementController`),uo=Symbol(`${io}_selectedElementPosition`),go=Symbol(`${io}_groupQueue`),vo=Symbol(`${io}_groupQueueVertexesList`),wo=Symbol(`${io}_isMoving`),mo=Symbol(`${io}_enableSelectInGroup`),yo=Symbol(`${io}_enableSnapToGrid`),po="#1973ba",xo="#5b5959b5",So="@middleware/select",bo="@middleware/select-clear",Io="@middleware/select-in-group",Ao="@middleware/snap-to-grid";function Mo(e,t,i){const{borderColor:o,borderWidth:n,background:a,lineDash:r}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.fillStyle=a,e.setLineDash(r),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.lineTo(t[0].x,t[0].y),e.closePath(),e.stroke(),e.fill()}function zo(e,t,i,o){const{borderColor:n,borderWidth:a,lineDash:r}=o;e.setLineDash([]),e.lineWidth=a,e.strokeStyle=n,e.setLineDash(r),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke()}function Ro(e,t,i){const{borderColor:o,borderWidth:n,lineDash:a}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.setLineDash(a),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[2].x,t[2].y),e.closePath(),e.stroke(),e.beginPath(),e.moveTo(t[1].x,t[1].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function Po(e,t,i){const{size:o,borderColor:n,borderWidth:a,lineDash:r}=i,l=t.x-o/2,s=t.x+o/2,h=t.y-o/2,c=t.y+o/2;Ro(e,[{x:l,y:h},{x:s,y:h},{x:s,y:c},{x:l,y:c}],{borderColor:n,borderWidth:a,lineDash:r})}function To(e,t,i){if(!t)return;const o={borderColor:po,borderWidth:1,background:"transparent",lineDash:[]};Mo(e,ke(t,i),o)}function Eo(e,t,i){if(!t)return;const o={borderColor:xo,borderWidth:1,background:"transparent",lineDash:[]};Mo(e,ke(t,i),o);const{controller:n}=i;if(n){const{topLeft:t,topRight:a,bottomLeft:r,bottomRight:l,topMiddle:s,bottomMiddle:h,leftMiddle:c,rightMiddle:d}=n,f={...o,borderWidth:1,background:xo};Ro(e,ke(s.vertexes,i),f),Ro(e,ke(h.vertexes,i),f),Ro(e,ke(c.vertexes,i),f),Ro(e,ke(d.vertexes,i),f),Ro(e,ke(t.vertexes,i),f),Ro(e,ke(a.vertexes,i),f),Ro(e,ke(r.vertexes,i),f),Ro(e,ke(l.vertexes,i),f)}}function Wo(e,t,i){if(!t)return;const{hideControllers:o}=i,{elementWrapper:n,topLeft:a,topRight:r,bottomLeft:l,bottomRight:s,top:h,rotate:c}=t,d={borderColor:po,borderWidth:2,background:"transparent",lineDash:[]},f={...d,borderWidth:4,background:"#FFFFFF"};Mo(e,ke(n,i),d),o||(zo(e,Ce(h.center,i),Ce(c.center,i),{...f,borderWidth:2}),Mo(e,ke(a.vertexes,i),f),Mo(e,ke(r.vertexes,i),f),Mo(e,ke(l.vertexes,i),f),Mo(e,ke(s.vertexes,i),f),function(e,t,i){const{size:o,borderColor:n,borderWidth:a,background:r}=i,l=t,s=o/2,h=s,c=s;if(h>=0&&c>=0){if("number"==typeof a&&a>0){const t=a/2+h,i=a/2+c;e.beginPath(),e.strokeStyle=n,e.lineWidth=a,e.circle(l.x,l.y,t,i,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath(),e.fillStyle=r,e.circle(l.x,l.y,h,c,0,0,2*Math.PI),e.closePath(),e.fill()}}(e,Ce(c.center,i),{...f,size:10,borderWidth:2}))}function Co(e,t){const{xLines:i,yLines:o}=t,n={borderColor:"#f7276e",borderWidth:1,lineDash:[]},a={...n,size:6};i&&i.forEach((t=>{t.forEach(((i,o)=>{Po(e,i,a),t[o+1]&&zo(e,t[o],t[o+1],n)}))})),o&&o.forEach((t=>{t.forEach(((i,o)=>{Po(e,i,a),t[o+1]&&zo(e,t[o],t[o+1],n)}))}))}function ko(e){return e*Math.PI/180}function Lo(e,t){return Math.sqrt(e*e+t*t)}function Oo(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function jo(e,t){const{ctx:i,viewScaleInfo:o,vertexes:n}=t,a=Ce(n[0],{viewScaleInfo:o}),r=Ce(n[1],{viewScaleInfo:o}),l=Ce(n[2],{viewScaleInfo:o}),s=Ce(n[3],{viewScaleInfo:o});return i.beginPath(),i.moveTo(a.x,a.y),i.lineTo(r.x,r.y),i.lineTo(l.x,l.y),i.lineTo(s.x,s.y),i.lineTo(a.x,a.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function Yo(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=Te(a),l=r[r.length-1];return!!l&&jo(e,{ctx:i,vertexes:l,viewScaleInfo:o,viewSizeInfo:n})}function Do(e,t){var i,o,n;const a={type:null,elements:[],elementVertexesList:[],groupQueue:[],groupQueueVertexesList:[]},{ctx:r,data:l,calculator:s,selectedElements:h,viewScaleInfo:c,viewSizeInfo:d,areaSize:f,groupQueue:u,selectedElementController:g}=t;if(g){const{left:t,right:i,top:o,bottom:n,topLeft:l,topRight:s,bottomLeft:f,bottomRight:v,rotate:w}=g,m=[t,i,o,n,l,s,f,v,w];for(let t=0;t<m.length;t++){const i=m[t];if(jo(e,{ctx:r,vertexes:i.vertexes,viewSizeInfo:d,viewScaleInfo:c})){a.type=`resize-${i.type}`,h&&(null==h?void 0:h.length)>0&&(a.groupQueue=u||[],a.elements=[h[0]]);break}}}if(u&&Array.isArray(u)&&u.length>0){const t=u[u.length-1];if((null==(i=null==t?void 0:t.detail)?void 0:i.children)&&Array.isArray(null==(o=null==t?void 0:t.detail)?void 0:o.children))for(let i=t.detail.children.length-1;i>=0;i--){const o=t.detail.children[i],n=Ee(o,{groupQueue:u});if(n&&jo(e,{ctx:r,vertexes:n,viewScaleInfo:c,viewSizeInfo:d}))return a.type||(a.type="over-element"),a.groupQueue=u,a.elements=[o],a}return a}if(null!==a.type)return a;if(f&&Array.isArray(h)&&(null==h?void 0:h.length)>1){const{x:t,y:i,w:o,h:n}=f;if(e.x>=t&&e.x<=t+o&&e.y>=i&&e.y<=i+n)return a.type="list-area",a.elements=h,a}if(l){const{index:t,element:i}=s.getPointElement(e,{data:l,viewScaleInfo:c,viewSizeInfo:d});if(t>=0&&i&&!0!==(null==(n=null==i?void 0:i.operations)?void 0:n.invisible))return a.elements=[i],a.type="over-element",a}return a}function Vo(e,t){const{x:i,y:o,w:n,h:a,angle:r=0}=e,{center:l,start:s,end:h,viewScaleInfo:c}=t,d=Ce(l,{viewScaleInfo:c}),f=Se(r),u=function(e,t,i){const o=ve(e,t),n=ve(e,i);return null!==n&&null!==o?o>3*Math.PI/2&&n<Math.PI/2?n+(2*Math.PI-o):n>3*Math.PI/2&&o<Math.PI/2?o+(2*Math.PI-n):n-o:0}(d,s,h);return{x:i,y:o,w:n,h:a,angle:f+u/Math.PI*180}}function Go(e,t){var i;if(!Array.isArray(e))return null;const o={x:0,y:0,w:0,h:0},{viewScaleInfo:n,viewSizeInfo:a}=t;let r=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 s=We(l,{viewScaleInfo:n,viewSizeInfo:a});if(s.angle&&(s.angle>0||s.angle<0)){const e=pe(s);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];s.x=Math.min(...t),s.y=Math.min(...i),s.w=Math.abs(Math.max(...t)-Math.min(...t)),s.h=Math.abs(Math.max(...i)-Math.min(...i))}}if(r){const e=Math.min(s.x,o.x),t=Math.min(s.y,o.y),i=Math.max(s.x+s.w,o.x+o.w),n=Math.max(s.y+s.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=s.x,o.y=s.y,o.w=s.w,o.h=s.h;r=s}return o}function Xo(e){return{minX:e.topLeft.x,minY:e.topLeft.y,maxX:e.bottomRight.x,maxY:e.bottomRight.y,midX:e.center.x,midY:e.center.y}}const No=(e,t)=>{if(0===e.length)throw null;if(1===e.length)return e[0];let i=0,o=e.length-1;for(;i<=o;){const n=Math.floor((i+o)/2);if(e[n]===t)return e[n];e[n]<t?i=n+1:o=n-1}return i>=e.length?e[o]:o<0?e[i]:Math.abs(e[o]-t)<=Math.abs(e[i]-t)?e[o]:e[i]},Bo=(e,t)=>Math.abs(e-t)<1e-5;function Fo(e,t){var i,o;const{data:n,groupQueue:a,calculator:r,viewScaleInfo:l,viewSizeInfo:s}=t;let h=n.elements||[];(null==a?void 0:a.length)>0&&(h=(null==(o=null==(i=a[a.length-1])?void 0:i.detail)?void 0:o.children)||[]);const c=[];h.forEach((t=>{if(t.uuid!==e){const e=r.calcViewRectInfoFromRange(t.uuid,{checkVisible:!0,viewScaleInfo:l,viewSizeInfo:s});e&&c.push(e)}}));const d=r.calcViewRectInfoFromRange(e,{viewScaleInfo:l,viewSizeInfo:s});if(!d)return null;const f={},u={},g={},v={},w=[],m=[];let y=[],p=[];const x=Xo(d);f[x.minX]=[x.minY,x.midY,x.maxY],f[x.midX]=[x.minY,x.midY,x.maxY],f[x.maxX]=[x.minY,x.midY,x.maxY],u[x.minY]=[x.minX,x.midX,x.maxX],u[x.midY]=[x.minX,x.midX,x.maxX],u[x.maxY]=[x.minX,x.midX,x.maxX],c.forEach((e=>{const t=Xo(e);g[t.minX]||(g[t.minX]=[]),g[t.midX]||(g[t.midX]=[]),g[t.maxX]||(g[t.maxX]=[]),v[t.minY]||(v[t.minY]=[]),v[t.midY]||(v[t.midY]=[]),v[t.maxY]||(v[t.maxY]=[]),g[t.minX]=[t.minY,t.midY,t.maxY],g[t.midX]=[t.minY,t.midY,t.maxY],g[t.maxX]=[t.minY,t.midY,t.maxY],y.push(t.minX),y.push(t.midX),y.push(t.maxX),v[t.minY]=[t.minX,t.midX,t.maxX],v[t.midY]=[t.minX,t.midX,t.maxX],v[t.maxY]=[t.minX,t.midX,t.maxX],p.push(t.minY),p.push(t.midY),p.push(t.maxY)})),y=y.sort(((e,t)=>e-t)),p=p.sort(((e,t)=>e-t));let S=null,b=null,I=null,A=null,M=null,z=null,R=null,P=null;if(y.length>0){I=No(y,x.minX),A=No(y,x.midX),M=No(y,x.maxX);const e=Math.abs(I-x.minX),t=Math.abs(A-x.midX),i=Math.abs(M-x.maxX),o=Math.min(e,t,i);o<=2/l.scale&&(Bo(o,e)?S=I-x.minX:Bo(o,t)?S=A-x.midX:Bo(o,i)&&(S=M-x.maxX))}if(p.length>0){z=No(p,x.minY),R=No(p,x.midY),P=No(p,x.maxY);const e=Math.abs(z-x.minY),t=Math.abs(R-x.midY),i=Math.abs(P-x.maxY),o=Math.min(e,t,i);o<=2/l.scale&&(Bo(o,e)?b=z-x.minY:Bo(o,t)?b=R-x.midY:Bo(o,i)&&(b=P-x.maxY))}const T={...x};if(null!==S&&(T.minX+=S,T.midX+=S,T.maxX+=S),null!==b&&(T.minY+=b,T.midY+=b,T.maxY+=b),B.x(S)&&null!==S&&null!==I&&null!==A&&null!==M){if(Bo(S,I-x.minX)){const e={x:I,yList:[]};e.yList.push(T.minY),e.yList.push(T.maxY),e.yList.push(...(null==v?void 0:v[I])||[]),w.push(e)}if(Bo(S,A-x.minX)){const e={x:A,yList:[]};e.yList.push(T.minY),e.yList.push(T.maxY),e.yList.push(...(null==v?void 0:v[A])||[]),w.push(e)}if(Bo(S,M-x.minX)){const e={x:M,yList:[]};e.yList.push(T.minY),e.yList.push(T.maxY),e.yList.push(...(null==v?void 0:v[M])||[]),w.push(e)}}if(B.y(b)&&null!==b&&null!==z&&null!==R&&null!==P){if(Bo(b,z-x.minY)){const e={y:z,xList:[]};e.xList.push(T.minX),e.xList.push(T.maxX),e.xList.push(...(null==g?void 0:g[z])||[]),m.push(e)}if(Bo(b,R-x.midY)){const e={y:R,xList:[]};e.xList.push(T.minX),e.xList.push(T.maxX),e.xList.push(...(null==g?void 0:g[z])||[]),m.push(e)}if(Bo(b,P-x.maxY)){const e={y:P,xList:[]};e.xList.push(T.minX),e.xList.push(T.maxX),e.xList.push(...(null==g?void 0:g[P])||[]),m.push(e)}}const E=[];(null==w?void 0:w.length)>0&&w.forEach(((e,t)=>{E.push([]),e.yList.forEach((i=>{E[t].push({x:e.x,y:i})}))}));const W=[];return(null==m?void 0:m.length)>0&&m.forEach(((e,t)=>{W.push([]),e.xList.forEach((i=>{W[t].push({x:i,y:e.y})}))})),{offsetX:S,offsetY:b,yLines:E,xLines:W}}const Ho="@middleware/text-edit",Zo="@middleware/text-change",Qo={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"},Uo="LAYOUT_SELECT",Jo=Symbol(`${Uo}_layoutActionType`),$o=Symbol(`${Uo}_layoutControlType`),Ko=Symbol(`${Uo}_layoutController`),qo=Symbol(`${Uo}_layoutIsHover`),_o=Symbol(`${Uo}_layoutIsSelected`),en="#b331c9",tn="#5b5959b5";function on(e,t){e.setLineDash([]),e.fillStyle="#FFFFFF",e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.fill(),e.strokeStyle=en,e.lineWidth=2,e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function nn(e,t){const{vertexes:i,strokeStyle:o,lineWidth:n}=t;e.setLineDash([]),e.strokeStyle=o,e.lineWidth=n,e.beginPath(),e.moveTo(i[0].x,i[0].y),e.lineTo(i[2].x,i[2].y),e.closePath(),e.stroke(),e.beginPath(),e.moveTo(i[1].x,i[1].y),e.lineTo(i[3].x,i[3].y),e.closePath(),e.stroke()}function an(e,t){const{start:i,end:o,centerVertexes:n,disabled:a}=t,r=!0===a?1:2,l=!0===a?tn:en;e.setLineDash([]),e.strokeStyle=l,e.lineWidth=r,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,o.y),e.closePath(),e.stroke(),!0===a&&nn(e,{vertexes:n,lineWidth:r,strokeStyle:l})}const rn="SCROLL",ln=Symbol(`${rn}_xThumbRect`),sn=Symbol(`${rn}_yThumbRect`),hn=Symbol(`${rn}_hoverXThumbRect`),cn=Symbol(`${rn}_hoverYThumbRect`),dn=Symbol(`${rn}_prevPoint`),fn=Symbol(`${rn}_activePoint`),un=Symbol(`${rn}_activeThumbType`),gn=16,vn=.3,wn={width:12,thumbColor:"#0000008A",thumbHoverColor:"#000000EE",scrollBarColor:"#FFFFFF60",showScrollBar:!1};function mn(e,t,i){const o=e,{x:n,y:a,w:r,h:l}=i;return o.beginPath(),o.rect(n,a,r,l),o.closePath(),!!o.isPointInPath(t.x,t.y)}function yn(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:l}=t;"X"===l?(o=o+n/4+0,n/=2):"Y"===l&&(i=i+a/4+0,a/=2);let s=t.r;s=Math.min(s,a/2,n/2),(a<2*s||n<2*s)&&(s=0),e.globalAlpha=vn,e.beginPath(),e.moveTo(i+s,o),e.arcTo(i+a,o,i+a,o+n,s),e.arcTo(i+a,o+n,i,o+n,s),e.arcTo(i,o+n,i,o,s),e.arcTo(i,o,i+a,o,s),e.closePath(),e.fillStyle=r,e.fill(),e.globalAlpha=1,e.beginPath(),e.lineWidth=1,e.strokeStyle=r,e.setLineDash([]),e.moveTo(i+s,o),e.arcTo(i+a,o,i+a,o+n,s),e.arcTo(i+a,o+n,i,o+n,s),e.arcTo(i,o+n,i,o,s),e.arcTo(i,o,i+a,o,s),e.closePath(),e.stroke()}e.restore()}function pn(e,t){const i=e,{viewScaleInfo:o,viewSizeInfo:n,scrollInfo:a}=t,{activeThumbType:r,prevPoint:l,activePoint:s,hoverXThumb:h,hoverYThumb:c}=a,d=function(e){const{viewScaleInfo:t,viewSizeInfo:i,hoverXThumb:o,hoverYThumb:n}=e,{width:a,height:r}=i,{offsetTop:l,offsetBottom:s,offsetLeft:h,offsetRight:c}=t,d=2.5*gn,f=gn;let u=0,g=0;u=Math.max(d,a-2*f-(Math.abs(h)+Math.abs(c))),u>=a&&(u=a),g=Math.max(d,r-2*f-(Math.abs(l)+Math.abs(s))),g>=r&&(g=r);const v=f;let w=v;h>0?w=v:c>0?w=a-u-f:h<=0&&u>0&&(0!==h||0!==c)&&(w=v+(a-u)*Math.abs(h)/(Math.abs(h)+Math.abs(c)),w=Math.min(Math.max(0,w-v),a-u));const m=f;let y=m;l>0?y=m:s>0?y=r-g-f:l<=0&&g>0&&(0!==l||0!==s)&&(y=m+(r-g)*Math.abs(l)/(Math.abs(l)+Math.abs(s)),y=Math.min(Math.max(0,y-m),r-g));const p={x:w,y:r-f,w:u,h:f},x={x:a-f,y:y,w:f,h:g};return{lineSize:f,xSize:u,ySize:g,translateY:y,translateX:w,xThumbColor:o?wn.thumbHoverColor:wn.thumbColor,yThumbColor:n?wn.thumbHoverColor:wn.thumbColor,scrollBarColor:wn.scrollBarColor,xThumbRect:p,yThumbRect:x}}({viewScaleInfo:o,viewSizeInfo:n,hoverXThumb:h,hoverYThumb:c});let f={...d.xThumbRect},u={...d.yThumbRect};return r&&l&&s&&("X"===r&&a.xThumbRect?(f={...a.xThumbRect},f.x=f.x+(s.x-l.x)):"Y"===r&&a.yThumbRect&&(u={...a.yThumbRect},u.y=u.y+(s.y-l.y))),yn(i,{axis:"X",...f,r:d.lineSize/2,color:d.xThumbColor}),yn(i,{axis:"Y",...u,r:d.lineSize/2,color:d.yThumbColor}),i.globalAlpha=1,{xThumbRect:f,yThumbRect:u}}function xn(e,t){const{snapshot:i}=t,o=he(i),n=se(i),a=function(e){const{sharedStore:t}=e;return{activePoint:t[fn]||null,prevPoint:t[dn]||null,activeThumbType:t[un]||null,xThumbRect:t[ln]||null,yThumbRect:t[sn]||null,hoverXThumb:t[hn],hoverYThumb:t[cn]}}(i),{xThumbRect:r,yThumbRect:l}=pn(e,{viewSizeInfo:o,viewScaleInfo:n,scrollInfo:a});return{xThumbRect:r,yThumbRect:l}}const Sn="@middleware/scale",bn=16,In="#000000",An="#00000080",Mn="monospace",zn="#AAAAAA20",Rn="#AAAAAA40",Pn="#196097",Tn=[1,2,5,10,20,50,100,200,500];function En(e){const{scale:t,viewLength:i,viewOffset:o}=e,n=[];let a=10;a=Be(a/t,{decimalPlaces:0}),a=function(e){e=Math.max(Tn[0],Math.min(e,Tn[Tn.length-1]));for(let t=0;t<Tn.length-1;t++){const i=Tn[t],o=Tn[t+1];if(!(e>o))return e===i||e===o?e:e<=(i+o)/2?i:o}return e}(a);const r=10*a,l=5*a;let s=0;const h=a*t,c=0-o,d=c%h,f=(c-d+h)/t,u=h-d+0;for(;u+s*h<i;){const e=Be(f+s*a,{decimalPlaces:0}),t={num:e,position:Be(u+s*h,{decimalPlaces:0}),showNum:e%r==0,isKeyNum:e%r==0,isSubKeyNum:e%l==0};n.push(t),s++}return{list:n,rulerUnit:a}}const Wn="@middleware/show-ruler",Cn=Symbol("DRAG_prevPoint"),kn="monospace";const Ln="#1973bac6",On="#ffffff",jn=10;return w=new WeakMap,m=new WeakMap,y=new WeakMap,p=new WeakSet,x=function(){b(this,y).style.position="relative"},e.Core=class{constructor(e,t){I(this,p),I(this,w,void 0),I(this,m,void 0),I(this,y,void 0);const{devicePixelRatio:i=1,width:o,height:n,createCustomContext2D:a}=t;A(this,y,e);const r=document.createElement("canvas");A(this,m,r),M(this,p,x).call(this),e.appendChild(r);const l=function(e,t){const{width:i,height:o,devicePixelRatio:n,offscreen:a,createCustomContext2D:r}=t,l={width:i,height:o,devicePixelRatio:n},s=e.getContext("2d");if(r){const e=r(l),t=r(l),i=r(l),o=J(Object.assign({ctx:s},l)),n=()=>{const{width:n,height:a}=e.$getSize();o.clearRect(0,0,n,a),o.drawImage(i.canvas,0,0,n,a),o.drawImage(e.canvas,0,0,n,a),o.drawImage(t.canvas,0,0,n,a),i.clearRect(0,0,n,a),e.clearRect(0,0,n,a),t.clearRect(0,0,n,a)};return{underlayContext:i,viewContext:e,overlayContext:t,boardContext:o,drawView:n}}if(!0===a){const e=$(l),t=$(l),i=$(l),o=J(Object.assign({ctx:s},l)),n=()=>{const{width:n,height:a}=e.$getSize();o.clearRect(0,0,n,a),o.drawImage(i.canvas,0,0,n,a),o.drawImage(e.canvas,0,0,n,a),o.drawImage(t.canvas,0,0,n,a),i.clearRect(0,0,n,a),e.clearRect(0,0,n,a),t.clearRect(0,0,n,a)};return{underlayContext:i,viewContext:e,overlayContext:t,boardContext:o,drawView:n}}{const e=J(l),t=J(l),n=J(l),a=J(Object.assign({ctx:s},l)),r=()=>{a.clearRect(0,0,i,o),a.drawImage(n.canvas,0,0,i,o),a.drawImage(e.canvas,0,0,i,o),a.drawImage(t.canvas,0,0,i,o),n.clearRect(0,0,i,o),e.clearRect(0,0,i,o),t.clearRect(0,0,i,o)};return{underlayContext:n,viewContext:e,overlayContext:t,boardContext:a,drawView:r}}}(r,{width:o,height:n,devicePixelRatio:i,offscreen:!0,createCustomContext2D:a}),s=new qi({boardContent:l,container:e}),h=s.getSharer();h.setActiveViewSizeInfo({width:o,height:n,devicePixelRatio:i,contextWidth:o,contextHeight:n}),A(this,w,s),this.resize(h.getActiveViewSizeInfo());const c=s.getEventHub();new eo(e,{eventHub:c})}isDestroyed(){return b(this,w).isDestroyed()}destroy(){b(this,w).destroy(),b(this,m).remove()}use(e){b(this,w).use(e)}disuse(e){b(this,w).disuse(e)}setData(e,t){be((null==e?void 0:e.elements)||[]),b(this,w).setData(e,t)}getData(){return b(this,w).getData()}scale(e){b(this,w).scale(e);b(this,w).getViewer().drawFrame()}resize(e){const t=b(this,w),i=t.getSharer().getActiveViewSizeInfo();t.resize({...i,...e})}clear(){b(this,w).clear()}on(e,t){b(this,w).getEventHub().on(e,t)}off(e,t){b(this,w).getEventHub().off(e,t)}trigger(e,t){b(this,w).getEventHub().trigger(e,t)}getViewInfo(){const e=b(this,w).getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){b(this,w).getViewer().drawFrame()}setViewScale(e){b(this,w).updateViewScaleInfo(e)}getLoadItemMap(){return b(this,w).getRenderer().getLoadItemMap()}onBoardWatcherEvents(){b(this,w).onWatcherEvents()}offBoardWatcherEvents(){b(this,w).offWatcherEvents()}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:o}=e;let n=!1;return{name:"@middleware/dragger",hover(){!0!==n&&t.trigger("cursor",{type:"drag-default"})},pointStart(e){const{point:o}=e;i.setSharedStorage(Cn,o),n=!0,t.trigger("cursor",{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(Cn);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(Cn,t)},pointEnd(){n=!1,i.setSharedStorage(Cn,null),t.trigger("cursor",{type:"drag-default"})}}},e.MiddlewareInfo=e=>{const{boardContent:t,calculator:i}=e,{overlayContext:o}=t;return{name:"@middleware/info",beforeDrawFrame({snapshot:e}){const{sharedStore:t}=e,n=t[ho],a=t[oo],r=t[go]||[];if(1===n.length){const t=n[0];if(t&&["select","drag","resize"].includes(a)){const n=se(e),a=he(e),{x:l,y:s,w:h,h:c,angle:d}=t,f=[...r,{uuid:P(),x:l,y:s,w:h,h:c,angle:d,type:"group",detail:{children:[]}}],u={viewScaleInfo:n,viewSizeInfo:a},g=i.calcViewRectInfoFromOrigin(t.uuid,u);let v=0;f.forEach((e=>{v+=e.angle||0}));const w=ce(Se(0-v));if(g){const e=null==g?void 0:g.center,i={topLeft:we(e,g.topLeft,w),topRight:we(e,g.topRight,w),bottomRight:we(e,g.bottomRight,w),bottomLeft:we(e,g.bottomLeft,w),center:we(e,g.center,w),top:we(e,g.top,w),right:we(e,g.right,w),bottom:we(e,g.bottom,w),left:we(e,g.left,w)},n=Be(t.x,{decimalPlaces:2}),a=Be(t.y,{decimalPlaces:2}),r=Be(t.w,{decimalPlaces:2}),l=Be(t.h,{decimalPlaces:2}),s=`${Be(n,{decimalPlaces:0})},${Be(a,{decimalPlaces:0})}`,h=`${Be(r,{decimalPlaces:0})}x${Be(l,{decimalPlaces:0})}`,c=`${Be(t.angle||0,{decimalPlaces:0})}°`;!function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,color:r,background:l,fontSize:s,lineHeight:h}=t;de(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:kn});const t=(h-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x-o/2-t,y:i.y},c={x:n.x+o+2*t,y:n.y+s+t},d={x:i.x-o/2,y:i.y};e.setLineDash([]),e.fillStyle=l,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(c.x,n.y),e.lineTo(c.x,c.y),e.lineTo(n.x,c.y),e.closePath(),e.fill(),e.fillStyle=r,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(o,{point:{x:i.bottom.x,y:i.bottom.y+jn},rotateCenter:i.center,angle:v,text:h,fontSize:jn,lineHeight:16,color:On,background:Ln}),function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,color:r,background:l,fontSize:s,lineHeight:h}=t;de(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:kn});const t=(h-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x,y:i.y},c={x:n.x+o+2*t,y:n.y+s+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=l,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(c.x,n.y),e.lineTo(c.x,c.y),e.lineTo(n.x,c.y),e.closePath(),e.fill(),e.fillStyle=r,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(o,{point:{x:i.topLeft.x,y:i.topLeft.y-20},rotateCenter:i.center,angle:v,text:s,fontSize:jn,lineHeight:16,color:On,background:Ln}),function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,color:r,background:l,fontSize:s,lineHeight:h}=t;de(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:kn});const t=(h-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x,y:i.y},c={x:n.x+o+2*t,y:n.y+s+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=l,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(c.x,n.y),e.lineTo(c.x,c.y),e.lineTo(n.x,c.y),e.closePath(),e.fill(),e.fillStyle=r,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(o,{point:{x:i.top.x+jn,y:i.top.y-20},rotateCenter:i.center,angle:v,text:c,fontSize:jn,lineHeight:16,color:On,background:Ln})}}}}}},e.MiddlewareLayoutSelector=e=>{const{sharer:t,boardContent:i,calculator:o,viewer:n,eventHub:a}=e,{overlayContext:r}=i;let l=null,s=null,h=null,c=null;const d=()=>{l=null,t.setSharedStorage(Jo,null),t.setSharedStorage($o,null),t.setSharedStorage(Ko,null),t.setSharedStorage(qo,null),t.setSharedStorage(_o,null),s=null,h=null,c=null},f=()=>{const e=t.getSharedStorage(oo);return!(!e||"area"===e)&&(d(),!0)},u=()=>{const e=t.getActiveStorage("data");if(null==e?void 0:e.layout){const{x:t,y:i,w:o,h:n}=e.layout;return{x:t,y:i,w:o,h:n}}return null},g=e=>{const i=u();if(i){const{x:o,y:n,w:a,h:r}=i;return function(e,t,i){return Oe(e,Pe(t))}(e,We({x:o-5,y:n-5,w:a+10,h:r+10},{viewScaleInfo:t.getActiveViewScaleInfo()}))}return!1},v=()=>{const e=t.getActiveViewScaleInfo(),i=u();if(i){const o=Xe(i,{viewScaleInfo:e,controllerSize:10});t.setSharedStorage(Ko,o)}else t.setSharedStorage(Ko,null)},w=e=>{const i=t.getActiveStorage("data"),o=t.getSharedStorage(Ko);if(o&&(null==i?void 0:i.layout)&&(null==e?void 0:e.point)){let i=null;if(o){const{topLeft:n,top:r,topRight:l,right:s,bottomRight:h,bottom:c,bottomLeft:d,left:f}=o,u=[n,r,l,s,h,c,d,f];for(let t=0;t<u.length;t++){const o=u[t];if(Oe(e.point,o.vertexes)){i=`${o.type}`;break}}if(i)return t.setSharedStorage($o,i),a.trigger(bo,{}),i}}return null},m=e=>{!0!==c&&a.trigger("cursor",{type:e?`resize-${e}`:e,groupQueue:[],element:u()})};return{name:"@middleware/layout-selector",use:()=>{d(),v()},hover:e=>{if(!0!==c&&!f()&&(!t.getSharedStorage(lo)||(d(),0)))if(g(e.point)?t.setSharedStorage(qo,!0):(t.setSharedStorage(qo,!1),!0===s&&(n.drawFrame(),s=!1)),!0!==t.getSharedStorage(_o))t.getSharedStorage(qo)&&!s&&n.drawFrame(),s=t.getSharedStorage(qo);else{const i=t.getSharedStorage(Jo),o=t.getActiveStorage("data");if(null==o?void 0:o.layout)if("resize"!==i){v();const i=w(e);i?m(i):(m(),t.setSharedStorage(Jo,null))}else{const t=w(e);m(t)}}},pointStart:e=>{if(f())return;g(e.point)?t.setSharedStorage(_o,!0):(!0===h&&(d(),n.drawFrame()),t.setSharedStorage(_o,!1)),v();const i=w(e);l=e.point,i&&t.setSharedStorage(Jo,"resize"),!0!==t.getSharedStorage(_o)||h||n.drawFrame(),h=t.getSharedStorage(_o)},pointMove:e=>{if(!t.getSharedStorage(_o)&&f())return;const i=t.getSharedStorage(Jo),a=t.getSharedStorage($o),r=t.getActiveStorage("data");if("resize"===i&&a&&(null==r?void 0:r.layout)){if(l){c=!0;const i=t.getActiveStorage("scale"),s=e.point.x-l.x,h=e.point.y-l.y,d=s/i,f=h/i,{x:u,y:g,w:v,h:w,operations:m={}}=r.layout,{position:y="absolute"}=m;"top"===a?"relative"===y?(r.layout.h=o.toGridNum(w-f),n.scroll({moveY:h})):(r.layout.y=o.toGridNum(g+f),r.layout.h=o.toGridNum(w-f)):"right"===a?r.layout.w=o.toGridNum(v+d):"bottom"===a?r.layout.h=o.toGridNum(w+f):"left"===a?"relative"===y?(r.layout.w=o.toGridNum(v-d),n.scroll({moveX:s})):(r.layout.x=o.toGridNum(u+d),r.layout.w=o.toGridNum(v-d)):"top-left"===a?"relative"===y?(r.layout.w=o.toGridNum(v-d),r.layout.h=o.toGridNum(w-f),n.scroll({moveX:s,moveY:h})):(r.layout.x=o.toGridNum(u+d),r.layout.y=o.toGridNum(g+f),r.layout.w=o.toGridNum(v-d),r.layout.h=o.toGridNum(w-f)):"top-right"===a?"relative"===y?(n.scroll({moveY:h}),r.layout.w=o.toGridNum(v+d),r.layout.h=o.toGridNum(w-f)):(r.layout.y=o.toGridNum(g+f),r.layout.w=o.toGridNum(v+d),r.layout.h=o.toGridNum(w-f)):"bottom-right"===a?(r.layout.w=o.toGridNum(v+d),r.layout.h=o.toGridNum(w+f)):"bottom-left"===a&&("relative"===y?(n.scroll({moveX:s}),r.layout.w=o.toGridNum(v-d),r.layout.h=o.toGridNum(w+f)):(r.layout.x=o.toGridNum(u+d),r.layout.w=o.toGridNum(v-d),r.layout.h=o.toGridNum(w+f)))}return l=e.point,v(),n.drawFrame(),!1}return!["resize"].includes(i)&&void 0},pointEnd:()=>{c=!1;const e=t.getSharedStorage(Jo),i=t.getSharedStorage($o),o=t.getActiveStorage("data");o&&"resize"===e&&i&&a.trigger(to,{type:"changeLayout",data:o})},beforeDrawFrame:({snapshot:e})=>{var t;if(f())return;const{sharedStore:i,activeStore:o}=e,n=i[Jo],a=i[qo],l=i[_o];if(null==(t=o.data)?void 0:t.layout){const{x:t,y:i,w:s,h:h}=o.data.layout,c=se(e),d={x:t,y:i,w:s,h:h},f=Xe(d,{viewScaleInfo:c,controllerSize:10});if(!0===a){const e=We(d,{viewScaleInfo:c});!function(e,t){const{layoutSize:i}=t,{x:o,y:n,w:a,h:r}=i;e.setLineDash([]),e.strokeStyle=en,e.lineWidth=1,e.beginPath(),e.moveTo(o,n),e.lineTo(o+a,n),e.lineTo(o+a,n+r),e.lineTo(o,n+r),e.lineTo(o,n),e.closePath(),e.stroke()}(r,{layoutSize:e})}(n&&["resize"].includes(n)||!0===l)&&function(e,t){const{controller:i,operations:o}=t,{topLeft:n,topRight:a,bottomLeft:r,bottomRight:l,topMiddle:s,rightMiddle:h,bottomMiddle:c,leftMiddle:d}=i;an(e,{start:n.center,end:a.center,centerVertexes:s.vertexes,disabled:!!(null==o?void 0:o.disabledTop)}),an(e,{start:a.center,end:l.center,centerVertexes:h.vertexes,disabled:!!(null==o?void 0:o.disabledRight)}),an(e,{start:l.center,end:r.center,centerVertexes:c.vertexes,disabled:!!(null==o?void 0:o.disabledBottom)}),an(e,{start:r.center,end:n.center,centerVertexes:d.vertexes,disabled:!!(null==o?void 0:o.disabledLeft)});const f={lineWidth:1,strokeStyle:tn};!0===(null==o?void 0:o.disabledTopLeft)?nn(e,{vertexes:n.vertexes,...f}):on(e,n.vertexes),!0===(null==o?void 0:o.disabledTopRight)?nn(e,{vertexes:a.vertexes,...f}):on(e,a.vertexes),!0===(null==o?void 0:o.disabledBottomRight)?nn(e,{vertexes:l.vertexes,...f}):on(e,l.vertexes),!0===(null==o?void 0:o.disabledBottomLeft)?nn(e,{vertexes:r.vertexes,...f}):on(e,r.vertexes)}(r,{controller:f,operations:o.data.layout.operations||{}})}},scrollX:()=>{d()},scrollY:()=>{d()},wheelScale:()=>{d()}}},e.MiddlewareRuler=e=>{const{boardContent:t,viewer:i,eventHub:o,calculator:n}=e,{overlayContext:a,underlayContext:r}=t;let l=!0,s=!0;const h=e=>{"boolean"==typeof(null==e?void 0:e.show)&&(l=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{name:"@middleware/ruler",use(){o.on(Wn,h)},disuse(){o.off(Wn,h)},beforeDrawFrame:({snapshot:e})=>{if(!0===l){const t=se(e),i=he(e);!function(e,t){const{snapshot:i,calculator:o}=t,{sharedStore:n}=i,a=n[ho],r=n[oo];if(["select","drag","drag-list","drag-list-end"].includes(r)&&a.length>0){const t=se(i),n=he(i),r=[],l=[],s=[],h=[],c=[];if(a.forEach((e=>{const i=o.calcViewRectInfoFromRange(e.uuid,{viewScaleInfo:t,viewSizeInfo:n});i&&(r.push(i),l.push(i.left.x),s.push(i.right.x),h.push(i.top.y),c.push(i.bottom.y))})),!(r.length>0))return;const d=Math.min(...l),f=Math.max(...s),u=Math.min(...h),g=Math.max(...c);e.globalAlpha=1,e.beginPath(),e.moveTo(d,0),e.lineTo(f,0),e.lineTo(f,bn),e.lineTo(d,bn),e.fillStyle=Pn,e.closePath(),e.fill(),e.beginPath(),e.moveTo(0,u),e.lineTo(bn,u),e.lineTo(bn,g),e.lineTo(0,g),e.fillStyle=Pn,e.closePath(),e.fill()}}(a,{snapshot:e,calculator:n}),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,bn),e.lineTo(bn,bn),e.lineTo(bn,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()}(a,{viewScaleInfo:t,viewSizeInfo:i});const{list:o,rulerUnit:l}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:n}=t,{width:a}=i;return En({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<bn||(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=In,e.stroke(),o.isKeyNum&&(e.fillStyle=An,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Mn}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(a,{scaleList:o});const{list:h}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n}=t,{height:a}=i;return En({axis:"Y",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});if(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<bn)&&(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=In,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===n.showNum)){const t=o,i=n.position+o,a=`${n.num}`;de(e,-90,{x:t,y:i},(()=>{e.fillStyle=An,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Mn}),e.fillText(a,13.2,n.position+o)}))}}}(a,{scaleList:h}),!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=Rn:e.strokeStyle=zn,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=Rn:e.strokeStyle=zn,e.lineWidth=1,e.closePath(),e.stroke()}}(1===l?a:r,{xList:o,yList:h,viewScaleInfo:t,viewSizeInfo:i})}}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:o}=e;return{name:"@middleware/scaler",wheelScale(e){const{deltaY:n,point:a}=e,{scale:r}=i.getActiveViewScaleInfo();let l=r;if(n<0?l=1.1*r:n>0&&(l=.9*r),l<.05||l>50)return;const{moveX:s,moveY:h}=t.scale({scale:l,point:a});t.scroll({moveX:s,moveY:h}),t.drawFrame();const c=Be(r);o.trigger(Sn,{scale:c})}}},e.MiddlewareScroller=e=>{const{viewer:t,boardContent:i,sharer:o,eventHub:n}=e,{overlayContext:a}=i;o.setSharedStorage(ln,null),o.setSharedStorage(sn,null);let r=!1;const l=()=>{o.setSharedStorage(dn,null),o.setSharedStorage(fn,null),o.setSharedStorage(un,null),o.setSharedStorage(hn,null),o.setSharedStorage(cn,null),r=!1};l();const s=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:a}=i;return n&&mn(e,t,n)?o="X":a&&mn(e,t,a)&&(o="Y"),o}(a,e,{xThumbRect:o.getSharedStorage(ln),yThumbRect:o.getSharedStorage(sn)});return{name:"@middleware/scroller",wheel:e=>{t.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),t.drawFrame()},hover:e=>{if(!0===r)return!1;const{point:t}=e,i=s(t);if("X"===i||"Y"===i)return"X"===i?(o.setSharedStorage(hn,!0),o.setSharedStorage(cn,!1)):(o.setSharedStorage(hn,!1),o.setSharedStorage(cn,!0)),n.trigger("cursor",{type:"default"}),!1;o.setSharedStorage(hn,!1),o.setSharedStorage(cn,!1)},pointStart:e=>{const{point:t}=e,i=s(t);if("X"===i||"Y"===i)return r=!0,o.setSharedStorage(un,i),o.setSharedStorage(dn,t),!1},pointMove:e=>{const{point:i}=e,n=o.getSharedStorage(un);if("X"===n||"Y"===n)return o.setSharedStorage(fn,i),"X"===n?(e=>{const i=o.getSharedStorage(dn);if(i){const{offsetLeft:n,offsetRight:a}=o.getActiveViewScaleInfo(),{width:r}=o.getActiveViewSizeInfo(),l=-(e.x-i.x)*(r+Math.abs(n)+Math.abs(a))/r;t.scroll({moveX:l}),t.drawFrame()}})(i):"Y"===n&&(e=>{const i=o.getSharedStorage(dn);if(i){const{offsetTop:n,offsetBottom:a}=o.getActiveViewScaleInfo(),{height:r}=o.getActiveViewSizeInfo(),l=-(e.y-i.y)*(r+Math.abs(n)+Math.abs(a))/r;t.scroll({moveY:l}),t.drawFrame()}})(i),o.setSharedStorage(dn,i),!1},pointEnd:()=>{r=!1;const e=o.getSharedStorage(un);if(l(),"X"===e||"Y"===e)return t.scroll({moveX:0,moveY:0}),t.drawFrame(),!1},beforeDrawFrame({snapshot:e}){const{xThumbRect:t,yThumbRect:i}=xn(a,{snapshot:e});o.setSharedStorage(ln,t),o.setSharedStorage(sn,i)}}},e.MiddlewareSelector=e=>{const{viewer:t,sharer:i,boardContent:o,calculator:n,eventHub:a}=e,{overlayContext:r}=o;let l=null,s=null;i.setSharedStorage(oo,null),i.setSharedStorage(yo,!0);const h=()=>i.getSharedStorage(ho),c=e=>{let t=i.getSharedStorage(go);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=Te(t);return i.setSharedStorage(go,t),i.setSharedStorage(vo,o),t.length>0},d=e=>{i.setSharedStorage(lo,e);let t=null;e&&(t=Ee(e,{groupQueue:i.getSharedStorage(go)})),i.setSharedStorage(so,t)},f=(e,t)=>{var o;if(i.setSharedStorage(ho,e),1===e.length){const t=Ge(e[0],{groupQueue:i.getSharedStorage(go),controllerSize:10,viewScaleInfo:i.getActiveViewScaleInfo()});i.setSharedStorage(fo,t),i.setSharedStorage(uo,ze(e[0].uuid,(null==(o=i.getActiveStorage("data"))?void 0:o.elements)||[]))}else i.setSharedStorage(fo,null),i.setSharedStorage(uo,[]);!0===(null==t?void 0:t.triggerEvent)&&a.trigger(So,{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(go),areaSize:null,selectedElementController:i.getSharedStorage(fo),selectedElementPosition:i.getSharedStorage(uo)}),g=()=>{i.setSharedStorage(oo,null),i.setSharedStorage(no,null),i.setSharedStorage(ao,null),i.setSharedStorage(ro,null),i.setSharedStorage(go,[]),i.setSharedStorage(vo,[]),i.setSharedStorage(lo,null),i.setSharedStorage(so,null),i.setSharedStorage(ho,[]),i.setSharedStorage(co,null),i.setSharedStorage(fo,null),i.setSharedStorage(uo,[]),i.setSharedStorage(wo,null),i.setSharedStorage(mo,null)};g();const v=({uuids:e,positions:o})=>{let n=[];const a=i.getSharedStorage(oo),r=i.getActiveStorage("data");n=o&&Array.isArray(o)?function(e,t){const i=[];return e.forEach((e=>{const o=Me(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 l=!1;if(a||1!==n.length?"select"===a&&1===n.length&&(l=!0):(i.setSharedStorage(oo,"select"),l=!0),l){const e=function(e,t){const i=[];return function e(t,o){var n;let a=null;for(let r=0;r<o.length;r++){const l=o[r];if(l.uuid===t){a=l;break}if(!a&&"group"===l.type){i.push(l);const o=e(t,(null===(n=null==l?void 0:l.detail)||void 0===n?void 0:n.children)||[]);if((null==o?void 0:o.uuid)===t){a=o;break}i.pop()}}return a}(e,t),i}(n[0].uuid,(null==r?void 0:r.elements)||[]);i.setSharedStorage(go,e),f(n),t.drawFrame()}},w=()=>{g(),t.drawFrame()},m=e=>{i.setSharedStorage(yo,!!e.enable)},y=e=>{i.setSharedStorage(mo,!!e.enable)};return{name:"@middleware/selector",use(){a.on(So,v),a.on(bo,w),a.on(Io,y),a.on(Ao,m)},disuse(){a.off(So,v),a.off(bo,w),a.off(Io,y),a.off(Ao,m)},hover:e=>{var o,l,c,f,g;const v=i.getSharedStorage(_o),w=i.getSharedStorage(no),m=i.getSharedStorage(oo),y=i.getSharedStorage(go),p=e=>{if(!0===v)return;const t=e.type;null===s&&a.trigger("cursor",{type:t,groupQueue:e.groupQueue,element:e.elements[0]})};if((null==y?void 0:y.length)>0){if(!Yo(e.point,{ctx:r,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:i.getSharedStorage(go)}))return d(null),void t.drawFrame();const n=Do(e.point,u());return p(n),w||["area","drag","drag-list"].includes(m)?(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(w||["area","drag","drag-list"].includes(m))return void d(null);if("drag"===m)return void d(null);const x=h(),S=i.getActiveViewScaleInfo(),b=i.getActiveViewSizeInfo(),I=Do(e.point,{...u(),areaSize:Go(x,{viewScaleInfo:S,viewSizeInfo:b,calculator:n})});if(p(I),null!==I.type){if(!("over-element"===I.type&&"select"===i.getSharedStorage(oo)&&1===I.elements.length&&I.elements[0].uuid===(null==(c=null==(l=h())?void 0:l[0])?void 0:c.uuid)||"over-element"===I.type&&null===i.getSharedStorage(oo)&&1===I.elements.length&&I.elements[0].uuid===(null==(f=i.getSharedStorage(lo))?void 0:f.uuid)))return"over-element"===I.type&&1===(null==(g=null==I?void 0:I.elements)?void 0:g.length)?(d(I.elements[0]),void t.drawFrame()):i.getSharedStorage(lo)?(d(null),void t.drawFrame()):void 0}else(i.getSharedStorage(lo)||i.getSharedStorage(so))&&(i.setSharedStorage(lo,null),i.setSharedStorage(so,null),t.drawFrame())},pointStart:e=>{var o,a,s,c,v,w,m,y,p,x;l=e.point;const S=i.getSharedStorage(go);if((null==S?void 0:S.length)>0){if(Yo(e.point,{ctx:r,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:S})){const t=Do(e.point,u());if(1===(null==(o=null==t?void 0:t.elements)?void 0:o.length)&&!0===(null==(s=null==(a=t.elements[0])?void 0:a.operations)?void 0:s.lock))return;d(null),"over-element"===t.type&&1===(null==(c=null==t?void 0:t.elements)?void 0:c.length)?(f([t.elements[0]],{triggerEvent:!0}),i.setSharedStorage(oo,"drag")):(null==(v=t.type)?void 0:v.startsWith("resize-"))?(i.setSharedStorage(no,t.type),i.setSharedStorage(oo,"resize")):f([],{triggerEvent:!0})}else g();return void t.drawFrame()}const b=Go(h(),{viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),calculator:n}),I=Do(e.point,{...u(),areaSize:b,groupQueue:[]});1===(null==(w=null==I?void 0:I.elements)?void 0:w.length)&&!0===(null==(y=null==(m=I.elements[0])?void 0:m.operations)?void 0:y.lock)||(d(null),"list-area"===I.type?i.setSharedStorage(oo,"drag-list"):"over-element"===I.type&&1===(null==(p=null==I?void 0:I.elements)?void 0:p.length)?(f([I.elements[0]],{triggerEvent:!0}),i.setSharedStorage(oo,"drag")):(null==(x=I.type)?void 0:x.startsWith("resize-"))?(i.setSharedStorage(no,I.type),i.setSharedStorage(oo,"resize")):(g(),i.setSharedStorage(oo,"area"),i.setSharedStorage(ao,e.point),f([],{triggerEvent:!0})),t.drawFrame())},pointMove:e=>{var o,a,r;i.setSharedStorage(wo,!0);const c=i.getActiveStorage("data"),d=h(),u=i.getActiveStorage("scale")||1,g=i.getActiveViewScaleInfo(),v=i.getActiveViewSizeInfo(),w=l,m=e.point,y=i.getSharedStorage(no),p=i.getSharedStorage(oo),x=i.getSharedStorage(go),S=i.getSharedStorage(yo);if("drag"===p){if(s="drag",c&&1===(null==d?void 0:d.length)&&w&&m&&!0!==(null==(a=null==(o=d[0])?void 0:o.operations)?void 0:a.lock)){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=me(e,a),r=me(t,a);o=r.x-i.x,n=r.y-i.y}return{moveX:o,moveY:n}}(w,m,x);let o=n.toGridNum(e/u),a=n.toGridNum(t/u);if(!0===S){const e=Fo(d[0].uuid,{calculator:n,data:c,groupQueue:x,viewScaleInfo:g,viewSizeInfo:v});try{e&&(B.x(e.offsetX)&&null!==e.offsetX&&(o=n.toGridNum(o+e.offsetX)),B.y(e.offsetY)&&null!==e.offsetY&&(a=n.toGridNum(a+e.offsetY)))}catch(e){console.error(e)}}d[0].x=n.toGridNum(d[0].x+o),d[0].y=n.toGridNum(d[0].y+a),f([d[0]]),n.modifyViewVisibleInfoMap(c,{modifyOptions:{type:"updateElement",content:{element:d[0],position:i.getSharedStorage(uo)||[]}},viewSizeInfo:v,viewScaleInfo:g})}t.drawFrame()}else if("drag-list"===p){if(s="drag-list",c&&w&&m&&(null==d?void 0:d.length)>1){const e=(m.x-w.x)/u,t=(m.y-w.y)/u;d.forEach((i=>{var o;i&&!0!==(null==(o=null==i?void 0:i.operations)?void 0:o.lock)&&(i.x=n.toGridNum(i.x+e),i.y=n.toGridNum(i.y+t),n.modifyViewVisibleInfoMap(c,{modifyOptions:{type:"updateElement",content:{element:i,position:ze(i.uuid,c.elements)||[]}},viewSizeInfo:v,viewScaleInfo:g}))})),i.setActiveStorage("data",c)}t.drawFrame()}else if("resize"===p){if(c&&1===(null==d?void 0:d.length)&&w&&(null==y?void 0:y.startsWith("resize-"))){s="resize";const e=[];x.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 o=w,a=m;if(x.length>0&&(o=me(w,e),a=me(m,e)),"resize-rotate"===y){const e=i.getSharedStorage(fo),t=ge([e.topLeft.center,e.topRight.center,e.bottomLeft.center,e.bottomRight.center]),o=Vo(d[0],{center:t,viewScaleInfo:g,viewSizeInfo:v,start:w,end:m,resizeType:y,sharer:i});d[0].angle=n.toGridNum(o.angle||0)}else{const e=function(e,t){var i,o,n,a,r,l,s,h,c;let{x:d,y:f,w:u,h:g,angle:v=0}=e;const w=ue({x:d,y:f,w:u,h:g,angle:v});v=Se(v);const m=ce(v),y=!!(null==(i=null==e?void 0:e.operations)?void 0:i.limitRatio),{start:p,end:x,resizeType:S,scale:b}=t;let I={...p},A={...x},M={x:I.x,y:w.y},z={x:A.x,y:w.y},R={...M},P={...z},T={x:w.x,y:I.y},E={x:w.x,y:A.y},W={...T},C={...E},k=(P.x-R.x)/b,L=(P.y-R.y)/b,O=Lo(k,L),j=(C.x-W.x)/b,Y=(C.y-W.y)/b,D=Lo(j,Y);(v>0||v<0)&&(I=we(w,p,0-m),A=we(w,x,0-m),M={x:I.x,y:w.y},z={x:A.x,y:w.y},R=we(w,M,m),P=we(w,z,m),T={x:w.x,y:I.y},E={x:w.x,y:A.y},W=we(w,T,m),C=we(w,E,m),k=(P.x-R.x)/b,L=(P.y-R.y)/b,O=Lo(k,L),O=Oo(O,L),j=(C.x-W.x)/b,Y=(C.y-W.y)/b,D=Lo(j,Y),D=Oo(D,Y));let V=(x.x-p.x)/b,G=(x.y-p.y)/b;if(!0===y)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(S)){const t=Math.max(Math.abs(V),Math.abs(G));V=(V>=0?1:-1)*t,G=(G>=0?1:-1)*t/e.w*e.h;const i=Math.max(Math.abs(j),Math.abs(Y));j=(j>=0?1:-1)*i,Y=(Y>=0?1:-1)*i/e.w*e.h;const o=Math.max(Math.abs(k),Math.abs(L));k=(k>=0?1:-1)*o,L=(L>=0?1:-1)*o/e.w*e.h}else if(["resize-top-left","resize-top-right","resize-bottom-left","resize-bottom-right"].includes(S)){{const t=Math.abs(V);V=(V>=0?1:-1)*t;const i=t/e.w*e.h;"resize-top-left"===S||"resize-bottom-right"===S?G=V>0?i:-i:"resize-top-right"!==S&&"resize-bottom-left"!==S||(G=V>0?-i:i)}O=Math.abs(O),D=O/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){D=0-Oo(D,Y);const e=ko(v),o=D/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){D=Oo(D,j);const e=ko(v-90),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){D=Oo(D,Y);const e=ko(v-180),o=D/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){D=0-Oo(D,j);const e=ko(v-270),o=D/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}g+D>0&&(!0===(null==(n=e.operations)?void 0:n.limitRatio)&&(u+=D/e.h*e.w),g+=D,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){D=Oo(D,Y);const e=ko(v),o=D/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){D=0-Oo(D,j);const e=ko(v-90),o=D/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){D=Oo(D,j);const e=ko(v-180),o=D/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){D=Oo(D,j);const e=ko(v-270),o=D/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}g+D>0&&(!0===(null==(r=e.operations)?void 0:r.limitRatio)&&(u+=D/e.h*e.w),g+=D,d=t-u/2,f=i-g/2)}break;case"resize-left":if(0===v)e.w-V>0&&(d+=V,u-=V,!0===(null==(l=e.operations)?void 0:l.limitRatio)&&(g-=V/e.w*e.h,f+=V/e.w*e.h/2));else if(v>0||v<0){let t=w.x,i=w.y;if(v<90){O=0-Oo(O,k);const e=ko(v),o=O/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){O=Oo(O,k);const e=ko(v-90),o=O/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){O=Oo(O,L);const e=ko(v-180),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){O=Oo(O,L);const e=ko(v-270),o=O/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}u+O>0&&(!0===(null==(s=e.operations)?void 0:s.limitRatio)&&(g+=O/e.w*e.h),u+=O,d=t-u/2,f=i-g/2)}break;case"resize-right":if(0===v)e.w+V>0&&(u+=V,!0===(null==(h=e.operations)?void 0:h.limitRatio)&&(f-=V*e.h/e.w/2,g+=V*e.h/e.w));else if(v>0||v<0){let t=w.x,i=w.y;if(v<90){O=Oo(O,L);const e=ko(v),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){O=Oo(O,G);const e=ko(v-90),o=O/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){O=Oo(O,G);const e=ko(v-180),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e),O=0-O}else if(v<360){O=Oo(O,V);const e=ko(v-270),o=O/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}u+O>0&&(!0===(null==(c=e.operations)?void 0:c.limitRatio)&&(g+=O/e.w*e.h),u+=O,d=t-u/2,f=i-g/2)}break;case"resize-top-left":if(0===v)u-V>0&&(d+=V,u-=V),g-G>0&&(f+=G,g-=G);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){D=0-Oo(D,Y),O=0-Oo(O,y?0-D:k);const i=D/2;e+=i*Math.sin(m),t-=i*Math.cos(m);const o=O/2;e-=o*Math.cos(m),t-=o*Math.sin(m)}else if(v<180){D=Oo(D,j),O=Oo(O,y?D:k);const i=ko(v-90),o=D/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){D=Oo(D,Y),O=Oo(O,y?D:L);const i=ko(v-180),o=D/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){D=0-Oo(D,j),O=Oo(O,y?D:L);const i=ko(v-270),o=D/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+D>0&&(g+=D),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-top-right":if(0===v)u+V>0&&(u+=V),g-G>0&&(f+=G,g-=G);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){D=0-Oo(D,Y),O=Oo(O,y?D:L);const i=ko(v),o=D/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){D=Oo(D,j),O=Oo(O,y?D:L);const i=ko(v-90),o=D/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){const i=ko(v-180);D=Oo(D,Y),O=Oo(O,y?D:0-k);const o=D/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){D=0-Oo(D,j),O=Oo(O,y?D:k);const i=ko(v-270),o=D/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+D>0&&(g+=D),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-bottom-left":if(0===v)e.h+G>0&&(g+=G),e.w-V>0&&(d+=V,u-=V);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){D=Oo(D,Y),O=0-Oo(O,y?0-D:k);const i=ko(v),o=D/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<180){D=0-Oo(D,j),O=Oo(O,y?D:k);const i=ko(v-90),o=D/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){D=Oo(D,j),O=Oo(O,y?D:L);const i=ko(v-180),o=D/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){D=Oo(D,j),O=Oo(O,y?D:L);const i=ko(v-270),o=D/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+D>0&&(g+=D),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-bottom-right":if(0===v)e.h+G>0&&(g+=G),e.w+V>0&&(u+=V);else if(v>0||v<0){let e=w.x,t=w.y;if(v<90){D=Oo(D,Y),O=Oo(O,y?D:L);const i=ko(v),o=D/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){D=0-Oo(D,j),O=Oo(O,y?D:G);const i=ko(v-90),o=D/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){D=Oo(D,j),O=Oo(O,y?D:0-L);const i=ko(v-180),o=D/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){D=Oo(D,j),O=Oo(O,y?D:k);const i=ko(v-270),o=D/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+D>0&&(g+=D),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}}return{x:d,y:f,w:u,h:g,angle:e.angle}}(d[0],{scale:u,start:o,end:a,resizeType:y,sharer:i}),t={ignore:!!d[0].angle};d[0].x=n.toGridNum(e.x,t),d[0].y=n.toGridNum(e.y,t),"group"===d[0].type&&!0===(null==(r=d[0].operations)?void 0:r.deepResize)?function(e,t){const i=t.w&&t.w>0?t.w:e.w,o=t.h&&t.h>0?t.h:e.h,n=i/e.w,a=o/e.h;if(n===a&&1===n)return e;const r=Math.min(n,a),l=Math.max(n,a);e.w=i,e.h=o;const s={xRatio:n,yRatio:a,minRatio:r,maxRatio:l};"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Ue(e,s)})),Qe(e,s)}(d[0],{w:n.toGridNum(e.w,t),h:n.toGridNum(e.h,t)}):(d[0].w=n.toGridNum(e.w,t),d[0].h=n.toGridNum(e.h,t))}f([d[0]]),n.modifyViewVisibleInfoMap(c,{modifyOptions:{type:"updateElement",content:{element:d[0],position:i.getSharedStorage(uo)||[]}},viewSizeInfo:v,viewScaleInfo:g}),t.drawFrame()}}else"area"===p&&(s="area",i.setSharedStorage(ro,e.point),t.drawFrame());l=e.point},pointEnd(e){s=null,i.setSharedStorage(wo,!1);const o=i.getActiveStorage("data"),r=i.getSharedStorage(ho),h=i.getSharedStorage(lo),c=i.getSharedStorage(no),d=i.getSharedStorage(oo),u=i.getActiveViewSizeInfo();let v=!1;if(l=null,"resize"===d&&c)i.setSharedStorage(no,null),v=!0;else if("area"===d){if(i.setSharedStorage(oo,null),o){const e=i.getSharedStorage(ao),t=i.getSharedStorage(ro);if(e&&t){const{elements:a}=function(e,t){var i;const o=[],n=[],a=[],{viewScaleInfo:r,viewSizeInfo:l,start:s,end:h}=t;if(!(Array.isArray(e.elements)&&s&&h))return{indexes:o,uuids:n,elements:a};const c=Math.min(s.x,h.x),d=Math.max(s.x,h.x),f=Math.min(s.y,h.y),u=Math.max(s.y,h.y);for(let t=0;t<e.elements.length;t++){const s=e.elements[t];if(!0===(null==(i=null==s?void 0:s.operations)?void 0:i.lock))continue;const h=We(s,{viewScaleInfo:r,viewSizeInfo:l}),g=ue(h);if(g.x>=c&&g.x<=d&&g.y>=f&&g.y<=u&&(o.push(t),n.push(s.uuid),a.push(s),h.angle&&(h.angle>0||h.angle<0))){const e=pe(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))}}}return{indexes:o,uuids:n,elements:a}}(o,{start:e,end:t,calculator:n,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()});a.length>0&&(i.setSharedStorage(oo,"drag-list"),f(a,{triggerEvent:!0}),v=!0)}}}else if("drag-list"===d)i.setSharedStorage(oo,"drag-list-end"),v=!0;else if(o){n.getPointElement(e.point,{data:o,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}).element?(i.setSharedStorage(oo,"select"),v=!0):i.setSharedStorage(oo,null)}null===i.getSharedStorage(oo)&&(g(),v=!0);(()=>{if(v){if(o&&Array.isArray(null==o?void 0:o.elements)&&["drag","drag-list"].includes(d)){const e=function(e,t,i){const o=Ie(e,{viewWidth:t.width,viewHeight:t.height,extend:null==i?void 0:i.extend});return!0===(null==i?void 0:i.extend)&&(o.contextWidth=Math.max(o.contextWidth,t.contextWidth),o.contextHeight=Math.max(o.contextHeight,t.contextHeight)),{contextSize:o}}(o.elements,u,{extend:!0});i.setActiveStorage("contextHeight",e.contextSize.contextHeight),i.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(o&&["drag","drag-list","drag-list-end","resize"].includes(d)){let e="dragElement";a.trigger(to,{data:o,type:e,selectedElements:r,hoverElement:h})}t.drawFrame()}})()},pointLeave(){l=null,g(),t.drawFrame()},doubleClick(e){var o,n,r,l,s,h,d,f;if(!1===i.getSharedStorage(mo))return;const g=Do(e.point,u());if(i.setSharedStorage(fo,null),i.setSharedStorage(ho,[]),1!==g.elements.length||!0!==(null==(n=null==(o=g.elements[0])?void 0:o.operations)?void 0:n.lock)){if(1===g.elements.length&&"group"===(null==(r=g.elements[0])?void 0:r.type)){if(!0===c(g.elements[0]))return i.setSharedStorage(oo,null),void t.drawFrame()}else 1!==g.elements.length||"text"!==(null==(l=g.elements[0])?void 0:l.type)||(null==(h=null==(s=g.elements[0])?void 0:s.operations)?void 0:h.invisible)||a.trigger(Ho,{element:g.elements[0],groupQueue:i.getSharedStorage(go)||[],position:ze(null==(d=g.elements[0])?void 0:d.uuid,(null==(f=i.getActiveStorage("data"))?void 0:f.elements)||[]),viewScaleInfo:i.getActiveViewScaleInfo()});i.setSharedStorage(oo,null)}},beforeDrawFrame({snapshot:t}){var i;const{activeStore:o,sharedStore:a}=t,{scale:l,offsetLeft:s,offsetTop:c,offsetRight:d,offsetBottom:f,width:u,height:g,contextHeight:v,contextWidth:w,devicePixelRatio:m}=o,y=e.sharer,p={scale:l,offsetLeft:s,offsetTop:c,offsetRight:d,offsetBottom:f},x={width:u,height:g,contextHeight:v,contextWidth:w,devicePixelRatio:m},S=a[ho][0],b=a[lo],I=a[so],A=a[oo],M=a[ao],z=a[ro],R=a[go],P=a[vo],T=a[wo],E=a[yo],W={calculator:n,viewScaleInfo:p,viewSizeInfo:x},C=S?Ge(S,{groupQueue:R,controllerSize:10,viewScaleInfo:p}):null,k=!!(null==(i=null==b?void 0:b.operations)?void 0:i.lock);if((null==R?void 0:R.length)>0){if(function(e,t,i){for(let o=0;o<t.length;o++){const n=t[o],a={borderColor:po,borderWidth:2,background:"transparent",lineDash:[4,4]};Mo(e,ke(n,i),a)}}(r,P,W),b&&"drag"!==A&&(k?Eo(r,I,{...W,controller:Ge(b,{groupQueue:R,controllerSize:10,viewScaleInfo:p})}):To(r,I,W)),!k&&S&&["select","drag","resize"].includes(A)&&(Wo(r,C,{...W,element:S,calculator:n,hideControllers:!!T&&"drag"===A}),"drag"===A&&!0===E)){const e=Fo(S.uuid,{calculator:n,data:o.data,groupQueue:R,viewScaleInfo:p,viewSizeInfo:x});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Co(r,{xLines:o,yLines:n})}}}else if(b&&"drag"!==A&&(k?Eo(r,I,{...W,controller:Ge(b,{groupQueue:R,controllerSize:10,viewScaleInfo:p})}):To(r,I,W)),!k&&S&&["select","drag","resize"].includes(A)){if(Wo(r,C,{...W,element:S,calculator:n,hideControllers:!!T&&"drag"===A}),"drag"===A&&!0===E){const e=Fo(S.uuid,{calculator:n,data:o.data,groupQueue:R,viewScaleInfo:p,viewSizeInfo:x});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Co(r,{xLines:o,yLines:n})}}}else if("area"===A&&M&&z)!function(e,t){const{start:i,end:o}=t;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=po,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:M,end:z});else if(["drag-list","drag-list-end"].includes(A)){const e=Go(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=po,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,sharer:n}=e,a=i.boardContext.canvas,r=document.createElement("div");r.setAttribute("contenteditable","true");const l=document.createElement("div"),s=e.container||document.body,h=document.createElement("div");let c=null,d=[];l.appendChild(r),l.style.position="absolute",h.appendChild(l),h.style.position="fixed",h.style.top="0",h.style.bottom="0",h.style.left="0",h.style.right="0",h.style.display="none",s.appendChild(h);const f=()=>{if(null==c?void 0:c.uuid){const e=n.getActiveOverrideElemenentMap();e&&delete e[c.uuid],n.setActiveOverrideElemenentMap(e),o.drawFrame()}h.style.display="none",c=null,d=[]},u=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:n,y:a,w:r,h:l}=t,s=Se(t.angle||0);return o.style.position="absolute",o.style.left=`${n}px`,o.style.top=`${a}px`,o.style.width=`${r}px`,o.style.height=`${l}px`,o.style.transform=`rotate(${s}deg)`,i.appendChild(o),o},g=e=>{const{viewScaleInfo:t,element:i,groupQueue:o}=e,{scale:n,offsetTop:a,offsetLeft:s}=t;l.children&&Array.from(l.children).forEach((e=>{e.remove()}));let h=l;for(let e=0;e<o.length;e++){const t=o[e],{x:i,y:r,w:l,h:c}=t,d={x:i*n,y:r*n,w:l*n,h:c*n,angle:Se(t.angle||0)};0===e&&(d.x+=s,d.y+=a),h=u({size:d,parent:h})}const c={...Qo,...i.detail};let d=i.x*n+s,f=i.y*n+a,g=i.w*n,v=i.h*n;o.length>0&&(d=i.x*n,f=i.y*n,g=i.w*n,v=i.h*n);let w="center",m="center";"left"===c.textAlign?w="start":"right"===c.textAlign&&(w="end"),"top"===c.verticalAlign?m="start":"bottom"===c.verticalAlign&&(m="end"),r.style.display="inline-flex",r.style.justifyContent=w,r.style.alignItems=m,r.style.position="absolute",r.style.left=d-1+"px",r.style.top=f-1+"px",r.style.width=`${g+2}px`,r.style.height=`${v+2}px`,r.style.transform=`rotate(${Se(i.angle||0)}deg)`,r.style.boxSizing="border-box",r.style.border="1px solid #1973ba",r.style.resize="none",r.style.overflow="hidden",r.style.wordBreak="break-all",r.style.borderRadius=("number"==typeof c.borderRadius?c.borderRadius:0)*n+"px",r.style.background=`${c.background||"transparent"}`,r.style.color=`${c.color||"#333333"}`,r.style.fontSize=c.fontSize*n+"px",r.style.lineHeight=(c.lineHeight||c.fontSize)*n+"px",r.style.fontFamily=$e(c.fontFamily),r.style.fontWeight=`${c.fontWeight}`,r.style.padding="0",r.style.margin="0",r.style.outline="none",r.innerText=c.text||"",h.appendChild(r)},v=()=>{const{left:e,top:t,width:i,height:o}=(()=>{const e=a.getBoundingClientRect(),{left:t,top:i,width:o,height:n}=e;return{left:t,top:i,width:o,height:n}})();l.style.position="absolute",l.style.overflow="hidden",l.style.top=`${t}px`,l.style.left=`${e}px`,l.style.width=`${i}px`,l.style.height=`${o}px`};h.addEventListener("click",(()=>{f()})),r.addEventListener("click",(e=>{e.stopPropagation()})),r.addEventListener("input",(()=>{c&&d&&(c.detail.text=r.innerText||"",t.trigger(Zo,{element:{uuid:c.uuid,detail:{text:c.detail.text}},position:[...d||[]]}),o.drawFrame())})),r.addEventListener("blur",(()=>{c&&d&&t.trigger(Zo,{element:{uuid:c.uuid,detail:{text:c.detail.text}},position:[...d]}),f()})),r.addEventListener("keydown",(e=>{e.stopPropagation()})),r.addEventListener("keypress",(e=>{e.stopPropagation()})),r.addEventListener("keyup",(e=>{e.stopPropagation()})),r.addEventListener("wheel",(e=>{e.stopPropagation(),e.preventDefault()}));const w=e=>{var t;(null==e?void 0:e.position)&&(null==e?void 0:e.element)&&"text"===(null==(t=null==e?void 0:e.element)?void 0:t.type)&&(c=e.element,d=e.position),(e=>{v(),g(e),h.style.display="block",(null==c?void 0:c.uuid)&&(n.setActiveOverrideElemenentMap({[c.uuid]:{operations:{invisible:!0}}}),o.drawFrame())})(e)};return{name:"@middleware/text-editor",use(){t.on(Ho,w)},disuse(){t.off(Ho,w)}}},e.eventChange=to,e.middlewareEventRuler=Wn,e.middlewareEventScale=Sn,e.middlewareEventSelect=So,e.middlewareEventSelectClear=bo,e.middlewareEventSelectInGroup=Io,e.middlewareEventSnapToGrid=Ao,e.middlewareEventTextChange=Zo,e.middlewareEventTextEdit=Ho,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});