@leafer/worker 1.9.7 → 1.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- const t={toURL(t,e){let i=encodeURIComponent(t);return"text"===e?i="data:text/plain;charset=utf-8,"+i:"svg"===e&&(i="data:image/svg+xml,"+i),i},image:{hitCanvasSize:100,maxCacheSize:4096e3,maxPatternSize:8847360,crossOrigin:"anonymous",getRealURL(e){const{prefix:i,suffix:s}=t.image;return!s||e.startsWith("data:")||e.startsWith("blob:")||(e+=(e.includes("?")?"&":"?")+s),i&&"/"===e[0]&&(e=i+e),e}}},e={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=i;return e[t]?e[t]++:(e[t]=1,0)}},i=e;var s;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(s||(s={}));const n={};function o(t){return void 0===t}function r(t){return null==t}function a(t){return"string"==typeof t}const{isFinite:h}=Number;function l(t){return"number"==typeof t}const d=/^-?\d+(?:\.\d+)?$/;function c(t){return"string"==typeof t&&d.test(t)?+t:t}const{isArray:u}=Array;function _(t){return t&&"object"==typeof t}function p(t){return _(t)&&!u(t)}function g(t){return"{}"===JSON.stringify(t)}const f={default:(t,e)=>(m(e,t),m(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach(n=>{var o,r;if(s=e[n],(null==s?void 0:s.constructor)===Object&&(null===(o=t[n])||void 0===o?void 0:o.constructor)===Object)return m(t[n],e[n],i&&i[n]);i&&n in i?(null===(r=i[n])||void 0===r?void 0:r.constructor)===Object&&m(t[n]={},e[n],i[n]):t[n]=e[n]})},copyAttrs:(t,e,i)=>(i.forEach(i=>{o(e[i])||(t[i]=e[i])}),t),clone:t=>JSON.parse(JSON.stringify(t)),toMap(t){const e={};for(let i=0,s=t.length;i<s;i++)e[t[i]]=!0;return e},stintSet(t,e,i){i||(i=void 0),t[e]!==i&&(t[e]=i)}},{assign:m}=f;class y{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __usePathBox(){return this.__pathInputed}get __blendMode(){if(this.eraser&&"path"!==this.eraser)return"destination-out";const{blendMode:t}=this;return"pass-through"===t?null:t}constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(!o(e))return e}return this[t]}__getData(){const t={tag:this.__leaf.tag},{__input:e}=this;let i;for(let s in this)"_"!==s[0]&&(i=e?e[s]:void 0,t[s]=o(i)?this[s]:i);return t}__setInput(t,e){this.__input||(this.__input={}),this.__input[t]=e}__getInput(t){if(this.__input){const e=this.__input[t];if(!o(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!o(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(u(t))for(let e of t)i[e]=this.__getInput(e);else for(let e in t)i[e]=this.__getInput(e);else{let t,e,{__input:s}=this;i.tag=this.__leaf.tag;for(let n in this)if("_"!==n[0]&&(t=this["_"+n],!o(t))){if("path"===n&&!this.__pathInputed)continue;e=s?s[n]:void 0,i[n]=o(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:n,e:o,f:r}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:n,e:o,f:r}}return i}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){const t=this;if("pass-through"===t.blendMode){const e=this.__leaf;t.opacity<1&&(e.isBranch||t.__hasMultiPaint)||e.__hasEraser||t.eraser||t.filter?t.__single=!0:t.__single&&(t.__single=!1)}else t.__single=!0}__removeNaturalSize(){this.__naturalWidth=this.__naturalHeight=void 0}destroy(){this.__input=this.__middle=null}}const{round:v,pow:w,PI:x}=Math,b={within:(t,e,i)=>(_(e)&&(i=e.max,e=e.min),!o(e)&&t<e&&(t=e),!o(i)&&t>i&&(t=i),t),fourNumber(t,e){let i;if(u(t))switch(t.length){case 4:i=o(e)?t:[...t];break;case 2:i=[t[0],t[1],t[0],t[1]];break;case 3:i=[t[0],t[1],t[2],t[1]];break;case 1:t=t[0];break;default:t=0}if(i||(i=[t,t,t,t]),e)for(let t=0;t<4;t++)i[t]>e&&(i[t]=e);return i},formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),b.float(t)),getGapRotation(t,e,i=0){let s=t+i;if(e>1){const t=Math.abs(s%e);(t<1||t>e-1)&&(s=Math.round(s/e)*e)}return s-i},float(t,e){const i=o(e)?1e12:w(10,e);return-0===(t=v(t*i)/i)?0:t},sign:t=>t<0?-1:1,getScaleData(t,e,i,s){if(s||(s={}),e){const t=(l(e)?e:e.width||0)/i.width,n=(l(e)?e:e.height||0)/i.height;s.scaleX=t||n||1,s.scaleY=n||t||1}else t&&b.assignScale(s,t);return s},assignScale(t,e){l(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},randInt:k,randColor:t=>`rgba(${k(255)},${k(255)},${k(255)},${t||1})`};function k(t){return Math.round(Math.random()*t)}const E=x/180,S=2*x,B=x/2;function T(){return{x:0,y:0}}function R(){return{x:0,y:0,width:0,height:0}}function C(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:O,cos:L,acos:P,sqrt:A}=Math,{float:M}=b,D={};function F(){return Object.assign(Object.assign(Object.assign({},{a:1,b:0,c:0,d:1,e:0,f:0}),{x:0,y:0,width:0,height:0}),{scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0})}const I={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:F(),tempMatrix:{},set(t,e=1,i=0,s=0,n=1,o=0,r=0){t.a=e,t.b=i,t.c=s,t.d=n,t.e=o,t.f=r},get:C,getWorld:F,copy(t,e){t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f},translate(t,e,i){t.e+=e,t.f+=i},translateInner(t,e,i,s){t.e+=t.a*e+t.c*i,t.f+=t.b*e+t.d*i,s&&(t.e-=e,t.f-=i)},scale(t,e,i=e){t.a*=e,t.b*=e,t.c*=i,t.d*=i},pixelScale(t,e,i){i||(i=t),i.a=t.a*e,i.b=t.b*e,i.c=t.c*e,i.d=t.d*e,i.e=t.e*e,i.f=t.f*e},scaleOfOuter(t,e,i,s){W.toInnerPoint(t,e,D),W.scaleOfInner(t,D,i,s)},scaleOfInner(t,e,i,s=i){W.translateInner(t,e.x,e.y),W.scale(t,i,s),W.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:o}=t,r=L(e*=E),a=O(e);t.a=i*r-s*a,t.b=i*a+s*r,t.c=n*r-o*a,t.d=n*a+o*r},rotateOfOuter(t,e,i){W.toInnerPoint(t,e,D),W.rotateOfInner(t,D,i)},rotateOfInner(t,e,i){W.translateInner(t,e.x,e.y),W.rotate(t,i),W.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:o,d:r}=t;i&&(i*=E,t.a=s+o*i,t.b=n+r*i),e&&(e*=E,t.c=o+s*e,t.d=r+n*e)},skewOfOuter(t,e,i,s){W.toInnerPoint(t,e,D),W.skewOfInner(t,D,i,s)},skewOfInner(t,e,i,s=0){W.translateInner(t,e.x,e.y),W.skew(t,i,s),W.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:n,d:o,e:r,f:a}=t;t.a=e.a*i+e.b*n,t.b=e.a*s+e.b*o,t.c=e.c*i+e.d*n,t.d=e.c*s+e.d*o,t.e=e.e*i+e.f*n+r,t.f=e.e*s+e.f*o+a},multiplyParent(t,e,i,s,n){const{e:r,f:a}=t;if(i||(i=t),o(s)&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:o,c:r,d:a}=t;i.a=s*e.a+o*e.c,i.b=s*e.b+o*e.d,i.c=r*e.a+a*e.c,i.d=r*e.b+a*e.d,n&&(i.scaleX=e.scaleX*n.scaleX,i.scaleY=e.scaleY*n.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,n&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=r*e.a+a*e.c+e.e,i.f=r*e.b+a*e.d+e.f},divide(t,e){W.multiply(t,W.tempInvert(e))},divideParent(t,e){W.multiplyParent(t,W.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=W;return W.copy(e,t),W.invert(e),e},invert(t){const{a:e,b:i,c:s,d:n,e:o,f:r}=t;if(i||s){const a=1/(e*n-i*s);t.a=n*a,t.b=-i*a,t.c=-s*a,t.d=e*a,t.e=-(o*n-r*s)*a,t.f=-(r*e-o*i)*a}else if(1===e&&1===n)t.e=-o,t.f=-r;else{const i=1/(e*n);t.a=n*i,t.d=e*i,t.e=-o*n*i,t.f=-r*e*i}},toOuterPoint(t,e,i,s){const{x:n,y:o}=e;i||(i=e),i.x=n*t.a+o*t.c,i.y=n*t.b+o*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:n,b:o,c:r,d:a}=t,h=1/(n*a-o*r),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*r)*h,i.y=(d*n-l*o)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*r)*h,i.y-=(s*n-e*o)*h}},setLayout(t,e,i,s,n){const{x:r,y:a,scaleX:h,scaleY:l}=e;if(o(n)&&(n=e.rotation||e.skewX||e.skewY),n){const{rotation:i,skewX:s,skewY:n}=e,o=i*E,r=L(o),a=O(o);if(s||n){const e=s*E,i=n*E;t.a=(r+i*-a)*h,t.b=(a+i*r)*h,t.c=(e*r-a)*l,t.d=(r+e*a)*l}else t.a=r*h,t.b=a*h,t.c=-a*l,t.d=r*l}else t.a=h,t.b=0,t.c=0,t.d=l;t.e=r,t.f=a,(i=i||s)&&W.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:n,b:o,c:r,d:a,e:h,f:l}=t;let d,c,u,_,p,g=h,f=l;if(o||r){const t=n*a-o*r;if(r&&!s){d=A(n*n+o*o),c=t/d;const e=n/d;u=o>0?P(e):-P(e)}else{c=A(r*r+a*a),d=t/c;const e=r/c;u=B-(a>0?P(-e):-P(e))}const e=M(L(u)),i=O(u);d=M(d),c=M(c),_=e?M((r/c+i)/e/E,9):0,p=e?M((o/d-i)/e/E,9):0,u=M(u/E)}else d=n,c=a,u=_=p=0;return(e=i||e)&&(g+=e.x*n+e.y*r,f+=e.x*o+e.y*a,i||(g-=e.x,f-=e.y)),{x:g,y:f,scaleX:d,scaleY:c,rotation:u,skewX:_,skewY:p}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:n,c:o,d:r}=t;n||o?i=(s*r-n*o)/(e=A(s*s+n*n)):(e=s,i=r)}return s.scaleX=e,s.scaleY=i,s},reset(t){W.set(t)}},W=I,{toInnerPoint:z,toOuterPoint:N}=I,{sin:Y,cos:H,abs:X,sqrt:V,atan2:j,min:U,round:G}=Math,K={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,i=0){t.x=e,t.y=i},setRadius(t,e,i){t.radiusX=e,t.radiusY=o(i)?e:i},copy(t,e){t.x=e.x,t.y=e.y},copyFrom(t,e,i){t.x=e,t.y=i},round(t,e){t.x=e?G(t.x-.5)+.5:G(t.x),t.y=e?G(t.y-.5)+.5:G(t.y)},move(t,e,i){_(e)?(t.x+=e.x,t.y+=e.y):(t.x+=e,t.y+=i)},scale(t,e,i=e){t.x&&(t.x*=e),t.y&&(t.y*=i)},scaleOf(t,e,i,s=i){t.x+=(t.x-e.x)*(i-1),t.y+=(t.y-e.y)*(s-1)},rotate(t,e,i){i||(i=q.defaultPoint);const s=H(e*=E),n=Y(e),o=t.x-i.x,r=t.y-i.y;t.x=i.x+o*s-r*n,t.y=i.y+o*n+r*s},tempToInnerOf(t,e){const{tempPoint:i}=q;return J(i,t),z(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=q;return J(i,t),N(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=q;return J(i,t),q.toInnerRadiusPointOf(t,e,i),i},toInnerRadiusPointOf(t,e,i){i||(i=t),z(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){z(e,t,i)},toOuterOf(t,e,i){N(e,t,i)},getCenter:(t,e)=>({x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}),getCenterX:(t,e)=>t+(e-t)/2,getCenterY:(t,e)=>t+(e-t)/2,getDistance:(t,e)=>Z(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=X(i-t),o=X(s-e);return V(n*n+o*o)},getMinDistanceFrom:(t,e,i,s,n,o)=>U(Z(t,e,i,s),Z(i,s,n,o)),getAngle:(t,e)=>$(t,e)/E,getRotation:(t,e,i,s)=>(s||(s=e),q.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/E),getRadianFrom(t,e,i,s,n,r,a,h){o(a)&&(a=i,h=s);const l=t-i,d=e-s,c=n-a,u=r-h;return Math.atan2(l*u-d*c,l*c+d*u)},getAtan2:(t,e)=>j(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s){const n=$(t,e);return(e=s?e:{}).x=t.x+H(n)*i,e.y=t.y+Y(n)*i,e},toNumberPoints(t){let e=t;return _(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},reset(t){q.reset(t)}},q=K,{getDistanceFrom:Z,copy:J,getAtan2:$}=q;class Q{constructor(t,e){this.set(t,e)}set(t,e){return _(t)?K.copy(this,t):K.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new Q(this)}move(t,e){return K.move(this,t,e),this}scale(t,e){return K.scale(this,t,e),this}scaleOf(t,e,i){return K.scaleOf(this,t,e,i),this}rotate(t,e){return K.rotate(this,t,e),this}rotateOf(t,e){return K.rotate(this,e,t),this}getRotation(t,e,i){return K.getRotation(this,t,e,i)}toInnerOf(t,e){return K.toInnerOf(this,t,e),this}toOuterOf(t,e){return K.toOuterOf(this,t,e),this}getCenter(t){return new Q(K.getCenter(this,t))}getDistance(t){return K.getDistance(this,t)}getDistancePoint(t,e,i){return new Q(K.getDistancePoint(this,t,e,i))}getAngle(t){return K.getAngle(this,t)}getAtan2(t){return K.getAtan2(this,t)}reset(){return K.reset(this),this}}const tt=new Q;class et{constructor(t,e,i,s,n,o){this.set(t,e,i,s,n,o)}set(t,e,i,s,n,o){return _(t)?I.copy(this,t):I.set(this,t,e,i,s,n,o),this}setWith(t){return I.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:i,d:s,e:n,f:o}=this;return{a:t,b:e,c:i,d:s,e:n,f:o}}clone(){return new et(this)}translate(t,e){return I.translate(this,t,e),this}translateInner(t,e){return I.translateInner(this,t,e),this}scale(t,e){return I.scale(this,t,e),this}scaleWith(t,e){return I.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}pixelScale(t){return I.pixelScale(this,t),this}scaleOfOuter(t,e,i){return I.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return I.scaleOfInner(this,t,e,i),this}rotate(t){return I.rotate(this,t),this}rotateOfOuter(t,e){return I.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return I.rotateOfInner(this,t,e),this}skew(t,e){return I.skew(this,t,e),this}skewOfOuter(t,e,i){return I.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return I.skewOfInner(this,t,e,i),this}multiply(t){return I.multiply(this,t),this}multiplyParent(t){return I.multiplyParent(this,t),this}divide(t){return I.divide(this,t),this}divideParent(t){return I.divideParent(this,t),this}invert(){return I.invert(this),this}invertWith(){return I.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){I.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){I.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return I.setLayout(this,t,e,i),this}getLayout(t,e,i){return I.getLayout(this,t,e,i)}withScale(t,e){return I.withScale(this,t,e)}reset(){I.reset(this)}}const it=new et,st={tempPointBounds:{},setPoint(t,e,i){t.minX=t.maxX=e,t.minY=t.maxY=i},addPoint(t,e,i){t.minX=e<t.minX?e:t.minX,t.minY=i<t.minY?i:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=i>t.maxY?i:t.maxY},addBounds(t,e,i,s,n){nt(t,e,i),nt(t,e+s,i+n)},copy(t,e){t.minX=e.minX,t.minY=e.minY,t.maxX=e.maxX,t.maxY=e.maxY},addPointBounds(t,e){t.minX=e.minX<t.minX?e.minX:t.minX,t.minY=e.minY<t.minY?e.minY:t.minY,t.maxX=e.maxX>t.maxX?e.maxX:t.maxX,t.maxY=e.maxY>t.maxY?e.maxY:t.maxY},toBounds(t,e){e.x=t.minX,e.y=t.minY,e.width=t.maxX-t.minX,e.height=t.maxY-t.minY}},{addPoint:nt}=st;var ot,rt;!function(t){t[t.top=0]="top",t[t.right=1]="right",t[t.bottom=2]="bottom",t[t.left=3]="left"}(ot||(ot={})),function(t){t[t.topLeft=0]="topLeft",t[t.top=1]="top",t[t.topRight=2]="topRight",t[t.right=3]="right",t[t.bottomRight=4]="bottomRight",t[t.bottom=5]="bottom",t[t.bottomLeft=6]="bottomLeft",t[t.left=7]="left",t[t.center=8]="center",t[t["top-left"]=0]="top-left",t[t["top-right"]=2]="top-right",t[t["bottom-right"]=4]="bottom-right",t[t["bottom-left"]=6]="bottom-left"}(rt||(rt={}));const at=[{x:0,y:0},{x:.5,y:0},{x:1,y:0},{x:1,y:.5},{x:1,y:1},{x:.5,y:1},{x:0,y:1},{x:0,y:.5},{x:.5,y:.5}];at.forEach(t=>t.type="percent");const ht={directionData:at,tempPoint:{},get:lt,toPoint(t,e,i,s,n,o){const r=lt(t);i.x=r.x,i.y=r.y,"percent"===r.type&&(i.x*=e.width,i.y*=e.height,n&&(o||(i.x-=n.x,i.y-=n.y),r.x&&(i.x-=1===r.x?n.width:.5===r.x?r.x*n.width:0),r.y&&(i.y-=1===r.y?n.height:.5===r.y?r.y*n.height:0))),s||(i.x+=e.x,i.y+=e.y)},getPoint:(t,e,i)=>(i||(i={}),ht.toPoint(t,e,i,!0),i)};function lt(t){return a(t)?at[rt[t]]:t}const{toPoint:dt}=ht,ct={toPoint(t,e,i,s,n,o){dt(t,i,s,n,e,o)}},{tempPointBounds:ut,setPoint:_t,addPoint:pt,toBounds:gt}=st,{toOuterPoint:ft}=I,{float:mt,fourNumber:yt}=b,{floor:vt,ceil:wt}=Math;let xt,bt,kt,Et;const St={},Bt={},Tt={},Rt={tempBounds:Tt,set(t,e=0,i=0,s=0,n=0){t.x=e,t.y=i,t.width=s,t.height=n},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,i,s,n){const{x:o,y:r,width:a,height:h}=e;if(u(i)){const e=yt(i);s?Ct.set(t,o+e[3],r+e[0],a-e[1]-e[3],h-e[2]-e[0]):Ct.set(t,o-e[3],r-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),Ct.set(t,o-i,r-i,a+2*i,h+2*i);n&&("width"===n?(t.y=r,t.height=h):(t.x=o,t.width=a))},minX:t=>t.width>0?t.x:t.x+t.width,minY:t=>t.height>0?t.y:t.y+t.height,maxX:t=>t.width>0?t.x+t.width:t.x,maxY:t=>t.height>0?t.y+t.height:t.y,move(t,e,i){t.x+=e,t.y+=i},scroll(t,e){t.x+=e.scrollX,t.y+=e.scrollY},getByMove:(t,e,i)=>(t=Object.assign({},t),Ct.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?Lt(e,t):e=t,i?(e.offsetX=-(Ct.maxX(i)-t.x),e.offsetY=-(Ct.maxY(i)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),Ct.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e,s){s||K.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){K.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(Ct.copy(Tt,t),Ct.toOuterOf(Tt,e),Tt),getOuterOf:(t,e)=>(t=Object.assign({},t),Ct.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:n}=e;s>0?(i.width=t.width*s,i.x=e.e+t.x*s):(i.width=t.width*-s,i.x=e.e+t.x*s-i.width),n>0?(i.height=t.height*n,i.y=e.f+t.y*n):(i.height=t.height*-n,i.y=e.f+t.y*n-i.height)}else St.x=t.x,St.y=t.y,ft(e,St,Bt),_t(ut,Bt.x,Bt.y),St.x=t.x+t.width,ft(e,St,Bt),pt(ut,Bt.x,Bt.y),St.y=t.y+t.height,ft(e,St,Bt),pt(ut,Bt.x,Bt.y),St.x=t.x,ft(e,St,Bt),pt(ut,Bt.x,Bt.y),gt(ut,i)},toInnerOf(t,e,i){i||(i=t),Ct.move(i,-e.e,-e.f),Ct.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Ct.getFitScale(t,e));return new et(s,0,0,s,-e.x*s,-e.y*s)},getFitScale(t,e,i){const s=t.width/e.width,n=t.height/e.height;return i?Math.max(s,n):Math.min(s,n)},put(t,e,i="center",s=1,n=!0,o){o||(o=e),a(s)&&(s=Ct.getFitScale(t,e,"cover"===s)),Tt.width=n?e.width*=s:e.width*s,Tt.height=n?e.height*=s:e.height*s,ct.toPoint(i,Tt,t,o,!0,!0)},getSpread(t,e,i){const s={};return Ct.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){Ct.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){Ct.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=vt(t.x),t.y=vt(t.y),t.width=e>t.x?wt(t.width+e-t.x):wt(t.width),t.height=i>t.y?wt(t.height+i-t.y):wt(t.height)},unsign(t){t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height)},float(t,e){t.x=mt(t.x,e),t.y=mt(t.y,e),t.width=mt(t.width,e),t.height=mt(t.height,e)},add(t,e,i){xt=t.x+t.width,bt=t.y+t.height,kt=e.x,Et=e.y,i||(kt+=e.width,Et+=e.height),xt=xt>kt?xt:kt,bt=bt>Et?bt:Et,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=xt-t.x,t.height=bt-t.y},addList(t,e){Ct.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){Ct.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){Ct.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let n,o=!0;for(let r=0,a=e.length;r<a;r++)n=i?i(e[r],r):e[r],n&&(n.width||n.height)&&(o?(o=!1,s||Lt(t,n)):Ot(t,n));o&&Ct.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?_t(ut,t.x,t.y):pt(ut,t.x,t.y)),gt(ut,t)},setPoint(t,e){Ct.set(t,e.x,e.y)},addPoint(t,e){Ot(t,e,!0)},getPoints(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]},hitRadiusPoint:(t,e,i)=>(i&&(e=K.tempToInnerRadiusPointOf(e,i)),e.x>=t.x-e.radiusX&&e.x<=t.x+t.width+e.radiusX&&e.y>=t.y-e.radiusY&&e.y<=t.y+t.height+e.radiusY),hitPoint:(t,e,i)=>(i&&(e=K.tempToInnerOf(e,i)),e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height),hit:(t,e,i)=>(i&&(e=Ct.tempToOuterOf(e,i)),!(t.y+t.height<e.y||e.y+e.height<t.y||t.x+t.width<e.x||e.x+e.width<t.x)),includes:(t,e,i)=>(i&&(e=Ct.tempToOuterOf(e,i)),t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height),getIntersectData(t,e,i){if(i&&(e=Ct.tempToOuterOf(e,i)),!Ct.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:o,height:r}=e;return xt=s+o,bt=n+r,kt=t.x+t.width,Et=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,xt=xt<kt?xt:kt,bt=bt<Et?bt:Et,o=xt-s,r=bt-n,{x:s,y:n,width:o,height:r}},intersect(t,e,i){Ct.copy(t,Ct.getIntersectData(t,e,i))},isSame:(t,e)=>t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height,isEmpty:t=>0===t.x&&0===t.y&&0===t.width&&0===t.height,reset(t){Ct.set(t)}},Ct=Rt,{add:Ot,copy:Lt}=Ct;class Pt{get minX(){return Rt.minX(this)}get minY(){return Rt.minY(this)}get maxX(){return Rt.maxX(this)}get maxY(){return Rt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return _(t)?Rt.copy(this,t):Rt.set(this,t,e,i,s),this}get(){const{x:t,y:e,width:i,height:s}=this;return{x:t,y:e,width:i,height:s}}clone(){return new Pt(this)}move(t,e){return Rt.move(this,t,e),this}scale(t,e,i){return Rt.scale(this,t,e,i),this}scaleOf(t,e,i){return Rt.scaleOf(this,t,e,i),this}toOuterOf(t,e){return Rt.toOuterOf(this,t,e),this}toInnerOf(t,e){return Rt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return Rt.getFitMatrix(this,t,e)}put(t,e,i){Rt.put(this,t,e,i)}spread(t,e){return Rt.spread(this,t,e),this}shrink(t,e){return Rt.shrink(this,t,e),this}ceil(){return Rt.ceil(this),this}unsign(){return Rt.unsign(this),this}float(t){return Rt.float(this,t),this}add(t){return Rt.add(this,t),this}addList(t){return Rt.setList(this,t,!0),this}setList(t){return Rt.setList(this,t),this}addListWithFn(t,e){return Rt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return Rt.setListWithFn(this,t,e),this}setPoint(t){return Rt.setPoint(this,t),this}setPoints(t){return Rt.setPoints(this,t),this}addPoint(t){return Rt.addPoint(this,t),this}getPoints(){return Rt.getPoints(this)}hitPoint(t,e){return Rt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return Rt.hitRadiusPoint(this,t,e)}hit(t,e){return Rt.hit(this,t,e)}includes(t,e){return Rt.includes(this,t,e)}intersect(t,e){return Rt.intersect(this,t,e),this}getIntersect(t,e){return new Pt(Rt.getIntersectData(this,t,e))}isSame(t){return Rt.isSame(this,t)}isEmpty(){return Rt.isEmpty(this)}reset(){Rt.reset(this)}}const At=new Pt;class Mt{constructor(t,e,i,s,n,o){_(t)?this.copy(t):this.set(t,e,i,s,n,o)}set(t=0,e=0,i=0,s=0,n=0,o=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=n,this.height=o}copy(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=t;this.set(e,i,s,n,o,r)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=this;return new Pt(n,e,o||t.width-n-i,r||t.height-e-s)}}const Dt={0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,".":1,e:1,E:1},{randColor:Ft}=b;class It{constructor(t){this.repeatMap={},this.name=t}static get(t){return new It(t)}static set filter(t){this.filterList=Wt(t)}static set exclude(t){this.excludeList=Wt(t)}static drawRepaint(t,e){const i=Ft();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(t,e,i){const s="hit"===It.showBounds,n=t.__nowWorld,o=Ft();s&&(e.setWorld(n),t.__drawHitPath(e),e.fillStyle=o.replace("1)",".2)"),e.fill()),e.resetTransform(),e.setStroke(o,2),s?e.stroke():e.strokeWorld(n,o)}log(...t){if(zt.enable){if(zt.filterList.length&&zt.filterList.every(t=>t!==this.name))return;if(zt.excludeList.length&&zt.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){zt.enable&&this.warn(...t)}warn(...t){zt.showWarn&&console.warn(this.name,...t)}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}function Wt(t){return t?a(t)&&(t=[t]):t=[],t}It.filterList=[],It.excludeList=[],It.showWarn=!0;const zt=It,Nt=It.get("RunTime"),Yt={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,i){const s=e.create(e.RUNTIME);return Ht.currentId=Ht.idMap[s]=i?performance.now():Date.now(),Ht.currentName=Ht.nameMap[s]=t,Ht.nameToIdMap[t]=s,s},end(t,e){const i=Ht.idMap[t],s=Ht.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;Ht.idMap[t]=Ht.nameMap[t]=Ht.nameToIdMap[s]=void 0,Nt.log(s,n,"ms")},endOfName(t,e){const i=Ht.nameToIdMap[t];o(i)||Ht.end(i,e)}},Ht=Yt,Xt=[],Vt={list:{},add(t,...e){this.list[t]=!0,Xt.push(...e)},has(t,e){const i=this.list[t];return!i&&e&&this.need(t),i},need(t){console.error("please install and import plugin: "+(t.includes("-x")?"":"@leafer-in/")+t)}};setTimeout(()=>Xt.forEach(t=>Vt.has(t,!0)));const jt={editor:t=>Vt.need("editor")},Ut=It.get("UICreator"),Gt={list:{},register(t){const{__tag:e}=t.prototype;Kt[e]&&Ut.repeat(e),Kt[e]=t},get(t,e,i,s,n,r){Kt[t]||Ut.error("not register "+t);const a=new Kt[t](e);return o(i)||(a.x=i,s&&(a.y=s),n&&(a.width=n),r&&(a.height=r)),a}},{list:Kt}=Gt,qt=It.get("EventCreator"),Zt={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],a(e)&&(Jt[e]&&qt.repeat(e),Jt[e]=t)})},changeName(t,e){const i=Jt[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,Jt[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new Jt[t](...e)},{nameList:Jt}=Zt;class $t{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:i}=this;for(let s=0,n=i.length;s<n;s++)if(e=i[s],e.recycled&&e.isSameSize(t))return e.recycled=!1,e.manager||(e.manager=this),e;const s=jt.canvas(t);return this.add(s),s}recycle(t){t.recycled=!0}clearRecycled(){let t;const e=[];for(let i=0,s=this.list.length;i<s;i++)t=this.list[i],t.recycled?t.destroy():e.push(t);this.list=e}clear(){this.list.forEach(t=>{t.destroy()}),this.list.length=0}destroy(){this.clear()}}function Qt(t,e,i,s){var n,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o<3?n(r):o>3?n(e,i,r):n(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r}function te(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){t.done?n(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(r,a)}h((s=s.apply(t,e||[])).next())})}function ee(t){return(e,i)=>{t||(t=i);const s={get(){return this.context[t]},set(e){this.context[t]=e}};"strokeCap"===i&&(s.set=function(e){this.context[t]="none"===e?"butt":e}),Object.defineProperty(e,i,s)}}"function"==typeof SuppressedError&&SuppressedError;const ie=[];function se(){return(t,e)=>{ie.push(e)}}const ne=[];let oe=class{set blendMode(t){"normal"===t&&(t="source-over"),this.context.globalCompositeOperation=t}get blendMode(){return this.context.globalCompositeOperation}set dashPattern(t){this.context.setLineDash(t||ne)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;ie.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,i,s,n,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,n,o){_(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,n,o)}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,i,s){}strokeRect(t,e,i,s){}clearRect(t,e,i,s){}drawImage(t,e,i,s,n,o,r,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/s*a;s+=e,e=0,o+=t,a-=t}if(i<0){const t=-i/n*h;n+=i,i=0,r+=t,h-=t}this.context.drawImage(t,e,i,s,n,o,r,a,h);break;case 5:this.context.drawImage(t,e,i,s,n);break;case 3:this.context.drawImage(t,e,i)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,i,s,n,o){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,n,o){}arcTo(t,e,i,s,n){}ellipse(t,e,i,s,n,o,r,a){}rect(t,e,i,s){}roundRect(t,e,i,s,n){}createConicGradient(t,e,i){}createLinearGradient(t,e,i,s){}createPattern(t,e){}createRadialGradient(t,e,i,s,n,o){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}};Qt([ee("imageSmoothingEnabled")],oe.prototype,"smooth",void 0),Qt([ee("imageSmoothingQuality")],oe.prototype,"smoothLevel",void 0),Qt([ee("globalAlpha")],oe.prototype,"opacity",void 0),Qt([ee()],oe.prototype,"fillStyle",void 0),Qt([ee()],oe.prototype,"strokeStyle",void 0),Qt([ee("lineWidth")],oe.prototype,"strokeWidth",void 0),Qt([ee("lineCap")],oe.prototype,"strokeCap",void 0),Qt([ee("lineJoin")],oe.prototype,"strokeJoin",void 0),Qt([ee("lineDashOffset")],oe.prototype,"dashOffset",void 0),Qt([ee()],oe.prototype,"miterLimit",void 0),Qt([ee()],oe.prototype,"shadowBlur",void 0),Qt([ee()],oe.prototype,"shadowColor",void 0),Qt([ee()],oe.prototype,"shadowOffsetX",void 0),Qt([ee()],oe.prototype,"shadowOffsetY",void 0),Qt([ee()],oe.prototype,"filter",void 0),Qt([ee()],oe.prototype,"font",void 0),Qt([ee()],oe.prototype,"fontKerning",void 0),Qt([ee()],oe.prototype,"fontStretch",void 0),Qt([ee()],oe.prototype,"fontVariantCaps",void 0),Qt([ee()],oe.prototype,"textAlign",void 0),Qt([ee()],oe.prototype,"textBaseline",void 0),Qt([ee()],oe.prototype,"textRendering",void 0),Qt([ee()],oe.prototype,"wordSpacing",void 0),Qt([ee()],oe.prototype,"letterSpacing",void 0),Qt([ee()],oe.prototype,"direction",void 0),Qt([se()],oe.prototype,"setTransform",null),Qt([se()],oe.prototype,"resetTransform",null),Qt([se()],oe.prototype,"getTransform",null),Qt([se()],oe.prototype,"save",null),Qt([se()],oe.prototype,"restore",null),Qt([se()],oe.prototype,"translate",null),Qt([se()],oe.prototype,"scale",null),Qt([se()],oe.prototype,"rotate",null),Qt([se()],oe.prototype,"fill",null),Qt([se()],oe.prototype,"stroke",null),Qt([se()],oe.prototype,"clip",null),Qt([se()],oe.prototype,"fillRect",null),Qt([se()],oe.prototype,"strokeRect",null),Qt([se()],oe.prototype,"clearRect",null),Qt([se()],oe.prototype,"beginPath",null),Qt([se()],oe.prototype,"moveTo",null),Qt([se()],oe.prototype,"lineTo",null),Qt([se()],oe.prototype,"bezierCurveTo",null),Qt([se()],oe.prototype,"quadraticCurveTo",null),Qt([se()],oe.prototype,"closePath",null),Qt([se()],oe.prototype,"arc",null),Qt([se()],oe.prototype,"arcTo",null),Qt([se()],oe.prototype,"ellipse",null),Qt([se()],oe.prototype,"rect",null),Qt([se()],oe.prototype,"roundRect",null),Qt([se()],oe.prototype,"createConicGradient",null),Qt([se()],oe.prototype,"createLinearGradient",null),Qt([se()],oe.prototype,"createPattern",null),Qt([se()],oe.prototype,"createRadialGradient",null),Qt([se()],oe.prototype,"fillText",null),Qt([se()],oe.prototype,"measureText",null),Qt([se()],oe.prototype,"strokeText",null);const{copy:re,multiplyParent:ae,pixelScale:he}=I,{round:le}=Math,de=new Pt,ce=new Pt,ue={width:1,height:1,pixelRatio:1},_e=["width","height","pixelRatio"];class pe extends oe{get width(){return this.size.width}get height(){return this.size.height}get pixelRatio(){return this.size.pixelRatio}get pixelWidth(){return this.width*this.pixelRatio||0}get pixelHeight(){return this.height*this.pixelRatio||0}get pixelSnap(){return this.config.pixelSnap}set pixelSnap(t){this.config.pixelSnap=t}get allowBackgroundColor(){return this.view&&this.parentView}constructor(i,s){super(),this.size={},this.worldTransform={},i||(i=ue),this.manager=s,this.innerId=e.create(e.CNAVAS);const{width:n,height:o,pixelRatio:r}=i;this.autoLayout=!n||!o,this.size.pixelRatio=r||t.devicePixelRatio,this.config=i,this.init()}init(){}__createContext(){const{view:t}=this,{contextSettings:e}=this.config;this.context=e?t.getContext("2d",e):t.getContext("2d"),this.__bindContext()}export(t,e){}toBlob(t,e){}toDataURL(t,e){}saveAs(t,e){}resize(t,e=!0){if(this.isSameSize(t))return;let i;this.context&&!this.unreal&&e&&this.width&&(i=this.getSameCanvas(),i.copyWorld(this));const s=this.size;f.copyAttrs(s,t,_e),_e.forEach(t=>s[t]||(s[t]=1)),this.bounds=new Pt(0,0,this.width,this.height),this.updateViewSize(),this.updateClientBounds(),this.context&&(this.smooth=this.config.smooth,!this.unreal&&i&&(this.clearWorld(i.bounds),this.copyWorld(i),i.recycle()))}updateViewSize(){}updateClientBounds(){}getClientBounds(t){return t&&this.updateClientBounds(),this.clientBounds||this.bounds}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e){const{pixelRatio:i,pixelSnap:s}=this,n=this.worldTransform;e&&ae(t,e,n),he(t,i,n),s&&(t.half&&t.half*i%2?(n.e=le(n.e-.5)+.5,n.f=le(n.f-.5)+.5):(n.e=le(n.e),n.f=le(n.f))),this.setTransform(n.a,n.b,n.c,n.d,n.e,n.f)}useWorldTransform(t){t&&(this.worldTransform=t);const e=this.worldTransform;e&&this.setTransform(e.a,e.b,e.c,e.d,e.e,e.f)}setStroke(t,e,i,s){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),i&&this.setStrokeOptions(i,s)}setStrokeOptions(t,e){let{strokeCap:i,strokeJoin:s,dashPattern:n,dashOffset:r,miterLimit:a}=t;e&&(e.strokeCap&&(i=e.strokeCap),e.strokeJoin&&(s=e.strokeJoin),o(e.dashPattern)||(n=e.dashPattern),o(e.dashOffset)||(r=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=i,this.strokeJoin=s,this.dashPattern=n,this.dashOffset=r,this.miterLimit=a}saveBlendMode(t){this.savedBlendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedBlendMode}hitFill(t,e){return!0}hitStroke(t,e){return!0}hitPixel(t,e,i=1){return!0}setWorldShadow(t,e,i,s){const{pixelRatio:n}=this;this.shadowOffsetX=t*n,this.shadowOffsetY=e*n,this.shadowBlur=i*n,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s,n=!0){s&&(this.blendMode=s),e?(this.setTempPixelBounds(e,n),i?(this.setTempPixelBounds2(i,n),i=ce):i=de,this.drawImage(t.view,de.x,de.y,de.width,de.height,i.x,i.y,i.width,i.height)):this.drawImage(t.view,0,0),s&&(this.blendMode="source-over")}copyWorldToInner(t,e,i,s,n=!0){e.b||e.c?(this.save(),this.resetTransform(),this.copyWorld(t,e,Rt.tempToOuterOf(i,e),s,n),this.restore()):(s&&(this.blendMode=s),this.setTempPixelBounds(e,n),this.drawImage(t.view,de.x,de.y,de.width,de.height,i.x,i.y,i.width,i.height),s&&(this.blendMode="source-over"))}copyWorldByReset(t,e,i,s,n,o=!0){this.resetTransform(),this.copyWorld(t,e,i,s,o),n||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempPixelBounds(t,!0,!0);const{context:s}=this,n=s.getImageData(de.x,de.y,de.width,de.height),{data:o}=n;for(let t=0,s=o.length;t<s;t+=4)i=.299*o[t]+.587*o[t+1]+.114*o[t+2],(e=o[t+3])&&(o[t+3]=255===e?i:e*(i/255));s.putImageData(n,de.x,de.y)}useMask(t,e,i){this.copyWorld(t,e,i,"destination-in")}useEraser(t,e,i){this.copyWorld(t,e,i,"destination-out")}fillWorld(t,e,i,s){i&&(this.blendMode=i),this.fillStyle=e,this.setTempPixelBounds(t,s),this.fillRect(de.x,de.y,de.width,de.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(de.x,de.y,de.width,de.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(de.x,de.y,de.width,de.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(de.x,de.y,de.width,de.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(de,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(ce,t,e,i)}copyToPixelBounds(t,e,i,s){t.set(e),s&&t.intersect(this.bounds),t.scale(this.pixelRatio),i&&t.ceil()}isSameSize(t){return this.width===t.width&&this.height===t.height&&(!t.pixelRatio||this.pixelRatio===t.pixelRatio)}getSameCanvas(t,e){const{size:i,pixelSnap:s}=this,n=this.manager?this.manager.get(i):jt.canvas(Object.assign({},i));return n.save(),t&&(re(n.worldTransform,this.worldTransform),n.useWorldTransform()),e&&(n.smooth=this.smooth),n.pixelSnap!==s&&(n.pixelSnap=s),n}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const ge={creator:{},parse(t,e){},convertToCanvasData(t,e){}},fe={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},me=Object.assign({M:1,m:10,L:2,l:20,H:3,h:30,V:4,v:40,C:5,c:50,S:6,s:60,Q:7,q:70,T:8,t:80,A:9,a:90,Z:11,z:11,R:12},fe),ye={M:3,m:3,L:3,l:3,H:2,h:2,V:2,v:2,C:7,c:7,S:5,s:5,Q:5,q:5,T:3,t:3,A:8,a:8,Z:1,z:1,N:5,D:9,X:6,G:9,F:5,O:7,P:4,U:6},ve={m:10,l:20,H:3,h:30,V:4,v:40,c:50,S:6,s:60,q:70,T:8,t:80,A:9,a:90},we=Object.assign(Object.assign({},ve),fe),xe=me,be={};for(let t in xe)be[xe[t]]=t;const ke={};for(let t in xe)ke[xe[t]]=ye[t];const Ee={drawRoundRect(t,e,i,s,n,o){const r=b.fourNumber(o,Math.min(s/2,n/2)),a=e+s,h=i+n;r[0]?t.moveTo(e+r[0],i):t.moveTo(e,i),r[1]?t.arcTo(a,i,a,h,r[1]):t.lineTo(a,i),r[2]?t.arcTo(a,h,e,h,r[2]):t.lineTo(a,h),r[3]?t.arcTo(e,h,e,i,r[3]):t.lineTo(e,h),r[0]?t.arcTo(e,i,a,i,r[0]):t.lineTo(e,i)}},{sin:Se,cos:Be,hypot:Te,atan2:Re,ceil:Ce,abs:Oe,PI:Le,sqrt:Pe,pow:Ae}=Math,{setPoint:Me,addPoint:De}=st,{set:Fe,toNumberPoints:Ie}=K,{M:We,L:ze,C:Ne,Q:Ye,Z:He}=me,Xe={},Ve={points(t,e,i,s){let n=Ie(e);if(t.push(We,n[0],n[1]),i&&n.length>5){let e,o,r,a,h,l,d,c,u,_,p,g,f,m=n.length;const y=!0===i?.5:i;s&&(n=[n[m-2],n[m-1],...n,n[0],n[1],n[2],n[3]],m=n.length);for(let i=2;i<m-2;i+=2)e=n[i-2],o=n[i-1],r=n[i],a=n[i+1],h=n[i+2],l=n[i+3],p=Pe(Ae(r-e,2)+Ae(a-o,2)),g=Pe(Ae(h-r,2)+Ae(l-a,2)),(p||g)&&(f=p+g,p=y*p/f,g=y*g/f,h-=e,l-=o,d=r-p*h,c=a-p*l,2===i?s||t.push(Ye,d,c,r,a):t.push(Ne,u,_,d,c,r,a),u=r+g*h,_=a+g*l);s||t.push(Ye,u,_,n[m-2],n[m-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(ze,n[e],n[e+1]);s&&t.push(He)},rect(t,e,i,s,n){ge.creator.path=t,ge.creator.moveTo(e,i).lineTo(e+s,i).lineTo(e+s,i+n).lineTo(e,i+n).lineTo(e,i)},roundRect(t,e,i,s,n,o){ge.creator.path=[],Ee.drawRoundRect(ge.creator,e,i,s,n,o),t.push(...ge.convertToCanvasData(ge.creator.path,!0))},arcTo(t,e,i,s,n,o,r,a,h,l,d){const c=s-e,u=n-i,_=o-s,p=r-n;let g=Re(u,c),f=Re(p,_);const m=Te(c,u),y=Te(_,p);let v=f-g;if(v<0&&(v+=S),m<1e-12||y<1e-12||v<1e-12||Oe(v-Le)<1e-12)return t&&t.push(ze,s,n),h&&(Me(h,e,i),De(h,s,n)),d&&Fe(d,e,i),void(l&&Fe(l,s,n));const w=c*p-_*u<0,x=w?-1:1,b=a/Be(v/2),k=s+b*Be(g+v/2+B*x),T=n+b*Se(g+v/2+B*x);return g-=B*x,f-=B*x,Ge(t,k,T,a,a,0,g/E,f/E,w,h,l,d)},arc:(t,e,i,s,n,o,r,a,h,l)=>Ge(t,e,i,s,s,0,n,o,r,a,h,l),ellipse(t,e,i,s,n,o,r,a,h,l,d,c){const u=o*E,_=Se(u),p=Be(u);let g=r*E,f=a*E;g>Le&&(g-=S),f<0&&(f+=S);let m=f-g;m<0?m+=S:m>S&&(m-=S),h&&(m-=S);const y=Ce(Oe(m/B)),v=m/y,w=Se(v/4),x=8/3*w*w/Se(v/2);f=g+v;let b,k,T,R,C,O,L,P,A=Be(g),M=Se(g),D=T=p*s*A-_*n*M,F=R=_*s*A+p*n*M,I=e+T,W=i+R;t&&t.push(t.length?ze:We,I,W),l&&Me(l,I,W),c&&Fe(c,I,W);for(let o=0;o<y;o++)b=Be(f),k=Se(f),T=p*s*b-_*n*k,R=_*s*b+p*n*k,C=e+D-x*(p*s*M+_*n*A),O=i+F-x*(_*s*M-p*n*A),L=e+T+x*(p*s*k+_*n*b),P=i+R+x*(_*s*k-p*n*b),t&&t.push(Ne,C,O,L,P,e+T,i+R),l&&Ue(e+D,i+F,C,O,L,P,e+T,i+R,l,!0),D=T,F=R,A=b,M=k,g=f,f+=v;d&&Fe(d,e+T,i+R)},quadraticCurveTo(t,e,i,s,n,o,r){t.push(Ne,(e+2*s)/3,(i+2*n)/3,(o+2*s)/3,(r+2*n)/3,o,r)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,n,o,r,a){Ue(t,e,(t+2*i)/3,(e+2*s)/3,(n+2*i)/3,(o+2*s)/3,n,o,r,a)},toTwoPointBounds(t,e,i,s,n,o,r,a,h,l){const d=[];let c,u,_,p,g,f,m,y,v=t,w=i,x=n,b=r;for(let t=0;t<2;++t)if(1==t&&(v=e,w=s,x=o,b=a),c=-3*v+9*w-9*x+3*b,u=6*v-12*w+6*x,_=3*w-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;p=-_/u,0<p&&p<1&&d.push(p)}else m=u*u-4*_*c,y=Math.sqrt(m),m<0||(g=(-u+y)/(2*c),0<g&&g<1&&d.push(g),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?De(h,t,e):Me(h,t,e),De(h,r,a);for(let l=0,c=d.length;l<c;l++)je(d[l],t,e,i,s,n,o,r,a,Xe),De(h,Xe.x,Xe.y)},getPointAndSet(t,e,i,s,n,o,r,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,_=3*d*t*t,p=t*t*t;l.x=c*e+u*s+_*o+p*a,l.y=c*i+u*n+_*r+p*h},getPoint(t,e,i,s,n,o,r,a,h){const l={};return je(t,e,i,s,n,o,r,a,h,l),l},getDerivative(t,e,i,s,n){const o=1-t;return 3*o*o*(i-e)+6*o*t*(s-i)+3*t*t*(n-s)}},{getPointAndSet:je,toTwoPointBounds:Ue,ellipse:Ge}=Ve,{sin:Ke,cos:qe,sqrt:Ze,atan2:Je}=Math,{ellipse:$e}=Ve,Qe={ellipticalArc(e,i,s,n,o,r,a,h,l,d,c){const u=(l-i)/2,_=(d-s)/2,p=r*E,g=Ke(p),f=qe(p),m=-f*u-g*_,y=-f*_+g*u,v=n*n,w=o*o,x=y*y,b=m*m,k=v*w-v*x-w*b;let B=0;if(k<0){const t=Ze(1-k/(v*w));n*=t,o*=t}else B=(a===h?-1:1)*Ze(k/(v*x+w*b));const T=B*n*y/o,R=-B*o*m/n,C=Je((y-R)/o,(m-T)/n),O=Je((-y-R)/o,(-m-T)/n);let L=O-C;0===h&&L>0?L-=S:1===h&&L<0&&(L+=S);const P=i+u+f*T-g*R,A=s+_+g*T+f*R,M=L<0?1:0;c||t.ellipseToCurve?$e(e,P,A,n,o,r,C/E,O/E,M):n!==o||r?e.push(me.G,P,A,n,o,r,C/E,O/E,M):e.push(me.O,P,A,n,C/E,O/E,M)}},{M:ti,m:ei,L:ii,l:si,H:ni,h:oi,V:ri,v:ai,C:hi,c:li,S:di,s:ci,Q:ui,q:_i,T:pi,t:gi,A:fi,a:mi,Z:yi,z:vi,N:wi,D:xi,X:bi,G:ki,F:Ei,O:Si,P:Bi,U:Ti}=me,{rect:Ri,roundRect:Ci,arcTo:Oi,arc:Li,ellipse:Pi,quadraticCurveTo:Ai}=Ve,{ellipticalArc:Mi}=Qe,Di=It.get("PathConvert"),Fi={},Ii={current:{dot:0},stringify(t,e){let i,s,n,o=0,r=t.length,a="";for(;o<r;){s=t[o],i=ke[s],a+=s===n?" ":be[s];for(let s=1;s<i;s++)a+=b.float(t[o+s],e),s===i-1||(a+=" ");n=s,o+=i}return a},parse(t,e){let i,s,n,o="";const r=[],a=e?we:ve;for(let e=0,h=t.length;e<h;e++)s=t[e],Dt[s]?("."===s&&(Wi.dot&&(zi(r,o),o=""),Wi.dot++),"0"===o&&"."!==s&&(zi(r,o),o=""),o+=s):me[s]?(o&&(zi(r,o),o=""),Wi.name=me[s],Wi.length=ye[s],Wi.index=0,zi(r,Wi.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?o+=s:(o&&zi(r,o),o=s):o&&(zi(r,o),o=""),n=s;return o&&zi(r,o),i?Ii.toCanvasData(r,e):r},toCanvasData(t,e){let i,s,n,o,r,a=0,h=0,l=0,d=0,c=0,u=t.length;const _=[];for(;c<u;){switch(n=t[c],n){case ei:t[c+1]+=a,t[c+2]+=h;case ti:a=t[c+1],h=t[c+2],_.push(ti,a,h),c+=3;break;case oi:t[c+1]+=a;case ni:a=t[c+1],_.push(ii,a,h),c+=2;break;case ai:t[c+1]+=h;case ri:h=t[c+1],_.push(ii,a,h),c+=2;break;case si:t[c+1]+=a,t[c+2]+=h;case ii:a=t[c+1],h=t[c+2],_.push(ii,a,h),c+=3;break;case ci:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=di;case di:r=o===hi||o===di,l=r?2*a-i:t[c+1],d=r?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],_.push(hi,l,d,i,s,a,h),c+=5;break;case li:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,n=hi;case hi:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],_.push(hi,t[c+1],t[c+2],i,s,a,h),c+=7;break;case gi:t[c+1]+=a,t[c+2]+=h,n=pi;case pi:r=o===ui||o===pi,i=r?2*a-i:t[c+1],s=r?2*h-s:t[c+2],e?Ai(_,a,h,i,s,t[c+1],t[c+2]):_.push(ui,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case _i:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=ui;case ui:i=t[c+1],s=t[c+2],e?Ai(_,a,h,i,s,t[c+3],t[c+4]):_.push(ui,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case mi:t[c+6]+=a,t[c+7]+=h;case fi:Mi(_,a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),a=t[c+6],h=t[c+7],c+=8;break;case vi:case yi:_.push(yi),c++;break;case wi:a=t[c+1],h=t[c+2],e?Ri(_,a,h,t[c+3],t[c+4]):Ni(_,t,c,5),c+=5;break;case xi:a=t[c+1],h=t[c+2],e?Ci(_,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):Ni(_,t,c,9),c+=9;break;case bi:a=t[c+1],h=t[c+2],e?Ci(_,a,h,t[c+3],t[c+4],t[c+5]):Ni(_,t,c,6),c+=6;break;case ki:Pi(e?_:Ni(_,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,Fi),a=Fi.x,h=Fi.y,c+=9;break;case Ei:e?Pi(_,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):Ni(_,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Si:Li(e?_:Ni(_,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,Fi),a=Fi.x,h=Fi.y,c+=7;break;case Bi:e?Li(_,t[c+1],t[c+2],t[c+3],0,360,!1):Ni(_,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Ti:Oi(e?_:Ni(_,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,Fi),a=Fi.x,h=Fi.y,c+=6;break;default:return Di.error(`command: ${n} [index:${c}]`,t),_}o=n}return _},objectToCanvasData(t){const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(ti,t.x,t.y);break;case"L":e.push(ii,t.x,t.y);break;case"C":e.push(hi,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(ui,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(yi)}}),e},copyData(t,e,i,s){for(let n=i,o=i+s;n<o;n++)t.push(e[n])},pushData(t,e){Wi.index===Wi.length&&(Wi.index=1,t.push(Wi.name)),t.push(Number(e)),Wi.index++,Wi.dot=0}},{current:Wi,pushData:zi,copyData:Ni}=Ii,{M:Yi,L:Hi,C:Xi,Q:Vi,Z:ji,N:Ui,D:Gi,X:Ki,G:qi,F:Zi,O:Ji,P:$i,U:Qi}=me,{getMinDistanceFrom:ts,getRadianFrom:es}=K,{tan:is,min:ss,abs:ns}=Math,os={},rs={beginPath(t){t.length=0},moveTo(t,e,i){t.push(Yi,e,i)},lineTo(t,e,i){t.push(Hi,e,i)},bezierCurveTo(t,e,i,s,n,o,r){t.push(Xi,e,i,s,n,o,r)},quadraticCurveTo(t,e,i,s,n){t.push(Vi,e,i,s,n)},closePath(t){t.push(ji)},rect(t,e,i,s,n){t.push(Ui,e,i,s,n)},roundRect(t,e,i,s,n,o){if(l(o))t.push(Ki,e,i,s,n,o);else{const r=b.fourNumber(o);r?t.push(Gi,e,i,s,n,...r):t.push(Ui,e,i,s,n)}},ellipse(t,e,i,s,n,o,a,h,l){r(o)?t.push(Zi,e,i,s,n):(r(a)&&(a=0),r(h)&&(h=360),t.push(qi,e,i,s,n,o,a,h,l?1:0))},arc(t,e,i,s,n,o,a){r(n)?t.push($i,e,i,s):(r(o)&&(o=360),t.push(Ji,e,i,s,n,o,a?1:0))},arcTo(t,e,i,s,n,r,a,h){if(!o(a)){const t=ts(a,h,e,i,s,n);r=ss(r,ss(t/2,t/2*ns(is(es(a,h,e,i,s,n)/2))))}t.push(Qi,e,i,s,n,r)},drawEllipse(t,e,i,s,n,o,a,h,l){Ve.ellipse(null,e,i,s,n,r(o)?0:o,r(a)?0:a,r(h)?360:h,l,null,null,os),t.push(Yi,os.x,os.y),as(t,e,i,s,n,o,a,h,l)},drawArc(t,e,i,s,n,o,a){Ve.arc(null,e,i,s,r(n)?0:n,r(o)?360:o,a,null,null,os),t.push(Yi,os.x,os.y),hs(t,e,i,s,n,o,a)},drawPoints(t,e,i,s){Ve.points(t,e,i,s)}},{ellipse:as,arc:hs}=rs,{moveTo:ls,lineTo:ds,quadraticCurveTo:cs,bezierCurveTo:us,closePath:_s,beginPath:ps,rect:gs,roundRect:fs,ellipse:ms,arc:ys,arcTo:vs,drawEllipse:ws,drawArc:xs,drawPoints:bs}=rs;class ks{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?a(t)?ge.parse(t):t:[],this}beginPath(){return ps(this.__path),this.paint(),this}moveTo(t,e){return ls(this.__path,t,e),this.paint(),this}lineTo(t,e){return ds(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,o){return us(this.__path,t,e,i,s,n,o),this.paint(),this}quadraticCurveTo(t,e,i,s){return cs(this.__path,t,e,i,s),this.paint(),this}closePath(){return _s(this.__path),this.paint(),this}rect(t,e,i,s){return gs(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return fs(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,o,r,a){return ms(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}arc(t,e,i,s,n,o){return ys(this.__path,t,e,i,s,n,o),this.paint(),this}arcTo(t,e,i,s,n){return vs(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,o,r,a){return ws(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}drawArc(t,e,i,s,n,o){return xs(this.__path,t,e,i,s,n,o),this.paint(),this}drawPoints(t,e,i){return bs(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:Es,L:Ss,C:Bs,Q:Ts,Z:Rs,N:Cs,D:Os,X:Ls,G:Ps,F:As,O:Ms,P:Ds,U:Fs}=me,Is=It.get("PathDrawer"),Ws={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case Es:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Ss:t.lineTo(e[s+1],e[s+2]),s+=3;break;case Bs:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case Ts:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Rs:t.closePath(),s+=1;break;case Cs:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Os:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],[e[s+5],e[s+6],e[s+7],e[s+8]]),s+=9;break;case Ls:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case Ps:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*E,e[s+6]*E,e[s+7]*E,e[s+8]),s+=9;break;case As:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,S,!1),s+=5;break;case Ms:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*E,e[s+5]*E,e[s+6]),s+=7;break;case Ds:t.arc(e[s+1],e[s+2],e[s+3],0,S,!1),s+=4;break;case Fs:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void Is.error(`command: ${i} [index:${s}]`,e)}}},{M:zs,L:Ns,C:Ys,Q:Hs,Z:Xs,N:Vs,D:js,X:Us,G:Gs,F:Ks,O:qs,P:Zs,U:Js}=me,{toTwoPointBounds:$s,toTwoPointBoundsByQuadraticCurve:Qs,arcTo:tn,arc:en,ellipse:sn}=Ve,{addPointBounds:nn,copy:on,addPoint:rn,setPoint:an,addBounds:hn,toBounds:ln}=st,dn=It.get("PathBounds");let cn,un,_n;const pn={},gn={},fn={},mn={toBounds(t,e){mn.toTwoPointBounds(t,gn),ln(gn,e)},toTwoPointBounds(t,e){if(!t||!t.length)return an(e,0,0);let i,s,n,o,r,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(r=t[a],0===a&&(r===Xs||r===Ys||r===Hs?an(e,h,l):an(e,t[a+1],t[a+2])),r){case zs:case Ns:h=t[a+1],l=t[a+2],rn(e,h,l),a+=3;break;case Ys:n=t[a+5],o=t[a+6],$s(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,o,pn),nn(e,pn),h=n,l=o,a+=7;break;case Hs:i=t[a+1],s=t[a+2],n=t[a+3],o=t[a+4],Qs(h,l,i,s,n,o,pn),nn(e,pn),h=n,l=o,a+=5;break;case Xs:a+=1;break;case Vs:h=t[a+1],l=t[a+2],hn(e,h,l,t[a+3],t[a+4]),a+=5;break;case js:case Us:h=t[a+1],l=t[a+2],hn(e,h,l,t[a+3],t[a+4]),a+=r===js?9:6;break;case Gs:sn(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],t[a+7],t[a+8],pn,fn),0===a?on(e,pn):nn(e,pn),h=fn.x,l=fn.y,a+=9;break;case Ks:h=t[a+1],l=t[a+2],un=t[a+3],_n=t[a+4],hn(e,h-un,l-_n,2*un,2*_n),h+=un,a+=5;break;case qs:en(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],pn,fn),0===a?on(e,pn):nn(e,pn),h=fn.x,l=fn.y,a+=7;break;case Zs:h=t[a+1],l=t[a+2],cn=t[a+3],hn(e,h-cn,l-cn,2*cn,2*cn),h+=cn,a+=4;break;case Js:tn(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],pn,fn),0===a?on(e,pn):nn(e,pn),h=fn.x,l=fn.y,a+=6;break;default:return void dn.error(`command: ${r} [index:${a}]`,t)}}},{M:yn,L:vn,Z:wn}=me,{getCenterX:xn,getCenterY:bn}=K,{arcTo:kn}=rs,En={smooth(t,e,i){let s,n,o,r=0,a=0,h=0,l=0,d=0,c=0,u=0,_=0,p=0;const g=t.length,f=[];for(;r<g;){switch(s=t[r],s){case yn:l=_=t[r+1],d=p=t[r+2],r+=3,t[r]===vn?(c=t[r+1],u=t[r+2],f.push(yn,xn(l,c),bn(d,u))):f.push(yn,l,d);break;case vn:switch(a=t[r+1],h=t[r+2],r+=3,t[r]){case vn:kn(f,a,h,t[r+1],t[r+2],e,_,p);break;case wn:kn(f,a,h,l,d,e,_,p);break;default:f.push(vn,a,h)}_=a,p=h;break;case wn:n!==wn&&(kn(f,l,d,c,u,e,_,p),f.push(wn)),r+=1;break;default:o=ke[s];for(let e=0;e<o;e++)f.push(t[r+e]);r+=o}n=s}return s!==wn&&(f[1]=l,f[2]=d),f}};function Sn(t){return new ks(t)}const Bn=Sn();ge.creator=Sn(),ge.parse=Ii.parse,ge.convertToCanvasData=Ii.toCanvasData;const{drawRoundRect:Tn}=Ee;function Rn(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){Tn(this,t,e,i,s,n)})}(t)}const Cn={alphaPixelTypes:["png","webp","svg"],upperCaseTypeMap:{},mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]},isOpaqueImage(t){const e=On.fileType(t);return["jpg","jpeg"].some(t=>t===e)},getExportOptions(t){switch(typeof t){case"object":return t;case"number":return{quality:t};case"boolean":return{blob:t};default:return{}}}},On=Cn;On.alphaPixelTypes.forEach(t=>On.upperCaseTypeMap[t]=t.toUpperCase());const Ln=It.get("TaskProcessor");class Pn{constructor(t){this.parallel=!0,this.time=1,this.id=e.create(e.TASK),this.task=t}run(){return te(this,void 0,void 0,function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){Ln.error(t)}})}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class An{get total(){return this.list.length+this.delayNumber}get finishedIndex(){return this.isComplete?0:this.index+this.parallelSuccessNumber}get remain(){return this.isComplete?this.total:this.total-this.finishedIndex}get percent(){const{total:t}=this;let e=0,i=0;for(let s=0;s<t;s++)s<=this.finishedIndex?(i+=this.list[s].time,s===this.finishedIndex&&(e=i)):e+=this.list[s].time;return this.isComplete?1:i/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&f.assign(this.config,t),this.empty()}add(t,e){let i,s,n,r;const a=new Pn(t);return a.parent=this,l(e)?r=e:e&&(s=e.parallel,i=e.start,n=e.time,r=e.delay),n&&(a.time=n),!1===s&&(a.parallel=!1),o(r)?this.push(a,i):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(a,i))},r)),this.isComplete=!1,a}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout(()=>this.start()))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[],this.delayNumber=0}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach(t=>{t.isComplete||t.cancel()}),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then(()=>{this.onTask(t),this.index++,this.nextTask()}).catch(t=>{this.onError(t)}):this.nextTask()}runParallelTasks(){this.parallelList.forEach(t=>this.runParallelTask(t))}runParallelTask(t){t.run().then(()=>{this.onTask(t),this.fillParallelTask()}).catch(t=>{this.onParallelError(t)})}nextTask(){this.total===this.finishedIndex?this.onComplete():this.timer=setTimeout(()=>this.run())}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.config.parallel;e>this.list.length&&(e=this.list.length);for(let i=this.index;i<e&&(t=this.list[i],t.parallel);i++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const i=e.length,s=this.finishedIndex+i;if(e.length){if(!this.running)return;s<this.total&&(t=this.list[s],t&&t.parallel&&(e.push(t),this.runParallelTask(t)))}else this.index+=this.parallelSuccessNumber,this.parallelSuccessNumber=0,this.nextTask()}onComplete(){this.stop(),this.config.onComplete&&this.config.onComplete()}onTask(t){t.complete(),this.config.onTask&&this.config.onTask()}onParallelError(t){this.parallelList.forEach(t=>{t.parallel=!1}),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.config.onError&&this.config.onError(t)}destroy(){this.stop()}}const Mn=It.get("Resource"),Dn={tasker:new An,map:{},get isComplete(){return Fn.tasker.isComplete},set(t,e){Fn.map[t]&&Mn.repeat(t),Fn.map[t]=e},get:t=>Fn.map[t],remove(t){const e=Fn.map[t];e&&(e.destroy&&e.destroy(),delete Fn.map[t])},loadImage(t,e){return new Promise((i,s)=>{const n=this.setImage(t,t,e);n.load(()=>i(n),t=>s(t))})},setImage(t,e,i){let s;return a(e)?s={url:e}:e.url||(s={url:t,view:e}),s&&(i&&(s.format=i),e=jt.image(s)),Fn.set(t,e),e},destroy(){Fn.map={}}},Fn=Dn,In={maxRecycled:10,recycledList:[],patternTasker:new An,get(t){let e=Dn.get(t.url);return e||Dn.set(t.url,e=jt.image(t)),e.use++,e},recycle(t){t.use--,setTimeout(()=>{t.use||Wn.recycledList.push(t)})},clearRecycled(){const t=Wn.recycledList;t.length>Wn.maxRecycled&&(t.forEach(t=>!t.use&&t.url&&Dn.remove(t.url)),t.length=0)},hasAlphaPixel:t=>Cn.alphaPixelTypes.some(e=>Wn.isFormat(e,t)),isFormat(t,e){if(e.format)return e.format===t;const{url:i}=e;if(i.startsWith("data:")){if(i.startsWith("data:"+Cn.mineType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+Cn.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){Wn.recycledList=[]}},Wn=In,{IMAGE:zn,create:Nn}=e,{floor:Yn,max:Hn}=Math;class Xn{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=Nn(zn),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}In.isFormat("svg",t)&&(this.isSVG=!0),In.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(e,i){if(!this.loading){this.loading=!0;let{loadImage:e,loadImageWithProgress:i}=t.origin,s=this.config.showProgress&&i&&this.onProgress.bind(this);s&&(e=i),Dn.tasker.add(()=>te(this,void 0,void 0,function*(){return yield e(this.url,s).then(t=>this.setView(t)).catch(t=>{this.error=t,this.onComplete(!1)})}))}return this.waitComplete.push(e,i),this.waitComplete.length-2}unload(t,e){const i=this.waitComplete;if(e){const e=i[t+1];e&&e({type:"stop"})}i[t]=i[t+1]=void 0}setView(t){this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)}onProgress(t){this.progress=t}onComplete(t){let e;this.waitComplete.forEach((i,s)=>{e=s%2,i&&(t?e||i(this):e&&i(this.error))}),this.waitComplete.length=0,this.loading=!1}getFull(t){return this.view}getCanvas(e,i,s,n,o,r,a){if(e||(e=this.width),i||(i=this.height),this.cache){let{params:t,data:e}=this.cache;for(let i in t)if(t[i]!==arguments[i]){e=null;break}if(e)return e}const h=t.origin.createCanvas(Hn(Yn(e+(o||0)),1),Hn(Yn(i+(r||0)),1)),l=h.getContext("2d");return s&&(l.globalAlpha=s),l.imageSmoothingEnabled=!1!==a,l.drawImage(this.view,0,0,e,i),this.cache=this.use>1?{data:h,params:arguments}:null,h}getPattern(e,i,s,n){const o=t.canvas.createPattern(e,i);try{s&&o.setTransform&&(o.setTransform(s),s=void 0)}catch(t){}return n&&f.stintSet(n,"transform",s),o}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}}function Vn(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function jn(t,e){return Object.getOwnPropertyDescriptor(t,e)}function Un(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}function Gn(t,e){return(i,s)=>qn(i,s,t,e&&e(s))}function Kn(t){return t}function qn(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};Vn(t,e,Object.assign(n,s||{})),So(t,e,i)}function Zn(t){return Gn(t)}function Jn(t,e){return Gn(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function $n(t,e){return Gn(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function Qn(t){return Gn(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),no(this))}}))}function to(t,e){return Gn(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function eo(t,e){return Gn(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function io(t,e){return Gn(t,t=>({set(i){this.__setAttr(t,i,e)&&no(this)}}))}function so(t){return Gn(t,t=>({set(e){this.__setAttr(t,e)&&(no(this),this.__.__removeNaturalSize())}}))}function no(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function oo(t){return Gn(t,t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),no(this)}}))}const ro=io;function ao(t,e){return Gn(t,t=>({set(i){this.__setAttr(t,i)&&(ho(this),e&&(this.__.__useStroke=!0))}}))}function ho(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&no(t)}const lo=ao;function co(t){return Gn(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function uo(t){return Gn(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function _o(t){return Gn(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;f.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip),this.__layout.surfaceChange()}}}))}function po(t){return Gn(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&fo(this)}}))}function go(t){return Gn(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>mo(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");mo(this,t,e,i),this.mask&&fo(this)}}))}function fo(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function mo(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||no(t))}function yo(t){return Gn(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))}function vo(t){return Gn(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}function wo(t){return Gn(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}function xo(t){return Gn(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===It.showBounds&&this.__layout.surfaceChange(),this.leafer&&this.leafer.updateCursor())}}))}function bo(t){return Gn(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}function ko(t){return(e,i)=>{Vn(e,"__DataProcessor",{get:()=>t})}}function Eo(t){return(e,i)=>{Vn(e,"__LayoutProcessor",{get:()=>t})}}function So(t,e,i){const s=t.__DataProcessor.prototype,n="_"+e,r=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=Un(e,i);if(o(i))a.get=function(){return this[n]};else if("function"==typeof i)a.get=function(){const t=this[n];return null==t?i(this.__leaf):t};else if(_(i)){const t=g(i);a.get=function(){const e=this[n];return null==e?this[n]=t?{}:f.clone(i):e}}const h=t.isBranchLeaf;"width"===e?a.get=function(){const t=this[n];if(null==t){const t=this,e=t.__naturalWidth,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.width:e?t._height&&t.__useNaturalRatio?t._height*e/t.__naturalHeight:e:h&&s.children.length?s.boxBounds.width:i}return t}:"height"===e&&(a.get=function(){const t=this[n];if(null==t){const t=this,e=t.__naturalHeight,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.height:e?t._width&&t.__useNaturalRatio?t._width*e/t.__naturalWidth:e:h&&s.children.length?s.boxBounds.height:i}return t});let l,d=s;for(;!l&&d;)l=jn(d,e),d=d.__proto__;l&&l.set&&(a.set=l.set),s[r]&&(a.set=s[r],delete s[r]),Vn(s,e,a)}const Bo=new It("rewrite"),To=[],Ro=["destroy","constructor"];function Co(t){return(e,i)=>{To.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function Oo(){return t=>{Lo()}}function Lo(t){To.length&&(To.forEach(e=>{t&&Bo.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),To.length=0)}function Po(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{if(!(Ro.includes(s)||e&&e.includes(s)))if(t.prototype){jn(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]})}}function Ao(){return t=>{Gt.register(t)}}function Mo(){return t=>{Zt.register(t)}}setTimeout(()=>Lo(!0));const{copy:Do,toInnerPoint:Fo,toOuterPoint:Io,scaleOfOuter:Wo,rotateOfOuter:zo,skewOfOuter:No,multiplyParent:Yo,divideParent:Ho,getLayout:Xo}=I,Vo={},{round:jo}=Math,Uo={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),qo(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)Ko(s[t],e,i)}},updateMatrix(t,e,i){const s=t.__layout;e?i&&(s.waitAutoLayout=!0,t.__hasAutoLayout&&(s.matrixChanged=!1)):s.waitAutoLayout&&(s.waitAutoLayout=!1),s.matrixChanged&&t.__updateLocalMatrix(),s.waitAutoLayout||t.__updateWorldMatrix()},updateBounds(t){const e=t.__layout;e.boundsChanged&&t.__updateLocalBounds(),e.waitAutoLayout||t.__updateWorldBounds()},updateAllWorldOpacity(t){if(t.__updateWorldOpacity(),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)Zo(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&Zo(t),t.__updateChange()},updateAllChange(t){if($o(t),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)Jo(e[t])}},worldHittable(t){for(;t;){if(!t.__.hittable)return!1;t=t.parent}return!0},draggable:t=>(t.draggable||t.editable)&&t.hitSelf&&!t.locked,copyCanvasByWorld(e,i,s,n,o,r){n||(n=e.__nowWorld),e.__worldFlipped||t.fullImageShadow?i.copyWorldByReset(s,n,e.__nowWorld,o,r):i.copyWorldToInner(s,n,e.__layout.renderBounds,o)},moveWorld(t,e,i=0,s,n){const o=_(e)?Object.assign({},e):{x:e,y:i};s?Io(t.localTransform,o,o,!0):t.parent&&Fo(t.parent.scrollWorldTransform,o,o,!0),Go.moveLocal(t,o.x,o.y,n)},moveLocal(t,e,i=0,s){_(e)&&(i=e.y,e=e.x),e+=t.x,i+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=jo(e),i=jo(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,o){Go.zoomOfLocal(t,Qo(t,e),i,s,n,o)},zoomOfLocal(t,e,i,s=i,n,o){const r=t.__localMatrix;if(l(s)||(s&&(o=s),s=i),Do(Vo,r),Wo(Vo,e,i,s),Go.hasHighPosition(t))Go.setTransform(t,Vo,n,o);else{const e=t.x+Vo.e-r.e,a=t.y+Vo.f-r.f;o&&!n?t.animate({x:e,y:a,scaleX:t.scaleX*i,scaleY:t.scaleY*s},o):(t.x=e,t.y=a,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){Go.rotateOfLocal(t,Qo(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;Do(Vo,n),zo(Vo,e,i),Go.hasHighPosition(t)?Go.setTransform(t,Vo,!1,s):t.set({x:t.x+Vo.e-n.e,y:t.y+Vo.f-n.f,rotation:b.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,o){Go.skewOfLocal(t,Qo(t,e),i,s,n,o)},skewOfLocal(t,e,i,s=0,n,o){Do(Vo,t.__localMatrix),No(Vo,e,i,s),Go.setTransform(t,Vo,n,o)},transformWorld(t,e,i,s){Do(Vo,t.worldTransform),Yo(Vo,e),t.parent&&Ho(Vo,t.parent.scrollWorldTransform),Go.setTransform(t,Vo,i,s)},transform(t,e,i,s){Do(Vo,t.localTransform),Yo(Vo,e),Go.setTransform(t,Vo,i,s)},setTransform(t,e,i,s){const n=t.__,o=n.origin&&Go.getInnerOrigin(t,n.origin),r=Xo(e,o,n.around&&Go.getInnerOrigin(t,n.around));if(Go.hasOffset(t)&&(r.x-=n.offsetX,r.y-=n.offsetY),i){const e=r.scaleX/t.scaleX,i=r.scaleY/t.scaleY;if(delete r.scaleX,delete r.scaleY,o){Rt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=Go.getInnerOrigin(t,n.origin);K.move(r,o.x-s.x,o.y-s.y)}t.set(r),t.scaleResize(e,i,!1)}else t.set(r,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return Wo(i,Go.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>K.tempToOuterOf(Go.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return ht.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(Do(Vo,t.worldTransform),Ho(Vo,e.scrollWorldTransform),i?Vo:Object.assign({},Vo)),drop(t,e,i,s){t.setTransform(Go.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||Go.hasOffset(t),hasOffset:t=>t.offsetX||t.offsetY,hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}},animateMove(e,i,s=.3){if(i.x||i.y)if(Math.abs(i.x)<1&&Math.abs(i.y)<1)e.move(i);else{const n=i.x*s,o=i.y*s;i.x-=n,i.y-=o,e.move(n,o),t.requestRender(()=>Go.animateMove(e,i,s))}}},Go=Uo,{updateAllMatrix:Ko,updateMatrix:qo,updateAllWorldOpacity:Zo,updateAllChange:Jo,updateChange:$o}=Go;function Qo(t,e){return t.updateLayout(),t.parent?K.tempToInnerOf(e,t.parent.scrollWorldTransform):e}const tr={worldBounds:t=>t.__world,localBoxBounds:t=>t.__.eraser||0===t.__.visible?null:t.__local||t.__layout,localStrokeBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localStrokeBounds,localRenderBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localRenderBounds,maskLocalBoxBounds:(t,e)=>ir(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>ir(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>ir(t,e)&&t.__layout.localRenderBounds,excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))};let er;function ir(t,e){return e||(er=0),t.__.mask&&(er=1),er<0?null:(er&&(er=-1),!0)}const{updateBounds:sr}=Uo,nr={sort:(t,e)=>t.__.zIndex===e.__.zIndex?t.__tempNumber-e.__tempNumber:t.__.zIndex-e.__.zIndex,pushAllChildBranch(t,e){if(t.__tempNumber=1,t.__.__childBranchNumber){const{children:i}=t;for(let s=0,n=i.length;s<n;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),or(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&o(i[t.parent.innerId]);)e.add(t.parent),t=t.parent;else for(;t.parent;)e.add(t.parent),t=t.parent},pushAllBranchStack(t,e){let i=e.length;const{children:s}=t;for(let t=0,i=s.length;t<i;t++)s[t].isBranch&&e.push(s[t]);for(let t=i,s=e.length;t<s;t++)rr(e[t],e)},updateBounds(t,e){const i=[t];rr(t,i),ar(i,e)},updateBoundsByBranchStack(t,e){let i,s;for(let n=t.length-1;n>-1;n--){i=t[n],s=i.children;for(let t=0,e=s.length;t<e;t++)sr(s[t]);e&&e===i||sr(i)}}},{pushAllChildBranch:or,pushAllBranchStack:rr,updateBoundsByBranchStack:ar}=nr,hr={run(t){if(t&&t.length){const e=t.length;for(let i=0;i<e;i++)t[i]();t.length===e?t.length=0:t.splice(0,e)}}},{getRelativeWorld:lr,updateBounds:dr}=Uo,{toOuterOf:cr,getPoints:ur,copy:_r}=Rt,pr="_localContentBounds",gr="_worldContentBounds",fr="_worldBoxBounds",mr="_worldStrokeBounds";class yr{get contentBounds(){return this._contentBounds||this.boxBounds}set contentBounds(t){this._contentBounds=t}get strokeBounds(){return this._strokeBounds||this.boxBounds}get renderBounds(){return this._renderBounds||this.boxBounds}set renderBounds(t){this._renderBounds=t}get localContentBounds(){return cr(this.contentBounds,this.leaf.__localMatrix,this[pr]||(this[pr]={})),this[pr]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return cr(this.contentBounds,this.leaf.__world,this[gr]||(this[gr]={})),this[gr]}get worldBoxBounds(){return cr(this.boxBounds,this.leaf.__world,this[fr]||(this[fr]={})),this[fr]}get worldStrokeBounds(){return cr(this.strokeBounds,this.leaf.__world,this[mr]||(this[mr]={})),this[mr]}get a(){return 1}get b(){return 0}get c(){return 0}get d(){return 1}get e(){return this.leaf.__.x}get f(){return this.leaf.__.y}get x(){return this.e+this.boxBounds.x}get y(){return this.f+this.boxBounds.y}get width(){return this.boxBounds.width}get height(){return this.boxBounds.height}constructor(t){this.leaf=t,this.leaf.__local&&(this._localRenderBounds=this._localStrokeBounds=this.leaf.__local),t.__world&&(this.boxBounds={x:0,y:0,width:0,height:0},this.boxChange(),this.matrixChange())}createLocal(){const t=this.leaf.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0};this._localStrokeBounds||(this._localStrokeBounds=t),this._localRenderBounds||(this._localRenderBounds=t)}update(){const{leaf:e}=this,{leafer:i}=e;if(e.isApp)return dr(e);if(i)i.ready?i.watcher.changed&&i.layouter.layout():i.start();else{let i=e;for(;i.parent&&!i.parent.leafer;)i=i.parent;const s=i;if(s.__fullLayouting)return;s.__fullLayouting=!0,t.layout(s),delete s.__fullLayouting}}getTransform(t="world"){this.update();const{leaf:e}=this;switch(t){case"world":return e.__world;case"local":return e.__localMatrix;case"inner":return I.defaultMatrix;case"page":t=e.zoomLayer;default:return lr(e,t)}}getBounds(t,e="world"){switch(this.update(),e){case"world":return this.getWorldBounds(t);case"local":return this.getLocalBounds(t);case"inner":return this.getInnerBounds(t);case"page":e=this.leaf.zoomLayer;default:return new Pt(this.getInnerBounds(t)).toOuterOf(this.getTransform(e))}}getInnerBounds(t="box"){switch(t){case"render":return this.renderBounds;case"content":if(this.contentBounds)return this.contentBounds;case"box":return this.boxBounds;case"stroke":return this.strokeBounds}}getLocalBounds(t="box"){switch(t){case"render":return this.localRenderBounds;case"stroke":return this.localStrokeBounds;case"content":if(this.contentBounds)return this.localContentBounds;case"box":return this.leaf.__localBoxBounds}}getWorldBounds(t="box"){switch(t){case"render":return this.leaf.__world;case"stroke":return this.worldStrokeBounds;case"content":if(this.contentBounds)return this.worldContentBounds;case"box":return this.worldBoxBounds}}getLayoutBounds(t,e="world",i){const{leaf:s}=this;let n,o,r,a=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(a),o=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;r={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},n=s.getLocalPointByInner(a);break;case"inner":n=a,o=I.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),o=lr(s,e,!0)}if(r||(r=I.getLayout(o)),_r(r,a),K.copy(r,n),i){const{scaleX:t,scaleY:e}=r,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(r.scaleX/=i,r.scaleY/=s,r.width*=i,r.height*=s)}return r}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=ur(this.getInnerBounds(t));let n;switch(e){case"world":n=null;break;case"local":n=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:n=e}return o(n)||s.forEach(t=>i.innerToWorld(t,null,!1,n)),s}shrinkContent(){const{x:t,y:e,width:i,height:s}=this.boxBounds;this._contentBounds={x:t,y:e,width:i,height:s}}spreadStroke(){const{x:t,y:e,width:i,height:s}=this.strokeBounds;this._strokeBounds={x:t,y:e,width:i,height:s},this._localStrokeBounds={x:t,y:e,width:i,height:s},this.renderSpread||this.spreadRenderCancel()}spreadRender(){const{x:t,y:e,width:i,height:s}=this.renderBounds;this._renderBounds={x:t,y:e,width:i,height:s},this._localRenderBounds={x:t,y:e,width:i,height:s}}shrinkContentCancel(){this._contentBounds=void 0}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this._strokeBounds=this.boxBounds,this._localStrokeBounds=this.leaf.__localBoxBounds,t&&this.spreadRenderCancel()}spreadRenderCancel(){this._renderBounds=this._strokeBounds,this._localRenderBounds=this._localStrokeBounds}boxChange(){this.boxChanged=!0,this.localBoxChanged?this.boundsChanged||(this.boundsChanged=!0):this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChange(),this.leaf.__local||this.createLocal()}matrixChange(){this.matrixChanged=!0,this.localBoxChanged?this.boundsChanged||(this.boundsChanged=!0):this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=this.affectChildrenSort=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class vr{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&t.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&t.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&t.event.stop(this.origin)}}class wr extends vr{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}wr.ADD="child.add",wr.REMOVE="child.remove",wr.CREATED="created",wr.MOUNTED="mounted",wr.UNMOUNTED="unmounted",wr.DESTROY="destroy";const xr="property.scroll";class br extends vr{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}br.CHANGE="property.change",br.LEAFER_CHANGE="property.leafer_change",br.SCROLL=xr;const kr={scrollX:xr,scrollY:xr};class Er extends vr{constructor(t,e){super(t),Object.assign(this,e)}}Er.LOAD="image.load",Er.LOADED="image.loaded",Er.ERROR="image.error";class Sr extends vr{static checkHas(t,e,i){"on"===i?e===Cr?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Br)||t.hasEvent(Tr)||t.hasEvent(Rr),t.__hasWorldEvent=t.hasEvent(Cr))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Br,t),"inner"===e&&t.emit(Tr,t)),t.emit(Rr,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Cr,this)}}Sr.RESIZE="bounds.resize",Sr.INNER="bounds.inner",Sr.LOCAL="bounds.local",Sr.WORLD="bounds.world";const{RESIZE:Br,INNER:Tr,LOCAL:Rr,WORLD:Cr}=Sr,Or={};[Br,Tr,Rr,Cr].forEach(t=>Or[t]=1);class Lr extends vr{get bigger(){if(!this.old)return!0;const{width:t,height:e}=this.old;return this.width>=t&&this.height>=e}get smaller(){return!this.bigger}get samePixelRatio(){return!this.old||this.pixelRatio===this.old.pixelRatio}constructor(t,e){_(t)?(super(Lr.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!o(this.resizingKeys[t.innerId])}}Lr.RESIZE="resize";class Pr extends vr{constructor(t,e){super(t),this.data=e}}Pr.REQUEST="watch.request",Pr.DATA="watch.data";class Ar extends vr{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}Ar.REQUEST="layout.request",Ar.START="layout.start",Ar.BEFORE="layout.before",Ar.LAYOUT="layout",Ar.AFTER="layout.after",Ar.AGAIN="layout.again",Ar.END="layout.end";class Mr extends vr{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Mr.REQUEST="render.request",Mr.CHILD_START="render.child_start",Mr.CHILD_END="render.child_end",Mr.START="render.start",Mr.BEFORE="render.before",Mr.RENDER="render",Mr.AFTER="render.after",Mr.AGAIN="render.again",Mr.END="render.end",Mr.NEXT="render.next";class Dr extends vr{}Dr.START="leafer.start",Dr.BEFORE_READY="leafer.before_ready",Dr.READY="leafer.ready",Dr.AFTER_READY="leafer.after_ready",Dr.VIEW_READY="leafer.view_ready",Dr.VIEW_COMPLETED="leafer.view_completed",Dr.STOP="leafer.stop",Dr.RESTART="leafer.restart",Dr.END="leafer.end",Dr.UPDATE_MODE="leafer.update_mode",Dr.TRANSFORM="leafer.transform",Dr.MOVE="leafer.move",Dr.SCALE="leafer.scale",Dr.ROTATE="leafer.rotate",Dr.SKEW="leafer.skew";const{MOVE:Fr,SCALE:Ir,ROTATE:Wr,SKEW:zr}=Dr,Nr={x:Fr,y:Fr,scaleX:Ir,scaleY:Ir,rotation:Wr,skewX:zr,skewY:zr},Yr={};class Hr{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(u(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)u(e=t[i])?this.on(i,e[0],e[1]):this.on(i,e);return}let s,n,o;i&&("once"===i?n=!0:"boolean"==typeof i?s=i:(s=i.capture,n=i.once));const r=Xr(this,s,!0),h=a(t)?t.split(" "):t,l=n?{listener:e,once:n}:{listener:e};h.forEach(t=>{t&&(o=r[t],o?-1===o.findIndex(t=>t.listener===e)&&o.push(l):r[t]=[l],Or[t]&&Sr.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=a(t)?t.split(" "):t;if(e){let t,n,o;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const r=Xr(this,t);s.forEach(t=>{t&&(n=r[t],n&&(o=n.findIndex(t=>t.listener===e),o>-1&&n.splice(o,1),n.length||delete r[t],Or[t]&&Sr.checkHas(this,t,"off")))})}else{const{__bubbleMap:t,__captureMap:e}=this;s.forEach(i=>{t&&delete t[i],e&&delete e[i]})}}else this.__bubbleMap=this.__captureMap=void 0}on_(t,e,i,s){return e?this.on(t,i?e=e.bind(i):e,s):u(t)&&t.forEach(t=>this.on(t[0],t[2]?t[1]=t[1].bind(t[2]):t[1],t[3])),{type:t,current:this,listener:e,options:s}}off_(t){if(!t)return;const e=u(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):u(t.type)&&t.type.forEach(e=>t.current.off(e[0],e[1],e[3])))}),e.length=0}once(t,e,i,s){if(!e)return u(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));_(i)?e=e.bind(i):s=i,this.on(t,e,{once:!0,capture:s})}emit(t,e,i){!e&&Zt.has(t)&&(e=Zt.get(t,{type:t,target:this,current:this}));const s=Xr(this,i)[t];if(s){let n;for(let o=0,r=s.length;o<r&&!((n=s[o])&&(n.listener(e),n.once&&(this.off(t,n.listener,i),o--,r--),e&&e.isStopNow));o++);}this.syncEventer&&this.syncEventer.emitEvent(e,i)}emitEvent(t,e){t.current=this,this.emit(t.type,t,e)}hasEvent(t,e){if(this.syncEventer&&this.syncEventer.hasEvent(t,e))return!0;const{__bubbleMap:i,__captureMap:s}=this,n=i&&i[t],r=s&&s[t];return!!(o(e)?n||r:e?r:n)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function Xr(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:Yr)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:Yr)}}const{on:Vr,on_:jr,off:Ur,off_:Gr,once:Kr,emit:qr,emitEvent:Zr,hasEvent:Jr,destroy:$r}=Hr.prototype,Qr={on:Vr,on_:jr,off:Ur,off_:Gr,once:Kr,emit:qr,emitEvent:Zr,hasEvent:Jr,destroyEventer:$r},ta=It.get("setAttr"),ea={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(!i||h(e)||o(e)||(ta.warn(this.innerName,t,e),e=void 0),_(e)||s!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new br(br.LEAFER_CHANGE,this,t,s,e));const i=Nr[t];i&&(this.emitEvent(new Dr(i,this)),this.emitEvent(new Dr(Dr.TRANSFORM,this)))}this.emitPropertyEvent(br.CHANGE,t,s,e);const i=kr[t];return i&&this.emitPropertyEvent(i,t,s,e),!0}return!1}return this.__realSetAttr(t,e),!0},emitPropertyEvent(t,e,i,s){const n=new br(t,this,e,i,s);this.isLeafer||this.hasEvent(t)&&this.emitEvent(n),this.leafer.emitEvent(n)},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||o(i.normalStyle[t])||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:ia,multiplyParent:sa,translateInner:na,defaultWorld:oa}=I,{toPoint:ra,tempPoint:aa}=ht,ha={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:n}=this;sa(this.__local||e,t?t.__scrollWorld||t.__world:oa,i,!!e.affectScaleOrRotation,n),s&&na(Object.assign(s,i),n.scrollX,n.scrollY)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged&&(t.resized||(t.resized="scale"))||t.rotationChanged)&&(ia(e,i,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=void 0),e.e=i.x+i.offsetX,e.f=i.y+i.offsetY,(i.around||i.origin)&&(ra(i.around||i.origin,t.boxBounds,aa),na(e,-aa.x,-aa.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:la,updateAllMatrix:da}=Uo,{updateBounds:ca}=nr,{toOuterOf:ua,copyAndSpread:_a,copy:pa}=Rt,{toBounds:ga}=mn,fa={__updateWorldBounds(){const t=this.__layout;ua(t.renderBounds,this.__world,this.__world),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Sr.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Sr.emitWorld(this)},__updateLocalBounds(){const t=this.__layout;t.boxChanged&&(this.__.__pathInputed||this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),t.resized="inner"),t.localBoxChanged&&(this.__local&&this.__updateLocalBoxBounds(),t.localBoxChanged=void 0,t.strokeSpread&&(t.strokeChanged=!0),t.renderSpread&&(t.renderChanged=!0),this.parent&&this.parent.__layout.boxChange()),t.boxChanged=void 0,t.strokeChanged&&(t.strokeSpread=this.__updateStrokeSpread(),t.strokeSpread?(t.strokeBounds===t.boxBounds&&t.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):t.spreadStrokeCancel(),t.strokeChanged=void 0,(t.renderSpread||t.strokeSpread!==t.strokeBoxSpread)&&(t.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),t.resized="inner"),t.renderChanged&&(t.renderSpread=this.__updateRenderSpread(),t.renderSpread?(t.renderBounds!==t.boxBounds&&t.renderBounds!==t.strokeBounds||t.spreadRender(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):t.spreadRenderCancel(),t.renderChanged=void 0,this.parent&&this.parent.__layout.renderChange()),t.resized||(t.resized="local"),t.boundsChanged=void 0},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),ua(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){ua(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){ua(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?ga(s.path,i):(i.x=0,i.y=0,i.width=s.width,i.height=s.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.__extraUpdate(),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),da(this),ca(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(da(this),ca(this,this))):la(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;_a(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout;e.renderSpread>0?_a(e.renderBounds,e.boxBounds,e.renderSpread):pa(e.renderBounds,e.strokeBounds)}},ma={__render(t,e){if(e.shape)return this.__renderShape(t,e);if(this.__worldOpacity){const i=this.__;if(i.bright&&!e.topRendering)return e.topList.add(this);if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=e.dimOpacity&&!i.dimskip?i.opacity*e.dimOpacity:i.opacity,this.__.__single){if("path"===i.eraser)return this.__renderEraser(t,e);const s=t.getSameCanvas(!0,!0);this.__draw(s,e,t),Uo.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);It.showBounds&&It.drawBounds(this,t,e)}},__renderShape(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawShape(t,e))},__clip(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawRenderPath(t),t.clipUI(this))},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{excludeRenderBounds:ya}=tr,va={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__nowWorld=this.__getNowWorld(e),this.__worldOpacity){const i=this.__;if(i.__useDim)if(i.dim)e.dimOpacity=!0===i.dim?.2:i.dim;else{if(i.bright&&!e.topRendering)return e.topList.add(this);i.dimskip&&e.dimOpacity&&(e.dimOpacity=0)}if(i.__single&&!this.isBranchLeaf){if("path"===i.eraser)return this.__renderEraser(t,e);const s=t.getSameCanvas(!1,!0);this.__renderBranch(s,e);const n=this.__nowWorld;t.opacity=e.dimOpacity?i.opacity*e.dimOpacity:i.opacity,t.copyWorldByReset(s,n,n,i.__blendMode,!0),s.recycle(n)}else this.__renderBranch(t,e)}},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{const{children:i}=this;for(let s=0,n=i.length;s<n;s++)ya(i[s],e)||i[s].__render(t,e)}},__clip(t,e){if(this.__worldOpacity){const{children:i}=this;for(let s=0,n=i.length;s<n;s++)ya(i[s],e)||i[s].__clip(t,e)}}},wa={},{LEAF:xa,create:ba}=e,{toInnerPoint:ka,toOuterPoint:Ea,multiplyParent:Sa}=I,{toOuterOf:Ba}=Rt,{copy:Ta,move:Ra}=K,{moveLocal:Ca,zoomOfLocal:Oa,rotateOfLocal:La,skewOfLocal:Pa,moveWorld:Aa,zoomOfWorld:Ma,rotateOfWorld:Da,skewOfWorld:Fa,transform:Ia,transformWorld:Wa,setTransform:za,getFlipTransform:Na,getLocalOrigin:Ya,getRelativeWorld:Ha,drop:Xa}=Uo;let Va=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return y}get __LayoutProcessor(){return yr}get leaferIsCreated(){return this.leafer&&this.leafer.created}get leaferIsReady(){return this.leafer&&this.leafer.ready}get isLeafer(){return!1}get isBranch(){return!1}get isBranchLeaf(){return!1}get __localMatrix(){return this.__local||this.__layout}get __localBoxBounds(){return this.__local||this.__layout}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get scrollWorldTransform(){return this.updateLayout(),this.__scrollWorld||this.__world}get boxBounds(){return this.getBounds("box","inner")}get renderBounds(){return this.getBounds("render","inner")}get worldBoxBounds(){return this.getBounds("box")}get worldStrokeBounds(){return this.getBounds("stroke")}get worldRenderBounds(){return this.getBounds("render")}get worldOpacity(){return this.updateLayout(),this.__worldOpacity}get __worldFlipped(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}get __inLazyBounds(){return this.leaferIsCreated&&this.leafer.lazyBounds.hit(this.__world)}get pathInputed(){return this.__.__pathInputed}set event(t){this.on(t)}constructor(t){this.innerId=ba(xa),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(wr.CREATED)}reset(t){this.leafer&&this.leafer.forceRender(this.__world),0!==t&&(this.__world={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0,scaleX:1,scaleY:1},null!==t&&(this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0})),this.__worldOpacity=1,this.__=new this.__DataProcessor(this),this.__layout=new this.__LayoutProcessor(this),this.__level&&this.resetCustom(),t&&(t.__&&(t=t.toJSON()),t.children?this.set(t):Object.assign(this,t))}resetCustom(){this.__hasMask=this.__hasEraser=null,this.forceUpdate()}waitParent(t,e){e&&(t=t.bind(e)),this.parent?t():this.on(wr.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(wr.MOUNTED,t,"once")}nextRender(t,e,i){this.leafer?this.leafer.nextRender(t,e,i):this.waitLeafer(()=>this.leafer.nextRender(t,e,i))}removeNextRender(t){this.nextRender(t,null,"off")}__bindLeafer(t){if(this.isLeafer&&null!==t&&(t=this),this.leafer&&!t&&this.leafer.leafs--,this.leafer=t,t?(t.leafs++,this.__level=this.parent?this.parent.__level+1:1,this.animation&&this.__runAnimation("in"),this.__bubbleMap&&this.__emitLifeEvent(wr.MOUNTED)):this.__emitLifeEvent(wr.UNMOUNTED),this.isBranch){const{children:e}=this;for(let i=0,s=e.length;i<s;i++)e[i].__bindLeafer(t)}}set(t,e){}get(t){}setAttr(t,e){this[t]=e}getAttr(t){return this[t]}getComputedAttr(t){return this.__[t]}toJSON(t){return t&&this.__layout.update(),this.__.__getInputData(null,t)}toString(t){return JSON.stringify(this.toJSON(t))}toSVG(){}__SVG(t){}toHTML(){}__setAttr(t,e){return!0}__getAttr(t){}setProxyAttr(t,e){}getProxyAttr(t){}find(t,e){}findTag(t){}findOne(t,e){}findId(t){}focus(t){}updateState(){}updateLayout(){this.__layout.update()}forceUpdate(t){o(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=o(e)?null:void 0,this[t]=e}forceRender(t,e){this.forceUpdate("surface")}__extraUpdate(){this.leaferIsReady&&this.leafer.layouter.addExtra(this)}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(t,e){}__updateContentBounds(){}__updateStrokeBounds(t){}__updateRenderBounds(t){}__updateAutoLayout(){}__updateFlowLayout(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){this.__hasEraser=!!t||this.children.some(t=>t.__.eraser)}__renderEraser(t,e){t.save(),this.__clip(t,e);const{renderBounds:i}=this.__layout;t.clearRect(i.x,i.y,i.width,i.height),t.restore()}__updateMask(t){this.__hasMask=this.children.some(t=>t.__.mask&&t.__.visible&&t.__.opacity)}__renderMask(t,e){}__getNowWorld(t){if(t.matrix){this.__cameraWorld||(this.__cameraWorld={});const e=this.__cameraWorld,i=this.__world;return Sa(i,t.matrix,e,void 0,i),Ba(this.__layout.renderBounds,e,e),e.half!==i.half&&(e.half=i.half),e}return this.__world}getClampRenderScale(){let{scaleX:t}=this.__nowWorld||this.__world;return t<0&&(t=-t),t>1?t:1}getRenderScaleData(t,e){let{scaleX:i,scaleY:s}=In.patternLocked?this.__world:this.__nowWorld;return t&&(i<0&&(i=-i),s<0&&(s=-s)),(!0===e||"zoom-in"===e&&i>1&&s>1)&&(i=s=1),wa.scaleX=i,wa.scaleY=s,wa}getTransform(t){return this.__layout.getTransform(t||"local")}getBounds(t,e){return this.__layout.getBounds(t,e)}getLayoutBounds(t,e,i){return this.__layout.getLayoutBounds(t,e,i)}getLayoutPoints(t,e){return this.__layout.getLayoutPoints(t,e)}getWorldBounds(t,e,i){const s=e?Ha(this,e):this.worldTransform,n=i?t:{};return Ba(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&Ta(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&Ta(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),ka(this.scrollWorldTransform,t,e,i)}innerToWorld(t,e,i,s){Ea(this.scrollWorldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getBoxPoint(t,e,i,s){return this.getBoxPointByInner(this.getInnerPoint(t,e,i,s),null,null,!0)}getBoxPointByInner(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return Ra(n,-o,-r),n}getInnerPoint(t,e,i,s){const n=s?t:{};return this.worldToInner(t,n,i,e),n}getInnerPointByBox(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return Ra(n,o,r),n}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const n=s?t:{};return this.worldToLocal(t,n,i,e),n}getLocalPointByInner(t,e,i,s){return this.getWorldPoint(t,this.parent,i,s)}getPagePoint(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,i,s)}getWorldPoint(t,e,i,s){const n=s?t:{};return this.innerToWorld(t,n,i,e),n}getWorldPointByBox(t,e,i,s){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,s),e,i,!0)}getWorldPointByLocal(t,e,i,s){const n=s?t:{};return this.localToWorld(t,n,i,e),n}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e,i){za(this,t,e,i)}transform(t,e,i){Ia(this,t,e,i)}move(t,e,i){Ca(this,t,e,i)}moveInner(t,e,i){Aa(this,t,e,!0,i)}scaleOf(t,e,i,s,n){Oa(this,Ya(this,t),e,i,s,n)}rotateOf(t,e,i){La(this,Ya(this,t),e,i)}skewOf(t,e,i,s,n){Pa(this,Ya(this,t),e,i,s,n)}transformWorld(t,e,i){Wa(this,t,e,i)}moveWorld(t,e,i){Aa(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){Ma(this,t,e,i,s,n)}rotateOfWorld(t,e){Da(this,t,e)}skewOfWorld(t,e,i,s,n){Fa(this,t,e,i,s,n)}flip(t,e){Ia(this,Na(this,t),!1,e)}scaleResize(t,e=t,i){this.scaleX*=t,this.scaleY*=e}__scaleResize(t,e){}resizeWidth(t){}resizeHeight(t){}hit(t,e){return!0}__hitWorld(t){return!0}__hit(t){return!0}__hitFill(t){return!0}__hitStroke(t,e){return!0}__hitPixel(t){return!0}__drawHitPath(t){}__updateHitCanvas(){}__render(t,e){}__drawFast(t,e){}__draw(t,e,i){}__clip(t,e){}__renderShape(t,e){}__drawShape(t,e){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return Vt.need("path")}getMotionPoint(t){return Vt.need("path")}getMotionTotal(){return 0}__updateMotionPath(){}__runAnimation(t,e){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}dropTo(t,e,i){Xa(this,t,e,i)}on(t,e,i){}off(t,e,i){}on_(t,e,i,s){}off_(t){}once(t,e,i,s){}emit(t,e,i){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,i){i?this.addAttr(t,e,i):So(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=io),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new wr(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(wr.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}};Va=Qt([Po(ea),Po(ha),Po(fa),Po(Qr),Po(ma)],Va);const{setListWithFn:ja}=Rt,{sort:Ua}=nr,{localBoxBounds:Ga,localStrokeBounds:Ka,localRenderBounds:qa,maskLocalBoxBounds:Za,maskLocalStrokeBounds:Ja,maskLocalRenderBounds:$a}=tr,Qa=new It("Branch");let th=class extends Va{__updateStrokeSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(t,e){ja(e||this.__layout.boxBounds,this.children,this.__hasMask?Za:Ga)}__updateStrokeBounds(t){ja(t||this.__layout.strokeBounds,this.children,this.__hasMask?Ja:Ka)}__updateRenderBounds(t){ja(t||this.__layout.renderBounds,this.children,this.__hasMask?$a:qa)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let i=0,s=e.length;i<s;i++)e[i].__tempNumber=i,e[i].__.zIndex&&(t=!0);e.sort(Ua),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return Qa.warn("add self or destroyed");const i=o(e);if(!t.__){if(u(t))return t.forEach(t=>{this.add(t,e),i||e++});t=Gt.get(t.tag,t)}t.parent&&t.parent.remove(t),t.parent=this,i?this.children.push(t):this.children.splice(e,0,t),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1);const s=t.__layout;s.boxChanged||s.boxChange(),s.matrixChanged||s.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(wr.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(wr.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}addMany(...t){this.add(t)}remove(t,e){t?t.__?t.animationOut?t.__runAnimation("out",()=>this.__remove(t,e)):this.__remove(t,e):this.find(t).forEach(t=>this.remove(t,e)):o(t)&&super.remove(null,e)}removeAll(t){const{children:e}=this;e.length&&(this.children=[],this.__preRemove(),this.__.__childBranchNumber=0,e.forEach(e=>{this.__realRemoveChild(e),t&&e.destroy()}))}clear(){this.removeAll(!0)}__remove(t,e){const i=this.children.indexOf(t);i>-1&&(this.children.splice(i,1),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),this.__preRemove(),this.__realRemoveChild(t),e&&t.destroy())}__preRemove(){this.__hasMask&&this.__updateMask(),this.__hasEraser&&this.__updateEraser(),this.__layout.boxChange(),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}__realRemoveChild(t){t.__emitLifeEvent(wr.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(wr.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new wr(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}};th=Qt([Po(va)],th);class eh{get length(){return this.list.length}constructor(t){this.reset(),t&&(u(t)?this.addList(t):this.add(t))}has(t){return t&&!o(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return o(e)?-1:e}add(t){const{list:e,keys:i}=this;o(i[t.innerId])&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(o(i[t.innerId])){const{list:s}=this;for(let t=e,n=s.length;t<n;t++)i[s[t].innerId]++;0===e?s.unshift(t):(e>s.length&&(e=s.length),s.splice(e,0,t)),i[t.innerId]=e}}addList(t){for(let e=0;e<t.length;e++)this.add(t[e])}remove(t){const{list:e}=this;let i;for(let s=0,n=e.length;s<n;s++)o(i)?e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]):this.keys[e[s].innerId]=s-1;o(i)||e.splice(i,1)}sort(t){const{list:e}=this;t?e.sort((t,e)=>e.__level-t.__level):e.sort((t,e)=>t.__level-e.__level)}forEach(t){this.list.forEach(t)}clone(){const t=new eh;return t.list=[...this.list],t.keys=Object.assign({},this.keys),t}update(){this.keys={};const{list:t,keys:e}=this;for(let i=0,s=t.length;i<s;i++)e[t[i].innerId]=i}reset(){this.list=[],this.keys={}}destroy(){this.reset()}}class ih{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(u(t)?this.addList(t):this.add(t))}has(t){return!o(this.keys[t.innerId])}without(t){return o(this.keys[t.innerId])}sort(t){const{levels:e}=this;t?e.sort((t,e)=>e-t):e.sort((t,e)=>t-e)}addList(t){t.forEach(t=>{this.add(t)})}add(t){const{keys:e,levelMap:i}=this;e[t.innerId]||(e[t.innerId]=1,i[t.__level]?i[t.__level].push(t):(i[t.__level]=[t],this.levels.push(t.__level)),this._length++)}forEach(t){let e;this.levels.forEach(i=>{e=this.levelMap[i];for(let i=0,s=e.length;i<s;i++)t(e[i])})}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}}const sh="1.9.7";class nh extends pe{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}Rn(OffscreenCanvasRenderingContext2D.prototype),Rn(Path2D.prototype);const{mineType:oh}=Cn;function rh(e,i){t.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:oh(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:oh(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:e=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",t.image.getRealURL(e),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},t.canvas=jt.canvas(),t.conicGradientSupport=!!t.canvas.context.createConicGradient}Object.assign(jt,{canvas:(t,e)=>new nh(t,e),image:t=>new Xn(t)}),t.name="web",t.isWorker=!0,t.backgrounder=!0,t.requestRender=function(t){requestAnimationFrame(t)},Vn(t,"devicePixelRatio",{get:()=>1});const{userAgent:ah}=navigator;ah.indexOf("Firefox")>-1?(t.conicGradientRotate90=!0,t.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.fullImageShadow=!0),ah.indexOf("Windows")>-1?(t.os="Windows",t.intWheelDeltaY=!0):ah.indexOf("Mac")>-1?t.os="Mac":ah.indexOf("Linux")>-1&&(t.os="Linux");class hh{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new eh;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new eh,this.target=t,e&&(this.config=f.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(Mr.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===wr.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new Pr(Pr.DATA,{updatedList:this.updatedList})),this.__updatedList=new eh,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[br.CHANGE,this.__onAttrChange,this],[[wr.ADD,wr.REMOVE],this.__onChildEvent,this],[Pr.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:lh,updateBounds:dh,updateChange:ch}=Uo,{pushAllChildBranch:uh,pushAllParent:_h}=nr;const{worldBounds:ph}=tr;class gh{constructor(t){this.updatedBounds=new Pt,this.beforeBounds=new Pt,this.afterBounds=new Pt,u(t)&&(t=new eh(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ph)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ph),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:fh,updateAllChange:mh}=Uo,yh=It.get("Layouter");class vh{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new ih,this.target=t,e&&(this.config=f.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(Ar.START),this.layoutOnce(),t.emitEvent(new Ar(Ar.END,this.layoutedBlocks,this.times))}catch(t){yh.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?yh.warn("layouting"):this.times>3?yh.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Pr.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=Yt.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=Ar,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new Ar(n,a,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(lh(t,!0),e.add(t),t.isBranch&&uh(t,e),_h(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),_h(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||dh(s[t])}dh(i)}})}(this.__levelList),function(t){t.list.forEach(ch)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new Ar(o,a,this.times)),i.emitEvent(new Ar(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,Yt.end(e)}fullLayout(){const t=Yt.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=Ar,o=this.getBlocks(new eh(e));e.emitEvent(new Ar(i,o,this.times)),vh.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new Ar(s,o,this.times)),e.emitEvent(new Ar(n,o,this.times)),this.addBlocks(o),Yt.end(t)}static fullLayout(t){fh(t,!0),t.isBranch?nr.updateBounds(t):Uo.updateBounds(t),mh(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new gh([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new gh(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[Ar.REQUEST,this.layout,this],[Ar.AGAIN,this.layoutAgain,this],[Pr.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const wh=It.get("Renderer");class xh{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.target=t,this.canvas=e,i&&(this.config=f.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(Ar.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(Mr.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(Mr.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(Mr.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new Pt,wh.log(e.innerName,"---\x3e");try{this.emitRender(Mr.START),this.renderOnce(t),this.emitRender(Mr.END,this.totalBounds),In.clearRecycled()}catch(t){this.rendering=!1,wh.error(t)}wh.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return wh.warn("rendering");if(this.times>3)return wh.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new Pt,this.renderOptions={},t)this.emitRender(Mr.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Mr.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Mr.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Mr.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=Yt.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new Pt(s);i.save(),s.spread(xh.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),Yt.end(e)}fullRender(){const t=Yt.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),Yt.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),It.showRepaint&&It.drawRepaint(s,e),t.render(this.target,s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new Pt;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const i=this.requestTime=Date.now(),s=()=>{const e=1e3/(Date.now()-i),{maxFPS:n}=this.config;if(n&&e>n-.5)return t.requestRender(s);this.FPS=Math.min(120,Math.ceil(e)),this.requestTime=0,this.checkRender()};t.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new Pt(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new Pt(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||wh.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new Mr(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[Mr.REQUEST,this.update,this],[Ar.END,this.__onLayoutEnd,this],[Mr.AGAIN,this.renderAgain,this],[Lr.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}xh.clipSpread=10;const{hitRadiusPoint:bh}=Rt;class kh{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new eh(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new eh;if(t.length){let e;const{x:n,y:o}=this.point,r={x:n,y:o,radiusX:0,radiusY:0};for(let n=0,o=t.length;n<o;n++)if(e=t[n],(i||Uo.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&Uo.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return i?t[0]:t.find(t=>Uo.worldHittable(t))}getPath(t){const e=new eh;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new eh;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new eh,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||bh(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Eh{constructor(t,e){this.config={},e&&(this.config=f.default(e,this.config)),this.picker=new kh(this.target=t,this),this.finder=jt.finder&&jt.finder()}getByPoint(e,i,s){const{target:n,picker:o}=this;return t.backgrounder&&n&&n.updateLayout(),o.getByPoint(e,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):Vt.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Sh(t){return Gn(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Bh(t){return Gn(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}function Th(){return(t,e)=>{const i="_"+e;Vn(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}function Rh(t){return(e,i)=>{Vn(e,i,Un(i,t))}}Object.assign(jt,{watcher:(t,e)=>new hh(t,e),layouter:(t,e)=>new vh(t,e),renderer:(t,e,i)=>new xh(t,e,i),selector:(t,e)=>new Eh(t,e)}),t.layout=vh.fullLayout,t.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new eh,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const Ch={},Oh={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},Lh={number:(t,e)=>_(t)?"percent"===t.type?t.value*e:t.value:t},Ph={},Ah={},Mh={},Dh={},Fh={},Ih={apply(){Vt.need("filter")}},Wh={},zh={setStyleName:()=>Vt.need("state"),set:()=>Vt.need("state")},Nh={list:{},register(t,e){Nh.list[t]=e},get:t=>Nh.list[t]},{parse:Yh,objectToCanvasData:Hh}=Ii,{stintSet:Xh}=f,{hasTransparent:Vh}=Oh,jh={},Uh=It.get("UIData");class Gh extends y{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){return this.__getRealStrokeWidth()}get __maxStrokeWidth(){const t=this;return t.__hasMultiStrokeStyle?Math.max(t.__hasMultiStrokeStyle,t.strokeWidth):t.strokeWidth}get __hasMultiPaint(){const t=this;return t.fill&&this.__useStroke||t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,Uh.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,Uh.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),a(t)||!t?(Xh(this,"__isTransparentFill",Vh(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):_(t)&&this.__setPaint("fill",t)}setStroke(t){a(t)||!t?(Xh(this,"__isTransparentStroke",Vh(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):_(t)&&this.__setPaint("stroke",t)}setPath(t){const e=a(t);e||t&&_(t[0])?(this.__setInput("path",t),this._path=e?Yh(t):Hh(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){Kh(this,"shadow",t)}setInnerShadow(t){Kh(this,"innerShadow",t)}setFilter(t){Kh(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&Ah.compute("fill",this.__leaf),e&&Ah.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeWidthFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),o(t.strokeWidthFixed)||(i=t.strokeWidthFixed)),i){const t=this.__leaf.getClampRenderScale();return t>1?e/t:e}return e}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),u(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=jh)):(this.__isStrokes=!0,this._stroke||(this._stroke=jh))}__removePaint(t,e){e&&this.__removeInput(t),Mh.recycleImage(t,this),"fill"===t?(Xh(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(Xh(this,"__isAlphaPixelStroke",void 0),Xh(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function Kh(t,e,i){t.__setInput(e,i),u(i)?(i.some(t=>!1===t.visible)&&(i=i.filter(t=>!1!==t.visible)),i.length||(i=void 0)):i=i&&!1!==i.visible?[i]:void 0,t["_"+e]=i}class qh extends Gh{}class Zh extends qh{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return this.__single||this.__clipAfterFill}get __clipAfterFill(){const t=this;return"show"!==t.overflow&&t.__leaf.children.length&&(t.__leaf.isOverflow||super.__clipAfterFill)}}class Jh extends qh{__getInputData(t,e){const i=super.__getInputData(t,e);return _e.forEach(t=>delete i[t]),i}}class $h extends Zh{}class Qh extends Gh{get __usePathBox(){return this.points||this.__pathInputed}}class tl extends Gh{get __boxStroke(){return!this.__pathInputed}}class el extends Gh{get __boxStroke(){return!this.__pathInputed}}class il extends Qh{}class sl extends Gh{}class nl extends Gh{get __pathInputed(){return 2}}class ol extends qh{}const rl={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class al extends Gh{get __useNaturalRatio(){return!1}setFontWeight(t){a(t)?(this.__setInput("fontWeight",t),t=rl[t]||400):this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=Gt.get("Rect",0);const n=e.__layout,o=i.__layout;s||(i.parent=e,i.__world=e.__world,o.boxBounds=n.boxBounds),i.set(t),o.strokeChanged&&n.strokeChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}}class hl extends tl{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class ll extends tl{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const dl={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:n}=i,o=this.__box;if((i.stroke||"all"===i.hitStroke)&&n&&"inside"!==s&&(e=t="center"===s?n/2:n,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:n;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*n),o&&(t=Math.max(o.__layout.strokeSpread=o.__updateStrokeSpread(),t),e=o.__layout.strokeBoxSpread),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n,filter:o,renderSpread:r}=this.__;e&&(t=Fh.getShadowSpread(this,e)),s&&(t=Math.max(t,s)),o&&(t+=Ih.getSpread(o)),r&&(t+=r);let a=t=Math.ceil(t);return i&&i.forEach(t=>a=Math.max(a,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)),n&&(a=Math.max(a,n)),this.__layout.renderShapeSpread=a,t+=this.__layout.strokeSpread||0,this.__box?Math.max(this.__box.__updateRenderSpread(),t):t}},{float:cl}=b,ul=new Pt,_l=new Pt,pl=new Pt,gl={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&fl.getValidMove(t.__localBoxBounds,fl.getDragBounds(t),s,e,!0),fl.axisMove(t,e)},limitScaleOf(t,e,i){const{dragBounds:s,dragBoundsType:n}=t;s&&fl.getValidScaleOf(t.__localBoxBounds,fl.getDragBounds(t),n,t.getLocalPointByInner(t.getInnerPointByBox(e)),i,!0)},axisMove(t,e){const{draggable:i}=t;"x"===i&&(e.y=0),"y"===i&&(e.x=0)},getDragBounds(t){const{dragBounds:e}=t;return"parent"===e?t.parent.boxBounds:e},isInnerMode:(t,e,i,s)=>"inner"===i||"auto"===i&&t[s]>e[s],getValidMove(t,e,i,s,n){const o=t.x+s.x,r=t.y+s.y,a=o+t.width,h=r+t.height,l=e.x+e.width,d=e.y+e.height;return n||(s=Object.assign({},s)),fl.isInnerMode(t,e,i,"width")?o>e.x?s.x+=e.x-o:a<l&&(s.x+=l-a):o<e.x?s.x+=e.x-o:a>l&&(s.x+=l-a),fl.isInnerMode(t,e,i,"height")?r>e.y?s.y+=e.y-r:h<d&&(s.y+=d-h):r<e.y?s.y+=e.y-r:h>d&&(s.y+=d-h),s.x=cl(s.x),s.y=cl(s.y),s},getValidScaleOf(t,e,i,s,n,o){let r,a;return o||(n=Object.assign({},n)),ul.set(t).scaleOf(s,n.x,n.y).unsign(),_l.set(ul).add(e),pl.set(ul).intersect(e),r=fl.isInnerMode(t,e,i,"width")?_l.width/ul.width:pl.width/ul.width,a=fl.isInnerMode(t,e,i,"height")?_l.height/ul.height:pl.height/ul.height,n.x=cl(pl.width)?n.x*r:1,n.y=cl(pl.height)?n.y*a:1,n}},fl=gl,{stintSet:ml}=f,yl={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);ml(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),ml(t,"__fillAfterStroke",e&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill)}if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,n=t.innerShadow||t.blur||t.backgroundBlur||t.filter;ml(t,"__isFastShadow",e&&!n&&e.length<2&&!e[0].spread&&!Fh.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(u(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!n)}t.__checkSingle(),ml(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){vl(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:n,stroke:o,__drawAfterFill:r,__fillAfterStroke:a,__isFastShadow:h}=s;if(this.__drawRenderPath(t),s.__useEffect&&!h){const h=Ah.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&Fh.shadow(this,t,h),a&&(s.__isStrokes?Ah.strokes(o,this,t):Ah.stroke(o,this,t)),n&&(s.__isFills?Ah.fills(n,this,t):Ah.fill(n,this,t)),r&&this.__drawAfterFill(t,e),d&&Fh.innerShadow(this,t,h),o&&!a&&(s.__isStrokes?Ah.strokes(o,this,t):Ah.stroke(o,this,t)),c&&Ih.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?Ah.strokes(o,this,t):Ah.stroke(o,this,t)),h){const e=s.shadow[0],{scaleX:i,scaleY:n}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*n,e.blur*i,Oh.string(e.color))}n&&(s.__isFills?Ah.fills(n,this,t):Ah.fill(n,this,t)),h&&t.restore(),r&&this.__drawAfterFill(t,e),o&&!a&&(s.__isStrokes?Ah.strokes(o,this,t):Ah.stroke(o,this,t))}}else s.__pathInputed?vl(this,t,e):this.__drawFast(t,e)},__drawShape(t,e){this.__drawRenderPath(t);const i=this.__,{fill:s,stroke:n}=i;s&&!e.ignoreFill&&(i.__isAlphaPixelFill?Ah.fills(s,this,t):Ah.fill("#000000",this,t)),i.__isCanvas&&this.__drawAfterFill(t,e),n&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?Ah.strokes(n,this,t):Ah.stroke("#000000",this,t))},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),t.clipUI(this),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function vl(t,e,i){const{fill:s,stroke:n,__drawAfterFill:o,__fillAfterStroke:r}=t.__;t.__drawRenderPath(e),r&&Ah.stroke(n,t,e),s&&Ah.fill(s,t,e),o&&t.__drawAfterFill(e,i),n&&!r&&Ah.stroke(n,t,e)}const wl={__drawFast(t,e){let{x:i,y:s,width:n,height:o}=this.__layout.boxBounds;const{fill:r,stroke:a,__drawAfterFill:h}=this.__;if(r&&(t.fillStyle=r,t.fillRect(i,s,n,o)),h&&this.__drawAfterFill(t,e),a){const{strokeAlign:r,__strokeWidth:h}=this.__;if(!h)return;t.setStroke(a,h,this.__);const l=h/2;switch(r){case"center":t.strokeRect(0,0,n,o);break;case"inside":n-=h,o-=h,n<0||o<0?(t.save(),this.__clip(t,e),t.strokeRect(i+l,s+l,n,o),t.restore()):t.strokeRect(i+l,s+l,n,o);break;case"outside":t.strokeRect(i-l,s-l,n+h,o+h)}}}};var xl;let bl=xl=class extends Va{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){b.assignScale(this,t)}get scale(){return this.__.scale}get isAutoWidth(){const t=this.__;return t.__autoWidth||t.autoWidth}get isAutoHeight(){const t=this.__;return t.__autoHeight||t.autoHeight}get pen(){const{path:t}=this.__;return Bn.set(this.path=t||[]),t||this.__drawPathByBox(Bn),Bn}reset(t){}set(t,e){t&&Object.assign(this,t)}get(t){return a(t)?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return Vt.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return Vt.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(Bn.set(i=[]),this.__drawPathByBox(Bn)),t?Ii.toCanvasData(i,!0):i}getPathString(t,e,i){return Ii.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Wh.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?En.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Ph.addArrows(this)):t.__pathForRender&&(t.__pathForRender=void 0)}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?Ws.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:n}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:o}=this.__;t.roundRect(e,i,s,n,l(o)?[o]:o)}else t.rect(e,i,s,n)}drawImagePlaceholder(t,e){Ah.fill(this.__.placeholderColor,this,t)}animate(t,e,i,s){return this.set(t),Vt.need("animate")}killAnimate(t,e){}export(t,e){return Vt.need("export")}syncExport(t,e){return Vt.need("export")}clone(t){const e=f.clone(this.toJSON());return t&&Object.assign(e,t),xl.one(e)}static one(t,e,i,s,n){return Gt.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){Ao()(this)}static registerData(t){ko(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};Qt([ko(Gh)],bl.prototype,"__",void 0),Qt([Th()],bl.prototype,"zoomLayer",void 0),Qt([Zn("")],bl.prototype,"id",void 0),Qt([Zn("")],bl.prototype,"name",void 0),Qt([Zn("")],bl.prototype,"className",void 0),Qt([uo("pass-through")],bl.prototype,"blendMode",void 0),Qt([po(1)],bl.prototype,"opacity",void 0),Qt([go(!0)],bl.prototype,"visible",void 0),Qt([uo(!1)],bl.prototype,"locked",void 0),Qt([_o(!1)],bl.prototype,"dim",void 0),Qt([_o(!1)],bl.prototype,"dimskip",void 0),Qt([yo(0)],bl.prototype,"zIndex",void 0),Qt([vo(!1)],bl.prototype,"mask",void 0),Qt([wo(!1)],bl.prototype,"eraser",void 0),Qt([Jn(0,!0)],bl.prototype,"x",void 0),Qt([Jn(0,!0)],bl.prototype,"y",void 0),Qt([io(100,!0)],bl.prototype,"width",void 0),Qt([io(100,!0)],bl.prototype,"height",void 0),Qt([to(1,!0)],bl.prototype,"scaleX",void 0),Qt([to(1,!0)],bl.prototype,"scaleY",void 0),Qt([eo(0,!0)],bl.prototype,"rotation",void 0),Qt([eo(0,!0)],bl.prototype,"skewX",void 0),Qt([eo(0,!0)],bl.prototype,"skewY",void 0),Qt([Jn(0,!0)],bl.prototype,"offsetX",void 0),Qt([Jn(0,!0)],bl.prototype,"offsetY",void 0),Qt([$n(0,!0)],bl.prototype,"scrollX",void 0),Qt([$n(0,!0)],bl.prototype,"scrollY",void 0),Qt([Qn()],bl.prototype,"origin",void 0),Qt([Qn()],bl.prototype,"around",void 0),Qt([Zn(!1)],bl.prototype,"lazy",void 0),Qt([so(1)],bl.prototype,"pixelRatio",void 0),Qt([co(0)],bl.prototype,"renderSpread",void 0),Qt([oo()],bl.prototype,"path",void 0),Qt([ro()],bl.prototype,"windingRule",void 0),Qt([ro(!0)],bl.prototype,"closed",void 0),Qt([io(0)],bl.prototype,"padding",void 0),Qt([io(!1)],bl.prototype,"lockRatio",void 0),Qt([io()],bl.prototype,"widthRange",void 0),Qt([io()],bl.prototype,"heightRange",void 0),Qt([Zn(!1)],bl.prototype,"draggable",void 0),Qt([Zn()],bl.prototype,"dragBounds",void 0),Qt([Zn("auto")],bl.prototype,"dragBoundsType",void 0),Qt([Zn(!1)],bl.prototype,"editable",void 0),Qt([xo(!0)],bl.prototype,"hittable",void 0),Qt([xo("path")],bl.prototype,"hitFill",void 0),Qt([lo("path")],bl.prototype,"hitStroke",void 0),Qt([xo(!1)],bl.prototype,"hitBox",void 0),Qt([xo(!0)],bl.prototype,"hitChildren",void 0),Qt([xo(!0)],bl.prototype,"hitSelf",void 0),Qt([xo()],bl.prototype,"hitRadius",void 0),Qt([bo("")],bl.prototype,"cursor",void 0),Qt([uo()],bl.prototype,"fill",void 0),Qt([lo(void 0,!0)],bl.prototype,"stroke",void 0),Qt([lo("inside")],bl.prototype,"strokeAlign",void 0),Qt([lo(1,!0)],bl.prototype,"strokeWidth",void 0),Qt([lo(!1)],bl.prototype,"strokeWidthFixed",void 0),Qt([lo("none")],bl.prototype,"strokeCap",void 0),Qt([lo("miter")],bl.prototype,"strokeJoin",void 0),Qt([lo()],bl.prototype,"dashPattern",void 0),Qt([lo(0)],bl.prototype,"dashOffset",void 0),Qt([lo(10)],bl.prototype,"miterLimit",void 0),Qt([ro(0)],bl.prototype,"cornerRadius",void 0),Qt([ro()],bl.prototype,"cornerSmoothing",void 0),Qt([Sh()],bl.prototype,"shadow",void 0),Qt([Sh()],bl.prototype,"innerShadow",void 0),Qt([Sh()],bl.prototype,"blur",void 0),Qt([Sh()],bl.prototype,"backgroundBlur",void 0),Qt([Sh()],bl.prototype,"grayscale",void 0),Qt([Sh()],bl.prototype,"filter",void 0),Qt([uo()],bl.prototype,"placeholderColor",void 0),Qt([Zn(100)],bl.prototype,"placeholderDelay",void 0),Qt([Zn({})],bl.prototype,"data",void 0),Qt([Co(Va.prototype.reset)],bl.prototype,"reset",null),bl=xl=Qt([Po(dl),Po(yl),Oo()],bl);let kl=class extends bl{get __tag(){return"Group"}get isBranch(){return!0}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach(t=>this.add(t)),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return this.childlessJSON||(e.children=this.children.map(e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var El;Qt([ko(qh)],kl.prototype,"__",void 0),Qt([io(0)],kl.prototype,"width",void 0),Qt([io(0)],kl.prototype,"height",void 0),kl=Qt([Po(th),Ao()],kl);const Sl=It.get("Leafer");let Bl=El=class extends kl{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&Dn.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||{x:0,y:0,width:0,height:0}}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),El.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,f.assign(s,t));const n=this.canvas=jt.canvas(s);this.__controllers.push(this.renderer=jt.renderer(this,n,s),this.watcher=jt.watcher(this,s),this.layouter=jt.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(),this.view=n.view,e||(this.selector=jt.selector(this),this.interaction=jt.interaction(this,n,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=jt.hitCanvasManager()),this.canvasManager=new $t,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(n),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),hr.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit(()=>{super.set(t,e)})}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(Dr.RESTART):this.emitLeafer(Dr.START),this.__controllers.forEach(t=>t.start()),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach(t=>t.stop()),this.running=!1,this.emitLeafer(Dr.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=f.copyAttrs({},t,_e);Object.keys(e).forEach(t=>this[t]=e[t])}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new Pt(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=f.copyAttrs({},this.canvas,_e);e.resize(t),this.updateLazyBounds(),this.__onResize(new Lr(t,i))}__onResize(t){this.emitEvent(t),f.copyAttrs(this.__,t,_e),setTimeout(()=>{this.canvasManager&&this.canvasManager.clearRecycled()},0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(){const{config:t,parentApp:e}=this;e||(t.width&&t.height||(this.autoLayout=new Mt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(_e.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t?(this.canvas.zIndex=e,setTimeout(()=>this.parent&&this.parent.__updateSortChildren())):"mode"===t&&this.emit(Dr.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&_e.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,n=f.copyAttrs({},s,_e);n[t]=i[t]=e,i.width&&i.height?s.stopAutoLayout():this.__checkAutoLayout(),this.__doResize(n)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(Dr.BEFORE_READY),this.emitLeafer(Dr.READY),this.emitLeafer(Dr.AFTER_READY),hr.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Dr.VIEW_READY),hr.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:n,pixelRatio:o}=this;const r="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,r.x+r.width)),i||(n=Math.max(1,r.y+r.height)),this.__doResize({width:s,height:n,pixelRatio:o})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){hr.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender(()=>{this.imageReady&&(t&&this.emitLeafer(Dr.VIEW_COMPLETED),hr.run(this.__viewCompletedWait),this.viewCompleted=!0)})}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender(()=>this.interaction.updateCursor())}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return Vt.need("view")}getValidMove(t,e,i){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new Dr(t,this))}__listenEvents(){const t=Yt.start("FirstCreate "+this.innerName);this.once([[Dr.START,()=>Yt.end(t)],[Ar.START,this.updateLazyBounds,this],[Mr.START,this.__onCreated,this],[Mr.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Pr.DATA,this.__onWatchData,this],[Ar.END,this.__onLayoutEnd,this],[Mr.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){El.list.remove(this);try{this.stop(),this.emitLeafer(Dr.END),this.__removeListenEvents(),this.__controllers.forEach(t=>!(this.parent&&t===this.interaction)&&t.destroy()),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager&&this.canvasManager.destroy()),this.canvas&&this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout(()=>{In.clearRecycled()},100)}catch(t){Sl.error(t)}}};t?e():setTimeout(e)}};Bl.list=new eh,Qt([ko(Jh)],Bl.prototype,"__",void 0),Qt([io()],Bl.prototype,"pixelRatio",void 0),Qt([Zn("normal")],Bl.prototype,"mode",void 0),Bl=El=Qt([Ao()],Bl);let Tl=class extends bl{get __tag(){return"Rect"}};Qt([ko(tl)],Tl.prototype,"__",void 0),Tl=Qt([Po(wl),Oo(),Ao()],Tl);const{add:Rl,includes:Cl,scroll:Ol}=Rt,Ll=Tl.prototype,Pl=kl.prototype;let Al=class extends kl{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){if(this.children.length&&!this.pathInputed){const t=this.__;if(t.__autoSide){t.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:e}=this.__layout;t.__autoSize||(t.__autoWidth?(e.width+=e.x,e.x=0,e.height=t.height,e.y=0):(e.height+=e.y,e.y=0,e.width=t.width,e.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t,e;if(this.children.length){const i=this.__,s=this.__layout,{renderBounds:n,boxBounds:o}=s,{overflow:r}=i,a=s.childrenRenderBounds||(s.childrenRenderBounds={x:0,y:0,width:0,height:0});super.__updateRenderBounds(a),(e=r.includes("scroll"))&&(Rl(a,o),Ol(a,i)),this.__updateRectRenderBounds(),t=!Cl(o,a),t&&"show"===r&&Rl(n,a)}else this.__updateRectRenderBounds();f.stintSet(this,"isOverflow",t),this.__checkScroll(e)}__updateRectRenderBounds(){}__checkScroll(t){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e)),this.hasScroller&&this.scroller.__render(t,e)}__drawContent(t,e){this.__renderGroup(t,e),(this.__.__useStroke||this.__.__useEffect)&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};Qt([ko(Zh)],Al.prototype,"__",void 0),Qt([io(100)],Al.prototype,"width",void 0),Qt([io(100)],Al.prototype,"height",void 0),Qt([Zn(!1)],Al.prototype,"resizeChildren",void 0),Qt([co("show")],Al.prototype,"overflow",void 0),Qt([Co(Ll.__updateStrokeSpread)],Al.prototype,"__updateStrokeSpread",null),Qt([Co(Ll.__updateRenderSpread)],Al.prototype,"__updateRectRenderSpread",null),Qt([Co(Ll.__updateBoxBounds)],Al.prototype,"__updateRectBoxBounds",null),Qt([Co(Ll.__updateStrokeBounds)],Al.prototype,"__updateStrokeBounds",null),Qt([Co(Ll.__updateRenderBounds)],Al.prototype,"__updateRectRenderBounds",null),Qt([Co(Ll.__updateChange)],Al.prototype,"__updateRectChange",null),Qt([Co(Ll.__render)],Al.prototype,"__renderRect",null),Qt([Co(Pl.__render)],Al.prototype,"__renderGroup",null),Al=Qt([Oo(),Ao()],Al);let Ml=class extends Al{get __tag(){return"Frame"}get isFrame(){return!0}};Qt([ko($h)],Ml.prototype,"__",void 0),Qt([uo("#FFFFFF")],Ml.prototype,"fill",void 0),Qt([co("hide")],Ml.prototype,"overflow",void 0),Ml=Qt([Ao()],Ml);const{moveTo:Dl,closePath:Fl,ellipse:Il}=rs;let Wl=class extends bl{get __tag(){return"Ellipse"}__updatePath(){const{width:e,height:i,innerRadius:s,startAngle:n,endAngle:o}=this.__,r=e/2,a=i/2,h=this.__.path=[];s?(n||o?(s<1&&Il(h,r,a,r*s,a*s,0,n,o,!1),Il(h,r,a,r,a,0,o,n,!0),s<1&&Fl(h)):(s<1&&(Il(h,r,a,r*s,a*s),Dl(h,e,a)),Il(h,r,a,r,a,0,360,0,!0)),t.ellipseToCurve&&(this.__.path=this.getPath(!0))):n||o?(Dl(h,r,a),Il(h,r,a,r,a,0,n,o,!1),Fl(h)):Il(h,r,a,r,a)}};Qt([ko(el)],Wl.prototype,"__",void 0),Qt([ro(0)],Wl.prototype,"innerRadius",void 0),Qt([ro(0)],Wl.prototype,"startAngle",void 0),Qt([ro(0)],Wl.prototype,"endAngle",void 0),Wl=Qt([Ao()],Wl);const{sin:zl,cos:Nl,PI:Yl}=Math,{moveTo:Hl,lineTo:Xl,closePath:Vl,drawPoints:jl}=rs;let Ul=class extends bl{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)jl(e,t.points,t.curve,!0);else{const{width:i,height:s,sides:n}=t,o=i/2,r=s/2;Hl(e,o,0);for(let t=1;t<n;t++)Xl(e,o+o*zl(2*t*Yl/n),r-r*Nl(2*t*Yl/n));Vl(e)}}};Qt([ko(il)],Ul.prototype,"__",void 0),Qt([ro(3)],Ul.prototype,"sides",void 0),Qt([ro()],Ul.prototype,"points",void 0),Qt([ro(0)],Ul.prototype,"curve",void 0),Ul=Qt([Oo(),Ao()],Ul);const{sin:Gl,cos:Kl,PI:ql}=Math,{moveTo:Zl,lineTo:Jl,closePath:$l}=rs;let Ql=class extends bl{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,o=e/2,r=this.__.path=[];Zl(r,n,0);for(let t=1;t<2*i;t++)Jl(r,n+(t%2==0?n:n*s)*Gl(t*ql/i),o-(t%2==0?o:o*s)*Kl(t*ql/i));$l(r)}};Qt([ko(sl)],Ql.prototype,"__",void 0),Qt([ro(5)],Ql.prototype,"corners",void 0),Qt([ro(.382)],Ql.prototype,"innerRadius",void 0),Ql=Qt([Ao()],Ql);const{moveTo:td,lineTo:ed,drawPoints:id}=rs,{rotate:sd,getAngle:nd,getDistance:od,defaultPoint:rd}=K;let ad=class extends bl{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&sd(i,e),i}set toPoint(t){this.width=od(rd,t),this.rotation=nd(rd,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?id(e,t.points,t.curve,t.closed):(td(e,0,0),ed(e,this.width,0))}};Qt([ko(Qh)],ad.prototype,"__",void 0),Qt([ao("center")],ad.prototype,"strokeAlign",void 0),Qt([io(0)],ad.prototype,"height",void 0),Qt([ro()],ad.prototype,"points",void 0),Qt([ro(0)],ad.prototype,"curve",void 0),Qt([ro(!1)],ad.prototype,"closed",void 0),ad=Qt([Ao()],ad);let hd=class extends Tl{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return u(t)&&t[0].image}};Qt([ko(hl)],hd.prototype,"__",void 0),Qt([io("")],hd.prototype,"url",void 0),hd=Qt([Ao()],hd);const ld=hd;let dd=class extends Tl{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=jt.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new Xn({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Er(Er.LOADED,{image:t}))})}draw(t,e,i,s){const n=new et(t.worldTransform).invert(),o=new et;e&&o.translate(e.x,e.y),i&&(l(i)?o.scale(i):o.scale(i.x,i.y)),s&&o.rotate(s),n.multiplyParent(o),t.__render(this.canvas,{matrix:n.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:n}=this.canvas;t.drawImage(n,0,0,n.width,n.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null),super.destroy()}};Qt([ko(ll)],dd.prototype,"__",void 0),Qt([Bh(100)],dd.prototype,"width",void 0),Qt([Bh(100)],dd.prototype,"height",void 0),Qt([Bh(1)],dd.prototype,"pixelRatio",void 0),Qt([Bh(!0)],dd.prototype,"smooth",void 0),Qt([Zn(!1)],dd.prototype,"safeResize",void 0),Qt([Bh()],dd.prototype,"contextSettings",void 0),dd=Qt([Ao()],dd);const{copyAndSpread:cd,includes:ud,spread:_d,setList:pd}=Rt;let gd=class extends bl{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:n,fontWeight:o,italic:r,textCase:a,textOverflow:h,padding:l}=t;t.__lineHeight=Lh.number(e,n),t.__letterSpacing=Lh.number(i,n),t.__padding=l?b.fourNumber(l):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*n)/2,t.__font=`${r?"italic ":""}${"small-caps"===a?"small-caps ":""}${"normal"!==o?o+" ":""}${n||12}px ${s||"caption"}`,t.__clipText="show"!==h&&!t.__autoSize,t.__textDrawData=Ch.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:n,__autoWidth:o,__autoHeight:r}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=a,t.__lineHeight<i&&_d(a,i/2),o||r){if(h.x=o?a.x:0,h.y=r?a.y:0,h.width=o?a.width:t.width,h.height=r?a.height:t.height,n){const[e,i,s,n]=t.__padding;o&&(h.x-=n,h.width+=i+n),r&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),f.stintSet(this,"isOverflow",!ud(h,a)),this.isOverflow?(pd(t.__textBoxBounds={},[h,a]),e.renderChanged=!0):t.__textBoxBounds=h}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;cd(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__updateChange(){super.__updateChange();const t=this.__box;t&&(t.__onUpdateSize(),t.__updateChange())}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!e.exporting||super.__draw(t,e,i)}__drawShape(t,e){e.shape&&this.__box&&this.__box.__drawShape(t,e),super.__drawShape(t,e)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}};Qt([ko(al)],gd.prototype,"__",void 0),Qt([io(0)],gd.prototype,"width",void 0),Qt([io(0)],gd.prototype,"height",void 0),Qt([uo()],gd.prototype,"boxStyle",void 0),Qt([Zn(!1)],gd.prototype,"resizeFontSize",void 0),Qt([uo("#000000")],gd.prototype,"fill",void 0),Qt([ao("outside")],gd.prototype,"strokeAlign",void 0),Qt([xo("all")],gd.prototype,"hitFill",void 0),Qt([io("")],gd.prototype,"text",void 0),Qt([io("")],gd.prototype,"placeholder",void 0),Qt([io("caption")],gd.prototype,"fontFamily",void 0),Qt([io(12)],gd.prototype,"fontSize",void 0),Qt([io("normal")],gd.prototype,"fontWeight",void 0),Qt([io(!1)],gd.prototype,"italic",void 0),Qt([io("none")],gd.prototype,"textCase",void 0),Qt([io("none")],gd.prototype,"textDecoration",void 0),Qt([io(0)],gd.prototype,"letterSpacing",void 0),Qt([io({type:"percent",value:1.5})],gd.prototype,"lineHeight",void 0),Qt([io(0)],gd.prototype,"paraIndent",void 0),Qt([io(0)],gd.prototype,"paraSpacing",void 0),Qt([io("x")],gd.prototype,"writingMode",void 0),Qt([io("left")],gd.prototype,"textAlign",void 0),Qt([io("top")],gd.prototype,"verticalAlign",void 0),Qt([io(!0)],gd.prototype,"autoSizeAlign",void 0),Qt([io("normal")],gd.prototype,"textWrap",void 0),Qt([io("show")],gd.prototype,"textOverflow",void 0),Qt([uo(!1)],gd.prototype,"textEditing",void 0),gd=Qt([Ao()],gd);let fd=class extends bl{get __tag(){return"Path"}};Qt([ko(nl)],fd.prototype,"__",void 0),Qt([ao("center")],fd.prototype,"strokeAlign",void 0),fd=Qt([Ao()],fd);let md=class extends kl{get __tag(){return"Pen"}setStyle(t){const e=this.pathElement=new fd(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,n,o){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,n){return this}ellipse(t,e,i,s,n,o,r,a){return this}arc(t,e,i,s,n,o){return this}arcTo(t,e,i,s,n){return this}drawEllipse(t,e,i,s,n,o,r,a){return this}drawArc(t,e,i,s,n,o){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};Qt([ko(ol)],md.prototype,"__",void 0),Qt([(t,e)=>{Vn(t,e,{get(){return this.__path}})}],md.prototype,"path",void 0),md=Qt([Po(ks,["set","path","paint"]),Ao()],md);let yd=class extends Bl{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){super(t,e)}init(t,e){if(super.init(t,e),t){const{ground:e,tree:i,sky:s,editor:n}=t;e&&(this.ground=this.addLeafer(e)),(i||n)&&(this.tree=this.addLeafer(i||{type:t.type||"design"})),(s||n)&&(this.sky=this.addLeafer(s)),n&&jt.editor(n,this)}}__setApp(){const{canvas:t}=this,{realCanvas:e,view:i}=this.config;e||i===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable()}__updateLocalBounds(){this.forEach(t=>t.updateLayout()),super.__updateLocalBounds()}start(){super.start(),this.forEach(t=>t.start())}stop(){this.forEach(t=>t.stop()),super.stop()}unlockLayout(){super.unlockLayout(),this.forEach(t=>t.unlockLayout())}lockLayout(){super.lockLayout(),this.forEach(t=>t.lockLayout())}forceRender(t,e){this.forEach(i=>i.forceRender(t,e))}addLeafer(t){const e=new Bl(t);return this.add(e),e}add(t,e){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout(()=>this.add(t,e),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t,e),o(e)||(t.canvas.childIndex=e),this.__listenChildEvents(t)}forEach(t){this.children.forEach(t)}__onCreated(){this.created=this.children.every(t=>t.created)}__onReady(){this.children.every(t=>t.ready)&&super.__onReady()}__onViewReady(){this.children.every(t=>t.viewReady)&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){t.context&&this.forEach(i=>e.matrix?i.__render(t,e):t.copyWorld(i.canvas,e.bounds))}__onResize(t){this.forEach(e=>e.resize(t)),super.__onResize(t)}updateLayout(){this.forEach(t=>t.updateLayout())}__getChildConfig(t){const e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&f.assign(e,t),this.autoLayout&&f.copyAttrs(e,this,_e),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[Ar.END,this.__onReady,this],[Mr.START,this.__onCreated,this],[Mr.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(Mr.END,this.__onChildRenderEnd,this))}};yd=Qt([Ao()],yd);const vd={},wd={isHoldSpaceKey:()=>wd.isHold("Space"),isHold:t=>vd[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){vd[t]||(vd[t]=!0)},setUpCode(t){vd[t]=!1}},xd={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class bd extends vr{get spaceKey(){return wd.isHoldSpaceKey()}get left(){return xd.left(this)}get right(){return xd.right(this)}get middle(){return xd.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return wd.isHoldKeys(t,this)}getBoxPoint(t){return(t||this.current).getBoxPoint(this)}getInnerPoint(t){return(t||this.current).getInnerPoint(this)}getLocalPoint(t){return(t||this.current).getLocalPoint(this)}getPagePoint(){return this.current.getPagePoint(this)}getInner(t){return this.getInnerPoint(t)}getLocal(t){return this.getLocalPoint(t)}getPage(){return this.getPagePoint()}static changeName(t,e){Zt.changeName(t,e)}}let kd=class extends bd{};kd.POINTER="pointer",kd.BEFORE_DOWN="pointer.before_down",kd.BEFORE_MOVE="pointer.before_move",kd.BEFORE_UP="pointer.before_up",kd.DOWN="pointer.down",kd.MOVE="pointer.move",kd.UP="pointer.up",kd.OVER="pointer.over",kd.OUT="pointer.out",kd.ENTER="pointer.enter",kd.LEAVE="pointer.leave",kd.TAP="tap",kd.DOUBLE_TAP="double_tap",kd.CLICK="click",kd.DOUBLE_CLICK="double_click",kd.LONG_PRESS="long_press",kd.LONG_TAP="long_tap",kd.MENU="pointer.menu",kd.MENU_TAP="pointer.menu_tap",kd=Qt([Mo()],kd);const Ed=kd,Sd={};let Bd=class extends kd{static setList(t){this.list=t instanceof eh?t:new eh(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const n=t.getLocalPoint(i,null,!0);return K.move(n,e.x-t.x,e.y-t.y),s&&this.limitMove(t,n),gl.axisMove(t,n),n}static limitMove(t,e){gl.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Sd,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Sd,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Sd,null,!0)}getPageTotal(){return this.getPageMove(!0)}getInnerTotal(t){return this.getInnerMove(t,!0)}getLocalTotal(t){return this.getLocalMove(t,!0)}getPageBounds(){const t=this.getPageTotal(),e=this.getPagePoint(),i={};return Rt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),Rt.unsign(i),i}assignMove(t){Sd.x=t?this.totalX:this.moveX,Sd.y=t?this.totalY:this.moveY}};Bd.BEFORE_DRAG="drag.before_drag",Bd.START="drag.start",Bd.DRAG="drag",Bd.END="drag.end",Bd.OVER="drag.over",Bd.OUT="drag.out",Bd.ENTER="drag.enter",Bd.LEAVE="drag.leave",Bd=Qt([Mo()],Bd);const Td=Bd;let Rd=class extends kd{static setList(t){Bd.setList(t)}static setData(t){Bd.setData(t)}};Rd.DROP="drop",Rd=Qt([Mo()],Rd);let Cd=class extends Bd{};Cd.BEFORE_MOVE="move.before_move",Cd.START="move.start",Cd.MOVE="move",Cd.END="move.end",Cd=Qt([Mo()],Cd);let Od=class extends kd{};Od.BEFORE_ROTATE="rotate.before_rotate",Od.START="rotate.start",Od.ROTATE="rotate",Od.END="rotate.end",Od=Qt([Mo()],Od);let Ld=class extends Bd{};Ld.SWIPE="swipe",Ld.LEFT="swipe.left",Ld.RIGHT="swipe.right",Ld.UP="swipe.up",Ld.DOWN="swipe.down",Ld=Qt([Mo()],Ld);let Pd=class extends kd{};Pd.BEFORE_ZOOM="zoom.before_zoom",Pd.START="zoom.start",Pd.ZOOM="zoom",Pd.END="zoom.end",Pd=Qt([Mo()],Pd);let Ad=class extends bd{};Ad.BEFORE_DOWN="key.before_down",Ad.BEFORE_UP="key.before_up",Ad.DOWN="key.down",Ad.HOLD="key.hold",Ad.UP="key.up",Ad=Qt([Mo()],Ad);const Md={getDragEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:i.x,y:i.y,moveX:i.x-e.x,moveY:i.y-e.y,totalX:i.x-t.x,totalY:i.y-t.y}),getDropEventData:(t,e,i)=>Object.assign(Object.assign({},t),{list:e,data:i}),getSwipeDirection:t=>t<-45&&t>-135?Ld.UP:t>45&&t<135?Ld.DOWN:t<=45&&t>=-45?Ld.RIGHT:Ld.LEFT,getSwipeEventData:(t,e,i)=>Object.assign(Object.assign({},i),{moveX:e.moveX,moveY:e.moveY,totalX:i.x-t.x,totalY:i.y-t.y,type:Dd.getSwipeDirection(K.getAngle(t,i))}),getBase(t){const e=1===t.button?4:t.button;return{altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,buttons:o(t.buttons)?1:0===t.buttons?e:t.buttons,origin:t}},pathHasEventType(t,e){const{list:i}=t;for(let t=0,s=i.length;t<s;t++)if(i[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const i=new eh,{list:s}=t;for(let t=0,n=s.length;t<n;t++)s[t].hasEvent(e)&&i.add(s[t]);return i},pathCanDrag:t=>t&&t.list.some(t=>Uo.draggable(t)||!t.isLeafer&&t.hasEvent(Bd.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},Dd=Md,Fd=new eh,{getDragEventData:Id,getDropEventData:Wd,getSwipeEventData:zd}=Md;class Nd{constructor(t){this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Id(t,t,t),this.canAnimate=this.canDragOut=!0}getList(t,e){const{proxy:i}=this.interaction.selector,s=i&&i.list.length,n=Bd.list||this.draggableList||Fd;return this.dragging&&(s?t?Fd:new eh(e?[...i.list,...i.dragHoverExclude]:i.list):n)}checkDrag(t,e){const{interaction:i}=this;if(this.moving&&t.buttons<1)return this.canAnimate=!1,void i.pointerCancel();!this.moving&&e&&(this.moving=i.canMove(this.downData)||i.isHoldRightKey||i.isMobileDragEmpty)&&(this.dragData.moveType="drag",i.emit(Cd.START,this.dragData)),this.moving||this.dragStart(t,e),this.drag(t)}dragStart(t,e){this.dragging||(this.dragging=e&&xd.left(t),this.dragging&&(this.interaction.emit(Bd.START,this.dragData),this.getDraggableList(this.dragData.path),this.setDragStartPoints(this.realDraggableList=this.getList(!0))))}setDragStartPoints(t){this.dragStartPoints={},t.forEach(t=>this.dragStartPoints[t.innerId]={x:t.x,y:t.y})}getDraggableList(t){let e;for(let i=0,s=t.length;i<s;i++)if(e=t.list[i],Uo.draggable(e)){this.draggableList=new eh(e);break}}drag(t){const{interaction:e,dragData:i,downData:s}=this,{path:n,throughPath:o}=s;this.dragData=Id(s,i,t),o&&(this.dragData.throughPath=o),this.dragData.path=n,this.moving?(this.dragData.moveType="drag",e.emit(Cd.BEFORE_MOVE,this.dragData),e.emit(Cd.MOVE,this.dragData)):this.dragging&&(this.dragReal(),e.emit(Bd.BEFORE_DRAG,this.dragData),e.emit(Bd.DRAG,this.dragData))}dragReal(t){const{interaction:e}=this,{running:i}=e,s=this.realDraggableList;if(s.length&&i){const{totalX:i,totalY:n}=this.dragData,{dragLimitAnimate:o}=e.p,r=!o||!!t;s.forEach(e=>{if(e.draggable){const s=a(e.draggable),h=Bd.getValidMove(e,this.dragStartPoints[e.innerId],{x:i,y:n},r||s);o&&!s&&t?Uo.animateMove(e,h,l(o)?o:.3):e.move(h)}})}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:i}=this,{path:s}=t;this.dragOverPath=s,i?s.indexAt(0)!==i.indexAt(0)&&(e.emit(Bd.OUT,t,i),e.emit(Bd.OVER,t,s)):e.emit(Bd.OVER,t,s)}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:i}=this,{path:s}=t;e.emit(Bd.LEAVE,t,i,s),e.emit(Bd.ENTER,t,s,i),this.dragEnterPath=s}dragEnd(t,e){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t,e)||this.dragEndReal(t))}dragEndReal(t){const{interaction:e,downData:i,dragData:s}=this;t||(t=s);const{path:n,throughPath:o}=i,r=Id(i,t,t);if(o&&(r.throughPath=o),r.path=n,this.moving&&(this.moving=!1,r.moveType="drag",e.emit(Cd.END,r)),this.dragging){const n=this.getList();this.dragging=!1,e.p.dragLimitAnimate&&this.dragReal(!0),e.emit(Bd.END,r),this.swipe(t,i,s,r),this.drop(t,n,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(K.getDistance(e,t)>n.config.pointer.swipeDistance){const t=zd(e,i,s);this.interaction.emit(t.type,t)}}drop(t,e,i){const s=Wd(t,e,Bd.data);s.path=i,this.interaction.emit(Rd.DROP,s),this.interaction.emit(Bd.LEAVE,t,i)}dragReset(){Bd.list=Bd.data=this.draggableList=this.dragData=this.downData=this.dragOverPath=this.dragEnterPath=null}checkDragEndAnimate(t,e){return!1}animate(t,e){}checkDragOut(t){}autoMoveOnDragOut(t){}autoMoveCancel(){}destroy(){this.dragReset()}}const Yd=It.get("emit");const Hd=["move","zoom","rotate","key"];function Xd(t,e,i,s,n){if(Hd.some(t=>e.startsWith(t))&&t.__.hitChildren&&!jd(t,n)){let o;for(let r=0,a=t.children.length;r<a;r++)o=t.children[r],!i.path.has(o)&&o.__.hittable&&Vd(o,e,i,s,n)}}function Vd(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!jd(t,n)&&(zh.updateEventStyle&&!s&&zh.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=Zt.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function jd(t,e){return e&&e.has(t)}const Ud={wheel:{zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8}},pointer:{type:"pointer",snap:!0,hitRadius:5,tapTime:120,longPressTime:800,transformTime:500,hover:!0,dragHover:!0,dragDistance:2,swipeDistance:20},touch:{preventDefault:"auto"},multiTouch:{},move:{autoDistance:2},zoom:{},cursor:!0,keyEvent:!0},{pathHasEventType:Gd,pathCanDrag:Kd,pathHasOutside:qd}=Md;class Zd{get dragging(){return this.dragger.dragging}get transforming(){return this.transformer.transforming}get moveMode(){return!0===this.m.drag||this.isHoldSpaceKey||this.isHoldMiddleKey||this.isHoldRightKey&&this.dragger.moving||this.isDragEmpty}get canHover(){return this.p.hover&&!this.config.mobile}get isDragEmpty(){return this.m.dragEmpty&&this.isRootPath(this.hoverData)&&(!this.downData||this.isRootPath(this.downData))}get isMobileDragEmpty(){return this.m.dragEmpty&&!this.canHover&&this.downData&&this.isTreePath(this.downData)}get isHoldMiddleKey(){return this.m.holdMiddleKey&&this.downData&&xd.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&xd.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&wd.isHoldSpaceKey()}get m(){return this.config.move}get p(){return this.config.pointer}get hitRadius(){return this.p.hitRadius}constructor(t,e,i,s){this.config=f.clone(Ud),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new eh(t),this.createTransformer(),this.dragger=new Nd(this),s&&(this.config=f.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(xd.defaultLeft(t),this.updateDownData(t),this.checkPath(t,e),this.downTime=Date.now(),this.emit(kd.BEFORE_DOWN,t),this.emit(kd.DOWN,t),xd.left(t)&&(this.tapWait(),this.longPressWait(t)),this.waitRightTap=xd.right(t),this.dragger.setDragData(t),this.isHoldRightKey||this.updateCursor(t))}pointerMove(t){if(t||(t=this.hoverData),!t)return;const{downData:e}=this;e&&xd.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(kd.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=K.getDistance(this.downData,t)>this.p.dragDistance;e&&(this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(t,e)}this.dragger.moving||(this.updateHoverData(t),this.checkPath(t),this.emit(kd.MOVE,t),this.pointerHover(t),this.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t))),this.updateCursor(this.downData||t)}pointerUp(t){const{downData:e}=this;if(t||(t=e),!e)return;xd.defaultLeft(t),t.multiTouch=e.multiTouch,this.findPath(t);const i=Object.assign(Object.assign({},t),{path:t.path.clone()});t.path.addList(e.path.list),this.checkPath(t),this.downData=null,this.emit(kd.BEFORE_UP,t),this.emit(kd.UP,t),this.touchLeave(t),t.isCancel||(this.tap(t),this.menuTap(t)),this.dragger.dragEnd(t),this.updateCursor(i)}pointerCancel(){const t=Object.assign({},this.dragger.dragData);t.isCancel=!0,this.pointerUp(t)}menu(t){this.findPath(t),this.emit(kd.MENU,t),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(t)}menuTap(t){this.waitRightTap&&this.waitMenuTap&&(this.emit(kd.MENU_TAP,t),this.waitRightTap=this.waitMenuTap=!1)}createTransformer(){}move(t){}zoom(t){}rotate(t){}transformEnd(){}wheel(t){}multiTouch(t,e){}keyDown(t){if(!this.config.keyEvent)return;this.emit(Ad.BEFORE_DOWN,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,wd.setDownCode(e),this.emit(Ad.HOLD,t,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(Ad.DOWN,t,this.defaultPath)}keyUp(t){if(!this.config.keyEvent)return;this.emit(Ad.BEFORE_UP,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]=!1,wd.setUpCode(e),this.emit(Ad.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new eh),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t))}pointerOverOrOut(t){const{path:e}=t,{overPath:i}=this;this.overPath=e,i?e.indexAt(0)!==i.indexAt(0)&&(this.emit(kd.OUT,t,i),this.emit(kd.OVER,t,e)):this.emit(kd.OVER,t,e)}pointerEnterOrLeave(t){let{path:e}=t;this.downData&&!this.moveMode&&(e=e.clone(),this.downData.path.forEach(t=>e.add(t)));const{enterPath:i}=this;this.enterPath=e,this.emit(kd.LEAVE,t,i,e),this.emit(kd.ENTER,t,e,i)}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(kd.LEAVE,t),this.dragger.dragging&&this.emit(Rd.LEAVE,t))}tap(t){const{pointer:e}=this.config,i=this.longTap(t);if(!e.tapMore&&i)return;if(!this.waitTap)return;e.tapMore&&this.emitTap(t);const s=Date.now()-this.downTime,n=[kd.DOUBLE_TAP,kd.DOUBLE_CLICK].some(e=>Gd(t.path,e));s<e.tapTime+50&&n?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout(()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))},e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}findPath(e,i){const{hitRadius:s,through:n}=this.p,{bottomList:o,target:r}=this;t.backgrounder||e.origin||r&&r.updateLayout();const a=this.selector.getByPoint(e,s,Object.assign({bottomList:o,name:e.type},i||{through:n}));return a.throughPath&&(e.throughPath=a.throughPath),e.path=a.path,a.path}isRootPath(t){return t&&t.path.list[0].isLeafer}isTreePath(t){const e=this.target.app;return!(!e||!e.isApp)&&(e.editor&&!t.path.has(e.editor)&&t.path.has(e.tree)&&!t.target.syncEventer)}checkPath(t,e){(e||this.moveMode&&!qd(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!Kd(t.path))&&!qd(t.path)}isDrag(t){return this.dragger.getList().has(t)}isPress(t){return this.downData&&this.downData.path.has(t)}isHover(t){return this.enterPath&&this.enterPath.has(t)}isFocus(t){return this.focusData===t}cancelHover(){const{hoverData:t}=this;t&&(t.path=this.defaultPath,this.pointerHover(t))}updateDownData(t,e,i){const{downData:s}=this;!t&&s&&(t=s),t&&(this.findPath(t,e),i&&s&&t.path.addList(s.path.list),this.downData=t)}updateHoverData(t){t||(t=this.hoverData),t&&(this.findPath(t,{exclude:this.dragger.getList(!1,!0),name:kd.MOVE}),this.hoverData=t)}updateCursor(t){if(!this.config.cursor||!this.canHover)return;if(t||(this.updateHoverData(),t=this.downData||this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.canMove(t))return this.setCursor(this.downData?"grabbing":"grab");if(!t)return;let e,i;const{path:s}=t;for(let t=0,n=s.length;t<n&&(e=s.list[t],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);t++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e),s={x:t.clientX-i.x,y:t.clientY-i.y},{bounds:n}=this.canvas;return s.x*=n.width/i.width,s.y*=n.height/i.height,this.p.snap&&K.round(s),s}emitTap(t){this.emit(kd.TAP,t),this.emit(kd.CLICK,t)}emitDoubleTap(t){this.emit(kd.DOUBLE_TAP,t),this.emit(kd.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){this.waitTap&&(clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0)}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout(()=>{this.longPressed=!0,this.emit(kd.LONG_PRESS,t)},this.p.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(kd.LONG_TAP,t),(Gd(t.path,kd.LONG_TAP)||Gd(t.path,kd.LONG_PRESS))&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressed=!1)}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new Pt(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(l(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Lr.RESIZE,this.__onResize,this)],t.once(Dr.READY,()=>this.__onResize())}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}emit(t,e,i,s){this.running&&function(t,e,i,s){if(!i&&!e.path)return;let n;e.type=t,i?e=Object.assign(Object.assign({},e),{path:i}):i=e.path,e.target=i.indexAt(0);try{for(let o=i.length-1;o>-1;o--){if(n=i.list[o],Vd(n,t,e,!0,s))return;n.isApp&&Xd(n,t,e,!0,s)}for(let o=0,r=i.length;o<r;o++)if(n=i.list[o],n.isApp&&Xd(n,t,e,!1,s),Vd(n,t,e,!1,s))return}catch(t){Yd.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer&&this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class Jd{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}Jd.custom={};class $d extends $t{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new eh,this.pixelList=new eh}getPixelType(t,e){return this.__autoClear(),this.pixelList.add(t),jt.hitCanvas(e)}getPathType(t){return this.__autoClear(),this.pathList.add(t),jt.hitCanvas()}clearImageType(){this.__clearLeafList(this.pixelList)}clearPathType(){this.__clearLeafList(this.pathList)}__clearLeafList(t){t.length&&(t.forEach(t=>{t.__hitCanvas&&(t.__hitCanvas.destroy(),t.__hitCanvas=null)}),t.reset())}__autoClear(){this.pathList.length+this.pixelList.length>this.maxTotal&&this.clear()}clear(){this.clearPathType(),this.clearImageType()}}t.getSelector=function(e){return e.leafer?e.leafer.selector:t.selector||(t.selector=jt.selector())};const{toInnerRadiusPointOf:Qd,copy:tc,setRadius:ec}=K,{hitRadiusPoint:ic,hitPoint:sc}=Rt,nc={},oc={},rc=Va.prototype;rc.hit=function(e,i=0){this.updateLayout(),tc(oc,e),ec(oc,i);const s=this.__world;return!!(i?ic(s,oc):sc(s,oc))&&(this.isBranch?t.getSelector(this).hitPoint(Object.assign({},oc),i,{target:this}):this.__hitWorld(oc))},rc.__hitWorld=function(t){const e=this.__;if(!e.hitSelf)return!1;const i=this.__world,s=this.__layout,n=i.width<10&&i.height<10;if(e.hitRadius&&(tc(nc,t),ec(t=nc,e.hitRadius)),Qd(t,i,nc),e.hitBox||n){if(Rt.hitRadiusPoint(s.boxBounds,nc))return!0;if(n)return!1}return!s.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),s.boundsChanged||(s.hitCanvasChanged=!1)),this.__hit(nc)},rc.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},rc.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},rc.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},rc.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const ac=new et,hc=bl.prototype;hc.__updateHitCanvas=function(){this.__box&&this.__box.__updateHitCanvas();const e=this.leafer||this.parent&&this.parent.leafer;if(!e)return;const i=this.__,{hitCanvasManager:s}=e,n=(i.__isAlphaPixelFill||i.__isCanvas)&&"pixel"===i.hitFill,o=i.__isAlphaPixelStroke&&"pixel"===i.hitStroke,r=n||o;this.__hitCanvas||(this.__hitCanvas=r?s.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):s.getPathType(this));const a=this.__hitCanvas;if(r){const{renderBounds:e}=this.__layout,s=t.image.hitCanvasSize,r=a.hitScale=At.set(0,0,s,s).getFitMatrix(e).a,{x:h,y:l,width:d,height:c}=At.set(e).scale(r);a.resize({width:d,height:c,pixelRatio:1}),a.clear(),In.patternLocked=!0,this.__renderShape(a,{matrix:ac.setWith(this.__world).scaleWith(1/r).invertWith().translate(-h,-l),ignoreFill:!n,ignoreStroke:!o}),In.patternLocked=!1,a.resetTransform(),i.__isHitPixel=!0}else i.__isHitPixel&&(i.__isHitPixel=!1);this.__drawHitPath(a),a.setStrokeOptions(i)},hc.__hit=function(t){if(this.__box&&this.__box.__hit(t))return!0;const e=this.__;if(e.__isHitPixel&&this.__hitPixel(t))return!0;const{hitFill:i}=e,s=(e.fill||e.__isCanvas)&&("path"===i||"pixel"===i&&!(e.__isAlphaPixelFill||e.__isCanvas))||"all"===i;if(s&&this.__hitFill(t))return!0;const{hitStroke:n,__maxStrokeWidth:o}=e,r=e.stroke&&("path"===n||"pixel"===n&&!e.__isAlphaPixelStroke)||"all"===n;if(!s&&!r)return!1;const a=2*t.radiusX;let h=a;if(r)switch(e.strokeAlign){case"inside":if(h+=2*o,!s&&this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a;break;case"center":h+=o;break;case"outside":if(h+=2*o,!s){if(!this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a}}return!!h&&this.__hitStroke(t,h)};const lc=bl.prototype,dc=Tl.prototype,cc=Al.prototype;dc.__updateHitCanvas=cc.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?lc.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},dc.__hitFill=cc.__hitFill=function(t){return this.__hitCanvas?lc.__hitFill.call(this,t):Rt.hitRadiusPoint(this.__layout.boxBounds,t)},gd.prototype.__drawHitPath=function(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__letterSpacing:n,__textDrawData:o}=this.__;t.beginPath(),n<0?this.__drawPathByBox(t):o.rows.forEach(n=>t.rect(n.x,n.y-s,n.width,e<i?i:e))},kl.prototype.pick=function(e,i){return i||(i=n),this.updateLayout(),t.getSelector(this).getByPoint(e,i.hitRadius||0,Object.assign(Object.assign({},i),{target:this}))};const uc=pe.prototype;function _c(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,o)))}}function pc(t,e){t.__.__font?_c(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function gc(t,e,i){switch(e.__.strokeAlign){case"center":fc(t,1,e,i);break;case"inside":mc(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?fc(t,2,e,i):mc(t,"outside",e,i)}}function fc(t,e,i,s){const n=i.__;_(t)?vc(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),yc(i,s))}function mc(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,fc(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",_c(i,n),n.blendMode="normal",Uo.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function yc(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(o){const{decorationHeight:t}=s;n.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function vc(t,e,i,s,n){let o;const r=s.__,{__hasMultiStrokeStyle:a}=r;a||n.setStroke(void 0,r.__strokeWidth*e,r);for(let h=0,l=t.length;h<l;h++)if(o=t[h],(!o.image||!Mh.checkImage(s,n,o,!1))&&o.style){if(a){const{strokeStyle:t}=o;t?n.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(o.style,r.__strokeWidth*e,r)}else n.strokeStyle=o.style;o.blendMode?(n.saveBlendMode(o.blendMode),i?yc(s,n):n.stroke(),n.restoreBlendMode()):i?yc(s,n):n.stroke()}}function wc(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)gc(t,e,i);else switch(s.strokeAlign){case"center":xc(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),xc(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)xc(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),xc(t,2,e,o),o.clipUI(s),o.clearWorld(n),Uo.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i)}}function xc(t,e,i,s){const n=i.__;_(t)?vc(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&Ah.strokeArrow(t,i,s)}uc.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},uc.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},uc.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:o,radiusY:r}=t;e&&(s-=e.x,n-=e.y),At.set(s-o,n-r,2*o,2*r).scale(i).ceil();const{data:a}=this.context.getImageData(At.x,At.y,At.width||1,At.height||1);for(let t=0,e=a.length;t<e;t+=4)if(a[t+3]>0)return!0;return a[3]>0};const{getSpread:bc,getOuterOf:kc,getByMove:Ec,getIntersectData:Sc}=Rt;let Bc;const{stintSet:Tc}=f,{hasTransparent:Rc}=Oh;function Cc(t,e,i){if(!_(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=Mh.image(i,t,e,n,!Bc||!Bc[e.url]);break;case"linear":s=Dh.linearGradient(e,n);break;case"radial":s=Dh.radialGradient(e,n);break;case"angular":s=Dh.conicGradient(e,n);break;case"solid":const{type:r,color:a,opacity:h}=e;s={type:r,style:Oh.string(a,h)};break;default:o(e.r)||(s={type:"solid",style:Oh.string(e)})}if(s){if(a(s.style)&&Rc(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Oc={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];u(a)||(a=[a]),Bc=Mh.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Cc(t,a[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),o=!0),"fill"===t?(Tc(i,"__isAlphaPixelFill",n),Tc(i,"__isTransparentFill",o)):(Tc(i,"__isAlphaPixelStroke",n),Tc(i,"__isTransparentStroke",o),Tc(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,pc(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(Mh.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),pc(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),pc(e,i),i.restoreBlendMode()):pc(e,i)}},fillPathOrText:pc,fillText:_c,stroke:wc,strokes:function(t,e,i){wc(t,e,i)},strokeText:gc,drawTextStroke:yc,shape:function(e,i,s){const n=i.getSameCanvas(),o=e.__nowWorld,r=i.bounds;let a,h,l,d,c,{scaleX:u,scaleY:_}=e.getRenderScaleData(!0);if(r.includes(o))c=n,a=d=o;else{const{renderShapeSpread:n}=e.__layout;let p;if(t.fullImageShadow)p=o;else{const t=n?bc(r,u===_?n*u:[n*_,n*u]):r;p=Sc(t,o)}l=r.getFitMatrix(p);let{a:g,d:f}=l;l.a<1&&(c=i.getSameCanvas(),e.__renderShape(c,s),u*=g,_*=f),d=kc(o,l),a=Ec(d,-l.e,-l.f);const m=s.matrix;m?(h=new et(l),h.multiply(m),g*=m.scaleX,f*=m.scaleY):h=l,h.withScale(g,f),s=Object.assign(Object.assign({},s),{matrix:h})}return e.__renderShape(n,s),{canvas:n,matrix:h,fitMatrix:l,bounds:a,worldCanvas:c,shapeBounds:d,scaleX:u,scaleY:_}}};let Lc={},Pc={a:1,b:0,c:0,d:1,e:0,f:0};const{get:Ac,rotateOfOuter:Mc,translate:Dc,scaleOfOuter:Fc,multiplyParent:Ic,scale:Wc,rotate:zc,skew:Nc}=I;function Yc(t,e,i,s,n,o,r){const a=Ac();Dc(a,e.x+i,e.y+s),Wc(a,n,o),r&&Mc(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function Hc(t,e,i,s,n,o,r,a,h){const l=Ac();Vc(l,e,i,s,n,o,r,a),h&&(Pc.a=e.width/h.width,Pc.d=e.height/h.height,Ic(l,Pc)),t.transform=l}function Xc(t,e,i,s,n,o,r,a,h,l,d,c){const u=Ac();if(c)Vc(u,e,n,o,r,a,h,l);else{if(h)if("center"===d)Mc(u,{x:i/2,y:s/2},h);else switch(zc(u,h),h){case 90:Dc(u,s,0);break;case 180:Dc(u,i,s);break;case 270:Dc(u,0,i)}Lc.x=e.x+n,Lc.y=e.y+o,Dc(u,Lc.x,Lc.y),r&&Fc(u,Lc,r,a)}t.transform=u}function Vc(t,e,i,s,n,o,r,a){r&&zc(t,r),a&&Nc(t,a.x,a.y),n&&Wc(t,n,o),Dc(t,e.x+i,e.y+s)}const{get:jc,translate:Uc}=I,Gc=new Pt,Kc={},qc={};function Zc(t,e,i,s){const{changeful:n,sync:o,scaleFixed:r}=i;n&&(t.changeful=n),o&&(t.sync=o),r&&(t.scaleFixed=r),t.data=Jc(i,s,e)}function Jc(t,e,i){t.padding&&(e=Gc.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:o,mode:r,align:h,offset:l,scale:d,size:c,rotation:u,skew:p,clipSize:g,repeat:f,gap:m,filters:y}=t,v=e.width===s&&e.height===n,w={mode:r},x="center"!==h&&(u||0)%180==90;let k,E;switch(Rt.set(qc,0,0,x?n:s,x?s:n),r&&"cover"!==r&&"fit"!==r?((d||c)&&(b.getScaleData(d,c,i,Kc),k=Kc.scaleX,E=Kc.scaleY),(h||m||f)&&(k&&Rt.scale(qc,k,E,!0),h&&ct.toPoint(h,qc,e,qc,!0,!0))):v&&!u||(k=E=Rt.getFitScale(e,qc,"fit"!==r),Rt.put(e,i,h,k,!1,qc),Rt.scale(qc,k,E,!0)),l&&K.move(qc,l),r){case"stretch":v||(s=e.width,n=e.height);break;case"normal":case"clip":(qc.x||qc.y||k||g||u||p)&&Hc(w,e,qc.x,qc.y,k,E,u,p,t.clipSize);break;case"repeat":(!v||k||u||p)&&Xc(w,e,s,n,qc.x,qc.y,k,E,u,p,h,t.freeTransform),f||(w.repeat="repeat");const i=_(f);(m||i)&&(w.gap=function(t,e,i,s,n){let o,r;_(t)?(o=t.x,r=t.y):o=r=t;return{x:$c(o,i,n.width,e&&e.x),y:$c(r,s,n.height,e&&e.y)}}(m,i&&f,qc.width,qc.height,e));break;default:k&&Yc(w,e,qc.x,qc.y,k,E,u)}return w.transform||(e.x||e.y)&&(w.transform=jc(),Uc(w.transform,e.x,e.y)),k&&"stretch"!==r&&(w.scaleX=k,w.scaleY=E),w.width=s,w.height=n,o&&(w.opacity=o),y&&(w.filters=y),f&&(w.repeat=a(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),w}function $c(t,e,i,s){const n=a(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let Qc,tu=new Pt;const{isSame:eu}=Rt;function iu(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Zc(n,s,i,o),!0}function su(t,e){ru(t,Er.LOAD,e)}function nu(t,e){ru(t,Er.LOADED,e)}function ou(t,e,i){e.error=i,t.forceUpdate("surface"),ru(t,Er.ERROR,e)}function ru(t,e,i){t.hasEvent(e)&&t.emitEvent(new Er(e,i))}function au(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:hu,scale:lu,copy:du}=I,{floor:cu,ceil:uu,max:_u,abs:pu}=Math;function gu(e,i,s){let{scaleX:n,scaleY:o}=e.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+o+"-"+s;if(i.patternId===r||e.destroyed)return!1;{const{image:a,data:h}=i;let l,d,{width:c,height:u,scaleX:_,scaleY:p,transform:g,repeat:f,gap:m}=h;n*=s,o*=s,_&&(_=pu(_),p=pu(p),d=hu(),du(d,g),lu(d,1/_,1/p),n*=_,o*=p),c*=n,u*=o;const y=c*u;if(!f&&y>t.image.maxCacheSize)return!1;let v=t.image.maxPatternSize;if(a.isSVG){const t=c/a.width;t>1&&(l=t/uu(t))}else{const t=a.width*a.height;v>t&&(v=t)}y>v&&(l=Math.sqrt(y/v)),l&&(n/=l,o/=l,c/=l,u/=l),_&&(n/=_,o/=p);const w=m&&m.x*n,x=m&&m.y*o;if(g||1!==n||1!==o){const t=c+(w||0),e=u+(x||0);n/=t/_u(cu(t),1),o/=e/_u(cu(e),1),d||(d=hu(),g&&du(d,g)),lu(d,1/n,1/o)}const b=a.getCanvas(c,u,h.opacity,h.filters,w,x,e.leafer&&e.leafer.config.smooth),k=a.getPattern(b,f||t.origin.noRepeat||"no-repeat",d,i);return i.style=k,i.patternId=r,!0}}const fu={image:function(t,e,i,s,n){let o,r;const a=In.get(i);return Qc&&i===Qc.paint&&eu(s,Qc.boxBounds)?o=Qc.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),Qc=a.use>1?{leafPaint:o,paint:i,boxBounds:tu.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(iu(t,e,i,a,o,s),n&&(su(t,r),nu(t,r))):a.error?n&&ou(t,r,a.error):(n&&(au(t,!0),su(t,r)),o.loadId=a.load(()=>{au(t,!1),t.destroyed||(iu(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),nu(t,r)),o.loadId=void 0},e=>{au(t,!1),ou(t,r,e),o.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(e,i,s,n){const{scaleX:o,scaleY:r}=e.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:a}=i,{data:h}=s;if(!h||s.patternId===o+"-"+r+"-"+a&&!Wh.running)return!1;if(n)if(h.repeat)n=!1;else if(!(s.changeful||"miniapp"===t.name&&Lr.isResizing(e)||Wh.running)){let{width:e,height:i}=h;e*=o*a,i*=r*a,h.scaleX&&(e*=h.scaleX,i*=h.scaleY),n=e*i>t.image.maxCacheSize}return n?(e.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(e,i,s,h),!0):(!s.style||s.sync||Wh.running?gu(e,s,a):s.patternTask||(s.patternTask=In.patternTasker.add(()=>te(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&gu(e,s,a),e.forceUpdate("surface")}),300)),!1)},createPattern:gu,recycleImage:function(t,e){const i=e["_"+t];if(u(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,In.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],u(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createData:Zc,getPatternData:Jc,fillOrFitMode:Yc,clipMode:Hc,repeatMode:Xc},{toPoint:mu}=ht,{hasTransparent:yu}=Oh,vu={},wu={};function xu(t,e,i,s){if(i){let n,o,r,h;for(let t=0,l=i.length;t<l;t++)n=i[t],a(n)?(r=t/(l-1),o=Oh.string(n,s)):(r=n.offset,o=Oh.string(n.color,s)),e.addColorStop(r,o),!h&&yu(o)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:bu,getDistance:ku}=K,{get:Eu,rotateOfOuter:Su,scaleOfOuter:Bu}=I,{toPoint:Tu}=ht,Ru={},Cu={};function Ou(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=bu(e,i);o=Eu(),n?(Bu(o,e,r/a*(s||1),1),Su(o,e,t+90)):(Bu(o,e,1,r/a*(s||1)),Su(o,e,t))}return o}const{getDistance:Lu}=K,{toPoint:Pu}=ht,Au={},Mu={};const Du={linearGradient:function(e,i){let{from:s,to:n,type:o,opacity:r}=e;mu(s||"top",i,vu),mu(n||"bottom",i,wu);const a=t.canvas.createLinearGradient(vu.x,vu.y,wu.x,wu.y),h={type:o,style:a};return xu(h,a,e.stops,r),h},radialGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,stretch:a}=e;Tu(s||"center",i,Ru),Tu(n||"bottom",i,Cu);const h=t.canvas.createRadialGradient(Ru.x,Ru.y,0,Ru.x,Ru.y,ku(Ru,Cu)),l={type:o,style:h};xu(l,h,e.stops,r);const d=Ou(i,Ru,Cu,a,!0);return d&&(l.transform=d),l},conicGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,stretch:a}=e;Pu(s||"center",i,Au),Pu(n||"bottom",i,Mu);const h=t.conicGradientSupport?t.canvas.createConicGradient(0,Au.x,Au.y):t.canvas.createRadialGradient(Au.x,Au.y,0,Au.x,Au.y,Lu(Au,Mu)),l={type:o,style:h};xu(l,h,e.stops,r);const d=Ou(i,Au,Mu,a||1,t.conicGradientRotate90);return d&&(l.transform=d),l},getTransform:Ou},{copy:Fu,toOffsetOutBounds:Iu}=Rt,Wu={},zu={};function Nu(e,i,s,n){const{bounds:o,shapeBounds:r}=n;if(t.fullImageShadow){if(Fu(Wu,e.bounds),Wu.x+=i.x-r.x,Wu.y+=i.y-r.y,s){const{fitMatrix:t}=n;Wu.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Wu.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Wu.width*=s,Wu.height*=s}e.copyWorld(n.canvas,e.bounds,Wu)}else s&&(Fu(Wu,i),Wu.x-=i.width/2*(s-1),Wu.y-=i.height/2*(s-1),Wu.width*=s,Wu.height*=s),e.copyWorld(n.canvas,r,s?Wu:i)}const{toOffsetOutBounds:Yu}=Rt,Hu={};const Xu={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,_=e.getSameCanvas(),p=a.length-1;Iu(l,zu),a.forEach((a,g)=>{let f=1;if(a.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}_.setWorldShadow(zu.offsetX+a.x*c*f,zu.offsetY+a.y*u*f,a.blur*c*f,Oh.string(a.color)),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*f:0,Nu(_,zu,n,i),s=l,a.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,o,"copy"),s=o),h?_.copyWorld(h,o,o,"destination-out"):_.copyWorld(i.canvas,d,l,"destination-out")),Fh.isTransformShadow(a)?Fh.renderTransformShadow(t,e,_,s,a):Uo.copyCanvasByWorld(t,e,_,s,a.blendMode),p&&g<p&&_.clearWorld(s)}),_.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,_=e.getSameCanvas(),p=a.length-1;Yu(l,Hu),a.forEach((a,g)=>{let f=1;if(a.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}_.save(),_.setWorldShadow(Hu.offsetX+a.x*c*f,Hu.offsetY+a.y*u*f,a.blur*c*f),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*f:0,Nu(_,Hu,n,i),_.restore(),h?(_.copyWorld(_,l,o,"copy"),_.copyWorld(h,o,o,"source-out"),s=o):(_.copyWorld(i.canvas,d,l,"source-out"),s=l),_.fillWorld(s,Oh.string(a.color),"source-in"),Uo.copyCanvasByWorld(t,e,_,s,a.blendMode),p&&g<p&&_.clearWorld(s)}),_.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowSpread:function(t,e){let i=0;return e.forEach(t=>i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread>0?t.spread:0)+1.5*t.blur)),i},isTransformShadow(t){}},{excludeRenderBounds:Vu}=tr;let ju;function Uu(t,e,i,s,n,o,r,a){switch(e){case"grayscale":ju||(ju=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);Ku(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":Ku(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function Gu(t){return t.getSameCanvas(!1,!0)}function Ku(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r)}kl.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++){if(i=h[l],a=i.__.mask,a){r&&(Uu(this,r,t,n,s,o,void 0,!0),s=n=null),o=i.__.opacity,ju=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=Gu(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=Gu(t)),n||(n=Gu(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a||Vu(i,e)||i.__render(t,e);continue}const d=1===o&&i.__.__blendMode;d&&Uu(this,r,t,n,s,o,void 0,!1),Vu(i,e)||i.__render(n||t,e),d&&Uu(this,r,t,n,s,o,d,!1)}Uu(this,r,t,n,s,o,void 0,!0)};const qu=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Zu=qu+"_#~&*+\\=|≮≯≈≠=…",Ju=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function $u(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Qu=$u("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),t_=$u("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),e_=$u(qu),i_=$u(Zu),s_=$u("- —/~|┆·");var n_;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(n_||(n_={}));const{Letter:o_,Single:r_,Before:a_,After:h_,Symbol:l_,Break:d_}=n_;function c_(t){return Qu[t]?o_:s_[t]?d_:t_[t]?a_:e_[t]?h_:i_[t]?l_:Ju.test(t)?r_:o_}const u_={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function __(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:p_}=u_,{Letter:g_,Single:f_,Before:m_,After:y_,Symbol:v_,Break:w_}=n_;let x_,b_,k_,E_,S_,B_,T_,R_,C_,O_,L_,P_,A_,M_,D_,F_,I_,W_=[];function z_(t,e){C_&&!R_&&(R_=C_),x_.data.push({char:t,width:e}),k_+=e}function N_(){E_+=k_,x_.width=k_,b_.words.push(x_),x_={data:[]},k_=0}function Y_(){M_&&(D_.paraNumber++,b_.paraStart=!0,M_=!1),C_&&(b_.startCharSize=R_,b_.endCharSize=C_,R_=0),b_.width=E_,F_.width?p_(b_):I_&&H_(),W_.push(b_),b_={words:[]},E_=0}function H_(){E_>(D_.maxWidth||0)&&(D_.maxWidth=E_)}const{top:X_,right:V_,bottom:j_,left:U_}=ot;function G_(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const K_={getDrawData:function(e,i){a(e)||(e=String(e));let s=0,n=0,o=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:d}=i;d&&(o?(s=d[U_],o-=d[V_]+d[U_]):i.autoSizeAlign||(s=d[U_]),r?(n=d[X_],r-=d[X_]+d[j_]):i.autoSizeAlign||(n=d[X_]));const c={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:t.canvas.font=l};return function(e,i,s){D_=e,W_=e.rows,F_=e.bounds,I_=!F_.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=t,{width:h,height:l}=F_;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;M_=!0,L_=null,R_=T_=C_=k_=E_=0,x_={data:[]},b_={words:[]},n&&(i=[...i]);for(let s=0,l=i.length;s<l;s++)B_=i[s],"\n"===B_?(k_&&N_(),b_.paraEnd=!0,Y_(),M_=!0):(O_=c_(B_),O_===g_&&"none"!==r&&(B_=__(B_,r,!k_)),T_=a.measureText(B_).width,n&&(n<0&&(C_=T_),T_+=n),P_=O_===f_&&(L_===f_||L_===g_)||L_===f_&&O_!==y_,A_=!(O_!==m_&&O_!==f_||L_!==v_&&L_!==y_),S_=M_&&o?h-o:h,t&&h&&E_+k_+T_>S_&&(e?(k_&&N_(),E_&&Y_()):(A_||(A_=O_===g_&&L_==y_),P_||A_||O_===w_||O_===m_||O_===f_||k_+T_>S_?(k_&&N_(),E_&&Y_()):E_&&Y_()))," "===B_&&!0!==M_&&E_+k_===0||(O_===w_?(" "===B_&&k_&&N_(),z_(B_,T_),N_()):P_||A_?(k_&&N_(),z_(B_,T_)):z_(B_,T_)),L_=O_);k_&&N_(),E_&&Y_(),W_.length>0&&(W_[W_.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{D_.paraNumber++,E_=a.measureText(t).width,W_.push({x:o||0,text:t,width:E_,paraStart:!0}),I_&&H_()})}(c,e,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":G_(e,"x",t[U_]);break;case"right":G_(e,"x",-t[V_])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":G_(e,"y",t[X_]);break;case"bottom":G_(e,"y",-t[j_])}}(d,c,i,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:_,y:p,width:g,height:f}=s,m=o*n+(c?c*(t.paraNumber-1):0),y=r;if(h&&m>f)m=Math.max(f,o),n>1&&(t.overflow=n);else if(f||u)switch(d){case"middle":p+=(f-m)/2;break;case"bottom":p+=f-m}y+=p;let v,w,x,b=g||u?g:t.maxWidth;for(let r=0,d=n;r<d;r++){if(v=i[r],v.x=_,v.width<g||v.width>g&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&c&&r>0&&(y+=c),v.y=y,y+=o,t.overflow>r&&y>m&&(v.isOverflow=!0,t.overflow=r+1),w=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,w-=x,x+=e.fontSize):x-=a),w<s.x&&(s.x=w),x>s.width&&(s.width=x),h&&g&&g<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=m}(c,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,d,c,u;s.forEach(t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,d=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===d?(t.x+=l,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach((e,i)=>{1===d?(c={char:"",x:a},a=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,a,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):a=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)})),t.words=null)})}(c,i,o),c.overflow&&function(e,i,s,n){if(!n)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=i;if(o.splice(r),a&&"show"!==a){let e,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.canvas.measureText(a).width:0,d=s+n-l;("none"===i.textWrap?o:[o[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let s=i;s>-1&&(e=t.data[s],h=e.x+e.width,!(s===i&&h<d));s--){if(h<d&&" "!==e.char||!s){t.data.splice(s+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:a,x:h}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(c,i,s,o),"none"!==h&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:o}=e;switch(t.decorationHeight=n/11,_(o)?(i=o.type,o.color&&(t.decorationColor=Oh.string(o.color)),o.offset&&(s=Math.min(.3*n,Math.max(o.offset,.15*-n)))):i=o,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(c,i),c}};const q_={string:function(t,e){const i=l(e)&&e<1;if(a(t)){if(!i||!Oh.object)return t;t=Oh.object(t)}let s=o(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};function Z_(t){return t?u(t)?t:[t]:[]}Object.assign(Ch,K_),Object.assign(Oh,q_),Object.assign(Ah,Oc),Object.assign(Mh,fu),Object.assign(Dh,Du),Object.assign(Fh,Xu),Object.assign(jt,{interaction:(t,e,i,s)=>new Zd(t,e,i,s),hitCanvas:(t,e)=>new nh(t,e),hitCanvasManager:()=>new $d}),rh();class J_ extends vr{get list(){return Z_(this.value)}get oldList(){return Z_(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function $_(t){return(e,i)=>{const s="_"+i;Vn(e,i,{get(){return this[s]},set(e){const n=this[s];if(n!==e){const o=this;if(o.config){const t="target"===i;if(t){o.setDimOthers(!1),o.setBright(!1),u(e)&&e.length>1&&e[0].locked&&e.splice(0,1),o.single&&(o.element.syncEventer=null);const{beforeSelect:t}=o.config;if(t){const i=t({target:e});if(_(i))e=i;else if(!1===i)return}}const s=t?J_.BEFORE_SELECT:J_.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new J_(s,{editor:o,value:e,oldValue:n}))}this[s]=e,t(this,n)}}})}}J_.BEFORE_SELECT="editor.before_select",J_.SELECT="editor.select",J_.AFTER_SELECT="editor.after_select",J_.BEFORE_HOVER="editor.before_hover",J_.HOVER="editor.hover";const{abs:Q_}=Math,{copy:tp,scale:ep}=I,{setListWithFn:ip}=Rt,{worldBounds:sp}=tr,np={a:1,b:0,c:0,d:1,e:0,f:0},op={x:0,y:0,width:0,height:0};class rp extends bl{constructor(){super(),this.list=[],this.visible=0,this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){e&&this.set(e),this.target=t,this.update()}update(t){const{list:e}=this;e.length?(ip(op,e,sp),t&&this.set(t),this.set(op),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const n=this.__,{stroke:o,strokeWidth:r,fill:h}=n,{bounds:l}=e;for(let d=0;d<i.length;d++){s=i[d];const{worldTransform:c,worldRenderBounds:u}=s;if(u.width&&u.height&&(!l||l.hit(u,e.matrix))){const i=Q_(c.scaleX),l=Q_(c.scaleY);if(tp(np,c),np.half=r%2,i!==l){ep(np,1/i,1/l),t.setWorld(np,e.matrix),t.beginPath(),n.strokeWidth=r;const{x:o,y:a,width:h,height:d}=s.__layout.boxBounds;t.rect(o*i,a*l,h*i,d*l)}else t.setWorld(np,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=r/Q_(c.scaleX);o&&(a(o)?Ah.stroke(o,this,t):Ah.strokes(o,this,t)),h&&(a(h)?Ah.fill(h,this,t):Ah.fills(h,this,t))}}n.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}Qt([$_(function(t){const e=t.target;t.list=e?u(e)?e:[e]:[]})],rp.prototype,"target",void 0);class ap extends kl{constructor(t){super(t),this.strokeArea=new Tl({strokeAlign:"center"}),this.fillArea=new Tl,this.visible=0,this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:n}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:n},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const hp={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return lp([t],i,e),i}};function lp(t,e,i){let s,n;for(let o=0,r=t.length;o<r;o++)if(s=t[o],n=s.__,n.hittable&&n.visible&&!n.locked&&i.hit(s.__world)){if(n.editable){if(s.isBranch&&!n.hitChildren){n.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&n.hitSelf&&e.push(s)}s.isBranch&&lp(s.children,e,i)}}const{findOne:dp,findByBounds:cp}=hp;class up extends kl{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector&&"normal"===this.app.mode}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new rp,this.targetStroker=new rp,this.bounds=new Pt,this.selectArea=new ap,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:n}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},n||{}))}}onSelect(){this.running&&(this.targetStroker.setTarget(this.editor.list),this.hoverStroker.target=null)}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedStyle:i}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2)},i||{}))}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(this.isHoldMultipleSelectKey(t)||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:n,y:o}=t.getInnerPoint(this);this.bounds.set(n,o),this.selectArea.setStyle({visible:!0,stroke:i,x:n,y:o},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new eh(cp(e.app,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach(e=>{n.has(e)||t.push(e)}),n.forEach(e=>{this.originList.has(e)||t.push(e)}),(t.length!==e.list.length||e.list.some((e,i)=>e!==t[i]))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=0)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){const{boxSelect:e,multipleSelect:i}=this.editor.mergeConfig;return!(!(this.running&&i&&e)||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||this.isHoldMultipleSelectKey(t)&&!dp(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new eh(this.editor.editBox.rect)};return dp(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):dp(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(this.isHoldMultipleSelectKey(t)||i)}isHoldMultipleSelectKey(t){const{multipleSelectKey:e}=this.editor.mergedConfig;return e?t.isHoldKeys(e):t.shiftKey}__listenEvents(){const{editor:t}=this;t.waitLeafer(()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_([[J_.HOVER,this.onHover,this],[J_.SELECT,this.onSelect,this]]),e.on_([[kd.MOVE,this.onPointerMove,this],[kd.BEFORE_DOWN,this.onBeforeDown,this],[kd.TAP,this.onTap,this],[Bd.START,this.onDragStart,this,!0],[Bd.DRAG,this.onDrag,this],[Bd.END,this.onDragEnd,this],[Cd.MOVE,this.onAutoMove,this],[[Pd.ZOOM,Cd.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:_p,top:pp,topRight:gp,right:fp,bottomRight:mp,bottom:yp,bottomLeft:vp,left:wp}=rt,{toPoint:xp}=ht,{within:bp,sign:kp}=b,Ep={getScaleData(t,e,i,s,n,o,r,a){let h,l={},d=1,c=1;const{boxBounds:u,widthRange:_,heightRange:p,dragBounds:g,worldBoxBounds:f}=t,{width:m,height:y}=e;o&&(s.x*=2,s.y*=2);const v=t.scaleX/e.scaleX,w=t.scaleY/e.scaleY,x=kp(v),b=kp(w),k=a?v:x*u.width/m,E=a?w:b*u.height/y;s.x*=a?v:x,s.y*=a?w:b;const S=(-s.y+y)/y,B=(s.x+m)/m,T=(s.y+y)/y,R=(-s.x+m)/m;switch(i){case pp:c=S,h="bottom";break;case fp:d=B,h="left";break;case yp:c=T,h="top";break;case wp:d=R,h="right";break;case _p:c=S,d=R,h="bottom-right";break;case gp:c=S,d=B,h="bottom-left";break;case mp:c=T,d=B,h="top-left";break;case vp:c=T,d=R,h="top-right"}if(n)if("corner"===n&&i%2)n=!1;else{let t;switch(i){case pp:case yp:t=c;break;case wp:case fp:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}const C=1!==d,O=1!==c;if(C&&(d/=k),O&&(c/=E),!r){const{worldTransform:e}=t;d<0&&(d=1/u.width/e.scaleX),c<0&&(c=1/u.height/e.scaleY)}if(xp(o||h,u,l,!0),g){const e={x:d,y:c};gl.limitScaleOf(t,l,e),d=e.x,c=e.y}if(C&&_){const e=u.width*t.scaleX;d=bp(e*d,_)/e}if(O&&p){const e=u.height*t.scaleY;c=bp(e*c,p)/e}return C&&Math.abs(d*f.width)<1&&(d=kp(d)/f.width),O&&Math.abs(c*f.height)<1&&(c=kp(c)/f.height),n&&d!==c&&(c=d=Math.min(d,c)),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:n,around:o}},getRotateData(t,e,i,s,n){let o,r={};switch(e){case _p:o="bottom-right";break;case gp:o="bottom-left";break;case mp:o="top-left";break;case vp:o="top-right";break;default:o="center"}return xp(n||o,t.boxBounds,r,!0),{origin:r,rotation:K.getRotation(s,t.getWorldPointByBox(r),i)}},getSkewData(t,e,i,s){let n,o,r={},a=0,h=0;switch(e){case pp:case _p:o={x:.5,y:0},n="bottom",a=1;break;case yp:case mp:o={x:.5,y:1},n="top",a=1;break;case wp:case vp:o={x:0,y:.5},n="right",h=1;break;case fp:case gp:o={x:1,y:.5},n="left",h=1}const{width:l,height:d}=t;o.x=o.x*l,o.y=o.y*d,xp(s||n,t,r,!0);const c=K.getRotation(o,r,{x:o.x+(a?i.x:0),y:o.y+(h?i.y:0)});return a?a=-c:h=c,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case wp:t=fp;break;case _p:t=gp;break;case vp:t=mp;break;case fp:t=wp;break;case gp:t=_p;break;case mp:t=vp}if(i)switch(t){case pp:t=yp;break;case _p:t=vp;break;case gp:t=mp;break;case yp:t=pp;break;case vp:t=_p;break;case mp:t=gp}return t}},Sp={};function Bp(t,e){const{enterPoint:i,dragging:s,skewing:n,resizing:o,flippedX:r,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return Tp(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:_,moveable:p,resizeable:g,rotateable:f,skewable:m}=t.mergeConfig;if("move"===l)return i.cursor=d,void(p||(i.visible=!1));if("button"===l)return void(i.cursor||(i.cursor="pointer"));let y=l.includes("resize");y&&f&&(t.isHoldRotateKey(e)||!g)&&(y=!1);const v=m&&!y&&("resize-line"===i.name||"skew"===l),w=s?n?_:o?c:u:v?_:y?c:u;h+=45*(Ep.getFlipDirection(i.direction,r,a)+1),h=2*Math.round(b.formatRotation(h,!0)/2);const{url:x,x:k,y:E}=w,S=x+h;Sp[S]?i.cursor=Sp[S]:Sp[S]=i.cursor={url:Rp(x,h),x:k,y:E}}function Tp(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function Rp(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Cp extends Al{constructor(t){super(t),this.useFastShadow=!0}}const Op=["top","right","bottom","left"],Lp=void 0;class Pp extends kl{get mergeConfig(){const{config:t}=this,{mergeConfig:e,editBox:i}=this.editor;return this.mergedConfig=t&&i!==this?Object.assign(Object.assign({},e),t):e}get target(){return this._target||this.editor.element}set target(t){this._target=t}get single(){return!!this._target||this.editor.single}get transformTool(){return this._transformTool||this.editor}set transformTool(t){this._transformTool=t}get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}get canUse(){return this.visible&&this.view.visible}get canGesture(){if(!this.canUse)return!1;const{moveable:t,resizeable:e,rotateable:i}=this.mergeConfig;return a(t)||a(e)||a(i)}constructor(t){super(),this.view=new kl,this.rect=new Cp({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Cp({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new kl({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:n,rotatePoints:o,resizeLines:r,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Cp({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),o.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Cp({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new Cp({name:"resize-point",hitRadius:5}),n.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),this.listenPointEvents(a,"move",8),s.addMany(...o,a,h,l,...r,...n),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:n,resizePoints:o,resizeLines:r}=this,{stroke:a,strokeWidth:h,resizeLine:l}=e,d=this.getPointsStyle(),c=this.getMiddlePointsStyle();let u;this.visible=!t.locked;for(let t=0;t<8;t++)u=o[t],u.set(this.getPointStyle(t%2?c[(t-1)/2%c.length]:d[t/2%d.length])),u.rotation=(t-(t%2?1:0))/2*90,t%2&&r[(t-1)/2].set(Object.assign({pointType:"resize",rotation:(t-1)/2*90},l||{}));n.set(this.getPointStyle(e.circle||e.rotatePoint||d[0])),s.set(Object.assign({stroke:a,strokeWidth:h,editConfig:Lp},e.rect||{}));const _=i&&this.transformTool.editTool;s.hittable=!_,s.syncEventer=_&&this.editor,_&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),Tp(this)}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:n,rotation:o,skewX:r,skewY:a,width:h,height:l}=this.target.getLayoutBounds("box",t,!0);this.visible=!this.target.locked,this.set({x:e,y:i,scaleX:s,scaleY:n,rotation:o,skewX:r,skewY:a}),this.updateBounds({x:0,y:0,width:h,height:l})}unload(){this.visible=!1,this.app&&(this.rect.syncEventer=this.app.interaction.bottomList=null)}updateBounds(t){const{editor:e,mergeConfig:i,single:s,rect:n,circle:o,buttons:r,resizePoints:a,rotatePoints:h,resizeLines:d}=this,{editMask:c}=e,{middlePoint:u,resizeable:_,rotateable:p,hideOnSmall:g,editBox:f,mask:m,dimOthers:y,bright:v,spread:w,hideRotatePoints:x,hideResizeLines:b}=i;if(c.visible=!!m||0,e.setDimOthers(y),e.setBright(!!y||v),w&&Rt.spread(t,w),this.view.worldOpacity){const{width:e,height:c}=t,m=l(g)?g:10,y=f&&!(g&&e<m&&c<m);let v,w,k,E={};for(let i=0;i<8;i++)ht.toPoint(ht.directionData[i],t,E),w=a[i],v=h[i],w.set(E),v.set(E),w.visible=y&&!(!_&&!p),v.visible=y&&p&&_&&!x,i%2&&(k=d[(i-1)/2],k.set(E),k.visible=w.visible&&!b,w.visible=v.visible=y&&!!u,(i+1)/2%2?(k.width=e+k.height,g&&2*w.width>e&&(w.visible=!1)):(k.width=c+k.height,g&&2*w.width>c&&(w.visible=!1)));o.visible=y&&p&&!(!i.circle&&!i.rotatePoint),o.visible&&this.layoutCircle(),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!s||f})),r.visible=y&&r.children.length>0||0,r.visible&&this.layoutButtons()}else n.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:n}=this.mergedConfig,o=Op.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,o,e||i,!!n)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:n}=this.mergedConfig,{flippedX:o,flippedY:r}=this;let a=Op.indexOf(e);(a%2&&o||(a+1)%2&&r)&&i&&(a=(a+2)%4);const h=i?Ep.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!n),i&&(t.rotation=90*(h-a)),t.scaleX=o?-1:1,t.scaleY=r?-1:1}setButtonPosition(t,e,i,s){const n=this.resizePoints[2*e+1],o=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?n.width:0)+t.boxBounds.width:(s?n.height:0)+t.boxBounds.height)/2)*r;o?(t.x=n.x+a,t.y=n.y):(t.x=n.x,t.y=n.y+a)}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:n,pointRadius:o}=this.mergedConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:n,height:n,cornerRadius:o,offsetX:0,offsetY:0,editConfig:Lp};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.mergedConfig;return u(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return u(t)?t:t?[t]:this.getPointsStyle()}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{editor:s,dragStartData:n}=this,{target:o}=this,{moveable:r,resizeable:a,rotateable:h,skewable:l,hideOnMove:d}=this.mergeConfig;"move"===i?(r&&(this.moving=!0),s.opacity=d?0:1):(i.includes("rotate")||this.isHoldRotateKey(t)||!a?(h&&(this.rotating=!0),"resize-rotate"===i?a&&(this.resizing=!0):"resize-line"===e.name&&(l&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&a&&(this.resizing=!0),"skew"===i&&l&&(this.skewing=!0)),n.x=t.x,n.y=t.y,n.point={x:o.x,y:o.y},n.bounds=Object.assign({},o.getLayoutBounds("box","local")),n.rotation=o.rotation,i&&i.includes("resize")&&(Lr.resizingKeys=s.leafList.keys)}onDragEnd(t){this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds&&this.transformTool.onMove(t),this.dragPoint=null,this.resetDoing();const{pointType:e}=t.current;"move"===e&&(this.editor.opacity=1),e&&e.includes("resize")&&(Lr.resizingKeys=null)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:n,skewing:o}=this;if(i)e.onMove(t);else if(s||n||o){const i=t.current;i.pointType&&(this.enterPoint=i),n&&e.onRotate(t),s&&e.onScale(t),o&&e.onSkew(t)}Bp(this,t)}resetDoing(){this.canUse&&(this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1)}onMove(t){this.canGesture&&"drag"!==t.moveType&&(t.stop(),a(this.mergeConfig.moveable)&&(this.gesturing=this.moving=!0,this.transformTool.onMove(t)))}onMoveEnd(t){this.moving&&this.transformTool.onMove(t),this.resetDoing()}onScale(t){this.canGesture&&(t.stop(),a(this.mergeConfig.resizeable)&&(this.gesturing=this.resizing=!0,this.transformTool.onScale(t)))}onRotate(t){this.canGesture&&(t.stop(),a(this.mergeConfig.rotateable)&&(this.gesturing=this.rotating=!0,this.transformTool.onRotate(t)))}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){Bp(this,t)}onArrow(t){const{editor:e,transformTool:i}=this;if(this.canUse&&e.editing&&this.mergeConfig.keyEvent){let e=0,s=0;const n=t.shiftKey?10:1;switch(t.code){case"ArrowDown":s=n;break;case"ArrowUp":s=-n;break;case"ArrowLeft":e=-n;break;case"ArrowRight":e=n}(e||s)&&i.move(e,s)}}onDoubleTap(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"double"!==e||i||this.openInner(t)}onLongPress(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"long"===e&&i&&this.openInner(t)}openInner(t){const{editor:e,target:i}=this;if(this.single){if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find(t=>t.editable&&t instanceof gd)||t.find(t=>t instanceof gd);if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){t.direction=i,t.pointType=e,this.__eventIds.push(t.on_([[Bd.START,this.onDragStart,this],[Bd.DRAG,this.onDrag,this],[Bd.END,this.onDragEnd,this],[kd.ENTER,e=>{this.enterPoint=t,Bp(this,e)}],[kd.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:t,editor:e,__eventIds:i}=this;i.push(t.on_([[kd.DOUBLE_TAP,this.onDoubleTap,this],[kd.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{i.push(e.app.on_([[[Ad.HOLD,Ad.UP],this.onKey,this],[Ad.DOWN,this.onArrow,this],[Cd.BEFORE_MOVE,this.onMove,this,!0],[Pd.BEFORE_ZOOM,this.onScale,this,!0],[Od.BEFORE_ROTATE,this.onRotate,this,!0],[Cd.END,this.onMoveEnd,this],[Pd.END,this.resetDoing,this],[Od.END,this.resetDoing,this]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const Ap={x:0,y:0,width:1e5,height:1e5};class Mp extends bl{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,Ap),Object.assign(this.__world,Ap)}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergedConfig;if(s&&i.editing){if(t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),e.bounds&&!e.bounds.hit(i.editBox.rect.__world,e.matrix))return;t.saveBlendMode("destination-out"),e=Object.assign(Object.assign({},e),{shape:!0}),i.list.forEach(i=>{i.__render(t,e);const{parent:s}=i;s&&s.textBox&&s.__renderShape(t,e)}),t.restoreBlendMode()}}destroy(){this.editor=null,super.destroy()}}const Dp='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',Fp={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${Dp}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${Dp}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${Dp}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,editBox:!0,hover:!0,select:"press",openInner:"double",multipleSelect:!0,boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},Ip=new Pt;function Wp(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{Ip.setListWithFn(i,t=>t.getBounds("box","page")),0===Ip.width&&(Ip.width=.1),0===Ip.height&&(Ip.height=.1),e.reset(Ip.get())}),s.add(e)}const zp=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Np=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Yp={group(t,e,i){t.sort(Np);const{app:s,parent:n}=t[0];let o;o=i&&i.add?i:new kl(i),n.addAt(o,n.children.indexOf(t[0])),t.sort(zp);const r=new et(e.worldTransform);return r.divideParent(n.scrollWorldTransform),o.setTransform(r),o.editable=!0,o.hitChildren=!1,s.lockLayout(),t.forEach(t=>t.dropTo(o)),s.unlockLayout(),o},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach(t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort(zp),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(Np),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},Hp=It.get("EditToolCreator");function Xp(){return t=>{jp.register(t)}}const Vp=Xp,jp={list:{},register(t){const{tag:e}=t.prototype;Up[e]&&Hp.repeat(e),Up[e]=t},get:(t,e)=>new Up[t](e)},{list:Up}=jp;class Gp extends J_{constructor(t,e){super(t,e)}}Gp.BEFORE_OPEN="innerEditor.before_open",Gp.OPEN="innerEditor.open",Gp.BEFORE_CLOSE="innerEditor.before_close",Gp.CLOSE="innerEditor.close";class Kp extends J_{constructor(t,e){super(t,e)}}Kp.BEFORE_GROUP="editor.before_group",Kp.GROUP="editor.group",Kp.BEFORE_UNGROUP="editor.before_ungroup",Kp.UNGROUP="editor.ungroup",Kp.BEFORE_OPEN="editor.before_open_group",Kp.OPEN="editor.open_group",Kp.BEFORE_CLOSE="editor.before_close_group",Kp.CLOSE="editor.close_group";const{updateMatrix:qp}=Uo,Zp={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},Jp="top-left";class $p extends Tl{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(br.CHANGE,e=>{if(this.checkChange&&Zp[e.attrName]){const{attrName:i,newValue:s,oldValue:n}=e,o="s"===i[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const r=this.__;r[i]=n,qp(this.parent),qp(this);const a=new et(this.__world);switch(r[i]=s,this.__layout.rotationChange(),qp(this),this.changedTransform=new et(this.__world).divide(a),i){case"x":t.move(o,0);break;case"y":t.move(0,o);break;case"rotation":t.rotateOf(Jp,o);break;case"scaleX":t.scaleOf(Jp,o,1);break;case"scaleY":t.scaleOf(Jp,1,o);break;case"skewX":t.skewOf(Jp,o,0);break;case"skewY":t.skewOf(Jp,0,o)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class Qp extends J_{constructor(t,e){super(t,e)}}Qp.BEFORE_MOVE="editor.before_move",Qp.MOVE="editor.move";class tg extends J_{constructor(t,e){super(t,e)}}tg.BEFORE_SCALE="editor.before_scale",tg.SCALE="editor.scale";class eg extends J_{constructor(t,e){super(t,e)}}eg.BEFORE_ROTATE="editor.before_rotate",eg.ROTATE="editor.rotate";class ig extends J_{constructor(t,e){super(t,e)}}ig.BEFORE_SKEW="editor.before_skew",ig.SKEW="editor.skew";class sg{onMove(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox;let n,{dragLimitAnimate:o}=i;const r=t.type===Cd.END||t.type===Bd.END,h=a(e.draggable),d=!o||r||h;if(t instanceof Cd)n=t.getLocalMove(e),d&&Bd.limitMove(e,n);else{const i={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(i.x)>Math.abs(i.y)?i.y=0:i.x=0),n=Bd.getValidMove(e,s.point,i,d)}(n.x||n.y)&&(o&&!h&&r?Uo.animateMove(this,n,l(o)?o:.3):this.move(n))}onScale(t){const{target:e,mergeConfig:i,single:s,dragStartData:n}=this.editBox;let{around:o,lockRatio:r,flipable:a,editSize:h}=i;if(t instanceof Pd)this.scaleOf(e.getBoxPoint(t),t.scale,t.scale);else{const{direction:i}=t.current;(t.shiftKey||e.lockRatio)&&(r=!0);const l=Ep.getScaleData(e,n.bounds,i,t.getInnerTotal(e),r,Ep.getAround(o,t.altKey),a,!s||"scale"===h);this.editTool&&this.editTool.onScaleWithDrag?(l.drag=t,this.scaleWithDrag(l)):this.scaleOf(l.origin,l.scaleX,l.scaleY)}}onRotate(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox,{around:n,rotateAround:o,rotateGap:r}=i,{direction:a}=t.current;let h,l;if(t instanceof Od)l=t.rotation,h=o?ht.getPoint(o,e.boxBounds):e.getBoxPoint(t);else{const i=Ep.getRotateData(e,a,t,s,t.shiftKey?null:o||e.around||e.origin||n||"center");l=s.rotation+i.rotation-e.rotation,h=i.origin}l=b.float(b.getGapRotation(l,r,e.rotation),2),l&&this.rotateOf(h,l)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:n,skewX:o,skewY:r}=Ep.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Ep.getAround(s,t.altKey));(o||r)&&this.skewOf(n,o,r)}move(t,e=0){if(!this.checkTransform("moveable"))return;_(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:n,editor:o}=this.editBox,{beforeMove:r}=s;if(r){const s=r({target:i,x:t,y:e});if(_(s))t=s.x,e=s.y;else if(!1===s)return}const a=i.getWorldPointByLocal({x:t,y:e},null,!0);n||i.safeChange(()=>i.move(t,e));const h={target:i,editor:o,moveX:a.x,moveY:a.y};this.emitEvent(new Qp(Qp.BEFORE_MOVE,h));const l=new Qp(Qp.MOVE,h);this.doMove(l),this.emitEvent(l)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{target:e,mergeConfig:i,editor:s}=this.editBox,{beforeScale:n}=i;if(n){const{origin:i,scaleX:s,scaleY:o,drag:r}=t;if(!1===n({target:e,drag:r,origin:i,scaleX:s,scaleY:o}))return}t=Object.assign(Object.assign({},t),{target:e,editor:s,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new tg(tg.BEFORE_SCALE,t));const o=new tg(tg.SCALE,t);this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:n,mergeConfig:o,single:r,editor:a}=this.editBox,{beforeScale:h}=o;if(h){const s=h({target:n,origin:t,scaleX:e,scaleY:i});if(_(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!r&&this.getChangedTransform(()=>n.safeChange(()=>n.scaleOf(t,e,i))),c={target:n,editor:a,worldOrigin:l,scaleX:e,scaleY:i,transform:d};this.emitEvent(new tg(tg.BEFORE_SCALE,c));const u=new tg(tg.SCALE,c);this.doScale(u),this.emitEvent(u)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,n=this.getWorldOrigin("center"),o=i?new et(Uo.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),r={target:e,editor:s,worldOrigin:n,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:o};this.emitEvent(new tg(tg.BEFORE_SCALE,r));const a=new tg(tg.SCALE,r);this.doScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:n,editor:o}=this.editBox,{beforeRotate:r}=s;if(r){const s=r({target:i,origin:t,rotation:e});if(l(s))e=s;else if(!1===s)return}const a=this.getWorldOrigin(t),h=!n&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),d={target:i,editor:o,worldOrigin:a,rotation:e,transform:h};this.emitEvent(new eg(eg.BEFORE_ROTATE,d));const c=new eg(eg.ROTATE,d);this.doRotate(c),this.emitEvent(c)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:n,mergeConfig:o,single:r,editor:a}=this.editBox,{beforeSkew:h}=o;if(h){const s=h({target:n,origin:t,skewX:e,skewY:i});if(_(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!r&&this.getChangedTransform(()=>n.safeChange(()=>n.skewOf(t,e,i))),c={target:n,editor:a,worldOrigin:l,skewX:e,skewY:i,transform:d};this.emitEvent(new ig(ig.BEFORE_SKEW,c));const u=new ig(ig.SKEW,c);this.doSkew(u),this.emitEvent(u)}doMove(t){this.editTool.onMove(t)}doScale(t){this.editTool.onScale(t)}doRotate(t){this.editTool.onRotate(t)}doSkew(t){this.editTool.onSkew(t)}checkTransform(t){const{target:e,mergeConfig:i}=this.editBox;return e&&!e.locked&&i[t]}getWorldOrigin(t){const{target:e}=this.editBox;return e.getWorldPoint(Uo.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const s=new et(e.worldTransform);return t(),new et(e.worldTransform).divide(s)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}let ng=class extends kl{get list(){return this.leafList.list}get dragHoverExclude(){return[this.editBox.rect]}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragPoint(){return this.editBox.dragPoint}get dragging(){return this.editBox.dragging}get gesturing(){return this.editBox.gesturing}get moving(){return this.editBox.moving}get resizing(){return this.editBox.resizing}get rotating(){return this.editBox.rotating}get skewing(){return this.editBox.skewing}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}get targetLeafer(){const t=this.list[0];return t&&t.leafer}constructor(t,e){super(e),this.leafList=new eh,this.openedGroupList=new eh,this.simulateTarget=new $p(this),this.editBox=new Pp(this),this.editToolList={},this.selector=new up(this),this.editMask=new Mp(this),this.targetEventIds=[];let i=f.clone(Fp);t&&(i=f.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),Vt.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}setDimOthers(t,e="dim",i){if(!i){const{dimTarget:t,targetLeafer:e}=this;i=t?u(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>f.stintSet(i,e,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&Wp(this),this.update()}updateEditTool(){if(this.unloadEditTool(),this.editing){const t=this.element;let e=t.editOuter||"EditTool";const{beforeEditOuter:i}=this.mergeConfig;if(i){const s=i({target:t,name:e});if(a(s))e=s;else if(!1===s)return}if(jp.list[e]){const t=this.editTool=this.editToolList[e]=this.editToolList[e]||jp.get(e,this);this.editBox.load(),t.load(),this.update()}}}unloadEditTool(){let t=this.editTool;t&&(this.editBox.unload(),t.unload(),this.editTool=null)}getEditSize(t){return this.mergeConfig.editSize}onMove(t){}onScale(t){}onRotate(t){}onSkew(t){}move(t,e=0){}scaleWithDrag(t){}scaleOf(t,e,i=e,s){}flip(t){}rotateOf(t,e){}skewOf(t,e,i=0,s){}checkTransform(t){}getWorldOrigin(t){}getChangedTransform(t){}group(t){return this.multiple&&(this.emitGroupEvent(Kp.BEFORE_GROUP),this.target=Yp.group(this.list,this.element,t),this.emitGroupEvent(Kp.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(Kp.BEFORE_UNGROUP,t)),this.target=Yp.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(Kp.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(Kp.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Kp.OPEN,t)}closeGroup(t){this.emitGroupEvent(Kp.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Kp.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!Uo.hasParent(e,t))&&e.push(t))),e.forEach(t=>this.closeGroup(t))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new Kp(t,{editTarget:e});e&&e.syncEventer||this.emitEvent(i),e&&e.emitEvent(i)}openInnerEditor(t,e,i){let s;if(a(e)?s=e:i||(i=e),t&&i&&(this.target=t),this.single){t||(t=this.element),s||(s=t.editInner);const{beforeEditInner:e}=this.mergeConfig;if(e){const i=e({target:t,name:s});if(a(i))s=i;else if(!1===i)return}jp.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[s]=this.editToolList[s]||jp.get(s,this),this.innerEditor.editTarget=t,this.emitInnerEvent(Gp.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Gp.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Gp.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Gp.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Gp(t,{editTarget:i,innerEditor:e});i.syncEventer||this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach(t=>t.locked=!0),this.update()}unlock(){this.list.forEach(t=>t.locked=!1),this.update()}toTop(){this.list.length&&(Yp.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Yp.toBottom(this.list),this.leafList.update())}onAppRenderStart(t){(this.targetChanged=t.children.some(t=>t!==this.leafer&&t.renderer.changed))&&this.editBox.forceRender()}onRenderStart(){this.targetChanged&&this.update()}onChildScroll(){this.multiple&&this.updateEditBox()}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e,targetLeafer:i,editMask:s}=this;this.targetEventIds=[e.on_(Mr.START,this.onRenderStart,this),i&&i.on_(br.SCROLL,this.onChildScroll,this),t.on_(Mr.CHILD_START,this.onAppRenderStart,this),t.on_(Dr.UPDATE_MODE,t=>{t.mode&&"normal"!==t.mode&&this.cancel()})],s.visible&&s.forceRender()}}removeTargetEvents(){const{targetEventIds:t,editMask:e}=this;t.length&&(this.off_(t),e.visible&&e.forceRender())}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach(t=>t.destroy()),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}};Qt([(t,e)=>{Vn(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,app:n}=this,a=Object.assign({},t);return e&&e.editConfig&&Object.assign(a,e.editConfig),s.config&&Object.assign(a,s.config),i&&(i.editConfig&&Object.assign(a,i.editConfig),"font-size"===a.editSize&&(a.lockRatio=!0),"resize-rotate"===i.pointType&&(a.around||(a.around="center"),r(a.lockRatio)&&(a.lockRatio=!0))),o(a.dragLimitAnimate)&&(a.dragLimitAnimate=n&&n.config.pointer.dragLimitAnimate),this.mergedConfig=a}})}],ng.prototype,"mergeConfig",void 0),Qt([$_(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof eh?i:new eh(i),t.multiple&&Wp(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new J_(J_.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new J_(J_.AFTER_SELECT,s))})],ng.prototype,"target",void 0),Qt([$_(function(t,e){t.emitEvent(new J_(J_.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],ng.prototype,"hoverTarget",void 0),ng=Qt([Po(sg,["editBox","editTool","emitEvent"])],ng);class og{static registerInnerEditor(){jp.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get editBox(){return this.editor.editBox}constructor(t){this.eventIds=[],this.editor=t,this.create()}onCreate(){}create(){this.view=new kl,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!0),this.onUnload())}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}let rg=class extends og{static registerEditTool(){jp.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:n,list:o}=s;n.lockLayout(),o.forEach(t=>{t.moveWorld(e,i)}),n.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach(t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(n,e,i,r)}),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:n}=t,{app:o,list:r}=n;o.lockLayout(),r.forEach(t=>{const o="scale"!==n.getEditSize(t);i?t.transformWorld(i,o):t.rotateOfWorld(s,e)}),o.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach(t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(n,e,i,r)}),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){this.editBox.update(),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};rg=Qt([Xp()],rg);const{left:ag,right:hg}=rt,{move:lg,copy:dg,toNumberPoints:cg}=K;let ug=class extends rg{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:n}=t,o=t.target,r=i===ag;if(o.pathInputed){const{path:t}=o.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,o.path=t}else if(o.points){const{points:t}=o,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,o.points=t}else{const t={x:0,y:0},{toPoint:i}=o;o.rotation=0,this.dragPoint(t,i,r,n,this.getInnerMove(o,e,s)),o.getLocalPointByInner(t,null,null,!0),o.getLocalPointByInner(i,null,null,!0),o.x=t.x,o.y=t.y,o.getInnerPointByLocal(i,null,null,!0),o.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){const e=cg(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,n){const{x:o,y:r}=n;i?(lg(t,o,r),s&&lg(e,-o,-r)):(s&&lg(t,-o,-r),lg(e,o,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:n}=t,o=this.editor.element;let r,a;if(o.pathInputed?r=this.getFromToByPath(o.__.path):o.points&&(r=this.getFromToByPoints(o.__.points)),r){const{from:i,to:a}=r;o.innerToWorld(i,i,!1,t),o.innerToWorld(a,a,!1,t),n.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),dg(s[7],i),dg(e[7],i),dg(s[3],a),dg(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===ag||t===hg,s[t].visible=a,e[t].visible=!r&&a}};ug=Qt([Xp()],ug);const{M:_g,L:pg,C:gg,Q:fg,Z:mg,N:yg,D:vg,X:wg,G:xg,F:bg,O:kg,P:Eg,U:Sg}=me,Bg={scale(t,e,i){if(!t)return;let s,n=0,o=t.length;for(;n<o;)switch(s=t[n],s){case _g:case pg:Tg(t,e,i,n,1),n+=3;break;case gg:Tg(t,e,i,n,3),n+=7;break;case fg:Tg(t,e,i,n,2),n+=5;break;case mg:n+=1;break;case yg:Tg(t,e,i,n,2),n+=5;break;case vg:Tg(t,e,i,n,2),n+=9;break;case wg:Tg(t,e,i,n,2),n+=6;break;case xg:Tg(t,e,i,n,2),n+=9;break;case bg:Tg(t,e,i,n,2),n+=5;break;case kg:t[n]=xg,t.splice(n+4,0,t[n+3],0),Tg(t,e,i,n,2),n+=9,o+=2;break;case Eg:t[n]=bg,t.splice(n+4,0,t[n+3]),Tg(t,e,i,n,2),n+=5,o+=1;break;case Sg:Tg(t,e,i,n,2),n+=6}},scalePoints(t,e,i,s,n){for(let o=n?s+1:0,r=n?o+2*n:t.length;o<r;o+=2)t[o]*=e,t[o+1]*=i}},{scalePoints:Tg}=Bg,Rg=I.get(),{topLeft:Cg,top:Og,topRight:Lg,right:Pg,bottom:Ag,left:Mg}=rt;function Dg(t,e,i){t.pathInputed?Ig(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function Fg(t,e,i,s){let n=e;if(!o(s)){const o=t.__layout;let{width:r,height:a}=o.boxBounds;switch(r*=i-e,a*=e-i,s){case Og:case Ag:n=i,o.affectScaleOrRotation?t.moveInner(-r/2,0):t.x-=r/2;break;case Mg:case Pg:o.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case Cg:case Lg:o.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const r=t.__,{padding:a}=r;a&&(t.padding=u(a)?a.map(t=>t*n):a*n),r.__autoWidth||(t.width*=n),r.__autoHeight||(t.height*=n)}function Ig(t,e,i){Bg.scale(t.__.path,e,i),t.path=t.__.path}function Wg(t,e,i){const{points:s}=t;_(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):Bg.scalePoints(s,e,i),t.points=s}function zg(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)Rg.a=e,Rg.d=i,s[t].transform(Rg,!0)}const Ng=Va.prototype;Ng.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},Ng.__scaleResize=function(t,e){Dg(this,t,e)},Ng.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},Ng.resizeHeight=function(t){const e=t/this.getBounds("box","local").height||1;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},gd.prototype.__scaleResize=function(t,e){const{app:i,editConfig:s}=this,n=i&&i.editor,o=n&&n.dragPoint;if(this.__.resizeFontSize||s&&"font-size"===s.editSize||o&&"font-size"===n.mergedConfig.editSize)Fg(this,t,e,o&&o.direction);else{const{__autoWidth:i,__autoHeight:s,textAlign:n,verticalAlign:o}=this.__,{boxBounds:r}=this.__layout;i&&"left"!==n&&1!==t&&(this.x+=r.x),s&&"top"!==o&&1!==e&&(this.y+=r.y),Dg(this,t,e)}},fd.prototype.__scaleResize=function(t,e){Ig(this,t,e)},ad.prototype.__scaleResize=function(t,e){this.pathInputed?Ig(this,t,e):this.points?Wg(this,t,e):this.width*=t},Ul.prototype.__scaleResize=function(t,e){this.pathInputed?Ig(this,t,e):this.points?Wg(this,t,e):Dg(this,t,e)},kl.prototype.__scaleResize=function(t,e){zg(this,t,e)},Al.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||Dg(this,t,e),i&&zg(this,t,e)},Vt.add("resize"),Vt.add("editor","resize"),jt.editor=function(t,e){const i=new ng(t);return e&&e.sky.add(e.editor=i),i},Al.addAttr("textBox",!1,Zn),bl.addAttr("editConfig",void 0,Zn),bl.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),Zn),bl.addAttr("editInner","PathEditor",Zn),kl.addAttr("editInner","",Zn),gd.addAttr("editInner","TextEditor",Zn),bl.setEditConfig=function(t){this.changeAttr("editConfig",t)},bl.setEditOuter=function(t){this.changeAttr("editOuter",t)},bl.setEditInner=function(t){this.changeAttr("editInner",t)};const Yg={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},Hg={top:"flex-start",middle:"center",bottom:"flex-end"},Xg={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function Vg(t,e,i){const{style:s}=t,{fill:n,padding:r,textWrap:h,textOverflow:l,textDecoration:d}=e;let c;s.fontFamily=e.fontFamily,s.fontSize=e.fontSize*i+"px",function(t,e){let i="black";u(e)&&(e=e[0]);if(_(e))switch(e.type){case"solid":i=Oh.string(e.color);break;case"image":break;case"linear":case"radial":case"angular":const t=e.stops[0];i=Oh.string(a(t)?t:t.color);break;default:o(e.r)||(i=Oh.string(e))}else i=e;t.color=i}(s,n),s.fontStyle=e.italic?"italic":"normal",s.fontWeight=e.fontWeight,_(d)?(c=d.type,d.color&&(s.textDecorationColor=Oh.string(d.color))):c=d,s.textDecoration=Xg[c],s.textTransform=Yg[e.textCase],s.textAlign="both"===e.textAlign?"justify":e.textAlign,s.display="flex",s.flexDirection="column",s.justifyContent=Hg[e.verticalAlign],s.lineHeight=(e.__.__lineHeight||0)*i+"px",s.letterSpacing=(e.__.__letterSpacing||0)*i+"px",s.whiteSpace="none"===h||e.__.__autoWidth?"nowrap":"normal",s.wordBreak="break"===h?"break-all":"normal",s.textIndent=(e.paraIndent||0)*i+"px",s.padding=u(r)?r.map(t=>t*i+"px").join(" "):(r||0)*i+"px",s.textOverflow="show"===l?"":"hide"===l?"clip":l}let jg=class extends og{constructor(){super(...arguments),this.config={selectAll:!0},this.eventIds=[]}get tag(){return"TextEditor"}onLoad(){const{editor:t}=this,{config:e}=t.app,i=this.editTarget;i.textEditing=!0,this.isHTMLText=!(i instanceof gd),this._keyEvent=e.keyEvent,e.keyEvent=!1;const s=this.editDom=document.createElement("div"),{style:n}=s;s.contentEditable="true",n.position="fixed",n.transformOrigin="left top",n.boxSizing="border-box",this.isHTMLText?s.innerHTML=String(i.text):s.innerText=String(i.text);const{view:o}=t.app;(this.inBody=o instanceof HTMLCanvasElement)?document.body.appendChild(s):o.appendChild(s),this.eventIds=[t.app.on_(kd.DOWN,e=>{let i,{target:n}=e.origin;for(;n;)n===s&&(i=!0),n=n.parentElement;i||t.closeInnerEditor()})],this.onFocus=this.onFocus.bind(this),this.onInput=this.onInput.bind(this),this.onPaste=this.onPaste.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onKeydown=this.onKeydown.bind(this),s.addEventListener("focus",this.onFocus),s.addEventListener("input",this.onInput),s.addEventListener("paste",this.onPaste),window.addEventListener("keydown",this.onKeydown),window.addEventListener("scroll",this.onUpdate);const r=window.getSelection(),a=document.createRange();if(this.config.selectAll)a.selectNodeContents(s);else{const t=s.childNodes[0];a.setStartAfter(t),a.setEndAfter(t),a.collapse(!0)}r.removeAllRanges(),r.addRange(a)}onInput(){const{editDom:t}=this;this.editTarget.text=this.isHTMLText?t.innerHTML:t.innerText}onFocus(){this.editDom.style.outline="none"}onKeydown(t){if("Escape"===t.code&&this.editor.closeInnerEditor(),"Enter"===t.key){t.preventDefault();const e=document.createElement("br"),i=document.createTextNode("​"),s=window.getSelection().getRangeAt(0);s.deleteContents(),s.insertNode(i),s.insertNode(e),s.setStartAfter(e),s.setEndAfter(e),this.onInput()}}onPaste(t){if(this.isHTMLText)return;t.preventDefault();const e=t.clipboardData;if(!e)return;let i=e.getData("text/plain").replace(/\r\n?/g,"\n");const s=window.getSelection();if(!s||!s.rangeCount)return;const n=s.getRangeAt(0);n.deleteContents();const o=i.split("\n"),r=document.createDocumentFragment();o.forEach((t,e)=>{e>0&&r.appendChild(document.createElement("br")),r.appendChild(document.createTextNode(t))}),n.insertNode(r),n.collapse(!1),s.removeAllRanges(),s.addRange(n),this.onInput()}onUpdate(){const{editTarget:t}=this;let e=1;if(!this.isHTMLText){const{scaleX:i,scaleY:s}=t.worldTransform;e=Math.max(Math.abs(i),Math.abs(s));t.fontSize*e<12&&(e*=12/t.fontSize)}this.textScale=e;let{width:i,height:s}=t,n=0,o=0;i*=e,s*=e;const r=t.__;if(r.__autoWidth&&(i+=20,r.autoSizeAlign))switch(r.textAlign){case"center":n=-i/2;break;case"right":n=-i}if(r.__autoHeight&&(s+=20,r.autoSizeAlign))switch(r.verticalAlign){case"middle":o=-s/2;break;case"bottom":o=-s}const{x:a,y:h}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds,{a:l,b:d,c:c,d:u,e:_,f:p}=new et(t.worldTransform).scale(1/e).translateInner(n,o),{style:g}=this.editDom;g.transform=`matrix(${l},${d},${c},${u},${_},${p})`,g.left=a+"px",g.top=h+"px",g.width=i+"px",g.height=s+"px",this.isHTMLText||Vg(this.editDom,t,e)}onUnload(){const{editTarget:t,editor:e,editDom:i}=this;t&&(this.onInput(),"\n"===t.text&&(t.text=""),t.textEditing=void 0,e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),i.removeEventListener("focus",this.onFocus),i.removeEventListener("input",this.onInput),i.removeEventListener("paste",this.onPaste),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("scroll",this.onUpdate),i.remove(),this.editDom=this.eventIds=void 0)}};function Ug(t,e,i){Gg(t.parentApp?t.parentApp:t,e),t.isApp||i||t.__eventIds.push(t.on_(Cd.BEFORE_MOVE,e=>{t.zoomLayer.move(t.getValidMove(e.moveX,e.moveY,!1))}),t.on_(Cd.END,e=>{Uo.animateMove(t.zoomLayer,t.getValidMove(e.moveX,e.moveY))}),t.on_(Pd.BEFORE_ZOOM,e=>{const{zoomLayer:i}=t,s=t.getValidScale(e.scale);1!==s&&i.scaleOfWorld(e,s)}))}function Gg(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&f.assign(i,e),f.assign(t.config,i,t.userConfig)}jg=Qt([Vp()],jg),Vt.add("text-editor","editor");const Kg=It.get("LeaferTypeCreator"),qg={list:{},register(t,e){Zg[t]&&Kg.repeat(t),Zg[t]=e},run(t,e){const i=Zg[t];i&&i(e)}},{list:Zg,register:Jg}=qg;Jg("viewport",Ug),Jg("custom",function(t){Ug(t,null,!0)}),Jg("design",function(t){Ug(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),Jg("document",function(t){Ug(t,{zoom:{min:1},move:{scroll:"limit"}})});const $g={getData(t){const e=t[0],i=t[1],s=K.getCenter(e.from,i.from),n=K.getCenter(e.to,i.to),o={x:n.x-s.x,y:n.y-s.y},r=K.getDistance(e.from,i.from);return{move:o,scale:K.getDistance(e.to,i.to)/r,rotation:K.getRotation(e.from,i.from,e.to,i.to),center:n}}},{abs:Qg,max:tf}=Math,{sign:ef,within:sf}=b,nf={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;t.shiftKey&&!s&&(s=n,n=0);const o=Qg(s),r=Qg(n);return o>50&&(s=tf(50,o/3)*ef(s)),r>50&&(n=tf(50,r/3)*ef(n)),{x:-s*i*2,y:-n*i*2}},getScale(e,i){let s,n=1,{zoomMode:o,zoomSpeed:r}=i;const a=e.deltaY||e.deltaX;if(o?(s="mouse"===o||!e.deltaX&&(t.intWheelDeltaY?Math.abs(a)>17:Math.ceil(a)!==a),(e.shiftKey||e.metaKey||e.ctrlKey)&&(s=!0)):s=!e.shiftKey&&(e.metaKey||e.ctrlKey),s){r=sf(r,0,1);const t=e.deltaY?i.delta.y:i.delta.x,s=sf(1-Qg(a)/(4*t)*r,.5,2);n=a>0?s:1/s}return n}};class of{get transforming(){return!!(this.moveData||this.zoomData||this.rotateData)}constructor(t){this.interaction=t}move(t){const{interaction:e}=this;t.moveType||(t.moveType="move"),this.moveData||(this.setPath(t),this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0}),e.emit(Cd.START,this.moveData)),t.path=this.moveData.path,e.emit(Cd.BEFORE_MOVE,t),e.emit(Cd.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;this.zoomData||(this.setPath(t),this.zoomData=Object.assign(Object.assign({},t),{scale:1}),e.emit(Pd.START,this.zoomData)),t.path=this.zoomData.path,e.emit(Pd.BEFORE_ZOOM,t),e.emit(Pd.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;this.rotateData||(this.setPath(t),this.rotateData=Object.assign(Object.assign({},t),{rotation:0}),e.emit(Od.START,this.rotateData)),t.path=this.rotateData.path,e.emit(Od.BEFORE_ROTATE,t),e.emit(Od.ROTATE,t),this.transformEndWait()}setPath(t){const{interaction:e}=this,{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,e.cancelHover()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout(()=>{this.transformEnd()},this.interaction.p.transformTime)}transformEnd(){const{interaction:t,moveData:e,zoomData:i,rotateData:s}=this;e&&t.emit(Cd.END,e),i&&t.emit(Pd.END,i),s&&t.emit(Od.END,s),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const rf=Bl.prototype,af=new Pt,hf=new Q;function lf(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function df(t,e){return Object.assign(Object.assign({},e),{scale:t})}rf.initType=function(t){qg.run(t,this)},rf.getValidMove=function(t,e,i=!0){const{scroll:s,disabled:n}=this.app.config.move;if(hf.set(t,e),s){const t=!0===s?"":s;t.includes("x")?hf.y=0:t.includes("y")?hf.x=0:Math.abs(hf.x)>Math.abs(hf.y)?hf.y=0:hf.x=0,i&&t.includes("limit")&&(af.set(this.__world).addPoint(this.zoomLayer),gl.getValidMove(af,this.canvas.bounds,"inner",hf,!0),t.includes("x")?hf.y=0:t.includes("y")&&(hf.x=0))}return{x:n?0:hf.x,y:n?0:hf.y}},rf.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,o=Math.abs(e*t);return i&&o<i?t=i/e:s&&o>s&&(t=s/e),n?1:t};const cf=Zd.prototype;cf.createTransformer=function(){this.transformer=new of(this)},cf.move=function(t){this.transformer.move(t)},cf.zoom=function(t){this.transformer.zoom(t)},cf.rotate=function(t){this.transformer.rotate(t)},cf.transformEnd=function(){this.transformer.transformEnd()},cf.wheel=function(t){const{wheel:e,pointer:i}=this.config,{posDeltaSpeed:s,negDeltaSpeed:n}=e;if(e.disabled)return;t.deltaX>0?s&&(t.deltaX*=s):n&&(t.deltaX*=n),t.deltaY>0?s&&(t.deltaY*=s):n&&(t.deltaY*=n);const o=e.getScale?e.getScale(t,e):nf.getScale(t,e);if(1!==o)this.zoom(df(o,t));else{const s=e.getMove?e.getMove(t,e):nf.getMove(t,e);i.snap&&K.round(s),this.move(lf(s,t))}},cf.multiTouch=function(t,e){if(this.config.multiTouch.disabled)return;const{move:i,rotation:s,scale:n,center:o}=$g.getData(e);Object.assign(t,o),t.multiTouch=!0,this.pointerWaitCancel(),this.rotate(function(t,e){return Object.assign(Object.assign({},e),{rotation:t})}(s,t)),this.zoom(df(n,t)),this.move(lf(i,t))};const uf=Nd.prototype,{abs:_f}=Math;function pf(t,e){let i=1;const s="out"===e,n=Math.abs(t);if(n>1){for(;s?i<n:i<=n;)i*=2;s&&(i/=2)}else{for(;s?i>=n:i>n;)i/=2;s||(i*=2)}return i/t}uf.checkDragEndAnimate=function(t,e){const{moveX:i,moveY:s}=this.dragData,n=_f(i),o=_f(s),r=e?1:.1,a=this.canAnimate&&this.moving&&(n>r||o>r)&&this.interaction.m.dragAnimate;if(a){const r="touch"===t.pointerType?3:1,h=70;n*(e=e?l(a)?a:.95:r)>h?e=h/n:o*e>h&&(e=h/o),t=Object.assign({},t),K.move(t,i*e,s*e),this.drag(t),this.animate(()=>{this.dragEnd(t,1)})}return a},uf.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},uf.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},uf.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:n,dragOut:o}=e.m;if(!o||!s||!n)return;const r=e.shrinkCanvasBounds,{x:a,y:h}=r,l=Rt.maxX(r),d=Rt.maxY(r),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let _=0,p=0;this.autoMoveTimer=setInterval(()=>{_+=c,p+=u,K.move(i,c,u),K.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:_,totalY:p,moveType:"drag"})),e.pointerMoveReal(t)},10)},uf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},Vt.add("viewport"),Vt.add("view"),Bl.prototype.zoom=function(t,e,i,s){let n;this.killAnimate(),p(e)?(n=e.padding,i=e.scroll,s=e.transition):n=e;const{zoomLayer:o}=this,h=this.canvas.bounds.clone().shrink(r(n)?30:n),d=new Pt,c={x:h.x+h.width/2,y:h.y+h.height/2};let g;const{x:f,y:m,scaleX:y,scaleY:v}=o.__;if(a(t))switch(t){case"in":g=pf(y,"in");break;case"out":g=pf(y,"out");break;case"fit":t=this.boxBounds;break;case"fit-width":(t=new Pt(this.boxBounds)).height=0;break;case"fit-height":(t=new Pt(this.boxBounds)).width=0}else l(t)&&(g=t/y);if(g)g=this.getValidScale(g),o.scaleOfWorld(c,g,g,!1,s);else if(_(t)){const e={x:f,y:m,scaleX:y,scaleY:v},n=u(t);if(n||t.tag){const e=n?t:[t];d.setListWithFn(e,tr.worldBounds)}else{const e=function(t,e){let i,{x:s,y:n,width:o,height:r}=t;return r||(r=o*(e.height/e.width),i=!0),o||(o=r*(e.width/e.height),i=!0),i?{x:s,y:n,width:o,height:r}:t}(t,h);d.set(o.getWorldBounds(e))}const{width:r,height:a}=d;let l=h.x-d.x,c=h.y-d.y;return i?(l+=Math.max((h.width-r)/2,0),c+=Math.max((h.height-a)/2,0)):(g=this.getValidScale(Math.min(h.width/r,h.height/a)),l+=(h.width-r*g)/2,c+=(h.height-a*g)/2,K.scaleOf(e,d,g),d.scaleOf(d,g),e.scaleX*=g,e.scaleY*=g),"x"===i?c=0:"y"===i&&(l=0),K.move(e,l,c),d.move(l,c),o.set(e,s),d}return o.worldBoxBounds};class gf extends kl{get isOutside(){return!0}constructor(t,e){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,e&&f.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(t){let e;a(t)?(e={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===t&&(e.fill="white",e.stroke="rgba(0,0,0,0.2)")):e=t,this.scrollXBar||this.addMany(this.scrollXBar=new Al,this.scrollYBar=new Al),e=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},e),e.height||(e.height=e.width),this.scrollXBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:e,padding:i}=this.config,{zoomLayer:s,canvas:n}=this.target.leafer,{worldRenderBounds:o}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(o))return;this.scrollBounds=new Pt(o);const r=n.bounds.clone().shrink(i),a=r.clone().add(o),h=this.ratioX=r.width/a.width,l=this.ratioY=r.height/a.height,d=(r.x-a.x)/a.width,c=(r.y-a.y)/a.height,u=h<1,_=l<1,{scrollXBar:p,scrollYBar:g}=this,{x:f,y:m,width:y,height:v}=r.shrink([2,_?g.width+6:2,u?p.height+6:2,2]);p.set({x:f+y*d,y:m+v+2,width:Math.max(y*h,e),visible:u}),g.set({x:f+y+2,y:m+v*c,height:Math.max(v*l,e),visible:_})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const e=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(e?-t.moveX/this.ratioX:0,e?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:t,scrollYBar:e}=this;this.__eventIds=[t.on_(Bd.DRAG,this.onDrag,this),e.on_(Bd.DRAG,this.onDrag,this),t.on_(Bd.END,this.onDragEnd,this),e.on_(Bd.END,this.onDragEnd,this),this.target.on_(Mr.BEFORE,()=>this.update(!0)),this.target.leafer.on_(Lr.RESIZE,()=>this.update())]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}Vt.add("scroll");class ff extends hl{setText(t){this._text=t,this.__htmlChanged=!0}}let mf=class extends hd{get __tag(){return"HTMLText"}constructor(t){super(t)}__updateBoxBounds(){const t=this.__;if(t.__htmlChanged){const e=document.createElement("div"),{style:i}=e;i.all="initial",i.position="absolute",i.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:s,height:n}=e.getBoundingClientRect(),o=s+10,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${n}">\n <foreignObject width="${o}" height="${n}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.text}\n </body>\n </foreignObject>\n </svg>`;t.__setImageFill("data:image/svg+xml,"+encodeURIComponent(r)),t.__naturalWidth=o/t.pixelRatio,t.__naturalHeight=n/t.pixelRatio,t.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}__draw(t,e,i){this.textEditing&&!e.exporting||super.__draw(t,e,i)}};Qt([ko(ff)],mf.prototype,"__",void 0),Qt([io("")],mf.prototype,"text",void 0),Qt([Zn("TextEditor")],mf.prototype,"editInner",void 0),Qt([uo(!1)],mf.prototype,"textEditing",void 0),mf=Qt([Ao()],mf),Vt.add("html");class yf extends Qh{}function vf(t){return Gn(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,ho(this)}}}))}let wf=class extends ad{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){Ph.register(t,e)}};Qt([ko(yf)],wf.prototype,"__",void 0),Qt([vf("angle")],wf.prototype,"endArrow",void 0),wf=Qt([Ao()],wf);const{M:xf,L:bf,C:kf,Q:Ef,O:Sf}=me,{rotate:Bf,copyFrom:Tf,scale:Rf}=K,Cf={},Of={layout(t,e,i,s,n,o,r){let a,h,l=0,d=t.length;for(;l<d;)switch(a=t[l],a){case xf:case bf:Lf(t,l+1,e,i,s,n,o,r),l+=3;break;case kf:for(h=1;h<6;h+=2)Lf(t,l+h,e,i,s,n,o,r);l+=7;break;case Ef:for(h=1;h<4;h+=2)Lf(t,l+h,e,i,s,n,o,r);l+=5;break;case Sf:t[l+1]+=e,t[l+2]+=i,s&&(t[l+3]*=s),o&&(t[l+4]+=o,t[l+5]+=o),l+=7}},rotate(t,e,i){Of.layout(t,0,0,1,1,e,i)}};function Lf(t,e,i,s,n,o,r,a){Tf(Cf,t[e],t[e+1]),r&&Bf(Cf,r,a),n&&Rf(Cf,n,o),t[e]=i+Cf.x,t[e+1]=s+Cf.y}const{layout:Pf,rotate:Af}=Of,{getAngle:Mf}=K,Df={x:-.5},Ff={connect:Df,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},If={connect:Df,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},Wf={connect:Df,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},zf={connect:Df,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},Nf={offset:Df,path:[...Wf.path],dashPath:[1,-2.5,0,2,-1,0]};Af(Nf.path,180,{x:-1.5,y:0});const Yf={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},Hf={connect:{x:.5},path:[...Yf.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},Xf={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},Vf={path:[...Xf.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},jf=f.clone(Xf),Uf=f.clone(Vf);Af(jf.path,45),Af(Uf.path,45);const Gf={angle:Ff,"angle-side":If,arrow:zf,triangle:Wf,"triangle-flip":Nf,circle:Hf,"circle-line":Yf,square:Vf,"square-line":Xf,diamond:Uf,"diamond-line":jf,mark:{offset:Df,path:[1,0,-2,2,0,2]}};function Kf(t,e,i,s,n,o,r){let a,h;const{strokeCap:l,strokeJoin:d}=t.__;_(e)?e.type?(h=e.scale,a=Gf[e.type]):a=e:a=Gf[e];const{offset:c,connect:u,path:p,dashPath:g}=a;let f=u?u.x:0,m=c?c.x:0;const y=[...p];return r&&g&&y.push(...g),"none"!==l&&(f-=.5),c&&("round"===d&&c.roundJoin?m+=c.roundJoin:"bevel"===d&&c.bevelJoin&&(m+=c.bevelJoin)),h&&Pf(y,0,0,h,h),m&&Pf(y,m,0),Pf(y,s.x,s.y,n,n,Mf(i,s)),o.x=(f+m)*n,y}const{M:qf,L:Zf,C:Jf,Q:$f,Z:Qf,N:tm,D:em,X:im,G:sm,F:nm,O:om,P:rm,U:am}=me,{copy:hm,copyFrom:lm,getDistancePoint:dm}=K,cm={},um={},_m={},pm={},gm={},fm={list:Gf,addArrows(t){const{startArrow:e,endArrow:i,strokeWidth:s,dashPattern:n,__pathForRender:o,cornerRadius:r}=t.__,a=!r;let h,l=0,d=o.length,c=0,u=e&&"none"!==e;for(;l<d;){switch(h=o[l],h){case qf:case Zf:(c<2||l+6>=d)&&(lm(gm,o[l+1],o[l+2]),!c&&u&&hm(um,gm)),l+=3;break;case Jf:(1===c||l+7>=d-3)&&mm(o,pm,gm,l+3),l+=7;break;case $f:(1===c||l+5>=d-3)&&mm(o,pm,gm,l+1),l+=5;break;case Qf:return;case tm:l+=5;break;case em:l+=9;break;case im:l+=6;break;case sm:l+=9;break;case nm:l+=5;break;case om:l+=7;break;case rm:l+=4;break;case am:(1===c||l+6>=d-3)&&(mm(o,pm,gm,l+1),l+6!==d&&(gm.x-=(gm.x-pm.x)/10,gm.y-=(gm.y-pm.y)/10)),l+=6}if(c++,1===c&&h!==qf)return;if(2===c&&u&&hm(_m,h===Zf?gm:pm),l===d){const r=t.__.__pathForRender=a?[...o]:o,d=t.__.__pathForArrow=[];if(u){const i=Kf(t,e,_m,um,s,cm,!!n);n?d.push(...i):r.push(...i),cm.x&&(dm(um,_m,-cm.x,!0),r[1]=_m.x,r[2]=_m.y)}if(i&&"none"!==i){const e=Kf(t,i,pm,gm,s,cm,!!n);if(n?d.push(...e):r.push(...e),cm.x){let t;switch(dm(gm,pm,-cm.x,!0),h){case Zf:t=l-3+1;break;case Jf:t=l-7+5;break;case $f:t=l-5+3;break;case am:t=l-6+3}t&&ym(r,pm,t)}}}else hm(pm,gm)}},register(t,e){this.list[t]=e},get(t){return this.list[t]}};function mm(t,e,i,s){lm(e,t[s],t[s+1]),lm(i,t[s+2],t[s+3])}function ym(t,e,i){t[i]=e.x,t[i+1]=e.y}Vt.add("arrow"),bl.addAttr("startArrow","none",vf),bl.addAttr("endArrow","none",vf),Object.assign(Ph,fm),Object.assign(Ah,{strokeArrow(t,e,i){e.__.dashPattern&&(i.beginPath(),e.__drawPathByData(i,e.__.__pathForArrow),i.dashPattern=null,i.stroke())}});let vm=class extends Al{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};Qt([ko(class extends Zh{})],vm.prototype,"__",void 0),Qt([Qn("x")],vm.prototype,"flow",void 0),vm=Qt([Ao()],vm);const wm={},xm={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},bm={"top-left":"from",top:"from","top-right":"from",right:"center","bottom-right":"to",bottom:"to","bottom-left":"to",left:"center",center:"center","baseline-left":"to","baseline-center":"to","baseline-right":"to"};function km(t,e,i){const s=t.__,{contentBounds:n}=t.__layout;ct.toPoint(i,e,n,wm),e.x=s.__autoWidth?n.x:wm.x,e.y=s.__autoHeight?n.y:wm.y}const{move:Em}=K;function Sm(t,e,i,s,n,o){const{children:r}=t;let a,h,{x:l,start:d}=e,c=s;l+=i;for(let t=0,i=e.count;t<i;t++)a=r[o?d-t:d+t],a.__.inFlow&&0!==a.__.visible?(h=a.__flowBounds,"from"!==n&&(c=s+(e.height-h.height)/("center"===n?2:1)),Em(a,l-h.x,c-h.y),l+=h.width+e.gap):i++}function Bm(t,e,i){const s="width"===i?"height":"width";t[i]=Math.max(t[i],e[i]),t[s]+=t.count?e[s]+t.gap:e[s],t.list.push(e),t.count++}const Tm={};function Rm(t,e){const{gap:i,flowAlign:s,flowWrap:n,__autoWidth:o,__autoHeight:r}=t.__,h=n&&(e?!o:!r);return _(i)?(Tm.xGap=i.x||0,Tm.yGap=i.y||0):Tm.xGap=Tm.yGap=c(i),Tm.isAutoXGap=a(Tm.xGap)&&!o,Tm.isAutoYGap=a(Tm.yGap)&&!r,Tm.complex=h||"top-left"!==s||t.__hasGrow||Tm.isAutoXGap||Tm.isAutoYGap,Tm.wrap=h,Tm.complex&&(Tm.isFitXGap="fit"===Tm.xGap&&!o,Tm.isFitYGap="fit"===Tm.yGap&&!r,_(s)?(Tm.contentAlign=s.content||"top-left",Tm.rowXAlign=s.x||"from",Tm.rowYAlign=s.y||"from"):(Tm.contentAlign=s,Tm.rowXAlign=xm[s],Tm.rowYAlign=bm[s])),Tm}function Cm(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function Om(t,e,i,s){const{count:n}=t;n>1&&(i>t[e]||s)&&(t.gap=(i-t[e])/(n-1),t[e]=i)}function Lm(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:Pm}=b;function Am(t,e,i,s){let n,o,r,a=0,h=e.hasRangeSize&&[],{grow:l,start:d}=e;const c=(i-e.width)/l,{children:u}=t;if(!(c<=0)){e.width=i;for(let t=0,i=e.count;t<i;t++)n=u[s?d-t:d+t],n.__.inFlow&&0!==n.__.visible?(o=n.__widthGrow)&&(r=Mm(n,n.__flowBounds,c*o),r?(a+=r,l-=o):h&&(n.__.widthRange?h.unshift(n):h.push(n))):i++;a&&function(t,e,i){let s,n,o,r;t.forEach(t=>{s=t.__widthGrow,n=e/i*s,r=Mm(t,o=t.__flowBounds,o.width+n),e-=n-r,i-=s})}(h,a,l)}}function Mm(t,e,i){const{widthRange:s,lockRatio:n}=t.__,o=s?Pm(i,s):i,r=o/e.width;return t.scaleResize(r,n?r:1),e.width=o,i-o}const{within:Dm}=b;function Fm(t,e,i,s){let n,o,r,a=0,h=e.hasRangeSize&&[],{grow:l,start:d}=e;const c=(i-e.height)/l,{children:u}=t;if(!(c<=0)){e.height=i;for(let t=0,i=e.count;t<i;t++)n=u[s?d-t:d+t],n.__.inFlow&&0!==n.__.visible?(o=n.__heightGrow)&&(r=Im(n,n.__flowBounds,c*o),r?(a+=r,l-=o):h&&(n.__.heightRange?h.unshift(n):h.push(n))):i++;a&&function(t,e,i){let s,n,o,r;t.forEach(t=>{s=t.__heightGrow,n=e/i*s,r=Im(t,o=t.__flowBounds,o.height+n),e-=n-r,i-=s})}(h,a,l)}}function Im(t,e,i){const{heightRange:s,lockRatio:n}=t.__,o=s?Dm(i,s):i,r=o/e.height;return t.scaleResize(n?r:1,r),e.height=o,i-o}const{move:Wm}=K;function zm(t,e){const i="width",{children:s,itemBox:n}=t,o=Rm(t,!0),{complex:r,wrap:a,xGap:h,yGap:l,isAutoXGap:d,isFitXGap:c}=o;if(!s.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},_=d?0:h;let p,g,f,m,y,{x:v,y:w,width:x,height:b}=t.__layout.contentBounds;for(let o=0,h=s.length;o<h;o++)p=s[m=e?h-1-o:o],p.__.inFlow&&0!==p.__.visible&&(g=Lm(p,n),r?(p.__flowBounds=g,y||(y=Cm(m,_)),a&&y.count&&y.width+g.width>x&&(y.grow?Am(t,y,x,e):d&&Om(y,i,x,c),Bm(u,y,i),y=Cm(m,_)),f=g.width,p.__widthGrow&&(y.grow+=p.__widthGrow,f=0,p.__.widthRange&&(y.hasRangeSize=!0)),p.__heightGrow&&Im(p,g,b),y.width+=y.count?f+_:f,y.height=Math.max(y.height,g.height),y.count++):(Wm(p,v-g.x,w-g.y),v+=g.width+_));if(r&&y){const{isAutoYGap:s,isFitYGap:n,contentAlign:r,rowXAlign:h,rowYAlign:_}=o;y.count&&(y.grow?Am(t,y,x,e):d&&Om(y,i,x,c),a&&Bm(u,y,i)),a?(s?Om(u,"height",b,n):u.height+=(u.gap=l)*(u.list.length-1),function(t,e,i,s){km(t,e,i);const{list:n}=e;if(n.length>1&&(s||(s=xm[i]),"from"!==s)){let t;for(let i=0,o=n.length;i<o;i++)t=n[i],t.x=e.width-t.width,"center"===s&&(t.x/=2)}}(t,u,r,h),function(t,e,i,s){const{list:n}=e,o="reverse"===t.__.flowWrap;let r,{x:a,y:h}=e;for(let l=0,d=n.length;l<d;l++)r=n[o?d-1-l:l],Sm(t,r,a,h,i,s),h+=r.height+e.gap}(t,u,_,e)):(km(t,y,r),Sm(t,y,0,y.y,_,e))}}const{move:Nm}=K;function Ym(t,e,i,s,n,o){const{children:r}=t;let a,h,{y:l,start:d}=e,c=i;l+=s;for(let t=0,s=e.count;t<s;t++)a=r[o?d-t:d+t],a.__.inFlow&&0!==a.__.visible?(h=a.__flowBounds,"from"!==n&&(c=i+(e.width-h.width)/("center"===n?2:1)),Nm(a,c-h.x,l-h.y),l+=h.height+e.gap):s++}const{move:Hm}=K;function Xm(t,e){const i="height",{children:s,itemBox:n}=t,o=Rm(t,!1),{complex:r,wrap:a,xGap:h,yGap:l,isAutoYGap:d,isFitYGap:c}=o;if(!s.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},_=d?0:l;let p,g,f,m,y,{x:v,y:w,width:x,height:b}=t.__layout.contentBounds;for(let o=0,h=s.length;o<h;o++)p=s[m=e?h-1-o:o],p.__.inFlow&&0!==p.__.visible&&(g=Lm(p,n),r?(p.__flowBounds=g,y||(y=Cm(m,_)),a&&y.count&&y.height+g.height>b&&(y.grow&&Fm(t,y,b,e),d&&Om(y,i,b,c),Bm(u,y,i),y=Cm(m,_)),f=g.height,p.__heightGrow&&(y.grow+=p.__heightGrow,f=0,p.__.heightRange&&(y.hasRangeSize=!0)),p.__widthGrow&&Mm(p,g,x),y.height+=y.count?f+_:f,y.width=Math.max(y.width,g.width),y.count++):(Hm(p,v-g.x,w-g.y),w+=g.height+_));if(r&&y){const{isAutoXGap:s,isFitXGap:n,contentAlign:r,rowXAlign:l,rowYAlign:_}=o;y.count&&(y.grow&&Fm(t,y,b,e),d&&Om(y,i,b,c),a&&Bm(u,y,i)),a?(s?Om(u,"width",x,n):u.width+=(u.gap=h)*(u.list.length-1),function(t,e,i,s){km(t,e,i);const{list:n}=e;if(n.length>1&&(s||(s=bm[i]),"from"!==s)){let t;for(let i=0,o=n.length;i<o;i++)t=n[i],t.y=e.height-t.height,"center"===s&&(t.y/=2)}}(t,u,r,_),function(t,e,i,s){const{list:n}=e,o="reverse"===t.__.flowWrap;let r,{x:a,y:h}=e;for(let l=0,d=n.length;l<d;l++)r=n[o?d-1-l:l],Ym(t,r,a,h,i,s),a+=r.width+e.gap}(t,u,l,e)):(km(t,y,r),Ym(t,y,y.x,0,l,e))}}function Vm(t){return Gn(t,t=>({set(e){const i=l(e)?e:0;"autoWidth"===t?this.__widthGrow=i:this.__heightGrow=i,!i||this.parent&&this.parent.__hasGrow||this.waitParent(()=>{this.parent.__hasGrow=!0}),this.__setAttr(t,e)&&no(this)}}))}Vt.add("flow","resize");const jm=Al.prototype,{__updateBoxBounds:Um}=kl.prototype;bl.addAttr("flow",!1,Qn),bl.addAttr("gap",0,io),bl.addAttr("flowAlign","top-left",io),bl.addAttr("flowWrap",!1,io),bl.addAttr("itemBox","box",io),bl.addAttr("inFlow",!0,io),bl.addAttr("autoWidth",void 0,Vm),bl.addAttr("autoHeight",void 0,Vm),bl.addAttr("autoBox",void 0,io);const{copyAndSpread:Gm}=Rt;jm.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:zm(this);break;case"y":Xm(this);break;case"x-reverse":zm(this,!0);break;case"y-reverse":Xm(this,!0)}t&&(this.leafer.created=!0)},jm.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,i=e.contentBounds===e.boxBounds;t?(i&&e.shrinkContent(),Gm(e.contentBounds,e.boxBounds,t,!0)):i||e.shrinkContentCancel()},jm.__updateBoxBounds=function(t){if(this.children.length&&!this.pathInputed){const e=this.__,{flow:i}=e;if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),i&&!t?this.__updateRectBoxBounds():Um.call(this);const{boxBounds:s}=this.__layout;e.__autoSize||(e.__autoWidth?(i||(s.width+=s.x,s.x=0),s.height=e.height,s.y=0):(i||(s.height+=s.y,s.y=0),s.width=e.width,s.x=0)),i&&t&&e.padding&&Gm(s,s,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();i&&this.__updateContentBounds()}else this.__updateRectBoxBounds()};const{cos:Km,sin:qm,pow:Zm,sqrt:Jm,abs:$m,ceil:Qm,floor:ty,round:ey,PI:iy}=Math,sy=5*iy,ny=1.70158,oy=2.5949095,ry=7.5625,ay=2.75;function hy(t){return e=>Zm(e,t)}function ly(t){return e=>1-Zm(1-e,t)}function dy(t){return e=>e<.5?.5*Zm(2*e,t):1-.5*Zm(2-2*e,t)}function cy(t){return t<1/ay?ry*t*t:t<2/ay?ry*(t-=1.5/ay)*t+.75:t<2.5/ay?ry*(t-=2.25/ay)*t+.9375:ry*(t-=2.625/ay)*t+.984375}function uy(t,e,i,s){const n={};return o=>{const r=~~(1e4*o),a=n[r];if(a)return a;let h,l,d,c=o;for(let e=0;e<8&&(h=1-c,d=_y(c,t,i)-o,l=3*h*h*t+6*h*c*(i-t)+3*c*c*(1-i),!($m(l)<1e-6));e++)c-=d/l;return n[r]=_y(c,e,s)}}function _y(t,e,i){const s=1-t;return 3*s*s*t*e+3*s*t*t*i+t*t*t}const py={get(t){const{list:e}=py;return a(t)?e[t||"ease"]:_(t)?e[t.name].apply(e,u(t.value)?t.value:[t.value]):e.ease},register(t,e){py.list[t]=e},list:{linear:t=>t,ease:uy(.25,.1,.25,1),"ease-in":uy(.42,0,1,1),"ease-out":uy(0,0,.58,1),"ease-in-out":uy(.42,0,.58,1),"sine-in":t=>1-Km(t*iy*.5),"sine-out":t=>qm(t*iy*.5),"sine-in-out":t=>.5*(1-Km(t*iy)),"quad-in":hy(2),"quad-out":ly(2),"quad-in-out":dy(2),"cubic-in":hy(3),"cubic-out":ly(3),"cubic-in-out":dy(3),"quart-in":hy(4),"quart-out":ly(4),"quart-in-out":dy(4),"quint-in":hy(5),"quint-out":ly(5),"quint-in-out":dy(5),"expo-in":t=>t?Zm(2,10*t-10):0,"expo-out":t=>1===t?1:1-Zm(2,10*-t),"expo-in-out":t=>0===t||1===t?t:t<.5?.5*Zm(2,2*t*10-10):.5*(2-Zm(2,10-2*t*10)),"circ-in":t=>1-Jm(1-Zm(t,2)),"circ-out":t=>Jm(1-Zm(t-1,2)),"circ-in-out":t=>t<.5?.5*(1-Jm(1-Zm(2*t,2))):.5*(Jm(1-Zm(2-2*t,2))+1),"back-in":t=>((ny+1)*t-ny)*t*t,"back-out":t=>(t-=1)*t*((ny+1)*t+ny)+1,"back-in-out":t=>t<.5?(t*=2)*t*((oy+1)*t-oy)*.5:.5*((t=2*t-2)*t*((oy+1)*t+oy)+2),"elastic-in":t=>0===t||1===t?t:-Zm(2,10*(t-1))*qm((t-1.1)*sy),"elastic-out":t=>0===t||1===t?t:Zm(2,-10*t)*qm((t-.1)*sy)+1,"elastic-in-out":t=>0===t||1===t?t:t<.5?-Zm(2,10*((t*=2)-1))*qm((t-1.1)*sy)*.5:Zm(2,10*(1-(t*=2)))*qm((t-1.1)*sy)*.5+1,"bounce-in":t=>1-cy(1-t),"bounce-out":cy,"bounce-in-out":t=>t<.5?.5*(1-cy(1-2*t)):.5*(1+cy(2*t-1)),"cubic-bezier":uy,steps:function(t,e="floor"){return i=>("floor"===e?ty(i*t):"ceil"===e?Qm(i*t):ey(i*t))/t}}};function gy(t){return(e,i)=>{Object.defineProperty(e,i,{get(){const e=this.config&&this.config[i];return void 0===e?t:e},set(t){this.config||(this.config={}),this.config[i]=t}})}}class fy{}fy.CREATED="created",fy.PLAY="play",fy.PAUSE="pause",fy.STOP="stop",fy.SEEK="seek",fy.UPDATE="update",fy.COMPLETED="completed";let my=class extends Hr{get endingStyle(){return"from"===this.realEnding?this.fromStyle:this.toStyle}get started(){return!!this.requestAnimateTime}get completed(){return this.time>=this.duration&&!this.started}get frame(){return this.frames[this.nowIndex]}get frameTotalTime(){return this.frame.totalTime||this.frame.duration||0}get nowReverse(){return(this.mainReverse?1:0)+(this.frameReverse?1:0)==1}get realEnding(){let t;const{ending:e,reverse:i,swing:s,loop:n}=this;return"from"===e?t=0:"to"===e?t=1:(t=i?0:1,s&&n&&l(n)&&(t+=n-1)),t%2?"to":"from"}constructor(t,e,i,s){super(),e&&(e.keyframes?(i=e,e=e.keyframes):e.style&&(i=e,e=e.style)),this.init(t,e,i,s)}init(t,e,i,s){switch(this.target=t,(s||this.isTemp)&&(this.isTemp=s),typeof i){case"number":this.config={duration:i};break;case"string":this.config={easing:i};break;case"object":this.config=i,i.event&&(this.event=i.event)}this.keyframes=u(e)?e:e?[e]:[];const{easing:n,attrs:o}=this;this.easingFn=py.get(n),(o||this.attrsMap)&&(this.attrsMap=o?o.reduce((t,e)=>(t[e]=!0,t),{}):void 0),this.frames=[],this.create(),this.autoplay&&this.frames.length&&(this.timer=setTimeout(()=>{this.timer=0,this.play()},0))}emitType(t){this.emit(t,this),this.parent&&this.parent.onChildEvent(t,this)}play(){this.destroyed||(this.running=!0,this.started?this.timer||this.requestAnimate():(this.clearTimer(),this.start()),this.emitType(fy.PLAY))}pause(){this.destroyed||(this.running=!1,this.clearTimer(),this.emitType(fy.PAUSE))}stop(){this.destroyed||(this.complete(),this.emitType(fy.STOP))}seek(t){this.destroyed||(_(t)&&(t=Lh.number(t,this.duration)),t&&(t/=this.speed),(!this.started||t<this.time)&&this.start(!0),this.time=t,this.animate(0,!0),this.clearTimer(()=>this.requestAnimate()),this.emitType(fy.SEEK))}kill(t=!0,e){this.killStyle=e,this.destroy(t)}create(){const{target:t,frames:e,keyframes:i,config:s}=this,{length:n}=i,r=!(n>1)||this.join;let a,h,d,c,u,_=0,p=0;n>1&&(this.fromStyle={},this.toStyle={});for(let s=0;s<n;s++){if(h=i[s],c=h.style||h,a||(a=r?t:c),d={style:c,beforeStyle:{}},u=1,h.style){const{duration:t,autoDuration:e,delay:i,autoDelay:s,easing:n,swing:o,loop:r}=h;o&&(d.swing=l(o)?o:2,u=2*d.swing-1),r&&(d.loop=u=l(r)?r:2),t?(d.duration=t,_+=t*u,i&&(d.totalTime=t+i)):e&&(d.autoDuration=e,p+=e*u),i?(d.delay=i,_+=i*u):s&&(d.autoDelay=s,p+=s*u),n&&(d.easingFn=py.get(n))}if(!d.autoDuration&&o(d.duration)&&(n>1?s>0||r?p+=u:d.duration=0:d.duration=this.duration),n>1)this.setBefore(d,c,a);else{for(let e in c)d.beforeStyle[e]=t[e];this.fromStyle=d.beforeStyle,this.toStyle=d.style}a=c,e.push(d)}p?((this.duration<=_||!s||!s.duration)&&this.changeDuration(_+.2*p),this.allocateTime((this.duration-_)/p)):_&&this.changeDuration(_),this.emitType(fy.CREATED)}changeDuration(t){const{config:e}=this;this.config=e?Object.assign(Object.assign({},e),{duration:t}):{duration:t}}setBefore(t,e,i){const{fromStyle:s,toStyle:n,target:r}=this;for(let a in e)o(s[a])&&(s[a]=n[a]=e===i?i[a]:r[a]),t.beforeStyle[a]=o(i[a])?n[a]:i[a],n[a]=e[a]}allocateTime(t){let e,{frames:i}=this,{length:s}=i;for(let n=0;n<s;n++)e=i[n],o(e.duration)&&(e.duration=e.autoDuration?t*e.autoDuration:t),e.totalTime||(e.autoDelay&&(e.delay=e.autoDelay*t),e.delay&&(e.totalTime=e.duration+e.delay))}requestAnimate(){this.requestAnimateTime=Date.now(),t.requestRender(this.animate.bind(this))}animate(t,e){if(!e){if(!this.running)return;this.time+=(Date.now()-this.requestAnimateTime)/1e3}const{duration:i}=this,s=this.time*this.speed;if(s<i){for(;s-this.playedTotalTime>this.frameTotalTime;)this.transition(1),this.mainReverse?this.reverseNextFrame():this.nextFrame();const t=this.nowReverse?0:this.frame.delay||0,e=s-this.playedTotalTime-t,i=this.frame.duration;if(e>i)this.transition(1);else if(e>=0){const t=i?e/i:1;this.transition(this.frame.easingFn?this.frame.easingFn(t):this.easingFn(t))}}else this.end();if(!e)if(s<i)this.requestAnimate();else{const{loop:t,loopDelay:e,swing:i}=this;if((!1!==t||i)&&(this.looped?this.looped++:this.looped=1,this.needLoop(this.looped,t,i)))return i&&(this.mainReverse=!this.mainReverse),void(e?this.timer=setTimeout(()=>{this.timer=0,this.begin()},e/this.speed*1e3):this.begin());this.complete()}}start(t){this.requestAnimateTime=1;const{reverse:e}=this;if((e||this.mainReverse)&&(this.mainReverse=e),this.looped&&(this.looped=0),t)this.begin(!0);else{const{delay:t}=this;t?this.timer=setTimeout(()=>{this.timer=0,this.begin()},t/this.speed*1e3):this.begin()}}begin(t){this.playedTotalTime=this.time=0,this.mainReverse?this.setTo():this.setFrom(),t||this.requestAnimate()}end(){this.mainReverse?this.setFrom():this.setTo()}complete(){this.requestAnimateTime=0,this.running=!1;const{endingStyle:t,killStyle:e}=this,i=e?{}:t;if(e)for(let s in t)s in e||(i[s]=t[s]);this.setStyle(i),this.clearTimer(),this.emitType(fy.COMPLETED)}setFrom(){this.nowIndex=0,this.setStyle(this.fromStyle)}setTo(){this.nowIndex=this.frames.length-1,this.setStyle(this.toStyle)}nextFrame(){if(this.needLoopFrame())return this.increaseTime();this.nowIndex+1>=this.frames.length||(this.increaseTime(),this.nowIndex++)}reverseNextFrame(){if(this.needLoopFrame())return this.increaseTime();this.nowIndex-1<0||(this.increaseTime(),this.nowIndex--)}transition(t){const{style:e,beforeStyle:i}=this.frame,s=this.nowReverse?e:i,n=this.nowReverse?i:e;if(0===t)this.setStyle(s);else if(1===t)this.setStyle(n);else{const{attrsMap:i,target:o}=this;let{betweenStyle:r}=this.frame;r||(r=this.frame.betweenStyle={}),Nh.setBetweenStyle(r,s,n,e,t,o,i),this.setStyle(r)}this.emitType(fy.UPDATE)}setStyle(t){const{target:e}=this;e&&t&&(this.style=t,e.__?e.set(t,!!this.isTemp&&"temp"):Object.assign(e,t))}increaseTime(){this.playedTotalTime+=this.frameTotalTime}needLoop(t,e,i){return!(this.needStopLoop(t,e)||this.needStopLoop(t,i,!0))}needStopLoop(t,e,i){return l(e)&&(!e||t>=(i?2*e-1:e))}needLoopFrame(){const{loop:t,swing:e}=this.frame;if(t||e){if(this.frameLooped?this.frameLooped++:this.frameLooped=1,e&&(this.frameReverse=!this.frameReverse),this.needLoop(this.frameLooped,t,e))return!0;this.frameLooped=this.frameReverse=void 0}return!1}clearTimer(t){this.timer&&(clearTimeout(this.timer),this.timer=0,t&&t())}destroy(t){this.destroyed||(super.destroy(),t&&!this.completed?this.stop():this.pause(),this.target=this.parent=this.config=this.frames=this.fromStyle=this.toStyle=this.style=this.killStyle=null,this.destroyed=!0)}};Qt([gy("ease")],my.prototype,"easing",void 0),Qt([gy(0)],my.prototype,"delay",void 0),Qt([gy(.2)],my.prototype,"duration",void 0),Qt([gy("auto")],my.prototype,"ending",void 0),Qt([gy(!1)],my.prototype,"reverse",void 0),Qt([gy(!1)],my.prototype,"swing",void 0),Qt([gy(!1)],my.prototype,"loop",void 0),Qt([gy(0)],my.prototype,"loopDelay",void 0),Qt([gy(1)],my.prototype,"speed",void 0),Qt([gy(!0)],my.prototype,"autoplay",void 0),Qt([gy()],my.prototype,"join",void 0),Qt([gy()],my.prototype,"attrs",void 0),my=Qt([Po(Qr)],my);let yy=class extends my{get completed(){return this.list.every(t=>t.completed)}get endingStyle(){return this._endingStyle}constructor(t,e,i){super(t,null),this.list=[],this.updateList(e,i)}updateList(t,e){this.fromStyle={},this.toStyle={},this._endingStyle={},t||(t=this.list.filter(t=>{const{completed:e}=t;return e&&t.destroy(),!e})),this.list=t.map(t=>{const i=t.target?t:new my(this.target,t,e);return i.parent=this,Object.assign(this.fromStyle,i.fromStyle),Object.assign(this.toStyle,i.toStyle),Object.assign(this._endingStyle,i.endingStyle),i})}play(){this.each(t=>t.play()),this.emitType(fy.PLAY)}pause(){this.each(t=>t.pause()),this.emitType(fy.PAUSE)}stop(){this.each(t=>t.stop()),this.emitType(fy.STOP)}seek(t){this.each(e=>e.seek(t)),this.emitType(fy.SEEK)}kill(t,e){this.each(i=>i.kill(t,e)),this.destroy()}onChildEvent(t,e){switch(t){case fy.COMPLETED:this.completed&&this.emitType(t);break;case fy.UPDATE:this.emitType(t)}}each(t){this.list.forEach(t)}destroy(t){const{list:e}=this;e.length&&(this.each(e=>e.destroy(t)),e.length=0)}};yy=Qt([Po(Qr)],yy);const vy={transparent:"FFF0",aliceblue:"F0F8FF",antiquewhite:"FAEBD7",aqua:"0FF",aquamarine:"7FFFD4",azure:"F0FFFF",beige:"F5F5DC",bisque:"FFE4C4",black:"0",blanchedalmond:"FFEBCD",blue:"00F",blueviolet:"8A2BE2",brown:"A52A2A",burlywood:"DEB887",cadetblue:"5F9EA0",chartreuse:"7FFF00",chocolate:"D2691E",coral:"FF7F50",cornflowerblue:"6495ED",cornsilk:"FFF8DC",crimson:"DC143C",cyan:"0FF",darkblue:"00008B",darkcyan:"008B8B",darkgoldenrod:"B8860B",darkgray:"A9",darkgreen:"006400",darkgrey:"A9",darkkhaki:"BDB76B",darkmagenta:"8B008B",darkolivegreen:"556B2F",darkorange:"FF8C00",darkorchid:"9932CC",darkred:"8B0000",darksalmon:"E9967A",darkseagreen:"8FBC8F",darkslateblue:"483D8B",darkslategray:"2F4F4F",darkslategrey:"2F4F4F",darkturquoise:"00CED1",darkviolet:"9400D3",deeppink:"FF1493",deepskyblue:"00BFFF",dimgray:"69",dimgrey:"69",dodgerblue:"1E90FF",firebrick:"B22222",floralwhite:"FFFAF0",forestgreen:"228B22",fuchsia:"F0F",gainsboro:"DC",ghostwhite:"F8F8FF",gold:"FFD700",goldenrod:"DAA520",gray:"80",green:"008000",greenyellow:"ADFF2F",grey:"80",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",lightgray:"D3",lightgreen:"90EE90",lightgrey:"D3",lightpink:"FFB6C1",lightsalmon:"FFA07A",lightseagreen:"20B2AA",lightskyblue:"87CEFA",lightslategray:"789",lightslategrey:"789",lightsteelblue:"B0C4DE",lightyellow:"FFFFE0",lime:"00FF00",limegreen:"32CD32",linen:"FAF0E6",magenta:"FF00FF",maroon:"800000",mediumaquamarine:"66CDAA",mediumblue:"0000CD",mediumorchid:"BA55D3",mediumpurple:"9370DB",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:"639",red:"F00",rosybrown:"BC8F8F",royalblue:"4169E1",saddlebrown:"8B4513",salmon:"FA8072",sandybrown:"F4A460",seagreen:"2E8B57",seashell:"FFF5EE",sienna:"A0522D",silver:"C0",skyblue:"87CEEB",slateblue:"6A5ACD",slategray:"708090",slategrey:"708090",snow:"FFFAFA",springgreen:"00FF7F",steelblue:"4682B4",tan:"D2B48C",teal:"008080",thistle:"D8BFD8",tomato:"FF6347",turquoise:"40E0D0",violet:"EE82EE",wheat:"F5DEB3",white:"F",whitesmoke:"F5",yellow:"FF0",yellowgreen:"9ACD32"},wy=/^rgb\((\d+),\s*(\d+),\s*(\d+)/i,xy=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d*\.?\d+)/i,by=/^hsl\((\d+),\s*(\d+)%\s*,\s*(\d+)%/i,ky=/^hsla\((\d+),\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d*\.?\d+)/i,Ey=parseInt,Sy=parseFloat,{round:By}=Math;let Ty={},Ry=0;function Cy(t){let e,i,s,n=1;switch(t.length){case 9:e=Ey(t.slice(1,3),16),i=Ey(t.slice(3,5),16),s=Ey(t.slice(5,7),16),n=Ey(t.slice(7,9),16)/255;break;case 7:e=Ey(t.slice(1,3),16),i=Ey(t.slice(3,5),16),s=Ey(t.slice(5,7),16);break;case 5:e=Ey(t[1]+t[1],16),i=Ey(t[2]+t[2],16),s=Ey(t[3]+t[3],16),n=Ey(t[4]+t[4],16)/255;break;case 4:e=Ey(t[1]+t[1],16),i=Ey(t[2]+t[2],16),s=Ey(t[3]+t[3],16);break;case 3:e=i=s=Ey(t[1]+t[2],16);break;case 2:e=i=s=Ey(t[1]+t[1],16)}return{r:e,g:i,b:s,a:n}}const Oy=1/6,Ly=.5,Py=2/3,Ay=1/3;function My(t,e,i){return i<0?i++:i>1&&i--,i<Oy?t+6*(e-t)*i:i<Ly?e:i<Py?t+(e-t)*(Py-i)*6:t}function Dy(t,e,i,s=1){let n,o,r;if(t/=360,i/=100,0===(e/=100))n=o=r=i;else{let s=i<.5?i*(1+e):i+e-i*e,a=2*i-s;n=My(a,s,t+Ay),o=My(a,s,t),r=My(a,s,t-Ay)}return{r:By(255*n),g:By(255*o),b:By(255*r),a:s}}Vt.add("color"),Oh.object=function(t,e){let i,s=!o(e)&&e<1;if(a(t)){const e=Ty[t];if(e)i=Object.assign({},e);else{switch(t[0]){case"#":i=Cy(t);break;case"R":case"r":"("===t[4]&&xy.test(t)?i=function(t){const e=xy.exec(t);return{r:Ey(e[1]),g:Ey(e[2]),b:Ey(e[3]),a:Sy(e[4])}}(t):"("===t[3]&&wy.test(t)&&(i=function(t){const e=wy.exec(t);return{r:Ey(e[1]),g:Ey(e[2]),b:Ey(e[3]),a:1}}(t));break;case"H":case"h":"("===t[4]&&ky.test(t)?i=function(t){const e=ky.exec(t);return Dy(Sy(e[1]),Sy(e[2]),Sy(e[3]),Sy(e[4]))}(t):"("===t[3]&&by.test(t)&&(i=function(t){const e=by.exec(t);return Dy(Sy(e[1]),Sy(e[2]),Sy(e[3]),1)}(t))}if(!i){const e=vy[t.toLowerCase()];e&&(i=Cy("#"+e))}i&&(Ry++,Ry>1e4&&(Ty={},Ry=0),Ty[t]=Object.assign({},i))}}else _(t)&&(o(t.a)&&(t.a=1),s&&(t=Object.assign({},t)),i=t);return i||(i={r:255,g:255,b:255,a:1}),s&&(i.a*=e),i};const{round:Fy}=Math,{fourNumber:Iy}=b,Wy={fill:Xy,stroke:Xy,cornerRadius:(t,e,i)=>l(t)&&l(e)?Yy(t,e,i):(t=Iy(t),e=Iy(e),t.map((t,s)=>Yy(t,e[s],i))),text(t,e,i){if(a(t)&&a(e)){const s=t.length,n=e.length,o=Yy(s,n,i,1);return s<n?e.substring(0,o):t.substring(0,o)}return l(t)||l(e)?b.float(Yy(t,e,i),Math.max(Ny(t),Ny(e))):e},boxStyle(t,e,i,s){t||(t={}),e||(e={});const n=Object.assign(Object.assign({},t),e);return Nh.setBetweenStyle(n,t,e,n,i,s),n},shadow:Vy,innerShadow:Vy},zy={value:function(t,e,i){const s=l(t),n=l(e);return s&&n?t+(e-t)*i:n||s?Yy(t,e,i):t},number:Yy,color:Hy,setBetweenStyle:function(t,e,i,s,n,o,r){let a,h,l;const{list:d,value:c}=Nh;for(let u in s)r&&!r[u]||(a=e[u],h=i[u],l=d[u]||c,a!==h&&(t[u]=l(a,h,n,o)))}};function Ny(t){const e=String(t).split(".")[1];return e?e.length:0}function Yy(t,e,i,s){t||(t=0),e||(e=0);const n=t+(e-t)*i;return s?Fy(n):n}function Hy(t,e,i){t=Oh.object(t),e=Oh.object(e);const s=Yy(t.r,e.r,i,1)+","+Yy(t.g,e.g,i,1)+","+Yy(t.b,e.b,i,1),n=Yy(t.a,e.a,i);return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}function Xy(t,e,i){return a(t)&&a(e)?Hy(t,e,i):e}function Vy(t,e,i){return u(t)||u(e)?e:(e=e||{},{x:Yy((t=t||{}).x,e.x,i),y:Yy(t.y,e.y,i),blur:Yy(t.blur,e.blur,i),spread:Yy(t.spread,e.spread,i),color:Hy(t.color||"#FFFFFF00",e.color||"#FFFFFF00",i),visible:e.visible,blendMode:e.blendMode,box:e.box||t.box})}Vt.add("animate","color"),zh.canAnimate=!0,Object.assign(Nh.list,Wy),Object.assign(Nh,zy);const jy=bl.prototype;bl.addAttr("animation",void 0,function(t){return Gn(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&(this.killAnimate("animation"),e&&this.animate(e,void 0,"animation"))}}))}),bl.addAttr("animationOut",void 0,Zn),bl.addAttr("transition",!0,Zn),bl.addAttr("transitionOut",void 0,Zn),jy.set=function(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))},jy.animate=function(t,e,i,s){if(o(t))return this.__animate;let n=u(t)&&!e&&i?new yy(this,t,s):new my(this,t,e,s);this.killAnimate(i,n.toStyle);const r=this.__animate;return r&&(n instanceof yy?n.list.unshift(r):n=new yy(this,[r,n])),this.__animate=n},jy.killAnimate=function(t,e){const i=this.__animate;if(i){let t=!1;if(e&&!i.completed){i instanceof yy&&i.updateList();const{toStyle:s}=i;for(let i in e)if(i in s){t=!0;break}}else t=!0;t&&(i.kill(!0,e),this.__animate=null)}},jy.__runAnimation=function(t,e){this.animate("in"===t?this.animation:this.animationOut,void 0,"animation"),e&&this.__animate.on(fy.COMPLETED,e)};const Uy=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],Gy=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:Ky}=Math,{getDerivative:qy}=Ve,Zy={getDistance(t,e,i,s,n,o,r,a,h=1){let l,d,c,u,_,p,g=0,f=h/2;for(let h=0;h<Uy.length;h++)l=f*(1+Uy[h]),d=f*(1-Uy[h]),c=qy(l,t,i,n,r),u=qy(l,e,s,o,a),_=qy(d,t,i,n,r),p=qy(d,e,s,o,a),g+=Gy[h]*(Ky(c*c+u*u)+Ky(_*_+p*p));return g*f},getRotation(t,e,i,s,n,o,r,a,h){const l=qy(t,e,s,o,a),d=qy(t,i,n,r,h);return Math.atan2(d,l)/E},getT(t,e,i,s,n,o,r,a,h,l,d=1){let c=0,u=1,_=t/e,p=d/e/3;if(_>=1)return 1;if(_<=0)return 0;for(;u-c>p;)Jy(i,s,n,o,r,a,h,l,_)<t?c=_:u=_,_=(c+u)/2;return _},cut(t,e,i,s,n,o,r,a,h,l){const d=1-e,c=d*i+e*n,u=d*s+e*o,_=d*n+e*r,p=d*o+e*a,g=d*c+e*_,f=d*u+e*p,m=d*g+e*(d*_+e*(d*r+e*h)),y=d*f+e*(d*p+e*(d*a+e*l));t.push(me.C,c,u,g,f,m,y)}},{getDistance:Jy}=Zy,{M:$y,L:Qy,C:tv,Z:ev}=me,iv={},sv={},nv={transform(t,e){let i,s=0;const n=t.length;for(;s<n;)switch(i=t[s],i){case $y:case Qy:nv.transformPoints(t,e,s,1),s+=3;break;case tv:nv.transformPoints(t,e,s,3),s+=7;break;case ev:s+=1}},transformPoints(t,e,i,s){for(let n=i+1,o=n+2*s;n<o;n+=2)iv.x=t[n],iv.y=t[n+1],I.toOuterPoint(e,iv),t[n]=iv.x,t[n+1]=iv.y},getMotionPathData(t){let e,i,s,n,o=0,r=[],a=0,h=0,l=0;const d=t.length;for(;a<d;){switch(n=t[a],n){case $y:case Qy:i=t[a+1],s=t[a+2],e=n===Qy&&a>0?K.getDistanceFrom(h,l,i,s):0,h=i,l=s,a+=3;break;case tv:i=t[a+5],s=t[a+6],e=Zy.getDistance(h,l,t[a+1],t[a+2],t[a+3],t[a+4],i,s),h=i,l=s,a+=7;break;case ev:a+=1;default:e=0}r.push(e),o+=e}return{total:o,segments:r,data:t}},getDistancePoint(t,e,i){const{segments:s,data:n}=t;e=Lh.number(e,t.total);let o,r,a,h,l,d,c,u,_,p=0,g={},f=0,m=0,y=0,v=0;const w=n.length;for(;f<w;){switch(h=n[f],h){case $y:case Qy:if(r=n[f+1],a=n[f+2],o=s[m],p+o>=e||!t.total)return f||(y=r,v=a),sv.x=y,sv.y=v,g.x=r,g.y=a,K.getDistancePoint(sv,g,e-p,!0),g.rotation=K.getAngle(sv,g),g;y=r,v=a,f+=3;break;case tv:if(r=n[f+5],a=n[f+6],o=s[m],p+o>=e)return l=n[f+1],d=n[f+2],c=n[f+3],u=n[f+4],_=Zy.getT(e-p,o,y,v,l,d,c,u,r,a,i),Ve.getPointAndSet(_,y,v,l,d,c,u,r,a,g),g.rotation=Zy.getRotation(_,y,v,l,d,c,u,r,a),g;y=r,v=a,f+=7;break;case ev:f+=1;default:o=0}m++,p+=o}return g},getDistancePath(t,e,i){const{segments:s,data:n}=t,o=[];e=Lh.number(e,t.total);let r,a,h,l,d,c,u,_,p,g=0,f={},m=0,y=0,v=0,w=0;const x=n.length;for(;m<x;){switch(l=n[m],l){case $y:case Qy:if(a=n[m+1],h=n[m+2],r=s[y],g+r>=e||!t.total)return m||(v=a,w=h),sv.x=v,sv.y=w,f.x=a,f.y=h,K.getDistancePoint(sv,f,e-g,!0),o.push(l,f.x,f.y),o;v=a,w=h,m+=3,o.push(l,v,w);break;case tv:if(d=n[m+1],c=n[m+2],u=n[m+3],_=n[m+4],a=n[m+5],h=n[m+6],r=s[y],g+r>=e)return p=Zy.getT(e-g,r,v,w,d,c,u,_,a,h,i),Zy.cut(o,p,v,w,d,c,u,_,a,h),o;v=a,w=h,m+=7,o.push(l,d,c,u,_,a,h);break;case ev:m+=1,o.push(l);default:r=0}y++,g+=r}return o}};function ov(t){return Gn(t,t=>({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!r(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}}))}Vt.add("motion-path"),Nh.register("motion",function(t,e,i,s){return _(t)&&(t=Lh.number(t,s.getMotionTotal())),_(e)&&(e=Lh.number(e,s.getMotionTotal())),Nh.number(t||0,e||0,i)}),Nh.register("motionRotation",function(t,e,i){return Nh.number(t,e,i)});const rv=bl.prototype,{updateMatrix:av,updateAllMatrix:hv}=Uo,{updateBounds:lv}=nr;function dv(t){const{motion:e,leaferIsCreated:i}=t;if(!r(e)){if(i&&(t.leafer.created=!1),t.motionPath){const i=uv(t);i.total&&(t.__.__pathForRender=nv.getDistancePath(i,e,t.motionPrecision))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(hv(t),lv(t,t)):av(t));i&&(t.leafer.created=!0)}}function cv(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function uv(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=nv.getMotionPathData(t.getPath(!0,!0))}function _v(t,e){return Gn(t,t=>({set(i){this.__setAttr(t,i),this.leaferIsReady?e?zh.setStyleName(this,e,i):zh.set(this,i):this.__layout.stateStyleChanged=!0}}))}function pv(t){return Gn(t,t=>({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}}))}function gv(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function fv(t,e){_(e)||(e=void 0),vv(t,e,"in")}function mv(t,e){const{normalStyle:i}=t;_(e)||(e=void 0),i&&(e||(e=i),vv(t,e,"out"))}bl.addAttr("motionPath",void 0,ov),bl.addAttr("motionPrecision",1,ov),bl.addAttr("motion",void 0,ov),bl.addAttr("motionRotation",!0,ov),rv.getMotionPathData=function(){return uv(cv(this))},rv.getMotionPoint=function(t){const e=cv(this),i=uv(e);if(!i.total)return{};const s=nv.getDistancePoint(i,t,e.motionPrecision);I.toOuterPoint(e.localTransform,s);const{motionRotation:n}=this;return!1===n?delete s.rotation:l(n)&&(s.rotation+=n),s},rv.getMotionTotal=function(){return this.getMotionPathData().total},rv.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent;for(let i=0;i<e.length;i++)t=e[i],r(t.motion)||t.__layout.matrixChanged||(t!==this&&t.__extraUpdate(),dv(t))}else dv(this)};const yv={};function vv(t,e,i){const{normalStyle:s}=t;e||(e=yv),e.scale&&(b.assignScale(e,e.scale),delete e.scale),e!==yv&&zh.canAnimate||(i=null);let n=!!i&&function(t,e,i){let s="in"===t?"transition":"transitionOut";"out"===t&&r(i[s])&&r(e[s])&&(s="transition");return r(e[s])?i[s]:e[s]}(i,e,t);const o=n?function(t,e){const i=bv(e,t),s=t.animate();s&&bv(i,t,s.fromStyle);return i}(t,e):void 0;zh.canAnimate&&wv(t)&&t.killAnimate("transition"),s&&t.set(s,"temp");const a=wv(t);if(a){const{animation:s}=a;if(s){const o=t.animate(s,void 0,"animation",!0);Object.assign(a,o.endingStyle),"in"!==i||e.animation!==s?o.kill():n=!1,delete a.animation}t.normalStyle=xv(a,t),t.set(a,"temp")}else t.normalStyle=void 0;if(n){const e=xv(o,t);t.set(o,"temp"),t.animate([o,e],n,"transition",!0)}t.__layout.stateStyleChanged=!1}function wv(t){let e;const i={},s=gv(t),n=s?t.state||s.state:t.state,o=n&&t.states[n];o&&zh.isState(n,t,s)&&(e=kv(i,o));const r=i.selectedStyle||t.selectedStyle;r&&zh.isSelected(t,s)&&(e=kv(i,r));const a=i.placeholderStyle||t.placeholderStyle;if(a&&zh.isPlacehold(t,s)&&(e=kv(i,a)),zh.isDisabled(t,s)){const s=i.disabledStyle||t.disabledStyle;s&&(e=kv(i,s))}else{const n=i.focusStyle||t.focusStyle;n&&zh.isFocus(t,s)&&(e=kv(i,n));const o=i.hoverStyle||t.hoverStyle;o&&zh.isHover(t,s)&&(e=kv(i,o));const r=i.pressStyle||t.pressStyle;r&&zh.isPress(t,s)&&(e=kv(i,r))}return e?i:void 0}function xv(t,e,i,s){const n=i?t:{},o=i||t;for(let t in o)s&&zh.animateExcludes[t]||(n[t]=e[t]);return n}function bv(t,e,i){return xv(t,e,i,!0)}function kv(t,e){return Object.assign(t,e),!0}function Ev(t,e){const i=t[e];i&&fv(t,i),t.button&&Bv(t.children,e)}function Sv(t,e,i){i||(i=t.states[e]),fv(t,i),t.button&&Bv(t.children,null,e)}function Bv(t,e,i){if(!t)return;let s,n;for(let r=0,a=t.length;r<a;r++){if(s=t[r],e){switch(n=!0,e){case"hoverStyle":zh.isHover(s)&&(n=!1);break;case"pressStyle":zh.isPress(s)&&(n=!1);break;case"focusStyle":zh.isFocus(s)&&(n=!1)}n&&Ev(s,e)}else o(i)||Sv(s,i);s.isBranch&&Bv(s.children,e,i)}}function Tv(t,e){const i=t[e];i&&mv(t,i),t.button&&Cv(t.children,e)}function Rv(t,e,i){mv(t,i),t.button&&Cv(t.children,null,e)}function Cv(t,e,i){if(!t)return;let s;for(let n=0,r=t.length;n<r;n++)s=t[n],e?Tv(s,e):o(i)||Rv(s,i),s.isBranch&&Cv(s.children,e,i)}function Ov(t,e,i){let s;const n=e.leafer?e.leafer.interaction:null;if(n&&(s=n[t](e),!s&&i)){const o=gv(e,i);o&&(s=n[t](o))}return s}function Lv(t,e,i){let s=e[t];if(!s&&i){const n=gv(e,i);n&&(s=n[t])}return s}Vt.add("state"),zh.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,placeholder:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1,placeholderStyle:1},zh.isState=function(t,e,i){return function(t,e,i){let s=e.states[t];if(!s&&i){const n=gv(e,i);n&&(s=n.states[t])}return!!s}(t,e,i)},zh.isSelected=function(t,e){return Lv("selected",t,e)},zh.isDisabled=function(t,e){return Lv("disabled",t,e)},zh.isFocus=function(t,e){return Ov("isFocus",t,e)},zh.isHover=function(t,e){return Ov("isHover",t,e)},zh.isPress=function(t,e){return Ov("isPress",t,e)},zh.isPlacehold=function(t,e){return t.__.__isPlacehold},zh.isDrag=function(t,e){return Ov("isDrag",t,e)},zh.setStyleName=function(t,e,i){i?Sv(t,e,t[e]):Rv(t,e,t[e])},zh.set=function(t,e){const i=t.states[e];i?Sv(t,e,i):Rv(t,e,i)},zh.getStyle=wv,zh.updateStyle=vv,zh.updateEventStyle=function(t,e){switch(e){case kd.ENTER:Ev(t,"hoverStyle");break;case kd.LEAVE:Tv(t,"hoverStyle");break;case kd.DOWN:Ev(t,"pressStyle");break;case kd.UP:Tv(t,"pressStyle")}};const Pv=bl.prototype;bl.addAttr("selected",!1,_v,"selectedStyle"),bl.addAttr("disabled",!1,_v,"disabledStyle"),bl.addAttr("states",{},pv),bl.addAttr("state","",_v),bl.addAttr("normalStyle",void 0,Zn),bl.addAttr("hoverStyle",void 0,pv),bl.addAttr("pressStyle",void 0,pv),bl.addAttr("focusStyle",void 0,pv),bl.addAttr("selectedStyle",void 0,pv),bl.addAttr("disabledStyle",void 0,pv),bl.addAttr("placeholderStyle",void 0,pv),bl.addAttr("button",!1,Zn),Pv.focus=function(t=!0){this.waitLeafer(()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?Ev(this,"focusStyle"):Tv(this,"focusStyle")})},Pv.updateState=function(){zh.updateStyle(this,void 0,"in")};const Av=gd.prototype,Mv="text";Vn(Av,Mv,Object.assign(Object.assign({},jn(Av,Mv)),{set(t){const e=this,i=e.text;e.__setAttr(Mv,t)&&(no(e),e.placeholderStyle&&e.placeholder&&(""===i||""===t)&&(e.__layout.stateStyleChanged=!0))}}));class Dv extends Gh{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}let Fv=class extends bl{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t)}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let e=0;u(t)?t.forEach(t=>this.__loadRobot(t,e,e+=t.total||1)):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),!o(t))if(l(t))this.now=t;else if(_(t)){const e=u(t),i=e?t:t.keyframes;this.__action=e?void 0:t;const{length:s}=i;if(s>1){const t=this.now=i[0],e=i[i.length-1];this.play(),this.__runAction(t,e)}else s&&(this.now=i[0])}}__loadRobot(t,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=In.get(t);s.ready?this.__createFrames(s,t,e,i):s.load(()=>this.__createFrames(s,t,e,i))}__createFrames(t,e,i,s){const{offset:n,size:o,total:r}=e,{width:a,height:h}=o&&(l(o)?{width:o,height:o}:o)||(r>1?this:t);let d=n?n.x:0,c=n?n.y:0;for(let e=i;e<s;e++)this.robotFrames[e]={view:t.view,x:d,y:c,width:a,height:h},d+a>=t.width?(d=0,c+=h):d+=a;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new Er(Er.LOADED,{image:t}))}__runAction(t,e){let{FPS:i,loop:s,__action:n}=this;n&&(n.FPS&&(i=n.FPS),o(n.loop)||(s=n.loop)),this.__timer=setTimeout(()=>{if(this.running){if(this.now===e){if(!s)return this.stop();this.now=t}else this.now++;this.__updateRobotBounds()}this.__runAction(t,e)},1e3/i)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const e=this.__,i=t.width/e.pixelRatio,s=t.height/e.pixelRatio;e.width===i&&e.height===s||this.forceUpdate("width"),e.__naturalWidth=i,e.__naturalHeight=s}}__drawContent(t,e){const{nowFrame:i}=this,{width:s,height:n}=this.__;i&&t.drawImage(i.view,i.x,i.y,i.width,i.height,0,0,s,n)}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}};Qt([ko(Dv)],Fv.prototype,"__",void 0),Qt([io()],Fv.prototype,"robot",void 0),Qt([Zn()],Fv.prototype,"actions",void 0),Qt([Zn("")],Fv.prototype,"action",void 0),Qt([uo(0)],Fv.prototype,"now",void 0),Qt([Zn(12)],Fv.prototype,"FPS",void 0),Qt([Zn(!0)],Fv.prototype,"loop",void 0),Fv=Qt([Ao()],Fv),Vt.add("robot");const{Yes:Iv,NoAndSkip:Wv,YesAndSkip:zv}=s,Nv={},Yv={},Hv={};class Xv{constructor(t){this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},(this.target=t)&&this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":Nv.id=t.substring(1),t=Nv;break;case".":Yv.className=t.substring(1),t=Yv;break;default:Hv.tag=t,t=Hv}case"object":if(o(t.id)){if(t.tag){const{tag:s}=t,n=u(s);return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?f.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className)}{const s=this.getById(t.id,e);return i?s:s?[s]:[]}case"function":return this.getByMethod(t,e,i,s)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&Uo.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let r=0,a=t.length;r<a;r++){if(n=t[r],o=e(n,s),o===Iv||o===zv){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<Wv&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(wr.REMOVE,this.__onRemoveChild,this),this.target.on_(br.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){const{__eventIds:t}=this;t&&t.length&&(this.__removeListenEvents(),this.innerIdMap={},this.idMap={}),this.findLeaf=null}}const Vv=bl.prototype;function jv(e){return e.leafer?e.leafer.selector:t.selector||(t.selector=jt.selector())}Vv.find=function(t,e){return jv(this).getBy(t,this,!1,e)},Vv.findOne=function(t,e){return jv(this).getBy(t,this,!0,e)},Vt.add("find"),jt.finder=function(t){return new Xv(t)};const{setPoint:Uv,addPoint:Gv,toBounds:Kv}=st;const qv={syncExport(e,i,s){let n;Wh.running=!0;try{const r=Cn.fileType(i),a=i.includes(".");s=Cn.getExportOptions(s);const{toURL:h}=t,{download:l}=t.origin;if("json"===r)a&&l(h(JSON.stringify(e.toJSON(s.json)),"text"),i),n={data:!!a||e.toJSON(s.json)};else if("svg"===r)a&&l(h(e.toSVG(),"svg"),i),n={data:!!a||e.toSVG()};else{let r,a,h=1,l=1;const{worldTransform:d,isLeafer:c,leafer:u,isFrame:_}=e,{slice:p,clip:g,trim:f,screenshot:m,padding:y,onCanvas:v}=s,w=o(s.smooth)?!u||u.config.smooth:s.smooth,x=s.contextSettings||(u?u.config.contextSettings:void 0),k=c&&m&&o(s.fill)?e.fill:s.fill,E=Cn.isOpaqueImage(i)||k,S=new et;if(m)r=!0===m?c?u.canvas.bounds:e.worldRenderBounds:m;else{let t=s.relative||(c?"inner":"local");switch(h=d.scaleX,l=d.scaleY,t){case"inner":S.set(d);break;case"local":S.set(d).divide(e.localTransform),h/=e.scaleX,l/=e.scaleY;break;case"world":h=1,l=1;break;case"page":t=u||e;default:S.set(d).divide(e.getTransform(t));const i=t.worldTransform;h/=h/i.scaleX,l/=l/i.scaleY}r=e.getBounds("render",t)}const B={scaleX:1,scaleY:1};b.getScaleData(s.scale,s.size,r,B);let T=s.pixelRatio||1,{x:R,y:C,width:O,height:L}=new Pt(r).scale(B.scaleX,B.scaleY);g&&(R+=g.x,C+=g.y,O=g.width,L=g.height);const P={exporting:!0,matrix:S.scale(1/B.scaleX,1/B.scaleY).invert().translate(-R,-C).withScale(1/h*B.scaleX,1/l*B.scaleY)};let A,M=jt.canvas({width:Math.floor(O),height:Math.floor(L),pixelRatio:T,smooth:w,contextSettings:x});p&&(A=e,A.__worldOpacity=0,e=u||e,P.bounds=M.bounds),M.save();const D=_&&!o(k),F=e.get("fill");if(D&&(e.fill=""),t.render(e,M,P),D&&(e.fill=F),M.restore(),A&&A.__updateWorldOpacity(),f){a=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,r,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,o=(a-n)/e,r?Gv(r,n,o):Uv(r={},n,o)),a++;const h=new Pt;return r&&(Kv(r,h),h.scale(1/t.pixelRatio).ceil()),h}(M);const t=M,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:T};M=jt.canvas(s),M.copyWorld(t,a,s),t.destroy()}if(y){const[t,e,i,s]=b.fourNumber(y),n=M,{width:o,height:r}=n;M=jt.canvas({width:o+s+e,height:r+t+i,pixelRatio:T}),M.copyWorld(n,n.bounds,{x:s,y:t,width:o,height:r}),n.destroy()}E&&M.fillWorld(M.bounds,k||"#FFFFFF","destination-over"),v&&v(M);n={data:"canvas"===i?M:M.export(i,s),width:M.pixelWidth,height:M.pixelHeight,renderBounds:r,trimBounds:a};const I=u&&u.app;I&&I.canvasManager&&I.canvasManager.clearRecycled()}}catch(t){n={data:"",error:t}}return Wh.running=!1,n},export(e,i,s){return Wh.running=!0,function(t){Zv||(Zv=new An);return new Promise(e=>{Zv.add(()=>te(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(n=>new Promise(o=>{const r=()=>te(this,void 0,void 0,function*(){if(!Dn.isComplete)return t.requestRender(r);const a=Wh.syncExport(e,i,s);a.data instanceof Promise&&(a.data=yield a.data),n(a),o()});e.updateLayout(),Jv(e);const{leafer:a}=e;a?a.waitViewCompleted(r):r()}))}};let Zv;function Jv(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>Jv(t))}const $v=pe.prototype,Qv=It.get("@leafer-in/export");$v.export=function(t,e){const{quality:i,blob:s}=Cn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},$v.toBlob=function(e,i){return new Promise(s=>{t.origin.canvasToBolb(this.view,e,i).then(t=>{s(t)}).catch(t=>{Qv.error(t),s(null)})})},$v.toDataURL=function(e,i){return t.origin.canvasToDataURL(this.view,e,i)},$v.saveAs=function(e,i){return new Promise(s=>{t.origin.canvasSaveAs(this.view,e,i).then(()=>{s(!0)}).catch(t=>{Qv.error(t),s(!1)})})},Vt.add("export"),Object.assign(Wh,qv),bl.prototype.export=function(t,e){return Wh.export(this,t,e)},bl.prototype.syncExport=function(t,e){return Wh.syncExport(this,t,e)},Vt.add("filter"),Object.assign(Ih,{list:{},register(t,e){Ih.list[t]=e},apply(t,e,i,s,n,o){let r;t.forEach(t=>{r=Ih.list[t.type],r&&r.apply(t,e,i,s,n,o)})},getSpread(t){let e,i=0;return t.forEach(t=>{e=Ih.list[t.type],e&&(i+=e.getSpread(t))}),i}}),Vt.add("bright"),bl.addAttr("bright",!1,_o);export{ct as AlignHelper,my as Animate,py as AnimateEasing,fy as AnimateEvent,yy as AnimateList,s as Answer,yd as App,ht as AroundHelper,wf as Arrow,yf as ArrowData,Mt as AutoBounds,Ve as BezierHelper,Pt as Bounds,Sr as BoundsEvent,Rt as BoundsHelper,Al as Box,Zh as BoxData,th as Branch,nr as BranchHelper,va as BranchRender,dd as Canvas,ll as CanvasData,$t as CanvasManager,wr as ChildEvent,Oh as ColorConvert,jt as Creator,Jd as Cursor,f as DataHelper,It as Debug,ot as Direction4,rt as Direction9,gl as DragBoundsHelper,Bd as DragEvent,Nd as Dragger,Rd as DropEvent,Pp as EditBox,Ep as EditDataHelper,Cp as EditPoint,up as EditSelect,hp as EditSelectHelper,rg as EditTool,jp as EditToolCreator,ng as Editor,J_ as EditorEvent,Kp as EditorGroupEvent,Yp as EditorHelper,Qp as EditorMoveEvent,eg as EditorRotateEvent,tg as EditorScaleEvent,ig as EditorSkewEvent,Fh as Effect,Wl as Ellipse,el as EllipseData,Qe as EllipseHelper,vr as Event,Zt as EventCreator,Hr as Eventer,Wh as Export,Cn as FileHelper,Ih as Filter,Xv as Finder,vm as Flow,Ml as Frame,$h as FrameData,kl as Group,qh as GroupData,mf as HTMLText,ff as HTMLTextData,Zy as HighBezierHelper,nv as HighCurveHelper,$d as HitCanvasManager,hd as Image,hl as ImageData,Er as ImageEvent,In as ImageManager,e as IncrementId,og as InnerEditor,Gp as InnerEditorEvent,Zd as InteractionBase,Md as InteractionHelper,Ad as KeyEvent,wd as Keyboard,Ar as LayoutEvent,vh as Layouter,Va as Leaf,fa as LeafBounds,tr as LeafBoundsHelper,y as LeafData,ea as LeafDataProxy,Qr as LeafEventer,Uo as LeafHelper,yr as LeafLayout,ih as LeafLevelList,eh as LeafList,ha as LeafMatrix,ma as LeafRender,Bl as Leafer,nh as LeaferCanvas,pe as LeaferCanvasBase,Jh as LeaferData,Dr as LeaferEvent,Xn as LeaferImage,qg as LeaferTypeCreator,ad as Line,Qh as LineData,ug as LineEditTool,b as MathHelper,et as Matrix,I as MatrixHelper,Cd as MoveEvent,$g as MultiTouchHelper,Td as MyDragEvent,ld as MyImage,Ed as MyPointerEvent,ve as NeedConvertToCanvasCommandMap,E as OneRadian,S as PI2,B as PI_2,Ah as Paint,Dh as PaintGradient,Mh as PaintImage,fd as Path,Ph as PathArrow,fm as PathArrowModule,mn as PathBounds,rs as PathCommandDataHelper,me as PathCommandMap,Ii as PathConvert,En as PathCorner,ks as PathCreator,nl as PathData,Ws as PathDrawer,ge as PathHelper,Of as PathMatrixHelper,ke as PathNumberCommandLengthMap,be as PathNumberCommandMap,Bg as PathScaler,md as Pen,ol as PenData,kh as Picker,t as Platform,Vt as Plugin,Q as Point,K as PointHelper,xd as PointerButton,kd as PointerEvent,Ul as Polygon,il as PolygonData,br as PropertyEvent,Tl as Rect,tl as RectData,Ee as RectHelper,wl as RectRender,Mr as RenderEvent,xh as Renderer,Lr as ResizeEvent,Dn as Resource,Fv as Robot,Dv as RobotData,Od as RotateEvent,Yt as Run,gf as ScrollBar,ap as SelectArea,Eh as Selector,Ql as Star,sl as StarData,zh as State,Dt as StringNumberMap,rp as Stroker,Ld as SwipeEvent,Pn as TaskItem,An as TaskProcessor,gd as Text,Ch as TextConvert,al as TextData,jg as TextEditor,sg as TransformTool,of as Transformer,Nh as Transition,st as TwoPointBoundsHelper,bl as UI,dl as UIBounds,Gt as UICreator,Gh as UIData,bd as UIEvent,yl as UIRender,Lh as UnitConvert,hr as WaitHelper,Pr as WatchEvent,hh as Watcher,nf as WheelEventHelper,Pd as ZoomEvent,Ug as addViewport,Gg as addViewportConfig,co as affectRenderBoundsType,ao as affectStrokeBoundsType,vf as arrowType,Kn as attr,Qn as autoLayoutType,io as boundsType,Rn as canvasPatch,_e as canvasSizeAttrs,Rh as createAttr,Un as createDescriptor,bo as cursorType,ko as dataProcessor,Zn as dataType,Gn as decorateLeafAttr,So as defineDataProcessor,Vn as defineKey,qn as defineLeafAttr,_o as dimType,no as doBoundsType,ho as doStrokeType,Sh as effectType,n as emptyData,wo as eraserType,kr as extraPropertyEventMap,R as getBoundsData,jn as getDescriptor,C as getMatrixData,T as getPointData,xo as hitType,u as isArray,p as isData,g as isEmptyData,h as isFinite,r as isNull,l as isNumber,_ as isObject,a as isString,o as isUndefined,Eo as layoutProcessor,Nr as leaferTransformAttrMap,vo as maskType,ov as motionPathType,so as naturalBoundsType,po as opacityType,Sn as path,oo as pathInputType,ro as pathType,Bn as pen,Jn as positionType,Xp as registerEditTool,Vp as registerInnerEditor,Ao as registerUI,Mo as registerUIEvent,Bh as resizeType,Co as rewrite,Oo as rewriteAble,eo as rotationType,Dg as scaleResize,Fg as scaleResizeFontSize,zg as scaleResizeGroup,Ig as scaleResizePath,Wg as scaleResizePoints,to as scaleType,$n as scrollType,yo as sortType,pv as stateStyleType,_v as stateType,lo as strokeType,uo as surfaceType,At as tempBounds,it as tempMatrix,tt as tempPoint,c as tryToNumber,rh as useCanvas,Po as useModule,sh as version,go as visibleType,Th as zoomLayerType};
1
+ const t={toURL(t,e){let i=encodeURIComponent(t);return"text"===e?i="data:text/plain;charset=utf-8,"+i:"svg"===e&&(i="data:image/svg+xml,"+i),i},image:{hitCanvasSize:100,maxCacheSize:4096e3,maxPatternSize:8847360,crossOrigin:"anonymous",getRealURL(e){const{prefix:i,suffix:s}=t.image;return!s||e.startsWith("data:")||e.startsWith("blob:")||(e+=(e.includes("?")?"&":"?")+s),i&&"/"===e[0]&&(e=i+e),e}}},e={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=i;return e[t]?e[t]++:(e[t]=1,0)}},i=e;var s;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(s||(s={}));const n={};function o(t){return void 0===t}function r(t){return null==t}function a(t){return"string"==typeof t}const{isFinite:h}=Number;function l(t){return"number"==typeof t}const d=/^-?\d+(?:\.\d+)?$/;function c(t){return"string"==typeof t&&d.test(t)?+t:t}const{isArray:u}=Array;function g(t){return t&&"object"==typeof t}function p(t){return g(t)&&!u(t)}function _(t){return"{}"===JSON.stringify(t)}const f={default:(t,e)=>(m(e,t),m(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach(n=>{var o,r;if(s=e[n],(null==s?void 0:s.constructor)===Object&&(null===(o=t[n])||void 0===o?void 0:o.constructor)===Object)return m(t[n],e[n],i&&i[n]);i&&n in i?(null===(r=i[n])||void 0===r?void 0:r.constructor)===Object&&m(t[n]={},e[n],i[n]):t[n]=e[n]})},copyAttrs:(t,e,i)=>(i.forEach(i=>{o(e[i])||(t[i]=e[i])}),t),clone:t=>JSON.parse(JSON.stringify(t)),toMap(t){const e={};for(let i=0,s=t.length;i<s;i++)e[t[i]]=!0;return e},stintSet(t,e,i){i||(i=void 0),t[e]!==i&&(t[e]=i)}},{assign:m}=f;class y{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __usePathBox(){return this.__pathInputed}get __blendMode(){if(this.eraser&&"path"!==this.eraser)return"destination-out";const{blendMode:t}=this;return"pass-through"===t?null:t}constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(!o(e))return e}return this[t]}__getData(){const t={tag:this.__leaf.tag},{__input:e}=this;let i;for(let s in this)"_"!==s[0]&&(i=e?e[s]:void 0,t[s]=o(i)?this[s]:i);return t}__setInput(t,e){this.__input||(this.__input={}),this.__input[t]=e}__getInput(t){if(this.__input){const e=this.__input[t];if(!o(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!o(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(u(t))for(let e of t)i[e]=this.__getInput(e);else for(let e in t)i[e]=this.__getInput(e);else{let t,e,{__input:s}=this;i.tag=this.__leaf.tag;for(let n in this)if("_"!==n[0]&&(t=this["_"+n],!o(t))){if("path"===n&&!this.__pathInputed)continue;e=s?s[n]:void 0,i[n]=o(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:n,e:o,f:r}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:n,e:o,f:r}}return i}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){const t=this;if("pass-through"===t.blendMode){const e=this.__leaf;t.opacity<1&&(e.isBranch||t.__hasMultiPaint)||e.__hasEraser||t.eraser||t.filter?t.__single=!0:t.__single&&(t.__single=!1)}else t.__single=!0}__removeNaturalSize(){this.__naturalWidth=this.__naturalHeight=void 0}destroy(){this.__input=this.__middle=null}}let v,w,x;const{max:b}=Math,k=[0,0,0,0],E={zero:[...k],tempFour:k,set:(t,e,i,s,n)=>(void 0===i&&(i=s=n=e),t[0]=e,t[1]=i,t[2]=s,t[3]=n,t),setTemp:(t,e,i,s)=>S(k,t,e,i,s),toTempAB(t,e,i){x=i?l(t)?e:t:[],l(t)?(v=T(t),w=e):l(e)?(v=t,w=T(e)):(v=t,w=e),4!==v.length&&(v=B(v)),4!==w.length&&(w=B(w))},get(t,e){let i;if(!l(t))switch(t.length){case 4:i=o(e)?t:[...t];break;case 2:i=[t[0],t[1],t[0],t[1]];break;case 3:i=[t[0],t[1],t[2],t[1]];break;case 1:t=t[0];break;default:t=0}if(i||(i=[t,t,t,t]),!o(e))for(let t=0;t<4;t++)i[t]>e&&(i[t]=e);return i},max:(t,e,i)=>l(t)&&l(e)?b(t,e):(R(t,e,i),S(x,b(v[0],w[0]),b(v[1],w[1]),b(v[2],w[2]),b(v[3],w[3]))),add:(t,e,i)=>l(t)&&l(e)?t+e:(R(t,e,i),S(x,v[0]+w[0],v[1]+w[1],v[2]+w[2],v[3]+w[3])),swapAndScale(t,e,i,s){if(l(t))return e===i?t*e:[t*i,t*e];const n=s?t:[],[o,r,a,h]=4===t.length?t:B(t);return S(n,a*i,h*e,o*i,r*e)}},{set:S,get:B,setTemp:T,toTempAB:R}=E,{round:C,pow:O,PI:L}=Math,P={within:(t,e,i)=>(g(e)&&(i=e.max,e=e.min),!o(e)&&t<e&&(t=e),!o(i)&&t>i&&(t=i),t),fourNumber:E.get,formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),P.float(t)),getGapRotation(t,e,i=0){let s=t+i;if(e>1){const t=Math.abs(s%e);(t<1||t>e-1)&&(s=Math.round(s/e)*e)}return s-i},float(t,e){const i=o(e)?1e12:O(10,e);return-0===(t=C(t*i)/i)?0:t},sign:t=>t<0?-1:1,getScaleData(t,e,i,s){if(s||(s={}),e){const t=(l(e)?e:e.width||0)/i.width,n=(l(e)?e:e.height||0)/i.height;s.scaleX=t||n||1,s.scaleY=n||t||1}else t&&P.assignScale(s,t);return s},assignScale(t,e){l(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},randInt:A,randColor:t=>`rgba(${A(255)},${A(255)},${A(255)},${t||1})`};function A(t){return Math.round(Math.random()*t)}const D=L/180,M=2*L,F=L/2;function I(){return{x:0,y:0}}function W(){return{x:0,y:0,width:0,height:0}}function z(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:N,cos:Y,acos:H,sqrt:X}=Math,{float:V}=P,j={};function U(){return Object.assign(Object.assign(Object.assign({},{a:1,b:0,c:0,d:1,e:0,f:0}),{x:0,y:0,width:0,height:0}),{scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0})}const G={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:U(),tempMatrix:{},set(t,e=1,i=0,s=0,n=1,o=0,r=0){t.a=e,t.b=i,t.c=s,t.d=n,t.e=o,t.f=r},get:z,getWorld:U,copy(t,e){t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f},translate(t,e,i){t.e+=e,t.f+=i},translateInner(t,e,i,s){t.e+=t.a*e+t.c*i,t.f+=t.b*e+t.d*i,s&&(t.e-=e,t.f-=i)},scale(t,e,i=e){t.a*=e,t.b*=e,t.c*=i,t.d*=i},pixelScale(t,e,i){i||(i=t),i.a=t.a*e,i.b=t.b*e,i.c=t.c*e,i.d=t.d*e,i.e=t.e*e,i.f=t.f*e},scaleOfOuter(t,e,i,s){K.toInnerPoint(t,e,j),K.scaleOfInner(t,j,i,s)},scaleOfInner(t,e,i,s=i){K.translateInner(t,e.x,e.y),K.scale(t,i,s),K.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:o}=t,r=Y(e*=D),a=N(e);t.a=i*r-s*a,t.b=i*a+s*r,t.c=n*r-o*a,t.d=n*a+o*r},rotateOfOuter(t,e,i){K.toInnerPoint(t,e,j),K.rotateOfInner(t,j,i)},rotateOfInner(t,e,i){K.translateInner(t,e.x,e.y),K.rotate(t,i),K.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:o,d:r}=t;i&&(i*=D,t.a=s+o*i,t.b=n+r*i),e&&(e*=D,t.c=o+s*e,t.d=r+n*e)},skewOfOuter(t,e,i,s){K.toInnerPoint(t,e,j),K.skewOfInner(t,j,i,s)},skewOfInner(t,e,i,s=0){K.translateInner(t,e.x,e.y),K.skew(t,i,s),K.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:n,d:o,e:r,f:a}=t;t.a=e.a*i+e.b*n,t.b=e.a*s+e.b*o,t.c=e.c*i+e.d*n,t.d=e.c*s+e.d*o,t.e=e.e*i+e.f*n+r,t.f=e.e*s+e.f*o+a},multiplyParent(t,e,i,s,n){const{e:r,f:a}=t;if(i||(i=t),o(s)&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:o,c:r,d:a}=t;i.a=s*e.a+o*e.c,i.b=s*e.b+o*e.d,i.c=r*e.a+a*e.c,i.d=r*e.b+a*e.d,n&&(i.scaleX=e.scaleX*n.scaleX,i.scaleY=e.scaleY*n.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,n&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=r*e.a+a*e.c+e.e,i.f=r*e.b+a*e.d+e.f},divide(t,e){K.multiply(t,K.tempInvert(e))},divideParent(t,e){K.multiplyParent(t,K.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=K;return K.copy(e,t),K.invert(e),e},invert(t){const{a:e,b:i,c:s,d:n,e:o,f:r}=t;if(i||s){const a=1/(e*n-i*s);t.a=n*a,t.b=-i*a,t.c=-s*a,t.d=e*a,t.e=-(o*n-r*s)*a,t.f=-(r*e-o*i)*a}else if(1===e&&1===n)t.e=-o,t.f=-r;else{const i=1/(e*n);t.a=n*i,t.d=e*i,t.e=-o*n*i,t.f=-r*e*i}},toOuterPoint(t,e,i,s){const{x:n,y:o}=e;i||(i=e),i.x=n*t.a+o*t.c,i.y=n*t.b+o*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:n,b:o,c:r,d:a}=t,h=1/(n*a-o*r),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*r)*h,i.y=(d*n-l*o)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*r)*h,i.y-=(s*n-e*o)*h}},setLayout(t,e,i,s,n){const{x:r,y:a,scaleX:h,scaleY:l}=e;if(o(n)&&(n=e.rotation||e.skewX||e.skewY),n){const{rotation:i,skewX:s,skewY:n}=e,o=i*D,r=Y(o),a=N(o);if(s||n){const e=s*D,i=n*D;t.a=(r+i*-a)*h,t.b=(a+i*r)*h,t.c=(e*r-a)*l,t.d=(r+e*a)*l}else t.a=r*h,t.b=a*h,t.c=-a*l,t.d=r*l}else t.a=h,t.b=0,t.c=0,t.d=l;t.e=r,t.f=a,(i=i||s)&&K.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:n,b:o,c:r,d:a,e:h,f:l}=t;let d,c,u,g,p,_=h,f=l;if(o||r){const t=n*a-o*r;if(r&&!s){d=X(n*n+o*o),c=t/d;const e=n/d;u=o>0?H(e):-H(e)}else{c=X(r*r+a*a),d=t/c;const e=r/c;u=F-(a>0?H(-e):-H(e))}const e=V(Y(u)),i=N(u);d=V(d),c=V(c),g=e?V((r/c+i)/e/D,9):0,p=e?V((o/d-i)/e/D,9):0,u=V(u/D)}else d=n,c=a,u=g=p=0;return(e=i||e)&&(_+=e.x*n+e.y*r,f+=e.x*o+e.y*a,i||(_-=e.x,f-=e.y)),{x:_,y:f,scaleX:d,scaleY:c,rotation:u,skewX:g,skewY:p}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:n,c:o,d:r}=t;n||o?i=(s*r-n*o)/(e=X(s*s+n*n)):(e=s,i=r)}return s.scaleX=e,s.scaleY=i,s},reset(t){K.set(t)}},K=G,{toInnerPoint:q,toOuterPoint:Z}=G,{sin:J,cos:$,abs:Q,sqrt:tt,atan2:et,min:it,round:st}=Math,nt={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,i=0){t.x=e,t.y=i},setRadius(t,e,i){t.radiusX=e,t.radiusY=o(i)?e:i},copy(t,e){t.x=e.x,t.y=e.y},copyFrom(t,e,i){t.x=e,t.y=i},round(t,e){t.x=e?st(t.x-.5)+.5:st(t.x),t.y=e?st(t.y-.5)+.5:st(t.y)},move(t,e,i){g(e)?(t.x+=e.x,t.y+=e.y):(t.x+=e,t.y+=i)},scale(t,e,i=e){t.x&&(t.x*=e),t.y&&(t.y*=i)},scaleOf(t,e,i,s=i){t.x+=(t.x-e.x)*(i-1),t.y+=(t.y-e.y)*(s-1)},rotate(t,e,i){i||(i=ot.defaultPoint);const s=$(e*=D),n=J(e),o=t.x-i.x,r=t.y-i.y;t.x=i.x+o*s-r*n,t.y=i.y+o*n+r*s},tempToInnerOf(t,e){const{tempPoint:i}=ot;return at(i,t),q(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=ot;return at(i,t),Z(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=ot;return at(i,t),ot.toInnerRadiusPointOf(t,e,i),i},toInnerRadiusPointOf(t,e,i){i||(i=t),q(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){q(e,t,i)},toOuterOf(t,e,i){Z(e,t,i)},getCenter:(t,e)=>({x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}),getCenterX:(t,e)=>t+(e-t)/2,getCenterY:(t,e)=>t+(e-t)/2,getDistance:(t,e)=>rt(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=Q(i-t),o=Q(s-e);return tt(n*n+o*o)},getMinDistanceFrom:(t,e,i,s,n,o)=>it(rt(t,e,i,s),rt(i,s,n,o)),getAngle:(t,e)=>ht(t,e)/D,getRotation:(t,e,i,s)=>(s||(s=e),ot.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/D),getRadianFrom(t,e,i,s,n,r,a,h){o(a)&&(a=i,h=s);const l=t-i,d=e-s,c=n-a,u=r-h;return Math.atan2(l*u-d*c,l*c+d*u)},getAtan2:(t,e)=>et(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s){const n=ht(t,e);return(e=s?e:{}).x=t.x+$(n)*i,e.y=t.y+J(n)*i,e},toNumberPoints(t){let e=t;return g(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},reset(t){ot.reset(t)}},ot=nt,{getDistanceFrom:rt,copy:at,getAtan2:ht}=ot;class lt{constructor(t,e){this.set(t,e)}set(t,e){return g(t)?nt.copy(this,t):nt.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new lt(this)}move(t,e){return nt.move(this,t,e),this}scale(t,e){return nt.scale(this,t,e),this}scaleOf(t,e,i){return nt.scaleOf(this,t,e,i),this}rotate(t,e){return nt.rotate(this,t,e),this}rotateOf(t,e){return nt.rotate(this,e,t),this}getRotation(t,e,i){return nt.getRotation(this,t,e,i)}toInnerOf(t,e){return nt.toInnerOf(this,t,e),this}toOuterOf(t,e){return nt.toOuterOf(this,t,e),this}getCenter(t){return new lt(nt.getCenter(this,t))}getDistance(t){return nt.getDistance(this,t)}getDistancePoint(t,e,i){return new lt(nt.getDistancePoint(this,t,e,i))}getAngle(t){return nt.getAngle(this,t)}getAtan2(t){return nt.getAtan2(this,t)}reset(){return nt.reset(this),this}}const dt=new lt;class ct{constructor(t,e,i,s,n,o){this.set(t,e,i,s,n,o)}set(t,e,i,s,n,o){return g(t)?G.copy(this,t):G.set(this,t,e,i,s,n,o),this}setWith(t){return G.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:i,d:s,e:n,f:o}=this;return{a:t,b:e,c:i,d:s,e:n,f:o}}clone(){return new ct(this)}translate(t,e){return G.translate(this,t,e),this}translateInner(t,e){return G.translateInner(this,t,e),this}scale(t,e){return G.scale(this,t,e),this}scaleWith(t,e){return G.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}pixelScale(t){return G.pixelScale(this,t),this}scaleOfOuter(t,e,i){return G.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return G.scaleOfInner(this,t,e,i),this}rotate(t){return G.rotate(this,t),this}rotateOfOuter(t,e){return G.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return G.rotateOfInner(this,t,e),this}skew(t,e){return G.skew(this,t,e),this}skewOfOuter(t,e,i){return G.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return G.skewOfInner(this,t,e,i),this}multiply(t){return G.multiply(this,t),this}multiplyParent(t){return G.multiplyParent(this,t),this}divide(t){return G.divide(this,t),this}divideParent(t){return G.divideParent(this,t),this}invert(){return G.invert(this),this}invertWith(){return G.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){G.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){G.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return G.setLayout(this,t,e,i),this}getLayout(t,e,i){return G.getLayout(this,t,e,i)}withScale(t,e){return G.withScale(this,t,e)}reset(){G.reset(this)}}const ut=new ct,gt={tempPointBounds:{},setPoint(t,e,i){t.minX=t.maxX=e,t.minY=t.maxY=i},addPoint(t,e,i){t.minX=e<t.minX?e:t.minX,t.minY=i<t.minY?i:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=i>t.maxY?i:t.maxY},addBounds(t,e,i,s,n){pt(t,e,i),pt(t,e+s,i+n)},copy(t,e){t.minX=e.minX,t.minY=e.minY,t.maxX=e.maxX,t.maxY=e.maxY},addPointBounds(t,e){t.minX=e.minX<t.minX?e.minX:t.minX,t.minY=e.minY<t.minY?e.minY:t.minY,t.maxX=e.maxX>t.maxX?e.maxX:t.maxX,t.maxY=e.maxY>t.maxY?e.maxY:t.maxY},toBounds(t,e){e.x=t.minX,e.y=t.minY,e.width=t.maxX-t.minX,e.height=t.maxY-t.minY}},{addPoint:pt}=gt;var _t,ft;!function(t){t[t.top=0]="top",t[t.right=1]="right",t[t.bottom=2]="bottom",t[t.left=3]="left"}(_t||(_t={})),function(t){t[t.topLeft=0]="topLeft",t[t.top=1]="top",t[t.topRight=2]="topRight",t[t.right=3]="right",t[t.bottomRight=4]="bottomRight",t[t.bottom=5]="bottom",t[t.bottomLeft=6]="bottomLeft",t[t.left=7]="left",t[t.center=8]="center",t[t["top-left"]=0]="top-left",t[t["top-right"]=2]="top-right",t[t["bottom-right"]=4]="bottom-right",t[t["bottom-left"]=6]="bottom-left"}(ft||(ft={}));const mt=[{x:0,y:0},{x:.5,y:0},{x:1,y:0},{x:1,y:.5},{x:1,y:1},{x:.5,y:1},{x:0,y:1},{x:0,y:.5},{x:.5,y:.5}];mt.forEach(t=>t.type="percent");const yt={directionData:mt,tempPoint:{},get:vt,toPoint(t,e,i,s,n,o){const r=vt(t);i.x=r.x,i.y=r.y,"percent"===r.type&&(i.x*=e.width,i.y*=e.height,n&&(o||(i.x-=n.x,i.y-=n.y),r.x&&(i.x-=1===r.x?n.width:.5===r.x?r.x*n.width:0),r.y&&(i.y-=1===r.y?n.height:.5===r.y?r.y*n.height:0))),s||(i.x+=e.x,i.y+=e.y)},getPoint:(t,e,i)=>(i||(i={}),yt.toPoint(t,e,i,!0),i)};function vt(t){return a(t)?mt[ft[t]]:t}const{toPoint:wt}=yt,xt={toPoint(t,e,i,s,n,o){wt(t,i,s,n,e,o)}},{tempPointBounds:bt,setPoint:kt,addPoint:Et,toBounds:St}=gt,{toOuterPoint:Bt}=G,{float:Tt,fourNumber:Rt}=P,{floor:Ct,ceil:Ot}=Math;let Lt,Pt,At,Dt;const Mt={},Ft={},It={},Wt={tempBounds:It,set(t,e=0,i=0,s=0,n=0){t.x=e,t.y=i,t.width=s,t.height=n},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,i,s,n){const{x:o,y:r,width:a,height:h}=e;if(u(i)){const e=Rt(i);s?zt.set(t,o+e[3],r+e[0],a-e[1]-e[3],h-e[2]-e[0]):zt.set(t,o-e[3],r-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),zt.set(t,o-i,r-i,a+2*i,h+2*i);n&&("width"===n?(t.y=r,t.height=h):(t.x=o,t.width=a))},minX:t=>t.width>0?t.x:t.x+t.width,minY:t=>t.height>0?t.y:t.y+t.height,maxX:t=>t.width>0?t.x+t.width:t.x,maxY:t=>t.height>0?t.y+t.height:t.y,move(t,e,i){t.x+=e,t.y+=i},scroll(t,e){t.x+=e.scrollX,t.y+=e.scrollY},getByMove:(t,e,i)=>(t=Object.assign({},t),zt.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?Yt(e,t):e=t,i||(i=t),e.offsetX=zt.maxX(i),e.offsetY=zt.maxY(i),zt.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e,s){s||nt.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){nt.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(zt.copy(It,t),zt.toOuterOf(It,e),It),getOuterOf:(t,e)=>(t=Object.assign({},t),zt.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:n}=e;s>0?(i.width=t.width*s,i.x=e.e+t.x*s):(i.width=t.width*-s,i.x=e.e+t.x*s-i.width),n>0?(i.height=t.height*n,i.y=e.f+t.y*n):(i.height=t.height*-n,i.y=e.f+t.y*n-i.height)}else Mt.x=t.x,Mt.y=t.y,Bt(e,Mt,Ft),kt(bt,Ft.x,Ft.y),Mt.x=t.x+t.width,Bt(e,Mt,Ft),Et(bt,Ft.x,Ft.y),Mt.y=t.y+t.height,Bt(e,Mt,Ft),Et(bt,Ft.x,Ft.y),Mt.x=t.x,Bt(e,Mt,Ft),Et(bt,Ft.x,Ft.y),St(bt,i)},toInnerOf(t,e,i){i||(i=t),zt.move(i,-e.e,-e.f),zt.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,zt.getFitScale(t,e));return new ct(s,0,0,s,-e.x*s,-e.y*s)},getFitScale(t,e,i){const s=t.width/e.width,n=t.height/e.height;return i?Math.max(s,n):Math.min(s,n)},put(t,e,i="center",s=1,n=!0,o){o||(o=e),a(s)&&(s=zt.getFitScale(t,e,"cover"===s)),It.width=n?e.width*=s:e.width*s,It.height=n?e.height*=s:e.height*s,xt.toPoint(i,It,t,o,!0,!0)},getSpread(t,e,i){const s={};return zt.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){zt.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){zt.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=Ct(t.x),t.y=Ct(t.y),t.width=e>t.x?Ot(t.width+e-t.x):Ot(t.width),t.height=i>t.y?Ot(t.height+i-t.y):Ot(t.height)},unsign(t){t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height)},float(t,e){t.x=Tt(t.x,e),t.y=Tt(t.y,e),t.width=Tt(t.width,e),t.height=Tt(t.height,e)},add(t,e,i){Lt=t.x+t.width,Pt=t.y+t.height,At=e.x,Dt=e.y,i||(At+=e.width,Dt+=e.height),Lt=Lt>At?Lt:At,Pt=Pt>Dt?Pt:Dt,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=Lt-t.x,t.height=Pt-t.y},addList(t,e){zt.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){zt.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){zt.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let n,o=!0;for(let r=0,a=e.length;r<a;r++)n=i?i(e[r],r):e[r],n&&(n.width||n.height)&&(o?(o=!1,s||Yt(t,n)):Nt(t,n));o&&zt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?kt(bt,t.x,t.y):Et(bt,t.x,t.y)),St(bt,t)},setPoint(t,e){zt.set(t,e.x,e.y)},addPoint(t,e){Nt(t,e,!0)},getPoints(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]},hitRadiusPoint:(t,e,i)=>(i&&(e=nt.tempToInnerRadiusPointOf(e,i)),e.x>=t.x-e.radiusX&&e.x<=t.x+t.width+e.radiusX&&e.y>=t.y-e.radiusY&&e.y<=t.y+t.height+e.radiusY),hitPoint:(t,e,i)=>(i&&(e=nt.tempToInnerOf(e,i)),e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height),hit:(t,e,i)=>(i&&(e=zt.tempToOuterOf(e,i)),!(t.y+t.height<e.y||e.y+e.height<t.y||t.x+t.width<e.x||e.x+e.width<t.x)),includes:(t,e,i)=>(i&&(e=zt.tempToOuterOf(e,i)),t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height),getIntersectData(t,e,i){if(i&&(e=zt.tempToOuterOf(e,i)),!zt.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:o,height:r}=e;return Lt=s+o,Pt=n+r,At=t.x+t.width,Dt=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,Lt=Lt<At?Lt:At,Pt=Pt<Dt?Pt:Dt,o=Lt-s,r=Pt-n,{x:s,y:n,width:o,height:r}},intersect(t,e,i){zt.copy(t,zt.getIntersectData(t,e,i))},isSame:(t,e)=>t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height,isEmpty:t=>0===t.x&&0===t.y&&0===t.width&&0===t.height,reset(t){zt.set(t)}},zt=Wt,{add:Nt,copy:Yt}=zt;class Ht{get minX(){return Wt.minX(this)}get minY(){return Wt.minY(this)}get maxX(){return Wt.maxX(this)}get maxY(){return Wt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return g(t)?Wt.copy(this,t):Wt.set(this,t,e,i,s),this}get(){const{x:t,y:e,width:i,height:s}=this;return{x:t,y:e,width:i,height:s}}clone(){return new Ht(this)}move(t,e){return Wt.move(this,t,e),this}scale(t,e,i){return Wt.scale(this,t,e,i),this}scaleOf(t,e,i){return Wt.scaleOf(this,t,e,i),this}toOuterOf(t,e){return Wt.toOuterOf(this,t,e),this}toInnerOf(t,e){return Wt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return Wt.getFitMatrix(this,t,e)}put(t,e,i){Wt.put(this,t,e,i)}spread(t,e){return Wt.spread(this,t,e),this}shrink(t,e){return Wt.shrink(this,t,e),this}ceil(){return Wt.ceil(this),this}unsign(){return Wt.unsign(this),this}float(t){return Wt.float(this,t),this}add(t){return Wt.add(this,t),this}addList(t){return Wt.setList(this,t,!0),this}setList(t){return Wt.setList(this,t),this}addListWithFn(t,e){return Wt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return Wt.setListWithFn(this,t,e),this}setPoint(t){return Wt.setPoint(this,t),this}setPoints(t){return Wt.setPoints(this,t),this}addPoint(t){return Wt.addPoint(this,t),this}getPoints(){return Wt.getPoints(this)}hitPoint(t,e){return Wt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return Wt.hitRadiusPoint(this,t,e)}hit(t,e){return Wt.hit(this,t,e)}includes(t,e){return Wt.includes(this,t,e)}intersect(t,e){return Wt.intersect(this,t,e),this}getIntersect(t,e){return new Ht(Wt.getIntersectData(this,t,e))}isSame(t){return Wt.isSame(this,t)}isEmpty(){return Wt.isEmpty(this)}reset(){Wt.reset(this)}}const Xt=new Ht;class Vt{constructor(t,e,i,s,n,o){g(t)?this.copy(t):this.set(t,e,i,s,n,o)}set(t=0,e=0,i=0,s=0,n=0,o=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=n,this.height=o}copy(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=t;this.set(e,i,s,n,o,r)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=this;return new Ht(n,e,o||t.width-n-i,r||t.height-e-s)}}const jt={0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,".":1,e:1,E:1},{randColor:Ut}=P;class Gt{constructor(t){this.repeatMap={},this.name=t}static get(t){return new Gt(t)}static set filter(t){this.filterList=Kt(t)}static set exclude(t){this.excludeList=Kt(t)}static drawRepaint(t,e){const i=Ut();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(t,e,i){const s="hit"===Gt.showBounds,n=t.__nowWorld,o=Ut();s&&(e.setWorld(n),t.__drawHitPath(e),e.fillStyle=o.replace("1)",".2)"),e.fill()),e.resetTransform(),e.setStroke(o,2),s?e.stroke():e.strokeWorld(n,o)}log(...t){if(qt.enable){if(qt.filterList.length&&qt.filterList.every(t=>t!==this.name))return;if(qt.excludeList.length&&qt.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){qt.enable&&this.warn(...t)}warn(...t){qt.showWarn&&console.warn(this.name,...t)}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}function Kt(t){return t?a(t)&&(t=[t]):t=[],t}Gt.filterList=[],Gt.excludeList=[],Gt.showWarn=!0;const qt=Gt,Zt=Gt.get("RunTime"),Jt={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,i){const s=e.create(e.RUNTIME);return $t.currentId=$t.idMap[s]=i?performance.now():Date.now(),$t.currentName=$t.nameMap[s]=t,$t.nameToIdMap[t]=s,s},end(t,e){const i=$t.idMap[t],s=$t.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;$t.idMap[t]=$t.nameMap[t]=$t.nameToIdMap[s]=void 0,Zt.log(s,n,"ms")},endOfName(t,e){const i=$t.nameToIdMap[t];o(i)||$t.end(i,e)}},$t=Jt,Qt=[],te={list:{},add(t,...e){this.list[t]=!0,Qt.push(...e)},has(t,e){const i=this.list[t];return!i&&e&&this.need(t),i},need(t){console.error("please install and import plugin: "+(t.includes("-x")?"":"@leafer-in/")+t)}};setTimeout(()=>Qt.forEach(t=>te.has(t,!0)));const ee={editor:t=>te.need("editor")},ie=Gt.get("UICreator"),se={list:{},register(t){const{__tag:e}=t.prototype;ne[e]&&ie.repeat(e),ne[e]=t},get(t,e,i,s,n,r){ne[t]||ie.error("not register "+t);const a=new ne[t](e);return o(i)||(a.x=i,s&&(a.y=s),n&&(a.width=n),r&&(a.height=r)),a}},{list:ne}=se,oe=Gt.get("EventCreator"),re={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],a(e)&&(ae[e]&&oe.repeat(e),ae[e]=t)})},changeName(t,e){const i=ae[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,ae[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new ae[t](...e)},{nameList:ae}=re;class he{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:i}=this;for(let s=0,n=i.length;s<n;s++)if(e=i[s],e.recycled&&e.isSameSize(t))return e.recycled=!1,e.manager||(e.manager=this),e;const s=ee.canvas(t);return this.add(s),s}recycle(t){t.recycled=!0}clearRecycled(){let t;const e=[];for(let i=0,s=this.list.length;i<s;i++)t=this.list[i],t.recycled?t.destroy():e.push(t);this.list=e}clear(){this.list.forEach(t=>{t.destroy()}),this.list.length=0}destroy(){this.clear()}}function le(t,e,i,s){var n,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o<3?n(r):o>3?n(e,i,r):n(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r}function de(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){t.done?n(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(r,a)}h((s=s.apply(t,e||[])).next())})}function ce(t){return(e,i)=>{t||(t=i);const s={get(){return this.context[t]},set(e){this.context[t]=e}};"strokeCap"===i&&(s.set=function(e){this.context[t]="none"===e?"butt":e}),Object.defineProperty(e,i,s)}}"function"==typeof SuppressedError&&SuppressedError;const ue=[];function ge(){return(t,e)=>{ue.push(e)}}const pe=[];let _e=class{set blendMode(t){"normal"===t&&(t="source-over"),this.context.globalCompositeOperation=t}get blendMode(){return this.context.globalCompositeOperation}set dashPattern(t){this.context.setLineDash(t||pe)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;ue.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,i,s,n,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,n,o){g(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,n,o)}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,i,s){}strokeRect(t,e,i,s){}clearRect(t,e,i,s){}drawImage(t,e,i,s,n,o,r,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/s*a;s+=e,e=0,o+=t,a-=t}if(i<0){const t=-i/n*h;n+=i,i=0,r+=t,h-=t}this.context.drawImage(t,e,i,s,n,o,r,a,h);break;case 5:this.context.drawImage(t,e,i,s,n);break;case 3:this.context.drawImage(t,e,i)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,i,s,n,o){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,n,o){}arcTo(t,e,i,s,n){}ellipse(t,e,i,s,n,o,r,a){}rect(t,e,i,s){}roundRect(t,e,i,s,n){}createConicGradient(t,e,i){}createLinearGradient(t,e,i,s){}createPattern(t,e){}createRadialGradient(t,e,i,s,n,o){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}};le([ce("imageSmoothingEnabled")],_e.prototype,"smooth",void 0),le([ce("imageSmoothingQuality")],_e.prototype,"smoothLevel",void 0),le([ce("globalAlpha")],_e.prototype,"opacity",void 0),le([ce()],_e.prototype,"fillStyle",void 0),le([ce()],_e.prototype,"strokeStyle",void 0),le([ce("lineWidth")],_e.prototype,"strokeWidth",void 0),le([ce("lineCap")],_e.prototype,"strokeCap",void 0),le([ce("lineJoin")],_e.prototype,"strokeJoin",void 0),le([ce("lineDashOffset")],_e.prototype,"dashOffset",void 0),le([ce()],_e.prototype,"miterLimit",void 0),le([ce()],_e.prototype,"shadowBlur",void 0),le([ce()],_e.prototype,"shadowColor",void 0),le([ce()],_e.prototype,"shadowOffsetX",void 0),le([ce()],_e.prototype,"shadowOffsetY",void 0),le([ce()],_e.prototype,"filter",void 0),le([ce()],_e.prototype,"font",void 0),le([ce()],_e.prototype,"fontKerning",void 0),le([ce()],_e.prototype,"fontStretch",void 0),le([ce()],_e.prototype,"fontVariantCaps",void 0),le([ce()],_e.prototype,"textAlign",void 0),le([ce()],_e.prototype,"textBaseline",void 0),le([ce()],_e.prototype,"textRendering",void 0),le([ce()],_e.prototype,"wordSpacing",void 0),le([ce()],_e.prototype,"letterSpacing",void 0),le([ce()],_e.prototype,"direction",void 0),le([ge()],_e.prototype,"setTransform",null),le([ge()],_e.prototype,"resetTransform",null),le([ge()],_e.prototype,"getTransform",null),le([ge()],_e.prototype,"save",null),le([ge()],_e.prototype,"restore",null),le([ge()],_e.prototype,"translate",null),le([ge()],_e.prototype,"scale",null),le([ge()],_e.prototype,"rotate",null),le([ge()],_e.prototype,"fill",null),le([ge()],_e.prototype,"stroke",null),le([ge()],_e.prototype,"clip",null),le([ge()],_e.prototype,"fillRect",null),le([ge()],_e.prototype,"strokeRect",null),le([ge()],_e.prototype,"clearRect",null),le([ge()],_e.prototype,"beginPath",null),le([ge()],_e.prototype,"moveTo",null),le([ge()],_e.prototype,"lineTo",null),le([ge()],_e.prototype,"bezierCurveTo",null),le([ge()],_e.prototype,"quadraticCurveTo",null),le([ge()],_e.prototype,"closePath",null),le([ge()],_e.prototype,"arc",null),le([ge()],_e.prototype,"arcTo",null),le([ge()],_e.prototype,"ellipse",null),le([ge()],_e.prototype,"rect",null),le([ge()],_e.prototype,"roundRect",null),le([ge()],_e.prototype,"createConicGradient",null),le([ge()],_e.prototype,"createLinearGradient",null),le([ge()],_e.prototype,"createPattern",null),le([ge()],_e.prototype,"createRadialGradient",null),le([ge()],_e.prototype,"fillText",null),le([ge()],_e.prototype,"measureText",null),le([ge()],_e.prototype,"strokeText",null);const{copy:fe,multiplyParent:me,pixelScale:ye}=G,{round:ve}=Math,we=new Ht,xe=new Ht,be={width:1,height:1,pixelRatio:1},ke=["width","height","pixelRatio"];class Ee extends _e{get width(){return this.size.width}get height(){return this.size.height}get pixelRatio(){return this.size.pixelRatio}get pixelWidth(){return this.width*this.pixelRatio||0}get pixelHeight(){return this.height*this.pixelRatio||0}get pixelSnap(){return this.config.pixelSnap}set pixelSnap(t){this.config.pixelSnap=t}get allowBackgroundColor(){return this.view&&this.parentView}constructor(i,s){super(),this.size={},this.worldTransform={},i||(i=be),this.manager=s,this.innerId=e.create(e.CNAVAS);const{width:n,height:o,pixelRatio:r}=i;this.autoLayout=!n||!o,this.size.pixelRatio=r||t.devicePixelRatio,this.config=i,this.init()}init(){}__createContext(){const{view:t}=this,{contextSettings:e}=this.config;this.context=e?t.getContext("2d",e):t.getContext("2d"),this.__bindContext()}export(t,e){}toBlob(t,e){}toDataURL(t,e){}saveAs(t,e){}resize(t,e=!0){if(this.isSameSize(t))return;let i;this.context&&!this.unreal&&e&&this.width&&(i=this.getSameCanvas(),i.copyWorld(this));const s=this.size;f.copyAttrs(s,t,ke),ke.forEach(t=>s[t]||(s[t]=1)),this.bounds=new Ht(0,0,this.width,this.height),this.updateViewSize(),this.updateClientBounds(),this.context&&(this.smooth=this.config.smooth,!this.unreal&&i&&(this.clearWorld(i.bounds),this.copyWorld(i),i.recycle()))}updateViewSize(){}updateClientBounds(){}getClientBounds(t){return t&&this.updateClientBounds(),this.clientBounds||this.bounds}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e){const{pixelRatio:i,pixelSnap:s}=this,n=this.worldTransform;e&&me(t,e,n),ye(t,i,n),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(n.e=ve(n.e-.5)+.5,n.f=ve(n.f-.5)+.5):(n.e=ve(n.e),n.f=ve(n.f))),this.setTransform(n.a,n.b,n.c,n.d,n.e,n.f)}useWorldTransform(t){t&&(this.worldTransform=t);const e=this.worldTransform;e&&this.setTransform(e.a,e.b,e.c,e.d,e.e,e.f)}setStroke(t,e,i,s){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),i&&this.setStrokeOptions(i,s)}setStrokeOptions(t,e){let{strokeCap:i,strokeJoin:s,dashPattern:n,dashOffset:r,miterLimit:a}=t;e&&(e.strokeCap&&(i=e.strokeCap),e.strokeJoin&&(s=e.strokeJoin),o(e.dashPattern)||(n=e.dashPattern),o(e.dashOffset)||(r=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=i,this.strokeJoin=s,this.dashPattern=n,this.dashOffset=r,this.miterLimit=a}saveBlendMode(t){this.savedBlendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedBlendMode}hitFill(t,e){return!0}hitStroke(t,e){return!0}hitPixel(t,e,i=1){return!0}setWorldShadow(t,e,i,s){const{pixelRatio:n}=this;this.shadowOffsetX=t*n,this.shadowOffsetY=e*n,this.shadowBlur=i*n,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s,n=!0){s&&(this.blendMode=s),e?(this.setTempPixelBounds(e,n),i?(this.setTempPixelBounds2(i,n),i=xe):i=we,this.drawImage(t.view,we.x,we.y,we.width,we.height,i.x,i.y,i.width,i.height)):this.drawImage(t.view,0,0),s&&(this.blendMode="source-over")}copyWorldToInner(t,e,i,s,n=!0){e.b||e.c?(this.save(),this.resetTransform(),this.copyWorld(t,e,Wt.tempToOuterOf(i,e),s,n),this.restore()):(s&&(this.blendMode=s),this.setTempPixelBounds(e,n),this.drawImage(t.view,we.x,we.y,we.width,we.height,i.x,i.y,i.width,i.height),s&&(this.blendMode="source-over"))}copyWorldByReset(t,e,i,s,n,o=!0){this.resetTransform(),this.copyWorld(t,e,i,s,o),n||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempPixelBounds(t,!0,!0);const{context:s}=this,n=s.getImageData(we.x,we.y,we.width,we.height),{data:o}=n;for(let t=0,s=o.length;t<s;t+=4)i=.299*o[t]+.587*o[t+1]+.114*o[t+2],(e=o[t+3])&&(o[t+3]=255===e?i:e*(i/255));s.putImageData(n,we.x,we.y)}useMask(t,e,i){this.copyWorld(t,e,i,"destination-in")}useEraser(t,e,i){this.copyWorld(t,e,i,"destination-out")}fillWorld(t,e,i,s){i&&(this.blendMode=i),this.fillStyle=e,this.setTempPixelBounds(t,s),this.fillRect(we.x,we.y,we.width,we.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(we.x,we.y,we.width,we.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(we.x,we.y,we.width,we.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(we.x,we.y,we.width,we.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(we,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(xe,t,e,i)}copyToPixelBounds(t,e,i,s){t.set(e),s&&t.intersect(this.bounds),t.scale(this.pixelRatio),i&&t.ceil()}isSameSize(t){return this.width===t.width&&this.height===t.height&&(!t.pixelRatio||this.pixelRatio===t.pixelRatio)}getSameCanvas(t,e){const{size:i,pixelSnap:s}=this,n=this.manager?this.manager.get(i):ee.canvas(Object.assign({},i));return n.save(),t&&(fe(n.worldTransform,this.worldTransform),n.useWorldTransform()),e&&(n.smooth=this.smooth),n.pixelSnap!==s&&(n.pixelSnap=s),n}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const Se={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Be={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Te=Object.assign({M:1,m:10,L:2,l:20,H:3,h:30,V:4,v:40,C:5,c:50,S:6,s:60,Q:7,q:70,T:8,t:80,A:9,a:90,Z:11,z:11,R:12},Be),Re={M:3,m:3,L:3,l:3,H:2,h:2,V:2,v:2,C:7,c:7,S:5,s:5,Q:5,q:5,T:3,t:3,A:8,a:8,Z:1,z:1,N:5,D:9,X:6,G:9,F:5,O:7,P:4,U:6},Ce={m:10,l:20,H:3,h:30,V:4,v:40,c:50,S:6,s:60,q:70,T:8,t:80,A:9,a:90},Oe=Object.assign(Object.assign({},Ce),Be),Le=Te,Pe={};for(let t in Le)Pe[Le[t]]=t;const Ae={};for(let t in Le)Ae[Le[t]]=Re[t];const De={drawRoundRect(t,e,i,s,n,o){const r=P.fourNumber(o,Math.min(s/2,n/2)),a=e+s,h=i+n;r[0]?t.moveTo(e+r[0],i):t.moveTo(e,i),r[1]?t.arcTo(a,i,a,h,r[1]):t.lineTo(a,i),r[2]?t.arcTo(a,h,e,h,r[2]):t.lineTo(a,h),r[3]?t.arcTo(e,h,e,i,r[3]):t.lineTo(e,h),r[0]?t.arcTo(e,i,a,i,r[0]):t.lineTo(e,i)}},{sin:Me,cos:Fe,hypot:Ie,atan2:We,ceil:ze,abs:Ne,PI:Ye,sqrt:He,pow:Xe}=Math,{setPoint:Ve,addPoint:je}=gt,{set:Ue,toNumberPoints:Ge}=nt,{M:Ke,L:qe,C:Ze,Q:Je,Z:$e}=Te,Qe={},ti={points(t,e,i,s){let n=Ge(e);if(t.push(Ke,n[0],n[1]),i&&n.length>5){let e,o,r,a,h,l,d,c,u,g,p,_,f,m=n.length;const y=!0===i?.5:i;s&&(n=[n[m-2],n[m-1],...n,n[0],n[1],n[2],n[3]],m=n.length);for(let i=2;i<m-2;i+=2)e=n[i-2],o=n[i-1],r=n[i],a=n[i+1],h=n[i+2],l=n[i+3],p=He(Xe(r-e,2)+Xe(a-o,2)),_=He(Xe(h-r,2)+Xe(l-a,2)),(p||_)&&(f=p+_,p=y*p/f,_=y*_/f,h-=e,l-=o,d=r-p*h,c=a-p*l,2===i?s||t.push(Je,d,c,r,a):t.push(Ze,u,g,d,c,r,a),u=r+_*h,g=a+_*l);s||t.push(Je,u,g,n[m-2],n[m-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(qe,n[e],n[e+1]);s&&t.push($e)},rect(t,e,i,s,n){Se.creator.path=t,Se.creator.moveTo(e,i).lineTo(e+s,i).lineTo(e+s,i+n).lineTo(e,i+n).lineTo(e,i)},roundRect(t,e,i,s,n,o){Se.creator.path=[],De.drawRoundRect(Se.creator,e,i,s,n,o),t.push(...Se.convertToCanvasData(Se.creator.path,!0))},arcTo(t,e,i,s,n,o,r,a,h,l,d){const c=s-e,u=n-i,g=o-s,p=r-n;let _=We(u,c),f=We(p,g);const m=Ie(c,u),y=Ie(g,p);let v=f-_;if(v<0&&(v+=M),m<1e-12||y<1e-12||v<1e-12||Ne(v-Ye)<1e-12)return t&&t.push(qe,s,n),h&&(Ve(h,e,i),je(h,s,n)),d&&Ue(d,e,i),void(l&&Ue(l,s,n));const w=c*p-g*u<0,x=w?-1:1,b=a/Fe(v/2),k=s+b*Fe(_+v/2+F*x),E=n+b*Me(_+v/2+F*x);return _-=F*x,f-=F*x,si(t,k,E,a,a,0,_/D,f/D,w,h,l,d)},arc:(t,e,i,s,n,o,r,a,h,l)=>si(t,e,i,s,s,0,n,o,r,a,h,l),ellipse(t,e,i,s,n,o,r,a,h,l,d,c){const u=o*D,g=Me(u),p=Fe(u);let _=r*D,f=a*D;_>Ye&&(_-=M),f<0&&(f+=M);let m=f-_;m<0?m+=M:m>M&&(m-=M),h&&(m-=M);const y=ze(Ne(m/F)),v=m/y,w=Me(v/4),x=8/3*w*w/Me(v/2);f=_+v;let b,k,E,S,B,T,R,C,O=Fe(_),L=Me(_),P=E=p*s*O-g*n*L,A=S=g*s*O+p*n*L,I=e+E,W=i+S;t&&t.push(t.length?qe:Ke,I,W),l&&Ve(l,I,W),c&&Ue(c,I,W);for(let o=0;o<y;o++)b=Fe(f),k=Me(f),E=p*s*b-g*n*k,S=g*s*b+p*n*k,B=e+P-x*(p*s*L+g*n*O),T=i+A-x*(g*s*L-p*n*O),R=e+E+x*(p*s*k+g*n*b),C=i+S+x*(g*s*k-p*n*b),t&&t.push(Ze,B,T,R,C,e+E,i+S),l&&ii(e+P,i+A,B,T,R,C,e+E,i+S,l,!0),P=E,A=S,O=b,L=k,_=f,f+=v;d&&Ue(d,e+E,i+S)},quadraticCurveTo(t,e,i,s,n,o,r){t.push(Ze,(e+2*s)/3,(i+2*n)/3,(o+2*s)/3,(r+2*n)/3,o,r)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,n,o,r,a){ii(t,e,(t+2*i)/3,(e+2*s)/3,(n+2*i)/3,(o+2*s)/3,n,o,r,a)},toTwoPointBounds(t,e,i,s,n,o,r,a,h,l){const d=[];let c,u,g,p,_,f,m,y,v=t,w=i,x=n,b=r;for(let t=0;t<2;++t)if(1==t&&(v=e,w=s,x=o,b=a),c=-3*v+9*w-9*x+3*b,u=6*v-12*w+6*x,g=3*w-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;p=-g/u,0<p&&p<1&&d.push(p)}else m=u*u-4*g*c,y=Math.sqrt(m),m<0||(_=(-u+y)/(2*c),0<_&&_<1&&d.push(_),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?je(h,t,e):Ve(h,t,e),je(h,r,a);for(let l=0,c=d.length;l<c;l++)ei(d[l],t,e,i,s,n,o,r,a,Qe),je(h,Qe.x,Qe.y)},getPointAndSet(t,e,i,s,n,o,r,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,g=3*d*t*t,p=t*t*t;l.x=c*e+u*s+g*o+p*a,l.y=c*i+u*n+g*r+p*h},getPoint(t,e,i,s,n,o,r,a,h){const l={};return ei(t,e,i,s,n,o,r,a,h,l),l},getDerivative(t,e,i,s,n){const o=1-t;return 3*o*o*(i-e)+6*o*t*(s-i)+3*t*t*(n-s)}},{getPointAndSet:ei,toTwoPointBounds:ii,ellipse:si}=ti,{sin:ni,cos:oi,sqrt:ri,atan2:ai}=Math,{ellipse:hi}=ti,li={ellipticalArc(e,i,s,n,o,r,a,h,l,d,c){const u=(l-i)/2,g=(d-s)/2,p=r*D,_=ni(p),f=oi(p),m=-f*u-_*g,y=-f*g+_*u,v=n*n,w=o*o,x=y*y,b=m*m,k=v*w-v*x-w*b;let E=0;if(k<0){const t=ri(1-k/(v*w));n*=t,o*=t}else E=(a===h?-1:1)*ri(k/(v*x+w*b));const S=E*n*y/o,B=-E*o*m/n,T=ai((y-B)/o,(m-S)/n),R=ai((-y-B)/o,(-m-S)/n);let C=R-T;0===h&&C>0?C-=M:1===h&&C<0&&(C+=M);const O=i+u+f*S-_*B,L=s+g+_*S+f*B,P=C<0?1:0;c||t.ellipseToCurve?hi(e,O,L,n,o,r,T/D,R/D,P):n!==o||r?e.push(Te.G,O,L,n,o,r,T/D,R/D,P):e.push(Te.O,O,L,n,T/D,R/D,P)}},{M:di,m:ci,L:ui,l:gi,H:pi,h:_i,V:fi,v:mi,C:yi,c:vi,S:wi,s:xi,Q:bi,q:ki,T:Ei,t:Si,A:Bi,a:Ti,Z:Ri,z:Ci,N:Oi,D:Li,X:Pi,G:Ai,F:Di,O:Mi,P:Fi,U:Ii}=Te,{rect:Wi,roundRect:zi,arcTo:Ni,arc:Yi,ellipse:Hi,quadraticCurveTo:Xi}=ti,{ellipticalArc:Vi}=li,ji=Gt.get("PathConvert"),Ui={},Gi={current:{dot:0},stringify(t,e){let i,s,n,o=0,r=t.length,a="";for(;o<r;){s=t[o],i=Ae[s],a+=s===n?" ":Pe[s];for(let s=1;s<i;s++)a+=P.float(t[o+s],e),s===i-1||(a+=" ");n=s,o+=i}return a},parse(t,e){let i,s,n,o="";const r=[],a=e?Oe:Ce;for(let e=0,h=t.length;e<h;e++)s=t[e],jt[s]?("."===s&&(Ki.dot&&(qi(r,o),o=""),Ki.dot++),"0"===o&&"."!==s&&(qi(r,o),o=""),o+=s):Te[s]?(o&&(qi(r,o),o=""),Ki.name=Te[s],Ki.length=Re[s],Ki.index=0,qi(r,Ki.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?o+=s:(o&&qi(r,o),o=s):o&&(qi(r,o),o=""),n=s;return o&&qi(r,o),i?Gi.toCanvasData(r,e):r},toCanvasData(t,e){let i,s,n,o,r,a=0,h=0,l=0,d=0,c=0,u=t.length;const g=[];for(;c<u;){switch(n=t[c],n){case ci:t[c+1]+=a,t[c+2]+=h;case di:a=t[c+1],h=t[c+2],g.push(di,a,h),c+=3;break;case _i:t[c+1]+=a;case pi:a=t[c+1],g.push(ui,a,h),c+=2;break;case mi:t[c+1]+=h;case fi:h=t[c+1],g.push(ui,a,h),c+=2;break;case gi:t[c+1]+=a,t[c+2]+=h;case ui:a=t[c+1],h=t[c+2],g.push(ui,a,h),c+=3;break;case xi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=wi;case wi:r=o===yi||o===wi,l=r?2*a-i:t[c+1],d=r?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],g.push(yi,l,d,i,s,a,h),c+=5;break;case vi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,n=yi;case yi:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],g.push(yi,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Si:t[c+1]+=a,t[c+2]+=h,n=Ei;case Ei:r=o===bi||o===Ei,i=r?2*a-i:t[c+1],s=r?2*h-s:t[c+2],e?Xi(g,a,h,i,s,t[c+1],t[c+2]):g.push(bi,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case ki:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=bi;case bi:i=t[c+1],s=t[c+2],e?Xi(g,a,h,i,s,t[c+3],t[c+4]):g.push(bi,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Ti:t[c+6]+=a,t[c+7]+=h;case Bi:Vi(g,a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),a=t[c+6],h=t[c+7],c+=8;break;case Ci:case Ri:g.push(Ri),c++;break;case Oi:a=t[c+1],h=t[c+2],e?Wi(g,a,h,t[c+3],t[c+4]):Zi(g,t,c,5),c+=5;break;case Li:a=t[c+1],h=t[c+2],e?zi(g,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):Zi(g,t,c,9),c+=9;break;case Pi:a=t[c+1],h=t[c+2],e?zi(g,a,h,t[c+3],t[c+4],t[c+5]):Zi(g,t,c,6),c+=6;break;case Ai:Hi(e?g:Zi(g,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,Ui),a=Ui.x,h=Ui.y,c+=9;break;case Di:e?Hi(g,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):Zi(g,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Mi:Yi(e?g:Zi(g,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,Ui),a=Ui.x,h=Ui.y,c+=7;break;case Fi:e?Yi(g,t[c+1],t[c+2],t[c+3],0,360,!1):Zi(g,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Ii:Ni(e?g:Zi(g,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,Ui),a=Ui.x,h=Ui.y,c+=6;break;default:return ji.error(`command: ${n} [index:${c}]`,t),g}o=n}return g},objectToCanvasData(t){const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(di,t.x,t.y);break;case"L":e.push(ui,t.x,t.y);break;case"C":e.push(yi,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(bi,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(Ri)}}),e},copyData(t,e,i,s){for(let n=i,o=i+s;n<o;n++)t.push(e[n])},pushData(t,e){Ki.index===Ki.length&&(Ki.index=1,t.push(Ki.name)),t.push(Number(e)),Ki.index++,Ki.dot=0}},{current:Ki,pushData:qi,copyData:Zi}=Gi,{M:Ji,L:$i,C:Qi,Q:ts,Z:es,N:is,D:ss,X:ns,G:os,F:rs,O:as,P:hs,U:ls}=Te,{getMinDistanceFrom:ds,getRadianFrom:cs}=nt,{tan:us,min:gs,abs:ps}=Math,_s={},fs={beginPath(t){t.length=0},moveTo(t,e,i){t.push(Ji,e,i)},lineTo(t,e,i){t.push($i,e,i)},bezierCurveTo(t,e,i,s,n,o,r){t.push(Qi,e,i,s,n,o,r)},quadraticCurveTo(t,e,i,s,n){t.push(ts,e,i,s,n)},closePath(t){t.push(es)},rect(t,e,i,s,n){t.push(is,e,i,s,n)},roundRect(t,e,i,s,n,o){if(l(o))t.push(ns,e,i,s,n,o);else{const r=P.fourNumber(o);r?t.push(ss,e,i,s,n,...r):t.push(is,e,i,s,n)}},ellipse(t,e,i,s,n,o,a,h,l){r(o)?t.push(rs,e,i,s,n):(r(a)&&(a=0),r(h)&&(h=360),t.push(os,e,i,s,n,o,a,h,l?1:0))},arc(t,e,i,s,n,o,a){r(n)?t.push(hs,e,i,s):(r(o)&&(o=360),t.push(as,e,i,s,n,o,a?1:0))},arcTo(t,e,i,s,n,r,a,h){if(!o(a)){const t=ds(a,h,e,i,s,n);r=gs(r,gs(t/2,t/2*ps(us(cs(a,h,e,i,s,n)/2))))}t.push(ls,e,i,s,n,r)},drawEllipse(t,e,i,s,n,o,a,h,l){ti.ellipse(null,e,i,s,n,r(o)?0:o,r(a)?0:a,r(h)?360:h,l,null,null,_s),t.push(Ji,_s.x,_s.y),ms(t,e,i,s,n,o,a,h,l)},drawArc(t,e,i,s,n,o,a){ti.arc(null,e,i,s,r(n)?0:n,r(o)?360:o,a,null,null,_s),t.push(Ji,_s.x,_s.y),ys(t,e,i,s,n,o,a)},drawPoints(t,e,i,s){ti.points(t,e,i,s)}},{ellipse:ms,arc:ys}=fs,{moveTo:vs,lineTo:ws,quadraticCurveTo:xs,bezierCurveTo:bs,closePath:ks,beginPath:Es,rect:Ss,roundRect:Bs,ellipse:Ts,arc:Rs,arcTo:Cs,drawEllipse:Os,drawArc:Ls,drawPoints:Ps}=fs;class As{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?a(t)?Se.parse(t):t:[],this}beginPath(){return Es(this.__path),this.paint(),this}moveTo(t,e){return vs(this.__path,t,e),this.paint(),this}lineTo(t,e){return ws(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,o){return bs(this.__path,t,e,i,s,n,o),this.paint(),this}quadraticCurveTo(t,e,i,s){return xs(this.__path,t,e,i,s),this.paint(),this}closePath(){return ks(this.__path),this.paint(),this}rect(t,e,i,s){return Ss(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return Bs(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,o,r,a){return Ts(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}arc(t,e,i,s,n,o){return Rs(this.__path,t,e,i,s,n,o),this.paint(),this}arcTo(t,e,i,s,n){return Cs(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,o,r,a){return Os(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}drawArc(t,e,i,s,n,o){return Ls(this.__path,t,e,i,s,n,o),this.paint(),this}drawPoints(t,e,i){return Ps(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:Ds,L:Ms,C:Fs,Q:Is,Z:Ws,N:zs,D:Ns,X:Ys,G:Hs,F:Xs,O:Vs,P:js,U:Us}=Te,Gs=Gt.get("PathDrawer"),Ks={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case Ds:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Ms:t.lineTo(e[s+1],e[s+2]),s+=3;break;case Fs:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case Is:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Ws:t.closePath(),s+=1;break;case zs:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Ns:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],[e[s+5],e[s+6],e[s+7],e[s+8]]),s+=9;break;case Ys:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case Hs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*D,e[s+6]*D,e[s+7]*D,e[s+8]),s+=9;break;case Xs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,M,!1),s+=5;break;case Vs:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*D,e[s+5]*D,e[s+6]),s+=7;break;case js:t.arc(e[s+1],e[s+2],e[s+3],0,M,!1),s+=4;break;case Us:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void Gs.error(`command: ${i} [index:${s}]`,e)}}},{M:qs,L:Zs,C:Js,Q:$s,Z:Qs,N:tn,D:en,X:sn,G:nn,F:on,O:rn,P:an,U:hn}=Te,{toTwoPointBounds:ln,toTwoPointBoundsByQuadraticCurve:dn,arcTo:cn,arc:un,ellipse:gn}=ti,{addPointBounds:pn,copy:_n,addPoint:fn,setPoint:mn,addBounds:yn,toBounds:vn}=gt,wn=Gt.get("PathBounds");let xn,bn,kn;const En={},Sn={},Bn={},Tn={toBounds(t,e){Tn.toTwoPointBounds(t,Sn),vn(Sn,e)},toTwoPointBounds(t,e){if(!t||!t.length)return mn(e,0,0);let i,s,n,o,r,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(r=t[a],0===a&&(r===Qs||r===Js||r===$s?mn(e,h,l):mn(e,t[a+1],t[a+2])),r){case qs:case Zs:h=t[a+1],l=t[a+2],fn(e,h,l),a+=3;break;case Js:n=t[a+5],o=t[a+6],ln(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,o,En),pn(e,En),h=n,l=o,a+=7;break;case $s:i=t[a+1],s=t[a+2],n=t[a+3],o=t[a+4],dn(h,l,i,s,n,o,En),pn(e,En),h=n,l=o,a+=5;break;case Qs:a+=1;break;case tn:h=t[a+1],l=t[a+2],yn(e,h,l,t[a+3],t[a+4]),a+=5;break;case en:case sn:h=t[a+1],l=t[a+2],yn(e,h,l,t[a+3],t[a+4]),a+=r===en?9:6;break;case nn:gn(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],t[a+7],t[a+8],En,Bn),0===a?_n(e,En):pn(e,En),h=Bn.x,l=Bn.y,a+=9;break;case on:h=t[a+1],l=t[a+2],bn=t[a+3],kn=t[a+4],yn(e,h-bn,l-kn,2*bn,2*kn),h+=bn,a+=5;break;case rn:un(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],En,Bn),0===a?_n(e,En):pn(e,En),h=Bn.x,l=Bn.y,a+=7;break;case an:h=t[a+1],l=t[a+2],xn=t[a+3],yn(e,h-xn,l-xn,2*xn,2*xn),h+=xn,a+=4;break;case hn:cn(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],En,Bn),0===a?_n(e,En):pn(e,En),h=Bn.x,l=Bn.y,a+=6;break;default:return void wn.error(`command: ${r} [index:${a}]`,t)}}},{M:Rn,L:Cn,Z:On}=Te,{getCenterX:Ln,getCenterY:Pn}=nt,{arcTo:An}=fs,Dn={smooth(t,e,i){let s,n,o,r=0,a=0,h=0,l=0,d=0,c=0,u=0,g=0,p=0;const _=t.length,f=[];for(;r<_;){switch(s=t[r],s){case Rn:l=g=t[r+1],d=p=t[r+2],r+=3,t[r]===Cn?(c=t[r+1],u=t[r+2],f.push(Rn,Ln(l,c),Pn(d,u))):f.push(Rn,l,d);break;case Cn:switch(a=t[r+1],h=t[r+2],r+=3,t[r]){case Cn:An(f,a,h,t[r+1],t[r+2],e,g,p);break;case On:An(f,a,h,l,d,e,g,p);break;default:f.push(Cn,a,h)}g=a,p=h;break;case On:n!==On&&(An(f,l,d,c,u,e,g,p),f.push(On)),r+=1;break;default:o=Ae[s];for(let e=0;e<o;e++)f.push(t[r+e]);r+=o}n=s}return s!==On&&(f[1]=l,f[2]=d),f}};function Mn(t){return new As(t)}const Fn=Mn();Se.creator=Mn(),Se.parse=Gi.parse,Se.convertToCanvasData=Gi.toCanvasData;const{drawRoundRect:In}=De;function Wn(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){In(this,t,e,i,s,n)})}(t)}const zn={alphaPixelTypes:["png","webp","svg"],upperCaseTypeMap:{},mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]},isOpaqueImage(t){const e=Nn.fileType(t);return["jpg","jpeg"].some(t=>t===e)},getExportOptions(t){switch(typeof t){case"object":return t;case"number":return{quality:t};case"boolean":return{blob:t};default:return{}}}},Nn=zn;Nn.alphaPixelTypes.forEach(t=>Nn.upperCaseTypeMap[t]=t.toUpperCase());const Yn=Gt.get("TaskProcessor");class Hn{constructor(t){this.parallel=!0,this.time=1,this.id=e.create(e.TASK),this.task=t}run(){return de(this,void 0,void 0,function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){Yn.error(t)}})}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class Xn{get total(){return this.list.length+this.delayNumber}get finishedIndex(){return this.isComplete?0:this.index+this.parallelSuccessNumber}get remain(){return this.isComplete?this.total:this.total-this.finishedIndex}get percent(){const{total:t}=this;let e=0,i=0;for(let s=0;s<t;s++)s<=this.finishedIndex?(i+=this.list[s].time,s===this.finishedIndex&&(e=i)):e+=this.list[s].time;return this.isComplete?1:i/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&f.assign(this.config,t),this.empty()}add(t,e){let i,s,n,r;const a=new Hn(t);return a.parent=this,l(e)?r=e:e&&(s=e.parallel,i=e.start,n=e.time,r=e.delay),n&&(a.time=n),!1===s&&(a.parallel=!1),o(r)?this.push(a,i):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(a,i))},r)),this.isComplete=!1,a}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout(()=>this.start()))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[],this.delayNumber=0}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach(t=>{t.isComplete||t.cancel()}),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then(()=>{this.onTask(t),this.index++,this.nextTask()}).catch(t=>{this.onError(t)}):this.nextTask()}runParallelTasks(){this.parallelList.forEach(t=>this.runParallelTask(t))}runParallelTask(t){t.run().then(()=>{this.onTask(t),this.fillParallelTask()}).catch(t=>{this.onParallelError(t)})}nextTask(){this.total===this.finishedIndex?this.onComplete():this.timer=setTimeout(()=>this.run())}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.config.parallel;e>this.list.length&&(e=this.list.length);for(let i=this.index;i<e&&(t=this.list[i],t.parallel);i++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const i=e.length,s=this.finishedIndex+i;if(e.length){if(!this.running)return;s<this.total&&(t=this.list[s],t&&t.parallel&&(e.push(t),this.runParallelTask(t)))}else this.index+=this.parallelSuccessNumber,this.parallelSuccessNumber=0,this.nextTask()}onComplete(){this.stop(),this.config.onComplete&&this.config.onComplete()}onTask(t){t.complete(),this.config.onTask&&this.config.onTask()}onParallelError(t){this.parallelList.forEach(t=>{t.parallel=!1}),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.config.onError&&this.config.onError(t)}destroy(){this.stop()}}const Vn=Gt.get("Resource"),jn={tasker:new Xn,map:{},get isComplete(){return Un.tasker.isComplete},set(t,e){Un.map[t]&&Vn.repeat(t),Un.map[t]=e},get:t=>Un.map[t],remove(t){const e=Un.map[t];e&&(e.destroy&&e.destroy(),delete Un.map[t])},loadImage(t,e){return new Promise((i,s)=>{const n=this.setImage(t,t,e);n.load(()=>i(n),t=>s(t))})},setImage(t,e,i){let s;return a(e)?s={url:e}:e.url||(s={url:t,view:e}),s&&(i&&(s.format=i),e=ee.image(s)),Un.set(t,e),e},destroy(){Un.map={}}},Un=jn,Gn={maxRecycled:10,recycledList:[],patternTasker:new Xn,get(t){let e=jn.get(t.url);return e||jn.set(t.url,e=ee.image(t)),e.use++,e},recycle(t){t.use--,setTimeout(()=>{t.use||Kn.recycledList.push(t)})},clearRecycled(){const t=Kn.recycledList;t.length>Kn.maxRecycled&&(t.forEach(t=>!t.use&&t.url&&jn.remove(t.url)),t.length=0)},hasAlphaPixel:t=>zn.alphaPixelTypes.some(e=>Kn.isFormat(e,t)),isFormat(t,e){if(e.format)return e.format===t;const{url:i}=e;if(i.startsWith("data:")){if(i.startsWith("data:"+zn.mineType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+zn.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){Kn.recycledList=[]}},Kn=Gn,{IMAGE:qn,create:Zn}=e,{floor:Jn,max:$n}=Math;class Qn{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=Zn(qn),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}Gn.isFormat("svg",t)&&(this.isSVG=!0),Gn.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(e,i){if(!this.loading){this.loading=!0;let{loadImage:e,loadImageWithProgress:i}=t.origin,s=this.config.showProgress&&i&&this.onProgress.bind(this);s&&(e=i),jn.tasker.add(()=>de(this,void 0,void 0,function*(){return yield e(this.url,s).then(t=>this.setView(t)).catch(t=>{this.error=t,this.onComplete(!1)})}))}return this.waitComplete.push(e,i),this.waitComplete.length-2}unload(t,e){const i=this.waitComplete;if(e){const e=i[t+1];e&&e({type:"stop"})}i[t]=i[t+1]=void 0}setView(t){this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)}onProgress(t){this.progress=t}onComplete(t){let e;this.waitComplete.forEach((i,s)=>{e=s%2,i&&(t?e||i(this):e&&i(this.error))}),this.waitComplete.length=0,this.loading=!1}getFull(t){return this.view}getCanvas(e,i,s,n,o,r,a){if(e||(e=this.width),i||(i=this.height),this.cache){let{params:t,data:e}=this.cache;for(let i in t)if(t[i]!==arguments[i]){e=null;break}if(e)return e}const h=t.origin.createCanvas($n(Jn(e+(o||0)),1),$n(Jn(i+(r||0)),1)),l=h.getContext("2d");return s&&(l.globalAlpha=s),l.imageSmoothingEnabled=!1!==a,l.drawImage(this.view,0,0,e,i),this.cache=this.use>1?{data:h,params:arguments}:null,h}getPattern(e,i,s,n){const o=t.canvas.createPattern(e,i);try{s&&o.setTransform&&(o.setTransform(s),s=void 0)}catch(t){}return n&&f.stintSet(n,"transform",s),o}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}}function to(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function eo(t,e){return Object.getOwnPropertyDescriptor(t,e)}function io(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}function so(t,e){return(i,s)=>oo(i,s,t,e&&e(s))}function no(t){return t}function oo(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};to(t,e,Object.assign(n,s||{})),Mo(t,e,i)}function ro(t){return so(t)}function ao(t,e){return so(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function ho(t,e){return so(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function lo(t){return so(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),_o(this))}}))}function co(t,e){return so(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function uo(t,e){return so(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function go(t,e){return so(t,t=>({set(i){this.__setAttr(t,i,e)&&_o(this)}}))}function po(t){return so(t,t=>({set(e){this.__setAttr(t,e)&&(_o(this),this.__.__removeNaturalSize())}}))}function _o(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function fo(t){return so(t,t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),_o(this)}}))}const mo=go;function yo(t,e){return so(t,t=>({set(i){this.__setAttr(t,i)&&(vo(this),e&&(this.__.__useStroke=!0))}}))}function vo(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&_o(t)}const wo=yo;function xo(t){return so(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function bo(t){return so(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function ko(t){return so(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;f.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip),this.__layout.surfaceChange()}}}))}function Eo(t){return so(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Bo(this)}}))}function So(t){return so(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>To(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");To(this,t,e,i),this.mask&&Bo(this)}}))}function Bo(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function To(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||_o(t))}function Ro(t){return so(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))}function Co(t){return so(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}function Oo(t){return so(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}function Lo(t){return so(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===Gt.showBounds&&this.__layout.surfaceChange(),this.leafer&&this.leafer.updateCursor())}}))}function Po(t){return so(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}function Ao(t){return(e,i)=>{to(e,"__DataProcessor",{get:()=>t})}}function Do(t){return(e,i)=>{to(e,"__LayoutProcessor",{get:()=>t})}}function Mo(t,e,i){const s=t.__DataProcessor.prototype,n="_"+e,r=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=io(e,i);if(o(i))a.get=function(){return this[n]};else if("function"==typeof i)a.get=function(){const t=this[n];return null==t?i(this.__leaf):t};else if(g(i)){const t=_(i);a.get=function(){const e=this[n];return null==e?this[n]=t?{}:f.clone(i):e}}const h=t.isBranchLeaf;"width"===e?a.get=function(){const t=this[n];if(null==t){const t=this,e=t.__naturalWidth,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.width:e?t._height&&t.__useNaturalRatio?t._height*e/t.__naturalHeight:e:h&&s.children.length?s.boxBounds.width:i}return t}:"height"===e&&(a.get=function(){const t=this[n];if(null==t){const t=this,e=t.__naturalHeight,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.height:e?t._width&&t.__useNaturalRatio?t._width*e/t.__naturalWidth:e:h&&s.children.length?s.boxBounds.height:i}return t});let l,d=s;for(;!l&&d;)l=eo(d,e),d=d.__proto__;l&&l.set&&(a.set=l.set),s[r]&&(a.set=s[r],delete s[r]),to(s,e,a)}const Fo=new Gt("rewrite"),Io=[],Wo=["destroy","constructor"];function zo(t){return(e,i)=>{Io.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function No(){return t=>{Yo()}}function Yo(t){Io.length&&(Io.forEach(e=>{t&&Fo.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Io.length=0)}function Ho(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{if(!(Wo.includes(s)||e&&e.includes(s)))if(t.prototype){eo(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]})}}function Xo(){return t=>{se.register(t)}}function Vo(){return t=>{re.register(t)}}setTimeout(()=>Yo(!0));const{copy:jo,toInnerPoint:Uo,toOuterPoint:Go,scaleOfOuter:Ko,rotateOfOuter:qo,skewOfOuter:Zo,multiplyParent:Jo,divideParent:$o,getLayout:Qo}=G,tr={},{round:er}=Math,ir={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),or(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)nr(s[t],e,i)}},updateMatrix(t,e,i){const s=t.__layout;e?i&&(s.waitAutoLayout=!0,t.__hasAutoLayout&&(s.matrixChanged=!1)):s.waitAutoLayout&&(s.waitAutoLayout=!1),s.matrixChanged&&t.__updateLocalMatrix(),s.waitAutoLayout||t.__updateWorldMatrix()},updateBounds(t){const e=t.__layout;e.boundsChanged&&t.__updateLocalBounds(),e.waitAutoLayout||t.__updateWorldBounds()},updateAllWorldOpacity(t){if(t.__updateWorldOpacity(),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)rr(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&rr(t),t.__updateChange()},updateAllChange(t){if(hr(t),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)ar(e[t])}},worldHittable(t){for(;t;){if(!t.__.hittable)return!1;t=t.parent}return!0},draggable:t=>(t.draggable||t.editable)&&t.hitSelf&&!t.locked,copyCanvasByWorld(e,i,s,n,o,r){n||(n=e.__nowWorld),e.__worldFlipped||t.fullImageShadow?i.copyWorldByReset(s,n,e.__nowWorld,o,r):i.copyWorldToInner(s,n,e.__layout.renderBounds,o)},moveWorld(t,e,i=0,s,n){const o=g(e)?Object.assign({},e):{x:e,y:i};s?Go(t.localTransform,o,o,!0):t.parent&&Uo(t.parent.scrollWorldTransform,o,o,!0),sr.moveLocal(t,o.x,o.y,n)},moveLocal(t,e,i=0,s){g(e)&&(i=e.y,e=e.x),e+=t.x,i+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=er(e),i=er(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,o){sr.zoomOfLocal(t,lr(t,e),i,s,n,o)},zoomOfLocal(t,e,i,s=i,n,o){const r=t.__localMatrix;if(l(s)||(s&&(o=s),s=i),jo(tr,r),Ko(tr,e,i,s),sr.hasHighPosition(t))sr.setTransform(t,tr,n,o);else{const e=t.x+tr.e-r.e,a=t.y+tr.f-r.f;o&&!n?t.animate({x:e,y:a,scaleX:t.scaleX*i,scaleY:t.scaleY*s},o):(t.x=e,t.y=a,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){sr.rotateOfLocal(t,lr(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;jo(tr,n),qo(tr,e,i),sr.hasHighPosition(t)?sr.setTransform(t,tr,!1,s):t.set({x:t.x+tr.e-n.e,y:t.y+tr.f-n.f,rotation:P.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,o){sr.skewOfLocal(t,lr(t,e),i,s,n,o)},skewOfLocal(t,e,i,s=0,n,o){jo(tr,t.__localMatrix),Zo(tr,e,i,s),sr.setTransform(t,tr,n,o)},transformWorld(t,e,i,s){jo(tr,t.worldTransform),Jo(tr,e),t.parent&&$o(tr,t.parent.scrollWorldTransform),sr.setTransform(t,tr,i,s)},transform(t,e,i,s){jo(tr,t.localTransform),Jo(tr,e),sr.setTransform(t,tr,i,s)},setTransform(t,e,i,s){const n=t.__,o=n.origin&&sr.getInnerOrigin(t,n.origin),r=Qo(e,o,n.around&&sr.getInnerOrigin(t,n.around));if(sr.hasOffset(t)&&(r.x-=n.offsetX,r.y-=n.offsetY),i){const e=r.scaleX/t.scaleX,i=r.scaleY/t.scaleY;if(delete r.scaleX,delete r.scaleY,o){Wt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=sr.getInnerOrigin(t,n.origin);nt.move(r,o.x-s.x,o.y-s.y)}t.set(r),t.scaleResize(e,i,!1)}else t.set(r,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return Ko(i,sr.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>nt.tempToOuterOf(sr.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return yt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(jo(tr,t.worldTransform),$o(tr,e.scrollWorldTransform),i?tr:Object.assign({},tr)),drop(t,e,i,s){t.setTransform(sr.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||sr.hasOffset(t),hasOffset:t=>t.offsetX||t.offsetY,hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}},animateMove(e,i,s=.3){if(i.x||i.y)if(Math.abs(i.x)<1&&Math.abs(i.y)<1)e.move(i);else{const n=i.x*s,o=i.y*s;i.x-=n,i.y-=o,e.move(n,o),t.requestRender(()=>sr.animateMove(e,i,s))}}},sr=ir,{updateAllMatrix:nr,updateMatrix:or,updateAllWorldOpacity:rr,updateAllChange:ar,updateChange:hr}=sr;function lr(t,e){return t.updateLayout(),t.parent?nt.tempToInnerOf(e,t.parent.scrollWorldTransform):e}const dr={worldBounds:t=>t.__world,localBoxBounds:t=>t.__.eraser||0===t.__.visible?null:t.__local||t.__layout,localStrokeBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localStrokeBounds,localRenderBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localRenderBounds,maskLocalBoxBounds:(t,e)=>ur(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>ur(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>ur(t,e)&&t.__layout.localRenderBounds,excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))};let cr;function ur(t,e){return e||(cr=0),t.__.mask&&(cr=1),cr<0?null:(cr&&(cr=-1),!0)}const{updateBounds:gr}=ir,pr={sort:(t,e)=>t.__.zIndex===e.__.zIndex?t.__tempNumber-e.__tempNumber:t.__.zIndex-e.__.zIndex,pushAllChildBranch(t,e){if(t.__tempNumber=1,t.__.__childBranchNumber){const{children:i}=t;for(let s=0,n=i.length;s<n;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),_r(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&o(i[t.parent.innerId]);)e.add(t.parent),t=t.parent;else for(;t.parent;)e.add(t.parent),t=t.parent},pushAllBranchStack(t,e){let i=e.length;const{children:s}=t;for(let t=0,i=s.length;t<i;t++)s[t].isBranch&&e.push(s[t]);for(let t=i,s=e.length;t<s;t++)fr(e[t],e)},updateBounds(t,e){const i=[t];fr(t,i),mr(i,e)},updateBoundsByBranchStack(t,e){let i,s;for(let n=t.length-1;n>-1;n--){i=t[n],s=i.children;for(let t=0,e=s.length;t<e;t++)gr(s[t]);e&&e===i||gr(i)}}},{pushAllChildBranch:_r,pushAllBranchStack:fr,updateBoundsByBranchStack:mr}=pr,yr={run(t){if(t&&t.length){const e=t.length;for(let i=0;i<e;i++)t[i]();t.length===e?t.length=0:t.splice(0,e)}}},{getRelativeWorld:vr,updateBounds:wr}=ir,{toOuterOf:xr,getPoints:br,copy:kr}=Wt,Er="_localContentBounds",Sr="_worldContentBounds",Br="_worldBoxBounds",Tr="_worldStrokeBounds";class Rr{get contentBounds(){return this._contentBounds||this.boxBounds}set contentBounds(t){this._contentBounds=t}get strokeBounds(){return this._strokeBounds||this.boxBounds}get renderBounds(){return this._renderBounds||this.boxBounds}set renderBounds(t){this._renderBounds=t}get localContentBounds(){return xr(this.contentBounds,this.leaf.__localMatrix,this[Er]||(this[Er]={})),this[Er]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return xr(this.contentBounds,this.leaf.__world,this[Sr]||(this[Sr]={})),this[Sr]}get worldBoxBounds(){return xr(this.boxBounds,this.leaf.__world,this[Br]||(this[Br]={})),this[Br]}get worldStrokeBounds(){return xr(this.strokeBounds,this.leaf.__world,this[Tr]||(this[Tr]={})),this[Tr]}get a(){return 1}get b(){return 0}get c(){return 0}get d(){return 1}get e(){return this.leaf.__.x}get f(){return this.leaf.__.y}get x(){return this.e+this.boxBounds.x}get y(){return this.f+this.boxBounds.y}get width(){return this.boxBounds.width}get height(){return this.boxBounds.height}constructor(t){this.leaf=t,this.leaf.__local&&(this._localRenderBounds=this._localStrokeBounds=this.leaf.__local),t.__world&&(this.boxBounds={x:0,y:0,width:0,height:0},this.boxChange(),this.matrixChange())}createLocal(){const t=this.leaf.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0};this._localStrokeBounds||(this._localStrokeBounds=t),this._localRenderBounds||(this._localRenderBounds=t)}update(){const{leaf:e}=this,{leafer:i}=e;if(e.isApp)return wr(e);if(i)i.ready?i.watcher.changed&&i.layouter.layout():i.start();else{let i=e;for(;i.parent&&!i.parent.leafer;)i=i.parent;const s=i;if(s.__fullLayouting)return;s.__fullLayouting=!0,t.layout(s),delete s.__fullLayouting}}getTransform(t="world"){this.update();const{leaf:e}=this;switch(t){case"world":return e.__world;case"local":return e.__localMatrix;case"inner":return G.defaultMatrix;case"page":t=e.zoomLayer;default:return vr(e,t)}}getBounds(t,e="world"){switch(this.update(),e){case"world":return this.getWorldBounds(t);case"local":return this.getLocalBounds(t);case"inner":return this.getInnerBounds(t);case"page":e=this.leaf.zoomLayer;default:return new Ht(this.getInnerBounds(t)).toOuterOf(this.getTransform(e))}}getInnerBounds(t="box"){switch(t){case"render":return this.renderBounds;case"content":if(this.contentBounds)return this.contentBounds;case"box":return this.boxBounds;case"stroke":return this.strokeBounds}}getLocalBounds(t="box"){switch(t){case"render":return this.localRenderBounds;case"stroke":return this.localStrokeBounds;case"content":if(this.contentBounds)return this.localContentBounds;case"box":return this.leaf.__localBoxBounds}}getWorldBounds(t="box"){switch(t){case"render":return this.leaf.__world;case"stroke":return this.worldStrokeBounds;case"content":if(this.contentBounds)return this.worldContentBounds;case"box":return this.worldBoxBounds}}getLayoutBounds(t,e="world",i){const{leaf:s}=this;let n,o,r,a=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(a),o=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;r={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},n=s.getLocalPointByInner(a);break;case"inner":n=a,o=G.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),o=vr(s,e,!0)}if(r||(r=G.getLayout(o)),kr(r,a),nt.copy(r,n),i){const{scaleX:t,scaleY:e}=r,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(r.scaleX/=i,r.scaleY/=s,r.width*=i,r.height*=s)}return r}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=br(this.getInnerBounds(t));let n;switch(e){case"world":n=null;break;case"local":n=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:n=e}return o(n)||s.forEach(t=>i.innerToWorld(t,null,!1,n)),s}shrinkContent(){const{x:t,y:e,width:i,height:s}=this.boxBounds;this._contentBounds={x:t,y:e,width:i,height:s}}spreadStroke(){const{x:t,y:e,width:i,height:s}=this.strokeBounds;this._strokeBounds={x:t,y:e,width:i,height:s},this._localStrokeBounds={x:t,y:e,width:i,height:s},this.renderSpread||this.spreadRenderCancel()}spreadRender(){const{x:t,y:e,width:i,height:s}=this.renderBounds;this._renderBounds={x:t,y:e,width:i,height:s},this._localRenderBounds={x:t,y:e,width:i,height:s}}shrinkContentCancel(){this._contentBounds=void 0}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this._strokeBounds=this.boxBounds,this._localStrokeBounds=this.leaf.__localBoxBounds,t&&this.spreadRenderCancel()}spreadRenderCancel(){this._renderBounds=this._strokeBounds,this._localRenderBounds=this._localStrokeBounds}boxChange(){this.boxChanged=!0,this.localBoxChanged?this.boundsChanged||(this.boundsChanged=!0):this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChange(),this.leaf.__local||this.createLocal()}matrixChange(){this.matrixChanged=!0,this.localBoxChanged?this.boundsChanged||(this.boundsChanged=!0):this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=this.affectChildrenSort=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class Cr{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&t.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&t.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&t.event.stop(this.origin)}}class Or extends Cr{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}Or.ADD="child.add",Or.REMOVE="child.remove",Or.CREATED="created",Or.MOUNTED="mounted",Or.UNMOUNTED="unmounted",Or.DESTROY="destroy";const Lr="property.scroll";class Pr extends Cr{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Pr.CHANGE="property.change",Pr.LEAFER_CHANGE="property.leafer_change",Pr.SCROLL=Lr;const Ar={scrollX:Lr,scrollY:Lr};class Dr extends Cr{constructor(t,e){super(t),Object.assign(this,e)}}Dr.LOAD="image.load",Dr.LOADED="image.loaded",Dr.ERROR="image.error";class Mr extends Cr{static checkHas(t,e,i){"on"===i?e===zr?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Fr)||t.hasEvent(Ir)||t.hasEvent(Wr),t.__hasWorldEvent=t.hasEvent(zr))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Fr,t),"inner"===e&&t.emit(Ir,t)),t.emit(Wr,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(zr,this)}}Mr.RESIZE="bounds.resize",Mr.INNER="bounds.inner",Mr.LOCAL="bounds.local",Mr.WORLD="bounds.world";const{RESIZE:Fr,INNER:Ir,LOCAL:Wr,WORLD:zr}=Mr,Nr={};[Fr,Ir,Wr,zr].forEach(t=>Nr[t]=1);class Yr extends Cr{get bigger(){if(!this.old)return!0;const{width:t,height:e}=this.old;return this.width>=t&&this.height>=e}get smaller(){return!this.bigger}get samePixelRatio(){return!this.old||this.pixelRatio===this.old.pixelRatio}constructor(t,e){g(t)?(super(Yr.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!o(this.resizingKeys[t.innerId])}}Yr.RESIZE="resize";class Hr extends Cr{constructor(t,e){super(t),this.data=e}}Hr.REQUEST="watch.request",Hr.DATA="watch.data";class Xr extends Cr{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}Xr.REQUEST="layout.request",Xr.START="layout.start",Xr.BEFORE="layout.before",Xr.LAYOUT="layout",Xr.AFTER="layout.after",Xr.AGAIN="layout.again",Xr.END="layout.end";class Vr extends Cr{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Vr.REQUEST="render.request",Vr.CHILD_START="render.child_start",Vr.CHILD_END="render.child_end",Vr.START="render.start",Vr.BEFORE="render.before",Vr.RENDER="render",Vr.AFTER="render.after",Vr.AGAIN="render.again",Vr.END="render.end",Vr.NEXT="render.next";class jr extends Cr{}jr.START="leafer.start",jr.BEFORE_READY="leafer.before_ready",jr.READY="leafer.ready",jr.AFTER_READY="leafer.after_ready",jr.VIEW_READY="leafer.view_ready",jr.VIEW_COMPLETED="leafer.view_completed",jr.STOP="leafer.stop",jr.RESTART="leafer.restart",jr.END="leafer.end",jr.UPDATE_MODE="leafer.update_mode",jr.TRANSFORM="leafer.transform",jr.MOVE="leafer.move",jr.SCALE="leafer.scale",jr.ROTATE="leafer.rotate",jr.SKEW="leafer.skew";const{MOVE:Ur,SCALE:Gr,ROTATE:Kr,SKEW:qr}=jr,Zr={x:Ur,y:Ur,scaleX:Gr,scaleY:Gr,rotation:Kr,skewX:qr,skewY:qr},Jr={};class $r{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(u(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)u(e=t[i])?this.on(i,e[0],e[1]):this.on(i,e);return}let s,n,o;i&&("once"===i?n=!0:"boolean"==typeof i?s=i:(s=i.capture,n=i.once));const r=Qr(this,s,!0),h=a(t)?t.split(" "):t,l=n?{listener:e,once:n}:{listener:e};h.forEach(t=>{t&&(o=r[t],o?-1===o.findIndex(t=>t.listener===e)&&o.push(l):r[t]=[l],Nr[t]&&Mr.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=a(t)?t.split(" "):t;if(e){let t,n,o;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const r=Qr(this,t);s.forEach(t=>{t&&(n=r[t],n&&(o=n.findIndex(t=>t.listener===e),o>-1&&n.splice(o,1),n.length||delete r[t],Nr[t]&&Mr.checkHas(this,t,"off")))})}else{const{__bubbleMap:t,__captureMap:e}=this;s.forEach(i=>{t&&delete t[i],e&&delete e[i]})}}else this.__bubbleMap=this.__captureMap=void 0}on_(t,e,i,s){return e?this.on(t,i?e=e.bind(i):e,s):u(t)&&t.forEach(t=>this.on(t[0],t[2]?t[1]=t[1].bind(t[2]):t[1],t[3])),{type:t,current:this,listener:e,options:s}}off_(t){if(!t)return;const e=u(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):u(t.type)&&t.type.forEach(e=>t.current.off(e[0],e[1],e[3])))}),e.length=0}once(t,e,i,s){if(!e)return u(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));g(i)?e=e.bind(i):s=i,this.on(t,e,{once:!0,capture:s})}emit(t,e,i){!e&&re.has(t)&&(e=re.get(t,{type:t,target:this,current:this}));const s=Qr(this,i)[t];if(s){let n;for(let o=0,r=s.length;o<r&&!((n=s[o])&&(n.listener(e),n.once&&(this.off(t,n.listener,i),o--,r--),e&&e.isStopNow));o++);}this.syncEventer&&this.syncEventer.emitEvent(e,i)}emitEvent(t,e){t.current=this,this.emit(t.type,t,e)}hasEvent(t,e){if(this.syncEventer&&this.syncEventer.hasEvent(t,e))return!0;const{__bubbleMap:i,__captureMap:s}=this,n=i&&i[t],r=s&&s[t];return!!(o(e)?n||r:e?r:n)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function Qr(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:Jr)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:Jr)}}const{on:ta,on_:ea,off:ia,off_:sa,once:na,emit:oa,emitEvent:ra,hasEvent:aa,destroy:ha}=$r.prototype,la={on:ta,on_:ea,off:ia,off_:sa,once:na,emit:oa,emitEvent:ra,hasEvent:aa,destroyEventer:ha},da=Gt.get("setAttr"),ca={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(!i||h(e)||o(e)||(da.warn(this.innerName,t,e),e=void 0),g(e)||s!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Pr(Pr.LEAFER_CHANGE,this,t,s,e));const i=Zr[t];i&&(this.emitEvent(new jr(i,this)),this.emitEvent(new jr(jr.TRANSFORM,this)))}this.emitPropertyEvent(Pr.CHANGE,t,s,e);const i=Ar[t];return i&&this.emitPropertyEvent(i,t,s,e),!0}return!1}return this.__realSetAttr(t,e),!0},emitPropertyEvent(t,e,i,s){const n=new Pr(t,this,e,i,s);this.isLeafer||this.hasEvent(t)&&this.emitEvent(n),this.leafer.emitEvent(n)},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||o(i.normalStyle[t])||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:ua,multiplyParent:ga,translateInner:pa,defaultWorld:_a}=G,{toPoint:fa,tempPoint:ma}=yt,ya={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:n}=this;ga(this.__local||e,t?t.__scrollWorld||t.__world:_a,i,!!e.affectScaleOrRotation,n),s&&pa(Object.assign(s,i),n.scrollX,n.scrollY)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged&&(t.resized||(t.resized="scale"))||t.rotationChanged)&&(ua(e,i,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=void 0),e.e=i.x+i.offsetX,e.f=i.y+i.offsetY,(i.around||i.origin)&&(fa(i.around||i.origin,t.boxBounds,ma),pa(e,-ma.x,-ma.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:va,updateAllMatrix:wa}=ir,{updateBounds:xa}=pr,{toOuterOf:ba,copyAndSpread:ka,copy:Ea}=Wt,{toBounds:Sa}=Tn,Ba={__updateWorldBounds(){const t=this.__layout;ba(t.renderBounds,this.__world,this.__world),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Mr.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Mr.emitWorld(this)},__updateLocalBounds(){const t=this.__layout;t.boxChanged&&(this.__.__pathInputed||this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),t.resized="inner"),t.localBoxChanged&&(this.__local&&this.__updateLocalBoxBounds(),t.localBoxChanged=void 0,t.strokeSpread&&(t.strokeChanged=!0),t.renderSpread&&(t.renderChanged=!0),this.parent&&this.parent.__layout.boxChange()),t.boxChanged=void 0,t.strokeChanged&&(t.strokeSpread=this.__updateStrokeSpread(),t.strokeSpread?(t.strokeBounds===t.boxBounds&&t.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):t.spreadStrokeCancel(),t.strokeChanged=void 0,(t.renderSpread||t.strokeSpread!==t.strokeBoxSpread)&&(t.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),t.resized="inner"),t.renderChanged&&(t.renderSpread=this.__updateRenderSpread(),t.renderSpread?(t.renderBounds!==t.boxBounds&&t.renderBounds!==t.strokeBounds||t.spreadRender(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):t.spreadRenderCancel(),t.renderChanged=void 0,this.parent&&this.parent.__layout.renderChange()),t.resized||(t.resized="local"),t.boundsChanged=void 0},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),ba(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){ba(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){ba(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?Sa(s.path,i):(i.x=0,i.y=0,i.width=s.width,i.height=s.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.__extraUpdate(),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),wa(this),xa(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(wa(this),xa(this,this))):va(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;ka(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;l(i)&&i<=0?Ea(e.renderBounds,e.strokeBounds):ka(e.renderBounds,e.boxBounds,i)}},Ta={__render(t,e){if(e.shape)return this.__renderShape(t,e);if(this.__worldOpacity){const i=this.__;if(i.bright&&!e.topRendering)return e.topList.add(this);if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=e.dimOpacity&&!i.dimskip?i.opacity*e.dimOpacity:i.opacity,this.__.__single){if("path"===i.eraser)return this.__renderEraser(t,e);const s=t.getSameCanvas(!0,!0);this.__draw(s,e,t),ir.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);Gt.showBounds&&Gt.drawBounds(this,t,e)}},__renderShape(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawShape(t,e))},__clip(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawRenderPath(t),t.clipUI(this))},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{excludeRenderBounds:Ra}=dr,Ca={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__nowWorld=this.__getNowWorld(e),this.__worldOpacity){const i=this.__;if(i.__useDim)if(i.dim)e.dimOpacity=!0===i.dim?.2:i.dim;else{if(i.bright&&!e.topRendering)return e.topList.add(this);i.dimskip&&e.dimOpacity&&(e.dimOpacity=0)}if(i.__single&&!this.isBranchLeaf){if("path"===i.eraser)return this.__renderEraser(t,e);const s=t.getSameCanvas(!1,!0);this.__renderBranch(s,e);const n=this.__nowWorld;t.opacity=e.dimOpacity?i.opacity*e.dimOpacity:i.opacity,t.copyWorldByReset(s,n,n,i.__blendMode,!0),s.recycle(n)}else this.__renderBranch(t,e)}},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{const{children:i}=this;for(let s=0,n=i.length;s<n;s++)Ra(i[s],e)||i[s].__render(t,e)}},__clip(t,e){if(this.__worldOpacity){const{children:i}=this;for(let s=0,n=i.length;s<n;s++)Ra(i[s],e)||i[s].__clip(t,e)}}},Oa={},{LEAF:La,create:Pa}=e,{stintSet:Aa}=f,{toInnerPoint:Da,toOuterPoint:Ma,multiplyParent:Fa}=G,{toOuterOf:Ia}=Wt,{copy:Wa,move:za}=nt,{moveLocal:Na,zoomOfLocal:Ya,rotateOfLocal:Ha,skewOfLocal:Xa,moveWorld:Va,zoomOfWorld:ja,rotateOfWorld:Ua,skewOfWorld:Ga,transform:Ka,transformWorld:qa,setTransform:Za,getFlipTransform:Ja,getLocalOrigin:$a,getRelativeWorld:Qa,drop:th}=ir;let eh=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return y}get __LayoutProcessor(){return Rr}get leaferIsCreated(){return this.leafer&&this.leafer.created}get leaferIsReady(){return this.leafer&&this.leafer.ready}get isLeafer(){return!1}get isBranch(){return!1}get isBranchLeaf(){return!1}get __localMatrix(){return this.__local||this.__layout}get __localBoxBounds(){return this.__local||this.__layout}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get scrollWorldTransform(){return this.updateLayout(),this.__scrollWorld||this.__world}get boxBounds(){return this.getBounds("box","inner")}get renderBounds(){return this.getBounds("render","inner")}get worldBoxBounds(){return this.getBounds("box")}get worldStrokeBounds(){return this.getBounds("stroke")}get worldRenderBounds(){return this.getBounds("render")}get worldOpacity(){return this.updateLayout(),this.__worldOpacity}get __worldFlipped(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}get __inLazyBounds(){return this.leaferIsCreated&&this.leafer.lazyBounds.hit(this.__world)}get pathInputed(){return this.__.__pathInputed}set event(t){this.on(t)}constructor(t){this.innerId=Pa(La),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(Or.CREATED)}reset(t){this.leafer&&this.leafer.forceRender(this.__world),0!==t&&(this.__world={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0,scaleX:1,scaleY:1},null!==t&&(this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0})),this.__worldOpacity=1,this.__=new this.__DataProcessor(this),this.__layout=new this.__LayoutProcessor(this),this.__level&&this.resetCustom(),t&&(t.__&&(t=t.toJSON()),t.children?this.set(t):Object.assign(this,t))}resetCustom(){this.__hasMask=this.__hasEraser=null,this.forceUpdate()}waitParent(t,e){e&&(t=t.bind(e)),this.parent?t():this.on(Or.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(Or.MOUNTED,t,"once")}nextRender(t,e,i){this.leafer?this.leafer.nextRender(t,e,i):this.waitLeafer(()=>this.leafer.nextRender(t,e,i))}removeNextRender(t){this.nextRender(t,null,"off")}__bindLeafer(t){if(this.isLeafer&&null!==t&&(t=this),this.leafer&&!t&&this.leafer.leafs--,this.leafer=t,t?(t.leafs++,this.__level=this.parent?this.parent.__level+1:1,this.animation&&this.__runAnimation("in"),this.__bubbleMap&&this.__emitLifeEvent(Or.MOUNTED)):this.__emitLifeEvent(Or.UNMOUNTED),this.isBranch){const{children:e}=this;for(let i=0,s=e.length;i<s;i++)e[i].__bindLeafer(t)}}set(t,e){}get(t){}setAttr(t,e){this[t]=e}getAttr(t){return this[t]}getComputedAttr(t){return this.__[t]}toJSON(t){return t&&this.__layout.update(),this.__.__getInputData(null,t)}toString(t){return JSON.stringify(this.toJSON(t))}toSVG(){}__SVG(t){}toHTML(){}__setAttr(t,e){return!0}__getAttr(t){}setProxyAttr(t,e){}getProxyAttr(t){}find(t,e){}findTag(t){}findOne(t,e){}findId(t){}focus(t){}updateState(){}updateLayout(){this.__layout.update()}forceUpdate(t){o(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=o(e)?null:void 0,this[t]=e}forceRender(t,e){this.forceUpdate("surface")}__extraUpdate(){this.leaferIsReady&&this.leafer.layouter.addExtra(this)}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(t,e){}__updateContentBounds(){}__updateStrokeBounds(t){}__updateRenderBounds(t){}__updateAutoLayout(){}__updateFlowLayout(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){this.__hasEraser=!!t||this.children.some(t=>t.__.eraser)}__renderEraser(t,e){t.save(),this.__clip(t,e);const{renderBounds:i}=this.__layout;t.clearRect(i.x,i.y,i.width,i.height),t.restore()}__updateMask(t){this.__hasMask=this.children.some(t=>t.__.mask&&t.__.visible&&t.__.opacity)}__renderMask(t,e){}__getNowWorld(t){if(t.matrix){this.__cameraWorld||(this.__cameraWorld={});const e=this.__cameraWorld,i=this.__world;return Fa(i,t.matrix,e,void 0,i),Ia(this.__layout.renderBounds,e,e),Aa(e,"half",i.half),Aa(e,"ignorePixelSnap",i.ignorePixelSnap),e}return this.__world}getClampRenderScale(){let{scaleX:t}=this.__nowWorld||this.__world;return t<0&&(t=-t),t>1?t:1}getRenderScaleData(t,e){let{scaleX:i,scaleY:s}=Gn.patternLocked?this.__world:this.__nowWorld;return t&&(i<0&&(i=-i),s<0&&(s=-s)),(!0===e||"zoom-in"===e&&i>1&&s>1)&&(i=s=1),Oa.scaleX=i,Oa.scaleY=s,Oa}getTransform(t){return this.__layout.getTransform(t||"local")}getBounds(t,e){return this.__layout.getBounds(t,e)}getLayoutBounds(t,e,i){return this.__layout.getLayoutBounds(t,e,i)}getLayoutPoints(t,e){return this.__layout.getLayoutPoints(t,e)}getWorldBounds(t,e,i){const s=e?Qa(this,e):this.worldTransform,n=i?t:{};return Ia(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&Wa(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&Wa(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Da(this.scrollWorldTransform,t,e,i)}innerToWorld(t,e,i,s){Ma(this.scrollWorldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getBoxPoint(t,e,i,s){return this.getBoxPointByInner(this.getInnerPoint(t,e,i,s),null,null,!0)}getBoxPointByInner(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return za(n,-o,-r),n}getInnerPoint(t,e,i,s){const n=s?t:{};return this.worldToInner(t,n,i,e),n}getInnerPointByBox(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return za(n,o,r),n}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const n=s?t:{};return this.worldToLocal(t,n,i,e),n}getLocalPointByInner(t,e,i,s){return this.getWorldPoint(t,this.parent,i,s)}getPagePoint(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,i,s)}getWorldPoint(t,e,i,s){const n=s?t:{};return this.innerToWorld(t,n,i,e),n}getWorldPointByBox(t,e,i,s){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,s),e,i,!0)}getWorldPointByLocal(t,e,i,s){const n=s?t:{};return this.localToWorld(t,n,i,e),n}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e,i){Za(this,t,e,i)}transform(t,e,i){Ka(this,t,e,i)}move(t,e,i){Na(this,t,e,i)}moveInner(t,e,i){Va(this,t,e,!0,i)}scaleOf(t,e,i,s,n){Ya(this,$a(this,t),e,i,s,n)}rotateOf(t,e,i){Ha(this,$a(this,t),e,i)}skewOf(t,e,i,s,n){Xa(this,$a(this,t),e,i,s,n)}transformWorld(t,e,i){qa(this,t,e,i)}moveWorld(t,e,i){Va(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){ja(this,t,e,i,s,n)}rotateOfWorld(t,e){Ua(this,t,e)}skewOfWorld(t,e,i,s,n){Ga(this,t,e,i,s,n)}flip(t,e){Ka(this,Ja(this,t),!1,e)}scaleResize(t,e=t,i){this.scaleX*=t,this.scaleY*=e}__scaleResize(t,e){}resizeWidth(t){}resizeHeight(t){}hit(t,e){return!0}__hitWorld(t){return!0}__hit(t){return!0}__hitFill(t){return!0}__hitStroke(t,e){return!0}__hitPixel(t){return!0}__drawHitPath(t){}__updateHitCanvas(){}__render(t,e){}__drawFast(t,e){}__draw(t,e,i){}__clip(t,e){}__renderShape(t,e){}__drawShape(t,e){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return te.need("path")}getMotionPoint(t){return te.need("path")}getMotionTotal(){return 0}__updateMotionPath(){}__runAnimation(t,e){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}dropTo(t,e,i){th(this,t,e,i)}on(t,e,i){}off(t,e,i){}on_(t,e,i,s){}off_(t){}once(t,e,i,s){}emit(t,e,i){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,i){i?this.addAttr(t,e,i):Mo(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=go),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new Or(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(Or.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}};eh=le([Ho(ca),Ho(ya),Ho(Ba),Ho(la),Ho(Ta)],eh);const{setListWithFn:ih}=Wt,{sort:sh}=pr,{localBoxBounds:nh,localStrokeBounds:oh,localRenderBounds:rh,maskLocalBoxBounds:ah,maskLocalStrokeBounds:hh,maskLocalRenderBounds:lh}=dr,dh=new Gt("Branch");let ch=class extends eh{__updateStrokeSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(t,e){ih(e||this.__layout.boxBounds,this.children,this.__hasMask?ah:nh)}__updateStrokeBounds(t){ih(t||this.__layout.strokeBounds,this.children,this.__hasMask?hh:oh)}__updateRenderBounds(t){ih(t||this.__layout.renderBounds,this.children,this.__hasMask?lh:rh)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let i=0,s=e.length;i<s;i++)e[i].__tempNumber=i,e[i].__.zIndex&&(t=!0);e.sort(sh),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return dh.warn("add self or destroyed");const i=o(e);if(!t.__){if(u(t))return t.forEach(t=>{this.add(t,e),i||e++});t=se.get(t.tag,t)}t.parent&&t.parent.remove(t),t.parent=this,i?this.children.push(t):this.children.splice(e,0,t),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1);const s=t.__layout;s.boxChanged||s.boxChange(),s.matrixChanged||s.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(Or.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Or.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}addMany(...t){this.add(t)}remove(t,e){t?t.__?t.animationOut?t.__runAnimation("out",()=>this.__remove(t,e)):this.__remove(t,e):this.find(t).forEach(t=>this.remove(t,e)):o(t)&&super.remove(null,e)}removeAll(t){const{children:e}=this;e.length&&(this.children=[],this.__preRemove(),this.__.__childBranchNumber=0,e.forEach(e=>{this.__realRemoveChild(e),t&&e.destroy()}))}clear(){this.removeAll(!0)}__remove(t,e){const i=this.children.indexOf(t);i>-1&&(this.children.splice(i,1),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),this.__preRemove(),this.__realRemoveChild(t),e&&t.destroy())}__preRemove(){this.__hasMask&&this.__updateMask(),this.__hasEraser&&this.__updateEraser(),this.__layout.boxChange(),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}__realRemoveChild(t){t.__emitLifeEvent(Or.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Or.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new Or(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}};ch=le([Ho(Ca)],ch);class uh{get length(){return this.list.length}constructor(t){this.reset(),t&&(u(t)?this.addList(t):this.add(t))}has(t){return t&&!o(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return o(e)?-1:e}add(t){const{list:e,keys:i}=this;o(i[t.innerId])&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(o(i[t.innerId])){const{list:s}=this;for(let t=e,n=s.length;t<n;t++)i[s[t].innerId]++;0===e?s.unshift(t):(e>s.length&&(e=s.length),s.splice(e,0,t)),i[t.innerId]=e}}addList(t){for(let e=0;e<t.length;e++)this.add(t[e])}remove(t){const{list:e}=this;let i;for(let s=0,n=e.length;s<n;s++)o(i)?e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]):this.keys[e[s].innerId]=s-1;o(i)||e.splice(i,1)}sort(t){const{list:e}=this;t?e.sort((t,e)=>e.__level-t.__level):e.sort((t,e)=>t.__level-e.__level)}forEach(t){this.list.forEach(t)}clone(){const t=new uh;return t.list=[...this.list],t.keys=Object.assign({},this.keys),t}update(){this.keys={};const{list:t,keys:e}=this;for(let i=0,s=t.length;i<s;i++)e[t[i].innerId]=i}reset(){this.list=[],this.keys={}}destroy(){this.reset()}}class gh{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(u(t)?this.addList(t):this.add(t))}has(t){return!o(this.keys[t.innerId])}without(t){return o(this.keys[t.innerId])}sort(t){const{levels:e}=this;t?e.sort((t,e)=>e-t):e.sort((t,e)=>t-e)}addList(t){t.forEach(t=>{this.add(t)})}add(t){const{keys:e,levelMap:i}=this;e[t.innerId]||(e[t.innerId]=1,i[t.__level]?i[t.__level].push(t):(i[t.__level]=[t],this.levels.push(t.__level)),this._length++)}forEach(t){let e;this.levels.forEach(i=>{e=this.levelMap[i];for(let i=0,s=e.length;i<s;i++)t(e[i])})}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}}const ph="1.9.9";class _h extends Ee{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}Wn(OffscreenCanvasRenderingContext2D.prototype),Wn(Path2D.prototype);const{mineType:fh}=zn;function mh(e,i){t.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:fh(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:fh(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:e=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",t.image.getRealURL(e),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},t.canvas=ee.canvas(),t.conicGradientSupport=!!t.canvas.context.createConicGradient}Object.assign(ee,{canvas:(t,e)=>new _h(t,e),image:t=>new Qn(t)}),t.name="web",t.isWorker=!0,t.backgrounder=!0,t.requestRender=function(t){requestAnimationFrame(t)},to(t,"devicePixelRatio",{get:()=>1});const{userAgent:yh}=navigator;yh.indexOf("Firefox")>-1?(t.conicGradientRotate90=!0,t.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.fullImageShadow=!0),yh.indexOf("Windows")>-1?(t.os="Windows",t.intWheelDeltaY=!0):yh.indexOf("Mac")>-1?t.os="Mac":yh.indexOf("Linux")>-1&&(t.os="Linux");class vh{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new uh;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new uh,this.target=t,e&&(this.config=f.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(Vr.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===Or.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new Hr(Hr.DATA,{updatedList:this.updatedList})),this.__updatedList=new uh,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Pr.CHANGE,this.__onAttrChange,this],[[Or.ADD,Or.REMOVE],this.__onChildEvent,this],[Hr.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:wh,updateBounds:xh,updateChange:bh}=ir,{pushAllChildBranch:kh,pushAllParent:Eh}=pr;const{worldBounds:Sh}=dr;class Bh{constructor(t){this.updatedBounds=new Ht,this.beforeBounds=new Ht,this.afterBounds=new Ht,u(t)&&(t=new uh(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Sh)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Sh),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:Th,updateAllChange:Rh}=ir,Ch=Gt.get("Layouter");class Oh{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new gh,this.target=t,e&&(this.config=f.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(Xr.START),this.layoutOnce(),t.emitEvent(new Xr(Xr.END,this.layoutedBlocks,this.times))}catch(t){Ch.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Ch.warn("layouting"):this.times>3?Ch.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Hr.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=Jt.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=Xr,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new Xr(n,a,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(wh(t,!0),e.add(t),t.isBranch&&kh(t,e),Eh(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Eh(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||xh(s[t])}xh(i)}})}(this.__levelList),function(t){t.list.forEach(bh)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new Xr(o,a,this.times)),i.emitEvent(new Xr(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,Jt.end(e)}fullLayout(){const t=Jt.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=Xr,o=this.getBlocks(new uh(e));e.emitEvent(new Xr(i,o,this.times)),Oh.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new Xr(s,o,this.times)),e.emitEvent(new Xr(n,o,this.times)),this.addBlocks(o),Jt.end(t)}static fullLayout(t){Th(t,!0),t.isBranch?pr.updateBounds(t):ir.updateBounds(t),Rh(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Bh([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Bh(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[Xr.REQUEST,this.layout,this],[Xr.AGAIN,this.layoutAgain,this],[Hr.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Lh=Gt.get("Renderer");class Ph{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=f.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(Xr.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(Vr.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(Vr.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(Vr.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new Ht,Lh.log(e.innerName,"---\x3e");try{this.emitRender(Vr.START),this.renderOnce(t),this.emitRender(Vr.END,this.totalBounds),Gn.clearRecycled()}catch(t){this.rendering=!1,Lh.error(t)}Lh.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Lh.warn("rendering");if(this.times>3)return Lh.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new Ht,this.renderOptions={},t)this.emitRender(Vr.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Vr.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Vr.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Vr.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=Jt.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new Ht(s);i.save(),s.spread(Ph.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),Jt.end(e)}fullRender(){const t=Jt.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),Jt.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),Gt.showRepaint&&Gt.drawRepaint(s,e),t.render(this.target,s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new Ht;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&e>s)return t.requestRender(i);const{frames:n}=this;n.length>30&&n.shift(),n.push(e),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};t.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new Ht(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new Ht(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Lh.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new Vr(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[Vr.REQUEST,this.update,this],[Xr.END,this.__onLayoutEnd,this],[Vr.AGAIN,this.renderAgain,this],[Yr.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Ph.clipSpread=10;const{hitRadiusPoint:Ah}=Wt;class Dh{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new uh(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new uh;if(t.length){let e;const{x:n,y:o}=this.point,r={x:n,y:o,radiusX:0,radiusY:0};for(let n=0,o=t.length;n<o;n++)if(e=t[n],(i||ir.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&ir.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return i?t[0]:t.find(t=>ir.worldHittable(t))}getPath(t){const e=new uh;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new uh;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new uh,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||Ah(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Mh{constructor(t,e){this.config={},e&&(this.config=f.default(e,this.config)),this.picker=new Dh(this.target=t,this),this.finder=ee.finder&&ee.finder()}getByPoint(e,i,s){const{target:n,picker:o}=this;return t.backgrounder&&n&&n.updateLayout(),o.getByPoint(e,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):te.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Fh(t){return so(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Ih(t){return so(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}function Wh(){return(t,e)=>{const i="_"+e;to(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}function zh(t){return(e,i)=>{to(e,i,io(i,t))}}Object.assign(ee,{watcher:(t,e)=>new vh(t,e),layouter:(t,e)=>new Oh(t,e),renderer:(t,e,i)=>new Ph(t,e,i),selector:(t,e)=>new Mh(t,e)}),t.layout=Oh.fullLayout,t.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new uh,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const Nh={},Yh={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},Hh={number:(t,e)=>g(t)?"percent"===t.type?t.value*e:t.value:t},Xh={},Vh={},jh={},Uh={},Gh={},Kh={apply(){te.need("filter")}},qh={},Zh={setStyleName:()=>te.need("state"),set:()=>te.need("state")},Jh={list:{},register(t,e){Jh.list[t]=e},get:t=>Jh.list[t]},{parse:$h,objectToCanvasData:Qh}=Gi,{stintSet:tl}=f,{hasTransparent:el}=Yh,il={},sl=Gt.get("UIData");class nl extends y{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){return this.__getRealStrokeWidth()}get __maxStrokeWidth(){const t=this;return t.__hasMultiStrokeStyle?Math.max(t.__hasMultiStrokeStyle,t.strokeWidth):t.strokeWidth}get __hasMultiPaint(){const t=this;return t.fill&&this.__useStroke||t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,sl.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,sl.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),a(t)||!t?(tl(this,"__isTransparentFill",el(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):g(t)&&this.__setPaint("fill",t)}setStroke(t){a(t)||!t?(tl(this,"__isTransparentStroke",el(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):g(t)&&this.__setPaint("stroke",t)}setPath(t){const e=a(t);e||t&&g(t[0])?(this.__setInput("path",t),this._path=e?$h(t):Qh(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){ol(this,"shadow",t)}setInnerShadow(t){ol(this,"innerShadow",t)}setFilter(t){ol(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&Vh.compute("fill",this.__leaf),e&&Vh.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeWidthFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),o(t.strokeWidthFixed)||(i=t.strokeWidthFixed)),i){const t=this.__leaf.getClampRenderScale();return t>1?e/t:e}return e}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),u(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=il)):(this.__isStrokes=!0,this._stroke||(this._stroke=il))}__removePaint(t,e){e&&this.__removeInput(t),jh.recycleImage(t,this),"fill"===t?(tl(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(tl(this,"__isAlphaPixelStroke",void 0),tl(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function ol(t,e,i){t.__setInput(e,i),u(i)?(i.some(t=>!1===t.visible)&&(i=i.filter(t=>!1!==t.visible)),i.length||(i=void 0)):i=i&&!1!==i.visible?[i]:void 0,t["_"+e]=i}class rl extends nl{}class al extends rl{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return this.__single||this.__clipAfterFill}get __clipAfterFill(){const t=this;return"show"!==t.overflow&&t.__leaf.children.length&&(t.__leaf.isOverflow||super.__clipAfterFill)}}class hl extends rl{__getInputData(t,e){const i=super.__getInputData(t,e);return ke.forEach(t=>delete i[t]),i}}class ll extends al{}class dl extends nl{get __usePathBox(){return this.points||this.__pathInputed}}class cl extends nl{get __boxStroke(){return!this.__pathInputed}}class ul extends nl{get __boxStroke(){return!this.__pathInputed}}class gl extends dl{}class pl extends nl{}class _l extends nl{get __pathInputed(){return 2}}class fl extends rl{}const ml={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class yl extends nl{get __useNaturalRatio(){return!1}setFontWeight(t){a(t)?(this.__setInput("fontWeight",t),t=ml[t]||400):this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=se.get("Rect",0);const n=e.__layout,o=i.__layout;s||(i.parent=e,i.__world=e.__world,o.boxBounds=n.boxBounds),i.set(t),o.strokeChanged&&n.strokeChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}}class vl extends cl{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class wl extends cl{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const{max:xl,add:bl}=E,kl={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:n}=i,o=this.__box;if((i.stroke||"all"===i.hitStroke)&&n&&"inside"!==s&&(e=t="center"===s?n/2:n,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:n;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*n),o&&(t=xl(t,o.__layout.strokeSpread=o.__updateStrokeSpread()),e=Math.max(e,o.__layout.strokeBoxSpread)),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n,filter:o,renderSpread:r}=this.__,{strokeSpread:a}=this.__layout,h=this.__box;e&&(t=Gh.getShadowRenderSpread(this,e)),s&&(t=xl(t,s)),o&&(t=bl(t,Kh.getSpread(o))),r&&(t=bl(t,r)),a&&(t=bl(t,a));let l=t;return i&&(l=xl(l,Gh.getInnerShadowSpread(this,i))),n&&(l=xl(l,n)),this.__layout.renderShapeSpread=l,h?xl(h.__updateRenderSpread(),t):t}},{float:El}=P,Sl=new Ht,Bl=new Ht,Tl=new Ht,Rl={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&Cl.getValidMove(t.__localBoxBounds,Cl.getDragBounds(t),s,e,!0),Cl.axisMove(t,e)},limitScaleOf(t,e,i){const{dragBounds:s,dragBoundsType:n}=t;s&&Cl.getValidScaleOf(t.__localBoxBounds,Cl.getDragBounds(t),n,t.getLocalPointByInner(t.getInnerPointByBox(e)),i,!0)},axisMove(t,e){const{draggable:i}=t;"x"===i&&(e.y=0),"y"===i&&(e.x=0)},getDragBounds(t){const{dragBounds:e}=t;return"parent"===e?t.parent.boxBounds:e},isInnerMode:(t,e,i,s)=>"inner"===i||"auto"===i&&t[s]>e[s],getValidMove(t,e,i,s,n){const o=t.x+s.x,r=t.y+s.y,a=o+t.width,h=r+t.height,l=e.x+e.width,d=e.y+e.height;return n||(s=Object.assign({},s)),Cl.isInnerMode(t,e,i,"width")?o>e.x?s.x+=e.x-o:a<l&&(s.x+=l-a):o<e.x?s.x+=e.x-o:a>l&&(s.x+=l-a),Cl.isInnerMode(t,e,i,"height")?r>e.y?s.y+=e.y-r:h<d&&(s.y+=d-h):r<e.y?s.y+=e.y-r:h>d&&(s.y+=d-h),s.x=El(s.x),s.y=El(s.y),s},getValidScaleOf(t,e,i,s,n,o){let r,a;return o||(n=Object.assign({},n)),Sl.set(t).scaleOf(s,n.x,n.y).unsign(),Bl.set(Sl).add(e),Tl.set(Sl).intersect(e),r=Cl.isInnerMode(t,e,i,"width")?Bl.width/Sl.width:Tl.width/Sl.width,a=Cl.isInnerMode(t,e,i,"height")?Bl.height/Sl.height:Tl.height/Sl.height,n.x=El(Tl.width)?n.x*r:1,n.y=El(Tl.height)?n.y*a:1,n}},Cl=Rl,{stintSet:Ol}=f,Ll={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);Ol(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),Ol(t,"__fillAfterStroke",e&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill)}if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,n=t.innerShadow||t.blur||t.backgroundBlur||t.filter;Ol(t,"__isFastShadow",e&&!n&&e.length<2&&!e[0].spread&&!Gh.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(u(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!n)}t.__checkSingle(),Ol(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){Pl(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:n,stroke:o,__drawAfterFill:r,__fillAfterStroke:a,__isFastShadow:h}=s;if(this.__drawRenderPath(t),s.__useEffect&&!h){const h=Vh.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&Gh.shadow(this,t,h),a&&(s.__isStrokes?Vh.strokes(o,this,t):Vh.stroke(o,this,t)),n&&(s.__isFills?Vh.fills(n,this,t):Vh.fill(n,this,t)),r&&this.__drawAfterFill(t,e),d&&Gh.innerShadow(this,t,h),o&&!a&&(s.__isStrokes?Vh.strokes(o,this,t):Vh.stroke(o,this,t)),c&&Kh.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?Vh.strokes(o,this,t):Vh.stroke(o,this,t)),h){const e=s.shadow[0],{scaleX:i,scaleY:n}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*n,e.blur*i,Yh.string(e.color))}n&&(s.__isFills?Vh.fills(n,this,t):Vh.fill(n,this,t)),h&&t.restore(),r&&this.__drawAfterFill(t,e),o&&!a&&(s.__isStrokes?Vh.strokes(o,this,t):Vh.stroke(o,this,t))}}else s.__pathInputed?Pl(this,t,e):this.__drawFast(t,e)},__drawShape(t,e){this.__drawRenderPath(t);const i=this.__,{fill:s,stroke:n}=i;s&&!e.ignoreFill&&(i.__isAlphaPixelFill?Vh.fills(s,this,t):Vh.fill("#000000",this,t)),i.__isCanvas&&this.__drawAfterFill(t,e),n&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?Vh.strokes(n,this,t):Vh.stroke("#000000",this,t))},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),t.clipUI(this),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Pl(t,e,i){const{fill:s,stroke:n,__drawAfterFill:o,__fillAfterStroke:r}=t.__;t.__drawRenderPath(e),r&&Vh.stroke(n,t,e),s&&Vh.fill(s,t,e),o&&t.__drawAfterFill(e,i),n&&!r&&Vh.stroke(n,t,e)}const Al={__drawFast(t,e){let{x:i,y:s,width:n,height:o}=this.__layout.boxBounds;const{fill:r,stroke:a,__drawAfterFill:h}=this.__;if(r&&(t.fillStyle=r,t.fillRect(i,s,n,o)),h&&this.__drawAfterFill(t,e),a){const{strokeAlign:r,__strokeWidth:h}=this.__;if(!h)return;t.setStroke(a,h,this.__);const l=h/2;switch(r){case"center":t.strokeRect(0,0,n,o);break;case"inside":n-=h,o-=h,n<0||o<0?(t.save(),this.__clip(t,e),t.strokeRect(i+l,s+l,n,o),t.restore()):t.strokeRect(i+l,s+l,n,o);break;case"outside":t.strokeRect(i-l,s-l,n+h,o+h)}}}};var Dl;let Ml=Dl=class extends eh{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){P.assignScale(this,t)}get scale(){return this.__.scale}get isAutoWidth(){const t=this.__;return t.__autoWidth||t.autoWidth}get isAutoHeight(){const t=this.__;return t.__autoHeight||t.autoHeight}get pen(){const{path:t}=this.__;return Fn.set(this.path=t||[]),t||this.__drawPathByBox(Fn),Fn}reset(t){}set(t,e){t&&Object.assign(this,t)}get(t){return a(t)?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return te.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return te.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(Fn.set(i=[]),this.__drawPathByBox(Fn)),t?Gi.toCanvasData(i,!0):i}getPathString(t,e,i){return Gi.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||qh.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?Dn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Xh.addArrows(this)):t.__pathForRender&&(t.__pathForRender=void 0)}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?Ks.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:n}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:o}=this.__;t.roundRect(e,i,s,n,l(o)?[o]:o)}else t.rect(e,i,s,n)}drawImagePlaceholder(t,e){Vh.fill(this.__.placeholderColor,this,t)}animate(t,e,i,s){return this.set(t),te.need("animate")}killAnimate(t,e){}export(t,e){return te.need("export")}syncExport(t,e){return te.need("export")}clone(t){const e=f.clone(this.toJSON());return t&&Object.assign(e,t),Dl.one(e)}static one(t,e,i,s,n){return se.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){Xo()(this)}static registerData(t){Ao(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};le([Ao(nl)],Ml.prototype,"__",void 0),le([Wh()],Ml.prototype,"zoomLayer",void 0),le([ro("")],Ml.prototype,"id",void 0),le([ro("")],Ml.prototype,"name",void 0),le([ro("")],Ml.prototype,"className",void 0),le([bo("pass-through")],Ml.prototype,"blendMode",void 0),le([Eo(1)],Ml.prototype,"opacity",void 0),le([So(!0)],Ml.prototype,"visible",void 0),le([bo(!1)],Ml.prototype,"locked",void 0),le([ko(!1)],Ml.prototype,"dim",void 0),le([ko(!1)],Ml.prototype,"dimskip",void 0),le([Ro(0)],Ml.prototype,"zIndex",void 0),le([Co(!1)],Ml.prototype,"mask",void 0),le([Oo(!1)],Ml.prototype,"eraser",void 0),le([ao(0,!0)],Ml.prototype,"x",void 0),le([ao(0,!0)],Ml.prototype,"y",void 0),le([go(100,!0)],Ml.prototype,"width",void 0),le([go(100,!0)],Ml.prototype,"height",void 0),le([co(1,!0)],Ml.prototype,"scaleX",void 0),le([co(1,!0)],Ml.prototype,"scaleY",void 0),le([uo(0,!0)],Ml.prototype,"rotation",void 0),le([uo(0,!0)],Ml.prototype,"skewX",void 0),le([uo(0,!0)],Ml.prototype,"skewY",void 0),le([ao(0,!0)],Ml.prototype,"offsetX",void 0),le([ao(0,!0)],Ml.prototype,"offsetY",void 0),le([ho(0,!0)],Ml.prototype,"scrollX",void 0),le([ho(0,!0)],Ml.prototype,"scrollY",void 0),le([lo()],Ml.prototype,"origin",void 0),le([lo()],Ml.prototype,"around",void 0),le([ro(!1)],Ml.prototype,"lazy",void 0),le([po(1)],Ml.prototype,"pixelRatio",void 0),le([xo(0)],Ml.prototype,"renderSpread",void 0),le([fo()],Ml.prototype,"path",void 0),le([mo()],Ml.prototype,"windingRule",void 0),le([mo(!0)],Ml.prototype,"closed",void 0),le([go(0)],Ml.prototype,"padding",void 0),le([go(!1)],Ml.prototype,"lockRatio",void 0),le([go()],Ml.prototype,"widthRange",void 0),le([go()],Ml.prototype,"heightRange",void 0),le([ro(!1)],Ml.prototype,"draggable",void 0),le([ro()],Ml.prototype,"dragBounds",void 0),le([ro("auto")],Ml.prototype,"dragBoundsType",void 0),le([ro(!1)],Ml.prototype,"editable",void 0),le([Lo(!0)],Ml.prototype,"hittable",void 0),le([Lo("path")],Ml.prototype,"hitFill",void 0),le([wo("path")],Ml.prototype,"hitStroke",void 0),le([Lo(!1)],Ml.prototype,"hitBox",void 0),le([Lo(!0)],Ml.prototype,"hitChildren",void 0),le([Lo(!0)],Ml.prototype,"hitSelf",void 0),le([Lo()],Ml.prototype,"hitRadius",void 0),le([Po("")],Ml.prototype,"cursor",void 0),le([bo()],Ml.prototype,"fill",void 0),le([wo(void 0,!0)],Ml.prototype,"stroke",void 0),le([wo("inside")],Ml.prototype,"strokeAlign",void 0),le([wo(1,!0)],Ml.prototype,"strokeWidth",void 0),le([wo(!1)],Ml.prototype,"strokeWidthFixed",void 0),le([wo("none")],Ml.prototype,"strokeCap",void 0),le([wo("miter")],Ml.prototype,"strokeJoin",void 0),le([wo()],Ml.prototype,"dashPattern",void 0),le([wo(0)],Ml.prototype,"dashOffset",void 0),le([wo(10)],Ml.prototype,"miterLimit",void 0),le([mo(0)],Ml.prototype,"cornerRadius",void 0),le([mo()],Ml.prototype,"cornerSmoothing",void 0),le([Fh()],Ml.prototype,"shadow",void 0),le([Fh()],Ml.prototype,"innerShadow",void 0),le([Fh()],Ml.prototype,"blur",void 0),le([Fh()],Ml.prototype,"backgroundBlur",void 0),le([Fh()],Ml.prototype,"grayscale",void 0),le([Fh()],Ml.prototype,"filter",void 0),le([bo()],Ml.prototype,"placeholderColor",void 0),le([ro(100)],Ml.prototype,"placeholderDelay",void 0),le([ro({})],Ml.prototype,"data",void 0),le([zo(eh.prototype.reset)],Ml.prototype,"reset",null),Ml=Dl=le([Ho(kl),Ho(Ll),No()],Ml);let Fl=class extends Ml{get __tag(){return"Group"}get isBranch(){return!0}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach(t=>this.add(t)),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return this.childlessJSON||(e.children=this.children.map(e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var Il;le([Ao(rl)],Fl.prototype,"__",void 0),le([go(0)],Fl.prototype,"width",void 0),le([go(0)],Fl.prototype,"height",void 0),Fl=le([Ho(ch),Xo()],Fl);const Wl=Gt.get("Leafer");let zl=Il=class extends Fl{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&jn.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||{x:0,y:0,width:0,height:0}}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Il.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,f.assign(s,t));const n=this.canvas=ee.canvas(s);this.__controllers.push(this.renderer=ee.renderer(this,n,s),this.watcher=ee.watcher(this,s),this.layouter=ee.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(),this.view=n.view,e||(this.selector=ee.selector(this),this.interaction=ee.interaction(this,n,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=ee.hitCanvasManager()),this.canvasManager=new he,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(n),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),yr.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit(()=>{super.set(t,e)})}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(jr.RESTART):this.emitLeafer(jr.START),this.__controllers.forEach(t=>t.start()),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach(t=>t.stop()),this.running=!1,this.emitLeafer(jr.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=f.copyAttrs({},t,ke);Object.keys(e).forEach(t=>this[t]=e[t])}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new Ht(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=f.copyAttrs({},this.canvas,ke);e.resize(t),this.updateLazyBounds(),this.__onResize(new Yr(t,i))}__onResize(t){this.emitEvent(t),f.copyAttrs(this.__,t,ke),setTimeout(()=>{this.canvasManager&&this.canvasManager.clearRecycled()},0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(){const{config:t,parentApp:e}=this;e||(t.width&&t.height||(this.autoLayout=new Vt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(ke.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t?(this.canvas.zIndex=e,setTimeout(()=>this.parent&&this.parent.__updateSortChildren())):"mode"===t&&this.emit(jr.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&ke.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,n=f.copyAttrs({},s,ke);n[t]=i[t]=e,i.width&&i.height?s.stopAutoLayout():this.__checkAutoLayout(),this.__doResize(n)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(jr.BEFORE_READY),this.emitLeafer(jr.READY),this.emitLeafer(jr.AFTER_READY),yr.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(jr.VIEW_READY),yr.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:n,pixelRatio:o}=this;const r="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,r.x+r.width)),i||(n=Math.max(1,r.y+r.height)),this.__doResize({width:s,height:n,pixelRatio:o})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){yr.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender(()=>{this.imageReady&&(t&&this.emitLeafer(jr.VIEW_COMPLETED),yr.run(this.__viewCompletedWait),this.viewCompleted=!0)})}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender(()=>this.interaction.updateCursor())}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return te.need("view")}getValidMove(t,e,i){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new jr(t,this))}__listenEvents(){const t=Jt.start("FirstCreate "+this.innerName);this.once([[jr.START,()=>Jt.end(t)],[Xr.START,this.updateLazyBounds,this],[Vr.START,this.__onCreated,this],[Vr.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Hr.DATA,this.__onWatchData,this],[Xr.END,this.__onLayoutEnd,this],[Vr.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){Il.list.remove(this);try{this.stop(),this.emitLeafer(jr.END),this.__removeListenEvents(),this.__controllers.forEach(t=>!(this.parent&&t===this.interaction)&&t.destroy()),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager&&this.canvasManager.destroy()),this.canvas&&this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout(()=>{Gn.clearRecycled()},100)}catch(t){Wl.error(t)}}};t?e():setTimeout(e)}};zl.list=new uh,le([Ao(hl)],zl.prototype,"__",void 0),le([go()],zl.prototype,"pixelRatio",void 0),le([ro("normal")],zl.prototype,"mode",void 0),zl=Il=le([Xo()],zl);let Nl=class extends Ml{get __tag(){return"Rect"}};le([Ao(cl)],Nl.prototype,"__",void 0),Nl=le([Ho(Al),No(),Xo()],Nl);const{add:Yl,includes:Hl,scroll:Xl}=Wt,Vl=Nl.prototype,jl=Fl.prototype;let Ul=class extends Fl{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){if(this.children.length&&!this.pathInputed){const t=this.__;if(t.__autoSide){t.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:e}=this.__layout;t.__autoSize||(t.__autoWidth?(e.width+=e.x,e.x=0,e.height=t.height,e.y=0):(e.height+=e.y,e.y=0,e.width=t.width,e.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t,e;if(this.children.length){const i=this.__,s=this.__layout,{renderBounds:n,boxBounds:o}=s,{overflow:r}=i,a=s.childrenRenderBounds||(s.childrenRenderBounds={x:0,y:0,width:0,height:0});super.__updateRenderBounds(a),(e=r.includes("scroll"))&&(Yl(a,o),Xl(a,i)),this.__updateRectRenderBounds(),t=!Hl(o,a),t&&"show"===r&&Yl(n,a)}else this.__updateRectRenderBounds();f.stintSet(this,"isOverflow",t),this.__checkScroll(e)}__updateRectRenderBounds(){}__checkScroll(t){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e)),this.hasScroller&&this.scroller.__render(t,e)}__drawContent(t,e){this.__renderGroup(t,e),(this.__.__useStroke||this.__.__useEffect)&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};le([Ao(al)],Ul.prototype,"__",void 0),le([go(100)],Ul.prototype,"width",void 0),le([go(100)],Ul.prototype,"height",void 0),le([ro(!1)],Ul.prototype,"resizeChildren",void 0),le([xo("show")],Ul.prototype,"overflow",void 0),le([zo(Vl.__updateStrokeSpread)],Ul.prototype,"__updateStrokeSpread",null),le([zo(Vl.__updateRenderSpread)],Ul.prototype,"__updateRectRenderSpread",null),le([zo(Vl.__updateBoxBounds)],Ul.prototype,"__updateRectBoxBounds",null),le([zo(Vl.__updateStrokeBounds)],Ul.prototype,"__updateStrokeBounds",null),le([zo(Vl.__updateRenderBounds)],Ul.prototype,"__updateRectRenderBounds",null),le([zo(Vl.__updateChange)],Ul.prototype,"__updateRectChange",null),le([zo(Vl.__render)],Ul.prototype,"__renderRect",null),le([zo(jl.__render)],Ul.prototype,"__renderGroup",null),Ul=le([No(),Xo()],Ul);let Gl=class extends Ul{get __tag(){return"Frame"}get isFrame(){return!0}};le([Ao(ll)],Gl.prototype,"__",void 0),le([bo("#FFFFFF")],Gl.prototype,"fill",void 0),le([xo("hide")],Gl.prototype,"overflow",void 0),Gl=le([Xo()],Gl);const{moveTo:Kl,closePath:ql,ellipse:Zl}=fs;let Jl=class extends Ml{get __tag(){return"Ellipse"}__updatePath(){const{width:e,height:i,innerRadius:s,startAngle:n,endAngle:o}=this.__,r=e/2,a=i/2,h=this.__.path=[];s?(n||o?(s<1&&Zl(h,r,a,r*s,a*s,0,n,o,!1),Zl(h,r,a,r,a,0,o,n,!0),s<1&&ql(h)):(s<1&&(Zl(h,r,a,r*s,a*s),Kl(h,e,a)),Zl(h,r,a,r,a,0,360,0,!0)),t.ellipseToCurve&&(this.__.path=this.getPath(!0))):n||o?(Kl(h,r,a),Zl(h,r,a,r,a,0,n,o,!1),ql(h)):Zl(h,r,a,r,a)}};le([Ao(ul)],Jl.prototype,"__",void 0),le([mo(0)],Jl.prototype,"innerRadius",void 0),le([mo(0)],Jl.prototype,"startAngle",void 0),le([mo(0)],Jl.prototype,"endAngle",void 0),Jl=le([Xo()],Jl);const{sin:$l,cos:Ql,PI:td}=Math,{moveTo:ed,lineTo:id,closePath:sd,drawPoints:nd}=fs;let od=class extends Ml{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)nd(e,t.points,t.curve,!0);else{const{width:i,height:s,sides:n}=t,o=i/2,r=s/2;ed(e,o,0);for(let t=1;t<n;t++)id(e,o+o*$l(2*t*td/n),r-r*Ql(2*t*td/n));sd(e)}}};le([Ao(gl)],od.prototype,"__",void 0),le([mo(3)],od.prototype,"sides",void 0),le([mo()],od.prototype,"points",void 0),le([mo(0)],od.prototype,"curve",void 0),od=le([No(),Xo()],od);const{sin:rd,cos:ad,PI:hd}=Math,{moveTo:ld,lineTo:dd,closePath:cd}=fs;let ud=class extends Ml{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,o=e/2,r=this.__.path=[];ld(r,n,0);for(let t=1;t<2*i;t++)dd(r,n+(t%2==0?n:n*s)*rd(t*hd/i),o-(t%2==0?o:o*s)*ad(t*hd/i));cd(r)}};le([Ao(pl)],ud.prototype,"__",void 0),le([mo(5)],ud.prototype,"corners",void 0),le([mo(.382)],ud.prototype,"innerRadius",void 0),ud=le([Xo()],ud);const{moveTo:gd,lineTo:pd,drawPoints:_d}=fs,{rotate:fd,getAngle:md,getDistance:yd,defaultPoint:vd}=nt;let wd=class extends Ml{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&fd(i,e),i}set toPoint(t){this.width=yd(vd,t),this.rotation=md(vd,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?_d(e,t.points,t.curve,t.closed):(gd(e,0,0),pd(e,this.width,0))}};le([Ao(dl)],wd.prototype,"__",void 0),le([yo("center")],wd.prototype,"strokeAlign",void 0),le([go(0)],wd.prototype,"height",void 0),le([mo()],wd.prototype,"points",void 0),le([mo(0)],wd.prototype,"curve",void 0),le([mo(!1)],wd.prototype,"closed",void 0),wd=le([Xo()],wd);let xd=class extends Nl{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return u(t)&&t[0].image}};le([Ao(vl)],xd.prototype,"__",void 0),le([go("")],xd.prototype,"url",void 0),xd=le([Xo()],xd);const bd=xd;let kd=class extends Nl{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=ee.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new Qn({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Dr(Dr.LOADED,{image:t}))})}draw(t,e,i,s){const n=new ct(t.worldTransform).invert(),o=new ct;e&&o.translate(e.x,e.y),i&&(l(i)?o.scale(i):o.scale(i.x,i.y)),s&&o.rotate(s),n.multiplyParent(o),t.__render(this.canvas,{matrix:n.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:n}=this.canvas;t.drawImage(n,0,0,n.width,n.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null),super.destroy()}};le([Ao(wl)],kd.prototype,"__",void 0),le([Ih(100)],kd.prototype,"width",void 0),le([Ih(100)],kd.prototype,"height",void 0),le([Ih(1)],kd.prototype,"pixelRatio",void 0),le([Ih(!0)],kd.prototype,"smooth",void 0),le([ro(!1)],kd.prototype,"safeResize",void 0),le([Ih()],kd.prototype,"contextSettings",void 0),kd=le([Xo()],kd);const{copyAndSpread:Ed,includes:Sd,spread:Bd,setList:Td}=Wt;let Rd=class extends Ml{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:n,fontWeight:o,italic:r,textCase:a,textOverflow:h,padding:l}=t;t.__lineHeight=Hh.number(e,n),t.__letterSpacing=Hh.number(i,n),t.__padding=l?P.fourNumber(l):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*n)/2,t.__font=`${r?"italic ":""}${"small-caps"===a?"small-caps ":""}${"normal"!==o?o+" ":""}${n||12}px ${s||"caption"}`,t.__clipText="show"!==h&&!t.__autoSize,t.__textDrawData=Nh.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:n,__autoWidth:o,__autoHeight:r}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=a,t.__lineHeight<i&&Bd(a,i/2),o||r){if(h.x=o?a.x:0,h.y=r?a.y:0,h.width=o?a.width:t.width,h.height=r?a.height:t.height,n){const[e,i,s,n]=t.__padding;o&&(h.x-=n,h.width+=i+n),r&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),f.stintSet(this,"isOverflow",!Sd(h,a)),this.isOverflow?(Td(t.__textBoxBounds={},[h,a]),e.renderChanged=!0):t.__textBoxBounds=h}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;Ed(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__updateChange(){super.__updateChange();const t=this.__box;t&&(t.__onUpdateSize(),t.__updateChange())}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!e.exporting||super.__draw(t,e,i)}__drawShape(t,e){e.shape&&this.__box&&this.__box.__drawShape(t,e),super.__drawShape(t,e)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}};le([Ao(yl)],Rd.prototype,"__",void 0),le([go(0)],Rd.prototype,"width",void 0),le([go(0)],Rd.prototype,"height",void 0),le([bo()],Rd.prototype,"boxStyle",void 0),le([ro(!1)],Rd.prototype,"resizeFontSize",void 0),le([bo("#000000")],Rd.prototype,"fill",void 0),le([yo("outside")],Rd.prototype,"strokeAlign",void 0),le([Lo("all")],Rd.prototype,"hitFill",void 0),le([go("")],Rd.prototype,"text",void 0),le([go("")],Rd.prototype,"placeholder",void 0),le([go("caption")],Rd.prototype,"fontFamily",void 0),le([go(12)],Rd.prototype,"fontSize",void 0),le([go("normal")],Rd.prototype,"fontWeight",void 0),le([go(!1)],Rd.prototype,"italic",void 0),le([go("none")],Rd.prototype,"textCase",void 0),le([go("none")],Rd.prototype,"textDecoration",void 0),le([go(0)],Rd.prototype,"letterSpacing",void 0),le([go({type:"percent",value:1.5})],Rd.prototype,"lineHeight",void 0),le([go(0)],Rd.prototype,"paraIndent",void 0),le([go(0)],Rd.prototype,"paraSpacing",void 0),le([go("x")],Rd.prototype,"writingMode",void 0),le([go("left")],Rd.prototype,"textAlign",void 0),le([go("top")],Rd.prototype,"verticalAlign",void 0),le([go(!0)],Rd.prototype,"autoSizeAlign",void 0),le([go("normal")],Rd.prototype,"textWrap",void 0),le([go("show")],Rd.prototype,"textOverflow",void 0),le([bo(!1)],Rd.prototype,"textEditing",void 0),Rd=le([Xo()],Rd);let Cd=class extends Ml{get __tag(){return"Path"}};le([Ao(_l)],Cd.prototype,"__",void 0),le([yo("center")],Cd.prototype,"strokeAlign",void 0),Cd=le([Xo()],Cd);let Od=class extends Fl{get __tag(){return"Pen"}setStyle(t){const e=this.pathElement=new Cd(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,n,o){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,n){return this}ellipse(t,e,i,s,n,o,r,a){return this}arc(t,e,i,s,n,o){return this}arcTo(t,e,i,s,n){return this}drawEllipse(t,e,i,s,n,o,r,a){return this}drawArc(t,e,i,s,n,o){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};le([Ao(fl)],Od.prototype,"__",void 0),le([(t,e)=>{to(t,e,{get(){return this.__path}})}],Od.prototype,"path",void 0),Od=le([Ho(As,["set","path","paint"]),Xo()],Od);let Ld=class extends zl{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){super(t,e)}init(t,e){if(super.init(t,e),t){const{ground:e,tree:i,sky:s,editor:n}=t;e&&(this.ground=this.addLeafer(e)),(i||n)&&(this.tree=this.addLeafer(i||{type:t.type||"design"})),(s||n)&&(this.sky=this.addLeafer(s)),n&&ee.editor(n,this)}}__setApp(){const{canvas:t}=this,{realCanvas:e,view:i}=this.config;e||i===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable()}__updateLocalBounds(){this.forEach(t=>t.updateLayout()),super.__updateLocalBounds()}start(){super.start(),this.forEach(t=>t.start())}stop(){this.forEach(t=>t.stop()),super.stop()}unlockLayout(){super.unlockLayout(),this.forEach(t=>t.unlockLayout())}lockLayout(){super.lockLayout(),this.forEach(t=>t.lockLayout())}forceRender(t,e){this.forEach(i=>i.forceRender(t,e))}addLeafer(t){const e=new zl(t);return this.add(e),e}add(t,e){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout(()=>this.add(t,e),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t,e),o(e)||(t.canvas.childIndex=e),this.__listenChildEvents(t)}forEach(t){this.children.forEach(t)}__onCreated(){this.created=this.children.every(t=>t.created)}__onReady(){this.children.every(t=>t.ready)&&super.__onReady()}__onViewReady(){this.children.every(t=>t.viewReady)&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){t.context&&this.forEach(i=>e.matrix?i.__render(t,e):t.copyWorld(i.canvas,e.bounds))}__onResize(t){this.forEach(e=>e.resize(t)),super.__onResize(t)}updateLayout(){this.forEach(t=>t.updateLayout())}__getChildConfig(t){const e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&f.assign(e,t),this.autoLayout&&f.copyAttrs(e,this,ke),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[Xr.END,this.__onReady,this],[Vr.START,this.__onCreated,this],[Vr.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(Vr.END,this.__onChildRenderEnd,this))}};Ld=le([Xo()],Ld);const Pd={},Ad={isHoldSpaceKey:()=>Ad.isHold("Space"),isHold:t=>Pd[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){Pd[t]||(Pd[t]=!0)},setUpCode(t){Pd[t]=!1}},Dd={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class Md extends Cr{get spaceKey(){return Ad.isHoldSpaceKey()}get left(){return Dd.left(this)}get right(){return Dd.right(this)}get middle(){return Dd.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return Ad.isHoldKeys(t,this)}getBoxPoint(t){return(t||this.current).getBoxPoint(this)}getInnerPoint(t){return(t||this.current).getInnerPoint(this)}getLocalPoint(t){return(t||this.current).getLocalPoint(this)}getPagePoint(){return this.current.getPagePoint(this)}getInner(t){return this.getInnerPoint(t)}getLocal(t){return this.getLocalPoint(t)}getPage(){return this.getPagePoint()}static changeName(t,e){re.changeName(t,e)}}let Fd=class extends Md{};Fd.POINTER="pointer",Fd.BEFORE_DOWN="pointer.before_down",Fd.BEFORE_MOVE="pointer.before_move",Fd.BEFORE_UP="pointer.before_up",Fd.DOWN="pointer.down",Fd.MOVE="pointer.move",Fd.UP="pointer.up",Fd.OVER="pointer.over",Fd.OUT="pointer.out",Fd.ENTER="pointer.enter",Fd.LEAVE="pointer.leave",Fd.TAP="tap",Fd.DOUBLE_TAP="double_tap",Fd.CLICK="click",Fd.DOUBLE_CLICK="double_click",Fd.LONG_PRESS="long_press",Fd.LONG_TAP="long_tap",Fd.MENU="pointer.menu",Fd.MENU_TAP="pointer.menu_tap",Fd=le([Vo()],Fd);const Id=Fd,Wd={};let zd=class extends Fd{static setList(t){this.list=t instanceof uh?t:new uh(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const n=t.getLocalPoint(i,null,!0);return nt.move(n,e.x-t.x,e.y-t.y),s&&this.limitMove(t,n),Rl.axisMove(t,n),n}static limitMove(t,e){Rl.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Wd,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Wd,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Wd,null,!0)}getPageTotal(){return this.getPageMove(!0)}getInnerTotal(t){return this.getInnerMove(t,!0)}getLocalTotal(t){return this.getLocalMove(t,!0)}getPageBounds(){const t=this.getPageTotal(),e=this.getPagePoint(),i={};return Wt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),Wt.unsign(i),i}assignMove(t){Wd.x=t?this.totalX:this.moveX,Wd.y=t?this.totalY:this.moveY}};zd.BEFORE_DRAG="drag.before_drag",zd.START="drag.start",zd.DRAG="drag",zd.END="drag.end",zd.OVER="drag.over",zd.OUT="drag.out",zd.ENTER="drag.enter",zd.LEAVE="drag.leave",zd=le([Vo()],zd);const Nd=zd;let Yd=class extends Fd{static setList(t){zd.setList(t)}static setData(t){zd.setData(t)}};Yd.DROP="drop",Yd=le([Vo()],Yd);let Hd=class extends zd{};Hd.BEFORE_MOVE="move.before_move",Hd.START="move.start",Hd.MOVE="move",Hd.END="move.end",Hd=le([Vo()],Hd);let Xd=class extends Fd{};Xd.BEFORE_ROTATE="rotate.before_rotate",Xd.START="rotate.start",Xd.ROTATE="rotate",Xd.END="rotate.end",Xd=le([Vo()],Xd);let Vd=class extends zd{};Vd.SWIPE="swipe",Vd.LEFT="swipe.left",Vd.RIGHT="swipe.right",Vd.UP="swipe.up",Vd.DOWN="swipe.down",Vd=le([Vo()],Vd);let jd=class extends Fd{};jd.BEFORE_ZOOM="zoom.before_zoom",jd.START="zoom.start",jd.ZOOM="zoom",jd.END="zoom.end",jd=le([Vo()],jd);let Ud=class extends Md{};Ud.BEFORE_DOWN="key.before_down",Ud.BEFORE_UP="key.before_up",Ud.DOWN="key.down",Ud.HOLD="key.hold",Ud.UP="key.up",Ud=le([Vo()],Ud);const Gd={getDragEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:i.x,y:i.y,moveX:i.x-e.x,moveY:i.y-e.y,totalX:i.x-t.x,totalY:i.y-t.y}),getDropEventData:(t,e,i)=>Object.assign(Object.assign({},t),{list:e,data:i}),getSwipeDirection:t=>t<-45&&t>-135?Vd.UP:t>45&&t<135?Vd.DOWN:t<=45&&t>=-45?Vd.RIGHT:Vd.LEFT,getSwipeEventData:(t,e,i)=>Object.assign(Object.assign({},i),{moveX:e.moveX,moveY:e.moveY,totalX:i.x-t.x,totalY:i.y-t.y,type:Kd.getSwipeDirection(nt.getAngle(t,i))}),getBase(t){const e=1===t.button?4:t.button;return{altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,buttons:o(t.buttons)?1:0===t.buttons?e:t.buttons,origin:t}},pathHasEventType(t,e){const{list:i}=t;for(let t=0,s=i.length;t<s;t++)if(i[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const i=new uh,{list:s}=t;for(let t=0,n=s.length;t<n;t++)s[t].hasEvent(e)&&i.add(s[t]);return i},pathCanDrag:t=>t&&t.list.some(t=>ir.draggable(t)||!t.isLeafer&&t.hasEvent(zd.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},Kd=Gd,qd=new uh,{getDragEventData:Zd,getDropEventData:Jd,getSwipeEventData:$d}=Gd;class Qd{constructor(t){this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Zd(t,t,t),this.canAnimate=this.canDragOut=!0}getList(t,e){const{proxy:i}=this.interaction.selector,s=i&&i.list.length,n=zd.list||this.draggableList||qd;return this.dragging&&(s?t?qd:new uh(e?[...i.list,...i.dragHoverExclude]:i.list):n)}checkDrag(t,e){const{interaction:i}=this;if(this.moving&&t.buttons<1)return this.canAnimate=!1,void i.pointerCancel();!this.moving&&e&&(this.moving=i.canMove(this.downData)||i.isHoldRightKey||i.isMobileDragEmpty)&&(this.dragData.moveType="drag",i.emit(Hd.START,this.dragData)),this.moving||this.dragStart(t,e),this.drag(t)}dragStart(t,e){this.dragging||(this.dragging=e&&Dd.left(t),this.dragging&&(this.interaction.emit(zd.START,this.dragData),this.getDraggableList(this.dragData.path),this.setDragStartPoints(this.realDraggableList=this.getList(!0))))}setDragStartPoints(t){this.dragStartPoints={},t.forEach(t=>this.dragStartPoints[t.innerId]={x:t.x,y:t.y})}getDraggableList(t){let e;for(let i=0,s=t.length;i<s;i++)if(e=t.list[i],ir.draggable(e)){this.draggableList=new uh(e);break}}drag(t){const{interaction:e,dragData:i,downData:s}=this,{path:n,throughPath:o}=s;this.dragData=Zd(s,i,t),o&&(this.dragData.throughPath=o),this.dragData.path=n,this.moving?(this.dragData.moveType="drag",e.emit(Hd.BEFORE_MOVE,this.dragData),e.emit(Hd.MOVE,this.dragData)):this.dragging&&(this.dragReal(),e.emit(zd.BEFORE_DRAG,this.dragData),e.emit(zd.DRAG,this.dragData))}dragReal(t){const{interaction:e}=this,{running:i}=e,s=this.realDraggableList;if(s.length&&i){const{totalX:i,totalY:n}=this.dragData,{dragLimitAnimate:o}=e.p,r=!o||!!t;s.forEach(e=>{if(e.draggable){const s=a(e.draggable),h=zd.getValidMove(e,this.dragStartPoints[e.innerId],{x:i,y:n},r||s);o&&!s&&t?ir.animateMove(e,h,l(o)?o:.3):e.move(h)}})}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:i}=this,{path:s}=t;this.dragOverPath=s,i?s.indexAt(0)!==i.indexAt(0)&&(e.emit(zd.OUT,t,i),e.emit(zd.OVER,t,s)):e.emit(zd.OVER,t,s)}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:i}=this,{path:s}=t;e.emit(zd.LEAVE,t,i,s),e.emit(zd.ENTER,t,s,i),this.dragEnterPath=s}dragEnd(t,e){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t,e)||this.dragEndReal(t))}dragEndReal(t){const{interaction:e,downData:i,dragData:s}=this;t||(t=s);const{path:n,throughPath:o}=i,r=Zd(i,t,t);if(o&&(r.throughPath=o),r.path=n,this.moving&&(this.moving=!1,r.moveType="drag",e.emit(Hd.END,r)),this.dragging){const n=this.getList();this.dragging=!1,e.p.dragLimitAnimate&&this.dragReal(!0),e.emit(zd.END,r),this.swipe(t,i,s,r),this.drop(t,n,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(nt.getDistance(e,t)>n.config.pointer.swipeDistance){const t=$d(e,i,s);this.interaction.emit(t.type,t)}}drop(t,e,i){const s=Jd(t,e,zd.data);s.path=i,this.interaction.emit(Yd.DROP,s),this.interaction.emit(zd.LEAVE,t,i)}dragReset(){zd.list=zd.data=this.draggableList=this.dragData=this.downData=this.dragOverPath=this.dragEnterPath=null}checkDragEndAnimate(t,e){return!1}animate(t,e){}checkDragOut(t){}autoMoveOnDragOut(t){}autoMoveCancel(){}destroy(){this.dragReset()}}const tc=Gt.get("emit");const ec=["move","zoom","rotate","key"];function ic(t,e,i,s,n){if(ec.some(t=>e.startsWith(t))&&t.__.hitChildren&&!nc(t,n)){let o;for(let r=0,a=t.children.length;r<a;r++)o=t.children[r],!i.path.has(o)&&o.__.hittable&&sc(o,e,i,s,n)}}function sc(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!nc(t,n)&&(Zh.updateEventStyle&&!s&&Zh.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=re.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function nc(t,e){return e&&e.has(t)}const oc={wheel:{zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8}},pointer:{type:"pointer",snap:!0,hitRadius:5,tapTime:120,longPressTime:800,transformTime:500,hover:!0,dragHover:!0,dragDistance:2,swipeDistance:20},touch:{preventDefault:"auto"},multiTouch:{},move:{autoDistance:2},zoom:{},cursor:!0,keyEvent:!0},{pathHasEventType:rc,pathCanDrag:ac,pathHasOutside:hc}=Gd;class lc{get dragging(){return this.dragger.dragging}get transforming(){return this.transformer.transforming}get moveMode(){return!0===this.m.drag||this.isHoldSpaceKey||this.isHoldMiddleKey||this.isHoldRightKey&&this.dragger.moving||this.isDragEmpty}get canHover(){return this.p.hover&&!this.config.mobile}get isDragEmpty(){return this.m.dragEmpty&&this.isRootPath(this.hoverData)&&(!this.downData||this.isRootPath(this.downData))}get isMobileDragEmpty(){return this.m.dragEmpty&&!this.canHover&&this.downData&&this.isTreePath(this.downData)}get isHoldMiddleKey(){return this.m.holdMiddleKey&&this.downData&&Dd.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&Dd.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&Ad.isHoldSpaceKey()}get m(){return this.config.move}get p(){return this.config.pointer}get hitRadius(){return this.p.hitRadius}constructor(t,e,i,s){this.config=f.clone(oc),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new uh(t),this.createTransformer(),this.dragger=new Qd(this),s&&(this.config=f.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(Dd.defaultLeft(t),this.updateDownData(t),this.checkPath(t,e),this.downTime=Date.now(),this.emit(Fd.BEFORE_DOWN,t),this.emit(Fd.DOWN,t),Dd.left(t)&&(this.tapWait(),this.longPressWait(t)),this.waitRightTap=Dd.right(t),this.dragger.setDragData(t),this.isHoldRightKey||this.updateCursor(t))}pointerMove(t){if(t||(t=this.hoverData),!t)return;const{downData:e}=this;e&&Dd.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(Fd.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=nt.getDistance(this.downData,t)>this.p.dragDistance;e&&(this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(t,e)}this.dragger.moving||(this.updateHoverData(t),this.checkPath(t),this.emit(Fd.MOVE,t),this.pointerHover(t),this.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t))),this.updateCursor(this.downData||t)}pointerUp(t){const{downData:e}=this;if(t||(t=e),!e)return;Dd.defaultLeft(t),t.multiTouch=e.multiTouch,this.findPath(t);const i=Object.assign(Object.assign({},t),{path:t.path.clone()});t.path.addList(e.path.list),this.checkPath(t),this.downData=null,this.emit(Fd.BEFORE_UP,t),this.emit(Fd.UP,t),this.touchLeave(t),t.isCancel||(this.tap(t),this.menuTap(t)),this.dragger.dragEnd(t),this.updateCursor(i)}pointerCancel(){const t=Object.assign({},this.dragger.dragData);t.isCancel=!0,this.pointerUp(t)}menu(t){this.findPath(t),this.emit(Fd.MENU,t),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(t)}menuTap(t){this.waitRightTap&&this.waitMenuTap&&(this.emit(Fd.MENU_TAP,t),this.waitRightTap=this.waitMenuTap=!1)}createTransformer(){}move(t){}zoom(t){}rotate(t){}transformEnd(){}wheel(t){}multiTouch(t,e){}keyDown(t){if(!this.config.keyEvent)return;this.emit(Ud.BEFORE_DOWN,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Ad.setDownCode(e),this.emit(Ud.HOLD,t,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(Ud.DOWN,t,this.defaultPath)}keyUp(t){if(!this.config.keyEvent)return;this.emit(Ud.BEFORE_UP,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]=!1,Ad.setUpCode(e),this.emit(Ud.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new uh),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t))}pointerOverOrOut(t){const{path:e}=t,{overPath:i}=this;this.overPath=e,i?e.indexAt(0)!==i.indexAt(0)&&(this.emit(Fd.OUT,t,i),this.emit(Fd.OVER,t,e)):this.emit(Fd.OVER,t,e)}pointerEnterOrLeave(t){let{path:e}=t;this.downData&&!this.moveMode&&(e=e.clone(),this.downData.path.forEach(t=>e.add(t)));const{enterPath:i}=this;this.enterPath=e,this.emit(Fd.LEAVE,t,i,e),this.emit(Fd.ENTER,t,e,i)}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(Fd.LEAVE,t),this.dragger.dragging&&this.emit(Yd.LEAVE,t))}tap(t){const{pointer:e}=this.config,i=this.longTap(t);if(!e.tapMore&&i)return;if(!this.waitTap)return;e.tapMore&&this.emitTap(t);const s=Date.now()-this.downTime,n=[Fd.DOUBLE_TAP,Fd.DOUBLE_CLICK].some(e=>rc(t.path,e));s<e.tapTime+50&&n?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout(()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))},e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}findPath(e,i){const{hitRadius:s,through:n}=this.p,{bottomList:o,target:r}=this;t.backgrounder||e.origin||r&&r.updateLayout();const a=this.selector.getByPoint(e,s,Object.assign({bottomList:o,name:e.type},i||{through:n}));return a.throughPath&&(e.throughPath=a.throughPath),e.path=a.path,a.path}isRootPath(t){return t&&t.path.list[0].isLeafer}isTreePath(t){const e=this.target.app;return!(!e||!e.isApp)&&(e.editor&&!t.path.has(e.editor)&&t.path.has(e.tree)&&!t.target.syncEventer)}checkPath(t,e){(e||this.moveMode&&!hc(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!ac(t.path))&&!hc(t.path)}isDrag(t){return this.dragger.getList().has(t)}isPress(t){return this.downData&&this.downData.path.has(t)}isHover(t){return this.enterPath&&this.enterPath.has(t)}isFocus(t){return this.focusData===t}cancelHover(){const{hoverData:t}=this;t&&(t.path=this.defaultPath,this.pointerHover(t))}updateDownData(t,e,i){const{downData:s}=this;!t&&s&&(t=s),t&&(this.findPath(t,e),i&&s&&t.path.addList(s.path.list),this.downData=t)}updateHoverData(t){t||(t=this.hoverData),t&&(this.findPath(t,{exclude:this.dragger.getList(!1,!0),name:Fd.MOVE}),this.hoverData=t)}updateCursor(t){if(!this.config.cursor||!this.canHover)return;if(t||(this.updateHoverData(),t=this.downData||this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.canMove(t))return this.setCursor(this.downData?"grabbing":"grab");if(!t)return;let e,i;const{path:s}=t;for(let t=0,n=s.length;t<n&&(e=s.list[t],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);t++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e),s={x:t.clientX-i.x,y:t.clientY-i.y},{bounds:n}=this.canvas;return s.x*=n.width/i.width,s.y*=n.height/i.height,this.p.snap&&nt.round(s),s}emitTap(t){this.emit(Fd.TAP,t),this.emit(Fd.CLICK,t)}emitDoubleTap(t){this.emit(Fd.DOUBLE_TAP,t),this.emit(Fd.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){this.waitTap&&(clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0)}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout(()=>{this.longPressed=!0,this.emit(Fd.LONG_PRESS,t)},this.p.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(Fd.LONG_TAP,t),(rc(t.path,Fd.LONG_TAP)||rc(t.path,Fd.LONG_PRESS))&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressed=!1)}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new Ht(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(l(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Yr.RESIZE,this.__onResize,this)],t.once(jr.READY,()=>this.__onResize())}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}emit(t,e,i,s){this.running&&function(t,e,i,s){if(!i&&!e.path)return;let n;e.type=t,i?e=Object.assign(Object.assign({},e),{path:i}):i=e.path,e.target=i.indexAt(0);try{for(let o=i.length-1;o>-1;o--){if(n=i.list[o],sc(n,t,e,!0,s))return;n.isApp&&ic(n,t,e,!0,s)}for(let o=0,r=i.length;o<r;o++)if(n=i.list[o],n.isApp&&ic(n,t,e,!1,s),sc(n,t,e,!1,s))return}catch(t){tc.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer&&this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class dc{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}dc.custom={};class cc extends he{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new uh,this.pixelList=new uh}getPixelType(t,e){return this.__autoClear(),this.pixelList.add(t),ee.hitCanvas(e)}getPathType(t){return this.__autoClear(),this.pathList.add(t),ee.hitCanvas()}clearImageType(){this.__clearLeafList(this.pixelList)}clearPathType(){this.__clearLeafList(this.pathList)}__clearLeafList(t){t.length&&(t.forEach(t=>{t.__hitCanvas&&(t.__hitCanvas.destroy(),t.__hitCanvas=null)}),t.reset())}__autoClear(){this.pathList.length+this.pixelList.length>this.maxTotal&&this.clear()}clear(){this.clearPathType(),this.clearImageType()}}t.getSelector=function(e){return e.leafer?e.leafer.selector:t.selector||(t.selector=ee.selector())};const{toInnerRadiusPointOf:uc,copy:gc,setRadius:pc}=nt,{hitRadiusPoint:_c,hitPoint:fc}=Wt,mc={},yc={},vc=eh.prototype;vc.hit=function(e,i=0){this.updateLayout(),gc(yc,e),pc(yc,i);const s=this.__world;return!!(i?_c(s,yc):fc(s,yc))&&(this.isBranch?t.getSelector(this).hitPoint(Object.assign({},yc),i,{target:this}):this.__hitWorld(yc))},vc.__hitWorld=function(t){const e=this.__;if(!e.hitSelf)return!1;const i=this.__world,s=this.__layout,n=i.width<10&&i.height<10;if(e.hitRadius&&(gc(mc,t),pc(t=mc,e.hitRadius)),uc(t,i,mc),e.hitBox||n){if(Wt.hitRadiusPoint(s.boxBounds,mc))return!0;if(n)return!1}return!s.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),s.boundsChanged||(s.hitCanvasChanged=!1)),this.__hit(mc)},vc.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},vc.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},vc.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},vc.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const wc=new ct,xc=Ml.prototype;xc.__updateHitCanvas=function(){this.__box&&this.__box.__updateHitCanvas();const e=this.leafer||this.parent&&this.parent.leafer;if(!e)return;const i=this.__,{hitCanvasManager:s}=e,n=(i.__isAlphaPixelFill||i.__isCanvas)&&"pixel"===i.hitFill,o=i.__isAlphaPixelStroke&&"pixel"===i.hitStroke,r=n||o;this.__hitCanvas||(this.__hitCanvas=r?s.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):s.getPathType(this));const a=this.__hitCanvas;if(r){const{renderBounds:e}=this.__layout,s=t.image.hitCanvasSize,r=a.hitScale=Xt.set(0,0,s,s).getFitMatrix(e).a,{x:h,y:l,width:d,height:c}=Xt.set(e).scale(r);a.resize({width:d,height:c,pixelRatio:1}),a.clear(),Gn.patternLocked=!0,this.__renderShape(a,{matrix:wc.setWith(this.__world).scaleWith(1/r).invertWith().translate(-h,-l),ignoreFill:!n,ignoreStroke:!o}),Gn.patternLocked=!1,a.resetTransform(),i.__isHitPixel=!0}else i.__isHitPixel&&(i.__isHitPixel=!1);this.__drawHitPath(a),a.setStrokeOptions(i)},xc.__hit=function(t){if(this.__box&&this.__box.__hit(t))return!0;const e=this.__;if(e.__isHitPixel&&this.__hitPixel(t))return!0;const{hitFill:i}=e,s=(e.fill||e.__isCanvas)&&("path"===i||"pixel"===i&&!(e.__isAlphaPixelFill||e.__isCanvas))||"all"===i;if(s&&this.__hitFill(t))return!0;const{hitStroke:n,__maxStrokeWidth:o}=e,r=e.stroke&&("path"===n||"pixel"===n&&!e.__isAlphaPixelStroke)||"all"===n;if(!s&&!r)return!1;const a=2*t.radiusX;let h=a;if(r)switch(e.strokeAlign){case"inside":if(h+=2*o,!s&&this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a;break;case"center":h+=o;break;case"outside":if(h+=2*o,!s){if(!this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a}}return!!h&&this.__hitStroke(t,h)};const bc=Ml.prototype,kc=Nl.prototype,Ec=Ul.prototype;kc.__updateHitCanvas=Ec.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?bc.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},kc.__hitFill=Ec.__hitFill=function(t){return this.__hitCanvas?bc.__hitFill.call(this,t):Wt.hitRadiusPoint(this.__layout.boxBounds,t)},Rd.prototype.__drawHitPath=function(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__letterSpacing:n,__textDrawData:o}=this.__;t.beginPath(),n<0?this.__drawPathByBox(t):o.rows.forEach(n=>t.rect(n.x,n.y-s,n.width,e<i?i:e))},Fl.prototype.pick=function(e,i){return i||(i=n),this.updateLayout(),t.getSelector(this).getByPoint(e,i.hitRadius||0,Object.assign(Object.assign({},i),{target:this}))};const Sc=Ee.prototype;function Bc(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,o)))}}function Tc(t,e){t.__.__font?Bc(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Rc(t,e,i){switch(e.__.strokeAlign){case"center":Cc(t,1,e,i);break;case"inside":Oc(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Cc(t,2,e,i):Oc(t,"outside",e,i)}}function Cc(t,e,i,s){const n=i.__;g(t)?Pc(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Lc(i,s))}function Oc(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Cc(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Bc(i,n),n.blendMode="normal",ir.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Lc(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(o){const{decorationHeight:t}=s;n.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function Pc(t,e,i,s,n){let o;const r=s.__,{__hasMultiStrokeStyle:a}=r;a||n.setStroke(void 0,r.__strokeWidth*e,r);for(let h=0,l=t.length;h<l;h++)if(o=t[h],(!o.image||!jh.checkImage(s,n,o,!1))&&o.style){if(a){const{strokeStyle:t}=o;t?n.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(o.style,r.__strokeWidth*e,r)}else n.strokeStyle=o.style;o.blendMode?(n.saveBlendMode(o.blendMode),i?Lc(s,n):n.stroke(),n.restoreBlendMode()):i?Lc(s,n):n.stroke()}}function Ac(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Rc(t,e,i);else switch(s.strokeAlign){case"center":Dc(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Dc(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Dc(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),Dc(t,2,e,o),o.clipUI(s),o.clearWorld(n),ir.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i)}}function Dc(t,e,i,s){const n=i.__;g(t)?Pc(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&Vh.strokeArrow(t,i,s)}Sc.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},Sc.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},Sc.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:o,radiusY:r}=t;e&&(s-=e.x,n-=e.y),Xt.set(s-o,n-r,2*o,2*r).scale(i).ceil();const{data:a}=this.context.getImageData(Xt.x,Xt.y,Xt.width||1,Xt.height||1);for(let t=0,e=a.length;t<e;t+=4)if(a[t+3]>0)return!0;return a[3]>0};const{getSpread:Mc,copyAndSpread:Fc,toOuterOf:Ic,getOuterOf:Wc,getByMove:zc,move:Nc,getIntersectData:Yc}=Wt,Hc={};let Xc;const{stintSet:Vc}=f,{hasTransparent:jc}=Yh;function Uc(t,e,i){if(!g(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=jh.image(i,t,e,n,!Xc||!Xc[e.url]);break;case"linear":s=Uh.linearGradient(e,n);break;case"radial":s=Uh.radialGradient(e,n);break;case"angular":s=Uh.conicGradient(e,n);break;case"solid":const{type:r,color:a,opacity:h}=e;s={type:r,style:Yh.string(a,h)};break;default:o(e.r)||(s={type:"solid",style:Yh.string(e)})}if(s){if(a(s.style)&&jc(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Gc={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];u(a)||(a=[a]),Xc=jh.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Uc(t,a[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),o=!0),"fill"===t?(Vc(i,"__isAlphaPixelFill",n),Vc(i,"__isTransparentFill",o)):(Vc(i,"__isAlphaPixelStroke",n),Vc(i,"__isTransparentStroke",o),Vc(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,Tc(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(jh.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),Tc(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Tc(e,i),i.restoreBlendMode()):Tc(e,i)}},fillPathOrText:Tc,fillText:Bc,stroke:Ac,strokes:function(t,e,i){Ac(t,e,i)},strokeText:Rc,drawTextStroke:Lc,shape:function(e,i,s){const n=i.getSameCanvas(),o=i.bounds,r=e.__nowWorld,a=e.__layout,h=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let l,d,c,u,g,p;Ic(a.strokeSpread?(Fc(Hc,a.boxBounds,a.strokeSpread),Hc):a.boxBounds,r,h);let{scaleX:_,scaleY:f}=e.getRenderScaleData(!0);if(o.includes(h))p=n,l=g=h,d=r;else{let n;if(t.fullImageShadow)n=h;else{const t=a.renderShapeSpread?Mc(o,E.swapAndScale(a.renderShapeSpread,_,f)):o;n=Yc(t,h)}u=o.getFitMatrix(n);let{a:m,d:y}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,s),_*=m,f*=y),g=Wc(h,u),l=zc(g,-u.e,-u.f),d=Wc(r,u),Nc(d,-u.e,-u.f);const v=s.matrix;v?(c=new ct(u),c.multiply(v),m*=v.scaleX,y*=v.scaleY):c=u,c.withScale(m,y),s=Object.assign(Object.assign({},s),{matrix:c})}return e.__renderShape(n,s),{canvas:n,matrix:c,fitMatrix:u,bounds:l,renderBounds:d,worldCanvas:p,shapeBounds:g,scaleX:_,scaleY:f}}};let Kc={},qc={a:1,b:0,c:0,d:1,e:0,f:0};const{get:Zc,rotateOfOuter:Jc,translate:$c,scaleOfOuter:Qc,multiplyParent:tu,scale:eu,rotate:iu,skew:su}=G;function nu(t,e,i,s,n,o,r){const a=Zc();$c(a,e.x+i,e.y+s),eu(a,n,o),r&&Jc(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function ou(t,e,i,s,n,o,r,a,h,l){const d=Zc();au(d,e,i,s,n,o,r,a),h&&(qc.a=h,qc.d=l,tu(d,qc)),t.transform=d}function ru(t,e,i,s,n,o,r,a,h,l,d,c){const u=Zc();if(c)au(u,e,n,o,r,a,h,l);else{if(h)if("center"===d)Jc(u,{x:i/2,y:s/2},h);else switch(iu(u,h),h){case 90:$c(u,s,0);break;case 180:$c(u,i,s);break;case 270:$c(u,0,i)}Kc.x=e.x+n,Kc.y=e.y+o,$c(u,Kc.x,Kc.y),r&&Qc(u,Kc,r,a)}t.transform=u}function au(t,e,i,s,n,o,r,a){r&&iu(t,r),a&&su(t,a.x,a.y),n&&eu(t,n,o),$c(t,e.x+i,e.y+s)}const{get:hu,translate:lu}=G,du=new Ht,cu={},uu={};function gu(t,e,i,s){const{changeful:n,sync:o,scaleFixed:r}=i;n&&(t.changeful=n),o&&(t.sync=o),r&&(t.scaleFixed=r),t.data=pu(i,s,e)}function pu(t,e,i){t.padding&&(e=du.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:o,mode:r,align:h,offset:l,scale:d,size:c,rotation:u,skew:p,clipSize:_,repeat:f,gap:m,filters:y}=t,v=e.width===s&&e.height===n,w={mode:r},x="center"!==h&&(u||0)%180==90;let b,k;switch(Wt.set(uu,0,0,x?n:s,x?s:n),r&&"cover"!==r&&"fit"!==r?((d||c)&&(P.getScaleData(d,c,i,cu),b=cu.scaleX,k=cu.scaleY),(h||m||f)&&(b&&Wt.scale(uu,b,k,!0),h&&xt.toPoint(h,uu,e,uu,!0,!0))):v&&!u||(b=k=Wt.getFitScale(e,uu,"fit"!==r),Wt.put(e,i,h,b,!1,uu),Wt.scale(uu,b,k,!0)),l&&nt.move(uu,l),r){case"stretch":v||(s=e.width,n=e.height);break;case"normal":case"clip":if(uu.x||uu.y||b||_||u||p){let t,i;_&&(t=e.width/_.width,i=e.height/_.height),ou(w,e,uu.x,uu.y,b,k,u,p,t,i),t&&(b=b?b*t:b,k=k?k*i:i)}break;case"repeat":(!v||b||u||p)&&ru(w,e,s,n,uu.x,uu.y,b,k,u,p,h,t.freeTransform),f||(w.repeat="repeat");const i=g(f);(m||i)&&(w.gap=function(t,e,i,s,n){let o,r;g(t)?(o=t.x,r=t.y):o=r=t;return{x:_u(o,i,n.width,e&&e.x),y:_u(r,s,n.height,e&&e.y)}}(m,i&&f,uu.width,uu.height,e));break;default:b&&nu(w,e,uu.x,uu.y,b,k,u)}return w.transform||(e.x||e.y)&&(w.transform=hu(),lu(w.transform,e.x,e.y)),b&&"stretch"!==r&&(w.scaleX=b,w.scaleY=k),w.width=s,w.height=n,o&&(w.opacity=o),y&&(w.filters=y),f&&(w.repeat=a(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),w}function _u(t,e,i,s){const n=a(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let fu,mu=new Ht;const{isSame:yu}=Wt;function vu(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||gu(n,s,i,o),!0}function wu(t,e){ku(t,Dr.LOAD,e)}function xu(t,e){ku(t,Dr.LOADED,e)}function bu(t,e,i){e.error=i,t.forceUpdate("surface"),ku(t,Dr.ERROR,e)}function ku(t,e,i){t.hasEvent(e)&&t.emitEvent(new Dr(e,i))}function Eu(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Su,scale:Bu,copy:Tu}=G,{floor:Ru,ceil:Cu,max:Ou,abs:Lu}=Math;function Pu(e,i,s){let{scaleX:n,scaleY:o}=e.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+o+"-"+s;if(i.patternId===r||e.destroyed)return!1;{const{image:a,data:h}=i;let l,d,{width:c,height:u,scaleX:g,scaleY:p,transform:_,repeat:f,gap:m}=h;n*=s,o*=s,g&&(g=Lu(g),p=Lu(p),d=Su(),Tu(d,_),Bu(d,1/g,1/p),n*=g,o*=p),c*=n,u*=o;const y=c*u;if(!f&&y>t.image.maxCacheSize)return!1;let v=t.image.maxPatternSize;if(a.isSVG){const t=c/a.width;t>1&&(l=t/Cu(t))}else{const t=a.width*a.height;v>t&&(v=t)}y>v&&(l=Math.sqrt(y/v)),l&&(n/=l,o/=l,c/=l,u/=l),g&&(n/=g,o/=p);const w=m&&m.x*n,x=m&&m.y*o;if(_||1!==n||1!==o){const t=c+(w||0),e=u+(x||0);n/=t/Ou(Ru(t),1),o/=e/Ou(Ru(e),1),d||(d=Su(),_&&Tu(d,_)),Bu(d,1/n,1/o)}const b=a.getCanvas(c,u,h.opacity,h.filters,w,x,e.leafer&&e.leafer.config.smooth),k=a.getPattern(b,f||t.origin.noRepeat||"no-repeat",d,i);return i.style=k,i.patternId=r,!0}}const Au={image:function(t,e,i,s,n){let o,r;const a=Gn.get(i);return fu&&i===fu.paint&&yu(s,fu.boxBounds)?o=fu.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),fu=a.use>1?{leafPaint:o,paint:i,boxBounds:mu.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(vu(t,e,i,a,o,s),n&&(wu(t,r),xu(t,r))):a.error?n&&bu(t,r,a.error):(n&&(Eu(t,!0),wu(t,r)),o.loadId=a.load(()=>{Eu(t,!1),t.destroyed||(vu(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),xu(t,r)),o.loadId=void 0},e=>{Eu(t,!1),bu(t,r,e),o.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(e,i,s,n){const{scaleX:o,scaleY:r}=e.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:a}=i,{data:h}=s;if(!h||s.patternId===o+"-"+r+"-"+a&&!qh.running)return!1;if(n)if(h.repeat)n=!1;else if(!(s.changeful||"miniapp"===t.name&&Yr.isResizing(e)||qh.running)){let{width:e,height:i}=h;e*=o*a,i*=r*a,h.scaleX&&(e*=h.scaleX,i*=h.scaleY),n=e*i>t.image.maxCacheSize}return n?(e.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(e,i,s,h),!0):(!s.style||s.sync||qh.running?Pu(e,s,a):s.patternTask||(s.patternTask=Gn.patternTasker.add(()=>de(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&Pu(e,s,a),e.forceUpdate("surface")}),300)),!1)},createPattern:Pu,recycleImage:function(t,e){const i=e["_"+t];if(u(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,Gn.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],u(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createData:gu,getPatternData:pu,fillOrFitMode:nu,clipMode:ou,repeatMode:ru},{toPoint:Du}=yt,{hasTransparent:Mu}=Yh,Fu={},Iu={};function Wu(t,e,i,s){if(i){let n,o,r,h;for(let t=0,l=i.length;t<l;t++)n=i[t],a(n)?(r=t/(l-1),o=Yh.string(n,s)):(r=n.offset,o=Yh.string(n.color,s)),e.addColorStop(r,o),!h&&Mu(o)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:zu,getDistance:Nu}=nt,{get:Yu,rotateOfOuter:Hu,scaleOfOuter:Xu}=G,{toPoint:Vu}=yt,ju={},Uu={};function Gu(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=zu(e,i);o=Yu(),n?(Xu(o,e,r/a*(s||1),1),Hu(o,e,t+90)):(Xu(o,e,1,r/a*(s||1)),Hu(o,e,t))}return o}const{getDistance:Ku}=nt,{toPoint:qu}=yt,Zu={},Ju={};const $u={linearGradient:function(e,i){let{from:s,to:n,type:o,opacity:r}=e;Du(s||"top",i,Fu),Du(n||"bottom",i,Iu);const a=t.canvas.createLinearGradient(Fu.x,Fu.y,Iu.x,Iu.y),h={type:o,style:a};return Wu(h,a,e.stops,r),h},radialGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,stretch:a}=e;Vu(s||"center",i,ju),Vu(n||"bottom",i,Uu);const h=t.canvas.createRadialGradient(ju.x,ju.y,0,ju.x,ju.y,Nu(ju,Uu)),l={type:o,style:h};Wu(l,h,e.stops,r);const d=Gu(i,ju,Uu,a,!0);return d&&(l.transform=d),l},conicGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,stretch:a}=e;qu(s||"center",i,Zu),qu(n||"bottom",i,Ju);const h=t.conicGradientSupport?t.canvas.createConicGradient(0,Zu.x,Zu.y):t.canvas.createRadialGradient(Zu.x,Zu.y,0,Zu.x,Zu.y,Ku(Zu,Ju)),l={type:o,style:h};Wu(l,h,e.stops,r);const d=Gu(i,Zu,Ju,a||1,t.conicGradientRotate90);return d&&(l.transform=d),l},getTransform:Gu},{copy:Qu,move:tg,toOffsetOutBounds:eg}=Wt,{max:ig}=Math,sg={},ng=new ct,og={};function rg(t,e){let i,s,n,o,r=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=t.spread||0,o=1.5*(t.blur||0),r=ig(r,n+o-s),a=ig(a,n+o+i),h=ig(h,n+o+s),l=ig(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function ag(e,i,s){const{shapeBounds:n}=s;let o,r;t.fullImageShadow?(Qu(sg,e.bounds),tg(sg,i.x-n.x,i.y-n.y),o=e.bounds,r=sg):(o=n,r=i),e.copyWorld(s.canvas,o,r)}const{toOffsetOutBounds:hg}=Wt,lg={};const dg=rg;const cg={shadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{shadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;eg(h,og,l),r.forEach((r,_)=>{let f=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}g.setWorldShadow(og.offsetX+(r.x||0)*c*f,og.offsetY+(r.y||0)*u*f,(r.blur||0)*c*f,Yh.string(r.color)),n=Gh.getShadowTransform(t,g,i,r,og,f),n&&g.setTransform(n),ag(g,og,i),n&&g.resetTransform(),s=l,r.box&&(g.restore(),g.save(),a&&(g.copyWorld(g,l,o,"copy"),s=o),a?g.copyWorld(a,o,o,"destination-out"):g.copyWorld(i.canvas,d,h,"destination-out")),ir.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{innerShadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;hg(h,lg,l),r.forEach((r,_)=>{let f=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}g.save(),g.setWorldShadow(lg.offsetX+(r.x||0)*c*f,lg.offsetY+(r.y||0)*u*f,(r.blur||0)*c*f),n=Gh.getShadowTransform(t,g,i,r,lg,f,!0),n&&g.setTransform(n),ag(g,lg,i),g.restore(),a?(g.copyWorld(g,l,o,"copy"),g.copyWorld(a,o,o,"source-out"),s=o):(g.copyWorld(i.canvas,d,h,"source-out"),s=l),g.fillWorld(s,Yh.string(r.color),"source-in"),ir.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:rg,getShadowTransform:function(t,e,i,s,n,o,r){if(s.spread){const i=1+2*s.spread/t.__layout.strokeBounds.width*o*(r?-1:1);return ng.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},i),ng}},isTransformShadow(t){},getInnerShadowSpread:dg},{excludeRenderBounds:ug}=dr;let gg;function pg(t,e,i,s,n,o,r,a){switch(e){case"grayscale":gg||(gg=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);fg(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":fg(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function _g(t){return t.getSameCanvas(!1,!0)}function fg(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r)}Fl.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++){if(i=h[l],a=i.__.mask,a){r&&(pg(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||ug(i,e)||i.__render(t,e),o=i.__.opacity,gg=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=_g(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=_g(t)),n||(n=_g(t)),i.__render(s,e));continue}const d=1===o&&i.__.__blendMode;d&&pg(this,r,t,n,s,o,void 0,!1),ug(i,e)||i.__render(n||t,e),d&&pg(this,r,t,n,s,o,d,!1)}pg(this,r,t,n,s,o,void 0,!0)};const mg=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",yg=mg+"_#~&*+\\=|≮≯≈≠=…",vg=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function wg(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const xg=wg("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),bg=wg("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),kg=wg(mg),Eg=wg(yg),Sg=wg("- —/~|┆·");var Bg;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Bg||(Bg={}));const{Letter:Tg,Single:Rg,Before:Cg,After:Og,Symbol:Lg,Break:Pg}=Bg;function Ag(t){return xg[t]?Tg:Sg[t]?Pg:bg[t]?Cg:kg[t]?Og:Eg[t]?Lg:vg.test(t)?Rg:Tg}const Dg={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Mg(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Fg}=Dg,{Letter:Ig,Single:Wg,Before:zg,After:Ng,Symbol:Yg,Break:Hg}=Bg;let Xg,Vg,jg,Ug,Gg,Kg,qg,Zg,Jg,$g,Qg,tp,ep,ip,sp,np,op,rp=[];function ap(t,e){Jg&&!Zg&&(Zg=Jg),Xg.data.push({char:t,width:e}),jg+=e}function hp(){Ug+=jg,Xg.width=jg,Vg.words.push(Xg),Xg={data:[]},jg=0}function lp(){ip&&(sp.paraNumber++,Vg.paraStart=!0,ip=!1),Jg&&(Vg.startCharSize=Zg,Vg.endCharSize=Jg,Zg=0),Vg.width=Ug,np.width?Fg(Vg):op&&dp(),rp.push(Vg),Vg={words:[]},Ug=0}function dp(){Ug>(sp.maxWidth||0)&&(sp.maxWidth=Ug)}const{top:cp,right:up,bottom:gp,left:pp}=_t;function _p(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const fp={getDrawData:function(e,i){a(e)||(e=String(e));let s=0,n=0,o=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:d}=i;d&&(o?(s=d[pp],o-=d[up]+d[pp]):i.autoSizeAlign||(s=d[pp]),r?(n=d[cp],r-=d[cp]+d[gp]):i.autoSizeAlign||(n=d[cp]));const c={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:t.canvas.font=l};return function(e,i,s){sp=e,rp=e.rows,np=e.bounds,op=!np.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=t,{width:h,height:l}=np;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;ip=!0,Qg=null,Zg=qg=Jg=jg=Ug=0,Xg={data:[]},Vg={words:[]},n&&(i=[...i]);for(let s=0,l=i.length;s<l;s++)Kg=i[s],"\n"===Kg?(jg&&hp(),Vg.paraEnd=!0,lp(),ip=!0):($g=Ag(Kg),$g===Ig&&"none"!==r&&(Kg=Mg(Kg,r,!jg)),qg=a.measureText(Kg).width,n&&(n<0&&(Jg=qg),qg+=n),tp=$g===Wg&&(Qg===Wg||Qg===Ig)||Qg===Wg&&$g!==Ng,ep=!($g!==zg&&$g!==Wg||Qg!==Yg&&Qg!==Ng),Gg=ip&&o?h-o:h,t&&h&&Ug+jg+qg>Gg&&(e?(jg&&hp(),Ug&&lp()):(ep||(ep=$g===Ig&&Qg==Ng),tp||ep||$g===Hg||$g===zg||$g===Wg||jg+qg>Gg?(jg&&hp(),Ug&&lp()):Ug&&lp()))," "===Kg&&!0!==ip&&Ug+jg===0||($g===Hg?(" "===Kg&&jg&&hp(),ap(Kg,qg),hp()):tp||ep?(jg&&hp(),ap(Kg,qg)):ap(Kg,qg)),Qg=$g);jg&&hp(),Ug&&lp(),rp.length>0&&(rp[rp.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{sp.paraNumber++,Ug=a.measureText(t).width,rp.push({x:o||0,text:t,width:Ug,paraStart:!0}),op&&dp()})}(c,e,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":_p(e,"x",t[pp]);break;case"right":_p(e,"x",-t[up])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":_p(e,"y",t[cp]);break;case"bottom":_p(e,"y",-t[gp])}}(d,c,i,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:g,y:p,width:_,height:f}=s,m=o*n+(c?c*(t.paraNumber-1):0),y=r;if(h&&m>f)m=Math.max(f,o),n>1&&(t.overflow=n);else if(f||u)switch(d){case"middle":p+=(f-m)/2;break;case"bottom":p+=f-m}y+=p;let v,w,x,b=_||u?_:t.maxWidth;for(let r=0,d=n;r<d;r++){if(v=i[r],v.x=g,v.width<_||v.width>_&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&c&&r>0&&(y+=c),v.y=y,y+=o,t.overflow>r&&y>m&&(v.isOverflow=!0,t.overflow=r+1),w=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,w-=x,x+=e.fontSize):x-=a),w<s.x&&(s.x=w),x>s.width&&(s.width=x),h&&_&&_<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=m}(c,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,d,c,u;s.forEach(t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,d=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===d?(t.x+=l,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach((e,i)=>{1===d?(c={char:"",x:a},a=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,a,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):a=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)})),t.words=null)})}(c,i,o),c.overflow&&function(e,i,s,n){if(!n)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=i;if(o.splice(r),a&&"show"!==a){let e,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.canvas.measureText(a).width:0,d=s+n-l;("none"===i.textWrap?o:[o[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let s=i;s>-1&&(e=t.data[s],h=e.x+e.width,!(s===i&&h<d));s--){if(h<d&&" "!==e.char||!s){t.data.splice(s+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:a,x:h}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(c,i,s,o),"none"!==h&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:o}=e;switch(t.decorationHeight=n/11,g(o)?(i=o.type,o.color&&(t.decorationColor=Yh.string(o.color)),o.offset&&(s=Math.min(.3*n,Math.max(o.offset,.15*-n)))):i=o,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(c,i),c}};const mp={string:function(t,e){if(!t)return"#000";const i=l(e)&&e<1;if(a(t)){if(!i||!Yh.object)return t;t=Yh.object(t)}let s=o(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};function yp(t){return t?u(t)?t:[t]:[]}Object.assign(Nh,fp),Object.assign(Yh,mp),Object.assign(Vh,Gc),Object.assign(jh,Au),Object.assign(Uh,$u),Object.assign(Gh,cg),Object.assign(ee,{interaction:(t,e,i,s)=>new lc(t,e,i,s),hitCanvas:(t,e)=>new _h(t,e),hitCanvasManager:()=>new cc}),mh();class vp extends Cr{get list(){return yp(this.value)}get oldList(){return yp(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function wp(t){return(e,i)=>{const s="_"+i;to(e,i,{get(){return this[s]},set(e){const n=this[s];if(n!==e){const o=this;if(o.config){const t="target"===i;if(t){const{beforeSelect:t}=o.config;if(t){const i=t({target:e});if(g(i))e=i;else if(!1===i)return}o.setDimOthers(!1),o.setBright(!1),u(e)&&e.length>1&&e[0].locked&&e.splice(0,1),o.single&&(o.element.syncEventer=null)}const s=t?vp.BEFORE_SELECT:vp.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new vp(s,{editor:o,value:e,oldValue:n}))}this[s]=e,t(this,n)}}})}}vp.BEFORE_SELECT="editor.before_select",vp.SELECT="editor.select",vp.AFTER_SELECT="editor.after_select",vp.BEFORE_HOVER="editor.before_hover",vp.HOVER="editor.hover";const{abs:xp}=Math,{copy:bp,scale:kp}=G,{setListWithFn:Ep}=Wt,{worldBounds:Sp}=dr,Bp={a:1,b:0,c:0,d:1,e:0,f:0},Tp={x:0,y:0,width:0,height:0};class Rp extends Ml{constructor(){super(),this.list=[],this.visible=0,this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){e&&this.set(e),this.target=t,this.update()}update(t){const{list:e}=this;e.length?(Ep(Tp,e,Sp),t&&this.set(t),this.set(Tp),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const n=this.__,{stroke:o,strokeWidth:r,fill:h}=n,{bounds:l}=e;for(let d=0;d<i.length;d++){s=i[d];const{worldTransform:c,worldRenderBounds:u}=s;if(u.width&&u.height&&(!l||l.hit(u,e.matrix))){const i=xp(c.scaleX),l=xp(c.scaleY);if(bp(Bp,c),Bp.half=r%2,i!==l){kp(Bp,1/i,1/l),t.setWorld(Bp,e.matrix),t.beginPath(),n.strokeWidth=r;const{x:o,y:a,width:h,height:d}=s.__layout.boxBounds;t.rect(o*i,a*l,h*i,d*l)}else t.setWorld(Bp,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=r/xp(c.scaleX);o&&(a(o)?Vh.stroke(o,this,t):Vh.strokes(o,this,t)),h&&(a(h)?Vh.fill(h,this,t):Vh.fills(h,this,t))}}n.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}le([wp(function(t){const e=t.target;t.list=e?u(e)?e:[e]:[]})],Rp.prototype,"target",void 0);class Cp extends Fl{constructor(t){super(t),this.strokeArea=new Nl({strokeAlign:"center"}),this.fillArea=new Nl,this.visible=0,this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:n}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:n},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const Op={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return Lp([t],i,e),i}};function Lp(t,e,i){let s,n;for(let o=0,r=t.length;o<r;o++)if(s=t[o],n=s.__,n.hittable&&n.visible&&!n.locked&&i.hit(s.__world)){if(n.editable){if(s.isBranch&&!n.hitChildren){n.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&n.hitSelf&&e.push(s)}s.isBranch&&Lp(s.children,e,i)}}const{findOne:Pp,findByBounds:Ap}=Op;class Dp extends Fl{get dragging(){return!!this.originList}get running(){const{editor:t,app:e}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector&&e&&"normal"===e.mode}get isMoveMode(){const{app:t}=this;return t&&t.interaction.moveMode}constructor(t){super(),this.hoverStroker=new Rp,this.targetStroker=new Rp,this.bounds=new Ht,this.selectArea=new Cp,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:n}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},n||{}))}}onSelect(){this.running&&(this.targetStroker.setTarget(this.editor.list),this.hoverStroker.target=null)}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedStyle:i}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2)},i||{}))}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i,selectKeep:s}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(s||(e.target=null))}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(this.isHoldMultipleSelectKey(t)||this.editor.mergedConfig.selectKeep||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:n,y:o}=t.getInnerPoint(this);this.bounds.set(n,o),this.selectArea.setStyle({visible:!0,stroke:i,x:n,y:o},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new uh(Ap(e.app,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach(e=>{n.has(e)||t.push(e)}),n.forEach(e=>{this.originList.has(e)||t.push(e)}),(t.length!==e.list.length||e.list.some((e,i)=>e!==t[i]))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=0)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){const{boxSelect:e,multipleSelect:i}=this.editor.mergeConfig;return!(!(this.running&&i&&e)||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||this.isHoldMultipleSelectKey(t)&&!Pp(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new uh(this.editor.editBox.rect)};return Pp(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):Pp(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(this.isHoldMultipleSelectKey(t)||i)}isHoldMultipleSelectKey(t){const{multipleSelectKey:e}=this.editor.mergedConfig;return e?t.isHoldKeys(e):t.shiftKey}__listenEvents(){const{editor:t}=this;t.waitLeafer(()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_([[vp.HOVER,this.onHover,this],[vp.SELECT,this.onSelect,this]]),e.on_([[Fd.MOVE,this.onPointerMove,this],[Fd.BEFORE_DOWN,this.onBeforeDown,this],[Fd.TAP,this.onTap,this],[zd.START,this.onDragStart,this,!0],[zd.DRAG,this.onDrag,this],[zd.END,this.onDragEnd,this],[Hd.MOVE,this.onAutoMove,this],[[jd.ZOOM,Hd.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:Mp,top:Fp,topRight:Ip,right:Wp,bottomRight:zp,bottom:Np,bottomLeft:Yp,left:Hp}=ft,{toPoint:Xp}=yt,{within:Vp,sign:jp}=P,Up={getScaleData(t,e,i,s,n,o,r,a){let h,d={},c=1,u=1;const{boxBounds:g,widthRange:p,heightRange:_,dragBounds:f,worldBoxBounds:m}=t,{width:y,height:v}=e,w=t.scaleX/e.scaleX,x=t.scaleY/e.scaleY,b=jp(w),k=jp(x),E=a?w:b*g.width/y,S=a?x:k*g.height/v;if(l(s))c=u=Math.sqrt(s);else{o&&(s.x*=2,s.y*=2),s.x*=a?w:b,s.y*=a?x:k;const t=(-s.y+v)/v,e=(s.x+y)/y,r=(s.y+v)/v,l=(-s.x+y)/y;switch(i){case Fp:u=t,h="bottom";break;case Wp:c=e,h="left";break;case Np:u=r,h="top";break;case Hp:c=l,h="right";break;case Mp:u=t,c=l,h="bottom-right";break;case Ip:u=t,c=e,h="bottom-left";break;case zp:u=r,c=e,h="top-left";break;case Yp:u=r,c=l,h="top-right"}if(n)if("corner"===n&&i%2)n=!1;else{let t;switch(i){case Fp:case Np:t=u;break;case Hp:case Wp:t=c;break;default:t=Math.sqrt(Math.abs(c*u))}c=c<0?-t:t,u=u<0?-t:t}}const B=1!==c,T=1!==u;if(B&&(c/=E),T&&(u/=S),!r){const{worldTransform:e}=t;c<0&&(c=1/g.width/e.scaleX),u<0&&(u=1/g.height/e.scaleY)}if(Xp(o||h,g,d,!0),f){const e={x:c,y:u};Rl.limitScaleOf(t,d,e),c=e.x,u=e.y}if(B&&p){const e=g.width*t.scaleX;c=Vp(e*c,p)/e}if(T&&_){const e=g.height*t.scaleY;u=Vp(e*u,_)/e}return B&&Math.abs(c*m.width)<1&&(c=jp(c)/m.width),T&&Math.abs(u*m.height)<1&&(u=jp(u)/m.height),n&&c!==u&&(u=c=Math.min(c,u)),{origin:d,scaleX:c,scaleY:u,direction:i,lockRatio:n,around:o}},getRotateData(t,e,i,s,n){let o,r={};switch(e){case Mp:o="bottom-right";break;case Ip:o="bottom-left";break;case zp:o="top-left";break;case Yp:o="top-right";break;default:o="center"}return Xp(n||o,t.boxBounds,r,!0),{origin:r,rotation:nt.getRotation(s,t.getWorldPointByBox(r),i)}},getSkewData(t,e,i,s){let n,o,r={},a=0,h=0;switch(e){case Fp:case Mp:o={x:.5,y:0},n="bottom",a=1;break;case Np:case zp:o={x:.5,y:1},n="top",a=1;break;case Hp:case Yp:o={x:0,y:.5},n="right",h=1;break;case Wp:case Ip:o={x:1,y:.5},n="left",h=1}const{width:l,height:d}=t;o.x=o.x*l,o.y=o.y*d,Xp(s||n,t,r,!0);const c=nt.getRotation(o,r,{x:o.x+(a?i.x:0),y:o.y+(h?i.y:0)});return a?a=-c:h=c,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case Hp:t=Wp;break;case Mp:t=Ip;break;case Yp:t=zp;break;case Wp:t=Hp;break;case Ip:t=Mp;break;case zp:t=Yp}if(i)switch(t){case Fp:t=Np;break;case Mp:t=Yp;break;case Ip:t=zp;break;case Np:t=Fp;break;case Yp:t=Mp;break;case zp:t=Ip}return t}},Gp={};function Kp(t,e){const{enterPoint:i,dragging:s,skewing:n,resizing:o,flippedX:r,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return qp(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:g,moveable:p,resizeable:_,rotateable:f,skewable:m}=t.mergeConfig;if("move"===l)return i.cursor=d,void(p||(i.visible=!1));if("button"===l)return void(i.cursor||(i.cursor="pointer"));let y=l.includes("resize");y&&f&&(t.isHoldRotateKey(e)||!_)&&(y=!1);const v=m&&!y&&("resize-line"===i.name||"skew"===l),w=s?n?g:o?c:u:v?g:y?c:u;h+=45*(Up.getFlipDirection(i.direction,r,a)+1),h=2*Math.round(P.formatRotation(h,!0)/2);const{url:x,x:b,y:k}=w,E=x+h;Gp[E]?i.cursor=Gp[E]:Gp[E]=i.cursor={url:Zp(x,h),x:b,y:k}}function qp(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function Zp(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Jp extends Ul{constructor(t){super(t),this.useFastShadow=!0}}const $p=["top","right","bottom","left"],Qp=void 0;class t_ extends Fl{get mergeConfig(){const{config:t}=this,{mergeConfig:e,editBox:i}=this.editor;return this.mergedConfig=t&&i!==this?Object.assign(Object.assign({},e),t):e}get target(){return this._target||this.editor.element}set target(t){this._target=t}get single(){return!!this._target||this.editor.single}get transformTool(){return this._transformTool||this.editor}set transformTool(t){this._transformTool=t}get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}get canUse(){return this.visible&&this.view.visible}get canGesture(){if(!this.canUse)return!1;const{moveable:t,resizeable:e,rotateable:i}=this.mergeConfig;return a(t)||a(e)||a(i)}get canDragLimitAnimate(){return this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds}constructor(t){super(),this.view=new Fl,this.rect=new Jp({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Jp({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new Fl({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:n,rotatePoints:o,resizeLines:r,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Jp({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),o.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Jp({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new Jp({name:"resize-point",hitRadius:5}),n.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),this.listenPointEvents(a,"move",8),s.addMany(...o,a,h,l,...r,...n),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:n,resizePoints:o,resizeLines:r}=this,{stroke:a,strokeWidth:h,resizeLine:l}=e,d=this.getPointsStyle(),c=this.getMiddlePointsStyle();let u;this.visible=!t.locked;for(let t=0;t<8;t++)u=o[t],u.set(this.getPointStyle(t%2?c[(t-1)/2%c.length]:d[t/2%d.length])),u.rotation=(t-(t%2?1:0))/2*90,t%2&&r[(t-1)/2].set(Object.assign({pointType:"resize",rotation:(t-1)/2*90},l||{}));n.set(this.getPointStyle(e.circle||e.rotatePoint||d[0])),s.set(Object.assign({stroke:a,strokeWidth:h,editConfig:Qp},e.rect||{}));const g=i&&this.transformTool.editTool;s.hittable=!g,s.syncEventer=g&&this.editor,g&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),qp(this)}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:n,rotation:o,skewX:r,skewY:a,width:h,height:l}=this.target.getLayoutBounds("box",t,!0);this.visible=!this.target.locked,this.set({x:e,y:i,scaleX:s,scaleY:n,rotation:o,skewX:r,skewY:a}),this.updateBounds({x:0,y:0,width:h,height:l})}unload(){this.visible=!1,this.app&&(this.rect.syncEventer=this.app.interaction.bottomList=null)}updateBounds(t){const{editor:e,mergeConfig:i,single:s,rect:n,circle:o,buttons:r,resizePoints:a,rotatePoints:h,resizeLines:d}=this,{editMask:c}=e,{middlePoint:u,resizeable:g,rotateable:p,hideOnSmall:_,editBox:f,mask:m,dimOthers:y,bright:v,spread:w,hideRotatePoints:x,hideResizeLines:b}=i;if(c.visible=!!m||0,e.setDimOthers(y),e.setBright(!!y||v),w&&Wt.spread(t,w),this.view.worldOpacity){const{width:e,height:c}=t,m=l(_)?_:10,y=f&&!(_&&e<m&&c<m);let v,w,k,E={};for(let i=0;i<8;i++)yt.toPoint(yt.directionData[i],t,E),w=a[i],v=h[i],w.set(E),v.set(E),w.visible=y&&!(!g&&!p),v.visible=y&&p&&g&&!x,i%2&&(k=d[(i-1)/2],k.set(E),k.visible=w.visible&&!b,w.visible=v.visible=y&&!!u,(i+1)/2%2?(k.width=e+k.height,_&&2*w.width>e&&(w.visible=!1)):(k.width=c+k.height,_&&2*w.width>c&&(w.visible=!1)));o.visible=y&&p&&!(!i.circle&&!i.rotatePoint),o.visible&&this.layoutCircle(),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!s||f})),r.visible=y&&r.children.length>0||0,r.visible&&this.layoutButtons()}else n.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:n}=this.mergedConfig,o=$p.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,o,e||i,!!n)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:n}=this.mergedConfig,{flippedX:o,flippedY:r}=this;let a=$p.indexOf(e);(a%2&&o||(a+1)%2&&r)&&i&&(a=(a+2)%4);const h=i?Up.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!n),i&&(t.rotation=90*(h-a)),t.scaleX=o?-1:1,t.scaleY=r?-1:1}setButtonPosition(t,e,i,s){const n=this.resizePoints[2*e+1],o=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?n.width:0)+t.boxBounds.width:(s?n.height:0)+t.boxBounds.height)/2)*r;o?(t.x=n.x+a,t.y=n.y):(t.x=n.x,t.y=n.y+a)}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:n,pointRadius:o}=this.mergedConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:n,height:n,cornerRadius:o,offsetX:0,offsetY:0,editConfig:Qp};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.mergedConfig;return u(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return u(t)?t:t?[t]:this.getPointsStyle()}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:n,rotateable:o,skewable:r}=this.mergeConfig;"move"===i?s&&(this.moving=!0):(i.includes("rotate")||this.isHoldRotateKey(t)||!n?(o&&(this.rotating=!0),"resize-rotate"===i?n&&(this.resizing=!0):"resize-line"===e.name&&(r&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&n&&(this.resizing=!0),"skew"===i&&r&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:n,skewing:o}=this;if(i)e.onMove(t);else if(s||n||o){const i=t.current;i.pointType&&(this.enterPoint=i),n&&e.onRotate(t),s&&e.onScale(t),o&&e.onSkew(t)}Kp(this,t)}onDragEnd(t){this.onTransformEnd(t),this.dragPoint=null}onTransformStart(t){if(this.canUse){this.moving&&(this.editor.opacity=this.mergedConfig.hideOnMove?0:1),this.resizing&&(Yr.resizingKeys=this.editor.leafList.keys);const{dragStartData:e,target:i}=this;e.x=t.x,e.y=t.y,e.totalOffset={x:0,y:0},e.point={x:i.x,y:i.y},e.bounds=Object.assign({},i.getLayoutBounds("box","local")),e.rotation=i.rotation}}onTransformEnd(t){this.canUse&&(this.canDragLimitAnimate&&(t instanceof zd||t instanceof Hd)&&this.transformTool.onMove(t),this.resizing&&(Yr.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.update())}onMove(t){this.canGesture&&"drag"!==t.moveType&&(t.stop(),a(this.mergedConfig.moveable)&&(this.gesturing=this.moving=!0,t.type===Hd.START?this.onTransformStart(t):this.transformTool.onMove(t)))}onScale(t){this.canGesture&&(t.stop(),a(this.mergedConfig.resizeable)&&(this.gesturing=this.resizing=!0,t.type===jd.START?this.onTransformStart(t):this.transformTool.onScale(t)))}onRotate(t){this.canGesture&&(t.stop(),a(this.mergedConfig.rotateable)&&(this.gesturing=this.rotating=!0,t.type===Xd.START?this.onTransformStart(t):this.transformTool.onRotate(t)))}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){Kp(this,t)}onArrow(t){if(this.canUse&&this.mergeConfig.keyEvent){let e=0,i=0;const s=t.shiftKey?10:1;switch(t.code){case"ArrowDown":i=s;break;case"ArrowUp":i=-s;break;case"ArrowLeft":e=-s;break;case"ArrowRight":e=s}(e||i)&&this.transformTool.move(e,i)}}onDoubleTap(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"double"!==e||i||this.openInner(t)}onLongPress(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"long"===e&&i&&this.openInner(t)}openInner(t){const{editor:e,target:i}=this;if(this.single){if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find(t=>t.editable&&t instanceof Rd)||t.find(t=>t instanceof Rd);if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){t.direction=i,t.pointType=e,this.__eventIds.push(t.on_([[zd.START,this.onDragStart,this],[zd.DRAG,this.onDrag,this],[zd.END,this.onDragEnd,this],[Fd.ENTER,e=>{this.enterPoint=t,Kp(this,e)}],[Fd.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:t,editor:e,__eventIds:i}=this;i.push(t.on_([[Fd.DOUBLE_TAP,this.onDoubleTap,this],[Fd.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{i.push(e.app.on_([[[Ud.HOLD,Ud.UP],this.onKey,this],[Ud.DOWN,this.onArrow,this],[[Hd.START,Hd.BEFORE_MOVE],this.onMove,this,!0],[[jd.START,jd.BEFORE_ZOOM],this.onScale,this,!0],[[Xd.START,Xd.BEFORE_ROTATE],this.onRotate,this,!0],[[Hd.END,jd.END,Xd.END],this.onTransformEnd,this]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const e_={x:0,y:0,width:1e5,height:1e5};class i_ extends Ml{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,e_),Object.assign(this.__world,e_)}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergedConfig;if(s&&i.editing){if(t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),e.bounds&&!e.bounds.hit(i.editBox.rect.__world,e.matrix))return;t.saveBlendMode("destination-out"),e=Object.assign(Object.assign({},e),{shape:!0}),i.list.forEach(i=>{i.__render(t,e);const{parent:s}=i;s&&s.textBox&&s.__renderShape(t,e)}),t.restoreBlendMode()}}destroy(){this.editor=null,super.destroy()}}const s_='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',n_={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${s_}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${s_}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${s_}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,editBox:!0,hover:!0,select:"press",openInner:"double",multipleSelect:!0,boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},o_=new Ht;function r_(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{o_.setListWithFn(i,t=>t.getBounds("box","page")),0===o_.width&&(o_.width=.1),0===o_.height&&(o_.height=.1),e.reset(o_.get())}),s.add(e)}const a_=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),h_=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),l_={group(t,e,i){t.sort(h_);const{app:s,parent:n}=t[0];let o;o=i&&i.add?i:new Fl(i),n.addAt(o,n.children.indexOf(t[0])),t.sort(a_);const r=new ct(e.worldTransform);return r.divideParent(n.scrollWorldTransform),o.setTransform(r),o.editable=!0,o.hitChildren=!1,s.lockLayout(),t.forEach(t=>t.dropTo(o)),s.unlockLayout(),o},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach(t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort(a_),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(h_),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},d_=Gt.get("EditToolCreator");function c_(){return t=>{g_.register(t)}}const u_=c_,g_={list:{},register(t){const{tag:e}=t.prototype;p_[e]&&d_.repeat(e),p_[e]=t},get:(t,e)=>new p_[t](e)},{list:p_}=g_;class __ extends vp{constructor(t,e){super(t,e)}}__.BEFORE_OPEN="innerEditor.before_open",__.OPEN="innerEditor.open",__.BEFORE_CLOSE="innerEditor.before_close",__.CLOSE="innerEditor.close";class f_ extends vp{constructor(t,e){super(t,e)}}f_.BEFORE_GROUP="editor.before_group",f_.GROUP="editor.group",f_.BEFORE_UNGROUP="editor.before_ungroup",f_.UNGROUP="editor.ungroup",f_.BEFORE_OPEN="editor.before_open_group",f_.OPEN="editor.open_group",f_.BEFORE_CLOSE="editor.before_close_group",f_.CLOSE="editor.close_group";const{updateMatrix:m_}=ir,y_={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},v_="top-left";class w_ extends Nl{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(Pr.CHANGE,e=>{if(this.checkChange&&y_[e.attrName]){const{attrName:i,newValue:s,oldValue:n}=e,o="s"===i[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const r=this.__;r[i]=n,m_(this.parent),m_(this);const a=new ct(this.__world);switch(r[i]=s,this.__layout.rotationChange(),m_(this),this.changedTransform=new ct(this.__world).divide(a),i){case"x":t.move(o,0);break;case"y":t.move(0,o);break;case"rotation":t.rotateOf(v_,o);break;case"scaleX":t.scaleOf(v_,o,1);break;case"scaleY":t.scaleOf(v_,1,o);break;case"skewX":t.skewOf(v_,o,0);break;case"skewY":t.skewOf(v_,0,o)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class x_ extends vp{constructor(t,e){super(t,e)}}x_.BEFORE_MOVE="editor.before_move",x_.MOVE="editor.move";class b_ extends vp{constructor(t,e){super(t,e)}}b_.BEFORE_SCALE="editor.before_scale",b_.SCALE="editor.scale";class k_ extends vp{constructor(t,e){super(t,e)}}k_.BEFORE_ROTATE="editor.before_rotate",k_.ROTATE="editor.rotate";class E_ extends vp{constructor(t,e){super(t,e)}}E_.BEFORE_SKEW="editor.before_skew",E_.SKEW="editor.skew";class S_{onMove(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox;let n,{dragLimitAnimate:o}=i;const r=t.type===Hd.END||t.type===zd.END,h=a(e.draggable),d=!o||r||h,c={x:t.totalX,y:t.totalY};t instanceof Hd&&nt.move(c,e.getWorldPointByLocal(s.totalOffset,null,!0)),t.shiftKey&&(Math.abs(c.x)>Math.abs(c.y)?c.y=0:c.x=0),n=zd.getValidMove(e,s.point,c,d),(n.x||n.y)&&(o&&!h&&r?ir.animateMove(this,n,l(o)?o:.3):this.move(n))}onScale(t){const{target:e,mergeConfig:i,single:s,dragStartData:n}=this.editBox;let o,{around:r,lockRatio:a,flipable:h,editSize:l}=i;t instanceof jd?(r=e.getBoxPoint(t),o=t.totalScale):o=t.getInnerTotal(e);const{direction:d}=t.current;(t.shiftKey||e.lockRatio)&&(a=!0);const c=Up.getScaleData(e,n.bounds,d,o,a,Up.getAround(r,t.altKey),h,!s||"scale"===l),u=e.x,g=e.y;t instanceof zd&&this.editTool&&this.editTool.onScaleWithDrag?(c.drag=t,this.scaleWithDrag(c)):this.scaleOf(c.origin,c.scaleX,c.scaleY),nt.move(n.totalOffset,e.x-u,e.y-g)}onRotate(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox,{around:n,rotateAround:o,rotateGap:r,diagonalRotateKey:a}=i,{direction:h}=t.current;let l,d;if(t instanceof Xd)d=t.rotation,l=o?yt.getPoint(o,e.boxBounds):e.getBoxPoint(t);else{const i=a?t.isHoldKeys(a):t.shiftKey,r=Up.getRotateData(e,h,t,s,i?null:o||e.around||e.origin||n||"center");d=s.rotation+r.rotation-e.rotation,l=r.origin}if(d=P.float(P.getGapRotation(d,r,e.rotation),2),!d)return;const c=e.x,u=e.y;this.rotateOf(l,d),nt.move(s.totalOffset,e.x-c,e.y-u)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:n,skewX:o,skewY:r}=Up.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Up.getAround(s,t.altKey));(o||r)&&this.skewOf(n,o,r)}move(t,e=0){if(!this.checkTransform("moveable"))return;g(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:n,editor:o}=this.editBox,{beforeMove:r}=s;if(r){const s=r({target:i,x:t,y:e});if(g(s))t=s.x,e=s.y;else if(!1===s)return}const a=i.getWorldPointByLocal({x:t,y:e},null,!0);n||i.safeChange(()=>i.move(t,e));const h={target:i,editor:o,moveX:a.x,moveY:a.y};this.emitEvent(new x_(x_.BEFORE_MOVE,h));const l=new x_(x_.MOVE,h);this.doMove(l),this.emitEvent(l)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{target:e,mergeConfig:i,editor:s}=this.editBox,{beforeScale:n}=i;if(n){const{origin:i,scaleX:s,scaleY:o,drag:r}=t;if(!1===n({target:e,drag:r,origin:i,scaleX:s,scaleY:o}))return}t=Object.assign(Object.assign({},t),{target:e,editor:s,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new b_(b_.BEFORE_SCALE,t));const o=new b_(b_.SCALE,t);this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:n,mergeConfig:o,single:r,editor:a}=this.editBox,{beforeScale:h}=o;if(h){const s=h({target:n,origin:t,scaleX:e,scaleY:i});if(g(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!r&&this.getChangedTransform(()=>n.safeChange(()=>n.scaleOf(t,e,i))),c={target:n,editor:a,worldOrigin:l,scaleX:e,scaleY:i,transform:d};this.emitEvent(new b_(b_.BEFORE_SCALE,c));const u=new b_(b_.SCALE,c);this.doScale(u),this.emitEvent(u)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,n=this.getWorldOrigin("center"),o=i?new ct(ir.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),r={target:e,editor:s,worldOrigin:n,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:o};this.emitEvent(new b_(b_.BEFORE_SCALE,r));const a=new b_(b_.SCALE,r);this.doScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:n,editor:o}=this.editBox,{beforeRotate:r}=s;if(r){const s=r({target:i,origin:t,rotation:e});if(l(s))e=s;else if(!1===s)return}const a=this.getWorldOrigin(t),h=!n&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),d={target:i,editor:o,worldOrigin:a,rotation:e,transform:h};this.emitEvent(new k_(k_.BEFORE_ROTATE,d));const c=new k_(k_.ROTATE,d);this.doRotate(c),this.emitEvent(c)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:n,mergeConfig:o,single:r,editor:a}=this.editBox,{beforeSkew:h}=o;if(h){const s=h({target:n,origin:t,skewX:e,skewY:i});if(g(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!r&&this.getChangedTransform(()=>n.safeChange(()=>n.skewOf(t,e,i))),c={target:n,editor:a,worldOrigin:l,skewX:e,skewY:i,transform:d};this.emitEvent(new E_(E_.BEFORE_SKEW,c));const u=new E_(E_.SKEW,c);this.doSkew(u),this.emitEvent(u)}doMove(t){this.editTool.onMove(t)}doScale(t){this.editTool.onScale(t)}doRotate(t){this.editTool.onRotate(t)}doSkew(t){this.editTool.onSkew(t)}checkTransform(t){const{target:e,mergeConfig:i}=this.editBox;return e&&!e.locked&&i[t]}getWorldOrigin(t){const{target:e}=this.editBox;return e.getWorldPoint(ir.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const s=new ct(e.worldTransform);return t(),new ct(e.worldTransform).divide(s)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}let B_=class extends Fl{get list(){return this.leafList.list}get dragHoverExclude(){return[this.editBox.rect]}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragPoint(){return this.editBox.dragPoint}get dragging(){return this.editBox.dragging}get gesturing(){return this.editBox.gesturing}get moving(){return this.editBox.moving}get resizing(){return this.editBox.resizing}get rotating(){return this.editBox.rotating}get skewing(){return this.editBox.skewing}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}get targetLeafer(){const t=this.list[0];return t&&t.leafer}constructor(t,e){super(e),this.leafList=new uh,this.openedGroupList=new uh,this.simulateTarget=new w_(this),this.editBox=new t_(this),this.editToolList={},this.selector=new Dp(this),this.editMask=new i_(this),this.targetEventIds=[];let i=f.clone(n_);t&&(i=f.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),te.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}setDimOthers(t,e="dim",i){if(!i){const{dimTarget:t,targetLeafer:e}=this;i=t?u(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>f.stintSet(i,e,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&r_(this),this.update()}updateEditTool(){if(this.unloadEditTool(),this.editing){const t=this.element;let e=t.editOuter||"EditTool";const{beforeEditOuter:i}=this.mergeConfig;if(i){const s=i({target:t,name:e});if(a(s))e=s;else if(!1===s)return}if(g_.list[e]){const t=this.editTool=this.editToolList[e]=this.editToolList[e]||g_.get(e,this);this.editBox.load(),t.load(),this.update()}}}unloadEditTool(){let t=this.editTool;t&&(this.editBox.unload(),t.unload(),this.editTool=null)}getEditSize(t){return this.mergeConfig.editSize}onMove(t){}onScale(t){}onRotate(t){}onSkew(t){}move(t,e=0){}scaleWithDrag(t){}scaleOf(t,e,i=e,s){}flip(t){}rotateOf(t,e){}skewOf(t,e,i=0,s){}checkTransform(t){}getWorldOrigin(t){}getChangedTransform(t){}group(t){return this.multiple&&(this.emitGroupEvent(f_.BEFORE_GROUP),this.target=l_.group(this.list,this.element,t),this.emitGroupEvent(f_.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(f_.BEFORE_UNGROUP,t)),this.target=l_.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(f_.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(f_.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(f_.OPEN,t)}closeGroup(t){this.emitGroupEvent(f_.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(f_.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!ir.hasParent(e,t))&&e.push(t))),e.forEach(t=>this.closeGroup(t))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new f_(t,{editTarget:e});e&&e.syncEventer||this.emitEvent(i),e&&e.emitEvent(i)}openInnerEditor(t,e,i){let s;if(a(e)?s=e:i||(i=e),t&&i&&(this.target=t),this.single){t||(t=this.element),s||(s=t.editInner);const{beforeEditInner:e}=this.mergeConfig;if(e){const i=e({target:t,name:s});if(a(i))s=i;else if(!1===i)return}g_.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[s]=this.editToolList[s]||g_.get(s,this),this.innerEditor.editTarget=t,this.emitInnerEvent(__.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(__.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(__.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(__.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new __(t,{editTarget:i,innerEditor:e});i.syncEventer||this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach(t=>t.locked=!0),this.update()}unlock(){this.list.forEach(t=>t.locked=!1),this.update()}toTop(){this.list.length&&(l_.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(l_.toBottom(this.list),this.leafList.update())}onAppRenderStart(t){(this.targetChanged=t.children.some(t=>t!==this.leafer&&t.renderer.changed))&&this.editBox.forceRender()}onRenderStart(){this.targetChanged&&this.update()}onChildScroll(){this.multiple&&this.updateEditBox()}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e,targetLeafer:i,editMask:s}=this;this.targetEventIds=[e.on_(Vr.START,this.onRenderStart,this),i&&i.on_(Pr.SCROLL,this.onChildScroll,this),t.on_(Vr.CHILD_START,this.onAppRenderStart,this),t.on_(jr.UPDATE_MODE,t=>{t.mode&&"normal"!==t.mode&&this.cancel()})],s.visible&&s.forceRender()}}removeTargetEvents(){const{targetEventIds:t,editMask:e}=this;t.length&&(this.off_(t),e.visible&&e.forceRender())}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach(t=>t.destroy()),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}};le([(t,e)=>{to(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,app:n}=this,a=Object.assign({},t);return e&&e.editConfig&&Object.assign(a,e.editConfig),s.config&&Object.assign(a,s.config),i&&(i.editConfig&&Object.assign(a,i.editConfig),"font-size"===a.editSize&&(a.lockRatio=!0),"resize-rotate"===i.pointType&&(a.around||(a.around="center"),r(a.lockRatio)&&(a.lockRatio=!0))),o(a.dragLimitAnimate)&&(a.dragLimitAnimate=n&&n.config.pointer.dragLimitAnimate),this.mergedConfig=a}})}],B_.prototype,"mergeConfig",void 0),le([wp(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof uh?i:new uh(i),t.multiple&&r_(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new vp(vp.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new vp(vp.AFTER_SELECT,s))})],B_.prototype,"target",void 0),le([wp(function(t,e){t.emitEvent(new vp(vp.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],B_.prototype,"hoverTarget",void 0),B_=le([Ho(S_,["editBox","editTool","emitEvent"])],B_);class T_{static registerInnerEditor(){g_.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get editBox(){return this.editor.editBox}constructor(t){this.eventIds=[],this.editor=t,this.create()}onCreate(){}create(){this.view=new Fl,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!0),this.onUnload())}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}let R_=class extends T_{static registerEditTool(){g_.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:n,list:o}=s;n.lockLayout(),o.forEach(t=>{t.moveWorld(e,i)}),n.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach(t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(n,e,i,r)}),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:n}=t,{app:o,list:r}=n;o.lockLayout(),r.forEach(t=>{const o="scale"!==n.getEditSize(t);i?t.transformWorld(i,o):t.rotateOfWorld(s,e)}),o.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach(t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(n,e,i,r)}),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){this.editBox.update(),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};R_=le([c_()],R_);const{left:C_,right:O_}=ft,{move:L_,copy:P_,toNumberPoints:A_}=nt;let D_=class extends R_{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:n}=t,o=t.target,r=i===C_;if(o.pathInputed){const{path:t}=o.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,o.path=t}else if(o.points){const{points:t}=o,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,o.points=t}else{const t={x:0,y:0},{toPoint:i}=o;o.rotation=0,this.dragPoint(t,i,r,n,this.getInnerMove(o,e,s)),o.getLocalPointByInner(t,null,null,!0),o.getLocalPointByInner(i,null,null,!0),o.x=t.x,o.y=t.y,o.getInnerPointByLocal(i,null,null,!0),o.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){const e=A_(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,n){const{x:o,y:r}=n;i?(L_(t,o,r),s&&L_(e,-o,-r)):(s&&L_(t,-o,-r),L_(e,o,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:n}=t,o=this.editor.element;let r,a;if(o.pathInputed?r=this.getFromToByPath(o.__.path):o.points&&(r=this.getFromToByPoints(o.__.points)),r){const{from:i,to:a}=r;o.innerToWorld(i,i,!1,t),o.innerToWorld(a,a,!1,t),n.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),P_(s[7],i),P_(e[7],i),P_(s[3],a),P_(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===C_||t===O_,s[t].visible=a,e[t].visible=!r&&a}};D_=le([c_()],D_);const{M:M_,L:F_,C:I_,Q:W_,Z:z_,N:N_,D:Y_,X:H_,G:X_,F:V_,O:j_,P:U_,U:G_}=Te,K_={scale(t,e,i){if(!t)return;let s,n=0,o=t.length;for(;n<o;)switch(s=t[n],s){case M_:case F_:q_(t,e,i,n,1),n+=3;break;case I_:q_(t,e,i,n,3),n+=7;break;case W_:q_(t,e,i,n,2),n+=5;break;case z_:n+=1;break;case N_:q_(t,e,i,n,2),n+=5;break;case Y_:q_(t,e,i,n,2),n+=9;break;case H_:q_(t,e,i,n,2),n+=6;break;case X_:q_(t,e,i,n,2),n+=9;break;case V_:q_(t,e,i,n,2),n+=5;break;case j_:t[n]=X_,t.splice(n+4,0,t[n+3],0),q_(t,e,i,n,2),n+=9,o+=2;break;case U_:t[n]=V_,t.splice(n+4,0,t[n+3]),q_(t,e,i,n,2),n+=5,o+=1;break;case G_:q_(t,e,i,n,2),n+=6}},scalePoints(t,e,i,s,n){for(let o=n?s+1:0,r=n?o+2*n:t.length;o<r;o+=2)t[o]*=e,t[o+1]*=i}},{scalePoints:q_}=K_,Z_=G.get(),{topLeft:J_,top:$_,topRight:Q_,right:tf,bottom:ef,left:sf}=ft;function nf(t,e,i){t.pathInputed?rf(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function of(t,e,i,s){let n=e;if(!o(s)){const o=t.__layout;let{width:r,height:a}=o.boxBounds;switch(r*=i-e,a*=e-i,s){case $_:case ef:n=i,o.affectScaleOrRotation?t.moveInner(-r/2,0):t.x-=r/2;break;case sf:case tf:o.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case J_:case Q_:o.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const r=t.__,{padding:a}=r;a&&(t.padding=u(a)?a.map(t=>t*n):a*n),r.__autoWidth||(t.width*=n),r.__autoHeight||(t.height*=n)}function rf(t,e,i){K_.scale(t.__.path,e,i),t.path=t.__.path}function af(t,e,i){const{points:s}=t;g(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):K_.scalePoints(s,e,i),t.points=s}function hf(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)Z_.a=e,Z_.d=i,s[t].transform(Z_,!0)}const lf=eh.prototype;lf.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},lf.__scaleResize=function(t,e){nf(this,t,e)},lf.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},lf.resizeHeight=function(t){const e=t/this.getBounds("box","local").height||1;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},Rd.prototype.__scaleResize=function(t,e){const{app:i,editConfig:s}=this,n=i&&i.editor,o=n&&n.dragPoint;if(this.__.resizeFontSize||s&&"font-size"===s.editSize||o&&"font-size"===n.mergedConfig.editSize)of(this,t,e,o&&o.direction);else{const{__autoWidth:i,__autoHeight:s,textAlign:n,verticalAlign:o}=this.__,{boxBounds:r}=this.__layout;i&&"left"!==n&&1!==t&&(this.x+=r.x),s&&"top"!==o&&1!==e&&(this.y+=r.y),nf(this,t,e)}},Cd.prototype.__scaleResize=function(t,e){rf(this,t,e)},wd.prototype.__scaleResize=function(t,e){this.pathInputed?rf(this,t,e):this.points?af(this,t,e):this.width*=t},od.prototype.__scaleResize=function(t,e){this.pathInputed?rf(this,t,e):this.points?af(this,t,e):nf(this,t,e)},Fl.prototype.__scaleResize=function(t,e){hf(this,t,e)},Ul.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||nf(this,t,e),i&&hf(this,t,e)},te.add("resize"),te.add("editor","resize"),ee.editor=function(t,e){const i=new B_(t);return e&&e.sky.add(e.editor=i),i},Ul.addAttr("textBox",!1,ro),Ml.addAttr("editConfig",void 0,ro),Ml.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),ro),Ml.addAttr("editInner","PathEditor",ro),Fl.addAttr("editInner","",ro),Rd.addAttr("editInner","TextEditor",ro),Ml.setEditConfig=function(t){this.changeAttr("editConfig",t)},Ml.setEditOuter=function(t){this.changeAttr("editOuter",t)},Ml.setEditInner=function(t){this.changeAttr("editInner",t)};const df={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},cf={top:"flex-start",middle:"center",bottom:"flex-end"},uf={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function gf(t,e,i){const{style:s}=t,{fill:n,padding:r,textWrap:h,textOverflow:l,textDecoration:d}=e;let c;s.fontFamily=e.fontFamily,s.fontSize=e.fontSize*i+"px",function(t,e){let i="black";u(e)&&(e=e[0]);if(g(e))switch(e.type){case"solid":i=Yh.string(e.color);break;case"image":break;case"linear":case"radial":case"angular":const t=e.stops[0];i=Yh.string(a(t)?t:t.color);break;default:o(e.r)||(i=Yh.string(e))}else i=e;t.color=i}(s,n),s.fontStyle=e.italic?"italic":"normal",s.fontWeight=e.fontWeight,g(d)?(c=d.type,d.color&&(s.textDecorationColor=Yh.string(d.color))):c=d,s.textDecoration=uf[c],s.textTransform=df[e.textCase],s.textAlign="both"===e.textAlign?"justify":e.textAlign,s.display="flex",s.flexDirection="column",s.justifyContent=cf[e.verticalAlign],s.lineHeight=(e.__.__lineHeight||0)*i+"px",s.letterSpacing=(e.__.__letterSpacing||0)*i+"px",s.whiteSpace="none"===h||e.__.__autoWidth?"nowrap":"normal",s.wordBreak="break"===h?"break-all":"normal",s.textIndent=(e.paraIndent||0)*i+"px",s.padding=u(r)?r.map(t=>t*i+"px").join(" "):(r||0)*i+"px",s.textOverflow="show"===l?"":"hide"===l?"clip":l}let pf=class extends T_{constructor(){super(...arguments),this.config={selectAll:!0},this.eventIds=[]}get tag(){return"TextEditor"}onLoad(){const{editor:t}=this,{config:e}=t.app,i=this.editTarget;i.textEditing=!0,this.isHTMLText=!(i instanceof Rd),this._keyEvent=e.keyEvent,e.keyEvent=!1;const s=this.editDom=document.createElement("div"),{style:n}=s;s.contentEditable="true",n.position="fixed",n.transformOrigin="left top",n.boxSizing="border-box",this.isHTMLText?s.innerHTML=String(i.text):s.innerText=String(i.text);const{view:o}=t.app;(this.inBody=o instanceof HTMLCanvasElement)?document.body.appendChild(s):o.appendChild(s),this.eventIds=[t.app.on_(Fd.DOWN,e=>{let i,{target:n}=e.origin;for(;n;)n===s&&(i=!0),n=n.parentElement;i||t.closeInnerEditor()})],this.onFocus=this.onFocus.bind(this),this.onInput=this.onInput.bind(this),this.onPaste=this.onPaste.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onKeydown=this.onKeydown.bind(this),s.addEventListener("focus",this.onFocus),s.addEventListener("input",this.onInput),s.addEventListener("paste",this.onPaste),window.addEventListener("keydown",this.onKeydown),window.addEventListener("scroll",this.onUpdate);const r=window.getSelection(),a=document.createRange();if(this.config.selectAll)a.selectNodeContents(s);else{const t=s.childNodes[0];a.setStartAfter(t),a.setEndAfter(t),a.collapse(!0)}r.removeAllRanges(),r.addRange(a)}onInput(){const{editDom:t}=this;this.editTarget.text=this.isHTMLText?t.innerHTML:t.innerText}onFocus(){this.editDom.style.outline="none"}onKeydown(t){if("Escape"===t.code&&this.editor.closeInnerEditor(),"Enter"===t.key){t.preventDefault();const e=document.createElement("br"),i=document.createTextNode("​"),s=window.getSelection().getRangeAt(0);s.deleteContents(),s.insertNode(i),s.insertNode(e),s.setStartAfter(e),s.setEndAfter(e),this.onInput()}}onPaste(t){if(this.isHTMLText)return;t.preventDefault();const e=t.clipboardData;if(!e)return;let i=e.getData("text/plain").replace(/\r\n?/g,"\n");const s=window.getSelection();if(!s||!s.rangeCount)return;const n=s.getRangeAt(0);n.deleteContents();const o=i.split("\n"),r=document.createDocumentFragment();o.forEach((t,e)=>{e>0&&r.appendChild(document.createElement("br")),r.appendChild(document.createTextNode(t))}),n.insertNode(r),n.collapse(!1),s.removeAllRanges(),s.addRange(n),this.onInput()}onUpdate(){const{editTarget:t}=this;let e=1;if(!this.isHTMLText){const{scaleX:i,scaleY:s}=t.worldTransform;e=Math.max(Math.abs(i),Math.abs(s));t.fontSize*e<12&&(e*=12/t.fontSize)}this.textScale=e;let{width:i,height:s}=t,n=0,o=0;i*=e,s*=e;const r=t.__;if(r.__autoWidth)switch(i+=20,r.textAlign){case"center":n=r.autoSizeAlign?-i/2:-10;break;case"right":n=r.autoSizeAlign?-i:-20}if(r.__autoHeight)switch(s+=20,r.verticalAlign){case"middle":o=r.autoSizeAlign?-s/2:-10;break;case"bottom":o=r.autoSizeAlign?-s:-20}const{x:a,y:h}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds,{a:l,b:d,c:c,d:u,e:g,f:p}=new ct(t.worldTransform).scale(1/e).translateInner(n,o),{style:_}=this.editDom;_.transform=`matrix(${l},${d},${c},${u},${g},${p})`,_.left=a+"px",_.top=h+"px",_.width=i+"px",_.height=s+"px",this.isHTMLText||gf(this.editDom,t,e)}onUnload(){const{editTarget:t,editor:e,editDom:i}=this;t&&(this.onInput(),"\n"===t.text&&(t.text=""),t.textEditing=void 0,e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),i.removeEventListener("focus",this.onFocus),i.removeEventListener("input",this.onInput),i.removeEventListener("paste",this.onPaste),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("scroll",this.onUpdate),i.remove(),this.editDom=this.eventIds=void 0)}};function _f(t,e,i){ff(t.parentApp?t.parentApp:t,e),t.isApp||i||t.__eventIds.push(t.on_(Hd.BEFORE_MOVE,e=>{t.zoomLayer.move(t.getValidMove(e.moveX,e.moveY,!1))}),t.on_(Hd.END,e=>{ir.animateMove(t.zoomLayer,t.getValidMove(e.moveX,e.moveY))}),t.on_(jd.BEFORE_ZOOM,e=>{const{zoomLayer:i}=t,s=t.getValidScale(e.scale);1!==s&&i.scaleOfWorld(e,s)}))}function ff(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&f.assign(i,e),f.assign(t.config,i,t.userConfig)}pf=le([u_()],pf),te.add("text-editor","editor");const mf=Gt.get("LeaferTypeCreator"),yf={list:{},register(t,e){vf[t]&&mf.repeat(t),vf[t]=e},run(t,e){const i=vf[t];i&&i(e)}},{list:vf,register:wf}=yf;wf("viewport",_f),wf("custom",function(t){_f(t,null,!0)}),wf("design",function(t){_f(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),wf("document",function(t){_f(t,{zoom:{min:1},move:{scroll:"limit"}})});const xf={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],i=t[1],s=nt.getCenter(e.from,i.from),n=nt.getCenter(e.to,i.to),o={x:n.x-s.x,y:n.y-s.y},r=nt.getDistance(e.from,i.from);return{move:o,scale:nt.getDistance(e.to,i.to)/r,rotation:nt.getRotation(e.from,i.from,e.to,i.to),center:n}},getType(t,e){const i=Math.hypot(t.move.x,t.move.y)/(e.move||5),s=Math.abs(t.scale-1)/(e.scale||.03),n=Math.abs(t.rotation)/(e.rotation||2);return i<1&&s<1&&n<1?"none":i>=s&&i>=n?"move":s>=n?"zoom":"rotate"},detect(t,e){const{state:i}=bf,s=bf.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),bf.add(t,i.totalData),i.totalData=t,s===i.type){if(i.typeCount++,i.typeCount>=(e.count||3)&&"none"!==s)return s}else i.type=s,i.typeCount=1;return Date.now()-i.startTime>=(e.time||160)?bf.getType(i.totalData,e):"none"},add(t,e){e&&(nt.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=bf;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},bf=xf,{abs:kf,max:Ef}=Math,{sign:Sf,within:Bf}=P,Tf={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;t.shiftKey&&!s&&(s=n,n=0);const o=kf(s),r=kf(n);return o>50&&(s=Ef(50,o/3)*Sf(s)),r>50&&(n=Ef(50,r/3)*Sf(n)),{x:-s*i*2,y:-n*i*2}},getScale(e,i){let s,n=1,{zoomMode:o,zoomSpeed:r}=i;const a=e.deltaY||e.deltaX;if(o?(s="mouse"===o||!e.deltaX&&(t.intWheelDeltaY?Math.abs(a)>17:Math.ceil(a)!==a),(e.shiftKey||e.metaKey||e.ctrlKey)&&(s=!0)):s=!e.shiftKey&&(e.metaKey||e.ctrlKey),s){r=Bf(r,0,1);const t=e.deltaY?i.delta.y:i.delta.x,s=Bf(1-kf(a)/(4*t)*r,.5,2);n=a>0?s:1/s}return n}};let Rf,Cf,Of,Lf;class Pf{get transforming(){return this.moving||this.zooming||this.rotating}get moving(){return!!this.moveData}get zooming(){return!!this.zoomData}get rotating(){return!!this.rotateData}constructor(t){this.interaction=t}move(t){const{interaction:e}=this;t.moveType||(t.moveType="move"),this.moveData||(this.setPath(t),Rf=0,Cf=0,this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0,totalX:Rf,totalY:Cf}),e.emit(Hd.START,this.moveData)),t.path=this.moveData.path,t.totalX=Rf+=t.moveX,t.totalY=Cf+=t.moveY,e.emit(Hd.BEFORE_MOVE,t),e.emit(Hd.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;this.zoomData||(this.setPath(t),Of=1,this.zoomData=Object.assign(Object.assign({},t),{scale:1,totalScale:Of}),e.emit(jd.START,this.zoomData)),t.path=this.zoomData.path,t.totalScale=Of*=t.scale,e.emit(jd.BEFORE_ZOOM,t),e.emit(jd.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;this.rotateData||(this.setPath(t),Lf=0,this.rotateData=Object.assign(Object.assign({},t),{rotation:0,totalRotation:Lf}),e.emit(Xd.START,this.rotateData)),t.path=this.rotateData.path,t.totalRotation=Lf+=t.rotation,e.emit(Xd.BEFORE_ROTATE,t),e.emit(Xd.ROTATE,t),this.transformEndWait()}setPath(t){const{interaction:e}=this,{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,e.cancelHover()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout(()=>{this.transformEnd()},this.interaction.p.transformTime)}transformEnd(){const{interaction:t,moveData:e,zoomData:i,rotateData:s}=this;e&&t.emit(Hd.END,Object.assign(Object.assign({},e),{totalX:Rf,totalY:Cf})),i&&t.emit(jd.END,Object.assign(Object.assign({},i),{totalScale:Of})),s&&t.emit(Xd.END,Object.assign(Object.assign({},s),{totalRotation:Lf})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const Af=zl.prototype,Df=new Ht,Mf=new lt;function Ff(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function If(t,e){return Object.assign(Object.assign({},e),{scale:t})}Af.initType=function(t){yf.run(t,this)},Af.getValidMove=function(t,e,i=!0){const{scroll:s,disabled:n}=this.app.config.move;if(Mf.set(t,e),s){const t=!0===s?"":s;t.includes("x")?Mf.y=0:t.includes("y")?Mf.x=0:Math.abs(Mf.x)>Math.abs(Mf.y)?Mf.y=0:Mf.x=0,i&&t.includes("limit")&&(Df.set(this.__world).addPoint(this.zoomLayer),Rl.getValidMove(Df,this.canvas.bounds,"inner",Mf,!0),t.includes("x")?Mf.y=0:t.includes("y")&&(Mf.x=0))}return{x:n?0:Mf.x,y:n?0:Mf.y}},Af.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,o=Math.abs(e*t);return i&&o<i?t=i/e:s&&o>s&&(t=s/e),n?1:t};const Wf=lc.prototype;Wf.createTransformer=function(){this.transformer=new Pf(this)},Wf.move=function(t){this.transformer.move(t)},Wf.zoom=function(t){this.transformer.zoom(t)},Wf.rotate=function(t){this.transformer.rotate(t)},Wf.transformEnd=function(){this.transformer.transformEnd()},Wf.wheel=function(t){const{wheel:e,pointer:i}=this.config,{posDeltaSpeed:s,negDeltaSpeed:n}=e;if(e.disabled)return;t.deltaX>0?s&&(t.deltaX*=s):n&&(t.deltaX*=n),t.deltaY>0?s&&(t.deltaY*=s):n&&(t.deltaY*=n);const o=e.getScale?e.getScale(t,e):Tf.getScale(t,e);if(1!==o)this.zoom(If(o,t));else{const s=e.getMove?e.getMove(t,e):Tf.getMove(t,e);i.snap&&nt.round(s),this.move(Ff(s,t))}},Wf.multiTouch=function(t,e){const{disabled:i,singleGesture:s}=this.config.multiTouch;if(i)return;this.pointerWaitCancel();let n=xf.getData(e),{moving:o,zooming:r,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch(xf.detect(n,g(s)?s:{})){case"move":o=!0;break;case"zoom":r=!0;break;case"rotate":a=!0;break;default:return}xf.reset()}o||(n.center=xf.state.center)}else o=r=a=!0;var h,l;Object.assign(t,n.center),t.multiTouch=!0,a&&this.rotate((h=n.rotation,l=t,Object.assign(Object.assign({},l),{rotation:h}))),r&&this.zoom(If(n.scale,t)),o&&this.move(Ff(n.move,t))};const zf=Qd.prototype,{abs:Nf}=Math;function Yf(t,e){let i=1;const s="out"===e,n=Math.abs(t);if(n>1){for(;s?i<n:i<=n;)i*=2;s&&(i/=2)}else{for(;s?i>=n:i>n;)i/=2;s||(i*=2)}return i/t}zf.checkDragEndAnimate=function(t,e){const{moveX:i,moveY:s}=this.dragData,n=Nf(i),o=Nf(s),r=e?1:.1,a=this.canAnimate&&this.moving&&(n>r||o>r)&&this.interaction.m.dragAnimate;if(a){const r="touch"===t.pointerType?3:1,h=70;n*(e=e?l(a)?a:.95:r)>h?e=h/n:o*e>h&&(e=h/o),t=Object.assign({},t),nt.move(t,i*e,s*e),this.drag(t),this.animate(()=>{this.dragEnd(t,1)})}return a},zf.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},zf.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},zf.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:n,dragOut:o}=e.m;if(!o||!s||!n)return;const r=e.shrinkCanvasBounds,{x:a,y:h}=r,l=Wt.maxX(r),d=Wt.maxY(r),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let g=0,p=0;this.autoMoveTimer=setInterval(()=>{g+=c,p+=u,nt.move(i,c,u),nt.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:g,totalY:p,moveType:"drag"})),e.pointerMoveReal(t)},10)},zf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},te.add("viewport"),te.add("view"),zl.prototype.zoom=function(t,e,i,s){let n;this.killAnimate(),p(e)?(n=e.padding,i=e.scroll,s=e.transition):n=e;const{zoomLayer:o}=this,h=this.canvas.bounds.clone().shrink(r(n)?30:n),d=new Ht,c={x:h.x+h.width/2,y:h.y+h.height/2};let _;const{x:f,y:m,scaleX:y,scaleY:v}=o.__;if(a(t))switch(t){case"in":_=Yf(y,"in");break;case"out":_=Yf(y,"out");break;case"fit":t=this.boxBounds;break;case"fit-width":(t=new Ht(this.boxBounds)).height=0;break;case"fit-height":(t=new Ht(this.boxBounds)).width=0}else l(t)&&(_=t/y);if(_)_=this.getValidScale(_),o.scaleOfWorld(c,_,_,!1,s);else if(g(t)){const e={x:f,y:m,scaleX:y,scaleY:v},n=u(t);if(n||t.tag){const e=n?t:[t];d.setListWithFn(e,dr.worldBounds)}else{const e=function(t,e){let i,{x:s,y:n,width:o,height:r}=t;return r||(r=o*(e.height/e.width),i=!0),o||(o=r*(e.width/e.height),i=!0),i?{x:s,y:n,width:o,height:r}:t}(t,h);d.set(o.getWorldBounds(e))}const{width:r,height:a}=d;let l=h.x-d.x,c=h.y-d.y;return i?(l+=Math.max((h.width-r)/2,0),c+=Math.max((h.height-a)/2,0)):(_=this.getValidScale(Math.min(h.width/r,h.height/a)),l+=(h.width-r*_)/2,c+=(h.height-a*_)/2,nt.scaleOf(e,d,_),d.scaleOf(d,_),e.scaleX*=_,e.scaleY*=_),"x"===i?c=0:"y"===i&&(l=0),nt.move(e,l,c),d.move(l,c),o.set(e,s),d}return o.worldBoxBounds};class Hf extends Fl{get isOutside(){return!0}constructor(t,e){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,e&&f.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(t){let e;a(t)?(e={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===t&&(e.fill="white",e.stroke="rgba(0,0,0,0.2)")):e=t,this.scrollXBar||this.addMany(this.scrollXBar=new Ul,this.scrollYBar=new Ul),e=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},e),e.height||(e.height=e.width),this.scrollXBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:e,padding:i}=this.config,{zoomLayer:s,canvas:n}=this.target.leafer,{worldRenderBounds:o}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(o))return;this.scrollBounds=new Ht(o);const r=n.bounds.clone().shrink(i),a=r.clone().add(o),h=this.ratioX=r.width/a.width,l=this.ratioY=r.height/a.height,d=(r.x-a.x)/a.width,c=(r.y-a.y)/a.height,u=h<1,g=l<1,{scrollXBar:p,scrollYBar:_}=this,{x:f,y:m,width:y,height:v}=r.shrink([2,g?_.width+6:2,u?p.height+6:2,2]);p.set({x:f+y*d,y:m+v+2,width:Math.max(y*h,e),visible:u}),_.set({x:f+y+2,y:m+v*c,height:Math.max(v*l,e),visible:g})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const e=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(e?-t.moveX/this.ratioX:0,e?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:t,scrollYBar:e}=this;this.__eventIds=[t.on_(zd.DRAG,this.onDrag,this),e.on_(zd.DRAG,this.onDrag,this),t.on_(zd.END,this.onDragEnd,this),e.on_(zd.END,this.onDragEnd,this),this.target.on_(Vr.BEFORE,()=>this.update(!0)),this.target.leafer.on_(Yr.RESIZE,()=>this.update())]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}te.add("scroll");class Xf extends vl{setText(t){this._text=t,this.__htmlChanged=!0}}let Vf=class extends xd{get __tag(){return"HTMLText"}constructor(t){super(t)}__updateBoxBounds(){const t=this.__;if(t.__htmlChanged){const e=document.createElement("div"),{style:i}=e;i.all="initial",i.position="absolute",i.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:s,height:n}=e.getBoundingClientRect(),o=s+10,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${n}">\n <foreignObject width="${o}" height="${n}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.text}\n </body>\n </foreignObject>\n </svg>`;t.__setImageFill("data:image/svg+xml,"+encodeURIComponent(r)),t.__naturalWidth=o/t.pixelRatio,t.__naturalHeight=n/t.pixelRatio,t.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}__draw(t,e,i){this.textEditing&&!e.exporting||super.__draw(t,e,i)}};le([Ao(Xf)],Vf.prototype,"__",void 0),le([go("")],Vf.prototype,"text",void 0),le([ro("TextEditor")],Vf.prototype,"editInner",void 0),le([bo(!1)],Vf.prototype,"textEditing",void 0),Vf=le([Xo()],Vf),te.add("html");class jf extends dl{}function Uf(t){return so(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,vo(this)}}}))}let Gf=class extends wd{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){Xh.register(t,e)}};le([Ao(jf)],Gf.prototype,"__",void 0),le([Uf("angle")],Gf.prototype,"endArrow",void 0),Gf=le([Xo()],Gf);const{M:Kf,L:qf,C:Zf,Q:Jf,O:$f}=Te,{rotate:Qf,copyFrom:tm,scale:em}=nt,im={},sm={layout(t,e,i,s,n,o,r){let a,h,l=0,d=t.length;for(;l<d;)switch(a=t[l],a){case Kf:case qf:nm(t,l+1,e,i,s,n,o,r),l+=3;break;case Zf:for(h=1;h<6;h+=2)nm(t,l+h,e,i,s,n,o,r);l+=7;break;case Jf:for(h=1;h<4;h+=2)nm(t,l+h,e,i,s,n,o,r);l+=5;break;case $f:t[l+1]+=e,t[l+2]+=i,s&&(t[l+3]*=s),o&&(t[l+4]+=o,t[l+5]+=o),l+=7}},rotate(t,e,i){sm.layout(t,0,0,1,1,e,i)}};function nm(t,e,i,s,n,o,r,a){tm(im,t[e],t[e+1]),r&&Qf(im,r,a),n&&em(im,n,o),t[e]=i+im.x,t[e+1]=s+im.y}const{layout:om,rotate:rm}=sm,{getAngle:am}=nt,hm={x:-.5},lm={connect:hm,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},dm={connect:hm,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},cm={connect:hm,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},um={connect:hm,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},gm={offset:hm,path:[...cm.path],dashPath:[1,-2.5,0,2,-1,0]};rm(gm.path,180,{x:-1.5,y:0});const pm={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},_m={connect:{x:.5},path:[...pm.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},fm={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},mm={path:[...fm.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},ym=f.clone(fm),vm=f.clone(mm);rm(ym.path,45),rm(vm.path,45);const wm={angle:lm,"angle-side":dm,arrow:um,triangle:cm,"triangle-flip":gm,circle:_m,"circle-line":pm,square:mm,"square-line":fm,diamond:vm,"diamond-line":ym,mark:{offset:hm,path:[1,0,-2,2,0,2]}};function xm(t,e,i,s,n,o,r){let a,h;const{strokeCap:l,strokeJoin:d}=t.__;g(e)?e.type?(h=e.scale,a=wm[e.type]):a=e:a=wm[e];const{offset:c,connect:u,path:p,dashPath:_}=a;let f=u?u.x:0,m=c?c.x:0;const y=[...p];return r&&_&&y.push(..._),"none"!==l&&(f-=.5),c&&("round"===d&&c.roundJoin?m+=c.roundJoin:"bevel"===d&&c.bevelJoin&&(m+=c.bevelJoin)),h&&om(y,0,0,h,h),m&&om(y,m,0),om(y,s.x,s.y,n,n,am(i,s)),o.x=(f+m)*n,y}const{M:bm,L:km,C:Em,Q:Sm,Z:Bm,N:Tm,D:Rm,X:Cm,G:Om,F:Lm,O:Pm,P:Am,U:Dm}=Te,{copy:Mm,copyFrom:Fm,getDistancePoint:Im}=nt,Wm={},zm={},Nm={},Ym={},Hm={},Xm={list:wm,addArrows(t){const{startArrow:e,endArrow:i,strokeWidth:s,dashPattern:n,__pathForRender:o,cornerRadius:r}=t.__,a=!r;let h,l=0,d=o.length,c=0,u=e&&"none"!==e;for(;l<d;){switch(h=o[l],h){case bm:case km:(c<2||l+6>=d)&&(Fm(Hm,o[l+1],o[l+2]),!c&&u&&Mm(zm,Hm)),l+=3;break;case Em:(1===c||l+7>=d-3)&&Vm(o,Ym,Hm,l+3),l+=7;break;case Sm:(1===c||l+5>=d-3)&&Vm(o,Ym,Hm,l+1),l+=5;break;case Bm:return;case Tm:l+=5;break;case Rm:l+=9;break;case Cm:l+=6;break;case Om:l+=9;break;case Lm:l+=5;break;case Pm:l+=7;break;case Am:l+=4;break;case Dm:(1===c||l+6>=d-3)&&(Vm(o,Ym,Hm,l+1),l+6!==d&&(Hm.x-=(Hm.x-Ym.x)/10,Hm.y-=(Hm.y-Ym.y)/10)),l+=6}if(c++,1===c&&h!==bm)return;if(2===c&&u&&Mm(Nm,h===km?Hm:Ym),l===d){const r=t.__.__pathForRender=a?[...o]:o,d=t.__.__pathForArrow=[];if(u){const i=xm(t,e,Nm,zm,s,Wm,!!n);n?d.push(...i):r.push(...i),Wm.x&&(Im(zm,Nm,-Wm.x,!0),r[1]=Nm.x,r[2]=Nm.y)}if(i&&"none"!==i){const e=xm(t,i,Ym,Hm,s,Wm,!!n);if(n?d.push(...e):r.push(...e),Wm.x){let t;switch(Im(Hm,Ym,-Wm.x,!0),h){case km:t=l-3+1;break;case Em:t=l-7+5;break;case Sm:t=l-5+3;break;case Dm:t=l-6+3}t&&jm(r,Ym,t)}}}else Mm(Ym,Hm)}},register(t,e){this.list[t]=e},get(t){return this.list[t]}};function Vm(t,e,i,s){Fm(e,t[s],t[s+1]),Fm(i,t[s+2],t[s+3])}function jm(t,e,i){t[i]=e.x,t[i+1]=e.y}te.add("arrow"),Ml.addAttr("startArrow","none",Uf),Ml.addAttr("endArrow","none",Uf),Object.assign(Xh,Xm),Object.assign(Vh,{strokeArrow(t,e,i){e.__.dashPattern&&(i.beginPath(),e.__drawPathByData(i,e.__.__pathForArrow),i.dashPattern=null,i.stroke())}});let Um=class extends Ul{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}};le([Ao(class extends al{})],Um.prototype,"__",void 0),le([lo("x")],Um.prototype,"flow",void 0),Um=le([Xo()],Um);const Gm={},Km={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},qm={"top-left":"from",top:"from","top-right":"from",right:"center","bottom-right":"to",bottom:"to","bottom-left":"to",left:"center",center:"center","baseline-left":"to","baseline-center":"to","baseline-right":"to"};function Zm(t,e,i){const s=t.__,{contentBounds:n}=t.__layout;xt.toPoint(i,e,n,Gm),e.x=s.__autoWidth?n.x:Gm.x,e.y=s.__autoHeight?n.y:Gm.y}const{move:Jm}=nt;function $m(t,e,i,s,n,o){const{children:r}=t;let a,h,{x:l,start:d}=e,c=s;l+=i;for(let t=0,i=e.count;t<i;t++)a=r[o?d-t:d+t],a.__.inFlow&&0!==a.__.visible?(h=a.__flowBounds,"from"!==n&&(c=s+(e.height-h.height)/("center"===n?2:1)),Jm(a,l-h.x,c-h.y),l+=h.width+e.gap):i++}function Qm(t,e,i){const s="width"===i?"height":"width";t[i]=Math.max(t[i],e[i]),t[s]+=t.count?e[s]+t.gap:e[s],t.list.push(e),t.count++}const ty={};function ey(t,e){const{gap:i,flowAlign:s,flowWrap:n,__autoWidth:o,__autoHeight:r}=t.__,h=n&&(e?!o:!r);return g(i)?(ty.xGap=i.x||0,ty.yGap=i.y||0):ty.xGap=ty.yGap=c(i),ty.isAutoXGap=a(ty.xGap)&&!o,ty.isAutoYGap=a(ty.yGap)&&!r,ty.complex=h||"top-left"!==s||t.__hasGrow||ty.isAutoXGap||ty.isAutoYGap,ty.wrap=h,ty.complex&&(ty.isFitXGap="fit"===ty.xGap&&!o,ty.isFitYGap="fit"===ty.yGap&&!r,g(s)?(ty.contentAlign=s.content||"top-left",ty.rowXAlign=s.x||"from",ty.rowYAlign=s.y||"from"):(ty.contentAlign=s,ty.rowXAlign=Km[s],ty.rowYAlign=qm[s])),ty}function iy(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function sy(t,e,i,s){const{count:n}=t;n>1&&(i>t[e]||s)&&(t.gap=(i-t[e])/(n-1),t[e]=i)}function ny(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:oy}=P;function ry(t,e,i,s){let n,o,r,a=0,h=e.hasRangeSize&&[],{grow:l,start:d}=e;const c=(i-e.width)/l,{children:u}=t;if(!(c<=0)){e.width=i;for(let t=0,i=e.count;t<i;t++)n=u[s?d-t:d+t],n.__.inFlow&&0!==n.__.visible?(o=n.__widthGrow)&&(r=ay(n,n.__flowBounds,c*o),r?(a+=r,l-=o):h&&(n.__.widthRange?h.unshift(n):h.push(n))):i++;a&&function(t,e,i){let s,n,o,r;t.forEach(t=>{s=t.__widthGrow,n=e/i*s,r=ay(t,o=t.__flowBounds,o.width+n),e-=n-r,i-=s})}(h,a,l)}}function ay(t,e,i){const{widthRange:s,lockRatio:n}=t.__,o=s?oy(i,s):i,r=o/e.width;return t.scaleResize(r,n?r:1),e.width=o,i-o}const{within:hy}=P;function ly(t,e,i,s){let n,o,r,a=0,h=e.hasRangeSize&&[],{grow:l,start:d}=e;const c=(i-e.height)/l,{children:u}=t;if(!(c<=0)){e.height=i;for(let t=0,i=e.count;t<i;t++)n=u[s?d-t:d+t],n.__.inFlow&&0!==n.__.visible?(o=n.__heightGrow)&&(r=dy(n,n.__flowBounds,c*o),r?(a+=r,l-=o):h&&(n.__.heightRange?h.unshift(n):h.push(n))):i++;a&&function(t,e,i){let s,n,o,r;t.forEach(t=>{s=t.__heightGrow,n=e/i*s,r=dy(t,o=t.__flowBounds,o.height+n),e-=n-r,i-=s})}(h,a,l)}}function dy(t,e,i){const{heightRange:s,lockRatio:n}=t.__,o=s?hy(i,s):i,r=o/e.height;return t.scaleResize(n?r:1,r),e.height=o,i-o}const{move:cy}=nt;function uy(t,e){const i="width",{children:s,itemBox:n}=t,o=ey(t,!0),{complex:r,wrap:a,xGap:h,yGap:l,isAutoXGap:d,isFitXGap:c}=o;if(!s.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=d?0:h;let p,_,f,m,y,{x:v,y:w,width:x,height:b}=t.__layout.contentBounds;for(let o=0,h=s.length;o<h;o++)p=s[m=e?h-1-o:o],p.__.inFlow&&0!==p.__.visible&&(_=ny(p,n),r?(p.__flowBounds=_,y||(y=iy(m,g)),a&&y.count&&y.width+_.width>x&&(y.grow?ry(t,y,x,e):d&&sy(y,i,x,c),Qm(u,y,i),y=iy(m,g)),f=_.width,p.__widthGrow&&(y.grow+=p.__widthGrow,f=0,p.__.widthRange&&(y.hasRangeSize=!0)),p.__heightGrow&&dy(p,_,b),y.width+=y.count?f+g:f,y.height=Math.max(y.height,_.height),y.count++):(cy(p,v-_.x,w-_.y),v+=_.width+g));if(r&&y){const{isAutoYGap:s,isFitYGap:n,contentAlign:r,rowXAlign:h,rowYAlign:g}=o;y.count&&(y.grow?ry(t,y,x,e):d&&sy(y,i,x,c),a&&Qm(u,y,i)),a?(s?sy(u,"height",b,n):u.height+=(u.gap=l)*(u.list.length-1),function(t,e,i,s){Zm(t,e,i);const{list:n}=e;if(n.length>1&&(s||(s=Km[i]),"from"!==s)){let t;for(let i=0,o=n.length;i<o;i++)t=n[i],t.x=e.width-t.width,"center"===s&&(t.x/=2)}}(t,u,r,h),function(t,e,i,s){const{list:n}=e,o="reverse"===t.__.flowWrap;let r,{x:a,y:h}=e;for(let l=0,d=n.length;l<d;l++)r=n[o?d-1-l:l],$m(t,r,a,h,i,s),h+=r.height+e.gap}(t,u,g,e)):(Zm(t,y,r),$m(t,y,0,y.y,g,e))}}const{move:gy}=nt;function py(t,e,i,s,n,o){const{children:r}=t;let a,h,{y:l,start:d}=e,c=i;l+=s;for(let t=0,s=e.count;t<s;t++)a=r[o?d-t:d+t],a.__.inFlow&&0!==a.__.visible?(h=a.__flowBounds,"from"!==n&&(c=i+(e.width-h.width)/("center"===n?2:1)),gy(a,c-h.x,l-h.y),l+=h.height+e.gap):s++}const{move:_y}=nt;function fy(t,e){const i="height",{children:s,itemBox:n}=t,o=ey(t,!1),{complex:r,wrap:a,xGap:h,yGap:l,isAutoYGap:d,isFitYGap:c}=o;if(!s.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=d?0:l;let p,_,f,m,y,{x:v,y:w,width:x,height:b}=t.__layout.contentBounds;for(let o=0,h=s.length;o<h;o++)p=s[m=e?h-1-o:o],p.__.inFlow&&0!==p.__.visible&&(_=ny(p,n),r?(p.__flowBounds=_,y||(y=iy(m,g)),a&&y.count&&y.height+_.height>b&&(y.grow&&ly(t,y,b,e),d&&sy(y,i,b,c),Qm(u,y,i),y=iy(m,g)),f=_.height,p.__heightGrow&&(y.grow+=p.__heightGrow,f=0,p.__.heightRange&&(y.hasRangeSize=!0)),p.__widthGrow&&ay(p,_,x),y.height+=y.count?f+g:f,y.width=Math.max(y.width,_.width),y.count++):(_y(p,v-_.x,w-_.y),w+=_.height+g));if(r&&y){const{isAutoXGap:s,isFitXGap:n,contentAlign:r,rowXAlign:l,rowYAlign:g}=o;y.count&&(y.grow&&ly(t,y,b,e),d&&sy(y,i,b,c),a&&Qm(u,y,i)),a?(s?sy(u,"width",x,n):u.width+=(u.gap=h)*(u.list.length-1),function(t,e,i,s){Zm(t,e,i);const{list:n}=e;if(n.length>1&&(s||(s=qm[i]),"from"!==s)){let t;for(let i=0,o=n.length;i<o;i++)t=n[i],t.y=e.height-t.height,"center"===s&&(t.y/=2)}}(t,u,r,g),function(t,e,i,s){const{list:n}=e,o="reverse"===t.__.flowWrap;let r,{x:a,y:h}=e;for(let l=0,d=n.length;l<d;l++)r=n[o?d-1-l:l],py(t,r,a,h,i,s),a+=r.width+e.gap}(t,u,l,e)):(Zm(t,y,r),py(t,y,y.x,0,l,e))}}function my(t){return so(t,t=>({set(e){const i=l(e)?e:0;"autoWidth"===t?this.__widthGrow=i:this.__heightGrow=i,!i||this.parent&&this.parent.__hasGrow||this.waitParent(()=>{this.parent.__hasGrow=!0}),this.__setAttr(t,e)&&_o(this)}}))}te.add("flow","resize");const yy=Ul.prototype,{__updateBoxBounds:vy}=Fl.prototype;Ml.addAttr("flow",!1,lo),Ml.addAttr("gap",0,go),Ml.addAttr("flowAlign","top-left",go),Ml.addAttr("flowWrap",!1,go),Ml.addAttr("itemBox","box",go),Ml.addAttr("inFlow",!0,go),Ml.addAttr("autoWidth",void 0,my),Ml.addAttr("autoHeight",void 0,my),Ml.addAttr("autoBox",void 0,go);const{copyAndSpread:wy}=Wt;yy.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:uy(this);break;case"y":fy(this);break;case"x-reverse":uy(this,!0);break;case"y-reverse":fy(this,!0)}t&&(this.leafer.created=!0)},yy.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,i=e.contentBounds===e.boxBounds;t?(i&&e.shrinkContent(),wy(e.contentBounds,e.boxBounds,t,!0)):i||e.shrinkContentCancel()},yy.__updateBoxBounds=function(t){if(this.children.length&&!this.pathInputed){const e=this.__,{flow:i}=e;if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),i&&!t?this.__updateRectBoxBounds():vy.call(this);const{boxBounds:s}=this.__layout;e.__autoSize||(e.__autoWidth?(i||(s.width+=s.x,s.x=0),s.height=e.height,s.y=0):(i||(s.height+=s.y,s.y=0),s.width=e.width,s.x=0)),i&&t&&e.padding&&wy(s,s,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();i&&this.__updateContentBounds()}else this.__updateRectBoxBounds()};const{cos:xy,sin:by,pow:ky,sqrt:Ey,abs:Sy,ceil:By,floor:Ty,round:Ry,PI:Cy}=Math,Oy=5*Cy,Ly=1.70158,Py=2.5949095,Ay=7.5625,Dy=2.75;function My(t){return e=>ky(e,t)}function Fy(t){return e=>1-ky(1-e,t)}function Iy(t){return e=>e<.5?.5*ky(2*e,t):1-.5*ky(2-2*e,t)}function Wy(t){return t<1/Dy?Ay*t*t:t<2/Dy?Ay*(t-=1.5/Dy)*t+.75:t<2.5/Dy?Ay*(t-=2.25/Dy)*t+.9375:Ay*(t-=2.625/Dy)*t+.984375}function zy(t,e,i,s){const n={};return o=>{const r=~~(1e4*o),a=n[r];if(a)return a;let h,l,d,c=o;for(let e=0;e<8&&(h=1-c,d=Ny(c,t,i)-o,l=3*h*h*t+6*h*c*(i-t)+3*c*c*(1-i),!(Sy(l)<1e-6));e++)c-=d/l;return n[r]=Ny(c,e,s)}}function Ny(t,e,i){const s=1-t;return 3*s*s*t*e+3*s*t*t*i+t*t*t}const Yy={get(t){const{list:e}=Yy;return a(t)?e[t||"ease"]:g(t)?e[t.name].apply(e,u(t.value)?t.value:[t.value]):e.ease},register(t,e){Yy.list[t]=e},list:{linear:t=>t,ease:zy(.25,.1,.25,1),"ease-in":zy(.42,0,1,1),"ease-out":zy(0,0,.58,1),"ease-in-out":zy(.42,0,.58,1),"sine-in":t=>1-xy(t*Cy*.5),"sine-out":t=>by(t*Cy*.5),"sine-in-out":t=>.5*(1-xy(t*Cy)),"quad-in":My(2),"quad-out":Fy(2),"quad-in-out":Iy(2),"cubic-in":My(3),"cubic-out":Fy(3),"cubic-in-out":Iy(3),"quart-in":My(4),"quart-out":Fy(4),"quart-in-out":Iy(4),"quint-in":My(5),"quint-out":Fy(5),"quint-in-out":Iy(5),"expo-in":t=>t?ky(2,10*t-10):0,"expo-out":t=>1===t?1:1-ky(2,10*-t),"expo-in-out":t=>0===t||1===t?t:t<.5?.5*ky(2,2*t*10-10):.5*(2-ky(2,10-2*t*10)),"circ-in":t=>1-Ey(1-ky(t,2)),"circ-out":t=>Ey(1-ky(t-1,2)),"circ-in-out":t=>t<.5?.5*(1-Ey(1-ky(2*t,2))):.5*(Ey(1-ky(2-2*t,2))+1),"back-in":t=>((Ly+1)*t-Ly)*t*t,"back-out":t=>(t-=1)*t*((Ly+1)*t+Ly)+1,"back-in-out":t=>t<.5?(t*=2)*t*((Py+1)*t-Py)*.5:.5*((t=2*t-2)*t*((Py+1)*t+Py)+2),"elastic-in":t=>0===t||1===t?t:-ky(2,10*(t-1))*by((t-1.1)*Oy),"elastic-out":t=>0===t||1===t?t:ky(2,-10*t)*by((t-.1)*Oy)+1,"elastic-in-out":t=>0===t||1===t?t:t<.5?-ky(2,10*((t*=2)-1))*by((t-1.1)*Oy)*.5:ky(2,10*(1-(t*=2)))*by((t-1.1)*Oy)*.5+1,"bounce-in":t=>1-Wy(1-t),"bounce-out":Wy,"bounce-in-out":t=>t<.5?.5*(1-Wy(1-2*t)):.5*(1+Wy(2*t-1)),"cubic-bezier":zy,steps:function(t,e="floor"){return i=>("floor"===e?Ty(i*t):"ceil"===e?By(i*t):Ry(i*t))/t}}};function Hy(t){return(e,i)=>{Object.defineProperty(e,i,{get(){const e=this.config&&this.config[i];return void 0===e?t:e},set(t){this.config||(this.config={}),this.config[i]=t}})}}class Xy{}Xy.CREATED="created",Xy.PLAY="play",Xy.PAUSE="pause",Xy.STOP="stop",Xy.SEEK="seek",Xy.UPDATE="update",Xy.COMPLETED="completed";let Vy=class extends $r{get endingStyle(){return"from"===this.realEnding?this.fromStyle:this.toStyle}get started(){return!!this.requestAnimateTime}get completed(){return this.time>=this.duration&&!this.started}get frame(){return this.frames[this.nowIndex]}get frameTotalTime(){return this.frame.totalTime||this.frame.duration||0}get nowReverse(){return(this.mainReverse?1:0)+(this.frameReverse?1:0)==1}get realEnding(){let t;const{ending:e,reverse:i,swing:s,loop:n}=this;return"from"===e?t=0:"to"===e?t=1:(t=i?0:1,s&&n&&l(n)&&(t+=n-1)),t%2?"to":"from"}constructor(t,e,i,s){super(),e&&(e.keyframes?(i=e,e=e.keyframes):e.style&&(i=e,e=e.style)),this.init(t,e,i,s)}init(t,e,i,s){switch(this.target=t,(s||this.isTemp)&&(this.isTemp=s),typeof i){case"number":this.config={duration:i};break;case"string":this.config={easing:i};break;case"object":this.config=i,i.event&&(this.event=i.event)}this.keyframes=u(e)?e:e?[e]:[];const{easing:n,attrs:o}=this;this.easingFn=Yy.get(n),(o||this.attrsMap)&&(this.attrsMap=o?o.reduce((t,e)=>(t[e]=!0,t),{}):void 0),this.frames=[],this.create(),this.autoplay&&this.frames.length&&(this.timer=setTimeout(()=>{this.timer=0,this.play()},0))}emitType(t){this.emit(t,this),this.parent&&this.parent.onChildEvent(t,this)}play(){this.destroyed||(this.running=!0,this.started?this.timer||this.requestAnimate():(this.clearTimer(),this.start()),this.emitType(Xy.PLAY))}pause(){this.destroyed||(this.running=!1,this.clearTimer(),this.emitType(Xy.PAUSE))}stop(){this.destroyed||(this.complete(),this.emitType(Xy.STOP))}seek(t){this.destroyed||(g(t)&&(t=Hh.number(t,this.duration)),t&&(t/=this.speed),(!this.started||t<this.time)&&this.start(!0),this.time=t,this.animate(0,!0),this.clearTimer(()=>this.requestAnimate()),this.emitType(Xy.SEEK))}kill(t=!0,e){this.killStyle=e,this.destroy(t)}create(){const{target:t,frames:e,keyframes:i,config:s}=this,{length:n}=i,r=!(n>1)||this.join;let a,h,d,c,u,g=0,p=0;n>1&&(this.fromStyle={},this.toStyle={});for(let s=0;s<n;s++){if(h=i[s],c=h.style||h,a||(a=r?t:c),d={style:c,beforeStyle:{}},u=1,h.style){const{duration:t,autoDuration:e,delay:i,autoDelay:s,easing:n,swing:o,loop:r}=h;o&&(d.swing=l(o)?o:2,u=2*d.swing-1),r&&(d.loop=u=l(r)?r:2),t?(d.duration=t,g+=t*u,i&&(d.totalTime=t+i)):e&&(d.autoDuration=e,p+=e*u),i?(d.delay=i,g+=i*u):s&&(d.autoDelay=s,p+=s*u),n&&(d.easingFn=Yy.get(n))}if(!d.autoDuration&&o(d.duration)&&(n>1?s>0||r?p+=u:d.duration=0:d.duration=this.duration),n>1)this.setBefore(d,c,a);else{for(let e in c)d.beforeStyle[e]=t[e];this.fromStyle=d.beforeStyle,this.toStyle=d.style}a=c,e.push(d)}p?((this.duration<=g||!s||!s.duration)&&this.changeDuration(g+.2*p),this.allocateTime((this.duration-g)/p)):g&&this.changeDuration(g),this.emitType(Xy.CREATED)}changeDuration(t){const{config:e}=this;this.config=e?Object.assign(Object.assign({},e),{duration:t}):{duration:t}}setBefore(t,e,i){const{fromStyle:s,toStyle:n,target:r}=this;for(let a in e)o(s[a])&&(s[a]=n[a]=e===i?i[a]:r[a]),t.beforeStyle[a]=o(i[a])?n[a]:i[a],n[a]=e[a]}allocateTime(t){let e,{frames:i}=this,{length:s}=i;for(let n=0;n<s;n++)e=i[n],o(e.duration)&&(e.duration=e.autoDuration?t*e.autoDuration:t),e.totalTime||(e.autoDelay&&(e.delay=e.autoDelay*t),e.delay&&(e.totalTime=e.duration+e.delay))}requestAnimate(){this.requestAnimateTime=Date.now(),t.requestRender(this.animate.bind(this))}animate(t,e){if(!e){if(!this.running)return;this.time+=(Date.now()-this.requestAnimateTime)/1e3}const{duration:i}=this,s=this.time*this.speed;if(s<i){for(;s-this.playedTotalTime>this.frameTotalTime;)this.transition(1),this.mainReverse?this.reverseNextFrame():this.nextFrame();const t=this.nowReverse?0:this.frame.delay||0,e=s-this.playedTotalTime-t,i=this.frame.duration;if(e>i)this.transition(1);else if(e>=0){const t=i?e/i:1;this.transition(this.frame.easingFn?this.frame.easingFn(t):this.easingFn(t))}}else this.end();if(!e)if(s<i)this.requestAnimate();else{const{loop:t,loopDelay:e,swing:i}=this;if((!1!==t||i)&&(this.looped?this.looped++:this.looped=1,this.needLoop(this.looped,t,i)))return i&&(this.mainReverse=!this.mainReverse),void(e?this.timer=setTimeout(()=>{this.timer=0,this.begin()},e/this.speed*1e3):this.begin());this.complete()}}start(t){this.requestAnimateTime=1;const{reverse:e}=this;if((e||this.mainReverse)&&(this.mainReverse=e),this.looped&&(this.looped=0),t)this.begin(!0);else{const{delay:t}=this;t?this.timer=setTimeout(()=>{this.timer=0,this.begin()},t/this.speed*1e3):this.begin()}}begin(t){this.playedTotalTime=this.time=0,this.mainReverse?this.setTo():this.setFrom(),t||this.requestAnimate()}end(){this.mainReverse?this.setFrom():this.setTo()}complete(){this.requestAnimateTime=0,this.running=!1;const{endingStyle:t,killStyle:e}=this,i=e?{}:t;if(e)for(let s in t)s in e||(i[s]=t[s]);this.setStyle(i),this.clearTimer(),this.emitType(Xy.COMPLETED)}setFrom(){this.nowIndex=0,this.setStyle(this.fromStyle)}setTo(){this.nowIndex=this.frames.length-1,this.setStyle(this.toStyle)}nextFrame(){if(this.needLoopFrame())return this.increaseTime();this.nowIndex+1>=this.frames.length||(this.increaseTime(),this.nowIndex++)}reverseNextFrame(){if(this.needLoopFrame())return this.increaseTime();this.nowIndex-1<0||(this.increaseTime(),this.nowIndex--)}transition(t){const{style:e,beforeStyle:i}=this.frame,s=this.nowReverse?e:i,n=this.nowReverse?i:e;if(0===t)this.setStyle(s);else if(1===t)this.setStyle(n);else{const{attrsMap:i,target:o}=this;let{betweenStyle:r}=this.frame;r||(r=this.frame.betweenStyle={}),Jh.setBetweenStyle(r,s,n,e,t,o,i),this.setStyle(r)}this.emitType(Xy.UPDATE)}setStyle(t){const{target:e}=this;e&&t&&(this.style=t,e.__?e.set(t,!!this.isTemp&&"temp"):Object.assign(e,t))}increaseTime(){this.playedTotalTime+=this.frameTotalTime}needLoop(t,e,i){return!(this.needStopLoop(t,e)||this.needStopLoop(t,i,!0))}needStopLoop(t,e,i){return l(e)&&(!e||t>=(i?2*e-1:e))}needLoopFrame(){const{loop:t,swing:e}=this.frame;if(t||e){if(this.frameLooped?this.frameLooped++:this.frameLooped=1,e&&(this.frameReverse=!this.frameReverse),this.needLoop(this.frameLooped,t,e))return!0;this.frameLooped=this.frameReverse=void 0}return!1}clearTimer(t){this.timer&&(clearTimeout(this.timer),this.timer=0,t&&t())}destroy(t){this.destroyed||(super.destroy(),t&&!this.completed?this.stop():this.pause(),this.target=this.parent=this.config=this.frames=this.fromStyle=this.toStyle=this.style=this.killStyle=null,this.destroyed=!0)}};le([Hy("ease")],Vy.prototype,"easing",void 0),le([Hy(0)],Vy.prototype,"delay",void 0),le([Hy(.2)],Vy.prototype,"duration",void 0),le([Hy("auto")],Vy.prototype,"ending",void 0),le([Hy(!1)],Vy.prototype,"reverse",void 0),le([Hy(!1)],Vy.prototype,"swing",void 0),le([Hy(!1)],Vy.prototype,"loop",void 0),le([Hy(0)],Vy.prototype,"loopDelay",void 0),le([Hy(1)],Vy.prototype,"speed",void 0),le([Hy(!0)],Vy.prototype,"autoplay",void 0),le([Hy()],Vy.prototype,"join",void 0),le([Hy()],Vy.prototype,"attrs",void 0),Vy=le([Ho(la)],Vy);let jy=class extends Vy{get completed(){return this.list.every(t=>t.completed)}get endingStyle(){return this._endingStyle}constructor(t,e,i){super(t,null),this.list=[],this.updateList(e,i)}updateList(t,e){this.fromStyle={},this.toStyle={},this._endingStyle={},t||(t=this.list.filter(t=>{const{completed:e}=t;return e&&t.destroy(),!e})),this.list=t.map(t=>{const i=t.target?t:new Vy(this.target,t,e);return i.parent=this,Object.assign(this.fromStyle,i.fromStyle),Object.assign(this.toStyle,i.toStyle),Object.assign(this._endingStyle,i.endingStyle),i})}play(){this.each(t=>t.play()),this.emitType(Xy.PLAY)}pause(){this.each(t=>t.pause()),this.emitType(Xy.PAUSE)}stop(){this.each(t=>t.stop()),this.emitType(Xy.STOP)}seek(t){this.each(e=>e.seek(t)),this.emitType(Xy.SEEK)}kill(t,e){this.each(i=>i.kill(t,e)),this.destroy()}onChildEvent(t,e){switch(t){case Xy.COMPLETED:this.completed&&this.emitType(t);break;case Xy.UPDATE:this.emitType(t)}}each(t){this.list.forEach(t)}destroy(t){const{list:e}=this;e.length&&(this.each(e=>e.destroy(t)),e.length=0)}};jy=le([Ho(la)],jy);const Uy={transparent:"FFF0",aliceblue:"F0F8FF",antiquewhite:"FAEBD7",aqua:"0FF",aquamarine:"7FFFD4",azure:"F0FFFF",beige:"F5F5DC",bisque:"FFE4C4",black:"0",blanchedalmond:"FFEBCD",blue:"00F",blueviolet:"8A2BE2",brown:"A52A2A",burlywood:"DEB887",cadetblue:"5F9EA0",chartreuse:"7FFF00",chocolate:"D2691E",coral:"FF7F50",cornflowerblue:"6495ED",cornsilk:"FFF8DC",crimson:"DC143C",cyan:"0FF",darkblue:"00008B",darkcyan:"008B8B",darkgoldenrod:"B8860B",darkgray:"A9",darkgreen:"006400",darkgrey:"A9",darkkhaki:"BDB76B",darkmagenta:"8B008B",darkolivegreen:"556B2F",darkorange:"FF8C00",darkorchid:"9932CC",darkred:"8B0000",darksalmon:"E9967A",darkseagreen:"8FBC8F",darkslateblue:"483D8B",darkslategray:"2F4F4F",darkslategrey:"2F4F4F",darkturquoise:"00CED1",darkviolet:"9400D3",deeppink:"FF1493",deepskyblue:"00BFFF",dimgray:"69",dimgrey:"69",dodgerblue:"1E90FF",firebrick:"B22222",floralwhite:"FFFAF0",forestgreen:"228B22",fuchsia:"F0F",gainsboro:"DC",ghostwhite:"F8F8FF",gold:"FFD700",goldenrod:"DAA520",gray:"80",green:"008000",greenyellow:"ADFF2F",grey:"80",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",lightgray:"D3",lightgreen:"90EE90",lightgrey:"D3",lightpink:"FFB6C1",lightsalmon:"FFA07A",lightseagreen:"20B2AA",lightskyblue:"87CEFA",lightslategray:"789",lightslategrey:"789",lightsteelblue:"B0C4DE",lightyellow:"FFFFE0",lime:"00FF00",limegreen:"32CD32",linen:"FAF0E6",magenta:"FF00FF",maroon:"800000",mediumaquamarine:"66CDAA",mediumblue:"0000CD",mediumorchid:"BA55D3",mediumpurple:"9370DB",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:"639",red:"F00",rosybrown:"BC8F8F",royalblue:"4169E1",saddlebrown:"8B4513",salmon:"FA8072",sandybrown:"F4A460",seagreen:"2E8B57",seashell:"FFF5EE",sienna:"A0522D",silver:"C0",skyblue:"87CEEB",slateblue:"6A5ACD",slategray:"708090",slategrey:"708090",snow:"FFFAFA",springgreen:"00FF7F",steelblue:"4682B4",tan:"D2B48C",teal:"008080",thistle:"D8BFD8",tomato:"FF6347",turquoise:"40E0D0",violet:"EE82EE",wheat:"F5DEB3",white:"F",whitesmoke:"F5",yellow:"FF0",yellowgreen:"9ACD32"},Gy=/^rgb\((\d+),\s*(\d+),\s*(\d+)/i,Ky=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d*\.?\d+)/i,qy=/^hsl\((\d+),\s*(\d+)%\s*,\s*(\d+)%/i,Zy=/^hsla\((\d+),\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d*\.?\d+)/i,Jy=parseInt,$y=parseFloat,{round:Qy}=Math;let tv={},ev=0;function iv(t){let e,i,s,n=1;switch(t.length){case 9:e=Jy(t.slice(1,3),16),i=Jy(t.slice(3,5),16),s=Jy(t.slice(5,7),16),n=Jy(t.slice(7,9),16)/255;break;case 7:e=Jy(t.slice(1,3),16),i=Jy(t.slice(3,5),16),s=Jy(t.slice(5,7),16);break;case 5:e=Jy(t[1]+t[1],16),i=Jy(t[2]+t[2],16),s=Jy(t[3]+t[3],16),n=Jy(t[4]+t[4],16)/255;break;case 4:e=Jy(t[1]+t[1],16),i=Jy(t[2]+t[2],16),s=Jy(t[3]+t[3],16);break;case 3:e=i=s=Jy(t[1]+t[2],16);break;case 2:e=i=s=Jy(t[1]+t[1],16)}return{r:e,g:i,b:s,a:n}}const sv=1/6,nv=.5,ov=2/3,rv=1/3;function av(t,e,i){return i<0?i++:i>1&&i--,i<sv?t+6*(e-t)*i:i<nv?e:i<ov?t+(e-t)*(ov-i)*6:t}function hv(t,e,i,s=1){let n,o,r;if(t/=360,i/=100,0===(e/=100))n=o=r=i;else{let s=i<.5?i*(1+e):i+e-i*e,a=2*i-s;n=av(a,s,t+rv),o=av(a,s,t),r=av(a,s,t-rv)}return{r:Qy(255*n),g:Qy(255*o),b:Qy(255*r),a:s}}te.add("color"),Yh.object=function(t,e){let i,s=!o(e)&&e<1;if(a(t)){const e=tv[t];if(e)i=Object.assign({},e);else{switch(t[0]){case"#":i=iv(t);break;case"R":case"r":"("===t[4]&&Ky.test(t)?i=function(t){const e=Ky.exec(t);return{r:Jy(e[1]),g:Jy(e[2]),b:Jy(e[3]),a:$y(e[4])}}(t):"("===t[3]&&Gy.test(t)&&(i=function(t){const e=Gy.exec(t);return{r:Jy(e[1]),g:Jy(e[2]),b:Jy(e[3]),a:1}}(t));break;case"H":case"h":"("===t[4]&&Zy.test(t)?i=function(t){const e=Zy.exec(t);return hv($y(e[1]),$y(e[2]),$y(e[3]),$y(e[4]))}(t):"("===t[3]&&qy.test(t)&&(i=function(t){const e=qy.exec(t);return hv($y(e[1]),$y(e[2]),$y(e[3]),1)}(t))}if(!i){const e=Uy[t.toLowerCase()];e&&(i=iv("#"+e))}i&&(ev++,ev>1e4&&(tv={},ev=0),tv[t]=Object.assign({},i))}}else g(t)&&(o(t.a)&&(t.a=1),s&&(t=Object.assign({},t)),i=t);return i||(i={r:255,g:255,b:255,a:1}),s&&(i.a*=e),i};const{round:lv}=Math,{fourNumber:dv}=P,cv={fill:fv,stroke:fv,cornerRadius:(t,e,i)=>l(t)&&l(e)?pv(t,e,i):(t=dv(t),e=dv(e),t.map((t,s)=>pv(t,e[s],i))),text(t,e,i){if(a(t)&&a(e)){const s=t.length,n=e.length,o=pv(s,n,i,1);return s<n?e.substring(0,o):t.substring(0,o)}return l(t)||l(e)?P.float(pv(t,e,i),Math.max(gv(t),gv(e))):e},boxStyle(t,e,i,s){t||(t={}),e||(e={});const n=Object.assign(Object.assign({},t),e);return Jh.setBetweenStyle(n,t,e,n,i,s),n},shadow:mv,innerShadow:mv},uv={value:function(t,e,i){const s=l(t),n=l(e);return s&&n?t+(e-t)*i:n||s?pv(t,e,i):t},number:pv,color:_v,setBetweenStyle:function(t,e,i,s,n,o,r){let a,h,l;const{list:d,value:c}=Jh;for(let u in s)r&&!r[u]||(a=e[u],h=i[u],l=d[u]||c,a!==h&&(t[u]=l(a,h,n,o)))}};function gv(t){const e=String(t).split(".")[1];return e?e.length:0}function pv(t,e,i,s){t||(t=0),e||(e=0);const n=t+(e-t)*i;return s?lv(n):n}function _v(t,e,i){t=Yh.object(t),e=Yh.object(e);const s=pv(t.r,e.r,i,1)+","+pv(t.g,e.g,i,1)+","+pv(t.b,e.b,i,1),n=pv(t.a,e.a,i);return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}function fv(t,e,i){return a(t)&&a(e)?_v(t,e,i):e}function mv(t,e,i){return u(t)||u(e)?e:(e=e||{},{x:pv((t=t||{}).x,e.x,i),y:pv(t.y,e.y,i),blur:pv(t.blur,e.blur,i),spread:pv(t.spread,e.spread,i),color:_v(t.color||"#FFFFFF00",e.color||"#FFFFFF00",i),visible:e.visible,blendMode:e.blendMode,box:e.box||t.box})}te.add("animate","color"),Zh.canAnimate=!0,Object.assign(Jh.list,cv),Object.assign(Jh,uv);const yv=Ml.prototype;Ml.addAttr("animation",void 0,function(t){return so(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&(this.killAnimate("animation"),e&&this.animate(e,void 0,"animation"))}}))}),Ml.addAttr("animationOut",void 0,ro),Ml.addAttr("transition",!0,ro),Ml.addAttr("transitionOut",void 0,ro),yv.set=function(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))},yv.animate=function(t,e,i,s){if(o(t))return this.__animate;let n=u(t)&&!e&&i?new jy(this,t,s):new Vy(this,t,e,s);this.killAnimate(i,n.toStyle);const r=this.__animate;return r&&(n instanceof jy?n.list.unshift(r):n=new jy(this,[r,n])),this.__animate=n},yv.killAnimate=function(t,e){const i=this.__animate;if(i){let t=!1;if(e&&!i.completed){i instanceof jy&&i.updateList();const{toStyle:s}=i;for(let i in e)if(i in s){t=!0;break}}else t=!0;t&&(i.kill(!0,e),this.__animate=null)}},yv.__runAnimation=function(t,e){this.animate("in"===t?this.animation:this.animationOut,void 0,"animation"),e&&this.__animate.on(Xy.COMPLETED,e)};const vv=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],wv=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:xv}=Math,{getDerivative:bv}=ti,kv={getDistance(t,e,i,s,n,o,r,a,h=1){let l,d,c,u,g,p,_=0,f=h/2;for(let h=0;h<vv.length;h++)l=f*(1+vv[h]),d=f*(1-vv[h]),c=bv(l,t,i,n,r),u=bv(l,e,s,o,a),g=bv(d,t,i,n,r),p=bv(d,e,s,o,a),_+=wv[h]*(xv(c*c+u*u)+xv(g*g+p*p));return _*f},getRotation(t,e,i,s,n,o,r,a,h){const l=bv(t,e,s,o,a),d=bv(t,i,n,r,h);return Math.atan2(d,l)/D},getT(t,e,i,s,n,o,r,a,h,l,d=1){let c=0,u=1,g=t/e,p=d/e/3;if(g>=1)return 1;if(g<=0)return 0;for(;u-c>p;)Ev(i,s,n,o,r,a,h,l,g)<t?c=g:u=g,g=(c+u)/2;return g},cut(t,e,i,s,n,o,r,a,h,l){const d=1-e,c=d*i+e*n,u=d*s+e*o,g=d*n+e*r,p=d*o+e*a,_=d*c+e*g,f=d*u+e*p,m=d*_+e*(d*g+e*(d*r+e*h)),y=d*f+e*(d*p+e*(d*a+e*l));t.push(Te.C,c,u,_,f,m,y)}},{getDistance:Ev}=kv,{M:Sv,L:Bv,C:Tv,Z:Rv}=Te,Cv={},Ov={},Lv={transform(t,e){let i,s=0;const n=t.length;for(;s<n;)switch(i=t[s],i){case Sv:case Bv:Lv.transformPoints(t,e,s,1),s+=3;break;case Tv:Lv.transformPoints(t,e,s,3),s+=7;break;case Rv:s+=1}},transformPoints(t,e,i,s){for(let n=i+1,o=n+2*s;n<o;n+=2)Cv.x=t[n],Cv.y=t[n+1],G.toOuterPoint(e,Cv),t[n]=Cv.x,t[n+1]=Cv.y},getMotionPathData(t){let e,i,s,n,o=0,r=[],a=0,h=0,l=0;const d=t.length;for(;a<d;){switch(n=t[a],n){case Sv:case Bv:i=t[a+1],s=t[a+2],e=n===Bv&&a>0?nt.getDistanceFrom(h,l,i,s):0,h=i,l=s,a+=3;break;case Tv:i=t[a+5],s=t[a+6],e=kv.getDistance(h,l,t[a+1],t[a+2],t[a+3],t[a+4],i,s),h=i,l=s,a+=7;break;case Rv:a+=1;default:e=0}r.push(e),o+=e}return{total:o,segments:r,data:t}},getDistancePoint(t,e,i){const{segments:s,data:n}=t;e=Hh.number(e,t.total);let o,r,a,h,l,d,c,u,g,p=0,_={},f=0,m=0,y=0,v=0;const w=n.length;for(;f<w;){switch(h=n[f],h){case Sv:case Bv:if(r=n[f+1],a=n[f+2],o=s[m],p+o>=e||!t.total)return f||(y=r,v=a),Ov.x=y,Ov.y=v,_.x=r,_.y=a,nt.getDistancePoint(Ov,_,e-p,!0),_.rotation=nt.getAngle(Ov,_),_;y=r,v=a,f+=3;break;case Tv:if(r=n[f+5],a=n[f+6],o=s[m],p+o>=e)return l=n[f+1],d=n[f+2],c=n[f+3],u=n[f+4],g=kv.getT(e-p,o,y,v,l,d,c,u,r,a,i),ti.getPointAndSet(g,y,v,l,d,c,u,r,a,_),_.rotation=kv.getRotation(g,y,v,l,d,c,u,r,a),_;y=r,v=a,f+=7;break;case Rv:f+=1;default:o=0}m++,p+=o}return _},getDistancePath(t,e,i){const{segments:s,data:n}=t,o=[];e=Hh.number(e,t.total);let r,a,h,l,d,c,u,g,p,_=0,f={},m=0,y=0,v=0,w=0;const x=n.length;for(;m<x;){switch(l=n[m],l){case Sv:case Bv:if(a=n[m+1],h=n[m+2],r=s[y],_+r>=e||!t.total)return m||(v=a,w=h),Ov.x=v,Ov.y=w,f.x=a,f.y=h,nt.getDistancePoint(Ov,f,e-_,!0),o.push(l,f.x,f.y),o;v=a,w=h,m+=3,o.push(l,v,w);break;case Tv:if(d=n[m+1],c=n[m+2],u=n[m+3],g=n[m+4],a=n[m+5],h=n[m+6],r=s[y],_+r>=e)return p=kv.getT(e-_,r,v,w,d,c,u,g,a,h,i),kv.cut(o,p,v,w,d,c,u,g,a,h),o;v=a,w=h,m+=7,o.push(l,d,c,u,g,a,h);break;case Rv:m+=1,o.push(l);default:r=0}y++,_+=r}return o}};function Pv(t){return so(t,t=>({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!r(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}}))}te.add("motion-path"),Jh.register("motion",function(t,e,i,s){return g(t)&&(t=Hh.number(t,s.getMotionTotal())),g(e)&&(e=Hh.number(e,s.getMotionTotal())),Jh.number(t||0,e||0,i)}),Jh.register("motionRotation",function(t,e,i){return Jh.number(t,e,i)});const Av=Ml.prototype,{updateMatrix:Dv,updateAllMatrix:Mv}=ir,{updateBounds:Fv}=pr;function Iv(t){const{motion:e,leaferIsCreated:i}=t;if(!r(e)){if(i&&(t.leafer.created=!1),t.motionPath){const i=zv(t);i.total&&(t.__.__pathForRender=Lv.getDistancePath(i,e,t.motionPrecision))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(Mv(t),Fv(t,t)):Dv(t));i&&(t.leafer.created=!0)}}function Wv(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function zv(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=Lv.getMotionPathData(t.getPath(!0,!0))}function Nv(t,e){return so(t,t=>({set(i){this.__setAttr(t,i),this.leaferIsReady?e?Zh.setStyleName(this,e,i):Zh.set(this,i):this.__layout.stateStyleChanged=!0}}))}function Yv(t){return so(t,t=>({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}}))}function Hv(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function Xv(t,e){g(e)||(e=void 0),Uv(t,e,"in")}function Vv(t,e){const{normalStyle:i}=t;g(e)||(e=void 0),i&&(e||(e=i),Uv(t,e,"out"))}Ml.addAttr("motionPath",void 0,Pv),Ml.addAttr("motionPrecision",1,Pv),Ml.addAttr("motion",void 0,Pv),Ml.addAttr("motionRotation",!0,Pv),Av.getMotionPathData=function(){return zv(Wv(this))},Av.getMotionPoint=function(t){const e=Wv(this),i=zv(e);if(!i.total)return{};const s=Lv.getDistancePoint(i,t,e.motionPrecision);G.toOuterPoint(e.localTransform,s);const{motionRotation:n}=this;return!1===n?delete s.rotation:l(n)&&(s.rotation+=n),s},Av.getMotionTotal=function(){return this.getMotionPathData().total},Av.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent;for(let i=0;i<e.length;i++)t=e[i],r(t.motion)||t.__layout.matrixChanged||(t!==this&&t.__extraUpdate(),Iv(t))}else Iv(this)};const jv={};function Uv(t,e,i){const{normalStyle:s}=t;e||(e=jv),e.scale&&(P.assignScale(e,e.scale),delete e.scale),e!==jv&&Zh.canAnimate||(i=null);let n=!!i&&function(t,e,i){let s="in"===t?"transition":"transitionOut";"out"===t&&r(i[s])&&r(e[s])&&(s="transition");return r(e[s])?i[s]:e[s]}(i,e,t);const o=n?function(t,e){const i=qv(e,t),s=t.animate();s&&qv(i,t,s.fromStyle);return i}(t,e):void 0;Zh.canAnimate&&Gv(t)&&t.killAnimate("transition"),s&&t.set(s,"temp");const a=Gv(t);if(a){const{animation:s}=a;if(s){const o=t.animate(s,void 0,"animation",!0);Object.assign(a,o.endingStyle),"in"!==i||e.animation!==s?o.kill():n=!1,delete a.animation}t.normalStyle=Kv(a,t),t.set(a,"temp")}else t.normalStyle=void 0;if(n){const e=Kv(o,t);t.set(o,"temp"),t.animate([o,e],n,"transition",!0)}t.__layout.stateStyleChanged=!1}function Gv(t){let e;const i={},s=Hv(t),n=s?t.state||s.state:t.state,o=n&&t.states[n];o&&Zh.isState(n,t,s)&&(e=Zv(i,o));const r=i.selectedStyle||t.selectedStyle;r&&Zh.isSelected(t,s)&&(e=Zv(i,r));const a=i.placeholderStyle||t.placeholderStyle;if(a&&Zh.isPlacehold(t,s)&&(e=Zv(i,a)),Zh.isDisabled(t,s)){const s=i.disabledStyle||t.disabledStyle;s&&(e=Zv(i,s))}else{const n=i.focusStyle||t.focusStyle;n&&Zh.isFocus(t,s)&&(e=Zv(i,n));const o=i.hoverStyle||t.hoverStyle;o&&Zh.isHover(t,s)&&(e=Zv(i,o));const r=i.pressStyle||t.pressStyle;r&&Zh.isPress(t,s)&&(e=Zv(i,r))}return e?i:void 0}function Kv(t,e,i,s){const n=i?t:{},o=i||t;for(let t in o)s&&Zh.animateExcludes[t]||(n[t]=e[t]);return n}function qv(t,e,i){return Kv(t,e,i,!0)}function Zv(t,e){return Object.assign(t,e),!0}function Jv(t,e){const i=t[e];i&&Xv(t,i),t.button&&Qv(t.children,e)}function $v(t,e,i){i||(i=t.states[e]),Xv(t,i),t.button&&Qv(t.children,null,e)}function Qv(t,e,i){if(!t)return;let s,n;for(let r=0,a=t.length;r<a;r++){if(s=t[r],e){switch(n=!0,e){case"hoverStyle":Zh.isHover(s)&&(n=!1);break;case"pressStyle":Zh.isPress(s)&&(n=!1);break;case"focusStyle":Zh.isFocus(s)&&(n=!1)}n&&Jv(s,e)}else o(i)||$v(s,i);s.isBranch&&Qv(s.children,e,i)}}function tw(t,e){const i=t[e];i&&Vv(t,i),t.button&&iw(t.children,e)}function ew(t,e,i){Vv(t,i),t.button&&iw(t.children,null,e)}function iw(t,e,i){if(!t)return;let s;for(let n=0,r=t.length;n<r;n++)s=t[n],e?tw(s,e):o(i)||ew(s,i),s.isBranch&&iw(s.children,e,i)}function sw(t,e,i){let s;const n=e.leafer?e.leafer.interaction:null;if(n&&(s=n[t](e),!s&&i)){const o=Hv(e,i);o&&(s=n[t](o))}return s}function nw(t,e,i){let s=e[t];if(!s&&i){const n=Hv(e,i);n&&(s=n[t])}return s}te.add("state"),Zh.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,placeholder:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1,placeholderStyle:1},Zh.isState=function(t,e,i){return function(t,e,i){let s=e.states[t];if(!s&&i){const n=Hv(e,i);n&&(s=n.states[t])}return!!s}(t,e,i)},Zh.isSelected=function(t,e){return nw("selected",t,e)},Zh.isDisabled=function(t,e){return nw("disabled",t,e)},Zh.isFocus=function(t,e){return sw("isFocus",t,e)},Zh.isHover=function(t,e){return sw("isHover",t,e)},Zh.isPress=function(t,e){return sw("isPress",t,e)},Zh.isPlacehold=function(t,e){return t.__.__isPlacehold},Zh.isDrag=function(t,e){return sw("isDrag",t,e)},Zh.setStyleName=function(t,e,i){i?$v(t,e,t[e]):ew(t,e,t[e])},Zh.set=function(t,e){const i=t.states[e];i?$v(t,e,i):ew(t,e,i)},Zh.getStyle=Gv,Zh.updateStyle=Uv,Zh.updateEventStyle=function(t,e){switch(e){case Fd.ENTER:Jv(t,"hoverStyle");break;case Fd.LEAVE:tw(t,"hoverStyle");break;case Fd.DOWN:Jv(t,"pressStyle");break;case Fd.UP:tw(t,"pressStyle")}};const ow=Ml.prototype;Ml.addAttr("selected",!1,Nv,"selectedStyle"),Ml.addAttr("disabled",!1,Nv,"disabledStyle"),Ml.addAttr("states",{},Yv),Ml.addAttr("state","",Nv),Ml.addAttr("normalStyle",void 0,ro),Ml.addAttr("hoverStyle",void 0,Yv),Ml.addAttr("pressStyle",void 0,Yv),Ml.addAttr("focusStyle",void 0,Yv),Ml.addAttr("selectedStyle",void 0,Yv),Ml.addAttr("disabledStyle",void 0,Yv),Ml.addAttr("placeholderStyle",void 0,Yv),Ml.addAttr("button",!1,ro),ow.set=function(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))},ow.focus=function(t=!0){this.waitLeafer(()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?Jv(this,"focusStyle"):tw(this,"focusStyle")})},ow.updateState=function(){Zh.updateStyle(this,void 0,"in")};const rw=Rd.prototype,aw="text";to(rw,aw,Object.assign(Object.assign({},eo(rw,aw)),{set(t){const e=this,i=e.text;e.__setAttr(aw,t)&&(_o(e),e.placeholderStyle&&e.placeholder&&(""===i||""===t)&&(e.__layout.stateStyleChanged=!0))}}));class hw extends nl{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}let lw=class extends Ml{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t)}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let e=0;u(t)?t.forEach(t=>this.__loadRobot(t,e,e+=t.total||1)):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),!o(t))if(l(t))this.now=t;else if(g(t)){const e=u(t),i=e?t:t.keyframes;this.__action=e?void 0:t;const{length:s}=i;if(s>1){const t=this.now=i[0],e=i[i.length-1];this.play(),this.__runAction(t,e)}else s&&(this.now=i[0])}}__loadRobot(t,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=Gn.get(t);s.ready?this.__createFrames(s,t,e,i):s.load(()=>this.__createFrames(s,t,e,i))}__createFrames(t,e,i,s){const{offset:n,size:o,total:r}=e,{width:a,height:h}=o&&(l(o)?{width:o,height:o}:o)||(r>1?this:t);let d=n?n.x:0,c=n?n.y:0;for(let e=i;e<s;e++)this.robotFrames[e]={view:t.view,x:d,y:c,width:a,height:h},d+a>=t.width?(d=0,c+=h):d+=a;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new Dr(Dr.LOADED,{image:t}))}__runAction(t,e){let{FPS:i,loop:s,__action:n}=this;n&&(n.FPS&&(i=n.FPS),o(n.loop)||(s=n.loop)),this.__timer=setTimeout(()=>{if(this.running){if(this.now===e){if(!s)return this.stop();this.now=t}else this.now++;this.__updateRobotBounds()}this.__runAction(t,e)},1e3/i)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const e=this.__,i=t.width/e.pixelRatio,s=t.height/e.pixelRatio;e.width===i&&e.height===s||this.forceUpdate("width"),e.__naturalWidth=i,e.__naturalHeight=s}}__drawContent(t,e){const{nowFrame:i}=this,{width:s,height:n}=this.__;i&&t.drawImage(i.view,i.x,i.y,i.width,i.height,0,0,s,n)}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}};le([Ao(hw)],lw.prototype,"__",void 0),le([go()],lw.prototype,"robot",void 0),le([ro()],lw.prototype,"actions",void 0),le([ro("")],lw.prototype,"action",void 0),le([bo(0)],lw.prototype,"now",void 0),le([ro(12)],lw.prototype,"FPS",void 0),le([ro(!0)],lw.prototype,"loop",void 0),lw=le([Xo()],lw),te.add("robot");const{Yes:dw,NoAndSkip:cw,YesAndSkip:uw}=s,gw={},pw={},_w={};class fw{constructor(t){this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},(this.target=t)&&this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":gw.id=t.substring(1),t=gw;break;case".":pw.className=t.substring(1),t=pw;break;default:_w.tag=t,t=_w}case"object":if(o(t.id)){if(t.tag){const{tag:s}=t,n=u(s);return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?f.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className)}{const s=this.getById(t.id,e);return i?s:s?[s]:[]}case"function":return this.getByMethod(t,e,i,s)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&ir.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let r=0,a=t.length;r<a;r++){if(n=t[r],o=e(n,s),o===dw||o===uw){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<cw&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(Or.REMOVE,this.__onRemoveChild,this),this.target.on_(Pr.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){const{__eventIds:t}=this;t&&t.length&&(this.__removeListenEvents(),this.innerIdMap={},this.idMap={}),this.findLeaf=null}}const mw=Ml.prototype;function yw(e){return e.leafer?e.leafer.selector:t.selector||(t.selector=ee.selector())}mw.find=function(t,e){return yw(this).getBy(t,this,!1,e)},mw.findOne=function(t,e){return yw(this).getBy(t,this,!0,e)},te.add("find"),ee.finder=function(t){return new fw(t)};const{setPoint:vw,addPoint:ww,toBounds:xw}=gt;const bw={syncExport(e,i,s){let n;qh.running=!0;try{const r=zn.fileType(i),a=i.includes(".");s=zn.getExportOptions(s);const{toURL:h}=t,{download:l}=t.origin;if("json"===r)a&&l(h(JSON.stringify(e.toJSON(s.json)),"text"),i),n={data:!!a||e.toJSON(s.json)};else if("svg"===r)a&&l(h(e.toSVG(),"svg"),i),n={data:!!a||e.toSVG()};else{let r,a,h=1,l=1;const{worldTransform:d,isLeafer:c,leafer:u,isFrame:g}=e,{slice:p,clip:_,trim:f,screenshot:m,padding:y,onCanvas:v}=s,w=o(s.smooth)?!u||u.config.smooth:s.smooth,x=s.contextSettings||(u?u.config.contextSettings:void 0),b=c&&m&&o(s.fill)?e.fill:s.fill,k=zn.isOpaqueImage(i)||b,E=new ct;if(m)r=!0===m?c?u.canvas.bounds:e.worldRenderBounds:m;else{let t=s.relative||(c?"inner":"local");switch(h=d.scaleX,l=d.scaleY,t){case"inner":E.set(d);break;case"local":E.set(d).divide(e.localTransform),h/=e.scaleX,l/=e.scaleY;break;case"world":h=1,l=1;break;case"page":t=u||e;default:E.set(d).divide(e.getTransform(t));const i=t.worldTransform;h/=h/i.scaleX,l/=l/i.scaleY}r=e.getBounds("render",t)}const S={scaleX:1,scaleY:1};P.getScaleData(s.scale,s.size,r,S);let B=s.pixelRatio||1,{x:T,y:R,width:C,height:O}=new Ht(r).scale(S.scaleX,S.scaleY);_&&(T+=_.x,R+=_.y,C=_.width,O=_.height);const L={exporting:!0,matrix:E.scale(1/S.scaleX,1/S.scaleY).invert().translate(-T,-R).withScale(1/h*S.scaleX,1/l*S.scaleY)};let A,D=ee.canvas({width:Math.floor(C),height:Math.floor(O),pixelRatio:B,smooth:w,contextSettings:x});p&&(A=e,A.__worldOpacity=0,e=u||e,L.bounds=D.bounds),D.save();const M=g&&!o(b),F=e.get("fill");if(M&&(e.fill=""),t.render(e,D,L),M&&(e.fill=F),D.restore(),A&&A.__updateWorldOpacity(),f){a=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,r,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,o=(a-n)/e,r?ww(r,n,o):vw(r={},n,o)),a++;const h=new Ht;return r&&(xw(r,h),h.scale(1/t.pixelRatio).ceil()),h}(D);const t=D,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:B};D=ee.canvas(s),D.copyWorld(t,a,s),t.destroy()}if(y){const[t,e,i,s]=P.fourNumber(y),n=D,{width:o,height:r}=n;D=ee.canvas({width:o+s+e,height:r+t+i,pixelRatio:B}),D.copyWorld(n,n.bounds,{x:s,y:t,width:o,height:r}),n.destroy()}k&&D.fillWorld(D.bounds,b||"#FFFFFF","destination-over"),v&&v(D);n={data:"canvas"===i?D:D.export(i,s),width:D.pixelWidth,height:D.pixelHeight,renderBounds:r,trimBounds:a};const I=u&&u.app;I&&I.canvasManager&&I.canvasManager.clearRecycled()}}catch(t){n={data:"",error:t}}return qh.running=!1,n},export(e,i,s){return qh.running=!0,function(t){kw||(kw=new Xn);return new Promise(e=>{kw.add(()=>de(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(n=>new Promise(o=>{const r=()=>de(this,void 0,void 0,function*(){if(!jn.isComplete)return t.requestRender(r);const a=qh.syncExport(e,i,s);a.data instanceof Promise&&(a.data=yield a.data),n(a),o()});e.updateLayout(),Ew(e);const{leafer:a}=e;a?a.waitViewCompleted(r):r()}))}};let kw;function Ew(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>Ew(t))}const Sw=Ee.prototype,Bw=Gt.get("@leafer-in/export");Sw.export=function(t,e){const{quality:i,blob:s}=zn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},Sw.toBlob=function(e,i){return new Promise(s=>{t.origin.canvasToBolb(this.view,e,i).then(t=>{s(t)}).catch(t=>{Bw.error(t),s(null)})})},Sw.toDataURL=function(e,i){return t.origin.canvasToDataURL(this.view,e,i)},Sw.saveAs=function(e,i){return new Promise(s=>{t.origin.canvasSaveAs(this.view,e,i).then(()=>{s(!0)}).catch(t=>{Bw.error(t),s(!1)})})},te.add("export"),Object.assign(qh,bw),Ml.prototype.export=function(t,e){return qh.export(this,t,e)},Ml.prototype.syncExport=function(t,e){return qh.syncExport(this,t,e)},te.add("filter"),Object.assign(Kh,{list:{},register(t,e){Kh.list[t]=e},apply(t,e,i,s,n,o){let r;t.forEach(t=>{r=Kh.list[t.type],r&&r.apply(t,e,i,s,n,o)})},getSpread(t){let e,i=0;return t.forEach(t=>{e=Kh.list[t.type],e&&(i+=e.getSpread(t))}),i}}),te.add("bright"),Ml.addAttr("bright",!1,ko);export{xt as AlignHelper,Vy as Animate,Yy as AnimateEasing,Xy as AnimateEvent,jy as AnimateList,s as Answer,Ld as App,yt as AroundHelper,Gf as Arrow,jf as ArrowData,Vt as AutoBounds,ti as BezierHelper,Ht as Bounds,Mr as BoundsEvent,Wt as BoundsHelper,Ul as Box,al as BoxData,ch as Branch,pr as BranchHelper,Ca as BranchRender,kd as Canvas,wl as CanvasData,he as CanvasManager,Or as ChildEvent,Yh as ColorConvert,ee as Creator,dc as Cursor,f as DataHelper,Gt as Debug,_t as Direction4,ft as Direction9,Rl as DragBoundsHelper,zd as DragEvent,Qd as Dragger,Yd as DropEvent,t_ as EditBox,Up as EditDataHelper,Jp as EditPoint,Dp as EditSelect,Op as EditSelectHelper,R_ as EditTool,g_ as EditToolCreator,B_ as Editor,vp as EditorEvent,f_ as EditorGroupEvent,l_ as EditorHelper,x_ as EditorMoveEvent,k_ as EditorRotateEvent,b_ as EditorScaleEvent,E_ as EditorSkewEvent,Gh as Effect,Jl as Ellipse,ul as EllipseData,li as EllipseHelper,Cr as Event,re as EventCreator,$r as Eventer,qh as Export,zn as FileHelper,Kh as Filter,fw as Finder,Um as Flow,E as FourNumberHelper,Gl as Frame,ll as FrameData,Fl as Group,rl as GroupData,Vf as HTMLText,Xf as HTMLTextData,kv as HighBezierHelper,Lv as HighCurveHelper,cc as HitCanvasManager,xd as Image,vl as ImageData,Dr as ImageEvent,Gn as ImageManager,e as IncrementId,T_ as InnerEditor,__ as InnerEditorEvent,lc as InteractionBase,Gd as InteractionHelper,Ud as KeyEvent,Ad as Keyboard,Xr as LayoutEvent,Oh as Layouter,eh as Leaf,Ba as LeafBounds,dr as LeafBoundsHelper,y as LeafData,ca as LeafDataProxy,la as LeafEventer,ir as LeafHelper,Rr as LeafLayout,gh as LeafLevelList,uh as LeafList,ya as LeafMatrix,Ta as LeafRender,zl as Leafer,_h as LeaferCanvas,Ee as LeaferCanvasBase,hl as LeaferData,jr as LeaferEvent,Qn as LeaferImage,yf as LeaferTypeCreator,wd as Line,dl as LineData,D_ as LineEditTool,P as MathHelper,ct as Matrix,G as MatrixHelper,Hd as MoveEvent,xf as MultiTouchHelper,Nd as MyDragEvent,bd as MyImage,Id as MyPointerEvent,Ce as NeedConvertToCanvasCommandMap,D as OneRadian,M as PI2,F as PI_2,Vh as Paint,Uh as PaintGradient,jh as PaintImage,Cd as Path,Xh as PathArrow,Xm as PathArrowModule,Tn as PathBounds,fs as PathCommandDataHelper,Te as PathCommandMap,Gi as PathConvert,Dn as PathCorner,As as PathCreator,_l as PathData,Ks as PathDrawer,Se as PathHelper,sm as PathMatrixHelper,Ae as PathNumberCommandLengthMap,Pe as PathNumberCommandMap,K_ as PathScaler,Od as Pen,fl as PenData,Dh as Picker,t as Platform,te as Plugin,lt as Point,nt as PointHelper,Dd as PointerButton,Fd as PointerEvent,od as Polygon,gl as PolygonData,Pr as PropertyEvent,Nl as Rect,cl as RectData,De as RectHelper,Al as RectRender,Vr as RenderEvent,Ph as Renderer,Yr as ResizeEvent,jn as Resource,lw as Robot,hw as RobotData,Xd as RotateEvent,Jt as Run,Hf as ScrollBar,Cp as SelectArea,Mh as Selector,ud as Star,pl as StarData,Zh as State,jt as StringNumberMap,Rp as Stroker,Vd as SwipeEvent,Hn as TaskItem,Xn as TaskProcessor,Rd as Text,Nh as TextConvert,yl as TextData,pf as TextEditor,S_ as TransformTool,Pf as Transformer,Jh as Transition,gt as TwoPointBoundsHelper,Ml as UI,kl as UIBounds,se as UICreator,nl as UIData,Md as UIEvent,Ll as UIRender,Hh as UnitConvert,yr as WaitHelper,Hr as WatchEvent,vh as Watcher,Tf as WheelEventHelper,jd as ZoomEvent,_f as addViewport,ff as addViewportConfig,xo as affectRenderBoundsType,yo as affectStrokeBoundsType,Uf as arrowType,no as attr,lo as autoLayoutType,go as boundsType,Wn as canvasPatch,ke as canvasSizeAttrs,zh as createAttr,io as createDescriptor,Po as cursorType,Ao as dataProcessor,ro as dataType,so as decorateLeafAttr,Mo as defineDataProcessor,to as defineKey,oo as defineLeafAttr,ko as dimType,_o as doBoundsType,vo as doStrokeType,Fh as effectType,n as emptyData,Oo as eraserType,Ar as extraPropertyEventMap,W as getBoundsData,eo as getDescriptor,z as getMatrixData,I as getPointData,Lo as hitType,u as isArray,p as isData,_ as isEmptyData,h as isFinite,r as isNull,l as isNumber,g as isObject,a as isString,o as isUndefined,Do as layoutProcessor,Zr as leaferTransformAttrMap,Co as maskType,Pv as motionPathType,po as naturalBoundsType,Eo as opacityType,Mn as path,fo as pathInputType,mo as pathType,Fn as pen,ao as positionType,c_ as registerEditTool,u_ as registerInnerEditor,Xo as registerUI,Vo as registerUIEvent,Ih as resizeType,zo as rewrite,No as rewriteAble,uo as rotationType,nf as scaleResize,of as scaleResizeFontSize,hf as scaleResizeGroup,rf as scaleResizePath,af as scaleResizePoints,co as scaleType,ho as scrollType,Ro as sortType,Yv as stateStyleType,Nv as stateType,wo as strokeType,bo as surfaceType,Xt as tempBounds,ut as tempMatrix,dt as tempPoint,c as tryToNumber,mh as useCanvas,Ho as useModule,ph as version,So as visibleType,Wh as zoomLayerType};
2
2
  //# sourceMappingURL=worker.module.min.js.map