@idraw/core 0.4.0-beta.4 → 0.4.0-beta.41

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 (87) hide show
  1. package/dist/esm/board/index.d.ts +44 -0
  2. package/dist/esm/board/index.js +358 -0
  3. package/dist/esm/board/sharer.d.ts +21 -0
  4. package/dist/esm/board/sharer.js +101 -0
  5. package/dist/esm/board/viewer.d.ts +32 -0
  6. package/dist/esm/board/viewer.js +165 -0
  7. package/dist/esm/board/watcher.d.ts +15 -0
  8. package/dist/esm/board/watcher.js +218 -0
  9. package/dist/esm/config.d.ts +28 -0
  10. package/dist/esm/config.js +34 -0
  11. package/dist/esm/index.d.ts +37 -8
  12. package/dist/esm/index.js +265 -10
  13. package/dist/esm/lib/cursor-image.d.ts +1 -0
  14. package/dist/esm/lib/cursor-image.js +1 -0
  15. package/dist/esm/lib/cursor.d.ts +3 -12
  16. package/dist/esm/lib/cursor.js +137 -112
  17. package/dist/esm/middleware/dragger/index.d.ts +2 -2
  18. package/dist/esm/middleware/dragger/index.js +5 -3
  19. package/dist/esm/middleware/info/config.d.ts +5 -0
  20. package/dist/esm/middleware/info/config.js +9 -0
  21. package/dist/esm/middleware/info/draw-info.d.ts +29 -0
  22. package/dist/esm/middleware/info/draw-info.js +113 -0
  23. package/dist/esm/middleware/info/index.d.ts +9 -0
  24. package/dist/esm/middleware/info/index.js +131 -0
  25. package/dist/esm/middleware/info/types.d.ts +3 -0
  26. package/dist/esm/middleware/info/types.js +1 -0
  27. package/dist/esm/middleware/layout-selector/config.d.ts +11 -0
  28. package/dist/esm/middleware/layout-selector/config.js +12 -0
  29. package/dist/esm/middleware/layout-selector/index.d.ts +5 -0
  30. package/dist/esm/middleware/layout-selector/index.js +371 -0
  31. package/dist/esm/middleware/layout-selector/types.d.ts +17 -0
  32. package/dist/esm/middleware/layout-selector/types.js +2 -0
  33. package/dist/esm/middleware/layout-selector/util.d.ts +9 -0
  34. package/dist/esm/middleware/layout-selector/util.js +78 -0
  35. package/dist/esm/middleware/pointer/index.d.ts +3 -0
  36. package/dist/esm/middleware/pointer/index.js +42 -0
  37. package/dist/esm/middleware/pointer/types.d.ts +3 -0
  38. package/dist/esm/middleware/pointer/types.js +1 -0
  39. package/dist/esm/middleware/ruler/config.d.ts +7 -0
  40. package/dist/esm/middleware/ruler/config.js +21 -0
  41. package/dist/esm/middleware/ruler/index.d.ts +3 -3
  42. package/dist/esm/middleware/ruler/index.js +33 -14
  43. package/dist/esm/middleware/ruler/types.d.ts +3 -0
  44. package/dist/esm/middleware/ruler/types.js +1 -0
  45. package/dist/esm/middleware/ruler/util.d.ts +20 -4
  46. package/dist/esm/middleware/ruler/util.js +99 -26
  47. package/dist/esm/middleware/scaler/index.d.ts +2 -3
  48. package/dist/esm/middleware/scaler/index.js +3 -2
  49. package/dist/esm/middleware/scroller/config.d.ts +4 -0
  50. package/dist/esm/middleware/scroller/config.js +10 -0
  51. package/dist/esm/middleware/scroller/index.d.ts +3 -2
  52. package/dist/esm/middleware/scroller/index.js +48 -6
  53. package/dist/esm/middleware/scroller/types.d.ts +11 -0
  54. package/dist/esm/middleware/scroller/types.js +1 -0
  55. package/dist/esm/middleware/scroller/util.d.ts +3 -2
  56. package/dist/esm/middleware/scroller/util.js +33 -44
  57. package/dist/esm/middleware/selector/config.d.ts +9 -1
  58. package/dist/esm/middleware/selector/config.js +17 -1
  59. package/dist/esm/middleware/selector/draw-auxiliary.d.ts +1 -0
  60. package/dist/esm/middleware/selector/draw-auxiliary.js +12 -0
  61. package/dist/esm/middleware/selector/draw-base.d.ts +30 -0
  62. package/dist/esm/middleware/selector/draw-base.js +100 -0
  63. package/dist/esm/middleware/selector/draw-debug.d.ts +5 -0
  64. package/dist/esm/middleware/selector/draw-debug.js +30 -0
  65. package/dist/esm/middleware/selector/draw-reference.d.ts +7 -0
  66. package/dist/esm/middleware/selector/draw-reference.js +31 -0
  67. package/dist/esm/middleware/selector/draw-wrapper.d.ts +16 -1
  68. package/dist/esm/middleware/selector/draw-wrapper.js +70 -38
  69. package/dist/esm/middleware/selector/index.d.ts +11 -4
  70. package/dist/esm/middleware/selector/index.js +450 -70
  71. package/dist/esm/middleware/selector/pattern/icon-rotate.d.ts +4 -0
  72. package/dist/esm/middleware/selector/pattern/icon-rotate.js +88 -0
  73. package/dist/esm/middleware/selector/pattern/index.d.ts +8 -0
  74. package/dist/esm/middleware/selector/pattern/index.js +38 -0
  75. package/dist/esm/middleware/selector/reference.d.ts +13 -0
  76. package/dist/esm/middleware/selector/reference.js +267 -0
  77. package/dist/esm/middleware/selector/types.d.ts +11 -5
  78. package/dist/esm/middleware/selector/types.js +2 -1
  79. package/dist/esm/middleware/selector/util.d.ts +14 -7
  80. package/dist/esm/middleware/selector/util.js +45 -43
  81. package/dist/esm/middleware/text-editor/index.d.ts +20 -3
  82. package/dist/esm/middleware/text-editor/index.js +168 -28
  83. package/dist/esm/record.d.ts +5 -0
  84. package/dist/esm/record.js +38 -0
  85. package/dist/index.global.js +5729 -1519
  86. package/dist/index.global.min.js +1 -1
  87. package/package.json +5 -6
