@idraw/util 0.4.0-beta.9 → 0.4.0

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 (105) hide show
  1. package/dist/esm/index.d.ts +46 -31
  2. package/dist/esm/index.js +46 -31
  3. package/dist/esm/{lib → tool}/color.js +9 -6
  4. package/dist/esm/{lib → tool}/event.d.ts +1 -0
  5. package/dist/esm/{lib → tool}/event.js +3 -0
  6. package/dist/esm/tool/flat-object.d.ts +6 -0
  7. package/dist/esm/tool/flat-object.js +28 -0
  8. package/dist/esm/tool/get-set-del.d.ts +4 -0
  9. package/dist/esm/tool/get-set-del.js +65 -0
  10. package/dist/esm/{lib → tool}/html.d.ts +1 -1
  11. package/dist/esm/{lib → tool}/html.js +6 -2
  12. package/dist/esm/{lib → tool}/istype.d.ts +1 -0
  13. package/dist/esm/{lib → tool}/istype.js +3 -0
  14. package/dist/esm/tool/merge.d.ts +1 -0
  15. package/dist/esm/tool/merge.js +17 -0
  16. package/dist/esm/tool/omit.d.ts +1 -0
  17. package/dist/esm/tool/omit.js +7 -0
  18. package/dist/esm/tool/store.d.ts +16 -0
  19. package/dist/esm/{lib → tool}/store.js +17 -5
  20. package/dist/esm/tool/unflat-object.d.ts +3 -0
  21. package/dist/esm/tool/unflat-object.js +91 -0
  22. package/dist/esm/{lib → tool}/uuid.d.ts +1 -1
  23. package/dist/esm/tool/uuid.js +39 -0
  24. package/dist/esm/view/box.d.ts +2 -0
  25. package/dist/esm/view/box.js +173 -0
  26. package/dist/esm/{lib → view}/canvas.d.ts +0 -1
  27. package/dist/esm/view/canvas.js +57 -0
  28. package/dist/esm/{lib → view}/check.js +14 -14
  29. package/dist/esm/{lib → view}/config.js +2 -2
  30. package/dist/esm/{lib → view}/context2d.d.ts +4 -0
  31. package/dist/esm/{lib → view}/context2d.js +20 -0
  32. package/dist/esm/view/controller.d.ts +12 -0
  33. package/dist/esm/view/controller.js +321 -0
  34. package/dist/esm/{lib → view}/data.d.ts +1 -0
  35. package/dist/esm/{lib → view}/data.js +43 -22
  36. package/dist/esm/{lib → view}/element.d.ts +5 -0
  37. package/dist/esm/{lib → view}/element.js +66 -5
  38. package/dist/esm/view/flat.d.ts +2 -0
  39. package/dist/esm/view/flat.js +133 -0
  40. package/dist/esm/view/group.d.ts +3 -0
  41. package/dist/esm/view/group.js +81 -0
  42. package/dist/esm/{lib → view}/handle-element.d.ts +11 -1
  43. package/dist/esm/{lib → view}/handle-element.js +102 -51
  44. package/dist/esm/view/handle-global.d.ts +4 -0
  45. package/dist/esm/view/handle-global.js +28 -0
  46. package/dist/esm/view/handle-layout.d.ts +4 -0
  47. package/dist/esm/view/handle-layout.js +28 -0
  48. package/dist/esm/{lib → view}/is.d.ts +3 -1
  49. package/dist/esm/{lib → view}/is.js +22 -6
  50. package/dist/esm/view/modify-record.d.ts +4 -0
  51. package/dist/esm/view/modify-record.js +10 -0
  52. package/dist/esm/view/point-move-element.d.ts +5 -0
  53. package/dist/esm/view/point-move-element.js +26 -0
  54. package/dist/esm/view/position.d.ts +15 -0
  55. package/dist/esm/view/position.js +79 -0
  56. package/dist/esm/view/rect.js +11 -0
  57. package/dist/esm/view/resize-element.d.ts +4 -0
  58. package/dist/esm/view/resize-element.js +255 -0
  59. package/dist/esm/{lib → view}/rotate.js +8 -13
  60. package/dist/esm/view/text.d.ts +1 -0
  61. package/dist/esm/view/text.js +4 -0
  62. package/dist/esm/{lib → view}/view-box.js +3 -1
  63. package/dist/esm/{lib → view}/view-calc.d.ts +16 -3
  64. package/dist/esm/{lib → view}/view-calc.js +127 -3
  65. package/dist/esm/view/view-content.d.ts +14 -0
  66. package/dist/esm/view/view-content.js +88 -0
  67. package/dist/index.global.js +1938 -346
  68. package/dist/index.global.min.js +1 -1
  69. package/package.json +2 -2
  70. package/dist/esm/lib/canvas.js +0 -81
  71. package/dist/esm/lib/controller.d.ts +0 -6
  72. package/dist/esm/lib/controller.js +0 -103
  73. package/dist/esm/lib/rect.js +0 -11
  74. package/dist/esm/lib/resize-element.d.ts +0 -2
  75. package/dist/esm/lib/resize-element.js +0 -101
  76. package/dist/esm/lib/store.d.ts +0 -11
  77. package/dist/esm/lib/uuid.js +0 -31
  78. /package/dist/esm/{lib → tool}/color.d.ts +0 -0
  79. /package/dist/esm/{lib → tool}/file.d.ts +0 -0
  80. /package/dist/esm/{lib → tool}/file.js +0 -0
  81. /package/dist/esm/{lib → tool}/image.d.ts +0 -0
  82. /package/dist/esm/{lib → tool}/image.js +0 -0
  83. /package/dist/esm/{lib → tool}/number.d.ts +0 -0
  84. /package/dist/esm/{lib → tool}/number.js +0 -0
  85. /package/dist/esm/{lib → tool}/time.d.ts +0 -0
  86. /package/dist/esm/{lib → tool}/time.js +0 -0
  87. /package/dist/esm/{lib → view}/check.d.ts +0 -0
  88. /package/dist/esm/{lib → view}/config.d.ts +0 -0
  89. /package/dist/esm/{lib → view}/load.d.ts +0 -0
  90. /package/dist/esm/{lib → view}/load.js +0 -0
  91. /package/dist/esm/{lib → view}/matrix.d.ts +0 -0
  92. /package/dist/esm/{lib → view}/matrix.js +0 -0
  93. /package/dist/esm/{lib → view}/middleware.d.ts +0 -0
  94. /package/dist/esm/{lib → view}/middleware.js +0 -0
  95. /package/dist/esm/{lib → view}/parser.d.ts +0 -0
  96. /package/dist/esm/{lib → view}/parser.js +0 -0
  97. /package/dist/esm/{lib → view}/point.d.ts +0 -0
  98. /package/dist/esm/{lib → view}/point.js +0 -0
  99. /package/dist/esm/{lib → view}/rect.d.ts +0 -0
  100. /package/dist/esm/{lib → view}/rotate.d.ts +0 -0
  101. /package/dist/esm/{lib → view}/svg-path.d.ts +0 -0
  102. /package/dist/esm/{lib → view}/svg-path.js +0 -0
  103. /package/dist/esm/{lib → view}/vertex.d.ts +0 -0
  104. /package/dist/esm/{lib → view}/vertex.js +0 -0
  105. /package/dist/esm/{lib → view}/view-box.d.ts +0 -0
