leafer-ui 1.0.1 → 1.0.3

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 +1 @@
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={},i={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=s;return e[t]?e[t]++:(e[t]=1,0)}},s=i,{round:r,pow:o,PI:n}=Math,a={within:(t,e,i)=>("object"==typeof e&&(i=e.max,e=e.min),void 0!==e&&t<e&&(t=e),void 0!==i&&t>i&&(t=i),t),fourNumber(t,e){let i;if(t instanceof Array)switch(t.length){case 4:i=void 0===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)),a.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=e?o(10,e):1e12;return-0===(t=r(t*i)/i)?0:t}},h=n/180,l=2*n,d=n/2;function c(){return{x:0,y:0}}function u(){return{x:0,y:0,width:0,height:0}}function _(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:p,cos:g,acos:f,sqrt:y}=Math,{float:m}=a,v={};function w(){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 x={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:w(),tempMatrix:{},set(t,e=1,i=0,s=0,r=1,o=0,n=0){t.a=e,t.b=i,t.c=s,t.d=r,t.e=o,t.f=n},get:_,getWorld:w,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},scaleOfOuter(t,e,i,s){b.toInnerPoint(t,e,v),b.scaleOfInner(t,v,i,s)},scaleOfInner(t,e,i,s=i){b.translateInner(t,e.x,e.y),b.scale(t,i,s),b.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:r,d:o}=t,n=g(e*=h),a=p(e);t.a=i*n-s*a,t.b=i*a+s*n,t.c=r*n-o*a,t.d=r*a+o*n},rotateOfOuter(t,e,i){b.toInnerPoint(t,e,v),b.rotateOfInner(t,v,i)},rotateOfInner(t,e,i){b.translateInner(t,e.x,e.y),b.rotate(t,i),b.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:r,c:o,d:n}=t;i&&(i*=h,t.a=s+o*i,t.b=r+n*i),e&&(e*=h,t.c=o+s*e,t.d=n+r*e)},skewOfOuter(t,e,i,s){b.toInnerPoint(t,e,v),b.skewOfInner(t,v,i,s)},skewOfInner(t,e,i,s=0){b.translateInner(t,e.x,e.y),b.skew(t,i,s),b.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:r,d:o,e:n,f:a}=t;t.a=e.a*i+e.b*r,t.b=e.a*s+e.b*o,t.c=e.c*i+e.d*r,t.d=e.c*s+e.d*o,t.e=e.e*i+e.f*r+n,t.f=e.e*s+e.f*o+a},multiplyParent(t,e,i,s,r,o){let{e:n,f:a}=t;if(o&&(n+=o.scrollX,a+=o.scrollY),i||(i=t),void 0===s&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:o,c:n,d:a}=t;i.a=s*e.a+o*e.c,i.b=s*e.b+o*e.d,i.c=n*e.a+a*e.c,i.d=n*e.b+a*e.d,r&&(i.scaleX=e.scaleX*r.scaleX,i.scaleY=e.scaleY*r.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,r&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=n*e.a+a*e.c+e.e,i.f=n*e.b+a*e.d+e.f},divide(t,e){b.multiply(t,b.tempInvert(e))},divideParent(t,e){b.multiplyParent(t,b.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=b;return b.copy(e,t),b.invert(e),e},invert(t){const{a:e,b:i,c:s,d:r,e:o,f:n}=t;if(i||s){const a=1/(e*r-i*s);t.a=r*a,t.b=-i*a,t.c=-s*a,t.d=e*a,t.e=-(o*r-n*s)*a,t.f=-(n*e-o*i)*a}else if(1===e&&1===r)t.e=-o,t.f=-n;else{const i=1/(e*r);t.a=r*i,t.d=e*i,t.e=-o*r*i,t.f=-n*e*i}},toOuterPoint(t,e,i,s){const{x:r,y:o}=e;i||(i=e),i.x=r*t.a+o*t.c,i.y=r*t.b+o*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:r,b:o,c:n,d:a}=t,h=1/(r*a-o*n),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*n)*h,i.y=(d*r-l*o)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*n)*h,i.y-=(s*r-e*o)*h}},setLayout(t,e,i,s,r){const{x:o,y:n,scaleX:a,scaleY:l}=e;if(void 0===r&&(r=e.rotation||e.skewX||e.skewY),r){const{rotation:i,skewX:s,skewY:r}=e,o=i*h,n=g(o),d=p(o);if(s||r){const e=s*h,i=r*h;t.a=(n+i*-d)*a,t.b=(d+i*n)*a,t.c=(e*n-d)*l,t.d=(n+e*d)*l}else t.a=n*a,t.b=d*a,t.c=-d*l,t.d=n*l}else t.a=a,t.b=0,t.c=0,t.d=l;t.e=o,t.f=n,(i=i||s)&&b.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:r,b:o,c:n,d:a,e:l,f:c}=t;let u,_,v,w,x,b=l,B=c;if(o||n){const t=r*a-o*n;if(n&&!s){u=y(r*r+o*o),_=t/u;const e=r/u;v=o>0?f(e):-f(e)}else{_=y(n*n+a*a),u=t/_;const e=n/_;v=d-(a>0?f(-e):-f(e))}const e=m(g(v)),i=p(v);u=m(u),_=m(_),w=e?m((n/_+i)/e/h,9):0,x=e?m((o/u-i)/e/h,9):0,v=m(v/h)}else u=r,_=a,v=w=x=0;return(e=i||e)&&(b+=e.x*r+e.y*n,B+=e.x*o+e.y*a,i||(b-=e.x,B-=e.y)),{x:b,y:B,scaleX:u,scaleY:_,rotation:v,skewX:w,skewY:x}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:r,c:o,d:n}=t;r||o?i=(s*n-r*o)/(e=y(s*s+r*r)):(e=s,i=n)}return s.scaleX=e,s.scaleY=i,s},reset(t){b.set(t)}},b=x,{toInnerPoint:B,toOuterPoint:R}=x,{sin:k,cos:C,abs:T,sqrt:E,atan2:P,min:O,PI:L}=Math,S={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=void 0===i?e:i},copy(t,e){t.x=e.x,t.y=e.y},copyFrom(t,e,i){t.x=e,t.y=i},move(t,e,i){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=M.defaultPoint);const s=C(e*=h),r=k(e),o=t.x-i.x,n=t.y-i.y;t.x=i.x+o*s-n*r,t.y=i.y+o*r+n*s},tempToInnerOf(t,e){const{tempPoint:i}=M;return A(i,t),B(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=M;return A(i,t),R(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=M;return A(i,t),M.toInnerRadiusPointOf(t,e,i),i},toInnerRadiusPointOf(t,e,i){i||(i=t),B(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){B(e,t,i)},toOuterOf(t,e,i){R(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)=>D(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const r=T(i-t),o=T(s-e);return E(r*r+o*o)},getMinDistanceFrom:(t,e,i,s,r,o)=>O(D(t,e,i,s),D(i,s,r,o)),getAngle:(t,e)=>W(t,e)/h,getRotation:(t,e,i,s)=>(s||(s=e),M.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/h),getRadianFrom(t,e,i,s,r,o,n,a){void 0===n&&(n=i,a=s);let h=P(e-s,t-i);const d=P(o-a,r-n)-h;return d<-L?d+l:d},getAtan2:(t,e)=>P(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s){const r=W(t,e);return(e=s?e:{}).x=t.x+C(r)*i,e.y=t.y+k(r)*i,e},reset(t){M.reset(t)}},M=S,{getDistanceFrom:D,copy:A,getAtan2:W}=M;class I{constructor(t,e){this.set(t,e)}set(t,e){return"object"==typeof t?S.copy(this,t):S.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new I(this)}move(t,e){return S.move(this,t,e),this}scale(t,e){return S.scale(this,t,e),this}scaleOf(t,e,i){return S.scaleOf(this,t,e,i),this}rotate(t,e){return S.rotate(this,t,e),this}rotateOf(t,e){return S.rotate(this,e,t),this}getRotation(t,e,i){return S.getRotation(this,t,e,i)}toInnerOf(t,e){return S.toInnerOf(this,t,e),this}toOuterOf(t,e){return S.toOuterOf(this,t,e),this}getCenter(t){return new I(S.getCenter(this,t))}getDistance(t){return S.getDistance(this,t)}getDistancePoint(t,e,i){return new I(S.getDistancePoint(this,t,e,i))}getAngle(t){return S.getAngle(this,t)}getAtan2(t){return S.getAtan2(this,t)}reset(){return S.reset(this),this}}const F=new I;class z{constructor(t,e,i,s,r,o){this.set(t,e,i,s,r,o)}set(t,e,i,s,r,o){return"object"==typeof t?x.copy(this,t):x.set(this,t,e,i,s,r,o),this}setWith(t){return x.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:i,d:s,e:r,f:o}=this;return{a:t,b:e,c:i,d:s,e:r,f:o}}clone(){return new z(this)}translate(t,e){return x.translate(this,t,e),this}translateInner(t,e){return x.translateInner(this,t,e),this}scale(t,e){return x.scale(this,t,e),this}scaleWith(t,e){return x.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}scaleOfOuter(t,e,i){return x.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return x.scaleOfInner(this,t,e,i),this}rotate(t){return x.rotate(this,t),this}rotateOfOuter(t,e){return x.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return x.rotateOfInner(this,t,e),this}skew(t,e){return x.skew(this,t,e),this}skewOfOuter(t,e,i){return x.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return x.skewOfInner(this,t,e,i),this}multiply(t){return x.multiply(this,t),this}multiplyParent(t){return x.multiplyParent(this,t),this}divide(t){return x.divide(this,t),this}divideParent(t){return x.divideParent(this,t),this}invert(){return x.invert(this),this}invertWith(){return x.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){x.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){x.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return x.setLayout(this,t,e,i),this}getLayout(t,e,i){return x.getLayout(this,t,e,i)}withScale(t,e){return x.withScale(this,t,e)}reset(){x.reset(this)}}const N=new z,Y={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,r){X(t,e,i),X(t,e+s,i+r)},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:X}=Y,{tempPointBounds:j,setPoint:H,addPoint:V,toBounds:U}=Y,{toOuterPoint:G}=x,{float:K,fourNumber:q}=a,{floor:Z,ceil:Q}=Math;let J,$,tt,et;const it={},st={},rt={tempBounds:{},set(t,e=0,i=0,s=0,r=0){t.x=e,t.y=i,t.width=s,t.height=r},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,i,s){if(i instanceof Array){const r=q(i);s?ot.set(t,e.x+r[3],e.y+r[0],e.width-r[1]-r[3],e.height-r[2]-r[0]):ot.set(t,e.x-r[3],e.y-r[0],e.width+r[1]+r[3],e.height+r[2]+r[0])}else s&&(i=-i),ot.set(t,e.x-i,e.y-i,e.width+2*i,e.height+2*i)},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},getByMove:(t,e,i)=>(t=Object.assign({},t),ot.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?at(e,t):e=t,i?(e.offsetX=-(ot.maxX(i)-t.x),e.offsetY=-(ot.maxY(i)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),ot.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e){S.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){S.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(ot.copy(ot.tempBounds,t),ot.toOuterOf(ot.tempBounds,e),ot.tempBounds),getOuterOf:(t,e)=>(t=Object.assign({},t),ot.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:r}=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),r>0?(i.height=t.height*r,i.y=e.f+t.y*r):(i.height=t.height*-r,i.y=e.f+t.y*r-i.height)}else it.x=t.x,it.y=t.y,G(e,it,st),H(j,st.x,st.y),it.x=t.x+t.width,G(e,it,st),V(j,st.x,st.y),it.y=t.y+t.height,G(e,it,st),V(j,st.x,st.y),it.x=t.x,G(e,it,st),V(j,st.x,st.y),U(j,i)},toInnerOf(t,e,i){i||(i=t),ot.move(i,-e.e,-e.f),ot.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Math.min(t.width/e.width,t.height/e.height));return new z(s,0,0,s,-e.x*s,-e.y*s)},getSpread(t,e){const i={};return ot.copyAndSpread(i,t,e),i},spread(t,e){ot.copyAndSpread(t,t,e)},shrink(t,e){ot.copyAndSpread(t,t,e,!0)},ceil(t){const{x:e,y:i}=t;t.x=Z(t.x),t.y=Z(t.y),t.width=e>t.x?Q(t.width+e-t.x):Q(t.width),t.height=i>t.y?Q(t.height+i-t.y):Q(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=K(t.x,e),t.y=K(t.y,e),t.width=K(t.width,e),t.height=K(t.height,e)},add(t,e,i){J=t.x+t.width,$=t.y+t.height,tt=e.x,et=e.y,i||(tt+=e.width,et+=e.height),J=J>tt?J:tt,$=$>et?$:et,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=J-t.x,t.height=$-t.y},addList(t,e){ot.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){ot.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){ot.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let r,o=!0;for(let n=0,a=e.length;n<a;n++)r=i?i(e[n]):e[n],r&&(r.width||r.height)&&(o?(o=!1,s||at(t,r)):nt(t,r));o&&ot.reset(t)},setPoints(t,e){e.forEach(((t,e)=>0===e?H(j,t.x,t.y):V(j,t.x,t.y))),U(j,t)},setPoint(t,e){ot.set(t,e.x,e.y)},addPoint(t,e){nt(t,e,!0)},getPoints(t){const{x:e,y:i,width:s,height:r}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+r},{x:e,y:i+r}]},hitRadiusPoint:(t,e,i)=>(i&&(e=S.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=S.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=ot.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=ot.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=ot.tempToOuterOf(e,i)),!ot.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:r,width:o,height:n}=e;return J=s+o,$=r+n,tt=t.x+t.width,et=t.y+t.height,s=s>t.x?s:t.x,r=r>t.y?r:t.y,J=J<tt?J:tt,$=$<et?$:et,o=J-s,n=$-r,{x:s,y:r,width:o,height:n}},intersect(t,e,i){ot.copy(t,ot.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){ot.set(t)}},ot=rt,{add:nt,copy:at}=ot;class ht{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"object"==typeof 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 ht(this)}move(t,e){return rt.move(this,t,e),this}scale(t,e){return rt.scale(this,t,e),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)}spread(t){return rt.spread(this,t),this}shrink(t){return rt.shrink(this,t),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 ht(rt.getIntersectData(this,t,e))}isSame(t){return rt.isSame(this,t)}isEmpty(){return rt.isEmpty(this)}reset(){rt.reset(this)}}const lt=new ht;class dt{constructor(t,e,i,s,r,o){"object"==typeof t?this.copy(t):this.set(t,e,i,s,r,o)}set(t=0,e=0,i=0,s=0,r=0,o=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=r,this.height=o}copy(t){const{top:e,right:i,bottom:s,left:r,width:o,height:n}=t;this.set(e,i,s,r,o,n)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:r,width:o,height:n}=this;return new ht(r,e,o||t.width-r-i,n||t.height-e-s)}}var ct,ut;!function(t){t[t.top=0]="top",t[t.right=1]="right",t[t.bottom=2]="bottom",t[t.left=3]="left"}(ct||(ct={})),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"}(ut||(ut={}));const _t=[{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}];_t.forEach((t=>t.type="percent"));const pt={directionData:_t,tempPoint:{},get:gt,toPoint(t,e,i,s,r){i||(i={});const o=gt(t);i.x=o.x,i.y=o.y,"percent"===o.type&&(i.x*=e.width,i.y*=e.height,r&&(i.x-=r.x,i.y-=r.y,o.x&&(i.x-=1===o.x?r.width:.5===o.x?o.x*r.width:0),o.y&&(i.y-=1===o.y?r.height:.5===o.y?o.y*r.height:0))),s||(i.x+=e.x,i.y+=e.y)}};function gt(t){return"string"==typeof t?_t[ut[t]]:t}const{toPoint:ft}=pt,yt={toPoint(t,e,i,s,r){ft(t,i,s,r,e)}},mt={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};class vt{constructor(t){this.repeatMap={},this.name=t}static get(t){return new vt(t)}static set filter(t){this.filterList=wt(t)}static set exclude(t){this.excludeList=wt(t)}log(...t){if(xt.enable){if(xt.filterList.length&&xt.filterList.every((t=>t!==this.name)))return;if(xt.excludeList.length&&xt.excludeList.some((t=>t===this.name)))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){xt.enable&&this.warn(...t)}warn(...t){xt.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?"string"==typeof t&&(t=[t]):t=[],t}vt.filterList=[],vt.excludeList=[],vt.showWarn=!0;const xt=vt,bt=vt.get("RunTime"),Bt={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const s=i.create(i.RUNTIME);return Rt.currentId=Rt.idMap[s]=e?performance.now():Date.now(),Rt.currentName=Rt.nameMap[s]=t,Rt.nameToIdMap[t]=s,s},end(t,e){const i=Rt.idMap[t],s=Rt.nameMap[t],r=e?(performance.now()-i)/1e3:Date.now()-i;Rt.idMap[t]=Rt.nameMap[t]=Rt.nameToIdMap[s]=void 0,bt.log(s,r,"ms")},endOfName(t,e){const i=Rt.nameToIdMap[t];void 0!==i&&Rt.end(i,e)}},Rt=Bt,kt=vt.get("UICreator"),Ct={list:{},register(t){const{__tag:e}=t.prototype;Tt[e]?kt.repeat(e):Tt[e]=t},get(t,e,i,s,r,o){const n=new Tt[t](e);return void 0!==i&&(n.x=i,s&&(n.y=s),r&&(n.width=r),o&&(n.height=o)),n}},{list:Tt}=Ct,Et=vt.get("EventCreator"),Pt={nameList:{},register(t){let e;Object.keys(t).forEach((i=>{e=t[i],"string"==typeof e&&(Ot[e]?Et.repeat(e):Ot[e]=t)}))},changeName(t,e){const i=Ot[t];if(i){const s=Object.keys(i).find((e=>i[e]===t));s&&(i[s]=e,Ot[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new Ot[t](...e)},{nameList:Ot}=Pt;class Lt{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let i;const{list:s}=this;for(let e=0,r=s.length;e<r;e++)if(i=s[e],i.recycled&&i.isSameSize(t))return i.recycled=!1,i.manager||(i.manager=this),i;const r=e.canvas(t);return this.add(r),r}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()}}const St={default:(t,e)=>(Mt(e,t),Mt(t,e),t),assign(t,e){let i;Object.keys(e).forEach((s=>{var r;i=e[s],(null==i?void 0:i.constructor)===Object&&(null===(r=t[s])||void 0===r?void 0:r.constructor)===Object?Mt(t[s],e[s]):t[s]=e[s]}))},copyAttrs:(t,e,i)=>(i.forEach((i=>{void 0!==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}},{assign:Mt}=St;class Dt{get __useNaturalRatio(){return!0}get __isLinePath(){return this.path&&6===this.path.length}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(void 0!==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]=void 0===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(void 0!==e)return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&void 0!==this.__input[t]&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(t instanceof Array)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 r in this)if("_"!==r[0]&&(t=this["_"+r],void 0!==t)){if("path"===r&&!this.__pathInputed)continue;e=s?s[r]:void 0,i[r]=void 0===e?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:r,e:o,f:n}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:r,e:o,f:n}}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||e.__hasEraser||t.eraser?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}}var At;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(At||(At={}));const Wt={};function It(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n}function Ft(t,e,i,s){return new(i||(i=Promise))((function(r,o){function n(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){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,a)}h((s=s.apply(t,e||[])).next())}))}function zt(t){return(e,i)=>{t||(t=i),Object.defineProperty(e,i,{get(){return this.context[t]},set(e){this.context[t]=e}})}}"function"==typeof SuppressedError&&SuppressedError;const Nt=[];function Yt(){return(t,e)=>{Nt.push(e)}}const Xt=[];let jt=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||Xt)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;Nt.forEach((e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))})),this.textBaseline="alphabetic"}setTransform(t,e,i,s,r,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,r,o){"object"==typeof t?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,r,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,r,o,n,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/r*h;r+=i,i=0,n+=t,h-=t}this.context.drawImage(t,e,i,s,r,o,n,a,h);break;case 5:this.context.drawImage(t,e,i,s,r);break;case 3:this.context.drawImage(t,e,i)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,i,s,r,o){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,r,o){}arcTo(t,e,i,s,r){}ellipse(t,e,i,s,r,o,n,a){}rect(t,e,i,s){}roundRect(t,e,i,s,r){}createConicGradient(t,e,i){}createLinearGradient(t,e,i,s){}createPattern(t,e){}createRadialGradient(t,e,i,s,r,o){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}};It([zt("imageSmoothingEnabled")],jt.prototype,"smooth",void 0),It([zt("imageSmoothingQuality")],jt.prototype,"smoothLevel",void 0),It([zt("globalAlpha")],jt.prototype,"opacity",void 0),It([zt()],jt.prototype,"fillStyle",void 0),It([zt()],jt.prototype,"strokeStyle",void 0),It([zt("lineWidth")],jt.prototype,"strokeWidth",void 0),It([zt("lineCap")],jt.prototype,"strokeCap",void 0),It([zt("lineJoin")],jt.prototype,"strokeJoin",void 0),It([zt("lineDashOffset")],jt.prototype,"dashOffset",void 0),It([zt()],jt.prototype,"miterLimit",void 0),It([zt()],jt.prototype,"shadowBlur",void 0),It([zt()],jt.prototype,"shadowColor",void 0),It([zt()],jt.prototype,"shadowOffsetX",void 0),It([zt()],jt.prototype,"shadowOffsetY",void 0),It([zt()],jt.prototype,"filter",void 0),It([zt()],jt.prototype,"font",void 0),It([zt()],jt.prototype,"fontKerning",void 0),It([zt()],jt.prototype,"fontStretch",void 0),It([zt()],jt.prototype,"fontVariantCaps",void 0),It([zt()],jt.prototype,"textAlign",void 0),It([zt()],jt.prototype,"textBaseline",void 0),It([zt()],jt.prototype,"textRendering",void 0),It([zt()],jt.prototype,"wordSpacing",void 0),It([zt()],jt.prototype,"letterSpacing",void 0),It([zt()],jt.prototype,"direction",void 0),It([Yt()],jt.prototype,"setTransform",null),It([Yt()],jt.prototype,"resetTransform",null),It([Yt()],jt.prototype,"getTransform",null),It([Yt()],jt.prototype,"save",null),It([Yt()],jt.prototype,"restore",null),It([Yt()],jt.prototype,"translate",null),It([Yt()],jt.prototype,"scale",null),It([Yt()],jt.prototype,"rotate",null),It([Yt()],jt.prototype,"fill",null),It([Yt()],jt.prototype,"stroke",null),It([Yt()],jt.prototype,"clip",null),It([Yt()],jt.prototype,"fillRect",null),It([Yt()],jt.prototype,"strokeRect",null),It([Yt()],jt.prototype,"clearRect",null),It([Yt()],jt.prototype,"beginPath",null),It([Yt()],jt.prototype,"moveTo",null),It([Yt()],jt.prototype,"lineTo",null),It([Yt()],jt.prototype,"bezierCurveTo",null),It([Yt()],jt.prototype,"quadraticCurveTo",null),It([Yt()],jt.prototype,"closePath",null),It([Yt()],jt.prototype,"arc",null),It([Yt()],jt.prototype,"arcTo",null),It([Yt()],jt.prototype,"ellipse",null),It([Yt()],jt.prototype,"rect",null),It([Yt()],jt.prototype,"roundRect",null),It([Yt()],jt.prototype,"createConicGradient",null),It([Yt()],jt.prototype,"createLinearGradient",null),It([Yt()],jt.prototype,"createPattern",null),It([Yt()],jt.prototype,"createRadialGradient",null),It([Yt()],jt.prototype,"fillText",null),It([Yt()],jt.prototype,"measureText",null),It([Yt()],jt.prototype,"strokeText",null);const{copy:Ht}=x,Vt={width:1,height:1,pixelRatio:1},Ut=["width","height","pixelRatio"];class Gt extends jt{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}get pixelHeight(){return this.height*this.pixelRatio}get allowBackgroundColor(){return this.view&&this.parentView}constructor(e,s){super(),this.size={},this.worldTransform={},e||(e=Vt),e.pixelRatio||(e.pixelRatio=t.devicePixelRatio),this.manager=s,this.innerId=i.create(i.CNAVAS);const{width:r,height:o,pixelRatio:n}=e;this.autoLayout=!r||!o,this.size.pixelRatio=n,this.config=e,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){if(this.isSameSize(t))return;let e;this.context&&!this.unreal&&this.width&&(e=this.getSameCanvas(),e.copyWorld(this)),St.copyAttrs(this.size,t,Ut),this.size.pixelRatio||(this.size.pixelRatio=1),this.bounds=new ht(0,0,this.width,this.height),this.context&&!this.unreal&&(this.updateViewSize(),this.smooth=this.config.smooth),this.updateClientBounds(),this.context&&!this.unreal&&e&&(this.clearWorld(e.bounds),this.copyWorld(e),e.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}=this,s=this.worldTransform;if(e){const{a:r,b:o,c:n,d:a,e:h,f:l}=e;this.setTransform(s.a=(t.a*r+t.b*n)*i,s.b=(t.a*o+t.b*a)*i,s.c=(t.c*r+t.d*n)*i,s.d=(t.c*o+t.d*a)*i,s.e=(t.e*r+t.f*n+h)*i,s.f=(t.e*o+t.f*a+l)*i)}else this.setTransform(s.a=t.a*i,s.b=t.b*i,s.c=t.c*i,s.d=t.d*i,s.e=t.e*i,s.f=t.f*i)}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){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),i&&this.setStrokeOptions(i)}setStrokeOptions(t){this.strokeCap="none"===t.strokeCap?"butt":t.strokeCap,this.strokeJoin=t.strokeJoin,this.dashPattern=t.dashPattern,this.dashOffset=t.dashOffset,this.miterLimit=t.miterLimit}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:r}=this;this.shadowOffsetX=t*r,this.shadowOffsetY=e*r,this.shadowBlur=i*r,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s){if(s&&(this.blendMode=s),e){const{pixelRatio:s}=this;i||(i=e),this.drawImage(t.view,e.x*s,e.y*s,e.width*s,e.height*s,i.x*s,i.y*s,i.width*s,i.height*s)}else this.drawImage(t.view,0,0);s&&(this.blendMode="source-over")}copyWorldToInner(t,e,i,s){if(s&&(this.blendMode=s),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,rt.tempToOuterOf(i,e)),this.restore();else{const{pixelRatio:s}=this;this.drawImage(t.view,e.x*s,e.y*s,e.width*s,e.height*s,i.x,i.y,i.width,i.height)}s&&(this.blendMode="source-over")}copyWorldByReset(t,e,i,s,r){this.resetTransform(),this.copyWorld(t,e,i,s),r||this.useWorldTransform()}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){i&&(this.blendMode=i),this.fillStyle=e,lt.set(t).scale(this.pixelRatio),this.fillRect(lt.x,lt.y,lt.width,lt.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i){i&&(this.blendMode=i),this.strokeStyle=e,lt.set(t).scale(this.pixelRatio),this.strokeRect(lt.x,lt.y,lt.width,lt.height),i&&(this.blendMode="source-over")}clearWorld(t,e){lt.set(t).scale(this.pixelRatio),e&&lt.ceil(),this.clearRect(lt.x,lt.y,lt.width,lt.height)}clipWorld(t,e){this.beginPath(),lt.set(t).scale(this.pixelRatio),e&&lt.ceil(),this.rect(lt.x,lt.y,lt.width,lt.height),this.clip()}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}isSameSize(t){return this.width===t.width&&this.height===t.height&&this.pixelRatio===t.pixelRatio}getSameCanvas(t,i){const s=this.manager?this.manager.get(this.size):e.canvas(Object.assign({},this.size));return s.save(),t&&(Ht(s.worldTransform,this.worldTransform),s.useWorldTransform()),i&&(s.smooth=this.smooth),s}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t,!0):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const Kt={creator:{},parse(t,e){},convertToCanvasData(t,e){}},qt={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Zt=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},qt),Qt={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},Jt={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},$t=Object.assign(Object.assign({},Jt),qt),te=Zt,ee={};for(let t in te)ee[te[t]]=t;const ie={};for(let t in te)ie[te[t]]=Qt[t];const se={drawRoundRect(t,e,i,s,r,o){const n=a.fourNumber(o,Math.min(s/2,r/2)),h=e+s,l=i+r;n[0]?t.moveTo(e+n[0],i):t.moveTo(e,i),n[1]?t.arcTo(h,i,h,l,n[1]):t.lineTo(h,i),n[2]?t.arcTo(h,l,e,l,n[2]):t.lineTo(h,l),n[3]?t.arcTo(e,l,e,i,n[3]):t.lineTo(e,l),n[0]?t.arcTo(e,i,h,i,n[0]):t.lineTo(e,i)}},{sin:re,cos:oe,atan2:ne,ceil:ae,abs:he,PI:le,sqrt:de,pow:ce}=Math,{setPoint:ue,addPoint:_e}=Y,{set:pe}=S,{M:ge,L:fe,C:ye,Q:me,Z:ve}=Zt,we={},xe={points(t,e,i,s){if(t.push(ge,e[0],e[1]),i&&e.length>5){let r,o,n,a,h,l,d,c,u,_,p,g,f,y=e.length;const m=!0===i?.5:i;s&&(y=(e=[e[y-2],e[y-1],...e,e[0],e[1],e[2],e[3]]).length);for(let i=2;i<y-2;i+=2)r=e[i-2],o=e[i-1],n=e[i],a=e[i+1],h=e[i+2],l=e[i+3],p=de(ce(n-r,2)+ce(a-o,2)),g=de(ce(h-n,2)+ce(l-a,2)),f=p+g,p=m*p/f,g=m*g/f,h-=r,l-=o,d=n-p*h,c=a-p*l,2===i?s||t.push(me,d,c,n,a):t.push(ye,u,_,d,c,n,a),u=n+g*h,_=a+g*l;s||t.push(me,u,_,e[y-2],e[y-1])}else for(let i=2,s=e.length;i<s;i+=2)t.push(fe,e[i],e[i+1]);s&&t.push(ve)},rect(t,e,i,s,r){Kt.creator.path=t,Kt.creator.moveTo(e,i).lineTo(e+s,i).lineTo(e+s,i+r).lineTo(e,i+r).lineTo(e,i)},roundRect(t,e,i,s,r,o){Kt.creator.path=[],se.drawRoundRect(Kt.creator,e,i,s,r,o),t.push(...Kt.convertToCanvasData(Kt.creator.path,!0))},arcTo(t,e,i,s,r,o,n,a,c,u,_){const p=s-e,g=r-i,f=o-s,y=n-r;let m=ne(g,p),v=ne(y,f),w=v-m;if(w<0&&(w+=l),w===le||he(p+g)<1e-12||he(f+y)<1e-12)return t&&t.push(fe,s,r),c&&(ue(c,e,i),_e(c,s,r)),_&&pe(_,e,i),void(u&&pe(u,s,r));const x=p*y-f*g<0,b=x?-1:1,B=a/oe(w/2),R=s+B*oe(m+w/2+d*b),k=r+B*re(m+w/2+d*b);return m-=d*b,v-=d*b,Re(t,R,k,a,a,0,m/h,v/h,x,c,u,_)},arc:(t,e,i,s,r,o,n,a,h,l)=>Re(t,e,i,s,s,0,r,o,n,a,h,l),ellipse(t,e,i,s,r,o,n,a,c,u,_,p){const g=o*h,f=re(g),y=oe(g);let m=n*h,v=a*h;m>le&&(m-=l),v<0&&(v+=l);let w=v-m;w<0?w+=l:w>l&&(w-=l),c&&(w-=l);const x=ae(he(w/d)),b=w/x,B=re(b/4),R=8/3*B*B/re(b/2);v=m+b;let k,C,T,E,P,O,L,S,M=oe(m),D=re(m),A=T=y*s*M-f*r*D,W=E=f*s*M+y*r*D,I=e+T,F=i+E;t&&t.push(fe,I,F),u&&ue(u,I,F),p&&pe(p,I,F);for(let o=0;o<x;o++)k=oe(v),C=re(v),T=y*s*k-f*r*C,E=f*s*k+y*r*C,P=e+A-R*(y*s*D+f*r*M),O=i+W-R*(f*s*D-y*r*M),L=e+T+R*(y*s*C+f*r*k),S=i+E+R*(f*s*C-y*r*k),t&&t.push(ye,P,O,L,S,e+T,i+E),u&&Be(e+A,i+W,P,O,L,S,e+T,i+E,u,!0),A=T,W=E,M=k,D=C,m=v,v+=b;_&&pe(_,e+T,i+E)},quadraticCurveTo(t,e,i,s,r,o,n){t.push(ye,(e+2*s)/3,(i+2*r)/3,(o+2*s)/3,(n+2*r)/3,o,n)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,r,o,n,a){Be(t,e,(t+2*i)/3,(e+2*s)/3,(r+2*i)/3,(o+2*s)/3,r,o,n,a)},toTwoPointBounds(t,e,i,s,r,o,n,a,h,l){const d=[];let c,u,_,p,g,f,y,m,v=t,w=i,x=r,b=n;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 y=u*u-4*_*c,m=Math.sqrt(y),y<0||(g=(-u+m)/(2*c),0<g&&g<1&&d.push(g),f=(-u-m)/(2*c),0<f&&f<1&&d.push(f));l?_e(h,t,e):ue(h,t,e),_e(h,n,a);for(let l=0,c=d.length;l<c;l++)be(d[l],t,e,i,s,r,o,n,a,we),_e(h,we.x,we.y)},getPointAndSet(t,e,i,s,r,o,n,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*r+_*n+p*h},getPoint(t,e,i,s,r,o,n,a,h){const l={};return be(t,e,i,s,r,o,n,a,h,l),l}},{getPointAndSet:be,toTwoPointBounds:Be,ellipse:Re}=xe,{sin:ke,cos:Ce,sqrt:Te,atan2:Ee}=Math,{ellipse:Pe}=xe,Oe={ellipticalArc(e,i,s,r,o,n,a,d,c,u,_){const p=(c-i)/2,g=(u-s)/2,f=n*h,y=ke(f),m=Ce(f),v=-m*p-y*g,w=-m*g+y*p,x=r*r,b=o*o,B=w*w,R=v*v,k=x*b-x*B-b*R;let C=0;if(k<0){const t=Te(1-k/(x*b));r*=t,o*=t}else C=(a===d?-1:1)*Te(k/(x*B+b*R));const T=C*r*w/o,E=-C*o*v/r,P=Ee((w-E)/o,(v-T)/r),O=Ee((-w-E)/o,(-v-T)/r);let L=O-P;0===d&&L>0?L-=l:1===d&&L<0&&(L+=l);const S=i+p+m*T-y*E,M=s+g+y*T+m*E,D=L<0?1:0;_||t.ellipseToCurve?Pe(e,S,M,r,o,n,P/h,O/h,D):r!==o||n?e.push(Zt.G,S,M,r,o,n,P/h,O/h,D):e.push(Zt.O,S,M,r,P/h,O/h,D)}},{M:Le,m:Se,L:Me,l:De,H:Ae,h:We,V:Ie,v:Fe,C:ze,c:Ne,S:Ye,s:Xe,Q:je,q:He,T:Ve,t:Ue,A:Ge,a:Ke,Z:qe,z:Ze,N:Qe,D:Je,X:$e,G:ti,F:ei,O:ii,P:si,U:ri}=Zt,{rect:oi,roundRect:ni,arcTo:ai,arc:hi,ellipse:li,quadraticCurveTo:di}=xe,{ellipticalArc:ci}=Oe,ui=vt.get("PathConvert"),_i={},pi={current:{dot:0},stringify(t,e){let i,s,r,o=0,n=t.length,h="";for(;o<n;){s=t[o],i=ie[s],h+=s===r?" ":ee[s];for(let s=1;s<i;s++)h+=a.float(t[o+s],e),s===i-1||(h+=" ");r=s,o+=i}return h},parse(t,e){let i,s,r,o="";const n=[],a=e?$t:Jt;for(let e=0,h=t.length;e<h;e++)s=t[e],mt[s]?("."===s&&(gi.dot&&(fi(n,o),o=""),gi.dot++),"0"===o&&"."!==s&&(fi(n,o),o=""),o+=s):Zt[s]?(o&&(fi(n,o),o=""),gi.name=Zt[s],gi.length=Qt[s],gi.index=0,fi(n,gi.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===r||"E"===r?o+=s:(o&&fi(n,o),o=s):o&&(fi(n,o),o=""),r=s;return o&&fi(n,o),i?pi.toCanvasData(n,e):n},toCanvasData(t,e){let i,s,r,o,n,a=0,h=0,l=0,d=0,c=0,u=t.length;const _=[];for(;c<u;){switch(r=t[c],r){case Se:t[c+1]+=a,t[c+2]+=h;case Le:a=t[c+1],h=t[c+2],_.push(Le,a,h),c+=3;break;case We:t[c+1]+=a;case Ae:a=t[c+1],_.push(Me,a,h),c+=2;break;case Fe:t[c+1]+=h;case Ie:h=t[c+1],_.push(Me,a,h),c+=2;break;case De:t[c+1]+=a,t[c+2]+=h;case Me:a=t[c+1],h=t[c+2],_.push(Me,a,h),c+=3;break;case Xe:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,r=Ye;case Ye:n=o===ze||o===Ye,l=n?2*a-i:t[c+1],d=n?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],_.push(ze,l,d,i,s,a,h),c+=5;break;case Ne:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,r=ze;case ze:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],_.push(ze,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Ue:t[c+1]+=a,t[c+2]+=h,r=Ve;case Ve:n=o===je||o===Ve,i=n?2*a-i:t[c+1],s=n?2*h-s:t[c+2],e?di(_,a,h,i,s,t[c+1],t[c+2]):_.push(je,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case He:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,r=je;case je:i=t[c+1],s=t[c+2],e?di(_,a,h,i,s,t[c+3],t[c+4]):_.push(je,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Ke:t[c+6]+=a,t[c+7]+=h;case Ge:ci(_,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 Ze:case qe:_.push(qe),c++;break;case Qe:a=t[c+1],h=t[c+2],e?oi(_,a,h,t[c+3],t[c+4]):yi(_,t,c,5),c+=5;break;case Je:a=t[c+1],h=t[c+2],e?ni(_,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):yi(_,t,c,9),c+=9;break;case $e:a=t[c+1],h=t[c+2],e?ni(_,a,h,t[c+3],t[c+4],t[c+5]):yi(_,t,c,6),c+=6;break;case ti:li(e?_:yi(_,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,_i),a=_i.x,h=_i.y,c+=9;break;case ei:e?li(_,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):yi(_,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case ii:hi(e?_:yi(_,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,_i),a=_i.x,h=_i.y,c+=7;break;case si:e?hi(_,t[c+1],t[c+2],t[c+3],0,360,!1):yi(_,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case ri:ai(e?_:yi(_,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,_i),a=_i.x,h=_i.y,c+=6;break;default:return ui.error(`command: ${r} [index:${c}]`,t),_}o=r}return _},copyData(t,e,i,s){for(let r=i,o=i+s;r<o;r++)t.push(e[r])},pushData(t,e){gi.index===gi.length&&(gi.index=1,t.push(gi.name)),t.push(Number(e)),gi.index++,gi.dot=0}},{current:gi,pushData:fi,copyData:yi}=pi,{M:mi,L:vi,C:wi,Q:xi,Z:bi,N:Bi,D:Ri,X:ki,G:Ci,F:Ti,O:Ei,P:Pi,U:Oi}=Zt,{getMinDistanceFrom:Li,getRadianFrom:Si}=S,{tan:Mi,min:Di,abs:Ai}=Math,Wi={},Ii={beginPath(t){t.length=0},moveTo(t,e,i){t.push(mi,e,i)},lineTo(t,e,i){t.push(vi,e,i)},bezierCurveTo(t,e,i,s,r,o,n){t.push(wi,e,i,s,r,o,n)},quadraticCurveTo(t,e,i,s,r){t.push(xi,e,i,s,r)},closePath(t){t.push(bi)},rect(t,e,i,s,r){t.push(Bi,e,i,s,r)},roundRect(t,e,i,s,r,o){if("number"==typeof o)t.push(ki,e,i,s,r,o);else{const n=a.fourNumber(o);n?t.push(Ri,e,i,s,r,...n):t.push(Bi,e,i,s,r)}},ellipse(t,e,i,s,r,o,n,a,h){void 0===o?t.push(Ti,e,i,s,r):(void 0===n&&(n=0),void 0===a&&(a=360),t.push(Ci,e,i,s,r,o,n,a,h?1:0))},arc(t,e,i,s,r,o,n){void 0===r?t.push(Pi,e,i,s):(void 0===o&&(o=360),t.push(Ei,e,i,s,r,o,n?1:0))},arcTo(t,e,i,s,r,o,n,a){if(void 0!==n){const h=Mi(Si(n,a,e,i,s,r)/2)*(Li(n,a,e,i,s,r)/2);t.push(Oi,e,i,s,r,Di(o,Ai(h)))}else t.push(Oi,e,i,s,r,o)},drawEllipse(t,e,i,s,r,o,n,a,h){xe.ellipse(null,e,i,s,r,void 0===o?0:o,void 0===n?0:n,void 0===a?360:a,h,null,null,Wi),t.push(mi,Wi.x,Wi.y),Fi(t,e,i,s,r,o,n,a,h)},drawArc(t,e,i,s,r,o,n){xe.arc(null,e,i,s,void 0===r?0:r,void 0===o?360:o,n,null,null,Wi),t.push(mi,Wi.x,Wi.y),zi(t,e,i,s,r,o,n)},drawPoints(t,e,i,s){xe.points(t,e,i,s)}},{ellipse:Fi,arc:zi}=Ii,{moveTo:Ni,lineTo:Yi,quadraticCurveTo:Xi,bezierCurveTo:ji,closePath:Hi,beginPath:Vi,rect:Ui,roundRect:Gi,ellipse:Ki,arc:qi,arcTo:Zi,drawEllipse:Qi,drawArc:Ji,drawPoints:$i}=Ii;class ts{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.clearPath=this.beginPath,this.set(t)}set(t){return this.__path=t?"string"==typeof t?Kt.parse(t):t:[],this}beginPath(){return Vi(this.__path),this}moveTo(t,e){return Ni(this.__path,t,e),this}lineTo(t,e){return Yi(this.__path,t,e),this}bezierCurveTo(t,e,i,s,r,o){return ji(this.__path,t,e,i,s,r,o),this}quadraticCurveTo(t,e,i,s){return Xi(this.__path,t,e,i,s),this}closePath(){return Hi(this.__path),this}rect(t,e,i,s){return Ui(this.__path,t,e,i,s),this}roundRect(t,e,i,s,r){return Gi(this.__path,t,e,i,s,r),this}ellipse(t,e,i,s,r,o,n,a){return Ki(this.__path,t,e,i,s,r,o,n,a),this}arc(t,e,i,s,r,o){return qi(this.__path,t,e,i,s,r,o),this}arcTo(t,e,i,s,r){return Zi(this.__path,t,e,i,s,r),this}drawEllipse(t,e,i,s,r,o,n,a){return Qi(this.__path,t,e,i,s,r,o,n,a),this}drawArc(t,e,i,s,r,o){return Ji(this.__path,t,e,i,s,r,o),this}drawPoints(t,e,i){return $i(this.__path,t,e,i),this}}const{M:es,L:is,C:ss,Q:rs,Z:os,N:ns,D:as,X:hs,G:ls,F:ds,O:cs,P:us,U:_s}=Zt,ps=vt.get("PathDrawer"),gs={drawPathByData(t,e){if(!e)return;let i,s=0,r=e.length;for(;s<r;)switch(i=e[s],i){case es:t.moveTo(e[s+1],e[s+2]),s+=3;break;case is:t.lineTo(e[s+1],e[s+2]),s+=3;break;case ss:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case rs:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case os:t.closePath(),s+=1;break;case ns:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case as: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 hs:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case ls:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*h,e[s+6]*h,e[s+7]*h,e[s+8]),s+=9;break;case ds:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,l,!1),s+=5;break;case cs:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*h,e[s+5]*h,e[s+6]),s+=7;break;case us:t.arc(e[s+1],e[s+2],e[s+3],0,l,!1),s+=4;break;case _s:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void ps.error(`command: ${i} [index:${s}]`,e)}}},{M:fs,L:ys,C:ms,Q:vs,Z:ws,N:xs,D:bs,X:Bs,G:Rs,F:ks,O:Cs,P:Ts,U:Es}=Zt,{toTwoPointBounds:Ps,toTwoPointBoundsByQuadraticCurve:Os,arcTo:Ls,arc:Ss,ellipse:Ms}=xe,{addPointBounds:Ds,copy:As,addPoint:Ws,setPoint:Is,addBounds:Fs,toBounds:zs}=Y,Ns=vt.get("PathBounds");let Ys,Xs,js;const Hs={},Vs={},Us={},Gs={toBounds(t,e){Gs.toTwoPointBounds(t,Vs),zs(Vs,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Is(e,0,0);let i,s,r,o,n,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(i=t[a],0===a&&(i===ws||i===ms||i===vs?Is(e,h,l):Is(e,t[a+1],t[a+2])),i){case fs:case ys:h=t[a+1],l=t[a+2],Ws(e,h,l),a+=3;break;case ms:o=t[a+5],n=t[a+6],Ps(h,l,t[a+1],t[a+2],t[a+3],t[a+4],o,n,Hs),Ds(e,Hs),h=o,l=n,a+=7;break;case vs:s=t[a+1],r=t[a+2],o=t[a+3],n=t[a+4],Os(h,l,s,r,o,n,Hs),Ds(e,Hs),h=o,l=n,a+=5;break;case ws:a+=1;break;case xs:h=t[a+1],l=t[a+2],Fs(e,h,l,t[a+3],t[a+4]),a+=5;break;case bs:case Bs:h=t[a+1],l=t[a+2],Fs(e,h,l,t[a+3],t[a+4]),a+=i===bs?9:6;break;case Rs:Ms(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],Hs,Us),0===a?As(e,Hs):Ds(e,Hs),h=Us.x,l=Us.y,a+=9;break;case ks:h=t[a+1],l=t[a+2],Xs=t[a+3],js=t[a+4],Fs(e,h-Xs,l-js,2*Xs,2*js),h+=Xs,a+=5;break;case Cs:Ss(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Hs,Us),0===a?As(e,Hs):Ds(e,Hs),h=Us.x,l=Us.y,a+=7;break;case Ts:h=t[a+1],l=t[a+2],Ys=t[a+3],Fs(e,h-Ys,l-Ys,2*Ys,2*Ys),h+=Ys,a+=4;break;case Es:Ls(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Hs,Us),0===a?As(e,Hs):Ds(e,Hs),h=Us.x,l=Us.y,a+=6;break;default:return void Ns.error(`command: ${i} [index:${a}]`,t)}}},{M:Ks,L:qs,C:Zs,Z:Qs}=Zt,{getCenterX:Js,getCenterY:$s}=S,{arcTo:tr}=Ii,er={smooth(t,e,i){let s,r=0,o=0,n=0,a=0,h=0,l=0,d=0,c=0,u=0;const _=t.length,p=[];for(;r<_;)switch(s=t[r],s){case Ks:a=c=t[r+1],h=u=t[r+2],r+=3,t[r]===qs?(l=t[r+1],d=t[r+2],p.push(Ks,Js(a,l),$s(h,d))):p.push(Ks,a,h);break;case qs:switch(o=t[r+1],n=t[r+2],r+=3,t[r]){case qs:tr(p,o,n,t[r+1],t[r+2],e,c,u);break;case Qs:tr(p,o,n,a,h,e,c,u);break;default:p.push(qs,o,n)}c=o,u=n;break;case Zs:p.push(Zs,t[r+1],t[r+2],t[r+3],t[r+4],t[r+5],t[r+6]),r+=7;break;case Qs:tr(p,a,h,l,d,e,c,u),p.push(Qs),r+=1}return s!==Qs&&(p[1]=a,p[2]=h),p}};Kt.creator=new ts,Kt.parse=pi.parse,Kt.convertToCanvasData=pi.toCanvasData;const ir=new ts,{drawRoundRect:sr}=se;function rr(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,r){sr(this,t,e,i,s,r)})}(t)}const or={opacityTypes:["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=nr.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{}}}},nr=or;nr.opacityTypes.forEach((t=>nr.upperCaseTypeMap[t]=t.toUpperCase()));const ar=vt.get("TaskProcessor");class hr{constructor(t){this.parallel=!0,this.time=1,this.id=i.create(i.TASK),this.task=t}run(){return Ft(this,void 0,void 0,(function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){ar.error(t)}}))}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class lr{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&&St.assign(this.config,t),this.empty()}add(t,e){let i,s,r,o;const n=new hr(t);return n.parent=this,"number"==typeof e?o=e:e&&(s=e.parallel,i=e.start,r=e.time,o=e.delay),r&&(n.time=r),!1===s&&(n.parallel=!1),void 0===o?this.push(n,i):(this.delayNumber++,setTimeout((()=>{this.delayNumber&&(this.delayNumber--,this.push(n,i))}),o)),this.isComplete=!1,n}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 dr={map:{},recycledList:[],tasker:new lr,patternTasker:new lr,get isComplete(){return cr.tasker.isComplete},get(t){let i=cr.map[t.url];return i||(i=e.image(t),cr.map[t.url]=i),i.use++,i},recycle(t){t.use--,setTimeout((()=>{t.use||cr.recycledList.push(t)}))},clearRecycled(){const t=cr.recycledList;t.length>100&&(t.forEach((t=>{!t.use&&t.url&&(delete cr.map[t.url],t.destroy())})),t.length=0)},hasOpacityPixel:t=>or.opacityTypes.some((e=>cr.isFormat(e,t))),isFormat(t,e){if(e.format===t)return!0;const{url:i}=e;if(i.startsWith("data:")){if(i.startsWith("data:"+or.mineType(t)))return!0}else if(i.includes("."+t)||i.includes("."+or.upperCaseTypeMap[t]))return!0;return!1},destroy(){cr.map={},cr.recycledList=[]}},cr=dr,{IMAGE:ur,create:_r}=i;class pr{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){this.use=0,this.waitComplete=[],this.innerId=_r(ur),this.config=t||{url:""},this.isSVG=dr.isFormat("svg",t),this.hasOpacityPixel=dr.hasOpacityPixel(t)}load(e,i){return this.loading||(this.loading=!0,dr.tasker.add((()=>Ft(this,void 0,void 0,(function*(){return yield t.origin.loadImage(this.url).then((t=>{this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)})).catch((t=>{this.error=t,this.onComplete(!1)}))}))))),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}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}getCanvas(e,i,s,r){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 o=t.origin.createCanvas(e,i),n=o.getContext("2d");return s&&(n.globalAlpha=s),n.drawImage(this.view,0,0,e,i),this.cache=this.use>1?{data:o,params:arguments}:null,o}getPattern(e,i,s,r){const o=t.canvas.createPattern(e,i);try{s&&o.setTransform&&(o.setTransform(s),s=null)}catch(t){}return r&&(r.transform=s),o}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}}function gr(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function fr(t,e){return Object.getOwnPropertyDescriptor(t,e)}function yr(t,e){return(i,s)=>vr(i,s,t,e&&e(s))}function mr(t){return t}function vr(t,e,i,s){const r={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};gr(t,e,Object.assign(r,s||{})),Hr(t,e,i)}function wr(t){return yr(t)}function xr(t,e){return yr(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}})))}function br(t){return yr(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__hasAutoLayout=!!e,this.__local||this.__layout.createLocal())}})))}function Br(t,e){return yr(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}})))}function Rr(t,e){return yr(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}})))}function kr(t,e){return yr(t,(t=>({set(i){this.__setAttr(t,i,e)&&Tr(this)}})))}function Cr(t){return yr(t,(t=>({set(e){this.__setAttr(t,e)&&(Tr(this),this.__.__removeNaturalSize())}})))}function Tr(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function Er(t){return yr(t,(t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),Tr(this)}})))}const Pr=kr;function Or(t){return yr(t,(t=>({set(e){this.__setAttr(t,e)&&Lr(this)}})))}function Lr(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&Tr(t)}const Sr=Or;function Mr(t){return yr(t,(t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}})))}function Dr(t){return yr(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}})))}function Ar(t){return yr(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange())}})))}function Wr(t){return yr(t,(t=>({set(e){const i=this.visible;this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange(),0!==i&&0!==e||Tr(this))}})))}function Ir(t){return yr(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.waitParent((()=>{this.parent.__layout.childrenSortChange()})))}})))}function Fr(t){return yr(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent((()=>{this.parent.__updateMask(e)})))}})))}function zr(t){return yr(t,(t=>({set(e){this.__setAttr(t,e)&&this.waitParent((()=>{this.parent.__updateEraser(e)}))}})))}function Nr(t){return yr(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,vt.showHitView&&(this.__layout.surfaceChanged||this.__layout.surfaceChange()),this.leafer&&this.leafer.updateCursor())}})))}function Yr(t){return yr(t,(t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}})))}function Xr(t){return(e,i)=>{gr(e,"__DataProcessor",{get:()=>t})}}function jr(t){return(e,i)=>{gr(e,"__LayoutProcessor",{get:()=>t})}}function Hr(t,e,i){const s=t.__DataProcessor.prototype,r="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),n={get(){const t=this[r];return void 0===t?i:t},set(t){this[r]=t}};void 0===i?n.get=function(){return this[r]}:"width"===e?n.get=function(){const t=this[r];if(void 0===t){const t=this;return t._height&&t.__naturalWidth&&t.__useNaturalRatio?t._height*t.__naturalWidth/t.__naturalHeight:t.__naturalWidth||i}return t}:"height"===e&&(n.get=function(){const t=this[r];if(void 0===t){const t=this;return t._width&&t.__naturalHeight&&t.__useNaturalRatio?t._width*t.__naturalHeight/t.__naturalWidth:t.__naturalHeight||i}return t});let a,h=s;for(;!a&&h;)a=fr(h,e),h=h.__proto__;a&&a.set&&(n.set=a.set),s[o]&&(n.set=s[o],delete s[o]),gr(s,e,n)}const Vr=new vt("rewrite"),Ur=[],Gr=["destroy","constructor"];function Kr(t){return(e,i)=>{Ur.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function qr(){return t=>{Zr()}}function Zr(t){Ur.length&&(Ur.forEach((e=>{t&&Vr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()})),Ur.length=0)}function Qr(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach((s=>{if(!(Gr.includes(s)||e&&e.includes(s)))if(t.prototype){fr(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]}))}}function Jr(){return t=>{Ct.register(t)}}function $r(){return t=>{Pt.register(t)}}setTimeout((()=>Zr(!0)));const{copy:to,toInnerPoint:eo,scaleOfOuter:io,rotateOfOuter:so,skewOfOuter:ro,multiplyParent:oo,divideParent:no,getLayout:ao}=x,ho={},lo={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),_o(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,r=s.length;t<r;t++)uo(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++)po(e[t])}},updateAllChange(t){if(po(t),t.__updateChange(),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)go(e[t])}},worldHittable(t){for(;t;){if(!t.__.hittable)return!1;t=t.parent}return!0},moveWorld(t,e,i=0){const s="object"==typeof e?Object.assign({},e):{x:e,y:i};t.parent&&eo(t.parent.worldTransform,s,s,!0),co.moveLocal(t,s.x,s.y)},moveLocal(t,e,i=0){"object"==typeof e?(t.x+=e.x,t.y+=e.y):(t.x+=e,t.y+=i)},zoomOfWorld(t,e,i,s,r){co.zoomOfLocal(t,yo(t,e),i,s,r)},zoomOfLocal(t,e,i,s=i,r){to(ho,t.__localMatrix),io(ho,e,i,s),t.origin||t.around?co.setTransform(t,ho,r):(fo(t,ho),t.scaleResize(i,s,!0!==r))},rotateOfWorld(t,e,i){co.rotateOfLocal(t,yo(t,e),i)},rotateOfLocal(t,e,i){to(ho,t.__localMatrix),so(ho,e,i),t.origin||t.around?co.setTransform(t,ho):(fo(t,ho),t.rotation=a.formatRotation(t.rotation+i))},skewOfWorld(t,e,i,s,r){co.skewOfLocal(t,yo(t,e),i,s,r)},skewOfLocal(t,e,i,s=0,r){to(ho,t.__localMatrix),ro(ho,e,i,s),co.setTransform(t,ho,r)},transformWorld(t,e,i){to(ho,t.worldTransform),oo(ho,e),t.parent&&no(ho,t.parent.worldTransform),co.setTransform(t,ho,i)},transform(t,e,i){to(ho,t.localTransform),oo(ho,e),co.setTransform(t,ho,i)},setTransform(t,e,i){const s=ao(e,t.origin&&co.getInnerOrigin(t,t.origin),t.around&&co.getInnerOrigin(t,t.around));if(i){const e=s.scaleX/t.scaleX,r=s.scaleY/t.scaleY;delete s.scaleX,delete s.scaleY,t.set(s),t.scaleResize(e,r,!0!==i)}else t.set(s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return io(i,co.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>S.tempToOuterOf(co.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return pt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(to(ho,t.worldTransform),no(ho,e.worldTransform),i?ho:Object.assign({},ho)),drop(t,e,i,s){t.setTransform(co.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}}},co=lo,{updateAllMatrix:uo,updateMatrix:_o,updateAllWorldOpacity:po,updateAllChange:go}=co;function fo(t,e){const{e:i,f:s}=t.__localMatrix;t.x+=e.e-i,t.y+=e.f-s}function yo(t,e){return t.__layout.update(),t.parent?S.tempToInnerOf(e,t.parent.__world):e}const mo={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=>t.__.mask?t.__localBoxBounds:null,maskLocalStrokeBounds:t=>t.__.mask?t.__layout.localStrokeBounds:null,maskLocalRenderBounds:t=>t.__.mask?t.__layout.localRenderBounds:null,excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))},{updateBounds:vo}=lo,wo={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,r=i.length;s<r;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),xo(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&void 0===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++)bo(e[t],e)},updateBounds(t,e){const i=[t];bo(t,i),Bo(i,e)},updateBoundsByBranchStack(t,e){let i,s;for(let r=t.length-1;r>-1;r--){i=t[r],s=i.children;for(let t=0,e=s.length;t<e;t++)vo(s[t]);e&&e===i||vo(i)}}},{pushAllChildBranch:xo,pushAllBranchStack:bo,updateBoundsByBranchStack:Bo}=wo,Ro={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:ko}=lo,{toOuterOf:Co,getPoints:To,copy:Eo}=rt,Po="_localContentBounds",Oo="_worldContentBounds",Lo="_worldBoxBounds",So="_worldStrokeBounds";class Mo{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}get localContentBounds(){return Co(this.contentBounds,this.leaf.__localMatrix,this[Po]||(this[Po]={})),this[Po]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return Co(this.contentBounds,this.leaf.__world,this[Oo]||(this[Oo]={})),this[Oo]}get worldBoxBounds(){return Co(this.boxBounds,this.leaf.__world,this[Lo]||(this[Lo]={})),this[Lo]}get worldStrokeBounds(){return Co(this.strokeBounds,this.leaf.__world,this[So]||(this[So]={})),this[So]}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.boxBounds={x:0,y:0,width:0,height:0},this.leaf.__local&&(this._localRenderBounds=this._localStrokeBounds=this.leaf.__local),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{leafer:e}=this.leaf;if(e)e.ready?e.watcher.changed&&e.layouter.layout():e.start();else{let e=this.leaf;for(;e.parent&&!e.parent.leafer;)e=e.parent;t.layout(e)}}getTransform(t="world"){this.update();const{leaf:e}=this;switch(t){case"world":return e.__world;case"local":return e.__localMatrix;case"inner":return x.defaultMatrix;case"page":t=e.zoomLayer;default:return ko(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 r,o,n=this.getInnerBounds(t);switch(e){case"world":r=s.getWorldPoint(n),o=s.__world;break;case"local":r=s.getLocalPointByInner(n),o=s.__localMatrix;break;case"inner":r=n,o=x.defaultMatrix;break;case"page":e=s.zoomLayer;default:r=s.getWorldPoint(n,e),o=ko(s,e,!0)}const a=x.getLayout(o);if(Eo(a,n),S.copy(a,r),i){const{scaleX:t,scaleY:e}=a,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(a.scaleX/=i,a.scaleY/=s,a.width*=i,a.height*=s)}return a}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=To(this.getInnerBounds(t));let r;switch(e){case"world":r=null;break;case"local":r=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:r=e}return void 0!==r&&s.forEach((t=>i.innerToWorld(t,null,!1,r))),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.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.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=!0,this.leaf.forceUpdate("surface"))}destroy(){}}const Do={},Ao={on(t,e,i){let s,r,o;i&&("once"===i?r=!0:"boolean"==typeof i?s=i:(s=i.capture,r=i.once));const n=Wo(this,s,!0),a="string"==typeof t?t.split(" "):t,h=r?{listener:e,once:r}:{listener:e};a.forEach((t=>{t&&(o=n[t],o?-1===o.findIndex((t=>t.listener===e))&&o.push(h):n[t]=[h])}))},off(t,e,i){if(t){const s="string"==typeof t?t.split(" "):t;if(e){let t,r,o;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const n=Wo(this,t);s.forEach((t=>{t&&(r=n[t],r&&(o=r.findIndex((t=>t.listener===e)),o>-1&&r.splice(o,1),r.length||delete n[t]))}))}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 i&&(e=e.bind(i)),this.on(t,e,s),{type:t,current:this,listener:e,options:s}},off_(t){if(!t)return;const e=t instanceof Array?t:[t];e.forEach((t=>t.current.off(t.type,t.listener,t.options))),e.length=0},once(t,e,i){this.on(t,e,{once:!0,capture:i})},emit(t,e,i){!e&&Pt.has(t)&&(e=Pt.get(t,{type:t,target:this,current:this}));const s=Wo(this,i)[t];if(s){let r;for(let o=0,n=s.length;o<n&&(r=s[o],r.listener(e),r.once&&(this.off(t,r.listener,i),o--,n--),!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,r=i&&i[t],o=s&&s[t];return!!(void 0===e?r||o:e?o:r)}};function Wo(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:Do)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:Do)}}class Io{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 Fo extends Io{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}Fo.ADD="child.add",Fo.REMOVE="child.remove",Fo.DESTROY="child.destroy";class zo extends Io{constructor(t,e,i,s,r){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=r}}zo.CHANGE="property.change",zo.LEAFER_CHANGE="property.leafer_change";class No extends Io{constructor(t,e){super(t),Object.assign(this,e)}}No.LOAD="image.load",No.LOADED="image.loaded",No.ERROR="image.error";class Yo extends Io{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){"object"==typeof t?(super(Yo.RESIZE),Object.assign(this,t)):super(t),this.old=e}}Yo.RESIZE="resize";class Xo extends Io{constructor(t,e){super(t),this.data=e}}Xo.REQUEST="watch.request",Xo.DATA="watch.data";class jo extends Io{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}jo.CHECK_UPDATE="layout.check_update",jo.REQUEST="layout.request",jo.START="layout.start",jo.BEFORE="layout.before",jo.LAYOUT="layout",jo.AFTER="layout.after",jo.AGAIN="layout.again",jo.END="layout.end";class Ho extends Io{}Ho.FRAME="animate.frame";class Vo extends Io{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Vo.REQUEST="render.request",Vo.START="render.start",Vo.BEFORE="render.before",Vo.RENDER="render",Vo.AFTER="render.after",Vo.AGAIN="render.again",Vo.END="render.end",Vo.NEXT="render.next";class Uo extends Io{}Uo.START="leafer.start",Uo.BEFORE_READY="leafer.before_ready",Uo.READY="leafer.ready",Uo.AFTER_READY="leafer.after_ready",Uo.VIEW_READY="leafer.view_ready",Uo.VIEW_COMPLETED="leafer.view_completed",Uo.STOP="leafer.stop",Uo.RESTART="leafer.restart",Uo.END="leafer.end";const{isFinite:Go}=Number,Ko=vt.get("setAttr"),qo={__setAttr(t,e,i){if(this.leafer&&this.leafer.created){const s=this.__.__getInput(t);if(i&&!Go(e)&&void 0!==e&&(Ko.warn(this.innerName,t,e),e=void 0),"object"==typeof e||s!==e){this.__[t]=e,this.__proxyData&&this.setProxyAttr(t,e);const{CHANGE:i}=zo,r=new zo(i,this,t,s,e);return this.isLeafer?this.emitEvent(new zo(zo.LEAFER_CHANGE,this,t,s,e)):this.hasEvent(i)&&this.emitEvent(r),this.leafer.emitEvent(r),!0}return!1}return this.__[t]=e,this.__proxyData&&this.setProxyAttr(t,e),!0},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:Zo,multiplyParent:Qo,translateInner:Jo,defaultWorld:$o}=x,{toPoint:tn,tempPoint:en}=pt,sn={__updateWorldMatrix(){Qo(this.__local||this.__layout,this.parent?this.parent.__world:$o,this.__world,!!this.__layout.affectScaleOrRotation,this.__,this.parent&&this.parent.__)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged||t.rotationChanged)&&(Zo(e,i,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=!1),e.e=i.x+i.offsetX,e.f=i.y+i.offsetY,(i.around||i.origin)&&(tn(i.around||i.origin,t.boxBounds,en),Jo(e,-en.x,-en.y,!i.around))}this.__layout.matrixChanged=!1}},{updateMatrix:rn,updateAllMatrix:on}=lo,{updateBounds:nn}=wo,{toOuterOf:an,copyAndSpread:hn,copy:ln}=rt,{toBounds:dn}=Gs,cn={__updateWorldBounds(){an(this.__layout.renderBounds,this.__world,this.__world),this.__layout.resized&&(this.__onUpdateSize(),this.__layout.resized=!1)},__updateLocalBounds(){const t=this.__layout;t.boxChanged&&(this.__.__pathInputed||this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),t.resized=!0),t.localBoxChanged&&(this.__local&&this.__updateLocalBoxBounds(),t.localBoxChanged=!1,t.strokeSpread&&(t.strokeChanged=!0),t.renderSpread&&(t.renderChanged=!0),this.parent&&this.parent.__layout.boxChange()),t.boxChanged=!1,t.strokeChanged&&(t.strokeSpread=this.__updateStrokeSpread(),t.strokeSpread?(t.strokeBounds===t.boxBounds&&t.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):t.spreadStrokeCancel(),t.strokeChanged=!1,(t.renderSpread||t.strokeSpread!==t.strokeBoxSpread)&&(t.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),t.resized=!0),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=!1,this.parent&&this.parent.__layout.renderChange()),t.boundsChanged=!1},__updateLocalBoxBounds(){this.__hasAutoLayout&&this.__updateAutoLayout(),an(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){an(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){an(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds,e=this.__;e.__pathInputed?dn(e.__pathForRender,t):(t.x=0,t.y=0,t.width=e.width,t.height=e.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),on(this),nn(this,this),this.__.__autoSide&&this.__updateBoxBounds()):(on(this),nn(this,this))):rn(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(){const t=this.__layout;hn(t.strokeBounds,t.boxBounds,t.strokeBoxSpread)},__updateRenderBounds(){const t=this.__layout;t.renderSpread>0?hn(t.renderBounds,t.boxBounds,t.renderSpread):ln(t.renderBounds,t.strokeBounds)}},un={__render(t,e){if(this.__worldOpacity)if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=this.__.opacity,this.__.__single){if("path"===this.__.eraser)return this.__renderEraser(t,e);const i=t.getSameCanvas(!0,!0);this.__draw(i,e),this.__worldFlipped?t.copyWorldByReset(i,this.__nowWorld,null,this.__.__blendMode,!0):t.copyWorldToInner(i,this.__nowWorld,this.__layout.renderBounds,this.__.__blendMode),i.recycle(this.__nowWorld)}else this.__draw(t,e)},__clip(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawRenderPath(t),this.__.windingRule?t.clip(this.__.windingRule):t.clip())},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{excludeRenderBounds:_n}=mo,pn={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__worldOpacity)if(this.__.__single){if("path"===this.__.eraser)return this.__renderEraser(t,e);const i=t.getSameCanvas(!1,!0);this.__renderBranch(i,e);const s=this.__getNowWorld(e);t.opacity=this.__.opacity,t.copyWorldByReset(i,s,s,this.__.__blendMode,!0),i.recycle(s)}else this.__renderBranch(t,e)},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{const{children:i}=this;for(let s=0,r=i.length;s<r;s++)_n(i[s],e)||i[s].__render(t,e)}},__clip(t,e){if(this.__worldOpacity){const{children:i}=this;for(let s=0,r=i.length;s<r;s++)_n(i[s],e)||i[s].__clip(t,e)}}},{LEAF:gn,create:fn}=i,{toInnerPoint:yn,toOuterPoint:mn,multiplyParent:vn}=x,{toOuterOf:wn}=rt,{copy:xn}=S,{moveLocal:bn,zoomOfLocal:Bn,rotateOfLocal:Rn,skewOfLocal:kn,moveWorld:Cn,zoomOfWorld:Tn,rotateOfWorld:En,skewOfWorld:Pn,transform:On,transformWorld:Ln,setTransform:Sn,getFlipTransform:Mn,getLocalOrigin:Dn,getRelativeWorld:An,drop:Wn}=lo;let In=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 Dt}get __LayoutProcessor(){return Mo}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 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.__layout.update(),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(){const{leafer:t}=this;return t&&t.created&&t.lazyBounds.hit(this.__world)}get pathInputed(){return this.__.__pathInputed}set event(t){let e;for(let i in t)e=t[i],e instanceof Array?this.on(i,e[0],e[1]):this.on(i,e)}constructor(t){this.innerId=fn(gn),this.reset(t)}reset(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.__parentWait?this.__parentWait.push(t):this.__parentWait=[t]}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.__leaferWait?this.__leaferWait.push(t):this.__leaferWait=[t]}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.__leaferWait&&Ro.run(this.__leaferWait)),this.isBranch){const{children:e}=this;for(let i=0,s=e.length;i<s;i++)e[i].__bindLeafer(t)}}set(t){}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){}updateLayout(){this.__layout.update()}forceUpdate(t){void 0===t?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=void 0===e?null:void 0,this[t]=e}forceRender(t){this.forceUpdate("surface")}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(){}__updateContentBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__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=!!t||this.children.some((t=>t.__.mask))}__renderMask(t,e){}__getNowWorld(t){if(t.matrix){this.__cameraWorld||(this.__cameraWorld={});const e=this.__cameraWorld;return vn(this.__world,t.matrix,e,void 0,this.__world),wn(this.__layout.renderBounds,e,e),e}return this.__world}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?An(this,e):this.worldTransform,r=i?t:{};return wn(t,s,r),r}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&xn(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&xn(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),yn(this.worldTransform,t,e,i)}innerToWorld(t,e,i,s){mn(this.worldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getInnerPoint(t,e,i,s){const r=s?t:{};return this.worldToInner(t,r,i,e),r}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const r=s?t:{};return this.worldToLocal(t,r,i,e),r}getLocalPointByInner(t,e,i,s){return this.getWorldPoint(t,this.parent,i,s)}getWorldPoint(t,e,i,s){const r=s?t:{};return this.innerToWorld(t,r,i,e),r}getWorldPointByLocal(t,e,i,s){const r=s?t:{};return this.localToWorld(t,r,i,e),r}getPagePoint(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,i,s)}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e){Sn(this,t,e)}transform(t,e){On(this,t,e)}move(t,e){bn(this,t,e)}scaleOf(t,e,i,s){Bn(this,Dn(this,t),e,i,s)}rotateOf(t,e){Rn(this,Dn(this,t),e)}skewOf(t,e,i,s){kn(this,Dn(this,t),e,i,s)}transformWorld(t,e){Ln(this,t,e)}moveWorld(t,e){Cn(this,t,e)}scaleOfWorld(t,e,i,s){Tn(this,t,e,i,s)}rotateOfWorld(t,e){En(this,t,e)}skewOfWorld(t,e,i,s){Pn(this,t,e,i,s)}flip(t){On(this,Mn(this,t))}scaleResize(t,e=t,i){this.scaleX*=t,this.scaleY*=e}__scaleResize(t,e){}resizeWidth(t){}resizeHeight(t){}__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){}__clip(t,e){}__renderShape(t,e,i,s){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}dropTo(t,e,i){Wn(this,t,e,i)}on(t,e,i){}off(t,e,i){}on_(t,e,i,s){}off_(t){}once(t,e,i){}emit(t,e,i){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,i){i?this.addAttr(t,e,i):Hr(this.prototype,t,e)}static addAttr(t,e,i){i||(i=kr),i(e)(this.prototype,t)}destroy(){if(!this.destroyed){const{parent:t}=this;t&&this.remove(),this.children&&this.removeAll(!0),this.hasEvent(Fo.DESTROY)&&this.emitEvent(new Fo(Fo.DESTROY,this,t)),this.__.destroy(),this.__layout.destroy(),this.__captureMap=this.__bubbleMap=this.__parentWait=this.__leaferWait=null,this.destroyed=!0}}};In=It([Qr(qo),Qr(sn),Qr(cn),Qr(Ao),Qr(un)],In);const{setListWithFn:Fn}=rt,{sort:zn}=wo,{localBoxBounds:Nn,localStrokeBounds:Yn,localRenderBounds:Xn,maskLocalBoxBounds:jn,maskLocalStrokeBounds:Hn,maskLocalRenderBounds:Vn}=mo;let Un=class extends In{__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(){Fn(this.__layout.boxBounds,this.children,this.__hasMask?jn:Nn)}__updateStrokeBounds(){Fn(this.__layout.strokeBounds,this.children,this.__hasMask?Hn:Yn)}__updateRenderBounds(){Fn(this.__layout.renderBounds,this.children,this.__hasMask?Vn:Xn)}__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(zn),this.__layout.affectChildrenSort=t}}add(t,e){t!==this&&(t.parent&&t.parent.remove(t),t.parent=this,void 0===e?this.children.push(t):this.children.splice(e,0,t),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1),t.__layout.boxChanged||t.__layout.boxChange(),t.__layout.matrixChanged||t.__layout.matrixChange(),t.__parentWait&&Ro.run(t.__parentWait),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Fo.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange())}addMany(...t){t.forEach((t=>this.add(t)))}remove(t,e){if(t){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())}else void 0===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)}__preRemove(){this.__hasMask&&this.__updateMask(),this.__hasEraser&&this.__updateEraser(),this.__layout.boxChange(),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}__realRemoveChild(t){t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Fo.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new Fo(t,e,this);e.hasEvent(t)&&e.emitEvent(i),this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}};Un=It([Qr(pn)],Un);class Gn{get length(){return this.list.length}constructor(t){this.reset(),t&&(t instanceof Array?this.addList(t):this.add(t))}has(t){return t&&void 0!==this.keys[t.innerId]}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return void 0===e?-1:e}add(t){const{list:e,keys:i}=this;void 0===i[t.innerId]&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(void 0===i[t.innerId]){const{list:s}=this;for(let t=e,r=s.length;t<r;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,r=e.length;s<r;s++)void 0!==i?this.keys[e[s].innerId]=s-1:e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]);void 0!==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 Gn;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 Kn{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(t instanceof Array?this.addList(t):this.add(t))}has(t){return void 0!==this.keys[t.innerId]}without(t){return void 0===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 qn="1.0.1",Zn={},Qn=vt.get("LeaferCanvas");class Jn extends Gt{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else Qn.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),Qn.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const e=t.devicePixelRatio;if(this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const i=this.view,{x:s,y:r,width:o,height:n}=this.autoBounds.getBoundsFrom(e),a={width:o,height:n,pixelRatio:t.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=i;t.marginLeft=s+"px",t.marginTop=r+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(t){const e={};St.copyAttrs(e,this,Ut),this.resize(t),void 0!==this.width&&this.resizeListener(new Yo(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}rr(CanvasRenderingContext2D.prototype),rr(Path2D.prototype);const{mineType:$n,fileType:ta}=or;function ea(i,s){t.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL($n(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,$n(e),i))),canvasSaveAs:(e,i,s)=>{const r=e.toDataURL($n(ta(i)),s);return t.origin.download(r,i)},download:(t,e)=>new Promise((i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()})),loadImage:e=>new Promise(((i,s)=>{const r=new Image,{crossOrigin:o}=t.image;o&&(r.setAttribute("crossOrigin",o),r.crossOrigin=o),r.onload=()=>{i(r)},r.onerror=t=>{s(t)},r.src=t.image.getRealURL(e)}))},t.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.canvas=e.canvas(),t.conicGradientSupport=!!t.canvas.context.createConicGradient}Object.assign(e,{canvas:(t,e)=>new Jn(t,e),image:t=>new pr(t)}),t.name="web",t.isMobile="ontouchstart"in window,t.requestRender=function(t){window.requestAnimationFrame(t)},gr(t,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:ia}=navigator;ia.indexOf("Firefox")>-1?(t.conicGradientRotate90=!0,t.intWheelDeltaY=!0,t.syncDomFont=!0):ia.indexOf("Safari")>-1&&-1===ia.indexOf("Chrome")&&(t.fullImageShadow=!0),ia.indexOf("Windows")>-1?(t.os="Windows",t.intWheelDeltaY=!0):ia.indexOf("Mac")>-1?t.os="Mac":ia.indexOf("Linux")>-1&&(t.os="Linux");class sa{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new Gn;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 Gn,this.target=t,e&&(this.config=St.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(Vo.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===Fo.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 Xo(Xo.DATA,{updatedList:this.updatedList})),this.__updatedList=new Gn,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(zo.CHANGE,this.__onAttrChange,this),t.on_([Fo.ADD,Fo.REMOVE],this.__onChildEvent,this),t.on_(Xo.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:ra,updateBounds:oa,updateAllWorldOpacity:na}=lo,{pushAllChildBranch:aa,pushAllParent:ha}=wo;const{worldBounds:la}=mo,da={x:0,y:0,width:1e5,height:1e5};class ca{constructor(t){this.updatedBounds=new ht,this.beforeBounds=new ht,this.afterBounds=new ht,t instanceof Array&&(t=new Gn(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,la)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(da):this.afterBounds.setListWithFn(t,la),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:ua,updateAllChange:_a}=lo,pa=vt.get("Layouter");class ga{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new Kn,this.target=t,e&&(this.config=St.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.running)return;const{target:t}=this;this.times=0;try{t.emit(jo.START),this.layoutOnce(),t.emitEvent(new jo(jo.END,this.layoutedBlocks,this.times))}catch(t){pa.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?pa.warn("layouting"):this.times>3?pa.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Xo.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=Bt.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:r,LAYOUT:o,AFTER:n}=jo,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new jo(r,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?(ra(t,!0),e.add(t),t.isBranch&&aa(t,e),ha(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ha(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((r=>{e=t.levelMap[r];for(let t=0,r=e.length;t<r;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||oa(s[t])}oa(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&na(t),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new jo(o,a,this.times)),i.emitEvent(new jo(n,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,Bt.end(e)}fullLayout(){const t=Bt.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:r}=jo,o=this.getBlocks(new Gn(e));e.emitEvent(new jo(i,o,this.times)),ga.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new jo(s,o,this.times)),e.emitEvent(new jo(r,o,this.times)),this.addBlocks(o),Bt.end(t)}static fullLayout(t){ua(t,!0),t.isBranch?wo.updateBounds(t):lo.updateBounds(t),_a(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ca([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ca(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(){const{target:t}=this;this.__eventIds=[t.on_(jo.REQUEST,this.layout,this),t.on_(jo.AGAIN,this.layoutAgain,this),t.on_(Xo.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const fa=vt.get("Renderer");class ya{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:60},this.target=t,this.canvas=e,i&&(this.config=St.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(jo.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new ht,fa.log(e.innerName,"---\x3e");try{this.emitRender(Vo.START),this.renderOnce(t),this.emitRender(Vo.END,this.totalBounds),dr.clearRecycled()}catch(t){this.rendering=!1,fa.error(t)}fa.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return fa.warn("rendering");if(this.times>3)return fa.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new ht,this.renderOptions={},t)this.emitRender(Vo.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Vo.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Vo.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Vo.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;if(!e)return fa.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=Bt.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),r=t.includes(this.target.__world),o=new ht(s);i.save(),r&&!vt.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,r,o),i.restore(),Bt.end(e)}fullRender(){const t=Bt.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),Bt.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),vt.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),vt.showHitView&&this.renderHitView(s),vt.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}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=Date.now();t.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(Ho.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(Vo.NEXT)),this.target&&this.__requestRender()}))}__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.changed=!0}}__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||fa.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 Vo(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Vo.REQUEST,this.update,this),t.on_(jo.END,this.__onLayoutEnd,this),t.on_(Vo.AGAIN,this.renderAgain,this),t.on_(Yo.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ma}=rt;class va{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,r=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 Gn(i.findList),i.findList||this.hitBranch(o);const{list:n}=this.findList,a=this.getBestMatchLeaf(n,i.bottomList,r),h=r?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:n.length?this.getThroughPath(n):h}:{path:h,target:a}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new Gn;const{x:s,y:r}=this.point,o={x:s,y:r,radiusX:0,radiusY:0};for(let s=0,r=t.length;s<r;s++)if(e=t[s],(i||lo.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.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),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new Gn;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new Gn;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new Gn,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,r,o;for(let t=0,n=i.length;t<n;t++){s=i[t],r=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!r||!r.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:r}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ma(i.__world,r),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,r)):s&&this.hitChild(i,r))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:wa,NoAndSkip:xa,YesAndSkip:ba}=At,Ba={},Ra={},ka={};class Ca{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(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,e&&(this.config=St.default(e,this.config)),this.picker=new va(t,this),this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const r=this.getByInnerId(t,e);return i?r:r?[r]:[];case"string":switch(t[0]){case"#":Ba.id=t.substring(1),t=Ba;break;case".":Ra.className=t.substring(1),t=Ra;break;default:ka.tag=t,t=ka}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:s}=t,r=s instanceof Array;return this.getByMethod(r?this.methods.tags:this.methods.tag,e,i,r?St.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,s)}}getByPoint(e,i,s){return"node"===t.name&&this.target.emit(jo.CHECK_UPDATE),this.picker.getByPoint(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&&lo.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 r=i?null:[];return this.eachFind(this.toChildren(e),t,r,s),r||this.findLeaf}eachFind(t,e,i,s){let r,o;for(let n=0,a=t.length;n<a;n++){if(r=t[n],o=e(r,s),o===wa||o===ba){if(!i)return void(this.findLeaf=r);i.push(r)}r.isBranch&&o<xa&&this.eachFind(r.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_(Fo.REMOVE,this.__onRemoveChild,this),this.target.on_(zo.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(e,{watcher:(t,e)=>new sa(t,e),layouter:(t,e)=>new ga(t,e),renderer:(t,e,i)=>new ya(t,e,i),selector:(t,e)=>new Ca(t,e)}),t.layout=ga.fullLayout;const Ta={},Ea={},Pa={},Oa={},La={},Sa={},Ma={},Da={},Aa={};function Wa(t){return yr(t,(t=>({set(e){this.__setAttr(t,e),this.waitLeafer((()=>{Aa.setStyle&&Aa.setStyle(this,t+"Style",e)}))}})))}function Ia(t){return yr(t,(t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,Lr(this)}}})))}function Fa(t){return yr(t,(t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function za(t){return yr(t,(t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function Na(){return(t,e)=>{const i="_"+e;gr(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}})}}const{parse:Ya}=pi,Xa={},ja=vt.get("UIData");class Ha extends Dt{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}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.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,ja.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,ja.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=Xa)):(this.__isFills&&(this.__removeInput("fill"),La.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Xa)):(this.__isStrokes&&(this.__removeInput("stroke"),La.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=Ya(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&Oa.compute("fill",this.__leaf),e&&Oa.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Va={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class Ua extends Ha{}class Ga extends Ua{get __boxStroke(){return!this.__pathInputed}}class Ka extends Ua{}class qa extends Ga{}class Za extends Ha{}class Qa extends Ha{get __boxStroke(){return!this.__pathInputed}}class Ja extends Ha{get __boxStroke(){return!this.__pathInputed}}class $a extends Ha{}class th extends Ha{}class eh extends Ha{}class ih extends Ua{}const sh={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class rh extends Ha{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=sh[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class oh extends Qa{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class nh extends Qa{}const ah={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:r}=i;if((i.stroke||"all"===i.hitStroke)&&r&&"inside"!==s&&(e=t="center"===s?r/2:r,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:r;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*r),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:r}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let o=t=Math.ceil(t);return i&&i.forEach((t=>{o=Math.max(o,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),r&&(o=Math.max(o,r)),this.__layout.renderShapeSpread=o,t+(this.__layout.strokeSpread||0)}},hh={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:r}=this.__;t.__useEffect=!!(e||i||s||r)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){lh(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:r,__drawAfterFill:o}=i;if(this.__drawRenderPath(t),i.__useEffect){const n=Oa.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:a,innerShadow:h}=i;a&&Ma.shadow(this,t,n),s&&(i.__isFills?Oa.fills(s,this,t):Oa.fill(s,this,t)),o&&this.__drawAfterFill(t,e),h&&Ma.innerShadow(this,t,n),r&&(i.__isStrokes?Oa.strokes(r,this,t):Oa.stroke(r,this,t)),n.worldCanvas&&n.worldCanvas.recycle(),n.canvas.recycle()}else s&&(i.__isFills?Oa.fills(s,this,t):Oa.fill(s,this,t)),o&&this.__drawAfterFill(t,e),r&&(i.__isStrokes?Oa.strokes(r,this,t):Oa.stroke(r,this,t))}else i.__pathInputed?lh(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:r,stroke:o}=this.__;this.__drawRenderPath(t),r&&!i&&(this.__.__pixelFill?Oa.fills(r,this,t):Oa.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),o&&!s&&(this.__.__pixelStroke?Oa.strokes(o,this,t):Oa.stroke("#000000",this,t))}}};function lh(t,e,i){const{fill:s,stroke:r,__drawAfterFill:o}=t.__;t.__drawRenderPath(e),s&&Oa.fill(s,t,e),o&&t.__drawAfterFill(e,i),r&&Oa.stroke(r,t,e)}const dh={__drawFast(t,e){let{width:i,height:s,fill:r,stroke:o,__drawAfterFill:n}=this.__;if(r&&(t.fillStyle=r,t.fillRect(0,0,i,s)),n&&this.__drawAfterFill(t,e),o){const{strokeAlign:r,__strokeWidth:n}=this.__;if(!n)return;t.setStroke(o,n,this.__);const a=n/2;switch(r){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=n,s-=n,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(a,a,i,s),t.restore()):t.strokeRect(a,a,i,s);break;case"outside":t.strokeRect(-a,-a,i+n,s+n)}}}};var ch;let uh=ch=class extends In{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){const{path:t}=this.__;return ir.set(this.path=t||[]),t||this.__drawPathByBox(ir),ir}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(ir.set(i=[]),this.__drawPathByBox(ir)),t?pi.toCanvasData(i,!0):i}getPathString(t,e){return pi.stringify(this.getPath(t,e))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Da.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?er.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Pa.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?gs.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:r}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:o}=this.__;t.roundRect(e,i,s,r,"number"==typeof o?[o]:o)}else t.rect(e,i,s,r)}export(t,e){return Da.export(this,t,e)}clone(){return ch.one(this.toJSON())}static one(t,e,i,s,r){return Ct.get(t.tag||this.prototype.__tag,t,e,i,s,r)}static registerUI(){Jr()(this)}static registerData(t){Xr(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,super.destroy()}};It([Xr(Ha)],uh.prototype,"__",void 0),It([Na()],uh.prototype,"zoomLayer",void 0),It([wr("")],uh.prototype,"id",void 0),It([wr("")],uh.prototype,"name",void 0),It([wr("")],uh.prototype,"className",void 0),It([Dr("pass-through")],uh.prototype,"blendMode",void 0),It([Ar(1)],uh.prototype,"opacity",void 0),It([Wr(!0)],uh.prototype,"visible",void 0),It([Wa(!1)],uh.prototype,"selected",void 0),It([Wa(!1)],uh.prototype,"disabled",void 0),It([Dr(!1)],uh.prototype,"locked",void 0),It([Ir(0)],uh.prototype,"zIndex",void 0),It([Fr(!1)],uh.prototype,"mask",void 0),It([zr(!1)],uh.prototype,"eraser",void 0),It([xr(0,!0)],uh.prototype,"x",void 0),It([xr(0,!0)],uh.prototype,"y",void 0),It([kr(100,!0)],uh.prototype,"width",void 0),It([kr(100,!0)],uh.prototype,"height",void 0),It([Br(1,!0)],uh.prototype,"scaleX",void 0),It([Br(1,!0)],uh.prototype,"scaleY",void 0),It([Rr(0,!0)],uh.prototype,"rotation",void 0),It([Rr(0,!0)],uh.prototype,"skewX",void 0),It([Rr(0,!0)],uh.prototype,"skewY",void 0),It([xr(0,!0)],uh.prototype,"offsetX",void 0),It([xr(0,!0)],uh.prototype,"offsetY",void 0),It([xr(0,!0)],uh.prototype,"scrollX",void 0),It([xr(0,!0)],uh.prototype,"scrollY",void 0),It([br()],uh.prototype,"origin",void 0),It([br()],uh.prototype,"around",void 0),It([wr(!1)],uh.prototype,"lazy",void 0),It([Cr(1)],uh.prototype,"pixelRatio",void 0),It([Er()],uh.prototype,"path",void 0),It([Pr()],uh.prototype,"windingRule",void 0),It([Pr(!0)],uh.prototype,"closed",void 0),It([br(!1)],uh.prototype,"flow",void 0),It([kr(0)],uh.prototype,"padding",void 0),It([kr(0)],uh.prototype,"gap",void 0),It([kr("top-left")],uh.prototype,"flowAlign",void 0),It([kr(!1)],uh.prototype,"flowWrap",void 0),It([kr("box")],uh.prototype,"itemBox",void 0),It([kr(!0)],uh.prototype,"inFlow",void 0),It([kr()],uh.prototype,"autoWidth",void 0),It([kr()],uh.prototype,"autoHeight",void 0),It([kr()],uh.prototype,"lockRatio",void 0),It([kr()],uh.prototype,"autoBox",void 0),It([kr()],uh.prototype,"widthRange",void 0),It([kr()],uh.prototype,"heightRange",void 0),It([wr(!1)],uh.prototype,"draggable",void 0),It([wr()],uh.prototype,"dragBounds",void 0),It([wr(!1)],uh.prototype,"editable",void 0),It([Nr(!0)],uh.prototype,"hittable",void 0),It([Nr("path")],uh.prototype,"hitFill",void 0),It([Sr("path")],uh.prototype,"hitStroke",void 0),It([Nr(!1)],uh.prototype,"hitBox",void 0),It([Nr(!0)],uh.prototype,"hitChildren",void 0),It([Nr(!0)],uh.prototype,"hitSelf",void 0),It([Nr()],uh.prototype,"hitRadius",void 0),It([Yr("")],uh.prototype,"cursor",void 0),It([Dr()],uh.prototype,"fill",void 0),It([Sr()],uh.prototype,"stroke",void 0),It([Sr("inside")],uh.prototype,"strokeAlign",void 0),It([Sr(1)],uh.prototype,"strokeWidth",void 0),It([Sr(!1)],uh.prototype,"strokeWidthFixed",void 0),It([Sr("none")],uh.prototype,"strokeCap",void 0),It([Sr("miter")],uh.prototype,"strokeJoin",void 0),It([Sr()],uh.prototype,"dashPattern",void 0),It([Sr()],uh.prototype,"dashOffset",void 0),It([Sr(10)],uh.prototype,"miterLimit",void 0),It([Ia("none")],uh.prototype,"startArrow",void 0),It([Ia("none")],uh.prototype,"endArrow",void 0),It([Pr(0)],uh.prototype,"cornerRadius",void 0),It([Pr()],uh.prototype,"cornerSmoothing",void 0),It([Fa()],uh.prototype,"shadow",void 0),It([Fa()],uh.prototype,"innerShadow",void 0),It([Fa()],uh.prototype,"blur",void 0),It([Fa()],uh.prototype,"backgroundBlur",void 0),It([Fa()],uh.prototype,"grayscale",void 0),It([wr()],uh.prototype,"normalStyle",void 0),It([wr()],uh.prototype,"hoverStyle",void 0),It([wr()],uh.prototype,"pressStyle",void 0),It([wr()],uh.prototype,"focusStyle",void 0),It([wr()],uh.prototype,"selectedStyle",void 0),It([wr()],uh.prototype,"disabledStyle",void 0),It([wr({})],uh.prototype,"data",void 0),It([Kr(In.prototype.reset)],uh.prototype,"reset",null),uh=ch=It([Qr(ah),Qr(hh),qr()],uh);let _h=class extends uh{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let i;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t),e.forEach((t=>{i=t.__?t:Ct.get(t.tag,t),this.add(i)})),t.children=e}else super.set(t)}toJSON(t){const e=super.toJSON(t);return 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 ph;It([Xr(Ua)],_h.prototype,"__",void 0),_h=It([Qr(Un),Jr()],_h);const gh=vt.get("Leafer");let fh=ph=class extends _h{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&dr.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()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},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),ph.list.add(this)}init(t,i){if(this.canvas)return;let s;this.__setLeafer(this),t&&St.assign(this.config,t);const{config:r}=this;this.initType(r.type);const o=this.canvas=e.canvas(r);this.__controllers.push(this.renderer=e.renderer(this,o,r),this.watcher=e.watcher(this,r),this.layouter=e.layouter(this,r)),this.isApp&&this.__setApp(),this.__checkAutoLayout(r,i),this.view=o.view,i?(this.__bindApp(i),s=i.running):(this.selector=e.selector(this),this.interaction=e.interaction(this,o,this.selector,r),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=e.hitCanvasManager()),this.canvasManager=new Lt,s=r.start),this.hittable=r.hittable,this.fill=r.fill,this.canvasManager.add(o),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),Ro.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(Uo.RESTART):this.emitLeafer(Uo.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(Uo.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=St.copyAttrs({},t,Ut);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new ht(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}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=St.copyAttrs({},this.canvas,Ut);e.resize(t),this.updateLazyBounds(),this.__onResize(new Yo(t,i))}__onResize(t){this.emitEvent(t),St.copyAttrs(this.__,t,Ut),t.width&&t.height||gh.warn("w = 0 or h = 0"),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(t,e){e||(t.width&&t.height||(this.autoLayout=new dt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Ut.includes(t)?(e||gh.warn(t+" is 0"),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())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Ut.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=St.copyAttrs({},this.canvas,Ut);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(Uo.BEFORE_READY),this.emitLeafer(Uo.READY),this.emitLeafer(Uo.AFTER_READY),Ro.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Uo.VIEW_READY),Ro.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){Ro.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(Uo.VIEW_COMPLETED),Ro.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)}zoom(t,e,i){return gh.error("need @leafer-in/view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new Uo(t,this))}__listenEvents(){const t=Bt.start("FirstCreate "+this.innerName);this.once(Uo.START,(()=>Bt.end(t))),this.once(jo.START,(()=>this.updateLazyBounds())),this.once(jo.END,(()=>this.__onReady())),this.once(Vo.START,(()=>this.__onCreated())),this.once(Vo.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(Xo.DATA,this.__onWatchData,this),this.on_(Vo.NEXT,this.__onNextRender,this),this.on_(jo.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){ph.list.remove(this);try{this.stop(),this.emitEvent(new Uo(Uo.END,this)),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.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{dr.clearRecycled()}),100)}catch(t){gh.error(t)}}};t?e():setTimeout(e)}};fh.list=new Gn,It([Xr(Ka)],fh.prototype,"__",void 0),It([kr()],fh.prototype,"pixelRatio",void 0),fh=ph=It([Jr()],fh);let yh=class extends uh{get __tag(){return"Rect"}constructor(t){super(t)}};It([Xr(Qa)],yh.prototype,"__",void 0),yh=It([Qr(dh),qr(),Jr()],yh);const mh=yh.prototype,vh=_h.prototype,wh={},{copy:xh,add:bh,includes:Bh}=rt;let Rh=class extends _h{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(){const t=this.__;if(this.children.length){if(t.__autoSide){if(this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.height+=e.y,e.width=t.width,e.x=e.y=0),t.__autoHeight||(e.width+=e.x,e.height=t.height,e.y=e.x=0)}}else this.__updateRectBoxBounds();t.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),xh(wh,e),this.__updateRectRenderBounds(),t=!Bh(e,wh)||void 0):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),t&&!(this.__.__drawAfterFill="hide"===this.__.overflow)&&bh(e,wh)}__updateRectRenderBounds(){}__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))}__drawAfterFill(t,e){const{length:i}=this.children;this.isOverflow?(t.save(),t.clip(),i&&this.__renderGroup(t,e),t.restore()):i&&this.__renderGroup(t,e),this.__.stroke&&i&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};It([Xr(Ga)],Rh.prototype,"__",void 0),It([wr(!1)],Rh.prototype,"resizeChildren",void 0),It([Mr("show")],Rh.prototype,"overflow",void 0),It([Kr(mh.__updateStrokeSpread)],Rh.prototype,"__updateStrokeSpread",null),It([Kr(mh.__updateRenderSpread)],Rh.prototype,"__updateRectRenderSpread",null),It([Kr(mh.__updateBoxBounds)],Rh.prototype,"__updateRectBoxBounds",null),It([Kr(mh.__updateStrokeBounds)],Rh.prototype,"__updateStrokeBounds",null),It([Kr(mh.__updateRenderBounds)],Rh.prototype,"__updateRectRenderBounds",null),It([Kr(mh.__updateChange)],Rh.prototype,"__updateRectChange",null),It([Kr(mh.__render)],Rh.prototype,"__renderRect",null),It([Kr(vh.__render)],Rh.prototype,"__renderGroup",null),Rh=It([qr(),Jr()],Rh);let kh=class extends Rh{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};It([Xr(qa)],kh.prototype,"__",void 0),It([Dr("#FFFFFF")],kh.prototype,"fill",void 0),It([Mr("hide")],kh.prototype,"overflow",void 0),kh=It([Jr()],kh);const{moveTo:Ch,closePath:Th,ellipse:Eh}=Ii;let Ph=class extends uh{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:i,innerRadius:s,startAngle:r,endAngle:o}=this.__,n=e/2,a=i/2,h=this.__.path=[];s?(r||o?(s<1&&Eh(h,n,a,n*s,a*s,0,r,o,!1),Eh(h,n,a,n,a,0,o,r,!0),s<1&&Th(h)):(s<1&&(Eh(h,n,a,n*s,a*s),Ch(h,e,a)),Eh(h,n,a,n,a,0,360,0,!0)),t.ellipseToCurve&&(this.__.path=this.getPath(!0))):r||o?(Ch(h,n,a),Eh(h,n,a,n,a,0,r,o,!1),Th(h)):Eh(h,n,a,n,a)}};It([Xr(Ja)],Ph.prototype,"__",void 0),It([Pr(0)],Ph.prototype,"innerRadius",void 0),It([Pr(0)],Ph.prototype,"startAngle",void 0),It([Pr(0)],Ph.prototype,"endAngle",void 0),Ph=It([Jr()],Ph);const{moveTo:Oh,lineTo:Lh,drawPoints:Sh}=Ii,{rotate:Mh,getAngle:Dh,getDistance:Ah,defaultPoint:Wh}=S,{toBounds:Ih}=Gs;let Fh=class extends uh{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&Mh(i,e),i}set toPoint(t){this.width=Ah(Wh,t),this.rotation=Dh(Wh,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?Sh(e,t.points,!1,t.closed):(Oh(e,0,0),Lh(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(Sh(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&Pa.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?Ih(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};It([Xr(Za)],Fh.prototype,"__",void 0),It([Or("center")],Fh.prototype,"strokeAlign",void 0),It([kr(0)],Fh.prototype,"height",void 0),It([Pr()],Fh.prototype,"points",void 0),It([Pr(0)],Fh.prototype,"curve",void 0),It([Pr(!1)],Fh.prototype,"closed",void 0),Fh=It([Jr()],Fh);const{sin:zh,cos:Nh,PI:Yh}=Math,{moveTo:Xh,lineTo:jh,closePath:Hh,drawPoints:Vh}=Ii,Uh=Fh.prototype;let Gh=class extends uh{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Vh(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,r=e/2,o=i/2;Xh(t,r,0);for(let e=1;e<s;e++)jh(t,r+r*zh(2*e*Yh/s),o-o*Nh(2*e*Yh/s))}Hh(t)}__updateRenderPath(){}__updateBoxBounds(){}};It([Xr($a)],Gh.prototype,"__",void 0),It([Pr(3)],Gh.prototype,"sides",void 0),It([Pr()],Gh.prototype,"points",void 0),It([Pr(0)],Gh.prototype,"curve",void 0),It([Kr(Uh.__updateRenderPath)],Gh.prototype,"__updateRenderPath",null),It([Kr(Uh.__updateBoxBounds)],Gh.prototype,"__updateBoxBounds",null),Gh=It([qr(),Jr()],Gh);const{sin:Kh,cos:qh,PI:Zh}=Math,{moveTo:Qh,lineTo:Jh,closePath:$h}=Ii;let tl=class extends uh{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,r=t/2,o=e/2,n=this.__.path=[];Qh(n,r,0);for(let t=1;t<2*i;t++)Jh(n,r+(t%2==0?r:r*s)*Kh(t*Zh/i),o-(t%2==0?o:o*s)*qh(t*Zh/i));$h(n)}};It([Xr(th)],tl.prototype,"__",void 0),It([Pr(5)],tl.prototype,"corners",void 0),It([Pr(.382)],tl.prototype,"innerRadius",void 0),tl=It([Jr()],tl);let el=class extends yh{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(No.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};It([Xr(oh)],el.prototype,"__",void 0),It([kr("")],el.prototype,"url",void 0),el=It([Jr()],el);let il=class extends yh{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=e.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0}draw(t,e,i,s){t.__layout.update();const r=new z(t.__world).invert(),o=new z;e&&o.translate(e.x,e.y),i&&("number"==typeof i?o.scale(i):o.scale(i.x,i.y)),s&&o.rotate(s),r.multiplyParent(o),t.__render(this.canvas,{matrix:r.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const i=this.canvas.view,{width:s,height:r}=this;this.__.cornerRadius||this.pathInputed?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,r),t.restore()):t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,r)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};It([Xr(nh)],il.prototype,"__",void 0),It([za(100)],il.prototype,"width",void 0),It([za(100)],il.prototype,"height",void 0),It([za(t.devicePixelRatio)],il.prototype,"pixelRatio",void 0),It([za(!0)],il.prototype,"smooth",void 0),It([za()],il.prototype,"contextSettings",void 0),il=It([Jr()],il);const{copyAndSpread:sl,includes:rl,isSame:ol,spread:nl,setList:al}=rt;let hl=class extends uh{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:i,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-i,s.width,e)))}__drawPathByData(t,e){const{x:i,y:s,width:r,height:o}=this.__layout.boxBounds;t.rect(i,s,r,o)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=Ta.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:r,fontSize:o,fontWeight:n,italic:h,textCase:l,textOverflow:d,padding:c}=t,u=t.__autoWidth,_=t.__autoHeight;t.__lineHeight=Va.number(i,o),t.__letterSpacing=Va.number(s,o),t.__padding=c?a.fourNumber(c):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${h?"italic ":""}${"small-caps"===l?"small-caps ":""}${"normal"!==n?n+" ":""}${o}px ${r}`,t.__clipText="show"!==d&&!t.__autoSize,this.__updateTextDrawData();const{bounds:p}=t.__textDrawData,g=e.boxBounds;if(t.__lineHeight<o&&nl(p,o/2),u||_){if(g.x=u?p.x:0,g.y=_?p.y:0,g.width=u?p.width:t.width,g.height=_?p.height:t.height,c){const[e,i,s,r]=t.__padding;u&&(g.x-=r,g.width+=i+r),_&&(g.y-=e,g.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();h&&(g.width+=.16*o);const f=rl(g,p)?g:p;ol(f,e.contentBounds)?t.__textBoxBounds=f:(e.contentBounds=f,e.renderChanged=!0,al(t.__textBoxBounds={},[g,p]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){sl(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};It([Xr(rh)],hl.prototype,"__",void 0),It([kr(0)],hl.prototype,"width",void 0),It([kr(0)],hl.prototype,"height",void 0),It([wr(!1)],hl.prototype,"resizeFontSize",void 0),It([Dr("#000000")],hl.prototype,"fill",void 0),It([Or("outside")],hl.prototype,"strokeAlign",void 0),It([Nr("all")],hl.prototype,"hitFill",void 0),It([kr("")],hl.prototype,"text",void 0),It([kr("L")],hl.prototype,"fontFamily",void 0),It([kr(12)],hl.prototype,"fontSize",void 0),It([kr("normal")],hl.prototype,"fontWeight",void 0),It([kr(!1)],hl.prototype,"italic",void 0),It([kr("none")],hl.prototype,"textCase",void 0),It([kr("none")],hl.prototype,"textDecoration",void 0),It([kr(0)],hl.prototype,"letterSpacing",void 0),It([kr({type:"percent",value:1.5})],hl.prototype,"lineHeight",void 0),It([kr(0)],hl.prototype,"paraIndent",void 0),It([kr(0)],hl.prototype,"paraSpacing",void 0),It([kr("left")],hl.prototype,"textAlign",void 0),It([kr("top")],hl.prototype,"verticalAlign",void 0),It([kr("normal")],hl.prototype,"textWrap",void 0),It([kr("show")],hl.prototype,"textOverflow",void 0),hl=It([Jr()],hl);let ll=class extends uh{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};It([Xr(eh)],ll.prototype,"__",void 0),It([Or("center")],ll.prototype,"strokeAlign",void 0),ll=It([Jr()],ll);let dl=class extends _h{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new ll(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,r,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,r){return this}ellipse(t,e,i,s,r,o,n,a){return this}arc(t,e,i,s,r,o){return this}arcTo(t,e,i,s,r){return this}drawEllipse(t,e,i,s,r,o,n,a){return this}drawArc(t,e,i,s,r,o){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.forceUpdate("path")}};It([Xr(ih)],dl.prototype,"__",void 0),It([(t,e)=>{gr(t,e,{get(){return this.__path}})}],dl.prototype,"path",void 0),dl=It([Qr(ts,["set","beginPath","path"]),Jr()],dl);let cl=class extends fh{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){super(t,e)}init(t,i){if(super.init(t,i),t){const{ground:i,tree:s,sky:r,editor:o}=t;i&&(this.ground=this.addLeafer(i)),(s||o)&&(this.tree=this.addLeafer(s)),(r||o)&&(this.sky=this.addLeafer(r||{type:"draw",usePartRender:!1})),o&&(this.editor=e.editor(o),this.sky.add(this.editor))}}__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(),this.__eventIds.push(this.on_(zo.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}forceRender(t){this.children.forEach((e=>e.forceRender(t)))}addLeafer(t){const e=new fh(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),void 0!==e&&(t.canvas.childIndex=e),this.__listenChildEvents(t)}__onPropertyChange(){vt.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__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){if(t.context){if(e.matrix){const{a:i,b:s,c:r,d:o,e:n,f:a}=e.matrix;t.setTransform(i,s,r,o,n,a)}this.children.forEach((e=>t.copyWorld(e.canvas)))}}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>t.__layout.update()))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&St.assign(e,t),this.autoLayout&&St.copyAttrs(e,this,Ut),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(jo.END,(()=>this.__onReady())),t.once(Vo.START,(()=>this.__onCreated())),t.once(Vo.END,(()=>this.__onViewReady())),this.realCanvas&&this.__eventIds.push(t.on_(Vo.END,this.__onChildRenderEnd,this))}};cl=It([Jr()],cl);const ul={},_l={isHoldSpaceKey:()=>_l.isHold("Space"),isHold:t=>ul[t],setDownCode(t){ul[t]||(ul[t]=!0)},setUpCode(t){ul[t]=!1}},pl={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 gl extends Io{get spaceKey(){return _l.isHoldSpaceKey()}get left(){return pl.left(this)}get right(){return pl.right(this)}get middle(){return pl.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}getPage(){return this.current.getPagePoint(this)}getInner(t){return t||(t=this.current),t.getInnerPoint(this)}getLocal(t){return t||(t=this.current),t.getLocalPoint(this)}static changeName(t,e){Pt.changeName(t,e)}}let fl=class extends gl{};fl.POINTER="pointer",fl.BEFORE_DOWN="pointer.before_down",fl.BEFORE_MOVE="pointer.before_move",fl.BEFORE_UP="pointer.before_up",fl.DOWN="pointer.down",fl.MOVE="pointer.move",fl.UP="pointer.up",fl.OVER="pointer.over",fl.OUT="pointer.out",fl.ENTER="pointer.enter",fl.LEAVE="pointer.leave",fl.TAP="tap",fl.DOUBLE_TAP="double_tap",fl.CLICK="click",fl.DOUBLE_CLICK="double_click",fl.LONG_PRESS="long_press",fl.LONG_TAP="long_tap",fl.MENU="pointer.menu",fl.MENU_TAP="pointer.menu_tap",fl=It([$r()],fl);const yl={};let ml=class extends fl{static setList(t){this.list=t instanceof Gn?t:new Gn(t)}static setData(t){this.data=t}static getValidMove(t,e,i){const{draggable:s,dragBounds:r,x:o,y:n}=t,a=t.getLocalPoint(i,null,!0);return a.x+=e.x-o,a.y+=e.y-n,r&&this.getMoveInDragBounds(t.__local,"parent"===r?t.parent.boxBounds:r,a,!0),"x"===s&&(a.y=0),"y"===s&&(a.x=0),a}static getMoveInDragBounds(t,e,i,s){const r=t.x+i.x,o=t.y+i.y,n=r+t.width,a=o+t.height,h=e.x+e.width,l=e.y+e.height;return s||(i=Object.assign({},i)),rt.includes(t,e)?(r>e.x?i.x+=e.x-r:n<h&&(i.x+=h-n),o>e.y?i.y+=e.y-o:a<l&&(i.y+=l-a)):(r<e.x?i.x+=e.x-r:n>h&&(i.x+=h-n),o<e.y?i.y+=e.y-o:a>l&&(i.y+=l-a)),i}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(yl,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(yl,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(yl,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.getPage(),i={};return rt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),rt.unsign(i),i}assignMove(t){yl.x=t?this.totalX:this.moveX,yl.y=t?this.totalY:this.moveY}};ml.BEFORE_DRAG="drag.before_drag",ml.START="drag.start",ml.DRAG="drag",ml.END="drag.end",ml.OVER="drag.over",ml.OUT="drag.out",ml.ENTER="drag.enter",ml.LEAVE="drag.leave",ml=It([$r()],ml);let vl=class extends fl{static setList(t){ml.setList(t)}static setData(t){ml.setData(t)}};vl.DROP="drop",vl=It([$r()],vl);let wl=class extends ml{};wl.BEFORE_MOVE="move.before_move",wl.START="move.start",wl.MOVE="move",wl.END="move.end",wl=It([$r()],wl);let xl=class extends gl{};xl.BEFORE_ROTATE="rotate.before_rotate",xl.START="rotate.start",xl.ROTATE="rotate",xl.END="rotate.end",xl=It([$r()],xl);let bl=class extends ml{};bl.SWIPE="swipe",bl.LEFT="swipe.left",bl.RIGHT="swipe.right",bl.UP="swipe.up",bl.DOWN="swipe.down",bl=It([$r()],bl);let Bl=class extends gl{};Bl.BEFORE_ZOOM="zoom.before_zoom",Bl.START="zoom.start",Bl.ZOOM="zoom",Bl.END="zoom.end",Bl=It([$r()],Bl);let Rl=class extends gl{};function kl(t){t.isApp||t.__eventIds.push(t.on_(wl.BEFORE_MOVE,(e=>{t.zoomLayer.move(t.getValidMove(e.moveX,e.moveY))})),t.on_(Bl.BEFORE_ZOOM,(e=>{const{zoomLayer:i}=t,s=t.getValidScale(e.scale);1!==s&&(S.scaleOf(i,e,s),i.scale=i.__.scaleX*s)})))}Rl.DOWN="key.down",Rl.HOLD="key.hold",Rl.UP="key.up",Rl=It([$r()],Rl);const Cl=vt.get("LeaferTypeCreator"),Tl={list:{},register(t,e){El[t]?Cl.repeat(t):El[t]=e},run(t,e){const i=El[t];i?i(e):Cl.error("no",t)}},{list:El,register:Pl}=Tl;Pl("draw",(()=>{})),Pl("custom",(()=>{})),Pl("design",kl),Pl("document",(function(t){kl(t),t.config.move.scroll="limit",t.config.zoom.min=1}));const Ol=fh.prototype;Ol.initType=function(t){Tl.run(t,this)},Ol.getValidMove=function(t,e){const{scroll:i,disabled:s}=this.app.config.move;if(i&&(Math.abs(t)>Math.abs(e)?e=0:t=0,"limit"===i)){const{x:i,y:s,width:r,height:o}=new ht(this.__world).addPoint(this.zoomLayer),n=i+r-this.width,a=s+o-this.height;i>=0&&n<=0?t=0:t>0?i+t>0&&(t=-i):t<0&&n+t<0&&(t=-n),s>=0&&a<=0?e=0:e>0?s+e>0&&(e=-s):e<0&&a+e<0&&(e=-a)}return{x:s?0:t,y:s?0:e}},Ol.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:r}=this.app.config.zoom,o=Math.abs(e*t);return o<i?t=i/e:o>s&&(t=s/e),r?1:t};class Ll{get transforming(){return!!(this.moveData||this.zoomData||this.rotateData)}constructor(t){this.interaction=t}move(t){const{interaction:e}=this;if(t.moveType||(t.moveType="move"),!this.moveData){const{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0}),e.cancelHover(),e.emit(wl.START,this.moveData)}t.path=this.moveData.path,e.emit(wl.BEFORE_MOVE,t),e.emit(wl.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;if(!this.zoomData){const{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,this.zoomData=Object.assign(Object.assign({},t),{scale:1}),e.cancelHover(),e.emit(Bl.START,this.zoomData)}t.path=this.zoomData.path,e.emit(Bl.BEFORE_ZOOM,t),e.emit(Bl.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;if(!this.rotateData){const{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,this.rotateData=Object.assign(Object.assign({},t),{rotation:0}),e.cancelHover(),e.emit(xl.START,this.rotateData)}t.path=this.rotateData.path,e.emit(xl.BEFORE_ROTATE,t),e.emit(xl.ROTATE,t),this.transformEndWait()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout((()=>{this.transformEnd()}),this.interaction.config.pointer.transformTime)}transformEnd(){this.moveEnd(),this.zoomEnd(),this.rotateEnd()}moveEnd(){this.moveData&&(this.interaction.emit(wl.END,this.moveData),this.moveData=null)}zoomEnd(){this.zoomData&&(this.interaction.emit(Bl.END,this.zoomData),this.zoomData=null)}rotateEnd(){this.rotateData&&(this.interaction.emit(xl.END,this.rotateData),this.rotateData=null)}destroy(){this.zoomData=this.moveData=this.rotateData=null}}const Sl={getMoveEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:t.x,y:t.y,moveX:e.x,moveY:e.y}),getRotateEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:t.x,y:t.y,rotation:e}),getZoomEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:t.x,y:t.y,scale:e}),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?bl.UP:t>45&&t<135?bl.DOWN:t<=45&&t>=-45?bl.RIGHT:bl.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:Ml.getSwipeDirection(S.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:void 0===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 Gn,{list:s}=t;for(let t=0,r=s.length;t<r;t++)s[t].hasEvent(e)&&i.add(s[t]);return i}},Ml=Sl,Dl=new Gn,{getDragEventData:Al,getDropEventData:Wl,getSwipeEventData:Il}=Sl;class Fl{constructor(t){this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Al(t,t,t),this.canAnimate=this.canDragOut=!0}getList(){const{proxy:t}=this.interaction.selector;return!this.dragging||t&&t.list.length?Dl:ml.list||this.dragableList||Dl}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(wl.START,this.dragData)),this.moving||this.dragStart(t,e),this.drag(t)}dragStart(t,e){this.dragging||(this.dragging=e&&pl.left(t),this.dragging&&(this.interaction.emit(ml.START,this.dragData),this.getDragableList(this.dragData.path),this.setDragStartPoints(this.realDragableList=this.getList())))}setDragStartPoints(t){this.dragStartPoints={},t.forEach((t=>this.dragStartPoints[t.innerId]={x:t.x,y:t.y}))}getDragableList(t){let e;for(let i=0,s=t.length;i<s;i++)if(e=t.list[i],(e.__.draggable||e.__.editable)&&e.__.hitSelf&&!e.__.locked){this.dragableList=new Gn(e);break}}drag(t){const{interaction:e,dragData:i,downData:s}=this,{path:r,throughPath:o}=s;this.dragData=Al(s,i,t),o&&(this.dragData.throughPath=o),this.dragData.path=r,this.moving?(this.dragData.moveType="drag",e.emit(wl.BEFORE_MOVE,this.dragData),e.emit(wl.MOVE,this.dragData)):this.dragging&&(this.dragReal(),e.emit(ml.BEFORE_DRAG,this.dragData),e.emit(ml.DRAG,this.dragData))}dragReal(){const{running:t}=this.interaction,e=this.realDragableList;if(e.length&&t){const{totalX:t,totalY:i}=this.dragData;e.forEach((e=>e.draggable&&e.move(ml.getValidMove(e,this.dragStartPoints[e.innerId],{x:t,y:i}))))}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:i}=this,{path:s}=t;this.dragOverPath=s,i?s.indexAt(0)!==i.indexAt(0)&&(e.emit(ml.OUT,t,i),e.emit(ml.OVER,t,s)):e.emit(ml.OVER,t,s)}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:i}=this,{path:s}=t;e.emit(ml.LEAVE,t,i,s),e.emit(ml.ENTER,t,s,i),this.dragEnterPath=s}dragEnd(t,e){if(!this.dragging&&!this.moving)return;const{moveX:i,moveY:s}=this.dragData;this.interaction.config.move.dragAnimate&&this.canAnimate&&this.moving&&(Math.abs(i)>1||Math.abs(s)>1)?(t=Object.assign({},t),e=.9*(e||("touch"===t.pointerType?2:1)),S.move(t,i*e,s*e),this.drag(t),this.animate((()=>{this.dragEnd(t,1)}))):this.dragEndReal(t)}dragEndReal(t){const{interaction:e,downData:i,dragData:s}=this;t||(t=s);const{path:r,throughPath:o}=i,n=Al(i,t,t);if(o&&(n.throughPath=o),n.path=r,this.moving&&(this.moving=!1,n.moveType="drag",e.emit(wl.END,n)),this.dragging){const r=this.getList();this.dragging=!1,e.emit(ml.END,n),this.swipe(t,i,s,n),this.drop(t,r,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}animate(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t}swipe(t,e,i,s){const{interaction:r}=this;if(S.getDistance(e,t)>r.config.pointer.swipeDistance){const t=Il(e,i,s);this.interaction.emit(t.type,t)}}drop(t,e,i){const s=Wl(t,e,ml.data);s.path=i,this.interaction.emit(vl.DROP,s),this.interaction.emit(ml.LEAVE,t,i)}dragReset(){ml.list=ml.data=this.dragableList=this.dragData=this.downData=this.dragOverPath=this.dragEnterPath=null}checkDragOut(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)}autoMoveOnDragOut(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:r,dragOut:o}=e.config.move;if(!o||!s||!r)return;const n=e.shrinkCanvasBounds,{x:a,y:h}=n,l=rt.maxX(n),d=rt.maxY(n),c=t.x<a?r:l<t.x?-r:0,u=t.y<h?r:d<t.y?-r:0;let _=0,p=0;this.autoMoveTimer=setInterval((()=>{_+=c,p+=u,S.move(i,c,u),S.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)}autoMoveCancel(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)}destroy(){this.dragReset()}}const zl=vt.get("emit");const Nl=["move","zoom","rotate","key"];function Yl(t,e,i,s,r){if(Nl.some((t=>e.startsWith(t)))&&t.__.hitChildren&&!jl(t,r)){let o;for(let n=0,a=t.children.length;n<a;n++)o=t.children[n],!i.path.has(o)&&o.__.hittable&&Xl(o,e,i,s,r)}}function Xl(t,e,i,s,r){if(t.destroyed)return!1;if(t.__.hitSelf&&!jl(t,r)&&(Aa.updateEventStyle&&Aa.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const r=Pt.get(e,i);if(t.emitEvent(r,s),r.isStop)return!0}return!1}function jl(t,e){return e&&e.has(t)}const Hl={getData(t){const e=t[0],i=t[1],s=S.getCenter(e.from,i.from),r=S.getCenter(e.to,i.to),o={x:r.x-s.x,y:r.y-s.y},n=S.getDistance(e.from,i.from);return{move:o,scale:S.getDistance(e.to,i.to)/n,angle:S.getRotation(e.from,i.from,e.to,i.to),center:r}}},Vl={wheel:{zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8},preventDefault:!0},pointer:{hitRadius:5,tapTime:120,longPressTime:800,transformTime:500,hover:!0,dragHover:!0,dragDistance:2,swipeDistance:20,preventDefaultMenu:!0},cursor:!0,keyEvent:!0},{pathHasEventType:Ul,getMoveEventData:Gl,getZoomEventData:Kl,getRotateEventData:ql}=Sl;class Zl{get dragging(){return this.dragger.dragging}get transforming(){return this.transformer.transforming}get moveMode(){return this.config.move.drag||this.isHoldSpaceKey||this.isHoldMiddleKey||this.isHoldRightKey&&this.dragger.moving||this.isDragEmpty}get canHover(){return this.config.pointer.hover&&!this.config.mobile}get isDragEmpty(){return this.config.move.dragEmpty&&this.isRootPath(this.hoverData)&&(!this.downData||this.isRootPath(this.downData))}get isMobileDragEmpty(){return this.config.move.dragEmpty&&!this.canHover&&this.downData&&this.isTreePath(this.downData)}get isHoldMiddleKey(){return this.config.move.holdMiddleKey&&this.downData&&pl.middle(this.downData)}get isHoldRightKey(){return this.config.move.holdRightKey&&this.downData&&pl.right(this.downData)}get isHoldSpaceKey(){return this.config.move.holdSpaceKey&&_l.isHoldSpaceKey()}get hitRadius(){return this.config.pointer.hitRadius}constructor(t,e,i,s){this.config=Vl,this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new Gn(t),this.transformer=new Ll(this),this.dragger=new Fl(this),s&&(this.config=St.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(pl.defaultLeft(t),this.updateDownData(t),this.checkPath(t,e),this.downTime=Date.now(),this.emit(fl.BEFORE_DOWN,t),this.emit(fl.DOWN,t),pl.left(t)&&(this.tapWait(),this.longPressWait(t)),this.waitMenuTap=pl.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&&pl.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(t){const{dragHover:e,dragDistance:i}=this.config.pointer;if(this.emit(fl.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=S.getDistance(this.downData,t)>i;e&&(this.waitTap&&this.pointerWaitCancel(),this.waitMenuTap=!1),this.dragger.checkDrag(t,e)}this.dragger.moving||(this.updateHoverData(t),this.checkPath(t),this.emit(fl.MOVE,t),this.dragging&&!e||this.pointerHover(t),this.dragger.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;pl.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(fl.BEFORE_UP,t),this.emit(fl.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)}multiTouch(t,e){const{move:i,angle:s,scale:r,center:o}=Hl.getData(e);this.rotate(ql(o,s,t)),this.zoom(Kl(o,r,t)),this.move(Gl(o,i,t))}menu(t){this.findPath(t),this.emit(fl.MENU,t)}menuTap(t){this.waitMenuTap&&this.emit(fl.MENU_TAP,t)}move(t){this.transformer.move(t)}zoom(t){this.transformer.zoom(t)}rotate(t){this.transformer.rotate(t)}transformEnd(){this.transformer.transformEnd()}keyDown(t){if(!this.config.keyEvent)return;const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,_l.setDownCode(e),this.emit(Rl.HOLD,t,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(Rl.DOWN,t,this.defaultPath)}keyUp(t){if(!this.config.keyEvent)return;const{code:e}=t;this.downKeyMap[e]=!1,_l.setUpCode(e),this.emit(Rl.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){this.canHover&&(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(fl.OUT,t,i),this.emit(fl.OVER,t,e)):this.emit(fl.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(fl.LEAVE,t,i,e),this.emit(fl.ENTER,t,e,i)}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(fl.LEAVE,t),this.dragger.dragging&&this.emit(vl.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,r=[fl.DOUBLE_TAP,fl.DOUBLE_CLICK].some((e=>Ul(t.path,e)));s<e.tapTime+50&&r?(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(t,e){const{hitRadius:i,through:s}=this.config.pointer,{bottomList:r}=this,o=this.selector.getByPoint(t,i,Object.assign({bottomList:r,name:t.type},e||{through:s}));return o.throughPath&&(t.throughPath=o.throughPath),t.path=o.path,o.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.canMove(t))&&(t.path=this.defaultPath)}canMove(t){return this.moveMode&&t&&t.path.list.every((t=>!t.isOutside))}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(),name:fl.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,r=s.length;t<r&&(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);return{x:t.clientX-i.x,y:t.clientY-i.y}}emitTap(t){this.emit(fl.TAP,t),this.emit(fl.CLICK,t)}emitDoubleTap(t){this.emit(fl.DOUBLE_TAP,t),this.emit(fl.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout((()=>{this.longPressed=!0,this.emit(fl.LONG_PRESS,t)}),this.config.pointer.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(fl.LONG_TAP,t),(Ul(t.path,fl.LONG_TAP)||Ul(t.path,fl.LONG_PRESS))&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){clearTimeout(this.longPressTimer),this.longPressed=!1}__onResize(){this.shrinkCanvasBounds=new ht(this.canvas.bounds),this.shrinkCanvasBounds.spread(-2)}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Yo.RESIZE,this.__onResize,this)],t.once(Uo.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 r;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(r=i.list[o],Xl(r,t,e,!0,s))return;r.isApp&&Yl(r,t,e,!0,s)}for(let o=0,n=i.length;o<n;o++)if(r=i.list[o],r.isApp&&Yl(r,t,e,!1,s),Xl(r,t,e,!1,s))return}catch(t){zl.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class Ql{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}Ql.custom={};class Jl extends Lt{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new Gn,this.pixelList=new Gn}getPixelType(t,i){return this.__autoClear(),this.pixelList.add(t),e.hitCanvas(i)}getPathType(t){return this.__autoClear(),this.pathList.add(t),e.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()}}const{toInnerRadiusPointOf:$l,copy:td,setRadius:ed}=S,id={},sd=In.prototype;sd.__hitWorld=function(t){if(!this.__.hitSelf)return!1;this.__.hitRadius&&(td(id,t),ed(t=id,this.__.hitRadius)),$l(t,this.__world,id);const{width:e,height:i}=this.__world,s=e<10&&i<10;if(this.__.hitBox||s){if(rt.hitRadiusPoint(this.__layout.boxBounds,id))return!0;if(s)return!1}return!this.__layout.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),this.__layout.boundsChanged||(this.__layout.hitCanvasChanged=!1)),this.__hit(id)},sd.__hitFill=function(t){var e;return null===(e=this.__hitCanvas)||void 0===e?void 0:e.hitFill(t,this.__.windingRule)},sd.__hitStroke=function(t,e){var i;return null===(i=this.__hitCanvas)||void 0===i?void 0:i.hitStroke(t,e)},sd.__hitPixel=function(t){var e;return null===(e=this.__hitCanvas)||void 0===e?void 0:e.hitPixel(t,this.__layout.renderBounds,this.__hitCanvas.hitScale)},sd.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const rd=new z,od=uh.prototype;od.__updateHitCanvas=function(){const e=this.__,{hitCanvasManager:i}=this.leafer,s=(e.__pixelFill||e.__isCanvas)&&"pixel"===e.hitFill,r=e.__pixelStroke&&"pixel"===e.hitStroke,o=s||r;this.__hitCanvas||(this.__hitCanvas=o?i.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):i.getPathType(this));const n=this.__hitCanvas;if(o){const{renderBounds:i}=this.__layout,o=t.image.hitCanvasSize,a=n.hitScale=lt.set(0,0,o,o).getFitMatrix(i,.5).a,{x:h,y:l,width:d,height:c}=lt.set(i).scale(a);n.resize({width:d,height:c,pixelRatio:1}),n.clear(),dr.patternLocked=!0,this.__renderShape(n,{matrix:rd.setWith(this.__world).scaleWith(1/a).invertWith().translate(-h,-l)},!s,!r),dr.patternLocked=!1,n.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(n),n.setStrokeOptions(e)},od.__hit=function(e){"miniapp"===t.name&&this.__drawHitPath(this.__hitCanvas);const i=this.__;if(i.__isHitPixel&&this.__hitPixel(e))return!0;const{hitFill:s}=i,r=(i.fill||i.__isCanvas)&&("path"===s||"pixel"===s&&!(i.__pixelFill||i.__isCanvas))||"all"===s;if(r&&this.__hitFill(e))return!0;const{hitStroke:o,__strokeWidth:n}=i,a=i.stroke&&("path"===o||"pixel"===o&&!i.__pixelStroke)||"all"===o;if(!r&&!a)return!1;const h=2*e.radiusX;let l=h;if(a)switch(i.strokeAlign){case"inside":if(l+=2*n,!r&&this.__hitFill(e)&&this.__hitStroke(e,l))return!0;l=h;break;case"center":l+=n;break;case"outside":if(l+=2*n,!r){if(!this.__hitFill(e)&&this.__hitStroke(e,l))return!0;l=h}}return!!l&&this.__hitStroke(e,l)};const nd=new uh,ad=yh.prototype;ad.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?nd.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},ad.__hitFill=function(t){return this.__hitCanvas?nd.__hitFill.call(this,t):rt.hitRadiusPoint(this.__layout.boxBounds,t)};const hd=uh.prototype,ld=_h.prototype;hd.find=function(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!1,e):[]},hd.findOne=function(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!0,e):null},ld.pick=function(t,e){return this.__layout.update(),e||(e={}),this.leafer?this.leafer.selector.getByPoint(t,e.hitRadius||0,Object.assign(Object.assign({},e),{target:this})):null};const dd=Gt.prototype;dd.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},dd.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},dd.hitPixel=function(t,e,i=1){let{x:s,y:r,radiusX:o,radiusY:n}=t;e&&(s-=e.x,r-=e.y),lt.set(s-o,r-n,2*o,2*n).scale(i).ceil();const{data:a}=this.context.getImageData(lt.x,lt.y,lt.width||1,lt.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 cd={convert(t,e){const i=Sl.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=Sl.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=cd.getTouch(t),s=Sl.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},ud={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:r}=t;return t.shiftKey&&!s&&(s=r,r=0),s>50&&(s=Math.max(50,s/3)),r>50&&(r=Math.max(50,r/3)),{x:-s*i*2,y:-r*i*2}},getScale(e,i){let s,r=1,{zoomMode:o,zoomSpeed:n}=i;const h=e.deltaY||e.deltaX;if(o?(s="mouse"===o||!e.deltaX&&(t.intWheelDeltaY?Math.abs(h)>17:Math.ceil(h)!==h),(e.shiftKey||e.metaKey||e.ctrlKey)&&(s=!0)):s=!e.shiftKey&&(e.metaKey||e.ctrlKey),s){n=a.within(n,0,1);r=1-h/(4*(e.deltaY?i.delta.y:i.delta.x))*n,r<.5&&(r=.5),r>=1.5&&(r=1.5)}return r}},_d={convert(t){const e=Sl.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{getMoveEventData:pd,getZoomEventData:gd,getRotateEventData:fd}=Sl;class yd extends Zl{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(_d.convert(t))}onKeyUp(t){this.keyUp(_d.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(cd.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||(this.usePointer||(this.usePointer=!0),this.pointerDown(cd.convert(t,this.getLocal(t))))}onPointerMove(t){this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||(this.usePointer||(this.usePointer=!0),this.pointerMove(cd.convert(t,this.getLocal(t,!0))))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(cd.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(cd.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(cd.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(cd.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){if(t.preventDefault(),this.multiTouchStart(t),this.usePointer)return;this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0;const e=cd.getTouch(t);this.pointerDown(cd.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=cd.getTouch(t);this.pointerMove(cd.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=cd.getTouch(t);this.pointerUp(cd.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(Sl.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}onWheel(t){this.preventDefaultWheel(t);const{wheel:e}=this.config;if(e.disabled)return;const i=e.getScale?e.getScale(t,e):ud.getScale(t,e),s=this.getLocal(t),r=Sl.getBase(t);1!==i?this.zoom(gd(s,i,r)):this.move(pd(s,e.getMove?e.getMove(t,e):ud.getMove(t,e),r))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=this.getLocal(t),i=Sl.getBase(t),s=t.scale/this.lastGestureScale,r=t.rotation-this.lastGestureRotation;let{rotateSpeed:o}=this.config.wheel;o=a.within(o,0,1),this.zoom(gd(e,s*s,i)),this.rotate(fd(e,r/Math.PI*180*(o/4+.1),i)),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,e,i=0){if(i++,t instanceof Array)t.forEach((t=>this.eachCursor(t,e,i)));else{const s="string"==typeof t&&Ql.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function md(t,e){let i;const{rows:s,decorationY:r,decorationHeight:o}=t.__.__textDrawData;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),r&&e.fillRect(i.x,i.y+r,i.width,o)}function vd(t,e,i){const{strokeAlign:s}=e.__,r="string"!=typeof t;switch(s){case"center":i.setStroke(r?void 0:t,e.__.strokeWidth,e.__),r?bd(t,!0,e,i):xd(e,i);break;case"inside":wd("inside",t,r,e,i);break;case"outside":wd("outside",t,r,e,i)}}function wd(t,e,i,s,r){const{__strokeWidth:o,__font:n}=s.__,a=r.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,s.__),a.font=n,i?bd(e,!0,s,a):xd(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",md(s,a),a.blendMode="normal",s.__worldFlipped?r.copyWorldByReset(a,s.__nowWorld):r.copyWorldToInner(a,s.__nowWorld,s.__layout.renderBounds),a.recycle(s.__nowWorld)}function xd(t,e){let i;const{rows:s,decorationY:r,decorationHeight:o}=t.__.__textDrawData;for(let t=0,n=s.length;t<n;t++)i=s[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)})),r&&e.strokeRect(i.x,i.y+r,i.width,o)}function bd(t,e,i,s){let r;for(let o=0,n=t.length;o<n;o++)r=t[o],r.image&&La.checkImage(i,s,r,!1)||r.style&&(s.strokeStyle=r.style,r.blendMode?(s.saveBlendMode(r.blendMode),e?xd(i,s):s.stroke(),s.restoreBlendMode()):e?xd(i,s):s.stroke())}const{getSpread:Bd,getOuterOf:Rd,getByMove:kd,getIntersectData:Cd}=rt;let Td;function Ed(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:r,blendMode:o,color:n,opacity:a}=e;return{type:r,blendMode:o,style:Ea.string(n,a)};case"image":return La.image(i,t,e,s,!Td||!Td[e.url]);case"linear":return Sa.linearGradient(e,s);case"radial":return Sa.radialGradient(e,s);case"angular":return Sa.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:Ea.string(e)}:void 0}}const Pd={compute:function(t,e){const i=e.__,s=[];let r,o=i.__input[t];o instanceof Array||(o=[o]),Td=La.recycleImage(t,i);for(let i,r=0,n=o.length;r<n;r++)i=Ed(t,o[r],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(r=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=r:i.__pixelStroke=r},fill:function(t,e,i){i.fillStyle=t,e.__.__font?md(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:r,__font:o}=e.__;for(let n=0,a=t.length;n<a;n++)s=t[n],s.image&&La.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?md(e,i):r?i.fill(r):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?md(e,i):r?i.fill(r):i.fill(),i.restoreBlendMode()):o?md(e,i):r?i.fill(r):i.fill())},fillText:md,stroke:function(t,e,i){const s=e.__,{__strokeWidth:r,strokeAlign:o,__font:n}=s;if(r)if(n)vd(t,e,i);else switch(o){case"center":i.setStroke(t,r,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*r,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*r,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:r,strokeAlign:o,__font:n}=s;if(r)if(n)vd(t,e,i);else switch(o){case"center":i.setStroke(void 0,r,s),bd(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*r,s),s.windingRule?i.clip(s.windingRule):i.clip(),bd(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,n=i.getSameCanvas(!0,!0);e.__drawRenderPath(n),n.setStroke(void 0,2*r,s),bd(t,!1,e,n),s.windingRule?n.clip(s.windingRule):n.clip(),n.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(n,e.__nowWorld):i.copyWorldToInner(n,e.__nowWorld,o),n.recycle(e.__nowWorld)}},strokeText:vd,drawTextStroke:xd,shape:function(t,e,i){const s=e.getSameCanvas(),r=t.__nowWorld;let o,n,a,h,{scaleX:l,scaleY:d}=r;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(r))h=s,o=a=r;else{const{renderShapeSpread:s}=t.__layout,c=Cd(s?Bd(e.bounds,l===d?s*l:[s*d,s*l]):e.bounds,r);n=e.bounds.getFitMatrix(c);let{a:u,d:_}=n;if(n.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=_),a=Rd(r,n),o=kd(a,-n.e,-n.f),i.matrix){const{matrix:t}=i;n.multiply(t),u*=t.scaleX,_*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:n.withScale(u,_)})}return t.__renderShape(s,i),{canvas:s,matrix:n,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:d}}};let Od={};const{get:Ld,rotateOfOuter:Sd,translate:Md,scaleOfOuter:Dd,scale:Ad,rotate:Wd}=x;function Id(t,e,i,s,r,o,n){const a=Ld();Md(a,e.x+i,e.y+s),Ad(a,r,o),n&&Sd(a,{x:e.x+e.width/2,y:e.y+e.height/2},n),t.transform=a}function Fd(t,e,i,s,r,o,n){const a=Ld();Md(a,e.x+i,e.y+s),r&&Ad(a,r,o),n&&Wd(a,n),t.transform=a}function zd(t,e,i,s,r,o,n,a,h,l){const d=Ld();if(h)if("center"===l)Sd(d,{x:i/2,y:s/2},h);else switch(Wd(d,h),h){case 90:Md(d,s,0);break;case 180:Md(d,i,s);break;case 270:Md(d,0,i)}Od.x=e.x+r,Od.y=e.y+o,Md(d,Od.x,Od.y),n&&Dd(d,Od,n,a),t.transform=d}const{get:Nd,translate:Yd}=x,Xd=new ht,jd={};function Hd(t,e,i,s){const{blendMode:r}=i;r&&(t.blendMode=r),t.data=Vd(i,s,e)}function Vd(t,e,i){let{width:s,height:r}=i;t.padding&&(e=Xd.set(e).shrink(t.padding));const{opacity:o,mode:n,align:a,offset:h,scale:l,size:d,rotation:c,repeat:u}=t,_=e.width===s&&e.height===r,p={mode:n},g="center"!==a&&(c||0)%180==90,f=g?r:s,y=g?s:r;let m,v,w=0,x=0;if(n&&"cover"!==n&&"fit"!==n)d?(m=("number"==typeof d?d:d.width)/s,v=("number"==typeof d?d:d.height)/r):l&&(m="number"==typeof l?l:l.x,v="number"==typeof l?l:l.y);else if(!_||c){const t=e.width/f,i=e.height/y;m=v="fit"===n?Math.min(t,i):Math.max(t,i),w+=(e.width-s*m)/2,x+=(e.height-r*v)/2}if(a){const t={x:w,y:x,width:f,height:y};m&&(t.width*=m,t.height*=v),yt.toPoint(a,t,e,jd,!0),w+=jd.x,x+=jd.y}switch(h&&(w+=h.x,x+=h.y),n){case"strench":_||(s=e.width,r=e.height);break;case"normal":case"clip":(w||x||m||c)&&Fd(p,e,w,x,m,v,c);break;case"repeat":(!_||m||c)&&zd(p,e,s,r,w,x,m,v,c,a),u||(p.repeat="repeat");break;default:m&&Id(p,e,w,x,m,v,c)}return p.transform||(e.x||e.y)&&(p.transform=Nd(),Yd(p.transform,e.x,e.y)),m&&"strench"!==n&&(p.scaleX=m,p.scaleY=v),p.width=s,p.height=r,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let Ud,Gd=new ht;const{isSame:Kd}=rt;function qd(t,e,i,s,r,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 r.data||Hd(r,s,i,o),!0}function Zd(t,e){$d(t,No.LOAD,e)}function Qd(t,e){$d(t,No.LOADED,e)}function Jd(t,e,i){e.error=i,t.forceUpdate("surface"),$d(t,No.ERROR,e)}function $d(t,e,i){t.hasEvent(e)&&t.emitEvent(new No(e,i))}function tc(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ec,scale:ic,copy:sc}=x,{ceil:rc,abs:oc}=Math;function nc(e,i,s){let{scaleX:r,scaleY:o}=dr.patternLocked?e.__world:e.__nowWorld;const n=r+"-"+o;if(i.patternId===n||e.destroyed)return!1;{r=oc(r),o=oc(o);const{image:e,data:a}=i;let h,l,{width:d,height:c,scaleX:u,scaleY:_,opacity:p,transform:g,repeat:f}=a;u&&(l=ec(),sc(l,g),ic(l,1/u,1/_),r*=u,o*=_),r*=s,o*=s,d*=r,c*=o;const y=d*c;if(!f&&y>t.image.maxCacheSize)return!1;let m=t.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}y>m&&(h=Math.sqrt(y/m)),h&&(r/=h,o/=h,d/=h,c/=h),u&&(r/=u,o/=_),(g||1!==r||1!==o)&&(l||(l=ec(),g&&sc(l,g)),ic(l,1/r,1/o));const v=e.getCanvas(rc(d)||1,rc(c)||1,p),w=e.getPattern(v,f||t.origin.noRepeat||"no-repeat",l,i);return i.style=w,i.patternId=n,!0}}const{abs:ac}=Math;const hc={image:function(t,e,i,s,r){let o,n;const a=dr.get(i);return Ud&&i===Ud.paint&&Kd(s,Ud.boxBounds)?o=Ud.leafPaint:(o={type:i.type,image:a},Ud=a.use>1?{leafPaint:o,paint:i,boxBounds:Gd.set(s)}:null),(r||a.loading)&&(n={image:a,attrName:e,attrValue:i}),a.ready?(qd(t,e,i,a,o,s),r&&(Zd(t,n),Qd(t,n))):a.error?r&&Jd(t,n,a.error):(tc(t,!0),r&&Zd(t,n),o.loadId=a.load((()=>{tc(t,!1),t.destroyed||(qd(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Qd(t,n)),o.loadId=null}),(e=>{tc(t,!1),Jd(t,n,e),o.loadId=null}))),o},checkImage:function(e,i,s,r){const{scaleX:o,scaleY:n}=dr.patternLocked?e.__world:e.__nowWorld;if(!s.data||s.patternId===o+"-"+n&&!Da.running)return!1;{const{data:a}=s;if(r)if(a.repeat)r=!1;else{let{width:e,height:s}=a;e*=ac(o)*i.pixelRatio,s*=ac(n)*i.pixelRatio,a.scaleX&&(e*=a.scaleX,s*=a.scaleY),r=e*s>t.image.maxCacheSize||Da.running}return r?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),a.opacity&&(i.opacity*=a.opacity),a.transform&&i.transform(a.transform),i.drawImage(s.image.view,0,0,a.width,a.height),i.restore(),!0):(!s.style||Da.running?nc(e,s,i.pixelRatio):s.patternTask||(s.patternTask=dr.patternTasker.add((()=>Ft(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&nc(e,s,i.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}},createPattern:nc,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,r,o,n;for(let a=0,h=i.length;a<h;a++)s=i[a].image,n=s&&s.url,n&&(r||(r={}),r[n]=!0,dr.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===n)))));return r}return null},createData:Hd,getPatternData:Vd,fillOrFitMode:Id,clipMode:Fd,repeatMode:zd},{toPoint:lc}=pt,dc={},cc={};function uc(t,e,i){let s;for(let r=0,o=e.length;r<o;r++)s=e[r],"string"==typeof s?t.addColorStop(r/(o-1),Ea.string(s,i)):t.addColorStop(s.offset,Ea.string(s.color,i))}const{getAngle:_c,getDistance:pc}=S,{get:gc,rotateOfOuter:fc,scaleOfOuter:yc}=x,{toPoint:mc}=pt,vc={},wc={};function xc(t,e,i,s,r){let o;const{width:n,height:a}=t;if(n!==a||s){const t=_c(e,i);o=gc(),r?(yc(o,e,n/a*(s||1),1),fc(o,e,t+90)):(yc(o,e,1,n/a*(s||1)),fc(o,e,t))}return o}const{getDistance:bc}=S,{toPoint:Bc}=pt,Rc={},kc={};const Cc={linearGradient:function(e,i){let{from:s,to:r,type:o,blendMode:n,opacity:a}=e;lc(s||"top",i,dc),lc(r||"bottom",i,cc);const h=t.canvas.createLinearGradient(dc.x,dc.y,cc.x,cc.y);uc(h,e.stops,a);const l={type:o,style:h};return n&&(l.blendMode=n),l},radialGradient:function(e,i){let{from:s,to:r,type:o,opacity:n,blendMode:a,stretch:h}=e;mc(s||"center",i,vc),mc(r||"bottom",i,wc);const l=t.canvas.createRadialGradient(vc.x,vc.y,0,vc.x,vc.y,pc(vc,wc));uc(l,e.stops,n);const d={type:o,style:l},c=xc(i,vc,wc,h,!0);return c&&(d.transform=c),a&&(d.blendMode=a),d},conicGradient:function(e,i){let{from:s,to:r,type:o,opacity:n,blendMode:a,stretch:h}=e;Bc(s||"center",i,Rc),Bc(r||"bottom",i,kc);const l=t.conicGradientSupport?t.canvas.createConicGradient(0,Rc.x,Rc.y):t.canvas.createRadialGradient(Rc.x,Rc.y,0,Rc.x,Rc.y,bc(Rc,kc));uc(l,e.stops,n);const d={type:o,style:l},c=xc(i,Rc,kc,h||1,t.conicGradientRotate90);return c&&(d.transform=c),a&&(d.blendMode=a),d},getTransform:xc},{copy:Tc,toOffsetOutBounds:Ec}=rt,Pc={},Oc={};function Lc(e,i,s,r){const{bounds:o,shapeBounds:n}=r;if(t.fullImageShadow){if(Tc(Pc,e.bounds),Pc.x+=i.x-n.x,Pc.y+=i.y-n.y,s){const{matrix:t}=r;Pc.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Pc.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Pc.width*=s,Pc.height*=s}e.copyWorld(r.canvas,e.bounds,Pc)}else s&&(Tc(Pc,i),Pc.x-=i.width/2*(s-1),Pc.y-=i.height/2*(s-1),Pc.width*=s,Pc.height*=s),e.copyWorld(r.canvas,n,s?Pc:i)}const{toOffsetOutBounds:Sc}=rt,Mc={};const Dc={shadow:function(t,e,i){let s,r;const{__nowWorld:o,__layout:n}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,_=e.getSameCanvas(),p=a.length-1;Ec(l,Oc),a.forEach(((a,g)=>{_.setWorldShadow(Oc.offsetX+a.x*c,Oc.offsetY+a.y*u,a.blur*c,a.color),r=a.spread?1+2*a.spread/(n.boxBounds.width+2*(n.strokeBoxSpread||0)):0,Lc(_,Oc,r,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")),t.__worldFlipped?e.copyWorldByReset(_,s,o,a.blendMode):e.copyWorldToInner(_,s,n.renderBounds,a.blendMode),p&&g<p&&_.clearWorld(s,!0)})),_.recycle(s)},innerShadow:function(t,e,i){let s,r;const{__nowWorld:o,__layout:n}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,_=e.getSameCanvas(),p=a.length-1;Sc(l,Mc),a.forEach(((a,g)=>{_.save(),_.setWorldShadow(Mc.offsetX+a.x*c,Mc.offsetY+a.y*u,a.blur*c),r=a.spread?1-2*a.spread/(n.boxBounds.width+2*(n.strokeBoxSpread||0)):0,Lc(_,Mc,r,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,a.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(_,s,o,a.blendMode):e.copyWorldToInner(_,s,n.renderBounds,a.blendMode),p&&g<p&&_.clearWorld(s,!0)})),_.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){}},{excludeRenderBounds:Ac}=mo;function Wc(t,e,i,s,r,o){switch(e){case"alpha":!function(t,e,i,s){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),s.recycle(r),Fc(t,e,i,1)}(t,i,s,r);break;case"opacity-path":Fc(t,i,s,o);break;case"path":i.restore()}}function Ic(t){return t.getSameCanvas(!1,!0)}function Fc(t,e,i,s){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r),i.recycle(r)}_h.prototype.__renderMask=function(t,e){let i,s,r,o,n;const{children:a}=this;for(let h=0,l=a.length;h<l;h++)i=a[h],i.__.mask&&(n&&(Wc(this,n,t,r,s,o),s=r=null),"path"===i.__.mask?(i.opacity<1?(n="opacity-path",o=i.opacity,r||(r=Ic(t))):(n="path",t.save()),i.__clip(r||t,e)):(n="alpha",s||(s=Ic(t)),r||(r=Ic(t)),i.__render(s,e)),"clipping"!==i.__.mask)||Ac(i,e)||i.__render(r||t,e);Wc(this,n,t,r,s,o)};const zc=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nc=zc+"_#~&*+\\=|≮≯≈≠=…",Yc=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 Xc(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const jc=Xc("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Hc=Xc("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Vc=Xc(zc),Uc=Xc(Nc),Gc=Xc("- —/~|┆·");var Kc;!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"}(Kc||(Kc={}));const{Letter:qc,Single:Zc,Before:Qc,After:Jc,Symbol:$c,Break:tu}=Kc;function eu(t){return jc[t]?qc:Gc[t]?tu:Hc[t]?Qc:Vc[t]?Jc:Uc[t]?$c:Yc.test(t)?Zc:qc}const iu={trimRight(t){const{words:e}=t;let i,s=0,r=e.length;for(let o=r-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(r-s,s)}};function su(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:ru}=iu,{Letter:ou,Single:nu,Before:au,After:hu,Symbol:lu,Break:du}=Kc;let cu,uu,_u,pu,gu,fu,yu,mu,vu,wu,xu,bu,Bu,Ru,ku,Cu,Tu=[];function Eu(t,e){vu&&!mu&&(mu=vu),cu.data.push({char:t,width:e}),_u+=e}function Pu(){pu+=_u,cu.width=_u,uu.words.push(cu),cu={data:[]},_u=0}function Ou(){Ru&&(ku.paraNumber++,uu.paraStart=!0,Ru=!1),vu&&(uu.startCharSize=mu,uu.endCharSize=vu,mu=0),uu.width=pu,Cu.width&&ru(uu),Tu.push(uu),uu={words:[]},pu=0}const Lu=0,Su=1,Mu=2;const{top:Du,right:Au,bottom:Wu,left:Iu}=ct;function Fu(t,e,i){const{bounds:s,rows:r}=t;s[e]+=i;for(let t=0;t<r.length;t++)r[t][e]+=i}const zu={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let s=0,r=0,o=i.__getInput("width")||0,n=i.__getInput("height")||0;const{textDecoration:a,__font:h,__padding:l}=i;l&&(o&&(s=l[Iu],o-=l[Au]+l[Iu]),n&&(r=l[Du],n-=l[Du]+l[Wu]));const d={bounds:{x:s,y:r,width:o,height:n},rows:[],paraNumber:0,font:t.canvas.font=h};return function(e,i,s){ku=e,Tu=e.rows,Cu=e.bounds;const{__letterSpacing:r,paraIndent:o,textCase:n}=s,{canvas:a}=t,{width:h,height:l}=Cu;if(h||l||r||"none"!==n){const t="none"!==s.textWrap,e="break"===s.textWrap;Ru=!0,xu=null,mu=yu=vu=_u=pu=0,cu={data:[]},uu={words:[]};for(let s=0,l=i.length;s<l;s++)fu=i[s],"\n"===fu?(_u&&Pu(),uu.paraEnd=!0,Ou(),Ru=!0):(wu=eu(fu),wu===ou&&"none"!==n&&(fu=su(fu,n,!_u)),yu=a.measureText(fu).width,r&&(r<0&&(vu=yu),yu+=r),bu=wu===nu&&(xu===nu||xu===ou)||xu===nu&&wu!==hu,Bu=!(wu!==au&&wu!==nu||xu!==lu&&xu!==hu),gu=Ru&&o?h-o:h,t&&h&&pu+_u+yu>gu&&(e?(_u&&Pu(),pu&&Ou()):(Bu||(Bu=wu===ou&&xu==hu),bu||Bu||wu===du||wu===au||wu===nu||_u+yu>gu?(_u&&Pu(),pu&&Ou()):pu&&Ou()))," "===fu&&!0!==Ru&&pu+_u===0||(wu===du?(" "===fu&&_u&&Pu(),Eu(fu,yu),Pu()):bu||Bu?(_u&&Pu(),Eu(fu,yu)):Eu(fu,yu)),xu=wu);_u&&Pu(),pu&&Ou(),Tu.length>0&&(Tu[Tu.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{ku.paraNumber++,Tu.push({x:o||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(d,e,i),l&&function(t,e,i,s,r){if(!s)switch(i.textAlign){case"left":Fu(e,"x",t[Iu]);break;case"right":Fu(e,"x",-t[Au])}if(!r)switch(i.verticalAlign){case"top":Fu(e,"y",t[Du]);break;case"bottom":Fu(e,"y",-t[Wu])}}(l,d,i,o,n),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:r,__baseLine:o,__letterSpacing:n,__clipText:a,textAlign:h,verticalAlign:l,paraSpacing:d}=e;let c,u,_,{x:p,y:g,width:f,height:y}=s,m=r*i.length+(d?d*(t.paraNumber-1):0),v=o;if(a&&m>y)m=Math.max(y,r),t.overflow=i.length;else switch(l){case"middle":g+=(y-m)/2;break;case"bottom":g+=y-m}v+=g;for(let o=0,l=i.length;o<l;o++){if(c=i[o],c.x=p,c.width<f||c.width>f&&!a)switch(h){case"center":c.x+=(f-c.width)/2;break;case"right":c.x+=f-c.width}c.paraStart&&d&&o>0&&(v+=d),c.y=v,v+=r,t.overflow>o&&v>m&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,_=c.width,n<0&&(c.width<0?(_=-c.width+e.fontSize+n,u-=_,_+=e.fontSize):_-=n),u<s.x&&(s.x=u),_>s.width&&(s.width=_),a&&f&&f<_&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=m}(d,i),function(t,e,i,s){const{rows:r}=t,{textAlign:o,paraIndent:n,letterSpacing:a}=e;let h,l,d,c,u;r.forEach((t=>{t.words&&(d=n&&t.paraStart?n:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=a||t.isOverflow?Lu:l>.01?Su:Mu,t.isOverflow&&!a&&(t.textMode=!0),c===Mu?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{c===Su?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(d,i,o),d.overflow&&function(e,i,s,r){if(!r)return;const{rows:o,overflow:n}=e;let{textOverflow:a}=i;if(o.splice(n),a&&"show"!==a){let e,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.canvas.measureText(a).width:0,d=s+r-l;("none"===i.textWrap?o:[o[n-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){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)}}))}}(d,i,s,o),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(d,i),d}};const Nu={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:Yu,addPoint:Xu,toBounds:ju}=Y;const Hu={export(i,s,r){this.running=!0;const o=or.fileType(s);return r=or.getExportOptions(r),function(t){Vu||(Vu=new lr);return new Promise((e=>{Vu.add((()=>Ft(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((a=>{const h=t=>{n(t),a(),this.running=!1},{toURL:l}=t,{download:d}=t.origin;if("json"===s)return h({data:i.toJSON(r.json)});if("json"===o)return d(l(JSON.stringify(i.toJSON(r.json)),"text"),s),h({data:!0});if("svg"===s)return h({data:i.toSVG()});if("svg"===o)return d(l(i.toSVG(),"svg"),s),h({data:!0});const{leafer:c}=i;c?(Uu(i),c.waitViewCompleted((()=>Ft(this,void 0,void 0,(function*(){let t,o,n=1,a=1;const{worldTransform:l,isLeafer:d,isFrame:u}=i,{slice:_,trim:p,onCanvas:g}=r;let f=r.scale||1,y=r.pixelRatio||1;const m=void 0===r.smooth?c.config.smooth:r.smooth,v=r.contextSettings||c.config.contextSettings;i.isApp&&(f*=y,y=i.app.pixelRatio);const w=r.screenshot||i.isApp,x=d&&w&&void 0===r.fill?i.fill:r.fill,b=or.isOpaqueImage(s)||x,B=new z;if(w)t=!0===w?d?c.canvas.bounds:i.worldRenderBounds:w;else{let e=r.relative||(d?"inner":"local");switch(n=l.scaleX,a=l.scaleY,e){case"inner":B.set(l);break;case"local":B.set(l).divide(i.localTransform),n/=i.scaleX,a/=i.scaleY;break;case"world":n=1,a=1;break;case"page":e=i.leafer;default:B.set(l).divide(i.getTransform(e));const t=e.worldTransform;n/=n/t.scaleX,a/=a/t.scaleY}t=i.getBounds("render",e)}const{x:R,y:k,width:C,height:T}=new ht(t).scale(f);let E=e.canvas({width:Math.round(C),height:Math.round(T),pixelRatio:y,smooth:m,contextSettings:v});const P={matrix:B.scale(1/f).invert().translate(-R,-k).withScale(1/n*f,1/a*f)};let O;if(_&&(O=i,O.__worldOpacity=0,i=c,P.bounds=E.bounds),E.save(),u&&void 0!==x){const t=i.get("fill");i.fill="",i.__render(E,P),i.fill=t}else i.__render(E,P);if(E.restore(),O&&O.__updateWorldOpacity(),p){o=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let r,o,n,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(r=a%e,o=(a-r)/e,n?Xu(n,r,o):Yu(n={},r,o)),a++;const h=new ht;return ju(n,h),h.scale(1/t.pixelRatio).ceil()}(E);const t=E,{width:i,height:s}=o,r={x:0,y:0,width:i,height:s,pixelRatio:y};E=e.canvas(r),E.copyWorld(t,o,r)}b&&E.fillWorld(E.bounds,x||"#FFFFFF","destination-over"),g&&g(E);const L="canvas"===s?E:yield E.export(s,r);h({data:L,width:E.pixelWidth,height:E.pixelHeight,renderBounds:t,trimBounds:o})}))))):h({data:!1})}))))}};let Vu;function Uu(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Uu(t)))}const Gu=Gt.prototype,Ku=vt.get("@leafer-ui/export");Gu.export=function(t,e){const{quality:i,blob:s}=or.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},Gu.toBlob=function(e,i){return new Promise((s=>{t.origin.canvasToBolb(this.view,e,i).then((t=>{s(t)})).catch((t=>{Ku.error(t),s(null)}))}))},Gu.toDataURL=function(e,i){return t.origin.canvasToDataURL(this.view,e,i)},Gu.saveAs=function(e,i){return new Promise((s=>{t.origin.canvasSaveAs(this.view,e,i).then((()=>{s(!0)})).catch((t=>{Ku.error(t),s(!1)}))}))},Object.assign(Ta,zu),Object.assign(Ea,Nu),Object.assign(Oa,Pd),Object.assign(La,hc),Object.assign(Sa,Cc),Object.assign(Ma,Dc),Object.assign(Da,Hu),Object.assign(e,{interaction:(t,e,i,s)=>new yd(t,e,i,s),hitCanvas:(t,e)=>new Jn(t,e),hitCanvasManager:()=>new Jl}),ea();export{yt as AlignHelper,Ho as AnimateEvent,At as Answer,cl as App,pt as AroundHelper,dt as AutoBounds,xe as BezierHelper,ht as Bounds,rt as BoundsHelper,Rh as Box,Ga as BoxData,Un as Branch,wo as BranchHelper,pn as BranchRender,il as Canvas,nh as CanvasData,Lt as CanvasManager,Fo as ChildEvent,Ea as ColorConvert,e as Creator,Ql as Cursor,St as DataHelper,vt as Debug,ct as Direction4,ut as Direction9,ml as DragEvent,vl as DropEvent,Ma as Effect,Ph as Ellipse,Ja as EllipseData,Oe as EllipseHelper,Io as Event,Pt as EventCreator,Da as Export,or as FileHelper,kh as Frame,qa as FrameData,_h as Group,Ua as GroupData,Jl as HitCanvasManager,el as Image,oh as ImageData,No as ImageEvent,dr as ImageManager,i as IncrementId,yd as Interaction,Zl as InteractionBase,Sl as InteractionHelper,Rl as KeyEvent,_l as Keyboard,jo as LayoutEvent,ga as Layouter,In as Leaf,cn as LeafBounds,mo as LeafBoundsHelper,Dt as LeafData,qo as LeafDataProxy,Ao as LeafEventer,lo as LeafHelper,Mo as LeafLayout,Kn as LeafLevelList,Gn as LeafList,sn as LeafMatrix,un as LeafRender,fh as Leafer,Jn as LeaferCanvas,Gt as LeaferCanvasBase,Ka as LeaferData,Uo as LeaferEvent,pr as LeaferImage,Tl as LeaferTypeCreator,Fh as Line,Za as LineData,a as MathHelper,z as Matrix,x as MatrixHelper,wl as MoveEvent,Hl as MultiTouchHelper,Jt as NeedConvertToCanvasCommandMap,h as OneRadian,l as PI2,d as PI_2,Oa as Paint,Sa as PaintGradient,La as PaintImage,ll as Path,Pa as PathArrow,Gs as PathBounds,Ii as PathCommandDataHelper,Zt as PathCommandMap,pi as PathConvert,er as PathCorner,ts as PathCreator,eh as PathData,gs as PathDrawer,Kt as PathHelper,ie as PathNumberCommandLengthMap,ee as PathNumberCommandMap,dl as Pen,ih as PenData,t as Platform,I as Point,S as PointHelper,pl as PointerButton,fl as PointerEvent,Gh as Polygon,$a as PolygonData,zo as PropertyEvent,yh as Rect,Qa as RectData,se as RectHelper,dh as RectRender,Vo as RenderEvent,ya as Renderer,Yo as ResizeEvent,xl as RotateEvent,Bt as Run,Ca as Selector,tl as Star,th as StarData,Aa as State,mt as StringNumberMap,bl as SwipeEvent,hr as TaskItem,lr as TaskProcessor,hl as Text,Ta as TextConvert,rh as TextData,Y as TwoPointBoundsHelper,uh as UI,ah as UIBounds,Ct as UICreator,Ha as UIData,gl as UIEvent,hh as UIRender,Va as UnitConvert,Ro as WaitHelper,Xo as WatchEvent,sa as Watcher,Bl as ZoomEvent,kl as addInteractionWindow,Mr as affectRenderBoundsType,Or as affectStrokeBoundsType,Ia as arrowType,mr as attr,br as autoLayoutType,kr as boundsType,rr as canvasPatch,Ut as canvasSizeAttrs,Yr as cursorType,Xr as dataProcessor,wr as dataType,yr as decorateLeafAttr,Hr as defineDataProcessor,gr as defineKey,vr as defineLeafAttr,Tr as doBoundsType,Lr as doStrokeType,Fa as effectType,Wt as emptyData,zr as eraserType,u as getBoundsData,fr as getDescriptor,_ as getMatrixData,c as getPointData,Nr as hitType,Zn as inviteCode,jr as layoutProcessor,Fr as maskType,Cr as naturalBoundsType,Ar as opacityType,Er as pathInputType,Pr as pathType,ir as pen,xr as positionType,Jr as registerUI,$r as registerUIEvent,za as resizeType,Kr as rewrite,qr as rewriteAble,Rr as rotationType,Br as scaleType,Ir as sortType,Wa as stateType,Sr as strokeType,Dr as surfaceType,lt as tempBounds,N as tempMatrix,F as tempPoint,ea as useCanvas,Qr as useModule,qn as version,Wr as visibleType,Na 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={},i={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=s;return e[t]?e[t]++:(e[t]=1,0)}},s=i,{round:n,pow:o,PI:r}=Math,a={within:(t,e,i)=>("object"==typeof e&&(i=e.max,e=e.min),void 0!==e&&t<e&&(t=e),void 0!==i&&t>i&&(t=i),t),fourNumber(t,e){let i;if(t instanceof Array)switch(t.length){case 4:i=void 0===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)),a.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=e?o(10,e):1e12;return-0===(t=n(t*i)/i)?0:t},getScaleData:(t,e,i,s)=>(s||(s={}),e?(s.scaleX=("number"==typeof e?e:e.width)/i.width,s.scaleY=("number"==typeof e?e:e.height)/i.height):t&&a.assignScale(s,t),s),assignScale(t,e){"number"==typeof e?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)}},h=r/180,l=2*r,d=r/2;function c(){return{x:0,y:0}}function u(){return{x:0,y:0,width:0,height:0}}function _(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:p,cos:g,acos:f,sqrt:y}=Math,{float:m}=a,v={};function w(){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 x={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:w(),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:_,getWorld:w,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},scaleOfOuter(t,e,i,s){b.toInnerPoint(t,e,v),b.scaleOfInner(t,v,i,s)},scaleOfInner(t,e,i,s=i){b.translateInner(t,e.x,e.y),b.scale(t,i,s),b.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:o}=t,r=g(e*=h),a=p(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){b.toInnerPoint(t,e,v),b.rotateOfInner(t,v,i)},rotateOfInner(t,e,i){b.translateInner(t,e.x,e.y),b.rotate(t,i),b.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:o,d:r}=t;i&&(i*=h,t.a=s+o*i,t.b=n+r*i),e&&(e*=h,t.c=o+s*e,t.d=r+n*e)},skewOfOuter(t,e,i,s){b.toInnerPoint(t,e,v),b.skewOfInner(t,v,i,s)},skewOfInner(t,e,i,s=0){b.translateInner(t,e.x,e.y),b.skew(t,i,s),b.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,o){let{e:r,f:a}=t;if(o&&(r+=o.scrollX,a+=o.scrollY),i||(i=t),void 0===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){b.multiply(t,b.tempInvert(e))},divideParent(t,e){b.multiplyParent(t,b.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=b;return b.copy(e,t),b.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:o,y:r,scaleX:a,scaleY:l}=e;if(void 0===n&&(n=e.rotation||e.skewX||e.skewY),n){const{rotation:i,skewX:s,skewY:n}=e,o=i*h,r=g(o),d=p(o);if(s||n){const e=s*h,i=n*h;t.a=(r+i*-d)*a,t.b=(d+i*r)*a,t.c=(e*r-d)*l,t.d=(r+e*d)*l}else t.a=r*a,t.b=d*a,t.c=-d*l,t.d=r*l}else t.a=a,t.b=0,t.c=0,t.d=l;t.e=o,t.f=r,(i=i||s)&&b.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:n,b:o,c:r,d:a,e:l,f:c}=t;let u,_,v,w,x,b=l,B=c;if(o||r){const t=n*a-o*r;if(r&&!s){u=y(n*n+o*o),_=t/u;const e=n/u;v=o>0?f(e):-f(e)}else{_=y(r*r+a*a),u=t/_;const e=r/_;v=d-(a>0?f(-e):-f(e))}const e=m(g(v)),i=p(v);u=m(u),_=m(_),w=e?m((r/_+i)/e/h,9):0,x=e?m((o/u-i)/e/h,9):0,v=m(v/h)}else u=n,_=a,v=w=x=0;return(e=i||e)&&(b+=e.x*n+e.y*r,B+=e.x*o+e.y*a,i||(b-=e.x,B-=e.y)),{x:b,y:B,scaleX:u,scaleY:_,rotation:v,skewX:w,skewY:x}},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=y(s*s+n*n)):(e=s,i=r)}return s.scaleX=e,s.scaleY=i,s},reset(t){b.set(t)}},b=x,{toInnerPoint:B,toOuterPoint:R}=x,{sin:C,cos:k,abs:E,sqrt:T,atan2:P,min:O,PI:S}=Math,L={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=void 0===i?e:i},copy(t,e){t.x=e.x,t.y=e.y},copyFrom(t,e,i){t.x=e,t.y=i},move(t,e,i){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=D.defaultPoint);const s=k(e*=h),n=C(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}=D;return A(i,t),B(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=D;return A(i,t),R(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=D;return A(i,t),D.toInnerRadiusPointOf(t,e,i),i},toInnerRadiusPointOf(t,e,i){i||(i=t),B(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){B(e,t,i)},toOuterOf(t,e,i){R(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)=>M(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=E(i-t),o=E(s-e);return T(n*n+o*o)},getMinDistanceFrom:(t,e,i,s,n,o)=>O(M(t,e,i,s),M(i,s,n,o)),getAngle:(t,e)=>I(t,e)/h,getRotation:(t,e,i,s)=>(s||(s=e),D.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/h),getRadianFrom(t,e,i,s,n,o,r,a){void 0===r&&(r=i,a=s);let h=P(e-s,t-i);const d=P(o-a,n-r)-h;return d<-S?d+l:d},getAtan2:(t,e)=>P(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s){const n=I(t,e);return(e=s?e:{}).x=t.x+k(n)*i,e.y=t.y+C(n)*i,e},reset(t){D.reset(t)}},D=L,{getDistanceFrom:M,copy:A,getAtan2:I}=D;class W{constructor(t,e){this.set(t,e)}set(t,e){return"object"==typeof t?L.copy(this,t):L.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new W(this)}move(t,e){return L.move(this,t,e),this}scale(t,e){return L.scale(this,t,e),this}scaleOf(t,e,i){return L.scaleOf(this,t,e,i),this}rotate(t,e){return L.rotate(this,t,e),this}rotateOf(t,e){return L.rotate(this,e,t),this}getRotation(t,e,i){return L.getRotation(this,t,e,i)}toInnerOf(t,e){return L.toInnerOf(this,t,e),this}toOuterOf(t,e){return L.toOuterOf(this,t,e),this}getCenter(t){return new W(L.getCenter(this,t))}getDistance(t){return L.getDistance(this,t)}getDistancePoint(t,e,i){return new W(L.getDistancePoint(this,t,e,i))}getAngle(t){return L.getAngle(this,t)}getAtan2(t){return L.getAtan2(this,t)}reset(){return L.reset(this),this}}const F=new W;class N{constructor(t,e,i,s,n,o){this.set(t,e,i,s,n,o)}set(t,e,i,s,n,o){return"object"==typeof t?x.copy(this,t):x.set(this,t,e,i,s,n,o),this}setWith(t){return x.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 N(this)}translate(t,e){return x.translate(this,t,e),this}translateInner(t,e){return x.translateInner(this,t,e),this}scale(t,e){return x.scale(this,t,e),this}scaleWith(t,e){return x.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}scaleOfOuter(t,e,i){return x.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return x.scaleOfInner(this,t,e,i),this}rotate(t){return x.rotate(this,t),this}rotateOfOuter(t,e){return x.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return x.rotateOfInner(this,t,e),this}skew(t,e){return x.skew(this,t,e),this}skewOfOuter(t,e,i){return x.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return x.skewOfInner(this,t,e,i),this}multiply(t){return x.multiply(this,t),this}multiplyParent(t){return x.multiplyParent(this,t),this}divide(t){return x.divide(this,t),this}divideParent(t){return x.divideParent(this,t),this}invert(){return x.invert(this),this}invertWith(){return x.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){x.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){x.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return x.setLayout(this,t,e,i),this}getLayout(t,e,i){return x.getLayout(this,t,e,i)}withScale(t,e){return x.withScale(this,t,e)}reset(){x.reset(this)}}const z=new N,Y={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){X(t,e,i),X(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:X}=Y,{tempPointBounds:j,setPoint:H,addPoint:U,toBounds:V}=Y,{toOuterPoint:G}=x,{float:K,fourNumber:q}=a,{floor:Z,ceil:Q}=Math;let J,$,tt,et;const it={},st={},nt={tempBounds:{},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(i instanceof Array){const e=q(i);s?ot.set(t,o+e[3],r+e[0],a-e[1]-e[3],h-e[2]-e[0]):ot.set(t,o-e[3],r-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),ot.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},getByMove:(t,e,i)=>(t=Object.assign({},t),ot.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?at(e,t):e=t,i?(e.offsetX=-(ot.maxX(i)-t.x),e.offsetY=-(ot.maxY(i)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),ot.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e){L.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){L.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(ot.copy(ot.tempBounds,t),ot.toOuterOf(ot.tempBounds,e),ot.tempBounds),getOuterOf:(t,e)=>(t=Object.assign({},t),ot.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 it.x=t.x,it.y=t.y,G(e,it,st),H(j,st.x,st.y),it.x=t.x+t.width,G(e,it,st),U(j,st.x,st.y),it.y=t.y+t.height,G(e,it,st),U(j,st.x,st.y),it.x=t.x,G(e,it,st),U(j,st.x,st.y),V(j,i)},toInnerOf(t,e,i){i||(i=t),ot.move(i,-e.e,-e.f),ot.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Math.min(t.width/e.width,t.height/e.height));return new N(s,0,0,s,-e.x*s,-e.y*s)},getSpread(t,e,i){const s={};return ot.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){ot.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){ot.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=Z(t.x),t.y=Z(t.y),t.width=e>t.x?Q(t.width+e-t.x):Q(t.width),t.height=i>t.y?Q(t.height+i-t.y):Q(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=K(t.x,e),t.y=K(t.y,e),t.width=K(t.width,e),t.height=K(t.height,e)},add(t,e,i){J=t.x+t.width,$=t.y+t.height,tt=e.x,et=e.y,i||(tt+=e.width,et+=e.height),J=J>tt?J:tt,$=$>et?$:et,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=J-t.x,t.height=$-t.y},addList(t,e){ot.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){ot.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){ot.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]):e[r],n&&(n.width||n.height)&&(o?(o=!1,s||at(t,n)):rt(t,n));o&&ot.reset(t)},setPoints(t,e){e.forEach(((t,e)=>0===e?H(j,t.x,t.y):U(j,t.x,t.y))),V(j,t)},setPoint(t,e){ot.set(t,e.x,e.y)},addPoint(t,e){rt(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=L.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=L.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=ot.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=ot.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=ot.tempToOuterOf(e,i)),!ot.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:o,height:r}=e;return J=s+o,$=n+r,tt=t.x+t.width,et=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,J=J<tt?J:tt,$=$<et?$:et,o=J-s,r=$-n,{x:s,y:n,width:o,height:r}},intersect(t,e,i){ot.copy(t,ot.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){ot.set(t)}},ot=nt,{add:rt,copy:at}=ot;class ht{get minX(){return nt.minX(this)}get minY(){return nt.minY(this)}get maxX(){return nt.maxX(this)}get maxY(){return nt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return"object"==typeof t?nt.copy(this,t):nt.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 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}toOuterOf(t,e){return nt.toOuterOf(this,t,e),this}toInnerOf(t,e){return nt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return nt.getFitMatrix(this,t,e)}spread(t,e){return nt.spread(this,t,e),this}shrink(t,e){return nt.shrink(this,t,e),this}ceil(){return nt.ceil(this),this}unsign(){return nt.unsign(this),this}float(t){return nt.float(this,t),this}add(t){return nt.add(this,t),this}addList(t){return nt.setList(this,t,!0),this}setList(t){return nt.setList(this,t),this}addListWithFn(t,e){return nt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return nt.setListWithFn(this,t,e),this}setPoint(t){return nt.setPoint(this,t),this}setPoints(t){return nt.setPoints(this,t),this}addPoint(t){return nt.addPoint(this,t),this}getPoints(){return nt.getPoints(this)}hitPoint(t,e){return nt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return nt.hitRadiusPoint(this,t,e)}hit(t,e){return nt.hit(this,t,e)}includes(t,e){return nt.includes(this,t,e)}intersect(t,e){return nt.intersect(this,t,e),this}getIntersect(t,e){return new ht(nt.getIntersectData(this,t,e))}isSame(t){return nt.isSame(this,t)}isEmpty(){return nt.isEmpty(this)}reset(){nt.reset(this)}}const lt=new ht;class dt{constructor(t,e,i,s,n,o){"object"==typeof 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)}}var ct,ut;!function(t){t[t.top=0]="top",t[t.right=1]="right",t[t.bottom=2]="bottom",t[t.left=3]="left"}(ct||(ct={})),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"}(ut||(ut={}));const _t=[{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}];_t.forEach((t=>t.type="percent"));const pt={directionData:_t,tempPoint:{},get:gt,toPoint(t,e,i,s,n){const o=gt(t);i.x=o.x,i.y=o.y,"percent"===o.type&&(i.x*=e.width,i.y*=e.height,n&&(i.x-=n.x,i.y-=n.y,o.x&&(i.x-=1===o.x?n.width:.5===o.x?o.x*n.width:0),o.y&&(i.y-=1===o.y?n.height:.5===o.y?o.y*n.height:0))),s||(i.x+=e.x,i.y+=e.y)}};function gt(t){return"string"==typeof t?_t[ut[t]]:t}const{toPoint:ft}=pt,yt={toPoint(t,e,i,s,n){ft(t,i,s,n,e)}},mt={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};class vt{constructor(t){this.repeatMap={},this.name=t}static get(t){return new vt(t)}static set filter(t){this.filterList=wt(t)}static set exclude(t){this.excludeList=wt(t)}log(...t){if(xt.enable){if(xt.filterList.length&&xt.filterList.every((t=>t!==this.name)))return;if(xt.excludeList.length&&xt.excludeList.some((t=>t===this.name)))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){xt.enable&&this.warn(...t)}warn(...t){xt.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?"string"==typeof t&&(t=[t]):t=[],t}vt.filterList=[],vt.excludeList=[],vt.showWarn=!0;const xt=vt,bt=vt.get("RunTime"),Bt={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const s=i.create(i.RUNTIME);return Rt.currentId=Rt.idMap[s]=e?performance.now():Date.now(),Rt.currentName=Rt.nameMap[s]=t,Rt.nameToIdMap[t]=s,s},end(t,e){const i=Rt.idMap[t],s=Rt.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;Rt.idMap[t]=Rt.nameMap[t]=Rt.nameToIdMap[s]=void 0,bt.log(s,n,"ms")},endOfName(t,e){const i=Rt.nameToIdMap[t];void 0!==i&&Rt.end(i,e)}},Rt=Bt;function Ct(t){console.error("need plugin: @leafer-in/"+t)}const kt=vt.get("UICreator"),Et={list:{},register(t){const{__tag:e}=t.prototype;Tt[e]?kt.repeat(e):Tt[e]=t},get(t,e,i,s,n,o){const r=new Tt[t](e);return void 0!==i&&(r.x=i,s&&(r.y=s),n&&(r.width=n),o&&(r.height=o)),r}},{list:Tt}=Et,Pt=vt.get("EventCreator"),Ot={nameList:{},register(t){let e;Object.keys(t).forEach((i=>{e=t[i],"string"==typeof e&&(St[e]?Pt.repeat(e):St[e]=t)}))},changeName(t,e){const i=St[t];if(i){const s=Object.keys(i).find((e=>i[e]===t));s&&(i[s]=e,St[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new St[t](...e)},{nameList:St}=Ot;class Lt{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let i;const{list:s}=this;for(let e=0,n=s.length;e<n;e++)if(i=s[e],i.recycled&&i.isSameSize(t))return i.recycled=!1,i.manager||(i.manager=this),i;const n=e.canvas(t);return this.add(n),n}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()}}const Dt={default:(t,e)=>(Mt(e,t),Mt(t,e),t),assign(t,e){let i;Object.keys(e).forEach((s=>{var n;i=e[s],(null==i?void 0:i.constructor)===Object&&(null===(n=t[s])||void 0===n?void 0:n.constructor)===Object?Mt(t[s],e[s]):t[s]=e[s]}))},copyAttrs:(t,e,i)=>(i.forEach((i=>{void 0!==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}},{assign:Mt}=Dt;class At{get __useNaturalRatio(){return!0}get __isLinePath(){return this.path&&6===this.path.length}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(void 0!==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]=void 0===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(void 0!==e)return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&void 0!==this.__input[t]&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(t instanceof Array)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],void 0!==t)){if("path"===n&&!this.__pathInputed)continue;e=s?s[n]:void 0,i[n]=void 0===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||e.__hasEraser||t.eraser?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}}var It;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(It||(It={}));const Wt={};function Ft(t){return null==t}function Nt(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 zt(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){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}function Yt(t){return(e,i)=>{t||(t=i),Object.defineProperty(e,i,{get(){return this.context[t]},set(e){this.context[t]=e}})}}"function"==typeof SuppressedError&&SuppressedError;const Xt=[];function jt(){return(t,e)=>{Xt.push(e)}}const Ht=[];let Ut=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||Ht)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;Xt.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){"object"==typeof 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}};Nt([Yt("imageSmoothingEnabled")],Ut.prototype,"smooth",void 0),Nt([Yt("imageSmoothingQuality")],Ut.prototype,"smoothLevel",void 0),Nt([Yt("globalAlpha")],Ut.prototype,"opacity",void 0),Nt([Yt()],Ut.prototype,"fillStyle",void 0),Nt([Yt()],Ut.prototype,"strokeStyle",void 0),Nt([Yt("lineWidth")],Ut.prototype,"strokeWidth",void 0),Nt([Yt("lineCap")],Ut.prototype,"strokeCap",void 0),Nt([Yt("lineJoin")],Ut.prototype,"strokeJoin",void 0),Nt([Yt("lineDashOffset")],Ut.prototype,"dashOffset",void 0),Nt([Yt()],Ut.prototype,"miterLimit",void 0),Nt([Yt()],Ut.prototype,"shadowBlur",void 0),Nt([Yt()],Ut.prototype,"shadowColor",void 0),Nt([Yt()],Ut.prototype,"shadowOffsetX",void 0),Nt([Yt()],Ut.prototype,"shadowOffsetY",void 0),Nt([Yt()],Ut.prototype,"filter",void 0),Nt([Yt()],Ut.prototype,"font",void 0),Nt([Yt()],Ut.prototype,"fontKerning",void 0),Nt([Yt()],Ut.prototype,"fontStretch",void 0),Nt([Yt()],Ut.prototype,"fontVariantCaps",void 0),Nt([Yt()],Ut.prototype,"textAlign",void 0),Nt([Yt()],Ut.prototype,"textBaseline",void 0),Nt([Yt()],Ut.prototype,"textRendering",void 0),Nt([Yt()],Ut.prototype,"wordSpacing",void 0),Nt([Yt()],Ut.prototype,"letterSpacing",void 0),Nt([Yt()],Ut.prototype,"direction",void 0),Nt([jt()],Ut.prototype,"setTransform",null),Nt([jt()],Ut.prototype,"resetTransform",null),Nt([jt()],Ut.prototype,"getTransform",null),Nt([jt()],Ut.prototype,"save",null),Nt([jt()],Ut.prototype,"restore",null),Nt([jt()],Ut.prototype,"translate",null),Nt([jt()],Ut.prototype,"scale",null),Nt([jt()],Ut.prototype,"rotate",null),Nt([jt()],Ut.prototype,"fill",null),Nt([jt()],Ut.prototype,"stroke",null),Nt([jt()],Ut.prototype,"clip",null),Nt([jt()],Ut.prototype,"fillRect",null),Nt([jt()],Ut.prototype,"strokeRect",null),Nt([jt()],Ut.prototype,"clearRect",null),Nt([jt()],Ut.prototype,"beginPath",null),Nt([jt()],Ut.prototype,"moveTo",null),Nt([jt()],Ut.prototype,"lineTo",null),Nt([jt()],Ut.prototype,"bezierCurveTo",null),Nt([jt()],Ut.prototype,"quadraticCurveTo",null),Nt([jt()],Ut.prototype,"closePath",null),Nt([jt()],Ut.prototype,"arc",null),Nt([jt()],Ut.prototype,"arcTo",null),Nt([jt()],Ut.prototype,"ellipse",null),Nt([jt()],Ut.prototype,"rect",null),Nt([jt()],Ut.prototype,"roundRect",null),Nt([jt()],Ut.prototype,"createConicGradient",null),Nt([jt()],Ut.prototype,"createLinearGradient",null),Nt([jt()],Ut.prototype,"createPattern",null),Nt([jt()],Ut.prototype,"createRadialGradient",null),Nt([jt()],Ut.prototype,"fillText",null),Nt([jt()],Ut.prototype,"measureText",null),Nt([jt()],Ut.prototype,"strokeText",null);const{copy:Vt}=x,Gt={width:1,height:1,pixelRatio:1},Kt=["width","height","pixelRatio"];class qt extends Ut{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}get pixelHeight(){return this.height*this.pixelRatio}get allowBackgroundColor(){return this.view&&this.parentView}constructor(e,s){super(),this.size={},this.worldTransform={},e||(e=Gt),e.pixelRatio||(e.pixelRatio=t.devicePixelRatio),this.manager=s,this.innerId=i.create(i.CNAVAS);const{width:n,height:o,pixelRatio:r}=e;this.autoLayout=!n||!o,this.size.pixelRatio=r,this.config=e,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){if(this.isSameSize(t))return;let e;this.context&&!this.unreal&&this.width&&(e=this.getSameCanvas(),e.copyWorld(this)),Dt.copyAttrs(this.size,t,Kt),this.size.pixelRatio||(this.size.pixelRatio=1),this.bounds=new ht(0,0,this.width,this.height),this.context&&!this.unreal&&(this.updateViewSize(),this.smooth=this.config.smooth),this.updateClientBounds(),this.context&&!this.unreal&&e&&(this.clearWorld(e.bounds),this.copyWorld(e),e.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}=this,s=this.worldTransform;if(e){const{a:n,b:o,c:r,d:a,e:h,f:l}=e;this.setTransform(s.a=(t.a*n+t.b*r)*i,s.b=(t.a*o+t.b*a)*i,s.c=(t.c*n+t.d*r)*i,s.d=(t.c*o+t.d*a)*i,s.e=(t.e*n+t.f*r+h)*i,s.f=(t.e*o+t.f*a+l)*i)}else this.setTransform(s.a=t.a*i,s.b=t.b*i,s.c=t.c*i,s.d=t.d*i,s.e=t.e*i,s.f=t.f*i)}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){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),i&&this.setStrokeOptions(i)}setStrokeOptions(t){this.strokeCap="none"===t.strokeCap?"butt":t.strokeCap,this.strokeJoin=t.strokeJoin,this.dashPattern=t.dashPattern,this.dashOffset=t.dashOffset,this.miterLimit=t.miterLimit}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){if(s&&(this.blendMode=s),e){const{pixelRatio:s}=this;i||(i=e),this.drawImage(t.view,e.x*s,e.y*s,e.width*s,e.height*s,i.x*s,i.y*s,i.width*s,i.height*s)}else this.drawImage(t.view,0,0);s&&(this.blendMode="source-over")}copyWorldToInner(t,e,i,s){if(s&&(this.blendMode=s),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,nt.tempToOuterOf(i,e)),this.restore();else{const{pixelRatio:s}=this;this.drawImage(t.view,e.x*s,e.y*s,e.width*s,e.height*s,i.x,i.y,i.width,i.height)}s&&(this.blendMode="source-over")}copyWorldByReset(t,e,i,s,n){this.resetTransform(),this.copyWorld(t,e,i,s),n||this.useWorldTransform()}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){i&&(this.blendMode=i),this.fillStyle=e,lt.set(t).scale(this.pixelRatio),this.fillRect(lt.x,lt.y,lt.width,lt.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i){i&&(this.blendMode=i),this.strokeStyle=e,lt.set(t).scale(this.pixelRatio),this.strokeRect(lt.x,lt.y,lt.width,lt.height),i&&(this.blendMode="source-over")}clearWorld(t,e){lt.set(t).scale(this.pixelRatio),e&&lt.ceil(),this.clearRect(lt.x,lt.y,lt.width,lt.height)}clipWorld(t,e){this.beginPath(),lt.set(t).scale(this.pixelRatio),e&&lt.ceil(),this.rect(lt.x,lt.y,lt.width,lt.height),this.clip()}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}isSameSize(t){return this.width===t.width&&this.height===t.height&&this.pixelRatio===t.pixelRatio}getSameCanvas(t,i){const s=this.manager?this.manager.get(this.size):e.canvas(Object.assign({},this.size));return s.save(),t&&(Vt(s.worldTransform,this.worldTransform),s.useWorldTransform()),i&&(s.smooth=this.smooth),s}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t,!0):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const Zt={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Qt={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Jt=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},Qt),$t={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},te={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},ee=Object.assign(Object.assign({},te),Qt),ie=Jt,se={};for(let t in ie)se[ie[t]]=t;const ne={};for(let t in ie)ne[ie[t]]=$t[t];const oe={drawRoundRect(t,e,i,s,n,o){const r=a.fourNumber(o,Math.min(s/2,n/2)),h=e+s,l=i+n;r[0]?t.moveTo(e+r[0],i):t.moveTo(e,i),r[1]?t.arcTo(h,i,h,l,r[1]):t.lineTo(h,i),r[2]?t.arcTo(h,l,e,l,r[2]):t.lineTo(h,l),r[3]?t.arcTo(e,l,e,i,r[3]):t.lineTo(e,l),r[0]?t.arcTo(e,i,h,i,r[0]):t.lineTo(e,i)}},{sin:re,cos:ae,atan2:he,ceil:le,abs:de,PI:ce,sqrt:ue,pow:_e}=Math,{setPoint:pe,addPoint:ge}=Y,{set:fe}=L,{M:ye,L:me,C:ve,Q:we,Z:xe}=Jt,be={},Be={points(t,e,i,s){if(t.push(ye,e[0],e[1]),i&&e.length>5){let n,o,r,a,h,l,d,c,u,_,p,g,f,y=e.length;const m=!0===i?.5:i;s&&(y=(e=[e[y-2],e[y-1],...e,e[0],e[1],e[2],e[3]]).length);for(let i=2;i<y-2;i+=2)n=e[i-2],o=e[i-1],r=e[i],a=e[i+1],h=e[i+2],l=e[i+3],p=ue(_e(r-n,2)+_e(a-o,2)),g=ue(_e(h-r,2)+_e(l-a,2)),f=p+g,p=m*p/f,g=m*g/f,h-=n,l-=o,d=r-p*h,c=a-p*l,2===i?s||t.push(we,d,c,r,a):t.push(ve,u,_,d,c,r,a),u=r+g*h,_=a+g*l;s||t.push(we,u,_,e[y-2],e[y-1])}else for(let i=2,s=e.length;i<s;i+=2)t.push(me,e[i],e[i+1]);s&&t.push(xe)},rect(t,e,i,s,n){Zt.creator.path=t,Zt.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){Zt.creator.path=[],oe.drawRoundRect(Zt.creator,e,i,s,n,o),t.push(...Zt.convertToCanvasData(Zt.creator.path,!0))},arcTo(t,e,i,s,n,o,r,a,c,u,_){const p=s-e,g=n-i,f=o-s,y=r-n;let m=he(g,p),v=he(y,f),w=v-m;if(w<0&&(w+=l),w===ce||de(p+g)<1e-12||de(f+y)<1e-12)return t&&t.push(me,s,n),c&&(pe(c,e,i),ge(c,s,n)),_&&fe(_,e,i),void(u&&fe(u,s,n));const x=p*y-f*g<0,b=x?-1:1,B=a/ae(w/2),R=s+B*ae(m+w/2+d*b),C=n+B*re(m+w/2+d*b);return m-=d*b,v-=d*b,ke(t,R,C,a,a,0,m/h,v/h,x,c,u,_)},arc:(t,e,i,s,n,o,r,a,h,l)=>ke(t,e,i,s,s,0,n,o,r,a,h,l),ellipse(t,e,i,s,n,o,r,a,c,u,_,p){const g=o*h,f=re(g),y=ae(g);let m=r*h,v=a*h;m>ce&&(m-=l),v<0&&(v+=l);let w=v-m;w<0?w+=l:w>l&&(w-=l),c&&(w-=l);const x=le(de(w/d)),b=w/x,B=re(b/4),R=8/3*B*B/re(b/2);v=m+b;let C,k,E,T,P,O,S,L,D=ae(m),M=re(m),A=E=y*s*D-f*n*M,I=T=f*s*D+y*n*M,W=e+E,F=i+T;t&&t.push(t.length?me:ye,W,F),u&&pe(u,W,F),p&&fe(p,W,F);for(let o=0;o<x;o++)C=ae(v),k=re(v),E=y*s*C-f*n*k,T=f*s*C+y*n*k,P=e+A-R*(y*s*M+f*n*D),O=i+I-R*(f*s*M-y*n*D),S=e+E+R*(y*s*k+f*n*C),L=i+T+R*(f*s*k-y*n*C),t&&t.push(ve,P,O,S,L,e+E,i+T),u&&Ce(e+A,i+I,P,O,S,L,e+E,i+T,u,!0),A=E,I=T,D=C,M=k,m=v,v+=b;_&&fe(_,e+E,i+T)},quadraticCurveTo(t,e,i,s,n,o,r){t.push(ve,(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){Ce(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,y,m,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 y=u*u-4*_*c,m=Math.sqrt(y),y<0||(g=(-u+m)/(2*c),0<g&&g<1&&d.push(g),f=(-u-m)/(2*c),0<f&&f<1&&d.push(f));l?ge(h,t,e):pe(h,t,e),ge(h,r,a);for(let l=0,c=d.length;l<c;l++)Re(d[l],t,e,i,s,n,o,r,a,be),ge(h,be.x,be.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 Re(t,e,i,s,n,o,r,a,h,l),l}},{getPointAndSet:Re,toTwoPointBounds:Ce,ellipse:ke}=Be,{sin:Ee,cos:Te,sqrt:Pe,atan2:Oe}=Math,{ellipse:Se}=Be,Le={ellipticalArc(e,i,s,n,o,r,a,d,c,u,_){const p=(c-i)/2,g=(u-s)/2,f=r*h,y=Ee(f),m=Te(f),v=-m*p-y*g,w=-m*g+y*p,x=n*n,b=o*o,B=w*w,R=v*v,C=x*b-x*B-b*R;let k=0;if(C<0){const t=Pe(1-C/(x*b));n*=t,o*=t}else k=(a===d?-1:1)*Pe(C/(x*B+b*R));const E=k*n*w/o,T=-k*o*v/n,P=Oe((w-T)/o,(v-E)/n),O=Oe((-w-T)/o,(-v-E)/n);let S=O-P;0===d&&S>0?S-=l:1===d&&S<0&&(S+=l);const L=i+p+m*E-y*T,D=s+g+y*E+m*T,M=S<0?1:0;_||t.ellipseToCurve?Se(e,L,D,n,o,r,P/h,O/h,M):n!==o||r?e.push(Jt.G,L,D,n,o,r,P/h,O/h,M):e.push(Jt.O,L,D,n,P/h,O/h,M)}},{M:De,m:Me,L:Ae,l:Ie,H:We,h:Fe,V:Ne,v:ze,C:Ye,c:Xe,S:je,s:He,Q:Ue,q:Ve,T:Ge,t:Ke,A:qe,a:Ze,Z:Qe,z:Je,N:$e,D:ti,X:ei,G:ii,F:si,O:ni,P:oi,U:ri}=Jt,{rect:ai,roundRect:hi,arcTo:li,arc:di,ellipse:ci,quadraticCurveTo:ui}=Be,{ellipticalArc:_i}=Le,pi=vt.get("PathConvert"),gi={},fi={current:{dot:0},stringify(t,e){let i,s,n,o=0,r=t.length,h="";for(;o<r;){s=t[o],i=ne[s],h+=s===n?" ":se[s];for(let s=1;s<i;s++)h+=a.float(t[o+s],e),s===i-1||(h+=" ");n=s,o+=i}return h},parse(t,e){let i,s,n,o="";const r=[],a=e?ee:te;for(let e=0,h=t.length;e<h;e++)s=t[e],mt[s]?("."===s&&(yi.dot&&(mi(r,o),o=""),yi.dot++),"0"===o&&"."!==s&&(mi(r,o),o=""),o+=s):Jt[s]?(o&&(mi(r,o),o=""),yi.name=Jt[s],yi.length=$t[s],yi.index=0,mi(r,yi.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?o+=s:(o&&mi(r,o),o=s):o&&(mi(r,o),o=""),n=s;return o&&mi(r,o),i?fi.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 Me:t[c+1]+=a,t[c+2]+=h;case De:a=t[c+1],h=t[c+2],_.push(De,a,h),c+=3;break;case Fe:t[c+1]+=a;case We:a=t[c+1],_.push(Ae,a,h),c+=2;break;case ze:t[c+1]+=h;case Ne:h=t[c+1],_.push(Ae,a,h),c+=2;break;case Ie:t[c+1]+=a,t[c+2]+=h;case Ae:a=t[c+1],h=t[c+2],_.push(Ae,a,h),c+=3;break;case He:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=je;case je:r=o===Ye||o===je,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(Ye,l,d,i,s,a,h),c+=5;break;case Xe: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=Ye;case Ye:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],_.push(Ye,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Ke:t[c+1]+=a,t[c+2]+=h,n=Ge;case Ge:r=o===Ue||o===Ge,i=r?2*a-i:t[c+1],s=r?2*h-s:t[c+2],e?ui(_,a,h,i,s,t[c+1],t[c+2]):_.push(Ue,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Ve:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ue;case Ue:i=t[c+1],s=t[c+2],e?ui(_,a,h,i,s,t[c+3],t[c+4]):_.push(Ue,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Ze:t[c+6]+=a,t[c+7]+=h;case qe:_i(_,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 Je:case Qe:_.push(Qe),c++;break;case $e:a=t[c+1],h=t[c+2],e?ai(_,a,h,t[c+3],t[c+4]):vi(_,t,c,5),c+=5;break;case ti:a=t[c+1],h=t[c+2],e?hi(_,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):vi(_,t,c,9),c+=9;break;case ei:a=t[c+1],h=t[c+2],e?hi(_,a,h,t[c+3],t[c+4],t[c+5]):vi(_,t,c,6),c+=6;break;case ii:ci(e?_:vi(_,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,gi),a=gi.x,h=gi.y,c+=9;break;case si:e?ci(_,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):vi(_,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case ni:di(e?_:vi(_,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,gi),a=gi.x,h=gi.y,c+=7;break;case oi:e?di(_,t[c+1],t[c+2],t[c+3],0,360,!1):vi(_,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case ri:li(e?_:vi(_,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,gi),a=gi.x,h=gi.y,c+=6;break;default:return pi.error(`command: ${n} [index:${c}]`,t),_}o=n}return _},copyData(t,e,i,s){for(let n=i,o=i+s;n<o;n++)t.push(e[n])},pushData(t,e){yi.index===yi.length&&(yi.index=1,t.push(yi.name)),t.push(Number(e)),yi.index++,yi.dot=0}},{current:yi,pushData:mi,copyData:vi}=fi,{M:wi,L:xi,C:bi,Q:Bi,Z:Ri,N:Ci,D:ki,X:Ei,G:Ti,F:Pi,O:Oi,P:Si,U:Li}=Jt,{getMinDistanceFrom:Di,getRadianFrom:Mi}=L,{tan:Ai,min:Ii,abs:Wi}=Math,Fi={},Ni={beginPath(t){t.length=0},moveTo(t,e,i){t.push(wi,e,i)},lineTo(t,e,i){t.push(xi,e,i)},bezierCurveTo(t,e,i,s,n,o,r){t.push(bi,e,i,s,n,o,r)},quadraticCurveTo(t,e,i,s,n){t.push(Bi,e,i,s,n)},closePath(t){t.push(Ri)},rect(t,e,i,s,n){t.push(Ci,e,i,s,n)},roundRect(t,e,i,s,n,o){if("number"==typeof o)t.push(Ei,e,i,s,n,o);else{const r=a.fourNumber(o);r?t.push(ki,e,i,s,n,...r):t.push(Ci,e,i,s,n)}},ellipse(t,e,i,s,n,o,r,a,h){void 0===o?t.push(Pi,e,i,s,n):(void 0===r&&(r=0),void 0===a&&(a=360),t.push(Ti,e,i,s,n,o,r,a,h?1:0))},arc(t,e,i,s,n,o,r){void 0===n?t.push(Si,e,i,s):(void 0===o&&(o=360),t.push(Oi,e,i,s,n,o,r?1:0))},arcTo(t,e,i,s,n,o,r,a){if(void 0!==r){const h=Ai(Mi(r,a,e,i,s,n)/2)*(Di(r,a,e,i,s,n)/2);t.push(Li,e,i,s,n,Ii(o,Wi(h)))}else t.push(Li,e,i,s,n,o)},drawEllipse(t,e,i,s,n,o,r,a,h){Be.ellipse(null,e,i,s,n,void 0===o?0:o,void 0===r?0:r,void 0===a?360:a,h,null,null,Fi),t.push(wi,Fi.x,Fi.y),zi(t,e,i,s,n,o,r,a,h)},drawArc(t,e,i,s,n,o,r){Be.arc(null,e,i,s,void 0===n?0:n,void 0===o?360:o,r,null,null,Fi),t.push(wi,Fi.x,Fi.y),Yi(t,e,i,s,n,o,r)},drawPoints(t,e,i,s){Be.points(t,e,i,s)}},{ellipse:zi,arc:Yi}=Ni,{moveTo:Xi,lineTo:ji,quadraticCurveTo:Hi,bezierCurveTo:Ui,closePath:Vi,beginPath:Gi,rect:Ki,roundRect:qi,ellipse:Zi,arc:Qi,arcTo:Ji,drawEllipse:$i,drawArc:ts,drawPoints:es}=Ni;class is{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.clearPath=this.beginPath,this.set(t)}set(t){return this.__path=t?"string"==typeof t?Zt.parse(t):t:[],this}beginPath(){return Gi(this.__path),this.paint(),this}moveTo(t,e){return Xi(this.__path,t,e),this.paint(),this}lineTo(t,e){return ji(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,o){return Ui(this.__path,t,e,i,s,n,o),this.paint(),this}quadraticCurveTo(t,e,i,s){return Hi(this.__path,t,e,i,s),this.paint(),this}closePath(){return Vi(this.__path),this.paint(),this}rect(t,e,i,s){return Ki(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return qi(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,o,r,a){return Zi(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}arc(t,e,i,s,n,o){return Qi(this.__path,t,e,i,s,n,o),this.paint(),this}arcTo(t,e,i,s,n){return Ji(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,o,r,a){return $i(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}drawArc(t,e,i,s,n,o){return ts(this.__path,t,e,i,s,n,o),this.paint(),this}drawPoints(t,e,i){return es(this.__path,t,e,i),this.paint(),this}paint(){}}const{M:ss,L:ns,C:os,Q:rs,Z:as,N:hs,D:ls,X:ds,G:cs,F:us,O:_s,P:ps,U:gs}=Jt,fs=vt.get("PathDrawer"),ys={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case ss:t.moveTo(e[s+1],e[s+2]),s+=3;break;case ns:t.lineTo(e[s+1],e[s+2]),s+=3;break;case os:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case rs:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case as:t.closePath(),s+=1;break;case hs:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case ls: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 ds:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case cs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*h,e[s+6]*h,e[s+7]*h,e[s+8]),s+=9;break;case us:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,l,!1),s+=5;break;case _s:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*h,e[s+5]*h,e[s+6]),s+=7;break;case ps:t.arc(e[s+1],e[s+2],e[s+3],0,l,!1),s+=4;break;case gs:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void fs.error(`command: ${i} [index:${s}]`,e)}}},{M:ms,L:vs,C:ws,Q:xs,Z:bs,N:Bs,D:Rs,X:Cs,G:ks,F:Es,O:Ts,P:Ps,U:Os}=Jt,{toTwoPointBounds:Ss,toTwoPointBoundsByQuadraticCurve:Ls,arcTo:Ds,arc:Ms,ellipse:As}=Be,{addPointBounds:Is,copy:Ws,addPoint:Fs,setPoint:Ns,addBounds:zs,toBounds:Ys}=Y,Xs=vt.get("PathBounds");let js,Hs,Us;const Vs={},Gs={},Ks={},qs={toBounds(t,e){qs.toTwoPointBounds(t,Gs),Ys(Gs,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Ns(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===bs||r===ws||r===xs?Ns(e,h,l):Ns(e,t[a+1],t[a+2])),r){case ms:case vs:h=t[a+1],l=t[a+2],Fs(e,h,l),a+=3;break;case ws:n=t[a+5],o=t[a+6],Ss(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,o,Vs),Is(e,Vs),h=n,l=o,a+=7;break;case xs:i=t[a+1],s=t[a+2],n=t[a+3],o=t[a+4],Ls(h,l,i,s,n,o,Vs),Is(e,Vs),h=n,l=o,a+=5;break;case bs:a+=1;break;case Bs:h=t[a+1],l=t[a+2],zs(e,h,l,t[a+3],t[a+4]),a+=5;break;case Rs:case Cs:h=t[a+1],l=t[a+2],zs(e,h,l,t[a+3],t[a+4]),a+=r===Rs?9:6;break;case ks:As(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],Vs,Ks),0===a?Ws(e,Vs):Is(e,Vs),h=Ks.x,l=Ks.y,a+=9;break;case Es:h=t[a+1],l=t[a+2],Hs=t[a+3],Us=t[a+4],zs(e,h-Hs,l-Us,2*Hs,2*Us),h+=Hs,a+=5;break;case Ts:Ms(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Vs,Ks),0===a?Ws(e,Vs):Is(e,Vs),h=Ks.x,l=Ks.y,a+=7;break;case Ps:h=t[a+1],l=t[a+2],js=t[a+3],zs(e,h-js,l-js,2*js,2*js),h+=js,a+=4;break;case Os:Ds(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Vs,Ks),0===a?Ws(e,Vs):Is(e,Vs),h=Ks.x,l=Ks.y,a+=6;break;default:return void Xs.error(`command: ${r} [index:${a}]`,t)}}},{M:Zs,L:Qs,C:Js,Z:$s}=Jt,{getCenterX:tn,getCenterY:en}=L,{arcTo:sn}=Ni,nn={smooth(t,e,i){let s,n=0,o=0,r=0,a=0,h=0,l=0,d=0,c=0,u=0;const _=t.length,p=[];for(;n<_;)switch(s=t[n],s){case Zs:a=c=t[n+1],h=u=t[n+2],n+=3,t[n]===Qs?(l=t[n+1],d=t[n+2],p.push(Zs,tn(a,l),en(h,d))):p.push(Zs,a,h);break;case Qs:switch(o=t[n+1],r=t[n+2],n+=3,t[n]){case Qs:sn(p,o,r,t[n+1],t[n+2],e,c,u);break;case $s:sn(p,o,r,a,h,e,c,u);break;default:p.push(Qs,o,r)}c=o,u=r;break;case Js:p.push(Js,t[n+1],t[n+2],t[n+3],t[n+4],t[n+5],t[n+6]),n+=7;break;case $s:sn(p,a,h,l,d,e,c,u),p.push($s),n+=1}return s!==$s&&(p[1]=a,p[2]=h),p}};Zt.creator=new is,Zt.parse=fi.parse,Zt.convertToCanvasData=fi.toCanvasData;const on=new is,{drawRoundRect:rn}=oe;function an(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){rn(this,t,e,i,s,n)})}(t)}const hn={opacityTypes:["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=ln.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{}}}},ln=hn;ln.opacityTypes.forEach((t=>ln.upperCaseTypeMap[t]=t.toUpperCase()));const dn=vt.get("TaskProcessor");class cn{constructor(t){this.parallel=!0,this.time=1,this.id=i.create(i.TASK),this.task=t}run(){return zt(this,void 0,void 0,(function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){dn.error(t)}}))}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class un{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&&Dt.assign(this.config,t),this.empty()}add(t,e){let i,s,n,o;const r=new cn(t);return r.parent=this,"number"==typeof e?o=e:e&&(s=e.parallel,i=e.start,n=e.time,o=e.delay),n&&(r.time=n),!1===s&&(r.parallel=!1),void 0===o?this.push(r,i):(this.delayNumber++,setTimeout((()=>{this.delayNumber&&(this.delayNumber--,this.push(r,i))}),o)),this.isComplete=!1,r}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 _n={map:{},recycledList:[],tasker:new un,patternTasker:new un,get isComplete(){return pn.tasker.isComplete},get(t){let i=pn.map[t.url];return i||(i=e.image(t),pn.map[t.url]=i),i.use++,i},recycle(t){t.use--,setTimeout((()=>{t.use||pn.recycledList.push(t)}))},clearRecycled(){const t=pn.recycledList;t.length>100&&(t.forEach((t=>{!t.use&&t.url&&(delete pn.map[t.url],t.destroy())})),t.length=0)},hasOpacityPixel:t=>hn.opacityTypes.some((e=>pn.isFormat(e,t))),isFormat(t,e){if(e.format===t)return!0;const{url:i}=e;if(i.startsWith("data:")){if(i.startsWith("data:"+hn.mineType(t)))return!0}else if(i.includes("."+t)||i.includes("."+hn.upperCaseTypeMap[t]))return!0;return!1},destroy(){pn.map={},pn.recycledList=[]}},pn=_n,{IMAGE:gn,create:fn}=i;class yn{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){this.use=0,this.waitComplete=[],this.innerId=fn(gn),this.config=t||{url:""},this.isSVG=_n.isFormat("svg",t),this.hasOpacityPixel=_n.hasOpacityPixel(t)}load(e,i){return this.loading||(this.loading=!0,_n.tasker.add((()=>zt(this,void 0,void 0,(function*(){return yield t.origin.loadImage(this.url).then((t=>{this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)})).catch((t=>{this.error=t,this.onComplete(!1)}))}))))),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}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}getCanvas(e,i,s,n){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 o=t.origin.createCanvas(e,i),r=o.getContext("2d");return s&&(r.globalAlpha=s),r.drawImage(this.view,0,0,e,i),this.cache=this.use>1?{data:o,params:arguments}:null,o}getPattern(e,i,s,n){const o=t.canvas.createPattern(e,i);try{s&&o.setTransform&&(o.setTransform(s),s=null)}catch(t){}return n&&(n.transform=s),o}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}}function mn(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function vn(t,e){return Object.getOwnPropertyDescriptor(t,e)}function wn(t,e){return(i,s)=>bn(i,s,t,e&&e(s))}function xn(t){return t}function bn(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};mn(t,e,Object.assign(n,s||{})),Kn(t,e,i)}function Bn(t){return wn(t)}function Rn(t,e){return wn(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}})))}function Cn(t){return wn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal())}})))}function kn(t,e){return wn(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}})))}function En(t,e){return wn(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}})))}function Tn(t,e){return wn(t,(t=>({set(i){this.__setAttr(t,i,e)&&On(this)}})))}function Pn(t){return wn(t,(t=>({set(e){this.__setAttr(t,e)&&(On(this),this.__.__removeNaturalSize())}})))}function On(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function Sn(t){return wn(t,(t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),On(this)}})))}const Ln=Tn;function Dn(t){return wn(t,(t=>({set(e){this.__setAttr(t,e)&&Mn(this)}})))}function Mn(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&On(t)}const An=Dn;function In(t){return wn(t,(t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}})))}function Wn(t){return wn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}})))}function Fn(t){return wn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange())}})))}function Nn(t){return wn(t,(t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",(()=>zn(this,t,e,i)))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");zn(this,t,e,i)}})))}function zn(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||On(t))}function Yn(t){return wn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.waitParent((()=>{this.parent.__layout.childrenSortChange()})))}})))}function Xn(t){return wn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent((()=>{this.parent.__updateMask(e)})))}})))}function jn(t){return wn(t,(t=>({set(e){this.__setAttr(t,e)&&this.waitParent((()=>{this.parent.__updateEraser(e)}))}})))}function Hn(t){return wn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,vt.showHitView&&(this.__layout.surfaceChanged||this.__layout.surfaceChange()),this.leafer&&this.leafer.updateCursor())}})))}function Un(t){return wn(t,(t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}})))}function Vn(t){return(e,i)=>{mn(e,"__DataProcessor",{get:()=>t})}}function Gn(t){return(e,i)=>{mn(e,"__LayoutProcessor",{get:()=>t})}}function Kn(t,e,i){const s=t.__DataProcessor.prototype,n="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),r={get(){const t=this[n];return void 0===t?i:t},set(t){this[n]=t}};if(void 0===i)r.get=function(){return this[n]};else if("object"==typeof i){const{clone:t}=Dt;r.get=function(){let e=this[n];return void 0===e&&(this[n]=e=t(i)),e}}"width"===e?r.get=function(){const t=this[n];if(void 0===t){const t=this;return t._height&&t.__naturalWidth&&t.__useNaturalRatio?t._height*t.__naturalWidth/t.__naturalHeight:t.__naturalWidth||i}return t}:"height"===e&&(r.get=function(){const t=this[n];if(void 0===t){const t=this;return t._width&&t.__naturalHeight&&t.__useNaturalRatio?t._width*t.__naturalHeight/t.__naturalWidth:t.__naturalHeight||i}return t});let a,h=s;for(;!a&&h;)a=vn(h,e),h=h.__proto__;a&&a.set&&(r.set=a.set),s[o]&&(r.set=s[o],delete s[o]),mn(s,e,r)}const qn=new vt("rewrite"),Zn=[],Qn=["destroy","constructor"];function Jn(t){return(e,i)=>{Zn.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function $n(){return t=>{to()}}function to(t){Zn.length&&(Zn.forEach((e=>{t&&qn.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()})),Zn.length=0)}function eo(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach((s=>{if(!(Qn.includes(s)||e&&e.includes(s)))if(t.prototype){vn(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]}))}}function io(){return t=>{Et.register(t)}}function so(){return t=>{Ot.register(t)}}setTimeout((()=>to(!0)));const{copy:no,toInnerPoint:oo,toOuterPoint:ro,scaleOfOuter:ao,rotateOfOuter:ho,skewOfOuter:lo,multiplyParent:co,divideParent:uo,getLayout:_o}=x,po={},go={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),mo(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)yo(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++)vo(e[t])}},updateAllChange(t){if(vo(t),t.__updateChange(),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)wo(e[t])}},worldHittable(t){for(;t;){if(!t.__.hittable)return!1;t=t.parent}return!0},moveWorld(t,e,i=0,s){const n="object"==typeof e?Object.assign({},e):{x:e,y:i};s?ro(t.localTransform,n,n,!0):t.parent&&oo(t.parent.worldTransform,n,n,!0),fo.moveLocal(t,n.x,n.y)},moveLocal(t,e,i=0){"object"==typeof e?(t.x+=e.x,t.y+=e.y):(t.x+=e,t.y+=i)},zoomOfWorld(t,e,i,s,n){fo.zoomOfLocal(t,bo(t,e),i,s,n)},zoomOfLocal(t,e,i,s=i,n){no(po,t.__localMatrix),ao(po,e,i,s),t.origin||t.around?fo.setTransform(t,po,n):(xo(t,po),t.scaleResize(i,s,!0!==n))},rotateOfWorld(t,e,i){fo.rotateOfLocal(t,bo(t,e),i)},rotateOfLocal(t,e,i){no(po,t.__localMatrix),ho(po,e,i),t.origin||t.around?fo.setTransform(t,po):(xo(t,po),t.rotation=a.formatRotation(t.rotation+i))},skewOfWorld(t,e,i,s,n){fo.skewOfLocal(t,bo(t,e),i,s,n)},skewOfLocal(t,e,i,s=0,n){no(po,t.__localMatrix),lo(po,e,i,s),fo.setTransform(t,po,n)},transformWorld(t,e,i){no(po,t.worldTransform),co(po,e),t.parent&&uo(po,t.parent.worldTransform),fo.setTransform(t,po,i)},transform(t,e,i){no(po,t.localTransform),co(po,e),fo.setTransform(t,po,i)},setTransform(t,e,i){const s=_o(e,t.origin&&fo.getInnerOrigin(t,t.origin),t.around&&fo.getInnerOrigin(t,t.around));if(i){const e=s.scaleX/t.scaleX,n=s.scaleY/t.scaleY;delete s.scaleX,delete s.scaleY,t.set(s),t.scaleResize(e,n,!0!==i)}else t.set(s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return ao(i,fo.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>L.tempToOuterOf(fo.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return pt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(no(po,t.worldTransform),uo(po,e.worldTransform),i?po:Object.assign({},po)),drop(t,e,i,s){t.setTransform(fo.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}}},fo=go,{updateAllMatrix:yo,updateMatrix:mo,updateAllWorldOpacity:vo,updateAllChange:wo}=fo;function xo(t,e){const{e:i,f:s}=t.__localMatrix;t.x+=e.e-i,t.y+=e.f-s}function bo(t,e){return t.__layout.update(),t.parent?L.tempToInnerOf(e,t.parent.__world):e}const Bo={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=>t.__.mask?t.__localBoxBounds:null,maskLocalStrokeBounds:t=>t.__.mask?t.__layout.localStrokeBounds:null,maskLocalRenderBounds:t=>t.__.mask?t.__layout.localRenderBounds:null,excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))},{updateBounds:Ro}=go,Co={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),ko(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&void 0===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++)Eo(e[t],e)},updateBounds(t,e){const i=[t];Eo(t,i),To(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++)Ro(s[t]);e&&e===i||Ro(i)}}},{pushAllChildBranch:ko,pushAllBranchStack:Eo,updateBoundsByBranchStack:To}=Co,Po={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:Oo}=go,{toOuterOf:So,getPoints:Lo,copy:Do}=nt,Mo="_localContentBounds",Ao="_worldContentBounds",Io="_worldBoxBounds",Wo="_worldStrokeBounds";class Fo{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}get localContentBounds(){return So(this.contentBounds,this.leaf.__localMatrix,this[Mo]||(this[Mo]={})),this[Mo]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return So(this.contentBounds,this.leaf.__world,this[Ao]||(this[Ao]={})),this[Ao]}get worldBoxBounds(){return So(this.boxBounds,this.leaf.__world,this[Io]||(this[Io]={})),this[Io]}get worldStrokeBounds(){return So(this.strokeBounds,this.leaf.__world,this[Wo]||(this[Wo]={})),this[Wo]}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.boxBounds={x:0,y:0,width:0,height:0},this.leaf.__local&&(this._localRenderBounds=this._localStrokeBounds=this.leaf.__local),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{leafer:e}=this.leaf;if(e)e.ready?e.watcher.changed&&e.layouter.layout():e.start();else{let e=this.leaf;for(;e.parent&&!e.parent.leafer;)e=e.parent;t.layout(e)}}getTransform(t="world"){this.update();const{leaf:e}=this;switch(t){case"world":return e.__world;case"local":return e.__localMatrix;case"inner":return x.defaultMatrix;case"page":t=e.zoomLayer;default:return Oo(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=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(r),o=s.__world;break;case"local":n=s.getLocalPointByInner(r),o=s.__localMatrix;break;case"inner":n=r,o=x.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(r,e),o=Oo(s,e,!0)}const a=x.getLayout(o);if(Do(a,r),L.copy(a,n),i){const{scaleX:t,scaleY:e}=a,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(a.scaleX/=i,a.scaleY/=s,a.width*=i,a.height*=s)}return a}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=Lo(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 void 0!==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.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.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class No{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 zo extends No{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}zo.ADD="child.add",zo.REMOVE="child.remove",zo.CREATED="created",zo.MOUNTED="mounted",zo.UNMOUNTED="unmounted",zo.DESTROY="destroy";class Yo extends No{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Yo.CHANGE="property.change",Yo.LEAFER_CHANGE="property.leafer_change";class Xo extends No{constructor(t,e){super(t),Object.assign(this,e)}}Xo.LOAD="image.load",Xo.LOADED="image.loaded",Xo.ERROR="image.error";class jo extends No{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){"object"==typeof t?(super(jo.RESIZE),Object.assign(this,t)):super(t),this.old=e}}jo.RESIZE="resize";class Ho extends No{constructor(t,e){super(t),this.data=e}}Ho.REQUEST="watch.request",Ho.DATA="watch.data";class Uo extends No{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}Uo.CHECK_UPDATE="layout.check_update",Uo.REQUEST="layout.request",Uo.START="layout.start",Uo.BEFORE="layout.before",Uo.LAYOUT="layout",Uo.AFTER="layout.after",Uo.AGAIN="layout.again",Uo.END="layout.end";class Vo extends No{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Vo.REQUEST="render.request",Vo.START="render.start",Vo.BEFORE="render.before",Vo.RENDER="render",Vo.AFTER="render.after",Vo.AGAIN="render.again",Vo.END="render.end",Vo.NEXT="render.next";class Go extends No{}Go.START="leafer.start",Go.BEFORE_READY="leafer.before_ready",Go.READY="leafer.ready",Go.AFTER_READY="leafer.after_ready",Go.VIEW_READY="leafer.view_ready",Go.VIEW_COMPLETED="leafer.view_completed",Go.STOP="leafer.stop",Go.RESTART="leafer.restart",Go.END="leafer.end";const Ko={};class qo{set event(t){this.on(t)}on(t,e,i){if(!e){let e,i=t;for(let t in i)e=i[t],e instanceof Array?this.on(t,e[0],e[1]):this.on(t,e);return}let s,n,o;i&&("once"===i?n=!0:"boolean"==typeof i?s=i:(s=i.capture,n=i.once));const r=Zo(this,s,!0),a="string"==typeof t?t.split(" "):t,h=n?{listener:e,once:n}:{listener:e};a.forEach((t=>{t&&(o=r[t],o?-1===o.findIndex((t=>t.listener===e))&&o.push(h):r[t]=[h])}))}off(t,e,i){if(t){const s="string"==typeof t?t.split(" "):t;if(e){let t,n,o;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const r=Zo(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]))}))}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 i&&(e=e.bind(i)),this.on(t,e,s),{type:t,current:this,listener:e,options:s}}off_(t){if(!t)return;const e=t instanceof Array?t:[t];e.forEach((t=>t.current.off(t.type,t.listener,t.options))),e.length=0}once(t,e,i){this.on(t,e,{once:!0,capture:i})}emit(t,e,i){!e&&Ot.has(t)&&(e=Ot.get(t,{type:t,target:this,current:this}));const s=Zo(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],o=s&&s[t];return!!(void 0===e?n||o:e?o:n)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function Zo(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:Ko)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:Ko)}}const{on:Qo,on_:Jo,off:$o,off_:tr,once:er,emit:ir,emitEvent:sr,hasEvent:nr,destroy:or}=qo.prototype,rr={on:Qo,on_:Jo,off:$o,off_:tr,once:er,emit:ir,emitEvent:sr,hasEvent:nr,destroyEventer:or},{isFinite:ar}=Number,hr=vt.get("setAttr"),lr={__setAttr(t,e,i){if(this.leafer&&this.leafer.created){const s=this.__.__getInput(t);if(i&&!ar(e)&&void 0!==e&&(hr.warn(this.innerName,t,e),e=void 0),"object"==typeof e||s!==e){this.__realSetAttr(t,e);const{CHANGE:i}=Yo,n=new Yo(i,this,t,s,e);return this.isLeafer?this.emitEvent(new Yo(Yo.LEAFER_CHANGE,this,t,s,e)):this.hasEvent(i)&&this.emitEvent(n),this.leafer.emitEvent(n),!0}return!1}return this.__realSetAttr(t,e),!0},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||void 0===i.normalStyle[t]||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:dr,multiplyParent:cr,translateInner:ur,defaultWorld:_r}=x,{toPoint:pr,tempPoint:gr}=pt,fr={__updateWorldMatrix(){cr(this.__local||this.__layout,this.parent?this.parent.__world:_r,this.__world,!!this.__layout.affectScaleOrRotation,this.__,this.parent&&this.parent.__)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged||t.rotationChanged)&&(dr(e,i,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=!1),e.e=i.x+i.offsetX,e.f=i.y+i.offsetY,(i.around||i.origin)&&(pr(i.around||i.origin,t.boxBounds,gr),ur(e,-gr.x,-gr.y,!i.around))}this.__layout.matrixChanged=!1}},{updateMatrix:yr,updateAllMatrix:mr}=go,{updateBounds:vr}=Co,{toOuterOf:wr,copyAndSpread:xr,copy:br}=nt,{toBounds:Br}=qs,Rr={__updateWorldBounds(){wr(this.__layout.renderBounds,this.__world,this.__world),this.__layout.resized&&(this.__onUpdateSize(),this.__layout.resized=!1)},__updateLocalBounds(){const t=this.__layout;t.boxChanged&&(this.__.__pathInputed||this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),t.resized=!0),t.localBoxChanged&&(this.__local&&this.__updateLocalBoxBounds(),t.localBoxChanged=!1,t.strokeSpread&&(t.strokeChanged=!0),t.renderSpread&&(t.renderChanged=!0),this.parent&&this.parent.__layout.boxChange()),t.boxChanged=!1,t.strokeChanged&&(t.strokeSpread=this.__updateStrokeSpread(),t.strokeSpread?(t.strokeBounds===t.boxBounds&&t.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):t.spreadStrokeCancel(),t.strokeChanged=!1,(t.renderSpread||t.strokeSpread!==t.strokeBoxSpread)&&(t.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),t.resized=!0),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=!1,this.parent&&this.parent.__layout.renderChange()),t.boundsChanged=!1},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),wr(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){wr(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){wr(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds,e=this.__;e.__pathInputed?Br(e.__pathForRender,t):(t.x=0,t.y=0,t.width=e.width,t.height=e.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),mr(this),vr(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(mr(this),vr(this,this))):yr(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(){const t=this.__layout;xr(t.strokeBounds,t.boxBounds,t.strokeBoxSpread)},__updateRenderBounds(){const t=this.__layout;t.renderSpread>0?xr(t.renderBounds,t.boxBounds,t.renderSpread):br(t.renderBounds,t.strokeBounds)}},Cr={__render(t,e){if(this.__worldOpacity)if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=this.__.opacity,this.__.__single){if("path"===this.__.eraser)return this.__renderEraser(t,e);const i=t.getSameCanvas(!0,!0);this.__draw(i,e),this.__worldFlipped?t.copyWorldByReset(i,this.__nowWorld,null,this.__.__blendMode,!0):t.copyWorldToInner(i,this.__nowWorld,this.__layout.renderBounds,this.__.__blendMode),i.recycle(this.__nowWorld)}else this.__draw(t,e)},__clip(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawRenderPath(t),this.__.windingRule?t.clip(this.__.windingRule):t.clip())},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{excludeRenderBounds:kr}=Bo,Er={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__worldOpacity)if(this.__.__single){if("path"===this.__.eraser)return this.__renderEraser(t,e);const i=t.getSameCanvas(!1,!0);this.__renderBranch(i,e);const s=this.__getNowWorld(e);t.opacity=this.__.opacity,t.copyWorldByReset(i,s,s,this.__.__blendMode,!0),i.recycle(s)}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++)kr(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++)kr(i[s],e)||i[s].__clip(t,e)}}},{LEAF:Tr,create:Pr}=i,{toInnerPoint:Or,toOuterPoint:Sr,multiplyParent:Lr}=x,{toOuterOf:Dr}=nt,{copy:Mr,move:Ar}=L,{moveLocal:Ir,zoomOfLocal:Wr,rotateOfLocal:Fr,skewOfLocal:Nr,moveWorld:zr,zoomOfWorld:Yr,rotateOfWorld:Xr,skewOfWorld:jr,transform:Hr,transformWorld:Ur,setTransform:Vr,getFlipTransform:Gr,getLocalOrigin:Kr,getRelativeWorld:qr,drop:Zr}=go;let Qr=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 At}get __LayoutProcessor(){return Fo}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 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.__layout.update(),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(){const{leafer:t}=this;return t&&t.created&&t.lazyBounds.hit(this.__world)}get pathInputed(){return this.__.__pathInputed}set event(t){this.on(t)}constructor(t){this.innerId=Pr(Tr),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(zo.CREATED)}reset(t){this.leafer&&this.leafer.forceRender(this.__world),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(zo.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(zo.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(zo.MOUNTED)):this.__emitLifeEvent(zo.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){void 0===t?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=void 0===e?null:void 0,this[t]=e}forceRender(t){this.forceUpdate("surface")}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(){}__updateContentBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__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=!!t||this.children.some((t=>t.__.mask))}__renderMask(t,e){}__getNowWorld(t){if(t.matrix){this.__cameraWorld||(this.__cameraWorld={});const e=this.__cameraWorld;return Lr(this.__world,t.matrix,e,void 0,this.__world),Dr(this.__layout.renderBounds,e,e),e}return this.__world}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?qr(this,e):this.worldTransform,n=i?t:{};return Dr(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&Mr(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&Mr(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Or(this.worldTransform,t,e,i)}innerToWorld(t,e,i,s){Sr(this.worldTransform,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 Ar(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 Ar(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){Vr(this,t,e)}transform(t,e){Hr(this,t,e)}move(t,e){Ir(this,t,e)}moveInner(t,e){zr(this,t,e,!0)}scaleOf(t,e,i,s){Wr(this,Kr(this,t),e,i,s)}rotateOf(t,e){Fr(this,Kr(this,t),e)}skewOf(t,e,i,s){Nr(this,Kr(this,t),e,i,s)}transformWorld(t,e){Ur(this,t,e)}moveWorld(t,e){zr(this,t,e)}scaleOfWorld(t,e,i,s){Yr(this,t,e,i,s)}rotateOfWorld(t,e){Xr(this,t,e)}skewOfWorld(t,e,i,s){jr(this,t,e,i,s)}flip(t){Hr(this,Gr(this,t))}scaleResize(t,e=t,i){this.scaleX*=t,this.scaleY*=e}__scaleResize(t,e){}resizeWidth(t){}resizeHeight(t){}__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){}__clip(t,e){}__renderShape(t,e,i,s){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return Ct("path")}getMotionPoint(t){return Ct("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){Zr(this,t,e,i)}on(t,e,i){}off(t,e,i){}on_(t,e,i,s){}off_(t){}once(t,e,i){}emit(t,e,i){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,i){i?this.addAttr(t,e,i):Kn(this.prototype,t,e)}static addAttr(t,e,i){i||(i=Tn),i(e)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new zo(t,this,this.parent))}destroy(){if(!this.destroyed){const{parent:t}=this;t&&this.remove(),this.children&&this.removeAll(!0),this.__emitLifeEvent(zo.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0}}};Qr=Nt([eo(lr),eo(fr),eo(Rr),eo(rr),eo(Cr)],Qr);const{setListWithFn:Jr}=nt,{sort:$r}=Co,{localBoxBounds:ta,localStrokeBounds:ea,localRenderBounds:ia,maskLocalBoxBounds:sa,maskLocalStrokeBounds:na,maskLocalRenderBounds:oa}=Bo;let ra=class extends Qr{__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(){Jr(this.__layout.boxBounds,this.children,this.__hasMask?sa:ta)}__updateStrokeBounds(){Jr(this.__layout.strokeBounds,this.children,this.__hasMask?na:ea)}__updateRenderBounds(){Jr(this.__layout.renderBounds,this.children,this.__hasMask?oa:ia)}__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($r),this.__layout.affectChildrenSort=t}}add(t,e){t!==this&&(t.parent&&t.parent.remove(t),t.parent=this,void 0===e?this.children.push(t):this.children.splice(e,0,t),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1),t.__layout.boxChanged||t.__layout.boxChange(),t.__layout.matrixChanged||t.__layout.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(zo.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(zo.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange())}addMany(...t){t.forEach((t=>this.add(t)))}remove(t,e){t?t.animationOut?t.__runAnimation("out",(()=>this.__remove(t,e))):this.__remove(t,e):void 0===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(zo.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(zo.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new zo(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}};ra=Nt([eo(Er)],ra);class aa{get length(){return this.list.length}constructor(t){this.reset(),t&&(t instanceof Array?this.addList(t):this.add(t))}has(t){return t&&void 0!==this.keys[t.innerId]}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return void 0===e?-1:e}add(t){const{list:e,keys:i}=this;void 0===i[t.innerId]&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(void 0===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++)void 0!==i?this.keys[e[s].innerId]=s-1:e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]);void 0!==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 aa;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 ha{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(t instanceof Array?this.addList(t):this.add(t))}has(t){return void 0!==this.keys[t.innerId]}without(t){return void 0===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 la="1.0.3",da=vt.get("LeaferCanvas");class ca extends qt{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else da.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),da.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const e=t.devicePixelRatio;if(this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const i=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(e),a={width:o,height:r,pixelRatio:t.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=i;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(t){const e={};Dt.copyAttrs(e,this,Kt),this.resize(t),void 0!==this.width&&this.resizeListener(new jo(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}an(CanvasRenderingContext2D.prototype),an(Path2D.prototype);const{mineType:ua,fileType:_a}=hn;function pa(i,s){t.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(ua(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,ua(e),i))),canvasSaveAs:(e,i,s)=>{const n=e.toDataURL(ua(_a(i)),s);return t.origin.download(n,i)},download:(t,e)=>new Promise((i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()})),loadImage:e=>new Promise(((i,s)=>{const n=new Image,{crossOrigin:o}=t.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=t.image.getRealURL(e)}))},t.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.canvas=e.canvas(),t.conicGradientSupport=!!t.canvas.context.createConicGradient}Object.assign(e,{canvas:(t,e)=>new ca(t,e),image:t=>new yn(t)}),t.name="web",t.isMobile="ontouchstart"in window,t.requestRender=function(t){window.requestAnimationFrame(t)},mn(t,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:ga}=navigator;ga.indexOf("Firefox")>-1?(t.conicGradientRotate90=!0,t.intWheelDeltaY=!0,t.syncDomFont=!0):ga.indexOf("Safari")>-1&&-1===ga.indexOf("Chrome")&&(t.fullImageShadow=!0),ga.indexOf("Windows")>-1?(t.os="Windows",t.intWheelDeltaY=!0):ga.indexOf("Mac")>-1?t.os="Mac":ga.indexOf("Linux")>-1&&(t.os="Linux");class fa{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new aa;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 aa,this.target=t,e&&(this.config=Dt.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(Vo.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===zo.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 Ho(Ho.DATA,{updatedList:this.updatedList})),this.__updatedList=new aa,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Yo.CHANGE,this.__onAttrChange,this),t.on_([zo.ADD,zo.REMOVE],this.__onChildEvent,this),t.on_(Ho.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:ya,updateBounds:ma,updateAllWorldOpacity:va}=go,{pushAllChildBranch:wa,pushAllParent:xa}=Co;const{worldBounds:ba}=Bo,Ba={x:0,y:0,width:1e5,height:1e5};class Ra{constructor(t){this.updatedBounds=new ht,this.beforeBounds=new ht,this.afterBounds=new ht,t instanceof Array&&(t=new aa(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ba)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(Ba):this.afterBounds.setListWithFn(t,ba),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:Ca,updateAllChange:ka}=go,Ea=vt.get("Layouter");class Ta{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new ha,this.target=t,e&&(this.config=Dt.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.running)return;const{target:t}=this;this.times=0;try{t.emit(Uo.START),this.layoutOnce(),t.emitEvent(new Uo(Uo.END,this.layoutedBlocks,this.times))}catch(t){Ea.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Ea.warn("layouting"):this.times>3?Ea.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Ho.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=Bt.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=Uo,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new Uo(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?(ya(t,!0),e.add(t),t.isBranch&&wa(t,e),xa(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),xa(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||ma(s[t])}ma(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&va(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new Uo(o,a,this.times)),i.emitEvent(new Uo(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,Bt.end(e)}fullLayout(){const t=Bt.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=Uo,o=this.getBlocks(new aa(e));e.emitEvent(new Uo(i,o,this.times)),Ta.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new Uo(s,o,this.times)),e.emitEvent(new Uo(n,o,this.times)),this.addBlocks(o),Bt.end(t)}static fullLayout(t){Ca(t,!0),t.isBranch?Co.updateBounds(t):go.updateBounds(t),ka(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Ra([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Ra(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(){const{target:t}=this;this.__eventIds=[t.on_(Uo.REQUEST,this.layout,this),t.on_(Uo.AGAIN,this.layoutAgain,this),t.on_(Ho.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Pa=vt.get("Renderer");class Oa{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:60},this.target=t,this.canvas=e,i&&(this.config=Dt.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(Uo.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new ht,Pa.log(e.innerName,"---\x3e");try{this.emitRender(Vo.START),this.renderOnce(t),this.emitRender(Vo.END,this.totalBounds),_n.clearRecycled()}catch(t){this.rendering=!1,Pa.error(t)}Pa.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Pa.warn("rendering");if(this.times>3)return Pa.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new ht,this.renderOptions={},t)this.emitRender(Vo.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Vo.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Vo.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Vo.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;if(!e)return Pa.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=Bt.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new ht(s);i.save(),n&&!vt.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),Bt.end(e)}fullRender(){const t=Bt.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),Bt.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),vt.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),vt.showHitView&&this.renderHitView(s),vt.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}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=Date.now();t.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(Vo.NEXT)),this.target&&this.__requestRender()}))}__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.changed=!0}}__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||Pa.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 Vo(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Vo.REQUEST,this.update,this),t.on_(Uo.END,this.__onLayoutEnd,this),t.on_(Vo.AGAIN,this.renderAgain,this),t.on_(jo.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:Sa}=nt;class La{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 aa(i.findList),i.findList||this.hitBranch(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}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new aa;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||go.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.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),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new aa;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new aa;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new aa,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||Sa(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&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&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:Da,NoAndSkip:Ma,YesAndSkip:Aa}=It,Ia={},Wa={},Fa={};class Na{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(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,e&&(this.config=Dt.default(e,this.config)),this.picker=new La(t,this),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"#":Ia.id=t.substring(1),t=Ia;break;case".":Wa.className=t.substring(1),t=Wa;break;default:Fa.tag=t,t=Fa}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:s}=t,n=s instanceof Array;return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?Dt.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,s)}}getByPoint(e,i,s){return"node"===t.name&&this.target.emit(Uo.CHECK_UPDATE),this.picker.getByPoint(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&&go.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===Da||o===Aa){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<Ma&&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_(zo.REMOVE,this.__onRemoveChild,this),this.target.on_(Yo.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function za(t){return wn(t,(t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function Ya(t){return wn(t,(t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function Xa(){return(t,e)=>{const i="_"+e;mn(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}})}}Object.assign(e,{watcher:(t,e)=>new fa(t,e),layouter:(t,e)=>new Ta(t,e),renderer:(t,e,i)=>new Oa(t,e,i),selector:(t,e)=>new Na(t,e)}),t.layout=Ta.fullLayout;const ja={},Ha={},Ua={},Va={},Ga={},Ka={},qa={},Za={},Qa={setStyleName:(t,e,i)=>Ct("state"),set:(t,e)=>Ct("state")},Ja={list:{},register(t,e){Ja.list[t]=e},get:t=>Ja.list[t]},{parse:$a}=fi,th={},eh=vt.get("UIData");class ih extends At{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}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,eh.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,eh.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=th)):(this.__isFills&&(this.__removeInput("fill"),Ga.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=th)):(this.__isStrokes&&(this.__removeInput("stroke"),Ga.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=$a(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&Va.compute("fill",this.__leaf),e&&Va.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const sh={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class nh extends ih{}class oh extends nh{get __boxStroke(){return!this.__pathInputed}}class rh extends nh{__getInputData(){const t=super.__getInputData();return Kt.forEach((e=>delete t[e])),t}}class ah extends oh{}class hh extends ih{}class lh extends ih{get __boxStroke(){return!this.__pathInputed}}class dh extends ih{get __boxStroke(){return!this.__pathInputed}}class ch extends ih{}class uh extends ih{}class _h extends ih{}class ph extends nh{}const gh={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class fh extends ih{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=gh[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class yh extends lh{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class mh extends lh{__getInputData(){const t=super.__getInputData();return t.url=this.__leaf.canvas.toDataURL("image/png"),t}}const vh={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:n}=i;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),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let o=t=Math.ceil(t);return i&&i.forEach((t=>{o=Math.max(o,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),n&&(o=Math.max(o,n)),this.__layout.renderShapeSpread=o,t+(this.__layout.strokeSpread||0)}},wh={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n}=this.__;t.__useEffect=!!(e||i||s||n)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){xh(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:n,__drawAfterFill:o}=i;if(this.__drawRenderPath(t),i.__useEffect){const r=Va.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:a,innerShadow:h}=i;a&&qa.shadow(this,t,r),s&&(i.__isFills?Va.fills(s,this,t):Va.fill(s,this,t)),o&&this.__drawAfterFill(t,e),h&&qa.innerShadow(this,t,r),n&&(i.__isStrokes?Va.strokes(n,this,t):Va.stroke(n,this,t)),r.worldCanvas&&r.worldCanvas.recycle(),r.canvas.recycle()}else s&&(i.__isFills?Va.fills(s,this,t):Va.fill(s,this,t)),o&&this.__drawAfterFill(t,e),n&&(i.__isStrokes?Va.strokes(n,this,t):Va.stroke(n,this,t))}else i.__pathInputed?xh(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:n,stroke:o}=this.__;this.__drawRenderPath(t),n&&!i&&(this.__.__pixelFill?Va.fills(n,this,t):Va.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),o&&!s&&(this.__.__pixelStroke?Va.strokes(o,this,t):Va.stroke("#000000",this,t))}}};function xh(t,e,i){const{fill:s,stroke:n,__drawAfterFill:o}=t.__;t.__drawRenderPath(e),s&&Va.fill(s,t,e),o&&t.__drawAfterFill(e,i),n&&Va.stroke(n,t,e)}const bh={__drawFast(t,e){let{width:i,height:s,fill:n,stroke:o,__drawAfterFill:r}=this.__;if(n&&(t.fillStyle=n,t.fillRect(0,0,i,s)),r&&this.__drawAfterFill(t,e),o){const{strokeAlign:n,__strokeWidth:r}=this.__;if(!r)return;t.setStroke(o,r,this.__);const a=r/2;switch(n){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=r,s-=r,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(a,a,i,s),t.restore()):t.strokeRect(a,a,i,s);break;case"outside":t.strokeRect(-a,-a,i+r,s+r)}}}};var Bh;let Rh=Bh=class extends Qr{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){a.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return on.set(this.path=t||[]),t||this.__drawPathByBox(on),on}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t,e){e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(on.set(i=[]),this.__drawPathByBox(on)),t?fi.toCanvasData(i,!0):i}getPathString(t,e){return fi.stringify(this.getPath(t,e))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Za.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?nn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Ua.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?ys.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,"number"==typeof o?[o]:o)}else t.rect(e,i,s,n)}animate(t,e,i,s){return Ct("animate")}killAnimate(t){}export(t,e){return Za.export(this,t,e)}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),Bh.one(e)}static one(t,e,i,s,n){return Et.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){io()(this)}static registerData(t){Vn(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};Nt([Vn(ih)],Rh.prototype,"__",void 0),Nt([Xa()],Rh.prototype,"zoomLayer",void 0),Nt([Bn("")],Rh.prototype,"id",void 0),Nt([Bn("")],Rh.prototype,"name",void 0),Nt([Bn("")],Rh.prototype,"className",void 0),Nt([Wn("pass-through")],Rh.prototype,"blendMode",void 0),Nt([Fn(1)],Rh.prototype,"opacity",void 0),Nt([Nn(!0)],Rh.prototype,"visible",void 0),Nt([Wn(!1)],Rh.prototype,"locked",void 0),Nt([Yn(0)],Rh.prototype,"zIndex",void 0),Nt([Xn(!1)],Rh.prototype,"mask",void 0),Nt([jn(!1)],Rh.prototype,"eraser",void 0),Nt([Rn(0,!0)],Rh.prototype,"x",void 0),Nt([Rn(0,!0)],Rh.prototype,"y",void 0),Nt([Tn(100,!0)],Rh.prototype,"width",void 0),Nt([Tn(100,!0)],Rh.prototype,"height",void 0),Nt([kn(1,!0)],Rh.prototype,"scaleX",void 0),Nt([kn(1,!0)],Rh.prototype,"scaleY",void 0),Nt([En(0,!0)],Rh.prototype,"rotation",void 0),Nt([En(0,!0)],Rh.prototype,"skewX",void 0),Nt([En(0,!0)],Rh.prototype,"skewY",void 0),Nt([Rn(0,!0)],Rh.prototype,"offsetX",void 0),Nt([Rn(0,!0)],Rh.prototype,"offsetY",void 0),Nt([Rn(0,!0)],Rh.prototype,"scrollX",void 0),Nt([Rn(0,!0)],Rh.prototype,"scrollY",void 0),Nt([Cn()],Rh.prototype,"origin",void 0),Nt([Cn()],Rh.prototype,"around",void 0),Nt([Bn(!1)],Rh.prototype,"lazy",void 0),Nt([Pn(1)],Rh.prototype,"pixelRatio",void 0),Nt([Sn()],Rh.prototype,"path",void 0),Nt([Ln()],Rh.prototype,"windingRule",void 0),Nt([Ln(!0)],Rh.prototype,"closed",void 0),Nt([Tn(0)],Rh.prototype,"padding",void 0),Nt([Bn(!1)],Rh.prototype,"draggable",void 0),Nt([Bn()],Rh.prototype,"dragBounds",void 0),Nt([Bn(!1)],Rh.prototype,"editable",void 0),Nt([Hn(!0)],Rh.prototype,"hittable",void 0),Nt([Hn("path")],Rh.prototype,"hitFill",void 0),Nt([An("path")],Rh.prototype,"hitStroke",void 0),Nt([Hn(!1)],Rh.prototype,"hitBox",void 0),Nt([Hn(!0)],Rh.prototype,"hitChildren",void 0),Nt([Hn(!0)],Rh.prototype,"hitSelf",void 0),Nt([Hn()],Rh.prototype,"hitRadius",void 0),Nt([Un("")],Rh.prototype,"cursor",void 0),Nt([Wn()],Rh.prototype,"fill",void 0),Nt([An()],Rh.prototype,"stroke",void 0),Nt([An("inside")],Rh.prototype,"strokeAlign",void 0),Nt([An(1)],Rh.prototype,"strokeWidth",void 0),Nt([An(!1)],Rh.prototype,"strokeWidthFixed",void 0),Nt([An("none")],Rh.prototype,"strokeCap",void 0),Nt([An("miter")],Rh.prototype,"strokeJoin",void 0),Nt([An()],Rh.prototype,"dashPattern",void 0),Nt([An()],Rh.prototype,"dashOffset",void 0),Nt([An(10)],Rh.prototype,"miterLimit",void 0),Nt([Ln(0)],Rh.prototype,"cornerRadius",void 0),Nt([Ln()],Rh.prototype,"cornerSmoothing",void 0),Nt([za()],Rh.prototype,"shadow",void 0),Nt([za()],Rh.prototype,"innerShadow",void 0),Nt([za()],Rh.prototype,"blur",void 0),Nt([za()],Rh.prototype,"backgroundBlur",void 0),Nt([za()],Rh.prototype,"grayscale",void 0),Nt([Bn({})],Rh.prototype,"data",void 0),Nt([Jn(Qr.prototype.reset)],Rh.prototype,"reset",null),Rh=Bh=Nt([eo(vh),eo(wh),$n()],Rh);let Ch=class extends Rh{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t.children){const{children:i}=t;let s;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>{s=t.__?t:Et.get(t.tag,t),this.add(s)})),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return 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 kh;Nt([Vn(nh)],Ch.prototype,"__",void 0),Ch=Nt([eo(ra),io()],Ch);const Eh=vt.get("Leafer");let Th=kh=class extends Ch{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&_n.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()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},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),kh.list.add(this)}init(t,i){if(this.canvas)return;let s;this.__setLeafer(this),t&&Dt.assign(this.config,t);const{config:n}=this;this.initType(n.type);const o=this.canvas=e.canvas(n);this.__controllers.push(this.renderer=e.renderer(this,o,n),this.watcher=e.watcher(this,n),this.layouter=e.layouter(this,n)),this.isApp&&this.__setApp(),this.__checkAutoLayout(n,i),this.view=o.view,i?(this.__bindApp(i),s=i.running):(this.selector=e.selector(this),this.interaction=e.interaction(this,o,this.selector,n),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=e.hitCanvasManager()),this.canvasManager=new Lt,s=n.start),this.hittable=n.hittable,this.fill=n.fill,this.canvasManager.add(o),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),Po.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(Go.RESTART):this.emitLeafer(Go.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(Go.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=Dt.copyAttrs({},t,Kt);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new ht(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}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=Dt.copyAttrs({},this.canvas,Kt);e.resize(t),this.updateLazyBounds(),this.__onResize(new jo(t,i))}__onResize(t){this.emitEvent(t),Dt.copyAttrs(this.__,t,Kt),t.width&&t.height||Eh.warn("w = 0 or h = 0"),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(t,e){e||(t.width&&t.height||(this.autoLayout=new dt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Kt.includes(t)?(e||Eh.warn(t+" is 0"),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())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Kt.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=Dt.copyAttrs({},this.canvas,Kt);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(Go.BEFORE_READY),this.emitLeafer(Go.READY),this.emitLeafer(Go.AFTER_READY),Po.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Go.VIEW_READY),Po.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){Po.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(Go.VIEW_COMPLETED),Po.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)}zoom(t,e,i){return Ct("view")}getValidMove(t,e){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))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new Go(t,this))}__listenEvents(){const t=Bt.start("FirstCreate "+this.innerName);this.once(Go.START,(()=>Bt.end(t))),this.once(Uo.START,(()=>this.updateLazyBounds())),this.once(Uo.END,(()=>this.__onReady())),this.once(Vo.START,(()=>this.__onCreated())),this.once(Vo.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(Ho.DATA,this.__onWatchData,this),this.on_(Vo.NEXT,this.__onNextRender,this),this.on_(Uo.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){kh.list.remove(this);try{this.stop(),this.emitEvent(new Go(Go.END,this)),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.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{_n.clearRecycled()}),100)}catch(t){Eh.error(t)}}};t?e():setTimeout(e)}};Th.list=new aa,Nt([Vn(rh)],Th.prototype,"__",void 0),Nt([Tn()],Th.prototype,"pixelRatio",void 0),Th=kh=Nt([io()],Th);let Ph=class extends Rh{get __tag(){return"Rect"}constructor(t){super(t)}};Nt([Vn(lh)],Ph.prototype,"__",void 0),Ph=Nt([eo(bh),$n(),io()],Ph);const Oh=Ph.prototype,Sh=Ch.prototype,Lh={},{copy:Dh,add:Mh,includes:Ah,copyAndSpread:Ih}=nt;let Wh=class extends Ch{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){const e=this.__;if(this.children.length){if(e.__autoSide){this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds();const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(i.width+=i.x,i.height=e.height,i.y=i.x=0):(i.height+=i.y,i.width=e.width,i.x=i.y=0)),t&&e.flow&&e.padding&&Ih(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),Dh(Lh,e),this.__updateRectRenderBounds(),t=!Ah(e,Lh)||!this.pathInputed||!this.__.cornerRadius):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),!(this.__.__drawAfterFill="hide"===this.__.overflow)&&t&&Mh(e,Lh)}__updateRectRenderBounds(){}__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))}__drawAfterFill(t,e){const{length:i}=this.children;this.isOverflow?(t.save(),t.clip(),i&&this.__renderGroup(t,e),t.restore()):i&&this.__renderGroup(t,e),this.__.stroke&&i&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};Nt([Vn(oh)],Wh.prototype,"__",void 0),Nt([Bn(!1)],Wh.prototype,"resizeChildren",void 0),Nt([In("show")],Wh.prototype,"overflow",void 0),Nt([Jn(Oh.__updateStrokeSpread)],Wh.prototype,"__updateStrokeSpread",null),Nt([Jn(Oh.__updateRenderSpread)],Wh.prototype,"__updateRectRenderSpread",null),Nt([Jn(Oh.__updateBoxBounds)],Wh.prototype,"__updateRectBoxBounds",null),Nt([Jn(Oh.__updateStrokeBounds)],Wh.prototype,"__updateStrokeBounds",null),Nt([Jn(Oh.__updateRenderBounds)],Wh.prototype,"__updateRectRenderBounds",null),Nt([Jn(Oh.__updateChange)],Wh.prototype,"__updateRectChange",null),Nt([Jn(Oh.__render)],Wh.prototype,"__renderRect",null),Nt([Jn(Sh.__render)],Wh.prototype,"__renderGroup",null),Wh=Nt([$n(),io()],Wh);let Fh=class extends Wh{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};Nt([Vn(ah)],Fh.prototype,"__",void 0),Nt([Wn("#FFFFFF")],Fh.prototype,"fill",void 0),Nt([In("hide")],Fh.prototype,"overflow",void 0),Fh=Nt([io()],Fh);const{moveTo:Nh,closePath:zh,ellipse:Yh}=Ni;let Xh=class extends Rh{get __tag(){return"Ellipse"}constructor(t){super(t)}__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&&Yh(h,r,a,r*s,a*s,0,n,o,!1),Yh(h,r,a,r,a,0,o,n,!0),s<1&&zh(h)):(s<1&&(Yh(h,r,a,r*s,a*s),Nh(h,e,a)),Yh(h,r,a,r,a,0,360,0,!0)),t.ellipseToCurve&&(this.__.path=this.getPath(!0))):n||o?(Nh(h,r,a),Yh(h,r,a,r,a,0,n,o,!1),zh(h)):Yh(h,r,a,r,a)}};Nt([Vn(dh)],Xh.prototype,"__",void 0),Nt([Ln(0)],Xh.prototype,"innerRadius",void 0),Nt([Ln(0)],Xh.prototype,"startAngle",void 0),Nt([Ln(0)],Xh.prototype,"endAngle",void 0),Xh=Nt([io()],Xh);const{moveTo:jh,lineTo:Hh,drawPoints:Uh}=Ni,{rotate:Vh,getAngle:Gh,getDistance:Kh,defaultPoint:qh}=L,{toBounds:Zh}=qs;let Qh=class extends Rh{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&Vh(i,e),i}set toPoint(t){this.width=Kh(qh,t),this.rotation=Gh(qh,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?Uh(e,t.points,!1,t.closed):(jh(e,0,0),Hh(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(Uh(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&Ua.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?Zh(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};Nt([Vn(hh)],Qh.prototype,"__",void 0),Nt([Dn("center")],Qh.prototype,"strokeAlign",void 0),Nt([Tn(0)],Qh.prototype,"height",void 0),Nt([Ln()],Qh.prototype,"points",void 0),Nt([Ln(0)],Qh.prototype,"curve",void 0),Nt([Ln(!1)],Qh.prototype,"closed",void 0),Qh=Nt([io()],Qh);const{sin:Jh,cos:$h,PI:tl}=Math,{moveTo:el,lineTo:il,closePath:sl,drawPoints:nl}=Ni,ol=Qh.prototype;let rl=class extends Rh{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)nl(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,n=e/2,o=i/2;el(t,n,0);for(let e=1;e<s;e++)il(t,n+n*Jh(2*e*tl/s),o-o*$h(2*e*tl/s))}sl(t)}__updateRenderPath(){}__updateBoxBounds(){}};Nt([Vn(ch)],rl.prototype,"__",void 0),Nt([Ln(3)],rl.prototype,"sides",void 0),Nt([Ln()],rl.prototype,"points",void 0),Nt([Ln(0)],rl.prototype,"curve",void 0),Nt([Jn(ol.__updateRenderPath)],rl.prototype,"__updateRenderPath",null),Nt([Jn(ol.__updateBoxBounds)],rl.prototype,"__updateBoxBounds",null),rl=Nt([$n(),io()],rl);const{sin:al,cos:hl,PI:ll}=Math,{moveTo:dl,lineTo:cl,closePath:ul}=Ni;let _l=class extends Rh{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,o=e/2,r=this.__.path=[];dl(r,n,0);for(let t=1;t<2*i;t++)cl(r,n+(t%2==0?n:n*s)*al(t*ll/i),o-(t%2==0?o:o*s)*hl(t*ll/i));ul(r)}};Nt([Vn(uh)],_l.prototype,"__",void 0),Nt([Ln(5)],_l.prototype,"corners",void 0),Nt([Ln(.382)],_l.prototype,"innerRadius",void 0),_l=Nt([io()],_l);let pl=class extends Ph{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(Xo.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};Nt([Vn(yh)],pl.prototype,"__",void 0),Nt([Tn("")],pl.prototype,"url",void 0),pl=Nt([io()],pl);const gl=pl;let fl=class extends Ph{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=e.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0,t&&t.url&&this.drawImage(t.url)}drawImage(t){new yn({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Xo(Xo.LOADED,{image:t}))}))}draw(t,e,i,s){t.__layout.update();const n=new N(t.__world).invert(),o=new N;e&&o.translate(e.x,e.y),i&&("number"==typeof 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()}__drawAfterFill(t,e){const{width:i,height:s,cornerRadius:n}=this.__,{view:o}=this.canvas;n||this.pathInputed?(t.save(),t.clip(),t.drawImage(o,0,0,o.width,o.height,0,0,i,s),t.restore()):t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};Nt([Vn(mh)],fl.prototype,"__",void 0),Nt([Ya(100)],fl.prototype,"width",void 0),Nt([Ya(100)],fl.prototype,"height",void 0),Nt([Ya(1)],fl.prototype,"pixelRatio",void 0),Nt([Ya(!0)],fl.prototype,"smooth",void 0),Nt([Ya()],fl.prototype,"contextSettings",void 0),fl=Nt([io()],fl);const{copyAndSpread:yl,includes:ml,isSame:vl,spread:wl,setList:xl}=nt;let bl=class extends Rh{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:n}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):n.rows.forEach((n=>t.rect(n.x,n.y-s,n.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:n,height:o}=this.__layout.boxBounds;t.rect(i,s,n,o)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=ja.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:n,fontSize:o,fontWeight:r,italic:h,textCase:l,textOverflow:d,padding:c}=t,u=t.__autoWidth,_=t.__autoHeight;t.__lineHeight=sh.number(i,o),t.__letterSpacing=sh.number(s,o),t.__padding=c?a.fourNumber(c):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${h?"italic ":""}${"small-caps"===l?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${n}`,t.__clipText="show"!==d&&!t.__autoSize,this.__updateTextDrawData();const{bounds:p}=t.__textDrawData,g=e.boxBounds;if(t.__lineHeight<o&&wl(p,o/2),u||_){if(g.x=u?p.x:0,g.y=_?p.y:0,g.width=u?p.width:t.width,g.height=_?p.height:t.height,c){const[e,i,s,n]=t.__padding;u&&(g.x-=n,g.width+=i+n),_&&(g.y-=e,g.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();h&&(g.width+=.16*o);const f=ml(g,p)?g:p;vl(f,e.contentBounds)?t.__textBoxBounds=f:(e.contentBounds=f,e.renderChanged=!0,xl(t.__textBoxBounds={},[g,p]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){yl(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};Nt([Vn(fh)],bl.prototype,"__",void 0),Nt([Tn(0)],bl.prototype,"width",void 0),Nt([Tn(0)],bl.prototype,"height",void 0),Nt([Bn(!1)],bl.prototype,"resizeFontSize",void 0),Nt([Wn("#000000")],bl.prototype,"fill",void 0),Nt([Dn("outside")],bl.prototype,"strokeAlign",void 0),Nt([Hn("all")],bl.prototype,"hitFill",void 0),Nt([Tn("")],bl.prototype,"text",void 0),Nt([Tn("L")],bl.prototype,"fontFamily",void 0),Nt([Tn(12)],bl.prototype,"fontSize",void 0),Nt([Tn("normal")],bl.prototype,"fontWeight",void 0),Nt([Tn(!1)],bl.prototype,"italic",void 0),Nt([Tn("none")],bl.prototype,"textCase",void 0),Nt([Tn("none")],bl.prototype,"textDecoration",void 0),Nt([Tn(0)],bl.prototype,"letterSpacing",void 0),Nt([Tn({type:"percent",value:1.5})],bl.prototype,"lineHeight",void 0),Nt([Tn(0)],bl.prototype,"paraIndent",void 0),Nt([Tn(0)],bl.prototype,"paraSpacing",void 0),Nt([Tn("left")],bl.prototype,"textAlign",void 0),Nt([Tn("top")],bl.prototype,"verticalAlign",void 0),Nt([Tn("normal")],bl.prototype,"textWrap",void 0),Nt([Tn("show")],bl.prototype,"textOverflow",void 0),bl=Nt([io()],bl);let Bl=class extends Rh{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};Nt([Vn(_h)],Bl.prototype,"__",void 0),Nt([Dn("center")],Bl.prototype,"strokeAlign",void 0),Bl=Nt([io()],Bl);let Rl=class extends Ch{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Bl(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),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")}};Nt([Vn(ph)],Rl.prototype,"__",void 0),Nt([(t,e)=>{mn(t,e,{get(){return this.__path}})}],Rl.prototype,"path",void 0),Rl=Nt([eo(is,["set","beginPath","path","paint"]),io()],Rl);let Cl=class extends Th{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){super(t,e)}init(t,i){if(super.init(t,i),t){const{ground:i,tree:s,sky:n,editor:o}=t;i&&(this.ground=this.addLeafer(i)),(s||o)&&(this.tree=this.addLeafer(s)),(n||o)&&(this.sky=this.addLeafer(n||{type:"draw",usePartRender:!1})),o&&(this.editor=e.editor(o),this.sky.add(this.editor))}}__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(),this.__eventIds.push(this.on_(Yo.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}forceRender(t){this.children.forEach((e=>e.forceRender(t)))}addLeafer(t){const e=new Th(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),void 0!==e&&(t.canvas.childIndex=e),this.__listenChildEvents(t)}__onPropertyChange(){vt.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__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){if(t.context){if(e.matrix){const{a:i,b:s,c:n,d:o,e:r,f:a}=e.matrix;t.setTransform(i,s,n,o,r,a)}this.children.forEach((e=>t.copyWorld(e.canvas)))}}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>t.__layout.update()))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&Dt.assign(e,t),this.autoLayout&&Dt.copyAttrs(e,this,Kt),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(Uo.END,(()=>this.__onReady())),t.once(Vo.START,(()=>this.__onCreated())),t.once(Vo.END,(()=>this.__onViewReady())),this.realCanvas&&this.__eventIds.push(t.on_(Vo.END,this.__onChildRenderEnd,this))}};Cl=Nt([io()],Cl);const kl={},El={isHoldSpaceKey:()=>El.isHold("Space"),isHold:t=>kl[t],setDownCode(t){kl[t]||(kl[t]=!0)},setUpCode(t){kl[t]=!1}},Tl={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 Pl extends No{get spaceKey(){return El.isHoldSpaceKey()}get left(){return Tl.left(this)}get right(){return Tl.right(this)}get middle(){return Tl.middle(this)}constructor(t){super(t.type),this.bubbles=!0,this.getInner=this.getInnerPoint,this.getLocal=this.getLocalPoint,this.getPage=this.getPagePoint,Object.assign(this,t)}getBoxPoint(t){return t||(t=this.current),t.getBoxPoint(this)}getInnerPoint(t){return t||(t=this.current),t.getInnerPoint(this)}getLocalPoint(t){return t||(t=this.current),t.getLocalPoint(this)}getPagePoint(){return this.current.getPagePoint(this)}static changeName(t,e){Ot.changeName(t,e)}}let Ol=class extends Pl{};Ol.POINTER="pointer",Ol.BEFORE_DOWN="pointer.before_down",Ol.BEFORE_MOVE="pointer.before_move",Ol.BEFORE_UP="pointer.before_up",Ol.DOWN="pointer.down",Ol.MOVE="pointer.move",Ol.UP="pointer.up",Ol.OVER="pointer.over",Ol.OUT="pointer.out",Ol.ENTER="pointer.enter",Ol.LEAVE="pointer.leave",Ol.TAP="tap",Ol.DOUBLE_TAP="double_tap",Ol.CLICK="click",Ol.DOUBLE_CLICK="double_click",Ol.LONG_PRESS="long_press",Ol.LONG_TAP="long_tap",Ol.MENU="pointer.menu",Ol.MENU_TAP="pointer.menu_tap",Ol=Nt([so()],Ol);const Sl=Ol,Ll={};let Dl=class extends Ol{static setList(t){this.list=t instanceof aa?t:new aa(t)}static setData(t){this.data=t}static getValidMove(t,e,i){const{draggable:s,dragBounds:n,x:o,y:r}=t,a=t.getLocalPoint(i,null,!0);return a.x+=e.x-o,a.y+=e.y-r,n&&this.getMoveInDragBounds(t.__local,"parent"===n?t.parent.boxBounds:n,a,!0),"x"===s&&(a.y=0),"y"===s&&(a.x=0),a}static getMoveInDragBounds(t,e,i,s){const n=t.x+i.x,o=t.y+i.y,r=n+t.width,a=o+t.height,h=e.x+e.width,l=e.y+e.height;return s||(i=Object.assign({},i)),nt.includes(t,e)?(n>e.x?i.x+=e.x-n:r<h&&(i.x+=h-r),o>e.y?i.y+=e.y-o:a<l&&(i.y+=l-a)):(n<e.x?i.x+=e.x-n:r>h&&(i.x+=h-r),o<e.y?i.y+=e.y-o:a>l&&(i.y+=l-a)),i}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Ll,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Ll,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Ll,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 nt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),nt.unsign(i),i}assignMove(t){Ll.x=t?this.totalX:this.moveX,Ll.y=t?this.totalY:this.moveY}};Dl.BEFORE_DRAG="drag.before_drag",Dl.START="drag.start",Dl.DRAG="drag",Dl.END="drag.end",Dl.OVER="drag.over",Dl.OUT="drag.out",Dl.ENTER="drag.enter",Dl.LEAVE="drag.leave",Dl=Nt([so()],Dl);const Ml=Dl;let Al=class extends Ol{static setList(t){Dl.setList(t)}static setData(t){Dl.setData(t)}};Al.DROP="drop",Al=Nt([so()],Al);let Il=class extends Dl{};Il.BEFORE_MOVE="move.before_move",Il.START="move.start",Il.MOVE="move",Il.END="move.end",Il=Nt([so()],Il);let Wl=class extends Pl{};Wl.BEFORE_ROTATE="rotate.before_rotate",Wl.START="rotate.start",Wl.ROTATE="rotate",Wl.END="rotate.end",Wl=Nt([so()],Wl);let Fl=class extends Dl{};Fl.SWIPE="swipe",Fl.LEFT="swipe.left",Fl.RIGHT="swipe.right",Fl.UP="swipe.up",Fl.DOWN="swipe.down",Fl=Nt([so()],Fl);let Nl=class extends Pl{};Nl.BEFORE_ZOOM="zoom.before_zoom",Nl.START="zoom.start",Nl.ZOOM="zoom",Nl.END="zoom.end",Nl=Nt([so()],Nl);let zl=class extends Pl{};function Yl(t){t.isApp||t.__eventIds.push(t.on_(Il.BEFORE_MOVE,(e=>{t.zoomLayer.move(t.getValidMove(e.moveX,e.moveY))})),t.on_(Nl.BEFORE_ZOOM,(e=>{const{zoomLayer:i}=t,s=t.getValidScale(e.scale);1!==s&&(L.scaleOf(i,e,s),i.scale=i.__.scaleX*s)})))}zl.DOWN="key.down",zl.HOLD="key.hold",zl.UP="key.up",zl=Nt([so()],zl);const Xl=vt.get("LeaferTypeCreator"),jl={list:{},register(t,e){Hl[t]?Xl.repeat(t):Hl[t]=e},run(t,e){const i=Hl[t];i&&i(e)}},{list:Hl,register:Ul}=jl;Ul("design",Yl),Ul("document",(function(t){Yl(t);const{move:e,zoom:i}=t.config;e.scroll="limit",i.min=1})),Ul("block",(function(t){const{config:e}=t;(e.wheel||(e.wheel={})).preventDefault=!1,(e.touch||(e.touch={})).preventDefault="auto"}));const Vl=Th.prototype;Vl.initType=function(t){jl.run(t,this)},Vl.getValidMove=function(t,e){const{scroll:i,disabled:s}=this.app.config.move;if(i&&(Math.abs(t)>Math.abs(e)?e=0:t=0,"limit"===i)){const{x:i,y:s,width:n,height:o}=new ht(this.__world).addPoint(this.zoomLayer),r=i+n-this.width,a=s+o-this.height;i>=0&&r<=0?t=0:t>0?i+t>0&&(t=-i):t<0&&r+t<0&&(t=-r),s>=0&&a<=0?e=0:e>0?s+e>0&&(e=-s):e<0&&a+e<0&&(e=-a)}return{x:s?0:t,y:s?0:e}},Vl.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,o=Math.abs(e*t);return o<i?t=i/e:o>s&&(t=s/e),n?1:t};class Gl{get transforming(){return!!(this.moveData||this.zoomData||this.rotateData)}constructor(t){this.interaction=t}move(t){const{interaction:e}=this;if(t.moveType||(t.moveType="move"),!this.moveData){const{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0}),e.cancelHover(),e.emit(Il.START,this.moveData)}t.path=this.moveData.path,e.emit(Il.BEFORE_MOVE,t),e.emit(Il.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;if(!this.zoomData){const{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,this.zoomData=Object.assign(Object.assign({},t),{scale:1}),e.cancelHover(),e.emit(Nl.START,this.zoomData)}t.path=this.zoomData.path,e.emit(Nl.BEFORE_ZOOM,t),e.emit(Nl.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;if(!this.rotateData){const{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,this.rotateData=Object.assign(Object.assign({},t),{rotation:0}),e.cancelHover(),e.emit(Wl.START,this.rotateData)}t.path=this.rotateData.path,e.emit(Wl.BEFORE_ROTATE,t),e.emit(Wl.ROTATE,t),this.transformEndWait()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout((()=>{this.transformEnd()}),this.interaction.config.pointer.transformTime)}transformEnd(){this.moveEnd(),this.zoomEnd(),this.rotateEnd()}moveEnd(){this.moveData&&(this.interaction.emit(Il.END,this.moveData),this.moveData=null)}zoomEnd(){this.zoomData&&(this.interaction.emit(Nl.END,this.zoomData),this.zoomData=null)}rotateEnd(){this.rotateData&&(this.interaction.emit(Wl.END,this.rotateData),this.rotateData=null)}destroy(){this.zoomData=this.moveData=this.rotateData=null}}const Kl={getMoveEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:t.x,y:t.y,moveX:e.x,moveY:e.y}),getRotateEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:t.x,y:t.y,rotation:e}),getZoomEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:t.x,y:t.y,scale:e}),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?Fl.UP:t>45&&t<135?Fl.DOWN:t<=45&&t>=-45?Fl.RIGHT:Fl.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:ql.getSwipeDirection(L.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:void 0===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 aa,{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=>t.draggable||t.editable||!t.isLeafer&&t.hasEvent(Dl.DRAG))),pathHasOutside:t=>t&&t.list.some((t=>t.isOutside))},ql=Kl,Zl=new aa,{getDragEventData:Ql,getDropEventData:Jl,getSwipeEventData:$l}=Kl;class td{constructor(t){this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Ql(t,t,t),this.canAnimate=this.canDragOut=!0}getList(){const{proxy:t}=this.interaction.selector;return!this.dragging||t&&t.list.length?Zl:Dl.list||this.dragableList||Zl}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(Il.START,this.dragData)),this.moving||this.dragStart(t,e),this.drag(t)}dragStart(t,e){this.dragging||(this.dragging=e&&Tl.left(t),this.dragging&&(this.interaction.emit(Dl.START,this.dragData),this.getDragableList(this.dragData.path),this.setDragStartPoints(this.realDragableList=this.getList())))}setDragStartPoints(t){this.dragStartPoints={},t.forEach((t=>this.dragStartPoints[t.innerId]={x:t.x,y:t.y}))}getDragableList(t){let e;for(let i=0,s=t.length;i<s;i++)if(e=t.list[i],(e.__.draggable||e.__.editable)&&e.__.hitSelf&&!e.__.locked){this.dragableList=new aa(e);break}}drag(t){const{interaction:e,dragData:i,downData:s}=this,{path:n,throughPath:o}=s;this.dragData=Ql(s,i,t),o&&(this.dragData.throughPath=o),this.dragData.path=n,this.moving?(this.dragData.moveType="drag",e.emit(Il.BEFORE_MOVE,this.dragData),e.emit(Il.MOVE,this.dragData)):this.dragging&&(this.dragReal(),e.emit(Dl.BEFORE_DRAG,this.dragData),e.emit(Dl.DRAG,this.dragData))}dragReal(){const{running:t}=this.interaction,e=this.realDragableList;if(e.length&&t){const{totalX:t,totalY:i}=this.dragData;e.forEach((e=>e.draggable&&e.move(Dl.getValidMove(e,this.dragStartPoints[e.innerId],{x:t,y:i}))))}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:i}=this,{path:s}=t;this.dragOverPath=s,i?s.indexAt(0)!==i.indexAt(0)&&(e.emit(Dl.OUT,t,i),e.emit(Dl.OVER,t,s)):e.emit(Dl.OVER,t,s)}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:i}=this,{path:s}=t;e.emit(Dl.LEAVE,t,i,s),e.emit(Dl.ENTER,t,s,i),this.dragEnterPath=s}dragEnd(t,e){if(!this.dragging&&!this.moving)return;const{moveX:i,moveY:s}=this.dragData;this.interaction.config.move.dragAnimate&&this.canAnimate&&this.moving&&(Math.abs(i)>1||Math.abs(s)>1)?(t=Object.assign({},t),e=.9*(e||("touch"===t.pointerType?2:1)),L.move(t,i*e,s*e),this.drag(t),this.animate((()=>{this.dragEnd(t,1)}))):this.dragEndReal(t)}dragEndReal(t){const{interaction:e,downData:i,dragData:s}=this;t||(t=s);const{path:n,throughPath:o}=i,r=Ql(i,t,t);if(o&&(r.throughPath=o),r.path=n,this.moving&&(this.moving=!1,r.moveType="drag",e.emit(Il.END,r)),this.dragging){const n=this.getList();this.dragging=!1,e.emit(Dl.END,r),this.swipe(t,i,s,r),this.drop(t,n,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}animate(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t}swipe(t,e,i,s){const{interaction:n}=this;if(L.getDistance(e,t)>n.config.pointer.swipeDistance){const t=$l(e,i,s);this.interaction.emit(t.type,t)}}drop(t,e,i){const s=Jl(t,e,Dl.data);s.path=i,this.interaction.emit(Al.DROP,s),this.interaction.emit(Dl.LEAVE,t,i)}dragReset(){Dl.list=Dl.data=this.dragableList=this.dragData=this.downData=this.dragOverPath=this.dragEnterPath=null}checkDragOut(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)}autoMoveOnDragOut(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:n,dragOut:o}=e.config.move;if(!o||!s||!n)return;const r=e.shrinkCanvasBounds,{x:a,y:h}=r,l=nt.maxX(r),d=nt.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,L.move(i,c,u),L.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)}autoMoveCancel(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)}destroy(){this.dragReset()}}const ed=vt.get("emit");const id=["move","zoom","rotate","key"];function sd(t,e,i,s,n){if(id.some((t=>e.startsWith(t)))&&t.__.hitChildren&&!od(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&&nd(o,e,i,s,n)}}function nd(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!od(t,n)&&(Qa.updateEventStyle&&!s&&Qa.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=Ot.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function od(t,e){return e&&e.has(t)}const rd={getData(t){const e=t[0],i=t[1],s=L.getCenter(e.from,i.from),n=L.getCenter(e.to,i.to),o={x:n.x-s.x,y:n.y-s.y},r=L.getDistance(e.from,i.from);return{move:o,scale:L.getDistance(e.to,i.to)/r,angle:L.getRotation(e.from,i.from,e.to,i.to),center:n}}},ad={wheel:{zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8},preventDefault:!0},pointer:{hitRadius:5,tapTime:120,longPressTime:800,transformTime:500,hover:!0,dragHover:!0,dragDistance:2,swipeDistance:20,preventDefaultMenu:!0},touch:{preventDefault:!0},cursor:!0,keyEvent:!0},{pathHasEventType:hd,getMoveEventData:ld,getZoomEventData:dd,getRotateEventData:cd,pathCanDrag:ud,pathHasOutside:_d}=Kl;class pd{get dragging(){return this.dragger.dragging}get transforming(){return this.transformer.transforming}get moveMode(){return!0===this.config.move.drag||this.isHoldSpaceKey||this.isHoldMiddleKey||this.isHoldRightKey&&this.dragger.moving||this.isDragEmpty}get canHover(){return this.config.pointer.hover&&!this.config.mobile}get isDragEmpty(){return this.config.move.dragEmpty&&this.isRootPath(this.hoverData)&&(!this.downData||this.isRootPath(this.downData))}get isMobileDragEmpty(){return this.config.move.dragEmpty&&!this.canHover&&this.downData&&this.isTreePath(this.downData)}get isHoldMiddleKey(){return this.config.move.holdMiddleKey&&this.downData&&Tl.middle(this.downData)}get isHoldRightKey(){return this.config.move.holdRightKey&&this.downData&&Tl.right(this.downData)}get isHoldSpaceKey(){return this.config.move.holdSpaceKey&&El.isHoldSpaceKey()}get hitRadius(){return this.config.pointer.hitRadius}constructor(t,e,i,s){this.config=Dt.clone(ad),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new aa(t),this.transformer=new Gl(this),this.dragger=new td(this),s&&(this.config=Dt.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(Tl.defaultLeft(t),this.updateDownData(t),this.checkPath(t,e),this.downTime=Date.now(),this.emit(Ol.BEFORE_DOWN,t),this.emit(Ol.DOWN,t),Tl.left(t)&&(this.tapWait(),this.longPressWait(t)),this.waitRightTap=Tl.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&&Tl.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(t){const{dragHover:e,dragDistance:i}=this.config.pointer;if(this.emit(Ol.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=L.getDistance(this.downData,t)>i;e&&(this.waitTap&&this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(t,e)}this.dragger.moving||(this.updateHoverData(t),this.checkPath(t),this.emit(Ol.MOVE,t),this.dragging&&!e||this.pointerHover(t),this.dragger.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;Tl.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(Ol.BEFORE_UP,t),this.emit(Ol.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)}multiTouch(t,e){const{move:i,angle:s,scale:n,center:o}=rd.getData(e);this.rotate(cd(o,s,t)),this.zoom(dd(o,n,t)),this.move(ld(o,i,t))}menu(t){this.findPath(t),this.emit(Ol.MENU,t),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(t)}menuTap(t){this.waitRightTap&&this.waitMenuTap&&(this.emit(Ol.MENU_TAP,t),this.waitRightTap=this.waitMenuTap=!1)}move(t){this.transformer.move(t)}zoom(t){this.transformer.zoom(t)}rotate(t){this.transformer.rotate(t)}transformEnd(){this.transformer.transformEnd()}keyDown(t){if(!this.config.keyEvent)return;const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,El.setDownCode(e),this.emit(zl.HOLD,t,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(zl.DOWN,t,this.defaultPath)}keyUp(t){if(!this.config.keyEvent)return;const{code:e}=t;this.downKeyMap[e]=!1,El.setUpCode(e),this.emit(zl.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){this.canHover&&(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(Ol.OUT,t,i),this.emit(Ol.OVER,t,e)):this.emit(Ol.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(Ol.LEAVE,t,i,e),this.emit(Ol.ENTER,t,e,i)}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(Ol.LEAVE,t),this.dragger.dragging&&this.emit(Al.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=[Ol.DOUBLE_TAP,Ol.DOUBLE_CLICK].some((e=>hd(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(t,e){const{hitRadius:i,through:s}=this.config.pointer,{bottomList:n}=this,o=this.selector.getByPoint(t,i,Object.assign({bottomList:n,name:t.type},e||{through:s}));return o.throughPath&&(t.throughPath=o.throughPath),t.path=o.path,o.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&&!_d(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.config.move.drag&&!ud(t.path))&&!_d(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(),name:Ol.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);return{x:t.clientX-i.x,y:t.clientY-i.y}}emitTap(t){this.emit(Ol.TAP,t),this.emit(Ol.CLICK,t)}emitDoubleTap(t){this.emit(Ol.DOUBLE_TAP,t),this.emit(Ol.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout((()=>{this.longPressed=!0,this.emit(Ol.LONG_PRESS,t)}),this.config.pointer.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(Ol.LONG_TAP,t),(hd(t.path,Ol.LONG_TAP)||hd(t.path,Ol.LONG_PRESS))&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){clearTimeout(this.longPressTimer),this.longPressed=!1}__onResize(){this.shrinkCanvasBounds=new ht(this.canvas.bounds),this.shrinkCanvasBounds.spread(-2)}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(jo.RESIZE,this.__onResize,this)],t.once(Go.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],nd(n,t,e,!0,s))return;n.isApp&&sd(n,t,e,!0,s)}for(let o=0,r=i.length;o<r;o++)if(n=i.list[o],n.isApp&&sd(n,t,e,!1,s),nd(n,t,e,!1,s))return}catch(t){ed.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class gd{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}gd.custom={};class fd extends Lt{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new aa,this.pixelList=new aa}getPixelType(t,i){return this.__autoClear(),this.pixelList.add(t),e.hitCanvas(i)}getPathType(t){return this.__autoClear(),this.pathList.add(t),e.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()}}const{toInnerRadiusPointOf:yd,copy:md,setRadius:vd}=L,wd={},xd=Qr.prototype;xd.__hitWorld=function(t){if(!this.__.hitSelf)return!1;this.__.hitRadius&&(md(wd,t),vd(t=wd,this.__.hitRadius)),yd(t,this.__world,wd);const{width:e,height:i}=this.__world,s=e<10&&i<10;if(this.__.hitBox||s){if(nt.hitRadiusPoint(this.__layout.boxBounds,wd))return!0;if(s)return!1}return!this.__layout.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),this.__layout.boundsChanged||(this.__layout.hitCanvasChanged=!1)),this.__hit(wd)},xd.__hitFill=function(t){var e;return null===(e=this.__hitCanvas)||void 0===e?void 0:e.hitFill(t,this.__.windingRule)},xd.__hitStroke=function(t,e){var i;return null===(i=this.__hitCanvas)||void 0===i?void 0:i.hitStroke(t,e)},xd.__hitPixel=function(t){var e;return null===(e=this.__hitCanvas)||void 0===e?void 0:e.hitPixel(t,this.__layout.renderBounds,this.__hitCanvas.hitScale)},xd.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const bd=new N,Bd=Rh.prototype;Bd.__updateHitCanvas=function(){const e=this.__,{hitCanvasManager:i}=this.leafer,s=(e.__pixelFill||e.__isCanvas)&&"pixel"===e.hitFill,n=e.__pixelStroke&&"pixel"===e.hitStroke,o=s||n;this.__hitCanvas||(this.__hitCanvas=o?i.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):i.getPathType(this));const r=this.__hitCanvas;if(o){const{renderBounds:i}=this.__layout,o=t.image.hitCanvasSize,a=r.hitScale=lt.set(0,0,o,o).getFitMatrix(i,.5).a,{x:h,y:l,width:d,height:c}=lt.set(i).scale(a);r.resize({width:d,height:c,pixelRatio:1}),r.clear(),_n.patternLocked=!0,this.__renderShape(r,{matrix:bd.setWith(this.__world).scaleWith(1/a).invertWith().translate(-h,-l)},!s,!n),_n.patternLocked=!1,r.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(r),r.setStrokeOptions(e)},Bd.__hit=function(e){"miniapp"===t.name&&this.__drawHitPath(this.__hitCanvas);const i=this.__;if(i.__isHitPixel&&this.__hitPixel(e))return!0;const{hitFill:s}=i,n=(i.fill||i.__isCanvas)&&("path"===s||"pixel"===s&&!(i.__pixelFill||i.__isCanvas))||"all"===s;if(n&&this.__hitFill(e))return!0;const{hitStroke:o,__strokeWidth:r}=i,a=i.stroke&&("path"===o||"pixel"===o&&!i.__pixelStroke)||"all"===o;if(!n&&!a)return!1;const h=2*e.radiusX;let l=h;if(a)switch(i.strokeAlign){case"inside":if(l+=2*r,!n&&this.__hitFill(e)&&this.__hitStroke(e,l))return!0;l=h;break;case"center":l+=r;break;case"outside":if(l+=2*r,!n){if(!this.__hitFill(e)&&this.__hitStroke(e,l))return!0;l=h}}return!!l&&this.__hitStroke(e,l)};const Rd=new Rh,Cd=Ph.prototype;Cd.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?Rd.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},Cd.__hitFill=function(t){return this.__hitCanvas?Rd.__hitFill.call(this,t):nt.hitRadiusPoint(this.__layout.boxBounds,t)};const kd=Rh.prototype,Ed=Ch.prototype;kd.find=function(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!1,e):[]},kd.findOne=function(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!0,e):null},Ed.pick=function(t,e){return this.__layout.update(),e||(e={}),this.leafer?this.leafer.selector.getByPoint(t,e.hitRadius||0,Object.assign(Object.assign({},e),{target:this})):null};const Td=qt.prototype;Td.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},Td.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},Td.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:o,radiusY:r}=t;e&&(s-=e.x,n-=e.y),lt.set(s-o,n-r,2*o,2*r).scale(i).ceil();const{data:a}=this.context.getImageData(lt.x,lt.y,lt.width||1,lt.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 Pd={convert(t,e){const i=Kl.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=Kl.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=Pd.getTouch(t),s=Kl.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},Od={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;return t.shiftKey&&!s&&(s=n,n=0),s>50&&(s=Math.max(50,s/3)),n>50&&(n=Math.max(50,n/3)),{x:-s*i*2,y:-n*i*2}},getScale(e,i){let s,n=1,{zoomMode:o,zoomSpeed:r}=i;const h=e.deltaY||e.deltaX;if(o?(s="mouse"===o||!e.deltaX&&(t.intWheelDeltaY?Math.abs(h)>17:Math.ceil(h)!==h),(e.shiftKey||e.metaKey||e.ctrlKey)&&(s=!0)):s=!e.shiftKey&&(e.metaKey||e.ctrlKey),s){r=a.within(r,0,1);n=1-h/(4*(e.deltaY?i.delta.y:i.delta.x))*r,n<.5&&(n=.5),n>=1.5&&(n=1.5)}return n}},Sd={convert(t){const e=Kl.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{getMoveEventData:Ld,getZoomEventData:Dd,getRotateEventData:Md,pathCanDrag:Ad}=Kl;class Id extends pd{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(Sd.convert(t))}onKeyUp(t){this.keyUp(Sd.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(Pd.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||(this.usePointer||(this.usePointer=!0),this.pointerDown(Pd.convert(t,this.getLocal(t))))}onPointerMove(t){this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||(this.usePointer||(this.usePointer=!0),this.pointerMove(Pd.convert(t,this.getLocal(t,!0))))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(Pd.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(Pd.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(Pd.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(Pd.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){const e=Pd.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&Ad(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.usePointer||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(Pd.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=Pd.getTouch(t);this.pointerMove(Pd.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=Pd.getTouch(t);this.pointerUp(Pd.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(Kl.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}onWheel(t){this.preventDefaultWheel(t);const{wheel:e}=this.config;if(e.disabled)return;const i=e.getScale?e.getScale(t,e):Od.getScale(t,e),s=this.getLocal(t),n=Kl.getBase(t);1!==i?this.zoom(Dd(s,i,n)):this.move(Ld(s,e.getMove?e.getMove(t,e):Od.getMove(t,e),n))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=this.getLocal(t),i=Kl.getBase(t),s=t.scale/this.lastGestureScale,n=t.rotation-this.lastGestureRotation;let{rotateSpeed:o}=this.config.wheel;o=a.within(o,0,1),this.zoom(Dd(e,s*s,i)),this.rotate(Md(e,n/Math.PI*180*(o/4+.1),i)),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,e,i=0){if(i++,t instanceof Array)t.forEach((t=>this.eachCursor(t,e,i)));else{const s="string"==typeof t&&gd.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function Wd(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function Fd(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Yd(t,!0,e,i):zd(e,i);break;case"inside":Nd("inside",t,n,e,i);break;case"outside":Nd("outside",t,n,e,i)}}function Nd(t,e,i,s,n){const{__strokeWidth:o,__font:r}=s.__,a=n.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,s.__),a.font=r,i?Yd(e,!0,s,a):zd(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",Wd(s,a),a.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(a,s.__nowWorld):n.copyWorldToInner(a,s.__nowWorld,s.__layout.renderBounds),a.recycle(s.__nowWorld)}function zd(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[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)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Yd(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&Ga.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?zd(i,s):s.stroke(),s.restoreBlendMode()):e?zd(i,s):s.stroke())}const{getSpread:Xd,getOuterOf:jd,getByMove:Hd,getIntersectData:Ud}=nt;let Vd;function Gd(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:Ha.string(r,a)};case"image":return Ga.image(i,t,e,s,!Vd||!Vd[e.url]);case"linear":return Ka.linearGradient(e,s);case"radial":return Ka.radialGradient(e,s);case"angular":return Ka.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:Ha.string(e)}:void 0}}const Kd={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Vd=Ga.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=Gd(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?Wd(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&Ga.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?Wd(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?Wd(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?Wd(e,i):n?i.fill(n):i.fill())},fillText:Wd,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)Fd(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)Fd(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Yd(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Yd(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*n,s),Yd(t,!1,e,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:Fd,drawTextStroke:zd,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:d}=n;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,c=Ud(s?Xd(e.bounds,l===d?s*l:[s*d,s*l]):e.bounds,n);r=e.bounds.getFitMatrix(c);let{a:u,d:_}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=_),a=jd(n,r),o=Hd(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,_*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,_)})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:d}}};let qd={};const{get:Zd,rotateOfOuter:Qd,translate:Jd,scaleOfOuter:$d,scale:tc,rotate:ec}=x;function ic(t,e,i,s,n,o,r){const a=Zd();Jd(a,e.x+i,e.y+s),tc(a,n,o),r&&Qd(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function sc(t,e,i,s,n,o,r){const a=Zd();Jd(a,e.x+i,e.y+s),n&&tc(a,n,o),r&&ec(a,r),t.transform=a}function nc(t,e,i,s,n,o,r,a,h,l){const d=Zd();if(h)if("center"===l)Qd(d,{x:i/2,y:s/2},h);else switch(ec(d,h),h){case 90:Jd(d,s,0);break;case 180:Jd(d,i,s);break;case 270:Jd(d,0,i)}qd.x=e.x+n,qd.y=e.y+o,Jd(d,qd.x,qd.y),r&&$d(d,qd,r,a),t.transform=d}const{get:oc,translate:rc}=x,ac=new ht,hc={},lc={};function dc(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=cc(i,s,e)}function cc(t,e,i){let{width:s,height:n}=i;t.padding&&(e=ac.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:h,offset:l,scale:d,size:c,rotation:u,repeat:_}=t,p=e.width===s&&e.height===n,g={mode:r},f="center"!==h&&(u||0)%180==90,y=f?n:s,m=f?s:n;let v,w,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(d||c)&&(a.getScaleData(d,c,i,lc),v=lc.scaleX,w=lc.scaleY);else if(!p||u){const t=e.width/y,i=e.height/m;v=w="fit"===r?Math.min(t,i):Math.max(t,i),x+=(e.width-s*v)/2,b+=(e.height-n*w)/2}if(h){const t={x:x,y:b,width:y,height:m};v&&(t.width*=v,t.height*=w),yt.toPoint(h,t,e,hc,!0),x+=hc.x,b+=hc.y}switch(l&&(x+=l.x,b+=l.y),r){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(x||b||v||u)&&sc(g,e,x,b,v,w,u);break;case"repeat":(!p||v||u)&&nc(g,e,s,n,x,b,v,w,u,h),_||(g.repeat="repeat");break;default:v&&ic(g,e,x,b,v,w,u)}return g.transform||(e.x||e.y)&&(g.transform=oc(),rc(g.transform,e.x,e.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=w),g.width=s,g.height=n,o&&(g.opacity=o),_&&(g.repeat="string"==typeof _?"x"===_?"repeat-x":"repeat-y":"repeat"),g}let uc,_c=new ht;const{isSame:pc}=nt;function gc(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||dc(n,s,i,o),!0}function fc(t,e){vc(t,Xo.LOAD,e)}function yc(t,e){vc(t,Xo.LOADED,e)}function mc(t,e,i){e.error=i,t.forceUpdate("surface"),vc(t,Xo.ERROR,e)}function vc(t,e,i){t.hasEvent(e)&&t.emitEvent(new Xo(e,i))}function wc(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:xc,scale:bc,copy:Bc}=x,{ceil:Rc,abs:Cc}=Math;function kc(e,i,s){let{scaleX:n,scaleY:o}=_n.patternLocked?e.__world:e.__nowWorld;const r=n+"-"+o+"-"+s;if(i.patternId===r||e.destroyed)return!1;{n=Cc(n),o=Cc(o);const{image:e,data:a}=i;let h,l,{width:d,height:c,scaleX:u,scaleY:_,opacity:p,transform:g,repeat:f}=a;u&&(l=xc(),Bc(l,g),bc(l,1/u,1/_),n*=u,o*=_),n*=s,o*=s,d*=n,c*=o;const y=d*c;if(!f&&y>t.image.maxCacheSize)return!1;let m=t.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}y>m&&(h=Math.sqrt(y/m)),h&&(n/=h,o/=h,d/=h,c/=h),u&&(n/=u,o/=_),(g||1!==n||1!==o)&&(l||(l=xc(),g&&Bc(l,g)),bc(l,1/n,1/o));const v=e.getCanvas(Rc(d)||1,Rc(c)||1,p),w=e.getPattern(v,f||t.origin.noRepeat||"no-repeat",l,i);return i.style=w,i.patternId=r,!0}}const{abs:Ec}=Math;const Tc={image:function(t,e,i,s,n){let o,r;const a=_n.get(i);return uc&&i===uc.paint&&pc(s,uc.boxBounds)?o=uc.leafPaint:(o={type:i.type,image:a},uc=a.use>1?{leafPaint:o,paint:i,boxBounds:_c.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(gc(t,e,i,a,o,s),n&&(fc(t,r),yc(t,r))):a.error?n&&mc(t,r,a.error):(wc(t,!0),n&&fc(t,r),o.loadId=a.load((()=>{wc(t,!1),t.destroyed||(gc(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),yc(t,r)),o.loadId=null}),(e=>{wc(t,!1),mc(t,r,e),o.loadId=null}))),o},checkImage:function(e,i,s,n){const{scaleX:o,scaleY:r}=_n.patternLocked?e.__world:e.__nowWorld,{pixelRatio:a}=i;if(!s.data||s.patternId===o+"-"+r+"-"+a&&!Za.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:e,height:i}=h;e*=Ec(o)*a,i*=Ec(r)*a,h.scaleX&&(e*=h.scaleX,i*=h.scaleY),n=e*i>t.image.maxCacheSize||Za.running}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),h.opacity&&(i.opacity*=h.opacity),h.transform&&i.transform(h.transform),i.drawImage(s.image.view,0,0,h.width,h.height),i.restore(),!0):(!s.style||s.sync||Za.running?kc(e,s,a):s.patternTask||(s.patternTask=_n.patternTasker.add((()=>zt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&kc(e,s,a),e.forceUpdate("surface")}))),300)),!1)}},createPattern:kc,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,_n.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null},createData:dc,getPatternData:cc,fillOrFitMode:ic,clipMode:sc,repeatMode:nc},{toPoint:Pc}=pt,Oc={},Sc={};function Lc(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),Ha.string(s,i)):t.addColorStop(s.offset,Ha.string(s.color,i))}}const{getAngle:Dc,getDistance:Mc}=L,{get:Ac,rotateOfOuter:Ic,scaleOfOuter:Wc}=x,{toPoint:Fc}=pt,Nc={},zc={};function Yc(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=Dc(e,i);o=Ac(),n?(Wc(o,e,r/a*(s||1),1),Ic(o,e,t+90)):(Wc(o,e,1,r/a*(s||1)),Ic(o,e,t))}return o}const{getDistance:Xc}=L,{toPoint:jc}=pt,Hc={},Uc={};const Vc={linearGradient:function(e,i){let{from:s,to:n,type:o,blendMode:r,opacity:a}=e;Pc(s||"top",i,Oc),Pc(n||"bottom",i,Sc);const h=t.canvas.createLinearGradient(Oc.x,Oc.y,Sc.x,Sc.y);Lc(h,e.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=e;Fc(s||"center",i,Nc),Fc(n||"bottom",i,zc);const l=t.canvas.createRadialGradient(Nc.x,Nc.y,0,Nc.x,Nc.y,Mc(Nc,zc));Lc(l,e.stops,r);const d={type:o,style:l},c=Yc(i,Nc,zc,h,!0);return c&&(d.transform=c),a&&(d.blendMode=a),d},conicGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=e;jc(s||"center",i,Hc),jc(n||"bottom",i,Uc);const l=t.conicGradientSupport?t.canvas.createConicGradient(0,Hc.x,Hc.y):t.canvas.createRadialGradient(Hc.x,Hc.y,0,Hc.x,Hc.y,Xc(Hc,Uc));Lc(l,e.stops,r);const d={type:o,style:l},c=Yc(i,Hc,Uc,h||1,t.conicGradientRotate90);return c&&(d.transform=c),a&&(d.blendMode=a),d},getTransform:Yc},{copy:Gc,toOffsetOutBounds:Kc}=nt,qc={},Zc={};function Qc(e,i,s,n){const{bounds:o,shapeBounds:r}=n;if(t.fullImageShadow){if(Gc(qc,e.bounds),qc.x+=i.x-r.x,qc.y+=i.y-r.y,s){const{matrix:t}=n;qc.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),qc.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),qc.width*=s,qc.height*=s}e.copyWorld(n.canvas,e.bounds,qc)}else s&&(Gc(qc,i),qc.x-=i.width/2*(s-1),qc.y-=i.height/2*(s-1),qc.width*=s,qc.height*=s),e.copyWorld(n.canvas,r,s?qc:i)}const{toOffsetOutBounds:Jc}=nt,$c={};const tu={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;Kc(l,Zc),a.forEach(((a,g)=>{_.setWorldShadow(Zc.offsetX+a.x*c,Zc.offsetY+a.y*u,a.blur*c,a.color),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Qc(_,Zc,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")),t.__worldFlipped?e.copyWorldByReset(_,s,o,a.blendMode):e.copyWorldToInner(_,s,r.renderBounds,a.blendMode),p&&g<p&&_.clearWorld(s,!0)})),_.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;Jc(l,$c),a.forEach(((a,g)=>{_.save(),_.setWorldShadow($c.offsetX+a.x*c,$c.offsetY+a.y*u,a.blur*c),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Qc(_,$c,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,a.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(_,s,o,a.blendMode):e.copyWorldToInner(_,s,r.renderBounds,a.blendMode),p&&g<p&&_.clearWorld(s,!0)})),_.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){}},{excludeRenderBounds:eu}=Bo;function iu(t,e,i,s,n,o){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),nu(t,e,i,1)}(t,i,s,n);break;case"opacity-path":nu(t,i,s,o);break;case"path":i.restore()}}function su(t){return t.getSameCanvas(!1,!0)}function nu(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}Ch.prototype.__renderMask=function(t,e){let i,s,n,o,r;const{children:a}=this;for(let h=0,l=a.length;h<l;h++)i=a[h],i.__.mask&&(r&&(iu(this,r,t,n,s,o),s=n=null),"path"===i.__.mask?(i.opacity<1?(r="opacity-path",o=i.opacity,n||(n=su(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="alpha",s||(s=su(t)),n||(n=su(t)),i.__render(s,e)),"clipping"!==i.__.mask)||eu(i,e)||i.__render(n||t,e);iu(this,r,t,n,s,o)};const ou=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ru=ou+"_#~&*+\\=|≮≯≈≠=…",au=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 hu(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const lu=hu("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),du=hu("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),cu=hu(ou),uu=hu(ru),_u=hu("- —/~|┆·");var pu;!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"}(pu||(pu={}));const{Letter:gu,Single:fu,Before:yu,After:mu,Symbol:vu,Break:wu}=pu;function xu(t){return lu[t]?gu:_u[t]?wu:du[t]?yu:cu[t]?mu:uu[t]?vu:au.test(t)?fu:gu}const bu={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 Bu(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:Ru}=bu,{Letter:Cu,Single:ku,Before:Eu,After:Tu,Symbol:Pu,Break:Ou}=pu;let Su,Lu,Du,Mu,Au,Iu,Wu,Fu,Nu,zu,Yu,Xu,ju,Hu,Uu,Vu,Gu=[];function Ku(t,e){Nu&&!Fu&&(Fu=Nu),Su.data.push({char:t,width:e}),Du+=e}function qu(){Mu+=Du,Su.width=Du,Lu.words.push(Su),Su={data:[]},Du=0}function Zu(){Hu&&(Uu.paraNumber++,Lu.paraStart=!0,Hu=!1),Nu&&(Lu.startCharSize=Fu,Lu.endCharSize=Nu,Fu=0),Lu.width=Mu,Vu.width&&Ru(Lu),Gu.push(Lu),Lu={words:[]},Mu=0}const Qu=0,Ju=1,$u=2;const{top:t_,right:e_,bottom:i_,left:s_}=ct;function n_(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 o_={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let s=0,n=0,o=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:a,__font:h,__padding:l}=i;l&&(o&&(s=l[s_],o-=l[e_]+l[s_]),r&&(n=l[t_],r-=l[t_]+l[i_]));const d={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:t.canvas.font=h};return function(e,i,s){Uu=e,Gu=e.rows,Vu=e.bounds;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=t,{width:h,height:l}=Vu;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Hu=!0,Yu=null,Fu=Wu=Nu=Du=Mu=0,Su={data:[]},Lu={words:[]};for(let s=0,l=i.length;s<l;s++)Iu=i[s],"\n"===Iu?(Du&&qu(),Lu.paraEnd=!0,Zu(),Hu=!0):(zu=xu(Iu),zu===Cu&&"none"!==r&&(Iu=Bu(Iu,r,!Du)),Wu=a.measureText(Iu).width,n&&(n<0&&(Nu=Wu),Wu+=n),Xu=zu===ku&&(Yu===ku||Yu===Cu)||Yu===ku&&zu!==Tu,ju=!(zu!==Eu&&zu!==ku||Yu!==Pu&&Yu!==Tu),Au=Hu&&o?h-o:h,t&&h&&Mu+Du+Wu>Au&&(e?(Du&&qu(),Mu&&Zu()):(ju||(ju=zu===Cu&&Yu==Tu),Xu||ju||zu===Ou||zu===Eu||zu===ku||Du+Wu>Au?(Du&&qu(),Mu&&Zu()):Mu&&Zu()))," "===Iu&&!0!==Hu&&Mu+Du===0||(zu===Ou?(" "===Iu&&Du&&qu(),Ku(Iu,Wu),qu()):Xu||ju?(Du&&qu(),Ku(Iu,Wu)):Ku(Iu,Wu)),Yu=zu);Du&&qu(),Mu&&Zu(),Gu.length>0&&(Gu[Gu.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Uu.paraNumber++,Gu.push({x:o||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(d,e,i),l&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":n_(e,"x",t[s_]);break;case"right":n_(e,"x",-t[e_])}if(!n)switch(i.verticalAlign){case"top":n_(e,"y",t[t_]);break;case"bottom":n_(e,"y",-t[i_])}}(l,d,i,o,r),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:a,textAlign:h,verticalAlign:l,paraSpacing:d}=e;let c,u,_,{x:p,y:g,width:f,height:y}=s,m=n*i.length+(d?d*(t.paraNumber-1):0),v=o;if(a&&m>y)m=Math.max(y,n),t.overflow=i.length;else switch(l){case"middle":g+=(y-m)/2;break;case"bottom":g+=y-m}v+=g;for(let o=0,l=i.length;o<l;o++){if(c=i[o],c.x=p,c.width<f||c.width>f&&!a)switch(h){case"center":c.x+=(f-c.width)/2;break;case"right":c.x+=f-c.width}c.paraStart&&d&&o>0&&(v+=d),c.y=v,v+=n,t.overflow>o&&v>m&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,_=c.width,r<0&&(c.width<0?(_=-c.width+e.fontSize+r,u-=_,_+=e.fontSize):_-=r),u<s.x&&(s.x=u),_>s.width&&(s.width=_),a&&f&&f<_&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=m}(d,i),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,l,d,c,u;n.forEach((t=>{t.words&&(d=r&&t.paraStart?r:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=a||t.isOverflow?Qu:l>.01?Ju:$u,t.isOverflow&&!a&&(t.textMode=!0),c===$u?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{c===Ju?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(d,i,o),d.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){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)}}))}}(d,i,s,o),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(d,i),d}};const r_={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!Ha.object)return t;t=Ha.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}},{setPoint:a_,addPoint:h_,toBounds:l_}=Y;const d_={export(i,s,n){this.running=!0;const o=hn.fileType(s),r=s.includes(".");return n=hn.getExportOptions(n),function(t){c_||(c_=new un);return new Promise((e=>{c_.add((()=>zt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((h=>new Promise((l=>{const d=t=>{h(t),l(),this.running=!1},{toURL:c}=t,{download:u}=t.origin;if("json"===o)return r&&u(c(JSON.stringify(i.toJSON(n.json)),"text"),s),d({data:!!r||i.toJSON(n.json)});if("svg"===o)return r&&u(c(i.toSVG(),"svg"),s),d({data:!!r||i.toSVG()});const{leafer:_}=i;_?(u_(i),_.waitViewCompleted((()=>zt(this,void 0,void 0,(function*(){let t,o,r=1,h=1;const{worldTransform:l,isLeafer:c,isFrame:u}=i,{slice:p,trim:g,onCanvas:f}=n,y=void 0===n.smooth?_.config.smooth:n.smooth,m=n.contextSettings||_.config.contextSettings,v=n.screenshot||i.isApp,w=c&&v&&void 0===n.fill?i.fill:n.fill,x=hn.isOpaqueImage(s)||w,b=new N;if(v)t=!0===v?c?_.canvas.bounds:i.worldRenderBounds:v;else{let e=n.relative||(c?"inner":"local");switch(r=l.scaleX,h=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(i.localTransform),r/=i.scaleX,h/=i.scaleY;break;case"world":r=1,h=1;break;case"page":e=i.leafer;default:b.set(l).divide(i.getTransform(e));const t=e.worldTransform;r/=r/t.scaleX,h/=h/t.scaleY}t=i.getBounds("render",e)}const B={scaleX:1,scaleY:1};a.getScaleData(n.scale,n.size,t,B);let R=n.pixelRatio||1;i.isApp&&(B.scaleX*=R,B.scaleY*=R,R=i.app.pixelRatio);const{x:C,y:k,width:E,height:T}=new ht(t).scale(B.scaleX,B.scaleY),P={matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-C,-k).withScale(1/r*B.scaleX,1/h*B.scaleY)};let O,S=e.canvas({width:Math.round(E),height:Math.round(T),pixelRatio:R,smooth:y,contextSettings:m});if(p&&(O=i,O.__worldOpacity=0,i=_,P.bounds=S.bounds),S.save(),u&&void 0!==w){const t=i.get("fill");i.fill="",i.__render(S,P),i.fill=t}else i.__render(S,P);if(S.restore(),O&&O.__updateWorldOpacity(),g){o=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?h_(r,n,o):a_(r={},n,o)),a++;const h=new ht;return l_(r,h),h.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:i,height:s}=o,n={x:0,y:0,width:i,height:s,pixelRatio:R};S=e.canvas(n),S.copyWorld(t,o,n)}x&&S.fillWorld(S.bounds,w||"#FFFFFF","destination-over"),f&&f(S);const L="canvas"===s?S:yield S.export(s,n);d({data:L,width:S.pixelWidth,height:S.pixelHeight,renderBounds:t,trimBounds:o})}))))):d({data:!1})}))))}};let c_;function u_(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>u_(t)))}const __=qt.prototype,p_=vt.get("@leafer-ui/export");__.export=function(t,e){const{quality:i,blob:s}=hn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},__.toBlob=function(e,i){return new Promise((s=>{t.origin.canvasToBolb(this.view,e,i).then((t=>{s(t)})).catch((t=>{p_.error(t),s(null)}))}))},__.toDataURL=function(e,i){return t.origin.canvasToDataURL(this.view,e,i)},__.saveAs=function(e,i){return new Promise((s=>{t.origin.canvasSaveAs(this.view,e,i).then((()=>{s(!0)})).catch((t=>{p_.error(t),s(!1)}))}))},Object.assign(ja,o_),Object.assign(Ha,r_),Object.assign(Va,Kd),Object.assign(Ga,Tc),Object.assign(Ka,Vc),Object.assign(qa,tu),Object.assign(Za,d_),Object.assign(e,{interaction:(t,e,i,s)=>new Id(t,e,i,s),hitCanvas:(t,e)=>new ca(t,e),hitCanvasManager:()=>new fd}),pa();export{yt as AlignHelper,It as Answer,Cl as App,pt as AroundHelper,dt as AutoBounds,Be as BezierHelper,ht as Bounds,nt as BoundsHelper,Wh as Box,oh as BoxData,ra as Branch,Co as BranchHelper,Er as BranchRender,fl as Canvas,mh as CanvasData,Lt as CanvasManager,zo as ChildEvent,Ha as ColorConvert,e as Creator,gd as Cursor,Dt as DataHelper,vt as Debug,ct as Direction4,ut as Direction9,Dl as DragEvent,Al as DropEvent,qa as Effect,Xh as Ellipse,dh as EllipseData,Le as EllipseHelper,No as Event,Ot as EventCreator,qo as Eventer,Za as Export,hn as FileHelper,Fh as Frame,ah as FrameData,Ch as Group,nh as GroupData,fd as HitCanvasManager,pl as Image,yh as ImageData,Xo as ImageEvent,_n as ImageManager,i as IncrementId,Id as Interaction,pd as InteractionBase,Kl as InteractionHelper,zl as KeyEvent,El as Keyboard,Uo as LayoutEvent,Ta as Layouter,Qr as Leaf,Rr as LeafBounds,Bo as LeafBoundsHelper,At as LeafData,lr as LeafDataProxy,rr as LeafEventer,go as LeafHelper,Fo as LeafLayout,ha as LeafLevelList,aa as LeafList,fr as LeafMatrix,Cr as LeafRender,Th as Leafer,ca as LeaferCanvas,qt as LeaferCanvasBase,rh as LeaferData,Go as LeaferEvent,yn as LeaferImage,jl as LeaferTypeCreator,Qh as Line,hh as LineData,a as MathHelper,N as Matrix,x as MatrixHelper,Il as MoveEvent,rd as MultiTouchHelper,Ml as MyDragEvent,gl as MyImage,Sl as MyPointerEvent,te as NeedConvertToCanvasCommandMap,h as OneRadian,l as PI2,d as PI_2,Va as Paint,Ka as PaintGradient,Ga as PaintImage,Bl as Path,Ua as PathArrow,qs as PathBounds,Ni as PathCommandDataHelper,Jt as PathCommandMap,fi as PathConvert,nn as PathCorner,is as PathCreator,_h as PathData,ys as PathDrawer,Zt as PathHelper,ne as PathNumberCommandLengthMap,se as PathNumberCommandMap,Rl as Pen,ph as PenData,t as Platform,W as Point,L as PointHelper,Tl as PointerButton,Ol as PointerEvent,rl as Polygon,ch as PolygonData,Yo as PropertyEvent,Ph as Rect,lh as RectData,oe as RectHelper,bh as RectRender,Vo as RenderEvent,Oa as Renderer,jo as ResizeEvent,Wl as RotateEvent,Bt as Run,Na as Selector,_l as Star,uh as StarData,Qa as State,mt as StringNumberMap,Fl as SwipeEvent,cn as TaskItem,un as TaskProcessor,bl as Text,ja as TextConvert,fh as TextData,Ja as Transition,Y as TwoPointBoundsHelper,Rh as UI,vh as UIBounds,Et as UICreator,ih as UIData,Pl as UIEvent,wh as UIRender,sh as UnitConvert,Po as WaitHelper,Ho as WatchEvent,fa as Watcher,Nl as ZoomEvent,Yl as addInteractionWindow,In as affectRenderBoundsType,Dn as affectStrokeBoundsType,xn as attr,Cn as autoLayoutType,Tn as boundsType,an as canvasPatch,Kt as canvasSizeAttrs,Un as cursorType,Vn as dataProcessor,Bn as dataType,wn as decorateLeafAttr,Kn as defineDataProcessor,mn as defineKey,bn as defineLeafAttr,On as doBoundsType,Mn as doStrokeType,za as effectType,Wt as emptyData,jn as eraserType,u as getBoundsData,vn as getDescriptor,_ as getMatrixData,c as getPointData,Hn as hitType,Ft as isNull,Gn as layoutProcessor,Xn as maskType,Pn as naturalBoundsType,Ct as needPlugin,Fn as opacityType,Sn as pathInputType,Ln as pathType,on as pen,Rn as positionType,io as registerUI,so as registerUIEvent,Ya as resizeType,Jn as rewrite,$n as rewriteAble,En as rotationType,kn as scaleType,Yn as sortType,An as strokeType,Wn as surfaceType,lt as tempBounds,z as tempMatrix,F as tempPoint,pa as useCanvas,eo as useModule,la as version,Nn as visibleType,Xa as zoomLayerType};