@@ -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 y=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:x}=window;function S(e){return new Promise(((t,i)=>{const o=new x;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function p(e){return y(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 S(t)}))}function b(e,t){return y(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 S(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,C=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},E=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class W{constructor(e,t){R.set(this,void 0),T.set(this,void 0),C(this,R,e,"f"),C(this,T,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f")}$undoPixelRatio(e){return e/E(this,T,"f").devicePixelRatio}$doPixelRatio(e){return E(this,T,"f").devicePixelRatio*e}$getContext(){return E(this,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"}`),E(this,R,"f").font=`${t.join(" ")}`}$getOffscreenCanvas(){return E(this,T,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:a}=E(this,R,"f");a.width=t*o,a.height=i*o,C(this,T,Object.assign(Object.assign({},E(this,T,"f")),{devicePixelRatio:o}),"f"),!0===n&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=E(this,T,"f"),{width:t,height:i}=E(this,R,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return E(this,R,"f").canvas}get fillStyle(){return E(this,R,"f").fillStyle}set fillStyle(e){E(this,R,"f").fillStyle=e}get strokeStyle(){return E(this,R,"f").strokeStyle}set strokeStyle(e){E(this,R,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(E(this,R,"f").lineWidth)}set lineWidth(e){E(this,R,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return E(this,R,"f").textAlign}set textAlign(e){E(this,R,"f").textAlign=e}get textBaseline(){return E(this,R,"f").textBaseline}set textBaseline(e){E(this,R,"f").textBaseline=e}get globalAlpha(){return E(this,R,"f").globalAlpha}set globalAlpha(e){E(this,R,"f").globalAlpha=e}get shadowColor(){return E(this,R,"f").shadowColor}set shadowColor(e){E(this,R,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(E(this,R,"f").shadowOffsetX)}set shadowOffsetX(e){E(this,R,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(E(this,R,"f").shadowOffsetY)}set shadowOffsetY(e){E(this,R,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(E(this,R,"f").shadowBlur)}set shadowBlur(e){E(this,R,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return E(this,R,"f").lineCap}set lineCap(e){E(this,R,"f").lineCap=e}get globalCompositeOperation(){return E(this,R,"f").globalCompositeOperation}set globalCompositeOperation(e){E(this,R,"f").globalCompositeOperation=e}fill(...e){return E(this,R,"f").fill(...e)}arc(e,t,i,o,n,a){return E(this,R,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,a)}rect(e,t,i,o){return E(this,R,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return E(this,R,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return E(this,R,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return E(this,R,"f").beginPath()}closePath(){return E(this,R,"f").closePath()}lineTo(e,t){return E(this,R,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return E(this,R,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return E(this,R,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}getLineDash(){return E(this,R,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return E(this,R,"f").setLineDash(t)}stroke(e){return e?E(this,R,"f").stroke(e):E(this,R,"f").stroke()}translate(e,t){return E(this,R,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return E(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?E(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)):E(this,R,"f").drawImage(t,this.$doPixelRatio(s),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(h))}createPattern(e,t){return E(this,R,"f").createPattern(e,t)}measureText(e){return E(this,R,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?E(this,R,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):E(this,R,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?E(this,R,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):E(this,R,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){E(this,R,"f").save()}restore(){E(this,R,"f").restore()}scale(e,t){E(this,R,"f").scale(e,t)}circle(e,t,i,o,n,a,s,r){E(this,R,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,a,s,r)}isPointInPath(e,t){return E(this,R,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return E(this,R,"f").clip(...e)}setTransform(e,t,i,o,n,a){return E(this,R,"f").setTransform(e,t,i,o,n,a)}getTransform(){return E(this,R,"f").getTransform()}createLinearGradient(e,t,i,o){return E(this,R,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,a){return E(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 E(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 k{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 D(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}class L{constructor(e){this._backUpDefaultStorage=v(e.defaultStorage),this._temp=this._createTempStorage()}set(e,t){this._temp[e]=t}get(e){return this._temp[e]}getSnapshot(){return v(this._temp)}clear(){this._temp=this._createTempStorage()}_createTempStorage(){return v(this._backUpDefaultStorage)}}function F(e){const{activeStore:t}=e;return{scale:null==t?void 0:t.scale,offsetTop:null==t?void 0:t.offsetTop,offsetBottom:null==t?void 0:t.offsetBottom,offsetLeft:null==t?void 0:t.offsetLeft,offsetRight:null==t?void 0:t.offsetRight}}function Y(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:null==t?void 0:t.width,height:null==t?void 0:t.height,contextWidth:null==t?void 0:t.contextWidth,contextHeight:null==t?void 0:t.contextHeight}}function B(e){return e/180*Math.PI}function G(e,t,i,o){const n=B(t||0);i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(n),e.translate(-i.x,-i.y)),o(e),i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(-n),e.translate(-i.x,-i.y))}function N(e,t,i){const o=V(t);G(e,t.angle||0,o,(()=>{i(e)}))}function V(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function X(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),i=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return V({x:t,y:i,w:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,h:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-i})}function 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 Q(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 $(e){const{angle:t=0}=e;return Q(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=$(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=$({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):Q(e,V({x:t,y:i,w:o,h:n,angle:a}),a)}function ae(e){const t=[];let i=0,o=0;const n=[],a=[...e];for(let e=0;e<a.length;e++){const{x: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=D(g[0],g[1]),w=D(g[1],g[2]),m=D(g[2],g[3]),y=D(g[3],g[0]),x=g[0],S=g[1],p=g[2],b=g[3],A=re(x,{size:a,angle:u}),I=re(S,{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),C=ne(z),E=[P[1],R[0],R[3],P[2]],W=[R[3],R[2],C[1],C[0]],O=[T[1],C[0],C[3],T[2]];return{elementWrapper:g,left:{type:"left",vertexes:[P[3],P[2],T[1],T[0]],center:y},right:{type:"right",vertexes:W,center:w},top:{type:"top",vertexes:E,center:v},bottom:{type:"bottom",vertexes:O,center:m},topLeft:{type:"top-left",vertexes:P,center:x},topRight:{type:"top-right",vertexes:R,center:S},bottomLeft:{type:"bottom-left",vertexes:T,center:b},bottomRight:{type:"bottom-right",vertexes:C,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 y=he(h.commands||[]),x=new Path2D(y);e.clip(x),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,y=0,x=0;Array.isArray(l)&&(w=(l[0]||0)*s,m=(l[1]||0)*s,y=(l[2]||0)*s,x=(l[3]||0)*s);if(x||m||w||y){e.lineCap="butt";let{x:i,y:o,w:n,h:a}=t;"border-box"===f?(i+=x/2,o+=w/2,n=n-x/2-m/2,a=a-w/2-y/2):"content-box"===f?(i-=x/2,o-=w/2,n=n+x/2+m/2,a=a+w/2+y/2):(i=t.x,o=t.y,n=t.w,a=t.h),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(i-x/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+y/2),e.closePath(),e.stroke()),y&&(e.beginPath(),e.lineWidth=y,e.moveTo(i-x/2,o+a),e.lineTo(i+n+m/2,o+a),e.closePath(),e.stroke()),x&&(e.beginPath(),e.lineWidth=x,e.moveTo(i,o-w/2),e.lineTo(i,o+a+y/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 ye(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,y=d-n*w,x=f-a*m,S=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(y,x),e.scale(S*w/h.scale,S*m/h.scale);const t=he(o.commands||[]),i=new Path2D(t);o.fill&&(e.fillStyle=o.fill,e.fill(i)),o.stroke&&0!==o.strokeWidth&&(e.strokeStyle=o.stroke,e.lineWidth=(o.strokeWidth||1)/c.devicePixelRatio,e.lineCap=o.strokeLineCap||"square",e.stroke(i)),e.translate(-y,-x),e.restore()}})}})}))}(e,t,i);break;case"group":{const o=Object.assign(Object.assign({},i.elementAssets||{}),t.detail.assets||{});!function(e,t,i){const{calculator:o,viewScaleInfo:n,viewSizeInfo:a}=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{ye(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 xe={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 Se,pe,be,Ae,Ie,Me,ze,Pe,Re,Te,Ce,Ee=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())}))},We=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 Oe=["image","svg","html"],je=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 ke extends k{constructor(){super(),Se.add(this),pe.set(this,{}),be.set(this,{}),Ae.set(this,{}),We(this,Se,"m",Ie).call(this,"image",((e,t)=>Ee(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 S(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),We(this,Se,"m",Ie).call(this,"html",((e,t)=>Ee(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}})))),We(this,Se,"m",Ie).call(this,"svg",((e,t)=>Ee(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}}))))}load(e,t){We(this,Se,"m",Ce).call(this,e)||Oe.includes(e.type)&&We(this,Se,"m",Te).call(this,e,t)}getContent(e){var t,i;const o=je(e);return(null===(i=null===(t=We(this,Ae,"f"))||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return We(this,Ae,"f")}setLoadItemMap(e){!function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(e,i):n?n.value=i:t.set(e,i)}(this,Ae,e,"f")}}pe=new WeakMap,be=new WeakMap,Ae=new WeakMap,Se=new WeakSet,Ie=function(e,t){We(this,pe,"f")[e]=t},Me=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},ze=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:We(this,Se,"m",Me).call(this,e)}},Pe=function(e){const t=je(e.element),i=We(this,Ae,"f")[t];i?i.startTime<e.startTime&&(We(this,Ae,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(We(this,Ae,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime})))},Re=function(e){const t=je(e.element),i=We(this,Ae,"f")[t];i?i.startTime<e.startTime&&(We(this,Ae,"f")[t]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(We(this,Ae,"f")[t]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime})))},Te=function(e,t){const i=We(this,Se,"m",ze).call(this,e),o=je(e);We(this,be,"f")[o]=i;const n=We(this,pe,"f")[e.type];"function"==typeof n&&(i.startTime=Date.now(),n(e,t).then((e=>{i.content=e.content,i.endTime=Date.now(),i.status="load",We(this,Se,"m",Pe).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,We(this,Se,"m",Re).call(this,i)})))},Ce=function(e){var t;const i=je(e),o=null===(t=We(this,be,"f"))||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==We(this,Se,"m",Me).call(this,e))};var De,Le,Fe,Ye,Be=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},Ge=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 Ne extends k{constructor(e){super(),De.add(this),Le.set(this,void 0),Fe.set(this,new ke),Be(this,Le,e,"f"),Ge(this,De,"m",Ye).call(this)}updateOptions(e){Be(this,Le,e,"f")}drawData(e,t){const i=Ge(this,Fe,"f"),{calculator:o}=Ge(this,Le,"f"),n=Ge(this,Le,"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({},xe),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{ye(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}=Ge(this,Le,"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}})}setLoadItemMap(e){Ge(this,Fe,"f").setLoadItemMap(e)}getLoadItemMap(){return Ge(this,Fe,"f").getLoadItemMap()}}Le=new WeakMap,Fe=new WeakMap,De=new WeakSet,Ye=function(){const e=Ge(this,Fe,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(()=>{}))};class Ve{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=$({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 Xe(e){return e>0||e<0||0===e}class Ze extends k{constructor(e){super();const t=new L({defaultStorage:{hasPointDown:!1,prevClickPoint:null}});this._store=t,this._opts=e,this._init()}_init(){const e=window;e.addEventListener("mousemove",(e=>{if(!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this._isVaildPoint(t)&&this.trigger("hover",{point:t})})),e.addEventListener("mousedown",(e=>{if(!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this._isVaildPoint(t)&&(this._store.set("hasPointDown",!0),this.trigger("pointStart",{point:t}))})),e.addEventListener("mousemove",(e=>{if(!this._isInTarget(e))return;e.preventDefault(),e.stopPropagation();const t=this._getPoint(e);this._isVaildPoint(t)?!0===this._store.get("hasPointDown")&&this.trigger("pointMove",{point:t}):this._store.get("hasPointDown")&&(this.trigger("pointLeave",{point:t}),this._store.set("hasPointDown",!1))})),e.addEventListener("mouseup",(e=>{if(this._store.set("hasPointDown",!1),!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this.trigger("pointEnd",{point:t})})),e.addEventListener("mouseleave",(e=>{if(this._store.set("hasPointDown",!1),!this._isInTarget(e))return;e.preventDefault();const t=this._getPoint(e);this.trigger("pointLeave",{point:t})})),e.addEventListener("wheel",(e=>{if(!this._isInTarget(e))return;const t=this._getPoint(e);if(!this._isVaildPoint(t))return;e.preventDefault();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!!(Xe(e.x)&&Xe(e.y)&&e.x<=i&&e.y<=o)}}const He={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0};class Qe{constructor(){const e=new L({defaultStorage:He}),t=new L({defaultStorage:{}});this._activeStore=e,this._sharedStore=t}getActiveStorage(e){return this._activeStore.get(e)}setActiveStorage(e,t){return this._activeStore.set(e,t)}getActiveStoreSnapshot(){return this._activeStore.getSnapshot()}getSharedStorage(e){return this._sharedStore.get(e)}setSharedStorage(e,t){return this._sharedStore.set(e,t)}getSharedStoreSnapshot(){return this._sharedStore.getSnapshot()}getActiveViewScaleInfo(){return{scale:this._activeStore.get("scale"),offsetTop:this._activeStore.get("offsetTop"),offsetBottom:this._activeStore.get("offsetBottom"),offsetLeft:this._activeStore.get("offsetLeft"),offsetRight:this._activeStore.get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:n,offsetRight:a}=e;this._activeStore.set("scale",t),this._activeStore.set("offsetTop",i),this._activeStore.set("offsetBottom",o),this._activeStore.set("offsetLeft",n),this._activeStore.set("offsetRight",a)}setActiveViewSizeInfo(e){this._activeStore.set("width",e.width),this._activeStore.set("height",e.height),this._activeStore.set("devicePixelRatio",e.devicePixelRatio),this._activeStore.set("contextWidth",e.contextWidth),this._activeStore.set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:this._activeStore.get("width"),height:this._activeStore.get("height"),devicePixelRatio:this._activeStore.get("devicePixelRatio"),contextWidth:this._activeStore.get("contextWidth"),contextHeight:this._activeStore.get("contextHeight")}}}const{requestAnimationFrame:$e}=window;class _e extends k{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")&&$e((()=>{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 Ue,Je,Ke,qe,et,tt,it,ot,nt,at,st,rt,lt,ht,ct,dt,ft,ut,gt,vt,wt,mt,yt,xt,St,pt,bt=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},At=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class It{constructor(e){Ue.add(this),Je.set(this,void 0),Ke.set(this,new WeakMap),qe.set(this,[]),et.set(this,[]),tt.set(this,void 0),it.set(this,void 0),ot.set(this,void 0),nt.set(this,void 0),at.set(this,void 0),st.set(this,new k);const{boardContent:t}=e,i=new Qe,o=new Ve({viewContext:t.viewContext}),n=new Ze({boardContent:t,sharer:i}),a=new Ne({viewContext:t.viewContext,sharer:i,calculator:o});bt(this,Je,e,"f"),bt(this,ot,i,"f"),bt(this,tt,n,"f"),bt(this,it,a,"f"),bt(this,at,o,"f"),bt(this,nt,new _e({boardContent:e.boardContent,sharer:i,renderer:a,calculator:At(this,at,"f"),beforeDrawFrame:e=>{At(this,Ue,"m",xt).call(this,e)},afterDrawFrame:e=>{At(this,Ue,"m",St).call(this,e)}}),"f"),At(this,Ue,"m",rt).call(this),At(this,Ue,"m",pt).call(this)}getSharer(){return At(this,ot,"f")}getViewer(){return At(this,nt,"f")}getRenderer(){return At(this,it,"f")}setData(e){const t=At(this,ot,"f");At(this,ot,"f").setActiveStorage("data",e);const i=t.getActiveViewSizeInfo(),o=K(e.elements,{viewWidth:i.width,viewHeight:i.height,extend:!0});At(this,nt,"f").drawFrame();const n=Object.assign(Object.assign({},i),o);return At(this,ot,"f").setActiveViewSizeInfo(n),{viewSizeInfo:n}}getData(){const{data:e}=At(this,ot,"f").getActiveStoreSnapshot();return e}use(e){var t,i,o;if(At(this,Ke,"f").has(e)){const o=At(this,Ke,"f").get(e);if(o)return null===(i=(t=o.middlewareObject).use)||void 0===i||i.call(t),o.status="enable",At(this,Ke,"f").set(e,o),void At(this,Ue,"m",pt).call(this)}const{boardContent:n,container:a}=At(this,Je,"f"),s=e({boardContent:n,sharer:At(this,ot,"f"),viewer:At(this,nt,"f"),calculator:At(this,at,"f"),eventHub:At(this,st,"f"),container:a});null===(o=s.use)||void 0===o||o.call(s),At(this,qe,"f").push(e),At(this,et,"f").push(s),At(this,Ke,"f").set(e,{status:"enable",middlewareObject:s}),At(this,Ue,"m",pt).call(this)}disuse(e){var t,i;const o=At(this,Ke,"f").get(e);o&&(null===(i=(t=o.middlewareObject).disuse)||void 0===i||i.call(t),o.status="disable",At(this,Ke,"f").set(e,o),At(this,Ue,"m",pt).call(this))}scale(e){const t=At(this,nt,"f"),{moveX:i,moveY:o}=t.scale(e);t.scroll({moveX:i,moveY:o})}scroll(e){return At(this,nt,"f").scroll(e)}updateViewScaleInfo(e){return At(this,nt,"f").updateViewScaleInfo(e)}resize(e){const t=At(this,nt,"f").resize(e),{width:i,height:o,devicePixelRatio:n}=e,{boardContent:a}=At(this,Je,"f");a.viewContext.$resize({width:i,height:o,devicePixelRatio:n}),a.helperContext.$resize({width:i,height:o,devicePixelRatio:n}),a.boardContext.$resize({width:i,height:o,devicePixelRatio:n}),a.underContext.$resize({width:i,height:o,devicePixelRatio:n}),At(this,nt,"f").drawFrame(),At(this,tt,"f").trigger("resize",t),At(this,ot,"f").setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=At(this,Je,"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),At(this,Ue,"m",yt).call(this)}getEventHub(){return At(this,st,"f")}}Je=new WeakMap,Ke=new WeakMap,qe=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,ot=new WeakMap,nt=new WeakMap,at=new WeakMap,st=new WeakMap,Ue=new WeakSet,rt=function(){At(this,tt,"f").on("pointStart",At(this,Ue,"m",lt).bind(this)),At(this,tt,"f").on("pointEnd",At(this,Ue,"m",ht).bind(this)),At(this,tt,"f").on("pointMove",h((e=>{At(this,Ue,"m",ct).call(this,e)}),10)),At(this,tt,"f").on("hover",h((e=>{At(this,Ue,"m",dt).call(this,e)}),10)),At(this,tt,"f").on("wheel",h((e=>{At(this,Ue,"m",ut).call(this,e)}),10)),At(this,tt,"f").on("wheelScale",h((e=>{At(this,Ue,"m",gt).call(this,e)}),10)),At(this,tt,"f").on("scrollX",At(this,Ue,"m",vt).bind(this)),At(this,tt,"f").on("scrollY",At(this,Ue,"m",wt).bind(this)),At(this,tt,"f").on("resize",At(this,Ue,"m",mt).bind(this)),At(this,tt,"f").on("doubleClick",At(this,Ue,"m",ft).bind(this))},lt=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointStart)||void 0===t?void 0:t.call(o,e)))return}},ht=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointEnd)||void 0===t?void 0:t.call(o,e)))return}},ct=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointMove)||void 0===t?void 0:t.call(o,e)))return}},dt=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.hover)||void 0===t?void 0:t.call(o,e)))return}},ft=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.doubleClick)||void 0===t?void 0:t.call(o,e)))return}},ut=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheel)||void 0===t?void 0:t.call(o,e)))return}},gt=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheelScale)||void 0===t?void 0:t.call(o,e)))return}},vt=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollX)||void 0===t?void 0:t.call(o,e)))return}},wt=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollY)||void 0===t?void 0:t.call(o,e)))return}},mt=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.resize)||void 0===t?void 0:t.call(o,e)))return}},yt=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.clear)||void 0===t?void 0:t.call(o,e)))return}},xt=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.beforeDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},St=function(e){var t;for(let i=0;i<At(this,et,"f").length;i++){const o=At(this,et,"f")[i];if(!1===(null===(t=null==o?void 0:o.afterDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},pt=function(){const e=[],t=At(this,Ke,"f");At(this,qe,"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)})),bt(this,et,e,"f")};const Mt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMjMtMDktMTdUMTY6MzE6MjMrMDg6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDIzL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jZyBlmVlrOYdYaS1HUUuQA/gWV9fd51URDyqn1c1j6MVFGjoidfW1oq2ABrYj0V82OmVzwHNajVdB88C5wOKTdM87NaxsrKyQsFKHC2BnTDo+/TWt8Bd5INeVC44NDT0xXYZdXNz8w/AaeyS8yjwCPdzQu92ht2m/OUjIyOfS1pkAoqItLS0fA+8D7wKPA0cxs6qC1O4T0xMfKYnb21tnXEDNjc3z+nXbW1t3wFvYz9dCAL7KUThHovFPtGTNjU1jQFSX18/lg68cuXKLUAaGxs3vkB7e/u3wHHgCQpUdnpTqdQvesJgMDisUVevXh3Xry9fvnxTv66qqprQ/cfHx/vVNj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==";class zt{constructor(e,t){this._cursorType=null,this._resizeCursorBaseImage=null,this._cursorImageMap={auto:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxucz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IcY2j219TQB0NV4A7qODgO4CFhYWLg4ODOb8AHccpG4A68m6pRQ1YAQ6A28A+8BXwBcDq6upTqVTquh+AuVyuW4q/opRRaQdZD1gCbgE3ge+BT4HdfD7/ZDwe/z2bzRY6hRsfH1/e3Nx8FDX/sgbgoZfvg6jo4ixqW7oIPA+8CrwHrAJuJBLJd+JaHMf5k6qmPgGeQe1SCenXk0/U21xcIC8AzwGvAJPAEuAmEon1xcXFba9w8/Pz5oqdB14CnpY+oij35km0qwmjwqAU8ISM9hIwBeQA17KsG9PT07+1gxsZGdmgdqW+BjwLDAAPoo4ALU+W9arVwWoIpXp9kouKZpPAO8AwQCwW+2d0dLQ0OTkZSafT0UKhUJ6bm9t2HKeysrIS3tra0g7+KvABUJC0g5rrJdRcbLpImtleRzYashc1P2OSXwbebDVykX3gW+Ab1AHqhuQ3pe6AJlFMO0CoPROHDcio5I8DL1A9C8dQbmod+APYAK4DvwjQnsDdErgyVTfTEaCG1GFYGHXG7TVSo2OkdvhlAflXoHSuNdfStFqaRhEi2kfdprrj6M5LAt0I8EDaaMdflPal48CB95hMr3Bt8h4jD0kyL5E0pN6dysZzW7N2AqjbmhdIZjJvufTOpE19x3g+9s1XJ/ck5tVbfdhu+rxDfLiSO+lFToCjZwrXyH2/0Lwv95z8B1jAqXmDnj4YAAAAAElFTkSuQmCC","rotate-0":Mt},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(){S(Mt).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 Pt="SELECT",Rt=Symbol(`${Pt}_actionType`),Tt=Symbol(`${Pt}_resizeType`),Ct=Symbol(`${Pt}_areaStart`),Et=Symbol(`${Pt}_areaEnd`),Wt=Symbol(`${Pt}_hoverElement`),Ot=Symbol(`${Pt}_hoverElementVertexes`),jt=Symbol(`${Pt}_selectedElementList`),kt=Symbol(`${Pt}_selectedElementListVertexes`),Dt=Symbol(`${Pt}_selectedElementController`),Lt=Symbol(`${Pt}_groupQueue`),Ft=Symbol(`${Pt}_groupQueueVertexesList`),Yt="#1973ba";function Bt(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 Gt(e,t,i){if(!t)return;const o={borderColor:Yt,borderWidth:1,background:"transparent",lineDash:[]};Bt(e,te(t,i),o)}function Nt(e,t,i){if(!t)return;const{elementWrapper:o,topLeft:n,topRight:a,bottomLeft:s,bottomRight:r}=t,l={borderColor:Yt,borderWidth:2,background:"transparent",lineDash:[]},h={...l,borderWidth:4,background:"#FFFFFF"};Bt(e,te(o,i),l),Bt(e,te(n.vertexes,i),h),Bt(e,te(a.vertexes,i),h),Bt(e,te(s.vertexes,i),h),Bt(e,te(r.vertexes,i),h)}function Vt(e){return e*Math.PI/180}function Xt(e,t){return Math.sqrt(e*e+t*t)}function Zt(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Ht(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 Qt(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&&Ht(e,{ctx:i,vertexes:r,viewScaleInfo:o,viewSizeInfo:n})}function $t(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(Ht(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&&Ht(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 _t(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=$(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 Ut="@middleware/text-edit",Jt={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"},Kt="@middleware/select",qt="SCROLL",ei=Symbol(`${qt}_xThumbRect`),ti=Symbol(`${qt}_yThumbRect`),ii=Symbol(`${qt}_prevPoint`),oi=Symbol(`${qt}_activePoint`),ni=Symbol(`${qt}_activeThumbType`),ai=16,si=.36,ri={width:12,thumbColor:"#000000AA",scrollBarColor:"#FFFFFF60",showScrollBar:!1};function li(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 hi(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=si,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 ci(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*ai,h=ai;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:ri.thumbColor,scrollBarColor:ri.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))),hi(i,{axis:"X",...c,r:h.lineSize/2,color:h.thumbColor}),hi(i,{axis:"Y",...d,r:h.lineSize/2,color:h.thumbColor}),i.globalAlpha=1,{xThumbRect:c,yThumbRect:d}}function di(e,t){const{snapshot:i}=t,o=Y(i),n=F(i),a=function(e){const{sharedStore:t}=e;return{activePoint:t[oi]||null,prevPoint:t[ii]||null,activeThumbType:t[ni]||null,xThumbRect:t[ei]||null,yThumbRect:t[ti]||null}}(i),{xThumbRect:s,yThumbRect:r}=ci(e,{viewSizeInfo:o,viewScaleInfo:n,scrollInfo:a});return{xThumbRect:s,yThumbRect:r}}const fi="@middleware/scale",ui=16,gi="#000000",vi="#00000080",wi="monospace",mi="#AAAAAA20",yi="#AAAAAA40";function xi(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 Si="@middleware/show-ruler",pi=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 It({boardContent:w,container:e}),y=m.getSharer();y.setActiveViewSizeInfo({width:c,height:d,devicePixelRatio:h,contextWidth:c,contextHeight:d}),l(this,t,m),this.resize(y.getActiveViewSizeInfo());const x=m.getEventHub();new zt(e,{eventHub:x})}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)}getLoadItemMap(){return s(this,t).getRenderer().getLoadItemMap()}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:o}=e;let n=!1;return{hover(){!0!==n&&t.trigger("cursor",{type:"drag-default"})},pointStart(e){const{point:o}=e;i.setSharedStorage(pi,o),n=!0,t.trigger("cursor",{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(pi);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(pi,t)},pointEnd(){n=!1,i.setSharedStorage(pi,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(Si,l)},disuse(){o.off(Si,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,ui),e.lineTo(ui,ui),e.lineTo(ui,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 xi({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<ui||(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=gi,e.stroke(),o.isKeyNum&&(e.fillStyle=vi,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:wi}),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 xi({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<ui)&&(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=gi,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=vi,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:wi}),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=yi:e.strokeStyle=mi,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=yi:e.strokeStyle=mi,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(fi,{scale:c})}}},e.MiddlewareScroller=e=>{const{viewer:t,boardContent:i,sharer:o}=e,{helperContext:n}=i;o.setSharedStorage(ei,null),o.setSharedStorage(ti,null);const a=()=>{o.setSharedStorage(ii,null),o.setSharedStorage(oi,null),o.setSharedStorage(ni,null)};a();const s=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:a}=i;return n&&li(e,t,n)?o="X":a&&li(e,t,a)&&(o="Y"),o}(n,e,{xThumbRect:o.getSharedStorage(ei),yThumbRect:o.getSharedStorage(ti)});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(ni,i),o.setSharedStorage(ii,t),!1},pointMove:e=>{const{point:i}=e,n=o.getSharedStorage(ni);if("X"===n||"Y"===n)return o.setSharedStorage(oi,i),"X"===n?(e=>{const i=o.getSharedStorage(ii);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(ii);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(ii,i),!1},pointEnd:()=>{const e=o.getSharedStorage(ni);if(a(),"X"===e||"Y"===e)return t.scroll({moveX:0,moveY:0}),t.drawFrame(),!1},beforeDrawFrame({snapshot:e}){const{xThumbRect:t,yThumbRect:i}=di(n,{snapshot:e});o.setSharedStorage(ei,t),o.setSharedStorage(ti,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(Rt,null);const h=()=>i.getSharedStorage(jt),c=e=>{let t=i.getSharedStorage(Lt);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(Lt,t),i.setSharedStorage(Ft,o),t.length>0},d=e=>{i.setSharedStorage(Wt,e);let t=null;e&&(t=se(e,{groupQueue:i.getSharedStorage(Lt)})),i.setSharedStorage(Ot,t)},f=(e,t)=>{if(i.setSharedStorage(jt,e),1===e.length){const t=le(e[0],{groupQueue:i.getSharedStorage(Lt),controllerSize:10,viewScaleInfo:i.getActiveViewScaleInfo()});i.setSharedStorage(Dt,t)}else i.setSharedStorage(Dt,null);!0===(null==t?void 0:t.triggerEvent)&&a.trigger(Kt,{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(Lt),areaSize:null,selectedElementController:i.getSharedStorage(Dt)}),g=()=>{i.setSharedStorage(Rt,null),i.setSharedStorage(Tt,null),i.setSharedStorage(Ct,null),i.setSharedStorage(Et,null),i.setSharedStorage(Lt,[]),i.setSharedStorage(Ft,[]),i.setSharedStorage(Wt,null),i.setSharedStorage(Ot,null),i.setSharedStorage(jt,[]),i.setSharedStorage(kt,null),i.setSharedStorage(Dt,null)};g();const v=({uuids:e,positions:o})=>{let n=[];const a=i.getSharedStorage(Rt),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(Rt,"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(Lt,e),f(n),t.drawFrame()}};return{use(){a.on(Kt,v)},disuse(){a.off(Kt,v)},hover:e=>{var o,r;const c=i.getSharedStorage(Tt),f=i.getSharedStorage(Rt),g=i.getSharedStorage(Lt),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(!Qt(e.point,{ctx:s,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:i.getSharedStorage(Lt)}))return d(null),void t.drawFrame();const n=$t(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(),y=i.getActiveViewSizeInfo(),x=$t(e.point,{...u(),areaSize:_t(w,{viewScaleInfo:m,viewSizeInfo:y,calculator:n})});return v(x),"over-element"===x.type&&1===(null==(r=null==x?void 0:x.elements)?void 0:r.length)?(i.setSharedStorage(Wt,x.elements[0]),d(x.elements[0]),void t.drawFrame()):i.getSharedStorage(Wt)?(d(null),void t.drawFrame()):void 0},pointStart:e=>{var o,a,l,c;r=e.point,d(null);const v=i.getSharedStorage(Lt);if((null==v?void 0:v.length)>0){if(Qt(e.point,{ctx:s,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),groupQueue:v})){const t=$t(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(Rt,"drag")):(null==(a=t.type)?void 0:a.startsWith("resize-"))?(i.setSharedStorage(Tt,t.type),i.setSharedStorage(Rt,"resize")):f([],{triggerEvent:!0})}else g();return void t.drawFrame()}const w=_t(h(),{viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo(),calculator:n}),m=$t(e.point,{...u(),areaSize:w,groupQueue:[]});"list-area"===m.type?i.setSharedStorage(Rt,"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(Rt,"drag")):(null==(c=m.type)?void 0:c.startsWith("resize-"))?(i.setSharedStorage(Tt,m.type),i.setSharedStorage(Rt,"resize")):(g(),i.setSharedStorage(Rt,"area"),i.setSharedStorage(Ct,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(Tt),u=i.getSharedStorage(Rt),g=i.getSharedStorage(Lt);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),y=!!(null==(i=null==e?void 0:e.operations)?void 0:i.limitRatio),{start:x,end:S,resizeType:p,scale:b}=t;let A={...x},I={...S},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},C={x:w.x,y:I.y},E={...T},W={...C},O=(R.x-P.x)/b,j=(R.y-P.y)/b,k=Xt(O,j),D=(W.x-E.x)/b,L=(W.y-E.y)/b,F=Xt(D,L);(v>0||v<0)&&(A=Z(w,x,0-m),I=Z(w,S,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},C={x:w.x,y:I.y},E=Z(w,T,m),W=Z(w,C,m),O=(R.x-P.x)/b,j=(R.y-P.y)/b,k=Xt(O,j),k=Zt(k,j),D=(W.x-E.x)/b,L=(W.y-E.y)/b,F=Xt(D,L),F=Zt(F,L));let Y=(S.x-x.x)/b,G=(S.y-x.y)/b;if(!0===y)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(D),Math.abs(L));D=(D>=0?1:-1)*i,L=(L>=0?1:-1)*i/e.w*e.h;const o=Math.max(Math.abs(O),Math.abs(j));O=(O>=0?1:-1)*o,j=(j>=0?1:-1)*o/e.w*e.h}else if(["resize-top-left","resize-top-right","resize-bottom-left","resize-bottom-right"].includes(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)}k=Math.abs(k),F=k/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-Zt(F,L);const e=Vt(v),o=F/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){F=Zt(F,D);const e=Vt(v-90),o=F/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){F=Zt(F,L);const e=Vt(v-180),o=F/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){F=0-Zt(F,D);const e=Vt(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=Zt(F,L);const e=Vt(v),o=F/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){F=0-Zt(F,D);const e=Vt(v-90),o=F/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){F=Zt(F,D);const e=Vt(v-180),o=F/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){F=Zt(F,D);const e=Vt(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){k=0-Zt(k,O);const e=Vt(v),o=k/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){k=Zt(k,O);const e=Vt(v-90),o=k/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){k=Zt(k,j);const e=Vt(v-180),o=k/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){k=Zt(k,j);const e=Vt(v-270),o=k/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}u+k>0&&(!0===(null==(l=e.operations)?void 0:l.limitRatio)&&(g+=k/e.w*e.h),u+=k,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){k=Zt(k,j);const e=Vt(v),o=k/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){k=Zt(k,G);const e=Vt(v-90),o=k/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){k=Zt(k,G);const e=Vt(v-180),o=k/2;t+=o*Math.cos(e),i+=o*Math.sin(e),k=0-k}else if(v<360){k=Zt(k,Y);const e=Vt(v-270),o=k/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}u+k>0&&(!0===(null==(c=e.operations)?void 0:c.limitRatio)&&(g+=k/e.w*e.h),u+=k,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-Zt(F,L),k=0-Zt(k,y?0-F:O);const i=F/2;e+=i*Math.sin(m),t-=i*Math.cos(m);const o=k/2;e-=o*Math.cos(m),t-=o*Math.sin(m)}else if(v<180){F=Zt(F,D),k=Zt(k,y?F:O);const i=Vt(v-90),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=k/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){F=Zt(F,L),k=Zt(k,y?F:j);const i=Vt(v-180),o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=k/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){F=0-Zt(F,D),k=Zt(k,y?F:j);const i=Vt(v-270),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=k/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+F>0&&(g+=F),u+k>0&&(u+=k),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-Zt(F,L),k=Zt(k,y?F:j);const i=Vt(v),o=F/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=k/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){F=Zt(F,D),k=Zt(k,y?F:j);const i=Vt(v-90),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=k/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){const i=Vt(v-180);F=Zt(F,L),k=Zt(k,y?F:0-O);const o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=k/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){F=0-Zt(F,D),k=Zt(k,y?F:O);const i=Vt(v-270),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=k/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+F>0&&(g+=F),u+k>0&&(u+=k),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=Zt(F,L),k=0-Zt(k,y?0-F:O);const i=Vt(v),o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=k/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<180){F=0-Zt(F,D),k=Zt(k,y?F:O);const i=Vt(v-90),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=k/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){F=Zt(F,D),k=Zt(k,y?F:j);const i=Vt(v-180),o=F/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=k/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){F=Zt(F,D),k=Zt(k,y?F:j);const i=Vt(v-270),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=k/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+F>0&&(g+=F),u+k>0&&(u+=k),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=Zt(F,L),k=Zt(k,y?F:j);const i=Vt(v),o=F/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=k/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){F=0-Zt(F,D),k=Zt(k,y?F:G);const i=Vt(v-90),o=F/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=k/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){F=Zt(F,D),k=Zt(k,y?F:0-j);const i=Vt(v-180),o=F/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=k/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){F=Zt(F,D),k=Zt(k,y?F:O);const i=Vt(v-270),o=F/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=k/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+F>0&&(g+=F),u+k>0&&(u+=k),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(Et,e.point),t.drawFrame());r=e.point},pointEnd(e){l=null;const o=i.getActiveStorage("data"),s=i.getSharedStorage(Tt),h=i.getSharedStorage(Rt),c=i.getActiveViewSizeInfo();let d=!1;if(r=null,"resize"===h&&s)i.setSharedStorage(Tt,null),d=!0;else if("area"===h){if(i.setSharedStorage(Rt,null),o){const e=i.getSharedStorage(Ct),t=i.getSharedStorage(Et);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=$(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(Rt,"drag-list"),f(a,{triggerEvent:!0}),d=!0)}}}else if("drag-list"===h)i.setSharedStorage(Rt,"drag-list-end"),d=!0;else if(o){n.getPointElement(e.point,{data:o,viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}).element?(i.setSharedStorage(Rt,"select"),d=!0):i.setSharedStorage(Rt,null)}null===i.getSharedStorage(Rt)&&(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=$t(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(Rt,null),void t.drawFrame()}else 1===s.elements.length&&"text"===(null==(n=s.elements[0])?void 0:n.type)&&a.trigger(Ut,{element:s.elements[0],groupQueue:i.getSharedStorage(Lt)||[],viewScaleInfo:i.getActiveViewScaleInfo()});i.setSharedStorage(Rt,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,y={scale:a,offsetLeft:r,offsetTop:l,offsetRight:c,offsetBottom:d},x={width:f,height:u,contextHeight:g,contextWidth:v,devicePixelRatio:w},S=o[jt][0],p=o[Wt],b=o[Ot],A=o[Rt],I=o[Ct],M=o[Et],z=o[Lt],P=o[Ft],R={calculator:n,viewScaleInfo:y,viewSizeInfo:x},T=S?le(S,{groupQueue:z,controllerSize:10,viewScaleInfo:y}):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:Yt,borderWidth:2,background:"transparent",lineDash:[4,4]};Bt(e,te(n,i),a)}}(s,P,R),p&&"drag"!==A&&Gt(s,b,R),S&&["select","drag","resize"].includes(A)&&Nt(s,T,{...R});else if(p&&"drag"!==A&&Gt(s,b,R),S&&["select","drag","resize"].includes(A))Nt(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=Yt,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=_t(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=Yt,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={...Jt,...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(Ut,g)},disuse(){t.off(Ut,g)}}},e.middlewareEventRuler=Si,e.middlewareEventScale=fi,e.middlewareEventSelect=Kt,e.middlewareEventTextEdit=Ut,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
1
+ var iDrawCore=function(e){"use strict";var t,i,o,n,l,a,r,s,h,c,d,u,f,g,v,m,y,p,w,x,S,b,A,I,M,z,R,C,T,P,E,L,k,O,W,D,j,Y,N,B,F,G,V,X,H,Z,Q,U,$,J,K,q,_,ee,te,ie,oe,ne,le,ae,re,se,he,ce,de,ue,fe,ge,ve=e=>{throw TypeError(e)},me=(e,t,i)=>t.has(e)||ve("Cannot "+i),ye=(e,t,i)=>(me(e,t,"read from private field"),i?i.call(e):t.get(e)),pe=(e,t,i)=>t.has(e)?ve("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),we=(e,t,i,o)=>(me(e,t,"write to private field"),o?o.call(e,i):t.set(e,i),i),xe=(e,t,i)=>(me(e,t,"access private method"),i);function Se(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 be(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 Ae(e){const t=function(e){let t=0xcbf29ce484222325n,i=0x84222325cbf29ce4n,o=0x1b3n*t,n=0x1000000n*i;const l=0x100000001b3n,a=4096;for(let r=0;r<e.length;r+=a){const s=e.slice(r,r+a);for(let e=0;e<s.length;e++){t=(t^BigInt(s.charCodeAt(e)+r+e))*l,i=(i^t)*l^o,o=(o^i)*l+n,n=(n^o)*l|0x1234567890abcdefn}}return t<<192n|i<<128n|o<<64n|n}(e);return function(e){const t="0123456789abcdefghijklmnopqrstuvwxyz";if(0n===e)return"0";let i="";for(;e>0n;){i=t[Number(e%36n)]+i,e/=36n}return i}(t).padStart(32,"0").slice(0,32)}function Ie(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function Me(e){return`@assets/${Ae(e)}`}function ze(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 Re(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const Ce={type(e,t){const i=Re(e);return!0===t?i.toLocaleLowerCase():i},array:e=>"Array"===Re(e),json:e=>"Object"===Re(e),function:e=>"Function"===Re(e),asyncFunction:e=>"AsyncFunction"===Re(e),boolean:e=>"Boolean"===Re(e),string:e=>"String"===Re(e),number:e=>"Number"===Re(e),undefined:e=>"Undefined"===Re(e),null:e=>"Null"===Re(e),promise:e=>"Promise"===Re(e)};var Te=function(e,t,i,o){return new(i||(i=Promise))((function(n,l){function a(e){try{s(o.next(e))}catch(e){l(e)}}function r(e){try{s(o.throw(e))}catch(e){l(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(a,r)}s((o=o.apply(e,t||[])).next())}))};const{Image:Pe}=window;function Ee(e){return new Promise(((t,i)=>{const o=new Pe;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function Le(e){return Te(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 Ee(t)}))}function ke(e,t){return Te(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 l=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"}),a=new FileReader;a.readAsDataURL(l),a.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},a.onerror=function(e){n(e)}}))}(e,t);return yield Ee(i)}))}function Oe(e){return"number"==typeof e&&e>=0}function We(e){return"number"==typeof e&&(e>0||e<=0)}function De(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function je(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const Ye={positiveNum:Oe,x:function(e){return We(e)},y:function(e){return We(e)},w:function(e){return Oe(e)},h:function(e){return Oe(e)},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:We,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return Oe(e)||Array.isArray(e)&&Oe(e[0])&&Oe(e[1])&&Oe(e[2])&&Oe(e[3])},borderRadius:function(e){return Oe(e)||Array.isArray(e)&&Oe(e[0])&&Oe(e[1])&&Oe(e[2])&&Oe(e[3])},color:function(e){return Se(e)},imageSrc:function(e){return je(e)||De(e)},imageURL:De,imageBase64:je,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 We(e)&&e>0},lineHeight:function(e){return We(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 We(e)&&e>0}};var Ne,Be,Fe=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},Ge=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 Ve{constructor(e,t){Ne.set(this,void 0),Be.set(this,void 0),Fe(this,Ne,e,"f"),Fe(this,Be,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f"),this.$resetFont()}$undoPixelRatio(e){return e/Ge(this,Be,"f").devicePixelRatio}$doPixelRatio(e){return Ge(this,Be,"f").devicePixelRatio*e}$getContext(){return Ge(this,Ne,"f")}$setContext(e){Fe(this,Ne,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"}`),Ge(this,Ne,"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 Ge(this,Be,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:l}=Ge(this,Ne,"f");l.width=t*o,l.height=i*o,Fe(this,Be,Object.assign(Object.assign({},Ge(this,Be,"f")),{devicePixelRatio:o}),"f"),!0===n&&(l.style.width=`${t}px`,l.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=Ge(this,Be,"f"),{width:t,height:i}=Ge(this,Ne,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return Ge(this,Ne,"f").canvas}get fillStyle(){return Ge(this,Ne,"f").fillStyle}set fillStyle(e){Ge(this,Ne,"f").fillStyle=e}get strokeStyle(){return Ge(this,Ne,"f").strokeStyle}set strokeStyle(e){Ge(this,Ne,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(Ge(this,Ne,"f").lineWidth)}set lineWidth(e){Ge(this,Ne,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return Ge(this,Ne,"f").textAlign}set textAlign(e){Ge(this,Ne,"f").textAlign=e}get textBaseline(){return Ge(this,Ne,"f").textBaseline}set textBaseline(e){Ge(this,Ne,"f").textBaseline=e}get globalAlpha(){return Ge(this,Ne,"f").globalAlpha}set globalAlpha(e){Ge(this,Ne,"f").globalAlpha=e}get shadowColor(){return Ge(this,Ne,"f").shadowColor}set shadowColor(e){Ge(this,Ne,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(Ge(this,Ne,"f").shadowOffsetX)}set shadowOffsetX(e){Ge(this,Ne,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(Ge(this,Ne,"f").shadowOffsetY)}set shadowOffsetY(e){Ge(this,Ne,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(Ge(this,Ne,"f").shadowBlur)}set shadowBlur(e){Ge(this,Ne,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return Ge(this,Ne,"f").lineCap}set lineCap(e){Ge(this,Ne,"f").lineCap=e}get globalCompositeOperation(){return Ge(this,Ne,"f").globalCompositeOperation}set globalCompositeOperation(e){Ge(this,Ne,"f").globalCompositeOperation=e}fill(...e){return Ge(this,Ne,"f").fill(...e)}arc(e,t,i,o,n,l){return Ge(this,Ne,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,l)}rect(e,t,i,o){return Ge(this,Ne,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return Ge(this,Ne,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return Ge(this,Ne,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return Ge(this,Ne,"f").beginPath()}closePath(){return Ge(this,Ne,"f").closePath()}lineTo(e,t){return Ge(this,Ne,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return Ge(this,Ne,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return Ge(this,Ne,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}bezierCurveTo(e,t,i,o,n,l){return Ge(this,Ne,"f").bezierCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(l))}quadraticCurveTo(e,t,i,o){return Ge(this,Ne,"f").quadraticCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return Ge(this,Ne,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return Ge(this,Ne,"f").setLineDash(t)}stroke(e){return e?Ge(this,Ne,"f").stroke(e):Ge(this,Ne,"f").stroke()}translate(e,t){return Ge(this,Ne,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return Ge(this,Ne,"f").rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],n=e[3],l=e[4],a=e[e.length-4],r=e[e.length-3],s=e[e.length-2],h=e[e.length-1];return 9===e.length?Ge(this,Ne,"f").drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(l),this.$doPixelRatio(a),this.$doPixelRatio(r),this.$doPixelRatio(s),this.$doPixelRatio(h)):Ge(this,Ne,"f").drawImage(t,this.$doPixelRatio(a),this.$doPixelRatio(r),this.$doPixelRatio(s),this.$doPixelRatio(h))}createPattern(e,t){return Ge(this,Ne,"f").createPattern(e,t)}measureText(e){return Ge(this,Ne,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?Ge(this,Ne,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):Ge(this,Ne,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?Ge(this,Ne,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):Ge(this,Ne,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){Ge(this,Ne,"f").save()}restore(){Ge(this,Ne,"f").restore()}scale(e,t){Ge(this,Ne,"f").scale(e,t)}circle(e,t,i,o,n,l,a,r){Ge(this,Ne,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,l,a,r)}isPointInPath(e,t){return Ge(this,Ne,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return Ge(this,Ne,"f").clip(...e)}setTransform(e,t,i,o,n,l){return Ge(this,Ne,"f").setTransform(e,t,i,o,n,l)}getTransform(){return Ge(this,Ne,"f").getTransform()}createLinearGradient(e,t,i,o){return Ge(this,Ne,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,l){return Ge(this,Ne,"f").createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(l))}createConicGradient(e,t,i){return Ge(this,Ne,"f").createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function Xe(e){const{width:t,height:i,devicePixelRatio:o}=e,n=new OffscreenCanvas(t*o,i*o),l=n.getContext("2d").canvas.getContext("2d");return new Ve(l,{devicePixelRatio:o,offscreenCanvas:n})}function He(e,t){const{width:i,height:o,devicePixelRatio:n}=t,l={width:i,height:o,devicePixelRatio:n},a=e.getContext("2d"),r=Xe(l),s=Xe(l),h=Xe(l),c=function(e){const{width:t,height:i,ctx:o,devicePixelRatio:n}=e;let l=o;if(!l){const e=document.createElement("canvas");e.width=t*n,e.height=i*n,l=e.getContext("2d")}return new Ve(l,e)}(Object.assign({ctx:a},l)),d=Xe(l);return{underlayContext:h,viewContext:r,overlayContext:s,boardContext:c,tempContext:d,drawView:()=>{const{width:e,height:t}=r.$getSize();c.clearRect(0,0,e,t),c.drawImage(h.canvas,0,0,e,t),c.drawImage(r.canvas,0,0,e,t),c.drawImage(s.canvas,0,0,e,t),h.clearRect(0,0,e,t),r.clearRect(0,0,e,t),s.clearRect(0,0,e,t)}}}Ne=new WeakMap,Be=new WeakMap;var Ze,Qe=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 Ue{constructor(){Ze.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,Ze,new Map,"f")}on(e,t){if(Qe(this,Ze,"f").has(e)){const i=Qe(this,Ze,"f").get(e)||[];null==i||i.push(t),Qe(this,Ze,"f").set(e,i)}else Qe(this,Ze,"f").set(e,[t])}off(e,t){if(Qe(this,Ze,"f").has(e)){const i=Qe(this,Ze,"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}Qe(this,Ze,"f").set(e,i||[])}}trigger(e,t){const i=Qe(this,Ze,"f").get(e);return!!Array.isArray(i)&&(i.forEach((e=>{e(t)})),!0)}has(e){if(Qe(this,Ze,"f").has(e)){const t=Qe(this,Ze,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){Qe(this,Ze,"f").clear()}}function $e(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}Ze=new WeakMap;var Je,Ke,qe,_e,et,tt=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},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)};class ot{constructor(e){Je.add(this),Ke.set(this,void 0),qe.set(this,void 0),_e.set(this,void 0),tt(this,qe,ze(e.defaultStorage),"f"),tt(this,Ke,it(this,Je,"m",et).call(this),"f"),tt(this,_e,e.defaultStatic||{},"f")}set(e,t){it(this,Ke,"f")[e]=t}get(e){return it(this,Ke,"f")[e]}setStatic(e,t){it(this,_e,"f")[e]=t}getStatic(e){return it(this,_e,"f")[e]}getSnapshot(e){return!0===(null==e?void 0:e.deepClone)?ze(it(this,Ke,"f")):Object.assign({},it(this,Ke,"f"))}clear(){tt(this,Ke,it(this,Je,"m",et).call(this),"f")}destroy(){tt(this,Ke,null,"f"),tt(this,_e,null,"f")}}function nt(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 lt(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 at(e){return e/180*Math.PI}function rt(e,t,i,o){const n=at(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 st(e,t,i){const o=ht(t);rt(e,t.angle||0,o,(()=>{i(e)}))}function ht(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function ct(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 ht({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 dt(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 ut(e,t,i){let o=dt(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 l=0,a=0;return 0===o?(l=0,a=0-n):o>0&&o<Math.PI/2?(l=Math.sin(o)*n,a=0-Math.cos(o)*n):o===Math.PI/2?(l=n,a=0):o>Math.PI/2&&o<Math.PI?(l=Math.sin(Math.PI-o)*n,a=Math.cos(Math.PI-o)*n):o===Math.PI?(l=0,a=n):o>Math.PI&&o<1.5*Math.PI?(l=0-Math.sin(o-Math.PI)*n,a=Math.cos(o-Math.PI)*n):o===1.5*Math.PI?(l=0-n,a=0):o>1.5*Math.PI&&o<2*Math.PI?(l=0-Math.sin(2*Math.PI-o)*n,a=0-Math.cos(2*Math.PI-o)*n):o===2*Math.PI&&(l=0,a=0-n),l+=e.x,a+=e.y,{x:l,y:a}}function ft(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:l,h:a,angle:r=0}=e,s=ut(ht({x:t,y:n,w:l,h:a}),{x:i,y:o},at(r));i=s.x,o=s.y})),{x:i,y:o}}return e}function gt(e,t,i){const{x:o,y:n,w:l,h:a}=e;let r={x:o,y:n},s={x:o+l,y:n},h={x:o+l,y:n+a},c={x:o,y:n+a};if(i&&(i>0||i<0)){const e=at(yt(i));r=ut(t,r,e),s=ut(t,s,e),h=ut(t,h,e),c=ut(t,c,e)}return[r,s,h,c]}function vt(e){const{angle:t=0}=e;return gt(e,ht(e),t)}function mt(e,t,i){return[ut(e,{x:t[0].x,y:t[0].y},i),ut(e,{x:t[1].x,y:t[1].y},i),ut(e,{x:t[2].x,y:t[2].y},i),ut(e,{x:t[3].x,y:t[3].y},i)]}function yt(e){if(!(e>0||e<0)||0===e||360===e)return 0;let t=e%360;return t<0?t+=360:360===e&&(t=0),t}function pt(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=pt(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.children))}))}return t}function wt(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=vt(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),l=Math.max(t.x+t.w,i.x+i.w),a=Math.max(t.y+t.h,i.y+i.h);i.x=o,i.y=n,i.w=Math.abs(l-o),i.h=Math.abs(a-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 xt(e,t){var i;const o=[];let n=e;if(t.length>1)for(let e=0;e<t.length-1;e++){const l=n[t[e]];if("group"!==(null==l?void 0:l.type)||!Array.isArray(null===(i=null==l?void 0:l.detail)||void 0===i?void 0:i.children))return null;o.push(l),n=l.detail.children}return o}function St(e){const{x:t,y:i,w:o,h:n,angle:l}=e;return{x:t,y:i,w:o,h:n,angle:l}}function bt(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"===(null==n?void 0:n.type))o=n.detail.children;else{if(t!==e.length-1)break;i=n}}return i}function At(e,t){const i=[];let o=!1;const n=t=>{var l;for(let a=0;a<t.length&&!0!==o;a++){i.push(a);const r=t[a];if(r.uuid===e){o=!0;break}if("group"===r.type&&n((null===(l=null==r?void 0:r.detail)||void 0===l?void 0:l.children)||[]),o)break;i.pop()}};return n(t),i}function It(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 Mt(e){const{x:t,y:i,w:o,h:n,angle:l=0}=e;return 0===l?It(e):gt(e,ht({x:t,y:i,w:o,h:n}),l)}function zt(e){const t=[];let i=0,o=0;const n=[],l=[...e];for(let e=0;e<l.length;e++){const{x:a,y:r,w:s,h:h,angle:c=0}=l[e];let d;if(i+=a,o+=r,0===e){const e={x:i,y:o,w:s,h:h};d=Mt({x:a,y:r,w:s,h:h,angle:c}),n.push({center:ht(e),angle:c,radian:at(c)})}else{d=It({x:i,y:o,w:s,h:h});for(let e=0;e<n.length;e++){const{center:t,radian:i}=n[e];d=mt(t,d,i)}const e=ct(d);if(c>0||c<0){d=mt(e,d,at(c))}n.push({center:e,angle:c,radian:at(c)})}t.push(d)}return t}function Rt(e,t){const i=function(e,t){const{groupQueue:i}=t;return i.length>0?zt([...i,e]):[Mt(e)]}(e,t);return i.pop()||null}function Ct(e,t){const{viewScaleInfo:i}=t,{x:o,y:n,w:l,h:a,angle:r}=e,{scale:s,offsetTop:h,offsetLeft:c}=i;return{x:o*s+c,y:n*s+h,w:l*s,h:a*s,angle:r}}function Tt(e,t){const{viewScaleInfo:i}=t,{x:o,y:n}=e,{scale:l,offsetTop:a,offsetLeft:r}=i;return{x:o*l+r,y:n*l+a}}function Pt(e,t){return[Tt(e[0],t),Tt(e[1],t),Tt(e[2],t),Tt(e[3],t)]}function Et(e,t){const{context2d:i,element:o,viewScaleInfo:n}=t,{angle:l=0}=o,{x:a,y:r,w:s,h:h}=Ct(o,{viewScaleInfo:n}),c=vt({x:a,y:r,w:s,h:h,angle:l});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 Lt(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],l=Math.min(...o),a=Math.max(...o),r=Math.min(...n),s=Math.max(...n);return e.x>l&&e.x<a&&e.y>r&&e.y<s}function kt(e,t){const{groupQueue:i}=t,o=Rt(e,{groupQueue:i}),n=$e(o[0],o[1]),l=$e(o[1],o[2]),a=$e(o[2],o[3]),r=$e(o[3],o[0]),s=o[0],h=o[1],c=o[2],d=o[3],u=Math.max(s.x,h.x,c.x,d.x),f=Math.max(s.y,h.y,c.y,d.y);return{center:{x:(u+Math.min(s.x,h.x,c.x,d.x))/2,y:(f+Math.min(s.y,h.y,c.y,d.y))/2},topLeft:s,topRight:h,bottomLeft:d,bottomRight:c,top:n,right:l,left:r,bottom:a}}function Ot(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),l={x:e.center.x,y:e.center.y},a={x:o,y:n},r={x:t,y:n},s={x:t,y:i},h={x:o,y:i},c=$e(a,r),d=$e(h,s),u=$e(a,h);return{center:l,topLeft:a,topRight:r,bottomLeft:h,bottomRight:s,top:c,right:$e(r,s),left:u,bottom:d}}function Wt(e,t){const{x:i,y:o}=e,{size:n,angle:l}=t;return{x:i-n/2,y:o-n/2,w:n,h:n,angle:l}}function Dt(e,t){const{groupQueue:i,controllerSize:o,viewScaleInfo:n,rotateControllerSize:l,rotateControllerPosition:a}=t,r=(o&&o>0?o:8)/n.scale,{x:s,y:h,w:c,h:d,angle:u=0}=e,f=l,g=a,v=[{uuid:Ie(),x:s,y:h,w:c,h:d,angle:u,type:"group",detail:{children:[]}},...i];let m=0;v.forEach((({angle:e=0})=>{m+=e}));const y=Rt(e,{groupQueue:i}),p=Rt({x:s,y:h-(g+f/2)/n.scale,h:d+(2*g+f)/n.scale,w:c,angle:u},{groupQueue:[...i]}),w=$e(y[0],y[1]),x=$e(y[1],y[2]),S=$e(y[2],y[3]),b=$e(y[3],y[0]),A=y[0],I=y[1],M=y[2],z=y[3],R=Wt(w,{size:r,angle:m}),C=Wt(x,{size:r,angle:m}),T=Wt(S,{size:r,angle:m}),P=Wt(b,{size:r,angle:m}),E=Wt(A,{size:r,angle:m}),L=Wt(I,{size:r,angle:m}),k=Wt(z,{size:r,angle:m}),O=Wt(M,{size:r,angle:m}),W=Mt(E),D=Mt(L),j=Mt(k),Y=Mt(O),N=[W[1],D[0],D[3],W[2]],B=[D[3],D[2],Y[1],Y[0]],F=[j[1],Y[0],Y[3],j[2]],G=[W[3],W[2],j[1],j[0]],V=Mt(R),X=Mt(C),H=Mt(T),Z=Mt(P),Q=$e(p[0],p[1]),U=Mt(Wt(Q,{size:1.1*l/n.scale,angle:m}));return{originalElementCenter:ht(e),originalElementSize:Object.assign({},e),elementWrapper:y,left:{type:"left",vertexes:G,center:b,size:r},right:{type:"right",vertexes:B,center:x,size:r},top:{type:"top",vertexes:N,center:w,size:r},bottom:{type:"bottom",vertexes:F,center:S,size:r},topLeft:{type:"top-left",vertexes:W,center:A,size:r},topRight:{type:"top-right",vertexes:D,center:I,size:r},bottomLeft:{type:"bottom-left",vertexes:j,center:z,size:r},bottomRight:{type:"bottom-right",vertexes:Y,center:M,size:r},leftMiddle:{type:"left-middle",vertexes:Z,center:b,size:r},rightMiddle:{type:"right-middle",vertexes:X,center:x,size:r},topMiddle:{type:"top-middle",vertexes:V,center:w,size:r},bottomMiddle:{type:"bottom-middle",vertexes:H,center:S,size:r},rotate:{type:"rotate",vertexes:U,center:Q,size:l}}}function jt(e,t){const{controllerSize:i,viewScaleInfo:o}=t,n=i&&i>0?i:8,{x:l,y:a,w:r,h:s}=Ct(e,{viewScaleInfo:o}),h=ht({x:l,y:a,w:r,h:s}),c={x:h.x,y:a},d={x:l+r,y:h.y},u={x:h.x,y:a+s},f={x:l,y:h.y},g={x:l,y:a},v={x:l+r,y:a},m={x:l+r,y:a+s},y={x:l,y:a+s},p=Wt(c,{size:n,angle:0}),w=Wt(d,{size:n,angle:0}),x=Wt(u,{size:n,angle:0}),S=Wt(f,{size:n,angle:0}),b=Wt(g,{size:n,angle:0}),A=Wt(v,{size:n,angle:0}),I=Wt(y,{size:n,angle:0}),M=Wt(m,{size:n,angle:0}),z=Mt(b),R=Mt(A),C=Mt(I),T=Mt(M),P=[z[1],R[0],R[3],z[2]],E=[R[3],R[2],T[1],T[0]],L=[C[1],T[0],T[3],C[2]],k=[z[3],z[2],C[1],C[0]],O=Mt(p),W=Mt(w),D=Mt(x);return{left:{type:"left",vertexes:k,center:f,size:n},right:{type:"right",vertexes:E,center:d,size:n},top:{type:"top",vertexes:P,center:c,size:n},bottom:{type:"bottom",vertexes:L,center:u,size:n},topLeft:{type:"top-left",vertexes:z,center:g,size:n},topRight:{type:"top-right",vertexes:R,center:v,size:n},bottomLeft:{type:"bottom-left",vertexes:C,center:y,size:n},bottomRight:{type:"bottom-right",vertexes:T,center:m,size:n},leftMiddle:{type:"left-middle",vertexes:Mt(S),center:f,size:n},rightMiddle:{type:"right-middle",vertexes:W,center:d,size:n},topMiddle:{type:"top-middle",vertexes:O,center:c,size:n},bottomMiddle:{type:"bottom-middle",vertexes:D,center:u,size:n}}}function Yt(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}function Nt(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))}Ke=new WeakMap,qe=new WeakMap,_e=new WeakMap,Je=new WeakSet,et=function(){return ze(it(this,qe,"f"))};const Bt="Text Element";const 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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function Gt(e,t){const{viewScaleInfo:i}=t,{scale:o}=i;let{borderRadius:n}=e.detail;const{borderDash:l}=e.detail,a=Array.isArray(l)&&l.length>0,{boxSizing:r=Ft.boxSizing,borderWidth:s}=e.detail;Array.isArray(s)&&(n=0);let{x:h,y:c,w:d,h:u}=e,f=[0,0,0,0];if("number"==typeof n){const e=n*o;f=[e,e,e,e]}else Array.isArray(n)&&4===(null==n?void 0:n.length)&&(f=[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"!==r||a?"content-box"===r?(h=e.x-g/2,c=e.y-g/2,d=e.w+g,u=e.h+g):(h=e.x,c=e.y,d=e.w,u=e.h):(h=e.x+g/2,c=e.y+g/2,d=e.w-g,u=e.h-g),d=Math.max(d,1),u=Math.max(u,1),f=f.map((e=>Math.min(e,d/2,u/2))),{x:h,y:c,w:d,h:u,radiusList:f}}function Vt(e,t="",i={},o){return Object.keys(e).forEach((n=>{var l;const a=t?`${t}${function(e){return/^\d+$/.test(e)&&!isNaN(Number(e))}(n)?`[${n}]`:`.${n}`}`:n;if(!(null===(l=null==o?void 0:o.ignorePaths)||void 0===l?void 0:l.includes(a))){const t=e[n];!function(e){return"object"==typeof e&&null!==e&&!(e instanceof Date)||Array.isArray(e)}(t)?i[a]=t:Vt(t,(Array.isArray(t),a),i,o)}})),i}function Xt(e,t){return"object"!=typeof e||null===e?{"":e}:Vt(e,"",{},t)}function Ht(e){return Xt(e,{ignorePaths:["detail.children"]})}function Zt(e){return Xt(e)}function Qt(e){return Xt(e)}function Ut(e){return Array.isArray(e)?[...e]:e.split(/\.|\[|\]/).filter((e=>""!==e))}function $t(e,t,i){if(!t)return;const o=Ut(t);let n=e;for(const e of o){if(null==n)return i;n=n[e]}return void 0!==n?n:i}function Jt(e,t,i){const o=Ut(t);if(0===o.length)return e;let n=e;if(n)for(let e=0;e<o.length;e++){const t=o[e];if(e===o.length-1){n[t]=i;break}if(n&&(void 0===(null==n?void 0:n[t])||"object"!=typeof(null==n?void 0:n[t])||null===(null==n?void 0:n[t]))){const i=o[e+1],l=/^\d+$/.test(i);n[t]=l?[]:{}}n=null==n?void 0:n[t]}return e}function Kt(e,t){const i=Ut(t);if(0===i.length)return e;let o=e;if(o)for(let e=0;e<i.length;e++){const t=i[e];if(e===i.length-1){delete o[t];break}if(o&&(void 0===(null==o?void 0:o[t])||"object"!=typeof(null==o?void 0:o[t])||null===(null==o?void 0:o[t]))){const n=i[e+1],l=/^\d+$/.test(n);o[t]=l?[]:{}}o=null==o?void 0:o[t]}return e}const qt=e=>Nt(e,{decimalPlaces:4});function _t(e,t){const{detail:i}=e,{xRatio:o,yRatio:n,maxRatio:l}=t,a=(o+n)/2,{borderWidth:r,borderRadius:s,borderDash:h,shadowOffsetX:c,shadowOffsetY:d,shadowBlur:u}=i;if("number"==typeof r)i.borderWidth=qt(r*a);else if(Array.isArray(i.borderWidth)){const e=r;i.borderWidth=[qt(e[0]*n),qt(e[1]*o),qt(e[2]*n),qt(e[3]*o)]}if("number"==typeof s)i.borderRadius=qt(s*a);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]=qt(e*l)})),"number"==typeof c&&(i.shadowOffsetX=qt(c*l)),"number"==typeof d&&(i.shadowOffsetX=qt(d*l)),"number"==typeof u&&(i.shadowOffsetX=qt(u*l))}function ei(e,t){const{type:i}=e;!function(e,t){const{xRatio:i,yRatio:o}=t,{x:n,y:l,w:a,h:r}=e;e.x=qt(n*i),e.y=qt(l*o),e.w=qt(a*i),e.h=qt(r*o),_t(e,t)}(e,t),"circle"===i||("text"===i?function(e,t){const{minRatio:i,maxRatio:o}=t,{fontSize:n,lineHeight:l}=e.detail,a=(i+o)/2;n&&n>0&&(e.detail.fontSize=qt(n*a)),l&&l>0&&(e.detail.lineHeight=qt(l*a))}(e,t):"image"===i||"svg"===i||"html"===i||"path"===i||"group"===i&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{ei(e,t)})))}function ti(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,l=o/e.h;if(n===l&&1===n)return e;const a=Math.min(n,l),r=Math.max(n,l);e.w=i,e.h=o;const s={xRatio:n,yRatio:l,minRatio:a,maxRatio:r};return"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{ei(e,s)})),_t(e,s),e}function ii(e,t,i){const o=function(e,t){let i=0,o=0,n=200,l=200;if(t){const{viewScaleInfo:a,viewSizeInfo:r}=t,{scale:s,offsetLeft:h,offsetTop:c}=a,{width:d,height:u}=r,f=d/4,g=u/4;n=200>=f?f/s:200/s,l=200>=g?g/s:200/s,["circle","svg","image"].includes(e)?n=l=Math.max(n,l):"text"===e&&(l=n/12*2),i=(0-h+d/2-n*s/2)/s,o=(0-c+u/2-l*s/2)/s}return{x:i,y:o,w:n,h:l}}(e,i);let n={};"rect"===e?n={background:"#D9D9D9"}:"circle"===e?n={background:"#D9D9D9",radius:0}:"text"===e?n=function(e){const t={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"};return{text:Bt,color:t.color,fontFamily:t.fontFamily,fontWeight:t.fontWeight,lineHeight:e.w/12,fontSize:e.w/12,textAlign:"center",verticalAlign:"middle"}}(o):"svg"===e?n={svg:'<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="#2c2c2c"></path></svg>'}:"image"===e?n={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===e&&(n={children:[],background:"#D9D9D9",overflow:"hidden"});return Object.assign(Object.assign(Object.assign({uuid:Ie()},o),t),{type:e,detail:Object.assign(Object.assign({},n),t.detail||{})})}function oi(e,t,i){let o=!1;if(1===t.length){const n=t[0];i.splice(n,0,e),o=!0}else if(t.length>1){let n=i;for(let i=0;i<t.length;i++){const l=n[t[i]];if(i===t.length-1){const l=t[i];n.splice(l,0,e),o=!0}else{if(!(i<t.length-1&&"group"===l.type))break;n=l.detail.children}}}return o}function ni(e,t){let i=!1;if(1===e.length){const o=e[0];t.splice(o,1),i=!0}else if(e.length>1){let o=t;for(let t=0;t<e.length;t++){const n=o[e[t]];if(t===e.length-1){const n=e[t];o.splice(n,1),i=!0}else{if(!(t<e.length-1&&"group"===n.type))break;o=n.detail.children}}}return i}function li(e,t,i){const o=Ht(t),n=["uuid","type"],l=Object.keys(o);if(l.forEach((t=>{if(!n.includes(t)){const i=o[t];Kt(e,t),void 0!==i&&Jt(e,t,i)}})),!0===(null==i?void 0:i.strict)){const t=Ht(e);Object.keys(t).forEach((t=>{n.includes(t)||l.includes(t)||Kt(e,t)}))}return e}function ai(e,t,i){var o,n;let l=null;for(let a=0;a<i.length;a++){const r=i[a];if(r.uuid===e){"group"===r.type&&!0===(null===(o=r.operations)||void 0===o?void 0:o.deepResize)&&(t.w&&t.w>0||t.h&&t.h>0)&&ti(r,{w:t.w,h:t.h}),li(r,t),l=r;break}"group"===r.type&&(l=ai(e,t,(null===(n=null==r?void 0:r.detail)||void 0===n?void 0:n.children)||[]))}return l}function ri(e,t,i,o){var n;const l=bt(e,i);return l&&("group"===l.type&&!0===(null===(n=l.operations)||void 0===n?void 0:n.deepResize)&&(t.w&&t.w>0||t.h&&t.h>0)&&ti(l,{w:t.w,h:t.h}),li(l,t,o)),l}const si=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function hi(e){return[e,...si].join(", ")}function ci(e,t,i){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:n,opacity:l=1}=i,{x:a,y:r}=o,{scale:s}=n;if("linear-gradient"===(null==t?void 0:t.type)){const{start:i,end:o,stops:n}=t,h={x:a+i.x*s,y:r+i.y*s},c={x:a+o.x*s,y:r+o.y*s},d=e.createLinearGradient(h.x,h.y,c.x,c.y);return n.forEach((e=>{d.addColorStop(e.offset,be(e.color,l))})),d}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:i,outer:o,stops:n}=t,h={x:a+i.x*s,y:r+i.y*s,radius:i.radius*s},c={x:a+o.x*s,y:r+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,be(e.color,l))})),d}return"#000000"}const di={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 ui(e){var t,i,o,n;let l=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&&(l=null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.opacity),l}function fi(e,t,i){const{pattern:o,renderContent:n,originElem:l,calcElemSize:a,viewScaleInfo:r,viewSizeInfo:s}=i||{},{parentOpacity:h}=i,c=ui(l)*h,{clipPath:d,clipPathStrokeColor:u,clipPathStrokeWidth:f}=l.detail,g=()=>{e.globalAlpha=c,gi(e,t,{pattern:o,viewScaleInfo:r,viewSizeInfo:s}),null==n||n(),vi(e,t,{viewScaleInfo:r}),e.globalAlpha=h};d?(function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:l,viewSizeInfo:a}=i,r=a.devicePixelRatio,{clipPath:s}=(null==n?void 0:n.detail)||{};if(s&&l&&s.commands){const{x:i,y:n,w:a,h:h}=l,{originW:c,originH:d,originX:u,originY:f}=s,g=a/c,v=h/d,m=i-u*g,y=n-f*v;e.save(),e.translate(m,y),e.scale(r*g,r*v);const p=Yt(s.commands||[]),w=new Path2D(p);e.clip(w,"nonzero"),e.translate(0-m,0-y),e.setTransform(1,0,0,1,0,0),st(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:l,calcElemSize:a,viewSizeInfo:s,renderContent:()=>{g()}}),"number"==typeof f&&f>0&&u&&function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:l,viewSizeInfo:a,parentOpacity:r}=i,s=a.devicePixelRatio,{clipPath:h,clipPathStrokeColor:c,clipPathStrokeWidth:d}=(null==n?void 0:n.detail)||{};if(h&&l&&h.commands&&"number"==typeof d&&d>0&&c){const{x:i,y:n,w:a,h:u}=l,{originW:f,originH:g,originX:v,originY:m}=h,y=a/f,p=u/g,w=i-v*y,x=n-m*p;e.save(),e.globalAlpha=r,e.translate(w,x),e.scale(s*y,s*p);const S=Yt(h.commands||[]),b=new Path2D(S);e.strokeStyle=c,e.lineWidth=d,e.stroke(b),e.translate(0-w,0-x),e.setTransform(1,0,0,1,0,0),st(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:l,calcElemSize:a,viewSizeInfo:s,parentOpacity:h})):g()}function gi(e,t,i){var o,n;const{pattern:l,viewScaleInfo:a,viewSizeInfo:r}=i,s=[];if(t.detail.background||l){const{x:i,y:r,w:h,h:c,radiusList:d}=Gt(t,{viewScaleInfo:a});if(e.beginPath(),e.moveTo(i+d[0],r),e.arcTo(i+h,r,i+h,r+c,d[1]),e.arcTo(i+h,r+c,i,r+c,d[2]),e.arcTo(i,r+c,i,r,d[3]),e.arcTo(i,r,i+h,r,d[0]),e.closePath(),"string"==typeof l)e.fillStyle=l;else if(["CanvasPattern"].includes(Ce.type(l)))e.fillStyle=l;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=ci(e,t.detail.background,{viewElementSize:{x:i,y:r,w:h,h:c},viewScaleInfo:a,opacity:e.globalAlpha});e.fillStyle=o}else if("radial-gradient"===(null===(n=t.detail.background)||void 0===n?void 0:n.type)){const o=ci(e,t.detail.background,{viewElementSize:{x:i,y:r,w:h,h:c},viewScaleInfo:a,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]+r):"rotate"===o.method?e.rotate(...o.args):"scale"===o.method&&e.scale(...o.args)}}e.fill("nonzero"),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function vi(e,t,i){if(0===t.detail.borderWidth)return;if(!Se(t.detail.borderColor))return;const{viewScaleInfo:o}=i,{scale:n}=o;let l=di.borderColor;!0===Se(t.detail.borderColor)&&(l=t.detail.borderColor);const{borderDash:a,borderWidth:r,borderRadius:s,boxSizing:h=di.boxSizing}=t.detail;let c=[];Array.isArray(a)&&a.length>0&&(c=a.map((e=>Math.ceil(e*n)))),c.length>0?e.lineCap="butt":e.lineCap="square";let d=[0,0,0,0];if("number"==typeof s){const e=s*n;d=[e,e,e,e]}else Array.isArray(s)&&4===(null==s?void 0:s.length)&&(d=[s[0]*n,s[1]*n,s[2]*n,s[3]*n]);let u=0;"number"==typeof r&&(u=r||1),u*=n,e.strokeStyle=l;let f=0,g=0,v=0,m=0;if(Array.isArray(r)&&(f=(r[0]||0)*n,g=(r[1]||0)*n,v=(r[2]||0)*n,m=(r[3]||0)*n),m||g||f||v){e.lineCap="butt";let{x:i,y:o,w:n,h:l}=t;"border-box"===h?(i+=m/2,o+=f/2,n=n-m/2-g/2,l=l-f/2-v/2):"content-box"===h?(i-=m/2,o-=f/2,n=n+m/2+g/2,l=l+f/2+v/2):(i=t.x,o=t.y,n=t.w,l=t.h),f&&(e.beginPath(),e.lineWidth=f,e.moveTo(i-m/2,o),e.lineTo(i+n+g/2,o),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(i+n,o-f/2),e.lineTo(i+n,o+l+v/2),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(i-m/2,o+l),e.lineTo(i+n+g/2,o+l),e.closePath(),e.stroke()),m&&(e.beginPath(),e.lineWidth=m,e.moveTo(i,o-f/2),e.lineTo(i,o+l+v/2),e.closePath(),e.stroke())}else{let{x:i,y:o,w:n,h:l}=t;"border-box"===h?(i=t.x+u/2,o=t.y+u/2,n=t.w-u,l=t.h-u):"content-box"===h?(i=t.x-u/2,o=t.y-u/2,n=t.w+u,l=t.h+u):(i=t.x,o=t.y,n=t.w,l=t.h),n=Math.max(n,1),l=Math.max(l,1),d=d.map((e=>Math.min(e,n/2,l/2))),e.setLineDash(c),e.lineWidth=u,e.beginPath(),e.moveTo(i+d[0],o),e.arcTo(i+n,o,i+n,o+l,d[1]),e.arcTo(i+n,o+l,i,o+l,d[2]),e.arcTo(i,o+l,i,o,d[3]),e.arcTo(i,o,i+n,o,d[0]),e.closePath(),e.stroke()}e.setLineDash([])}function mi(e,t,i){const{detail:o}=t,{viewScaleInfo:n,renderContent:l}=i,{shadowColor:a,shadowOffsetX:r,shadowOffsetY:s,shadowBlur:h}=o;Ye.number(h)?(e.save(),e.shadowColor=a||di.shadowColor,e.shadowOffsetX=(r||0)*n.scale,e.shadowOffsetY=(s||0)*n.scale,e.shadowBlur=(h||0)*n.scale,l(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,l(),e.restore())}const yi={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 pi(e,t,i){var o,n;const{detail:l}=t,{originX:a,originY:r,originW:s,originH:h,fillRule:c}=l,{viewScaleInfo:d,viewSizeInfo:u,parentOpacity:f}=i,{x:g,y:v,w:m,h:y,angle:p}=Ct(t,{viewScaleInfo:d})||t,w=m/s,x=y/h,S=g-a*w,b=v-r*x,A=t.detail,{clipPath:I,clipPathStrokeColor:M,clipPathStrokeWidth:z}=A,R=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}(A,["clipPath","clipPathStrokeColor","clipPathStrokeWidth"]),C=d.scale*u.devicePixelRatio,T=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:y,angle:p});let P=Object.assign({},T);P.detail=R;let E=Object.assign({},t);E.detail=R,l.fill&&"string"!==l.fill&&(null===(n=null===(o=l.fill)||void 0===o?void 0:o.type)||void 0===n?void 0:n.includes("gradient"))&&(P=Object.assign(Object.assign({},T),{detail:Object.assign(Object.assign({},T.detail),{background:l.fill,clipPath:{commands:l.commands,originX:a,originY:r,originW:s,originH:h}})}),E.detail=Object.assign({},P.detail)),st(e,{x:g,y:v,w:m,h:y,angle:p},(()=>{fi(e,P,{originElem:E,calcElemSize:{x:g,y:v,w:m,h:y,angle:p},viewScaleInfo:d,viewSizeInfo:u,parentOpacity:f,renderContent:()=>{mi(e,T,{viewScaleInfo:d,renderContent:()=>{e.save(),e.translate(S,b),e.scale(C*w/d.scale,C*x/d.scale);const t=Yt(l.commands||[]),i=new Path2D(t);l.fill&&("string"==typeof l.fill?e.fillStyle=l.fill:e.fillStyle="transparent"),l.fill&&e.fill(i,c||"nonzero"),l.stroke&&0!==l.strokeWidth&&(e.strokeStyle=l.stroke,e.lineWidth=(l.strokeWidth||1)/u.devicePixelRatio,e.lineCap=l.strokeLineCap||"square",e.stroke(i)),e.translate(-S,-b),e.restore()}})}})}))}function wi(e,t,i){var o,n,l;if(!0===(null===(o=null==t?void 0:t.operations)||void 0===o?void 0:o.invisible))return;const{w:a,h:r}=t,{scale:s}=i.viewScaleInfo;if(s<1&&(a*s<.4||r*s<.4)||0===i.parentOpacity)return;const{overrideElementMap:h}=i;if(!(null===(l=null===(n=null==h?void 0:h[t.uuid])||void 0===n?void 0:n.operations)||void 0===l?void 0:l.invisible))try{switch(t.type){case"rect":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:l}=i,{x:a,y:r,w:s,h:h,angle:c}=Ct(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:a,y:r,w:s,h:h,angle:c});st(e,{x:a,y:r,w:s,h:h,angle:c},(()=>{mi(e,d,{viewScaleInfo:o,renderContent:()=>{fi(e,d,{originElem:t,calcElemSize:{x:a,y:r,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:l,renderContent:()=>{}})}})}))}(e,t,i);break;case"circle":!function(e,t,i){const{detail:o,angle:n}=t,{viewScaleInfo:l,viewSizeInfo:a,parentOpacity:r}=i,{background:s="#000000",borderColor:h="#000000",boxSizing:c,borderWidth:d=0,borderDash:u}=o;let f=0;"number"==typeof d&&d>0?f=d:Array.isArray(d)&&"number"==typeof d[0]&&d[0]>0&&(f=d[0]),f*=l.scale;const{x:g,y:v,w:m,h:y}=Ct({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:l})||t,p=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:y,angle:n});st(e,{x:g,y:v,w:m,h:y,angle:n},(()=>{mi(e,p,{viewScaleInfo:l,renderContent:()=>{let t=m/2,i=y/2;const o=g+t,n=v+i,a=t,d=i;if(f>0&&("content-box"===c||("center-line"===c?(t-=f/2,i-=f/2):(t-=f,i-=f))),t>=0&&i>=0){const c=ui(p)*r;e.globalAlpha=c,e.beginPath();const w=ci(e,s,{viewElementSize:{x:g,y:v,w:m,h:y},viewScaleInfo:l,opacity:e.globalAlpha});if(e.fillStyle=w,e.circle(o,n,a,d,0,0,2*Math.PI),e.closePath(),e.fill("nonzero"),e.globalAlpha=r,"number"==typeof f&&f>0){const a=f/2+t,r=f/2+i;if(e.beginPath(),u){const t=u.map((e=>e*l.scale));e.setLineDash(t)}e.strokeStyle=h,e.lineWidth=f,e.circle(o,n,a,r,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:l,calculator:a}=i,{x:r,y:s,w:h,h:c,angle:d}=Ct(t,{viewScaleInfo:o})||t,u=Object.assign(Object.assign({},t),{x:r,y:s,w:h,h:c,angle:d});st(e,{x:r,y:s,w:h,h:c,angle:d},(()=>{var i,f;mi(e,u,{viewScaleInfo:o,renderContent:()=>{fi(e,u,{originElem:t,calcElemSize:{x:r,y:s,w:h,h:c,angle:d},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:l})}});{const n=Object.assign(Object.assign({},yi),t.detail),l=(n.fontSize||yi.fontSize)*o.scale;if(l<2)return;e.fillStyle=t.detail.color||yi.color,e.textBaseline="top",e.$setFont({fontWeight:n.fontWeight,fontSize:l,fontFamily:hi(n.fontFamily)});{const l=a.getVirtualFlatItem(t.uuid);Array.isArray(null==l?void 0:l.textLines)&&(null===(i=null==l?void 0:l.textLines)||void 0===i?void 0:i.length)>0&&(void 0!==n.textShadowColor&&Se(n.textShadowColor)&&(e.shadowColor=n.textShadowColor),void 0!==n.textShadowOffsetX&&Ye.number(n.textShadowOffsetX)&&(e.shadowOffsetX=n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&Ye.number(n.textShadowOffsetY)&&(e.shadowOffsetY=n.textShadowOffsetY),void 0!==n.textShadowBlur&&Ye.number(n.textShadowBlur)&&(e.shadowBlur=n.textShadowBlur),null===(f=null==l?void 0:l.textLines)||void 0===f||f.forEach((t=>{e.fillText(t.text,r+t.x*o.scale,s+t.y*o.scale)})))}}}))}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:l,parentOpacity:a}=i,{x:r,y:s,w:h,h:c,angle:d}=Ct(t,{viewScaleInfo:n})||t,u=Object.assign(Object.assign({},t),{x:r,y:s,w:h,h:c,angle:d});st(e,{x:r,y:s,w:h,h:c,angle:d},(()=>{mi(e,u,{viewScaleInfo:n,renderContent:()=>{fi(e,u,{originElem:t,calcElemSize:{x:r,y:s,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:l,parentOpacity:a,renderContent:()=>{if(o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"image"===t.type&&o){e.globalAlpha=ui(t)*a;const{x:i,y:l,w:r,h:s,radiusList:h}=Gt(u,{viewScaleInfo:n}),{detail:c}=t,{scaleMode:d,originW:f=0,originH:g=0}=c,v=e.$undoPixelRatio(f),m=e.$undoPixelRatio(g);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+h[0],l),e.arcTo(i+r,l,i+r,l+s,h[1]),e.arcTo(i+r,l+s,i,l+s,h[2]),e.arcTo(i,l+s,i,l,h[3]),e.arcTo(i,l,i+r,l,h[0]),e.closePath(),e.fill("nonzero"),e.clip("nonzero"),d&&g&&f){let n=0,a=0,h=v,c=m;const u=i,f=l,g=r,y=s;if(v>t.w||m>t.h)if("fill"===d){const e=Math.max(t.w/v,t.h/m),i=m*e;n=(v*e-t.w)/2/e,a=(i-t.h)/2/e,h=t.w/e,c=t.h/e}else if("tile"===d)n=0,a=0,h=t.w,c=t.h;else if("fit"===d){const e=Math.min(t.w/v,t.h/m);n=(v-t.w/e)/2,a=(m-t.h/e)/2,h=t.w/e,c=t.h/e}e.drawImage(o,n,a,h,c,u,f,g,y)}else e.drawImage(o,i,l,r,s);e.globalAlpha=a,e.restore()}}})}})}))}(e,t,i);break;case"svg":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:l,parentOpacity:a}=i,{x:r,y:s,w:h,h:c,angle:d}=Ct(t,{viewScaleInfo:n})||t;st(e,{x:r,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"svg"===t.type&&o&&(e.globalAlpha=ui(t)*a,e.drawImage(o,r,s,h,c),e.globalAlpha=a)}))}(e,t,i);break;case"html":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:l,parentOpacity:a}=i,{x:r,y:s,w:h,h:c,angle:d}=Ct(t,{viewScaleInfo:n})||t;st(e,{x:r,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"html"===t.type&&o&&(e.globalAlpha=ui(t)*a,e.drawImage(o,r,s,h,c),e.globalAlpha=a)}))}(e,t,i);break;case"path":pi(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:l}=i,{x:a,y:r,w:s,h:h,angle:c}=Ct({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:a,y:r,w:s,h:h,angle:c});st(e,{x:a,y:r,w:s,h:h,angle:c},(()=>{e.globalAlpha=ui(t)*l,mi(e,d,{viewScaleInfo:o,renderContent:()=>{fi(e,d,{originElem:t,calcElemSize:{x:a,y:r,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:l,renderContent:()=>{const{x:n,y:a,w:r,h:s,radiusList:h}=Gt(d,{viewScaleInfo:o});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+h[0],a),e.arcTo(n+r,a,n+r,a+s,h[1]),e.arcTo(n+r,a+s,n,a+s,h[2]),e.arcTo(n,a+s,n,a,h[3]),e.arcTo(n,a,n+r,a,h[0]),e.closePath(),e.fill("nonzero"),e.clip("nonzero")),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 r=t.detail.children[o];if(r=Object.assign(Object.assign({},r),{x:n.x+r.x,y:n.y+r.y}),!0===i.forceDrawAll||(null==a?void 0:a.needRender(r)))try{wi(e,r,Object.assign(Object.assign({},i),{parentOpacity:l*ui(t)}))}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=l}))}(e,t,Object.assign(Object.assign({},i),{elementAssets:o}));break}}}catch(e){console.error(e)}}const xi={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 Si(e,t,i){var o;const{elements:n=[]}=t,{parentOpacity:l}=i;for(let t=0;t<n.length;t++){const a=n[t],r=Object.assign(Object.assign({},a),{detail:Object.assign(Object.assign({},xi),null==a?void 0:a.detail)});if(!0===i.forceDrawAll||(null===(o=i.calculator)||void 0===o?void 0:o.needRender(r)))try{wi(e,r,Object.assign(Object.assign({},i),{parentOpacity:l}))}catch(e){console.error(e)}}}var bi,Ai,Ii,Mi,zi,Ri,Ci,Ti,Pi,Ei,Li,ki,Oi=function(e,t,i,o){return new(i||(i=Promise))((function(n,l){function a(e){try{s(o.next(e))}catch(e){l(e)}}function r(e){try{s(o.throw(e))}catch(e){l(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(a,r)}s((o=o.apply(e,t||[])).next())}))},Wi=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)},Di=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i};const ji=["image","svg","html"],Yi=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-]{0,}$/.test(`${n}`)?n:Me(n):Me(`${Ie()}-${e.uuid}-${Ie()}-${Ie()}`)};class Ni extends Ue{constructor(){super(),bi.add(this),Ai.set(this,{}),Ii.set(this,{}),Mi.set(this,{}),zi.set(this,!1),Wi(this,bi,"m",Ri).call(this,"image",((e,t)=>Oi(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 Ee(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),Wi(this,bi,"m",Ri).call(this,"html",((e,t)=>Oi(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 ke(o,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),Wi(this,bi,"m",Ri).call(this,"svg",((e,t)=>Oi(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 Le(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}}))))}isDestroyed(){return Wi(this,zi,"f")}destroy(){Di(this,zi,!0,"f"),this.clear(),Di(this,Ai,null,"f"),Di(this,Ii,null,"f"),Di(this,Mi,null,"f")}load(e,t){!0!==Wi(this,zi,"f")&&(Wi(this,bi,"m",ki).call(this,e)||ji.includes(e.type)&&Wi(this,bi,"m",Li).call(this,e,t))}getContent(e){var t,i;const o=Yi(e);return(null===(i=null===(t=Wi(this,Mi,"f"))||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return Wi(this,Mi,"f")}setLoadItemMap(e){Di(this,Mi,e,"f")}}Ai=new WeakMap,Ii=new WeakMap,Mi=new WeakMap,zi=new WeakMap,bi=new WeakSet,Ri=function(e,t){Wi(this,Ai,"f")[e]=t},Ci=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},Ti=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:Wi(this,bi,"m",Ci).call(this,e)}},Pi=function(e){const t=Yi(e.element),i=Wi(this,Mi,"f")[t];Wi(this,zi,"f")||(i?i.startTime<e.startTime&&(Wi(this,Mi,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(Wi(this,Mi,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},Ei=function(e){var t;const i=Yi(e.element),o=null===(t=Wi(this,Mi,"f"))||void 0===t?void 0:t[i];Wi(this,zi,"f")||(o?o.startTime<e.startTime&&(Wi(this,Mi,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(Wi(this,Mi,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},Li=function(e,t){const i=Wi(this,bi,"m",Ti).call(this,e),o=Yi(e);if(Wi(this,Ii,"f")[o])return;Wi(this,Ii,"f")[o]=i;const n=Wi(this,Ai,"f")[e.type];"function"!=typeof n||Wi(this,zi,"f")||(i.startTime=Date.now(),n(e,t).then((e=>{Wi(this,zi,"f")||(i.content=e.content,i.endTime=Date.now(),i.status="load",Wi(this,bi,"m",Pi).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,Wi(this,bi,"m",Ei).call(this,i)})))},ki=function(e){var t;const i=Yi(e),o=null===(t=Wi(this,Ii,"f"))||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==Wi(this,bi,"m",Ci).call(this,e))};const Bi={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 Fi(e,t){const{w:i,h:o}=e,n=t.tempContext,l=[],a=Object.assign(Object.assign({},Bi),e.detail),r=a.fontSize||Bi.fontSize,s=r;if(s<2)return{};const h=a.lineHeight||r;n.textBaseline="top",n.$setFont({fontWeight:a.fontWeight,fontSize:s,fontFamily:hi(a.fontFamily)});let c=a.text.replace(/\r\n/gi,"\n");"lowercase"===a.textTransform?c=c.toLowerCase():"uppercase"===a.textTransform&&(c=c.toUpperCase());const d=h,u=c.split("\n");let f=0;u.forEach(((e,t)=>{if("maxContent"===a.minInlineSize)l.push({x:0,y:0,text:e,width:n.$undoPixelRatio(n.measureText(e).width)});else{let h="",c="",g=e.split(c);if("normal"===a.wordBreak){c=" ";const t=e.split(c);g=[],t.forEach(((e,i)=>{g.push(e),i<t.length-1&&g.push(c)}))}if(1===g.length&&"visible"===a.overflow)l.push({x:0,y:0,text:g[0],width:n.$undoPixelRatio(n.measureText(g[0]).width)});else if(g.length>0){for(let e=0;e<g.length&&(r=n.$doPixelRatio(i),s=n.measureText(h+g[e]).width,r>=s?h+=g[e]||"":(l.push({x:0,y:0,text:h,width:n.$undoPixelRatio(n.measureText(h).width)}),h=g[e]||"",f++),!((f+1)*d>o&&"hidden"===a.overflow));e++)if(g.length-1===e&&(f+1)*d<=o){l.push({x:0,y:0,text:h,width:n.$undoPixelRatio(n.measureText(h).width)}),t<u.length-1&&f++;break}}else l.push({x:0,y:0,text:"",width:0})}var r,s}));let g=0,v=0;d>s&&(v=(d-s)/2),l.length*d<o&&("top"===a.verticalAlign?g=0:"bottom"===a.verticalAlign?g+=o-l.length*d:g+=(o-l.length*d)/2);{const e=0+g;l.forEach(((t,o)=>{let n=0;"center"===a.textAlign?n=0+(i-t.width)/2:"right"===a.textAlign&&(n=i-t.width+0),l[o].x=n,l[o].y=e+d*o+v}))}return{textLines:l}}function Gi(e,t){let i={};return"text"===e.type&&(i=Fi(e,t)),i}function Vi(e,t){const{viewScaleInfo:i,viewSizeInfo:o,tempContext:n}=t,l=function(e,t){const i={},o=[],n=l=>{const a={type:l.type,isVisibleInView:!0,position:[...o]};let r=null;r=kt(l,{groupQueue:xt(e,o)||[]});const s=Object.assign(Object.assign(Object.assign({},a),{originRectInfo:r,rangeRectInfo:Ye.angle(l.angle)?Ot(r):r}),Gi(l,t));i[l.uuid]=s,"group"===l.type&&l.detail.children.forEach(((e,t)=>{o.push(t),n(e),o.pop()}))};return e.forEach(((e,t)=>{o.push(t),n(e),o.pop()})),i}(e,{tempContext:n});return Xi(l,{viewScaleInfo:i,viewSizeInfo:o})}function Xi(e,t){const i=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n,offsetLeft:l}=t,{width:a,height:r}=i,s=0-l/o,h=0-n/o,c=a/o,d=r/o,u=ht({x:s,y:h,w:c,h:d}),f={x:s,y:h},g={x:s+c,y:h},v={x:s,y:h+d},m={x:s+c,y:h+d},y={x:s,y:u.y},p={x:u.x,y:h},w={x:s+c,y:u.y},x={x:u.x,y:h+d};return{center:u,topLeft:f,topRight:g,bottomLeft:v,bottomRight:m,left:y,top:p,right:w,bottom:x}}(t);let o=0,n=0;return Object.keys(e).forEach((t=>{const l=e[t];l.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),l=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),a=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),r=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<=r&&o>=a&&n<=h&&l>=s||r<=l&&r>=l&&r<=l&&r>=l}(l.rangeRectInfo,i),l.isVisibleInView?o++:n++})),{virtualFlatItemMap:e,visibleCount:o,invisibleCount:n}}var Hi,Zi,Qi=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Ui=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 $i{constructor(e){Hi.set(this,void 0),Zi.set(this,void 0),Qi(this,Hi,e,"f"),Qi(this,Zi,new ot({defaultStorage:{virtualFlatItemMap:{},visibleCount:0,invisibleCount:0}}),"f")}toGridNum(e,t){return!0===(null==t?void 0:t.ignore)?e:Math.round(e)}destroy(){Qi(this,Hi,null,"f")}needRender(e){const t=Ui(this,Zi,"f").get("virtualFlatItemMap")[e.uuid];return!t||t.isVisibleInView}getPointElement(e,t){const i=Ui(this,Hi,"f").tempContext;return function(e,t){var i,o,n;const{context2d:l,data:a,viewScaleInfo:r,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,a=0,s=0;for(let e=0;e<=t;e++)n+=h[e].x,a+=h[e].y,s+=h[e].angle||0;const d=h[t];if(d&&"group"===d.type&&Array.isArray(null===(i=d.detail)||void 0===i?void 0:i.children))for(let i=0;i<d.detail.children.length;i++){const u=d.detail.children[i];if(!0!==(null===(o=null==u?void 0:u.operations)||void 0===o?void 0:o.invisible)){if(!u)break;if(Et(e,{context2d:l,element:{x:n+u.x,y:a+u.y,w:u.w,h:u.h,angle:s+(u.angle||0)},viewScaleInfo:r})){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=a.elements.length-1;t>=0;t--){const i=a.elements[t];if(!0!==(null===(n=null==i?void 0:i.operations)||void 0===n?void 0:n.invisible)&&Et(e,{context2d:l,element:i,viewScaleInfo:r})){c.index=t,c.element=i;break}}return c}(e,Object.assign(Object.assign({},t),{context2d:i}))}resetVirtualFlatItemMap(e,t){if(e){const{virtualFlatItemMap:i,invisibleCount:o,visibleCount:n}=Vi(e.elements,Object.assign(Object.assign({},t),{tempContext:Ui(this,Hi,"f").tempContext}));Ui(this,Zi,"f").set("virtualFlatItemMap",i),Ui(this,Zi,"f").set("invisibleCount",o),Ui(this,Zi,"f").set("visibleCount",n)}}updateVisiableStatus(e){const{virtualFlatItemMap:t,invisibleCount:i,visibleCount:o}=Xi(Ui(this,Zi,"f").get("virtualFlatItemMap"),e);Ui(this,Zi,"f").set("virtualFlatItemMap",t),Ui(this,Zi,"f").set("invisibleCount",i),Ui(this,Zi,"f").set("visibleCount",o)}calcViewRectInfoFromOrigin(e,t){const i=Ui(this,Zi,"f").get("virtualFlatItemMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:l}=t,{center:a,left:r,right:s,bottom:h,top:c,topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=i.originRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n};return{center:Tt(a,v),left:Tt(r,v),right:Tt(s,v),bottom:Tt(h,v),top:Tt(c,v),topLeft:Tt(d,v),topRight:Tt(u,v),bottomLeft:Tt(f,v),bottomRight:Tt(g,v)}}calcViewRectInfoFromRange(e,t){const i=Ui(this,Zi,"f").get("virtualFlatItemMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:l}=t,{center:a,left:r,right:s,bottom:h,top:c,topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=i.rangeRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n};return{center:Tt(a,v),left:Tt(r,v),right:Tt(s,v),bottom:Tt(h,v),top:Tt(c,v),topLeft:Tt(d,v),topRight:Tt(u,v),bottomLeft:Tt(f,v),bottomRight:Tt(g,v)}}modifyText(e){const t=Ui(this,Zi,"f").get("virtualFlatItemMap"),i=t[e.uuid];if(e&&"text"===e.type){const o=Object.assign(Object.assign({},i),Fi(e,{tempContext:Ui(this,Hi,"f").tempContext}));t[e.uuid]=o,Ui(this,Zi,"f").set("virtualFlatItemMap",t)}}modifyVirtualFlatItemMap(e,t){const{modifyInfo:i,viewScaleInfo:o,viewSizeInfo:n}=t,{type:l,content:a}=i,r=e.elements,s=Ui(this,Zi,"f").get("virtualFlatItemMap");if("deleteElement"===l){const{element:e}=a,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]})),Ui(this,Zi,"f").set("virtualFlatItemMap",s)}else if("addElement"===l||"updateElement"===l){const{position:t}=a,i=bt(t,e.elements),h=xt(r,t);if(i)if("updateElement"===l&&"group"===i.type)this.resetVirtualFlatItemMap(e,{viewScaleInfo:o,viewSizeInfo:n});else{const e=kt(i,{groupQueue:h||[]}),a=Object.assign({type:i.type,originRectInfo:e,rangeRectInfo:Ye.angle(i.angle)?Ot(e):e,isVisibleInView:!0,position:[...t]},Gi(i,{tempContext:Ui(this,Hi,"f").tempContext}));s[i.uuid]=a,Ui(this,Zi,"f").set("virtualFlatItemMap",s),"updateElement"===l&&this.updateVisiableStatus({viewScaleInfo:o,viewSizeInfo:n})}}else"moveElement"===l&&this.resetVirtualFlatItemMap(e,{viewScaleInfo:o,viewSizeInfo:n})}getVirtualFlatItem(e){return Ui(this,Zi,"f").get("virtualFlatItemMap")[e]||null}}Hi=new WeakMap,Zi=new WeakMap;var Ji,Ki,qi,_i,eo,to,io=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},oo=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 no extends Ue{constructor(e){super(),Ji.add(this),Ki.set(this,void 0),qi.set(this,new Ni),_i.set(this,void 0),eo.set(this,!1),io(this,Ki,e,"f"),io(this,_i,new $i({tempContext:e.tempContext}),"f"),oo(this,Ji,"m",to).call(this)}isDestroyed(){return oo(this,eo,"f")}destroy(){this.clear(),io(this,Ki,null,"f"),oo(this,qi,"f").destroy(),io(this,qi,null,"f"),io(this,eo,!0,"f")}updateOptions(e){io(this,Ki,e,"f")}drawData(e,t){const i=oo(this,qi,"f"),o=oo(this,_i,"f"),{sharer:n}=oo(this,Ki,"f"),l=oo(this,Ki,"f").viewContext;l.clearRect(0,0,l.canvas.width,l.canvas.height);const a={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height};!0===t.forceDrawAll&&oo(this,_i,"f").resetVirtualFlatItemMap(e,{viewScaleInfo:t.viewScaleInfo,viewSizeInfo:t.viewSizeInfo});const r=Object.assign({loader:i,calculator:o,parentElementSize:a,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:l}=o;e.globalAlpha=1,e.fillStyle=t.background,e.fillRect(0,0,n,l)}}(l,e.global,r),e.layout?function(e,t,i,o){const{viewScaleInfo:n,viewSizeInfo:l,parentOpacity:a}=i,r=Object.assign({uuid:"layout",type:"group"},t),{x:s,y:h,w:c,h:d}=Ct(r,{viewScaleInfo:n})||r,u=Object.assign(Object.assign({},r),{x:s,y:h,w:c,h:d,angle:0});if(e.globalAlpha=1,mi(e,u,{viewScaleInfo:n,renderContent:()=>{gi(e,u,{viewScaleInfo:n,viewSizeInfo:l})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:o,viewSizeInfo:n}=i,l=Object.assign({uuid:"layout",type:"group"},t),a=Ct(l,{viewScaleInfo:o})||l,r=Object.assign(Object.assign({},l),a),{x:s,y:h,w:c,h:d,radiusList:u}=Gt(r,{viewScaleInfo:o});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(s+u[0],h),e.arcTo(s+c,h,s+c,h+d,u[1]),e.arcTo(s+c,h+d,s,h+d,u[2]),e.arcTo(s,h+d,s,h,u[3]),e.arcTo(s,h,s+c,h,u[0]),e.closePath(),e.fill("nonzero"),e.clip("nonzero")}o(e),"hidden"===t.detail.overflow&&e.restore(),vi(e,u,{viewScaleInfo:n}),e.globalAlpha=a}(l,e.layout,r,(()=>{Si(l,e,r)})):Si(l,e,r)}scale(e){const{sharer:t}=oo(this,Ki,"f");if(!t)return;const{data:i,offsetTop:o,offsetBottom:n,offsetLeft:l,offsetRight:a,width:r,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:n,offsetLeft:l,offsetRight:a},viewSizeInfo:{width:r,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){oo(this,qi,"f").setLoadItemMap(e)}getLoadItemMap(){return oo(this,qi,"f").getLoadItemMap()}getLoader(){return oo(this,qi,"f")}getCalculator(){return oo(this,_i,"f")}}function lo(e){return e>0||e<0||0===e}Ki=new WeakMap,qi=new WeakMap,_i=new WeakMap,eo=new WeakMap,Ji=new WeakSet,to=function(){const e=oo(this,qi,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))};class ao extends Ue{constructor(e){super(),pe(this,n),pe(this,t),pe(this,i),pe(this,o,!1),pe(this,a,(e=>{if(!xe(this,n,g).call(this,e))return;const t=xe(this,n,v).call(this,e);if(!xe(this,n,m).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})})),pe(this,r,(e=>{if(2!==e.button)return;if(!xe(this,n,g).call(this,e))return;e.preventDefault();const t=xe(this,n,v).call(this,e);xe(this,n,m).call(this,t)&&this.trigger("contextMenu",{point:t})})),pe(this,s,(e=>{if(!xe(this,n,g).call(this,e))return;e.preventDefault();const t=xe(this,n,v).call(this,e);if(!xe(this,n,m).call(this,t))return;const o=Date.now(),l=ye(this,i).get("prevClickPoint");l&&o-l.t<=500&&Math.abs(l.x-t.x)<=5&&Math.abs(l.y-t.y)<=5?this.trigger("doubleClick",{point:t}):ye(this,i).set("prevClickPoint",t)})),pe(this,h,(e=>{ye(this,i).set("hasPointDown",!1),e.preventDefault();const t=xe(this,n,v).call(this,e);this.trigger("pointLeave",{point:t})})),pe(this,c,(e=>{if(ye(this,i).set("hasPointDown",!1),!xe(this,n,g).call(this,e))return;e.preventDefault();const t=xe(this,n,v).call(this,e);this.trigger("pointEnd",{point:t})})),pe(this,d,(e=>{if(!xe(this,n,g).call(this,e))return;e.preventDefault(),e.stopPropagation();const t=xe(this,n,v).call(this,e);xe(this,n,m).call(this,t)?!0===ye(this,i).get("hasPointDown")&&this.trigger("pointMove",{point:t}):ye(this,i).get("hasPointDown")&&(this.trigger("pointLeave",{point:t}),ye(this,i).set("hasPointDown",!1))})),pe(this,u,(e=>{if(0!==e.button)return;if(!xe(this,n,g).call(this,e))return;e.preventDefault();const t=xe(this,n,v).call(this,e);xe(this,n,m).call(this,t)&&(ye(this,i).set("hasPointDown",!0),this.trigger("pointStart",{point:t}))})),pe(this,f,(e=>{if(!xe(this,n,g).call(this,e))return void(!0===ye(this,i).get("inCanvas")&&(ye(this,i).set("inCanvas",!1),ye(this,h).call(this,e)));ye(this,i).set("inCanvas",!0),e.preventDefault();const t=xe(this,n,v).call(this,e);xe(this,n,m).call(this,t)&&this.trigger("hover",{point:t})}));const y=new ot({defaultStorage:{hasPointDown:!1,prevClickPoint:null,inCanvas:!0}});we(this,i,y),we(this,t,e),xe(this,n,l).call(this)}onEvents(){if(ye(this,o))return;const e=ye(this,t).boardContent.boardContext.canvas,i=window;i.addEventListener("mousemove",ye(this,f)),i.addEventListener("mousedown",ye(this,u)),i.addEventListener("mousemove",ye(this,d)),i.addEventListener("mouseup",ye(this,c)),e.addEventListener("wheel",ye(this,a),{passive:!1}),i.addEventListener("click",ye(this,s)),i.addEventListener("contextmenu",ye(this,r))}offEvents(){const e=window,i=ye(this,t).boardContent.boardContext.canvas;e.removeEventListener("mousemove",ye(this,f)),e.removeEventListener("mousedown",ye(this,u)),e.removeEventListener("mousemove",ye(this,d)),e.removeEventListener("mouseup",ye(this,c)),e.removeEventListener("mouseleave",ye(this,h)),i.removeEventListener("wheel",ye(this,a)),e.removeEventListener("click",ye(this,s)),e.removeEventListener("contextmenu",ye(this,r))}destroy(){this.offEvents(),ye(this,i).destroy(),we(this,o,!0)}}t=new WeakMap,i=new WeakMap,o=new WeakMap,n=new WeakSet,l=function(){this.onEvents()},a=new WeakMap,r=new WeakMap,s=new WeakMap,h=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,f=new WeakMap,g=function(e){return e.target===ye(this,t).boardContent.boardContext.canvas},v=function(e){const i=ye(this,t).boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-i.left,y:e.clientY-i.top,t:Date.now()}},m=function(e){const i=ye(this,t).sharer.getActiveViewSizeInfo(),{width:o,height:n}=i;return!!(lo(e.x)&&lo(e.y)&&e.x<=o&&e.y<=n)};const ro={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 so{constructor(){pe(this,y),pe(this,p);const e=new ot({defaultStorage:ro}),t=new ot({defaultStorage:{}});we(this,y,e),we(this,p,t)}getActiveStorage(e){return ye(this,y).get(e)}setActiveStorage(e,t){return ye(this,y).set(e,t)}getActiveStoreSnapshot(e){return ye(this,y).getSnapshot(e)}getSharedStorage(e){return ye(this,p).get(e)}setSharedStorage(e,t){return ye(this,p).set(e,t)}getSharedStoreSnapshot(e){return ye(this,p).getSnapshot(e)}getActiveViewScaleInfo(){return{scale:ye(this,y).get("scale"),offsetTop:ye(this,y).get("offsetTop"),offsetBottom:ye(this,y).get("offsetBottom"),offsetLeft:ye(this,y).get("offsetLeft"),offsetRight:ye(this,y).get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:n,offsetRight:l}=e;ye(this,y).set("scale",t),ye(this,y).set("offsetTop",i),ye(this,y).set("offsetBottom",o),ye(this,y).set("offsetLeft",n),ye(this,y).set("offsetRight",l)}setActiveViewSizeInfo(e){ye(this,y).set("width",e.width),ye(this,y).set("height",e.height),ye(this,y).set("devicePixelRatio",e.devicePixelRatio),ye(this,y).set("contextWidth",e.contextWidth),ye(this,y).set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:ye(this,y).get("width"),height:ye(this,y).get("height"),devicePixelRatio:ye(this,y).get("devicePixelRatio"),contextWidth:ye(this,y).get("contextWidth"),contextHeight:ye(this,y).get("contextHeight")}}getActiveOverrideElemenentMap(){return ye(this,y).get("overrideElementMap")}setActiveOverrideElemenentMap(e){ye(this,y).set("overrideElementMap",e)}}y=new WeakMap,p=new WeakMap;const{requestAnimationFrame:ho}=window;class co extends Ue{constructor(e){super(),pe(this,b),pe(this,w),pe(this,x,[]),pe(this,S,"FREE"),we(this,w,e),xe(this,b,A).call(this)}resetVirtualFlatItemMap(e,t){e&&ye(this,w).calculator.resetVirtualFlatItemMap(e,t)}drawFrame(){const{sharer:e}=ye(this,w),t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();ye(this,x).push({activeStore:t,sharedStore:i}),xe(this,b,I).call(this)}scale(e){const{scale:t,point:i,ignoreUpdateVisibleStatus:o}=e,{sharer:n}=ye(this,w),{moveX:l,moveY:a}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:n,offsetTop:l}=o,a=t/o.scale,r=i.x,s=i.y;return{moveX:r-r*a+(n*a-n),moveY:s-s*a+(l*a-l)}}({scale:t,point:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});return n.setActiveStorage("scale",t),o||ye(this,w).calculator.updateVisiableStatus({viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),{moveX:l,moveY:a}}scroll(e){const{sharer:t}=ye(this,w),i=t.getActiveViewScaleInfo(),{moveX:o,moveY:n,ignoreUpdateVisibleStatus:l}=e,a=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:n}=e,{scale:l}=o,{width:a,height:r,contextWidth:s,contextHeight:h}=n;let c=o.offsetLeft,d=o.offsetRight,u=o.offsetTop,f=o.offsetBottom;return c+=t,u+=i,d=a-(s*l+c),f=r-(h*l+u),{scale:l,offsetTop:u,offsetLeft:c,offsetRight:d,offsetBottom:f}}({moveX:o,moveY:n,viewScaleInfo:i,viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(a),l||ye(this,w).calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),a}updateViewScaleInfo(e){const{sharer:t}=ye(this,w),i=function(e,t){const{scale:i,offsetX:o,offsetY:n}=e,{viewSizeInfo:l}=t,{width:a,height:r,contextWidth:s,contextHeight:h}=l,c=0-o*i,d=0-n*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:a-(s*i+c/i),offsetBottom:r-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),ye(this,w).calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),i}resize(e={},t){const{sharer:i}=ye(this,w),o={...i.getActiveViewSizeInfo(),...e},{width:n,height:l,devicePixelRatio:a}=o,{underlayContext:r,boardContext:s,overlayContext:h,viewContext:c}=ye(this,w).boardContent;return s.canvas.width=n*a,s.canvas.height=l*a,s.canvas.style.width=`${n}px`,s.canvas.style.height=`${l}px`,r.canvas.width=n*a,r.canvas.height=l*a,h.canvas.width=n*a,h.canvas.height=l*a,c.canvas.width=n*a,c.canvas.height=l*a,i.setActiveViewSizeInfo(o),(null==t?void 0:t.ignoreUpdateVisibleStatus)||ye(this,w).calculator.updateVisiableStatus({viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}),o}}w=new WeakMap,x=new WeakMap,S=new WeakMap,b=new WeakSet,A=function(){const{renderer:e}=ye(this,w);e.on("load",(()=>{this.drawFrame()}))},I=function(){if("DRAWING"===ye(this,S)||0===ye(this,x).length)return;we(this,S,"DRAWING");const e=ye(this,x).shift(),{renderer:t,boardContent:i,beforeDrawFrame:o,afterDrawFrame:n}=ye(this,w);if(e){const{scale:l,offsetTop:a,offsetBottom:r,offsetLeft:s,offsetRight:h,width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g}=e.activeStore,v={scale:l,offsetTop:a,offsetBottom:r,offsetLeft:s,offsetRight:h},m={width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g};(null==e?void 0:e.activeStore.data)&&t.drawData(e.activeStore.data,{viewScaleInfo:v,viewSizeInfo:m}),o({snapshot:e}),i.drawView(),n({snapshot:e})}0!==ye(this,x).length?we(this,S,"DRAWING")&&ho((()=>{xe(this,b,I).call(this)})):we(this,S,"COMPLETE")};class uo{constructor(e){pe(this,W),pe(this,M),pe(this,z,new Map),pe(this,R,[]),pe(this,C),pe(this,T),pe(this,P),pe(this,E),pe(this,L),pe(this,k,new Ue),pe(this,O,!1);const{boardContent:t}=e,i=new so,o=new ao({boardContent:t,sharer:i}),n=new no({viewContext:t.viewContext,tempContext:t.tempContext,sharer:i}),l=n.getCalculator();we(this,M,e),we(this,P,i),we(this,C,o),we(this,T,n),we(this,L,l),we(this,E,new co({boardContent:e.boardContent,sharer:i,renderer:n,calculator:ye(this,L),beforeDrawFrame:e=>{xe(this,W,J).call(this,e)},afterDrawFrame:e=>{xe(this,W,K).call(this,e)}})),xe(this,W,D).call(this),xe(this,W,q).call(this)}isDestroyed(){return ye(this,O)}destroy(){ye(this,C).destroy(),ye(this,T).destroy(),ye(this,L).destroy(),ye(this,k).destroy(),we(this,O,!0)}getSharer(){return ye(this,P)}getViewer(){return ye(this,E)}getRenderer(){return ye(this,T)}setData(e){const t=ye(this,P);ye(this,P).setActiveStorage("data",e);const i=t.getActiveViewSizeInfo(),o=t.getActiveViewScaleInfo(),n=wt(e.elements,{viewWidth:i.width,viewHeight:i.height,extend:!0});ye(this,E).resetVirtualFlatItemMap(e,{viewSizeInfo:i,viewScaleInfo:o}),ye(this,E).drawFrame();const l={...i,...n};return ye(this,P).setActiveViewSizeInfo(l),{viewSizeInfo:l}}getData(){const{data:e}=ye(this,P).getActiveStoreSnapshot();return e}use(e,t){var i,o,n;if(ye(this,z).has(e)){const t=ye(this,z).get(e);return void(t&&"enable"!==t.status&&(t.status="enable",null==(o=(i=t.middlewareObject).use)||o.call(i),xe(this,W,q).call(this)))}const{boardContent:l,container:a}=ye(this,M),r=e({boardContent:l,sharer:ye(this,P),viewer:ye(this,E),calculator:ye(this,L),eventHub:ye(this,k),container:a},t);null==(n=r.use)||n.call(r),ye(this,z).set(e,{status:"enable",middlewareObject:r,config:t}),xe(this,W,q).call(this)}disuse(e){var t,i;if(ye(this,z).has(e)){const o=ye(this,z).get(e);o&&(null==(i=(t=o.middlewareObject).disuse)||i.call(t),o.status="disable"),ye(this,z).delete(e),xe(this,W,q).call(this)}}resetMiddlewareConfig(e,t){var i,o;if(ye(this,z).has(e)){const n=ye(this,z).get(e);n&&(null==(o=(i=n.middlewareObject).resetConfig)||o.call(i,t))}}scale(e){const t=ye(this,E),{ignoreUpdateVisibleStatus:i}=e,{moveX:o,moveY:n}=t.scale({...e,ignoreUpdateVisibleStatus:!0});t.scroll({moveX:o,moveY:n,ignoreUpdateVisibleStatus:i})}scroll(e){return ye(this,E).scroll(e)}updateViewScaleInfo(e){return ye(this,E).updateViewScaleInfo(e)}resize(e,t){const i=ye(this,E).resize(e,t),{width:o,height:n,devicePixelRatio:l}=e,{boardContent:a}=ye(this,M);a.viewContext.$resize({width:o,height:n,devicePixelRatio:l}),a.overlayContext.$resize({width:o,height:n,devicePixelRatio:l}),a.boardContext.$resize({width:o,height:n,devicePixelRatio:l}),a.underlayContext.$resize({width:o,height:n,devicePixelRatio:l}),ye(this,E).drawFrame(),ye(this,C).trigger("resize",i),ye(this,P).setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=ye(this,M),{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),xe(this,W,$).call(this)}getEventHub(){return ye(this,k)}onWatcherEvents(){ye(this,C).onEvents()}offWatcherEvents(){ye(this,C).offEvents()}}M=new WeakMap,z=new WeakMap,R=new WeakMap,C=new WeakMap,T=new WeakMap,P=new WeakMap,E=new WeakMap,L=new WeakMap,k=new WeakMap,O=new WeakMap,W=new WeakSet,D=function(){ye(this,C).on("pointStart",xe(this,W,j).bind(this)),ye(this,C).on("pointEnd",xe(this,W,Y).bind(this)),ye(this,C).on("pointMove",xe(this,W,N).bind(this)),ye(this,C).on("pointLeave",xe(this,W,B).bind(this)),ye(this,C).on("hover",xe(this,W,F).bind(this)),ye(this,C).on("wheel",xe(this,W,X).bind(this)),ye(this,C).on("wheelScale",xe(this,W,H).bind(this)),ye(this,C).on("scrollX",xe(this,W,Z).bind(this)),ye(this,C).on("scrollY",xe(this,W,Q).bind(this)),ye(this,C).on("resize",xe(this,W,U).bind(this)),ye(this,C).on("doubleClick",xe(this,W,G).bind(this)),ye(this,C).on("contextMenu",xe(this,W,V).bind(this)),ye(this,T).on("load",(()=>{ye(this,k).trigger("loadResource")}))},j=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.pointStart)?void 0:t.call(o,e)))return}},Y=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.pointEnd)?void 0:t.call(o,e)))return}},N=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.pointMove)?void 0:t.call(o,e)))return}},B=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.pointLeave)?void 0:t.call(o,e)))return}},F=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.hover)?void 0:t.call(o,e)))return}},G=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.doubleClick)?void 0:t.call(o,e)))return}},V=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.contextMenu)?void 0:t.call(o,e)))return}},X=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.wheel)?void 0:t.call(o,e)))return}},H=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.wheelScale)?void 0:t.call(o,e)))return}},Z=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.scrollX)?void 0:t.call(o,e)))return}},Q=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.scrollY)?void 0:t.call(o,e)))return}},U=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.resize)?void 0:t.call(o,e)))return}},$=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.clear)?void 0:t.call(o,e)))return}},J=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.beforeDrawFrame)?void 0:t.call(o,e)))return}},K=function(e){var t;for(let i=0;i<ye(this,R).length;i++){const o=ye(this,R)[i];if(!1===(null==(t=null==o?void 0:o.afterDrawFrame)?void 0:t.call(o,e)))return}},q=function(){const e=[];for(const[t,i]of ye(this,z))"enable"===(null==i?void 0:i.status)&&(null==i?void 0:i.middlewareObject)&&e.push(i.middlewareObject);we(this,R,e)};const fo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4P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vVNj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==",go="selectInGroup",vo={CURSOR:"cursor",CHANGE:"change",RULER:"ruler",SCALE:"scale",SELECT_LAYOUT:"selectLayout",SELECT:"select",CLEAR_SELECT:"clearSelect",TEXT_EDIT:"textEdit",TEXT_CHANGE:"textChange",CONTEXT_MENU:"contextMenu",SELECT_IN_GROUP:go,SNAP_TO_GRID:go},mo={};Object.keys(vo).forEach((e=>{Object.defineProperty(mo,e,{value:vo[e],writable:!1})}));class yo{constructor(e,t){pe(this,ne),pe(this,_),pe(this,ee),pe(this,te,null),pe(this,ie,null),pe(this,oe,{auto:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0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ch5J+qOkH0v6tqTXzDk5EwGGlNFjOWQOd8px4vUN4E3cpn2pz/jgwQPef/99Ll68yJ07d+jt7WVwcJBIJEJJSQlz586loaGBTZs2UVdXF5w0OoDLwFWcbPsct6r04+bRLHEYCoWyAD1kBDfHleHmsxrccccS3NFHNV/eenBy6iZwCycMOnHz5wBuDh2nyyY6H0zhFmoF7vtxk+l9q3ieQfrDo8msF7cy3cN56g7ZWnKcep7IxnrQmz+wHKu2K3EKJWbPpWSUTQ4ZtRJc23sC6ZGB9ZM52JwcboIQjzUvZvNxYfeHlyVkZFcBbux6wKA6ShjoM5yM8uH0Xpuy8ekAQuZc2W8P8nEei9p9mMmPgAfJHO0O27e0lHppw9MEDJo//A4eoE91iB48SJ80lFMB/t/+V/sPGZfTmtMFR4EAAAAASUVORK5CYII="}),we(this,ee,e),we(this,_,t.eventHub),xe(this,ne,le).call(this),xe(this,ne,ae).call(this)}}function po(e){const{modifiedElement:t,beforeElement:i}=e,{uuid:o,...n}=t,l=Ht(n);let a={};Object.keys(l).forEach((e=>{let t=$t(i,e);void 0===t&&/(borderRadius|borderWidth)\[[0-9]{1,}\]$/.test(e)&&(e=e.replace(/\[[0-9]{1,}\]$/,""),t=$t(i,e)),a[e]=t})),a=Ht(a);return{type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:o,before:a,after:l}}}_=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,oe=new WeakMap,ne=new WeakSet,le=function(){const e=ye(this,_);xe(this,ne,re).call(this,"default"),e.on(mo.CURSOR,(e=>{var t;"over-element"!==e.type&&e.type?"resize-rotate"===e.type?xe(this,ne,re).call(this,"rotate"):"string"==typeof e.type&&(null==(t=e.type)?void 0:t.startsWith("resize-"))?xe(this,ne,se).call(this,e):"drag-default"===e.type?xe(this,ne,re).call(this,"drag-default"):"drag-active"===e.type?xe(this,ne,re).call(this,"drag-active"):xe(this,ne,re).call(this,"auto"):xe(this,ne,re).call(this,"auto")}))},ae=function(){Ee(fo).then((e=>{we(this,ie,e)})).catch((e=>{console.error(e)}))},re=function(e){if(ye(this,te)===e)return;we(this,te,e);const t=ye(this,oe)[ye(this,te)]||ye(this,oe).auto;let i=0,o=0;(e.startsWith("rotate-")&&ye(this,oe)[ye(this,te)]||"rotate"===e)&&(i=10,o=10),ye(this,ee).style.cursor="default"===e?"default":`image-set(url(${t})2x) ${i} ${o}, auto`},se=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+=yt((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+=yt(e.angle||0)})),i=yt(i);const o=xe(this,ne,he).call(this,i);xe(this,ne,re).call(this,o)},he=function(e){const t=`rotate-${e}`;if(!ye(this,oe)[t]){const i=ye(this,ie);if(i){const o=document.createElement("canvas"),n=i.width,l=i.height,a={x:n/2,y:l/2};o.width=n,o.height=l;const r=o.getContext("2d"),s=at(e);r.translate(a.x,a.y),r.rotate(s),r.translate(-a.x,-a.y),r.drawImage(i,0,0,n,l),r.translate(a.x,a.y),r.rotate(-s),r.translate(-a.x,-a.y);const h=o.toDataURL("image/png");ye(this,oe)[t]=h}}return t};const wo="SELECT",xo=Symbol(`${wo}_actionType`),So=Symbol(`${wo}_resizeType`),bo=Symbol(`${wo}_areaStart`),Ao=Symbol(`${wo}_areaEnd`),Io=Symbol(`${wo}_hoverElement`),Mo=Symbol(`${wo}_hoverElementVertexes`),zo=Symbol(`${wo}_selectedElementList`),Ro=Symbol(`${wo}_selectedElementListVertexes`),Co=Symbol(`${wo}_selectedElementController`),To=Symbol(`${wo}_selectedElementPosition`),Po=Symbol(`${wo}_groupQueue`),Eo=Symbol(`${wo}_groupQueueVertexesList`),Lo=Symbol(`${wo}_isMoving`),ko=Symbol(`${wo}_enableSelectInGroup`),Oo=Symbol(`${wo}_enableSnapToGrid`),Wo={activeColor:"#1973ba",activeAreaColor:"#1976d21c",lockedColor:"#5b5959b5",referenceColor:"#f7276e"};function Do(e,t,i){const{borderColor:o,borderWidth:n,background:l,lineDash:a}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.fillStyle=l,e.setLineDash(a),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("nonzero")}function jo(e,t,i,o){const{borderColor:n,borderWidth:l,lineDash:a}=o;e.setLineDash([]),e.lineWidth=l,e.strokeStyle=n,e.setLineDash(a),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke()}function Yo(e,t,i){const{borderColor:o,borderWidth:n,lineDash:l}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.setLineDash(l),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 No(e,t,i){const{size:o,borderColor:n,borderWidth:l,lineDash:a}=i,r=t.x-o/2,s=t.x+o/2,h=t.y-o/2,c=t.y+o/2;Yo(e,[{x:r,y:h},{x:s,y:h},{x:s,y:c},{x:r,y:c}],{borderColor:n,borderWidth:l,lineDash:a})}function Bo(e,t,i){if(!t)return;const{style:o}=i,{activeColor:n}=o,l={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};Do(e,Pt(t,i),l)}function Fo(e,t,i){if(!t)return;const{style:o}=i,{lockedColor:n}=o,l={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};Do(e,Pt(t,i),l);const{controller:a}=i;if(a){const{topLeft:t,topRight:o,bottomLeft:n,bottomRight:r,topMiddle:s,bottomMiddle:h,leftMiddle:c,rightMiddle:d}=a,u={...l,borderWidth:1};Yo(e,Pt(s.vertexes,i),u),Yo(e,Pt(h.vertexes,i),u),Yo(e,Pt(c.vertexes,i),u),Yo(e,Pt(d.vertexes,i),u),Yo(e,Pt(t.vertexes,i),u),Yo(e,Pt(o.vertexes,i),u),Yo(e,Pt(n.vertexes,i),u),Yo(e,Pt(r.vertexes,i),u)}}function Go(e,t,i){var o;if(!t)return;const{hideControllers:n,style:l,rotateControllerPattern:a,viewSizeInfo:r,element:s}=i,{devicePixelRatio:h=1}=r,{activeColor:c}=l,{elementWrapper:d,topLeft:u,topRight:f,bottomLeft:g,bottomRight:v,rotate:m}=t,y={borderColor:c,borderWidth:2,background:"transparent",lineDash:[]},p={...y,borderWidth:4,background:"#FFFFFF"};if(Do(e,Pt(d,i),y),!n&&(Do(e,Pt(u.vertexes,i),p),Do(e,Pt(f.vertexes,i),p),Do(e,Pt(g.vertexes,i),p),Do(e,Pt(v.vertexes,i),p),!1!==(null==(o=null==s?void 0:s.operations)?void 0:o.rotatable))){!function(e,t,i){const{size:o,background:n}=i,l=t,a=o/2,r=a,s=a;r>=0&&s>=0&&(e.beginPath(),e.fillStyle=n,e.circle(l.x,l.y,r,s,0,0,2*Math.PI),e.closePath(),e.fill("nonzero"))}(e,Tt(m.center,i),{...p,size:m.size});const t=Tt(m.center,i);e.drawImage(a.canvas,0,0,a.canvas.width/h,a.canvas.height/h,t.x-m.size/2,t.y-m.size/2,m.size,m.size)}}function Vo(e,t){const{xLines:i,yLines:o,style:n}=t,{referenceColor:l}=n,a={borderColor:l,borderWidth:1,lineDash:[]},r={...a,size:6};i&&i.forEach((t=>{t.forEach(((i,o)=>{No(e,i,r),t[o+1]&&jo(e,t[o],t[o+1],a)}))})),o&&o.forEach((t=>{t.forEach(((i,o)=>{No(e,i,r),t[o+1]&&jo(e,t[o],t[o+1],a)}))}))}function Xo(e){return e*Math.PI/180}function Ho(e,t){return Math.sqrt(e*e+t*t)}function Zo(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Qo(e,t){const{ctx:i,viewScaleInfo:o,vertexes:n}=t,l=Tt(n[0],{viewScaleInfo:o}),a=Tt(n[1],{viewScaleInfo:o}),r=Tt(n[2],{viewScaleInfo:o}),s=Tt(n[3],{viewScaleInfo:o});return i.beginPath(),i.moveTo(l.x,l.y),i.lineTo(a.x,a.y),i.lineTo(r.x,r.y),i.lineTo(s.x,s.y),i.lineTo(l.x,l.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function Uo(e,t){const{ctx:i,viewScaleInfo:o,viewSizeInfo:n,groupQueue:l}=t;if(!(l&&(null==l?void 0:l.length)>0))return!1;const a=zt(l),r=a[a.length-1];return!!r&&Qo(e,{ctx:i,vertexes:r,viewScaleInfo:o})}function $o(e,t){var i,o,n,l,a;const r={type:null,elements:[],elementVertexesList:[],groupQueue:[],groupQueueVertexesList:[]},{ctx:s,data:h,calculator:c,selectedElements:d,viewScaleInfo:u,viewSizeInfo:f,areaSize:g,groupQueue:v,selectedElementController:m}=t;if(m){const{left:t,right:n,top:l,bottom:a,topLeft:h,topRight:c,bottomLeft:f,bottomRight:g,rotate:y}=m,p=[t,n,l,a,h,c,f,g];1===(null==d?void 0:d.length)&&!1!==(null==(o=null==(i=null==d?void 0:d[0])?void 0:i.operations)?void 0:o.rotatable)&&p.push(y);for(let t=0;t<p.length;t++){const i=p[t];if(Qo(e,{ctx:s,vertexes:i.vertexes,viewScaleInfo:u})){r.type=`resize-${i.type}`,d&&(null==d?void 0:d.length)>0&&(r.groupQueue=v||[],r.elements=[d[0]]);break}}}if(v&&Array.isArray(v)&&v.length>0){const t=v[v.length-1];if((null==(n=null==t?void 0:t.detail)?void 0:n.children)&&Array.isArray(null==(l=null==t?void 0:t.detail)?void 0:l.children))for(let i=t.detail.children.length-1;i>=0;i--){const o=t.detail.children[i],n=Rt(o,{groupQueue:v});if(n&&Qo(e,{ctx:s,vertexes:n,viewScaleInfo:u}))return r.type||(r.type="over-element"),r.groupQueue=v,r.elements=[o],r}return r}if(null!==r.type)return r;if(g&&Array.isArray(d)&&(null==d?void 0:d.length)>1){const{x:t,y:i,w:o,h:n}=g;if(e.x>=t&&e.x<=t+o&&e.y>=i&&e.y<=i+n)return r.type="list-area",r.elements=d,r}if(h){const{index:t,element:i}=c.getPointElement(e,{data:h,viewScaleInfo:u,viewSizeInfo:f});if(t>=0&&i&&!0!==(null==(a=null==i?void 0:i.operations)?void 0:a.invisible))return r.elements=[i],r.type="over-element",r}return r}function Jo(e,t){const{x:i,y:o,w:n,h:l,angle:a=0}=e,{center:r,start:s,end:h,viewScaleInfo:c}=t,d=Tt(r,{viewScaleInfo:c}),u=yt(a),f=function(e,t,i){const o=dt(e,t),n=dt(e,i);return null!==n&&null!==o?n-o:0}(d,s,h);return{x:i,y:o,w:n,h:l,angle:yt(u+f/Math.PI*180)}}function Ko(e,t){var i;if(!Array.isArray(e))return null;const o={x:0,y:0,w:0,h:0},{viewScaleInfo:n}=t;let l=null;for(let t=0;t<e.length;t++){const a=e[t];if(null==(i=null==a?void 0:a.operations)?void 0:i.invisible)continue;const r=Ct(a,{viewScaleInfo:n});if(r.angle&&(r.angle>0||r.angle<0)){const e=vt(r);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];r.x=Math.min(...t),r.y=Math.min(...i),r.w=Math.abs(Math.max(...t)-Math.min(...t)),r.h=Math.abs(Math.max(...i)-Math.min(...i))}}if(l){const e=Math.min(r.x,o.x),t=Math.min(r.y,o.y),i=Math.max(r.x+r.w,o.x+o.w),n=Math.max(r.y+r.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=r.x,o.y=r.y,o.w=r.w,o.h=r.h;l=r}return o}function qo(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 _o=(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]},en=(e,t)=>Math.abs(e-t)<1e-5;function tn(e,t){var i,o;const{data:n,groupQueue:l,calculator:a,viewScaleInfo:r,viewSizeInfo:s}=t;let h=n.elements||[];(null==l?void 0:l.length)>0&&(h=(null==(o=null==(i=l[l.length-1])?void 0:i.detail)?void 0:o.children)||[]);const c=[];h.forEach((t=>{if(t.uuid!==e){const e=a.calcViewRectInfoFromRange(t.uuid,{checkVisible:!0,viewScaleInfo:r,viewSizeInfo:s});e&&c.push(e)}}));const d=a.calcViewRectInfoFromRange(e,{viewScaleInfo:r,viewSizeInfo:s});if(!d)return null;const u={},f={},g=[],v=[];let m=[],y=[];const p=qo(d);c.forEach((e=>{const t=qo(e);u[t.minX]||(u[t.minX]=[]),u[t.midX]||(u[t.midX]=[]),u[t.maxX]||(u[t.maxX]=[]),f[t.minY]||(f[t.minY]=[]),f[t.midY]||(f[t.midY]=[]),f[t.maxY]||(f[t.maxY]=[]),u[t.minX]=[t.minY,t.midY,t.maxY],u[t.midX]=[t.minY,t.midY,t.maxY],u[t.maxX]=[t.minY,t.midY,t.maxY],m.push(t.minX),m.push(t.midX),m.push(t.maxX),f[t.minY]=[t.minX,t.midX,t.maxX],f[t.midY]=[t.minX,t.midX,t.maxX],f[t.maxY]=[t.minX,t.midX,t.maxX],y.push(t.minY),y.push(t.midY),y.push(t.maxY)})),m=m.sort(((e,t)=>e-t)),y=y.sort(((e,t)=>e-t));let w=null,x=null,S=null,b=null,A=null,I=null,M=null,z=null;if(m.length>0){S=_o(m,p.minX),b=_o(m,p.midX),A=_o(m,p.maxX);const e=Math.abs(S-p.minX),t=Math.abs(b-p.midX),i=Math.abs(A-p.maxX),o=Math.min(e,t,i);o<=2/r.scale&&(en(o,e)?w=S-p.minX:en(o,t)?w=b-p.midX:en(o,i)&&(w=A-p.maxX))}if(y.length>0){I=_o(y,p.minY),M=_o(y,p.midY),z=_o(y,p.maxY);const e=Math.abs(I-p.minY),t=Math.abs(M-p.midY),i=Math.abs(z-p.maxY),o=Math.min(e,t,i);o<=2/r.scale&&(en(o,e)?x=I-p.minY:en(o,t)?x=M-p.midY:en(o,i)&&(x=z-p.maxY))}const R={...p};if(null!==w&&(R.minX+=w,R.midX+=w,R.maxX+=w),null!==x&&(R.minY+=x,R.midY+=x,R.maxY+=x),Ye.x(w)&&null!==w&&null!==S&&null!==b&&null!==A){if(en(w,S-p.minX)){const e={x:S,yList:[]};e.yList.push(R.minY),e.yList.push(R.maxY),e.yList.push(...(null==f?void 0:f[S])||[]),g.push(e)}if(en(w,b-p.minX)){const e={x:b,yList:[]};e.yList.push(R.minY),e.yList.push(R.maxY),e.yList.push(...(null==f?void 0:f[b])||[]),g.push(e)}if(en(w,A-p.minX)){const e={x:A,yList:[]};e.yList.push(R.minY),e.yList.push(R.maxY),e.yList.push(...(null==f?void 0:f[A])||[]),g.push(e)}}if(Ye.y(x)&&null!==x&&null!==I&&null!==M&&null!==z){if(en(x,I-p.minY)){const e={y:I,xList:[]};e.xList.push(R.minX),e.xList.push(R.maxX),e.xList.push(...(null==u?void 0:u[I])||[]),v.push(e)}if(en(x,M-p.midY)){const e={y:M,xList:[]};e.xList.push(R.minX),e.xList.push(R.maxX),e.xList.push(...(null==u?void 0:u[I])||[]),v.push(e)}if(en(x,z-p.maxY)){const e={y:z,xList:[]};e.xList.push(R.minX),e.xList.push(R.maxX),e.xList.push(...(null==u?void 0:u[z])||[]),v.push(e)}}const C=[];(null==g?void 0:g.length)>0&&g.forEach(((e,t)=>{C.push([]),e.yList.forEach((i=>{C[t].push({x:e.x,y:i})}))}));const T=[];return(null==v?void 0:v.length)>0&&v.forEach(((e,t)=>{T.push([]),e.xList.forEach((i=>{T[t].push({x:i,y:e.y})}))})),{offsetX:w,offsetY:x,yLines:C,xLines:T}}const on="LAYOUT_SELECT",nn=Symbol(`${on}_layoutActionType`),ln=Symbol(`${on}_layoutControlType`),an=Symbol(`${on}_layoutController`),rn=Symbol(`${on}_layoutIsHoverContent`),sn=Symbol(`${on}_layoutIsHoverController`),hn=Symbol(`${on}_layoutIsSelected`),cn=Symbol(`${on}_layoutIsSelected`),dn={activeColor:"#b331c9"};function un(e,t,i){const{activeColor:o}=i;e.setLineDash([]),e.fillStyle="#FFFFFF",e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.fill("nonzero"),e.strokeStyle=o,e.lineWidth=2,e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function fn(e,t){const{start:i,end:o,style:n}=t,{activeColor:l}=n,a=l;e.setLineDash([]),e.strokeStyle=a,e.lineWidth=2,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,o.y),e.closePath(),e.stroke()}function gn(e){const{fill:t,devicePixelRatio:i}=e,o=(e=>({uuid:Ie(),type:"path",x:0,y:0,w:200,h:200,detail:{commands:[{type:"M",params:[512,0]},{type:"c",params:[282.8,0,512,229.2,512,512]},{type:"s",params:[-229.2,512,-512,512]},{type:"S",params:[0,794.8,0,512,229.2,0,512,0]},{type:"z",params:[]},{type:"m",params:[309.8,253.8]},{type:"c",params:[0,-10.5,-6.5,-19.8,-15.7,-23.8,-9.7,-4,-21,-2,-28.2,5.6]},{type:"l",params:[-52.5,52]},{type:"c",params:[-56.9,-53.7,-133.9,-85.5,-213.4,-85.5,-170.7,0,-309.8,139.2,-309.8,309.8,0,170.6,139.2,309.8,309.8,309.8,92.4,0,179.5,-40.8,238.4,-111.8,4,-5.2,4,-12.9,-.8,-17.3]},{type:"L",params:[694.3,637]},{type:"c",params:[-2.8,-2.4,-6.5,-3.6,-10.1,-3.6,-3.6,.4,-7.3,2,-9.3,4.8,-39.5,51.2,-98.8,80.3,-163,80.3,-113.8,0,-206.5,-92.8,-206.5,-206.5,0,-113.8,92.8,-206.5,206.5,-206.5,52.8,0,102.9,20.2,140.8,55.3]},{type:"L",params:[597,416.5]},{type:"c",params:[-7.7,7.3,-9.7,18.6,-5.6,27.9,4,9.7,13.3,16.1,23.8,16.1]},{type:"H",params:[796]},{type:"c",params:[14.1,0,25.8,-11.7,25.8,-25.8]},{type:"V",params:[253.8]},{type:"z",params:[]}],fill:"#2c2c2c",stroke:"transparent",strokeWidth:0,originX:0,originY:0,originW:1024,originH:1024,opacity:1,...e}}))({fill:t}),{w:n,h:l}=o,a=Xe({width:n,height:l,devicePixelRatio:i});return wi(a,o,{loader:void 0,viewScaleInfo:{scale:1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0},viewSizeInfo:{width:n,height:l,devicePixelRatio:i,contextWidth:n,contextHeight:l},parentElementSize:{x:0,y:0,w:n,h:l},parentOpacity:1}),{context2d:a,fill:t}}const vn="monospace";const mn="@middleware/internal-event/show-info-angle",yn={textBackground:"#1973bac6",textColor:"#ffffff"},pn=10,wn="SCROLL",xn=Symbol(`${wn}_xThumbRect`),Sn=Symbol(`${wn}_yThumbRect`),bn=Symbol(`${wn}_hoverXThumbRect`),An=Symbol(`${wn}_hoverYThumbRect`),In=Symbol(`${wn}_prevPoint`),Mn=Symbol(`${wn}_activePoint`),zn=Symbol(`${wn}_activeThumbType`),Rn={thumbBackground:"#0000003A",thumbBorderColor:"#0000008A",hoverThumbBackground:"#0000005F",hoverThumbBorderColor:"#000000EE",activeThumbBackground:"#0000005E",activeThumbBorderColor:"#000000F0"};function Cn(e,t,i){const o=e,{x:n,y:l,w:a,h:r}=i;return o.beginPath(),o.rect(n,l,a,r),o.closePath(),!!o.isPointInPath(t.x,t.y)}function Tn(e,t){let{x:i,y:o,h:n,w:l}=t;const{background:a,borderColor:r}=t;e.save(),e.shadowColor="#FFFFFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=1;{const{axis:s}=t;"X"===s?(o=o+n/4+0,n/=2):"Y"===s&&(i=i+l/4+0,l/=2);let h=t.r;h=Math.min(h,l/2,n/2),(l<2*h||n<2*h)&&(h=0),e.globalAlpha=1,e.beginPath(),e.moveTo(i+h,o),e.arcTo(i+l,o,i+l,o+n,h),e.arcTo(i+l,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+l,o,h),e.closePath(),e.fillStyle=a,e.fill("nonzero"),e.beginPath(),e.lineWidth=1,e.strokeStyle=r,e.setLineDash([]),e.moveTo(i+h,o),e.arcTo(i+l,o,i+l,o+n,h),e.arcTo(i+l,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+l,o,h),e.closePath(),e.stroke()}e.restore()}function Pn(e,t){const i=e,{viewScaleInfo:o,viewSizeInfo:n,scrollInfo:l,style:a}=t,{activeThumbType:r,prevPoint:s,activePoint:h,hoverXThumb:c,hoverYThumb:d}=l,u=function(e){const{viewScaleInfo:t,viewSizeInfo:i,hoverXThumb:o,hoverYThumb:n,style:l}=e,{width:a,height:r}=i,{offsetTop:s,offsetBottom:h,offsetLeft:c,offsetRight:d}=t,u=16,{thumbBackground:f,thumbBorderColor:g,hoverThumbBackground:v,hoverThumbBorderColor:m}=l;let y=0,p=0;y=Math.max(40,a-32-(Math.abs(c)+Math.abs(d))),y>=a&&(y=a),p=Math.max(40,r-32-(Math.abs(s)+Math.abs(h))),p>=r&&(p=r);let w=16;c>0?w=16:d>0?w=a-y-u:c<=0&&y>0&&(0!==c||0!==d)&&(w=16+(a-y)*Math.abs(c)/(Math.abs(c)+Math.abs(d)),w=Math.min(Math.max(0,w-16),a-y));let x=16;return s>0?x=16:h>0?x=r-p-u:s<=0&&p>0&&(0!==s||0!==h)&&(x=16+(r-p)*Math.abs(s)/(Math.abs(s)+Math.abs(h)),x=Math.min(Math.max(0,x-16),r-p)),{lineSize:u,xSize:y,ySize:p,translateY:x,translateX:w,xThumbBackground:o?v:f,yThumbBackground:n?v:f,xThumbBorderColor:o?m:g,yThumbBorderColor:n?m:g,xThumbRect:{x:w,y:r-u,w:y,h:u},yThumbRect:{x:a-u,y:x,w:u,h:p}}}({viewScaleInfo:o,viewSizeInfo:n,hoverXThumb:c,hoverYThumb:d,style:a});let f={...u.xThumbRect},g={...u.yThumbRect};return r&&s&&h&&("X"===r&&l.xThumbRect?(f={...l.xThumbRect},f.x=f.x+(h.x-s.x)):"Y"===r&&l.yThumbRect&&(g={...l.yThumbRect},g.y=g.y+(h.y-s.y))),Tn(i,{axis:"X",...f,r:u.lineSize/2,background:u.xThumbBackground,borderColor:u.xThumbBorderColor}),Tn(i,{axis:"Y",...g,r:u.lineSize/2,background:u.yThumbBackground,borderColor:u.yThumbBorderColor}),{xThumbRect:f,yThumbRect:g}}function En(e,t){const{snapshot:i,style:o}=t,n=lt(i),l=nt(i),a=function(e){const{sharedStore:t}=e;return{activePoint:t[Mn]||null,prevPoint:t[In]||null,activeThumbType:t[zn]||null,xThumbRect:t[xn]||null,yThumbRect:t[Sn]||null,hoverXThumb:t[bn],hoverYThumb:t[An]}}(i),{xThumbRect:r,yThumbRect:s}=Pn(e,{viewSizeInfo:n,viewScaleInfo:l,scrollInfo:a,style:o});return{xThumbRect:r,yThumbRect:s}}const Ln=16,kn="monospace",On={background:"#FFFFFFA8",borderColor:"#00000080",scaleColor:"#000000",textColor:"#00000080",gridColor:"#AAAAAA20",gridPrimaryColor:"#AAAAAA40",selectedAreaColor:"#19609780"},Wn=[1,2,5,10,20,50,100,200,500];function Dn(e){const{scale:t,viewLength:i,viewOffset:o}=e,n=[];let l=10;l=Nt(l/t,{decimalPlaces:0}),l=function(e){e=Math.max(Wn[0],Math.min(e,Wn[Wn.length-1]));for(let t=0;t<Wn.length-1;t++){const i=Wn[t],o=Wn[t+1];if(!(e>o))return e===i||e===o?e:e<=(i+o)/2?i:o}return e}(l);const a=10*l,r=5*l;let s=0;const h=l*t,c=0-o,d=c%h,u=(c-d+h)/t,f=h-d+0;for(;f+s*h<i;){const e=Nt(u+s*l,{decimalPlaces:0}),t={num:e,position:Nt(f+s*h,{decimalPlaces:0}),showNum:e%a==0,isKeyNum:e%a==0,isSubKeyNum:e%r==0};n.push(t),s++}return{list:n,rulerUnit:l}}const jn={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"},Yn=Symbol("DRAG_prevPoint");return ce=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakSet,ge=function(){ye(this,ue).style.position="relative"},e.Board=uo,e.Calculator=$i,e.Core=class{constructor(e,t){pe(this,fe),pe(this,ce),pe(this,de),pe(this,ue);const{devicePixelRatio:i=1,width:o,height:n}=t;we(this,ue,e);const l=document.createElement("canvas");l.setAttribute("tabindex","0"),we(this,de,l),xe(this,fe,ge).call(this),e.appendChild(l);const a=He(l,{width:o,height:n,devicePixelRatio:i}),r=new uo({boardContent:a,container:e}),s=r.getSharer();s.setActiveViewSizeInfo({width:o,height:n,devicePixelRatio:i,contextWidth:o,contextHeight:n}),we(this,ce,r),this.resize(s.getActiveViewSizeInfo());const h=r.getEventHub();new yo(e,{eventHub:h})}isDestroyed(){return ye(this,ce).isDestroyed()}destroy(){ye(this,ce).destroy(),ye(this,de).remove()}use(e,t){ye(this,ce).use(e,t)}disuse(e){ye(this,ce).disuse(e)}resetMiddlewareConfig(e,t){ye(this,ce).resetMiddlewareConfig(e,t)}setData(e){pt((null==e?void 0:e.elements)||[]),ye(this,ce).setData(e)}getData(){return ye(this,ce).getData()}scale(e){ye(this,ce).scale(e);ye(this,ce).getViewer().drawFrame()}resize(e){const t=ye(this,ce),i=t.getSharer().getActiveViewSizeInfo();t.resize({...i,...e})}clear(){ye(this,ce).clear()}on(e,t){ye(this,ce).getEventHub().on(e,t)}off(e,t){ye(this,ce).getEventHub().off(e,t)}trigger(e,t){ye(this,ce).getEventHub().trigger(e,t)}getViewInfo(){const e=ye(this,ce).getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){ye(this,ce).getViewer().drawFrame()}setViewScale(e){ye(this,ce).updateViewScaleInfo(e)}getLoadItemMap(){return ye(this,ce).getRenderer().getLoadItemMap()}onBoardWatcherEvents(){ye(this,ce).onWatcherEvents()}offBoardWatcherEvents(){ye(this,ce).offWatcherEvents()}createElement(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n}=this.getViewInfo();return ii(e,t||{},!0===(null==i?void 0:i.viewCenter)?{viewScaleInfo:o,viewSizeInfo:n}:void 0)}updateElement(e){const t=this.getData()||{elements:[]},i=e.uuid,o=At(i,t.elements),n=bt(o,t.elements);if(!n)return null;const l=Ht(n),a=Ht(ri(o,e,t.elements,{strict:!0}));this.setData(t),this.refresh();return{type:"updateElement",time:Date.now(),content:{method:"updateElement",uuid:i,before:l,after:a}}}modifyElement(e){const{uuid:t,...i}=e,o=this.getData()||{elements:[]},n=At(t,o.elements),l=bt(n,o.elements);if(!l)return null;const a=po({modifiedElement:e,beforeElement:l});return ri(n,i,o.elements),this.setData(o),this.refresh(),a}modifyElements(e){const t=this.getData()||{elements:[]};let i=null;const o=[],n=[];return e.forEach((e=>{const{uuid:i,...l}=e,a=At(i,t.elements),r=bt(a,t.elements);if(!r)return null;const s=po({modifiedElement:e,beforeElement:r});s.content&&(o.push({...s.content.before,uuid:i}),n.push({...s.content.after,uuid:i})),ri(a,l,t.elements)})),i={type:"modifyElements",time:Date.now(),content:{method:"modifyElements",before:o,after:n}},this.setData(t),this.refresh(),i}addElement(e,t){var i;const o=this.getData()||{elements:[]};if(t&&(null==(i=null==t?void 0:t.position)?void 0:i.length)){if(null==t?void 0:t.position){oi(e,[...(null==t?void 0:t.position)||[]],o.elements)}}else o.elements.push(e);const n=At(e.uuid,o.elements),l={type:"addElement",time:Date.now(),content:{method:"addElement",uuid:e.uuid,position:n,element:ze(e)}};return this.setData(o),this.refresh(),l}deleteElement(e){const t=this.getData()||{elements:[]},i=At(e,t.elements),o=bt(i,t.elements),n={type:"deleteElement",time:Date.now(),content:{method:"deleteElement",uuid:e,position:i,element:o?ze(o):null}};return function(e,t){ni(At(e,t),t)}(e,t.elements),this.setData(t),this.refresh(),n}moveElement(e,t){const i=this.getData()||{elements:[]},o=At(e,i.elements),n={type:"moveElement",time:Date.now(),content:{method:"moveElement",uuid:e,from:[...o],to:[...t]}},{elements:l}=function(e,t){const i=[...t.from],o=[...t.to];if(0===i.length||0===o.length)return{elements:e,from:i,to:o};if(i.length<=o.length)for(let t=0;t<i.length;t++)if(o[t]!==i[t]);else if(t===i.length-1)return{elements:e,from:i,to:o};const n=bt(i,e);if(n){if(!oi(n,o,e))return{elements:e,from:i,to:o};let t=-1,l=!1;if(i.length>=1&&o.length>=1){if(i.length<=o.length)if(1===i.length)i[0]<o[0]&&(l=!0);else for(let e=0;e<i.length&&i[e]===o[e];e++)if(i.length===i.length-1){l=!0;break}if(i.length>=o.length)if(1===o.length)o[0]<i[0]&&(l=!0);else for(let e=0;e<o.length&&(e===o.length-1&&o[e]<i[e]&&(l=!0),i[e]===o[e]);e++);}if(!0===l)for(let e=0;e<i.length&&o[e]>=0;e++)o[e]!==i[e]&&o[e]<i[e]&&e==o.length-1&&(t=e);t>=0&&(i[t]=i[t]+1),ni(i,e)}return{elements:e,from:i,to:o}}(i.elements,{from:o,to:t});return i.elements=l,this.setData(i),this.refresh(),n}modifyLayout(e){const t=this.getData()||{elements:[]},i={type:"modifyLayout",time:Date.now(),content:{method:"modifyLayout",before:null,after:null}};if(null===e)return t.layout?(i.content.before=Zt(t.layout),delete t.layout,this.setData(t),this.refresh(),i):i;const o=t.layout;let n={};const l=Zt(e);return t.layout?(Object.keys(l).forEach((e=>{let t=$t(o,e);void 0===t&&/(borderRadius|borderWidth)\[[0-9]{1,}\]$/.test(e)&&(e=e.replace(/\[[0-9]{1,}\]$/,""),t=$t(o,e)),n[e]=t})),n=Zt(n),i.content.before=n):t.layout={},i.content.after=l,function(e,t){const i=Zt(t),o=[];Object.keys(i).forEach((t=>{if(!o.includes(t)){const o=i[t];Kt(e,t),void 0!==o&&Jt(e,t,o)}}))}(t.layout,e),this.setData(t),this.refresh(),i}modifyGlobal(e){const t=this.getData()||{elements:[]},i={type:"modifyGlobal",time:Date.now(),content:{method:"modifyGlobal",before:null,after:null}};if(null===e)return t.global?(i.content.before=Qt(t.global),delete t.global,this.setData(t),this.refresh(),i):i;const o=t.global;let n={};const l=Qt(e);return t.global?(Object.keys(l).forEach((e=>{n[e]=$t(o,e)})),n=Qt(n),i.content.before=n):t.global={},i.content.after=l,function(e,t){const i=Qt(t),o=[];Object.keys(i).forEach((t=>{if(!o.includes(t)){const o=i[t];Kt(e,t),void 0!==o&&Jt(e,t,o)}}))}(t.global,e),this.setData(t),this.refresh(),i}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:o}=e;let n=!1;return{name:"@middleware/dragger",hover(){!0!==n&&t.trigger(mo.CURSOR,{type:"drag-default"})},pointStart(e){const{point:o}=e;i.setSharedStorage(Yn,o),n=!0,t.trigger(mo.CURSOR,{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(Yn);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(Yn,t)},pointEnd(){n=!1,i.setSharedStorage(Yn,null),t.trigger(mo.CURSOR,{type:"drag-default"})}}},e.MiddlewareInfo=(e,t)=>{const{boardContent:i,calculator:o,eventHub:n}=e,{overlayContext:l}=i;let a={...yn,...t},r=!0;const s=({show:e})=>{r=e};return{name:"@middleware/info",use(){n.on(mn,s)},disuse(){n.off(mn,s)},resetConfig(e){a={...a,...e}},beforeDrawFrame({snapshot:e}){var t;const{textBackground:i,textColor:n}=a,s={textBackground:i,textColor:n},{sharedStore:h}=e,c=h[zo],d=h[xo],u=h[Po]||[];if(1===c.length){const i=c[0];if(i&&["select","drag","resize"].includes(d)){const n=nt(e),a=lt(e),{x:h,y:c,w:d,h:f,angle:g}=i,v=[...u,{uuid:Ie(),x:h,y:c,w:d,h:f,angle:g,type:"group",detail:{children:[]}}],m={viewScaleInfo:n,viewSizeInfo:a},y=o.calcViewRectInfoFromOrigin(i.uuid,m);let p=0;v.forEach((e=>{p+=e.angle||0}));const w=at(yt(0-p));if(y){const e=null==y?void 0:y.center,o={topLeft:ut(e,y.topLeft,w),topRight:ut(e,y.topRight,w),bottomRight:ut(e,y.bottomRight,w),bottomLeft:ut(e,y.bottomLeft,w),center:ut(e,y.center,w),top:ut(e,y.top,w),right:ut(e,y.right,w),bottom:ut(e,y.bottom,w),left:ut(e,y.left,w)},n=Nt(i.x,{decimalPlaces:2}),a=Nt(i.y,{decimalPlaces:2}),h=Nt(i.w,{decimalPlaces:2}),c=Nt(i.h,{decimalPlaces:2}),d=`${Nt(n,{decimalPlaces:0})},${Nt(a,{decimalPlaces:0})}`,u=`${Nt(h,{decimalPlaces:0})}x${Nt(c,{decimalPlaces:0})}`,f=`${Nt(i.angle||0,{decimalPlaces:0})}°`;!function(e,t){const{point:i,rotateCenter:o,angle:n,text:l,style:a,fontSize:r,lineHeight:s}=t,{textColor:h,textBackground:c}=a;rt(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:r,fontFamily:vn});const t=(s-r)/2,o=e.$undoPixelRatio(e.measureText(l).width),n={x:i.x-o/2-t,y:i.y},a={x:n.x+o+2*t,y:n.y+r+t},d={x:i.x-o/2,y:i.y};e.setLineDash([]),e.fillStyle=c,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(a.x,n.y),e.lineTo(a.x,a.y),e.lineTo(n.x,a.y),e.closePath(),e.fill("nonzero"),e.fillStyle=h,e.textBaseline="top",e.fillText(l,d.x,d.y+t)}))}(l,{point:{x:o.bottom.x,y:o.bottom.y+pn},rotateCenter:o.center,angle:p,text:u,fontSize:pn,lineHeight:16,style:s}),function(e,t){const{point:i,rotateCenter:o,angle:n,text:l,style:a,fontSize:r,lineHeight:s}=t,{textBackground:h,textColor:c}=a;rt(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:r,fontFamily:vn});const t=(s-r)/2,o=e.$undoPixelRatio(e.measureText(l).width),n={x:i.x,y:i.y},a={x:n.x+o+2*t,y:n.y+r+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(a.x,n.y),e.lineTo(a.x,a.y),e.lineTo(n.x,a.y),e.closePath(),e.fill("nonzero"),e.fillStyle=c,e.textBaseline="top",e.fillText(l,d.x,d.y+t)}))}(l,{point:{x:o.topLeft.x,y:o.topLeft.y-20},rotateCenter:o.center,angle:p,text:d,fontSize:pn,lineHeight:16,style:s}),r&&!1!==(null==(t=i.operations)?void 0:t.rotatable)&&function(e,t){const{point:i,rotateCenter:o,angle:n,text:l,style:a,fontSize:r,lineHeight:s}=t,{textBackground:h,textColor:c}=a;rt(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:r,fontFamily:vn});const t=(s-r)/2,o=e.$undoPixelRatio(e.measureText(l).width),n={x:i.x,y:i.y},a={x:n.x+o+2*t,y:n.y+r+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(a.x,n.y),e.lineTo(a.x,a.y),e.lineTo(n.x,a.y),e.closePath(),e.fill("nonzero"),e.fillStyle=c,e.textBaseline="top",e.fillText(l,d.x,d.y+t)}))}(l,{point:{x:o.top.x+pn+4,y:o.top.y-20-18},rotateCenter:o.center,angle:p,text:f,fontSize:pn,lineHeight:16,style:s})}}}}}},e.MiddlewareLayoutSelector=(e,t)=>{const{sharer:i,boardContent:o,calculator:n,viewer:l,eventHub:a}=e,{overlayContext:r}=o;let s={...dn,...t},h=null,c=null,d=null,u=null;const f=()=>{h=null,i.setSharedStorage(nn,null),i.setSharedStorage(ln,null),i.setSharedStorage(an,null),i.setSharedStorage(rn,null),i.setSharedStorage(sn,null),i.setSharedStorage(hn,null),i.setSharedStorage(cn,null),c=null,d=null},g=()=>{const e=i.getSharedStorage(xo);return!(!e||"area"===e)&&(f(),!0)},v=()=>{const e=i.getActiveStorage("data");if(null==e?void 0:e.layout){const{x:t,y:i,w:o,h:n}=e.layout;return{x:t,y:i,w:o,h:n}}return null},m=e=>{const t=v();if(t){const{x:o,y:n,w:l,h:a}=t;return function(e,t){return Lt(e,Mt(t))}(e,Ct({x:o-5,y:n-5,w:l+10,h:a+10},{viewScaleInfo:i.getActiveViewScaleInfo()}))}return!1},y=()=>{const e=i.getActiveViewScaleInfo(),t=v();if(t){const o=jt(t,{viewScaleInfo:e,controllerSize:10});i.setSharedStorage(an,o)}else i.setSharedStorage(an,null)},p=e=>{const t=i.getActiveStorage("data"),o=i.getSharedStorage(an);let n=null;if(o&&(null==t?void 0:t.layout)&&(null==e?void 0:e.point)){let t=null;if(o){const{topLeft:l,top:r,topRight:s,right:h,bottomRight:c,bottom:d,bottomLeft:u,left:f}=o,g=[l,r,s,h,c,d,u,f];for(let i=0;i<g.length;i++){const o=g[i];if(Lt(e.point,o.vertexes)){t=`${o.type}`;break}}t&&(i.setSharedStorage(ln,t),a.trigger(mo.CLEAR_SELECT),n=t)}}return n?i.setSharedStorage(sn,!0):i.setSharedStorage(sn,!1),n},w=e=>{!0!==i.getSharedStorage(cn)&&a.trigger(mo.CURSOR,{type:e?`resize-${e}`:e,groupQueue:[],element:v()})};return{name:"@middleware/layout-selector",use:()=>{f(),y()},resetConfig(e){s={...s,...e}},hover:e=>{if(!0!==i.getSharedStorage(cn)&&!g()){if(m(e.point)?i.setSharedStorage(rn,!0):(i.setSharedStorage(rn,!1),!0===c&&(l.drawFrame(),c=!1)),!0===i.getSharedStorage(hn)){const t=i.getSharedStorage(nn),o=i.getActiveStorage("data");if(null==o?void 0:o.layout)if("resize"!==t){y();const t=p(e);t?w(t):(w(),i.setSharedStorage(nn,null))}else{const t=p(e);w(t)}return!0!==i.getSharedStorage(sn)&&void 0}return i.getSharedStorage(rn)&&!c&&l.drawFrame(),c=i.getSharedStorage(rn),!0!==i.getSharedStorage(sn)&&void 0}},pointStart:e=>{if(g())return;m(e.point)?i.setSharedStorage(hn,!0):(!0===d&&(f(),l.drawFrame()),i.setSharedStorage(hn,!1));const t=i.getActiveStorage("data");u=(null==t?void 0:t.layout)?St(t.layout):null,y();const o=p(e);return h=e.point,o&&i.setSharedStorage(nn,"resize"),!0!==i.getSharedStorage(hn)||d||(l.drawFrame(),a.trigger(mo.SELECT_LAYOUT)),d=i.getSharedStorage(hn),!0!==i.getSharedStorage(sn)&&void 0},pointMove:e=>{if(!i.getSharedStorage(hn)&&g())return;const t=i.getSharedStorage(nn),o=i.getSharedStorage(ln),a=i.getActiveStorage("data");if("resize"===t&&o&&(null==a?void 0:a.layout)){if(h){i.setSharedStorage(cn,!0);const t=i.getActiveStorage("scale"),r=e.point.x-h.x,s=e.point.y-h.y,c=r/t,d=s/t,{x:u,y:f,w:g,h:v,operations:m={}}=a.layout,{position:y="absolute"}=m;"top"===o?"relative"===y?(a.layout.h=n.toGridNum(v-d),l.scroll({moveY:s})):(a.layout.y=n.toGridNum(f+d),a.layout.h=n.toGridNum(v-d)):"right"===o?a.layout.w=n.toGridNum(g+c):"bottom"===o?a.layout.h=n.toGridNum(v+d):"left"===o?"relative"===y?(a.layout.w=n.toGridNum(g-c),l.scroll({moveX:r})):(a.layout.x=n.toGridNum(u+c),a.layout.w=n.toGridNum(g-c)):"top-left"===o?"relative"===y?(a.layout.w=n.toGridNum(g-c),a.layout.h=n.toGridNum(v-d),l.scroll({moveX:r,moveY:s})):(a.layout.x=n.toGridNum(u+c),a.layout.y=n.toGridNum(f+d),a.layout.w=n.toGridNum(g-c),a.layout.h=n.toGridNum(v-d)):"top-right"===o?"relative"===y?(l.scroll({moveY:s}),a.layout.w=n.toGridNum(g+c),a.layout.h=n.toGridNum(v-d)):(a.layout.y=n.toGridNum(f+d),a.layout.w=n.toGridNum(g+c),a.layout.h=n.toGridNum(v-d)):"bottom-right"===o?(a.layout.w=n.toGridNum(g+c),a.layout.h=n.toGridNum(v+d)):"bottom-left"===o&&("relative"===y?(l.scroll({moveX:r}),a.layout.w=n.toGridNum(g-c),a.layout.h=n.toGridNum(v+d)):(a.layout.x=n.toGridNum(u+c),a.layout.w=n.toGridNum(g-c),a.layout.h=n.toGridNum(v+d)))}return h=e.point,y(),l.drawFrame(),!1}return!["resize"].includes(t)&&void 0},pointEnd:()=>{i.setSharedStorage(cn,!1);const e=i.getSharedStorage(nn),t=i.getSharedStorage(ln),o=i.getActiveStorage("data");if(o&&"resize"===e&&t){let e;u&&(e={type:"modifyLayout",time:Date.now(),content:{method:"modifyLayout",before:Zt(u),after:Zt(St(o.layout))}}),a.trigger(mo.CHANGE,{type:"dragLayout",data:o,modifyRecord:e})}if(u=null,i.setSharedStorage(nn,null),i.setSharedStorage(ln,null),!0===i.getSharedStorage(sn))return!1},beforeDrawFrame:({snapshot:e})=>{var t;if(g())return;const{activeColor:i}=s,o={activeColor:i},{sharedStore:n,activeStore:l}=e,a=n[nn],h=n[rn],c=n[hn];if(null==(t=l.data)?void 0:t.layout){const{x:t,y:i,w:n,h:s}=l.data.layout,d=nt(e),u={x:t,y:i,w:n,h:s},f=jt(u,{viewScaleInfo:d,controllerSize:10});if(!0===h){const e=Ct(u,{viewScaleInfo:d});!function(e,t){const{layoutSize:i,style:o}=t,{activeColor:n}=o,{x:l,y:a,w:r,h:s}=i;e.setLineDash([]),e.strokeStyle=n,e.lineWidth=1,e.beginPath(),e.moveTo(l,a),e.lineTo(l+r,a),e.lineTo(l+r,a+s),e.lineTo(l,a+s),e.lineTo(l,a),e.closePath(),e.stroke()}(r,{layoutSize:e,style:o})}(a&&["resize"].includes(a)||!0===c)&&function(e,t){const{controller:i,style:o}=t,{topLeft:n,topRight:l,bottomLeft:a,bottomRight:r,topMiddle:s,rightMiddle:h,bottomMiddle:c,leftMiddle:d}=i;fn(e,{start:n.center,end:l.center,centerVertexes:s.vertexes,style:o}),fn(e,{start:l.center,end:r.center,centerVertexes:h.vertexes,style:o}),fn(e,{start:r.center,end:a.center,centerVertexes:c.vertexes,style:o}),fn(e,{start:a.center,end:n.center,centerVertexes:d.vertexes,style:o}),un(e,n.vertexes,o),un(e,l.vertexes,o),un(e,r.vertexes,o),un(e,a.vertexes,o)}(r,{controller:f,style:o})}},scrollX:()=>{f()},scrollY:()=>{f()},wheelScale:()=>{f()}}},e.MiddlewarePointer=e=>{const{boardContent:t,eventHub:i,sharer:o}=e,n=t.boardContext.canvas,l=e.container||document.body,a=`idraw-middleware-pointer-${Math.random().toString(26).substring(2)}`;let r=document.createElement("div");return{name:"@middleware/pointer",use(){r.setAttribute("id",a),r.style.position="fixed",r.style.top="0",r.style.bottom="unset",r.style.left="0",r.style.right="unset",l.appendChild(r)},disuse(){l.removeChild(r),r.remove(),r=null},contextMenu(e){const{point:t}=e,{left:l,top:a}=(()=>{const e=n.getBoundingClientRect(),{left:t,top:i,width:o,height:l}=e;return{left:t,top:i,width:o,height:l}})();r.style.left=`${l+t.x}px`,r.style.top=`${a+t.y}px`;const s=o.getSharedStorage(zo);i.trigger(mo.CONTEXT_MENU,{pointerContainer:r,selectedElements:s||[]})}}},e.MiddlewareRuler=(e,t)=>{const{boardContent:i,viewer:o,eventHub:n,calculator:l}=e,{overlayContext:a,underlayContext:r}=i;let s={...On,...t},h=!0,c=!0;const d=e=>{"boolean"==typeof(null==e?void 0:e.show)&&(h=e.show),"boolean"==typeof(null==e?void 0:e.showGrid)&&(c=e.showGrid),"boolean"!=typeof(null==e?void 0:e.show)&&"boolean"!=typeof(null==e?void 0:e.showGrid)||o.drawFrame()};return{name:"@middleware/ruler",use(){n.on(mo.RULER,d)},disuse(){n.off(mo.RULER,d)},resetConfig(e){s={...s,...e}},beforeDrawFrame:({snapshot:e})=>{const{background:t,borderColor:i,scaleColor:o,textColor:n,gridColor:d,gridPrimaryColor:u,selectedAreaColor:f}=s,g={background:t,borderColor:i,scaleColor:o,textColor:n,gridColor:d,gridPrimaryColor:u,selectedAreaColor:f};if(!0===h){const t=nt(e),i=lt(e);!function(e,t){const{viewSizeInfo:i,style:o}=t,{width:n,height:l}=i,{background:a,borderColor:r}=o;e.beginPath();const s=-1;e.moveTo(s,s),e.lineTo(n+1,s),e.lineTo(n+1,Ln),e.lineTo(Ln,Ln),e.lineTo(Ln,l+1),e.lineTo(s,l+1),e.lineTo(s,s),e.closePath(),e.fillStyle=a,e.fill("nonzero"),e.lineWidth=1,e.setLineDash([]),e.strokeStyle=r,e.stroke()}(a,{viewSizeInfo:i,style:g}),function(e,t){const{snapshot:i,calculator:o,style:n}=t,{sharedStore:l}=i,{selectedAreaColor:a}=n,r=l[zo],s=l[xo];if(["select","drag","drag-list","drag-list-end"].includes(s)&&r.length>0){const t=nt(i),n=lt(i),l=[],s=[],h=[],c=[],d=[];if(r.forEach((e=>{const i=o.calcViewRectInfoFromRange(e.uuid,{viewScaleInfo:t,viewSizeInfo:n});i&&(l.push(i),s.push(i.left.x),h.push(i.right.x),c.push(i.top.y),d.push(i.bottom.y))})),!(l.length>0))return;const u=Math.min(...s),f=Math.max(...h),g=Math.min(...c),v=Math.max(...d);e.globalAlpha=1,e.beginPath(),e.moveTo(u,0),e.lineTo(f,0),e.lineTo(f,Ln),e.lineTo(u,Ln),e.fillStyle=a,e.closePath(),e.fill("nonzero"),e.beginPath(),e.moveTo(0,g),e.lineTo(Ln,g),e.lineTo(Ln,v),e.lineTo(0,v),e.fillStyle=a,e.closePath(),e.fill("nonzero")}}(a,{snapshot:e,calculator:l,style:g});const{list:o,rulerUnit:n}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:n}=t,{width:l}=i;return Dn({scale:o,viewLength:l,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:l}=o;for(let t=0;t<i.length;t++){const o=i[t];o.position<Ln||(e.beginPath(),e.moveTo(o.position,16),e.lineTo(o.position,o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8),e.closePath(),e.lineWidth=1,e.setLineDash([]),e.fillStyle=n,e.stroke(),o.isKeyNum&&(e.fillStyle=l,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:kn}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(a,{scaleList:o,style:g});const{list:s}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n}=t,{height:l}=i;return Dn({scale:o,viewLength:l,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});if(function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:l}=o,a=3.2;for(let t=0;t<i.length;t++){const o=i[t];if(!(o.position<Ln)&&(e.beginPath(),e.moveTo(16,o.position),e.lineTo(o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8,o.position),e.closePath(),e.fillStyle=n,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===o.showNum)){const t=a,i=o.position+a,n=`${o.num}`;rt(e,-90,{x:t,y:i},(()=>{e.fillStyle=l,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:kn}),e.fillText(n,13.2,o.position+a)}))}}}(a,{scaleList:s,style:g}),!0===c){!function(e,t){const{xList:i,yList:o,viewSizeInfo:n,style:l}=t,{width:a,height:r}=n,{gridColor:s,gridPrimaryColor:h}=l;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=h:e.strokeStyle=s,e.closePath(),e.lineWidth=1,e.setLineDash([]),e.stroke()}for(let t=0;t<o.length;t++){const i=o[t];e.beginPath(),e.moveTo(0,i.position),e.lineTo(a,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=s,e.lineWidth=1,e.closePath(),e.stroke()}}(1===n?a:r,{xList:o,yList:s,viewSizeInfo:i,style:g})}}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:o}=e;return{name:"@middleware/scaler",wheelScale(e){const{deltaY:n,point:l}=e,{scale:a}=i.getActiveViewScaleInfo();let r=a;if(n<0?r=1.1*a:n>0&&(r=.9*a),r<.05||r>50)return;const{moveX:s,moveY:h}=t.scale({scale:r,point:l});t.scroll({moveX:s,moveY:h}),t.drawFrame();const c=Nt(a);o.trigger(mo.SCALE,{scale:c})}}},e.MiddlewareScroller=(e,t)=>{const{viewer:i,boardContent:o,sharer:n,eventHub:l}=e,{overlayContext:a}=o;n.setSharedStorage(xn,null),n.setSharedStorage(Sn,null);let r=!1,s={...Rn,...t};const h=()=>{n.setSharedStorage(In,null),n.setSharedStorage(Mn,null),n.setSharedStorage(zn,null),n.setSharedStorage(bn,null),n.setSharedStorage(An,null),r=!1};h();const c=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:l}=i;return n&&Cn(e,t,n)?o="X":l&&Cn(e,t,l)&&(o="Y"),o}(a,e,{xThumbRect:n.getSharedStorage(xn),yThumbRect:n.getSharedStorage(Sn)});return{name:"@middleware/scroller",resetConfig(e){s={...s,...e}},wheel:e=>{i.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),i.drawFrame()},hover:e=>{if(!0===r)return!1;const{point:t}=e,i=c(t);if("X"===i||"Y"===i)return"X"===i?(n.setSharedStorage(bn,!0),n.setSharedStorage(An,!1)):(n.setSharedStorage(bn,!1),n.setSharedStorage(An,!0)),l.trigger(mo.CURSOR,{type:"default"}),!1;n.setSharedStorage(bn,!1),n.setSharedStorage(An,!1)},pointStart:e=>{const{point:t}=e,i=c(t);if("X"===i||"Y"===i)return r=!0,n.setSharedStorage(zn,i),n.setSharedStorage(In,t),!1},pointMove:e=>{const{point:t}=e,o=n.getSharedStorage(zn);if("X"===o||"Y"===o)return n.setSharedStorage(Mn,t),"X"===o?(e=>{const t=n.getSharedStorage(In);if(t){const{offsetLeft:o,offsetRight:l}=n.getActiveViewScaleInfo(),{width:a}=n.getActiveViewSizeInfo(),r=-(e.x-t.x)*(a+Math.abs(o)+Math.abs(l))/a;i.scroll({moveX:r}),i.drawFrame()}})(t):"Y"===o&&(e=>{const t=n.getSharedStorage(In);if(t){const{offsetTop:o,offsetBottom:l}=n.getActiveViewScaleInfo(),{height:a}=n.getActiveViewSizeInfo(),r=-(e.y-t.y)*(a+Math.abs(o)+Math.abs(l))/a;i.scroll({moveY:r}),i.drawFrame()}})(t),n.setSharedStorage(In,t),!1},pointEnd:()=>{r=!1;const e=n.getSharedStorage(zn);if(h(),"X"===e||"Y"===e)return i.scroll({moveX:0,moveY:0}),i.drawFrame(),!1},beforeDrawFrame({snapshot:e}){const{thumbBackground:t,thumbBorderColor:i,hoverThumbBackground:o,hoverThumbBorderColor:l,activeThumbBackground:r,activeThumbBorderColor:h}=s,c={thumbBackground:t,thumbBorderColor:i,hoverThumbBackground:o,hoverThumbBorderColor:l,activeThumbBackground:r,activeThumbBorderColor:h},{xThumbRect:d,yThumbRect:u}=En(a,{snapshot:e,style:c});n.setSharedStorage(xn,d),n.setSharedStorage(Sn,u)}}},e.MiddlewareSelector=(e,t)=>{let i={...Wo,...t};const{viewer:o,sharer:n,boardContent:l,calculator:a,eventHub:r}=e,{overlayContext:s}=l;let h=null,c=[],d=null,u=null,f=null,g=null,v=gn({fill:i.activeColor,devicePixelRatio:n.getActiveViewSizeInfo().devicePixelRatio});n.setSharedStorage(xo,null),n.setSharedStorage(Oo,!0);const m=()=>n.getSharedStorage(zo),y=e=>{let t=n.getSharedStorage(Po);Array.isArray(t)||(t=[]),t.length>0?!function(e,t){var i;if("group"===(null==t?void 0:t.type)&&Array.isArray(null==(i=null==t?void 0:t.detail)?void 0:i.children))for(let i=0;i<t.detail.children.length;i++){const o=t.detail.children[i];if(e.uuid===o.uuid)return!0}return!1}(e,t[t.length-1])?t=[]:t.push(e):0===t.length&&t.push(e);const i=zt(t);return n.setSharedStorage(Po,t),n.setSharedStorage(Eo,i),t.length>0},p=e=>{n.setSharedStorage(Io,e);let t=null;e&&(t=Rt(e,{groupQueue:n.getSharedStorage(Po)})),n.setSharedStorage(Mo,t)},w=()=>{const e=n.getSharedStorage(zo);if(1===e.length){const t=Dt(e[0],{groupQueue:n.getSharedStorage(Po),controllerSize:10,viewScaleInfo:n.getActiveViewScaleInfo(),rotateControllerPosition:22,rotateControllerSize:20});n.setSharedStorage(Co,t)}},x=(e,t)=>{var i;if(n.setSharedStorage(zo,e),1===e.length?(w(),n.setSharedStorage(To,At(e[0].uuid,(null==(i=n.getActiveStorage("data"))?void 0:i.elements)||[]))):(n.setSharedStorage(Co,null),n.setSharedStorage(To,[])),!0===(null==t?void 0:t.triggerEvent)){const t=e.map((e=>e.uuid)),i=n.getActiveStorage("data"),o=function(e,t){const i=[],o={};let n=!1;const l=t=>{var a;for(let r=0;r<t.length&&!0!==n;r++){i.push(r);const s=t[r];if(e.includes(s.uuid)){if(o[s.uuid]=[...i],Object.keys(o).length===e.length){n=!0;break}}else"group"===s.type&&l((null===(a=null==s?void 0:s.detail)||void 0===a?void 0:a.children)||[]);if(n)break;i.pop()}};return l(t),o}(t,(null==i?void 0:i.elements)||[]);r.trigger(mo.SELECT,{type:"clickCanvas",uuids:t,positions:e.map((e=>[...o[e.uuid]]))})}},S=()=>({ctx:s,calculator:a,data:n.getActiveStorage("data"),selectedElements:m(),viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:n.getSharedStorage(Po),areaSize:null,selectedElementController:n.getSharedStorage(Co),selectedElementPosition:n.getSharedStorage(To)}),b=()=>{n.setSharedStorage(xo,null),n.setSharedStorage(So,null),n.setSharedStorage(bo,null),n.setSharedStorage(Ao,null),n.setSharedStorage(Po,[]),n.setSharedStorage(Eo,[]),n.setSharedStorage(Io,null),n.setSharedStorage(Mo,null),n.setSharedStorage(zo,[]),n.setSharedStorage(Ro,null),n.setSharedStorage(Co,null),n.setSharedStorage(To,[]),n.setSharedStorage(Lo,null)};b();const A=({uuids:e=[],positions:t})=>{let i=[];const l=n.getSharedStorage(xo),a=n.getActiveStorage("data");i=t&&Array.isArray(t)?function(e,t){const i=[];return e.forEach((e=>{const o=bt(e,t);o&&i.push(o)})),i}(t,(null==a?void 0:a.elements)||[]):function(e,t){const i=[];return function t(o){var n;for(let l=0;l<o.length;l++){const a=o[l];e.includes(a.uuid)?i.push(a):"group"===a.type&&t((null===(n=null==a?void 0:a.detail)||void 0===n?void 0:n.children)||[])}}(t),i}(e,(null==a?void 0:a.elements)||[]);let r=!1;if(l||1!==i.length?"select"===l&&1===i.length&&(r=!0):(n.setSharedStorage(xo,"select"),r=!0),r){const e=function(e,t){const i=[];return function e(t,o){var n;let l=null;for(let a=0;a<o.length;a++){const r=o[a];if(r.uuid===t){l=r;break}if(!l&&"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){l=o;break}i.pop()}}return l}(e,t),i}(i[0].uuid,(null==a?void 0:a.elements)||[]);n.setSharedStorage(Po,e),x(i),o.drawFrame()}},I=()=>{b(),o.drawFrame()},M=e=>{n.setSharedStorage(Oo,!!e.enable)},z=e=>{n.setSharedStorage(ko,!!e.enable)};return{name:"@middleware/selector",use(){r.on(mo.SELECT,A),r.on(mo.CLEAR_SELECT,I),r.on(mo.SELECT_IN_GROUP,z),r.on(mo.SNAP_TO_GRID,M)},disuse(){r.off(mo.SELECT,A),r.off(mo.CLEAR_SELECT,I),r.off(mo.SELECT_IN_GROUP,z),r.off(mo.SNAP_TO_GRID,M),b(),i=null},resetConfig(e){i={...i,...e}},hover:e=>{var t,i,l,a,h;const c=n.getSharedStorage(hn);if(!0===n.getSharedStorage(cn))return;const d=n.getSharedStorage(So),u=n.getSharedStorage(xo),g=n.getSharedStorage(Po),v=e=>{if(!0===c)return;const t=e.type;null===f&&r.trigger(mo.CURSOR,{type:t,groupQueue:e.groupQueue,element:e.elements[0]})};if((null==g?void 0:g.length)>0){if(!Uo(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:n.getSharedStorage(Po)}))return p(null),void o.drawFrame();const i=$o(e.point,S());return v(i),d||["area","drag","drag-list"].includes(u)?(p(null),void o.drawFrame()):1===(null==(t=null==i?void 0:i.elements)?void 0:t.length)?(p(i.elements[0]),void o.drawFrame()):(p(null),void o.drawFrame())}if(d||["area","drag","drag-list"].includes(u))return void p(null);if("drag"===u)return void p(null);const y=m(),w=n.getActiveViewScaleInfo();n.getActiveViewSizeInfo();const x=$o(e.point,{...S(),areaSize:Ko(y,{viewScaleInfo:w})});if(v(x),null!==x.type){if(!("over-element"===x.type&&"select"===n.getSharedStorage(xo)&&1===x.elements.length&&x.elements[0].uuid===(null==(l=null==(i=m())?void 0:i[0])?void 0:l.uuid)||"over-element"===x.type&&null===n.getSharedStorage(xo)&&1===x.elements.length&&x.elements[0].uuid===(null==(a=n.getSharedStorage(Io))?void 0:a.uuid)))return"over-element"===x.type&&1===(null==(h=null==x?void 0:x.elements)?void 0:h.length)?(p(x.elements[0]),void o.drawFrame()):n.getSharedStorage(Io)?(p(null),void o.drawFrame()):void 0}else(n.getSharedStorage(Io)||n.getSharedStorage(Mo))&&(n.setSharedStorage(Io,null),n.setSharedStorage(Mo,null),o.drawFrame())},pointStart:e=>{var t,i,l,a,r,f,g,v,y,w,A,I;h=e.point,d=e.point;const M=n.getSharedStorage(Po);if((null==M?void 0:M.length)>0){if(Uo(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:M})){const o=$o(e.point,S()),s=1===(null==(t=null==o?void 0:o.elements)?void 0:t.length)&&!0===(null==(l=null==(i=o.elements[0])?void 0:i.operations)?void 0:l.locked);p(null),1===(null==(a=null==o?void 0:o.elements)?void 0:a.length)&&(u=St(null==o?void 0:o.elements[0])),!0===s?b():"over-element"===o.type&&1===(null==(r=null==o?void 0:o.elements)?void 0:r.length)?(x([o.elements[0]],{triggerEvent:!0}),n.setSharedStorage(xo,"drag"),c=[{...St(null==o?void 0:o.elements[0]),uuid:null==o?void 0:o.elements[0].uuid}]):(null==(f=o.type)?void 0:f.startsWith("resize-"))?(n.setSharedStorage(So,o.type),n.setSharedStorage(xo,"resize")):x([],{triggerEvent:!0})}else b();return void o.drawFrame()}const z=Ko(m(),{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),R=$o(e.point,{...S(),areaSize:z,groupQueue:[]}),C=1===(null==(g=null==R?void 0:R.elements)?void 0:g.length)&&!0===(null==(y=null==(v=R.elements[0])?void 0:v.operations)?void 0:y.locked);p(null),1===(null==(w=null==R?void 0:R.elements)?void 0:w.length)&&(u=St(null==R?void 0:R.elements[0])),!0===C?(b(),n.setSharedStorage(xo,"area"),n.setSharedStorage(bo,e.point),x([],{triggerEvent:!0})):"list-area"===R.type?n.setSharedStorage(xo,"drag-list"):"over-element"===R.type&&1===(null==(A=null==R?void 0:R.elements)?void 0:A.length)?(x([R.elements[0]],{triggerEvent:!0}),n.setSharedStorage(xo,"drag"),c=[{...St(null==R?void 0:R.elements[0]),uuid:null==R?void 0:R.elements[0].uuid}]):(null==(I=R.type)?void 0:I.startsWith("resize-"))?(n.setSharedStorage(So,R.type),n.setSharedStorage(xo,"resize")):(b(),n.setSharedStorage(xo,"area"),n.setSharedStorage(bo,e.point),x([],{triggerEvent:!0})),o.drawFrame()},pointMove:e=>{var t,i,l;n.setSharedStorage(Lo,!0);const s=n.getActiveStorage("data"),c=m(),v=n.getActiveStorage("scale")||1,y=n.getActiveViewScaleInfo(),p=n.getActiveViewSizeInfo(),w=h,S=d,b=e.point,A=n.getSharedStorage(So),I=n.getSharedStorage(xo),M=n.getSharedStorage(Po),z=n.getSharedStorage(Oo);if("drag"===I){if(g=!0,f="drag",r.trigger(mn,{show:!1}),s&&1===(null==c?void 0:c.length)&&u&&S&&b&&!0!==(null==(i=null==(t=c[0])?void 0:t.operations)?void 0:i.locked)){const{moveX:e,moveY:t}=function(e,t,i){let o=t.x-e.x,n=t.y-e.y;const l=[];if(i.forEach((e=>{const{x:t,y:i,w:o,h:n,angle:a=0}=e;l.push({x:t,y:i,w:o,h:n,angle:0-a})})),(null==i?void 0:i.length)>0){const i=ft(e,l),a=ft(t,l);o=a.x-i.x,n=a.y-i.y}return{moveX:o,moveY:n}}(S,b,M);let i=a.toGridNum(e/v),o=a.toGridNum(t/v);if(!0===z){const e=tn(c[0].uuid,{calculator:a,data:s,groupQueue:M,viewScaleInfo:y,viewSizeInfo:p});try{e&&(Ye.x(e.offsetX)&&null!==e.offsetX&&(i=a.toGridNum(i+e.offsetX)),Ye.y(e.offsetY)&&null!==e.offsetY&&(o=a.toGridNum(o+e.offsetY)))}catch(e){console.error(e)}}c[0].x=a.toGridNum(u.x+i),c[0].y=a.toGridNum(u.y+o),x([c[0]]),a.modifyVirtualFlatItemMap(s,{modifyInfo:{type:"updateElement",content:{element:c[0],position:n.getSharedStorage(To)||[]}},viewSizeInfo:p,viewScaleInfo:y})}o.drawFrame()}else if("drag-list"===I){if(g=!0,f="drag-list",s&&S&&w&&b&&(null==c?void 0:c.length)>1){const e=(b.x-w.x)/v,t=(b.y-w.y)/v;c.forEach((i=>{var o;i&&!0!==(null==(o=null==i?void 0:i.operations)?void 0:o.locked)&&(i.x=a.toGridNum(i.x+e),i.y=a.toGridNum(i.y+t),a.modifyVirtualFlatItemMap(s,{modifyInfo:{type:"updateElement",content:{element:i,position:At(i.uuid,s.elements)||[]}},viewSizeInfo:p,viewScaleInfo:y}))})),n.setActiveStorage("data",s)}o.drawFrame()}else if("resize"===I){if(s&&1===(null==c?void 0:c.length)&&S&&u&&(null==A?void 0:A.startsWith("resize-"))){g=!0,f="resize";const e=[];M.forEach((t=>{const{x:i,y:o,w:n,h:l,angle:a=0}=t;e.push({x:i,y:o,w:n,h:l,angle:0-a})}));let t=S,i=b;if(M.length>0&&(t=ft(S,e),i=ft(b,e)),"resize-rotate"===A){const e=n.getSharedStorage(Co),t=ct([e.topLeft.center,e.topRight.center,e.bottomLeft.center,e.bottomRight.center]),i=Jo(u,{center:t,viewScaleInfo:y,start:S,end:b});c[0].angle=a.toGridNum(i.angle||0)}else{const e=function(e,t){var i,o,n,l,a,r,s,h,c;let{x:d,y:u,w:f,h:g,angle:v=0}=e;const m=ht({x:d,y:u,w:f,h:g});v=yt(v);const y=at(v),p=!!(null==(i=null==e?void 0:e.operations)?void 0:i.limitRatio),{start:w,end:x,resizeType:S,scale:b}=t;let A={...w},I={...x},M={x:A.x,y:m.y},z={x:I.x,y:m.y},R={...M},C={...z},T={x:m.x,y:A.y},P={x:m.x,y:I.y},E={...T},L={...P},k=(C.x-R.x)/b,O=(C.y-R.y)/b,W=Ho(k,O),D=(L.x-E.x)/b,j=(L.y-E.y)/b,Y=Ho(D,j);(v>0||v<0)&&(A=ut(m,w,0-y),I=ut(m,x,0-y),M={x:A.x,y:m.y},z={x:I.x,y:m.y},R=ut(m,M,y),C=ut(m,z,y),T={x:m.x,y:A.y},P={x:m.x,y:I.y},E=ut(m,T,y),L=ut(m,P,y),k=(C.x-R.x)/b,O=(C.y-R.y)/b,W=Ho(k,O),W=Zo(W,O),D=(L.x-E.x)/b,j=(L.y-E.y)/b,Y=Ho(D,j),Y=Zo(Y,j));let N=(x.x-w.x)/b,B=(x.y-w.y)/b;if(!0===p)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(S)){const t=Math.max(Math.abs(N),Math.abs(B));N=(N>=0?1:-1)*t,B=(B>=0?1:-1)*t/e.w*e.h;const i=Math.max(Math.abs(D),Math.abs(j));D=(D>=0?1:-1)*i,j=(j>=0?1:-1)*i/e.w*e.h;const o=Math.max(Math.abs(k),Math.abs(O));k=(k>=0?1:-1)*o,O=(O>=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(N);N=(N>=0?1:-1)*t;const i=t/e.w*e.h;"resize-top-left"===S||"resize-bottom-right"===S?B=N>0?i:-i:"resize-top-right"!==S&&"resize-bottom-left"!==S||(B=N>0?-i:i)}W=Math.abs(W),Y=W/e.w*e.h}switch(S){case"resize-top":if(0===v)g-B>0&&(u+=B,g-=B,!0===(null==(o=e.operations)?void 0:o.limitRatio)&&(d+=B/e.h*e.w/2,f-=B/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=0-Zo(Y,j);const e=Xo(v),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){Y=Zo(Y,D);const e=Xo(v-90),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){Y=Zo(Y,j);const e=Xo(v-180),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){Y=0-Zo(Y,D);const e=Xo(v-270),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}g+Y>0&&(!0===(null==(n=e.operations)?void 0:n.limitRatio)&&(f+=Y/e.h*e.w),g+=Y,d=t-f/2,u=i-g/2)}break;case"resize-bottom":if(0===v)e.h+B>0&&(g+=B,!0===(null==(l=e.operations)?void 0:l.limitRatio)&&(d-=B/e.h*e.w/2,f+=B/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=Zo(Y,j);const e=Xo(v),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){Y=0-Zo(Y,D);const e=Xo(v-90),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){Y=Zo(Y,D);const e=Xo(v-180),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){Y=Zo(Y,D);const e=Xo(v-270),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}g+Y>0&&(!0===(null==(a=e.operations)?void 0:a.limitRatio)&&(f+=Y/e.h*e.w),g+=Y,d=t-f/2,u=i-g/2)}break;case"resize-left":if(0===v)e.w-N>0&&(d+=N,f-=N,!0===(null==(r=e.operations)?void 0:r.limitRatio)&&(g-=N/e.w*e.h,u+=N/e.w*e.h/2));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){W=0-Zo(W,k);const e=Xo(v),o=W/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){W=Zo(W,k);const e=Xo(v-90),o=W/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){W=Zo(W,O);const e=Xo(v-180),o=W/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){W=Zo(W,O);const e=Xo(v-270),o=W/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}f+W>0&&(!0===(null==(s=e.operations)?void 0:s.limitRatio)&&(g+=W/e.w*e.h),f+=W,d=t-f/2,u=i-g/2)}break;case"resize-right":if(0===v)e.w+N>0&&(f+=N,!0===(null==(h=e.operations)?void 0:h.limitRatio)&&(u-=N*e.h/e.w/2,g+=N*e.h/e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){W=Zo(W,O);const e=Xo(v),o=W/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){W=Zo(W,B);const e=Xo(v-90),o=W/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){W=Zo(W,B);const e=Xo(v-180),o=W/2;t+=o*Math.cos(e),i+=o*Math.sin(e),W=0-W}else if(v<360){W=Zo(W,N);const e=Xo(v-270),o=W/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}f+W>0&&(!0===(null==(c=e.operations)?void 0:c.limitRatio)&&(g+=W/e.w*e.h),f+=W,d=t-f/2,u=i-g/2)}break;case"resize-top-left":if(0===v)f-N>0&&(d+=N,f-=N),g-B>0&&(u+=B,g-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-Zo(Y,j),W=0-Zo(W,p?0-Y:k);const i=Y/2;e+=i*Math.sin(y),t-=i*Math.cos(y);const o=W/2;e-=o*Math.cos(y),t-=o*Math.sin(y)}else if(v<180){Y=Zo(Y,D),W=Zo(W,p?Y:k);const i=Xo(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=W/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=Zo(Y,j),W=Zo(W,p?Y:O);const i=Xo(v-180),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=W/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=0-Zo(Y,D),W=Zo(W,p?Y:O);const i=Xo(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=W/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),f+W>0&&(f+=W),d=e-f/2,u=t-g/2}break;case"resize-top-right":if(0===v)f+N>0&&(f+=N),g-B>0&&(u+=B,g-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-Zo(Y,j),W=Zo(W,p?Y:O);const i=Xo(v),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=W/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=Zo(Y,D),W=Zo(W,p?Y:O);const i=Xo(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=W/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){const i=Xo(v-180);Y=Zo(Y,j),W=Zo(W,p?Y:0-k);const o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=W/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=0-Zo(Y,D),W=Zo(W,p?Y:k);const i=Xo(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=W/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),f+W>0&&(f+=W),d=e-f/2,u=t-g/2}break;case"resize-bottom-left":if(0===v)e.h+B>0&&(g+=B),e.w-N>0&&(d+=N,f-=N);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=Zo(Y,j),W=0-Zo(W,p?0-Y:k);const i=Xo(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=W/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<180){Y=0-Zo(Y,D),W=Zo(W,p?Y:k);const i=Xo(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=W/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=Zo(Y,D),W=Zo(W,p?Y:O);const i=Xo(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=W/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=Zo(Y,D),W=Zo(W,p?Y:O);const i=Xo(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=W/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),f+W>0&&(f+=W),d=e-f/2,u=t-g/2}break;case"resize-bottom-right":if(0===v)e.h+B>0&&(g+=B),e.w+N>0&&(f+=N);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=Zo(Y,j),W=Zo(W,p?Y:O);const i=Xo(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=W/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=0-Zo(Y,D),W=Zo(W,p?Y:B);const i=Xo(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=W/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){Y=Zo(Y,D),W=Zo(W,p?Y:0-O);const i=Xo(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=W/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=Zo(Y,D),W=Zo(W,p?Y:k);const i=Xo(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=W/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),f+W>0&&(f+=W),d=e-f/2,u=t-g/2}}return{x:d,y:u,w:f,h:g,angle:e.angle}}({...u,operations:c[0].operations},{scale:v,start:t,end:i,resizeType:A}),o={ignore:!!u.angle};c[0].x=a.toGridNum(e.x,o),c[0].y=a.toGridNum(e.y,o),"group"===c[0].type&&!0===(null==(l=c[0].operations)?void 0:l.deepResize)?ti(c[0],{w:a.toGridNum(e.w,o),h:a.toGridNum(e.h,o)}):(c[0].w=a.toGridNum(e.w,o),c[0].h=a.toGridNum(e.h,o))}x([c[0]]),a.modifyVirtualFlatItemMap(s,{modifyInfo:{type:"updateElement",content:{element:c[0],position:n.getSharedStorage(To)||[]}},viewSizeInfo:p,viewScaleInfo:y}),o.drawFrame()}}else"area"===I&&(f="area",n.setSharedStorage(Ao,e.point),o.drawFrame());h=e.point},pointEnd(e){f=null,n.setSharedStorage(Lo,!1);const t=n.getActiveStorage("data"),i=n.getSharedStorage(zo),l=n.getSharedStorage(Io),s=n.getSharedStorage(So),v=n.getSharedStorage(xo),m=n.getActiveViewSizeInfo();let y=!1;if(h=null,d=null,u=null,"drag"===v&&r.trigger(mn,{show:!0}),"resize"===v&&s)n.setSharedStorage(So,null),y=!0;else if("area"===v){if(n.setSharedStorage(xo,null),t){const e=n.getSharedStorage(bo),i=n.getSharedStorage(Ao);if(e&&i){const{elements:o}=function(e,t){var i;const o=[],n=[],l=[],{viewScaleInfo:a,start:r,end:s}=t;if(!(Array.isArray(e.elements)&&r&&s))return{indexes:o,uuids:n,elements:l};const h=Math.min(r.x,s.x),c=Math.max(r.x,s.x),d=Math.min(r.y,s.y),u=Math.max(r.y,s.y);for(let t=0;t<e.elements.length;t++){const r=e.elements[t];if(!0===(null==(i=null==r?void 0:r.operations)?void 0:i.locked))continue;const s=Ct(r,{viewScaleInfo:a}),f=ht(s);if(f.x>=h&&f.x<=c&&f.y>=d&&f.y<=u&&(o.push(t),n.push(r.uuid),l.push(r),s.angle&&(s.angle>0||s.angle<0))){const e=vt(s);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];s.x=Math.min(...t),s.y=Math.min(...i),s.w=Math.abs(Math.max(...t)-Math.min(...t)),s.h=Math.abs(Math.max(...i)-Math.min(...i))}}}return{indexes:o,uuids:n,elements:l}}(t,{start:e,end:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});o.length>0&&(n.setSharedStorage(xo,"drag-list"),x(o,{triggerEvent:!0}),y=!0)}}}else if("drag-list"===v)n.setSharedStorage(xo,"drag-list-end"),y=!0;else if(t){a.getPointElement(e.point,{data:t,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}).element?(n.setSharedStorage(xo,"select"),y=!0):n.setSharedStorage(xo,null)}null===n.getSharedStorage(xo)&&(b(),y=!0);(()=>{if(y){if(t&&Array.isArray(null==t?void 0:t.elements)&&["drag","drag-list"].includes(v)){const e=function(e,t,i){const o=wt(e,{viewWidth:t.width,viewHeight:t.height,extend:null==i?void 0:i.extend});return!0===(null==i?void 0:i.extend)&&(o.contextWidth=Math.max(o.contextWidth,t.contextWidth),o.contextHeight=Math.max(o.contextHeight,t.contextHeight)),{contextSize:o}}(t.elements,m,{extend:!0});n.setActiveStorage("contextHeight",e.contextSize.contextHeight),n.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(t&&["drag","drag-list","drag-list-end","resize"].includes(v)){let e="dragElement";if(g){const o=c[0];let n;1===i.length?n={type:"dragElement",time:0,content:{method:"modifyElement",uuid:o.uuid,before:Ht(o),after:Ht(St(i[0]))}}:i.length>1&&(n={type:"dragElements",time:0,content:{method:"modifyElements",before:c.map((e=>({...Ht(e),uuid:e.uuid}))),after:i.map((e=>({...Ht(St(e)),uuid:e.uuid})))}}),r.trigger(mo.CHANGE,{data:t,type:e,selectedElements:i,hoverElement:l,modifyRecord:n}),g=!1}}o.drawFrame()}})()},pointLeave(){f=null,n.setSharedStorage(So,null),r.trigger(mo.CURSOR,{type:"default"})},doubleClick(e){var t,i,l,a,s,h,c,d;if(!1===n.getSharedStorage(ko))return;const u=$o(e.point,S());if(n.setSharedStorage(Co,null),n.setSharedStorage(zo,[]),1!==u.elements.length||!0!==(null==(i=null==(t=u.elements[0])?void 0:t.operations)?void 0:i.locked)){if(1===u.elements.length&&"group"===(null==(l=u.elements[0])?void 0:l.type)){if(!0===y(u.elements[0]))return n.setSharedStorage(xo,null),void o.drawFrame()}else 1!==u.elements.length||"text"!==(null==(a=u.elements[0])?void 0:a.type)||(null==(h=null==(s=u.elements[0])?void 0:s.operations)?void 0:h.invisible)||r.trigger(mo.TEXT_EDIT,{element:u.elements[0],groupQueue:n.getSharedStorage(Po)||[],position:At(null==(c=u.elements[0])?void 0:c.uuid,(null==(d=n.getActiveStorage("data"))?void 0:d.elements)||[]),viewScaleInfo:n.getActiveViewScaleInfo()});n.setSharedStorage(xo,null)}},wheel(){w()},wheelScale(){w()},contextMenu:e=>{var t,i,l,a,r,h,c,d;const u=n.getSharedStorage(Po);if((null==u?void 0:u.length)>0){if(Uo(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:u})){const n=$o(e.point,S());1===(null==(t=null==n?void 0:n.elements)?void 0:t.length)&&!0!==(null==(l=null==(i=n.elements[0])?void 0:i.operations)?void 0:l.locked)?(b(),x([n.elements[0]],{triggerEvent:!0}),o.drawFrame()):(null==(a=null==n?void 0:n.elements)?void 0:a.length)||b()}return}const f=Ko(m(),{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),g=$o(e.point,{...S(),areaSize:f,groupQueue:[]});if(1===(null==(r=null==g?void 0:g.elements)?void 0:r.length)&&!0!==(null==(c=null==(h=g.elements[0])?void 0:h.operations)?void 0:c.locked))return b(),x([g.elements[0]],{triggerEvent:!0}),void o.drawFrame();(null==(d=null==g?void 0:g.elements)?void 0:d.length)||b()},beforeDrawFrame({snapshot:t}){var o;const{activeColor:n,activeAreaColor:l,lockedColor:r,referenceColor:h}=i,c={activeColor:n,activeAreaColor:l,lockedColor:r,referenceColor:h},{activeStore:d,sharedStore:u}=t,{scale:f,offsetLeft:g,offsetTop:y,offsetRight:p,offsetBottom:w,width:x,height:S,contextHeight:b,contextWidth:A,devicePixelRatio:I}=d;v.fill!==n&&(v=gn({fill:i.activeColor,devicePixelRatio:I}));const M=e.sharer,z={scale:f,offsetLeft:g,offsetTop:y,offsetRight:p,offsetBottom:w},R={width:x,height:S,contextHeight:b,contextWidth:A,devicePixelRatio:I},C=u[zo],T=C[0],P=u[Io],E=u[Mo],L=u[xo],k=u[bo],O=u[Ao],W=u[Po],D=u[Eo],j=u[Lo],Y=u[Oo],N={calculator:a,viewScaleInfo:z,viewSizeInfo:R,style:c};let B=u[Co];var F,G;B&&1===C.length&&T&&(F=T,G=B.originalElementSize,(F.x!==G.x||F.y!==G.y||F.h!==G.h||F.w!==G.w||yt(F.angle||0)!==yt(G.angle||0))&&(B=Dt(T,{groupQueue:W||[],controllerSize:10,viewScaleInfo:z,rotateControllerPosition:22,rotateControllerSize:20}),M.setSharedStorage(Co,B)));const V=!!(null==(o=null==P?void 0:P.operations)?void 0:o.locked);if((null==W?void 0:W.length)>0){if(function(e,t,i){const{style:o}=i,{activeColor:n}=o;for(let o=0;o<t.length;o++){const l={borderColor:n,borderWidth:2,background:"transparent",lineDash:[4,4]};Do(e,Pt(t[o],i),l)}}(s,D,N),P&&"drag"!==L&&(V?Fo(s,E,{...N,controller:B,style:c}):Bo(s,E,N)),T&&["select","drag","resize"].includes(L)&&(Go(s,B,{...N,element:T,hideControllers:!!j&&"drag"===L,rotateControllerPattern:v.context2d,style:c}),"drag"===L&&!0===Y)){const e=tn(T.uuid,{calculator:a,data:d.data,groupQueue:W,viewScaleInfo:z,viewSizeInfo:R});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Vo(s,{xLines:o,yLines:n,style:c})}}}else if(P&&"drag"!==L&&(V?Fo(s,E,{...N,controller:B,style:c}):Bo(s,E,N)),T&&["select","drag","resize"].includes(L)){if(Go(s,B,{...N,element:T,hideControllers:!!j&&"drag"===L,rotateControllerPattern:v.context2d,style:c}),"drag"===L&&!0===Y){const e=tn(T.uuid,{calculator:a,data:d.data,groupQueue:W,viewScaleInfo:z,viewSizeInfo:R});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Vo(s,{xLines:o,yLines:n,style:c})}}}else if("area"===L&&k&&O)!function(e,t){const{start:i,end:o,style:n}=t,{activeColor:l,activeAreaColor:a}=n;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=l,e.fillStyle=a,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("nonzero")}(s,{start:k,end:O,style:c});else if(["drag-list","drag-list-end"].includes(L)){const e=Ko(m(),{viewScaleInfo:M.getActiveViewScaleInfo(),viewSizeInfo:M.getActiveViewSizeInfo()});e&&function(e,t){const{areaSize:i,style:o}=t,{activeColor:n,activeAreaColor:l}=o,{x:a,y:r,w:s,h:h}=i;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=n,e.fillStyle=l,e.beginPath(),e.moveTo(a,r),e.lineTo(a+s,r),e.lineTo(a+s,r+h),e.lineTo(a,r+h),e.closePath(),e.stroke(),e.fill("nonzero")}(s,{areaSize:e,style:c})}}}},e.MiddlewareTextEditor=e=>{const{eventHub:t,boardContent:i,viewer:o,sharer:n,calculator:l}=e,a=i.boardContext.canvas,r=e.container||document.body;let s=document.createElement("div");s.setAttribute("contenteditable","true");let h=document.createElement("div"),c=document.createElement("div"),d=null,u=[],f="";const g=`idraw-middleware-text-editor-${Math.random().toString(26).substring(2)}`;c.setAttribute("id",g),h.appendChild(s),h.style.position="absolute",c.appendChild(h),c.style.position="fixed",c.style.top="0",c.style.bottom="0",c.style.left="0",c.style.right="0",c.style.display="none",r.appendChild(c);const v=()=>{if(null==d?void 0:d.uuid){const e=n.getActiveOverrideElemenentMap();e&&delete e[d.uuid],n.setActiveOverrideElemenentMap(e),o.drawFrame()}c.style.display="none",d=null,u=[]},m=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:n,y:l,w:a,h:r}=t,s=yt(t.angle||0);return o.style.position="absolute",o.style.left=`${n}px`,o.style.top=`${l}px`,o.style.width=`${a}px`,o.style.height=`${r}px`,o.style.transform=`rotate(${s}deg)`,i.appendChild(o),o},y=e=>{const{viewScaleInfo:t,element:i,groupQueue:o}=e,{scale:n,offsetTop:l,offsetLeft:a}=t;h.children&&Array.from(h.children).forEach((e=>{e.remove()}));let r=h;for(let e=0;e<o.length;e++){const t=o[e],{x:i,y:s,w:h,h:c}=t,d={x:i*n,y:s*n,w:h*n,h:c*n,angle:yt(t.angle||0)};0===e&&(d.x+=a,d.y+=l),r=m({size:d,parent:r})}const c={...jn,...i.detail};let d=i.x*n+a,u=i.y*n+l,f=i.w*n,g=i.h*n;o.length>0&&(d=i.x*n,u=i.y*n,f=i.w*n,g=i.h*n);let v="center",y="center";"left"===c.textAlign?v="start":"right"===c.textAlign&&(v="end"),"top"===c.verticalAlign?y="start":"bottom"===c.verticalAlign&&(y="end"),s.style.display="inline-flex",s.style.justifyContent=v,s.style.alignItems=y,s.style.position="absolute",s.style.left=d-1+"px",s.style.top=u-1+"px",s.style.width=`${f+2}px`,s.style.height=`${g+2}px`,s.style.transform=`rotate(${yt(i.angle||0)}deg)`,s.style.boxSizing="border-box",s.style.border="1px solid #1973ba",s.style.resize="none",s.style.overflow="hidden",s.style.wordBreak="break-all",s.style.borderRadius=("number"==typeof c.borderRadius?c.borderRadius:0)*n+"px",s.style.background=`${c.background||"transparent"}`,s.style.color=`${c.color||"#333333"}`,s.style.fontSize=c.fontSize*n+"px",s.style.lineHeight=(c.lineHeight||c.fontSize)*n+"px",s.style.fontFamily=hi(c.fontFamily),s.style.fontWeight=`${c.fontWeight}`,s.style.padding="0",s.style.margin="0",s.style.outline="none",s.innerText=c.text||"",r.appendChild(s)},p=()=>{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}})();h.style.position="absolute",h.style.overflow="hidden",h.style.top=`${t}px`,h.style.left=`${e}px`,h.style.width=`${i}px`,h.style.height=`${o}px`},w=()=>{v()},x=e=>{e.stopPropagation()},S=()=>{d&&u&&(d.detail.text=s.innerText||"",t.trigger(mo.TEXT_CHANGE,{element:{uuid:d.uuid,detail:{text:d.detail.text}},position:[...u||[]]}),l.modifyText(d),o.drawFrame())},b=()=>{if(d&&u){d.detail.text=s.innerText||"",t.trigger(mo.TEXT_CHANGE,{element:{uuid:d.uuid,detail:{text:d.detail.text}},position:[...u]});const e=n.getActiveStorage("data")||{elements:[]},i={detail:{text:d.detail.text}};ai(d.uuid,i,e.elements),t.trigger(mo.CHANGE,{selectedElements:[{...d,detail:{...d.detail,...i.detail}}],data:e,type:"modifyElement",modifyRecord:{type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:d.uuid,before:{"detail.text":f},after:{"detail.text":d.detail.text}}}}),l.modifyText(d),o.drawFrame()}v()},A=e=>{e.stopPropagation()},I=e=>{e.stopPropagation()},M=e=>{e.stopPropagation()},z=e=>{e.stopPropagation(),e.preventDefault()};c.addEventListener("click",w),s.addEventListener("click",x),s.addEventListener("input",S),s.addEventListener("blur",b),s.addEventListener("keydown",A),s.addEventListener("keypress",I),s.addEventListener("keyup",M),s.addEventListener("wheel",z);const R=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)&&(d=e.element,u=e.position),(e=>{p(),y(e),c.style.display="block",f="",(null==d?void 0:d.uuid)&&(n.setActiveOverrideElemenentMap({[d.uuid]:{operations:{invisible:!0}}}),f=d.detail.text||"",o.drawFrame())})(e)};return{name:"@middleware/text-editor",use(){t.on(mo.TEXT_EDIT,R)},disuse(){t.off(mo.TEXT_EDIT,R),c.removeEventListener("click",w),s.removeEventListener("click",x),s.removeEventListener("input",S),s.removeEventListener("blur",b),s.removeEventListener("keydown",A),s.removeEventListener("keypress",I),s.removeEventListener("keyup",M),s.removeEventListener("wheel",z),h.removeChild(s),c.removeChild(h),r.removeChild(c),s.remove(),h.remove(),c=null,s=null,h=null,c=null,d=null,u=null,f=null}}},e.Sharer=so,e.coreEventKeys=mo,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});