@@ -1 +1 @@
1
- var iDrawUtil=function(t){"use strict";var e,n,i,o,r,a,l,s=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},c=(t,e,n)=>(s(t,e,"read from private field"),n?n.call(t):e.get(t)),h=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},u=(t,e,n,i)=>(s(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),d=(t,e,n)=>(s(t,e,"access private method"),n);function f(t){return"string"==typeof t&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}const g={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function y(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function x(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n)*t.charCodeAt(n)*n*n;return e.toString(16).substring(0,4)}function p(t){const e=t.length,n=Math.floor(e/2),i=t.substring(0,4).padEnd(4,"0"),o=t.substring(0,4).padEnd(4,"0");return`@assets/${x(e.toString(16).padEnd(4,i))}${x(t.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${x(t.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${x(t.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${x(t.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${x(t.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${x(t.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${x(o.padEnd(4,i).padEnd(4,o))}`}function m(t){return/^@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(`${t}`)}function w(t){return function t(e){const n=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return e;if("Array"===n){const n=[];return e.forEach((e=>{n.push(t(e))})),n}if("Object"===n){const n={};Object.keys(e).forEach((i=>{n[i]=t(e[i])}));return Object.getOwnPropertySymbols(e).forEach((i=>{n[i]=t(e[i])})),n}}(t)}function v(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const b={type(t,e){const n=v(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===v(t),json:t=>"Object"===v(t),function:t=>"Function"===v(t),asyncFunction:t=>"AsyncFunction"===v(t),string:t=>"String"===v(t),number:t=>"Number"===v(t),undefined:t=>"Undefined"===v(t),null:t=>"Null"===v(t),promise:t=>"Promise"===v(t)};const{Image:P}=window;function M(t){return new Promise(((e,n)=>{const i=new P;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function R(t){return"number"==typeof t&&(t>0||t<=0)}function I(t){return"number"==typeof t&&t>=0}function $(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function E(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const A={x:function(t){return R(t)},y:function(t){return R(t)},w:I,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:R,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return I(t)},borderRadius:function(t){return R(t)&&t>=0},color:function(t){return f(t)},imageSrc:function(t){return E(t)||$(t)},imageURL:$,imageBase64:E,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let n=document.createElement("div");n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return R(t)&&t>0},lineHeight:function(t){return R(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)},strokeWidth:function(t){return R(t)&&t>0}};function S(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(t.hasOwnProperty("borderColor")&&!A.color(e))&&(!(t.hasOwnProperty("borderRadius")&&!A.number(n))&&!(t.hasOwnProperty("borderWidth")&&!A.number(i)))}const C={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(A.x(e)&&A.y(n)&&A.w(i)&&A.h(o)&&A.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:a,fontWeight:l,background:s,strokeWidth:c,strokeColor:h}=t;return!!A.text(e)&&(!!A.color(n)&&(!!A.fontSize(i)&&(!(t.hasOwnProperty("background")&&!A.color(s))&&(!(t.hasOwnProperty("fontWeight")&&!A.fontWeight(l))&&(!(t.hasOwnProperty("lineHeight")&&!A.lineHeight(o))&&(!(t.hasOwnProperty("fontFamily")&&!A.fontFamily(r))&&(!(t.hasOwnProperty("textAlign")&&!A.textAlign(a))&&(!(t.hasOwnProperty("strokeWidth")&&!A.strokeWidth(c))&&(!(t.hasOwnProperty("strokeColor")&&!A.color(h))&&!!S(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(t.hasOwnProperty("background")&&!A.color(e))&&!!S(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(t.hasOwnProperty("background")&&!A.color(e))&&(!(t.hasOwnProperty("borderColor")&&!A.color(n))&&!(t.hasOwnProperty("borderWidth")&&!A.number(i)))},imageDesc:function(t){const{src:e}=t;return!!A.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!A.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!A.html(e)}};class k{constructor(t,i){h(this,e,void 0),h(this,n,void 0),u(this,e,t),u(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i})}$undoPixelRatio(t){return t/c(this,n).devicePixelRatio}$doPixelRatio(t){return c(this,n).devicePixelRatio*t}$getContext(){return c(this,e)}$setFont(t){const n=[];t.fontWeight&&n.push(`${t.fontWeight}`),n.push(`${this.$doPixelRatio(t.fontSize||12)}px`),n.push(`${t.fontFamily||"sans-serif"}`),c(this,e).font=`${n.join(" ")}`}$getOffscreenCanvas(){return c(this,n).offscreenCanvas}$resize(t){const{width:i,height:o,devicePixelRatio:r,resetStyle:a}=t,{canvas:l}=c(this,e);l.width=i*r,l.height=o*r,u(this,n,{...c(this,n),devicePixelRatio:r}),!0===a&&(l.style.width=`${i}px`,l.style.height=`${o}px`)}$getSize(){const{devicePixelRatio:t}=c(this,n),{width:i,height:o}=c(this,e).canvas;return{width:i/t,height:o/t,devicePixelRatio:t}}get canvas(){return c(this,e).canvas}get fillStyle(){return c(this,e).fillStyle}set fillStyle(t){c(this,e).fillStyle=t}get strokeStyle(){return c(this,e).strokeStyle}set strokeStyle(t){c(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(c(this,e).lineWidth)}set lineWidth(t){c(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return c(this,e).textAlign}set textAlign(t){c(this,e).textAlign=t}get textBaseline(){return c(this,e).textBaseline}set textBaseline(t){c(this,e).textBaseline=t}get globalAlpha(){return c(this,e).globalAlpha}set globalAlpha(t){c(this,e).globalAlpha=t}get shadowColor(){return c(this,e).shadowColor}set shadowColor(t){c(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(c(this,e).shadowOffsetX)}set shadowOffsetX(t){c(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(c(this,e).shadowOffsetY)}set shadowOffsetY(t){c(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(c(this,e).shadowBlur)}set shadowBlur(t){c(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return c(this,e).lineCap}set lineCap(t){c(this,e).lineCap=t}get globalCompositeOperation(){return c(this,e).globalCompositeOperation}set globalCompositeOperation(t){c(this,e).globalCompositeOperation=t}fill(...t){return c(this,e).fill(...t)}arc(t,n,i,o,r,a){return c(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,a)}rect(t,n,i,o){return c(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(t,n,i,o){return c(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(t,n,i,o){return c(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return c(this,e).beginPath()}closePath(){return c(this,e).closePath()}lineTo(t,n){return c(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return c(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,o,r){return c(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}getLineDash(){return c(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return c(this,e).setLineDash(n)}stroke(t){return t?c(this,e).stroke(t):c(this,e).stroke()}translate(t,n){return c(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return c(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],o=t[2],r=t[3],a=t[4],l=t[t.length-4],s=t[t.length-3],h=t[t.length-2],u=t[t.length-1];return 9===t.length?c(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h),this.$doPixelRatio(u)):c(this,e).drawImage(n,this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h),this.$doPixelRatio(u))}createPattern(t,n){return c(this,e).createPattern(t,n)}measureText(t){return c(this,e).measureText(t)}fillText(t,n,i,o){return void 0!==o?c(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,o){return void 0!==o?c(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){c(this,e).save()}restore(){c(this,e).restore()}scale(t,n){c(this,e).scale(t,n)}circle(t,n,i,o,r,a,l,s){c(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,l,s)}isPointInPath(t,n){return c(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return c(this,e).clip(...t)}setTransform(t,n,i,o,r,a){return c(this,e).setTransform(t,n,i,o,r,a)}getTransform(){return c(this,e).getTransform()}createLinearGradient(t,n,i,o){return c(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(t,n,i,o,r,a){return c(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}createConicGradient(t,n,i){return c(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function z(t){const{width:e,height:n,ctx:i,devicePixelRatio:o}=t;let r=i;if(!r){const t=document.createElement("canvas");t.width=e*o,t.height=n*o,r=t.getContext("2d")}return new k(r,t)}function O(t){const{width:e,height:n,devicePixelRatio:i}=t,o=new OffscreenCanvas(e*i,n*i),r=o.getContext("2d").canvas.getContext("2d");return new k(r,{devicePixelRatio:i,offscreenCanvas:o})}e=new WeakMap,n=new WeakMap;function L(t,e){const n=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===n?n:Math.sqrt(n)}function T(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function D(t){return t>=0||t<0}function j(t){return D(t.x)&&D(t.y)&&t.t>0}function W(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}i=new WeakMap;function F(t){return t/180*Math.PI}function H(t,e,n,i){const o=F(e||0);n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(o),t.translate(-n.x,-n.y)),i(t),n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(-o),t.translate(-n.x,-n.y))}function V(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function N(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return V({x:e,y:n,w:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,h:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function B(t,e,n){const i=function(t,e){const n=e.x-t.x,i=e.y-t.y;if(0===n){if(i<0)return 0;if(i>0)return Math.PI}else if(0===i){if(n<0)return 3*Math.PI/2;if(n>0)return Math.PI/2}return n>0&&i<0?Math.atan(Math.abs(n)/Math.abs(i)):n>0&&i>0?Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i>0?Math.PI+Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i<0?2*Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):0}(t,e);let o=i+n;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const r=L(t,e);let a=0,l=0;return 0===o?(a=0,l=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,l=0-Math.cos(o)*r):o===Math.PI/2?(a=r,l=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,l=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,l=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,l=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,l=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,l=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,l=0-r),a+=t.x,l+=t.y,{x:a,y:l}}function G(t,e,n){const{x:i,y:o,w:r,h:a}=t;let l={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+a},h={x:i,y:o+a};if(n&&(n>0||n<0)){const t=F(Y(n));l=B(e,l,t),s=B(e,s,t),c=B(e,c,t),h=B(e,h,t)}return[l,s,c,h]}function U(t){const{angle:e=0}=t;return G(t,V(t),e)}function Q(t,e,n){return[B(t,{x:e[0].x,y:e[0].y},n),B(t,{x:e[1].x,y:e[1].y},n),B(t,{x:e[2].x,y:e[2].y},n),B(t,{x:e[3].x,y:e[3].y},n)]}function Y(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}function X(t,e){const n={x:0,y:0,w:0,h:0};t.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=U(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(e.x,n.x),o=Math.min(e.y,n.y),r=Math.max(e.x+e.w,n.x+n.w),a=Math.max(e.y+e.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(a-o)})),(null==e?void 0:e.extend)&&(n.x=Math.min(n.x,0),n.y=Math.min(n.y,0));const i={contextWidth:n.w,contextHeight:n.h};return(null==e?void 0:e.viewWidth)&&(null==e?void 0:e.viewHeight)&&(null==e?void 0:e.viewWidth)>0&&(null==e?void 0:e.viewHeight)>0&&(e.viewWidth>n.x+n.w&&(i.contextWidth=e.viewWidth-n.x),e.viewHeight>n.y+n.h&&(i.contextHeight=e.viewHeight-n.y)),i}function q(t,e){let n=null,i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(e<t.length-1&&"group"===o.type)i=o.detail.children;else{if(e!==t.length-1)break;n=o}}return n}function Z(t,e){const n=[];let i=!1;const o=e=>{var r;for(let a=0;a<e.length&&!0!==i;a++){n.push(a);const l=e[a];if(l.uuid===t){i=!0;break}if("group"===l.type&&o((null==(r=null==l?void 0:l.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(e),n}function J(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,a=e.x,l=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=a&&i<=c&&r>=l}function K(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:a,angle:l}=t,{scale:s,offsetTop:c,offsetLeft:h}=n;return{x:i*s+h,y:o*s+c,w:r*s,h:a*s,angle:l}}function _(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:a,offsetLeft:l}=n;return{x:i*r+l,y:o*r+a}}function tt(t,e){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=e,{angle:a=0}=i,{x:l,y:s,w:c,h:h}=K(i,{viewScaleInfo:o,viewSizeInfo:r}),u=U({x:l,y:s,w:c,h:h,angle:a});if(u.length>=2){n.beginPath(),n.moveTo(u[0].x,u[0].y);for(let t=1;t<u.length;t++)n.lineTo(u[t].x,u[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function et(t){const{x:e,y:n,h:i,w:o}=t;return[{x:e,y:n},{x:e+o,y:n},{x:e+o,y:n+i},{x:e,y:n+i}]}function nt(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?et(t):G(t,V({x:e,y:n,w:i,h:o,angle:r}),r)}function it(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:a,y:l,w:s,h:c,angle:h=0}=r[t];let u;if(n+=a,i+=l,0===t){const t={x:n,y:i,w:s,h:c,angle:h};u=nt({x:a,y:l,w:s,h:c,angle:h}),o.push({center:V(t),angle:h,radian:F(h)})}else{u=et({x:n,y:i,w:s,h:c,angle:h});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];u=Q(e,u,n)}const t=N(u);if(h>0||h<0){u=Q(t,u,F(h))}o.push({center:t,angle:h,radian:F(h)})}e.push(u)}return e}function ot(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[nt(t)];return it([...n,t])}function rt(t,e){return ot(t,e).pop()||null}function at(t,e){const{x:n,y:i}=t,{size:o,angle:r}=e;return{x:n-o/2,y:i-o/2,w:o,h:o,angle:r}}o=new WeakMap,r=new WeakMap,a=new WeakSet,l=function(){return w(c(this,r))};const lt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,st=/(-?\d+(?:\.\d+)?)/gi;const ct=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,ht=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,ut=/^\s*$/,dt={};function ft(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(dt[n[1]]||"/"===t.charAt(t.length-2))&&(e.isVoid=!0),e.name.startsWith("!--"))){const e=t.indexOf("--\x3e");return{type:"comment",name:null,attributes:{},children:[],isVoid:!1,comment:-1!==e?t.slice(4,e):""}}const i=new RegExp(ct);let o=null;for(;o=i.exec(t),null!==o;)if(o[0].trim())if(o[1]){const t=o[1].trim();let n=[t,""];t.indexOf("=")>-1&&(n=t.split("=")),e.attributes[n[0]]=n[1],i.lastIndex--}else o[2]&&(e.attributes[o[2]]=o[3].trim().substring(1,o[3].length-1));return e}function gt(t,e){switch(e.type){case"text":return t+e.textContent;case"element":return t+="<"+e.name+(e.attributes?function(t){const e=[];for(let n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}(e.attributes):"")+(e.isVoid?"/>":">"),e.isVoid?t:t+e.children.reduce(gt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function yt(t,e){let n=2;return void 0!==(null==e?void 0:e.decimalPlaces)&&(null==e?void 0:e.decimalPlaces)>=0&&(n=e.decimalPlaces),parseFloat(t.toFixed(n))}function xt(t){return t[1]!=-1*t[3]||t[4]!=t[0]||t[0]*t[4]-t[3]*t[1]!=1?null:Math.acos(t[0])}const pt="Text Element";function mt(){return{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 wt(){return{background:"#D9D9D9"}}const vt={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"};const bt=t=>yt(t,{decimalPlaces:4});function Pt(t,e){const{detail:n}=t,{xRatio:i,yRatio:o,maxRatio:r}=e,a=(i+o)/2,{borderWidth:l,borderRadius:s,borderDash:c,shadowOffsetX:h,shadowOffsetY:u,shadowBlur:d}=n;if("number"==typeof l)n.borderWidth=bt(l*a);else if(Array.isArray(n.borderWidth)){const t=l;n.borderWidth=[bt(t[0]*o),bt(t[1]*i),bt(t[2]*o),bt(t[3]*i)]}if("number"==typeof s)n.borderRadius=bt(s*a);else if(Array.isArray(n.borderRadius)){const t=s;n.borderRadius=[t[0]*i,t[1]*i,t[2]*o,t[3]*o]}Array.isArray(c)&&c.forEach(((t,e)=>{n.borderDash[e]=bt(t*r)})),"number"==typeof h&&(n.shadowOffsetX=bt(h*r)),"number"==typeof u&&(n.shadowOffsetX=bt(u*r)),"number"==typeof d&&(n.shadowOffsetX=bt(d*r))}function Mt(t,e){const{type:n}=t;!function(t,e){const{xRatio:n,yRatio:i}=e,{x:o,y:r,w:a,h:l}=t;t.x=bt(o*n),t.y=bt(r*i),t.w=bt(a*n),t.h=bt(l*i),Pt(t,e)}(t,e),"circle"===n||("text"===n?function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:o,lineHeight:r}=t.detail,a=(n+i)/2;o&&o>0&&(t.detail.fontSize=bt(o*a)),r&&r>0&&(t.detail.lineHeight=bt(r*a))}(t,e):"image"===n||"svg"===n||"html"===n||"path"===n||"group"===n&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Mt(t,e)})))}function Rt(t,e){const n=e.w&&e.w>0?e.w:t.w,i=e.h&&e.h>0?e.h:t.h,o=n/t.w,r=i/t.h;if(o===r&&1===o)return t;const a=Math.min(o,r),l=Math.max(o,r);t.w=n,t.h=i;const s={xRatio:o,yRatio:r,minRatio:a,maxRatio:l};return"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Mt(t,s)})),Pt(t,s),t}const It=200,$t=200;function Et(t,e,n){let i=!1;if(1===e.length){const o=e[0];n.splice(o,0,t),i=!0}else if(e.length>1){let o=n;for(let n=0;n<e.length;n++){const r=o[e[n]];if(n===e.length-1){const r=e[n];o.splice(r,0,t),i=!0}else{if(!(n<e.length-1&&"group"===r.type))break;o=r.detail.children}}}return i}function At(t,e){let n=!1;if(1===t.length){const i=t[0];e.splice(i,1),n=!0}else if(t.length>1){let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(e===t.length-1){const o=t[e];i.splice(o,1),n=!0}else{if(!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}}}return n}function St(t,e){var n;const i=Object.keys(e);for(let o=0;o<i.length;o++){const r=i[o];["x","y","w","h","angle","name"].includes(r)?t[r]=e[r]:["detail","operations"].includes(r)&&(b.json(e[r])?((null==t?void 0:t.hasOwnProperty(r))||(t[r]={}),b.json(t[r])&&(t[r]={...t[r],...e[r]})):b.array(e[r])&&((null==t?void 0:t.hasOwnProperty(r))||(t[r]=[]),b.array(t[r])&&(null==(n=null==e?void 0:e[r])||n.forEach(((e,n)=>{t[r][n]=e})),t[r]=[...t[r],...e[r]])))}return t}return t.Context2D=k,t.EventEmitter=class{constructor(){h(this,i,void 0),u(this,i,new Map)}on(t,e){if(c(this,i).has(t)){const n=c(this,i).get(t)||[];null==n||n.push(e),c(this,i).set(t,n)}else c(this,i).set(t,[e])}off(t,e){if(c(this,i).has(t)){const n=c(this,i).get(t);if(Array.isArray(n))for(let t=0;t<(null==n?void 0:n.length);t++)if(n[t]===e){n.splice(t,1);break}c(this,i).set(t,n||[])}}trigger(t,e){const n=c(this,i).get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(c(this,i).has(t)){const e=c(this,i).get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){c(this,i).clear()}},t.Store=class{constructor(t){h(this,a),h(this,o,void 0),h(this,r,void 0),u(this,r,w(t.defaultStorage)),u(this,o,d(this,a,l).call(this))}set(t,e){c(this,o)[t]=e}get(t){return c(this,o)[t]}getSnapshot(){return w(c(this,o))}clear(){u(this,o,d(this,a,l).call(this))}destroy(){u(this,o,null)}},t.calcDistance=L,t.calcElementCenter=V,t.calcElementCenterFromVertexes=N,t.calcElementListSize=function(t){var e;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<t.length;o++){const r=t[o];if(null==(e=null==r?void 0:r.operations)?void 0:e.invisible)continue;const a={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(a.angle&&(a.angle>0||a.angle<0)){const t=U(a);if(4===t.length){const e=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y];a.x=Math.min(...e),a.y=Math.min(...n),a.w=Math.abs(Math.max(...e)-Math.min(...e)),a.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const t=Math.min(a.x,n.x),e=Math.min(a.y,n.y),i=Math.max(a.x+a.w,n.x+n.w),o=Math.max(a.y+a.h,n.y+n.h);n.x=t,n.y=e,n.w=Math.abs(i-t),n.h=Math.abs(o-e)}else n.x=a.x,n.y=a.y,n.w=a.w,n.h=a.h;i=a}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}},t.calcElementQueueVertexesQueueInGroup=it,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o}=e,r=(i&&i>0?i:8)/o.scale,{x:a,y:l,w:s,h:c,angle:h=0}=t,u=[{uuid:y(),x:a,y:l,w:s,h:c,angle:h,type:"group",detail:{children:[]}},...n];let d=0;u.forEach((({angle:t=0})=>{d+=t}));const f=rt(t,{groupQueue:n}),g=W(f[0],f[1]),x=W(f[1],f[2]),p=W(f[2],f[3]),m=W(f[3],f[0]),w=f[0],v=f[1],b=f[2],P=f[3],M=at(w,{size:r,angle:d}),R=at(v,{size:r,angle:d}),I=at(P,{size:r,angle:d}),$=at(b,{size:r,angle:d}),E=nt(M),A=nt(R),S=nt(I),C=nt($),k=[E[1],A[0],A[3],E[2]],z=[A[3],A[2],C[1],C[0]],O=[S[1],C[0],C[3],S[2]];return{elementWrapper:f,left:{type:"left",vertexes:[E[3],E[2],S[1],S[0]],center:m},right:{type:"right",vertexes:z,center:x},top:{type:"top",vertexes:k,center:g},bottom:{type:"bottom",vertexes:O,center:p},topLeft:{type:"top-left",vertexes:E,center:w},topRight:{type:"top-right",vertexes:A,center:v},bottomLeft:{type:"bottom-left",vertexes:S,center:P},bottomRight:{type:"bottom-right",vertexes:C,center:b}}},t.calcElementVertexesInGroup=rt,t.calcElementVertexesQueueInGroup=ot,t.calcElementsContextSize=X,t.calcElementsViewInfo=function(t,e,n){const i=X(t,{viewWidth:e.width,viewHeight:e.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,e.contextWidth),i.contextHeight=Math.max(i.contextHeight,e.contextHeight)),{contextSize:i}},t.calcSpeed=function(t,e){return L(t,e)/Math.abs(e.t-t.t)},t.calcViewBoxSize=function(t,e){const{viewScaleInfo:n}=e,{scale:i}=n;let{borderRadius:o}=t.detail;const{boxSizing:r=vt.boxSizing,borderWidth:a}=t.detail;Array.isArray(a)&&(o=0);let{x:l,y:s,w:c,h:h}=t,u=[0,0,0,0];if("number"==typeof o){const t=o*i;u=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(u=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let d=0;return"number"==typeof a&&(d=(a||0)*i),"border-box"===r?(l=t.x+d/2,s=t.y+d/2,c=t.w-d,h=t.h-d):"content-box"===r?(l=t.x-d/2,s=t.y-d/2,c=t.w+d,h=t.h+d):(l=t.x,s=t.y,c=t.w,h=t.h),c=Math.max(c,1),h=Math.max(h,1),u=u.map((t=>Math.min(t,c/2,h/2))),{x:l,y:s,w:c,h:h,radiusList:u}},t.calcViewElementSize=K,t.calcViewPointSize=_,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:o}=t,{viewSizeInfo:r}=e,{width:a,height:l,contextWidth:s,contextHeight:c}=r,h=0-i*n,u=0-o*n;return{scale:n,offsetLeft:h,offsetTop:u,offsetRight:a-(s*n+h/n),offsetBottom:l-(c*n+u/n)}},t.calcViewVertexes=function(t,e){return[_(t[0],e),_(t[1],e),_(t[2],e),_(t[3],e)]},t.check=C,t.checkRectIntersect=J,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=g[e];return"string"==typeof n?n:null},t.colorToCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if("linear-gradient"===(null==t?void 0:t.type)){const n=[];"number"==typeof t.angle?n.push(`${t.angle}deg`):n.push("180deg"),Array.isArray(t.stops)&&t.stops.forEach((t=>{n.push(`${t.color} ${100*t.offset}%`)})),e=`linear-gradient(${n.join(", ")})`}else if("radial-gradient"===(null==t?void 0:t.type)){const n=[];Array.isArray(t.stops)&&t.stops.forEach((t=>{n.push(`${t.color} ${100*t.offset}%`)})),e=`radial-gradient(circle, ${n.join(", ")})`}return e},t.colorToLinearGradientCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if("radial-gradient"===(null==t?void 0:t.type)||"linear-gradient"===(null==t?void 0:t.type)){const n=[];Array.isArray(t.stops)&&t.stops.length>0&&(t.stops.forEach(((e,i)=>{n.push(`${e.color} ${100*e.offset}%`),i===t.stops.length-1&&e.offset<1&&n.push(`${e.color} ${100*e.offset}%`)})),e=`linear-gradient(90deg, ${n.join(", ")})`)}return e},t.compose=function(t){return function(e,n){return function i(o){let r=t[o];o===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,i.bind(null,o+1)))}catch(t){return Promise.reject(t)}}(0)}},t.compressImage=function(t,e){let n=.5;const i=(null==e?void 0:e.type)||"image/png";return(null==e?void 0:e.radio)&&(null==e?void 0:e.radio)>0&&(null==e?void 0:e.radio)<=1&&(n=null==e?void 0:e.radio),new Promise(((e,o)=>{const r=new Image;r.addEventListener("load",(()=>{const{width:t,height:o}=r,a=t*n,l=o*n;let s=document.createElement("canvas");s.width=a,s.height=l;s.getContext("2d").drawImage(r,0,0,a,l);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=p,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o,offscreen:r}=e,a={width:n,height:i,devicePixelRatio:o};if(!0===r){const e=t.getContext("2d"),n=O(a),i=O(a),o=O(a),r=z({ctx:e,...a}),l=()=>{const{width:t,height:e}=n.$getSize();r.clearRect(0,0,t,e),r.drawImage(o.canvas,0,0,t,e),r.drawImage(n.canvas,0,0,t,e),r.drawImage(i.canvas,0,0,t,e),o.clearRect(0,0,t,e),n.clearRect(0,0,t,e),i.clearRect(0,0,t,e)};return{underContext:o,viewContext:n,helperContext:i,boardContext:r,drawView:l}}{const e=t.getContext("2d"),o=z(a),r=z(a),l=z(a),s=z({ctx:e,...a}),c=()=>{s.clearRect(0,0,n,i),s.drawImage(l.canvas,0,0,n,i),s.drawImage(o.canvas,0,0,n,i),s.drawImage(r.canvas,0,0,n,i),l.clearRect(0,0,n,i),o.clearRect(0,0,n,i),r.clearRect(0,0,n,i)};return{underContext:l,viewContext:o,helperContext:r,boardContext:s,drawView:c}}},t.createContext2D=z,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=It,r=$t;if(e){const{viewScaleInfo:a,viewSizeInfo:l}=e,{scale:s,offsetLeft:c,offsetTop:h}=a,{width:u,height:d}=l,f=u/4,g=d/4;o=It>=f?f/s:It/s,r=$t>=g?g/s:$t/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/pt.length*2),n=(0-c+u/2-o*s/2)/s,i=(0-h+d/2-r*s/2)/s}return{x:n,y:i,w:o,h:r}}(t,n);let o={};return"rect"===t?o={background:"#D9D9D9"}:"circle"===t?o={background:"#D9D9D9",radius:0}:"text"===t?o=function(t){const e={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};return{text:pt,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,lineHeight:t.w/pt.length,fontSize:t.w/pt.length,textAlign:"center",verticalAlign:"middle"}}(i):"svg"===t?o={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"===t?o={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===t&&(o={children:[],background:"#D9D9D9",overflow:"hidden"}),{...i,...e,uuid:y(),type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=O,t.createUUID=y,t.debounce=function(t,e){let n=-1;return function(...i){n>=0&&window.clearTimeout(n),n=setTimeout((()=>{t(...i),n=-1}),e)}},t.deepClone=w,t.deepCloneElement=function(t){const e=w(t),n=t=>{t.uuid=y(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e},t.deepResizeGroupElement=Rt,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return At(Z(t,e),e)},t.deleteElementInListByPosition=At,t.downloadFileFromText=function(t,e){const{fileName:n}=e,i=function(t){const e=(new TextEncoder).encode(t),n=new Blob([e],{type:"text/plain;charset=utf-8"});return window.URL.createObjectURL(n)}(t);let o=document.createElement("a");o.href=i,o.download=n,o.click(),o=null},t.downloadImageFromCanvas=function(t,e){const{fileName:n,type:i="image/jpeg"}=e,o=t.toDataURL(i);let r=document.createElement("a");r.href=o,r.download=n,r.click(),r=null},t.equalPoint=T,t.equalTouchPoint=function(t,e){return!0===T(t,e)&&t.f===e.f},t.filterCompactData=function(t,e){const n=t.assets||{},i=w(t),o=(null==e?void 0:e.loadItemMap)||{},r=t=>{t.forEach((t=>{var e,i,a;if("image"===t.type&&t.detail.src){const i=t.detail.src;if(m(i)&&!n[i]&&o[i]&&"string"==typeof(null==(e=o[i])?void 0:e.source))n[i]={type:"image",value:o[i].source};else{const e=p(i);n[e]||(n[e]={type:"image",value:i}),t.detail.src=e}}else if("svg"===t.type){const e=t.detail.svg,r=p(e);m(e)&&!n[e]&&o[e]&&"string"==typeof(null==(i=o[e])?void 0:i.source)?n[e]={type:"svg",value:o[e].source}:n[r]||(n[r]={type:"svg",value:e}),t.detail.svg=r}else if("html"===t.type){const e=t.detail.html,i=p(e);m(e)&&!n[e]&&o[e]&&"string"==typeof(null==(a=o[e])?void 0:a.source)?n[e]={type:"html",value:o[e].source}:n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,r(t.detail.children)}}))};return r(i.elements),i.assets=n,i},t.filterElementAsset=function(t){let e=null,n=null,i=null;return"image"===t.type?i=t.detail.src:"svg"===t.type?i=t.detail.svg:"html"===t.type&&(i=t.detail.html),"string"!=typeof i||m(i)||(e=p(i),n={type:t.type,value:i},"image"===t.type?t.detail.src=e:"svg"===t.type?t.detail.svg=e:"html"===t.type&&(t.detail.html=e)),{element:t,assetId:e,assetItem:n}},t.findElementFromList=function t(e,n){var i;let o=null;for(let r=0;r<n.length;r++){const a=n[r];if(a.uuid===e){o=a;break}if(!o&&"group"===a.type){const n=t(e,(null==(i=null==a?void 0:a.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementFromListByPosition=q,t.findElementQueueFromListByPosition=function(t,e){const n=[];let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(!o)break;if(n.push(o),!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}return n},t.findElementsFromList=function(t,e){const n=[];return function e(i){var o;for(let r=0;r<i.length;r++){const a=i[r];t.includes(a.uuid)?n.push(a):"group"===a.type&&e((null==(o=null==a?void 0:a.detail)?void 0:o.children)||[])}}(e),n},t.findElementsFromListByPositions=function(t,e){const n=[];return t.forEach((t=>{const i=q(t,e);i&&n.push(i)})),n},t.formatNumber=yt,t.generateHTML=function(t){return t.reduce((function(t,e){return t+gt("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.getCenterFromTwoPoints=W,t.getDefaultElementDetailConfig=mt,t.getDefaultElementRectDetail=wt,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&m(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&m(t.detail.svg)?e.push(t.detail.svg):"html"===t.type&&t.detail.html?e.push(t.detail.html):"group"===t.type&&Array.isArray(t.detail.children)&&n(t.detail.children)}))};return n(t),e},t.getElementPositionFromList=Z,t.getElementRotateVertexes=G,t.getElementSize=function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return{x:e,y:n,w:i,h:o,angle:r}},t.getElementVertexes=et,t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let a=0;a<i.length;a++){const l=i[a];if(l.uuid===e){r=l;break}if(!r&&"group"===l.type){n.push(l);const i=t(e,(null==(o=null==l?void 0:l.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===e){r=i;break}n.pop()}}return r}(t,e),n},t.getSelectedElementUUIDs=function(t,e){var n;let i=[];return Array.isArray(null==t?void 0:t.elements)&&(null==(n=null==t?void 0:t.elements)?void 0:n.length)>0&&Array.isArray(e)&&e.length>0&&e.forEach((e=>{var n;"number"==typeof e?(null==(n=null==t?void 0:t.elements)?void 0:n[e])&&i.push(t.elements[e].uuid):"string"==typeof e&&(i=i.concat(function(t,e){var n;const i=[];if("string"==typeof e&&/^\d+(\.\d+)*$/.test(e)){const o=e.split(".");let r=t;for(;o.length>0;){const t=o.shift();if("string"==typeof t){const e=r[parseInt(t)];e&&0===o.length?i.push(e.uuid):"group"===e.type&&o.length>0&&(r=(null==(n=null==e?void 0:e.detail)?void 0:n.children)||[])}break}}return i}(t.elements,e)))})),i},t.getViewPointAtElement=function(t,e){var n,i,o;const{context2d:r,data:a,viewScaleInfo:l,viewSizeInfo:s,groupQueue:c}=e,h={index:-1,element:null,groupQueueIndex:-1};if(c&&Array.isArray(c)&&(null==c?void 0:c.length)>0)for(let e=c.length-1;e>=0;e--){let o=0,a=0,u=0;for(let t=0;t<=e;t++)o+=c[t].x,a+=c[t].y,u+=c[t].angle||0;const d=c[e];if(d&&"group"===d.type&&Array.isArray(null==(n=d.detail)?void 0:n.children))for(let n=0;n<d.detail.children.length;n++){const f=d.detail.children[n];if(!0!==(null==(i=null==f?void 0:f.operations)?void 0:i.invisible)){if(!f)break;if(tt(t,{context2d:r,element:{x:o+f.x,y:a+f.y,w:f.w,h:f.h,angle:u+(f.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){h.element=f,(e<c.length-1||"group"!==f.type)&&(h.groupQueueIndex=e);break}}}if(h.element)break}if(h.element)return h;for(let e=a.elements.length-1;e>=0;e--){const n=a.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&tt(t,{context2d:r,element:n,viewScaleInfo:l,viewSizeInfo:s})){h.index=e,h.element=n;break}}return h},t.getViewScaleInfoFromSnapshot=function(t){const{activeStore:e}=t;return{scale:null==e?void 0:e.scale,offsetTop:null==e?void 0:e.offsetTop,offsetBottom:null==e?void 0:e.offsetBottom,offsetLeft:null==e?void 0:e.offsetLeft,offsetRight:null==e?void 0:e.offsetRight}},t.getViewSizeInfoFromSnapshot=function(t){const{activeStore:e}=t;return{devicePixelRatio:e.devicePixelRatio,width:null==e?void 0:e.width,height:null==e?void 0:e.height,contextWidth:null==e?void 0:e.contextWidth,contextHeight:null==e?void 0:e.contextHeight}},t.insertElementToListByPosition=Et,t.is=A,t.isAssetId=m,t.isColorStr=f,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:a}=t,{x:l,y:s,w:c,h:h}=K(t,{viewScaleInfo:i,viewSizeInfo:n}),u=U({x:l,y:s,w:c,h:h,angle:a}),d={x:0,y:0,w:o,h:r},f=Math.min(u[0].x,u[1].x,u[2].x,u[3].x),g=Math.min(u[0].y,u[1].y,u[2].y,u[3].y);return J(d,{x:f,y:g,w:Math.max(u[0].x,u[1].x,u[2].x,u[3].x)-f,h:Math.max(u[0].y,u[1].y,u[2].y,u[3].y)-g})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isViewPointInElement=tt,t.istype=b,t.limitAngle=Y,t.loadHTML=async function(t,e){t=t.replace(/\&/gi,"&amp;");const n=await function(t,e){const{width:n,height:i}=e;return new Promise(((e,o)=>{const r=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},a.onerror=function(t){o(t)}}))}(t,e);return await M(n)},t.loadImage=M,t.loadSVG=async function(t){const e=await function(t){return new Promise(((e,n)=>{const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},o.onerror=function(t){n(t)}}))}(t);return await M(e)},t.matrixToAngle=function(t){const e=xt(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=xt,t.mergeElementAsset=function(t,e){const n=t;let i=null,o=null;return"image"===n.type?i=n.detail.src:"svg"===n.type?i=n.detail.svg:"html"===n.type&&(i=n.detail.html),i&&(null==i?void 0:i.startsWith("@assets/"))&&(o=e[i]),(null==o?void 0:o.type)===n.type&&"string"==typeof(null==o?void 0:o.value)&&(null==o?void 0:o.value)&&("image"===n.type?n.detail.src=o.value:"svg"===n.type?n.detail.svg=o.value:"html"===n.type&&(n.detail.html=o.value)),n},t.mergeHexColorAlpha=function(t,e){if(1===e)return t;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=t;if(i.test(t)?n=parseInt(t.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(t)&&(n=parseInt(t.substring(7,9).replace(/^\#/,"0x")),o=t.substring(0,7)),n*=e,i.test(o)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o},t.moveElementPosition=function(t,e){const{from:n,to:i}=e;if(0===n.length||0===i.length)return t;if(n.length<=i.length)for(let e=0;e<n.length;e++)if(i[e]!==n[e]);else if(e===n.length-1)return t;const o=q(n,t);if(o){if(!Et(o,i,t))return t;let e=-1;for(let t=0;t<n.length&&i[t]>=0;t++)i[t]!==n[t]&&i[t]<n[t]&&t==i.length-1&&(e=t);e>=0&&(n[e]=n[e]+1),At(n,t)}return t},t.parseAngleToRadian=F,t.parseFileToBase64=function(t){return new Promise((function(e,n){let i=new FileReader;i.addEventListener("load",(function(){e(i.result),i=null})),i.addEventListener("error",(function(t){n(t),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsDataURL(t)}))},t.parseFileToText=function(t){return new Promise((function(e,n){let i=new FileReader;i.addEventListener("load",(function(){e(i.result),i=null})),i.addEventListener("error",(function(t){n(t),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsText(t)}))},t.parseHTML=function(t){const e=[],n=[];let i,o=-1;return t.replace(ht,((r,a)=>{const l="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=a+r.length,h=t.charAt(c);let u;if(s){const t=ft(r);return o<0?(e.push(t),r):(u=n[o],u.children.push(t),r)}if(l){if(o++,i=ft(r),!i.isVoid&&h&&"<"!==h){const e=t.slice(c,t.indexOf("<",c));e.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:e.trim()})}0===o&&e.push(i),u=n[o-1],u&&u.children.push(i),n[o]=i}if((!l||!Array.isArray(i)&&i.isVoid)&&(o>-1&&!Array.isArray(i)&&(i.isVoid||i.name===r.slice(2,-1))&&(o--,i=-1===o?e:n[o]),"<"!==h&&h)){u=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);ut.test(r)&&(r=" "),(i>-1&&o+u.length>=0||" "!==r)&&r.trim()&&u.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:r.trim()})}return r})),e},t.parseRadianToAngle=function(t){return t/Math.PI*180},t.parseSVGPath=function(t){const e=[];return t.replace(lt,((t,n,i)=>{const o=i.match(st),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.pickFile=function(t){const{accept:e,success:n,error:i}=t;let o=document.createElement("input");o.type="file",e&&(o.accept=e),o.addEventListener("change",(function(){var t;const e=null==(t=o.files)?void 0:t[0];n({file:e}),o=null})),o.addEventListener("error",(function(t){"function"==typeof i&&i(t),o=null})),o.click()},t.rotateByCenter=H,t.rotateElement=function(t,e,n){const i=V(e);H(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=U,t.rotatePoint=B,t.rotatePointInGroup=function(t,e){if((null==e?void 0:e.length)>0){let n=t.x,i=t.y;return e.forEach((t=>{const{x:e,y:o,w:r,h:a,angle:l=0}=t,s=B(V({x:e,y:o,w:r,h:a,angle:l}),{x:n,y:i},F(l));n=s.x,i=s.y})),{x:n,y:i}}return t},t.rotateVertexes=Q,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=w(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=p(e);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=p(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=p(e);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,o(t.detail.children)}}))};return o(i.elements),i.assets=n,i},t.throttle=function(t,e){let n=-1;return function(...i){n>=0||(n=setTimeout((()=>{t(...i),n=-1}),e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^\#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.updateElementInList=function t(e,n,i){var o,r;let a=null;for(let l=0;l<i.length;l++){const s=i[l];if(s.uuid===e){"group"===s.type&&!0===(null==(o=s.operations)?void 0:o.deepResize)&&(n.w&&n.w>0||n.h&&n.h>0)&&Rt(s,{w:n.w,h:n.h}),St(s,n),a=s;break}"group"===s.type&&(a=t(e,n,(null==(r=null==s?void 0:s.detail)?void 0:r.children)||[]))}return a},t.vaildPoint=j,t.vaildTouchPoint=function(t){return!0===j(t)&&t.f>=0},t.validateElements=function t(e){let n=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(n=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(n=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(n=t(null==(o=null==e?void 0:e.detail)?void 0:o.children))}))}return n},t.viewScale=function(t){const{scale:e,point:n,viewScaleInfo:i}=t,{offsetLeft:o,offsetTop:r}=i,a=e/i.scale,l=n.x,s=n.y;return{moveX:l-l*a+(o*a-o),moveY:s-s*a+(r*a-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:a,height:l,contextWidth:s,contextHeight:c}=o;let h=i.offsetLeft,u=i.offsetRight,d=i.offsetTop,f=i.offsetBottom;return h+=e,d+=n,u=a-(s*r+h),f=l-(c*r+d),{scale:r,offsetTop:d,offsetLeft:h,offsetRight:u,offsetBottom:f}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
1
+ var iDrawUtil=function(t){"use strict";var e,n,i,o,r,l,a,s,c=t=>{throw TypeError(t)},u=(t,e,n)=>e.has(t)||c("Cannot "+n),f=(t,e,n)=>(u(t,e,"read from private field"),n?n.call(t):e.get(t)),h=(t,e,n)=>e.has(t)?c("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),d=(t,e,n,i)=>(u(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),y=(t,e,n)=>(u(t,e,"access private method"),n);function g(t){return"string"==typeof t&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}const x={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function p(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function m(t,e){let n=0;for(let e=0;e<t.length;e++)n+=t.charCodeAt(e);return(n+e).toString(16).substring(0,4)}function b(t,e){const n=t.length,i=function(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n);return e}(e),o=Math.floor(n/2),r=t.substring(0,4).padStart(4,"0"),l=t.substring(0,4).padStart(4,"0");return`@assets/${m(n.toString(16).padStart(4,r),i).padStart(4,"0")}${m(t.substring(o-4,o).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-8,o-4).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-12,o-8).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-16,o-12).padStart(4,l),i).padStart(4,"0")}-${m(t.substring(o,o+4).padStart(4,l),i).padStart(4,"0")}${m(t.substring(o+4,o+8).padStart(4,l),i).padStart(4,"0")}${m(l.padStart(4,r).padStart(4,l),i)}`}function v(t){return/^@assets\/[0-9a-z-]{0,}$/.test(`${t}`)}function w(t){return function t(e){const n=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return e;if("Array"===n){const n=[];return e.forEach((e=>{n.push(t(e))})),n}if("Object"===n){const n={};Object.keys(e).forEach((i=>{n[i]=t(e[i])}));return Object.getOwnPropertySymbols(e).forEach((i=>{n[i]=t(e[i])})),n}}(t)}function M(t){const e=w(t),n=t=>{t.uuid=p(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e}function P(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const R={type(t,e){const n=P(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===P(t),json:t=>"Object"===P(t),function:t=>"Function"===P(t),asyncFunction:t=>"AsyncFunction"===P(t),boolean:t=>"Boolean"===P(t),string:t=>"String"===P(t),number:t=>"Number"===P(t),undefined:t=>"Undefined"===P(t),null:t=>"Null"===P(t),promise:t=>"Promise"===P(t)};const{Image:I}=window;function S(t){return new Promise(((e,n)=>{const i=new I;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function $(t){return"number"==typeof t&&t>=0}function E(t){return"number"==typeof t&&(t>0||t<=0)}function A(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function z(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const k={positiveNum:$,x:function(t){return E(t)},y:function(t){return E(t)},w:function(t){return $(t)},h:function(t){return $(t)},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:E,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return $(t)||Array.isArray(t)&&$(t[0])&&$(t[1])&&$(t[2])&&$(t[3])},borderRadius:function(t){return $(t)||Array.isArray(t)&&$(t[0])&&$(t[1])&&$(t[2])&&$(t[3])},color:function(t){return g(t)},imageSrc:function(t){return z(t)||A(t)},imageURL:A,imageBase64:z,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let n=document.createElement("div");n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return E(t)&&t>0},lineHeight:function(t){return E(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)},strokeWidth:function(t){return E(t)&&t>0}};function O(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"borderColor")&&!k.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"borderRadius")&&!k.number(n))&&!(Object.prototype.hasOwnProperty.call(t,"borderWidth")&&!k.number(i)))}const L={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(k.x(e)&&k.y(n)&&k.w(i)&&k.h(o)&&k.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:l,fontWeight:a,background:s,strokeWidth:c,strokeColor:u}=t;return!!k.text(e)&&(!!k.color(n)&&(!!k.fontSize(i)&&(!(Object.prototype.hasOwnProperty.call(t,"background")&&!k.color(s))&&(!(Object.prototype.hasOwnProperty.call(t,"fontWeight")&&!k.fontWeight(a))&&(!(Object.prototype.hasOwnProperty.call(t,"lineHeight")&&!k.lineHeight(o))&&(!(Object.prototype.hasOwnProperty.call(t,"fontFamily")&&!k.fontFamily(r))&&(!(Object.prototype.hasOwnProperty.call(t,"textAlign")&&!k.textAlign(l))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeWidth")&&!k.strokeWidth(c))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeColor")&&!k.color(u))&&!!O(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!k.color(e))&&!!O(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!k.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"borderColor")&&!k.color(n))&&!(Object.prototype.hasOwnProperty.call(t,"borderWidth")&&!k.number(i)))},imageDesc:function(t){const{src:e}=t;return!!k.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!k.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!k.html(e)}};class C{constructor(t,i){h(this,e),h(this,n),d(this,e,t),d(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i}),this.$resetFont()}$undoPixelRatio(t){return t/f(this,n).devicePixelRatio}$doPixelRatio(t){return f(this,n).devicePixelRatio*t}$getContext(){return f(this,e)}$setContext(t){d(this,e,t)}$setFont(t){const n=[];t.fontWeight&&n.push(`${t.fontWeight}`),n.push(`${this.$doPixelRatio(t.fontSize||12)}px`),n.push(`${t.fontFamily||"sans-serif"}`),f(this,e).font=`${n.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 f(this,n).offscreenCanvas}$resize(t){const{width:i,height:o,devicePixelRatio:r,resetStyle:l}=t,{canvas:a}=f(this,e);a.width=i*r,a.height=o*r,d(this,n,{...f(this,n),devicePixelRatio:r}),!0===l&&(a.style.width=`${i}px`,a.style.height=`${o}px`)}$getSize(){const{devicePixelRatio:t}=f(this,n),{width:i,height:o}=f(this,e).canvas;return{width:i/t,height:o/t,devicePixelRatio:t}}get canvas(){return f(this,e).canvas}get fillStyle(){return f(this,e).fillStyle}set fillStyle(t){f(this,e).fillStyle=t}get strokeStyle(){return f(this,e).strokeStyle}set strokeStyle(t){f(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(f(this,e).lineWidth)}set lineWidth(t){f(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return f(this,e).textAlign}set textAlign(t){f(this,e).textAlign=t}get textBaseline(){return f(this,e).textBaseline}set textBaseline(t){f(this,e).textBaseline=t}get globalAlpha(){return f(this,e).globalAlpha}set globalAlpha(t){f(this,e).globalAlpha=t}get shadowColor(){return f(this,e).shadowColor}set shadowColor(t){f(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(f(this,e).shadowOffsetX)}set shadowOffsetX(t){f(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(f(this,e).shadowOffsetY)}set shadowOffsetY(t){f(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(f(this,e).shadowBlur)}set shadowBlur(t){f(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return f(this,e).lineCap}set lineCap(t){f(this,e).lineCap=t}get globalCompositeOperation(){return f(this,e).globalCompositeOperation}set globalCompositeOperation(t){f(this,e).globalCompositeOperation=t}fill(...t){return f(this,e).fill(...t)}arc(t,n,i,o,r,l){return f(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,l)}rect(t,n,i,o){return f(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(t,n,i,o){return f(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(t,n,i,o){return f(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return f(this,e).beginPath()}closePath(){return f(this,e).closePath()}lineTo(t,n){return f(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return f(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,o,r){return f(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}bezierCurveTo(t,n,i,o,r,l){return f(this,e).bezierCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l))}quadraticCurveTo(t,n,i,o){return f(this,e).quadraticCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return f(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return f(this,e).setLineDash(n)}stroke(t){return t?f(this,e).stroke(t):f(this,e).stroke()}translate(t,n){return f(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return f(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],o=t[2],r=t[3],l=t[4],a=t[t.length-4],s=t[t.length-3],c=t[t.length-2],u=t[t.length-1];return 9===t.length?f(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u)):f(this,e).drawImage(n,this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u))}createPattern(t,n){return f(this,e).createPattern(t,n)}measureText(t){return f(this,e).measureText(t)}fillText(t,n,i,o){return void 0!==o?f(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):f(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,o){return void 0!==o?f(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):f(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){f(this,e).save()}restore(){f(this,e).restore()}scale(t,n){f(this,e).scale(t,n)}circle(t,n,i,o,r,l,a,s){f(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,l,a,s)}isPointInPath(t,n){return f(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return f(this,e).clip(...t)}setTransform(t,n,i,o,r,l){return f(this,e).setTransform(t,n,i,o,r,l)}getTransform(){return f(this,e).getTransform()}createLinearGradient(t,n,i,o){return f(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(t,n,i,o,r,l){return f(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l))}createConicGradient(t,n,i){return f(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function j(t){const{width:e,height:n,ctx:i,devicePixelRatio:o}=t;let r=i;if(!r){const t=document.createElement("canvas");t.width=e*o,t.height=n*o,r=t.getContext("2d")}return new C(r,t)}function T(t){const{width:e,height:n,devicePixelRatio:i}=t,o=new OffscreenCanvas(e*i,n*i),r=o.getContext("2d").canvas.getContext("2d");return new C(r,{devicePixelRatio:i,offscreenCanvas:o})}e=new WeakMap,n=new WeakMap;function D(t,e){const n=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===n?n:Math.sqrt(n)}function W(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function N(t){return t>=0||t<0}function F(t){return N(t.x)&&N(t.y)&&t.t>0}function B(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}i=new WeakMap;function V(t){return t/180*Math.PI}function H(t,e,n,i){const o=V(e||0);n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(o),t.translate(-n.x,-n.y)),i(t),n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(-o),t.translate(-n.x,-n.y))}function G(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function Q(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return G({x:e,y:n,w:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,h:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function Y(t,e){const n=e.x-t.x,i=e.y-t.y;if(0===n){if(i<0)return 0;if(i>0)return Math.PI}else if(0===i){if(n<0)return 3*Math.PI/2;if(n>0)return Math.PI/2}return n>0&&i<0?Math.atan(Math.abs(n)/Math.abs(i)):n>0&&i>0?Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i>0?Math.PI+Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i<0?2*Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):0}function U(t,e,n){let i=Y(t,e)+n;i>2*Math.PI?i-=2*Math.PI:i<0-2*Math.PI&&(i+=2*Math.PI),i<0&&(i+=2*Math.PI);const o=D(t,e);let r=0,l=0;return 0===i?(r=0,l=0-o):i>0&&i<Math.PI/2?(r=Math.sin(i)*o,l=0-Math.cos(i)*o):i===Math.PI/2?(r=o,l=0):i>Math.PI/2&&i<Math.PI?(r=Math.sin(Math.PI-i)*o,l=Math.cos(Math.PI-i)*o):i===Math.PI?(r=0,l=o):i>Math.PI&&i<1.5*Math.PI?(r=0-Math.sin(i-Math.PI)*o,l=Math.cos(i-Math.PI)*o):i===1.5*Math.PI?(r=0-o,l=0):i>1.5*Math.PI&&i<2*Math.PI?(r=0-Math.sin(2*Math.PI-i)*o,l=0-Math.cos(2*Math.PI-i)*o):i===2*Math.PI&&(r=0,l=0-o),r+=t.x,l+=t.y,{x:r,y:l}}function X(t,e){if((null==e?void 0:e.length)>0){let n=t.x,i=t.y;return e.forEach((t=>{const{x:e,y:o,w:r,h:l,angle:a=0}=t,s=U(G({x:e,y:o,w:r,h:l}),{x:n,y:i},V(a));n=s.x,i=s.y})),{x:n,y:i}}return t}function q(t,e,n){const{x:i,y:o,w:r,h:l}=t;let a={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+l},u={x:i,y:o+l};if(n&&(n>0||n<0)){const t=V(K(n));a=U(e,a,t),s=U(e,s,t),c=U(e,c,t),u=U(e,u,t)}return[a,s,c,u]}function Z(t){const{angle:e=0}=t;return q(t,G(t),e)}function J(t,e,n){return[U(t,{x:e[0].x,y:e[0].y},n),U(t,{x:e[1].x,y:e[1].y},n),U(t,{x:e[2].x,y:e[2].y},n),U(t,{x:e[3].x,y:e[3].y},n)]}function K(t){if(!(t>0||t<0)||0===t||360===t)return 0;let e=t%360;return e<0?e+=360:360===t&&(e=0),e}function _(t){var e;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<t.length;o++){const r=t[o];if(null==(e=null==r?void 0:r.operations)?void 0:e.invisible)continue;const l={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(l.angle&&(l.angle>0||l.angle<0)){const t=Z(l);if(4===t.length){const e=[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.x=Math.min(...e),l.y=Math.min(...n),l.w=Math.abs(Math.max(...e)-Math.min(...e)),l.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const t=Math.min(l.x,n.x),e=Math.min(l.y,n.y),i=Math.max(l.x+l.w,n.x+n.w),o=Math.max(l.y+l.h,n.y+n.h);n.x=t,n.y=e,n.w=Math.abs(i-t),n.h=Math.abs(o-e)}else n.x=l.x,n.y=l.y,n.w=l.w,n.h=l.h;i=l}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}}function tt(t,e){const n={x:0,y:0,w:0,h:0};t.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=Z(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(e.x,n.x),o=Math.min(e.y,n.y),r=Math.max(e.x+e.w,n.x+n.w),l=Math.max(e.y+e.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(l-o)})),(null==e?void 0:e.extend)&&(n.x=Math.min(n.x,0),n.y=Math.min(n.y,0));const i={contextWidth:n.w,contextHeight:n.h};return(null==e?void 0:e.viewWidth)&&(null==e?void 0:e.viewHeight)&&(null==e?void 0:e.viewWidth)>0&&(null==e?void 0:e.viewHeight)>0&&(e.viewWidth>n.x+n.w&&(i.contextWidth=e.viewWidth-n.x),e.viewHeight>n.y+n.h&&(i.contextHeight=e.viewHeight-n.y)),i}function et(t,e){let n=null,i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(e<t.length-1&&"group"===(null==o?void 0:o.type))i=o.detail.children;else{if(e!==t.length-1)break;n=o}}return n}function nt(t,e){const n=[];let i=!1;const o=e=>{var r;for(let l=0;l<e.length&&!0!==i;l++){n.push(l);const a=e[l];if(a.uuid===t){i=!0;break}if("group"===a.type&&o((null==(r=null==a?void 0:a.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(e),n}function it(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,l=e.x,a=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=l&&i<=c&&r>=a}function ot(t){const{x:e,y:n,h:i,w:o}=t;return[{x:e,y:n},{x:e+o,y:n},{x:e+o,y:n+i},{x:e,y:n+i}]}function rt(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?ot(t):q(t,G({x:e,y:n,w:i,h:o}),r)}function lt(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:l,y:a,w:s,h:c,angle:u=0}=r[t];let f;if(n+=l,i+=a,0===t){const t={x:n,y:i,w:s,h:c};f=rt({x:l,y:a,w:s,h:c,angle:u}),o.push({center:G(t),angle:u,radian:V(u)})}else{f=ot({x:n,y:i,w:s,h:c});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];f=J(e,f,n)}const t=Q(f);if(u>0||u<0){f=J(t,f,V(u))}o.push({center:t,angle:u,radian:V(u)})}e.push(f)}return e}function at(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[rt(t)];return lt([...n,t])}function st(t,e){return at(t,e).pop()||null}function ct(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:l,angle:a}=t,{scale:s,offsetTop:c,offsetLeft:u}=n;return{x:i*s+u,y:o*s+c,w:r*s,h:l*s,angle:a}}function ut(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:l,offsetLeft:a}=n;return{x:i*r+a,y:o*r+l}}function ft(t,e){const{context2d:n,element:i,viewScaleInfo:o}=e,{angle:r=0}=i,{x:l,y:a,w:s,h:c}=ct(i,{viewScaleInfo:o}),u=Z({x:l,y:a,w:s,h:c,angle:r});if(u.length>=2){n.beginPath(),n.moveTo(u[0].x,u[0].y);for(let t=1;t<u.length;t++)n.lineTo(u[t].x,u[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function ht(t,e,n){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],r=Math.min(...i),l=Math.max(...i),a=Math.min(...o),s=Math.max(...o);return t.x>r&&t.x<l&&t.y>a&&t.y<s||!0===(null==n?void 0:n.includeBorder)&&(t.x===r||t.x===l||t.y===a||t.y===s)}function dt(t,e){const{groupQueue:n}=e,i=st(t,{groupQueue:n}),o=B(i[0],i[1]),r=B(i[1],i[2]),l=B(i[2],i[3]),a=B(i[3],i[0]),s=i[0],c=i[1],u=i[2],f=i[3],h=Math.max(s.x,c.x,u.x,f.x),d=Math.max(s.y,c.y,u.y,f.y);return{center:{x:(h+Math.min(s.x,c.x,u.x,f.x))/2,y:(d+Math.min(s.y,c.y,u.y,f.y))/2},topLeft:s,topRight:c,bottomLeft:f,bottomRight:u,top:o,right:r,left:a,bottom:l}}function yt(t,e){const{x:n,y:i}=t,{size:o,angle:r}=e;return{x:n-o/2,y:i-o/2,w:o,h:o,angle:r}}o=new WeakMap,r=new WeakMap,l=new WeakMap,a=new WeakSet,s=function(){return w(f(this,r))};const gt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,xt=/(-?\d+(?:\.\d+)?)/gi;const pt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,mt=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,bt=/^\s*$/,vt={};function wt(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(vt[n[1]]||"/"===t.charAt(t.length-2))&&(e.isVoid=!0),e.name.startsWith("!--"))){const e=t.indexOf("--\x3e");return{type:"comment",name:null,attributes:{},children:[],isVoid:!1,comment:-1!==e?t.slice(4,e):""}}const i=new RegExp(pt);let o=null;for(;o=i.exec(t),null!==o;)if(o[0].trim())if(o[1]){const t=o[1].trim();let n=[t,""];t.indexOf("=")>-1&&(n=t.split("=")),e.attributes[n[0]]=n[1],i.lastIndex--}else o[2]&&(e.attributes[o[2]]=o[3].trim().substring(1,o[3].length-1));return e}function Mt(t,e){switch(e.type){case"text":return t+e.textContent;case"element":return t+="<"+e.name+(e.attributes?function(t){const e=[];for(const n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}(e.attributes):"")+(e.isVoid?"/>":">"),e.isVoid?t:t+e.children.reduce(Mt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function Pt(t,e){let n=2;return void 0!==(null==e?void 0:e.decimalPlaces)&&(null==e?void 0:e.decimalPlaces)>=0&&(n=e.decimalPlaces),parseFloat(t.toFixed(n))}function Rt(t){return t[1]!=-1*t[3]||t[4]!=t[0]||t[0]*t[4]-t[3]*t[1]!=1?null:Math.acos(t[0])}const It="Text Element";function St(){return{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 $t(){return{background:"#D9D9D9"}}const Et={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function At(t,e="",n={},i){return Object.keys(t).forEach((o=>{var r;const l=e?`${e}${function(t){return/^\d+$/.test(t)&&!isNaN(Number(t))}(o)?`[${o}]`:`.${o}`}`:o;if(!(null==(r=null==i?void 0:i.ignorePaths)?void 0:r.includes(l))){const e=t[o];!function(t){return"object"==typeof t&&null!==t&&!(t instanceof Date)||Array.isArray(t)}(e)?n[l]=e:At(e,(Array.isArray(e),l),n,i)}})),n}function zt(t,e){return"object"!=typeof t||null===t?{"":t}:At(t,"",{},e)}function kt(t){return zt(t,{ignorePaths:["detail.children"]})}function Ot(t){return zt(t)}function Lt(t){return zt(t)}function Ct(t){return Array.isArray(t)?[...t]:t.split(/\.|\[|\]/).filter((t=>""!==t))}function jt(t,e,n){const i=Ct(e);if(0===i.length)return t;let o=t;if(o)for(let t=0;t<i.length;t++){const e=i[t];if(t===i.length-1){o[e]=n;break}if(o&&(void 0===(null==o?void 0:o[e])||"object"!=typeof(null==o?void 0:o[e])||null===(null==o?void 0:o[e]))){const n=i[t+1],r=/^\d+$/.test(n);o[e]=r?[]:{}}o=null==o?void 0:o[e]}return t}function Tt(t,e){const n=Ct(e);if(0===n.length)return t;let i=t;if(i)for(let t=0;t<n.length;t++){const e=n[t];if(t===n.length-1){delete i[e];break}if(i&&(void 0===(null==i?void 0:i[e])||"object"!=typeof(null==i?void 0:i[e])||null===(null==i?void 0:i[e]))){const o=n[t+1],r=/^\d+$/.test(o);i[e]=r?[]:{}}i=null==i?void 0:i[e]}return t}const Dt=t=>Pt(t,{decimalPlaces:4});function Wt(t,e){const n={detail:{}},i={detail:{}},o={type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:t.uuid,before:null,after:null}},{detail:r}=t,{xRatio:l,yRatio:a,maxRatio:s}=e,c=(l+a)/2,{borderWidth:u,borderRadius:f,borderDash:h,shadowOffsetX:d,shadowOffsetY:y,shadowBlur:g}=r;if("number"==typeof u)r.borderWidth=Dt(u*c),n.detail.borderWidth=u,i.detail.borderWidth=r.borderWidth;else if(Array.isArray(r.borderWidth)){const t=u;r.borderWidth=[Dt(t[0]*a),Dt(t[1]*l),Dt(t[2]*a),Dt(t[3]*l)],n.detail.borderWidth=[...t],i.detail.borderWidth=[...r.borderWidth]}if("number"==typeof f)r.borderRadius=Dt(f*c),n.detail.borderRadius=f,i.detail.borderRadius=r.borderRadius;else if(Array.isArray(r.borderRadius)){const t=f;r.borderRadius=[t[0]*l,t[1]*l,t[2]*a,t[3]*a],n.detail.borderRadius=[...t],i.detail.borderRadius=[...r.borderRadius]}return Array.isArray(h)&&(h.forEach(((t,e)=>{r.borderDash[e]=Dt(t*s)})),n.detail.borderDash=[...h],i.detail.borderDash=[...r.borderDash]),"number"==typeof d&&(r.shadowOffsetX=Dt(d*s),n.detail.shadowOffsetX=d,i.detail.shadowOffsetX=r.shadowOffsetX),"number"==typeof y&&(r.shadowOffsetY=Dt(y*s),n.detail.shadowOffsetY=y,i.detail.shadowOffsetY=r.shadowOffsetY),"number"==typeof g&&(r.shadowBlur=Dt(g*s),n.detail.shadowBlur=g,i.detail.shadowBlur=r.shadowBlur),o.content.before=kt(n),o.content.after=kt(i),o}function Nt(t,e,n){const{type:i,uuid:o}=t,r=function(t,e){const{xRatio:n,yRatio:i}=e,{uuid:o,x:r,y:l,w:a,h:s}=t;t.x=Dt(r*n),t.y=Dt(l*i),t.w=Dt(a*n),t.h=Dt(s*i);const c={type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:o,before:{x:r,y:l,w:a,h:s},after:{x:t.x,y:t.y,w:t.w,h:t.h}}},u=Wt(t,e);return c.content.before={...c.content.before,...u.content.before},c.content.after={...c.content.after,...u.content.after},c}(t,e),l={...r.content.before,uuid:o},a={...r.content.after,uuid:o};if(null==n||n.content.before.push(l),null==n||n.content.after.push(a),"circle"===i);else if("text"===i){const n=function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:o,lineHeight:r}=t.detail,l=(n+i)/2,a={},s={};return o&&o>0&&(t.detail.fontSize=Dt(o*l),a["detail.fontSize"]=o,s["detail.fontSize"]=t.detail.fontSize),r&&r>0&&(t.detail.lineHeight=Dt(r*l),a["detail.lineHeight"]=r,s["detail.lineHeight"]=t.detail.lineHeight),{type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:t.uuid,before:a,after:s}}}(t,e);Object.keys(n.content.before||{}).forEach((t=>{var e;l[t]=null==(e=n.content.before)?void 0:e[t]})),Object.keys(n.content.after||{}).forEach((t=>{var e;a[t]=null==(e=n.content.after)?void 0:e[t]}))}else"image"===i||"svg"===i||"html"===i||"path"===i||"group"===i&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Nt(t,e,n)}))}function Ft(t,e,n){const i={type:"resizeElements",time:Date.now(),content:{method:"modifyElements",before:[],after:[]}},o=t.uuid,r=t.x,l=t.y,a=t.w,s=t.h,c=R.number(e.x)?e.x:t.x,u=R.number(e.y)?e.y:t.y,f=(e.w&&e.w>0?e.w:t.w)||0,h=(e.h&&e.h>0?e.h:t.h)||0,d={uuid:o,x:r,y:l,w:a,h:s},y={uuid:o,x:c,y:u,w:f,h:h};if("deepResize"===(null==n?void 0:n.resizeEffect)){i.content.before.push(d),i.content.after.push(y);const e=f/t.w,n=h/t.h;if(e===n&&1===e)return i;const o=Math.min(e,n),r=Math.max(e,n);t.w=f,t.h=h;const l={xRatio:e,yRatio:n,minRatio:o,maxRatio:r};"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Nt(t,l,i)}));const a=Wt(t,l);return Object.keys(a.content.before||{}).forEach((t=>{var e;d[t]=null==(e=a.content.before)?void 0:e[t]})),Object.keys(a.content.after||{}).forEach((t=>{var e;y[t]=null==(e=a.content.after)?void 0:e[t]})),i}if("fixed"===(null==n?void 0:n.resizeEffect)){i.content.before.push(d),i.content.after.push(y);const e=c-t.x,n=u-t.y,o=f-t.w;return function(t,e,n){if("group"!==t.type||!Array.isArray(t.detail.children))return;const{moveX:i,moveY:o,moveH:r,moveW:l}=e;let a=0,s=0,c=!1;0===i&&0===o||0===r&&0===l||(c=!0,a=-i,s=-o),!0===c&&t.detail.children.forEach((t=>{const{uuid:e,x:i,y:o}=t,r=i+a,l=o+s,c={uuid:e,x:i,y:o},u={uuid:e,x:r,y:l};t.x=r,t.y=l,null==n||n.content.before.push(c),null==n||n.content.after.push(u)}))}(t,{moveX:e,moveY:n,moveH:h-t.h,moveW:o},i),t.w=f,t.h=h,t.x=c,t.y=u,i}return t.w=f,t.h=h,t.x=c,t.y=u,i.content.before.push(d),i.content.after.push(y),i}function Bt(t,e,n){let i=!1;if(1===e.length){const o=e[0];n.splice(o,0,t),i=!0}else if(e.length>1){let o=n;for(let n=0;n<e.length;n++){const r=o[e[n]];if(n===e.length-1){const r=e[n];o.splice(r,0,t),i=!0}else{if(!(n<e.length-1&&"group"===r.type))break;o=r.detail.children}}}return i}function Vt(t,e){let n=!1;if(1===t.length){const i=t[0];e.splice(i,1),n=!0}else if(t.length>1){let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(e===t.length-1){const o=t[e];i.splice(o,1),n=!0}else{if(!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}}}return n}function Ht(t,e,n){const i=kt(e),o=["uuid","type"],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Tt(t,e),void 0!==n&&jt(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=kt(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Tt(t,e)}))}return t}const Gt=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function Qt(t){const e=[...t.from],n=[...t.to];if(0===e.length||0===n.length)return null;if(e.length<=n.length)for(let t=0;t<e.length;t++)if(n[t]!==e[t]);else if(t===e.length-1)return null;let i=null;if(e.length>=1&&n.length>=1){if(e.length<=n.length)if(1===e.length)e[0]<n[0]&&(i="up-down");else for(let t=0;t<e.length&&e[t]===n[t];t++)if(e.length===e.length-1){i="up-down";break}if(e.length>=n.length)if(1===n.length)n[0]<e[0]&&(i="down-up");else for(let t=0;t<n.length&&(t===n.length-1&&n[t]<e[t]&&(i="down-up"),e[t]===n[t]);t++);}const o=e.length-1,r=n.length-1;return"up-down"===i&&o>=0?n[o]-=1:"down-up"===i&&r>=0&&(e[r]+=1),{from:e,to:n}}function Yt(t){const e=/([\w-]+)|\[(\d+)\]/g,n=[];let i;for(;null!==(i=e.exec(t));){const t=i[1]||i[2];t&&n.push(t)}return n}function Ut(t,e,n){let i=t;for(let t=0;t<e.length;t++){const o=e[t],r=Xt(o),l=t===e.length-1;try{r?qt(i,o):Zt(i,o)}catch(n){throw new Error(`Structure conflict at path '${e.slice(0,t+1).join(".")}': ${n.message}`)}l?Kt(i,o,n):i=Jt(i,o,e[t+1])}}function Xt(t){return/^\d+$/.test(t)}function qt(t,e){if(!Array.isArray(t))throw new Error("Expected array but found "+typeof t);const n=Number(e);n>t.length&&(t.length=n+1)}function Zt(t,e){if(Array.isArray(t))throw new Error(`Cannot create object property '${e}' on array`);if("object"!=typeof t||null===t)throw new Error(`Invalid structure for property '${e}'`)}function Jt(t,e,n){const i=!!n&&Xt(n);if(Array.isArray(t)){const n=Number(e);return t[n]||(t[n]=i?[]:{}),t[n]}return t[e]||(t[e]=i?[]:{}),t[e]}function Kt(t,e,n){if(Array.isArray(t)){const i=Number(e);i>=t.length&&(t.length=i+1),t[i]=n}else t[e]=n}return t.Context2D=C,t.EventEmitter=class{constructor(){h(this,i),d(this,i,new Map)}on(t,e){if(f(this,i).has(t)){const n=f(this,i).get(t)||[];null==n||n.push(e),f(this,i).set(t,n)}else f(this,i).set(t,[e])}off(t,e){if(f(this,i).has(t)){const n=f(this,i).get(t);if(Array.isArray(n))for(let t=0;t<(null==n?void 0:n.length);t++)if(n[t]===e){n.splice(t,1);break}f(this,i).set(t,n||[])}}trigger(t,e){const n=f(this,i).get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(f(this,i).has(t)){const e=f(this,i).get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){f(this,i).clear()}},t.Store=class{constructor(t){h(this,a),h(this,o),h(this,r),h(this,l),d(this,r,w(t.defaultStorage)),d(this,o,y(this,a,s).call(this)),d(this,l,t.defaultStatic||{})}set(t,e){f(this,o)[t]=e}get(t){return f(this,o)[t]}setStatic(t,e){f(this,l)[t]=e}getStatic(t){return f(this,l)[t]}getSnapshot(t){return!0===(null==t?void 0:t.deepClone)?w(f(this,o)):{...f(this,o)}}clear(){d(this,o,y(this,a,s).call(this))}destroy(){d(this,o,null),d(this,l,null)}},t.calcDistance=D,t.calcElementCenter=G,t.calcElementCenterFromVertexes=Q,t.calcElementListSize=_,t.calcElementOriginRectInfo=dt,t.calcElementQueueVertexesQueueInGroup=lt,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o,rotateControllerSize:r,rotateControllerPosition:l}=e,a=(i&&i>0?i:8)/o.scale,{x:s,y:c,w:u,h:f,angle:h=0}=t,d=r,y=l,g=[{uuid:p(),x:s,y:c,w:u,h:f,angle:h,type:"group",detail:{children:[]}},...n];let x=0;g.forEach((({angle:t=0})=>{x+=t}));const m=st(t,{groupQueue:n}),b=st({x:s,y:c-(y+d/2)/o.scale,h:f+(2*y+d)/o.scale,w:u,angle:h},{groupQueue:[...n]}),v=B(m[0],m[1]),w=B(m[1],m[2]),M=B(m[2],m[3]),P=B(m[3],m[0]),R=m[0],I=m[1],S=m[2],$=m[3],E=yt(v,{size:a,angle:x}),A=yt(w,{size:a,angle:x}),z=yt(M,{size:a,angle:x}),k=yt(P,{size:a,angle:x}),O=yt(R,{size:a,angle:x}),L=yt(I,{size:a,angle:x}),C=yt($,{size:a,angle:x}),j=yt(S,{size:a,angle:x}),T=rt(O),D=rt(L),W=rt(C),N=rt(j),F=[T[1],D[0],D[3],T[2]],V=[D[3],D[2],N[1],N[0]],H=[W[1],N[0],N[3],W[2]],Q=[T[3],T[2],W[1],W[0]],Y=rt(E),U=rt(A),X=rt(z),q=rt(k),Z=B(b[0],b[1]),J=rt(yt(Z,{size:1.1*r/o.scale,angle:x}));return{originalElementCenter:G(t),originalElementSize:{...t},elementWrapper:m,left:{type:"left",vertexes:Q,center:P,size:a},right:{type:"right",vertexes:V,center:w,size:a},top:{type:"top",vertexes:F,center:v,size:a},bottom:{type:"bottom",vertexes:H,center:M,size:a},topLeft:{type:"top-left",vertexes:T,center:R,size:a},topRight:{type:"top-right",vertexes:D,center:I,size:a},bottomLeft:{type:"bottom-left",vertexes:W,center:$,size:a},bottomRight:{type:"bottom-right",vertexes:N,center:S,size:a},leftMiddle:{type:"left-middle",vertexes:q,center:P,size:a},rightMiddle:{type:"right-middle",vertexes:U,center:w,size:a},topMiddle:{type:"top-middle",vertexes:Y,center:v,size:a},bottomMiddle:{type:"bottom-middle",vertexes:X,center:M,size:a},rotate:{type:"rotate",vertexes:J,center:Z,size:r}}},t.calcElementVertexesInGroup=st,t.calcElementVertexesQueueInGroup=at,t.calcElementViewRectInfo=function(t,e){const{groupQueue:n,viewScaleInfo:i,range:o}=e,r=dt(t,{groupQueue:n}),{center:l,top:a,bottom:s,left:c,right:u,topLeft:f,topRight:h,bottomLeft:d,bottomRight:y}=r,g={center:ut(l,{viewScaleInfo:i}),topLeft:ut(f,{viewScaleInfo:i}),topRight:ut(h,{viewScaleInfo:i}),bottomLeft:ut(d,{viewScaleInfo:i}),bottomRight:ut(y,{viewScaleInfo:i}),top:ut(a,{viewScaleInfo:i}),right:ut(u,{viewScaleInfo:i}),left:ut(c,{viewScaleInfo:i}),bottom:ut(s,{viewScaleInfo:i})};if(!0===o){const t=Math.max(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),e=Math.max(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),n=Math.min(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),i=Math.min(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),o={x:g.center.x,y:g.center.y},r={x:n,y:i},l={x:t,y:i},a={x:t,y:e},s={x:n,y:e},c=B(r,l),u=B(s,a),f=B(r,s);return{center:o,topLeft:r,topRight:l,bottomLeft:s,bottomRight:a,top:c,right:B(l,a),left:f,bottom:u}}return g},t.calcElementsContextSize=tt,t.calcElementsViewInfo=function(t,e,n){const i=tt(t,{viewWidth:e.width,viewHeight:e.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,e.contextWidth),i.contextHeight=Math.max(i.contextHeight,e.contextHeight)),{contextSize:i}},t.calcLayoutSizeController=function(t,e){const{controllerSize:n,viewScaleInfo:i}=e,o=n&&n>0?n:8,{x:r,y:l,w:a,h:s}=ct(t,{viewScaleInfo:i}),c=G({x:r,y:l,w:a,h:s}),u={x:c.x,y:l},f={x:r+a,y:c.y},h={x:c.x,y:l+s},d={x:r,y:c.y},y={x:r,y:l},g={x:r+a,y:l},x={x:r+a,y:l+s},p={x:r,y:l+s},m=yt(u,{size:o,angle:0}),b=yt(f,{size:o,angle:0}),v=yt(h,{size:o,angle:0}),w=yt(d,{size:o,angle:0}),M=yt(y,{size:o,angle:0}),P=yt(g,{size:o,angle:0}),R=yt(p,{size:o,angle:0}),I=yt(x,{size:o,angle:0}),S=rt(M),$=rt(P),E=rt(R),A=rt(I),z=[S[1],$[0],$[3],S[2]],k=[$[3],$[2],A[1],A[0]],O=[E[1],A[0],A[3],E[2]],L=[S[3],S[2],E[1],E[0]],C=rt(m),j=rt(b),T=rt(v);return{left:{type:"left",vertexes:L,center:d,size:o},right:{type:"right",vertexes:k,center:f,size:o},top:{type:"top",vertexes:z,center:u,size:o},bottom:{type:"bottom",vertexes:O,center:h,size:o},topLeft:{type:"top-left",vertexes:S,center:y,size:o},topRight:{type:"top-right",vertexes:$,center:g,size:o},bottomLeft:{type:"bottom-left",vertexes:E,center:p,size:o},bottomRight:{type:"bottom-right",vertexes:A,center:x,size:o},leftMiddle:{type:"left-middle",vertexes:rt(w),center:d,size:o},rightMiddle:{type:"right-middle",vertexes:j,center:f,size:o},topMiddle:{type:"top-middle",vertexes:C,center:u,size:o},bottomMiddle:{type:"bottom-middle",vertexes:T,center:h,size:o}}},t.calcPointMoveElementInGroup=function(t,e,n){let i=e.x-t.x,o=e.y-t.y;const r=[];if(n.forEach((t=>{const{x:e,y:n,w:i,h:o,angle:l=0}=t;r.push({x:e,y:n,w:i,h:o,angle:0-l})})),(null==n?void 0:n.length)>0){const n=X(t,r),l=X(e,r);i=l.x-n.x,o=l.y-n.y}return{moveX:i,moveY:o}},t.calcRadian=function(t,e,n){const i=Y(t,e),o=Y(t,n);return null!==o&&null!==i?o-i:0},t.calcResultMovePosition=Qt,t.calcRevertMovePosition=function(t){const e=Qt(t);return e?{from:[...e.to],to:[...e.from]}:e},t.calcSpeed=function(t,e){return D(t,e)/Math.abs(e.t-t.t)},t.calcViewBoxSize=function(t,e){const{viewScaleInfo:n}=e,{scale:i}=n;let{borderRadius:o}=t.detail;const{borderDash:r}=t.detail,l=Array.isArray(r)&&r.length>0,{boxSizing:a=Et.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:c,y:u,w:f,h:h}=t,d=[0,0,0,0];if("number"==typeof o){const t=o*i;d=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(d=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let y=0;return"number"==typeof s&&(y=(s||0)*i),"border-box"!==a||l?"content-box"===a?(c=t.x-y/2,u=t.y-y/2,f=t.w+y,h=t.h+y):(c=t.x,u=t.y,f=t.w,h=t.h):(c=t.x+y/2,u=t.y+y/2,f=t.w-y,h=t.h-y),f=Math.max(f,1),h=Math.max(h,1),d=d.map((t=>Math.min(t,f/2,h/2))),{x:c,y:u,w:f,h:h,radiusList:d}},t.calcViewCenter=function(t){let e=0,n=0;if(t){const{viewScaleInfo:i,viewSizeInfo:o}=t,{offsetLeft:r,offsetTop:l,scale:a}=i,{width:s,height:c}=o;e=0-r+s/a/2,n=0-l+c/a/2}return{x:e,y:n}},t.calcViewCenterContent=function(t,e){var n,i,o,r,l,a,s,c,u,f;let h=0,d=0,y=1,g=(null==(i=null==(n=null==t?void 0:t.elements)?void 0:n[0])?void 0:i.x)||0,x=(null==(r=null==(o=null==t?void 0:t.elements)?void 0:o[0])?void 0:r.y)||0,p=(null==(a=null==(l=null==t?void 0:t.elements)?void 0:l[0])?void 0:a.w)||0,m=(null==(c=null==(s=null==t?void 0:t.elements)?void 0:s[0])?void 0:c.h)||0;const{width:b,height:v}=e.viewSizeInfo;if(t.layout&&"hidden"===(null==(f=null==(u=t.layout)?void 0:u.detail)?void 0:f.overflow)?(g=0,x=0,p=t.layout.w||0,m=t.layout.h||0):t.elements.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=Z(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const n=Math.min(e.x,g),i=Math.min(e.y,x),o=Math.max(e.x+e.w,g+p),r=Math.max(e.y+e.h,x+m);g=n,x=i,p=Math.abs(o-n),m=Math.abs(r-i)})),t.layout){const{x:e,y:n,w:i,h:o}=t.layout;k.x(e)&&k.y(n)&&k.w(i)&&k.h(o)&&(g=Math.min(g,e),x=Math.min(x,n),p=Math.max(p,i),m=Math.max(m,o))}if(p>0&&m>0){const t=Pt(b/p,{decimalPlaces:4}),e=Pt(v/m,{decimalPlaces:4});y=Math.min(t,e,1),h=(p*y-b)/2/y+g,d=(m*y-v)/2/y+x}return{offsetX:Pt(h,{decimalPlaces:0}),offsetY:Pt(d,{decimalPlaces:0}),scale:y}},t.calcViewElementSize=ct,t.calcViewPointSize=ut,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:o}=t,{viewSizeInfo:r}=e,{width:l,height:a,contextWidth:s,contextHeight:c}=r,u=0-i*n,f=0-o*n;return{scale:n,offsetLeft:u,offsetTop:f,offsetRight:l-(s*n+u/n),offsetBottom:a-(c*n+f/n)}},t.calcViewVertexes=function(t,e){return[ut(t[0],e),ut(t[1],e),ut(t[2],e),ut(t[3],e)]},t.check=L,t.checkRectIntersect=it,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=x[e];return"string"==typeof n?n:null},t.colorToCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if(1===(null==t?void 0:t.stops.length))e=t.stops[0].color;else if("linear-gradient"===(null==t?void 0:t.type)){const n=[];"number"==typeof t.angle?n.push(`${t.angle}deg`):n.push("180deg"),Array.isArray(t.stops)&&t.stops.forEach((t=>{n.push(`${t.color} ${100*t.offset}%`)})),e=`linear-gradient(${n.join(", ")})`}else if("radial-gradient"===(null==t?void 0:t.type)){const n=[];Array.isArray(t.stops)&&t.stops.forEach((t=>{n.push(`${t.color} ${100*t.offset}%`)})),e=`radial-gradient(circle, ${n.join(", ")})`}return e},t.colorToLinearGradientCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if("radial-gradient"===(null==t?void 0:t.type)||"linear-gradient"===(null==t?void 0:t.type)){const n=[];Array.isArray(t.stops)&&t.stops.length>0&&(t.stops.forEach(((e,i)=>{n.push(`${e.color} ${100*e.offset}%`),i===t.stops.length-1&&e.offset<1&&n.push(`${e.color} ${100*e.offset}%`)})),e=`linear-gradient(90deg, ${n.join(", ")})`)}return e},t.compose=function(t){return function(e,n){return function i(o){let r=t[o];o===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,i.bind(null,o+1)))}catch(t){return Promise.reject(t)}}(0)}},t.compressImage=function(t,e){let n=.5;const i=(null==e?void 0:e.type)||"image/png";return(null==e?void 0:e.radio)&&(null==e?void 0:e.radio)>0&&(null==e?void 0:e.radio)<=1&&(n=null==e?void 0:e.radio),new Promise(((e,o)=>{const r=new Image;r.addEventListener("load",(()=>{const{width:t,height:o}=r,l=t*n,a=o*n;let s=document.createElement("canvas");s.width=l,s.height=a;s.getContext("2d").drawImage(r,0,0,l,a);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=b,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o}=e,r={width:n,height:i,devicePixelRatio:o},l=t.getContext("2d"),a=T(r),s=T(r),c=T(r),u=j({ctx:l,...r}),f=T(r);return{underlayContext:c,viewContext:a,overlayContext:s,boardContext:u,tempContext:f,drawView:()=>{const{width:t,height:e}=a.$getSize();u.clearRect(0,0,t,e),u.drawImage(c.canvas,0,0,t,e),u.drawImage(a.canvas,0,0,t,e),u.drawImage(s.canvas,0,0,t,e),c.clearRect(0,0,t,e),a.clearRect(0,0,t,e),s.clearRect(0,0,t,e)}}},t.createContext2D=j,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=200,r=200;if(e){const{viewScaleInfo:l,viewSizeInfo:a}=e,{scale:s,offsetLeft:c,offsetTop:u}=l,{width:f,height:h}=a,d=f/4,y=h/4;o=200>=d?d/s:200/s,r=200>=y?y/s:200/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/12*2),n=(0-c+f/2-o*s/2)/s,i=(0-u+h/2-r*s/2)/s}return{x:n,y:i,w:o,h:r}}(t,n);let o={};return"rect"===t?o={background:"#D9D9D9"}:"circle"===t?o={background:"#D9D9D9",radius:0}:"text"===t?o=function(t){const e={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};return{text:It,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontSize:t.w/12,textAlign:"center",verticalAlign:"middle"}}(i):"svg"===t?o={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"===t?o={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===t&&(o={children:[],background:"#D9D9D9",overflow:"hidden"}),{uuid:p(),...i,...e,type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=T,t.createUUID=p,t.debounce=function(t,e){let n=-1;return function(...i){n>=0&&window.clearTimeout(n),n=setTimeout((()=>{t(...i),n=-1}),e)}},t.deepClone=w,t.deepCloneData=function(t){const{elements:e,...n}=t;return{...w(n),elements:e.map((t=>M(t)))}},t.deepCloneElement=M,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return Vt(nt(t,e),e)},t.deleteElementInListByPosition=Vt,t.downloadFileFromText=function(t,e){const{fileName:n}=e,i=function(t){const e=(new TextEncoder).encode(t),n=new Blob([e],{type:"text/plain;charset=utf-8"});return window.URL.createObjectURL(n)}(t);let o=document.createElement("a");o.href=i,o.download=n,o.click(),o=null},t.downloadImageFromCanvas=function(t,e){const{fileName:n,type:i="image/jpeg"}=e,o=t.toDataURL(i);let r=document.createElement("a");r.href=o,r.download=n,r.click(),r=null},t.elementToBoxInfo=function(t){const{x:e,y:n,w:i,h:o,detail:r}=t,{borderWidth:l,borderRadius:a,boxSizing:s}=r;let c=0,u=0,f=0,h=0,d=0,y=0,g=0,x=0;"number"==typeof l&&l>0?(c=l,u=l,f=l,h=l):Array.isArray(l)&&(c=k.positiveNum(l[0])?l[0]:0,u=k.positiveNum(l[1])?l[0]:0,f=k.positiveNum(l[2])?l[0]:0,h=k.positiveNum(l[3])?l[0]:0),"number"==typeof a&&a>0?(d=a,y=a,g=a,x=a):Array.isArray(a)&&(d=k.positiveNum(a[0])?a[0]:0,y=k.positiveNum(a[0])?a[0]:0,g=k.positiveNum(a[0])?a[0]:0,x=k.positiveNum(a[0])?a[0]:0);const p={x:e,y:n},m={x:e+i,y:n},b={x:e+i,y:n+o},v={x:e,y:n+o},w={x:e,y:n+d},M={x:e+d,y:n},P={x:e+i-y,y:n},R={x:e+i,y:n+y},I={x:e+i,y:n+o-x},S={x:e+i-x,y:n+o},$={x:e+g,y:n+o},E={x:e,y:n+o-g};let A={...p},z={...m},O={...b},L={...v},C={...w},j={...M},T={...P},D={...R},W={...I},N={...S},F={...$},B={...E},V={...p},H={...m},G={...b},Q={...v},Y={...w},U={...M},X={...P},q={...R},Z={...I},J={...S},K={...$},_={...E};return"border-box"===s?(V={x:V.x+h,y:V.y+c},H={x:H.x-u,y:H.y+c},G={x:G.x-u,y:G.y-f},Q={x:Q.x+h,y:Q.y-f},Y={x:Y.x+h,y:Y.y+c},U={x:U.x+h,y:U.y+c},X={x:X.x-u,y:X.y+c},q={x:q.x-u,y:q.y+c},Z={x:Z.x-u,y:Z.y-f},J={x:J.x-u,y:J.y-f},K={x:K.x+h,y:K.y-f},_={x:_.x+h,y:_.y-f}):"content-box"===s?(A={x:A.x-h,y:A.y-c},z={x:z.x+u,y:z.y-c},O={x:O.x+u,y:O.y+f},L={x:L.x-h,y:L.y+f},C={x:C.x-h,y:C.y-c},j={x:j.x-h,y:j.y-c},T={x:T.x+u,y:T.y-c},D={x:D.x+u,y:D.y-c},W={x:W.x+u,y:W.y+f},N={x:N.x+u,y:N.y+f},F={x:F.x-h,y:F.y+f},B={x:B.x-h,y:B.y+f}):(V={x:V.x+h/2,y:V.y+c/2},H={x:H.x-u/2,y:H.y+c/2},G={x:G.x-u/2,y:G.y-f/2},Q={x:Q.x+h/2,y:Q.y-f/2},Y={x:Y.x+h/2,y:Y.y+c/2},U={x:U.x+h/2,y:U.y+c/2},X={x:X.x-u/2,y:X.y+c/2},q={x:q.x-u/2,y:q.y+c/2},Z={x:Z.x-u/2,y:Z.y-f/2},J={x:J.x-u/2,y:J.y-f/2},K={x:K.x+h/2,y:K.y-f/2},_={x:_.x+h/2,y:_.y-f/2},A={x:A.x-h/2,y:A.y-c/2},z={x:z.x+u/2,y:z.y-c/2},O={x:O.x+u/2,y:O.y+f/2},L={x:L.x-h/2,y:L.y+f/2},C={x:C.x-h/2,y:C.y-c/2},j={x:j.x-h/2,y:j.y-c/2},T={x:T.x+u/2,y:T.y-c/2},D={x:D.x+u/2,y:D.y-c/2},W={x:W.x+u/2,y:W.y+f/2},N={x:N.x+u/2,y:N.y+f/2},F={x:F.x-h/2,y:F.y+f/2},B={x:B.x-h/2,y:B.y+f/2}),{btw:c,brw:u,bbw:f,blw:h,btlr:d,btrr:y,bblr:g,bbrr:x,p0:p,p1:m,p2:b,p3:v,p0s:w,p0e:M,p1s:P,p1e:R,p2s:I,p2e:S,p3s:$,p3e:E,op0:A,op1:z,op2:O,op3:L,op0s:C,op0e:j,op1s:T,op1e:D,op2s:W,op2e:N,op3s:F,op3e:B,ip0:V,ip1:H,ip2:G,ip3:Q,ip0s:Y,ip0e:U,ip1s:X,ip1e:q,ip2s:Z,ip2e:J,ip3s:K,ip3e:_}},t.enhanceFontFamliy=function(t){return[t,...Gt].join(", ")},t.equalPoint=W,t.equalTouchPoint=function(t,e){return!0===W(t,e)&&t.f===e.f},t.filterCompactData=function(t,e){const n=t.assets||{},i=w(t),o=(null==e?void 0:e.loadItemMap)||{},r=t=>{t.forEach((t=>{var e,i,l;if("image"===t.type&&t.detail.src){const i=t.detail.src;if(v(i)&&!n[i]&&o[i]&&"string"==typeof(null==(e=o[i])?void 0:e.source))n[i]={type:"image",value:o[i].source};else if(!n[i]){const e=b(i,t.uuid);n[e]||(n[e]={type:"image",value:i}),t.detail.src=e}}else if("svg"===t.type){const e=t.detail.svg;if(v(e)&&!n[e]&&o[e]&&"string"==typeof(null==(i=o[e])?void 0:i.source))n[e]={type:"svg",value:o[e].source};else if(!n[e]){const i=b(e,t.uuid);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}}else if("html"===t.type){const e=t.detail.html;if(v(e)&&!n[e]&&o[e]&&"string"==typeof(null==(l=o[e])?void 0:l.source))n[e]={type:"html",value:o[e].source};else if(!n[e]){const i=b(e,t.uuid);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,r(t.detail.children)}}))};return r(i.elements),i.assets=n,i},t.filterElementAsset=function(t){let e=null,n=null,i=null;return"image"===t.type?i=t.detail.src:"svg"===t.type?i=t.detail.svg:"html"===t.type&&(i=t.detail.html),"string"!=typeof i||v(i)||(e=b(i,t.uuid),n={type:t.type,value:i},"image"===t.type?t.detail.src=e:"svg"===t.type?t.detail.svg=e:"html"===t.type&&(t.detail.html=e)),{element:t,assetId:e,assetItem:n}},t.findElementFromList=function t(e,n){var i;let o=null;for(let r=0;r<n.length;r++){const l=n[r];if(l.uuid===e){o=l;break}if(!o&&"group"===l.type){const n=t(e,(null==(i=null==l?void 0:l.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementFromListByPosition=et,t.findElementQueueFromListByPosition=function(t,e){const n=[];let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(!o)break;if(n.push(o),!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}return n},t.findElementsFromList=function(t,e){const n=[];return function e(i){var o;for(let r=0;r<i.length;r++){const l=i[r];t.includes(l.uuid)?n.push(l):"group"===l.type&&e((null==(o=null==l?void 0:l.detail)?void 0:o.children)||[])}}(e),n},t.findElementsFromListByPositions=function(t,e){const n=[];return t.forEach((t=>{const i=et(t,e);i&&n.push(i)})),n},t.flatElementList=function(t){const e=[],n=[],i=t=>{if(!function(t){var e;if(["rect","circle"].includes(t.type)){const e=t.detail;if(!e.background&&!e.borderWidth)return!1;if("transparent"===e.background&&!e.borderWidth)return!1}if(["group"].includes(t.type)){const e=t.detail||{},{children:n}=e;if(!(n.length>0||e.background||e.borderWidth))return!1;if(!(n.length>0||"transparent"!==e.background||e.borderWidth))return!1}if("text"===t.type&&!t.detail.text)return!1;if("image"===t.type&&!t.detail.src)return!1;if("html"===t.type&&!t.detail.html)return!1;if("svg"===t.type&&!t.detail.svg)return!1;if("path"===t.type){const n=t.detail;if(!((null==(e=null==n?void 0:n.commands)?void 0:e.length)>0))return!1}return!0}(t))return;const i=function(t,e){const{groupQueue:n}=e;let{x:i,y:o}=t;const{w:r,h:l,angle:a=0}=t;let s=0;if(n.forEach((t=>{i+=t.x,o+=t.y,s+=t.angle||0})),s=K(s),0===s)return{x:i,y:o,w:r,h:l,angle:a};s+=t.angle||0,s=K(s);const c=st(t,{groupQueue:n}),u=U(Q(c),c[0],V(0-s));return i=u.x,o=u.y,{x:i,y:o,w:r,h:l,angle:s}}(t,{groupQueue:n}),o={...t,...i};e.push(o)},o=t=>{var e;if(!0!==(null==(e=null==t?void 0:t.operations)?void 0:e.invisible))if("group"===t.type){const{detail:e}=t,{children:r,...l}=e;i({...t,detail:{...l,children:[]}}),n.push(t),r.forEach((t=>{o(t)})),n.pop()}else i(t)};for(let e=0;e<t.length;e++){const n=t[e];o(n)}return e},t.flatObject=zt,t.formatNumber=Pt,t.generateHTML=function(t){return t.reduce((function(t,e){return t+Mt("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.get=function(t,e,n){if(!e)return;const i=Ct(e);let o=t;for(const t of i){if(null==o)return n;o=o[t]}return void 0!==o?o:n},t.getCenterFromTwoPoints=B,t.getDefaultElementDetailConfig=St,t.getDefaultElementRectDetail=$t,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&v(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&v(t.detail.svg)?e.push(t.detail.svg):"html"===t.type&&t.detail.html?e.push(t.detail.html):"group"===t.type&&Array.isArray(t.detail.children)&&n(t.detail.children)}))};return n(t),e},t.getElementPositionFromList=nt,t.getElementPositionMapFromList=function(t,e){const n=[],i={};let o=!1;const r=e=>{var l;for(let a=0;a<e.length&&!0!==o;a++){n.push(a);const s=e[a];if(t.includes(s.uuid)){if(i[s.uuid]=[...n],Object.keys(i).length===t.length){o=!0;break}}else"group"===s.type&&r((null==(l=null==s?void 0:s.detail)?void 0:l.children)||[]);if(o)break;n.pop()}};return r(e),i},t.getElementRotateVertexes=q,t.getElementSize=function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return{x:e,y:n,w:i,h:o,angle:r}},t.getElementVertexes=ot,t.getGroupQueueByElementPosition=function(t,e){var n;const i=[];let o=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const r=o[e[t]];if("group"!==(null==r?void 0:r.type)||!Array.isArray(null==(n=null==r?void 0:r.detail)?void 0:n.children))return null;i.push(r),o=r.detail.children}return i},t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let l=0;l<i.length;l++){const a=i[l];if(a.uuid===e){r=a;break}if(!r&&"group"===a.type){n.push(a);const i=t(e,(null==(o=null==a?void 0:a.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===e){r=i;break}n.pop()}}return r}(t,e),n},t.getSelectedElementUUIDs=function(t,e){var n;let i=[];return Array.isArray(null==t?void 0:t.elements)&&(null==(n=null==t?void 0:t.elements)?void 0:n.length)>0&&Array.isArray(e)&&e.length>0&&e.forEach((e=>{var n;"number"==typeof e?(null==(n=null==t?void 0:t.elements)?void 0:n[e])&&i.push(t.elements[e].uuid):"string"==typeof e&&(i=i.concat(function(t,e){var n;const i=[];if("string"==typeof e&&/^\d+(\.\d+)*$/.test(e)){const o=e.split(".");let r=t;for(;o.length>0;){const t=o.shift();if("string"==typeof t){const e=r[parseInt(t)];e&&0===o.length?i.push(e.uuid):"group"===e.type&&o.length>0&&(r=(null==(n=null==e?void 0:e.detail)?void 0:n.children)||[])}break}}return i}(t.elements,e)))})),i},t.getViewPointAtElement=function(t,e){var n,i,o;const{context2d:r,data:l,viewScaleInfo:a,viewSizeInfo:s,groupQueue:c}=e,u={index:-1,element:null,groupQueueIndex:-1};if(c&&Array.isArray(c)&&(null==c?void 0:c.length)>0)for(let e=c.length-1;e>=0;e--){let o=0,l=0,s=0;for(let t=0;t<=e;t++)o+=c[t].x,l+=c[t].y,s+=c[t].angle||0;const f=c[e];if(f&&"group"===f.type&&Array.isArray(null==(n=f.detail)?void 0:n.children))for(let n=0;n<f.detail.children.length;n++){const h=f.detail.children[n];if(!0!==(null==(i=null==h?void 0:h.operations)?void 0:i.invisible)){if(!h)break;if(ft(t,{context2d:r,element:{x:o+h.x,y:l+h.y,w:h.w,h:h.h,angle:s+(h.angle||0)},viewScaleInfo:a})){u.element=h,(e<c.length-1||"group"!==h.type)&&(u.groupQueueIndex=e);break}}}if(u.element)break}if(u.element)return u;for(let e=l.elements.length-1;e>=0;e--){const n=l.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&ft(t,{context2d:r,element:n,viewScaleInfo:a})){u.index=e,u.element=n;break}}return u},t.getViewScaleInfoFromSnapshot=function(t){const{activeStore:e}=t;return{scale:null==e?void 0:e.scale,offsetTop:null==e?void 0:e.offsetTop,offsetBottom:null==e?void 0:e.offsetBottom,offsetLeft:null==e?void 0:e.offsetLeft,offsetRight:null==e?void 0:e.offsetRight}},t.getViewSizeInfoFromSnapshot=function(t){const{activeStore:e}=t;return{devicePixelRatio:e.devicePixelRatio,width:null==e?void 0:e.width,height:null==e?void 0:e.height,contextWidth:null==e?void 0:e.contextWidth,contextHeight:null==e?void 0:e.contextHeight}},t.groupElementsByPosition=function(t,e){if(e.length>1){let n=!0,i=[];for(let t=1;t<e.length;t++){const o=e[t-1],r=e[t];if(!(o.length>0&&r.length>0)){n=!1;break}if(o.length!==r.length){n=!1;break}const l=[...o],a=[...r],s=l.pop(),c=a.pop();1===t&&"number"==typeof s&&s>=0&&i.push(s),"number"==typeof c&&c>=0&&i.push(c)}if(!0!==n)return console.error("[idraw]: The grouped elements are not siblings!"),t;i.sort(((t,e)=>t-e));const o=[...e[0]].splice(0,e[0].length-1),r=[],l=[...o,i[0]];for(let e=0;e<i.length;e++){const n=et([...o,i[e]],t);n&&r.push(n)}const a=_(r);for(let t=0;t<r.length;t++){const e=r[t];e&&(e.x-=a.x,e.y-=a.y)}for(let e=i.length-1;e>=0;e--){Vt([...o,i[e]],t)}Bt({name:"Group",uuid:p(),type:"group",...a,detail:{children:r}},l,t)}return t},t.insertElementToListByPosition=Bt,t.is=k,t.isAssetId=v,t.isColorStr=g,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:l}=t,{x:a,y:s,w:c,h:u}=ct(t,{viewScaleInfo:i}),f=Z({x:a,y:s,w:c,h:u,angle:l}),h={x:0,y:0,w:o,h:r},d=Math.min(f[0].x,f[1].x,f[2].x,f[3].x),y=Math.min(f[0].y,f[1].y,f[2].y,f[3].y);return it(h,{x:d,y:y,w:Math.max(f[0].x,f[1].x,f[2].x,f[3].x)-d,h:Math.max(f[0].y,f[1].y,f[2].y,f[3].y)-y})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isSameElementSize=function(t,e){return t.x===e.x&&t.y===e.y&&t.h===e.h&&t.w===e.w&&K(t.angle||0)===K(e.angle||0)},t.isViewPointInElement=ft,t.isViewPointInElementSize=function(t,e,n){return ht(t,rt(e),n)},t.isViewPointInVertexes=ht,t.istype=R,t.limitAngle=K,t.loadHTML=async function(t,e){t=t.replace(/\&/gi,"&amp;");const n=await function(t,e){const{width:n,height:i}=e;return new Promise(((e,o)=>{const r=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),l=new FileReader;l.readAsDataURL(r),l.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},l.onerror=function(t){o(t)}}))}(t,e);return await S(n)},t.loadImage=S,t.loadSVG=async function(t){const e=await function(t){return new Promise(((e,n)=>{const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},o.onerror=function(t){n(t)}}))}(t);return await S(e)},t.matrixToAngle=function(t){const e=Rt(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=Rt,t.merge=function t(e,n){const i=e;for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&("object"==typeof n[e]&&null!==n[e]&&"object"==typeof i[e]&&null!==i[e]?i[e]=t(i[e],n[e]):i[e]=n[e]);return e},t.mergeElement=Ht,t.mergeElementAsset=function(t,e){const n=t;let i=null,o=null;return"image"===n.type?i=n.detail.src:"svg"===n.type?i=n.detail.svg:"html"===n.type&&(i=n.detail.html),i&&(null==i?void 0:i.startsWith("@assets/"))&&(o=e[i]),(null==o?void 0:o.type)===n.type&&"string"==typeof(null==o?void 0:o.value)&&(null==o?void 0:o.value)&&("image"===n.type?n.detail.src=o.value:"svg"===n.type?n.detail.svg=o.value:"html"===n.type&&(n.detail.html=o.value)),n},t.mergeGlobal=function(t,e,n){const i=Lt(e),o=[],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Tt(t,e),void 0!==n&&jt(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=Lt(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Tt(t,e)}))}return t},t.mergeHexColorAlpha=function(t,e){if(1===e)return t;let n=1;const i=/^#[0-9a-f]{6,6}$/i;let o=t;if(i.test(t)?n=parseInt(t.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(t)&&(n=parseInt(t.substring(7,9).replace(/^#/,"0x")),o=t.substring(0,7)),n*=e,i.test(o)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o},t.mergeLayout=function(t,e,n){const i=Ot(e),o=[],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Tt(t,e),void 0!==n&&jt(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=Ot(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Tt(t,e)}))}return t},t.moveElementPosition=function(t,e){const n=[...e.from],i=[...e.to];if(0===n.length||0===i.length)return{elements:t,from:n,to:i};if(n.length<=i.length)for(let e=0;e<n.length;e++)if(i[e]!==n[e]);else if(e===n.length-1)return{elements:t,from:n,to:i};const o=et(n,t);if(o){if(!Bt(o,i,t))return{elements:t,from:n,to:i};let e=-1,r=!1;if(n.length>=1&&i.length>=1){if(n.length<=i.length)if(1===n.length)n[0]<i[0]&&(r=!0);else for(let t=0;t<n.length&&n[t]===i[t];t++)if(n.length===n.length-1){r=!0;break}if(n.length>=i.length)if(1===i.length)i[0]<n[0]&&(r=!0);else for(let t=0;t<i.length&&(t===i.length-1&&i[t]<n[t]&&(r=!0),n[t]===i[t]);t++);}if(!0===r)for(let t=0;t<n.length&&i[t]>=0;t++)i[t]!==n[t]&&i[t]<n[t]&&t==i.length-1&&(e=t);e>=0&&(n[e]=n[e]+1),Vt(n,t)}return{elements:t,from:n,to:i}},t.omit=function(t,e){const n={...t};for(const t of e)delete n[t];return n},t.originRectInfoToRangeRectInfo=function(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),n=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),i=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),r={x:t.center.x,y:t.center.y},l={x:i,y:o},a={x:e,y:o},s={x:e,y:n},c={x:i,y:n},u=B(l,a),f=B(c,s),h=B(l,c);return{center:r,topLeft:l,topRight:a,bottomLeft:c,bottomRight:s,top:u,right:B(a,s),left:h,bottom:f}},t.parseAngleToRadian=V,t.parseFileToBase64=function(t){return new Promise((function(e,n){let i=new FileReader;i.addEventListener("load",(function(){e(i.result),i=null})),i.addEventListener("error",(function(t){n(t),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsDataURL(t)}))},t.parseFileToText=function(t){return new Promise((function(e,n){let i=new FileReader;i.addEventListener("load",(function(){e(i.result),i=null})),i.addEventListener("error",(function(t){n(t),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsText(t)}))},t.parseHTML=function(t){const e=[],n=[];let i,o=-1;return t.replace(mt,((r,l)=>{const a="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=l+r.length,u=t.charAt(c);let f;if(s){const t=wt(r);return o<0?(e.push(t),r):(f=n[o],f.children.push(t),r)}if(a){if(o++,i=wt(r),!i.isVoid&&u&&"<"!==u){const e=t.slice(c,t.indexOf("<",c));e.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:e.trim()})}0===o&&e.push(i),f=n[o-1],f&&f.children.push(i),n[o]=i}if((!a||!Array.isArray(i)&&i.isVoid)&&(o>-1&&!Array.isArray(i)&&(i.isVoid||i.name===r.slice(2,-1))&&(o--,i=-1===o?e:n[o]),"<"!==u&&u)){f=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);bt.test(r)&&(r=" "),(i>-1&&o+f.length>=0||" "!==r)&&r.trim()&&f.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:r.trim()})}return r})),e},t.parseRadianToAngle=function(t){return t/Math.PI*180},t.parseSVGPath=function(t){const e=[];return t.replace(gt,((t,n,i)=>{const o=i.match(xt),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.pickFile=function(t){const{accept:e,success:n,error:i}=t;let o=document.createElement("input");o.type="file",e&&(o.accept=e),o.addEventListener("change",(function(){var t;const e=null==(t=o.files)?void 0:t[0];n({file:e}),o=null})),o.addEventListener("error",(function(t){"function"==typeof i&&i(t),o=null})),o.click()},t.resizeEffectGroupElement=Ft,t.rotateByCenter=H,t.rotateElement=function(t,e,n){const i=G(e);H(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=Z,t.rotatePoint=U,t.rotatePointInGroup=X,t.rotateVertexes=J,t.set=jt,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=w(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=b(e,t.uuid);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=b(e,t.uuid);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=b(e,t.uuid);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,o(t.detail.children)}}))};return o(i.elements),i.assets=n,i},t.throttle=function(t,e){let n=-1;return function(...i){n>=0||(n=setTimeout((()=>{t(...i),n=-1}),e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.toFlattenElement=kt,t.toFlattenGlobal=Lt,t.toFlattenLayout=Ot,t.toPath=Ct,t.unflatObject=function(t){const e={};for(const[n,i]of Object.entries(t)){Ut(e,Yt(n),i)}return e},t.ungroupElementsByPosition=function(t,e){var n;const i=et(e,t);i&&"group"===(null==i?void 0:i.type)&&Array.isArray(null==(n=null==i?void 0:i.detail)?void 0:n.children)||console.error("[idraw]: The ungrouped element is not a group element!");const o=[...e].splice(0,e.length-1),r=e[e.length-1],{x:l,y:a}=i;return Vt(e,t),i.detail.children.forEach(((e,n)=>{e.x+=l,e.y+=a;Bt(e,[...o,r+n],t)})),t},t.updateElementInList=function t(e,n,i){var o,r,l;let a=null;for(let s=0;s<i.length;s++){const c=i[s];if(c.uuid===e){"group"===c.type&&(null==(o=c.operations)?void 0:o.resizeEffect)&&Ft(c,{...n},{resizeEffect:null==(r=c.operations)?void 0:r.resizeEffect}),Ht(c,n),a=c;break}"group"===c.type&&(a=t(e,n,(null==(l=null==c?void 0:c.detail)?void 0:l.children)||[]))}return a},t.updateElementInListByPosition=function(t,e,n,i){var o,r;const l=et(t,n);return l&&("group"===l.type&&(null==(o=l.operations)?void 0:o.resizeEffect)&&Ft(l,{...e},{resizeEffect:null==(r=l.operations)?void 0:r.resizeEffect}),Ht(l,e,i)),l},t.vaildPoint=F,t.vaildTouchPoint=function(t){return!0===F(t)&&t.f>=0},t.validateElements=function t(e){let n=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(n=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(n=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(n=t(null==(o=null==e?void 0:e.detail)?void 0:o.children))}))}return n},t.viewScale=function(t){const{scale:e,point:n,viewScaleInfo:i}=t,{offsetLeft:o,offsetTop:r}=i,l=e/i.scale,a=n.x,s=n.y;return{moveX:a-a*l+(o*l-o),moveY:s-s*l+(r*l-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:l,height:a,contextWidth:s,contextHeight:c}=o;let u=i.offsetLeft,f=i.offsetRight,h=i.offsetTop,d=i.offsetBottom;return u+=e,h+=n,f=l-(s*r+u),d=a-(c*r+h),{scale:r,offsetTop:h,offsetLeft:u,offsetRight:f,offsetBottom:d}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idraw/util",
3
- "version": "0.4.0-beta.9",
3
+ "version": "0.4.0",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -18,7 +18,7 @@
18
18
  "url": "https://github.com/idrawjs/idraw/issues"
19
19
  },
20
20
  "homepage": "https://github.com/idrawjs/idraw#readme",
21
- "author": "chenshenhai",
21
+ "author": "idrawjs",
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
24
  "@idraw/types": "^0.4.0-alpha.0"
@@ -1,81 +0,0 @@
1
- import { Context2D } from './context2d';
2
- export function createContext2D(opts) {
3
- const { width, height, ctx, devicePixelRatio } = opts;
4
- let context = ctx;
5
- if (!context) {
6
- const canvas = document.createElement('canvas');
7
- canvas.width = width * devicePixelRatio;
8
- canvas.height = height * devicePixelRatio;
9
- context = canvas.getContext('2d');
10
- }
11
- const context2d = new Context2D(context, opts);
12
- return context2d;
13
- }
14
- export function createOffscreenContext2D(opts) {
15
- const { width, height, devicePixelRatio } = opts;
16
- const offCanvas = new OffscreenCanvas(width * devicePixelRatio, height * devicePixelRatio);
17
- const offRenderCtx = offCanvas.getContext('2d');
18
- const offCtx = offRenderCtx.canvas.getContext('2d');
19
- const context2d = new Context2D(offCtx, {
20
- devicePixelRatio,
21
- offscreenCanvas: offCanvas
22
- });
23
- return context2d;
24
- }
25
- export function createBoardContent(canvas, opts) {
26
- const { width, height, devicePixelRatio, offscreen } = opts;
27
- const ctxOpts = {
28
- width,
29
- height,
30
- devicePixelRatio
31
- };
32
- if (offscreen === true) {
33
- const ctx = canvas.getContext('2d');
34
- const viewContext = createOffscreenContext2D(ctxOpts);
35
- const helperContext = createOffscreenContext2D(ctxOpts);
36
- const underContext = createOffscreenContext2D(ctxOpts);
37
- const boardContext = createContext2D(Object.assign({ ctx }, ctxOpts));
38
- const drawView = () => {
39
- const { width: w, height: h } = viewContext.$getSize();
40
- boardContext.clearRect(0, 0, w, h);
41
- boardContext.drawImage(underContext.canvas, 0, 0, w, h);
42
- boardContext.drawImage(viewContext.canvas, 0, 0, w, h);
43
- boardContext.drawImage(helperContext.canvas, 0, 0, w, h);
44
- underContext.clearRect(0, 0, w, h);
45
- viewContext.clearRect(0, 0, w, h);
46
- helperContext.clearRect(0, 0, w, h);
47
- };
48
- const content = {
49
- underContext,
50
- viewContext,
51
- helperContext,
52
- boardContext,
53
- drawView
54
- };
55
- return content;
56
- }
57
- else {
58
- const ctx = canvas.getContext('2d');
59
- const viewContext = createContext2D(ctxOpts);
60
- const helperContext = createContext2D(ctxOpts);
61
- const underContext = createContext2D(ctxOpts);
62
- const boardContext = createContext2D(Object.assign({ ctx }, ctxOpts));
63
- const drawView = () => {
64
- boardContext.clearRect(0, 0, width, height);
65
- boardContext.drawImage(underContext.canvas, 0, 0, width, height);
66
- boardContext.drawImage(viewContext.canvas, 0, 0, width, height);
67
- boardContext.drawImage(helperContext.canvas, 0, 0, width, height);
68
- underContext.clearRect(0, 0, width, height);
69
- viewContext.clearRect(0, 0, width, height);
70
- helperContext.clearRect(0, 0, width, height);
71
- };
72
- const content = {
73
- underContext,
74
- viewContext,
75
- helperContext,
76
- boardContext,
77
- drawView
78
- };
79
- return content;
80
- }
81
- }
@@ -1,6 +0,0 @@
1
- import type { Element, ElementSize, ElementSizeController, ViewScaleInfo } from '@idraw/types';
2
- export declare function calcElementSizeController(elemSize: ElementSize, opts: {
3
- groupQueue: Element<'group'>[];
4
- controllerSize?: number;
5
- viewScaleInfo: ViewScaleInfo;
6
- }): ElementSizeController;
@@ -1,103 +0,0 @@
1
- import { createUUID } from './uuid';
2
- import { getCenterFromTwoPoints } from './point';
3
- import { calcElementVertexesInGroup, calcElementVertexes } from './vertex';
4
- function createControllerElementSizeFromCenter(center, opts) {
5
- const { x, y } = center;
6
- const { size, angle } = opts;
7
- return {
8
- x: x - size / 2,
9
- y: y - size / 2,
10
- w: size,
11
- h: size,
12
- angle
13
- };
14
- }
15
- export function calcElementSizeController(elemSize, opts) {
16
- const { groupQueue, controllerSize, viewScaleInfo } = opts;
17
- const ctrlSize = (controllerSize && controllerSize > 0 ? controllerSize : 8) / viewScaleInfo.scale;
18
- const { x, y, w, h, angle = 0 } = elemSize;
19
- const ctrlGroupQueue = [
20
- ...[
21
- {
22
- uuid: createUUID(),
23
- x,
24
- y,
25
- w,
26
- h,
27
- angle,
28
- type: 'group',
29
- detail: { children: [] }
30
- }
31
- ],
32
- ...groupQueue
33
- ];
34
- let totalAngle = 0;
35
- ctrlGroupQueue.forEach(({ angle = 0 }) => {
36
- totalAngle += angle;
37
- });
38
- const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
39
- const topCenter = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
40
- const rightCenter = getCenterFromTwoPoints(vertexes[1], vertexes[2]);
41
- const bottomCenter = getCenterFromTwoPoints(vertexes[2], vertexes[3]);
42
- const leftCenter = getCenterFromTwoPoints(vertexes[3], vertexes[0]);
43
- const topLeftCenter = vertexes[0];
44
- const topRightCenter = vertexes[1];
45
- const bottomRightCenter = vertexes[2];
46
- const bottomLeftCenter = vertexes[3];
47
- const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: totalAngle });
48
- const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: totalAngle });
49
- const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: totalAngle });
50
- const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, { size: ctrlSize, angle: totalAngle });
51
- const topLeftVertexes = calcElementVertexes(topLeftSize);
52
- const topRightVertexes = calcElementVertexes(topRightSize);
53
- const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
54
- const bottomRightVertexes = calcElementVertexes(bottomRightSize);
55
- const topVertexes = [topLeftVertexes[1], topRightVertexes[0], topRightVertexes[3], topLeftVertexes[2]];
56
- const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
57
- const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
58
- const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
59
- const sizeController = {
60
- elementWrapper: vertexes,
61
- left: {
62
- type: 'left',
63
- vertexes: leftVertexes,
64
- center: leftCenter
65
- },
66
- right: {
67
- type: 'right',
68
- vertexes: rightVertexes,
69
- center: rightCenter
70
- },
71
- top: {
72
- type: 'top',
73
- vertexes: topVertexes,
74
- center: topCenter
75
- },
76
- bottom: {
77
- type: 'bottom',
78
- vertexes: bottomVertexes,
79
- center: bottomCenter
80
- },
81
- topLeft: {
82
- type: 'top-left',
83
- vertexes: topLeftVertexes,
84
- center: topLeftCenter
85
- },
86
- topRight: {
87
- type: 'top-right',
88
- vertexes: topRightVertexes,
89
- center: topRightCenter
90
- },
91
- bottomLeft: {
92
- type: 'bottom-left',
93
- vertexes: bottomLeftVertexes,
94
- center: bottomLeftCenter
95
- },
96
- bottomRight: {
97
- type: 'bottom-right',
98
- vertexes: bottomRightVertexes,
99
- center: bottomRightCenter
100
- }
101
- };
102
- return sizeController;
103
- }
@@ -1,11 +0,0 @@
1
- export function checkRectIntersect(rect1, rect2) {
2
- const react1MinX = rect1.x;
3
- const react1MinY = rect1.y;
4
- const react1MaxX = rect1.x + rect1.w;
5
- const react1MaxY = rect1.y + rect1.h;
6
- const react2MinX = rect2.x;
7
- const react2MinY = rect2.y;
8
- const react2MaxX = rect2.x + rect2.w;
9
- const react2MaxY = rect2.y + rect2.h;
10
- return react1MinX <= react2MaxX && react1MaxX >= react2MinX && react1MinY <= react2MaxY && react1MaxY >= react2MinY;
11
- }
@@ -1,2 +0,0 @@
1
- import type { Element, ElementSize } from '@idraw/types';
2
- export declare function deepResizeGroupElement(elem: Element<'group'>, size: Pick<Partial<ElementSize>, 'w' | 'h'>): Element<'group'>;
@@ -1,101 +0,0 @@
1
- import { formatNumber } from './number';
2
- const doNum = (n) => {
3
- return formatNumber(n, { decimalPlaces: 4 });
4
- };
5
- function resizeElementBaseDetail(elem, opts) {
6
- const { detail } = elem;
7
- const { xRatio, yRatio, maxRatio } = opts;
8
- const middleRatio = (xRatio + yRatio) / 2;
9
- const { borderWidth, borderRadius, borderDash, shadowOffsetX, shadowOffsetY, shadowBlur } = detail;
10
- if (typeof borderWidth === 'number') {
11
- detail.borderWidth = doNum(borderWidth * middleRatio);
12
- }
13
- else if (Array.isArray(detail.borderWidth)) {
14
- const bw = borderWidth;
15
- detail.borderWidth = [doNum(bw[0] * yRatio), doNum(bw[1] * xRatio), doNum(bw[2] * yRatio), doNum(bw[3] * xRatio)];
16
- }
17
- if (typeof borderRadius === 'number') {
18
- detail.borderRadius = doNum(borderRadius * middleRatio);
19
- }
20
- else if (Array.isArray(detail.borderRadius)) {
21
- const br = borderRadius;
22
- detail.borderRadius = [br[0] * xRatio, br[1] * xRatio, br[2] * yRatio, br[3] * yRatio];
23
- }
24
- if (Array.isArray(borderDash)) {
25
- borderDash.forEach((dash, i) => {
26
- detail.borderDash[i] = doNum(dash * maxRatio);
27
- });
28
- }
29
- if (typeof shadowOffsetX === 'number') {
30
- detail.shadowOffsetX = doNum(shadowOffsetX * maxRatio);
31
- }
32
- if (typeof shadowOffsetY === 'number') {
33
- detail.shadowOffsetX = doNum(shadowOffsetY * maxRatio);
34
- }
35
- if (typeof shadowBlur === 'number') {
36
- detail.shadowOffsetX = doNum(shadowBlur * maxRatio);
37
- }
38
- }
39
- function resizeElementBase(elem, opts) {
40
- const { xRatio, yRatio } = opts;
41
- const { x, y, w, h } = elem;
42
- elem.x = doNum(x * xRatio);
43
- elem.y = doNum(y * yRatio);
44
- elem.w = doNum(w * xRatio);
45
- elem.h = doNum(h * yRatio);
46
- resizeElementBaseDetail(elem, opts);
47
- }
48
- function resizeTextElementDetail(elem, opts) {
49
- const { minRatio, maxRatio } = opts;
50
- const { fontSize, lineHeight } = elem.detail;
51
- const ratio = (minRatio + maxRatio) / 2;
52
- if (fontSize && fontSize > 0) {
53
- elem.detail.fontSize = doNum(fontSize * ratio);
54
- }
55
- if (lineHeight && lineHeight > 0) {
56
- elem.detail.lineHeight = doNum(lineHeight * ratio);
57
- }
58
- }
59
- function resizeElement(elem, opts) {
60
- const { type } = elem;
61
- resizeElementBase(elem, opts);
62
- if (type === 'circle') {
63
- }
64
- else if (type === 'text') {
65
- resizeTextElementDetail(elem, opts);
66
- }
67
- else if (type === 'image') {
68
- }
69
- else if (type === 'svg') {
70
- }
71
- else if (type === 'html') {
72
- }
73
- else if (type === 'path') {
74
- }
75
- else if (type === 'group' && Array.isArray(elem.detail.children)) {
76
- elem.detail.children.forEach((child) => {
77
- resizeElement(child, opts);
78
- });
79
- }
80
- }
81
- export function deepResizeGroupElement(elem, size) {
82
- const resizeW = size.w && size.w > 0 ? size.w : elem.w;
83
- const resizeH = size.h && size.h > 0 ? size.h : elem.h;
84
- const xRatio = resizeW / elem.w;
85
- const yRatio = resizeH / elem.h;
86
- if (xRatio === yRatio && xRatio === 1) {
87
- return elem;
88
- }
89
- const minRatio = Math.min(xRatio, yRatio);
90
- const maxRatio = Math.max(xRatio, yRatio);
91
- elem.w = resizeW;
92
- elem.h = resizeH;
93
- const opts = { xRatio, yRatio, minRatio, maxRatio };
94
- if (elem.type === 'group' && Array.isArray(elem.detail.children)) {
95
- elem.detail.children.forEach((child) => {
96
- resizeElement(child, opts);
97
- });
98
- }
99
- resizeElementBaseDetail(elem, opts);
100
- return elem;
101
- }