@idraw/util 0.4.0-beta.13 → 0.4.0-beta.15
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.
|
@@ -10,12 +10,16 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _Context2D_ctx, _Context2D_opts;
|
|
13
|
+
const defaultFontSize = 12;
|
|
14
|
+
const defaultFontWeight = '400';
|
|
15
|
+
const defaultFontFamily = `-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'`;
|
|
13
16
|
export class Context2D {
|
|
14
17
|
constructor(ctx, opts) {
|
|
15
18
|
_Context2D_ctx.set(this, void 0);
|
|
16
19
|
_Context2D_opts.set(this, void 0);
|
|
17
20
|
__classPrivateFieldSet(this, _Context2D_ctx, ctx, "f");
|
|
18
21
|
__classPrivateFieldSet(this, _Context2D_opts, Object.assign({ devicePixelRatio: 1, offscreenCanvas: null }, opts), "f");
|
|
22
|
+
this.$resetFont();
|
|
19
23
|
}
|
|
20
24
|
$undoPixelRatio(num) {
|
|
21
25
|
return num / __classPrivateFieldGet(this, _Context2D_opts, "f").devicePixelRatio;
|
|
@@ -38,6 +42,13 @@ export class Context2D {
|
|
|
38
42
|
strList.push(`${opts.fontFamily || 'sans-serif'}`);
|
|
39
43
|
__classPrivateFieldGet(this, _Context2D_ctx, "f").font = `${strList.join(' ')}`;
|
|
40
44
|
}
|
|
45
|
+
$resetFont() {
|
|
46
|
+
this.$setFont({
|
|
47
|
+
fontSize: defaultFontSize,
|
|
48
|
+
fontFamily: defaultFontFamily,
|
|
49
|
+
fontWeight: defaultFontWeight
|
|
50
|
+
});
|
|
51
|
+
}
|
|
41
52
|
$getOffscreenCanvas() {
|
|
42
53
|
return __classPrivateFieldGet(this, _Context2D_opts, "f").offscreenCanvas;
|
|
43
54
|
}
|
package/dist/index.global.js
CHANGED
|
@@ -915,6 +915,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
915
915
|
svgDesc,
|
|
916
916
|
htmlDesc
|
|
917
917
|
};
|
|
918
|
+
const defaultFontSize = 12;
|
|
919
|
+
const defaultFontWeight = "400";
|
|
920
|
+
const defaultFontFamily = `-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'`;
|
|
918
921
|
class Context2D {
|
|
919
922
|
// private _width: number = 0;
|
|
920
923
|
// private _height: number = 0;
|
|
@@ -923,6 +926,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
923
926
|
__privateAdd(this, _opts, void 0);
|
|
924
927
|
__privateSet(this, _ctx, ctx);
|
|
925
928
|
__privateSet(this, _opts, { ...{ devicePixelRatio: 1, offscreenCanvas: null }, ...opts });
|
|
929
|
+
this.$resetFont();
|
|
926
930
|
}
|
|
927
931
|
$undoPixelRatio(num) {
|
|
928
932
|
return num / __privateGet(this, _opts).devicePixelRatio;
|
|
@@ -945,6 +949,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
945
949
|
strList.push(`${opts.fontFamily || "sans-serif"}`);
|
|
946
950
|
__privateGet(this, _ctx).font = `${strList.join(" ")}`;
|
|
947
951
|
}
|
|
952
|
+
$resetFont() {
|
|
953
|
+
this.$setFont({
|
|
954
|
+
fontSize: defaultFontSize,
|
|
955
|
+
fontFamily: defaultFontFamily,
|
|
956
|
+
fontWeight: defaultFontWeight
|
|
957
|
+
});
|
|
958
|
+
}
|
|
948
959
|
$getOffscreenCanvas() {
|
|
949
960
|
return __privateGet(this, _opts).offscreenCanvas;
|
|
950
961
|
}
|
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawUtil=function(e){"use strict";var t,n,i,o,r,a,l,s=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},c=(e,t,n)=>(s(e,t,"read from private field"),n?n.call(e):t.get(e)),h=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},u=(e,t,n,i)=>(s(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),d=(e,t,n)=>(s(e,t,"access private method"),n);function f(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}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 m(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function x(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function y(e){const t=e.length,n=Math.floor(t/2),i=e.substring(0,4).padEnd(4,"0"),o=e.substring(0,4).padEnd(4,"0");return`@assets/${x(t.toString(16).padEnd(4,i))}${x(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${x(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${x(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${x(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${x(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${x(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${x(o.padEnd(4,i).padEnd(4,o))}`}function p(e){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(`${e}`)}function w(e){return function e(t){const n=function(e){return Object.prototype.toString.call(e).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(t);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return t;if("Array"===n){const n=[];return t.forEach((t=>{n.push(e(t))})),n}if("Object"===n){const n={};Object.keys(t).forEach((i=>{n[i]=e(t[i])}));return Object.getOwnPropertySymbols(t).forEach((i=>{n[i]=e(t[i])})),n}}(e)}function v(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const b={type(e,t){const n=v(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===v(e),json:e=>"Object"===v(e),function:e=>"Function"===v(e),asyncFunction:e=>"AsyncFunction"===v(e),boolean:e=>"Boolean"===v(e),string:e=>"String"===v(e),number:e=>"Number"===v(e),undefined:e=>"Undefined"===v(e),null:e=>"Null"===v(e),promise:e=>"Promise"===v(e)};const{Image:M}=window;function P(e){return new Promise(((t,n)=>{const i=new M;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function R(e){return"number"==typeof e&&(e>0||e<=0)}function I(e){return"number"==typeof e&&e>=0}function $(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function E(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const A={x:function(e){return R(e)},y:function(e){return R(e)},w:I,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:R,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return I(e)},borderRadius:function(e){return R(e)&&e>=0},color:function(e){return f(e)},imageSrc:function(e){return E(e)||$(e)},imageURL:$,imageBase64:E,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return R(e)&&e>0},lineHeight:function(e){return R(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return R(e)&&e>0}};function S(e={}){const{borderColor:t,borderRadius:n,borderWidth:i}=e;return!(e.hasOwnProperty("borderColor")&&!A.color(t))&&(!(e.hasOwnProperty("borderRadius")&&!A.number(n))&&!(e.hasOwnProperty("borderWidth")&&!A.number(i)))}const C={attrs:function(e){const{x:t,y:n,w:i,h:o,angle:r}=e;return!!(A.x(t)&&A.y(n)&&A.w(i)&&A.h(o)&&A.angle(r))&&(r>=-360&&r<=360)},textDesc:function(e){const{text:t,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:a,fontWeight:l,background:s,strokeWidth:c,strokeColor:h}=e;return!!A.text(t)&&(!!A.color(n)&&(!!A.fontSize(i)&&(!(e.hasOwnProperty("background")&&!A.color(s))&&(!(e.hasOwnProperty("fontWeight")&&!A.fontWeight(l))&&(!(e.hasOwnProperty("lineHeight")&&!A.lineHeight(o))&&(!(e.hasOwnProperty("fontFamily")&&!A.fontFamily(r))&&(!(e.hasOwnProperty("textAlign")&&!A.textAlign(a))&&(!(e.hasOwnProperty("strokeWidth")&&!A.strokeWidth(c))&&(!(e.hasOwnProperty("strokeColor")&&!A.color(h))&&!!S(e))))))))))},rectDesc:function(e){const{background:t}=e;return!(e.hasOwnProperty("background")&&!A.color(t))&&!!S(e)},circleDesc:function(e){const{background:t,borderColor:n,borderWidth:i}=e;return!(e.hasOwnProperty("background")&&!A.color(t))&&(!(e.hasOwnProperty("borderColor")&&!A.color(n))&&!(e.hasOwnProperty("borderWidth")&&!A.number(i)))},imageDesc:function(e){const{src:t}=e;return!!A.imageSrc(t)},svgDesc:function(e){const{svg:t}=e;return!!A.svg(t)},htmlDesc:function(e){const{html:t}=e;return!!A.html(t)}};class k{constructor(e,i){h(this,t,void 0),h(this,n,void 0),u(this,t,e),u(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i})}$undoPixelRatio(e){return e/c(this,n).devicePixelRatio}$doPixelRatio(e){return c(this,n).devicePixelRatio*e}$getContext(){return c(this,t)}$setContext(e){u(this,t,e)}$setFont(e){const n=[];e.fontWeight&&n.push(`${e.fontWeight}`),n.push(`${this.$doPixelRatio(e.fontSize||12)}px`),n.push(`${e.fontFamily||"sans-serif"}`),c(this,t).font=`${n.join(" ")}`}$getOffscreenCanvas(){return c(this,n).offscreenCanvas}$resize(e){const{width:i,height:o,devicePixelRatio:r,resetStyle:a}=e,{canvas:l}=c(this,t);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:e}=c(this,n),{width:i,height:o}=c(this,t).canvas;return{width:i/e,height:o/e,devicePixelRatio:e}}get canvas(){return c(this,t).canvas}get fillStyle(){return c(this,t).fillStyle}set fillStyle(e){c(this,t).fillStyle=e}get strokeStyle(){return c(this,t).strokeStyle}set strokeStyle(e){c(this,t).strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(c(this,t).lineWidth)}set lineWidth(e){c(this,t).lineWidth=this.$doPixelRatio(e)}get textAlign(){return c(this,t).textAlign}set textAlign(e){c(this,t).textAlign=e}get textBaseline(){return c(this,t).textBaseline}set textBaseline(e){c(this,t).textBaseline=e}get globalAlpha(){return c(this,t).globalAlpha}set globalAlpha(e){c(this,t).globalAlpha=e}get shadowColor(){return c(this,t).shadowColor}set shadowColor(e){c(this,t).shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(c(this,t).shadowOffsetX)}set shadowOffsetX(e){c(this,t).shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(c(this,t).shadowOffsetY)}set shadowOffsetY(e){c(this,t).shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(c(this,t).shadowBlur)}set shadowBlur(e){c(this,t).shadowBlur=this.$doPixelRatio(e)}get lineCap(){return c(this,t).lineCap}set lineCap(e){c(this,t).lineCap=e}get globalCompositeOperation(){return c(this,t).globalCompositeOperation}set globalCompositeOperation(e){c(this,t).globalCompositeOperation=e}fill(...e){return c(this,t).fill(...e)}arc(e,n,i,o,r,a){return c(this,t).arc(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,a)}rect(e,n,i,o){return c(this,t).rect(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,n,i,o){return c(this,t).fillRect(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,n,i,o){return c(this,t).clearRect(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return c(this,t).beginPath()}closePath(){return c(this,t).closePath()}lineTo(e,n){return c(this,t).lineTo(this.$doPixelRatio(e),this.$doPixelRatio(n))}moveTo(e,n){return c(this,t).moveTo(this.$doPixelRatio(e),this.$doPixelRatio(n))}arcTo(e,n,i,o,r){return c(this,t).arcTo(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}getLineDash(){return c(this,t).getLineDash()}setLineDash(e){const n=e.map((e=>this.$doPixelRatio(e)));return c(this,t).setLineDash(n)}stroke(e){return e?c(this,t).stroke(e):c(this,t).stroke()}translate(e,n){return c(this,t).translate(this.$doPixelRatio(e),this.$doPixelRatio(n))}rotate(e){return c(this,t).rotate(e)}drawImage(...e){const n=e[0],i=e[1],o=e[2],r=e[3],a=e[4],l=e[e.length-4],s=e[e.length-3],h=e[e.length-2],u=e[e.length-1];return 9===e.length?c(this,t).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,t).drawImage(n,this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h),this.$doPixelRatio(u))}createPattern(e,n){return c(this,t).createPattern(e,n)}measureText(e){return c(this,t).measureText(e)}fillText(e,n,i,o){return void 0!==o?c(this,t).fillText(e,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,t).fillText(e,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(e,n,i,o){return void 0!==o?c(this,t).strokeText(e,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,t).strokeText(e,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){c(this,t).save()}restore(){c(this,t).restore()}scale(e,n){c(this,t).scale(e,n)}circle(e,n,i,o,r,a,l,s){c(this,t).ellipse(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,l,s)}isPointInPath(e,n){return c(this,t).isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(n))}clip(...e){return c(this,t).clip(...e)}setTransform(e,n,i,o,r,a){return c(this,t).setTransform(e,n,i,o,r,a)}getTransform(){return c(this,t).getTransform()}createLinearGradient(e,n,i,o){return c(this,t).createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,n,i,o,r,a){return c(this,t).createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}createConicGradient(e,n,i){return c(this,t).createConicGradient(e,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function z(e){const{width:t,height:n,ctx:i,devicePixelRatio:o}=e;let r=i;if(!r){const e=document.createElement("canvas");e.width=t*o,e.height=n*o,r=e.getContext("2d")}return new k(r,e)}function O(e){const{width:t,height:n,devicePixelRatio:i}=e,o=new OffscreenCanvas(t*i,n*i),r=o.getContext("2d").canvas.getContext("2d");return new k(r,{devicePixelRatio:i,offscreenCanvas:o})}t=new WeakMap,n=new WeakMap;function L(e,t){const n=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y);return 0===n?n:Math.sqrt(n)}function T(e,t){return e.x===t.x&&e.y===t.y&&e.t===t.t}function D(e){return e>=0||e<0}function j(e){return D(e.x)&&D(e.y)&&e.t>0}function W(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}i=new WeakMap;function V(e){return e/180*Math.PI}function F(e,t,n,i){const o=V(t||0);n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(o),e.translate(-n.x,-n.y)),i(e),n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(-o),e.translate(-n.x,-n.y))}function H(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function B(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),n=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return H({x:t,y:n,w:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,h:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-n})}function N(e,t){const n=t.x-e.x,i=t.y-e.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 G(e,t,n){let i=N(e,t)+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=L(e,t);let r=0,a=0;return 0===i?(r=0,a=0-o):i>0&&i<Math.PI/2?(r=Math.sin(i)*o,a=0-Math.cos(i)*o):i===Math.PI/2?(r=o,a=0):i>Math.PI/2&&i<Math.PI?(r=Math.sin(Math.PI-i)*o,a=Math.cos(Math.PI-i)*o):i===Math.PI?(r=0,a=o):i>Math.PI&&i<1.5*Math.PI?(r=0-Math.sin(i-Math.PI)*o,a=Math.cos(i-Math.PI)*o):i===1.5*Math.PI?(r=0-o,a=0):i>1.5*Math.PI&&i<2*Math.PI?(r=0-Math.sin(2*Math.PI-i)*o,a=0-Math.cos(2*Math.PI-i)*o):i===2*Math.PI&&(r=0,a=0-o),r+=e.x,a+=e.y,{x:r,y:a}}function Q(e,t,n){const{x:i,y:o,w:r,h:a}=e;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 e=V(X(n));l=G(t,l,e),s=G(t,s,e),c=G(t,c,e),h=G(t,h,e)}return[l,s,c,h]}function U(e){const{angle:t=0}=e;return Q(e,H(e),t)}function Y(e,t,n){return[G(e,{x:t[0].x,y:t[0].y},n),G(e,{x:t[1].x,y:t[1].y},n),G(e,{x:t[2].x,y:t[2].y},n),G(e,{x:t[3].x,y:t[3].y},n)]}function X(e){if(!(e>0||e<0)||0===e)return 0;let t=e%360;return t<0&&(t+=360),t}function q(e,t){const n={x:0,y:0,w:0,h:0};e.forEach((e=>{const t={x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=U(t);if(4===e.length){const n=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...n),t.y=Math.min(...i),t.w=Math.abs(Math.max(...n)-Math.min(...n)),t.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(t.x,n.x),o=Math.min(t.y,n.y),r=Math.max(t.x+t.w,n.x+n.w),a=Math.max(t.y+t.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(a-o)})),(null==t?void 0:t.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==t?void 0:t.viewWidth)&&(null==t?void 0:t.viewHeight)&&(null==t?void 0:t.viewWidth)>0&&(null==t?void 0:t.viewHeight)>0&&(t.viewWidth>n.x+n.w&&(i.contextWidth=t.viewWidth-n.x),t.viewHeight>n.y+n.h&&(i.contextHeight=t.viewHeight-n.y)),i}function Z(e,t){let n=null,i=t;for(let t=0;t<e.length;t++){const o=i[e[t]];if(t<e.length-1&&"group"===o.type)i=o.detail.children;else{if(t!==e.length-1)break;n=o}}return n}function J(e,t){const n=[];let i=!1;const o=t=>{var r;for(let a=0;a<t.length&&!0!==i;a++){n.push(a);const l=t[a];if(l.uuid===e){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(t),n}function K(e,t){const n=e.x,i=e.y,o=e.x+e.w,r=e.y+e.h,a=t.x,l=t.y,s=t.x+t.w,c=t.y+t.h;return n<=s&&o>=a&&i<=c&&r>=l}function _(e,t){const{viewScaleInfo:n}=t,{x:i,y:o,w:r,h:a,angle:l}=e,{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 ee(e,t){const{viewScaleInfo:n}=t,{x:i,y:o}=e,{scale:r,offsetTop:a,offsetLeft:l}=n;return{x:i*r+l,y:o*r+a}}function te(e,t){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=t,{angle:a=0}=i,{x:l,y:s,w:c,h:h}=_(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 e=1;e<u.length;e++)n.lineTo(u[e].x,u[e].y);n.closePath()}return!!n.isPointInPath(e.x,e.y)}function ne(e){const{x:t,y:n,h:i,w:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t+o,y:n+i},{x:t,y:n+i}]}function ie(e){const{x:t,y:n,w:i,h:o,angle:r=0}=e;return 0===r?ne(e):Q(e,H({x:t,y:n,w:i,h:o,angle:r}),r)}function oe(e){const t=[];let n=0,i=0;const o=[],r=[...e];for(let e=0;e<r.length;e++){const{x:a,y:l,w:s,h:c,angle:h=0}=r[e];let u;if(n+=a,i+=l,0===e){const e={x:n,y:i,w:s,h:c,angle:h};u=ie({x:a,y:l,w:s,h:c,angle:h}),o.push({center:H(e),angle:h,radian:V(h)})}else{u=ne({x:n,y:i,w:s,h:c,angle:h});for(let e=0;e<o.length;e++){const{center:t,radian:n}=o[e];u=Y(t,u,n)}const e=B(u);if(h>0||h<0){u=Y(e,u,V(h))}o.push({center:e,angle:h,radian:V(h)})}t.push(u)}return t}function re(e,t){const{groupQueue:n}=t;if(!(n.length>0))return[ie(e)];return oe([...n,e])}function ae(e,t){return re(e,t).pop()||null}function le(e,t){const{x:n,y:i}=e,{size:o,angle:r}=t;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 se=/([astvzqmhlc])([^astvzqmhlc]*)/gi,ce=/(-?\d+(?:\.\d+)?)/gi;const he=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,ue=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,de=/^\s*$/,fe={};function ge(e){const t={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(fe[n[1]]||"/"===e.charAt(e.length-2))&&(t.isVoid=!0),t.name.startsWith("!--"))){const t=e.indexOf("--\x3e");return{type:"comment",name:null,attributes:{},children:[],isVoid:!1,comment:-1!==t?e.slice(4,t):""}}const i=new RegExp(he);let o=null;for(;o=i.exec(e),null!==o;)if(o[0].trim())if(o[1]){const e=o[1].trim();let n=[e,""];e.indexOf("=")>-1&&(n=e.split("=")),t.attributes[n[0]]=n[1],i.lastIndex--}else o[2]&&(t.attributes[o[2]]=o[3].trim().substring(1,o[3].length-1));return t}function me(e,t){switch(t.type){case"text":return e+t.textContent;case"element":return e+="<"+t.name+(t.attributes?function(e){const t=[];for(let n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attributes):"")+(t.isVoid?"/>":">"),t.isVoid?e:e+t.children.reduce(me,"")+"</"+t.name+">";case"comment":return e+="\x3c!--"+t.comment+"--\x3e"}}function xe(e,t){let n=2;return void 0!==(null==t?void 0:t.decimalPlaces)&&(null==t?void 0:t.decimalPlaces)>=0&&(n=t.decimalPlaces),parseFloat(e.toFixed(n))}function ye(e){return e[1]!=-1*e[3]||e[4]!=e[0]||e[0]*e[4]-e[3]*e[1]!=1?null:Math.acos(e[0])}const pe="Text Element";function we(){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 ve(){return{background:"#D9D9D9"}}const be={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 Me=e=>xe(e,{decimalPlaces:4});function Pe(e,t){const{detail:n}=e,{xRatio:i,yRatio:o,maxRatio:r}=t,a=(i+o)/2,{borderWidth:l,borderRadius:s,borderDash:c,shadowOffsetX:h,shadowOffsetY:u,shadowBlur:d}=n;if("number"==typeof l)n.borderWidth=Me(l*a);else if(Array.isArray(n.borderWidth)){const e=l;n.borderWidth=[Me(e[0]*o),Me(e[1]*i),Me(e[2]*o),Me(e[3]*i)]}if("number"==typeof s)n.borderRadius=Me(s*a);else if(Array.isArray(n.borderRadius)){const e=s;n.borderRadius=[e[0]*i,e[1]*i,e[2]*o,e[3]*o]}Array.isArray(c)&&c.forEach(((e,t)=>{n.borderDash[t]=Me(e*r)})),"number"==typeof h&&(n.shadowOffsetX=Me(h*r)),"number"==typeof u&&(n.shadowOffsetX=Me(u*r)),"number"==typeof d&&(n.shadowOffsetX=Me(d*r))}function Re(e,t){const{type:n}=e;!function(e,t){const{xRatio:n,yRatio:i}=t,{x:o,y:r,w:a,h:l}=e;e.x=Me(o*n),e.y=Me(r*i),e.w=Me(a*n),e.h=Me(l*i),Pe(e,t)}(e,t),"circle"===n||("text"===n?function(e,t){const{minRatio:n,maxRatio:i}=t,{fontSize:o,lineHeight:r}=e.detail,a=(n+i)/2;o&&o>0&&(e.detail.fontSize=Me(o*a)),r&&r>0&&(e.detail.lineHeight=Me(r*a))}(e,t):"image"===n||"svg"===n||"html"===n||"path"===n||"group"===n&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Re(e,t)})))}function Ie(e,t){const n=t.w&&t.w>0?t.w:e.w,i=t.h&&t.h>0?t.h:e.h,o=n/e.w,r=i/e.h;if(o===r&&1===o)return e;const a=Math.min(o,r),l=Math.max(o,r);e.w=n,e.h=i;const s={xRatio:o,yRatio:r,minRatio:a,maxRatio:l};return"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Re(e,s)})),Pe(e,s),e}const $e=200,Ee=200;function Ae(e,t,n){let i=!1;if(1===t.length){const o=t[0];n.splice(o,0,e),i=!0}else if(t.length>1){let o=n;for(let n=0;n<t.length;n++){const r=o[t[n]];if(n===t.length-1){const r=t[n];o.splice(r,0,e),i=!0}else{if(!(n<t.length-1&&"group"===r.type))break;o=r.detail.children}}}return i}function Se(e,t){let n=!1;if(1===e.length){const i=e[0];t.splice(i,1),n=!0}else if(e.length>1){let i=t;for(let t=0;t<e.length;t++){const o=i[e[t]];if(t===e.length-1){const o=e[t];i.splice(o,1),n=!0}else{if(!(t<e.length-1&&"group"===o.type))break;i=o.detail.children}}}return n}function Ce(e,t){const n=[...t.from],i=[...t.to];if(0===n.length||0===i.length)return{elements:e,from:n,to:i};if(n.length<=i.length)for(let t=0;t<n.length;t++)if(i[t]!==n[t]);else if(t===n.length-1)return{elements:e,from:n,to:i};const o=Z(n,e);if(o){if(!Ae(o,i,e))return{elements:e,from:n,to:i};let t=-1;for(let e=0;e<n.length&&i[e]>=0;e++)i[e]!==n[e]&&i[e]<n[e]&&e==i.length-1&&(t=e);t>=0&&(n[t]=n[t]+1),Se(n,e)}return{elements:e,from:n,to:i}}function ke(e,t){var n;const i=Object.keys(t);for(let o=0;o<i.length;o++){const r=i[o];["x","y","w","h","angle","name"].includes(r)?e[r]=t[r]:["detail","operations"].includes(r)&&(b.json(t[r])?((null==e?void 0:e.hasOwnProperty(r))||(e[r]={}),b.json(e[r])&&(e[r]={...e[r],...t[r]})):b.array(t[r])&&((null==e?void 0:e.hasOwnProperty(r))||(e[r]=[]),b.array(e[r])&&(null==(n=null==t?void 0:t[r])||n.forEach(((t,n)=>{e[r][n]=t})),e[r]=[...e[r],...t[r]])))}return e}function ze(e,t,n){var i;const o=Z(e,n);return o&&("group"===o.type&&!0===(null==(i=o.operations)?void 0:i.deepResize)&&(t.w&&t.w>0||t.h&&t.h>0)&&Ie(o,{w:t.w,h:t.h}),ke(o,t)),o}function Oe(e,t,n=void 0){const i=t.split(".").reduce(((e,t)=>Object(e)[t]),e);return void 0===i?n:i}function Le(e,t,n){const i=t.split(".");return"object"!=typeof e||i.reduce(((e,t,i,o)=>i===o.length-1?(e[t]=n,null):(t in e||(e[t]=/^[0-9]{1,}$/.test(o[i+1])?[]:{}),e[t])),e),e}return e.Context2D=k,e.EventEmitter=class{constructor(){h(this,i,void 0),u(this,i,new Map)}on(e,t){if(c(this,i).has(e)){const n=c(this,i).get(e)||[];null==n||n.push(t),c(this,i).set(e,n)}else c(this,i).set(e,[t])}off(e,t){if(c(this,i).has(e)){const n=c(this,i).get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}c(this,i).set(e,n||[])}}trigger(e,t){const n=c(this,i).get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(c(this,i).has(e)){const t=c(this,i).get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){c(this,i).clear()}},e.Store=class{constructor(e){h(this,a),h(this,o,void 0),h(this,r,void 0),u(this,r,w(e.defaultStorage)),u(this,o,d(this,a,l).call(this))}set(e,t){c(this,o)[e]=t}get(e){return c(this,o)[e]}getSnapshot(){return w(c(this,o))}clear(){u(this,o,d(this,a,l).call(this))}destroy(){u(this,o,null)}},e.calcDistance=L,e.calcElementCenter=H,e.calcElementCenterFromVertexes=B,e.calcElementListSize=function(e){var t;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<e.length;o++){const r=e[o];if(null==(t=null==r?void 0:r.operations)?void 0:t.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 e=U(a);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],n=[e[0].y,e[1].y,e[2].y,e[3].y];a.x=Math.min(...t),a.y=Math.min(...n),a.w=Math.abs(Math.max(...t)-Math.min(...t)),a.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const e=Math.min(a.x,n.x),t=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=e,n.y=t,n.w=Math.abs(i-e),n.h=Math.abs(o-t)}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)}},e.calcElementQueueVertexesQueueInGroup=oe,e.calcElementSizeController=function(e,t){const{groupQueue:n,controllerSize:i,viewScaleInfo:o}=t,r=(i&&i>0?i:8)/o.scale,{x:a,y:l,w:s,h:c,angle:h=0}=e,u=[{uuid:m(),x:a,y:l,w:s,h:c,angle:h,type:"group",detail:{children:[]}},...n];let d=0;u.forEach((({angle:e=0})=>{d+=e}));const f=ae(e,{groupQueue:n}),g=ae({x:a-2*r,y:l-2*r,h:c+4*r,w:s+4*r,angle:h},{groupQueue:[...n]}),x=W(f[0],f[1]),y=W(f[1],f[2]),p=W(f[2],f[3]),w=W(f[3],f[0]),v=f[0],b=f[1],M=f[2],P=f[3],R=le(x,{size:r,angle:d}),I=le(y,{size:r,angle:d}),$=le(p,{size:r,angle:d}),E=le(w,{size:r,angle:d}),A=le(v,{size:r,angle:d}),S=le(b,{size:r,angle:d}),C=le(P,{size:r,angle:d}),k=le(M,{size:r,angle:d}),z=ie(A),O=ie(S),L=ie(C),T=ie(k),D=[z[1],O[0],O[3],z[2]],j=[O[3],O[2],T[1],T[0]],V=[L[1],T[0],T[3],L[2]],F=[z[3],z[2],L[1],L[0]],H=ie(R),B=ie(I),N=ie($),G=ie(E),Q=W(g[0],g[1]);return{elementWrapper:f,left:{type:"left",vertexes:F,center:w},right:{type:"right",vertexes:j,center:y},top:{type:"top",vertexes:D,center:x},bottom:{type:"bottom",vertexes:V,center:p},topLeft:{type:"top-left",vertexes:z,center:v},topRight:{type:"top-right",vertexes:O,center:b},bottomLeft:{type:"bottom-left",vertexes:L,center:P},bottomRight:{type:"bottom-right",vertexes:T,center:M},leftMiddle:{type:"left-middle",vertexes:G,center:w},rightMiddle:{type:"right-middle",vertexes:B,center:y},topMiddle:{type:"top-middle",vertexes:H,center:x},bottomMiddle:{type:"bottom-middle",vertexes:N,center:p},rotate:{type:"rotate",vertexes:ie(le(Q,{size:r,angle:d})),center:Q}}},e.calcElementVertexesInGroup=ae,e.calcElementVertexesQueueInGroup=re,e.calcElementsContextSize=q,e.calcElementsViewInfo=function(e,t,n){const i=q(e,{viewWidth:t.width,viewHeight:t.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,t.contextWidth),i.contextHeight=Math.max(i.contextHeight,t.contextHeight)),{contextSize:i}},e.calcRadian=function(e,t,n){const i=N(e,t),o=N(e,n);return null!==o&&null!==i?i>3*Math.PI/2&&o<Math.PI/2?o+(2*Math.PI-i):o>3*Math.PI/2&&i<Math.PI/2?i+(2*Math.PI-o):o-i:0},e.calcSpeed=function(e,t){return L(e,t)/Math.abs(t.t-e.t)},e.calcViewBoxSize=function(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o}=e.detail;const{boxSizing:r=be.boxSizing,borderWidth:a}=e.detail;Array.isArray(a)&&(o=0);let{x:l,y:s,w:c,h:h}=e,u=[0,0,0,0];if("number"==typeof o){const e=o*i;u=[e,e,e,e]}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=e.x+d/2,s=e.y+d/2,c=e.w-d,h=e.h-d):"content-box"===r?(l=e.x-d/2,s=e.y-d/2,c=e.w+d,h=e.h+d):(l=e.x,s=e.y,c=e.w,h=e.h),c=Math.max(c,1),h=Math.max(h,1),u=u.map((e=>Math.min(e,c/2,h/2))),{x:l,y:s,w:c,h:h,radiusList:u}},e.calcViewCenter=function(e){let t=0,n=0;if(e){const{viewScaleInfo:i,viewSizeInfo:o}=e,{offsetLeft:r,offsetTop:a,scale:l}=i,{width:s,height:c}=o;t=0-r+s/l/2,n=0-a+c/l/2}return{x:t,y:n}},e.calcViewCenterContent=function(e,t){var n,i,o,r,a,l,s,c;let h=0,u=0,d=1,f=(null==(i=null==(n=null==e?void 0:e.elements)?void 0:n[0])?void 0:i.x)||0,g=(null==(r=null==(o=null==e?void 0:e.elements)?void 0:o[0])?void 0:r.y)||0,m=(null==(l=null==(a=null==e?void 0:e.elements)?void 0:a[0])?void 0:l.w)||0,x=(null==(c=null==(s=null==e?void 0:e.elements)?void 0:s[0])?void 0:c.h)||0;const{width:y,height:p}=t.viewSizeInfo;if(e.elements.forEach((e=>{const t={x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=U(t);if(4===e.length){const n=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...n),t.y=Math.min(...i),t.w=Math.abs(Math.max(...n)-Math.min(...n)),t.h=Math.abs(Math.max(...i)-Math.min(...i))}}const n=Math.min(t.x,f),i=Math.min(t.y,g),o=Math.max(t.x+t.w,f+m),r=Math.max(t.y+t.h,g+x);f=n,g=i,m=Math.abs(o-n),x=Math.abs(r-i)})),m>0&&x>0){const e=xe(y/m,{decimalPlaces:4}),t=xe(p/x,{decimalPlaces:4});d=Math.min(e,t,1),h=(m*d-y)/2/d+f,u=(x*d-p)/2/d+g}return{offsetX:xe(h,{decimalPlaces:0}),offsetY:xe(u,{decimalPlaces:0}),scale:d}},e.calcViewElementSize=_,e.calcViewPointSize=ee,e.calcViewScaleInfo=function(e,t){const{scale:n,offsetX:i,offsetY:o}=e,{viewSizeInfo:r}=t,{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)}},e.calcViewVertexes=function(e,t){return[ee(e[0],t),ee(e[1],t),ee(e[2],t),ee(e[3],t)]},e.check=C,e.checkRectIntersect=K,e.colorNameToHex=function(e){const t=e.toLowerCase(),n=g[t];return"string"==typeof n?n:null},e.colorToCSS=function(e){let t="transparent";if("string"==typeof e)t=e;else if("linear-gradient"===(null==e?void 0:e.type)){const n=[];"number"==typeof e.angle?n.push(`${e.angle}deg`):n.push("180deg"),Array.isArray(e.stops)&&e.stops.forEach((e=>{n.push(`${e.color} ${100*e.offset}%`)})),t=`linear-gradient(${n.join(", ")})`}else if("radial-gradient"===(null==e?void 0:e.type)){const n=[];Array.isArray(e.stops)&&e.stops.forEach((e=>{n.push(`${e.color} ${100*e.offset}%`)})),t=`radial-gradient(circle, ${n.join(", ")})`}return t},e.colorToLinearGradientCSS=function(e){let t="transparent";if("string"==typeof e)t=e;else if("radial-gradient"===(null==e?void 0:e.type)||"linear-gradient"===(null==e?void 0:e.type)){const n=[];Array.isArray(e.stops)&&e.stops.length>0&&(e.stops.forEach(((t,i)=>{n.push(`${t.color} ${100*t.offset}%`),i===e.stops.length-1&&t.offset<1&&n.push(`${t.color} ${100*t.offset}%`)})),t=`linear-gradient(90deg, ${n.join(", ")})`)}return t},e.compose=function(e){return function(t,n){return function i(o){let r=e[o];o===e.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(t,i.bind(null,o+1)))}catch(e){return Promise.reject(e)}}(0)}},e.compressImage=function(e,t){let n=.5;const i=(null==t?void 0:t.type)||"image/png";return(null==t?void 0:t.radio)&&(null==t?void 0:t.radio)>0&&(null==t?void 0:t.radio)<=1&&(n=null==t?void 0:t.radio),new Promise(((t,o)=>{const r=new Image;r.addEventListener("load",(()=>{const{width:e,height:o}=r,a=e*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,t(c)})),r.addEventListener("error",(e=>{o(e)})),r.src=e}))},e.createAssetId=y,e.createBoardContent=function(e,t){const{width:n,height:i,devicePixelRatio:o,offscreen:r,createCustomContext2D:a}=t,l={width:n,height:i,devicePixelRatio:o},s=e.getContext("2d");if(a){const e=a(l),t=a(l),n=a(l),i=z({ctx:s,...l}),o=()=>{const{width:o,height:r}=e.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),n.clearRect(0,0,o,r),e.clearRect(0,0,o,r),t.clearRect(0,0,o,r)};return{underContext:n,viewContext:e,helperContext:t,boardContext:i,drawView:o}}if(!0===r){const e=O(l),t=O(l),n=O(l),i=z({ctx:s,...l}),o=()=>{const{width:o,height:r}=e.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),n.clearRect(0,0,o,r),e.clearRect(0,0,o,r),t.clearRect(0,0,o,r)};return{underContext:n,viewContext:e,helperContext:t,boardContext:i,drawView:o}}{const e=z(l),t=z(l),o=z(l),r=z({ctx:s,...l}),a=()=>{r.clearRect(0,0,n,i),r.drawImage(o.canvas,0,0,n,i),r.drawImage(e.canvas,0,0,n,i),r.drawImage(t.canvas,0,0,n,i),o.clearRect(0,0,n,i),e.clearRect(0,0,n,i),t.clearRect(0,0,n,i)};return{underContext:o,viewContext:e,helperContext:t,boardContext:r,drawView:a}}},e.createContext2D=z,e.createElement=function(e,t,n){const i=function(e,t){let n=0,i=0,o=$e,r=Ee;if(t){const{viewScaleInfo:a,viewSizeInfo:l}=t,{scale:s,offsetLeft:c,offsetTop:h}=a,{width:u,height:d}=l,f=u/4,g=d/4;o=$e>=f?f/s:$e/s,r=Ee>=g?g/s:Ee/s,["circle","svg","image"].includes(e)?o=r=Math.max(o,r):"text"===e&&(r=o/pe.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}}(e,n);let o={};return"rect"===e?o={background:"#D9D9D9"}:"circle"===e?o={background:"#D9D9D9",radius:0}:"text"===e?o=function(e){const t={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};return{text:pe,color:t.color,fontFamily:t.fontFamily,fontWeight:t.fontWeight,lineHeight:e.w/pe.length,fontSize:e.w/pe.length,textAlign:"center",verticalAlign:"middle"}}(i):"svg"===e?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"===e?o={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===e&&(o={children:[],background:"#D9D9D9",overflow:"hidden"}),{...i,...t,uuid:m(),type:e,detail:{...o,...t.detail||{}}}},e.createOffscreenContext2D=O,e.createUUID=m,e.debounce=function(e,t){let n=-1;return function(...i){n>=0&&window.clearTimeout(n),n=setTimeout((()=>{e(...i),n=-1}),t)}},e.deepClone=w,e.deepCloneElement=function(e){const t=w(e),n=e=>{e.uuid=m(),"group"===e.type&&e.detail.children&&e.detail.children.forEach((e=>{n(e)}))};return n(t),t},e.deepResizeGroupElement=Ie,e.delay=function(e){return new Promise((t=>{setTimeout((()=>{t()}),e)}))},e.deleteElementInList=function(e,t){return Se(J(e,t),t)},e.deleteElementInListByPosition=Se,e.downloadFileFromText=function(e,t){const{fileName:n}=t,i=function(e){const t=(new TextEncoder).encode(e),n=new Blob([t],{type:"text/plain;charset=utf-8"});return window.URL.createObjectURL(n)}(e);let o=document.createElement("a");o.href=i,o.download=n,o.click(),o=null},e.downloadImageFromCanvas=function(e,t){const{fileName:n,type:i="image/jpeg"}=t,o=e.toDataURL(i);let r=document.createElement("a");r.href=o,r.download=n,r.click(),r=null},e.equalPoint=T,e.equalTouchPoint=function(e,t){return!0===T(e,t)&&e.f===t.f},e.filterCompactData=function(e,t){const n=e.assets||{},i=w(e),o=(null==t?void 0:t.loadItemMap)||{},r=e=>{e.forEach((e=>{var t,i,a;if("image"===e.type&&e.detail.src){const i=e.detail.src;if(p(i)&&!n[i]&&o[i]&&"string"==typeof(null==(t=o[i])?void 0:t.source))n[i]={type:"image",value:o[i].source};else if(!n[i]){const t=y(i);n[t]||(n[t]={type:"image",value:i}),e.detail.src=t}}else if("svg"===e.type){const t=e.detail.svg;if(p(t)&&!n[t]&&o[t]&&"string"==typeof(null==(i=o[t])?void 0:i.source))n[t]={type:"svg",value:o[t].source};else if(!n[t]){const i=y(t);n[i]||(n[i]={type:"svg",value:t}),e.detail.svg=i}}else if("html"===e.type){const t=e.detail.html;if(p(t)&&!n[t]&&o[t]&&"string"==typeof(null==(a=o[t])?void 0:a.source))n[t]={type:"html",value:o[t].source};else if(!n[t]){const i=y(t);n[i]||(n[i]={type:"html",value:t}),e.detail.html=i}}else if("group"===e.type&&Array.isArray(e.detail.children)){const t=e.detail.assets||{};Object.keys(t).forEach((e=>{n[e]||(n[e]=t[e])})),delete e.detail.assets,r(e.detail.children)}}))};return r(i.elements),i.assets=n,i},e.filterElementAsset=function(e){let t=null,n=null,i=null;return"image"===e.type?i=e.detail.src:"svg"===e.type?i=e.detail.svg:"html"===e.type&&(i=e.detail.html),"string"!=typeof i||p(i)||(t=y(i),n={type:e.type,value:i},"image"===e.type?e.detail.src=t:"svg"===e.type?e.detail.svg=t:"html"===e.type&&(e.detail.html=t)),{element:e,assetId:t,assetItem:n}},e.findElementFromList=function e(t,n){var i;let o=null;for(let r=0;r<n.length;r++){const a=n[r];if(a.uuid===t){o=a;break}if(!o&&"group"===a.type){const n=e(t,(null==(i=null==a?void 0:a.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===t){o=n;break}}}return o},e.findElementFromListByPosition=Z,e.findElementQueueFromListByPosition=function(e,t){const n=[];let i=t;for(let t=0;t<e.length;t++){const o=i[e[t]];if(!o)break;if(n.push(o),!(t<e.length-1&&"group"===o.type))break;i=o.detail.children}return n},e.findElementsFromList=function(e,t){const n=[];return function t(i){var o;for(let r=0;r<i.length;r++){const a=i[r];e.includes(a.uuid)?n.push(a):"group"===a.type&&t((null==(o=null==a?void 0:a.detail)?void 0:o.children)||[])}}(t),n},e.findElementsFromListByPositions=function(e,t){const n=[];return e.forEach((e=>{const i=Z(e,t);i&&n.push(i)})),n},e.formatNumber=xe,e.generateHTML=function(e){return e.reduce((function(e,t){return e+me("",t)}),"")},e.generateSVGPath=function(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t},e.getCenterFromTwoPoints=W,e.getDefaultElementDetailConfig=we,e.getDefaultElementRectDetail=ve,e.getElemenetsAssetIds=function(e){const t=[],n=e=>{e.forEach((e=>{"image"===e.type&&p(e.detail.src)?t.push(e.detail.src):"svg"===e.type&&p(e.detail.svg)?t.push(e.detail.svg):"html"===e.type&&e.detail.html?t.push(e.detail.html):"group"===e.type&&Array.isArray(e.detail.children)&&n(e.detail.children)}))};return n(e),t},e.getElementPositionFromList=J,e.getElementRotateVertexes=Q,e.getElementSize=function(e){const{x:t,y:n,w:i,h:o,angle:r}=e;return{x:t,y:n,w:i,h:o,angle:r}},e.getElementVertexes=ne,e.getGroupQueueFromList=function(e,t){const n=[];return function e(t,i){var o;let r=null;for(let a=0;a<i.length;a++){const l=i[a];if(l.uuid===t){r=l;break}if(!r&&"group"===l.type){n.push(l);const i=e(t,(null==(o=null==l?void 0:l.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===t){r=i;break}n.pop()}}return r}(e,t),n},e.getModifiedElement=function(e,t){const n={},i=[],o=e=>{if(b.json(e)){Object.keys(e).forEach((r=>{if(i.push(r),b.json(e[r])||b.array(e[r]))o(e[r]);else{const e=i.join(".");if("uuid"!==e){const o=Oe(t,e);Le(n,i.join("."),o)}}i.pop()}))}else b.array(e)&&e.forEach((r=>{if(i.push(r),b.json(e[r])||b.array(e[r]))o(e[r]);else{const e=Oe(t,i.join("."));Le(n,i.join("."),e)}i.pop()}))};return o(e),n},e.getSelectedElementUUIDs=function(e,t){var n;let i=[];return Array.isArray(null==e?void 0:e.elements)&&(null==(n=null==e?void 0:e.elements)?void 0:n.length)>0&&Array.isArray(t)&&t.length>0&&t.forEach((t=>{var n;"number"==typeof t?(null==(n=null==e?void 0:e.elements)?void 0:n[t])&&i.push(e.elements[t].uuid):"string"==typeof t&&(i=i.concat(function(e,t){var n;const i=[];if("string"==typeof t&&/^\d+(\.\d+)*$/.test(t)){const o=t.split(".");let r=e;for(;o.length>0;){const e=o.shift();if("string"==typeof e){const t=r[parseInt(e)];t&&0===o.length?i.push(t.uuid):"group"===t.type&&o.length>0&&(r=(null==(n=null==t?void 0:t.detail)?void 0:n.children)||[])}break}}return i}(e.elements,t)))})),i},e.getViewPointAtElement=function(e,t){var n,i,o;const{context2d:r,data:a,viewScaleInfo:l,viewSizeInfo:s,groupQueue:c}=t,h={index:-1,element:null,groupQueueIndex:-1};if(c&&Array.isArray(c)&&(null==c?void 0:c.length)>0)for(let t=c.length-1;t>=0;t--){let o=0,a=0,u=0;for(let e=0;e<=t;e++)o+=c[e].x,a+=c[e].y,u+=c[e].angle||0;const d=c[t];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(te(e,{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,(t<c.length-1||"group"!==f.type)&&(h.groupQueueIndex=t);break}}}if(h.element)break}if(h.element)return h;for(let t=a.elements.length-1;t>=0;t--){const n=a.elements[t];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&te(e,{context2d:r,element:n,viewScaleInfo:l,viewSizeInfo:s})){h.index=t,h.element=n;break}}return h},e.getViewScaleInfoFromSnapshot=function(e){const{activeStore:t}=e;return{scale:null==t?void 0:t.scale,offsetTop:null==t?void 0:t.offsetTop,offsetBottom:null==t?void 0:t.offsetBottom,offsetLeft:null==t?void 0:t.offsetLeft,offsetRight:null==t?void 0:t.offsetRight}},e.getViewSizeInfoFromSnapshot=function(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:null==t?void 0:t.width,height:null==t?void 0:t.height,contextWidth:null==t?void 0:t.contextWidth,contextHeight:null==t?void 0:t.contextHeight}},e.insertElementToListByPosition=Ae,e.is=A,e.isAssetId=p,e.isColorStr=f,e.isElementInView=function(e,t){const{viewSizeInfo:n,viewScaleInfo:i}=t,{width:o,height:r}=n,{angle:a}=e,{x:l,y:s,w:c,h:h}=_(e,{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 K(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})},e.isResourceElement=function(e){return["image","svg","html"].includes(null==e?void 0:e.type)},e.isViewPointInElement=te,e.istype=b,e.limitAngle=X,e.loadHTML=async function(e,t){e=e.replace(/\&/gi,"&");const n=await function(e,t){const{width:n,height:i}=t;return new Promise(((t,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 ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(e){var n;const i=null==(n=null==e?void 0:e.target)?void 0:n.result;t(i)},a.onerror=function(e){o(e)}}))}(e,t);return await P(n)},e.loadImage=P,e.loadSVG=async function(e){const t=await function(e){return new Promise(((t,n)=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(e){var n;const i=null==(n=null==e?void 0:e.target)?void 0:n.result;t(i)},o.onerror=function(e){n(e)}}))}(e);return await P(t)},e.matrixToAngle=function(e){const t=ye(e);if("number"==typeof t){return 180*t/Math.PI}return t},e.matrixToRadian=ye,e.mergeElementAsset=function(e,t){const n=e;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=t[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},e.mergeHexColorAlpha=function(e,t){if(1===t)return e;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=e;if(i.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),o=e.substring(0,7)),n*=t,i.test(o)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${e.toString(16).toUpperCase()}`}return o},e.modifyElement=function(e,t){const{type:n}=t,i={...t.content};if("addElement"===n){const n=t,{element:i,position:o}=n.content;(null==o?void 0:o.length)>0?Ae(i,[...o],e.elements):e.elements.push(i)}else if("deleteElement"===n){const n=t,{position:i}=n.content;Se(i,e.elements)}else if("moveElement"===n){const n=t,{from:o,to:r}=n.content,a=Ce(e.elements,{from:o,to:r});i.from=a.from,i.to=a.to,e.elements=a.elements}else if("updateElement"===n){const n=t,{position:i,afterModifiedElement:o}=n.content;ze(i,o,e.elements)}return{data:e,content:i}},e.moveElementPosition=Ce,e.parseAngleToRadian=V,e.parseFileToBase64=function(e){return new Promise((function(t,n){let i=new FileReader;i.addEventListener("load",(function(){t(i.result),i=null})),i.addEventListener("error",(function(e){n(e),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsDataURL(e)}))},e.parseFileToText=function(e){return new Promise((function(t,n){let i=new FileReader;i.addEventListener("load",(function(){t(i.result),i=null})),i.addEventListener("error",(function(e){n(e),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsText(e)}))},e.parseHTML=function(e){const t=[],n=[];let i,o=-1;return e.replace(ue,((r,a)=>{const l="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=a+r.length,h=e.charAt(c);let u;if(s){const e=ge(r);return o<0?(t.push(e),r):(u=n[o],u.children.push(e),r)}if(l){if(o++,i=ge(r),!i.isVoid&&h&&"<"!==h){const t=e.slice(c,e.indexOf("<",c));t.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:t.trim()})}0===o&&t.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?t:n[o]),"<"!==h&&h)){u=-1===o?t:n[o].children;const i=e.indexOf("<",c);let r=e.slice(c,-1===i?void 0:i);de.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})),t},e.parseRadianToAngle=function(e){return e/Math.PI*180},e.parseSVGPath=function(e){const t=[];return e.replace(se,((e,n,i)=>{const o=i.match(ce),r={type:n,params:o?o.map(Number):[]};return t.push(r),e})),t},e.pickFile=function(e){const{accept:t,success:n,error:i}=e;let o=document.createElement("input");o.type="file",t&&(o.accept=t),o.addEventListener("change",(function(){var e;const t=null==(e=o.files)?void 0:e[0];n({file:t}),o=null})),o.addEventListener("error",(function(e){"function"==typeof i&&i(e),o=null})),o.click()},e.rotateByCenter=F,e.rotateElement=function(e,t,n){const i=H(t);F(e,t.angle||0,i,(()=>{n(e)}))},e.rotateElementVertexes=U,e.rotatePoint=G,e.rotatePointInGroup=function(e,t){if((null==t?void 0:t.length)>0){let n=e.x,i=e.y;return t.forEach((e=>{const{x:t,y:o,w:r,h:a,angle:l=0}=e,s=G(H({x:t,y:o,w:r,h:a,angle:l}),{x:n,y:i},V(l));n=s.x,i=s.y})),{x:n,y:i}}return e},e.rotateVertexes=Y,e.sortDataAsserts=function(e,t){const n=e.assets||{};let i=e;!0===(null==t?void 0:t.clone)&&(i=w(e));const o=e=>{e.forEach((e=>{if("image"===e.type&&e.detail.src){const t=e.detail.src,i=y(t);n[i]||(n[i]={type:"image",value:t}),e.detail.src=i}else if("svg"===e.type){const t=e.detail.svg,i=y(t);n[i]||(n[i]={type:"svg",value:t}),e.detail.svg=i}else if("html"===e.type){const t=e.detail.html,i=y(t);n[i]||(n[i]={type:"html",value:t}),e.detail.html=i}else if("group"===e.type&&Array.isArray(e.detail.children)){const t=e.detail.assets||{};Object.keys(t).forEach((e=>{n[e]||(n[e]=t[e])})),delete e.detail.assets,o(e.detail.children)}}))};return o(i.elements),i.assets=n,i},e.throttle=function(e,t){let n=-1;return function(...i){n>=0||(n=setTimeout((()=>{e(...i),n=-1}),t))}},e.toColorHexNum=function(e){return parseInt(e.replace(/^\#/,"0x"))},e.toColorHexStr=function(e){return"#"+e.toString(16)},e.updateElementInList=function e(t,n,i){var o,r;let a=null;for(let l=0;l<i.length;l++){const s=i[l];if(s.uuid===t){"group"===s.type&&!0===(null==(o=s.operations)?void 0:o.deepResize)&&(n.w&&n.w>0||n.h&&n.h>0)&&Ie(s,{w:n.w,h:n.h}),ke(s,n),a=s;break}"group"===s.type&&(a=e(t,n,(null==(r=null==s?void 0:s.detail)?void 0:r.children)||[]))}return a},e.updateElementInListByPosition=ze,e.vaildPoint=j,e.vaildTouchPoint=function(e){return!0===j(e)&&e.f>=0},e.validateElements=function e(t){let n=!0;if(Array.isArray(t)){const i=[];t.forEach((t=>{var o;"string"==typeof t.uuid&&t.uuid?i.includes(t.uuid)?(n=!1,console.warn(`Duplicate uuids: ${t.uuid}`)):i.push(t.uuid):(n=!1,console.warn("Element missing uuid",t)),"group"===t.type&&(n=e(null==(o=null==t?void 0:t.detail)?void 0:o.children))}))}return n},e.viewScale=function(e){const{scale:t,point:n,viewScaleInfo:i}=e,{offsetLeft:o,offsetTop:r}=i,a=t/i.scale,l=n.x,s=n.y;return{moveX:l-l*a+(o*a-o),moveY:s-s*a+(r*a-r)}},e.viewScroll=function(e){const{moveX:t=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=e,{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+=t,d+=n,u=a-(s*r+h),f=l-(c*r+d),{scale:r,offsetTop:d,offsetLeft:h,offsetRight:u,offsetBottom:f}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
|
1
|
+
var iDrawUtil=function(e){"use strict";var t,n,i,o,r,a,l,s=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},c=(e,t,n)=>(s(e,t,"read from private field"),n?n.call(e):t.get(e)),h=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},u=(e,t,n,i)=>(s(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),d=(e,t,n)=>(s(e,t,"access private method"),n);function f(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}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 m(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function y(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function x(e){const t=e.length,n=Math.floor(t/2),i=e.substring(0,4).padEnd(4,"0"),o=e.substring(0,4).padEnd(4,"0");return`@assets/${y(t.toString(16).padEnd(4,i))}${y(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${y(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${y(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${y(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${y(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${y(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${y(o.padEnd(4,i).padEnd(4,o))}`}function p(e){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(`${e}`)}function w(e){return function e(t){const n=function(e){return Object.prototype.toString.call(e).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(t);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return t;if("Array"===n){const n=[];return t.forEach((t=>{n.push(e(t))})),n}if("Object"===n){const n={};Object.keys(t).forEach((i=>{n[i]=e(t[i])}));return Object.getOwnPropertySymbols(t).forEach((i=>{n[i]=e(t[i])})),n}}(e)}function v(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const b={type(e,t){const n=v(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===v(e),json:e=>"Object"===v(e),function:e=>"Function"===v(e),asyncFunction:e=>"AsyncFunction"===v(e),boolean:e=>"Boolean"===v(e),string:e=>"String"===v(e),number:e=>"Number"===v(e),undefined:e=>"Undefined"===v(e),null:e=>"Null"===v(e),promise:e=>"Promise"===v(e)};const{Image:M}=window;function P(e){return new Promise(((t,n)=>{const i=new M;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function I(e){return"number"==typeof e&&(e>0||e<=0)}function R(e){return"number"==typeof e&&e>=0}function $(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function E(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const S={x:function(e){return I(e)},y:function(e){return I(e)},w:R,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:I,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return R(e)},borderRadius:function(e){return I(e)&&e>=0},color:function(e){return f(e)},imageSrc:function(e){return E(e)||$(e)},imageURL:$,imageBase64:E,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return I(e)&&e>0},lineHeight:function(e){return I(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return I(e)&&e>0}};function A(e={}){const{borderColor:t,borderRadius:n,borderWidth:i}=e;return!(e.hasOwnProperty("borderColor")&&!S.color(t))&&(!(e.hasOwnProperty("borderRadius")&&!S.number(n))&&!(e.hasOwnProperty("borderWidth")&&!S.number(i)))}const C={attrs:function(e){const{x:t,y:n,w:i,h:o,angle:r}=e;return!!(S.x(t)&&S.y(n)&&S.w(i)&&S.h(o)&&S.angle(r))&&(r>=-360&&r<=360)},textDesc:function(e){const{text:t,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:a,fontWeight:l,background:s,strokeWidth:c,strokeColor:h}=e;return!!S.text(t)&&(!!S.color(n)&&(!!S.fontSize(i)&&(!(e.hasOwnProperty("background")&&!S.color(s))&&(!(e.hasOwnProperty("fontWeight")&&!S.fontWeight(l))&&(!(e.hasOwnProperty("lineHeight")&&!S.lineHeight(o))&&(!(e.hasOwnProperty("fontFamily")&&!S.fontFamily(r))&&(!(e.hasOwnProperty("textAlign")&&!S.textAlign(a))&&(!(e.hasOwnProperty("strokeWidth")&&!S.strokeWidth(c))&&(!(e.hasOwnProperty("strokeColor")&&!S.color(h))&&!!A(e))))))))))},rectDesc:function(e){const{background:t}=e;return!(e.hasOwnProperty("background")&&!S.color(t))&&!!A(e)},circleDesc:function(e){const{background:t,borderColor:n,borderWidth:i}=e;return!(e.hasOwnProperty("background")&&!S.color(t))&&(!(e.hasOwnProperty("borderColor")&&!S.color(n))&&!(e.hasOwnProperty("borderWidth")&&!S.number(i)))},imageDesc:function(e){const{src:t}=e;return!!S.imageSrc(t)},svgDesc:function(e){const{svg:t}=e;return!!S.svg(t)},htmlDesc:function(e){const{html:t}=e;return!!S.html(t)}};class k{constructor(e,i){h(this,t,void 0),h(this,n,void 0),u(this,t,e),u(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i}),this.$resetFont()}$undoPixelRatio(e){return e/c(this,n).devicePixelRatio}$doPixelRatio(e){return c(this,n).devicePixelRatio*e}$getContext(){return c(this,t)}$setContext(e){u(this,t,e)}$setFont(e){const n=[];e.fontWeight&&n.push(`${e.fontWeight}`),n.push(`${this.$doPixelRatio(e.fontSize||12)}px`),n.push(`${e.fontFamily||"sans-serif"}`),c(this,t).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 c(this,n).offscreenCanvas}$resize(e){const{width:i,height:o,devicePixelRatio:r,resetStyle:a}=e,{canvas:l}=c(this,t);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:e}=c(this,n),{width:i,height:o}=c(this,t).canvas;return{width:i/e,height:o/e,devicePixelRatio:e}}get canvas(){return c(this,t).canvas}get fillStyle(){return c(this,t).fillStyle}set fillStyle(e){c(this,t).fillStyle=e}get strokeStyle(){return c(this,t).strokeStyle}set strokeStyle(e){c(this,t).strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(c(this,t).lineWidth)}set lineWidth(e){c(this,t).lineWidth=this.$doPixelRatio(e)}get textAlign(){return c(this,t).textAlign}set textAlign(e){c(this,t).textAlign=e}get textBaseline(){return c(this,t).textBaseline}set textBaseline(e){c(this,t).textBaseline=e}get globalAlpha(){return c(this,t).globalAlpha}set globalAlpha(e){c(this,t).globalAlpha=e}get shadowColor(){return c(this,t).shadowColor}set shadowColor(e){c(this,t).shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(c(this,t).shadowOffsetX)}set shadowOffsetX(e){c(this,t).shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(c(this,t).shadowOffsetY)}set shadowOffsetY(e){c(this,t).shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(c(this,t).shadowBlur)}set shadowBlur(e){c(this,t).shadowBlur=this.$doPixelRatio(e)}get lineCap(){return c(this,t).lineCap}set lineCap(e){c(this,t).lineCap=e}get globalCompositeOperation(){return c(this,t).globalCompositeOperation}set globalCompositeOperation(e){c(this,t).globalCompositeOperation=e}fill(...e){return c(this,t).fill(...e)}arc(e,n,i,o,r,a){return c(this,t).arc(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,a)}rect(e,n,i,o){return c(this,t).rect(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,n,i,o){return c(this,t).fillRect(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,n,i,o){return c(this,t).clearRect(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return c(this,t).beginPath()}closePath(){return c(this,t).closePath()}lineTo(e,n){return c(this,t).lineTo(this.$doPixelRatio(e),this.$doPixelRatio(n))}moveTo(e,n){return c(this,t).moveTo(this.$doPixelRatio(e),this.$doPixelRatio(n))}arcTo(e,n,i,o,r){return c(this,t).arcTo(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}getLineDash(){return c(this,t).getLineDash()}setLineDash(e){const n=e.map((e=>this.$doPixelRatio(e)));return c(this,t).setLineDash(n)}stroke(e){return e?c(this,t).stroke(e):c(this,t).stroke()}translate(e,n){return c(this,t).translate(this.$doPixelRatio(e),this.$doPixelRatio(n))}rotate(e){return c(this,t).rotate(e)}drawImage(...e){const n=e[0],i=e[1],o=e[2],r=e[3],a=e[4],l=e[e.length-4],s=e[e.length-3],h=e[e.length-2],u=e[e.length-1];return 9===e.length?c(this,t).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,t).drawImage(n,this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h),this.$doPixelRatio(u))}createPattern(e,n){return c(this,t).createPattern(e,n)}measureText(e){return c(this,t).measureText(e)}fillText(e,n,i,o){return void 0!==o?c(this,t).fillText(e,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,t).fillText(e,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(e,n,i,o){return void 0!==o?c(this,t).strokeText(e,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,t).strokeText(e,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){c(this,t).save()}restore(){c(this,t).restore()}scale(e,n){c(this,t).scale(e,n)}circle(e,n,i,o,r,a,l,s){c(this,t).ellipse(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,l,s)}isPointInPath(e,n){return c(this,t).isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(n))}clip(...e){return c(this,t).clip(...e)}setTransform(e,n,i,o,r,a){return c(this,t).setTransform(e,n,i,o,r,a)}getTransform(){return c(this,t).getTransform()}createLinearGradient(e,n,i,o){return c(this,t).createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,n,i,o,r,a){return c(this,t).createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}createConicGradient(e,n,i){return c(this,t).createConicGradient(e,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function z(e){const{width:t,height:n,ctx:i,devicePixelRatio:o}=e;let r=i;if(!r){const e=document.createElement("canvas");e.width=t*o,e.height=n*o,r=e.getContext("2d")}return new k(r,e)}function O(e){const{width:t,height:n,devicePixelRatio:i}=e,o=new OffscreenCanvas(t*i,n*i),r=o.getContext("2d").canvas.getContext("2d");return new k(r,{devicePixelRatio:i,offscreenCanvas:o})}t=new WeakMap,n=new WeakMap;function L(e,t){const n=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y);return 0===n?n:Math.sqrt(n)}function T(e,t){return e.x===t.x&&e.y===t.y&&e.t===t.t}function D(e){return e>=0||e<0}function j(e){return D(e.x)&&D(e.y)&&e.t>0}function W(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}i=new WeakMap;function F(e){return e/180*Math.PI}function V(e,t,n,i){const o=F(t||0);n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(o),e.translate(-n.x,-n.y)),i(e),n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(-o),e.translate(-n.x,-n.y))}function H(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function N(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),n=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return H({x:t,y:n,w:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,h:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-n})}function B(e,t){const n=t.x-e.x,i=t.y-e.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 G(e,t,n){let i=B(e,t)+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=L(e,t);let r=0,a=0;return 0===i?(r=0,a=0-o):i>0&&i<Math.PI/2?(r=Math.sin(i)*o,a=0-Math.cos(i)*o):i===Math.PI/2?(r=o,a=0):i>Math.PI/2&&i<Math.PI?(r=Math.sin(Math.PI-i)*o,a=Math.cos(Math.PI-i)*o):i===Math.PI?(r=0,a=o):i>Math.PI&&i<1.5*Math.PI?(r=0-Math.sin(i-Math.PI)*o,a=Math.cos(i-Math.PI)*o):i===1.5*Math.PI?(r=0-o,a=0):i>1.5*Math.PI&&i<2*Math.PI?(r=0-Math.sin(2*Math.PI-i)*o,a=0-Math.cos(2*Math.PI-i)*o):i===2*Math.PI&&(r=0,a=0-o),r+=e.x,a+=e.y,{x:r,y:a}}function U(e,t,n){const{x:i,y:o,w:r,h:a}=e;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 e=F(X(n));l=G(t,l,e),s=G(t,s,e),c=G(t,c,e),h=G(t,h,e)}return[l,s,c,h]}function Q(e){const{angle:t=0}=e;return U(e,H(e),t)}function Y(e,t,n){return[G(e,{x:t[0].x,y:t[0].y},n),G(e,{x:t[1].x,y:t[1].y},n),G(e,{x:t[2].x,y:t[2].y},n),G(e,{x:t[3].x,y:t[3].y},n)]}function X(e){if(!(e>0||e<0)||0===e)return 0;let t=e%360;return t<0&&(t+=360),t}function q(e,t){const n={x:0,y:0,w:0,h:0};e.forEach((e=>{const t={x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=Q(t);if(4===e.length){const n=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...n),t.y=Math.min(...i),t.w=Math.abs(Math.max(...n)-Math.min(...n)),t.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(t.x,n.x),o=Math.min(t.y,n.y),r=Math.max(t.x+t.w,n.x+n.w),a=Math.max(t.y+t.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(a-o)})),(null==t?void 0:t.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==t?void 0:t.viewWidth)&&(null==t?void 0:t.viewHeight)&&(null==t?void 0:t.viewWidth)>0&&(null==t?void 0:t.viewHeight)>0&&(t.viewWidth>n.x+n.w&&(i.contextWidth=t.viewWidth-n.x),t.viewHeight>n.y+n.h&&(i.contextHeight=t.viewHeight-n.y)),i}function Z(e,t){let n=null,i=t;for(let t=0;t<e.length;t++){const o=i[e[t]];if(t<e.length-1&&"group"===o.type)i=o.detail.children;else{if(t!==e.length-1)break;n=o}}return n}function J(e,t){const n=[];let i=!1;const o=t=>{var r;for(let a=0;a<t.length&&!0!==i;a++){n.push(a);const l=t[a];if(l.uuid===e){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(t),n}function K(e,t){const n=e.x,i=e.y,o=e.x+e.w,r=e.y+e.h,a=t.x,l=t.y,s=t.x+t.w,c=t.y+t.h;return n<=s&&o>=a&&i<=c&&r>=l}function _(e,t){const{viewScaleInfo:n}=t,{x:i,y:o,w:r,h:a,angle:l}=e,{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 ee(e,t){const{viewScaleInfo:n}=t,{x:i,y:o}=e,{scale:r,offsetTop:a,offsetLeft:l}=n;return{x:i*r+l,y:o*r+a}}function te(e,t){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=t,{angle:a=0}=i,{x:l,y:s,w:c,h:h}=_(i,{viewScaleInfo:o,viewSizeInfo:r}),u=Q({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 e=1;e<u.length;e++)n.lineTo(u[e].x,u[e].y);n.closePath()}return!!n.isPointInPath(e.x,e.y)}function ne(e){const{x:t,y:n,h:i,w:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t+o,y:n+i},{x:t,y:n+i}]}function ie(e){const{x:t,y:n,w:i,h:o,angle:r=0}=e;return 0===r?ne(e):U(e,H({x:t,y:n,w:i,h:o,angle:r}),r)}function oe(e){const t=[];let n=0,i=0;const o=[],r=[...e];for(let e=0;e<r.length;e++){const{x:a,y:l,w:s,h:c,angle:h=0}=r[e];let u;if(n+=a,i+=l,0===e){const e={x:n,y:i,w:s,h:c,angle:h};u=ie({x:a,y:l,w:s,h:c,angle:h}),o.push({center:H(e),angle:h,radian:F(h)})}else{u=ne({x:n,y:i,w:s,h:c,angle:h});for(let e=0;e<o.length;e++){const{center:t,radian:n}=o[e];u=Y(t,u,n)}const e=N(u);if(h>0||h<0){u=Y(e,u,F(h))}o.push({center:e,angle:h,radian:F(h)})}t.push(u)}return t}function re(e,t){const{groupQueue:n}=t;if(!(n.length>0))return[ie(e)];return oe([...n,e])}function ae(e,t){return re(e,t).pop()||null}function le(e,t){const{x:n,y:i}=e,{size:o,angle:r}=t;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 se=/([astvzqmhlc])([^astvzqmhlc]*)/gi,ce=/(-?\d+(?:\.\d+)?)/gi;const he=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,ue=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,de=/^\s*$/,fe={};function ge(e){const t={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(fe[n[1]]||"/"===e.charAt(e.length-2))&&(t.isVoid=!0),t.name.startsWith("!--"))){const t=e.indexOf("--\x3e");return{type:"comment",name:null,attributes:{},children:[],isVoid:!1,comment:-1!==t?e.slice(4,t):""}}const i=new RegExp(he);let o=null;for(;o=i.exec(e),null!==o;)if(o[0].trim())if(o[1]){const e=o[1].trim();let n=[e,""];e.indexOf("=")>-1&&(n=e.split("=")),t.attributes[n[0]]=n[1],i.lastIndex--}else o[2]&&(t.attributes[o[2]]=o[3].trim().substring(1,o[3].length-1));return t}function me(e,t){switch(t.type){case"text":return e+t.textContent;case"element":return e+="<"+t.name+(t.attributes?function(e){const t=[];for(let n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attributes):"")+(t.isVoid?"/>":">"),t.isVoid?e:e+t.children.reduce(me,"")+"</"+t.name+">";case"comment":return e+="\x3c!--"+t.comment+"--\x3e"}}function ye(e,t){let n=2;return void 0!==(null==t?void 0:t.decimalPlaces)&&(null==t?void 0:t.decimalPlaces)>=0&&(n=t.decimalPlaces),parseFloat(e.toFixed(n))}function xe(e){return e[1]!=-1*e[3]||e[4]!=e[0]||e[0]*e[4]-e[3]*e[1]!=1?null:Math.acos(e[0])}const pe="Text Element";function we(){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 ve(){return{background:"#D9D9D9"}}const be={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 Me=e=>ye(e,{decimalPlaces:4});function Pe(e,t){const{detail:n}=e,{xRatio:i,yRatio:o,maxRatio:r}=t,a=(i+o)/2,{borderWidth:l,borderRadius:s,borderDash:c,shadowOffsetX:h,shadowOffsetY:u,shadowBlur:d}=n;if("number"==typeof l)n.borderWidth=Me(l*a);else if(Array.isArray(n.borderWidth)){const e=l;n.borderWidth=[Me(e[0]*o),Me(e[1]*i),Me(e[2]*o),Me(e[3]*i)]}if("number"==typeof s)n.borderRadius=Me(s*a);else if(Array.isArray(n.borderRadius)){const e=s;n.borderRadius=[e[0]*i,e[1]*i,e[2]*o,e[3]*o]}Array.isArray(c)&&c.forEach(((e,t)=>{n.borderDash[t]=Me(e*r)})),"number"==typeof h&&(n.shadowOffsetX=Me(h*r)),"number"==typeof u&&(n.shadowOffsetX=Me(u*r)),"number"==typeof d&&(n.shadowOffsetX=Me(d*r))}function Ie(e,t){const{type:n}=e;!function(e,t){const{xRatio:n,yRatio:i}=t,{x:o,y:r,w:a,h:l}=e;e.x=Me(o*n),e.y=Me(r*i),e.w=Me(a*n),e.h=Me(l*i),Pe(e,t)}(e,t),"circle"===n||("text"===n?function(e,t){const{minRatio:n,maxRatio:i}=t,{fontSize:o,lineHeight:r}=e.detail,a=(n+i)/2;o&&o>0&&(e.detail.fontSize=Me(o*a)),r&&r>0&&(e.detail.lineHeight=Me(r*a))}(e,t):"image"===n||"svg"===n||"html"===n||"path"===n||"group"===n&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Ie(e,t)})))}function Re(e,t){const n=t.w&&t.w>0?t.w:e.w,i=t.h&&t.h>0?t.h:e.h,o=n/e.w,r=i/e.h;if(o===r&&1===o)return e;const a=Math.min(o,r),l=Math.max(o,r);e.w=n,e.h=i;const s={xRatio:o,yRatio:r,minRatio:a,maxRatio:l};return"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Ie(e,s)})),Pe(e,s),e}const $e=200,Ee=200;function Se(e,t,n){let i=!1;if(1===t.length){const o=t[0];n.splice(o,0,e),i=!0}else if(t.length>1){let o=n;for(let n=0;n<t.length;n++){const r=o[t[n]];if(n===t.length-1){const r=t[n];o.splice(r,0,e),i=!0}else{if(!(n<t.length-1&&"group"===r.type))break;o=r.detail.children}}}return i}function Ae(e,t){let n=!1;if(1===e.length){const i=e[0];t.splice(i,1),n=!0}else if(e.length>1){let i=t;for(let t=0;t<e.length;t++){const o=i[e[t]];if(t===e.length-1){const o=e[t];i.splice(o,1),n=!0}else{if(!(t<e.length-1&&"group"===o.type))break;i=o.detail.children}}}return n}function Ce(e,t){const n=[...t.from],i=[...t.to];if(0===n.length||0===i.length)return{elements:e,from:n,to:i};if(n.length<=i.length)for(let t=0;t<n.length;t++)if(i[t]!==n[t]);else if(t===n.length-1)return{elements:e,from:n,to:i};const o=Z(n,e);if(o){if(!Se(o,i,e))return{elements:e,from:n,to:i};let t=-1;for(let e=0;e<n.length&&i[e]>=0;e++)i[e]!==n[e]&&i[e]<n[e]&&e==i.length-1&&(t=e);t>=0&&(n[t]=n[t]+1),Ae(n,e)}return{elements:e,from:n,to:i}}function ke(e,t){var n;const i=Object.keys(t);for(let o=0;o<i.length;o++){const r=i[o];["x","y","w","h","angle","name"].includes(r)?e[r]=t[r]:["detail","operations"].includes(r)&&(b.json(t[r])?((null==e?void 0:e.hasOwnProperty(r))||(e[r]={}),b.json(e[r])&&(e[r]={...e[r],...t[r]})):b.array(t[r])&&((null==e?void 0:e.hasOwnProperty(r))||(e[r]=[]),b.array(e[r])&&(null==(n=null==t?void 0:t[r])||n.forEach(((t,n)=>{e[r][n]=t})),e[r]=[...e[r],...t[r]])))}return e}function ze(e,t,n){var i;const o=Z(e,n);return o&&("group"===o.type&&!0===(null==(i=o.operations)?void 0:i.deepResize)&&(t.w&&t.w>0||t.h&&t.h>0)&&Re(o,{w:t.w,h:t.h}),ke(o,t)),o}function Oe(e,t,n=void 0){const i=t.split(".").reduce(((e,t)=>Object(e)[t]),e);return void 0===i?n:i}function Le(e,t,n){const i=t.split(".");return"object"!=typeof e||i.reduce(((e,t,i,o)=>i===o.length-1?(e[t]=n,null):(t in e||(e[t]=/^[0-9]{1,}$/.test(o[i+1])?[]:{}),e[t])),e),e}return e.Context2D=k,e.EventEmitter=class{constructor(){h(this,i,void 0),u(this,i,new Map)}on(e,t){if(c(this,i).has(e)){const n=c(this,i).get(e)||[];null==n||n.push(t),c(this,i).set(e,n)}else c(this,i).set(e,[t])}off(e,t){if(c(this,i).has(e)){const n=c(this,i).get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}c(this,i).set(e,n||[])}}trigger(e,t){const n=c(this,i).get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(c(this,i).has(e)){const t=c(this,i).get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){c(this,i).clear()}},e.Store=class{constructor(e){h(this,a),h(this,o,void 0),h(this,r,void 0),u(this,r,w(e.defaultStorage)),u(this,o,d(this,a,l).call(this))}set(e,t){c(this,o)[e]=t}get(e){return c(this,o)[e]}getSnapshot(){return w(c(this,o))}clear(){u(this,o,d(this,a,l).call(this))}destroy(){u(this,o,null)}},e.calcDistance=L,e.calcElementCenter=H,e.calcElementCenterFromVertexes=N,e.calcElementListSize=function(e){var t;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<e.length;o++){const r=e[o];if(null==(t=null==r?void 0:r.operations)?void 0:t.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 e=Q(a);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],n=[e[0].y,e[1].y,e[2].y,e[3].y];a.x=Math.min(...t),a.y=Math.min(...n),a.w=Math.abs(Math.max(...t)-Math.min(...t)),a.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const e=Math.min(a.x,n.x),t=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=e,n.y=t,n.w=Math.abs(i-e),n.h=Math.abs(o-t)}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)}},e.calcElementQueueVertexesQueueInGroup=oe,e.calcElementSizeController=function(e,t){const{groupQueue:n,controllerSize:i,viewScaleInfo:o}=t,r=(i&&i>0?i:8)/o.scale,{x:a,y:l,w:s,h:c,angle:h=0}=e,u=[{uuid:m(),x:a,y:l,w:s,h:c,angle:h,type:"group",detail:{children:[]}},...n];let d=0;u.forEach((({angle:e=0})=>{d+=e}));const f=ae(e,{groupQueue:n}),g=ae({x:a-2*r,y:l-2*r,h:c+4*r,w:s+4*r,angle:h},{groupQueue:[...n]}),y=W(f[0],f[1]),x=W(f[1],f[2]),p=W(f[2],f[3]),w=W(f[3],f[0]),v=f[0],b=f[1],M=f[2],P=f[3],I=le(y,{size:r,angle:d}),R=le(x,{size:r,angle:d}),$=le(p,{size:r,angle:d}),E=le(w,{size:r,angle:d}),S=le(v,{size:r,angle:d}),A=le(b,{size:r,angle:d}),C=le(P,{size:r,angle:d}),k=le(M,{size:r,angle:d}),z=ie(S),O=ie(A),L=ie(C),T=ie(k),D=[z[1],O[0],O[3],z[2]],j=[O[3],O[2],T[1],T[0]],F=[L[1],T[0],T[3],L[2]],V=[z[3],z[2],L[1],L[0]],H=ie(I),N=ie(R),B=ie($),G=ie(E),U=W(g[0],g[1]);return{elementWrapper:f,left:{type:"left",vertexes:V,center:w},right:{type:"right",vertexes:j,center:x},top:{type:"top",vertexes:D,center:y},bottom:{type:"bottom",vertexes:F,center:p},topLeft:{type:"top-left",vertexes:z,center:v},topRight:{type:"top-right",vertexes:O,center:b},bottomLeft:{type:"bottom-left",vertexes:L,center:P},bottomRight:{type:"bottom-right",vertexes:T,center:M},leftMiddle:{type:"left-middle",vertexes:G,center:w},rightMiddle:{type:"right-middle",vertexes:N,center:x},topMiddle:{type:"top-middle",vertexes:H,center:y},bottomMiddle:{type:"bottom-middle",vertexes:B,center:p},rotate:{type:"rotate",vertexes:ie(le(U,{size:r,angle:d})),center:U}}},e.calcElementVertexesInGroup=ae,e.calcElementVertexesQueueInGroup=re,e.calcElementsContextSize=q,e.calcElementsViewInfo=function(e,t,n){const i=q(e,{viewWidth:t.width,viewHeight:t.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,t.contextWidth),i.contextHeight=Math.max(i.contextHeight,t.contextHeight)),{contextSize:i}},e.calcRadian=function(e,t,n){const i=B(e,t),o=B(e,n);return null!==o&&null!==i?i>3*Math.PI/2&&o<Math.PI/2?o+(2*Math.PI-i):o>3*Math.PI/2&&i<Math.PI/2?i+(2*Math.PI-o):o-i:0},e.calcSpeed=function(e,t){return L(e,t)/Math.abs(t.t-e.t)},e.calcViewBoxSize=function(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o}=e.detail;const{boxSizing:r=be.boxSizing,borderWidth:a}=e.detail;Array.isArray(a)&&(o=0);let{x:l,y:s,w:c,h:h}=e,u=[0,0,0,0];if("number"==typeof o){const e=o*i;u=[e,e,e,e]}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=e.x+d/2,s=e.y+d/2,c=e.w-d,h=e.h-d):"content-box"===r?(l=e.x-d/2,s=e.y-d/2,c=e.w+d,h=e.h+d):(l=e.x,s=e.y,c=e.w,h=e.h),c=Math.max(c,1),h=Math.max(h,1),u=u.map((e=>Math.min(e,c/2,h/2))),{x:l,y:s,w:c,h:h,radiusList:u}},e.calcViewCenter=function(e){let t=0,n=0;if(e){const{viewScaleInfo:i,viewSizeInfo:o}=e,{offsetLeft:r,offsetTop:a,scale:l}=i,{width:s,height:c}=o;t=0-r+s/l/2,n=0-a+c/l/2}return{x:t,y:n}},e.calcViewCenterContent=function(e,t){var n,i,o,r,a,l,s,c;let h=0,u=0,d=1,f=(null==(i=null==(n=null==e?void 0:e.elements)?void 0:n[0])?void 0:i.x)||0,g=(null==(r=null==(o=null==e?void 0:e.elements)?void 0:o[0])?void 0:r.y)||0,m=(null==(l=null==(a=null==e?void 0:e.elements)?void 0:a[0])?void 0:l.w)||0,y=(null==(c=null==(s=null==e?void 0:e.elements)?void 0:s[0])?void 0:c.h)||0;const{width:x,height:p}=t.viewSizeInfo;if(e.elements.forEach((e=>{const t={x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=Q(t);if(4===e.length){const n=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...n),t.y=Math.min(...i),t.w=Math.abs(Math.max(...n)-Math.min(...n)),t.h=Math.abs(Math.max(...i)-Math.min(...i))}}const n=Math.min(t.x,f),i=Math.min(t.y,g),o=Math.max(t.x+t.w,f+m),r=Math.max(t.y+t.h,g+y);f=n,g=i,m=Math.abs(o-n),y=Math.abs(r-i)})),m>0&&y>0){const e=ye(x/m,{decimalPlaces:4}),t=ye(p/y,{decimalPlaces:4});d=Math.min(e,t,1),h=(m*d-x)/2/d+f,u=(y*d-p)/2/d+g}return{offsetX:ye(h,{decimalPlaces:0}),offsetY:ye(u,{decimalPlaces:0}),scale:d}},e.calcViewElementSize=_,e.calcViewPointSize=ee,e.calcViewScaleInfo=function(e,t){const{scale:n,offsetX:i,offsetY:o}=e,{viewSizeInfo:r}=t,{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)}},e.calcViewVertexes=function(e,t){return[ee(e[0],t),ee(e[1],t),ee(e[2],t),ee(e[3],t)]},e.check=C,e.checkRectIntersect=K,e.colorNameToHex=function(e){const t=e.toLowerCase(),n=g[t];return"string"==typeof n?n:null},e.colorToCSS=function(e){let t="transparent";if("string"==typeof e)t=e;else if("linear-gradient"===(null==e?void 0:e.type)){const n=[];"number"==typeof e.angle?n.push(`${e.angle}deg`):n.push("180deg"),Array.isArray(e.stops)&&e.stops.forEach((e=>{n.push(`${e.color} ${100*e.offset}%`)})),t=`linear-gradient(${n.join(", ")})`}else if("radial-gradient"===(null==e?void 0:e.type)){const n=[];Array.isArray(e.stops)&&e.stops.forEach((e=>{n.push(`${e.color} ${100*e.offset}%`)})),t=`radial-gradient(circle, ${n.join(", ")})`}return t},e.colorToLinearGradientCSS=function(e){let t="transparent";if("string"==typeof e)t=e;else if("radial-gradient"===(null==e?void 0:e.type)||"linear-gradient"===(null==e?void 0:e.type)){const n=[];Array.isArray(e.stops)&&e.stops.length>0&&(e.stops.forEach(((t,i)=>{n.push(`${t.color} ${100*t.offset}%`),i===e.stops.length-1&&t.offset<1&&n.push(`${t.color} ${100*t.offset}%`)})),t=`linear-gradient(90deg, ${n.join(", ")})`)}return t},e.compose=function(e){return function(t,n){return function i(o){let r=e[o];o===e.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(t,i.bind(null,o+1)))}catch(e){return Promise.reject(e)}}(0)}},e.compressImage=function(e,t){let n=.5;const i=(null==t?void 0:t.type)||"image/png";return(null==t?void 0:t.radio)&&(null==t?void 0:t.radio)>0&&(null==t?void 0:t.radio)<=1&&(n=null==t?void 0:t.radio),new Promise(((t,o)=>{const r=new Image;r.addEventListener("load",(()=>{const{width:e,height:o}=r,a=e*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,t(c)})),r.addEventListener("error",(e=>{o(e)})),r.src=e}))},e.createAssetId=x,e.createBoardContent=function(e,t){const{width:n,height:i,devicePixelRatio:o,offscreen:r,createCustomContext2D:a}=t,l={width:n,height:i,devicePixelRatio:o},s=e.getContext("2d");if(a){const e=a(l),t=a(l),n=a(l),i=z({ctx:s,...l}),o=()=>{const{width:o,height:r}=e.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),n.clearRect(0,0,o,r),e.clearRect(0,0,o,r),t.clearRect(0,0,o,r)};return{underContext:n,viewContext:e,helperContext:t,boardContext:i,drawView:o}}if(!0===r){const e=O(l),t=O(l),n=O(l),i=z({ctx:s,...l}),o=()=>{const{width:o,height:r}=e.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),n.clearRect(0,0,o,r),e.clearRect(0,0,o,r),t.clearRect(0,0,o,r)};return{underContext:n,viewContext:e,helperContext:t,boardContext:i,drawView:o}}{const e=z(l),t=z(l),o=z(l),r=z({ctx:s,...l}),a=()=>{r.clearRect(0,0,n,i),r.drawImage(o.canvas,0,0,n,i),r.drawImage(e.canvas,0,0,n,i),r.drawImage(t.canvas,0,0,n,i),o.clearRect(0,0,n,i),e.clearRect(0,0,n,i),t.clearRect(0,0,n,i)};return{underContext:o,viewContext:e,helperContext:t,boardContext:r,drawView:a}}},e.createContext2D=z,e.createElement=function(e,t,n){const i=function(e,t){let n=0,i=0,o=$e,r=Ee;if(t){const{viewScaleInfo:a,viewSizeInfo:l}=t,{scale:s,offsetLeft:c,offsetTop:h}=a,{width:u,height:d}=l,f=u/4,g=d/4;o=$e>=f?f/s:$e/s,r=Ee>=g?g/s:Ee/s,["circle","svg","image"].includes(e)?o=r=Math.max(o,r):"text"===e&&(r=o/pe.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}}(e,n);let o={};return"rect"===e?o={background:"#D9D9D9"}:"circle"===e?o={background:"#D9D9D9",radius:0}:"text"===e?o=function(e){const t={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};return{text:pe,color:t.color,fontFamily:t.fontFamily,fontWeight:t.fontWeight,lineHeight:e.w/pe.length,fontSize:e.w/pe.length,textAlign:"center",verticalAlign:"middle"}}(i):"svg"===e?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"===e?o={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===e&&(o={children:[],background:"#D9D9D9",overflow:"hidden"}),{...i,...t,uuid:m(),type:e,detail:{...o,...t.detail||{}}}},e.createOffscreenContext2D=O,e.createUUID=m,e.debounce=function(e,t){let n=-1;return function(...i){n>=0&&window.clearTimeout(n),n=setTimeout((()=>{e(...i),n=-1}),t)}},e.deepClone=w,e.deepCloneElement=function(e){const t=w(e),n=e=>{e.uuid=m(),"group"===e.type&&e.detail.children&&e.detail.children.forEach((e=>{n(e)}))};return n(t),t},e.deepResizeGroupElement=Re,e.delay=function(e){return new Promise((t=>{setTimeout((()=>{t()}),e)}))},e.deleteElementInList=function(e,t){return Ae(J(e,t),t)},e.deleteElementInListByPosition=Ae,e.downloadFileFromText=function(e,t){const{fileName:n}=t,i=function(e){const t=(new TextEncoder).encode(e),n=new Blob([t],{type:"text/plain;charset=utf-8"});return window.URL.createObjectURL(n)}(e);let o=document.createElement("a");o.href=i,o.download=n,o.click(),o=null},e.downloadImageFromCanvas=function(e,t){const{fileName:n,type:i="image/jpeg"}=t,o=e.toDataURL(i);let r=document.createElement("a");r.href=o,r.download=n,r.click(),r=null},e.equalPoint=T,e.equalTouchPoint=function(e,t){return!0===T(e,t)&&e.f===t.f},e.filterCompactData=function(e,t){const n=e.assets||{},i=w(e),o=(null==t?void 0:t.loadItemMap)||{},r=e=>{e.forEach((e=>{var t,i,a;if("image"===e.type&&e.detail.src){const i=e.detail.src;if(p(i)&&!n[i]&&o[i]&&"string"==typeof(null==(t=o[i])?void 0:t.source))n[i]={type:"image",value:o[i].source};else if(!n[i]){const t=x(i);n[t]||(n[t]={type:"image",value:i}),e.detail.src=t}}else if("svg"===e.type){const t=e.detail.svg;if(p(t)&&!n[t]&&o[t]&&"string"==typeof(null==(i=o[t])?void 0:i.source))n[t]={type:"svg",value:o[t].source};else if(!n[t]){const i=x(t);n[i]||(n[i]={type:"svg",value:t}),e.detail.svg=i}}else if("html"===e.type){const t=e.detail.html;if(p(t)&&!n[t]&&o[t]&&"string"==typeof(null==(a=o[t])?void 0:a.source))n[t]={type:"html",value:o[t].source};else if(!n[t]){const i=x(t);n[i]||(n[i]={type:"html",value:t}),e.detail.html=i}}else if("group"===e.type&&Array.isArray(e.detail.children)){const t=e.detail.assets||{};Object.keys(t).forEach((e=>{n[e]||(n[e]=t[e])})),delete e.detail.assets,r(e.detail.children)}}))};return r(i.elements),i.assets=n,i},e.filterElementAsset=function(e){let t=null,n=null,i=null;return"image"===e.type?i=e.detail.src:"svg"===e.type?i=e.detail.svg:"html"===e.type&&(i=e.detail.html),"string"!=typeof i||p(i)||(t=x(i),n={type:e.type,value:i},"image"===e.type?e.detail.src=t:"svg"===e.type?e.detail.svg=t:"html"===e.type&&(e.detail.html=t)),{element:e,assetId:t,assetItem:n}},e.findElementFromList=function e(t,n){var i;let o=null;for(let r=0;r<n.length;r++){const a=n[r];if(a.uuid===t){o=a;break}if(!o&&"group"===a.type){const n=e(t,(null==(i=null==a?void 0:a.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===t){o=n;break}}}return o},e.findElementFromListByPosition=Z,e.findElementQueueFromListByPosition=function(e,t){const n=[];let i=t;for(let t=0;t<e.length;t++){const o=i[e[t]];if(!o)break;if(n.push(o),!(t<e.length-1&&"group"===o.type))break;i=o.detail.children}return n},e.findElementsFromList=function(e,t){const n=[];return function t(i){var o;for(let r=0;r<i.length;r++){const a=i[r];e.includes(a.uuid)?n.push(a):"group"===a.type&&t((null==(o=null==a?void 0:a.detail)?void 0:o.children)||[])}}(t),n},e.findElementsFromListByPositions=function(e,t){const n=[];return e.forEach((e=>{const i=Z(e,t);i&&n.push(i)})),n},e.formatNumber=ye,e.generateHTML=function(e){return e.reduce((function(e,t){return e+me("",t)}),"")},e.generateSVGPath=function(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t},e.getCenterFromTwoPoints=W,e.getDefaultElementDetailConfig=we,e.getDefaultElementRectDetail=ve,e.getElemenetsAssetIds=function(e){const t=[],n=e=>{e.forEach((e=>{"image"===e.type&&p(e.detail.src)?t.push(e.detail.src):"svg"===e.type&&p(e.detail.svg)?t.push(e.detail.svg):"html"===e.type&&e.detail.html?t.push(e.detail.html):"group"===e.type&&Array.isArray(e.detail.children)&&n(e.detail.children)}))};return n(e),t},e.getElementPositionFromList=J,e.getElementRotateVertexes=U,e.getElementSize=function(e){const{x:t,y:n,w:i,h:o,angle:r}=e;return{x:t,y:n,w:i,h:o,angle:r}},e.getElementVertexes=ne,e.getGroupQueueFromList=function(e,t){const n=[];return function e(t,i){var o;let r=null;for(let a=0;a<i.length;a++){const l=i[a];if(l.uuid===t){r=l;break}if(!r&&"group"===l.type){n.push(l);const i=e(t,(null==(o=null==l?void 0:l.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===t){r=i;break}n.pop()}}return r}(e,t),n},e.getModifiedElement=function(e,t){const n={},i=[],o=e=>{if(b.json(e)){Object.keys(e).forEach((r=>{if(i.push(r),b.json(e[r])||b.array(e[r]))o(e[r]);else{const e=i.join(".");if("uuid"!==e){const o=Oe(t,e);Le(n,i.join("."),o)}}i.pop()}))}else b.array(e)&&e.forEach((r=>{if(i.push(r),b.json(e[r])||b.array(e[r]))o(e[r]);else{const e=Oe(t,i.join("."));Le(n,i.join("."),e)}i.pop()}))};return o(e),n},e.getSelectedElementUUIDs=function(e,t){var n;let i=[];return Array.isArray(null==e?void 0:e.elements)&&(null==(n=null==e?void 0:e.elements)?void 0:n.length)>0&&Array.isArray(t)&&t.length>0&&t.forEach((t=>{var n;"number"==typeof t?(null==(n=null==e?void 0:e.elements)?void 0:n[t])&&i.push(e.elements[t].uuid):"string"==typeof t&&(i=i.concat(function(e,t){var n;const i=[];if("string"==typeof t&&/^\d+(\.\d+)*$/.test(t)){const o=t.split(".");let r=e;for(;o.length>0;){const e=o.shift();if("string"==typeof e){const t=r[parseInt(e)];t&&0===o.length?i.push(t.uuid):"group"===t.type&&o.length>0&&(r=(null==(n=null==t?void 0:t.detail)?void 0:n.children)||[])}break}}return i}(e.elements,t)))})),i},e.getViewPointAtElement=function(e,t){var n,i,o;const{context2d:r,data:a,viewScaleInfo:l,viewSizeInfo:s,groupQueue:c}=t,h={index:-1,element:null,groupQueueIndex:-1};if(c&&Array.isArray(c)&&(null==c?void 0:c.length)>0)for(let t=c.length-1;t>=0;t--){let o=0,a=0,u=0;for(let e=0;e<=t;e++)o+=c[e].x,a+=c[e].y,u+=c[e].angle||0;const d=c[t];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(te(e,{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,(t<c.length-1||"group"!==f.type)&&(h.groupQueueIndex=t);break}}}if(h.element)break}if(h.element)return h;for(let t=a.elements.length-1;t>=0;t--){const n=a.elements[t];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&te(e,{context2d:r,element:n,viewScaleInfo:l,viewSizeInfo:s})){h.index=t,h.element=n;break}}return h},e.getViewScaleInfoFromSnapshot=function(e){const{activeStore:t}=e;return{scale:null==t?void 0:t.scale,offsetTop:null==t?void 0:t.offsetTop,offsetBottom:null==t?void 0:t.offsetBottom,offsetLeft:null==t?void 0:t.offsetLeft,offsetRight:null==t?void 0:t.offsetRight}},e.getViewSizeInfoFromSnapshot=function(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:null==t?void 0:t.width,height:null==t?void 0:t.height,contextWidth:null==t?void 0:t.contextWidth,contextHeight:null==t?void 0:t.contextHeight}},e.insertElementToListByPosition=Se,e.is=S,e.isAssetId=p,e.isColorStr=f,e.isElementInView=function(e,t){const{viewSizeInfo:n,viewScaleInfo:i}=t,{width:o,height:r}=n,{angle:a}=e,{x:l,y:s,w:c,h:h}=_(e,{viewScaleInfo:i,viewSizeInfo:n}),u=Q({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 K(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})},e.isResourceElement=function(e){return["image","svg","html"].includes(null==e?void 0:e.type)},e.isViewPointInElement=te,e.istype=b,e.limitAngle=X,e.loadHTML=async function(e,t){e=e.replace(/\&/gi,"&");const n=await function(e,t){const{width:n,height:i}=t;return new Promise(((t,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 ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(e){var n;const i=null==(n=null==e?void 0:e.target)?void 0:n.result;t(i)},a.onerror=function(e){o(e)}}))}(e,t);return await P(n)},e.loadImage=P,e.loadSVG=async function(e){const t=await function(e){return new Promise(((t,n)=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(e){var n;const i=null==(n=null==e?void 0:e.target)?void 0:n.result;t(i)},o.onerror=function(e){n(e)}}))}(e);return await P(t)},e.matrixToAngle=function(e){const t=xe(e);if("number"==typeof t){return 180*t/Math.PI}return t},e.matrixToRadian=xe,e.mergeElementAsset=function(e,t){const n=e;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=t[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},e.mergeHexColorAlpha=function(e,t){if(1===t)return e;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=e;if(i.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),o=e.substring(0,7)),n*=t,i.test(o)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${e.toString(16).toUpperCase()}`}return o},e.modifyElement=function(e,t){const{type:n}=t,i={...t.content};if("addElement"===n){const n=t,{element:i,position:o}=n.content;(null==o?void 0:o.length)>0?Se(i,[...o],e.elements):e.elements.push(i)}else if("deleteElement"===n){const n=t,{position:i}=n.content;Ae(i,e.elements)}else if("moveElement"===n){const n=t,{from:o,to:r}=n.content,a=Ce(e.elements,{from:o,to:r});i.from=a.from,i.to=a.to,e.elements=a.elements}else if("updateElement"===n){const n=t,{position:i,afterModifiedElement:o}=n.content;ze(i,o,e.elements)}return{data:e,content:i}},e.moveElementPosition=Ce,e.parseAngleToRadian=F,e.parseFileToBase64=function(e){return new Promise((function(t,n){let i=new FileReader;i.addEventListener("load",(function(){t(i.result),i=null})),i.addEventListener("error",(function(e){n(e),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsDataURL(e)}))},e.parseFileToText=function(e){return new Promise((function(t,n){let i=new FileReader;i.addEventListener("load",(function(){t(i.result),i=null})),i.addEventListener("error",(function(e){n(e),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsText(e)}))},e.parseHTML=function(e){const t=[],n=[];let i,o=-1;return e.replace(ue,((r,a)=>{const l="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=a+r.length,h=e.charAt(c);let u;if(s){const e=ge(r);return o<0?(t.push(e),r):(u=n[o],u.children.push(e),r)}if(l){if(o++,i=ge(r),!i.isVoid&&h&&"<"!==h){const t=e.slice(c,e.indexOf("<",c));t.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:t.trim()})}0===o&&t.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?t:n[o]),"<"!==h&&h)){u=-1===o?t:n[o].children;const i=e.indexOf("<",c);let r=e.slice(c,-1===i?void 0:i);de.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})),t},e.parseRadianToAngle=function(e){return e/Math.PI*180},e.parseSVGPath=function(e){const t=[];return e.replace(se,((e,n,i)=>{const o=i.match(ce),r={type:n,params:o?o.map(Number):[]};return t.push(r),e})),t},e.pickFile=function(e){const{accept:t,success:n,error:i}=e;let o=document.createElement("input");o.type="file",t&&(o.accept=t),o.addEventListener("change",(function(){var e;const t=null==(e=o.files)?void 0:e[0];n({file:t}),o=null})),o.addEventListener("error",(function(e){"function"==typeof i&&i(e),o=null})),o.click()},e.rotateByCenter=V,e.rotateElement=function(e,t,n){const i=H(t);V(e,t.angle||0,i,(()=>{n(e)}))},e.rotateElementVertexes=Q,e.rotatePoint=G,e.rotatePointInGroup=function(e,t){if((null==t?void 0:t.length)>0){let n=e.x,i=e.y;return t.forEach((e=>{const{x:t,y:o,w:r,h:a,angle:l=0}=e,s=G(H({x:t,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 e},e.rotateVertexes=Y,e.sortDataAsserts=function(e,t){const n=e.assets||{};let i=e;!0===(null==t?void 0:t.clone)&&(i=w(e));const o=e=>{e.forEach((e=>{if("image"===e.type&&e.detail.src){const t=e.detail.src,i=x(t);n[i]||(n[i]={type:"image",value:t}),e.detail.src=i}else if("svg"===e.type){const t=e.detail.svg,i=x(t);n[i]||(n[i]={type:"svg",value:t}),e.detail.svg=i}else if("html"===e.type){const t=e.detail.html,i=x(t);n[i]||(n[i]={type:"html",value:t}),e.detail.html=i}else if("group"===e.type&&Array.isArray(e.detail.children)){const t=e.detail.assets||{};Object.keys(t).forEach((e=>{n[e]||(n[e]=t[e])})),delete e.detail.assets,o(e.detail.children)}}))};return o(i.elements),i.assets=n,i},e.throttle=function(e,t){let n=-1;return function(...i){n>=0||(n=setTimeout((()=>{e(...i),n=-1}),t))}},e.toColorHexNum=function(e){return parseInt(e.replace(/^\#/,"0x"))},e.toColorHexStr=function(e){return"#"+e.toString(16)},e.updateElementInList=function e(t,n,i){var o,r;let a=null;for(let l=0;l<i.length;l++){const s=i[l];if(s.uuid===t){"group"===s.type&&!0===(null==(o=s.operations)?void 0:o.deepResize)&&(n.w&&n.w>0||n.h&&n.h>0)&&Re(s,{w:n.w,h:n.h}),ke(s,n),a=s;break}"group"===s.type&&(a=e(t,n,(null==(r=null==s?void 0:s.detail)?void 0:r.children)||[]))}return a},e.updateElementInListByPosition=ze,e.vaildPoint=j,e.vaildTouchPoint=function(e){return!0===j(e)&&e.f>=0},e.validateElements=function e(t){let n=!0;if(Array.isArray(t)){const i=[];t.forEach((t=>{var o;"string"==typeof t.uuid&&t.uuid?i.includes(t.uuid)?(n=!1,console.warn(`Duplicate uuids: ${t.uuid}`)):i.push(t.uuid):(n=!1,console.warn("Element missing uuid",t)),"group"===t.type&&(n=e(null==(o=null==t?void 0:t.detail)?void 0:o.children))}))}return n},e.viewScale=function(e){const{scale:t,point:n,viewScaleInfo:i}=e,{offsetLeft:o,offsetTop:r}=i,a=t/i.scale,l=n.x,s=n.y;return{moveX:l-l*a+(o*a-o),moveY:s-s*a+(r*a-r)}},e.viewScroll=function(e){const{moveX:t=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=e,{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+=t,d+=n,u=a-(s*r+h),f=l-(c*r+d),{scale:r,offsetTop:d,offsetLeft:h,offsetRight:u,offsetBottom:f}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|