@leafer-editor/worker 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var LeaferUI=function(t){"use strict";var e,i;t.PathNodeHandleType=void 0,(e=t.PathNodeHandleType||(t.PathNodeHandleType={}))[e.none=1]="none",e[e.free=2]="free",e[e.mirrorAngle=3]="mirrorAngle",e[e.mirror=4]="mirror",t.Answer=void 0,(i=t.Answer||(t.Answer={}))[i.No=0]="No",i[i.Yes=1]="Yes",i[i.NoAndSkip=2]="NoAndSkip",i[i.YesAndSkip=3]="YesAndSkip";const s={};function n(t){return void 0===t}function r(t){return null==t}function o(t){return"string"==typeof t}const{isFinite:a}=Number;function h(t){return"number"==typeof t}const l=/^-?\d+(?:\.\d+)?$/;const{isArray:d}=Array;function c(t){return t&&"object"==typeof t}function u(t){return c(t)&&!d(t)}function p(t){return"{}"===JSON.stringify(t)}const g={default:(t,e)=>(_(e,t),_(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach(n=>{var r,o;if(s=e[n],(null==s?void 0:s.constructor)===Object&&(null===(r=t[n])||void 0===r?void 0:r.constructor)===Object)return _(t[n],e[n],i&&i[n]);i&&n in i?(null===(o=i[n])||void 0===o?void 0:o.constructor)===Object&&_(t[n]={},e[n],i[n]):t[n]=e[n]})},copyAttrs:(t,e,i)=>(i.forEach(i=>{n(e[i])||(t[i]=e[i])}),t),clone:t=>JSON.parse(JSON.stringify(t)),toMap(t){const e={};for(let i=0,s=t.length;i<s;i++)e[t[i]]=!0;return e},stintSet(t,e,i){i||(i=void 0),t[e]!==i&&(t[e]=i)}},{assign:_}=g;class f{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __usePathBox(){return this.__pathInputed}get __blendMode(){if(this.eraser&&"path"!==this.eraser)return"destination-out";const{blendMode:t}=this;return"pass-through"===t?null:t}constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(!n(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]=n(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(!n(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!n(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(d(t))for(let e of t)i[e]=this.__getInput(e);else for(let e in t)i[e]=this.__getInput(e);else{let t,e,{__input:s}=this;i.tag=this.__leaf.tag;for(let r in this)if("_"!==r[0]&&(t=this["_"+r],!n(t))){if("path"===r&&!this.__pathInputed)continue;e=s?s[r]:void 0,i[r]=n(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:n,e:r,f:o}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:n,e:r,f:o}}return i}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){const t=this;if("pass-through"===t.blendMode){const e=this.__leaf;t.opacity<1&&(e.isBranch||t.__hasMultiPaint)||e.__hasEraser||t.eraser||t.filter?t.__single=!0:t.__single&&(t.__single=!1)}else t.__single=!0}__removeNaturalSize(){this.__naturalWidth=this.__naturalHeight=void 0}destroy(){this.__input=this.__middle=null}}const m={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=y;return e[t]?e[t]++:(e[t]=1,0)}},y=m;let v,x,w;const{max:E}=Math,b=[0,0,0,0],k={zero:[...b],tempFour:b,set:(t,e,i,s,n)=>(void 0===i&&(i=s=n=e),t[0]=e,t[1]=i,t[2]=s,t[3]=n,t),setTemp:(t,e,i,s)=>T(b,t,e,i,s),toTempAB(t,e,i){w=i?h(t)?e:t:[],h(t)?(v=B(t),x=e):h(e)?(v=t,x=B(e)):(v=t,x=e),4!==v.length&&(v=S(v)),4!==x.length&&(x=S(x))},get(t,e){let i;if(!h(t))switch(t.length){case 4:i=n(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]),!n(e))for(let t=0;t<4;t++)i[t]>e&&(i[t]=e);return i},max:(t,e,i)=>h(t)&&h(e)?E(t,e):(P(t,e,i),T(w,E(v[0],x[0]),E(v[1],x[1]),E(v[2],x[2]),E(v[3],x[3]))),add:(t,e,i)=>h(t)&&h(e)?t+e:(P(t,e,i),T(w,v[0]+x[0],v[1]+x[1],v[2]+x[2],v[3]+x[3])),swapAndScale(t,e,i,s){if(h(t))return e===i?t*e:[t*i,t*e];const n=s?t:[],[r,o,a,l]=4===t.length?t:S(t);return T(n,a*i,l*e,r*i,o*e)}},{set:T,get:S,setTemp:B,toTempAB:P}=k,{round:L,pow:R,max:C,floor:O,PI:M}=Math,D={within:(t,e,i)=>(c(e)&&(i=e.max,e=e.min),!n(e)&&t<e&&(t=e),!n(i)&&t>i&&(t=i),t),fourNumber:k.get,formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),D.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=n(e)?1e12:R(10,e);return-0===(t=L(t*i)/i)?0:t},sign:t=>t<0?-1:1,getScaleData(t,e,i,s){if(s||(s={}),e){const t=(h(e)?e:e.width||0)/i.width,n=(h(e)?e:e.height||0)/i.height;s.scaleX=t||n||1,s.scaleY=n||t||1}else t&&D.assignScale(s,t);return s},assignScale(t,e){h(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},getFloorScale:(t,e=1)=>C(O(t),e)/t,randInt:I,randColor:t=>`rgba(${I(255)},${I(255)},${I(255)},${t||1})`};function I(t){return Math.round(Math.random()*t)}const A=M/180,W=2*M,F=M/2;function z(){return{x:0,y:0}}function U(){return{x:0,y:0,width:0,height:0}}function H(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:N,cos:Y,acos:X,sqrt:V}=Math,{float:j}=D,G={};function K(){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 Z={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:K(),tempMatrix:{},set(t,e=1,i=0,s=0,n=1,r=0,o=0){t.a=e,t.b=i,t.c=s,t.d=n,t.e=r,t.f=o},get:H,getWorld:K,copy(t,e){t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f},translate(t,e,i){t.e+=e,t.f+=i},translateInner(t,e,i,s){t.e+=t.a*e+t.c*i,t.f+=t.b*e+t.d*i,s&&(t.e-=e,t.f-=i)},scale(t,e,i=e){t.a*=e,t.b*=e,t.c*=i,t.d*=i},pixelScale(t,e,i){i||(i=t),i.a=t.a*e,i.b=t.b*e,i.c=t.c*e,i.d=t.d*e,i.e=t.e*e,i.f=t.f*e},scaleOfOuter(t,e,i,s){q.toInnerPoint(t,e,G),q.scaleOfInner(t,G,i,s)},scaleOfInner(t,e,i,s=i){q.translateInner(t,e.x,e.y),q.scale(t,i,s),q.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:r}=t,o=Y(e*=A),a=N(e);t.a=i*o-s*a,t.b=i*a+s*o,t.c=n*o-r*a,t.d=n*a+r*o},rotateOfOuter(t,e,i){q.toInnerPoint(t,e,G),q.rotateOfInner(t,G,i)},rotateOfInner(t,e,i){q.translateInner(t,e.x,e.y),q.rotate(t,i),q.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:r,d:o}=t;i&&(i*=A,t.a=s+r*i,t.b=n+o*i),e&&(e*=A,t.c=r+s*e,t.d=o+n*e)},skewOfOuter(t,e,i,s){q.toInnerPoint(t,e,G),q.skewOfInner(t,G,i,s)},skewOfInner(t,e,i,s=0){q.translateInner(t,e.x,e.y),q.skew(t,i,s),q.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:n,d:r,e:o,f:a}=t;t.a=e.a*i+e.b*n,t.b=e.a*s+e.b*r,t.c=e.c*i+e.d*n,t.d=e.c*s+e.d*r,t.e=e.e*i+e.f*n+o,t.f=e.e*s+e.f*r+a},multiplyParent(t,e,i,s,r){const{e:o,f:a}=t;if(i||(i=t),n(s)&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:n,c:o,d:a}=t;i.a=s*e.a+n*e.c,i.b=s*e.b+n*e.d,i.c=o*e.a+a*e.c,i.d=o*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=o*e.a+a*e.c+e.e,i.f=o*e.b+a*e.d+e.f},divide(t,e){q.multiply(t,q.tempInvert(e))},divideParent(t,e){q.multiplyParent(t,q.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=q;return q.copy(e,t),q.invert(e),e},invert(t){const{a:e,b:i,c:s,d:n,e:r,f:o}=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=-(r*n-o*s)*a,t.f=-(o*e-r*i)*a}else if(1===e&&1===n)t.e=-r,t.f=-o;else{const i=1/(e*n);t.a=n*i,t.d=e*i,t.e=-r*n*i,t.f=-o*e*i}},toOuterPoint(t,e,i,s){const{x:n,y:r}=e;i||(i=e),i.x=n*t.a+r*t.c,i.y=n*t.b+r*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:n,b:r,c:o,d:a}=t,h=1/(n*a-r*o),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*o)*h,i.y=(d*n-l*r)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*o)*h,i.y-=(s*n-e*r)*h}},setLayout(t,e,i,s,r){const{x:o,y:a,scaleX:h,scaleY:l}=e;if(n(r)&&(r=e.rotation||e.skewX||e.skewY),r){const{rotation:i,skewX:s,skewY:n}=e,r=i*A,o=Y(r),a=N(r);if(s||n){const e=s*A,i=n*A;t.a=(o+i*-a)*h,t.b=(a+i*o)*h,t.c=(e*o-a)*l,t.d=(o+e*a)*l}else t.a=o*h,t.b=a*h,t.c=-a*l,t.d=o*l}else t.a=h,t.b=0,t.c=0,t.d=l;t.e=o,t.f=a,(i=i||s)&&q.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:n,b:r,c:o,d:a,e:h,f:l}=t;let d,c,u,p,g,_=h,f=l;if(r||o){const t=n*a-r*o;if(o&&!s){d=V(n*n+r*r),c=t/d;const e=n/d;u=r>0?X(e):-X(e)}else{c=V(o*o+a*a),d=t/c;const e=o/c;u=F-(a>0?X(-e):-X(e))}const e=j(Y(u)),i=N(u);d=j(d),c=j(c),p=e?j((o/c+i)/e/A,9):0,g=e?j((r/d-i)/e/A,9):0,u=j(u/A)}else d=n,c=a,u=p=g=0;return(e=i||e)&&(_+=e.x*n+e.y*o,f+=e.x*r+e.y*a,i||(_-=e.x,f-=e.y)),{x:_,y:f,scaleX:d,scaleY:c,rotation:u,skewX:p,skewY:g}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:n,c:r,d:o}=t;n||r?i=(s*o-n*r)/(e=V(s*s+n*n)):(e=s,i=o)}return s.scaleX=e,s.scaleY=i,s},reset(t){q.set(t)}},q=Z,{float:J}=D,{toInnerPoint:$,toOuterPoint:Q}=Z,{sin:tt,cos:et,abs:it,sqrt:st,atan2:nt,min:rt,round:ot}=Math,at={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=n(i)?e:i},copy(t,e){t.x=e.x,t.y=e.y},copyFrom(t,e,i){t.x=e,t.y=i},round(t,e){t.x=e?ot(t.x-.5)+.5:ot(t.x),t.y=e?ot(t.y-.5)+.5:ot(t.y)},move(t,e,i){c(e)?(t.x+=e.x,t.y+=e.y):(t.x+=e,t.y+=i)},scale(t,e,i=e){t.x&&(t.x*=e),t.y&&(t.y*=i)},scaleOf(t,e,i,s=i){t.x+=(t.x-e.x)*(i-1),t.y+=(t.y-e.y)*(s-1)},rotate(t,e,i){i||(i=ht.defaultPoint);const s=et(e*=A),n=tt(e),r=t.x-i.x,o=t.y-i.y;t.x=i.x+r*s-o*n,t.y=i.y+r*n+o*s},tempToInnerOf(t,e){const{tempPoint:i}=ht;return dt(i,t),$(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=ht;return dt(i,t),Q(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=ht;return dt(i,t),ht.toInnerRadiusPointOf(t,e,i),i},copyRadiusPoint:(t,e,i,s)=>(dt(t,e),ct(t,i,s),t),toInnerRadiusPointOf(t,e,i){i||(i=t),$(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){$(e,t,i)},toOuterOf(t,e,i){Q(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)=>lt(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=it(i-t),r=it(s-e);return st(n*n+r*r)},getMinDistanceFrom:(t,e,i,s,n,r)=>rt(lt(t,e,i,s),lt(i,s,n,r)),getAngle:(t,e)=>ut(t,e)/A,getRotation:(t,e,i,s)=>(s||(s=e),ht.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/A),getRadianFrom(t,e,i,s,r,o,a,h){n(a)&&(a=i,h=s);const l=t-i,d=e-s,c=r-a,u=o-h;return Math.atan2(l*u-d*c,l*c+d*u)},getAtan2:(t,e)=>nt(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s,n){const r=ut(t,e);return n&&(t=e),s||(e={}),e.x=t.x+et(r)*i,e.y=t.y+tt(r)*i,e},toNumberPoints(t){let e=t;return c(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},isSame:(t,e)=>J(t.x)===J(e.x)&&J(t.y)===J(e.y),reset(t){ht.reset(t)}},ht=at,{getDistanceFrom:lt,copy:dt,setRadius:ct,getAtan2:ut}=ht;class pt{constructor(t,e){this.set(t,e)}set(t,e){return c(t)?at.copy(this,t):at.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new pt(this)}move(t,e){return at.move(this,t,e),this}scale(t,e){return at.scale(this,t,e),this}scaleOf(t,e,i){return at.scaleOf(this,t,e,i),this}rotate(t,e){return at.rotate(this,t,e),this}rotateOf(t,e){return at.rotate(this,e,t),this}getRotation(t,e,i){return at.getRotation(this,t,e,i)}toInnerOf(t,e){return at.toInnerOf(this,t,e),this}toOuterOf(t,e){return at.toOuterOf(this,t,e),this}getCenter(t){return new pt(at.getCenter(this,t))}getDistance(t){return at.getDistance(this,t)}getDistancePoint(t,e,i,s){return new pt(at.getDistancePoint(this,t,e,i,s))}getAngle(t){return at.getAngle(this,t)}getAtan2(t){return at.getAtan2(this,t)}isSame(t){return at.isSame(this,t)}reset(){return at.reset(this),this}}const gt=new pt;class _t{constructor(t,e,i,s,n,r){this.set(t,e,i,s,n,r)}set(t,e,i,s,n,r){return c(t)?Z.copy(this,t):Z.set(this,t,e,i,s,n,r),this}setWith(t){return Z.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:r}=this;return{a:t,b:e,c:i,d:s,e:n,f:r}}clone(){return new _t(this)}translate(t,e){return Z.translate(this,t,e),this}translateInner(t,e){return Z.translateInner(this,t,e),this}scale(t,e){return Z.scale(this,t,e),this}scaleWith(t,e){return Z.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}pixelScale(t){return Z.pixelScale(this,t),this}scaleOfOuter(t,e,i){return Z.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return Z.scaleOfInner(this,t,e,i),this}rotate(t){return Z.rotate(this,t),this}rotateOfOuter(t,e){return Z.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return Z.rotateOfInner(this,t,e),this}skew(t,e){return Z.skew(this,t,e),this}skewOfOuter(t,e,i){return Z.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return Z.skewOfInner(this,t,e,i),this}multiply(t){return Z.multiply(this,t),this}multiplyParent(t){return Z.multiplyParent(this,t),this}divide(t){return Z.divide(this,t),this}divideParent(t){return Z.divideParent(this,t),this}invert(){return Z.invert(this),this}invertWith(){return Z.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){Z.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){Z.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return Z.setLayout(this,t,e,i),this}getLayout(t,e,i){return Z.getLayout(this,t,e,i)}withScale(t,e){return Z.withScale(this,t,e)}reset(){Z.reset(this)}}const ft=new _t,mt={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){yt(t,e,i),yt(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:yt}=mt;var vt,xt;t.Direction4=void 0,(vt=t.Direction4||(t.Direction4={}))[vt.top=0]="top",vt[vt.right=1]="right",vt[vt.bottom=2]="bottom",vt[vt.left=3]="left",t.Direction9=void 0,(xt=t.Direction9||(t.Direction9={}))[xt.topLeft=0]="topLeft",xt[xt.top=1]="top",xt[xt.topRight=2]="topRight",xt[xt.right=3]="right",xt[xt.bottomRight=4]="bottomRight",xt[xt.bottom=5]="bottom",xt[xt.bottomLeft=6]="bottomLeft",xt[xt.left=7]="left",xt[xt.center=8]="center",xt[xt["top-left"]=0]="top-left",xt[xt["top-right"]=2]="top-right",xt[xt["bottom-right"]=4]="bottom-right",xt[xt["bottom-left"]=6]="bottom-left";const wt=[{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}];wt.forEach(t=>t.type="percent");const Et={directionData:wt,tempPoint:{},get:bt,toPoint(t,e,i,s,n,r){const o=bt(t);i.x=o.x,i.y=o.y,"percent"===o.type&&(i.x*=e.width,i.y*=e.height,n&&(r||(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)},getPoint:(t,e,i)=>(i||(i={}),Et.toPoint(t,e,i,!0),i)};function bt(e){return o(e)?wt[t.Direction9[e]]:e}const{toPoint:kt}=Et,Tt={toPoint(t,e,i,s,n,r){kt(t,i,s,n,e,r)}},{tempPointBounds:St,setPoint:Bt,addPoint:Pt,toBounds:Lt}=mt,{toOuterPoint:Rt}=Z,{float:Ct,fourNumber:Ot}=D,{floor:Mt,ceil:Dt}=Math;let It,At,Wt,Ft;const zt={},Ut={},Ht={},Nt={tempBounds:Ht,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:r,y:o,width:a,height:h}=e;if(d(i)){const e=Ot(i);s?Yt.set(t,r+e[3],o+e[0],a-e[1]-e[3],h-e[2]-e[0]):Yt.set(t,r-e[3],o-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),Yt.set(t,r-i,o-i,a+2*i,h+2*i);n&&("width"===n?(t.y=o,t.height=h):(t.x=r,t.width=a))},minX:t=>t.width>0?t.x:t.x+t.width,minY:t=>t.height>0?t.y:t.y+t.height,maxX:t=>t.width>0?t.x+t.width:t.x,maxY:t=>t.height>0?t.y+t.height:t.y,move(t,e,i){t.x+=e,t.y+=i},scroll(t,e){t.x+=e.scrollX,t.y+=e.scrollY},getByMove:(t,e,i)=>(t=Object.assign({},t),Yt.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?Vt(e,t):e=t,i||(i=t),e.offsetX=Yt.maxX(i),e.offsetY=Yt.maxY(i),Yt.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e,s){s||at.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){at.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(Yt.copy(Ht,t),Yt.toOuterOf(Ht,e),Ht),getOuterOf:(t,e)=>(t=Object.assign({},t),Yt.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:n,e:r,f:o}=e;s>0?(i.width=t.width*s,i.x=r+t.x*s):(i.width=t.width*-s,i.x=r+t.x*s-i.width),n>0?(i.height=t.height*n,i.y=o+t.y*n):(i.height=t.height*-n,i.y=o+t.y*n-i.height)}else zt.x=t.x,zt.y=t.y,Rt(e,zt,Ut),Bt(St,Ut.x,Ut.y),zt.x=t.x+t.width,Rt(e,zt,Ut),Pt(St,Ut.x,Ut.y),zt.y=t.y+t.height,Rt(e,zt,Ut),Pt(St,Ut.x,Ut.y),zt.x=t.x,Rt(e,zt,Ut),Pt(St,Ut.x,Ut.y),Lt(St,i)},toInnerOf(t,e,i){i||(i=t),Yt.move(i,-e.e,-e.f),Yt.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Yt.getFitScale(t,e));return new _t(s,0,0,s,-e.x*s,-e.y*s)},getFitScale(t,e,i){const s=t.width/e.width,n=t.height/e.height;return i?Math.max(s,n):Math.min(s,n)},put(t,e,i="center",s=1,n=!0,r){r||(r=e),o(s)&&(s=Yt.getFitScale(t,e,"cover"===s)),Ht.width=n?e.width*=s:e.width*s,Ht.height=n?e.height*=s:e.height*s,Tt.toPoint(i,Ht,t,r,!0,!0)},getSpread(t,e,i){const s={};return Yt.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){Yt.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){Yt.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=Mt(t.x),t.y=Mt(t.y),t.width=e>t.x?Dt(t.width+e-t.x):Dt(t.width),t.height=i>t.y?Dt(t.height+i-t.y):Dt(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=Ct(t.x,e),t.y=Ct(t.y,e),t.width=Ct(t.width,e),t.height=Ct(t.height,e)},add(t,e,i){It=t.x+t.width,At=t.y+t.height,Wt=e.x,Ft=e.y,i||(Wt+=e.width,Ft+=e.height),It=It>Wt?It:Wt,At=At>Ft?At:Ft,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=It-t.x,t.height=At-t.y},addList(t,e){Yt.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){Yt.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){Yt.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let n,r=!0;for(let o=0,a=e.length;o<a;o++)n=i?i(e[o],o):e[o],n&&(n.width||n.height)&&(r?(r=!1,s||Vt(t,n)):Xt(t,n));r&&Yt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?Bt(St,t.x,t.y):Pt(St,t.x,t.y)),Lt(St,t)},setPoint(t,e){Yt.set(t,e.x,e.y)},addPoint(t,e){Xt(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=at.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=at.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=Yt.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=Yt.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=Yt.tempToOuterOf(e,i)),!Yt.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:r,height:o}=e;return It=s+r,At=n+o,Wt=t.x+t.width,Ft=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,It=It<Wt?It:Wt,At=At<Ft?At:Ft,r=It-s,o=At-n,{x:s,y:n,width:r,height:o}},intersect(t,e,i){Yt.copy(t,Yt.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,hasSize:t=>t.width&&t.height,reset(t){Yt.set(t)}},Yt=Nt,{add:Xt,copy:Vt}=Yt;class jt{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 c(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 jt(this)}move(t,e){return Nt.move(this,t,e),this}scale(t,e,i){return Nt.scale(this,t,e,i),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)}put(t,e,i){Nt.put(this,t,e,i)}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 jt(Nt.getIntersectData(this,t,e))}isSame(t){return Nt.isSame(this,t)}isEmpty(){return Nt.isEmpty(this)}reset(){Nt.reset(this)}}const Gt=new jt;class Kt{constructor(t,e,i,s,n,r){c(t)?this.copy(t):this.set(t,e,i,s,n,r)}set(t=0,e=0,i=0,s=0,n=0,r=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=n,this.height=r}copy(t){const{top:e,right:i,bottom:s,left:n,width:r,height:o}=t;this.set(e,i,s,n,r,o)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:n,width:r,height:o}=this;return new jt(n,e,r||t.width-n-i,o||t.height-e-s)}}const Zt={number:(t,e)=>c(t)?"percent"===t.type?t.value*e:t.value:t},qt={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},{floor:Jt,max:$t}=Math,Qt={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",isLarge:(t,e,i,s)=>t.width*t.height*(e?e*i:1)>(s||te.maxCacheSize),isSuperLarge:(t,e,i)=>te.isLarge(t,e,i,te.maxPatternSize),getRealURL(t){const{prefix:e,suffix:i}=te;return!i||t.startsWith("data:")||t.startsWith("blob:")||(t+=(t.includes("?")?"&":"?")+i),e&&"/"===t[0]&&(t=e+t),t},resize(t,e,i,s,n,r,o,a,h,l){const d=$t(Jt(e+(s||0)),1),c=$t(Jt(i+(n||0)),1);let u,p,g;l&&(g=Zt.number(l.offset,"x"===l.type?e:i))&&("x"===l.type?u=!0:p=!0);const _=Qt.origin.createCanvas(p?2*d:d,u?2*c:c),f=_.getContext("2d");if(a&&(f.globalAlpha=a),f.imageSmoothingEnabled=!1!==o,te.canUse(t)){if(r){const s=e/r.width,n=i/r.height;f.setTransform(s,0,0,n,-r.x*s,-r.y*n),f.drawImage(t,0,0,t.width,t.height)}else f.drawImage(t,0,0,e,i);g&&(f.drawImage(_,0,0,d,c,u?g-d:d,u?c:g-c,d,c),f.drawImage(_,0,0,d,c,u?g:d,u?c:g,d,c))}return _},canUse:t=>t&&t.width&&!t.__closed,setPatternTransform(t,e,i){try{e&&t.setTransform&&(t.setTransform(e),e=void 0)}catch(t){}i&&g.stintSet(i,"transform",e)}}},{image:te}=Qt,{randColor:ee}=D;class ie{constructor(t){this.repeatMap={},this.name=t}static get(t){return new ie(t)}static set filter(t){this.filterList=se(t)}static set exclude(t){this.excludeList=se(t)}static drawRepaint(t,e){const i=ee();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(t,e,i){const s="hit"===ie.showBounds,n=t.__nowWorld,r=ee();s&&(e.setWorld(n),t.__drawHitPath(e),e.fillStyle=r.replace("1)",".2)"),e.fill()),e.resetTransform(),e.setStroke(r,2),s?e.stroke():e.strokeWorld(n,r)}log(...t){if(ne.enable){if(ne.filterList.length&&ne.filterList.every(t=>t!==this.name))return;if(ne.excludeList.length&&ne.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){ne.enable&&this.warn(...t)}warn(...t){ne.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 se(t){return t?o(t)&&(t=[t]):t=[],t}ie.filterList=[],ie.excludeList=[],ie.showWarn=!0;const ne=ie,re=ie.get("RunTime"),oe={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const i=m.create(m.RUNTIME);return ae.currentId=ae.idMap[i]=e?performance.now():Date.now(),ae.currentName=ae.nameMap[i]=t,ae.nameToIdMap[t]=i,i},end(t,e){const i=ae.idMap[t],s=ae.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;ae.idMap[t]=ae.nameMap[t]=ae.nameToIdMap[s]=void 0,re.log(s,n,"ms")},endOfName(t,e){const i=ae.nameToIdMap[t];n(i)||ae.end(i,e)}},ae=oe,he=[],le={list:{},add(t,...e){this.list[t]=!0,he.push(...e)},has(t,e){const i=this.list[t];return!i&&e&&this.need(t),i},need(t){console.error("please install and import plugin: "+(t.includes("-x")?"":"@leafer-in/")+t)}};setTimeout(()=>he.forEach(t=>le.has(t,!0)));const de={editor:t=>le.need("editor")},ce=ie.get("UICreator"),ue={list:{},register(t){const{__tag:e}=t.prototype;pe[e]&&ce.repeat(e),pe[e]=t},get(t,e,i,s,r,o){pe[t]||ce.error("not register "+t);const a=new pe[t](e);return n(i)||(a.x=i,s&&(a.y=s),r&&(a.width=r),o&&(a.height=o)),a}},{list:pe}=ue,ge=ie.get("EventCreator"),_e={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],o(e)&&(fe[e]&&ge.repeat(e),fe[e]=t)})},changeName(t,e){const i=fe[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,fe[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new fe[t](...e)},{nameList:fe}=_e;class me{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:i}=this;for(let s=0,n=i.length;s<n;s++)if(e=i[s],e.recycled&&e.isSameSize(t))return e.recycled=!1,e.manager||(e.manager=this),e;const s=de.canvas(t);return this.add(s),s}recycle(t){t.recycled=!0}clearRecycled(){let t;const e=[];for(let i=0,s=this.list.length;i<s;i++)t=this.list[i],t.recycled?t.destroy():e.push(t);this.list=e}clear(){this.list.forEach(t=>{t.destroy()}),this.list.length=0}destroy(){this.clear()}}function ye(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o}function ve(t,e,i,s){return new(i||(i=Promise))(function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(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(o,a)}h((s=s.apply(t,e||[])).next())})}function xe(t){return(e,i)=>{t||(t=i);const s={get(){return this.context[t]},set(e){this.context[t]=e}};"strokeCap"===i&&(s.set=function(e){this.context[t]="none"===e?"butt":e}),Object.defineProperty(e,i,s)}}"function"==typeof SuppressedError&&SuppressedError;const we=[];function Ee(){return(t,e)=>{we.push(e)}}const be=[];class ke{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||be)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;we.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,i,s,n,r){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,n,r){c(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,n,r)}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,r,o,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/s*a;s+=e,e=0,r+=t,a-=t}if(i<0){const t=-i/n*h;n+=i,i=0,o+=t,h-=t}this.context.drawImage(t,e,i,s,n,r,o,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,r){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,n,r){}arcTo(t,e,i,s,n){}ellipse(t,e,i,s,n,r,o,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,r){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}}ye([xe("imageSmoothingEnabled")],ke.prototype,"smooth",void 0),ye([xe("imageSmoothingQuality")],ke.prototype,"smoothLevel",void 0),ye([xe("globalAlpha")],ke.prototype,"opacity",void 0),ye([xe()],ke.prototype,"fillStyle",void 0),ye([xe()],ke.prototype,"strokeStyle",void 0),ye([xe("lineWidth")],ke.prototype,"strokeWidth",void 0),ye([xe("lineCap")],ke.prototype,"strokeCap",void 0),ye([xe("lineJoin")],ke.prototype,"strokeJoin",void 0),ye([xe("lineDashOffset")],ke.prototype,"dashOffset",void 0),ye([xe()],ke.prototype,"miterLimit",void 0),ye([xe()],ke.prototype,"shadowBlur",void 0),ye([xe()],ke.prototype,"shadowColor",void 0),ye([xe()],ke.prototype,"shadowOffsetX",void 0),ye([xe()],ke.prototype,"shadowOffsetY",void 0),ye([xe()],ke.prototype,"filter",void 0),ye([xe()],ke.prototype,"font",void 0),ye([xe()],ke.prototype,"fontKerning",void 0),ye([xe()],ke.prototype,"fontStretch",void 0),ye([xe()],ke.prototype,"fontVariantCaps",void 0),ye([xe()],ke.prototype,"textAlign",void 0),ye([xe()],ke.prototype,"textBaseline",void 0),ye([xe()],ke.prototype,"textRendering",void 0),ye([xe()],ke.prototype,"wordSpacing",void 0),ye([xe()],ke.prototype,"letterSpacing",void 0),ye([xe()],ke.prototype,"direction",void 0),ye([Ee()],ke.prototype,"setTransform",null),ye([Ee()],ke.prototype,"resetTransform",null),ye([Ee()],ke.prototype,"getTransform",null),ye([Ee()],ke.prototype,"save",null),ye([Ee()],ke.prototype,"restore",null),ye([Ee()],ke.prototype,"translate",null),ye([Ee()],ke.prototype,"scale",null),ye([Ee()],ke.prototype,"rotate",null),ye([Ee()],ke.prototype,"fill",null),ye([Ee()],ke.prototype,"stroke",null),ye([Ee()],ke.prototype,"clip",null),ye([Ee()],ke.prototype,"fillRect",null),ye([Ee()],ke.prototype,"strokeRect",null),ye([Ee()],ke.prototype,"clearRect",null),ye([Ee()],ke.prototype,"beginPath",null),ye([Ee()],ke.prototype,"moveTo",null),ye([Ee()],ke.prototype,"lineTo",null),ye([Ee()],ke.prototype,"bezierCurveTo",null),ye([Ee()],ke.prototype,"quadraticCurveTo",null),ye([Ee()],ke.prototype,"closePath",null),ye([Ee()],ke.prototype,"arc",null),ye([Ee()],ke.prototype,"arcTo",null),ye([Ee()],ke.prototype,"ellipse",null),ye([Ee()],ke.prototype,"rect",null),ye([Ee()],ke.prototype,"roundRect",null),ye([Ee()],ke.prototype,"createConicGradient",null),ye([Ee()],ke.prototype,"createLinearGradient",null),ye([Ee()],ke.prototype,"createPattern",null),ye([Ee()],ke.prototype,"createRadialGradient",null),ye([Ee()],ke.prototype,"fillText",null),ye([Ee()],ke.prototype,"measureText",null),ye([Ee()],ke.prototype,"strokeText",null);const{copy:Te,multiplyParent:Se,pixelScale:Be}=Z,{round:Pe}=Math,Le=new jt,Re=new jt,Ce={width:1,height:1,pixelRatio:1},Oe=["width","height","pixelRatio"];class Me extends ke{get width(){return this.size.width}get height(){return this.size.height}get pixelRatio(){return this.size.pixelRatio}get pixelWidth(){return this.width*this.pixelRatio||0}get pixelHeight(){return this.height*this.pixelRatio||0}get pixelSnap(){return this.config.pixelSnap}set pixelSnap(t){this.config.pixelSnap=t}get allowBackgroundColor(){return this.view&&this.parentView}constructor(t,e){super(),this.size={},this.worldTransform={},t||(t=Ce),this.manager=e,this.innerId=m.create(m.CNAVAS);const{width:i,height:s,pixelRatio:n}=t;this.autoLayout=!i||!s,this.size.pixelRatio=n||Qt.devicePixelRatio,this.config=t,this.init()}init(){}__createContext(){const{view:t}=this,{contextSettings:e}=this.config;this.context=e?t.getContext("2d",e):t.getContext("2d"),this.__bindContext()}export(t,e){}toBlob(t,e){}toDataURL(t,e){}saveAs(t,e){}resize(t,e=!0){if(this.isSameSize(t))return;let i;this.context&&!this.unreal&&e&&this.width&&(i=this.getSameCanvas(),i.copyWorld(this));const s=this.size;g.copyAttrs(s,t,Oe),Oe.forEach(t=>s[t]||(s[t]=1)),this.bounds=new jt(0,0,this.width,this.height),this.updateViewSize(),this.updateClientBounds(),this.context&&(this.smooth=this.config.smooth,!this.unreal&&i&&(this.clearWorld(i.bounds),this.copyWorld(i),i.recycle()))}updateViewSize(){}updateClientBounds(){}getClientBounds(t){return t&&this.updateClientBounds(),this.clientBounds||this.bounds}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e){const{pixelRatio:i,pixelSnap:s}=this,n=this.worldTransform;e&&Se(t,e,n),Be(t,i,n),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(n.e=Pe(n.e-.5)+.5,n.f=Pe(n.f-.5)+.5):(n.e=Pe(n.e),n.f=Pe(n.f))),this.setTransform(n.a,n.b,n.c,n.d,n.e,n.f)}useWorldTransform(t){t&&(this.worldTransform=t);const e=this.worldTransform;e&&this.setTransform(e.a,e.b,e.c,e.d,e.e,e.f)}setStroke(t,e,i,s){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),i&&this.setStrokeOptions(i,s)}setStrokeOptions(t,e){let{strokeCap:i,strokeJoin:s,dashPattern:r,dashOffset:o,miterLimit:a}=t;e&&(e.strokeCap&&(i=e.strokeCap),e.strokeJoin&&(s=e.strokeJoin),n(e.dashPattern)||(r=e.dashPattern),n(e.dashOffset)||(o=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=i,this.strokeJoin=s,this.dashPattern=r,this.dashOffset=o,this.miterLimit=a}saveBlendMode(t){this.savedBlendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedBlendMode}hitFill(t,e){return!0}hitStroke(t,e){return!0}hitPixel(t,e,i=1){return!0}setWorldShadow(t,e,i,s){const{pixelRatio:n}=this;this.shadowOffsetX=t*n,this.shadowOffsetY=e*n,this.shadowBlur=i*n,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s,n){s&&(this.blendMode=s),e?(this.setTempPixelBounds(e,n),i?(this.setTempPixelBounds2(i,n),i=Re):i=Le,this.drawImage(t.view,Le.x,Le.y,Le.width,Le.height,i.x,i.y,i.width,i.height)):this.drawImage(t.view,0,0),s&&(this.blendMode="source-over")}copyWorldToInner(t,e,i,s,n){e.b||e.c?(this.save(),this.resetTransform(),this.copyWorld(t,e,Nt.tempToOuterOf(i,e),s,n),this.restore()):(s&&(this.blendMode=s),this.setTempPixelBounds(e,n),this.drawImage(t.view,Le.x,Le.y,Le.width,Le.height,i.x,i.y,i.width,i.height),s&&(this.blendMode="source-over"))}copyWorldByReset(t,e,i,s,n,r){this.resetTransform(),this.copyWorld(t,e,i,s,r),n||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempPixelBounds(t,!0,!0);const{context:s}=this,n=s.getImageData(Le.x,Le.y,Le.width,Le.height),{data:r}=n;for(let t=0,s=r.length;t<s;t+=4)i=.299*r[t]+.587*r[t+1]+.114*r[t+2],(e=r[t+3])&&(r[t+3]=255===e?i:e*(i/255));s.putImageData(n,Le.x,Le.y)}useMask(t,e,i){this.copyWorld(t,e,i,"destination-in")}useEraser(t,e,i){this.copyWorld(t,e,i,"destination-out")}fillWorld(t,e,i,s){i&&(this.blendMode=i),this.fillStyle=e,this.setTempPixelBounds(t,s),this.fillRect(Le.x,Le.y,Le.width,Le.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(Le.x,Le.y,Le.width,Le.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(Le.x,Le.y,Le.width,Le.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(Le.x,Le.y,Le.width,Le.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(Le,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(Re,t,e,i)}copyToPixelBounds(t,e,i,s){t.set(e),s&&t.intersect(this.bounds),t.scale(this.pixelRatio),i&&t.ceil()}isSameSize(t){return this.width===t.width&&this.height===t.height&&(!t.pixelRatio||this.pixelRatio===t.pixelRatio)}getSameCanvas(t,e){const{size:i,pixelSnap:s}=this,n=this.manager?this.manager.get(i):de.canvas(Object.assign({},i));return n.save(),t&&(Te(n.worldTransform,this.worldTransform),n.useWorldTransform()),e&&(n.smooth=this.smooth),n.pixelSnap!==s&&(n.pixelSnap=s),n}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const De={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Ie={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Ae=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},Ie),We={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},Fe={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},ze=Object.assign(Object.assign({},Fe),Ie),Ue=Ae,He={};for(let t in Ue)He[Ue[t]]=t;const Ne={};for(let t in Ue)Ne[Ue[t]]=We[t];const Ye={drawRoundRect(t,e,i,s,n,r){const o=D.fourNumber(r,Math.min(s/2,n/2)),a=e+s,h=i+n;o[0]?t.moveTo(e+o[0],i):t.moveTo(e,i),o[1]?t.arcTo(a,i,a,h,o[1]):t.lineTo(a,i),o[2]?t.arcTo(a,h,e,h,o[2]):t.lineTo(a,h),o[3]?t.arcTo(e,h,e,i,o[3]):t.lineTo(e,h),o[0]?t.arcTo(e,i,a,i,o[0]):t.lineTo(e,i)}},{sin:Xe,cos:Ve,hypot:je,atan2:Ge,ceil:Ke,abs:Ze,PI:qe,sqrt:Je,pow:$e}=Math,{setPoint:Qe,addPoint:ti}=mt,{set:ei,toNumberPoints:ii}=at,{M:si,L:ni,C:ri,Q:oi,Z:ai}=Ae,hi={},li={points(t,e,i,s){let n=ii(e);if(t.push(si,n[0],n[1]),i&&n.length>5){let e,r,o,a,h,l,d,c,u,p,g,_,f,m,y,v=n.length;const x=!0===i?.5:i;s&&(n=[n[v-2],n[v-1],...n,n[0],n[1],n[2],n[3]],v=n.length);for(let i=2;i<v-2;i+=2)e=n[i-2],r=n[i-1],o=n[i],a=n[i+1],h=n[i+2],l=n[i+3],g=o-e,_=a-r,f=Je($e(g,2)+$e(_,2)),m=Je($e(h-o,2)+$e(l-a,2)),(f||m)&&(y=f+m,f=x*f/y,m=x*m/y,h-=e,l-=r,d=o-f*h,c=a-f*l,2===i?s||t.push(oi,d,c,o,a):(g||_)&&t.push(ri,u,p,d,c,o,a),u=o+m*h,p=a+m*l);s||t.push(oi,u,p,n[v-2],n[v-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(ni,n[e],n[e+1]);s&&t.push(ai)},rect(t,e,i,s,n){De.creator.path=t,De.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,r){De.creator.path=[],Ye.drawRoundRect(De.creator,e,i,s,n,r),t.push(...De.convertToCanvasData(De.creator.path,!0))},arcTo(t,e,i,s,n,r,o,a,h,l,d){const c=s-e,u=n-i,p=r-s,g=o-n;let _=Ge(u,c),f=Ge(g,p);const m=je(c,u),y=je(p,g);let v=f-_;if(v<0&&(v+=W),m<1e-12||y<1e-12||v<1e-12||Ze(v-qe)<1e-12)return t&&t.push(ni,s,n),h&&(Qe(h,e,i),ti(h,s,n)),d&&ei(d,e,i),void(l&&ei(l,s,n));const x=c*g-p*u<0,w=x?-1:1,E=a/Ve(v/2),b=s+E*Ve(_+v/2+F*w),k=n+E*Xe(_+v/2+F*w);return _-=F*w,f-=F*w,ui(t,b,k,a,a,0,_/A,f/A,x,h,l,d)},arc:(t,e,i,s,n,r,o,a,h,l)=>ui(t,e,i,s,s,0,n,r,o,a,h,l),ellipse(t,e,i,s,n,r,o,a,h,l,d,c){const u=r*A,p=Xe(u),g=Ve(u);let _=o*A,f=a*A;_>qe&&(_-=W),f<0&&(f+=W);let m=f-_;m<0?m+=W:m>W&&(m-=W),h&&(m-=W);const y=Ke(Ze(m/F)),v=m/y,x=Xe(v/4),w=8/3*x*x/Xe(v/2);f=_+v;let E,b,k,T,S,B,P,L,R=Ve(_),C=Xe(_),O=k=g*s*R-p*n*C,M=T=p*s*R+g*n*C,D=e+k,I=i+T;t&&t.push(t.length?ni:si,D,I),l&&Qe(l,D,I),c&&ei(c,D,I);for(let r=0;r<y;r++)E=Ve(f),b=Xe(f),k=g*s*E-p*n*b,T=p*s*E+g*n*b,S=e+O-w*(g*s*C+p*n*R),B=i+M-w*(p*s*C-g*n*R),P=e+k+w*(g*s*b+p*n*E),L=i+T+w*(p*s*b-g*n*E),t&&t.push(ri,S,B,P,L,e+k,i+T),l&&ci(e+O,i+M,S,B,P,L,e+k,i+T,l,!0),O=k,M=T,R=E,C=b,_=f,f+=v;d&&ei(d,e+k,i+T)},quadraticCurveTo(t,e,i,s,n,r,o){t.push(ri,(e+2*s)/3,(i+2*n)/3,(r+2*s)/3,(o+2*n)/3,r,o)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,n,r,o,a){ci(t,e,(t+2*i)/3,(e+2*s)/3,(n+2*i)/3,(r+2*s)/3,n,r,o,a)},toTwoPointBounds(t,e,i,s,n,r,o,a,h,l){const d=[];let c,u,p,g,_,f,m,y,v=t,x=i,w=n,E=o;for(let t=0;t<2;++t)if(1==t&&(v=e,x=s,w=r,E=a),c=-3*v+9*x-9*w+3*E,u=6*v-12*x+6*w,p=3*x-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;g=-p/u,0<g&&g<1&&d.push(g)}else m=u*u-4*p*c,y=Math.sqrt(m),m<0||(_=(-u+y)/(2*c),0<_&&_<1&&d.push(_),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?ti(h,t,e):Qe(h,t,e),ti(h,o,a);for(let l=0,c=d.length;l<c;l++)di(d[l],t,e,i,s,n,r,o,a,hi),ti(h,hi.x,hi.y)},getPointAndSet(t,e,i,s,n,r,o,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,p=3*d*t*t,g=t*t*t;l.x=c*e+u*s+p*r+g*a,l.y=c*i+u*n+p*o+g*h},getPoint(t,e,i,s,n,r,o,a,h){const l={};return di(t,e,i,s,n,r,o,a,h,l),l},getDerivative(t,e,i,s,n){const r=1-t;return 3*r*r*(i-e)+6*r*t*(s-i)+3*t*t*(n-s)}},{getPointAndSet:di,toTwoPointBounds:ci,ellipse:ui}=li,{sin:pi,cos:gi,sqrt:_i,atan2:fi}=Math,{ellipse:mi}=li,yi={ellipticalArc(t,e,i,s,n,r,o,a,h,l,d){const c=(h-e)/2,u=(l-i)/2,p=r*A,g=pi(p),_=gi(p),f=-_*c-g*u,m=-_*u+g*c,y=s*s,v=n*n,x=m*m,w=f*f,E=y*v-y*x-v*w;let b=0;if(E<0){const t=_i(1-E/(y*v));s*=t,n*=t}else b=(o===a?-1:1)*_i(E/(y*x+v*w));const k=b*s*m/n,T=-b*n*f/s,S=fi((m-T)/n,(f-k)/s),B=fi((-m-T)/n,(-f-k)/s);let P=B-S;0===a&&P>0?P-=W:1===a&&P<0&&(P+=W);const L=e+c+_*k-g*T,R=i+u+g*k+_*T,C=P<0?1:0;d||Qt.ellipseToCurve?mi(t,L,R,s,n,r,S/A,B/A,C):s!==n||r?t.push(Ae.G,L,R,s,n,r,S/A,B/A,C):t.push(Ae.O,L,R,s,S/A,B/A,C)}},vi={toCommand:t=>[],toNode:t=>[]},{M:xi,m:wi,L:Ei,l:bi,H:ki,h:Ti,V:Si,v:Bi,C:Pi,c:Li,S:Ri,s:Ci,Q:Oi,q:Mi,T:Di,t:Ii,A:Ai,a:Wi,Z:Fi,z:zi,N:Ui,D:Hi,X:Ni,G:Yi,F:Xi,O:Vi,P:ji,U:Gi}=Ae,{rect:Ki,roundRect:Zi,arcTo:qi,arc:Ji,ellipse:$i,quadraticCurveTo:Qi}=li,{ellipticalArc:ts}=yi,es=ie.get("PathConvert"),is={},ss={current:{dot:0},stringify(t,e){let i,s,n,r=0,o=t.length,a="";for(;r<o;){s=t[r],i=Ne[s],a+=s===n?" ":He[s];for(let s=1;s<i;s++)a+=D.float(t[r+s],e),s===i-1||(a+=" ");n=s,r+=i}return a},parse(t,e){let i,s,n,r="";const o=[],a=e?ze:Fe;for(let e=0,h=t.length;e<h;e++)s=t[e],qt[s]?("."===s&&(ns.dot&&(rs(o,r),r=""),ns.dot++),"0"===r&&"."!==s&&(rs(o,r),r=""),r+=s):Ae[s]?(r&&(rs(o,r),r=""),ns.name=Ae[s],ns.length=We[s],ns.index=0,rs(o,ns.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?r+=s:(r&&rs(o,r),r=s):r&&(rs(o,r),r=""),n=s;return r&&rs(o,r),i?ss.toCanvasData(o,e):o},toCanvasData(t,e){let i,s,n,r,o,a=0,h=0,l=0,d=0,c=0,u=t.length;const p=[];for(;c<u;){switch(n=t[c],n){case wi:t[c+1]+=a,t[c+2]+=h;case xi:a=t[c+1],h=t[c+2],p.push(xi,a,h),c+=3;break;case Ti:t[c+1]+=a;case ki:a=t[c+1],p.push(Ei,a,h),c+=2;break;case Bi:t[c+1]+=h;case Si:h=t[c+1],p.push(Ei,a,h),c+=2;break;case bi:t[c+1]+=a,t[c+2]+=h;case Ei:a=t[c+1],h=t[c+2],p.push(Ei,a,h),c+=3;break;case Ci:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ri;case Ri:o=r===Pi||r===Ri,l=o?2*a-i:t[c+1],d=o?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],p.push(Pi,l,d,i,s,a,h),c+=5;break;case Li:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,n=Pi;case Pi:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],p.push(Pi,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Ii:t[c+1]+=a,t[c+2]+=h,n=Di;case Di:o=r===Oi||r===Di,i=o?2*a-i:t[c+1],s=o?2*h-s:t[c+2],e?Qi(p,a,h,i,s,t[c+1],t[c+2]):p.push(Oi,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Mi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Oi;case Oi:i=t[c+1],s=t[c+2],e?Qi(p,a,h,i,s,t[c+3],t[c+4]):p.push(Oi,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Wi:t[c+6]+=a,t[c+7]+=h;case Ai:ts(p,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 zi:case Fi:p.push(Fi),c++;break;case Ui:a=t[c+1],h=t[c+2],e?Ki(p,a,h,t[c+3],t[c+4]):os(p,t,c,5),c+=5;break;case Hi:a=t[c+1],h=t[c+2],e?Zi(p,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):os(p,t,c,9),c+=9;break;case Ni:a=t[c+1],h=t[c+2],e?Zi(p,a,h,t[c+3],t[c+4],t[c+5]):os(p,t,c,6),c+=6;break;case Yi:$i(e?p:os(p,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,is),a=is.x,h=is.y,c+=9;break;case Xi:e?$i(p,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):os(p,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Vi:Ji(e?p:os(p,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,is),a=is.x,h=is.y,c+=7;break;case ji:e?Ji(p,t[c+1],t[c+2],t[c+3],0,360,!1):os(p,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Gi:qi(e?p:os(p,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,is),a=is.x,h=is.y,c+=6;break;default:return es.error(`command: ${n} [index:${c}]`,t),p}r=n}return p},objectToCanvasData(t){if(t[0].name.length>1)return vi.toCommand(t);{const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(xi,t.x,t.y);break;case"L":e.push(Ei,t.x,t.y);break;case"C":e.push(Pi,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Oi,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(Fi)}}),e}},copyData(t,e,i,s){for(let n=i,r=i+s;n<r;n++)t.push(e[n])},pushData(t,e){ns.index===ns.length&&(ns.index=1,t.push(ns.name)),t.push(Number(e)),ns.index++,ns.dot=0}},{current:ns,pushData:rs,copyData:os}=ss,{M:as,L:hs,C:ls,Q:ds,Z:cs,N:us,D:ps,X:gs,G:_s,F:fs,O:ms,P:ys,U:vs}=Ae,{getMinDistanceFrom:xs,getRadianFrom:ws}=at,{tan:Es,min:bs,abs:ks}=Math,Ts={},Ss={beginPath(t){t.length=0},moveTo(t,e,i){t.push(as,e,i)},lineTo(t,e,i){t.push(hs,e,i)},bezierCurveTo(t,e,i,s,n,r,o){t.push(ls,e,i,s,n,r,o)},quadraticCurveTo(t,e,i,s,n){t.push(ds,e,i,s,n)},closePath(t){t.push(cs)},rect(t,e,i,s,n){t.push(us,e,i,s,n)},roundRect(t,e,i,s,n,r){if(h(r))t.push(gs,e,i,s,n,r);else{const o=D.fourNumber(r);o?t.push(ps,e,i,s,n,...o):t.push(us,e,i,s,n)}},ellipse(t,e,i,s,n,o,a,h,l){if(s===n)return Ps(t,e,i,s,a,h,l);r(o)?t.push(fs,e,i,s,n):(r(a)&&(a=0),r(h)&&(h=360),t.push(_s,e,i,s,n,o,a,h,l?1:0))},arc(t,e,i,s,n,o,a){r(n)?t.push(ys,e,i,s):(r(n)&&(n=0),r(o)&&(o=360),t.push(ms,e,i,s,n,o,a?1:0))},arcTo(t,e,i,s,r,o,a,h,l){if(!n(a)){const t=xs(a,h,e,i,s,r)/(l?1:2);o=bs(o,bs(t,t*ks(Es(ws(a,h,e,i,s,r)/2))))}t.push(vs,e,i,s,r,o)},drawEllipse(t,e,i,s,n,o,a,h,l){li.ellipse(null,e,i,s,n,r(o)?0:o,r(a)?0:a,r(h)?360:h,l,null,null,Ts),t.push(as,Ts.x,Ts.y),Bs(t,e,i,s,n,o,a,h,l)},drawArc(t,e,i,s,n,o,a){li.arc(null,e,i,s,r(n)?0:n,r(o)?360:o,a,null,null,Ts),t.push(as,Ts.x,Ts.y),Ps(t,e,i,s,n,o,a)},drawPoints(t,e,i,s){li.points(t,e,i,s)}},{ellipse:Bs,arc:Ps}=Ss,{moveTo:Ls,lineTo:Rs,quadraticCurveTo:Cs,bezierCurveTo:Os,closePath:Ms,beginPath:Ds,rect:Is,roundRect:As,ellipse:Ws,arc:Fs,arcTo:zs,drawEllipse:Us,drawArc:Hs,drawPoints:Ns}=Ss;class Ys{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?o(t)?De.parse(t):t:[],this}beginPath(){return Ds(this.__path),this.paint(),this}moveTo(t,e){return Ls(this.__path,t,e),this.paint(),this}lineTo(t,e){return Rs(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,r){return Os(this.__path,t,e,i,s,n,r),this.paint(),this}quadraticCurveTo(t,e,i,s){return Cs(this.__path,t,e,i,s),this.paint(),this}closePath(){return Ms(this.__path),this.paint(),this}rect(t,e,i,s){return Is(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return As(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,r,o,a){return Ws(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}arc(t,e,i,s,n,r){return Fs(this.__path,t,e,i,s,n,r),this.paint(),this}arcTo(t,e,i,s,n){return zs(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,r,o,a){return Us(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}drawArc(t,e,i,s,n,r){return Hs(this.__path,t,e,i,s,n,r),this.paint(),this}drawPoints(t,e,i){return Ns(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:Xs,L:Vs,C:js,Q:Gs,Z:Ks,N:Zs,D:qs,X:Js,G:$s,F:Qs,O:tn,P:en,U:sn}=Ae,nn=ie.get("PathDrawer"),rn={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case Xs:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Vs:t.lineTo(e[s+1],e[s+2]),s+=3;break;case js:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case Gs:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Ks:t.closePath(),s+=1;break;case Zs:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case qs: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 Js:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case $s:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*A,e[s+6]*A,e[s+7]*A,e[s+8]),s+=9;break;case Qs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,W,!1),s+=5;break;case tn:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*A,e[s+5]*A,e[s+6]),s+=7;break;case en:t.arc(e[s+1],e[s+2],e[s+3],0,W,!1),s+=4;break;case sn:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void nn.error(`command: ${i} [index:${s}]`,e)}}},{M:on,L:an,C:hn,Q:ln,Z:dn,N:cn,D:un,X:pn,G:gn,F:_n,O:fn,P:mn,U:yn}=Ae,{toTwoPointBounds:vn,toTwoPointBoundsByQuadraticCurve:xn,arcTo:wn,arc:En,ellipse:bn}=li,{addPointBounds:kn,copy:Tn,addPoint:Sn,setPoint:Bn,addBounds:Pn,toBounds:Ln}=mt,Rn=ie.get("PathBounds");let Cn,On,Mn;const Dn={},In={},An={},Wn={toBounds(t,e){Wn.toTwoPointBounds(t,In),Ln(In,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Bn(e,0,0);let i,s,n,r,o,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(o=t[a],0===a&&(o===dn||o===hn||o===ln?Bn(e,h,l):Bn(e,t[a+1],t[a+2])),o){case on:case an:h=t[a+1],l=t[a+2],Sn(e,h,l),a+=3;break;case hn:n=t[a+5],r=t[a+6],vn(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,r,Dn),kn(e,Dn),h=n,l=r,a+=7;break;case ln:i=t[a+1],s=t[a+2],n=t[a+3],r=t[a+4],xn(h,l,i,s,n,r,Dn),kn(e,Dn),h=n,l=r,a+=5;break;case dn:a+=1;break;case cn:h=t[a+1],l=t[a+2],Pn(e,h,l,t[a+3],t[a+4]),a+=5;break;case un:case pn:h=t[a+1],l=t[a+2],Pn(e,h,l,t[a+3],t[a+4]),a+=o===un?9:6;break;case gn:bn(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],Dn,An),0===a?Tn(e,Dn):kn(e,Dn),h=An.x,l=An.y,a+=9;break;case _n:h=t[a+1],l=t[a+2],On=t[a+3],Mn=t[a+4],Pn(e,h-On,l-Mn,2*On,2*Mn),h+=On,a+=5;break;case fn:En(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Dn,An),0===a?Tn(e,Dn):kn(e,Dn),h=An.x,l=An.y,a+=7;break;case mn:h=t[a+1],l=t[a+2],Cn=t[a+3],Pn(e,h-Cn,l-Cn,2*Cn,2*Cn),h+=Cn,a+=4;break;case yn:wn(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Dn,An),0===a?Tn(e,Dn):kn(e,Dn),h=An.x,l=An.y,a+=6;break;default:return void Rn.error(`command: ${o} [index:${a}]`,t)}}},{M:Fn,L:zn,Z:Un}=Ae,{getCenterX:Hn,getCenterY:Nn}=at,{arcTo:Yn}=Ss,Xn={smooth(t,e,i){let s,n,r,o=0,a=0,h=0,l=0,c=0,u=0,p=0,g=0,_=0;d(e)&&(e=e[0]||0);const f=t.length,m=9===f,y=[];for(;o<f;){switch(s=t[o],s){case Fn:l=g=t[o+1],c=_=t[o+2],o+=3,t[o]===zn?(u=t[o+1],p=t[o+2],m?y.push(Fn,l,c):y.push(Fn,Hn(l,u),Nn(c,p))):y.push(Fn,l,c);break;case zn:switch(a=t[o+1],h=t[o+2],o+=3,t[o]){case zn:Yn(y,a,h,t[o+1],t[o+2],e,g,_,m);break;case Un:Yn(y,a,h,l,c,e,g,_,m);break;default:y.push(zn,a,h)}g=a,_=h;break;case Un:n!==Un&&(Yn(y,l,c,u,p,e,g,_,m),y.push(Un)),o+=1;break;default:r=Ne[s];for(let e=0;e<r;e++)y.push(t[o+e]);o+=r}n=s}return s!==Un&&(y[1]=l,y[2]=c),y}};function Vn(t){return new Ys(t)}const jn=Vn();De.creator=Vn(),De.parse=ss.parse,De.convertToCanvasData=ss.toCanvasData;const{drawRoundRect:Gn}=Ye;function Kn(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){Gn(this,t,e,i,s,n)})}(t)}const Zn={alphaPixelTypes:["png","webp","svg"],upperCaseTypeMap:{},mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]},isOpaqueImage(t){const e=qn.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{}}}},qn=Zn;qn.alphaPixelTypes.forEach(t=>qn.upperCaseTypeMap[t]=t.toUpperCase());const Jn=ie.get("TaskProcessor");class $n{constructor(t){this.parallel=!0,this.time=1,this.id=m.create(m.TASK),this.task=t}run(){return ve(this,void 0,void 0,function*(){try{if(this.isComplete||this.runing)return;if(this.runing=!0,this.canUse&&!this.canUse())return this.cancel();this.task&&(yield this.task())}catch(t){Jn.error(t)}})}complete(){this.isComplete=!0,this.parent=this.task=this.canUse=null}cancel(){this.isCancel=!0,this.complete()}}class Qn{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&&g.assign(this.config,t),this.empty()}add(t,e,i){let s,r,o,a;const l=new $n(t);return l.parent=this,h(e)?a=e:e&&(r=e.parallel,s=e.start,o=e.time,a=e.delay,i||(i=e.canUse)),o&&(l.time=o),!1===r&&(l.parallel=!1),i&&(l.canUse=i),n(a)?this.push(l,s):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(l,s))},a)),this.isComplete=!1,l}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.run()}),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++,t.isCancel?this.runTask():this.nextTask()}).catch(t=>{this.onError(t)}):this.timer=setTimeout(()=>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;const{config:e,list:i,index:s}=this;this.parallelList=[],this.parallelSuccessNumber=0;let n=s+e.parallel;if(n>i.length&&(n=i.length),e.parallel>1)for(let e=s;e<n&&(t=i[e],t.parallel);e++)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 tr=ie.get("Resource"),er={tasker:new Qn,map:{},get isComplete(){return ir.tasker.isComplete},set(t,e){ir.map[t]&&tr.repeat(t),ir.map[t]=e},get:t=>ir.map[t],remove(t){const e=ir.map[t];e&&(e.destroy&&e.destroy(),delete ir.map[t])},loadImage(t,e){return new Promise((i,s)=>{const n=this.setImage(t,t,e);n.load(()=>i(n),t=>s(t))})},setImage(t,e,i){let s;return o(e)?s={url:e}:e.url||(s={url:t,view:e}),s&&(i&&(s.format=i),e=de.image(s)),ir.set(t,e),e},destroy(){ir.map={}}},ir=er,sr={maxRecycled:10,recycledList:[],patternTasker:new Qn({parallel:1}),get(t){let e=er.get(t.url);return e||er.set(t.url,e=de.image(t)),e.use++,e},recycle(t){t.use--,setTimeout(()=>{t.use||(Qt.image.isLarge(t)?t.url&&er.remove(t.url):(t.clearLevels(),nr.recycledList.push(t)))})},recyclePaint(t){nr.recycle(t.image)},clearRecycled(t){const e=nr.recycledList;(e.length>nr.maxRecycled||t)&&(e.forEach(e=>(!e.use||t)&&e.url&&er.remove(e.url)),e.length=0)},clearLevels(){},hasAlphaPixel:t=>Zn.alphaPixelTypes.some(e=>nr.isFormat(e,t)),isFormat(t,e){if(e.format)return e.format===t;const{url:i}=e;if(i.startsWith("data:")){if(i.startsWith("data:"+Zn.mineType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+Zn.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){this.clearRecycled(!0)}},nr=sr,{IMAGE:rr,create:or}=m;class ar{get url(){return this.config.url}get crossOrigin(){const{crossOrigin:t}=this.config;return n(t)?Qt.image.crossOrigin:t}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=or(rr),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}sr.isFormat("svg",t)&&(this.isSVG=!0),sr.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(t,e,i){return this.loading||(this.loading=!0,er.tasker.add(()=>ve(this,void 0,void 0,function*(){return yield Qt.origin.loadImage(this.getLoadUrl(i),this.crossOrigin,this).then(t=>{i&&this.setThumbView(t),this.setView(t)}).catch(t=>{this.error=t,this.onComplete(!1)})}))),this.waitComplete.push(t,e),this.waitComplete.length-2}unload(t,e){const i=this.waitComplete;if(e){const e=i[t+1];e&&e({type:"stop"})}i[t]=i[t+1]=void 0}setView(t){this.ready=!0,this.width||(this.width=t.width,this.height=t.height,this.view=t),this.onComplete(!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}getFull(t){return this.view}getCanvas(t,e,i,s,n,r,o,a){if(t||(t=this.width),e||(e=this.height),this.cache){let{params:t,data:e}=this.cache;for(let i in t)if(t[i]!==arguments[i]){e=null;break}if(e)return e}const h=Qt.image.resize(this.view,t,e,n,r,void 0,o,i,s,a);return this.cache=this.use>1?{data:h,params:arguments}:null,h}getPattern(t,e,i,s){const n=Qt.canvas.createPattern(t,e);return Qt.image.setPatternTransform(n,i,s),n}getLoadUrl(t){return this.url}setThumbView(t){}getThumbSize(t){}getMinLevel(){}getLevelData(t,e,i){}clearLevels(t){}destroy(){this.clearLevels();const{view:t}=this;t&&t.close&&t.close(),this.config={url:""},this.cache=this.view=null,this.waitComplete.length=0}}function hr(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function lr(t,e){return Object.getOwnPropertyDescriptor(t,e)}function dr(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}function cr(t,e){return(i,s)=>pr(i,s,t,e&&e(s))}function ur(t){return t}function pr(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};hr(t,e,Object.assign(n,s||{})),Hr(t,e,i)}function gr(t){return cr(t)}function _r(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function fr(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function mr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),Er(this))}}))}function yr(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function vr(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function xr(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i,e)&&Er(this)}}))}function wr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(Er(this),this.__.__removeNaturalSize())}}))}function Er(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function br(t){return cr(t,t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),Er(this)}}))}const kr=xr;function Tr(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i)&&(Sr(this),e&&(this.__.__useStroke=!0))}}))}function Sr(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&Er(t)}const Br=Tr;function Pr(t){return cr(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Lr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function Rr(t){return cr(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;g.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip),this.__layout.surfaceChange()}}}))}function Cr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Mr(this)}}))}function Or(t){return cr(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Dr(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Dr(this,t,e,i),this.mask&&Mr(this)}}))}function Mr(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Dr(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||Er(t))}function Ir(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))}function Ar(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}function Wr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}function Fr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===ie.showBounds&&this.__layout.surfaceChange(),this.leafer&&this.leafer.updateCursor())}}))}function zr(t){return cr(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}function Ur(t){return(e,i)=>{hr(e,"__DataProcessor",{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),a=dr(e,i);if(n(i))a.get=function(){return this[r]};else if("function"==typeof i)a.get=function(){const t=this[r];return null==t?i(this.__leaf):t};else if(c(i)){const t=p(i);a.get=function(){const e=this[r];return null==e?this[r]=t?{}:g.clone(i):e}}const h=t.isBranchLeaf;"width"===e?a.get=function(){const t=this[r];if(null==t){const t=this,e=t.__naturalWidth,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.width:e?t._height&&t.__useNaturalRatio?t._height*e/t.__naturalHeight:e:h&&s.children.length?s.boxBounds.width:i}return t}:"height"===e&&(a.get=function(){const t=this[r];if(null==t){const t=this,e=t.__naturalHeight,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.height:e?t._width&&t.__useNaturalRatio?t._width*e/t.__naturalWidth:e:h&&s.children.length?s.boxBounds.height:i}return t});let l,d=s;for(;!l&&d;)l=lr(d,e),d=d.__proto__;l&&l.set&&(a.set=l.set),s[o]&&(a.set=s[o],delete s[o]),hr(s,e,a)}const Nr=new ie("rewrite"),Yr=[],Xr=["destroy","constructor"];function Vr(t){return(e,i)=>{Yr.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function jr(){return t=>{Gr()}}function Gr(t){Yr.length&&(Yr.forEach(e=>{t&&Nr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Yr.length=0)}function Kr(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{if(!(Xr.includes(s)||e&&e.includes(s)))if(t.prototype){lr(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]})}}function Zr(){return t=>{ue.register(t)}}function qr(){return t=>{_e.register(t)}}setTimeout(()=>Gr(!0));const{copy:Jr,toInnerPoint:$r,toOuterPoint:Qr,scaleOfOuter:to,rotateOfOuter:eo,skewOfOuter:io,multiplyParent:so,divideParent:no,getLayout:ro}=Z,oo={},{round:ao}=Math,ho={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),uo(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)co(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])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&po(t),t.__updateChange()},updateAllChange(t){if(_o(t),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},draggable:t=>(t.draggable||t.editable)&&t.hitSelf&&!t.locked,copyCanvasByWorld(t,e,i,s,n,r){s||(s=t.__nowWorld),t.__worldFlipped||Qt.fullImageShadow?e.copyWorldByReset(i,s,t.__nowWorld,n,r):e.copyWorldToInner(i,s,t.__layout.renderBounds,n)},moveWorld(t,e,i=0,s,n){const r=c(e)?Object.assign({},e):{x:e,y:i};s?Qr(t.localTransform,r,r,!0):t.parent&&$r(t.parent.scrollWorldTransform,r,r,!0),lo.moveLocal(t,r.x,r.y,n)},moveLocal(t,e,i=0,s){c(e)&&(i=e.y,e=e.x),e+=t.x,i+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=ao(e),i=ao(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,r){lo.zoomOfLocal(t,fo(t,e),i,s,n,r)},zoomOfLocal(t,e,i,s=i,n,r){const o=t.__localMatrix;if(h(s)||(s&&(r=s),s=i),Jr(oo,o),to(oo,e,i,s),lo.hasHighPosition(t))lo.setTransform(t,oo,n,r);else{const e=t.x+oo.e-o.e,a=t.y+oo.f-o.f;r&&!n?t.animate({x:e,y:a,scaleX:t.scaleX*i,scaleY:t.scaleY*s},r):(t.x=e,t.y=a,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){lo.rotateOfLocal(t,fo(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;Jr(oo,n),eo(oo,e,i),lo.hasHighPosition(t)?lo.setTransform(t,oo,!1,s):t.set({x:t.x+oo.e-n.e,y:t.y+oo.f-n.f,rotation:D.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,r){lo.skewOfLocal(t,fo(t,e),i,s,n,r)},skewOfLocal(t,e,i,s=0,n,r){Jr(oo,t.__localMatrix),io(oo,e,i,s),lo.setTransform(t,oo,n,r)},transformWorld(t,e,i,s){Jr(oo,t.worldTransform),so(oo,e),t.parent&&no(oo,t.parent.scrollWorldTransform),lo.setTransform(t,oo,i,s)},transform(t,e,i,s){Jr(oo,t.localTransform),so(oo,e),lo.setTransform(t,oo,i,s)},setTransform(t,e,i,s){const n=t.__,r=n.origin&&lo.getInnerOrigin(t,n.origin),o=ro(e,r,n.around&&lo.getInnerOrigin(t,n.around));if(lo.hasOffset(t)&&(o.x-=n.offsetX,o.y-=n.offsetY),i){const e=o.scaleX/t.scaleX,i=o.scaleY/t.scaleY;if(delete o.scaleX,delete o.scaleY,r){Nt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=lo.getInnerOrigin(t,n.origin);at.move(o,r.x-s.x,r.y-s.y)}t.set(o),t.scaleResize(e,i,!1)}else t.set(o,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return to(i,lo.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>at.tempToOuterOf(lo.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return Et.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(Jr(oo,t.worldTransform),no(oo,e.scrollWorldTransform),i?oo:Object.assign({},oo)),drop(t,e,i,s){t.setTransform(lo.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||lo.hasOffset(t),hasOffset:t=>t.offsetX||t.offsetY,hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}},animateMove(t,e,i=.3){if(e.x||e.y)if(Math.abs(e.x)<1&&Math.abs(e.y)<1)t.move(e);else{const s=e.x*i,n=e.y*i;e.x-=s,e.y-=n,t.move(s,n),Qt.requestRender(()=>lo.animateMove(t,e,i))}}},lo=ho,{updateAllMatrix:co,updateMatrix:uo,updateAllWorldOpacity:po,updateAllChange:go,updateChange:_o}=lo;function fo(t,e){return t.updateLayout(),t.parent?at.tempToInnerOf(e,t.parent.scrollWorldTransform):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,e)=>vo(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>vo(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>vo(t,e)&&t.__layout.localRenderBounds,excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))};let yo;function vo(t,e){return e||(yo=0),t.__.mask&&(yo=1),yo<0?null:(yo&&(yo=-1),!0)}const{updateBounds:xo}=ho,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,n=i.length;s<n;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),Eo(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&n(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),ko(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++)xo(s[t]);e&&e===i||xo(i)}},move(t,e,i){let s;const{children:n}=t;for(let r=0,o=n.length;r<o;r++)s=(t=n[r]).__world,s.e+=e,s.f+=i,s.x+=e,s.y+=i,t.isBranch&&To(t,e,i)},scale(t,e,i,s,n,r,o){let a;const{children:h}=t,l=s-1,d=n-1;for(let c=0,u=h.length;c<u;c++)a=(t=h[c]).__world,a.a*=s,a.d*=n,(a.b||a.c)&&(a.b*=s,a.c*=n),a.e===a.x&&a.f===a.y?(a.x=a.e+=(a.e-r)*l+e,a.y=a.f+=(a.f-o)*d+i):(a.e+=(a.e-r)*l+e,a.f+=(a.f-o)*d+i,a.x+=(a.x-r)*l+e,a.y+=(a.y-o)*d+i),a.width*=s,a.height*=n,a.scaleX*=s,a.scaleY*=n,t.isBranch&&So(t,e,i,s,n,r,o)}},{pushAllChildBranch:Eo,pushAllBranchStack:bo,updateBoundsByBranchStack:ko,move:To,scale:So}=wo,Bo={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:Po,updateBounds:Lo}=ho,{toOuterOf:Ro,getPoints:Co,copy:Oo}=Nt,Mo="_localContentBounds",Do="_worldContentBounds",Io="_worldBoxBounds",Ao="_worldStrokeBounds";class Wo{get contentBounds(){return this._contentBounds||this.boxBounds}set contentBounds(t){this._contentBounds=t}get strokeBounds(){return this._strokeBounds||this.boxBounds}get renderBounds(){return this._renderBounds||this.boxBounds}set renderBounds(t){this._renderBounds=t}get localContentBounds(){return Ro(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 Ro(this.contentBounds,this.leaf.__world,this[Do]||(this[Do]={})),this[Do]}get worldBoxBounds(){return Ro(this.boxBounds,this.leaf.__world,this[Io]||(this[Io]={})),this[Io]}get worldStrokeBounds(){return Ro(this.strokeBounds,this.leaf.__world,this[Ao]||(this[Ao]={})),this[Ao]}get a(){return 1}get b(){return 0}get c(){return 0}get d(){return 1}get e(){return this.leaf.__.x}get f(){return this.leaf.__.y}get x(){return this.e+this.boxBounds.x}get y(){return this.f+this.boxBounds.y}get width(){return this.boxBounds.width}get height(){return this.boxBounds.height}constructor(t){this.leaf=t,this.leaf.__local&&(this._localRenderBounds=this._localStrokeBounds=this.leaf.__local),t.__world&&(this.boxBounds={x:0,y:0,width:0,height:0},this.boxChange(),this.matrixChange())}createLocal(){const t=this.leaf.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0};this._localStrokeBounds||(this._localStrokeBounds=t),this._localRenderBounds||(this._localRenderBounds=t)}update(){const{leaf:t}=this,{leafer:e}=t;if(t.isApp)return Lo(t);if(e)e.ready?e.watcher.changed&&e.layouter.layout():e.start();else{let e=t;for(;e.parent&&!e.parent.leafer;)e=e.parent;const i=e;if(i.__fullLayouting)return;i.__fullLayouting=!0,Qt.layout(i),delete i.__fullLayouting}}getTransform(t="world"){this.update();const{leaf:e}=this;switch(t){case"world":return e.__world;case"local":return e.__localMatrix;case"inner":return Z.defaultMatrix;case"page":t=e.zoomLayer;default:return Po(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 jt(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,r,o,a=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(a),r=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;o={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},n=s.getLocalPointByInner(a);break;case"inner":n=a,r=Z.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),r=Po(s,e,!0)}if(o||(o=Z.getLayout(r)),Oo(o,a),at.copy(o,n),i){const{scaleX:t,scaleY:e}=o,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(o.scaleX/=i,o.scaleY/=s,o.width*=i,o.height*=s)}return o}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=Co(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 n(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.boundsChanged||(this.boundsChanged=!0):this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChange(),this.leaf.__local||this.createLocal()}matrixChange(){this.matrixChanged=!0,this.localBoxChanged?this.boundsChanged||(this.boundsChanged=!0):this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=this.affectChildrenSort=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class Fo{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&Qt.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&Qt.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&Qt.event.stop(this.origin)}}class zo extends Fo{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";const Uo="property.scroll";class Ho extends Fo{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Ho.CHANGE="property.change",Ho.LEAFER_CHANGE="property.leafer_change",Ho.SCROLL=Uo;const No={scrollX:Uo,scrollY:Uo};class Yo extends Fo{constructor(t,e){super(t),Object.assign(this,e)}}Yo.LOAD="image.load",Yo.LOADED="image.loaded",Yo.ERROR="image.error";class Xo extends Fo{static checkHas(t,e,i){"on"===i?e===Ko?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Vo)||t.hasEvent(jo)||t.hasEvent(Go),t.__hasWorldEvent=t.hasEvent(Ko))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Vo,t),"inner"===e&&t.emit(jo,t)),t.emit(Go,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Ko,this)}}Xo.RESIZE="bounds.resize",Xo.INNER="bounds.inner",Xo.LOCAL="bounds.local",Xo.WORLD="bounds.world";const{RESIZE:Vo,INNER:jo,LOCAL:Go,WORLD:Ko}=Xo,Zo={};[Vo,jo,Go,Ko].forEach(t=>Zo[t]=1);class qo extends Fo{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){c(t)?(super(qo.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!n(this.resizingKeys[t.innerId])}}qo.RESIZE="resize";class Jo extends Fo{constructor(t,e){super(t),this.data=e}}Jo.REQUEST="watch.request",Jo.DATA="watch.data";class $o extends Fo{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}$o.REQUEST="layout.request",$o.START="layout.start",$o.BEFORE="layout.before",$o.LAYOUT="layout",$o.AFTER="layout.after",$o.AGAIN="layout.again",$o.END="layout.end";class Qo extends Fo{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Qo.REQUEST="render.request",Qo.CHILD_START="render.child_start",Qo.CHILD_END="render.child_end",Qo.START="render.start",Qo.BEFORE="render.before",Qo.RENDER="render",Qo.AFTER="render.after",Qo.AGAIN="render.again",Qo.END="render.end",Qo.NEXT="render.next";class ta extends Fo{}ta.START="leafer.start",ta.BEFORE_READY="leafer.before_ready",ta.READY="leafer.ready",ta.AFTER_READY="leafer.after_ready",ta.VIEW_READY="leafer.view_ready",ta.VIEW_COMPLETED="leafer.view_completed",ta.STOP="leafer.stop",ta.RESTART="leafer.restart",ta.END="leafer.end",ta.UPDATE_MODE="leafer.update_mode",ta.TRANSFORM="leafer.transform",ta.MOVE="leafer.move",ta.SCALE="leafer.scale",ta.ROTATE="leafer.rotate",ta.SKEW="leafer.skew";const{MOVE:ea,SCALE:ia,ROTATE:sa,SKEW:na}=ta,ra={x:ea,y:ea,scaleX:ia,scaleY:ia,rotation:sa,skewX:na,skewY:na},oa={};class aa{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(d(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)d(e=t[i])?this.on(i,e[0],e[1]):this.on(i,e);return}let s,n,r;i&&("once"===i?n=!0:"boolean"==typeof i?s=i:(s=i.capture,n=i.once));const a=ha(this,s,!0),h=o(t)?t.split(" "):t,l=n?{listener:e,once:n}:{listener:e};h.forEach(t=>{t&&(r=a[t],r?-1===r.findIndex(t=>t.listener===e)&&r.push(l):a[t]=[l],Zo[t]&&Xo.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=o(t)?t.split(" "):t;if(e){let t,n,r;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const o=ha(this,t);s.forEach(t=>{t&&(n=o[t],n&&(r=n.findIndex(t=>t.listener===e),r>-1&&n.splice(r,1),n.length||delete o[t],Zo[t]&&Xo.checkHas(this,t,"off")))})}else{const{__bubbleMap:t,__captureMap:e}=this;s.forEach(i=>{t&&delete t[i],e&&delete e[i]})}}else this.__bubbleMap=this.__captureMap=void 0}on_(t,e,i,s){return e?this.on(t,i?e=e.bind(i):e,s):d(t)&&t.forEach(t=>this.on(t[0],t[2]?t[1]=t[1].bind(t[2]):t[1],t[3])),{type:t,current:this,listener:e,options:s}}off_(t){if(!t)return;const e=d(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):d(t.type)&&t.type.forEach(e=>t.current.off(e[0],e[1],e[3])))}),e.length=0}once(t,e,i,s){if(!e)return d(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));c(i)?e=e.bind(i):s=i,this.on(t,e,{once:!0,capture:s})}emit(t,e,i){!e&&_e.has(t)&&(e=_e.get(t,{type:t,target:this,current:this}));const s=ha(this,i)[t];if(s){let n;for(let r=0,o=s.length;r<o&&!((n=s[r])&&(n.listener(e),n.once&&(this.off(t,n.listener,i),r--,o--),e&&e.isStopNow));r++);}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!!(n(e)?r||o:e?o:r)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function ha(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:oa)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:oa)}}const{on:la,on_:da,off:ca,off_:ua,once:pa,emit:ga,emitEvent:_a,hasEvent:fa,destroy:ma}=aa.prototype,ya={on:la,on_:da,off:ca,off_:ua,once:pa,emit:ga,emitEvent:_a,hasEvent:fa,destroyEventer:ma},va=ie.get("setAttr"),xa={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(!i||a(e)||n(e)||(va.warn(this.innerName,t,e),e=void 0),c(e)||s!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Ho(Ho.LEAFER_CHANGE,this,t,s,e));const i=ra[t];i&&(this.emitEvent(new ta(i,this)),this.emitEvent(new ta(ta.TRANSFORM,this)))}this.emitPropertyEvent(Ho.CHANGE,t,s,e);const i=No[t];return i&&this.emitPropertyEvent(i,t,s,e),!0}return!1}return this.__realSetAttr(t,e),!0},emitPropertyEvent(t,e,i,s){const n=new Ho(t,this,e,i,s);this.isLeafer||this.hasEvent(t)&&this.emitEvent(n),this.leafer.emitEvent(n)},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||n(i.normalStyle[t])||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:wa,multiplyParent:Ea,translateInner:ba,defaultWorld:ka}=Z,{toPoint:Ta,tempPoint:Sa}=Et,Ba={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:n}=this;Ea(this.__local||e,t?t.__scrollWorld||t.__world:ka,i,!!e.affectScaleOrRotation,n),s&&ba(Object.assign(s,i),n.scrollX,n.scrollY)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged&&(t.resized||(t.resized="scale"))||t.rotationChanged)&&(wa(e,i,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=void 0),e.e=i.x+i.offsetX,e.f=i.y+i.offsetY,(i.around||i.origin)&&(Ta(i.around||i.origin,t.boxBounds,Sa),ba(e,-Sa.x,-Sa.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:Pa,updateAllMatrix:La}=ho,{updateBounds:Ra}=wo,{toOuterOf:Ca,copyAndSpread:Oa,copy:Ma}=Nt,{toBounds:Da}=Wn,Ia={__updateWorldBounds(){const{__layout:t,__world:e}=this;Ca(t.renderBounds,e,e),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Xo.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Xo.emitWorld(this)},__updateLocalBounds(){const t=this.__layout;t.boxChanged&&(this.__.__pathInputed||this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),t.resized="inner"),t.localBoxChanged&&(this.__local&&this.__updateLocalBoxBounds(),t.localBoxChanged=void 0,t.strokeSpread&&(t.strokeChanged=!0),t.renderSpread&&(t.renderChanged=!0),this.parent&&this.parent.__layout.boxChange()),t.boxChanged=void 0,t.strokeChanged&&(t.strokeSpread=this.__updateStrokeSpread(),t.strokeSpread?(t.strokeBounds===t.boxBounds&&t.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):t.spreadStrokeCancel(),t.strokeChanged=void 0,(t.renderSpread||t.strokeSpread!==t.strokeBoxSpread)&&(t.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),t.resized="inner"),t.renderChanged&&(t.renderSpread=this.__updateRenderSpread(),t.renderSpread?(t.renderBounds!==t.boxBounds&&t.renderBounds!==t.strokeBounds||t.spreadRender(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):t.spreadRenderCancel(),t.renderChanged=void 0,this.parent&&this.parent.__layout.renderChange()),t.resized||(t.resized="local"),t.boundsChanged=void 0},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),Ca(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Ca(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Ca(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?Da(s.path,i):(i.x=0,i.y=0,i.width=s.width,i.height=s.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.__extraUpdate(),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),La(this),Ra(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(La(this),Ra(this,this))):Pa(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;Oa(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;h(i)&&i<=0?Ma(e.renderBounds,e.strokeBounds):Oa(e.renderBounds,e.boxBounds,i)}},Aa={__render(t,e){if(e.shape)return this.__renderShape(t,e);if((!e.cellList||e.cellList.has(this))&&this.__worldOpacity){const i=this.__;if(i.bright&&!e.topRendering)return e.topList.add(this);if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=e.dimOpacity&&!i.dimskip?i.opacity*e.dimOpacity:i.opacity,this.__.__single){if("path"===i.eraser)return this.__renderEraser(t,e);const s=t.getSameCanvas(!0,!0);this.__draw(s,e,t),ho.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);ie.showBounds&&ie.drawBounds(this,t,e)}},__renderShape(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawShape(t,e))},__clip(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawRenderPath(t),t.clipUI(this))},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{excludeRenderBounds:Wa}=mo,{hasSize:Fa}=Nt,za={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){const i=this.__nowWorld=this.__getNowWorld(e);if(this.__worldOpacity&&Fa(i)){const s=this.__;if(s.__useDim)if(s.dim)e.dimOpacity=!0===s.dim?.2:s.dim;else{if(s.bright&&!e.topRendering)return e.topList.add(this);s.dimskip&&e.dimOpacity&&(e.dimOpacity=0)}if(s.__single&&!this.isBranchLeaf){if("path"===s.eraser)return this.__renderEraser(t,e);const n=t.getSameCanvas(!1,!0);this.__renderBranch(n,e),t.opacity=e.dimOpacity?s.opacity*e.dimOpacity:s.opacity,t.copyWorldByReset(n,i,i,s.__blendMode,!0),n.recycle(i)}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++)Wa(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++)Wa(i[s],e)||i[s].__clip(t,e)}}},Ua={},{LEAF:Ha,create:Na}=m,{stintSet:Ya}=g,{toInnerPoint:Xa,toOuterPoint:Va,multiplyParent:ja}=Z,{toOuterOf:Ga}=Nt,{copy:Ka,move:Za}=at,{moveLocal:qa,zoomOfLocal:Ja,rotateOfLocal:$a,skewOfLocal:Qa,moveWorld:th,zoomOfWorld:eh,rotateOfWorld:ih,skewOfWorld:sh,transform:nh,transformWorld:rh,setTransform:oh,getFlipTransform:ah,getLocalOrigin:hh,getRelativeWorld:lh,drop:dh}=ho;t.Leaf=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 f}get __LayoutProcessor(){return Wo}get leaferIsCreated(){return this.leafer&&this.leafer.created}get leaferIsReady(){return this.leafer&&this.leafer.ready}get isLeafer(){return!1}get isBranch(){return!1}get isBranchLeaf(){return!1}get __localMatrix(){return this.__local||this.__layout}get __localBoxBounds(){return this.__local||this.__layout}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get scrollWorldTransform(){return this.updateLayout(),this.__scrollWorld||this.__world}get boxBounds(){return this.getBounds("box","inner")}get renderBounds(){return this.getBounds("render","inner")}get worldBoxBounds(){return this.getBounds("box")}get worldStrokeBounds(){return this.getBounds("stroke")}get worldRenderBounds(){return this.getBounds("render")}get worldOpacity(){return this.updateLayout(),this.__worldOpacity}get __worldFlipped(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}get __inLazyBounds(){return this.leaferIsCreated&&this.leafer.lazyBounds.hit(this.__world)}get pathInputed(){return this.__.__pathInputed}set event(t){this.on(t)}constructor(t){this.innerId=Na(Ha),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(zo.CREATED)}reset(t){this.leafer&&this.leafer.forceRender(this.__world),0!==t&&(this.__world={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0,scaleX:1,scaleY:1},null!==t&&(this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0})),this.__worldOpacity=1,this.__=new this.__DataProcessor(this),this.__layout=new this.__LayoutProcessor(this),this.__level&&this.resetCustom(),t&&(t.__&&(t=t.toJSON()),t.children?this.set(t):Object.assign(this,t))}resetCustom(){this.__hasMask=this.__hasEraser=null,this.forceUpdate()}waitParent(t,e){e&&(t=t.bind(e)),this.parent?t():this.on(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){n(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=n(e)?null:void 0,this[t]=e}forceRender(t,e){this.forceUpdate("surface")}__extraUpdate(){this.leaferIsReady&&this.leafer.layouter.addExtra(this)}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(t,e){}__updateContentBounds(){}__updateStrokeBounds(t){}__updateRenderBounds(t){}__updateAutoLayout(){}__updateFlowLayout(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){this.__hasEraser=!!t||this.children.some(t=>t.__.eraser)}__renderEraser(t,e){t.save(),this.__clip(t,e);const{renderBounds:i}=this.__layout;t.clearRect(i.x,i.y,i.width,i.height),t.restore()}__updateMask(t){this.__hasMask=this.children.some(t=>t.__.mask&&t.__.visible&&t.__.opacity)}__renderMask(t,e){}__getNowWorld(t){if(t.matrix){this.__cameraWorld||(this.__cameraWorld={});const e=this.__cameraWorld,i=this.__world;return ja(i,t.matrix,e,void 0,i),Ga(this.__layout.renderBounds,e,e),Ya(e,"half",i.half),Ya(e,"ignorePixelSnap",i.ignorePixelSnap),e}return this.__world}getClampRenderScale(){let{scaleX:t}=this.__nowWorld||this.__world;return t<0&&(t=-t),t>1?t:1}getRenderScaleData(t,e){let{scaleX:i,scaleY:s}=sr.patternLocked?this.__world:this.__nowWorld;return t&&(i<0&&(i=-i),s<0&&(s=-s)),(!0===e||"zoom-in"===e&&i>1&&s>1)&&(i=s=1),Ua.scaleX=i,Ua.scaleY=s,Ua}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?lh(this,e):this.worldTransform,n=i?t:{};return Ga(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&Ka(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&Ka(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Xa(this.scrollWorldTransform,t,e,i)}innerToWorld(t,e,i,s){Va(this.scrollWorldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getBoxPoint(t,e,i,s){return this.getBoxPointByInner(this.getInnerPoint(t,e,i,s),null,null,!0)}getBoxPointByInner(t,e,i,s){const n=s?t:Object.assign({},t),{x:r,y:o}=this.boxBounds;return Za(n,-r,-o),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:r,y:o}=this.boxBounds;return Za(n,r,o),n}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const n=s?t:{};return this.worldToLocal(t,n,i,e),n}getLocalPointByInner(t,e,i,s){return this.getWorldPoint(t,this.parent,i,s)}getPagePoint(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,i,s)}getWorldPoint(t,e,i,s){const n=s?t:{};return this.innerToWorld(t,n,i,e),n}getWorldPointByBox(t,e,i,s){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,s),e,i,!0)}getWorldPointByLocal(t,e,i,s){const n=s?t:{};return this.localToWorld(t,n,i,e),n}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e,i){oh(this,t,e,i)}transform(t,e,i){nh(this,t,e,i)}move(t,e,i){qa(this,t,e,i)}moveInner(t,e,i){th(this,t,e,!0,i)}scaleOf(t,e,i,s,n){Ja(this,hh(this,t),e,i,s,n)}rotateOf(t,e,i){$a(this,hh(this,t),e,i)}skewOf(t,e,i,s,n){Qa(this,hh(this,t),e,i,s,n)}transformWorld(t,e,i){rh(this,t,e,i)}moveWorld(t,e,i){th(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){eh(this,t,e,i,s,n)}rotateOfWorld(t,e){ih(this,t,e)}skewOfWorld(t,e,i,s,n){sh(this,t,e,i,s,n)}flip(t,e){nh(this,ah(this,t),!1,e)}scaleResize(t,e=t,i){this.scaleX*=t,this.scaleY*=e}__scaleResize(t,e){}resizeWidth(t){}resizeHeight(t){}hit(t,e){return!0}__hitWorld(t,e){return!0}__hit(t,e){return!0}__hitFill(t){return!0}__hitStroke(t,e){return!0}__hitPixel(t){return!0}__drawHitPath(t){}__updateHitCanvas(){}__render(t,e){}__drawFast(t,e){}__draw(t,e,i){}__clip(t,e){}__renderShape(t,e){}__drawShape(t,e){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return le.need("path")}getMotionPoint(t){return le.need("path")}getMotionTotal(){return 0}__updateMotionPath(){}__runAnimation(t,e){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}dropTo(t,e,i){dh(this,t,e,i)}on(t,e,i){}off(t,e,i){}on_(t,e,i,s){}off_(t){}once(t,e,i,s){}emit(t,e,i){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,i){i?this.addAttr(t,e,i):Hr(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=xr),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new zo(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(zo.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}},t.Leaf=ye([Kr(xa),Kr(Ba),Kr(Ia),Kr(ya),Kr(Aa)],t.Leaf);const{setListWithFn:ch}=Nt,{sort:uh}=wo,{localBoxBounds:ph,localStrokeBounds:gh,localRenderBounds:_h,maskLocalBoxBounds:fh,maskLocalStrokeBounds:mh,maskLocalRenderBounds:yh}=mo,vh=new ie("Branch");t.Branch=class extends t.Leaf{__updateStrokeSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(t,e){ch(e||this.__layout.boxBounds,this.children,this.__hasMask?fh:ph)}__updateStrokeBounds(t){ch(t||this.__layout.strokeBounds,this.children,this.__hasMask?mh:gh)}__updateRenderBounds(t){ch(t||this.__layout.renderBounds,this.children,this.__hasMask?yh:_h)}__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(uh),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return vh.warn("add self or destroyed");const i=n(e);if(!t.__){if(d(t))return t.forEach(t=>{this.add(t,e),i||e++});t=ue.get(t.tag,t)}t.parent&&t.parent.remove(t),t.parent=this,i?this.children.push(t):this.children.splice(e,0,t),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1);const s=t.__layout;s.boxChanged||s.boxChange(),s.matrixChanged||s.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(zo.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(zo.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}addMany(...t){this.add(t)}remove(t,e){t?t.__?t.animationOut?t.__runAnimation("out",()=>this.__remove(t,e)):this.__remove(t,e):this.find(t).forEach(t=>this.remove(t,e)):n(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)}},t.Branch=ye([Kr(za)],t.Branch);class xh{get length(){return this.list.length}constructor(t){this.reset(),t&&(d(t)?this.addList(t):this.add(t))}has(t){return t&&!n(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return n(e)?-1:e}add(t){const{list:e,keys:i}=this;n(i[t.innerId])&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(n(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,r=e.length;s<r;s++)n(i)?e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]):this.keys[e[s].innerId]=s-1;n(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 xh;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 wh{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(d(t)?this.addList(t):this.add(t))}has(t){return!n(this.keys[t.innerId])}without(t){return n(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}}class Eh extends Me{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=Qt.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}Kn(OffscreenCanvasRenderingContext2D.prototype),Kn(Path2D.prototype);const{mineType:bh}=Zn;function kh(t,e){Qt.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:bh(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:bh(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((e,i)=>{let s=new XMLHttpRequest;s.open("GET",Qt.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then(t=>{e(t)}).catch(t=>{i(t)})},s.onerror=t=>i(t),s.send()})},Qt.canvas=de.canvas(),Qt.conicGradientSupport=!!Qt.canvas.context.createConicGradient}Object.assign(de,{canvas:(t,e)=>new Eh(t,e),image:t=>new ar(t)}),Qt.name="web",Qt.isWorker=!0,Qt.backgrounder=!0,Qt.requestRender=function(t){requestAnimationFrame(t)},hr(Qt,"devicePixelRatio",{get:()=>1});const{userAgent:Th}=navigator;Th.indexOf("Firefox")>-1?(Qt.conicGradientRotate90=!0,Qt.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(Qt.fullImageShadow=!0),Th.indexOf("Windows")>-1?(Qt.os="Windows",Qt.intWheelDeltaY=!0):Th.indexOf("Mac")>-1?Qt.os="Mac":Th.indexOf("Linux")>-1&&(Qt.os="Linux");class Sh{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new xh;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 xh,this.target=t,e&&(this.config=g.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(Qo.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(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 Jo(Jo.DATA,{updatedList:this.updatedList})),this.__updatedList=new xh,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Ho.CHANGE,this.__onAttrChange,this],[[zo.ADD,zo.REMOVE],this.__onChildEvent,this],[Jo.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:Bh,updateBounds:Ph,updateChange:Lh}=ho,{pushAllChildBranch:Rh,pushAllParent:Ch}=wo;const{worldBounds:Oh}=mo;class Mh{constructor(t){this.updatedBounds=new jt,this.beforeBounds=new jt,this.afterBounds=new jt,d(t)&&(t=new xh(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Oh)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Oh),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:Dh,updateAllChange:Ih}=ho,Ah=ie.get("Layouter");class Wh{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new wh,this.target=t,e&&(this.config=g.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit($o.START),this.layoutOnce(),t.emitEvent(new $o($o.END,this.layoutedBlocks,this.times))}catch(t){Ah.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Ah.warn("layouting"):this.times>3?Ah.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Jo.REQUEST),this.totalTimes>1&&this.config.usePartLayout?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=oe.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:r,AFTER:o}=$o,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new $o(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?(Bh(t,!0),e.add(t),t.isBranch&&Rh(t,e),Ch(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Ch(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||Ph(s[t])}Ph(i)}})}(this.__levelList),function(t){t.list.forEach(Lh)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new $o(r,a,this.times)),i.emitEvent(new $o(o,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,oe.end(e)}fullLayout(){const t=oe.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=$o,r=this.getBlocks(new xh(e));e.emitEvent(new $o(i,r,this.times)),Wh.fullLayout(e),r.forEach(t=>{t.setAfter()}),e.emitEvent(new $o(s,r,this.times)),e.emitEvent(new $o(n,r,this.times)),this.addBlocks(r),oe.end(t)}static fullLayout(t){Dh(t,!0),t.isBranch?wo.updateBounds(t):ho.updateBounds(t),Ih(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Mh([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Mh(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[$o.REQUEST,this.layout,this],[$o.AGAIN,this.layoutAgain,this],[Jo.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Fh=ie.get("Renderer");class zh{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,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=g.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit($o.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(Qo.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(Qo.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(Qo.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new jt,Fh.log(e.innerName,"---\x3e");try{this.emitRender(Qo.START),this.renderOnce(t),this.emitRender(Qo.END,this.totalBounds),sr.clearRecycled()}catch(t){this.rendering=!1,Fh.error(t)}Fh.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Fh.warn("rendering");if(this.times>3)return Fh.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new jt,this.renderOptions={},t)this.emitRender(Qo.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Qo.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Qo.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Qo.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=oe.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new jt(s);i.save(),s.spread(zh.clipSpread).ceil();const{ceilPartPixel:r}=this.config;i.clipWorld(s,r),i.clearWorld(s,r),this.__render(s,n),i.restore(),oe.end(e)}fullRender(){const t=oe.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),oe.end(t)}__render(t,e){const{canvas:i,target:s}=this,n=t.includes(s.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),ie.showRepaint&&ie.drawRepaint(i,t),this.config.useCellRender&&(r.cellList=this.getCellList()),Qt.render(s,i,r),this.renderBounds=e=e||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}getCellList(){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new jt;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&t>i)return Qt.requestRender(e);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};Qt.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new jt(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 jt(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Fh.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 Qo(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[Qo.REQUEST,this.update,this],[$o.END,this.__onLayoutEnd,this],[Qo.AGAIN,this.renderAgain,this],[qo.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}zh.clipSpread=10;const Uh={},{copyRadiusPoint:Hh}=at,{hitRadiusPoint:Nh}=Nt;class Yh{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,r=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new xh(i.findList),i.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:o}=this.findList,a=this.getBestMatchLeaf(o,i.bottomList,n,!!i.findList),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:o.length?this.getThroughPath(o):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const n=this.findList=new xh;if(t.length){let e;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||ho.worldHittable(e))&&(this.hitChild(e,o),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&ho.hasParent(t,e))){n.reset();break}return n.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),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>ho.worldHittable(t))}getPath(t){const e=new xh,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new xh;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new xh,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,r;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(r=s.list[t],!n||!n.has(r));t++)e.add(r)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s,n;const{point:r}=this;for(let o=t.length-1;o>-1;o--)if(i=t[o],n=i.__,n.visible&&(!e||n.mask))if(s=Nh(i.__world,n.hitRadius?Hh(Uh,r,n.hitRadius):r),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&n.__clipAfterFill&&!i.__hitWorld(r,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,r)}}else 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){let i,n=[];const{children:r}=s;for(let s=0,o=r.length;s<o;s++)if(i=r[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Xh{constructor(t,e){this.config={},e&&(this.config=g.default(e,this.config)),this.picker=new Yh(this.target=t,this),this.finder=de.finder&&de.finder()}getByPoint(t,e,i){const{target:s,picker:n}=this;return Qt.backgrounder&&s&&s.updateLayout(),n.getByPoint(t,e,i)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):le.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Vh(t){return cr(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}}))}function jh(t){return cr(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}function Gh(){return(t,e)=>{const i="_"+e;hr(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(de,{watcher:(t,e)=>new Sh(t,e),layouter:(t,e)=>new Wh(t,e),renderer:(t,e,i)=>new zh(t,e,i),selector:(t,e)=>new Xh(t,e)}),Qt.layout=Wh.fullLayout,Qt.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new xh,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const Kh={},Zh={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},qh=Zt,Jh={},$h={},Qh={},tl={},el={},il={apply(){le.need("filter")}},sl={},nl={setStyleName:()=>le.need("state"),set:()=>le.need("state")},rl={list:{},register(t,e){rl.list[t]=e},get:t=>rl.list[t]},{parse:ol,objectToCanvasData:al}=ss,{stintSet:hl}=g,{hasTransparent:ll}=Zh,dl={originPaint:{}},cl=ie.get("UIData");class ul extends f{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){return this.__getRealStrokeWidth()}get __maxStrokeWidth(){const t=this;return t.__hasMultiStrokeStyle?Math.max(t.__hasMultiStrokeStyle,t.strokeWidth):t.strokeWidth}get __hasMultiPaint(){const t=this;return t.fill&&this.__useStroke||t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return null==this._width}get __autoHeight(){return null==this._height}get __autoSide(){return null==this._width||null==this._height}get __autoSize(){return null==this._width&&null==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,cl.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,cl.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),o(t)||!t?(hl(this,"__isTransparentFill",ll(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):c(t)&&this.__setPaint("fill",t)}setStroke(t){o(t)||!t?(hl(this,"__isTransparentStroke",ll(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):c(t)&&this.__setPaint("stroke",t)}setPath(t){const e=o(t);e||t&&c(t[0])?(this.__setInput("path",t),this._path=e?ol(t):al(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){pl(this,"shadow",t)}setInnerShadow(t){pl(this,"innerShadow",t)}setFilter(t){pl(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&$h.compute("fill",this.__leaf),e&&$h.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeWidthFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),n(t.strokeWidthFixed)||(i=t.strokeWidthFixed)),i){const t=this.__leaf.getClampRenderScale();return t>1?e/t:e}return e}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),d(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=dl)):(this.__isStrokes=!0,this._stroke||(this._stroke=dl))}__removePaint(t,e){e&&this.__removeInput(t),Qh.recycleImage(t,this),"fill"===t?(hl(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(hl(this,"__isAlphaPixelStroke",void 0),hl(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function pl(t,e,i){t.__setInput(e,i),d(i)?(i.some(t=>!1===t.visible)&&(i=i.filter(t=>!1!==t.visible)),i.length||(i=void 0)):i=i&&!1!==i.visible?[i]:void 0,t["_"+e]=i}class gl extends ul{}class _l extends gl{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return this.__single||this.__clipAfterFill}get __clipAfterFill(){const t=this;return"show"!==t.overflow&&t.__leaf.children.length&&(t.__leaf.isOverflow||super.__clipAfterFill)}}class fl extends gl{__getInputData(t,e){const i=super.__getInputData(t,e);return Oe.forEach(t=>delete i[t]),i}}class ml extends _l{}class yl extends ul{get __usePathBox(){return this.points||this.__pathInputed}}class vl extends ul{get __boxStroke(){return!this.__pathInputed}}class xl extends ul{get __boxStroke(){return!this.__pathInputed}}class wl extends yl{}class El extends ul{}class bl extends ul{get __pathInputed(){return 2}}class kl extends gl{}const Tl={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Sl extends ul{get __useNaturalRatio(){return!1}setFontWeight(t){o(t)?(this.__setInput("fontWeight",t),t=Tl[t]||400):this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=ue.get("Rect",0);const n=e.__layout,r=i.__layout;s||(i.parent=e,i.__world=e.__world,r.boxBounds=n.boxBounds),i.set(t),r.strokeChanged&&n.strokeChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}__getInputData(t,e){const i=super.__getInputData(t,e);return i.textEditing&&delete i.textEditing,i}}class Bl extends vl{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return t.url&&delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url&&delete i.fill,i}}class Pl extends vl{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const{max:Ll,add:Rl}=k,Cl={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:n}=i,r=this.__box;if((i.stroke||"all"===i.hitStroke)&&n&&"inside"!==s&&(e=t="center"===s?n/2:n,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:n;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*n),r&&(t=Ll(t,r.__layout.strokeSpread=r.__updateStrokeSpread()),e=Math.max(e,r.__layout.strokeBoxSpread)),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n,filter:r,renderSpread:o}=this.__,{strokeSpread:a}=this.__layout,h=this.__box;e&&(t=el.getShadowRenderSpread(this,e)),s&&(t=Ll(t,s)),r&&(t=Rl(t,il.getSpread(r))),o&&(t=Rl(t,o)),a&&(t=Rl(t,a));let l=t;return i&&(l=Ll(l,el.getInnerShadowSpread(this,i))),n&&(l=Ll(l,n)),this.__layout.renderShapeSpread=l,h?Ll(h.__updateRenderSpread(),t):t}},{stintSet:Ol}=g,Ml={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);Ol(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),Ol(t,"__fillAfterStroke",e&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill)}if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,n=t.innerShadow||t.blur||t.backgroundBlur||t.filter;Ol(t,"__isFastShadow",e&&!n&&e.length<2&&!e[0].spread&&!el.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(d(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!n)}t.__checkSingle(),Ol(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){Dl(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:n,stroke:r,__drawAfterFill:o,__fillAfterStroke:a,__isFastShadow:h}=s;if(this.__drawRenderPath(t),s.__useEffect&&!h){const h=$h.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&el.shadow(this,t,h),a&&(s.__isStrokes?$h.strokes(r,this,t,e):$h.stroke(r,this,t,e)),n&&(s.__isFills?$h.fills(n,this,t,e):$h.fill(n,this,t,e)),o&&this.__drawAfterFill(t,e),d&&el.innerShadow(this,t,h),r&&!a&&(s.__isStrokes?$h.strokes(r,this,t,e):$h.stroke(r,this,t,e)),c&&il.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?$h.strokes(r,this,t,e):$h.stroke(r,this,t,e)),h){const e=s.shadow[0],{scaleX:i,scaleY:n}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*n,e.blur*i,Zh.string(e.color))}n&&(s.__isFills?$h.fills(n,this,t,e):$h.fill(n,this,t,e)),h&&t.restore(),o&&this.__drawAfterFill(t,e),r&&!a&&(s.__isStrokes?$h.strokes(r,this,t,e):$h.stroke(r,this,t,e))}}else s.__pathForRender?Dl(this,t,e):this.__drawFast(t,e)},__drawShape(t,e){this.__drawRenderPath(t);const i=this.__,{fill:s,stroke:n}=i;s&&!e.ignoreFill&&(i.__isAlphaPixelFill?$h.fills(s,this,t,e):$h.fill("#000000",this,t,e)),i.__isCanvas&&this.__drawAfterFill(t,e),n&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?$h.strokes(n,this,t,e):$h.stroke("#000000",this,t,e))},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),t.clipUI(this),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Dl(t,e,i){const{fill:s,stroke:n,__drawAfterFill:r,__fillAfterStroke:o}=t.__;t.__drawRenderPath(e),o&&$h.stroke(n,t,e,i),s&&$h.fill(s,t,e,i),r&&t.__drawAfterFill(e,i),n&&!o&&$h.stroke(n,t,e,i)}const Il={__drawFast(t,e){let{x:i,y:s,width:n,height:r}=this.__layout.boxBounds;const{fill:o,stroke:a,__drawAfterFill:h}=this.__;if(o&&(t.fillStyle=o,t.fillRect(i,s,n,r)),h&&this.__drawAfterFill(t,e),a){const{strokeAlign:o,__strokeWidth:h}=this.__;if(!h)return;t.setStroke(a,h,this.__);const l=h/2;switch(o){case"center":t.strokeRect(0,0,n,r);break;case"inside":n-=h,r-=h,n<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(i+l,s+l,n,r),t.restore()):t.strokeRect(i+l,s+l,n,r);break;case"outside":t.strokeRect(i-l,s-l,n+h,r+h)}}}};var Al,Wl;t.UI=Al=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){D.assignScale(this,t)}get scale(){return this.__.scale}get isAutoWidth(){const t=this.__;return t.__autoWidth||t.autoWidth}get isAutoHeight(){const t=this.__;return t.__autoHeight||t.autoHeight}get pen(){const{path:t}=this.__;return jn.set(this.path=t||[]),t||this.__drawPathByBox(jn),jn}reset(t){}set(t,e){t&&Object.assign(this,t)}get(t){return o(t)?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return le.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return le.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(jn.set(i=[]),this.__drawPathByBox(jn,!e)),t?ss.toCanvasData(i,!0):i}getPathString(t,e,i){return ss.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||sl.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?Xn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Jh.addArrows(this)):t.__pathForRender&&(t.__pathForRender=void 0)}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path,!0)}__drawPathByData(t,e,i){e?rn.drawPathByData(t,e):this.__drawPathByBox(t,i)}__drawPathByBox(t,e){const{x:i,y:s,width:n,height:r}=this.__layout.boxBounds;if(this.__.cornerRadius&&!e){const{cornerRadius:e}=this.__;t.roundRect(i,s,n,r,h(e)?[e]:e)}else t.rect(i,s,n,r);t.closePath()}drawImagePlaceholder(t,e,i){$h.fill(this.__.placeholderColor,this,e,i)}animate(t,e,i,s){return this.set(t),le.need("animate")}killAnimate(t,e){}export(t,e){return le.need("export")}syncExport(t,e){return le.need("export")}clone(t){const e=g.clone(this.toJSON());return t&&Object.assign(e,t),Al.one(e)}static one(t,e,i,s,n){return ue.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){Zr()(this)}static registerData(t){Ur(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}},ye([Ur(ul)],t.UI.prototype,"__",void 0),ye([Gh()],t.UI.prototype,"zoomLayer",void 0),ye([gr("")],t.UI.prototype,"id",void 0),ye([gr("")],t.UI.prototype,"name",void 0),ye([gr("")],t.UI.prototype,"className",void 0),ye([Lr("pass-through")],t.UI.prototype,"blendMode",void 0),ye([Cr(1)],t.UI.prototype,"opacity",void 0),ye([Or(!0)],t.UI.prototype,"visible",void 0),ye([Lr(!1)],t.UI.prototype,"locked",void 0),ye([Rr(!1)],t.UI.prototype,"dim",void 0),ye([Rr(!1)],t.UI.prototype,"dimskip",void 0),ye([Ir(0)],t.UI.prototype,"zIndex",void 0),ye([Ar(!1)],t.UI.prototype,"mask",void 0),ye([Wr(!1)],t.UI.prototype,"eraser",void 0),ye([_r(0,!0)],t.UI.prototype,"x",void 0),ye([_r(0,!0)],t.UI.prototype,"y",void 0),ye([xr(100,!0)],t.UI.prototype,"width",void 0),ye([xr(100,!0)],t.UI.prototype,"height",void 0),ye([yr(1,!0)],t.UI.prototype,"scaleX",void 0),ye([yr(1,!0)],t.UI.prototype,"scaleY",void 0),ye([vr(0,!0)],t.UI.prototype,"rotation",void 0),ye([vr(0,!0)],t.UI.prototype,"skewX",void 0),ye([vr(0,!0)],t.UI.prototype,"skewY",void 0),ye([_r(0,!0)],t.UI.prototype,"offsetX",void 0),ye([_r(0,!0)],t.UI.prototype,"offsetY",void 0),ye([fr(0,!0)],t.UI.prototype,"scrollX",void 0),ye([fr(0,!0)],t.UI.prototype,"scrollY",void 0),ye([mr()],t.UI.prototype,"origin",void 0),ye([mr()],t.UI.prototype,"around",void 0),ye([gr(!1)],t.UI.prototype,"lazy",void 0),ye([wr(1)],t.UI.prototype,"pixelRatio",void 0),ye([Pr(0)],t.UI.prototype,"renderSpread",void 0),ye([br()],t.UI.prototype,"path",void 0),ye([kr()],t.UI.prototype,"windingRule",void 0),ye([kr(!0)],t.UI.prototype,"closed",void 0),ye([xr(0)],t.UI.prototype,"padding",void 0),ye([xr(!1)],t.UI.prototype,"lockRatio",void 0),ye([xr()],t.UI.prototype,"widthRange",void 0),ye([xr()],t.UI.prototype,"heightRange",void 0),ye([gr(!1)],t.UI.prototype,"draggable",void 0),ye([gr()],t.UI.prototype,"dragBounds",void 0),ye([gr("auto")],t.UI.prototype,"dragBoundsType",void 0),ye([gr(!1)],t.UI.prototype,"editable",void 0),ye([Fr(!0)],t.UI.prototype,"hittable",void 0),ye([Fr("path")],t.UI.prototype,"hitFill",void 0),ye([Br("path")],t.UI.prototype,"hitStroke",void 0),ye([Fr(!1)],t.UI.prototype,"hitBox",void 0),ye([Fr(!0)],t.UI.prototype,"hitChildren",void 0),ye([Fr(!0)],t.UI.prototype,"hitSelf",void 0),ye([Fr()],t.UI.prototype,"hitRadius",void 0),ye([zr("")],t.UI.prototype,"cursor",void 0),ye([Lr()],t.UI.prototype,"fill",void 0),ye([Br(void 0,!0)],t.UI.prototype,"stroke",void 0),ye([Br("inside")],t.UI.prototype,"strokeAlign",void 0),ye([Br(1,!0)],t.UI.prototype,"strokeWidth",void 0),ye([Br(!1)],t.UI.prototype,"strokeWidthFixed",void 0),ye([Br("none")],t.UI.prototype,"strokeCap",void 0),ye([Br("miter")],t.UI.prototype,"strokeJoin",void 0),ye([Br()],t.UI.prototype,"dashPattern",void 0),ye([Br(0)],t.UI.prototype,"dashOffset",void 0),ye([Br(10)],t.UI.prototype,"miterLimit",void 0),ye([kr(0)],t.UI.prototype,"cornerRadius",void 0),ye([kr()],t.UI.prototype,"cornerSmoothing",void 0),ye([Vh()],t.UI.prototype,"shadow",void 0),ye([Vh()],t.UI.prototype,"innerShadow",void 0),ye([Vh()],t.UI.prototype,"blur",void 0),ye([Vh()],t.UI.prototype,"backgroundBlur",void 0),ye([Vh()],t.UI.prototype,"grayscale",void 0),ye([Vh()],t.UI.prototype,"filter",void 0),ye([Lr()],t.UI.prototype,"placeholderColor",void 0),ye([gr(100)],t.UI.prototype,"placeholderDelay",void 0),ye([gr({})],t.UI.prototype,"data",void 0),ye([Vr(t.Leaf.prototype.reset)],t.UI.prototype,"reset",null),t.UI=Al=ye([Kr(Cl),Kr(Ml),jr()],t.UI),t.Group=class extends t.UI{get __tag(){return"Group"}get isBranch(){return!0}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach(t=>this.add(t)),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return this.childlessJSON||(e.children=this.children.map(e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},ye([Ur(gl)],t.Group.prototype,"__",void 0),ye([xr(0)],t.Group.prototype,"width",void 0),ye([xr(0)],t.Group.prototype,"height",void 0),t.Group=ye([Kr(t.Branch),Zr()],t.Group);const Fl=ie.get("Leafer");t.Leafer=Wl=class extends t.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&er.isComplete}get layoutLocked(){return!this.layouter.running}get view(){return this.canvas&&this.canvas.view}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||{x:0,y:0,width:0,height:0}}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Wl.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,g.assign(s,t));const n=this.canvas=de.canvas(s);this.__controllers.push(this.renderer=de.renderer(this,n,s),this.watcher=de.watcher(this,s),this.layouter=de.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(),e||(this.selector=de.selector(this),this.interaction=de.interaction(this,n,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=de.hitCanvasManager()),this.canvasManager=new me,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(n),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),Bo.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit(()=>{super.set(t,e)})}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(ta.RESTART):this.emitLeafer(ta.START),this.__controllers.forEach(t=>t.start()),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach(t=>t.stop()),this.running=!1,this.emitLeafer(ta.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=g.copyAttrs({},t,Oe);Object.keys(e).forEach(t=>this[t]=e[t])}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new jt(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=g.copyAttrs({},this.canvas,Oe);e.resize(t),this.updateLazyBounds(),this.__onResize(new qo(t,i))}__onResize(t){this.emitEvent(t),g.copyAttrs(this.__,t,Oe),setTimeout(()=>{this.canvasManager&&this.canvasManager.clearRecycled()},0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(){const{config:t,parentApp:e}=this;e||(t.width&&t.height||(this.autoLayout=new Kt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Oe.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t?(this.canvas.zIndex=e,setTimeout(()=>this.parent&&this.parent.__updateSortChildren())):"mode"===t&&this.emit(ta.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Oe.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,n=g.copyAttrs({},s,Oe);n[t]=i[t]=e,i.width&&i.height?s.stopAutoLayout():this.__checkAutoLayout(),this.__doResize(n)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(ta.BEFORE_READY),this.emitLeafer(ta.READY),this.emitLeafer(ta.AFTER_READY),Bo.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(ta.VIEW_READY),Bo.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:n,pixelRatio:r}=this;const o="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,o.x+o.width)),i||(n=Math.max(1,o.y+o.height)),this.__doResize({width:s,height:n,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){Bo.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender(()=>{this.imageReady&&(t&&this.emitLeafer(ta.VIEW_COMPLETED),Bo.run(this.__viewCompletedWait),this.viewCompleted=!0)})}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender(()=>this.interaction.updateCursor())}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return le.need("view")}getValidMove(t,e,i){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new ta(t,this))}__listenEvents(){const t=oe.start("FirstCreate "+this.innerName);this.once([[ta.START,()=>oe.end(t)],[$o.START,this.updateLazyBounds,this],[Qo.START,this.__onCreated,this],[Qo.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Jo.DATA,this.__onWatchData,this],[$o.END,this.__onLayoutEnd,this],[Qo.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){Wl.list.remove(this);try{this.stop(),this.emitLeafer(ta.END),this.__removeListenEvents(),this.__controllers.forEach(t=>!(this.parent&&t===this.interaction)&&t.destroy()),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager&&this.canvasManager.destroy()),this.canvas&&this.canvas.destroy(),this.config.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout(()=>{sr.clearRecycled()},100)}catch(t){Fl.error(t)}}};t?e():setTimeout(e)}},t.Leafer.list=new xh,ye([Ur(fl)],t.Leafer.prototype,"__",void 0),ye([xr()],t.Leafer.prototype,"pixelRatio",void 0),ye([gr("normal")],t.Leafer.prototype,"mode",void 0),t.Leafer=Wl=ye([Zr()],t.Leafer),t.Rect=class extends t.UI{get __tag(){return"Rect"}},ye([Ur(vl)],t.Rect.prototype,"__",void 0),t.Rect=ye([Kr(Il),jr(),Zr()],t.Rect);const{add:zl,includes:Ul,scroll:Hl}=Nt,Nl=t.Rect.prototype,Yl=t.Group.prototype;t.Box=class extends t.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){if(this.children.length&&!this.pathInputed){const t=this.__;if(t.__autoSide){t.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:e}=this.__layout;t.__autoSize||(t.__autoWidth?(e.width+=e.x,e.x=0,e.height=t.height,e.y=0):(e.height+=e.y,e.y=0,e.width=t.width,e.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t,e;if(this.children.length){const i=this.__,s=this.__layout,{renderBounds:n,boxBounds:r}=s,{overflow:o}=i,a=s.childrenRenderBounds||(s.childrenRenderBounds={x:0,y:0,width:0,height:0});super.__updateRenderBounds(a),(e=o&&o.includes("scroll"))&&(zl(a,r),Hl(a,i)),this.__updateRectRenderBounds(),t=!Ul(r,a),t&&"show"===o&&zl(n,a)}else this.__updateRectRenderBounds();g.stintSet(this,"isOverflow",t),this.__checkScroll(e)}__updateRectRenderBounds(){}__checkScroll(t){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e)),this.hasScroller&&this.scroller.__render(t,e)}__drawContent(t,e){this.__renderGroup(t,e),(this.__.__useStroke||this.__.__useEffect)&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}},ye([Ur(_l)],t.Box.prototype,"__",void 0),ye([xr(100)],t.Box.prototype,"width",void 0),ye([xr(100)],t.Box.prototype,"height",void 0),ye([gr(!1)],t.Box.prototype,"resizeChildren",void 0),ye([Pr("show")],t.Box.prototype,"overflow",void 0),ye([Vr(Nl.__updateStrokeSpread)],t.Box.prototype,"__updateStrokeSpread",null),ye([Vr(Nl.__updateRenderSpread)],t.Box.prototype,"__updateRectRenderSpread",null),ye([Vr(Nl.__updateBoxBounds)],t.Box.prototype,"__updateRectBoxBounds",null),ye([Vr(Nl.__updateStrokeBounds)],t.Box.prototype,"__updateStrokeBounds",null),ye([Vr(Nl.__updateRenderBounds)],t.Box.prototype,"__updateRectRenderBounds",null),ye([Vr(Nl.__updateChange)],t.Box.prototype,"__updateRectChange",null),ye([Vr(Nl.__render)],t.Box.prototype,"__renderRect",null),ye([Vr(Yl.__render)],t.Box.prototype,"__renderGroup",null),t.Box=ye([jr(),Zr()],t.Box),t.Frame=class extends t.Box{get __tag(){return"Frame"}get isFrame(){return!0}},ye([Ur(ml)],t.Frame.prototype,"__",void 0),ye([Lr("#FFFFFF")],t.Frame.prototype,"fill",void 0),ye([Pr("hide")],t.Frame.prototype,"overflow",void 0),t.Frame=ye([Zr()],t.Frame);const{moveTo:Xl,closePath:Vl,ellipse:jl}=Ss;t.Ellipse=class extends t.UI{get __tag(){return"Ellipse"}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:n}=this.__,r=t/2,o=e/2,a=this.__.path=[];let h;i?s||n?(i<1?jl(a,r,o,r*i,o*i,0,s,n,!1):h=!0,jl(a,r,o,r,o,0,n,s,!0)):(i<1&&(jl(a,r,o,r*i,o*i),Xl(a,t,o)),jl(a,r,o,r,o,0,360,0,!0)):s||n?(Xl(a,r,o),jl(a,r,o,r,o,0,s,n,!1)):jl(a,r,o,r,o),h||Vl(a),Qt.ellipseToCurve&&(this.__.path=this.getPath(!0))}},ye([Ur(xl)],t.Ellipse.prototype,"__",void 0),ye([kr(0)],t.Ellipse.prototype,"innerRadius",void 0),ye([kr(0)],t.Ellipse.prototype,"startAngle",void 0),ye([kr(0)],t.Ellipse.prototype,"endAngle",void 0),t.Ellipse=ye([Zr()],t.Ellipse);const{sin:Gl,cos:Kl,PI:Zl}=Math,{moveTo:ql,lineTo:Jl,closePath:$l,drawPoints:Ql}=Ss;t.Polygon=class extends t.UI{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)Ql(e,t.points,t.curve,!0);else{const{width:i,height:s,sides:n}=t,r=i/2,o=s/2;ql(e,r,0);for(let t=1;t<n;t++)Jl(e,r+r*Gl(2*t*Zl/n),o-o*Kl(2*t*Zl/n));$l(e)}}},ye([Ur(wl)],t.Polygon.prototype,"__",void 0),ye([kr(3)],t.Polygon.prototype,"sides",void 0),ye([kr()],t.Polygon.prototype,"points",void 0),ye([kr(0)],t.Polygon.prototype,"curve",void 0),t.Polygon=ye([jr(),Zr()],t.Polygon);const{sin:td,cos:ed,PI:id}=Math,{moveTo:sd,lineTo:nd,closePath:rd}=Ss;t.Star=class extends t.UI{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,r=e/2,o=this.__.path=[];sd(o,n,0);for(let t=1;t<2*i;t++)nd(o,n+(t%2==0?n:n*s)*td(t*id/i),r-(t%2==0?r:r*s)*ed(t*id/i));rd(o)}},ye([Ur(El)],t.Star.prototype,"__",void 0),ye([kr(5)],t.Star.prototype,"corners",void 0),ye([kr(.382)],t.Star.prototype,"innerRadius",void 0),t.Star=ye([Zr()],t.Star);const{moveTo:od,lineTo:ad,drawPoints:hd}=Ss,{rotate:ld,getAngle:dd,getDistance:cd,defaultPoint:ud}=at;t.Line=class extends t.UI{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&ld(i,e),i}set toPoint(t){this.width=cd(ud,t),this.rotation=dd(ud,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?hd(e,t.points,t.curve,t.closed):(od(e,0,0),ad(e,this.width,0))}},ye([Ur(yl)],t.Line.prototype,"__",void 0),ye([Tr("center")],t.Line.prototype,"strokeAlign",void 0),ye([xr(0)],t.Line.prototype,"height",void 0),ye([kr()],t.Line.prototype,"points",void 0),ye([kr(0)],t.Line.prototype,"curve",void 0),ye([kr(!1)],t.Line.prototype,"closed",void 0),t.Line=ye([Zr()],t.Line),t.Image=class extends t.Rect{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return d(t)&&t[0].image}},ye([Ur(Bl)],t.Image.prototype,"__",void 0),ye([xr("")],t.Image.prototype,"url",void 0),t.Image=ye([Zr()],t.Image);const pd=t.Image;t.Canvas=class extends t.Rect{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=de.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new ar({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Yo(Yo.LOADED,{image:t}))})}draw(t,e,i,s){const n=new _t(t.worldTransform).invert(),r=new _t;e&&r.translate(e.x,e.y),i&&(h(i)?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),n.multiplyParent(r),t.__render(this.canvas,{matrix:n.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:n}=this.canvas;t.drawImage(n,0,0,n.width,n.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null),super.destroy()}},ye([Ur(Pl)],t.Canvas.prototype,"__",void 0),ye([jh(100)],t.Canvas.prototype,"width",void 0),ye([jh(100)],t.Canvas.prototype,"height",void 0),ye([jh(1)],t.Canvas.prototype,"pixelRatio",void 0),ye([jh(!0)],t.Canvas.prototype,"smooth",void 0),ye([gr(!1)],t.Canvas.prototype,"safeResize",void 0),ye([jh()],t.Canvas.prototype,"contextSettings",void 0),t.Canvas=ye([Zr()],t.Canvas);const{copyAndSpread:gd,includes:_d,spread:fd,setList:md}=Nt,{stintSet:yd}=g;t.Text=class extends t.UI{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:n,fontWeight:r,italic:o,textCase:a,textOverflow:h,padding:l,width:d,height:c}=t;t.__lineHeight=qh.number(e,n),t.__letterSpacing=qh.number(i,n),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*n)/2,t.__font=`${o?"italic ":""}${"small-caps"===a?"small-caps ":""}${"normal"!==r?r+" ":""}${n||12}px ${s||"caption"}`,yd(t,"__padding",l&&D.fourNumber(l)),yd(t,"__clipText","show"!==h&&!t.__autoSize),yd(t,"__isCharMode",d||c||t.__letterSpacing||"none"!==a),t.__textDrawData=Kh.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:n,__autoWidth:r,__autoHeight:o}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=a,t.__lineHeight<i&&fd(a,i/2),r||o){if(h.x=r?a.x:0,h.y=o?a.y:0,h.width=r?a.width:t.width,h.height=o?a.height:t.height,n){const[e,i,s,n]=t.__padding;r&&(h.x-=n,h.width+=i+n),o&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),g.stintSet(this,"isOverflow",!_d(h,a)),this.isOverflow?(md(t.__textBoxBounds={},[h,a]),e.renderChanged=!0):t.__textBoxBounds=h}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;gd(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__updateChange(){super.__updateChange();const t=this.__box;t&&(t.__onUpdateSize(),t.__updateChange())}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!e.exporting||super.__draw(t,e,i)}__drawShape(t,e){e.shape&&this.__box&&this.__box.__drawShape(t,e),super.__drawShape(t,e)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}},ye([Ur(Sl)],t.Text.prototype,"__",void 0),ye([xr(0)],t.Text.prototype,"width",void 0),ye([xr(0)],t.Text.prototype,"height",void 0),ye([Lr()],t.Text.prototype,"boxStyle",void 0),ye([gr(!1)],t.Text.prototype,"resizeFontSize",void 0),ye([Lr("#000000")],t.Text.prototype,"fill",void 0),ye([Tr("outside")],t.Text.prototype,"strokeAlign",void 0),ye([Fr("all")],t.Text.prototype,"hitFill",void 0),ye([xr("")],t.Text.prototype,"text",void 0),ye([xr("")],t.Text.prototype,"placeholder",void 0),ye([xr("caption")],t.Text.prototype,"fontFamily",void 0),ye([xr(12)],t.Text.prototype,"fontSize",void 0),ye([xr("normal")],t.Text.prototype,"fontWeight",void 0),ye([xr(!1)],t.Text.prototype,"italic",void 0),ye([xr("none")],t.Text.prototype,"textCase",void 0),ye([xr("none")],t.Text.prototype,"textDecoration",void 0),ye([xr(0)],t.Text.prototype,"letterSpacing",void 0),ye([xr({type:"percent",value:1.5})],t.Text.prototype,"lineHeight",void 0),ye([xr(0)],t.Text.prototype,"paraIndent",void 0),ye([xr(0)],t.Text.prototype,"paraSpacing",void 0),ye([xr("x")],t.Text.prototype,"writingMode",void 0),ye([xr("left")],t.Text.prototype,"textAlign",void 0),ye([xr("top")],t.Text.prototype,"verticalAlign",void 0),ye([xr(!0)],t.Text.prototype,"autoSizeAlign",void 0),ye([xr("normal")],t.Text.prototype,"textWrap",void 0),ye([xr("show")],t.Text.prototype,"textOverflow",void 0),ye([Lr(!1)],t.Text.prototype,"textEditing",void 0),t.Text=ye([Zr()],t.Text),t.Path=class extends t.UI{get __tag(){return"Path"}},ye([Ur(bl)],t.Path.prototype,"__",void 0),ye([Tr("center")],t.Path.prototype,"strokeAlign",void 0),t.Path=ye([Zr()],t.Path),t.Pen=class extends t.Group{get __tag(){return"Pen"}setStyle(e){const i=this.pathElement=new t.Path(e);return this.pathStyle=e,this.__path=i.path||(i.path=[]),this.add(i),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,n,r){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,r,o,a){return this}arc(t,e,i,s,n,r){return this}arcTo(t,e,i,s,n){return this}drawEllipse(t,e,i,s,n,r,o,a){return this}drawArc(t,e,i,s,n,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}},ye([Ur(kl)],t.Pen.prototype,"__",void 0),ye([(t,e)=>{hr(t,e,{get(){return this.__path}})}],t.Pen.prototype,"path",void 0),t.Pen=ye([Kr(Ys,["set","path","paint"]),Zr()],t.Pen),t.App=class extends t.Leafer{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){super(t,e)}init(t,e){if(super.init(t,e),t){const{ground:e,tree:i,sky:s,editor:n}=t;e&&(this.ground=this.addLeafer(e)),(i||n)&&(this.tree=this.addLeafer(i||{type:t.type||"design"})),(s||n)&&(this.sky=this.addLeafer(s)),n&&de.editor(n,this)}}__setApp(){const{canvas:t}=this,{realCanvas:e,view:i}=this.config;e||i===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable()}__updateLocalBounds(){this.forEach(t=>t.updateLayout()),super.__updateLocalBounds()}start(){super.start(),this.forEach(t=>t.start())}stop(){this.forEach(t=>t.stop()),super.stop()}unlockLayout(){super.unlockLayout(),this.forEach(t=>t.unlockLayout())}lockLayout(){super.lockLayout(),this.forEach(t=>t.lockLayout())}forceRender(t,e){this.forEach(i=>i.forceRender(t,e))}addLeafer(e){const i=new t.Leafer(e);return this.add(i),i}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),n(e)||(t.canvas.childIndex=e),this.__listenChildEvents(t)}forEach(t){this.children.forEach(t)}__onCreated(){this.created=this.children.every(t=>t.created)}__onReady(){this.children.every(t=>t.ready)&&super.__onReady()}__onViewReady(){this.children.every(t=>t.viewReady)&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){t.context&&this.forEach(i=>e.matrix?i.__render(t,e):t.copyWorld(i.canvas,e.bounds))}__onResize(t){this.forEach(e=>e.resize(t)),super.__onResize(t)}updateLayout(){this.forEach(t=>t.updateLayout())}__getChildConfig(t){const e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&g.assign(e,t),this.autoLayout&&g.copyAttrs(e,this,Oe),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[$o.END,this.__onReady,this],[Qo.START,this.__onCreated,this],[Qo.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(Qo.END,this.__onChildRenderEnd,this))}},t.App=ye([Zr()],t.App);const vd={},xd={isHoldSpaceKey:()=>xd.isHold("Space"),isHold:t=>vd[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){vd[t]||(vd[t]=!0)},setUpCode(t){vd[t]=!1}},wd={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 Ed extends Fo{get spaceKey(){return xd.isHoldSpaceKey()}get left(){return wd.left(this)}get right(){return wd.right(this)}get middle(){return wd.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return xd.isHoldKeys(t,this)}getBoxPoint(t){return(t||this.current).getBoxPoint(this)}getInnerPoint(t){return(t||this.current).getInnerPoint(this)}getLocalPoint(t){return(t||this.current).getLocalPoint(this)}getPagePoint(){return this.current.getPagePoint(this)}getInner(t){return this.getInnerPoint(t)}getLocal(t){return this.getLocalPoint(t)}getPage(){return this.getPagePoint()}static changeName(t,e){_e.changeName(t,e)}}const{min:bd,max:kd,abs:Td}=Math,{float:Sd,sign:Bd}=D,{minX:Pd,maxX:Ld,minY:Rd,maxY:Cd}=Nt,Od=new jt,Md=new jt,Dd={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&Id.getValidMove(t.__localBoxBounds,Id.getDragBounds(t),s,e,!0),Id.axisMove(t,e)},limitScaleOf(t,e,i,s){const{dragBounds:n,dragBoundsType:r}=t;n&&Id.getValidScaleOf(t.__localBoxBounds,Id.getDragBounds(t),r,t.getLocalPointByInner(t.getInnerPointByBox(e)),i,s,!0)},axisMove(t,e){const{draggable:i}=t;"x"===i&&(e.y=0),"y"===i&&(e.x=0)},getDragBounds(t){const{dragBounds:e}=t;return"parent"===e?t.parent.boxBounds:e},isInnerMode:(t,e,i,s)=>"inner"===i||"auto"===i&&t[s]>e[s],getValidMove(t,e,i,s,n){const r=t.x+s.x,o=t.y+s.y,a=r+t.width,h=o+t.height,l=e.x+e.width,d=e.y+e.height;return n||(s=Object.assign({},s)),Id.isInnerMode(t,e,i,"width")?r>e.x?s.x+=e.x-r:a<l&&(s.x+=l-a):r<e.x?s.x+=e.x-r:a>l&&(s.x+=l-a),Id.isInnerMode(t,e,i,"height")?o>e.y?s.y+=e.y-o:h<d&&(s.y+=d-h):o<e.y?s.y+=e.y-o:h>d&&(s.y+=d-h),s.x=Sd(s.x),s.y=Sd(s.y),s},getValidScaleOf(t,e,i,s,n,r,o){o||(n=Object.assign({},n)),Md.set(e),Od.set(t).scaleOf(s,n.x,n.y);const h=(s.x-t.x)/t.width,l=1-h,d=(s.y-t.y)/t.height,c=1-d;let u,p,g,_,f=1,m=1;return Id.isInnerMode(t,e,i,"width")?(n.x<0&&Od.scaleOf(s,f=1/n.x,1),g=Sd(Od.minX-Md.minX),_=Sd(Md.maxX-Od.maxX),u=h&&g>0?1+g/(h*Od.width):1,p=l&&_>0?1+_/(l*Od.width):1,f*=kd(u,p)):(n.x<0&&((Sd(Pd(t)-Pd(e))<=0||Sd(Ld(e)-Ld(t))<=0)&&Od.scaleOf(s,f=1/n.x,1),Od.unsign()),g=Sd(Md.minX-Od.minX),_=Sd(Od.maxX-Md.maxX),u=h&&g>0?1-g/(h*Od.width):1,p=l&&_>0?1-_/(l*Od.width):1,f*=bd(u,p)),Id.isInnerMode(t,e,i,"height")?(n.y<0&&Od.scaleOf(s,1,m=1/n.y),g=Sd(Od.minY-Md.minY),_=Sd(Md.maxY-Od.maxY),u=d&&g>0?1+g/(d*Od.height):1,p=c&&_>0?1+_/(c*Od.height):1,m*=kd(u,p),r&&(u=kd(Td(f),Td(m)),f=Bd(f)*u,m=Bd(m)*u)):(n.y<0&&((Sd(Rd(t)-Rd(e))<=0||Sd(Cd(e)-Cd(t))<=0)&&Od.scaleOf(s,1,m=1/n.y),Od.unsign()),g=Sd(Md.minY-Od.minY),_=Sd(Od.maxY-Md.maxY),u=d&&g>0?1-g/(d*Od.height):1,p=c&&_>0?1-_/(c*Od.height):1,m*=bd(u,p)),n.x*=a(f)?f:1,n.y*=a(m)?m:1,n}},Id=Dd;t.PointerEvent=class extends Ed{},t.PointerEvent.POINTER="pointer",t.PointerEvent.BEFORE_DOWN="pointer.before_down",t.PointerEvent.BEFORE_MOVE="pointer.before_move",t.PointerEvent.BEFORE_UP="pointer.before_up",t.PointerEvent.DOWN="pointer.down",t.PointerEvent.MOVE="pointer.move",t.PointerEvent.UP="pointer.up",t.PointerEvent.OVER="pointer.over",t.PointerEvent.OUT="pointer.out",t.PointerEvent.ENTER="pointer.enter",t.PointerEvent.LEAVE="pointer.leave",t.PointerEvent.TAP="tap",t.PointerEvent.DOUBLE_TAP="double_tap",t.PointerEvent.CLICK="click",t.PointerEvent.DOUBLE_CLICK="double_click",t.PointerEvent.LONG_PRESS="long_press",t.PointerEvent.LONG_TAP="long_tap",t.PointerEvent.MENU="pointer.menu",t.PointerEvent.MENU_TAP="pointer.menu_tap",t.PointerEvent=ye([qr()],t.PointerEvent);const Ad=t.PointerEvent,Wd={};t.DragEvent=class extends t.PointerEvent{static setList(t){this.list=t instanceof xh?t:new xh(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const n=t.getLocalPoint(i,null,!0);return at.move(n,e.x-t.x,e.y-t.y),s&&this.limitMove(t,n),Dd.axisMove(t,n),n}static limitMove(t,e){Dd.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Wd,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Wd,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Wd,null,!0)}getPageTotal(){return this.getPageMove(!0)}getInnerTotal(t){return this.getInnerMove(t,!0)}getLocalTotal(t){return this.getLocalMove(t,!0)}getPageBounds(){const t=this.getPageTotal(),e=this.getPagePoint(),i={};return Nt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),Nt.unsign(i),i}assignMove(t){Wd.x=t?this.totalX:this.moveX,Wd.y=t?this.totalY:this.moveY}},t.DragEvent.BEFORE_DRAG="drag.before_drag",t.DragEvent.START="drag.start",t.DragEvent.DRAG="drag",t.DragEvent.END="drag.end",t.DragEvent.OVER="drag.over",t.DragEvent.OUT="drag.out",t.DragEvent.ENTER="drag.enter",t.DragEvent.LEAVE="drag.leave",t.DragEvent=ye([qr()],t.DragEvent);const Fd=t.DragEvent;t.DropEvent=class extends t.PointerEvent{static setList(e){t.DragEvent.setList(e)}static setData(e){t.DragEvent.setData(e)}},t.DropEvent.DROP="drop",t.DropEvent=ye([qr()],t.DropEvent),t.MoveEvent=class extends t.DragEvent{},t.MoveEvent.BEFORE_MOVE="move.before_move",t.MoveEvent.START="move.start",t.MoveEvent.MOVE="move",t.MoveEvent.DRAG_ANIMATE="move.drag_animate",t.MoveEvent.END="move.end",t.MoveEvent.PULL_DOWN="move.pull_down",t.MoveEvent.REACH_BOTTOM="move.reach_bottom",t.MoveEvent=ye([qr()],t.MoveEvent),t.TouchEvent=class extends Ed{},t.TouchEvent=ye([qr()],t.TouchEvent);const zd=t.TouchEvent;t.RotateEvent=class extends t.PointerEvent{},t.RotateEvent.BEFORE_ROTATE="rotate.before_rotate",t.RotateEvent.START="rotate.start",t.RotateEvent.ROTATE="rotate",t.RotateEvent.END="rotate.end",t.RotateEvent=ye([qr()],t.RotateEvent),t.SwipeEvent=class extends t.DragEvent{},t.SwipeEvent.SWIPE="swipe",t.SwipeEvent.LEFT="swipe.left",t.SwipeEvent.RIGHT="swipe.right",t.SwipeEvent.UP="swipe.up",t.SwipeEvent.DOWN="swipe.down",t.SwipeEvent=ye([qr()],t.SwipeEvent),t.ZoomEvent=class extends t.PointerEvent{},t.ZoomEvent.BEFORE_ZOOM="zoom.before_zoom",t.ZoomEvent.START="zoom.start",t.ZoomEvent.ZOOM="zoom",t.ZoomEvent.END="zoom.end",t.ZoomEvent=ye([qr()],t.ZoomEvent),t.KeyEvent=class extends Ed{},t.KeyEvent.BEFORE_DOWN="key.before_down",t.KeyEvent.BEFORE_UP="key.before_up",t.KeyEvent.DOWN="key.down",t.KeyEvent.HOLD="key.hold",t.KeyEvent.UP="key.up",t.KeyEvent=ye([qr()],t.KeyEvent);const Ud={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:e=>e<-45&&e>-135?t.SwipeEvent.UP:e>45&&e<135?t.SwipeEvent.DOWN:e<=45&&e>=-45?t.SwipeEvent.RIGHT:t.SwipeEvent.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:Hd.getSwipeDirection(at.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,time:Date.now(),buttons:n(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 xh,{list:s}=t;for(let t=0,n=s.length;t<n;t++)s[t].hasEvent(e)&&i.add(s[t]);return i},pathCanDrag:e=>e&&e.list.some(e=>ho.draggable(e)||!e.isLeafer&&e.hasEvent(t.DragEvent.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},Hd=Ud,Nd=new xh,{getDragEventData:Yd,getDropEventData:Xd,getSwipeEventData:Vd}=Ud;class jd{constructor(t){this.dragDataList=[],this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Yd(t,t,t),this.canAnimate=this.canDragOut=!0}getList(e,i){const{proxy:s}=this.interaction.selector,n=s&&s.list.length,r=t.DragEvent.list||this.draggableList||Nd;return this.dragging&&(n?e?Nd:new xh(i?[...s.list,...s.dragHoverExclude]:s.list):r)}checkDrag(e,i){const{interaction:s}=this;if(this.moving&&e.buttons<1)return this.canAnimate=!1,void s.pointerCancel();!this.moving&&i&&(this.moving=s.canMove(this.downData)||s.isHoldRightKey||s.isMobileDragEmpty)&&(this.dragData.moveType="drag",s.emit(t.MoveEvent.START,this.dragData)),this.moving||this.dragStart(e,i),this.drag(e)}dragStart(e,i){this.dragging||(this.dragging=i&&wd.left(e),this.dragging&&(this.interaction.emit(t.DragEvent.START,this.dragData),this.getDraggableList(this.dragData.path),this.setDragStartPoints(this.realDraggableList=this.getList(!0))))}setDragStartPoints(t){this.dragStartPoints={},t.forEach(t=>this.dragStartPoints[t.innerId]={x:t.x,y:t.y})}getDraggableList(t){let e;for(let i=0,s=t.length;i<s;i++)if(e=t.list[i],ho.draggable(e)){this.draggableList=new xh(e);break}}drag(e){const{interaction:i,dragData:s,downData:n}=this,{path:r,throughPath:o}=n;this.dragData=Yd(n,s,e),o&&(this.dragData.throughPath=o),this.dragData.path=r,this.dragDataList.push(this.dragData),this.moving?(e.moving=!0,this.dragData.moveType="drag",i.emit(t.MoveEvent.BEFORE_MOVE,this.dragData),i.emit(t.MoveEvent.MOVE,this.dragData)):this.dragging&&(e.dragging=!0,this.dragReal(),i.emit(t.DragEvent.BEFORE_DRAG,this.dragData),i.emit(t.DragEvent.DRAG,this.dragData))}dragReal(e){const{interaction:i}=this,{running:s}=i,n=this.realDraggableList;if(n.length&&s){const{totalX:s,totalY:r}=this.dragData,{dragLimitAnimate:a}=i.p,l=!a||!!e;n.forEach(i=>{if(i.draggable){const n=o(i.draggable),d=t.DragEvent.getValidMove(i,this.dragStartPoints[i.innerId],{x:s,y:r},l||n);a&&!n&&e?ho.animateMove(i,d,h(a)?a:.3):i.move(d)}})}}dragOverOrOut(e){const{interaction:i}=this,{dragOverPath:s}=this,{path:n}=e;this.dragOverPath=n,s?n.indexAt(0)!==s.indexAt(0)&&(i.emit(t.DragEvent.OUT,e,s),i.emit(t.DragEvent.OVER,e,n)):i.emit(t.DragEvent.OVER,e,n)}dragEnterOrLeave(e){const{interaction:i}=this,{dragEnterPath:s}=this,{path:n}=e;i.emit(t.DragEvent.LEAVE,e,s,n),i.emit(t.DragEvent.ENTER,e,n,s),this.dragEnterPath=n}dragEnd(t){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t)||this.dragEndReal(t))}dragEndReal(e){const{interaction:i,downData:s,dragData:n}=this;e||(e=n);const{path:r,throughPath:o}=s,a=Yd(s,e,e);if(o&&(a.throughPath=o),a.path=r,this.moving&&(this.moving=!1,a.moveType="drag",i.emit(t.MoveEvent.END,a)),this.dragging){const r=this.getList();this.dragging=!1,i.p.dragLimitAnimate&&this.dragReal(!0),i.emit(t.DragEvent.END,a),this.swipe(e,s,n,a),this.drop(e,r,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(at.getDistance(e,t)>n.config.pointer.swipeDistance){const t=Vd(e,i,s);this.interaction.emit(t.type,t)}}drop(e,i,s){const n=Xd(e,i,t.DragEvent.data);n.path=s,this.interaction.emit(t.DropEvent.DROP,n),this.interaction.emit(t.DragEvent.LEAVE,e,s)}dragReset(){t.DragEvent.list=t.DragEvent.data=this.draggableList=this.dragData=this.downData=this.dragOverPath=this.dragEnterPath=null,this.dragDataList=[]}checkDragEndAnimate(t,e){return!1}animate(t,e){}stopAnimate(){}checkDragOut(t){}autoMoveOnDragOut(t){}autoMoveCancel(){}destroy(){this.dragReset()}}const Gd=ie.get("emit");const Kd=["move","zoom","rotate","key"];function Zd(t,e,i,s,n){if(Kd.some(t=>e.startsWith(t))&&t.__.hitChildren&&!Jd(t,n)){let r;for(let o=0,a=t.children.length;o<a;o++)r=t.children[o],!i.path.has(r)&&r.__.hittable&&qd(r,e,i,s,n)}}function qd(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!Jd(t,n)&&(nl.updateEventStyle&&!s&&nl.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=_e.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function Jd(t,e){return e&&e.has(t)}const $d={wheel:{zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8}},pointer:{type:"pointer",snap:!0,hitRadius:5,tapTime:120,longPressTime:800,transformTime:500,hover:!0,dragHover:!0,dragDistance:2,swipeDistance:20},touch:{preventDefault:"auto"},multiTouch:{},move:{autoDistance:2},zoom:{},cursor:!0,keyEvent:!0},{pathHasEventType:Qd,pathCanDrag:tc,pathHasOutside:ec}=Ud;class ic{get dragging(){return this.dragger.dragging}get transforming(){return this.transformer.transforming}get moveMode(){return!0===this.m.drag||this.isHoldSpaceKey||this.isHoldMiddleKey||this.isHoldRightKey&&this.dragger.moving||this.isDragEmpty}get canHover(){return this.p.hover&&!this.config.mobile}get isDragEmpty(){return this.m.dragEmpty&&this.isRootPath(this.hoverData)&&(!this.downData||this.isRootPath(this.downData))}get isMobileDragEmpty(){return this.m.dragEmpty&&!this.canHover&&this.downData&&this.isTreePath(this.downData)}get isHoldMiddleKey(){return this.m.holdMiddleKey&&this.downData&&wd.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&wd.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&xd.isHoldSpaceKey()}get m(){return this.config.move}get p(){return this.config.pointer}get hitRadius(){return this.p.hitRadius}constructor(t,e,i,s){this.config=g.clone($d),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new xh(t),this.createTransformer(),this.dragger=new jd(this),s&&(this.config=g.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(e,i){e||(e=this.hoverData),e&&(wd.defaultLeft(e),this.updateDownData(e),this.checkPath(e,i),this.downTime=Date.now(),this.emit(t.PointerEvent.BEFORE_DOWN,e),this.emit(t.PointerEvent.DOWN,e),wd.left(e)&&(this.tapWait(),this.longPressWait(e)),this.waitRightTap=wd.right(e),this.dragger.setDragData(e),this.isHoldRightKey||this.updateCursor(e))}pointerMove(t){if(t||(t=this.hoverData),!t)return;const{downData:e}=this;e&&wd.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(e){if(this.emit(t.PointerEvent.BEFORE_MOVE,e,this.defaultPath),this.downData){const t=at.getDistance(this.downData,e)>this.p.dragDistance;t&&(this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(e,t)}this.dragger.moving||(this.updateHoverData(e),this.checkPath(e),this.emit(t.PointerEvent.MOVE,e),this.pointerHover(e),this.dragging&&(this.dragger.dragOverOrOut(e),this.dragger.dragEnterOrLeave(e))),this.updateCursor(this.downData||e)}pointerUp(e){const{downData:i}=this;if(e||(e=i),!i)return;wd.defaultLeft(e),e.multiTouch=i.multiTouch,this.findPath(e);const s=Object.assign(Object.assign({},e),{path:e.path.clone()});e.path.addList(i.path.list),this.checkPath(e),this.downData=null,this.emit(t.PointerEvent.BEFORE_UP,e),this.emit(t.PointerEvent.UP,e),this.touchLeave(e),e.isCancel||(this.tap(e),this.menuTap(e)),this.dragger.dragEnd(e),this.updateCursor(s)}pointerCancel(){const t=Object.assign({},this.dragger.dragData);t.isCancel=!0,this.pointerUp(t)}menu(e){this.findPath(e),this.emit(t.PointerEvent.MENU,e),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(e)}menuTap(e){this.waitRightTap&&this.waitMenuTap&&(this.emit(t.PointerEvent.MENU_TAP,e),this.waitRightTap=this.waitMenuTap=!1)}createTransformer(){}move(t){}zoom(t){}rotate(t){}transformEnd(){}wheel(t){}multiTouch(t,e){}keyDown(e){if(!this.config.keyEvent)return;this.emit(t.KeyEvent.BEFORE_DOWN,e,this.defaultPath);const{code:i}=e;this.downKeyMap[i]||(this.downKeyMap[i]=!0,xd.setDownCode(i),this.emit(t.KeyEvent.HOLD,e,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(t.KeyEvent.DOWN,e,this.defaultPath)}keyUp(e){if(!this.config.keyEvent)return;this.emit(t.KeyEvent.BEFORE_UP,e,this.defaultPath);const{code:i}=e;this.downKeyMap[i]=!1,xd.setUpCode(i),this.emit(t.KeyEvent.UP,e,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new xh),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t))}pointerOverOrOut(e){const{path:i}=e,{overPath:s}=this;this.overPath=i,s?i.indexAt(0)!==s.indexAt(0)&&(this.emit(t.PointerEvent.OUT,e,s),this.emit(t.PointerEvent.OVER,e,i)):this.emit(t.PointerEvent.OVER,e,i)}pointerEnterOrLeave(e){let{path:i}=e;this.downData&&!this.moveMode&&(i=i.clone(),this.downData.path.forEach(t=>i.add(t)));const{enterPath:s}=this;this.enterPath=i,this.emit(t.PointerEvent.LEAVE,e,s,i),this.emit(t.PointerEvent.ENTER,e,i,s)}touchLeave(e){"touch"===e.pointerType&&this.enterPath&&(this.emit(t.PointerEvent.LEAVE,e),this.dragger.dragging&&this.emit(t.DropEvent.LEAVE,e))}tap(e){const{pointer:i}=this.config,s=this.longTap(e);if(!i.tapMore&&s)return;if(!this.waitTap)return;i.tapMore&&this.emitTap(e);const n=Date.now()-this.downTime,r=[t.PointerEvent.DOUBLE_TAP,t.PointerEvent.DOUBLE_CLICK].some(t=>Qd(e.path,t));n<i.tapTime+50&&r?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(e)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout(()=>{i.tapMore||(this.tapWaitCancel(),this.emitTap(e))},i.tapTime))):i.tapMore||(this.tapWaitCancel(),this.emitTap(e))}findPath(t,e){const{hitRadius:i,through:s}=this.p,{bottomList:n,target:r}=this;Qt.backgrounder||t.origin||r&&r.updateLayout();const 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&&!ec(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!tc(t.path))&&!ec(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))}stopDragAnimate(){this.dragger.stopAnimate()}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(e){e||(e=this.hoverData),e&&(this.findPath(e,{exclude:this.dragger.getList(!1,!0),name:t.PointerEvent.MOVE}),this.hoverData=e)}updateCursor(t){if(!this.config.cursor||!this.canHover)return;if(t||(this.updateHoverData(),t=this.downData||this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.canMove(t))return this.setCursor(this.downData?"grabbing":"grab");if(!t)return;let e,i;const{path:s}=t;for(let t=0,n=s.length;t<n&&(e=s.list[t],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);t++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e),s={x:t.clientX-i.x,y:t.clientY-i.y},{bounds:n}=this.canvas;return s.x*=n.width/i.width,s.y*=n.height/i.height,this.p.snap&&at.round(s),s}emitTap(e){this.emit(t.PointerEvent.TAP,e),this.emit(t.PointerEvent.CLICK,e)}emitDoubleTap(e){this.emit(t.PointerEvent.DOUBLE_TAP,e),this.emit(t.PointerEvent.DOUBLE_CLICK,e)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){this.waitTap&&(clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0)}longPressWait(e){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout(()=>{this.longPressed=!0,this.emit(t.PointerEvent.LONG_PRESS,e)},this.p.longPressTime)}longTap(e){let i;return this.longPressed&&(this.emit(t.PointerEvent.LONG_TAP,e),(Qd(e.path,t.PointerEvent.LONG_TAP)||Qd(e.path,t.PointerEvent.LONG_PRESS))&&(i=!0)),this.longPressWaitCancel(),i}longPressWaitCancel(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressed=!1)}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new jt(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(h(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(qo.RESIZE,this.__onResize,this)],t.once(ta.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 r=i.length-1;r>-1;r--){if(n=i.list[r],qd(n,t,e,!0,s))return;n.isApp&&Zd(n,t,e,!0,s)}for(let r=0,o=i.length;r<o;r++)if(n=i.list[r],n.isApp&&Zd(n,t,e,!1,s),qd(n,t,e,!1,s))return}catch(t){Gd.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer&&this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class sc{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}sc.custom={};class nc extends me{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new xh,this.pixelList=new xh}getPixelType(t,e){return this.__autoClear(),this.pixelList.add(t),de.hitCanvas(e)}getPathType(t){return this.__autoClear(),this.pathList.add(t),de.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()}}Qt.getSelector=function(t){return t.leafer?t.leafer.selector:Qt.selector||(Qt.selector=de.selector())};const{toInnerRadiusPointOf:rc,copyRadiusPoint:oc}=at,{hitRadiusPoint:ac,hitPoint:hc}=Nt,lc={},dc={},cc=t.Leaf.prototype;cc.hit=function(t,e=0){this.updateLayout(),oc(dc,t,e);const i=this.__world;return!!(e?ac(i,dc):hc(i,dc))&&(this.isBranch?Qt.getSelector(this).hitPoint(Object.assign({},dc),e,{target:this}):this.__hitWorld(dc))},cc.__hitWorld=function(t,e){const i=this.__;if(!i.hitSelf)return!1;const s=this.__world,n=this.__layout,r=s.width<10&&s.height<10;if(i.hitRadius&&(oc(lc,t,i.hitRadius),t=lc),rc(t,s,lc),i.hitBox||r){if(Nt.hitRadiusPoint(n.boxBounds,lc))return!0;if(r)return!1}return!n.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),n.boundsChanged||(n.hitCanvasChanged=!1)),this.__hit(lc,e)},cc.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},cc.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},cc.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},cc.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const uc=new _t,pc=t.UI.prototype;pc.__updateHitCanvas=function(){this.__box&&this.__box.__updateHitCanvas();const{hitCanvasManager:t}=this.leafer||this.parent&&this.parent.leafer||{};if(!t)return;const e=this.__,i=(e.__isAlphaPixelFill||e.__isCanvas)&&"pixel"===e.hitFill,s=e.__isAlphaPixelStroke&&"pixel"===e.hitStroke,n=i||s;this.__hitCanvas||(this.__hitCanvas=n?t.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):t.getPathType(this));const r=this.__hitCanvas;if(n){const{renderBounds:t}=this.__layout,n=Qt.image.hitCanvasSize,o=r.hitScale=Gt.set(0,0,n,n).getFitMatrix(t).a,{x:a,y:h,width:l,height:d}=Gt.set(t).scale(o);r.resize({width:l,height:d,pixelRatio:1}),r.clear(),sr.patternLocked=!0,this.__renderShape(r,{matrix:uc.setWith(this.__world).scaleWith(1/o).invertWith().translate(-a,-h),snapshot:!0,ignoreFill:!i,ignoreStroke:!s}),sr.patternLocked=!1,r.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(r),r.setStrokeOptions(e)},pc.__hit=function(t,e){if(this.__box&&this.__box.__hit(t))return!0;const i=this.__;if(i.__isHitPixel&&this.__hitPixel(t))return!0;const{hitFill:s}=i,n=(i.fill||i.__isCanvas)&&("path"===s||"pixel"===s&&!(i.__isAlphaPixelFill||i.__isCanvas))||"all"===s||e;if(n&&this.__hitFill(t))return!0;const{hitStroke:r,__maxStrokeWidth:o}=i,a=i.stroke&&("path"===r||"pixel"===r&&!i.__isAlphaPixelStroke)||"all"===r;if(!n&&!a)return!1;const h=2*t.radiusX;let l=h;if(a)switch(i.strokeAlign){case"inside":if(l+=2*o,!n&&this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h;break;case"center":l+=o;break;case"outside":if(l+=2*o,!n){if(!this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h}}return!!l&&this.__hitStroke(t,l)};const gc=t.UI.prototype,_c=t.Rect.prototype,fc=t.Box.prototype;_c.__updateHitCanvas=fc.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?gc.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},_c.__hitFill=fc.__hitFill=function(t){return this.__hitCanvas?gc.__hitFill.call(this,t):Nt.hitRadiusPoint(this.__layout.boxBounds,t)},t.Text.prototype.__drawHitPath=function(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__letterSpacing:n,__textDrawData:r}=this.__;t.beginPath(),n<0?this.__drawPathByBox(t):r.rows.forEach(n=>t.rect(n.x,n.y-s,n.width,e<i?i:e))},t.Group.prototype.pick=function(t,e){return e||(e=s),this.updateLayout(),Qt.getSelector(this).getByPoint(t,e.hitRadius||0,Object.assign(Object.assign({},e),{target:this}))};const mc=Me.prototype;function yc(t,e,i){t.__.__font?$h.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function vc(t,e,i,s,n){const r=i.__;c(t)?$h.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,r.__strokeWidth*e,r),s.stroke()),r.__useArrow&&$h.strokeArrow(t,i,s,n)}function xc(t,e,i,s,n){const r=i.__;c(t)?$h.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,r.__strokeWidth*e,r),$h.drawTextStroke(i,s,n))}function wc(t,e,i,s,n){const r=s.getSameCanvas(!0,!0);r.font=i.__.__font,xc(t,2,i,r,n),r.blendMode="outside"===e?"destination-out":"destination-in",$h.fillText(i,r,n),r.blendMode="normal",ho.copyCanvasByWorld(i,s,r),r.recycle(i.__nowWorld)}mc.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},mc.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},mc.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:r,radiusY:o}=t;e&&(s-=e.x,n-=e.y),Gt.set(s-r,n-o,2*r,2*o).scale(i).ceil();const{data:a}=this.context.getImageData(Gt.x,Gt.y,Gt.width||1,Gt.height||1);for(let t=0,e=a.length;t<e;t+=4)if(a[t+3]>0)return!0;return a[3]>0};const{getSpread:Ec,copyAndSpread:bc,toOuterOf:kc,getOuterOf:Tc,getByMove:Sc,move:Bc,getIntersectData:Pc}=Nt,Lc={};let Rc;const{stintSet:Cc}=g,{hasTransparent:Oc}=Zh;function Mc(t,e,i){if(!c(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:r}=i.__layout;switch(e.type){case"image":if(!e.url)return;s=Qh.image(i,t,e,r,!Rc||!Rc[e.url]);break;case"linear":s=tl.linearGradient(e,r);break;case"radial":s=tl.radialGradient(e,r);break;case"angular":s=tl.conicGradient(e,r);break;case"solid":const{type:o,color:a,opacity:h}=e;s={type:o,style:Zh.string(a,h)};break;default:n(e.r)||(s={type:"solid",style:Zh.string(e)})}if(s&&(s.originPaint=e,o(s.style)&&Oc(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const Dc={compute:function(t,e){const i=e.__,s=[];let n,r,o,a=i.__input[t];d(a)||(a=[a]),Rc=Qh.recycleImage(t,i);for(let i,n=0,r=a.length;n<r;n++)(i=Mc(t,a[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),r=!0),"fill"===t?(Cc(i,"__isAlphaPixelFill",n),Cc(i,"__isTransparentFill",r)):(Cc(i,"__isAlphaPixelStroke",n),Cc(i,"__isTransparentStroke",r),Cc(i,"__hasMultiStrokeStyle",o))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,yc(e,i,s)},fills:function(t,e,i,s){let n,r,o;for(let a=0,h=t.length;a<h;a++){if(n=t[a],r=n.originPaint,n.image){if(o?o++:o=1,Qh.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===o&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||r.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),r.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===r.scaleFixed||"zoom-in"===r.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}r.blendMode&&(i.blendMode=r.blendMode),yc(e,i,s),i.restore()}else r.blendMode?(i.saveBlendMode(r.blendMode),yc(e,i,s),i.restoreBlendMode()):yc(e,i,s)}},fillPathOrText:yc,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:r}=s.__textDrawData;let o;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(r){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>r.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)$h.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":vc(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),vc(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)vc(t,2,e,i,s);else{const{renderBounds:r}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),vc(t,2,e,o,s),o.clipUI(n),o.clearWorld(r),ho.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){$h.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":xc(t,1,e,i,s);break;case"inside":wc(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?xc(t,2,e,i,s):wc(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:r,decorationY:o}=n;for(let t=0,i=r.length;t<i;t++)s=r[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(o){const{decorationHeight:t}=n;r.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,r){let o;const a=s.__,{__hasMultiStrokeStyle:h}=a;h||n.setStroke(void 0,a.__strokeWidth*e,a);for(let l=0,d=t.length;l<d;l++)if(o=t[l],(!o.image||!Qh.checkImage(o,!1,s,n,r))&&o.style){if(h){const{strokeStyle:t}=o;t?n.setStroke(o.style,a.__getRealStrokeWidth(t)*e,a,t):n.setStroke(o.style,a.__strokeWidth*e,a)}else n.strokeStyle=o.style;o.originPaint.blendMode?(n.saveBlendMode(o.originPaint.blendMode),i?$h.drawTextStroke(s,n,r):n.stroke(),n.restoreBlendMode()):i?$h.drawTextStroke(s,n,r):n.stroke()}},shape:function(t,e,i){const s=e.getSameCanvas(),n=e.bounds,r=t.__nowWorld,o=t.__layout,a=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let h,l,d,c,u,p;kc(o.strokeSpread?(bc(Lc,o.boxBounds,o.strokeSpread),Lc):o.boxBounds,r,a);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(a))p=s,h=u=a,l=r;else{let s;if(Qt.fullImageShadow)s=a;else{const t=o.renderShapeSpread?Ec(n,k.swapAndScale(o.renderShapeSpread,g,_)):n;s=Pc(t,a)}c=n.getFitMatrix(s);let{a:f,d:m}=c;c.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,i),g*=f,_*=m),u=Tc(a,c),h=Sc(u,-c.e,-c.f),l=Tc(r,c),Bc(l,-c.e,-c.f);const y=i.matrix;y?(d=new _t(c),d.multiply(y),f*=y.scaleX,m*=y.scaleY):d=c,d.withScale(f,m),i=Object.assign(Object.assign({},i),{matrix:d})}return t.__renderShape(s,i),{canvas:s,matrix:d,fitMatrix:c,bounds:h,renderBounds:l,worldCanvas:p,shapeBounds:u,scaleX:g,scaleY:_}}};let Ic,Ac=new jt;const{isSame:Wc}=Nt;function Fc(t,e,i,s,n,r){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||Qh.createData(n,s,i,r),!0}function zc(t,e){Nc(t,Yo.LOAD,e)}function Uc(t,e){Nc(t,Yo.LOADED,e)}function Hc(t,e,i){e.error=i,t.forceUpdate("surface"),Nc(t,Yo.ERROR,e)}function Nc(t,e,i){t.hasEvent(e)&&t.emitEvent(new Yo(e,i))}function Yc(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Xc,translate:Vc}=Z,jc=new jt,Gc={},Kc={};function Zc(t,e,i,s){const n=o(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let qc={},Jc={a:1,b:0,c:0,d:1,e:0,f:0};const{get:$c,set:Qc,rotateOfOuter:tu,translate:eu,scaleOfOuter:iu,multiplyParent:su,scale:nu,rotate:ru,skew:ou}=Z;function au(t,e,i,s,n,r,o,a){o&&ru(t,o),a&&ou(t,a.x,a.y),n&&nu(t,n,r),eu(t,e.x+i,e.y+s)}const{get:hu,scale:lu,copy:du}=Z,{getFloorScale:cu}=D,{abs:uu}=Math;const pu={image:function(t,e,i,s,n){let r,o;const a=sr.get(i);return Ic&&i===Ic.paint&&Wc(s,Ic.boxBounds)?r=Ic.leafPaint:(r={type:i.type,image:a},a.hasAlphaPixel&&(r.isTransparent=!0),Ic=a.use>1?{leafPaint:r,paint:i,boxBounds:Ac.set(s)}:null),(n||a.loading)&&(o={image:a,attrName:e,attrValue:i}),a.ready?(Fc(t,e,i,a,r,s),n&&(zc(t,o),Uc(t,o))):a.error?n&&Hc(t,o,a.error):(n&&(Yc(t,!0),zc(t,o)),r.loadId=a.load(()=>{Yc(t,!1),t.destroyed||(Fc(t,e,i,a,r,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Uc(t,o)),r.loadId=void 0},e=>{Yc(t,!1),Hc(t,o,e),r.loadId=void 0},i.lod&&a.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),r},checkImage:function(t,e,i,s,n){const{scaleX:r,scaleY:o}=Qh.getImageRenderScaleData(t,i,s,n),{image:a,data:h,originPaint:l}=t,{exporting:d,snapshot:c}=n;return!(!h||t.patternId===r+"-"+o&&!d||c)&&(e&&(h.repeat?e=!1:l.changeful||"miniapp"===Qt.name&&qo.isResizing(i)||d||(e=Qt.image.isLarge(a,r,o)||a.width*r>8096||a.height*o>8096)),e?(i.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),Qh.drawImage(t,r,o,i,s,n),!0):(!t.style||l.sync||d?Qh.createPattern(t,i,s,n):Qh.createPatternTask(t,i,s,n),!1))},drawImage:function(t,e,i,s,n,r){const{data:o,image:a}=t,{blendMode:h}=t.originPaint,{opacity:l,transform:d}=o,c=a.getFull(o.filters),u=s.__;let p,{width:g,height:_}=a;(p=d&&!d.onlyScale||u.path||u.cornerRadius)||l||h?(n.save(),p&&n.clipUI(s),h&&(n.blendMode=h),l&&(n.opacity*=l),d&&n.transform(d),n.drawImage(c,0,0,g,_),n.restore()):(o.scaleX&&(g*=o.scaleX,_*=o.scaleY),n.drawImage(c,0,0,g,_))},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:r}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return r&&r.scaleX&&(n.scaleX*=Math.abs(r.scaleX),n.scaleY*=Math.abs(r.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(d(i)){let s,n,r,o,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(r||(r={}),r[a]=!0,sr.recyclePaint(s),n.loading&&(o||(o=e.__input&&e.__input[t]||[],d(o)||(o=[o])),n.unload(i[h].loadId,!o.some(t=>t.url===a))));return r}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=sr.patternTasker.add(()=>ve(this,void 0,void 0,function*(){Qh.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,i,s){let{scaleX:n,scaleY:r}=Qh.getImageRenderScaleData(t,e,i,s),o=n+"-"+r;if(t.patternId!==o&&!e.destroyed&&(!Qt.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:i,data:s}=t,{transform:a,gap:h}=s,l=Qh.getPatternFixScale(t,n,r);let d,c,u,{width:p,height:g}=i;l&&(n*=l,r*=l),p*=n,g*=r,h&&(c=h.x*n/uu(s.scaleX||1),u=h.y*r/uu(s.scaleY||1)),(a||1!==n||1!==r)&&(n*=cu(p+(c||0)),r*=cu(g+(u||0)),d=hu(),a&&du(d,a),lu(d,1/n,1/r));const _=i.getCanvas(p,g,s.opacity,s.filters,c,u,e.leafer&&e.leafer.config.smooth,s.interlace),f=i.getPattern(_,s.repeat||Qt.origin.noRepeat||"no-repeat",d,t);t.style=f,t.patternId=o}},getPatternFixScale:function(t,e,i){const{image:s}=t;let n,r=Qt.image.maxPatternSize,o=s.width*s.height;return s.isSVG?e>1&&(n=Math.ceil(e)/e):r>o&&(r=o),(o*=e*i)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,s){t.data=Qh.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=jc.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:n}=i,{opacity:r,mode:a,align:l,offset:d,scale:u,size:p,rotation:g,skew:_,clipSize:f,repeat:m,gap:y,filters:v,interlace:x}=t,w=e.width===s&&e.height===n,E={mode:a},b="center"!==l&&(g||0)%180==90;let k,T;switch(Nt.set(Kc,0,0,b?n:s,b?s:n),a&&"cover"!==a&&"fit"!==a?((u||p)&&(D.getScaleData(u,p,i,Gc),k=Gc.scaleX,T=Gc.scaleY),(l||y||m)&&(k&&Nt.scale(Kc,k,T,!0),l&&Tt.toPoint(l,Kc,e,Kc,!0,!0))):w&&!g||(k=T=Nt.getFitScale(e,Kc,"fit"!==a),Nt.put(e,i,l,k,!1,Kc),Nt.scale(Kc,k,T,!0)),d&&at.move(Kc,d),a){case"stretch":w?k&&(k=T=void 0):(k=e.width/s,T=e.height/n,Qh.stretchMode(E,e,k,T));break;case"normal":case"clip":if(Kc.x||Kc.y||k||f||g||_){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),Qh.clipMode(E,e,Kc.x,Kc.y,k,T,g,_,t,i),t&&(k=k?k*t:t,T=T?T*i:i)}break;case"repeat":(!w||k||g||_)&&Qh.repeatMode(E,e,s,n,Kc.x,Kc.y,k,T,g,_,l,t.freeTransform),m||(E.repeat="repeat");const i=c(m);(y||i)&&(E.gap=function(t,e,i,s,n){let r,o;c(t)?(r=t.x,o=t.y):r=o=t;return{x:Zc(r,i,n.width,e&&e.x),y:Zc(o,s,n.height,e&&e.y)}}(y,i&&m,Kc.width,Kc.height,e));break;default:k&&Qh.fillOrFitMode(E,e,Kc.x,Kc.y,k,T,g)}return E.transform||(e.x||e.y)&&Vc(E.transform=Xc(),e.x,e.y),k&&(E.scaleX=k,E.scaleY=T),r&&r<1&&(E.opacity=r),v&&(E.filters=v),m&&(E.repeat=o(m)?"x"===m?"repeat-x":"repeat-y":"repeat"),x&&(E.interlace=h(x)||"percent"===x.type?{type:"x",offset:x}:x),E},stretchMode:function(t,e,i,s){const n=$c(),{x:r,y:o}=e;r||o?eu(n,r,o):n.onlyScale=!0,nu(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,r,o){const a=$c();eu(a,e.x+i,e.y+s),nu(a,n,r),o&&tu(a,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=a},clipMode:function(t,e,i,s,n,r,o,a,h,l){const d=$c();au(d,e,i,s,n,r,o,a),h&&(o||a?(Qc(Jc),iu(Jc,e,h,l),su(d,Jc)):iu(d,e,h,l)),t.transform=d},repeatMode:function(t,e,i,s,n,r,o,a,h,l,d,c){const u=$c();if(c)au(u,e,n,r,o,a,h,l);else{if(h)if("center"===d)tu(u,{x:i/2,y:s/2},h);else switch(ru(u,h),h){case 90:eu(u,s,0);break;case 180:eu(u,i,s);break;case 270:eu(u,0,i)}qc.x=e.x+n,qc.y=e.y+r,eu(u,qc.x,qc.y),o&&iu(u,qc,o,a)}t.transform=u}},{toPoint:gu}=Et,{hasTransparent:_u}=Zh,fu={},mu={};function yu(t,e,i,s){if(i){let n,r,a,h;for(let t=0,l=i.length;t<l;t++)n=i[t],o(n)?(a=t/(l-1),r=Zh.string(n,s)):(a=n.offset,r=Zh.string(n.color,s)),e.addColorStop(a,r),!h&&_u(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:vu,getDistance:xu}=at,{get:wu,rotateOfOuter:Eu,scaleOfOuter:bu}=Z,{toPoint:ku}=Et,Tu={},Su={};function Bu(t,e,i,s,n){let r;const{width:o,height:a}=t;if(o!==a||s){const t=vu(e,i);r=wu(),n?(bu(r,e,o/a*(s||1),1),Eu(r,e,t+90)):(bu(r,e,1,o/a*(s||1)),Eu(r,e,t))}return r}const{getDistance:Pu}=at,{toPoint:Lu}=Et,Ru={},Cu={};const Ou={linearGradient:function(t,e){let{from:i,to:s,type:n,opacity:r}=t;gu(i||"top",e,fu),gu(s||"bottom",e,mu);const o=Qt.canvas.createLinearGradient(fu.x,fu.y,mu.x,mu.y),a={type:n,style:o};return yu(a,o,t.stops,r),a},radialGradient:function(t,e){let{from:i,to:s,type:n,opacity:r,stretch:o}=t;ku(i||"center",e,Tu),ku(s||"bottom",e,Su);const a=Qt.canvas.createRadialGradient(Tu.x,Tu.y,0,Tu.x,Tu.y,xu(Tu,Su)),h={type:n,style:a};yu(h,a,t.stops,r);const l=Bu(e,Tu,Su,o,!0);return l&&(h.transform=l),h},conicGradient:function(t,e){let{from:i,to:s,type:n,opacity:r,stretch:o}=t;Lu(i||"center",e,Ru),Lu(s||"bottom",e,Cu);const a=Qt.conicGradientSupport?Qt.canvas.createConicGradient(0,Ru.x,Ru.y):Qt.canvas.createRadialGradient(Ru.x,Ru.y,0,Ru.x,Ru.y,Pu(Ru,Cu)),h={type:n,style:a};yu(h,a,t.stops,r);const l=Bu(e,Ru,Cu,o||1,Qt.conicGradientRotate90);return l&&(h.transform=l),h},getTransform:Bu},{copy:Mu,move:Du,toOffsetOutBounds:Iu}=Nt,{max:Au,abs:Wu}=Math,Fu={},zu=new _t,Uu={};function Hu(t,e){let i,s,n,r,o=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,r=1.5*(t.blur||0),n=Wu(t.spread||0),o=Au(o,n+r-s),a=Au(a,n+r+i),h=Au(h,n+r+s),l=Au(l,n+r-i)}),o===a&&a===h&&h===l?o:[o,a,h,l]}function Nu(t,e,i){const{shapeBounds:s}=i;let n,r;Qt.fullImageShadow?(Mu(Fu,t.bounds),Du(Fu,e.x-s.x,e.y-s.y),n=t.bounds,r=Fu):(n=s,r=e),t.copyWorld(i.canvas,n,r)}const{toOffsetOutBounds:Yu}=Nt,Xu={};const Vu=Hu;const ju={shadow:function(t,e,i){let s,n;const{__nowWorld:r}=t,{shadow:o}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;Iu(h,Uu,l),o.forEach((o,_)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}p.setWorldShadow(Uu.offsetX+(o.x||0)*c*f,Uu.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f,Zh.string(o.color)),n=el.getShadowTransform(t,p,i,o,Uu,f),n&&p.setTransform(n),Nu(p,Uu,i),n&&p.resetTransform(),s=l,o.box&&(p.restore(),p.save(),a&&(p.copyWorld(p,l,r,"copy"),s=r),a?p.copyWorld(a,r,r,"destination-out"):p.copyWorld(i.canvas,d,h,"destination-out")),ho.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:r}=t,{innerShadow:o}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;Yu(h,Xu,l),o.forEach((o,_)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}p.save(),p.setWorldShadow(Xu.offsetX+(o.x||0)*c*f,Xu.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f),n=el.getShadowTransform(t,p,i,o,Xu,f,!0),n&&p.setTransform(n),Nu(p,Xu,i),p.restore(),a?(p.copyWorld(p,l,r,"copy"),p.copyWorld(a,r,r,"source-out"),s=r):(p.copyWorld(i.canvas,d,h,"source-out"),s=l),p.fillWorld(s,Zh.string(o.color),"source-in"),ho.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Hu,getShadowTransform:function(t,e,i,s,n,r,o){if(s.spread){const i=2*s.spread*r*(o?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return zu.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),zu}},isTransformShadow(t){},getInnerShadowSpread:Vu},{excludeRenderBounds:Gu}=mo;let Ku;function Zu(t,e,i,s,n,r,o,a){switch(e){case"grayscale":Ku||(Ku=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,r){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),r&&s.recycle(o);Ju(t,e,i,1,n,r)}(t,i,s,n,o,a);break;case"opacity-path":Ju(t,i,s,r,o,a);break;case"path":a&&i.restore()}}function qu(t){return t.getSameCanvas(!1,!0)}function Ju(t,e,i,s,n,r){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),r?i.recycle(o):i.clearWorld(o)}t.Group.prototype.__renderMask=function(t,e){let i,s,n,r,o,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++){if(i=h[l],a=i.__.mask,a){o&&(Zu(this,o,t,n,s,r,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||Gu(i,e)||i.__render(t,e),r=i.__.opacity,Ku=!1,"path"===a||"clipping-path"===a?(r<1?(o="opacity-path",n||(n=qu(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===a?"grayscale":"alpha",s||(s=qu(t)),n||(n=qu(t)),i.__render(s,e));continue}const d=1===r&&i.__.__blendMode;d&&Zu(this,o,t,n,s,r,void 0,!1),Gu(i,e)||i.__render(n||t,e),d&&Zu(this,o,t,n,s,r,d,!1)}Zu(this,o,t,n,s,r,void 0,!0)};const $u=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qu=$u+"_#~&*+\\=|≮≯≈≠=…",tp=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 ep(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ip=ep("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),sp=ep("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),np=ep($u),rp=ep(Qu),op=ep("- —/~|┆·");var ap;!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"}(ap||(ap={}));const{Letter:hp,Single:lp,Before:dp,After:cp,Symbol:up,Break:pp}=ap;function gp(t){return ip[t]?hp:op[t]?pp:sp[t]?dp:np[t]?cp:rp[t]?up:tp.test(t)?lp:hp}const _p={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let r=n-1;r>-1&&(i=e[r].data[0]," "===i.char);r--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function fp(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:mp}=_p,{Letter:yp,Single:vp,Before:xp,After:wp,Symbol:Ep,Break:bp}=ap;let kp,Tp,Sp,Bp,Pp,Lp,Rp,Cp,Op,Mp,Dp,Ip,Ap,Wp,Fp,zp,Up,Hp=[];function Np(t,e){Op&&!Cp&&(Cp=Op),kp.data.push({char:t,width:e}),Sp+=e}function Yp(){Bp+=Sp,kp.width=Sp,Tp.words.push(kp),kp={data:[]},Sp=0}function Xp(){Wp&&(Fp.paraNumber++,Tp.paraStart=!0,Wp=!1),Op&&(Tp.startCharSize=Cp,Tp.endCharSize=Op,Cp=0),Tp.width=Bp,zp.width?mp(Tp):Up&&Vp(),Hp.push(Tp),Tp={words:[]},Bp=0}function Vp(){Bp>(Fp.maxWidth||0)&&(Fp.maxWidth=Bp)}const{top:jp,right:Gp,bottom:Kp,left:Zp}=t.Direction4;function qp(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 Jp={getDrawData:function(t,e){o(t)||(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,r=e.__getInput("height")||0;const{__padding:a}=e;a&&(n?(i=a[Zp],n-=a[Gp]+a[Zp],!n&&(n=.01)):e.autoSizeAlign||(i=a[Zp]),r?(s=a[jp],r-=a[jp]+a[Kp],!r&&(r=.01)):e.autoSizeAlign||(s=a[jp]));const h={bounds:{x:i,y:s,width:n,height:r},rows:[],paraNumber:0,font:Qt.canvas.font=e.__font};return function(t,e,i){Fp=t,Hp=t.rows,zp=t.bounds,Up=!zp.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:r}=i,{canvas:o}=Qt,{width:a}=zp;if(i.__isCharMode){const t="none"!==i.textWrap,h="break"===i.textWrap;Wp=!0,Dp=null,Cp=Rp=Op=Sp=Bp=0,kp={data:[]},Tp={words:[]},s&&(e=[...e]);for(let i=0,l=e.length;i<l;i++)Lp=e[i],"\n"===Lp?(Sp&&Yp(),Tp.paraEnd=!0,Xp(),Wp=!0):(Mp=gp(Lp),Mp===yp&&"none"!==r&&(Lp=fp(Lp,r,!Sp)),Rp=o.measureText(Lp).width,s&&(s<0&&(Op=Rp),Rp+=s),Ip=Mp===vp&&(Dp===vp||Dp===yp)||Dp===vp&&Mp!==wp,Ap=!(Mp!==xp&&Mp!==vp||Dp!==Ep&&Dp!==wp),Pp=Wp&&n?a-n:a,t&&a&&Bp+Sp+Rp>Pp&&(h?(Sp&&Yp(),Bp&&Xp()):(Ap||(Ap=Mp===yp&&Dp==wp),Ip||Ap||Mp===bp||Mp===xp||Mp===vp||Sp+Rp>Pp?(Sp&&Yp(),Bp&&Xp()):Bp&&Xp()))," "===Lp&&!0!==Wp&&Bp+Sp===0||(Mp===bp?(" "===Lp&&Sp&&Yp(),Np(Lp,Rp),Yp()):Ip||Ap?(Sp&&Yp(),Np(Lp,Rp)):Np(Lp,Rp)),Dp=Mp);Sp&&Yp(),Bp&&Xp(),Hp.length>0&&(Hp[Hp.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Fp.paraNumber++,Bp=o.measureText(t).width,Hp.push({x:n||0,text:t,width:Bp,paraStart:!0}),Up&&Vp()})}(h,t,e),a&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":qp(e,"x",t[Zp]);break;case"right":qp(e,"x",-t[Gp])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":qp(e,"y",t[jp]);break;case"bottom":qp(e,"y",-t[Kp])}}(a,h,e,n,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:r,__baseLine:o,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:p,y:g,width:_,height:f}=s,m=r*n+(c?c*(t.paraNumber-1):0),y=o;if(h&&m>f)m=Math.max(e.__autoHeight?m:f,r),n>1&&(t.overflow=n);else if(f||u)switch(d){case"middle":g+=(f-m)/2;break;case"bottom":g+=f-m}y+=g;let v,x,w,E=_||u?_:t.maxWidth;for(let o=0,d=n;o<d;o++){if(v=i[o],v.x=p,v.width<_||v.width>_&&!h)switch(l){case"center":v.x+=(E-v.width)/2;break;case"right":v.x+=E-v.width}v.paraStart&&c&&o>0&&(y+=c),v.y=y,y+=r,t.overflow>o&&y>m&&(v.isOverflow=!0,t.overflow=o+1),x=v.x,w=v.width,a<0&&(v.width<0?(w=-v.width+e.fontSize+a,x-=w,w+=e.fontSize):w-=a),x<s.x&&(s.x=x),w>s.width&&(s.width=w),h&&_&&_<w&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=m}(h,e),e.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:r,__letterSpacing:o}=e,a=i&&n.includes("both"),h=a||i&&n.includes("justify"),l=h&&n.includes("letter");let d,c,u,p,g,_,f,m,y,v;s.forEach(t=>{t.words&&(g=r&&t.paraStart?r:0,m=t.words.length,h&&(v=!t.paraEnd||a,c=i-t.width-g,l?p=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?c/(m-1):0),_=o||t.isOverflow||l?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===_?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,d=t.x,t.data=[],t.words.forEach((e,i)=>{1===_?(f={char:"",x:d},d=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,d,f),(t.isOverflow||" "!==f.char)&&t.data.push(f)):d=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,d,t.data,t.isOverflow,v&&p),v&&(y=i===m-1,u?y||(d+=u,t.width+=u):p&&(t.width+=p*(e.data.length-(y?1:0))))})),t.words=null)})}(h,e,n),h.overflow&&function(t,e,i,s){const{rows:n,overflow:r}=t;let{textOverflow:o}=e;if(r&&n.splice(r),s&&o&&"show"!==o){let t,a;"hide"===o?o="":"ellipsis"===o&&(o="...");const h=o?Qt.canvas.measureText(o).width:0,l=i+s-h;("none"===e.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],a=t.x+t.width,!(s===i&&a<l));s--){if(a<l&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=h,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(h,e,i,n),"none"!==e.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:r}=e;switch(t.decorationHeight=n/11,c(r)?(i=r.type,r.color&&(t.decorationColor=Zh.string(r.color)),r.offset&&(s=Math.min(.3*n,Math.max(r.offset,.15*-n)))):i=r,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(h,e),h}};const $p={string:function(t,e){if(!t)return"#000";const i=h(e)&&e<1;if(o(t)){if(!i||!Zh.object)return t;t=Zh.object(t)}let s=n(t.a)?1:t.a;i&&(s*=e);const r=t.r+","+t.g+","+t.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}};function Qp(t){return t?d(t)?t:[t]:[]}Object.assign(Kh,Jp),Object.assign(Zh,$p),Object.assign($h,Dc),Object.assign(Qh,pu),Object.assign(tl,Ou),Object.assign(el,ju),Object.assign(de,{interaction:(t,e,i,s)=>new ic(t,e,i,s),hitCanvas:(t,e)=>new Eh(t,e),hitCanvasManager:()=>new nc}),kh();class tg extends Fo{get list(){return Qp(this.value)}get oldList(){return Qp(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function eg(t){return(e,i)=>{const s="_"+i;hr(e,i,{get(){return this[s]},set(e){const n=this[s];if(n!==e){const r=this;if(r.config){const t="target"===i;if(t){const{beforeSelect:t}=r.config;if(t){const i=t({target:e});if(c(i))e=i;else if(!1===i)return}r.setDimOthers(!1),r.setBright(!1),d(e)&&e.length>1&&e[0].locked&&e.splice(0,1),r.single&&(delete r.element.syncEventer,delete r.element.__world.ignorePixelSnap)}const s=t?tg.BEFORE_SELECT:tg.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new tg(s,{editor:r,value:e,oldValue:n}))}this[s]=e,t(this,n)}}})}}tg.BEFORE_SELECT="editor.before_select",tg.SELECT="editor.select",tg.AFTER_SELECT="editor.after_select",tg.BEFORE_HOVER="editor.before_hover",tg.HOVER="editor.hover";const{abs:ig}=Math,{copy:sg}=Z,{setListWithFn:ng}=Nt,{worldBounds:rg}=mo,og={a:1,b:0,c:0,d:1,e:0,f:0},ag={x:0,y:0,width:0,height:0};class hg extends t.UI{constructor(){super(),this.list=[],this.visible=0,this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){e&&this.set(e),this.target=t,this.update()}update(t){const{list:e}=this;e.length?(ng(ag,e,rg),t&&this.set(t),this.set(ag),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const n=this.__,{stroke:r,strokeWidth:a,fill:h}=n,{bounds:l}=e;for(let d=0;d<i.length;d++){s=i[d];const{worldTransform:c,worldRenderBounds:u}=s;if(u.width&&u.height&&(!l||l.hit(u,e.matrix))){const i=ig(c.scaleX),l=ig(c.scaleY);if(sg(og,c),og.half=a%2,t.setWorld(og,e.matrix),t.beginPath(),"path"===this.strokePathType||s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=a/Math.max(i,l),n.shadow){const e=n.shadow[0],{scaleX:i,scaleY:s}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*s,e.blur*i,Zh.string(e.color))}r&&(o(r)?$h.stroke(r,this,t,e):$h.strokes(r,this,t,e)),h&&(o(h)?$h.fill(h,this,t,e):$h.fills(h,this,t,e)),n.shadow&&t.restore()}}n.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}ye([eg(function(t){const e=t.target;t.list=e?d(e)?e:[e]:[]})],hg.prototype,"target",void 0),ye([Lr("render-path")],hg.prototype,"strokePathType",void 0);class lg extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=0,this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:n}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:n},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const dg={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return cg([t],i,e),i}};function cg(t,e,i){let s,n;for(let r=0,o=t.length;r<o;r++)if(s=t[r],n=s.__,n.hittable&&n.visible&&!n.locked&&i.hit(s.__world)){if(n.editable){if(s.isBranch&&!n.hitChildren){n.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&n.hitSelf&&e.push(s)}s.isBranch&&cg(s.children,e,i)}}const{findOne:ug,findByBounds:pg}=dg;class gg extends t.Group{get dragging(){return!!this.originList}get running(){const{editor:t,app:e}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector&&e&&"normal"===e.mode}get isMoveMode(){const{app:t}=this;return t&&t.interaction.moveMode}constructor(t){super(),this.hoverStroker=new hg,this.targetStroker=new hg,this.bounds=new jt,this.selectArea=new lg,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{hoverTarget:e,mergeConfig:i}=t,s=Object.assign({},i);e&&e.editConfig&&Object.assign(s,e.editConfig);const{stroke:n,strokeWidth:r,hover:o,hoverStyle:a}=s;this.hoverStroker.setTarget(o?e:null,Object.assign({stroke:n,strokeWidth:r},a||{}))}}onSelect(){this.running&&(this.targetStroker.setTarget(this.editor.list),this.hoverStroker.target=null)}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedPathType:i,selectedStyle:s}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2),strokePathType:i},s||{}))}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i,selectKeep:s}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(s||(e.target=null))}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(this.isHoldMultipleSelectKey(t)||this.editor.mergedConfig.selectKeep||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:n,y:r}=t.getInnerPoint(this);this.bounds.set(n,r),this.selectArea.setStyle({visible:!0,stroke:i,x:n,y:r},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new xh(pg(e.app,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach(e=>{n.has(e)||t.push(e)}),n.forEach(e=>{this.originList.has(e)||t.push(e)}),(t.length!==e.list.length||e.list.some((e,i)=>e!==t[i]))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=0)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){const{boxSelect:e,multipleSelect:i}=this.editor.mergeConfig;return!(!(this.running&&i&&e)||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||this.isHoldMultipleSelectKey(t)&&!ug(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new xh(this.editor.editBox.rect)};return ug(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):ug(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(this.isHoldMultipleSelectKey(t)||i)}isHoldMultipleSelectKey(t){const{multipleSelectKey:e}=this.editor.mergedConfig;return e?t.isHoldKeys(e):t.shiftKey}__listenEvents(){const{editor:e}=this;e.waitLeafer(()=>{const{app:i}=e;i.selector.proxy=e,this.__eventIds=[e.on_([[tg.HOVER,this.onHover,this],[tg.SELECT,this.onSelect,this]]),i.on_([[t.PointerEvent.MOVE,this.onPointerMove,this],[t.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this],[t.PointerEvent.TAP,this.onTap,this],[t.DragEvent.START,this.onDragStart,this,!0],[t.DragEvent.DRAG,this.onDrag,this],[t.DragEvent.END,this.onDragEnd,this],[t.MoveEvent.MOVE,this.onAutoMove,this],[[t.ZoomEvent.ZOOM,t.MoveEvent.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:_g,top:fg,topRight:mg,right:yg,bottomRight:vg,bottom:xg,bottomLeft:wg,left:Eg}=t.Direction9,{toPoint:bg}=Et,{within:kg,sign:Tg}=D,{abs:Sg}=Math,Bg={getScaleData(t,e,i,s,n,r,o,a){let l,d,c={},u=1,p=1;const{boxBounds:g,widthRange:_,heightRange:f,dragBounds:m,worldBoxBounds:y}=t,{width:v,height:x}=e,w=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,b=Tg(w),k=Tg(E),T=a?w:b*g.width/v,S=a?E:k*g.height/x;if(h(s))u=p=Math.sqrt(s);else{r&&(s.x*=2,s.y*=2),s.x*=a?w:b,s.y*=a?E:k;const t=(-s.y+x)/x,e=(s.x+v)/v,o=(s.y+x)/x,h=(-s.x+v)/v;switch(i){case fg:p=t,l="bottom";break;case yg:u=e,l="left";break;case xg:p=o,l="top";break;case Eg:u=h,l="right";break;case _g:p=t,u=h,l="bottom-right";break;case mg:p=t,u=e,l="bottom-left";break;case vg:p=o,u=e,l="top-left";break;case wg:p=o,u=h,l="top-right"}if(n)if("corner"===n&&i%2)n=!1;else switch(i){case fg:case xg:u=p;break;case Eg:case yg:p=u;break;default:d=Math.sqrt(Sg(u*p)),u=Tg(u)*d,p=Tg(p)*d}}const B=1!==u,P=1!==p;if(B&&(u/=T),P&&(p/=S),!o){const{worldTransform:e}=t;u<0&&(u=1/g.width/e.scaleX),p<0&&(p=1/g.height/e.scaleY)}if(bg(r||l,g,c,!0),m){const e={x:u,y:p};Dd.limitScaleOf(t,c,e,n),u=e.x,p=e.y}if(B&&_){const e=g.width*t.scaleX;u=kg(e*u,_)/e}if(P&&f){const e=g.height*t.scaleY;p=kg(e*p,f)/e}return B&&Sg(u*y.width)<1&&(u=Tg(u)/y.width),P&&Sg(p*y.height)<1&&(p=Tg(p)/y.height),n&&u!==p&&(d=Math.min(Sg(u),Sg(p)),u=Tg(u)*d,p=Tg(p)*d),isFinite(u)||(u=1),isFinite(p)||(p=1),{origin:c,scaleX:u,scaleY:p,direction:i,lockRatio:n,around:r}},getRotateData(t,e,i,s,n){let r,o={};switch(e){case _g:r="bottom-right";break;case mg:r="bottom-left";break;case vg:r="top-left";break;case wg:r="top-right";break;default:r="center"}return bg(n||r,t.boxBounds,o,!0),{origin:o,rotation:at.getRotation(s,t.getWorldPointByBox(o),i)}},getSkewData(t,e,i,s){let n,r,o={},a=0,h=0;switch(e){case fg:case _g:r={x:.5,y:0},n="bottom",a=1;break;case xg:case vg:r={x:.5,y:1},n="top",a=1;break;case Eg:case wg:r={x:0,y:.5},n="right",h=1;break;case yg:case mg:r={x:1,y:.5},n="left",h=1}const{width:l,height:d}=t;r.x=r.x*l,r.y=r.y*d,bg(s||n,t,o,!0);const c=at.getRotation(r,o,{x:r.x+(a?i.x:0),y:r.y+(h?i.y:0)});return a?a=-c:h=c,{origin:o,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case Eg:t=yg;break;case _g:t=mg;break;case wg:t=vg;break;case yg:t=Eg;break;case mg:t=_g;break;case vg:t=wg}if(i)switch(t){case fg:t=xg;break;case _g:t=wg;break;case mg:t=vg;break;case xg:t=fg;break;case wg:t=_g;break;case vg:t=mg}return t}},Pg={};function Lg(t,e){const{enterPoint:i,dragging:s,skewing:n,resizing:r,flippedX:o,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return Rg(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:p,moveable:g,resizeable:_,rotateable:f,skewable:m}=t.mergeConfig;if("move"===l)return i.cursor=d,void(g||(i.visible=!1));if("button"===l)return void(i.cursor||(i.cursor="pointer"));let y=l.includes("resize");y&&f&&(t.isHoldRotateKey(e)||!_)&&(y=!1);const v=m&&!y&&("resize-line"===i.name||"skew"===l),x=s?n?p:r?c:u:v?p:y?c:u;h+=45*(Bg.getFlipDirection(i.direction,o,a)+1),h=2*Math.round(D.formatRotation(h,!0)/2);const{url:w,x:E,y:b}=x,k=w+h;Pg[k]?i.cursor=Pg[k]:Pg[k]=i.cursor={url:Cg(w,h),x:E,y:b}}function Rg(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function Cg(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Og extends t.Box{constructor(t){super(t),this.useFastShadow=!0}}const Mg=["top","right","bottom","left"],Dg=void 0;class Ig extends t.Group{get mergeConfig(){const{config:t}=this,{mergeConfig:e,editBox:i}=this.editor;return this.mergedConfig=t&&i!==this?Object.assign(Object.assign({},e),t):e}get target(){return this._target||this.editor.element}set target(t){this._target=t}get single(){return!!this._target||this.editor.single}get transformTool(){return this._transformTool||this.editor}set transformTool(t){this._transformTool=t}get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}get canUse(){return this.app&&this.editor.editing}get canGesture(){if(!this.canUse)return!1;const{moveable:t,resizeable:e,rotateable:i}=this.mergeConfig;return o(t)||o(e)||o(i)}get canDragLimitAnimate(){return this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds}constructor(e){super(),this.view=new t.Group,this.rect=new Og({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Og({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:n,rotatePoints:r,resizeLines:o,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Og({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),r.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Og({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),o.push(e),this.listenPointEvents(e,"resize",s)),i=new Og({name:"resize-point",hitRadius:5}),n.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),this.listenPointEvents(a,"move",8),s.addMany(...r,a,h,l,...o,...n),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:n,resizePoints:o,resizeLines:a}=this,{stroke:h,strokeWidth:l,ignorePixelSnap:d}=e,c=this.getPointsStyle(),u=this.getMiddlePointsStyle(),p=this.getResizeLinesStyle();let _;this.visible=!t.locked;for(let t=0;t<8;t++)_=o[t],_.set(this.getPointStyle(t%2?u[(t-1)/2%u.length]:c[t/2%c.length])),_.rotation=(t-(t%2?1:0))/2*90,t%2&&a[(t-1)/2].set(Object.assign({pointType:"resize",rotation:(t-1)/2*90},p[(t-1)/2%p.length]||{}));n.set(this.getPointStyle(e.circle||e.rotatePoint||c[0])),s.set(Object.assign({stroke:h,strokeWidth:l,opacity:1,editConfig:Dg},e.rect||{}));const f=r(e.rectThrough)?i:e.rectThrough;s.hittable=!f,f&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),i&&g.stintSet(t.__world,"ignorePixelSnap",d),Rg(this)}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:n,rotation:r,skewX:o,skewY:a,width:h,height:l}=this.target.getLayoutBounds("box",t,!0);this.visible=!this.target.locked,this.set({x:e,y:i,scaleX:s,scaleY:n,rotation:r,skewX:o,skewY:a}),this.updateBounds({x:0,y:0,width:h,height:l})}unload(){this.visible=!1,this.app&&(this.rect.syncEventer=this.app.interaction.bottomList=null)}updateBounds(t){const{editor:e,mergeConfig:i,single:s,rect:n,circle:r,buttons:o,resizePoints:a,rotatePoints:l,resizeLines:d}=this,{editMask:c}=e,{middlePoint:u,resizeable:p,rotateable:g,hideOnSmall:_,editBox:f,mask:m,dimOthers:y,bright:v,spread:x,hideRotatePoints:w,hideResizeLines:E}=i;if(c.visible=!!m||0,e.setDimOthers(y),e.setBright(!!y||v),x&&Nt.spread(t,x),this.view.worldOpacity){const{width:e,height:c}=t,m=h(_)?_:10,y=f&&!(_&&e<m&&c<m);let v,x,b,k={};for(let i=0;i<8;i++)Et.toPoint(Et.directionData[i],t,k),x=a[i],v=l[i],x.set(k),v.set(k),x.visible=y&&!(!p&&!g),v.visible=y&&g&&p&&!w,i%2&&(b=d[(i-1)/2],b.set(k),b.visible=x.visible&&!E,x.visible=v.visible=y&&!!u,(i+1)/2%2?(b.width=e+b.height,_&&2*x.width>e&&(x.visible=!1)):(b.width=c+b.height,_&&2*x.width>c&&(x.visible=!1)));r.visible=y&&g&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!s||f})),o.visible=y&&o.children.length>0||0,o.visible&&this.layoutButtons()}else n.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:n}=this.mergedConfig,r=Mg.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,e||i,!!n)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:n}=this.mergedConfig,{flippedX:r,flippedY:o}=this;let a=Mg.indexOf(e);(a%2&&r||(a+1)%2&&o)&&i&&(a=(a+2)%4);const h=i?Bg.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!n),i&&(t.rotation=90*(h-a)),t.scaleX=r?-1:1,t.scaleY=o?-1:1}setButtonPosition(t,e,i,s){const n=this.resizePoints[2*e+1],r=e%2,o=e&&3!==e?1:-1,a=(i+(e%2?(s?n.width:0)+t.boxBounds.width:(s?n.height:0)+t.boxBounds.height)/2)*o;r?(t.x=n.x+a,t.y=n.y):(t.x=n.x,t.y=n.y+a)}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:n,pointRadius:r}=this.mergedConfig,o={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",opacity:1,width:n,height:n,cornerRadius:r,offsetX:0,offsetY:0,editConfig:Dg};return t?Object.assign(o,t):o}getPointsStyle(){const{point:t}=this.mergedConfig;return d(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return d(t)?t:t?[t]:this.getPointsStyle()}getResizeLinesStyle(){const{resizeLine:t}=this.mergedConfig;return d(t)?t:[t]}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:n,rotateable:r,skewable:o}=this.mergeConfig;"move"===i?s&&(this.moving=!0):(i.includes("rotate")||this.isHoldRotateKey(t)||!n?(r&&(this.rotating=!0),"resize-rotate"===i?n&&(this.resizing=!0):"resize-line"===e.name&&(o&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&n&&(this.resizing=!0),"skew"===i&&o&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:n,skewing:r}=this;if(i)e.onMove(t);else if(s||n||r){const i=t.current;i.pointType&&(this.enterPoint=i),n&&e.onRotate(t),s&&e.onScale(t),r&&e.onSkew(t)}Lg(this,t)}onDragEnd(t){this.onTransformEnd(t),this.dragPoint=null}onTransformStart(t){(this.moving||this.gesturing)&&(this.editor.opacity=this.mergedConfig.hideOnMove?0:1),this.resizing&&(qo.resizingKeys=this.editor.leafList.keys);const{dragStartData:e,target:i}=this;e.x=t.x,e.y=t.y,e.totalOffset={x:0,y:0},e.point={x:i.x,y:i.y},e.bounds=Object.assign({},i.getLayoutBounds("box","local")),e.rotation=i.rotation}onTransformEnd(e){this.canDragLimitAnimate&&(e instanceof t.DragEvent||e instanceof t.MoveEvent)&&this.transformTool.onMove(e),this.resizing&&(qo.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(e){if(this.canGesture&&"drag"!==e.moveType&&(e.stop(),o(this.mergedConfig.moveable)))switch(this.gesturing=this.moving=!0,e.type){case t.MoveEvent.START:this.onTransformStart(e);break;case t.MoveEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onMove(e)}}onScale(e){if(this.canGesture&&(e.stop(),o(this.mergedConfig.resizeable)))switch(this.gesturing=this.resizing=!0,e.type){case t.ZoomEvent.START:this.onTransformStart(e);break;case t.ZoomEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onScale(e)}}onRotate(e){if(this.canGesture&&(e.stop(),o(this.mergedConfig.rotateable)))switch(this.gesturing=this.rotating=!0,e.type){case t.ZoomEvent.START:this.onTransformStart(e);break;case t.ZoomEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onRotate(e)}}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){Lg(this,t)}onArrow(t){if(this.canUse&&this.mergeConfig.keyEvent){let e=0,i=0;const s=t.shiftKey?10:1;switch(t.code){case"ArrowDown":i=s;break;case"ArrowUp":i=-s;break;case"ArrowLeft":e=-s;break;case"ArrowRight":e=s}(e||i)&&this.transformTool.move(e,i)}}onDoubleTap(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"double"!==e||i||this.openInner(t)}onLongPress(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"long"===e&&i&&this.openInner(t)}openInner(e){const{editor:i,target:s}=this;if(this.single){if(s.locked)return;if(s.isBranch&&!s.editInner){if(s.textBox){const{children:e}=s,n=e.find(e=>e.editable&&e instanceof t.Text)||e.find(e=>e instanceof t.Text);if(n)return i.openInnerEditor(n)}i.openGroup(s),i.target=i.selector.findDeepOne(e)}else i.openInnerEditor()}}listenPointEvents(e,i,s){e.direction=s,e.pointType=i,this.__eventIds.push(e.on_([[t.DragEvent.START,this.onDragStart,this],[t.DragEvent.DRAG,this.onDrag,this],[t.DragEvent.END,this.onDragEnd,this],[t.PointerEvent.ENTER,t=>{this.enterPoint=e,Lg(this,t)}],[t.PointerEvent.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:e,editor:i,__eventIds:s}=this;s.push(e.on_([[t.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this],[t.PointerEvent.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{s.push(i.app.on_([[[t.KeyEvent.HOLD,t.KeyEvent.UP],this.onKey,this],[t.KeyEvent.DOWN,this.onArrow,this],[[t.MoveEvent.START,t.MoveEvent.BEFORE_MOVE,t.MoveEvent.END],this.onMove,this,!0],[[t.ZoomEvent.START,t.ZoomEvent.BEFORE_ZOOM,t.ZoomEvent.END],this.onScale,this,!0],[[t.RotateEvent.START,t.RotateEvent.BEFORE_ROTATE,t.RotateEvent.END],this.onRotate,this,!0]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const Ag={x:0,y:0,width:1e5,height:1e5};class Wg extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,Ag),Object.assign(this.__world,Ag)}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergedConfig;if(s&&i.editing){if(t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),e.bounds&&!e.bounds.hit(i.editBox.rect.__world,e.matrix))return;t.saveBlendMode("destination-out"),e=Object.assign(Object.assign({},e),{shape:!0}),i.list.forEach(i=>{i.__render(t,e);const{parent:s}=i;s&&s.textBox&&s.__renderShape(t,e)}),t.restoreBlendMode()}}destroy(){this.editor=null,super.destroy()}}const Fg='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',zg={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${Fg}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${Fg}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${Fg}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,editBox:!0,hover:!0,select:"press",openInner:"double",multipleSelect:!0,boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},Ug=new jt;function Hg(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{Ug.setListWithFn(i,t=>t.getBounds("box","page")),0===Ug.width&&(Ug.width=.1),0===Ug.height&&(Ug.height=.1),e.reset(Ug.get())}),s.add(e)}const Ng=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Yg=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Xg={group(e,i,s){e.sort(Yg);const{app:n,parent:r}=e[0];let o;o=s&&s.add?s:new t.Group(s),r.addAt(o,r.children.indexOf(e[0])),e.sort(Ng);const a=new _t(i.worldTransform);return a.divideParent(r.scrollWorldTransform),o.setTransform(a),o.editable=!0,o.hitChildren=!1,n.lockLayout(),e.forEach(t=>t.dropTo(o)),n.unlockLayout(),o},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach(t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort(Ng),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(Yg),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},Vg=ie.get("EditToolCreator");function jg(){return t=>{Kg.register(t)}}const Gg=jg,Kg={list:{},register(t){const{tag:e}=t.prototype;Zg[e]&&Vg.repeat(e),Zg[e]=t},get:(t,e)=>new Zg[t](e)},{list:Zg}=Kg;class qg extends tg{constructor(t,e){super(t,e)}}qg.BEFORE_OPEN="innerEditor.before_open",qg.OPEN="innerEditor.open",qg.BEFORE_CLOSE="innerEditor.before_close",qg.CLOSE="innerEditor.close";class Jg extends tg{constructor(t,e){super(t,e)}}Jg.BEFORE_GROUP="editor.before_group",Jg.GROUP="editor.group",Jg.BEFORE_UNGROUP="editor.before_ungroup",Jg.UNGROUP="editor.ungroup",Jg.BEFORE_OPEN="editor.before_open_group",Jg.OPEN="editor.open_group",Jg.BEFORE_CLOSE="editor.before_close_group",Jg.CLOSE="editor.close_group";const{updateMatrix:$g}=ho,Qg={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},t_="top-left";class e_ extends t.Rect{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(Ho.CHANGE,e=>{if(this.checkChange&&Qg[e.attrName]){const{attrName:i,newValue:s,oldValue:n}=e,r="s"===i[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const o=this.__;o[i]=n,$g(this.parent),$g(this);const a=new _t(this.__world);switch(o[i]=s,this.__layout.rotationChange(),$g(this),this.changedTransform=new _t(this.__world).divide(a),i){case"x":t.move(r,0);break;case"y":t.move(0,r);break;case"rotation":t.rotateOf(t_,r);break;case"scaleX":t.scaleOf(t_,r,1);break;case"scaleY":t.scaleOf(t_,1,r);break;case"skewX":t.skewOf(t_,r,0);break;case"skewY":t.skewOf(t_,0,r)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class i_ extends tg{constructor(t,e){super(t,e)}}i_.BEFORE_MOVE="editor.before_move",i_.MOVE="editor.move";class s_ extends tg{constructor(t,e){super(t,e)}}s_.BEFORE_SCALE="editor.before_scale",s_.SCALE="editor.scale";class n_ extends tg{constructor(t,e){super(t,e)}}n_.BEFORE_ROTATE="editor.before_rotate",n_.ROTATE="editor.rotate";class r_ extends tg{constructor(t,e){super(t,e)}}r_.BEFORE_SKEW="editor.before_skew",r_.SKEW="editor.skew";class o_{onMove(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox;let r,{dragLimitAnimate:a}=s;const l=e.type===t.MoveEvent.END||e.type===t.DragEvent.END,d=o(i.draggable),c=!a||l||d,u={x:e.totalX,y:e.totalY};e instanceof t.MoveEvent&&at.move(u,i.getWorldPointByLocal(n.totalOffset,null,!0)),e.shiftKey&&(Math.abs(u.x)>Math.abs(u.y)?u.y=0:u.x=0),r=t.DragEvent.getValidMove(i,n.point,u,c),(r.x||r.y)&&(a&&!d&&l?ho.animateMove(this,r,h(a)?a:.3):this.move(r))}onScale(e){const{target:i,mergeConfig:s,single:n,dragStartData:r}=this.editBox;let o,{around:a,lockRatio:h,flipable:l,editSize:d}=s;e instanceof t.ZoomEvent?(a||(a=i.getBoxPoint(e)),o=e.totalScale):o=e.getInnerTotal(i);const{direction:c}=e.current;(e.shiftKey||i.lockRatio)&&(h=!0);const u=Bg.getScaleData(i,r.bounds,c,o,h,Bg.getAround(a,e.altKey),l,!n||"scale"===d),p=i.x,g=i.y;e instanceof t.DragEvent&&this.editTool&&this.editTool.onScaleWithDrag?(u.drag=e,this.scaleWithDrag(u)):this.scaleOf(u.origin,u.scaleX,u.scaleY),at.move(r.totalOffset,i.x-p,i.y-g)}onRotate(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox,{around:r,rotateAround:o,rotateGap:a,diagonalRotateKey:h}=s,{direction:l}=e.current;let d,c;if(e instanceof t.RotateEvent)c=e.rotation,d=o?Et.getPoint(o,i.boxBounds):i.getBoxPoint(e);else{const t=h?e.isHoldKeys(h):e.shiftKey,s=Bg.getRotateData(i,l,e,n,t?null:o||i.around||i.origin||r||"center");c=n.rotation+s.rotation-i.rotation,d=s.origin}if(c=D.float(D.getGapRotation(c,a,i.rotation),2),!c)return;const u=i.x,p=i.y;this.rotateOf(d,c),at.move(n.totalOffset,i.x-u,i.y-p)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:n,skewX:r,skewY:o}=Bg.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Bg.getAround(s,t.altKey));(r||o)&&this.skewOf(n,r,o)}move(t,e=0){if(!this.checkTransform("moveable"))return;c(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:n,editor:r}=this.editBox,{beforeMove:o}=s;if(o){const s=o({target:i,x:t,y:e});if(c(s))t=s.x,e=s.y;else if(!1===s)return}const a=i.getWorldPointByLocal({x:t,y:e},null,!0);n||i.safeChange(()=>i.move(t,e));const h={target:i,editor:r,moveX:a.x,moveY:a.y};this.emitEvent(new i_(i_.BEFORE_MOVE,h));const l=new i_(i_.MOVE,h);this.doMove(l),this.emitEvent(l)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{target:e,mergeConfig:i,editor:s}=this.editBox,{beforeScale:n}=i;if(n){const{origin:i,scaleX:s,scaleY:r,drag:o}=t;if(!1===n({target:e,drag:o,origin:i,scaleX:s,scaleY:r}))return}t=Object.assign(Object.assign({},t),{target:e,editor:s,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new s_(s_.BEFORE_SCALE,t));const r=new s_(s_.SCALE,t);this.editTool.onScaleWithDrag(r),this.emitEvent(r)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:n,mergeConfig:r,single:o,editor:a}=this.editBox,{beforeScale:h}=r;if(h){const s=h({target:n,origin:t,scaleX:e,scaleY:i});if(c(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!o&&this.getChangedTransform(()=>n.safeChange(()=>n.scaleOf(t,e,i))),u={target:n,editor:a,worldOrigin:l,scaleX:e,scaleY:i,transform:d};this.emitEvent(new s_(s_.BEFORE_SCALE,u));const p=new s_(s_.SCALE,u);this.doScale(p),this.emitEvent(p)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,n=this.getWorldOrigin("center"),r=i?new _t(ho.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),o={target:e,editor:s,worldOrigin:n,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:r};this.emitEvent(new s_(s_.BEFORE_SCALE,o));const a=new s_(s_.SCALE,o);this.doScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:n,editor:r}=this.editBox,{beforeRotate:o}=s;if(o){const s=o({target:i,origin:t,rotation:e});if(h(s))e=s;else if(!1===s)return}const a=this.getWorldOrigin(t),l=!n&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),d={target:i,editor:r,worldOrigin:a,rotation:e,transform:l};this.emitEvent(new n_(n_.BEFORE_ROTATE,d));const c=new n_(n_.ROTATE,d);this.doRotate(c),this.emitEvent(c)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:n,mergeConfig:r,single:o,editor:a}=this.editBox,{beforeSkew:h}=r;if(h){const s=h({target:n,origin:t,skewX:e,skewY:i});if(c(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!o&&this.getChangedTransform(()=>n.safeChange(()=>n.skewOf(t,e,i))),u={target:n,editor:a,worldOrigin:l,skewX:e,skewY:i,transform:d};this.emitEvent(new r_(r_.BEFORE_SKEW,u));const p=new r_(r_.SKEW,u);this.doSkew(p),this.emitEvent(p)}doMove(t){this.editTool.onMove(t)}doScale(t){this.editTool.onScale(t)}doRotate(t){this.editTool.onRotate(t)}doSkew(t){this.editTool.onSkew(t)}checkTransform(t){const{target:e,mergeConfig:i}=this.editBox;return e&&!e.locked&&i[t]}getWorldOrigin(t){const{target:e}=this.editBox;return e.getWorldPoint(ho.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const s=new _t(e.worldTransform);return t(),new _t(e.worldTransform).divide(s)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}t.Editor=class extends t.Group{get list(){return this.leafList.list}get dragHoverExclude(){return[this.editBox.rect]}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragPoint(){return this.editBox.dragPoint}get dragging(){return this.editBox.dragging}get gesturing(){return this.editBox.gesturing}get moving(){return this.editBox.moving}get resizing(){return this.editBox.resizing}get rotating(){return this.editBox.rotating}get skewing(){return this.editBox.skewing}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}get targetLeafer(){const t=this.list[0];return t&&t.leafer}constructor(t,e){super(e),this.leafList=new xh,this.openedGroupList=new xh,this.simulateTarget=new e_(this),this.editBox=new Ig(this),this.editToolList={},this.selector=new gg(this),this.editMask=new Wg(this),this.targetEventIds=[];let i=g.clone(zg);t&&(i=g.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),le.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}getItem(t){return this.list[t||0]}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}setDimOthers(t,e="dim",i){if(!i){const{dimTarget:t,targetLeafer:e}=this;i=t?d(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>g.stintSet(i,e,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&Hg(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||Kg.get(t,this)}updateEditTool(){if(this.unloadEditTool(),this.editing){const t=this.element;let e=t.editOuter||"EditTool";const{beforeEditOuter:i}=this.mergeConfig;if(i){const s=i({target:t,name:e});if(o(s))e=s;else if(!1===s)return}if(Kg.list[e]){const t=this.editTool=this.getEditTool(e);this.editBox.load(),t.load(),this.update()}}}unloadEditTool(){let t=this.editTool;t&&(this.editBox.unload(),t.unload(),this.editTool=null)}getEditSize(t){return this.mergeConfig.editSize}onMove(t){}onScale(t){}onRotate(t){}onSkew(t){}move(t,e=0){}scaleWithDrag(t){}scaleOf(t,e,i=e,s){}flip(t){}rotateOf(t,e){}skewOf(t,e,i=0,s){}checkTransform(t){}getWorldOrigin(t){}getChangedTransform(t){}group(t){return this.multiple&&(this.emitGroupEvent(Jg.BEFORE_GROUP),this.target=Xg.group(this.list,this.element,t),this.emitGroupEvent(Jg.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(Jg.BEFORE_UNGROUP,t)),this.target=Xg.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(Jg.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(Jg.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Jg.OPEN,t)}closeGroup(t){this.emitGroupEvent(Jg.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Jg.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!ho.hasParent(e,t))&&e.push(t))),e.forEach(t=>this.closeGroup(t))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new Jg(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||Kg.get(t,this)}openInnerEditor(t,e,i){let s;if(o(e)?s=e:i||(i=e),t&&i&&(this.target=t),this.single){t||(t=this.element),s||(s=t.editInner);const{beforeEditInner:e}=this.mergeConfig;if(e){const i=e({target:t,name:s});if(o(i))s=i;else if(!1===i)return}Kg.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(qg.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(qg.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(qg.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(qg.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new qg(t,{editTarget:i,innerEditor:e});this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach(t=>t.locked=!0),this.update()}unlock(){this.list.forEach(t=>t.locked=!1),this.update()}toTop(){this.list.length&&(Xg.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Xg.toBottom(this.list),this.leafList.update())}onAppRenderStart(t){(this.targetChanged=t.children.some(t=>t!==this.leafer&&t.renderer.changed))&&this.editBox.forceRender()}onRenderStart(){this.targetChanged&&this.update()}onChildScroll(){this.multiple&&this.updateEditBox()}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e,targetLeafer:i,editMask:s}=this;this.targetEventIds=[e.on_(Qo.START,this.onRenderStart,this),i&&i.on_(Ho.SCROLL,this.onChildScroll,this),t.on_(Qo.CHILD_START,this.onAppRenderStart,this),t.on_(ta.UPDATE_MODE,t=>{t.mode&&"normal"!==t.mode&&this.cancel()})],s.visible&&s.forceRender()}}removeTargetEvents(){const{targetEventIds:t,editMask:e}=this;t.length&&(this.off_(t),e.visible&&e.forceRender())}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach(t=>t.destroy()),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}},ye([(t,e)=>{hr(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,app:o}=this,a=Object.assign({},t);if(e&&e.editConfig){let{editConfig:t}=e;(t.hover||t.hoverStyle)&&(t=Object.assign({},t),delete t.hover,delete t.hoverStyle),Object.assign(a,t)}return s.config&&Object.assign(a,s.config),i&&(i.editConfig&&Object.assign(a,i.editConfig),"font-size"===a.editSize&&(a.lockRatio=!0),"resize-rotate"===i.pointType&&(a.around||(a.around="center"),r(a.lockRatio)&&(a.lockRatio=!0))),n(a.dragLimitAnimate)&&(a.dragLimitAnimate=o&&o.config.pointer.dragLimitAnimate),this.mergedConfig=a}})}],t.Editor.prototype,"mergeConfig",void 0),ye([eg(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof xh?i:new xh(i),t.multiple&&Hg(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new tg(tg.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new tg(tg.AFTER_SELECT,s))})],t.Editor.prototype,"target",void 0),ye([eg(function(t,e){t.emitEvent(new tg(tg.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],t.Editor.prototype,"hoverTarget",void 0),t.Editor=ye([Kr(o_,["editBox","editTool","emitEvent"])],t.Editor);class a_{static registerInnerEditor(){Kg.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get editBox(){return this._editBox||this.editor.editBox}set editBox(t){this._editBox=t}constructor(t){this.eventIds=[],this.editor=t,this.create()}onCreate(){}create(){this.view=new t.Group,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!0),this.onUnload())}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}t.EditTool=class extends a_{static registerEditTool(){Kg.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach(t=>{t.moveWorld(e,i)}),n.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:n,editor:r}=t,{app:o,list:a}=r;o.lockLayout(),a.forEach(t=>{const o="scale"!==r.getEditSize(t);s?t.transformWorld(s,o):t.scaleOfWorld(n,e,i,o)}),o.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:n}=t,{app:r,list:o}=n;r.lockLayout(),o.forEach(t=>{const r="scale"!==n.getEditSize(t);i?t.transformWorld(i,r):t.rotateOfWorld(s,e)}),r.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:n,editor:r}=t,{app:o,list:a}=r;o.lockLayout(),a.forEach(t=>{const o="scale"!==r.getEditSize(t);s?t.transformWorld(s,o):t.skewOfWorld(n,e,i,o)}),o.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){this.editBox.update(),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},t.EditTool=ye([jg()],t.EditTool);const{left:h_,right:l_}=t.Direction9,{move:d_,copy:c_,toNumberPoints:u_}=at;t.LineEditTool=class extends t.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:n}=t,r=t.target,o=i===h_;if(r.pathInputed){const{path:t}=r.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,o,n,this.getInnerMove(r,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,r.path=t}else if(r.points){const{points:t}=r,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,o,n,this.getInnerMove(r,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,r.points=t}else{const t={x:0,y:0},{toPoint:i}=r;r.rotation=0,this.dragPoint(t,i,o,n,this.getInnerMove(r,e,s)),r.getLocalPointByInner(t,null,null,!0),r.getLocalPointByInner(i,null,null,!0),r.x=t.x,r.y=t.y,r.getInnerPointByLocal(i,null,null,!0),r.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){const e=u_(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,n){const{x:r,y:o}=n;i?(d_(t,r,o),s&&d_(e,-r,-o)):(s&&d_(t,-r,-o),d_(e,r,o))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:n}=t,r=t.target;let o,a;if(r.pathInputed?o=this.getFromToByPath(r.__.path):r.points&&(o=this.getFromToByPoints(r.__.points)),o){const{from:i,to:a}=o;r.innerToWorld(i,i,!1,t),r.innerToWorld(a,a,!1,t),n.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),c_(s[7],i),c_(e[7],i),c_(s[3],a),c_(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===h_||t===l_,s[t].visible=a,e[t].visible=!o&&a}},t.LineEditTool=ye([jg()],t.LineEditTool);const{M:p_,L:g_,C:__,Q:f_,Z:m_,N:y_,D:v_,X:x_,G:w_,F:E_,O:b_,P:k_,U:T_}=Ae,S_={scale(t,e,i){if(!t)return;let s,n=0,r=t.length;for(;n<r;)switch(s=t[n],s){case p_:case g_:B_(t,e,i,n,1),n+=3;break;case __:B_(t,e,i,n,3),n+=7;break;case f_:B_(t,e,i,n,2),n+=5;break;case m_:n+=1;break;case y_:B_(t,e,i,n,2),n+=5;break;case v_:B_(t,e,i,n,2),n+=9;break;case x_:B_(t,e,i,n,2),n+=6;break;case w_:B_(t,e,i,n,2),n+=9;break;case E_:B_(t,e,i,n,2),n+=5;break;case b_:t[n]=w_,t.splice(n+4,0,t[n+3],0),B_(t,e,i,n,2),n+=9,r+=2;break;case k_:t[n]=E_,t.splice(n+4,0,t[n+3]),B_(t,e,i,n,2),n+=5,r+=1;break;case T_:B_(t,e,i,n,2),n+=6}},scalePoints(t,e,i,s,n){for(let r=n?s+1:0,o=n?r+2*n:t.length;r<o;r+=2)t[r]*=e,t[r+1]*=i}},{scalePoints:B_}=S_,P_=Z.get(),{topLeft:L_,top:R_,topRight:C_,right:O_,bottom:M_,left:D_}=t.Direction9;function I_(t,e,i){t.pathInputed?A_(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function A_(t,e,i){S_.scale(t.__.path,e,i),t.path=t.__.path}function W_(t,e,i){const{points:s}=t;c(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):S_.scalePoints(s,e,i),t.points=s}function F_(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)P_.a=e,P_.d=i,s[t].transform(P_,!0)}const z_=t.Leaf.prototype;function U_(t){const{scroll:e,disabled:i}=t.app.config.move;return!e||i?"":!0===e?"free":e}function H_(e,i,s){N_(e.parentApp?e.parentApp:e,i),e.isApp||s||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,t=>{const i=e.getValidMove(t.moveX,t.moveY,!1);if(U_(e).includes("limit")){const s=e.getValidMove(0,0);if(s.x||s.y){const e=100,n=200,r="drag"===t.moveType?.3:.05;Math.abs(s.x)>e?i.x=0:i.x*=r,Math.abs(s.y)>n?i.y=0:i.y*=r}}e.zoomLayer.move(i)}),e.on_(t.MoveEvent.DRAG_ANIMATE,()=>{const t=e.getValidMove(0,0);(t.x||t.y)&&e.interaction.stopDragAnimate()}),e.on_(t.MoveEvent.END,t=>{ho.animateMove(e.zoomLayer,e.getValidMove(t.moveX,t.moveY))}),e.on_(t.ZoomEvent.BEFORE_ZOOM,t=>{const{zoomLayer:i}=e,s=e.getValidScale(t.scale);1!==s&&i.scaleOfWorld(t,s)}))}function N_(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&g.assign(i,e),g.assign(t.config,i,t.userConfig)}z_.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},z_.__scaleResize=function(t,e){I_(this,t,e)},z_.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},z_.resizeHeight=function(t){const e=t/this.getBounds("box","local").height||1;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},t.Text.prototype.__scaleResize=function(t,e){const{app:i,editConfig:s}=this,r=i&&i.editor,o=r&&r.dragPoint;if(this.__.resizeFontSize||s&&"font-size"===s.editSize||o&&"font-size"===r.mergedConfig.editSize)!function(t,e,i,s){let r=e;if(!n(s)){const n=t.__layout;let{width:o,height:a}=n.boxBounds;switch(o*=i-e,a*=e-i,s){case R_:case M_:r=i,n.affectScaleOrRotation?t.moveInner(-o/2,0):t.x-=o/2;break;case D_:case O_:n.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case L_:case C_:n.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=r;const o=t.__,{padding:a}=o;a&&(t.padding=d(a)?a.map(t=>t*r):a*r),o.__autoWidth||(t.width*=r),o.__autoHeight||(t.height*=r)}(this,t,e,o&&o.direction);else{const{__autoWidth:i,__autoHeight:s,textAlign:n,verticalAlign:r}=this.__,{boxBounds:o}=this.__layout;i&&"left"!==n&&1!==t&&(this.x+=o.x),s&&"top"!==r&&1!==e&&(this.y+=o.y),I_(this,t,e)}},t.Path.prototype.__scaleResize=function(t,e){A_(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?A_(this,t,e):this.points?W_(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?A_(this,t,e):this.points?W_(this,t,e):I_(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){F_(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||I_(this,t,e),i&&F_(this,t,e)},le.add("resize"),le.add("editor","resize"),de.editor=function(e,i){const s=new t.Editor(e);return i&&i.sky.add(i.editor=s),s},t.Box.addAttr("textBox",!1,gr),t.UI.addAttr("editConfig",void 0,gr),t.UI.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),gr),t.UI.addAttr("editInner","PathEditor",gr),t.Group.addAttr("editInner","",gr),t.Text.addAttr("editInner","TextEditor",gr),t.UI.setEditConfig=function(t){this.changeAttr("editConfig",t)},t.UI.setEditOuter=function(t){this.changeAttr("editOuter",t)},t.UI.setEditInner=function(t){this.changeAttr("editInner",t)};const Y_=ie.get("LeaferTypeCreator"),X_={list:{},register(t,e){V_[t]&&Y_.repeat(t),V_[t]=e},run(t,e){const i=V_[t];i&&i(e)}},{list:V_,register:j_}=X_;j_("viewport",H_),j_("custom",function(t){H_(t,null,!0)}),j_("design",function(t){H_(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),j_("document",function(t){H_(t,{zoom:{min:1},move:{scroll:"limit"}})});const G_={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],i=t[1],s=at.getCenter(e.from,i.from),n=at.getCenter(e.to,i.to),r={x:n.x-s.x,y:n.y-s.y},o=at.getDistance(e.from,i.from);return{move:r,scale:at.getDistance(e.to,i.to)/o,rotation:at.getRotation(e.from,i.from,e.to,i.to),center:n}},getType(t,e){const i=Math.hypot(t.move.x,t.move.y)/(e.move||5),s=Math.abs(t.scale-1)/(e.scale||.03),n=Math.abs(t.rotation)/(e.rotation||2);return i<1&&s<1&&n<1?"none":i>=s&&i>=n?"move":s>=n?"zoom":"rotate"},detect(t,e){const{state:i}=K_,s=K_.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),K_.add(t,i.totalData),i.totalData=t,s===i.type){if(i.typeCount++,i.typeCount>=(e.count||3)&&"none"!==s)return s}else i.type=s,i.typeCount=1;return Date.now()-i.startTime>=(e.time||160)?K_.getType(i.totalData,e):"none"},add(t,e){e&&(at.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=K_;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},K_=G_,{abs:Z_,max:q_}=Math,{sign:J_,within:$_}=D,Q_={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;t.shiftKey&&!s&&(s=n,n=0);const r=Z_(s),o=Z_(n);return r>50&&(s=q_(50,r/3)*J_(s)),o>50&&(n=q_(50,o/3)*J_(n)),{x:-s*i*2,y:-n*i*2}},getScale(t,e){let i,s=1,{zoomMode:n,zoomSpeed:r}=e;const o=t.deltaY||t.deltaX;if(n?(i="mouse"===n||!t.deltaX&&(Qt.intWheelDeltaY?Math.abs(o)>17:Math.ceil(o)!==o),(t.shiftKey||t.metaKey||t.ctrlKey)&&(i=!0)):i=!t.shiftKey&&(t.metaKey||t.ctrlKey),i){r=$_(r,0,1);const i=t.deltaY?e.delta.y:e.delta.x,n=$_(1-Z_(o)/(4*i)*r,.5,2);s=o>0?n:1/n}return s}};let tf,ef,sf,nf;class rf{get transforming(){return this.moving||this.zooming||this.rotating}get moving(){return!!this.moveData}get zooming(){return!!this.zoomData}get rotating(){return!!this.rotateData}constructor(t){this.interaction=t}move(e){const{interaction:i}=this;e.moveType||(e.moveType="move"),this.moveData||(this.setPath(e),tf=0,ef=0,this.moveData=Object.assign(Object.assign({},e),{moveX:0,moveY:0,totalX:tf,totalY:ef}),i.emit(t.MoveEvent.START,this.moveData)),e.path=this.moveData.path,e.totalX=tf+=e.moveX,e.totalY=ef+=e.moveY,i.emit(t.MoveEvent.BEFORE_MOVE,e),i.emit(t.MoveEvent.MOVE,e),this.transformEndWait()}zoom(e){const{interaction:i}=this;this.zoomData||(this.setPath(e),sf=1,this.zoomData=Object.assign(Object.assign({},e),{scale:1,totalScale:sf}),i.emit(t.ZoomEvent.START,this.zoomData)),e.path=this.zoomData.path,e.totalScale=sf*=e.scale,i.emit(t.ZoomEvent.BEFORE_ZOOM,e),i.emit(t.ZoomEvent.ZOOM,e),this.transformEndWait()}rotate(e){const{interaction:i}=this;this.rotateData||(this.setPath(e),nf=0,this.rotateData=Object.assign(Object.assign({},e),{rotation:0,totalRotation:nf}),i.emit(t.RotateEvent.START,this.rotateData)),e.path=this.rotateData.path,e.totalRotation=nf+=e.rotation,i.emit(t.RotateEvent.BEFORE_ROTATE,e),i.emit(t.RotateEvent.ROTATE,e),this.transformEndWait()}setPath(t){const{interaction:e}=this,{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,e.cancelHover()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout(()=>{this.transformEnd()},this.interaction.p.transformTime)}transformEnd(){const{interaction:e,moveData:i,zoomData:s,rotateData:n}=this;i&&e.emit(t.MoveEvent.END,Object.assign(Object.assign({},i),{totalX:tf,totalY:ef})),s&&e.emit(t.ZoomEvent.END,Object.assign(Object.assign({},s),{totalScale:sf})),n&&e.emit(t.RotateEvent.END,Object.assign(Object.assign({},n),{totalRotation:nf})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const of=t.Leafer.prototype,af=new jt,hf=new pt;function lf(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function df(t,e){return Object.assign(Object.assign({},e),{scale:t})}of.initType=function(t){X_.run(t,this)},of.getValidMove=function(t,e,i=!0){const{disabled:s,scrollSpread:n}=this.app.config.move;hf.set(t,e);const r=U_(this);return r&&(r.includes("x")?hf.y=0:r.includes("y")?hf.x=0:Math.abs(hf.x)>Math.abs(hf.y)?hf.y=0:hf.x=0,i&&r.includes("limit")&&(af.set(this.__world).addPoint(this.zoomLayer),n&&af.spread(n),Dd.getValidMove(af,this.canvas.bounds,"auto",hf,!0),r.includes("x")?hf.y=0:r.includes("y")&&(hf.x=0))),{x:s?0:hf.x,y:s?0:hf.y}},of.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,r=Math.abs(e*t);return i&&r<i?t=i/e:s&&r>s&&(t=s/e),n?1:t};const cf=ic.prototype;cf.createTransformer=function(){this.transformer=new rf(this)},cf.move=function(t){this.transformer.move(t)},cf.zoom=function(t){this.transformer.zoom(t)},cf.rotate=function(t){this.transformer.rotate(t)},cf.transformEnd=function(){this.transformer.transformEnd()},cf.wheel=function(t){const{wheel:e,pointer:i}=this.config,{posDeltaSpeed:s,negDeltaSpeed:n}=e;if(e.disabled)return;t.deltaX>0?s&&(t.deltaX*=s):n&&(t.deltaX*=n),t.deltaY>0?s&&(t.deltaY*=s):n&&(t.deltaY*=n);const r=e.getScale?e.getScale(t,e):Q_.getScale(t,e);if(1!==r)this.zoom(df(r,t));else{const s=e.getMove?e.getMove(t,e):Q_.getMove(t,e);i.snap&&at.round(s),this.move(lf(s,t))}},cf.multiTouch=function(t,e){const{disabled:i,singleGesture:s}=this.config.multiTouch;if(i)return;this.pointerWaitCancel();let n=G_.getData(e),{moving:r,zooming:o,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch(G_.detect(n,c(s)?s:{})){case"move":r=!0;break;case"zoom":o=!0;break;case"rotate":a=!0;break;default:return}G_.reset()}r||(n.center=G_.state.center)}else r=o=a=!0;var h,l;Object.assign(t,n.center),t.multiTouch=!0,a&&this.rotate((h=n.rotation,l=t,Object.assign(Object.assign({},l),{rotation:h}))),o&&this.zoom(df(n.scale,t)),r&&this.move(lf(n.move,t))};const uf=jd.prototype,{abs:pf,min:gf,max:_f,hypot:ff}=Math;function mf(t,e){let i=1;const s="out"===e,n=Math.abs(t);if(n>1){for(;s?i<n:i<=n;)i*=2;s&&(i/=2)}else{for(;s?i>=n:i>n;)i/=2;s||(i*=2)}return i/t}uf.checkDragEndAnimate=function(e){const{interaction:i}=this,s=this.canAnimate&&this.moving&&i.m.dragAnimate;if(s){const n=h(s)?s:.95,r=.15,o=150;let a,l,d,c=0,u=0,p=0,g=0,_=3;const{dragDataList:f}=this,m=f.length;for(let t=m-1;t>=_f(m-3,0)&&(d=f[t],!(d.time&&Date.now()-d.time>100));t--)a=_--,c+=d.moveX*a,u+=d.moveY*a,g+=a,l=ff(d.moveX,d.moveY),l>p&&(p=l);if(g&&(c/=g,u/=g),p>8){const t=1.15+gf((p-8)/17,1)*(1.6-1.15);c*=t,u*=t}const y=_f(pf(c),pf(u));y>o&&(l=o/y,c*=l,u*=l);const v=()=>{if(c*=n,u*=n,e=Object.assign({},e),pf(c)<r&&pf(u)<r)return this.dragEndReal(e);at.move(e,c,u),this.drag(e),this.animate(v),i.emit(t.MoveEvent.DRAG_ANIMATE,e)};this.animate(v)}return s},uf.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},uf.stopAnimate=function(){this.animate(null,"off"),this.interaction.target.nextRender(()=>{this.dragData&&this.dragEndReal(this.dragData)})},uf.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},uf.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:n,dragOut:r}=e.m;if(!r||!s||!n)return;const o=e.shrinkCanvasBounds,{x:a,y:h}=o,l=Nt.maxX(o),d=Nt.maxY(o),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let p=0,g=0;this.autoMoveTimer=setInterval(()=>{p+=c,g+=u,at.move(i,c,u),at.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:p,totalY:g,moveType:"drag"})),e.pointerMoveReal(t)},10)},uf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},le.add("viewport"),le.add("view"),t.Leafer.prototype.zoom=function(t,e,i,s){let n;u(e)?(n=e.padding,i=e.scroll,s=e.transition):n=e;const{zoomLayer:a}=this,l=this.canvas.bounds.clone().shrink(r(n)?30:n),p=new jt,g={x:l.x+l.width/2,y:l.y+l.height/2};let _;a.killAnimate();const{x:f,y:m,scaleX:y,scaleY:v}=a.__,{boxBounds:x}=a;if(o(t))switch(t){case"in":_=mf(y,"in");break;case"out":_=mf(y,"out");break;case"fit":t=x;break;case"fit-width":(t=new jt(x)).height=0;break;case"fit-height":(t=new jt(x)).width=0}else h(t)&&(_=t/y);if(_)_=this.getValidScale(_),a.scaleOfWorld(g,_,_,!1,s);else if(c(t)){const e={x:f,y:m,scaleX:y,scaleY:v},n=d(t);if(n||t.tag){const e=n?t:[t];p.setListWithFn(e,mo.worldBounds)}else{const e=function(t,e){let i,{x:s,y:n,width:r,height:o}=t;return o||(o=r*(e.height/e.width),i=!0),r||(r=o*(e.width/e.height),i=!0),i?{x:s,y:n,width:r,height:o}:t}(t,l);p.set(a.getWorldBounds(e))}const{width:r,height:o}=p;let h=l.x-p.x,c=l.y-p.y;return i?(h+=Math.max((l.width-r)/2,0),c+=Math.max((l.height-o)/2,0)):(_=this.getValidScale(Math.min(l.width/r,l.height/o)),h+=(l.width-r*_)/2,c+=(l.height-o*_)/2,at.scaleOf(e,p,_),p.scaleOf(p,_),e.scaleX*=_,e.scaleY*=_),"x"===i?c=0:"y"===i&&(h=0),at.move(e,h,c),p.move(h,c),a.set(e,s),p}return a.worldBoxBounds};class yf extends t.Group{get isOutside(){return!0}constructor(t,e){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,e&&g.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(e){let i;o(e)?(i={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===e&&(i.fill="white",i.stroke="rgba(0,0,0,0.2)")):i=e,this.scrollXBar||this.addMany(this.scrollXBar=new t.Box,this.scrollYBar=new t.Box),i=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},i),i.height||(i.height=i.width),this.scrollXBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:e,padding:i}=this.config,{zoomLayer:s,canvas:n}=this.target.leafer,{worldRenderBounds:r}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(r))return;this.scrollBounds=new jt(r);const o=n.bounds.clone().shrink(i),a=o.clone().add(r),h=this.ratioX=o.width/a.width,l=this.ratioY=o.height/a.height,d=(o.x-a.x)/a.width,c=(o.y-a.y)/a.height,u=h<1,p=l<1,{scrollXBar:g,scrollYBar:_}=this,{x:f,y:m,width:y,height:v}=o.shrink([2,p?_.width+6:2,u?g.height+6:2,2]);g.set({x:f+y*d,y:m+v+2,width:Math.max(y*h,e),visible:u}),_.set({x:f+y+2,y:m+v*c,height:Math.max(v*l,e),visible:p})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const e=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(e?-t.moveX/this.ratioX:0,e?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:e,scrollYBar:i}=this;this.__eventIds=[e.on_(t.DragEvent.DRAG,this.onDrag,this),i.on_(t.DragEvent.DRAG,this.onDrag,this),e.on_(t.DragEvent.END,this.onDragEnd,this),i.on_(t.DragEvent.END,this.onDragEnd,this),this.target.on_(Qo.BEFORE,()=>this.update(!0)),this.target.leafer.on_(qo.RESIZE,()=>this.update())]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}le.add("scroll");class vf extends yl{}function xf(t){return cr(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__,e="none"!==t.startArrow||"none"!==t.endArrow;t.__useArrow!==e&&Er(this),t.__useArrow=e,Sr(this)}}}))}t.Arrow=class extends t.Line{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){Jh.register(t,e)}},ye([Ur(vf)],t.Arrow.prototype,"__",void 0),ye([xf("angle")],t.Arrow.prototype,"endArrow",void 0),t.Arrow=ye([Zr()],t.Arrow);const{M:wf,L:Ef,C:bf,Q:kf,O:Tf}=Ae,{rotate:Sf,copyFrom:Bf,scale:Pf}=at,Lf={},Rf={layout(t,e,i,s,n,r,o){let a,h,l=0,d=t.length;for(;l<d;)switch(a=t[l],a){case wf:case Ef:Cf(t,l+1,e,i,s,n,r,o),l+=3;break;case bf:for(h=1;h<6;h+=2)Cf(t,l+h,e,i,s,n,r,o);l+=7;break;case kf:for(h=1;h<4;h+=2)Cf(t,l+h,e,i,s,n,r,o);l+=5;break;case Tf:t[l+1]+=e,t[l+2]+=i,s&&(t[l+3]*=s),r&&(t[l+4]+=r,t[l+5]+=r),l+=7}},rotate(t,e,i){Rf.layout(t,0,0,1,1,e,i)}};function Cf(t,e,i,s,n,r,o,a){Bf(Lf,t[e],t[e+1]),o&&Sf(Lf,o,a),n&&Pf(Lf,n,r),t[e]=i+Lf.x,t[e+1]=s+Lf.y}const{layout:Of,rotate:Mf}=Rf,{getAngle:Df}=at,If={x:-.5},Af={connect:If,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},Wf={connect:If,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},Ff={connect:If,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},zf={connect:If,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},Uf={offset:If,path:[...Ff.path],dashPath:[1,-2.5,0,2,-1,0]};Mf(Uf.path,180,{x:-1.5,y:0});const Hf={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},Nf={connect:{x:.5},path:[...Hf.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},Yf={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},Xf={path:[...Yf.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},Vf=g.clone(Yf),jf=g.clone(Xf);Mf(Vf.path,45),Mf(jf.path,45);const Gf={angle:Af,"angle-side":Wf,arrow:zf,triangle:Ff,"triangle-flip":Uf,circle:Nf,"circle-line":Hf,square:Xf,"square-line":Yf,diamond:jf,"diamond-line":Vf,mark:{offset:If,path:[1,0,-2,2,0,2]}};function Kf(t,e,i,s,n,r,o){let a,h;const{strokeCap:l,strokeJoin:d}=t.__;c(e)?e.type?(h=e.scale,a=Gf[e.type]):a=e:a=Gf[e];const{offset:u,connect:p,path:g,dashPath:_}=a;let f=p?p.x:0,m=u?u.x:0;const y=[...g];return o&&_&&y.push(..._),"none"!==l&&(f-=.5),u&&("round"===d&&u.roundJoin?m+=u.roundJoin:"bevel"===d&&u.bevelJoin&&(m+=u.bevelJoin)),h&&Of(y,0,0,h,h),m&&Of(y,m,0),Of(y,s.x,s.y,n,n,Df(i,s)),r.x=(f+m)*n,y}const{M:Zf,L:qf,C:Jf,Q:$f,Z:Qf,N:tm,D:em,X:im,G:sm,F:nm,O:rm,P:om,U:am}=Ae,{copy:hm,copyFrom:lm,getDistancePoint:dm}=at,cm={},um={},pm={},gm={},_m={},fm={list:Gf,addArrows(t){const{startArrow:e,endArrow:i,strokeWidth:s,dashPattern:n,__pathForRender:r,cornerRadius:o}=t.__,a=!o;let h,l=0,d=r.length,c=0,u=e&&"none"!==e;for(;l<d;){switch(h=r[l],h){case Zf:case qf:(c<2||l+6>=d)&&(lm(_m,r[l+1],r[l+2]),!c&&u&&hm(um,_m)),l+=3;break;case Jf:(1===c||l+7>=d-3)&&mm(r,gm,_m,l+3),l+=7;break;case $f:(1===c||l+5>=d-3)&&mm(r,gm,_m,l+1),l+=5;break;case Qf:return;case tm:l+=5;break;case em:l+=9;break;case im:l+=6;break;case sm:l+=9;break;case nm:l+=5;break;case rm:l+=7;break;case om:l+=4;break;case am:(1===c||l+6>=d-3)&&(mm(r,gm,_m,l+1),l+6!==d&&(_m.x-=(_m.x-gm.x)/10,_m.y-=(_m.y-gm.y)/10)),l+=6}if(c++,1===c&&h!==Zf)return;if(2===c&&u&&hm(pm,h===qf?_m:gm),l===d){const o=t.__.__pathForRender=a?[...r]:r,d=t.__.__pathForArrow=[];if(u){const i=Kf(t,e,pm,um,s,cm,!!n);n?d.push(...i):o.push(...i),cm.x&&(dm(um,pm,-cm.x,!0),o[1]=pm.x,o[2]=pm.y)}if(i&&"none"!==i){const e=Kf(t,i,gm,_m,s,cm,!!n);if(n?d.push(...e):o.push(...e),cm.x){let t;switch(dm(_m,gm,-cm.x,!0),h){case qf:t=l-3+1;break;case Jf:t=l-7+5;break;case $f:t=l-5+3;break;case am:t=l-6+3}t&&ym(o,gm,t)}}}else hm(gm,_m)}},register(t,e){this.list[t]=e},get(t){return this.list[t]}};function mm(t,e,i,s){lm(e,t[s],t[s+1]),lm(i,t[s+2],t[s+3])}function ym(t,e,i){t[i]=e.x,t[i+1]=e.y}le.add("arrow"),t.UI.addAttr("startArrow","none",xf),t.UI.addAttr("endArrow","none",xf),Object.assign(Jh,fm),Object.assign($h,{strokeArrow(t,e,i,s){e.__.dashPattern&&(i.beginPath(),e.__drawPathByData(i,e.__.__pathForArrow),i.dashPattern=null,i.stroke())}});const{Yes:vm,NoAndSkip:xm,YesAndSkip:wm}=t.Answer,Em={},bm={},km={};class Tm{constructor(t){this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},(this.target=t)&&this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const r=this.getByInnerId(t,e);return i?r:r?[r]:[];case"string":switch(t[0]){case"#":Em.id=t.substring(1),t=Em;break;case".":bm.className=t.substring(1),t=bm;break;default:km.tag=t,t=km}case"object":if(n(t.id)){if(t.tag){const{tag:s}=t,n=d(s);return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?g.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className)}{const s=this.getById(t.id,e);return i?s:s?[s]:[]}case"function":return this.getByMethod(t,e,i,s)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&ho.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,r;for(let o=0,a=t.length;o<a;o++){if(n=t[o],r=e(n,s),"boolean"==typeof r&&(r=r?1:0),r===vm||r===wm){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&r<xm&&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_(Ho.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){const{__eventIds:t}=this;t&&t.length&&(this.__removeListenEvents(),this.innerIdMap={},this.idMap={}),this.findLeaf=null}}const Sm=t.UI.prototype;function Bm(t){return t.leafer?t.leafer.selector:Qt.selector||(Qt.selector=de.selector())}Sm.find=function(t,e){return Bm(this).getBy(t,this,!1,e)},Sm.findOne=function(t,e){return Bm(this).getBy(t,this,!0,e)},le.add("find"),de.finder=function(t){return new Tm(t)};const{setPoint:Pm,addPoint:Lm,toBounds:Rm}=mt;const Cm={syncExport(t,e,i){let s;sl.running=!0;try{const r=Zn.fileType(e),o=e.includes(".");i=Zn.getExportOptions(i);const{toURL:a}=Qt,{download:h}=Qt.origin;if("json"===r)o&&h(a(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!o||t.toJSON(i.json)};else if("svg"===r)o&&h(a(t.toSVG(),"svg"),e),s={data:!!o||t.toSVG()};else{let r,o,a=1,h=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:u}=t,{slice:p,clip:g,trim:_,screenshot:f,padding:m,onCanvas:y}=i,v=n(i.smooth)?!c||c.config.smooth:i.smooth,x=i.contextSettings||(c?c.config.contextSettings:void 0),w=d&&f&&n(i.fill)?t.fill:i.fill,E=Zn.isOpaqueImage(e)||w,b=new _t;if(f)r=!0===f?d?c.canvas.bounds:t.worldRenderBounds:f;else{let e=i.relative||(d?"inner":"local");switch(a=l.scaleX,h=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),a/=t.scaleX,h/=t.scaleY;break;case"world":a=1,h=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,h/=h/i.scaleY}r=t.getBounds("render",e)}const k={scaleX:1,scaleY:1};D.getScaleData(i.scale,i.size,r,k);let T=i.pixelRatio||1,{x:S,y:B,width:P,height:L}=new jt(r).scale(k.scaleX,k.scaleY);g&&(S+=g.x,B+=g.y,P=g.width,L=g.height,g.rotation&&b.rotateOfInner({x:S,y:B},-g.rotation));const R={exporting:!0,matrix:b.scale(1/k.scaleX,1/k.scaleY).invert().translate(-S,-B).withScale(1/a*k.scaleX,1/h*k.scaleY)};let C,O=de.canvas({width:Math.floor(P),height:Math.floor(L),pixelRatio:T,smooth:v,contextSettings:x});p&&(C=t,C.__worldOpacity=0,t=c||t,R.bounds=O.bounds),O.save();const M=u&&!n(w),I=t.get("fill");if(M&&(t.fill=""),Qt.render(t,O,R),M&&(t.fill=I),O.restore(),C&&C.__updateWorldOpacity(),_){o=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,r,o,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,r=(a-n)/e,o?Lm(o,n,r):Pm(o={},n,r)),a++;const h=new jt;return o&&(Rm(o,h),h.scale(1/t.pixelRatio).ceil()),h}(O);const t=O,{width:e,height:i}=o,s={x:0,y:0,width:e,height:i,pixelRatio:T};O=de.canvas(s),O.copyWorld(t,o,s),t.destroy()}if(m){const[t,e,i,s]=D.fourNumber(m),n=O,{width:r,height:o}=n;O=de.canvas({width:r+s+e,height:o+t+i,pixelRatio:T}),O.copyWorld(n,n.bounds,{x:s,y:t,width:r,height:o}),n.destroy()}E&&O.fillWorld(O.bounds,w||"#FFFFFF","destination-over"),y&&y(O);s={data:"canvas"===e?O:O.export(e,i),width:O.pixelWidth,height:O.pixelHeight,renderBounds:r,trimBounds:o};const A=c&&c.app;A&&A.canvasManager&&A.canvasManager.clearRecycled()}}catch(t){s={data:"",error:t}}return sl.running=!1,s},export(t,e,i){return sl.running=!0,function(t){Om||(Om=new Qn);return new Promise(e=>{Om.add(()=>ve(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(n=>{const r=()=>ve(this,void 0,void 0,function*(){if(!er.isComplete)return Qt.requestRender(r);const o=sl.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()});t.updateLayout(),Mm(t);const{leafer:o}=t;o?o.waitViewCompleted(r):r()}))}};let Om;function Mm(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>Mm(t))}const Dm=Me.prototype,Im=ie.get("@leafer-in/export");Dm.export=function(t,e){const{quality:i,blob:s}=Zn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},Dm.toBlob=function(t,e){return new Promise(i=>{Qt.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{Im.error(t),i(null)})})},Dm.toDataURL=function(t,e){return Qt.origin.canvasToDataURL(this.view,t,e)},Dm.saveAs=function(t,e){return new Promise(i=>{Qt.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{Im.error(t),i(!1)})})},le.add("export"),Object.assign(sl,Cm),t.UI.prototype.export=function(t,e){return sl.export(this,t,e)},t.UI.prototype.syncExport=function(t,e){return sl.syncExport(this,t,e)};const Am={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},Wm={top:"flex-start",middle:"center",bottom:"flex-end"},Fm={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function zm(t,e,i){const{style:s}=t,{fill:r,padding:a,textWrap:h,textOverflow:l,textDecoration:u}=e;let p;s.fontFamily=e.fontFamily,s.fontSize=e.fontSize*i+"px",function(t,e){let i="black";d(e)&&(e=e[0]);if(c(e))switch(e.type){case"solid":i=Zh.string(e.color);break;case"image":break;case"linear":case"radial":case"angular":const t=e.stops[0];i=Zh.string(o(t)?t:t.color);break;default:n(e.r)||(i=Zh.string(e))}else i=e;t.color=i}(s,r),s.fontStyle=e.italic?"italic":"normal",s.fontWeight=e.fontWeight,c(u)?(p=u.type,u.color&&(s.textDecorationColor=Zh.string(u.color))):p=u,s.textDecoration=Fm[p],s.textTransform=Am[e.textCase],s.textAlign="both"===e.textAlign?"justify":e.textAlign,s.display="flex",s.flexDirection="column",s.justifyContent=Wm[e.verticalAlign],s.lineHeight=(e.__.__lineHeight||0)*i+"px",s.letterSpacing=(e.__.__letterSpacing||0)*i+"px",s.whiteSpace="none"===h||e.__.__autoWidth?"nowrap":"normal",s.wordBreak="break"===h?"break-all":"normal",s.textIndent=(e.paraIndent||0)*i+"px",s.padding=d(a)?a.map(t=>t*i+"px").join(" "):(a||0)*i+"px",s.textOverflow="show"===l?"":"hide"===l?"clip":l}t.TextEditor=class extends a_{constructor(){super(...arguments),this.config={selectAll:!0},this.eventIds=[]}get tag(){return"TextEditor"}onLoad(){const{editor:e}=this,{config:i}=e.app,s=this.editTarget;s.textEditing=!0,this.isHTMLText=!(s instanceof t.Text),this._keyEvent=i.keyEvent,i.keyEvent=!1;const n=this.editDom=document.createElement("div");n.classList.add("leafer-text-editor");const{style:r}=n;n.contentEditable="true",r.position="fixed",r.transformOrigin="left top",r.boxSizing="border-box",this.isHTMLText?n.innerHTML=String(s.text):n.innerText=String(s.text);const{view:o}=e.app;(this.inBody=o instanceof HTMLCanvasElement)?document.body.appendChild(n):o.appendChild(n),this.eventIds=[e.app.on_(t.PointerEvent.DOWN,t=>{let i,{target:s}=t.origin;for(;s;)s===n&&(i=!0),s=s.parentElement;i||e.closeInnerEditor()})],this.onFocus=this.onFocus.bind(this),this.onInput=this.onInput.bind(this),this.onPaste=this.onPaste.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onKeydown=this.onKeydown.bind(this),n.addEventListener("focus",this.onFocus),n.addEventListener("input",this.onInput),n.addEventListener("paste",this.onPaste),window.addEventListener("keydown",this.onKeydown),window.addEventListener("scroll",this.onUpdate);const a=window.getSelection(),h=document.createRange();if(this.config.selectAll)h.selectNodeContents(n);else{const t=n.childNodes[0];t&&(h.setStartAfter(t),h.setEndAfter(t)),h.collapse(!0)}a.removeAllRanges(),a.addRange(h)}onInput(){const{editDom:t}=this;this.editTarget.text=this.isHTMLText?t.innerHTML:t.innerText}onFocus(){this.editDom.style.outline="none"}onKeydown(t){if("Escape"===t.code&&this.editor.closeInnerEditor(),"Enter"===t.key){t.preventDefault();const e=document.createElement("br"),i=document.createTextNode("​"),s=window.getSelection().getRangeAt(0);s.deleteContents(),s.insertNode(i),s.insertNode(e),s.setStartAfter(e),s.setEndAfter(e),this.onInput()}}onPaste(t){if(this.isHTMLText)return;t.preventDefault();const e=t.clipboardData;if(!e)return;let i=e.getData("text/plain").replace(/\r\n?/g,"\n");const s=window.getSelection();if(!s||!s.rangeCount)return;const n=s.getRangeAt(0);n.deleteContents();const r=i.split("\n"),o=document.createDocumentFragment();r.forEach((t,e)=>{e>0&&o.appendChild(document.createElement("br")),o.appendChild(document.createTextNode(t))}),n.insertNode(o),n.collapse(!1),s.removeAllRanges(),s.addRange(n),this.onInput()}onUpdate(){const{editTarget:t}=this;let e=1;if(!this.isHTMLText){const{scaleX:i,scaleY:s}=t.worldTransform;e=Math.max(Math.abs(i),Math.abs(s));t.fontSize*e<12&&(e*=12/t.fontSize)}this.textScale=e;let{width:i,height:s}=t,n=0,r=0;i*=e,s*=e;const o=t.__;if(o.__autoWidth)switch(i+=20,o.textAlign){case"center":n=o.autoSizeAlign?-i/2:-10;break;case"right":n=o.autoSizeAlign?-i:-20}if(o.__autoHeight)switch(s+=20,o.verticalAlign){case"middle":r=o.autoSizeAlign?-s/2:-10;break;case"bottom":r=o.autoSizeAlign?-s:-20}const{x:a,y:h}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds,{a:l,b:d,c:c,d:u,e:p,f:g}=new _t(t.worldTransform).scale(1/e).translateInner(n,r),{style:_}=this.editDom;_.transform=`matrix(${l},${d},${c},${u},${p},${g})`,_.left=a+"px",_.top=h+"px",_.width=i+"px",_.height=s+"px",this.isHTMLText||zm(this.editDom,t,e)}onUnload(){const{editTarget:t,editor:e,editDom:i}=this;t&&(this.onInput(),"\n"===t.text&&(t.text=""),t.textEditing=void 0,e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),i.removeEventListener("focus",this.onFocus),i.removeEventListener("input",this.onInput),i.removeEventListener("paste",this.onPaste),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("scroll",this.onUpdate),i.remove(),this.editDom=this.eventIds=void 0)}},t.TextEditor=ye([Gg()],t.TextEditor),le.add("text-editor","editor");class Um extends Bl{setText(t){this._text=t,this.__htmlChanged=!0}}const Hm={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",hellip:"…",middot:"·",bull:"•",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",cent:"¢",pound:"£",yen:"¥",euro:"€",times:"×",divide:"÷",plusmn:"±",minus:"−",frac12:"½",frac14:"¼",frac34:"¾",sup2:"²",sup3:"³",deg:"°",reg:"®",copy:"©",trade:"™",section:"§",para:"¶",dagger:"†",Dagger:"‡",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",alpha:"α",beta:"β",gamma:"γ",delta:"δ",pi:"π",sigma:"σ",omega:"ω",Omega:"Ω",micro:"µ",infinity:"∞",not:"¬",equiv:"≡",le:"≤",ge:"≥"};return t.HTMLText=class extends t.Image{get __tag(){return"HTMLText"}constructor(t){super(t)}__updateBoxBounds(){const t=this.__;if(t.__htmlChanged){const e=document.createElement("div"),{style:i}=e;i.all="initial",i.position="absolute",i.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:s,height:n}=e.getBoundingClientRect(),r=s+10,o=`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${n}">\n <foreignObject width="${r}" height="${n}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.decodeText(this.text)}\n </body>\n </foreignObject>\n </svg>`;t.__setImageFill("data:image/svg+xml,"+encodeURIComponent(o)),t.__naturalWidth=r/t.pixelRatio,t.__naturalHeight=n/t.pixelRatio,t.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}__draw(t,e,i){this.textEditing&&!e.exporting||super.__draw(t,e,i)}decodeText(t){if(!t.includes("&"))return t;let e,i,s="",n=0;for(;n<t.length;){if("&"===t[n]){const r=t.indexOf(";",n+1);if(r>n+1&&(e=t.slice(n+1,r),i=Hm[e],void 0!==i)){s+=i,n=r+1;continue}}s+=t[n++]}return s}static addUnicodeEntity(t,e){o(t)?Hm[t]=e:Object.assign(Hm,t)}},ye([Ur(Um)],t.HTMLText.prototype,"__",void 0),ye([xr("")],t.HTMLText.prototype,"text",void 0),ye([gr("TextEditor")],t.HTMLText.prototype,"editInner",void 0),ye([Lr(!1)],t.HTMLText.prototype,"textEditing",void 0),t.HTMLText=ye([Zr()],t.HTMLText),le.add("html"),t.AlignHelper=Tt,t.AroundHelper=Et,t.ArrowData=vf,t.AutoBounds=Kt,t.BezierHelper=li,t.Bounds=jt,t.BoundsEvent=Xo,t.BoundsHelper=Nt,t.BoxData=_l,t.BranchHelper=wo,t.BranchRender=za,t.CanvasData=Pl,t.CanvasManager=me,t.ChildEvent=zo,t.ColorConvert=Zh,t.Creator=de,t.Cursor=sc,t.DataHelper=g,t.Debug=ie,t.DragBoundsHelper=Dd,t.Dragger=jd,t.EditBox=Ig,t.EditDataHelper=Bg,t.EditPoint=Og,t.EditSelect=gg,t.EditSelectHelper=dg,t.EditToolCreator=Kg,t.EditorEvent=tg,t.EditorGroupEvent=Jg,t.EditorHelper=Xg,t.EditorMoveEvent=i_,t.EditorRotateEvent=n_,t.EditorScaleEvent=s_,t.EditorSkewEvent=r_,t.Effect=el,t.EllipseData=xl,t.EllipseHelper=yi,t.Event=Fo,t.EventCreator=_e,t.Eventer=aa,t.Export=sl,t.FileHelper=Zn,t.Filter=il,t.Finder=Tm,t.FourNumberHelper=k,t.FrameData=ml,t.GroupData=gl,t.HTMLTextData=Um,t.HitCanvasManager=nc,t.ImageData=Bl,t.ImageEvent=Yo,t.ImageManager=sr,t.IncrementId=m,t.InnerEditor=a_,t.InnerEditorEvent=qg,t.InteractionBase=ic,t.InteractionHelper=Ud,t.Keyboard=xd,t.LayoutEvent=$o,t.Layouter=Wh,t.LeafBounds=Ia,t.LeafBoundsHelper=mo,t.LeafData=f,t.LeafDataProxy=xa,t.LeafEventer=ya,t.LeafHelper=ho,t.LeafLayout=Wo,t.LeafLevelList=wh,t.LeafList=xh,t.LeafMatrix=Ba,t.LeafRender=Aa,t.LeaferCanvas=Eh,t.LeaferCanvasBase=Me,t.LeaferData=fl,t.LeaferEvent=ta,t.LeaferImage=ar,t.LeaferTypeCreator=X_,t.LineData=yl,t.MathHelper=D,t.Matrix=_t,t.MatrixHelper=Z,t.MultiTouchHelper=G_,t.MyDragEvent=Fd,t.MyImage=pd,t.MyPointerEvent=Ad,t.MyTouchEvent=zd,t.NeedConvertToCanvasCommandMap=Fe,t.OneRadian=A,t.PI2=W,t.PI_2=F,t.Paint=$h,t.PaintGradient=tl,t.PaintImage=Qh,t.PathArrow=Jh,t.PathArrowModule=fm,t.PathBounds=Wn,t.PathCommandDataHelper=Ss,t.PathCommandMap=Ae,t.PathCommandNodeHelper=vi,t.PathConvert=ss,t.PathCorner=Xn,t.PathCreator=Ys,t.PathData=bl,t.PathDrawer=rn,t.PathHelper=De,t.PathMatrixHelper=Rf,t.PathNumberCommandLengthMap=Ne,t.PathNumberCommandMap=He,t.PenData=kl,t.Picker=Yh,t.Platform=Qt,t.Plugin=le,t.Point=pt,t.PointHelper=at,t.PointerButton=wd,t.PolygonData=wl,t.PropertyEvent=Ho,t.RectData=vl,t.RectHelper=Ye,t.RectRender=Il,t.RenderEvent=Qo,t.Renderer=zh,t.ResizeEvent=qo,t.Resource=er,t.Run=oe,t.ScrollBar=yf,t.SelectArea=lg,t.Selector=Xh,t.StarData=El,t.State=nl,t.StringNumberMap=qt,t.Stroker=hg,t.TaskItem=$n,t.TaskProcessor=Qn,t.TextConvert=Kh,t.TextData=Sl,t.TransformTool=o_,t.Transformer=rf,t.Transition=rl,t.TwoPointBoundsHelper=mt,t.UIBounds=Cl,t.UICreator=ue,t.UIData=ul,t.UIEvent=Ed,t.UIRender=Ml,t.UnitConvert=qh,t.UnitConvertHelper=Zt,t.WaitHelper=Bo,t.WatchEvent=Jo,t.Watcher=Sh,t.WheelEventHelper=Q_,t.addViewport=H_,t.addViewportConfig=N_,t.affectRenderBoundsType=Pr,t.affectStrokeBoundsType=Tr,t.arrowType=xf,t.attr=ur,t.autoLayoutType=mr,t.boundsType=xr,t.canvasPatch=Kn,t.canvasSizeAttrs=Oe,t.createAttr=function(t){return(e,i)=>{hr(e,i,dr(i,t))}},t.createDescriptor=dr,t.cursorType=zr,t.dataProcessor=Ur,t.dataType=gr,t.decorateLeafAttr=cr,t.defineDataProcessor=Hr,t.defineKey=hr,t.defineLeafAttr=pr,t.dimType=Rr,t.doBoundsType=Er,t.doStrokeType=Sr,t.effectType=Vh,t.emptyData=s,t.eraserType=Wr,t.extraPropertyEventMap=No,t.getBoundsData=U,t.getDescriptor=lr,t.getMatrixData=H,t.getPointData=z,t.hitType=Fr,t.isArray=d,t.isData=u,t.isEmptyData=p,t.isFinite=a,t.isNull=r,t.isNumber=h,t.isObject=c,t.isString=o,t.isUndefined=n,t.layoutProcessor=function(t){return(e,i)=>{hr(e,"__LayoutProcessor",{get:()=>t})}},t.leaferTransformAttrMap=ra,t.maskType=Ar,t.naturalBoundsType=wr,t.opacityType=Cr,t.path=Vn,t.pathInputType=br,t.pathType=kr,t.pen=jn,t.positionType=_r,t.registerEditTool=jg,t.registerInnerEditor=Gg,t.registerUI=Zr,t.registerUIEvent=qr,t.resizeType=jh,t.rewrite=Vr,t.rewriteAble=jr,t.rotationType=vr,t.scaleType=yr,t.scrollType=fr,t.sortType=Ir,t.strokeType=Br,t.surfaceType=Lr,t.tempBounds=Gt,t.tempMatrix=ft,t.tempPoint=gt,t.tryToNumber=function(t){return"string"==typeof t&&l.test(t)?+t:t},t.useCanvas=kh,t.useModule=Kr,t.version="2.0.1",t.visibleType=Or,t.zoomLayerType=Gh,t}({});function Leafer(t){return new LeaferUI.Leafer(t)}Object.setPrototypeOf(Leafer,LeaferUI),Leafer.prototype=LeaferUI.Leafer.prototype;
1
+ var LeaferUI=function(t){"use strict";var e,i;function s(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o}function n(t,e,i,s){return new(i||(i=Promise))(function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(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(o,a)}h((s=s.apply(t,e||[])).next())})}t.PathNodeHandleType=void 0,(e=t.PathNodeHandleType||(t.PathNodeHandleType={}))[e.none=1]="none",e[e.free=2]="free",e[e.mirrorAngle=3]="mirrorAngle",e[e.mirror=4]="mirror","function"==typeof SuppressedError&&SuppressedError,t.Answer=void 0,(i=t.Answer||(t.Answer={}))[i.No=0]="No",i[i.Yes=1]="Yes",i[i.NoAndSkip=2]="NoAndSkip",i[i.YesAndSkip=3]="YesAndSkip";const r={};function o(t){return void 0===t}function a(t){return null==t}function h(t){return"string"==typeof t}const{isFinite:l}=Number;function d(t){return"number"==typeof t}const c=/^-?\d+(?:\.\d+)?$/;const{isArray:u}=Array;function p(t){return t&&"object"==typeof t}function g(t){return p(t)&&!u(t)}function _(t){return"{}"===JSON.stringify(t)}const f={default:(t,e)=>(m(e,t),m(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach(n=>{var r,o;if(s=e[n],(null==s?void 0:s.constructor)===Object&&(null===(r=t[n])||void 0===r?void 0:r.constructor)===Object)return m(t[n],e[n],i&&i[n]);i&&n in i?(null===(o=i[n])||void 0===o?void 0:o.constructor)===Object&&m(t[n]={},e[n],i[n]):t[n]=e[n]})},copyAttrs:(t,e,i)=>(i.forEach(i=>{o(e[i])||(t[i]=e[i])}),t),clone:t=>JSON.parse(JSON.stringify(t)),toMap(t){const e={};for(let i=0,s=t.length;i<s;i++)e[t[i]]=!0;return e},stintSet(t,e,i){i||(i=void 0),t[e]!==i&&(t[e]=i)}},{assign:m}=f;class y{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __usePathBox(){return this.__pathInputed}get __blendMode(){if(this.eraser&&"path"!==this.eraser)return"destination-out";const{blendMode:t}=this;return"pass-through"===t?null:t}constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(!o(e))return e}return this[t]}__getData(){const t={tag:this.__leaf.tag},{__input:e}=this;let i;for(let s in this)"_"!==s[0]&&(i=e?e[s]:void 0,t[s]=o(i)?this[s]:i);return t}__setInput(t,e){this.__input||(this.__input={}),this.__input[t]=e}__getInput(t){if(this.__input){const e=this.__input[t];if(!o(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!o(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(u(t))for(let e of t)i[e]=this.__getInput(e);else for(let e in t)i[e]=this.__getInput(e);else{let t,e,{__input:s}=this;i.tag=this.__leaf.tag;for(let n in this)if("_"!==n[0]&&(t=this["_"+n],!o(t))){if("path"===n&&!this.__pathInputed)continue;e=s?s[n]:void 0,i[n]=o(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:n,e:r,f:o}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:n,e:r,f:o}}return i}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){const t=this;if("pass-through"===t.blendMode){const e=this.__leaf;t.opacity<1&&(e.isBranch||t.__hasMultiPaint)||e.__hasEraser||t.eraser||t.filter?t.__single=!0:t.__single&&(t.__single=!1)}else t.__single=!0}__removeNaturalSize(){this.__naturalWidth=this.__naturalHeight=void 0}destroy(){this.__input=this.__middle=null}}const v={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=x;return e[t]?e[t]++:(e[t]=1,0)}},x=v;let w,E,b;const{max:k}=Math,T=[0,0,0,0],S={zero:[...T],tempFour:T,set:(t,e,i,s,n)=>(void 0===i&&(i=s=n=e),t[0]=e,t[1]=i,t[2]=s,t[3]=n,t),setTemp:(t,e,i,s)=>B(T,t,e,i,s),toTempAB(t,e,i){b=i?d(t)?e:t:[],d(t)?(w=L(t),E=e):d(e)?(w=t,E=L(e)):(w=t,E=e),4!==w.length&&(w=P(w)),4!==E.length&&(E=P(E))},get(t,e){let i;if(!d(t))switch(t.length){case 4:i=o(e)?t:[...t];break;case 2:i=[t[0],t[1],t[0],t[1]];break;case 3:i=[t[0],t[1],t[2],t[1]];break;case 1:t=t[0];break;default:t=0}if(i||(i=[t,t,t,t]),!o(e))for(let t=0;t<4;t++)i[t]>e&&(i[t]=e);return i},max:(t,e,i)=>d(t)&&d(e)?k(t,e):(R(t,e,i),B(b,k(w[0],E[0]),k(w[1],E[1]),k(w[2],E[2]),k(w[3],E[3]))),add:(t,e,i)=>d(t)&&d(e)?t+e:(R(t,e,i),B(b,w[0]+E[0],w[1]+E[1],w[2]+E[2],w[3]+E[3])),swapAndScale(t,e,i,s){if(d(t))return e===i?t*e:[t*i,t*e];const n=s?t:[],[r,o,a,h]=4===t.length?t:P(t);return B(n,a*i,h*e,r*i,o*e)}},{set:B,get:P,setTemp:L,toTempAB:R}=S,{round:C,pow:O,max:M,floor:D,PI:I}=Math,A={within:(t,e,i)=>(p(e)&&(i=e.max,e=e.min),!o(e)&&t<e&&(t=e),!o(i)&&t>i&&(t=i),t),fourNumber:S.get,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=o(e)?1e12:O(10,e);return-0===(t=C(t*i)/i)?0:t},sign:t=>t<0?-1:1,getScaleData(t,e,i,s){if(s||(s={}),e){const t=(d(e)?e:e.width||0)/i.width,n=(d(e)?e:e.height||0)/i.height;s.scaleX=t||n||1,s.scaleY=n||t||1}else t&&A.assignScale(s,t);return s},assignScale(t,e){d(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},getFloorScale:(t,e=1)=>M(D(t),e)/t,randInt:W,randColor:t=>`rgba(${W(255)},${W(255)},${W(255)},${t||1})`};function W(t){return Math.round(Math.random()*t)}const F=I/180,z=2*I,U=I/2;function H(){return{x:0,y:0}}function N(){return{x:0,y:0,width:0,height:0}}function Y(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:X,cos:V,acos:j,sqrt:G}=Math,{float:K}=A,Z={};function q(){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 J={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:q(),tempMatrix:{},set(t,e=1,i=0,s=0,n=1,r=0,o=0){t.a=e,t.b=i,t.c=s,t.d=n,t.e=r,t.f=o},get:Y,getWorld:q,copy(t,e){t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f},translate(t,e,i){t.e+=e,t.f+=i},translateInner(t,e,i,s){t.e+=t.a*e+t.c*i,t.f+=t.b*e+t.d*i,s&&(t.e-=e,t.f-=i)},scale(t,e,i=e){t.a*=e,t.b*=e,t.c*=i,t.d*=i},pixelScale(t,e,i){i||(i=t),i.a=t.a*e,i.b=t.b*e,i.c=t.c*e,i.d=t.d*e,i.e=t.e*e,i.f=t.f*e},scaleOfOuter(t,e,i,s){$.toInnerPoint(t,e,Z),$.scaleOfInner(t,Z,i,s)},scaleOfInner(t,e,i,s=i){$.translateInner(t,e.x,e.y),$.scale(t,i,s),$.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:r}=t,o=V(e*=F),a=X(e);t.a=i*o-s*a,t.b=i*a+s*o,t.c=n*o-r*a,t.d=n*a+r*o},rotateOfOuter(t,e,i){$.toInnerPoint(t,e,Z),$.rotateOfInner(t,Z,i)},rotateOfInner(t,e,i){$.translateInner(t,e.x,e.y),$.rotate(t,i),$.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:r,d:o}=t;i&&(i*=F,t.a=s+r*i,t.b=n+o*i),e&&(e*=F,t.c=r+s*e,t.d=o+n*e)},skewOfOuter(t,e,i,s){$.toInnerPoint(t,e,Z),$.skewOfInner(t,Z,i,s)},skewOfInner(t,e,i,s=0){$.translateInner(t,e.x,e.y),$.skew(t,i,s),$.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:n,d:r,e:o,f:a}=t;t.a=e.a*i+e.b*n,t.b=e.a*s+e.b*r,t.c=e.c*i+e.d*n,t.d=e.c*s+e.d*r,t.e=e.e*i+e.f*n+o,t.f=e.e*s+e.f*r+a},multiplyParent(t,e,i,s,n){const{e:r,f:a}=t;if(i||(i=t),o(s)&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:r,c:o,d:a}=t;i.a=s*e.a+r*e.c,i.b=s*e.b+r*e.d,i.c=o*e.a+a*e.c,i.d=o*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){$.multiply(t,$.tempInvert(e))},divideParent(t,e){$.multiplyParent(t,$.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=$;return $.copy(e,t),$.invert(e),e},invert(t){const{a:e,b:i,c:s,d:n,e:r,f:o}=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=-(r*n-o*s)*a,t.f=-(o*e-r*i)*a}else if(1===e&&1===n)t.e=-r,t.f=-o;else{const i=1/(e*n);t.a=n*i,t.d=e*i,t.e=-r*n*i,t.f=-o*e*i}},toOuterPoint(t,e,i,s){const{x:n,y:r}=e;i||(i=e),i.x=n*t.a+r*t.c,i.y=n*t.b+r*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:n,b:r,c:o,d:a}=t,h=1/(n*a-r*o),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*o)*h,i.y=(d*n-l*r)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*o)*h,i.y-=(s*n-e*r)*h}},setLayout(t,e,i,s,n){const{x:r,y:a,scaleX:h,scaleY:l}=e;if(o(n)&&(n=e.rotation||e.skewX||e.skewY),n){const{rotation:i,skewX:s,skewY:n}=e,r=i*F,o=V(r),a=X(r);if(s||n){const e=s*F,i=n*F;t.a=(o+i*-a)*h,t.b=(a+i*o)*h,t.c=(e*o-a)*l,t.d=(o+e*a)*l}else t.a=o*h,t.b=a*h,t.c=-a*l,t.d=o*l}else t.a=h,t.b=0,t.c=0,t.d=l;t.e=r,t.f=a,(i=i||s)&&$.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:n,b:r,c:o,d:a,e:h,f:l}=t;let d,c,u,p,g,_=h,f=l;if(r||o){const t=n*a-r*o;if(o&&!s){d=G(n*n+r*r),c=t/d;const e=n/d;u=r>0?j(e):-j(e)}else{c=G(o*o+a*a),d=t/c;const e=o/c;u=U-(a>0?j(-e):-j(e))}const e=K(V(u)),i=X(u);d=K(d),c=K(c),p=e?K((o/c+i)/e/F,9):0,g=e?K((r/d-i)/e/F,9):0,u=K(u/F)}else d=n,c=a,u=p=g=0;return(e=i||e)&&(_+=e.x*n+e.y*o,f+=e.x*r+e.y*a,i||(_-=e.x,f-=e.y)),{x:_,y:f,scaleX:d,scaleY:c,rotation:u,skewX:p,skewY:g}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:n,c:r,d:o}=t;n||r?i=(s*o-n*r)/(e=G(s*s+n*n)):(e=s,i=o)}return s.scaleX=e,s.scaleY=i,s},reset(t){$.set(t)}},$=J,{float:Q}=A,{toInnerPoint:tt,toOuterPoint:et}=J,{sin:it,cos:st,abs:nt,sqrt:rt,atan2:ot,min:at,round:ht}=Math,lt={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,i=0){t.x=e,t.y=i},setRadius(t,e,i){t.radiusX=e,t.radiusY=o(i)?e:i},copy(t,e){t.x=e.x,t.y=e.y},copyFrom(t,e,i){t.x=e,t.y=i},round(t,e){t.x=e?ht(t.x-.5)+.5:ht(t.x),t.y=e?ht(t.y-.5)+.5:ht(t.y)},move(t,e,i){p(e)?(t.x+=e.x,t.y+=e.y):(t.x+=e,t.y+=i)},scale(t,e,i=e){t.x&&(t.x*=e),t.y&&(t.y*=i)},scaleOf(t,e,i,s=i){t.x+=(t.x-e.x)*(i-1),t.y+=(t.y-e.y)*(s-1)},rotate(t,e,i){i||(i=dt.defaultPoint);const s=st(e*=F),n=it(e),r=t.x-i.x,o=t.y-i.y;t.x=i.x+r*s-o*n,t.y=i.y+r*n+o*s},tempToInnerOf(t,e){const{tempPoint:i}=dt;return ut(i,t),tt(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=dt;return ut(i,t),et(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=dt;return ut(i,t),dt.toInnerRadiusPointOf(t,e,i),i},copyRadiusPoint:(t,e,i,s)=>(ut(t,e),pt(t,i,s),t),toInnerRadiusPointOf(t,e,i){i||(i=t),tt(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){tt(e,t,i)},toOuterOf(t,e,i){et(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)=>ct(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=nt(i-t),r=nt(s-e);return rt(n*n+r*r)},getMinDistanceFrom:(t,e,i,s,n,r)=>at(ct(t,e,i,s),ct(i,s,n,r)),getAngle:(t,e)=>gt(t,e)/F,getRotation:(t,e,i,s)=>(s||(s=e),dt.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/F),getRadianFrom(t,e,i,s,n,r,a,h){o(a)&&(a=i,h=s);const l=t-i,d=e-s,c=n-a,u=r-h;return Math.atan2(l*u-d*c,l*c+d*u)},getAtan2:(t,e)=>ot(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s,n){const r=gt(t,e);return n&&(t=e),s||(e={}),e.x=t.x+st(r)*i,e.y=t.y+it(r)*i,e},toNumberPoints(t){let e=t;return p(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},isSame:(t,e)=>Q(t.x)===Q(e.x)&&Q(t.y)===Q(e.y),reset(t){dt.reset(t)}},dt=lt,{getDistanceFrom:ct,copy:ut,setRadius:pt,getAtan2:gt}=dt;class _t{constructor(t,e){this.set(t,e)}set(t,e){return p(t)?lt.copy(this,t):lt.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new _t(this)}move(t,e){return lt.move(this,t,e),this}scale(t,e){return lt.scale(this,t,e),this}scaleOf(t,e,i){return lt.scaleOf(this,t,e,i),this}rotate(t,e){return lt.rotate(this,t,e),this}rotateOf(t,e){return lt.rotate(this,e,t),this}getRotation(t,e,i){return lt.getRotation(this,t,e,i)}toInnerOf(t,e){return lt.toInnerOf(this,t,e),this}toOuterOf(t,e){return lt.toOuterOf(this,t,e),this}getCenter(t){return new _t(lt.getCenter(this,t))}getDistance(t){return lt.getDistance(this,t)}getDistancePoint(t,e,i,s){return new _t(lt.getDistancePoint(this,t,e,i,s))}getAngle(t){return lt.getAngle(this,t)}getAtan2(t){return lt.getAtan2(this,t)}isSame(t){return lt.isSame(this,t)}reset(){return lt.reset(this),this}}const ft=new _t;class mt{constructor(t,e,i,s,n,r){this.set(t,e,i,s,n,r)}set(t,e,i,s,n,r){return p(t)?J.copy(this,t):J.set(this,t,e,i,s,n,r),this}setWith(t){return J.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:r}=this;return{a:t,b:e,c:i,d:s,e:n,f:r}}clone(){return new mt(this)}translate(t,e){return J.translate(this,t,e),this}translateInner(t,e){return J.translateInner(this,t,e),this}scale(t,e){return J.scale(this,t,e),this}scaleWith(t,e){return J.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}pixelScale(t){return J.pixelScale(this,t),this}scaleOfOuter(t,e,i){return J.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return J.scaleOfInner(this,t,e,i),this}rotate(t){return J.rotate(this,t),this}rotateOfOuter(t,e){return J.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return J.rotateOfInner(this,t,e),this}skew(t,e){return J.skew(this,t,e),this}skewOfOuter(t,e,i){return J.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return J.skewOfInner(this,t,e,i),this}multiply(t){return J.multiply(this,t),this}multiplyParent(t){return J.multiplyParent(this,t),this}divide(t){return J.divide(this,t),this}divideParent(t){return J.divideParent(this,t),this}invert(){return J.invert(this),this}invertWith(){return J.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){J.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){J.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return J.setLayout(this,t,e,i),this}getLayout(t,e,i){return J.getLayout(this,t,e,i)}withScale(t,e){return J.withScale(this,t,e)}reset(){J.reset(this)}}const yt=new mt,vt={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){xt(t,e,i),xt(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:xt}=vt;var wt,Et;t.Direction4=void 0,(wt=t.Direction4||(t.Direction4={}))[wt.top=0]="top",wt[wt.right=1]="right",wt[wt.bottom=2]="bottom",wt[wt.left=3]="left",t.Direction9=void 0,(Et=t.Direction9||(t.Direction9={}))[Et.topLeft=0]="topLeft",Et[Et.top=1]="top",Et[Et.topRight=2]="topRight",Et[Et.right=3]="right",Et[Et.bottomRight=4]="bottomRight",Et[Et.bottom=5]="bottom",Et[Et.bottomLeft=6]="bottomLeft",Et[Et.left=7]="left",Et[Et.center=8]="center",Et[Et["top-left"]=0]="top-left",Et[Et["top-right"]=2]="top-right",Et[Et["bottom-right"]=4]="bottom-right",Et[Et["bottom-left"]=6]="bottom-left";const bt=[{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}];bt.forEach(t=>t.type="percent");const kt={directionData:bt,tempPoint:{},get:Tt,toPoint(t,e,i,s,n,r){const o=Tt(t);i.x=o.x,i.y=o.y,"percent"===o.type&&(i.x*=e.width,i.y*=e.height,n&&(r||(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)},getPoint:(t,e,i)=>(i||(i={}),kt.toPoint(t,e,i,!0),i)};function Tt(e){return h(e)?bt[t.Direction9[e]]:e}const{toPoint:St}=kt,Bt={toPoint(t,e,i,s,n,r){St(t,i,s,n,e,r)}},{tempPointBounds:Pt,setPoint:Lt,addPoint:Rt,toBounds:Ct}=vt,{toOuterPoint:Ot}=J,{float:Mt,fourNumber:Dt}=A,{floor:It,ceil:At}=Math;let Wt,Ft,zt,Ut;const Ht={},Nt={},Yt={},Xt={tempBounds:Yt,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:r,y:o,width:a,height:h}=e;if(u(i)){const e=Dt(i);s?Vt.set(t,r+e[3],o+e[0],a-e[1]-e[3],h-e[2]-e[0]):Vt.set(t,r-e[3],o-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),Vt.set(t,r-i,o-i,a+2*i,h+2*i);n&&("width"===n?(t.y=o,t.height=h):(t.x=r,t.width=a))},minX:t=>t.width>0?t.x:t.x+t.width,minY:t=>t.height>0?t.y:t.y+t.height,maxX:t=>t.width>0?t.x+t.width:t.x,maxY:t=>t.height>0?t.y+t.height:t.y,move(t,e,i){t.x+=e,t.y+=i},scroll(t,e){t.x+=e.scrollX,t.y+=e.scrollY},getByMove:(t,e,i)=>(t=Object.assign({},t),Vt.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?Gt(e,t):e=t,i||(i=t),e.offsetX=Vt.maxX(i),e.offsetY=Vt.maxY(i),Vt.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e,s){s||lt.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){lt.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(Vt.copy(Yt,t),Vt.toOuterOf(Yt,e),Yt),getOuterOf:(t,e)=>(t=Object.assign({},t),Vt.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:n,e:r,f:o}=e;s>0?(i.width=t.width*s,i.x=r+t.x*s):(i.width=t.width*-s,i.x=r+t.x*s-i.width),n>0?(i.height=t.height*n,i.y=o+t.y*n):(i.height=t.height*-n,i.y=o+t.y*n-i.height)}else Ht.x=t.x,Ht.y=t.y,Ot(e,Ht,Nt),Lt(Pt,Nt.x,Nt.y),Ht.x=t.x+t.width,Ot(e,Ht,Nt),Rt(Pt,Nt.x,Nt.y),Ht.y=t.y+t.height,Ot(e,Ht,Nt),Rt(Pt,Nt.x,Nt.y),Ht.x=t.x,Ot(e,Ht,Nt),Rt(Pt,Nt.x,Nt.y),Ct(Pt,i)},toInnerOf(t,e,i){i||(i=t),Vt.move(i,-e.e,-e.f),Vt.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Vt.getFitScale(t,e));return new mt(s,0,0,s,-e.x*s,-e.y*s)},getFitScale(t,e,i){const s=t.width/e.width,n=t.height/e.height;return i?Math.max(s,n):Math.min(s,n)},put(t,e,i="center",s=1,n=!0,r){r||(r=e),h(s)&&(s=Vt.getFitScale(t,e,"cover"===s)),Yt.width=n?e.width*=s:e.width*s,Yt.height=n?e.height*=s:e.height*s,Bt.toPoint(i,Yt,t,r,!0,!0)},getSpread(t,e,i){const s={};return Vt.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){Vt.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){Vt.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=It(t.x),t.y=It(t.y),t.width=e>t.x?At(t.width+e-t.x):At(t.width),t.height=i>t.y?At(t.height+i-t.y):At(t.height)},unsign(t){t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height)},float(t,e){t.x=Mt(t.x,e),t.y=Mt(t.y,e),t.width=Mt(t.width,e),t.height=Mt(t.height,e)},add(t,e,i){Wt=t.x+t.width,Ft=t.y+t.height,zt=e.x,Ut=e.y,i||(zt+=e.width,Ut+=e.height),Wt=Wt>zt?Wt:zt,Ft=Ft>Ut?Ft:Ut,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=Wt-t.x,t.height=Ft-t.y},addList(t,e){Vt.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){Vt.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){Vt.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let n,r=!0;for(let o=0,a=e.length;o<a;o++)n=i?i(e[o],o):e[o],n&&(n.width||n.height)&&(r?(r=!1,s||Gt(t,n)):jt(t,n));r&&Vt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?Lt(Pt,t.x,t.y):Rt(Pt,t.x,t.y)),Ct(Pt,t)},setPoint(t,e){Vt.set(t,e.x,e.y)},addPoint(t,e){jt(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=lt.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=lt.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=Vt.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=Vt.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=Vt.tempToOuterOf(e,i)),!Vt.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:r,height:o}=e;return Wt=s+r,Ft=n+o,zt=t.x+t.width,Ut=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,Wt=Wt<zt?Wt:zt,Ft=Ft<Ut?Ft:Ut,r=Wt-s,o=Ft-n,{x:s,y:n,width:r,height:o}},intersect(t,e,i){Vt.copy(t,Vt.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,hasSize:t=>t.width&&t.height,reset(t){Vt.set(t)}},Vt=Xt,{add:jt,copy:Gt}=Vt;class Kt{get minX(){return Xt.minX(this)}get minY(){return Xt.minY(this)}get maxX(){return Xt.maxX(this)}get maxY(){return Xt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return p(t)?Xt.copy(this,t):Xt.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 Kt(this)}move(t,e){return Xt.move(this,t,e),this}scale(t,e,i){return Xt.scale(this,t,e,i),this}scaleOf(t,e,i){return Xt.scaleOf(this,t,e,i),this}toOuterOf(t,e){return Xt.toOuterOf(this,t,e),this}toInnerOf(t,e){return Xt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return Xt.getFitMatrix(this,t,e)}put(t,e,i){Xt.put(this,t,e,i)}spread(t,e){return Xt.spread(this,t,e),this}shrink(t,e){return Xt.shrink(this,t,e),this}ceil(){return Xt.ceil(this),this}unsign(){return Xt.unsign(this),this}float(t){return Xt.float(this,t),this}add(t){return Xt.add(this,t),this}addList(t){return Xt.setList(this,t,!0),this}setList(t){return Xt.setList(this,t),this}addListWithFn(t,e){return Xt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return Xt.setListWithFn(this,t,e),this}setPoint(t){return Xt.setPoint(this,t),this}setPoints(t){return Xt.setPoints(this,t),this}addPoint(t){return Xt.addPoint(this,t),this}getPoints(){return Xt.getPoints(this)}hitPoint(t,e){return Xt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return Xt.hitRadiusPoint(this,t,e)}hit(t,e){return Xt.hit(this,t,e)}includes(t,e){return Xt.includes(this,t,e)}intersect(t,e){return Xt.intersect(this,t,e),this}getIntersect(t,e){return new Kt(Xt.getIntersectData(this,t,e))}isSame(t){return Xt.isSame(this,t)}isEmpty(){return Xt.isEmpty(this)}reset(){Xt.reset(this)}}const Zt=new Kt;class qt{constructor(t,e,i,s,n,r){p(t)?this.copy(t):this.set(t,e,i,s,n,r)}set(t=0,e=0,i=0,s=0,n=0,r=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=n,this.height=r}copy(t){const{top:e,right:i,bottom:s,left:n,width:r,height:o}=t;this.set(e,i,s,n,r,o)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:n,width:r,height:o}=this;return new Kt(n,e,r||t.width-n-i,o||t.height-e-s)}}const Jt={number:(t,e)=>p(t)?"percent"===t.type?t.value*e:t.value:t},$t={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},{floor:Qt,max:te}=Math,ee={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",isLarge:(t,e,i,s)=>t.width*t.height*(e?e*i:1)>(s||ie.maxCacheSize),isSuperLarge:(t,e,i)=>ie.isLarge(t,e,i,ie.maxPatternSize),getRealURL(t){const{prefix:e,suffix:i}=ie;return!i||t.startsWith("data:")||t.startsWith("blob:")||(t+=(t.includes("?")?"&":"?")+i),e&&"/"===t[0]&&(t=e+t),t},resize(t,e,i,s,n,r,o,a,h,l){const d=te(Qt(e+(s||0)),1),c=te(Qt(i+(n||0)),1);let u,p,g;l&&(g=Jt.number(l.offset,"x"===l.type?e:i))&&("x"===l.type?u=!0:p=!0);const _=ee.origin.createCanvas(p?2*d:d,u?2*c:c),f=_.getContext("2d");if(a&&(f.globalAlpha=a),f.imageSmoothingEnabled=!1!==o,ie.canUse(t)){if(r){const s=e/r.width,n=i/r.height;f.setTransform(s,0,0,n,-r.x*s,-r.y*n),f.drawImage(t,0,0,t.width,t.height)}else f.drawImage(t,0,0,e,i);g&&(f.drawImage(_,0,0,d,c,u?g-d:d,u?c:g-c,d,c),f.drawImage(_,0,0,d,c,u?g:d,u?c:g,d,c))}return _},canUse:t=>t&&t.width&&!t.__closed,setPatternTransform(t,e,i){try{e&&t.setTransform&&(t.setTransform(e),e=void 0)}catch(t){}i&&f.stintSet(i,"transform",e)}}},{image:ie}=ee,{randColor:se}=A;class ne{constructor(t){this.repeatMap={},this.name=t}static get(t){return new ne(t)}static set filter(t){this.filterList=re(t)}static set exclude(t){this.excludeList=re(t)}static drawRepaint(t,e){const i=se();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(t,e,i){const s="hit"===ne.showBounds,n=t.__nowWorld,r=se();s&&(e.setWorld(n),t.__drawHitPath(e),e.fillStyle=r.replace("1)",".2)"),e.fill()),e.resetTransform(),e.setStroke(r,2),s?e.stroke():e.strokeWorld(n,r)}log(...t){if(oe.enable){if(oe.filterList.length&&oe.filterList.every(t=>t!==this.name))return;if(oe.excludeList.length&&oe.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){oe.enable&&this.warn(...t)}warn(...t){oe.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 re(t){return t?h(t)&&(t=[t]):t=[],t}ne.filterList=[],ne.excludeList=[],ne.showWarn=!0;const oe=ne,ae=ne.get("RunTime"),he={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const i=v.create(v.RUNTIME);return le.currentId=le.idMap[i]=e?performance.now():Date.now(),le.currentName=le.nameMap[i]=t,le.nameToIdMap[t]=i,i},end(t,e){const i=le.idMap[t],s=le.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;le.idMap[t]=le.nameMap[t]=le.nameToIdMap[s]=void 0,ae.log(s,n,"ms")},endOfName(t,e){const i=le.nameToIdMap[t];o(i)||le.end(i,e)}},le=he,de=[],ce={list:{},add(t,...e){this.list[t]=!0,de.push(...e)},has(t,e){const i=this.list[t];return!i&&e&&this.need(t),i},need(t){console.error("please install and import plugin: "+(t.includes("-x")?"":"@leafer-in/")+t)}};setTimeout(()=>de.forEach(t=>ce.has(t,!0)));const ue={editor:t=>ce.need("editor")},pe=ne.get("UICreator"),ge={list:{},register(t){const{__tag:e}=t.prototype;_e[e]&&pe.repeat(e),_e[e]=t},get(t,e,i,s,n,r){if(!_e[t])return void pe.warn("not register "+t);const a=new _e[t](e);return o(i)||(a.x=i,s&&(a.y=s),n&&(a.width=n),r&&(a.height=r)),a}},{list:_e}=ge,fe=ne.get("EventCreator"),me={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],h(e)&&(ye[e]&&fe.repeat(e),ye[e]=t)})},changeName(t,e){const i=ye[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,ye[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new ye[t](...e)},{nameList:ye}=me;class ve{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:i}=this;for(let s=0,n=i.length;s<n;s++)if(e=i[s],e.recycled&&e.isSameSize(t))return e.recycled=!1,e.manager||(e.manager=this),e;const s=ue.canvas(t);return this.add(s),s}recycle(t){t.recycled=!0}clearRecycled(){let t;const e=[];for(let i=0,s=this.list.length;i<s;i++)t=this.list[i],t.recycled?t.destroy():e.push(t);this.list=e}clear(){this.list.forEach(t=>{t.destroy()}),this.list.length=0}destroy(){this.clear()}}function xe(t){return(e,i)=>{t||(t=i);const s={get(){return this.context[t]},set(e){this.context[t]=e}};"strokeCap"===i&&(s.set=function(e){this.context[t]="none"===e?"butt":e}),Object.defineProperty(e,i,s)}}const we=[];function Ee(){return(t,e)=>{we.push(e)}}const be=[];class ke{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||be)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;we.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,i,s,n,r){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,n,r){p(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,n,r)}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,r,o,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/s*a;s+=e,e=0,r+=t,a-=t}if(i<0){const t=-i/n*h;n+=i,i=0,o+=t,h-=t}this.context.drawImage(t,e,i,s,n,r,o,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,r){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,n,r){}arcTo(t,e,i,s,n){}ellipse(t,e,i,s,n,r,o,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,r){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}}s([xe("imageSmoothingEnabled")],ke.prototype,"smooth",void 0),s([xe("imageSmoothingQuality")],ke.prototype,"smoothLevel",void 0),s([xe("globalAlpha")],ke.prototype,"opacity",void 0),s([xe()],ke.prototype,"fillStyle",void 0),s([xe()],ke.prototype,"strokeStyle",void 0),s([xe("lineWidth")],ke.prototype,"strokeWidth",void 0),s([xe("lineCap")],ke.prototype,"strokeCap",void 0),s([xe("lineJoin")],ke.prototype,"strokeJoin",void 0),s([xe("lineDashOffset")],ke.prototype,"dashOffset",void 0),s([xe()],ke.prototype,"miterLimit",void 0),s([xe()],ke.prototype,"shadowBlur",void 0),s([xe()],ke.prototype,"shadowColor",void 0),s([xe()],ke.prototype,"shadowOffsetX",void 0),s([xe()],ke.prototype,"shadowOffsetY",void 0),s([xe()],ke.prototype,"filter",void 0),s([xe()],ke.prototype,"font",void 0),s([xe()],ke.prototype,"fontKerning",void 0),s([xe()],ke.prototype,"fontStretch",void 0),s([xe()],ke.prototype,"fontVariantCaps",void 0),s([xe()],ke.prototype,"textAlign",void 0),s([xe()],ke.prototype,"textBaseline",void 0),s([xe()],ke.prototype,"textRendering",void 0),s([xe()],ke.prototype,"wordSpacing",void 0),s([xe()],ke.prototype,"letterSpacing",void 0),s([xe()],ke.prototype,"direction",void 0),s([Ee()],ke.prototype,"setTransform",null),s([Ee()],ke.prototype,"resetTransform",null),s([Ee()],ke.prototype,"getTransform",null),s([Ee()],ke.prototype,"save",null),s([Ee()],ke.prototype,"restore",null),s([Ee()],ke.prototype,"translate",null),s([Ee()],ke.prototype,"scale",null),s([Ee()],ke.prototype,"rotate",null),s([Ee()],ke.prototype,"fill",null),s([Ee()],ke.prototype,"stroke",null),s([Ee()],ke.prototype,"clip",null),s([Ee()],ke.prototype,"fillRect",null),s([Ee()],ke.prototype,"strokeRect",null),s([Ee()],ke.prototype,"clearRect",null),s([Ee()],ke.prototype,"beginPath",null),s([Ee()],ke.prototype,"moveTo",null),s([Ee()],ke.prototype,"lineTo",null),s([Ee()],ke.prototype,"bezierCurveTo",null),s([Ee()],ke.prototype,"quadraticCurveTo",null),s([Ee()],ke.prototype,"closePath",null),s([Ee()],ke.prototype,"arc",null),s([Ee()],ke.prototype,"arcTo",null),s([Ee()],ke.prototype,"ellipse",null),s([Ee()],ke.prototype,"rect",null),s([Ee()],ke.prototype,"roundRect",null),s([Ee()],ke.prototype,"createConicGradient",null),s([Ee()],ke.prototype,"createLinearGradient",null),s([Ee()],ke.prototype,"createPattern",null),s([Ee()],ke.prototype,"createRadialGradient",null),s([Ee()],ke.prototype,"fillText",null),s([Ee()],ke.prototype,"measureText",null),s([Ee()],ke.prototype,"strokeText",null);const{copy:Te,multiplyParent:Se,pixelScale:Be}=J,{round:Pe}=Math,Le=new Kt,Re=new Kt,Ce={width:1,height:1,pixelRatio:1},Oe=["width","height","pixelRatio"];class Me extends ke{get width(){return this.size.width}get height(){return this.size.height}get pixelRatio(){return this.size.pixelRatio}get pixelWidth(){return this.width*this.pixelRatio||0}get pixelHeight(){return this.height*this.pixelRatio||0}get pixelSnap(){return this.config.pixelSnap}set pixelSnap(t){this.config.pixelSnap=t}get allowBackgroundColor(){return this.view&&this.parentView}constructor(t,e){super(),this.size={},this.worldTransform={},t||(t=Ce),this.manager=e,this.innerId=v.create(v.CNAVAS);const{width:i,height:s,pixelRatio:n}=t;this.autoLayout=!i||!s,this.size.pixelRatio=n||ee.devicePixelRatio,this.config=t,this.init()}init(){}__createContext(){const{view:t}=this,{contextSettings:e}=this.config;this.context=e?t.getContext("2d",e):t.getContext("2d"),this.__bindContext()}export(t,e){}toBlob(t,e){}toDataURL(t,e){}saveAs(t,e){}resize(t,e=!0){if(this.isSameSize(t))return;let i;this.context&&!this.unreal&&e&&this.width&&(i=this.getSameCanvas(),i.copyWorld(this));const s=this.size;f.copyAttrs(s,t,Oe),Oe.forEach(t=>s[t]||(s[t]=1)),this.bounds=new Kt(0,0,this.width,this.height),this.updateViewSize(),this.updateClientBounds(),this.context&&(this.smooth=this.config.smooth,!this.unreal&&i&&(this.clearWorld(i.bounds),this.copyWorld(i),i.recycle()))}updateViewSize(){}updateClientBounds(){}getClientBounds(t){return t&&this.updateClientBounds(),this.clientBounds||this.bounds}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e){const{pixelRatio:i,pixelSnap:s}=this,n=this.worldTransform;e&&Se(t,e,n),Be(t,i,n),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(n.e=Pe(n.e-.5)+.5,n.f=Pe(n.f-.5)+.5):(n.e=Pe(n.e),n.f=Pe(n.f))),this.setTransform(n.a,n.b,n.c,n.d,n.e,n.f)}useWorldTransform(t){t&&(this.worldTransform=t);const e=this.worldTransform;e&&this.setTransform(e.a,e.b,e.c,e.d,e.e,e.f)}setStroke(t,e,i,s){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),i&&this.setStrokeOptions(i,s)}setStrokeOptions(t,e){let{strokeCap:i,strokeJoin:s,dashPattern:n,dashOffset:r,miterLimit:a}=t;e&&(e.strokeCap&&(i=e.strokeCap),e.strokeJoin&&(s=e.strokeJoin),o(e.dashPattern)||(n=e.dashPattern),o(e.dashOffset)||(r=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=i,this.strokeJoin=s,this.dashPattern=n,this.dashOffset=r,this.miterLimit=a}saveBlendMode(t){this.savedBlendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedBlendMode}hitFill(t,e){return!0}hitStroke(t,e){return!0}hitPixel(t,e,i=1){return!0}setWorldShadow(t,e,i,s){const{pixelRatio:n}=this;this.shadowOffsetX=t*n,this.shadowOffsetY=e*n,this.shadowBlur=i*n,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s,n){s&&(this.blendMode=s),e?(this.setTempPixelBounds(e,n),i?(this.setTempPixelBounds2(i,n),i=Re):i=Le,this.drawImage(t.view,Le.x,Le.y,Le.width,Le.height,i.x,i.y,i.width,i.height)):this.drawImage(t.view,0,0),s&&(this.blendMode="source-over")}copyWorldToInner(t,e,i,s,n){e.b||e.c?(this.save(),this.resetTransform(),this.copyWorld(t,e,Xt.tempToOuterOf(i,e),s,n),this.restore()):(s&&(this.blendMode=s),this.setTempPixelBounds(e,n),this.drawImage(t.view,Le.x,Le.y,Le.width,Le.height,i.x,i.y,i.width,i.height),s&&(this.blendMode="source-over"))}copyWorldByReset(t,e,i,s,n,r){this.resetTransform(),this.copyWorld(t,e,i,s,r),n||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempPixelBounds(t,!0,!0);const{context:s}=this,n=s.getImageData(Le.x,Le.y,Le.width,Le.height),{data:r}=n;for(let t=0,s=r.length;t<s;t+=4)i=.299*r[t]+.587*r[t+1]+.114*r[t+2],(e=r[t+3])&&(r[t+3]=255===e?i:e*(i/255));s.putImageData(n,Le.x,Le.y)}useMask(t,e,i){this.copyWorld(t,e,i,"destination-in")}useEraser(t,e,i){this.copyWorld(t,e,i,"destination-out")}fillWorld(t,e,i,s){i&&(this.blendMode=i),this.fillStyle=e,this.setTempPixelBounds(t,s),this.fillRect(Le.x,Le.y,Le.width,Le.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(Le.x,Le.y,Le.width,Le.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(Le.x,Le.y,Le.width,Le.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(Le.x,Le.y,Le.width,Le.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(Le,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(Re,t,e,i)}copyToPixelBounds(t,e,i,s){t.set(e),s&&t.intersect(this.bounds),t.scale(this.pixelRatio),i&&t.ceil()}isSameSize(t){return this.width===t.width&&this.height===t.height&&(!t.pixelRatio||this.pixelRatio===t.pixelRatio)}getSameCanvas(t,e){const{size:i,pixelSnap:s}=this,n=this.manager?this.manager.get(i):ue.canvas(Object.assign({},i));return n.save(),t&&(Te(n.worldTransform,this.worldTransform),n.useWorldTransform()),e&&(n.smooth=this.smooth),n.pixelSnap!==s&&(n.pixelSnap=s),n}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const De={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Ie={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Ae=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},Ie),We={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},Fe={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},ze=Object.assign(Object.assign({},Fe),Ie),Ue=Ae,He={};for(let t in Ue)He[Ue[t]]=t;const Ne={};for(let t in Ue)Ne[Ue[t]]=We[t];const Ye={drawRoundRect(t,e,i,s,n,r){const o=A.fourNumber(r,Math.min(s/2,n/2)),a=e+s,h=i+n;o[0]?t.moveTo(e+o[0],i):t.moveTo(e,i),o[1]?t.arcTo(a,i,a,h,o[1]):t.lineTo(a,i),o[2]?t.arcTo(a,h,e,h,o[2]):t.lineTo(a,h),o[3]?t.arcTo(e,h,e,i,o[3]):t.lineTo(e,h),o[0]?t.arcTo(e,i,a,i,o[0]):t.lineTo(e,i)}},{sin:Xe,cos:Ve,hypot:je,atan2:Ge,ceil:Ke,abs:Ze,PI:qe,sqrt:Je,pow:$e}=Math,{setPoint:Qe,addPoint:ti}=vt,{set:ei,toNumberPoints:ii}=lt,{M:si,L:ni,C:ri,Q:oi,Z:ai}=Ae,hi={},li={points(t,e,i,s){let n=ii(e);if(t.push(si,n[0],n[1]),i&&n.length>5){let e,r,o,a,h,l,d,c,u,p,g,_,f,m,y,v=n.length;const x=!0===i?.5:i;s&&(n=[n[v-2],n[v-1],...n,n[0],n[1],n[2],n[3]],v=n.length);for(let i=2;i<v-2;i+=2)e=n[i-2],r=n[i-1],o=n[i],a=n[i+1],h=n[i+2],l=n[i+3],g=o-e,_=a-r,f=Je($e(g,2)+$e(_,2)),m=Je($e(h-o,2)+$e(l-a,2)),(f||m)&&(y=f+m,f=x*f/y,m=x*m/y,h-=e,l-=r,d=o-f*h,c=a-f*l,2===i?s||t.push(oi,d,c,o,a):(g||_)&&t.push(ri,u,p,d,c,o,a),u=o+m*h,p=a+m*l);s||t.push(oi,u,p,n[v-2],n[v-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(ni,n[e],n[e+1]);s&&t.push(ai)},rect(t,e,i,s,n){De.creator.path=t,De.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,r){De.creator.path=[],Ye.drawRoundRect(De.creator,e,i,s,n,r),t.push(...De.convertToCanvasData(De.creator.path,!0))},arcTo(t,e,i,s,n,r,o,a,h,l,d){const c=s-e,u=n-i,p=r-s,g=o-n;let _=Ge(u,c),f=Ge(g,p);const m=je(c,u),y=je(p,g);let v=f-_;if(v<0&&(v+=z),m<1e-12||y<1e-12||v<1e-12||Ze(v-qe)<1e-12)return t&&t.push(ni,s,n),h&&(Qe(h,e,i),ti(h,s,n)),d&&ei(d,e,i),void(l&&ei(l,s,n));const x=c*g-p*u<0,w=x?-1:1,E=a/Ve(v/2),b=s+E*Ve(_+v/2+U*w),k=n+E*Xe(_+v/2+U*w);return _-=U*w,f-=U*w,ui(t,b,k,a,a,0,_/F,f/F,x,h,l,d)},arc:(t,e,i,s,n,r,o,a,h,l)=>ui(t,e,i,s,s,0,n,r,o,a,h,l),ellipse(t,e,i,s,n,r,o,a,h,l,d,c){const u=r*F,p=Xe(u),g=Ve(u);let _=o*F,f=a*F;_>qe&&(_-=z),f<0&&(f+=z);let m=f-_;m<0?m+=z:m>z&&(m-=z),h&&(m-=z);const y=Ke(Ze(m/U)),v=m/y,x=Xe(v/4),w=8/3*x*x/Xe(v/2);f=_+v;let E,b,k,T,S,B,P,L,R=Ve(_),C=Xe(_),O=k=g*s*R-p*n*C,M=T=p*s*R+g*n*C,D=e+k,I=i+T;t&&t.push(t.length?ni:si,D,I),l&&Qe(l,D,I),c&&ei(c,D,I);for(let r=0;r<y;r++)E=Ve(f),b=Xe(f),k=g*s*E-p*n*b,T=p*s*E+g*n*b,S=e+O-w*(g*s*C+p*n*R),B=i+M-w*(p*s*C-g*n*R),P=e+k+w*(g*s*b+p*n*E),L=i+T+w*(p*s*b-g*n*E),t&&t.push(ri,S,B,P,L,e+k,i+T),l&&ci(e+O,i+M,S,B,P,L,e+k,i+T,l,!0),O=k,M=T,R=E,C=b,_=f,f+=v;d&&ei(d,e+k,i+T)},quadraticCurveTo(t,e,i,s,n,r,o){t.push(ri,(e+2*s)/3,(i+2*n)/3,(r+2*s)/3,(o+2*n)/3,r,o)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,n,r,o,a){ci(t,e,(t+2*i)/3,(e+2*s)/3,(n+2*i)/3,(r+2*s)/3,n,r,o,a)},toTwoPointBounds(t,e,i,s,n,r,o,a,h,l){const d=[];let c,u,p,g,_,f,m,y,v=t,x=i,w=n,E=o;for(let t=0;t<2;++t)if(1==t&&(v=e,x=s,w=r,E=a),c=-3*v+9*x-9*w+3*E,u=6*v-12*x+6*w,p=3*x-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;g=-p/u,0<g&&g<1&&d.push(g)}else m=u*u-4*p*c,y=Math.sqrt(m),m<0||(_=(-u+y)/(2*c),0<_&&_<1&&d.push(_),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?ti(h,t,e):Qe(h,t,e),ti(h,o,a);for(let l=0,c=d.length;l<c;l++)di(d[l],t,e,i,s,n,r,o,a,hi),ti(h,hi.x,hi.y)},getPointAndSet(t,e,i,s,n,r,o,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,p=3*d*t*t,g=t*t*t;l.x=c*e+u*s+p*r+g*a,l.y=c*i+u*n+p*o+g*h},getPoint(t,e,i,s,n,r,o,a,h){const l={};return di(t,e,i,s,n,r,o,a,h,l),l},getDerivative(t,e,i,s,n){const r=1-t;return 3*r*r*(i-e)+6*r*t*(s-i)+3*t*t*(n-s)}},{getPointAndSet:di,toTwoPointBounds:ci,ellipse:ui}=li,{sin:pi,cos:gi,sqrt:_i,atan2:fi}=Math,{ellipse:mi}=li,yi={ellipticalArc(t,e,i,s,n,r,o,a,h,l,d){const c=(h-e)/2,u=(l-i)/2,p=r*F,g=pi(p),_=gi(p),f=-_*c-g*u,m=-_*u+g*c,y=s*s,v=n*n,x=m*m,w=f*f,E=y*v-y*x-v*w;let b=0;if(E<0){const t=_i(1-E/(y*v));s*=t,n*=t}else b=(o===a?-1:1)*_i(E/(y*x+v*w));const k=b*s*m/n,T=-b*n*f/s,S=fi((m-T)/n,(f-k)/s),B=fi((-m-T)/n,(-f-k)/s);let P=B-S;0===a&&P>0?P-=z:1===a&&P<0&&(P+=z);const L=e+c+_*k-g*T,R=i+u+g*k+_*T,C=P<0?1:0;d||ee.ellipseToCurve?mi(t,L,R,s,n,r,S/F,B/F,C):s!==n||r?t.push(Ae.G,L,R,s,n,r,S/F,B/F,C):t.push(Ae.O,L,R,s,S/F,B/F,C)}},vi={toCommand:t=>[],toNode:t=>[]},{M:xi,m:wi,L:Ei,l:bi,H:ki,h:Ti,V:Si,v:Bi,C:Pi,c:Li,S:Ri,s:Ci,Q:Oi,q:Mi,T:Di,t:Ii,A:Ai,a:Wi,Z:Fi,z:zi,N:Ui,D:Hi,X:Ni,G:Yi,F:Xi,O:Vi,P:ji,U:Gi}=Ae,{rect:Ki,roundRect:Zi,arcTo:qi,arc:Ji,ellipse:$i,quadraticCurveTo:Qi}=li,{ellipticalArc:ts}=yi,es=ne.get("PathConvert"),is={},ss={current:{dot:0},stringify(t,e){let i,s,n,r=0,o=t.length,a="";for(;r<o;){s=t[r],i=Ne[s],a+=s===n?" ":He[s];for(let s=1;s<i;s++)a+=A.float(t[r+s],e),s===i-1||(a+=" ");n=s,r+=i}return a},parse(t,e){let i,s,n,r="";const o=[],a=e?ze:Fe;for(let e=0,h=t.length;e<h;e++)s=t[e],$t[s]?("."===s&&(ns.dot&&(rs(o,r),r=""),ns.dot++),"0"===r&&"."!==s&&(rs(o,r),r=""),r+=s):Ae[s]?(r&&(rs(o,r),r=""),ns.name=Ae[s],ns.length=We[s],ns.index=0,rs(o,ns.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?r+=s:(r&&rs(o,r),r=s):r&&(rs(o,r),r=""),n=s;return r&&rs(o,r),i?ss.toCanvasData(o,e):o},toCanvasData(t,e){let i,s,n,r,o,a=0,h=0,l=0,d=0,c=0,u=t.length;const p=[];for(;c<u;){switch(n=t[c],n){case wi:t[c+1]+=a,t[c+2]+=h;case xi:a=t[c+1],h=t[c+2],p.push(xi,a,h),c+=3;break;case Ti:t[c+1]+=a;case ki:a=t[c+1],p.push(Ei,a,h),c+=2;break;case Bi:t[c+1]+=h;case Si:h=t[c+1],p.push(Ei,a,h),c+=2;break;case bi:t[c+1]+=a,t[c+2]+=h;case Ei:a=t[c+1],h=t[c+2],p.push(Ei,a,h),c+=3;break;case Ci:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ri;case Ri:o=r===Pi||r===Ri,l=o?2*a-i:t[c+1],d=o?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],p.push(Pi,l,d,i,s,a,h),c+=5;break;case Li:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,n=Pi;case Pi:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],p.push(Pi,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Ii:t[c+1]+=a,t[c+2]+=h,n=Di;case Di:o=r===Oi||r===Di,i=o?2*a-i:t[c+1],s=o?2*h-s:t[c+2],e?Qi(p,a,h,i,s,t[c+1],t[c+2]):p.push(Oi,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Mi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Oi;case Oi:i=t[c+1],s=t[c+2],e?Qi(p,a,h,i,s,t[c+3],t[c+4]):p.push(Oi,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Wi:t[c+6]+=a,t[c+7]+=h;case Ai:ts(p,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 zi:case Fi:p.push(Fi),c++;break;case Ui:a=t[c+1],h=t[c+2],e?Ki(p,a,h,t[c+3],t[c+4]):os(p,t,c,5),c+=5;break;case Hi:a=t[c+1],h=t[c+2],e?Zi(p,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):os(p,t,c,9),c+=9;break;case Ni:a=t[c+1],h=t[c+2],e?Zi(p,a,h,t[c+3],t[c+4],t[c+5]):os(p,t,c,6),c+=6;break;case Yi:$i(e?p:os(p,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,is),a=is.x,h=is.y,c+=9;break;case Xi:e?$i(p,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):os(p,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Vi:Ji(e?p:os(p,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,is),a=is.x,h=is.y,c+=7;break;case ji:e?Ji(p,t[c+1],t[c+2],t[c+3],0,360,!1):os(p,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Gi:qi(e?p:os(p,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,is),a=is.x,h=is.y,c+=6;break;default:return es.error(`command: ${n} [index:${c}]`,t),p}r=n}return p},objectToCanvasData(t){if(t[0].name.length>1)return vi.toCommand(t);{const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(xi,t.x,t.y);break;case"L":e.push(Ei,t.x,t.y);break;case"C":e.push(Pi,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Oi,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(Fi)}}),e}},copyData(t,e,i,s){for(let n=i,r=i+s;n<r;n++)t.push(e[n])},pushData(t,e){ns.index===ns.length&&(ns.index=1,t.push(ns.name)),t.push(Number(e)),ns.index++,ns.dot=0}},{current:ns,pushData:rs,copyData:os}=ss,{M:as,L:hs,C:ls,Q:ds,Z:cs,N:us,D:ps,X:gs,G:_s,F:fs,O:ms,P:ys,U:vs}=Ae,{getMinDistanceFrom:xs,getRadianFrom:ws}=lt,{tan:Es,min:bs,abs:ks}=Math,Ts={},Ss={beginPath(t){t.length=0},moveTo(t,e,i){t.push(as,e,i)},lineTo(t,e,i){t.push(hs,e,i)},bezierCurveTo(t,e,i,s,n,r,o){t.push(ls,e,i,s,n,r,o)},quadraticCurveTo(t,e,i,s,n){t.push(ds,e,i,s,n)},closePath(t){t.push(cs)},rect(t,e,i,s,n){t.push(us,e,i,s,n)},roundRect(t,e,i,s,n,r){if(d(r))t.push(gs,e,i,s,n,r);else{const o=A.fourNumber(r);o?t.push(ps,e,i,s,n,...o):t.push(us,e,i,s,n)}},ellipse(t,e,i,s,n,r,o,h,l){if(s===n)return Ps(t,e,i,s,o,h,l);a(r)?t.push(fs,e,i,s,n):(a(o)&&(o=0),a(h)&&(h=360),t.push(_s,e,i,s,n,r,o,h,l?1:0))},arc(t,e,i,s,n,r,o){a(n)?t.push(ys,e,i,s):(a(n)&&(n=0),a(r)&&(r=360),t.push(ms,e,i,s,n,r,o?1:0))},arcTo(t,e,i,s,n,r,a,h,l){if(!o(a)){const t=xs(a,h,e,i,s,n)/(l?1:2);r=bs(r,bs(t,t*ks(Es(ws(a,h,e,i,s,n)/2))))}t.push(vs,e,i,s,n,r)},drawEllipse(t,e,i,s,n,r,o,h,l){li.ellipse(null,e,i,s,n,a(r)?0:r,a(o)?0:o,a(h)?360:h,l,null,null,Ts),t.push(as,Ts.x,Ts.y),Bs(t,e,i,s,n,r,o,h,l)},drawArc(t,e,i,s,n,r,o){li.arc(null,e,i,s,a(n)?0:n,a(r)?360:r,o,null,null,Ts),t.push(as,Ts.x,Ts.y),Ps(t,e,i,s,n,r,o)},drawPoints(t,e,i,s){li.points(t,e,i,s)}},{ellipse:Bs,arc:Ps}=Ss,{moveTo:Ls,lineTo:Rs,quadraticCurveTo:Cs,bezierCurveTo:Os,closePath:Ms,beginPath:Ds,rect:Is,roundRect:As,ellipse:Ws,arc:Fs,arcTo:zs,drawEllipse:Us,drawArc:Hs,drawPoints:Ns}=Ss;class Ys{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?h(t)?De.parse(t):t:[],this}beginPath(){return Ds(this.__path),this.paint(),this}moveTo(t,e){return Ls(this.__path,t,e),this.paint(),this}lineTo(t,e){return Rs(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,r){return Os(this.__path,t,e,i,s,n,r),this.paint(),this}quadraticCurveTo(t,e,i,s){return Cs(this.__path,t,e,i,s),this.paint(),this}closePath(){return Ms(this.__path),this.paint(),this}rect(t,e,i,s){return Is(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return As(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,r,o,a){return Ws(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}arc(t,e,i,s,n,r){return Fs(this.__path,t,e,i,s,n,r),this.paint(),this}arcTo(t,e,i,s,n){return zs(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,r,o,a){return Us(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}drawArc(t,e,i,s,n,r){return Hs(this.__path,t,e,i,s,n,r),this.paint(),this}drawPoints(t,e,i){return Ns(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:Xs,L:Vs,C:js,Q:Gs,Z:Ks,N:Zs,D:qs,X:Js,G:$s,F:Qs,O:tn,P:en,U:sn}=Ae,nn=ne.get("PathDrawer"),rn={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case Xs:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Vs:t.lineTo(e[s+1],e[s+2]),s+=3;break;case js:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case Gs:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Ks:t.closePath(),s+=1;break;case Zs:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case qs: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 Js:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case $s:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*F,e[s+6]*F,e[s+7]*F,e[s+8]),s+=9;break;case Qs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,z,!1),s+=5;break;case tn:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*F,e[s+5]*F,e[s+6]),s+=7;break;case en:t.arc(e[s+1],e[s+2],e[s+3],0,z,!1),s+=4;break;case sn:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void nn.error(`command: ${i} [index:${s}]`,e)}}},{M:on,L:an,C:hn,Q:ln,Z:dn,N:cn,D:un,X:pn,G:gn,F:_n,O:fn,P:mn,U:yn}=Ae,{toTwoPointBounds:vn,toTwoPointBoundsByQuadraticCurve:xn,arcTo:wn,arc:En,ellipse:bn}=li,{addPointBounds:kn,copy:Tn,addPoint:Sn,setPoint:Bn,addBounds:Pn,toBounds:Ln}=vt,Rn=ne.get("PathBounds");let Cn,On,Mn;const Dn={},In={},An={},Wn={toBounds(t,e){Wn.toTwoPointBounds(t,In),Ln(In,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Bn(e,0,0);let i,s,n,r,o,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(o=t[a],0===a&&(o===dn||o===hn||o===ln?Bn(e,h,l):Bn(e,t[a+1],t[a+2])),o){case on:case an:h=t[a+1],l=t[a+2],Sn(e,h,l),a+=3;break;case hn:n=t[a+5],r=t[a+6],vn(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,r,Dn),kn(e,Dn),h=n,l=r,a+=7;break;case ln:i=t[a+1],s=t[a+2],n=t[a+3],r=t[a+4],xn(h,l,i,s,n,r,Dn),kn(e,Dn),h=n,l=r,a+=5;break;case dn:a+=1;break;case cn:h=t[a+1],l=t[a+2],Pn(e,h,l,t[a+3],t[a+4]),a+=5;break;case un:case pn:h=t[a+1],l=t[a+2],Pn(e,h,l,t[a+3],t[a+4]),a+=o===un?9:6;break;case gn:bn(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],Dn,An),0===a?Tn(e,Dn):kn(e,Dn),h=An.x,l=An.y,a+=9;break;case _n:h=t[a+1],l=t[a+2],On=t[a+3],Mn=t[a+4],Pn(e,h-On,l-Mn,2*On,2*Mn),h+=On,a+=5;break;case fn:En(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Dn,An),0===a?Tn(e,Dn):kn(e,Dn),h=An.x,l=An.y,a+=7;break;case mn:h=t[a+1],l=t[a+2],Cn=t[a+3],Pn(e,h-Cn,l-Cn,2*Cn,2*Cn),h+=Cn,a+=4;break;case yn:wn(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Dn,An),0===a?Tn(e,Dn):kn(e,Dn),h=An.x,l=An.y,a+=6;break;default:return void Rn.error(`command: ${o} [index:${a}]`,t)}}},{M:Fn,L:zn,Z:Un}=Ae,{getCenterX:Hn,getCenterY:Nn}=lt,{arcTo:Yn}=Ss,Xn={smooth(t,e,i){let s,n,r,o=0,a=0,h=0,l=0,d=0,c=0,p=0,g=0,_=0;u(e)&&(e=e[0]||0);const f=t.length,m=9===f,y=[];for(;o<f;){switch(s=t[o],s){case Fn:l=g=t[o+1],d=_=t[o+2],o+=3,t[o]===zn?(c=t[o+1],p=t[o+2],m?y.push(Fn,l,d):y.push(Fn,Hn(l,c),Nn(d,p))):y.push(Fn,l,d);break;case zn:switch(a=t[o+1],h=t[o+2],o+=3,t[o]){case zn:Yn(y,a,h,t[o+1],t[o+2],e,g,_,m);break;case Un:Yn(y,a,h,l,d,e,g,_,m);break;default:y.push(zn,a,h)}g=a,_=h;break;case Un:n!==Un&&(Yn(y,l,d,c,p,e,g,_,m),y.push(Un)),o+=1;break;default:r=Ne[s];for(let e=0;e<r;e++)y.push(t[o+e]);o+=r}n=s}return s!==Un&&(y[1]=l,y[2]=d),y}};function Vn(t){return new Ys(t)}const jn=Vn();De.creator=Vn(),De.parse=ss.parse,De.convertToCanvasData=ss.toCanvasData;const{drawRoundRect:Gn}=Ye;function Kn(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){Gn(this,t,e,i,s,n)})}(t)}const Zn={alphaPixelTypes:["png","webp","svg"],upperCaseTypeMap:{},mimeType:(t,e="image")=>!t||t.startsWith(e)?t:("jpg"===t&&(t="jpeg"),e+"/"+t),fileType(t){const e=t.split(".");return e[e.length-1]},isOpaqueImage(t){const e=qn.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{}}}},qn=Zn;qn.mineType=qn.mimeType,qn.alphaPixelTypes.forEach(t=>qn.upperCaseTypeMap[t]=t.toUpperCase());const Jn=ne.get("TaskProcessor");class $n{constructor(t){this.parallel=!0,this.time=1,this.id=v.create(v.TASK),this.task=t}run(){return n(this,void 0,void 0,function*(){try{if(this.isComplete||this.runing)return;if(this.runing=!0,this.canUse&&!this.canUse())return this.cancel();this.task&&(yield this.task())}catch(t){Jn.error(t)}})}complete(){this.isComplete=!0,this.parent=this.task=this.canUse=null}cancel(){this.isCancel=!0,this.complete()}}class Qn{get total(){return this.list.length+this.delayNumber}get finishedIndex(){return this.isComplete?0:this.index+this.parallelSuccessNumber}get remain(){return this.isComplete?this.total:this.total-this.finishedIndex}get percent(){const{total:t}=this;let e=0,i=0;for(let s=0;s<t;s++)s<=this.finishedIndex?(i+=this.list[s].time,s===this.finishedIndex&&(e=i)):e+=this.list[s].time;return this.isComplete?1:i/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&f.assign(this.config,t),this.empty()}add(t,e,i){let s,n,r,a;const h=new $n(t);return h.parent=this,d(e)?a=e:e&&(n=e.parallel,s=e.start,r=e.time,a=e.delay,i||(i=e.canUse)),r&&(h.time=r),!1===n&&(h.parallel=!1),i&&(h.canUse=i),o(a)?this.push(h,s):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(h,s))},a)),this.isComplete=!1,h}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.run()}),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++,t.isCancel?this.runTask():this.nextTask()}).catch(t=>{this.onError(t)}):this.timer=setTimeout(()=>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;const{config:e,list:i,index:s}=this;this.parallelList=[],this.parallelSuccessNumber=0;let n=s+e.parallel;if(n>i.length&&(n=i.length),e.parallel>1)for(let e=s;e<n&&(t=i[e],t.parallel);e++)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 tr=ne.get("Resource"),er={tasker:new Qn,queue:new Qn({parallel:1}),map:{},get isComplete(){return ir.tasker.isComplete},set(t,e){ir.map[t]&&tr.repeat(t),ir.map[t]=e},get:t=>ir.map[t],remove(t){const e=ir.map[t];e&&(e.destroy&&e.destroy(),delete ir.map[t])},loadImage(t,e){return new Promise((i,s)=>{const n=this.setImage(t,t,e);n.load(()=>i(n),t=>s(t))})},setImage(t,e,i){let s;return h(e)?s={url:e}:e.url||(s={url:t,view:e}),s&&(i&&(s.format=i),e=ue.image(s)),ir.set(t,e),e},loadFilm(t,e){},loadVideo(t,e){},destroy(){ir.map={}}},ir=er,sr={maxRecycled:10,recycledList:[],patternTasker:er.queue,get(t,e){let i=er.get(t.url);return i||er.set(t.url,i="film"===e?ue.film(t):ue.image(t)),i.use++,i},recycle(t){t.use--,setTimeout(()=>{t.use||(ee.image.isLarge(t)?t.url&&er.remove(t.url):(t.clearLevels(),nr.recycledList.push(t)))})},recyclePaint(t){nr.recycle(t.image)},clearRecycled(t){const e=nr.recycledList;(e.length>nr.maxRecycled||t)&&(e.forEach(e=>(!e.use||t)&&e.url&&er.remove(e.url)),e.length=0)},clearLevels(){},hasAlphaPixel:t=>Zn.alphaPixelTypes.some(e=>nr.isFormat(e,t)),isFormat(t,e){if(e.format)return e.format===t;const{url:i}=e;if(i.startsWith("data:")){if(i.startsWith("data:"+Zn.mimeType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+Zn.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){this.clearRecycled(!0)}},nr=sr,{IMAGE:rr,create:or}=v;class ar{get tag(){return"Image"}get url(){return this.config.url}get crossOrigin(){const{crossOrigin:t}=this.config;return o(t)?ee.image.crossOrigin:t}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=or(rr),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}sr.isFormat("svg",t)&&(this.isSVG=!0),sr.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(t,e,i){return this.loading||(this.loading=!0,er.tasker.add(()=>n(this,void 0,void 0,function*(){return yield ee.origin["load"+this.tag](this.getLoadUrl(i),this.crossOrigin,this).then(t=>{i&&this.setThumbView(t),this.setView(t)}).catch(t=>{this.error=t,this.onComplete(!1)})}))),this.waitComplete.push(t,e),this.waitComplete.length-2}unload(t,e){const i=this.waitComplete;if(e){const e=i[t+1];e&&e({type:"stop"})}i[t]=i[t+1]=void 0}setView(t){this.ready=!0,this.width||(this.width=t.width,this.height=t.height,this.view=t),this.onComplete(!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}getFull(t){return this.view}getCanvas(t,e,i,s,n,r,o,a){if(t||(t=this.width),e||(e=this.height),this.cache){let{params:t,data:e}=this.cache;for(let i in t)if(t[i]!==arguments[i]){e=null;break}if(e)return e}const h=ee.image.resize(this.view,t,e,n,r,void 0,o,i,s,a);return this.cache=this.use>1?{data:h,params:arguments}:null,h}getPattern(t,e,i,s){const n=ee.canvas.createPattern(t,e);return ee.image.setPatternTransform(n,i,s),n}render(t,e,i,s,n,r,o,a,h){t.drawImage(this.view,e,i,s,n)}getLoadUrl(t){return this.url}setThumbView(t){}getThumbSize(t){}getMinLevel(){}getLevelData(t,e,i){}clearLevels(t){}destroy(){this.clearLevels();const{view:t}=this;t&&t.close&&t.close(),this.config={url:""},this.cache=this.view=null,this.waitComplete.length=0}}function hr(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function lr(t,e){return Object.getOwnPropertyDescriptor(t,e)}function dr(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}function cr(t,e){return(i,s)=>pr(i,s,t,e&&e(s))}function ur(t){return t}function pr(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};hr(t,e,Object.assign(n,s||{})),Hr(t,e,i)}function gr(t){return cr(t)}function _r(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function fr(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function mr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),Er(this))}}))}function yr(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function vr(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function xr(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i,e)&&Er(this)}}))}function wr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(Er(this),this.__.__removeNaturalSize())}}))}function Er(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function br(t){return cr(t,t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),Er(this)}}))}const kr=xr;function Tr(t,e){return cr(t,t=>({set(i){this.__setAttr(t,i)&&(Sr(this),e&&(this.__.__useStroke=!0))}}))}function Sr(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&Er(t)}const Br=Tr;function Pr(t){return cr(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Lr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function Rr(t){return cr(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;f.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip),this.__layout.surfaceChange()}}}))}function Cr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Mr(this)}}))}function Or(t){return cr(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Dr(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Dr(this,t,e,i),this.mask&&Mr(this)}}))}function Mr(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Dr(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||Er(t))}function Ir(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))}function Ar(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}function Wr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}function Fr(t){return cr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===ne.showBounds&&this.__layout.surfaceChange(),this.leafer&&this.leafer.updateCursor())}}))}function zr(t){return cr(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}function Ur(t){return(e,i)=>{hr(e,"__DataProcessor",{get:()=>t})}}function Hr(t,e,i){const s=t.__DataProcessor.prototype,n="_"+e,r=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=dr(e,i);if(o(i))a.get=function(){return this[n]};else if("function"==typeof i)a.get=function(){const t=this[n];return null==t?i(this.__leaf):t};else if(p(i)){const t=_(i);a.get=function(){const e=this[n];return null==e?this[n]=t?{}:f.clone(i):e}}const h=t.isBranchLeaf;"width"===e?a.get=function(){const t=this[n];if(null==t){const t=this,e=t.__naturalWidth,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.width:e?t._height&&t.__useNaturalRatio?t._height*e/t.__naturalHeight:e:h&&s.children.length?s.boxBounds.width:i}return t}:"height"===e&&(a.get=function(){const t=this[n];if(null==t){const t=this,e=t.__naturalHeight,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.height:e?t._width&&t.__useNaturalRatio?t._width*e/t.__naturalWidth:e:h&&s.children.length?s.boxBounds.height:i}return t});let l,d=s;for(;!l&&d;)l=lr(d,e),d=d.__proto__;l&&l.set&&(a.set=l.set),s[r]&&(a.set=s[r],delete s[r]),hr(s,e,a)}const Nr=new ne("rewrite"),Yr=[],Xr=["destroy","constructor"];function Vr(t){return(e,i)=>{Yr.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function jr(){return t=>{Gr()}}function Gr(t){Yr.length&&(Yr.forEach(e=>{t&&Nr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Yr.length=0)}function Kr(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{if(!(Xr.includes(s)||e&&e.includes(s)))if(t.prototype){lr(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]})}}function Zr(){return t=>{ge.register(t)}}function qr(){return t=>{me.register(t)}}setTimeout(()=>Gr(!0));const{copy:Jr,toInnerPoint:$r,toOuterPoint:Qr,scaleOfOuter:to,rotateOfOuter:eo,skewOfOuter:io,multiplyParent:so,divideParent:no,getLayout:ro}=J,oo={},{round:ao}=Math,ho={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),uo(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)co(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])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&po(t),t.__updateChange()},updateAllChange(t){if(_o(t),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},draggable:t=>(t.draggable||t.editable)&&t.hitSelf&&!t.locked,copyCanvasByWorld(t,e,i,s,n,r){s||(s=t.__nowWorld),t.__worldFlipped||ee.fullImageShadow?e.copyWorldByReset(i,s,t.__nowWorld,n,r):e.copyWorldToInner(i,s,t.__layout.renderBounds,n)},moveWorld(t,e,i=0,s,n){const r=p(e)?Object.assign({},e):{x:e,y:i};s?Qr(t.localTransform,r,r,!0):t.parent&&$r(t.parent.scrollWorldTransform,r,r,!0),lo.moveLocal(t,r.x,r.y,n)},moveLocal(t,e,i=0,s){p(e)&&(i=e.y,e=e.x),e+=t.x,i+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=ao(e),i=ao(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,r){lo.zoomOfLocal(t,fo(t,e),i,s,n,r)},zoomOfLocal(t,e,i,s=i,n,r){const o=t.__localMatrix;if(d(s)||(s&&(r=s),s=i),Jr(oo,o),to(oo,e,i,s),lo.hasHighPosition(t))lo.setTransform(t,oo,n,r);else{const e=t.x+oo.e-o.e,a=t.y+oo.f-o.f;r&&!n?t.animate({x:e,y:a,scaleX:t.scaleX*i,scaleY:t.scaleY*s},r):(t.x=e,t.y=a,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){lo.rotateOfLocal(t,fo(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;Jr(oo,n),eo(oo,e,i),lo.hasHighPosition(t)?lo.setTransform(t,oo,!1,s):t.set({x:t.x+oo.e-n.e,y:t.y+oo.f-n.f,rotation:A.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,r){lo.skewOfLocal(t,fo(t,e),i,s,n,r)},skewOfLocal(t,e,i,s=0,n,r){Jr(oo,t.__localMatrix),io(oo,e,i,s),lo.setTransform(t,oo,n,r)},transformWorld(t,e,i,s){Jr(oo,t.worldTransform),so(oo,e),t.parent&&no(oo,t.parent.scrollWorldTransform),lo.setTransform(t,oo,i,s)},transform(t,e,i,s){Jr(oo,t.localTransform),so(oo,e),lo.setTransform(t,oo,i,s)},setTransform(t,e,i,s){const n=t.__,r=n.origin&&lo.getInnerOrigin(t,n.origin),o=ro(e,r,n.around&&lo.getInnerOrigin(t,n.around));if(lo.hasOffset(t)&&(o.x-=n.offsetX,o.y-=n.offsetY),i){const e=o.scaleX/t.scaleX,i=o.scaleY/t.scaleY;if(delete o.scaleX,delete o.scaleY,r){Xt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=lo.getInnerOrigin(t,n.origin);lt.move(o,r.x-s.x,r.y-s.y)}t.set(o),t.scaleResize(e,i,!1)}else t.set(o,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return to(i,lo.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>lt.tempToOuterOf(lo.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return kt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(Jr(oo,t.worldTransform),no(oo,e.scrollWorldTransform),i?oo:Object.assign({},oo)),drop(t,e,i,s){t.setTransform(lo.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||lo.hasOffset(t),hasOffset:t=>t.offsetX||t.offsetY,hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}},animateMove(t,e,i=.3){if(e.x||e.y)if(Math.abs(e.x)<1&&Math.abs(e.y)<1)t.move(e);else{const s=e.x*i,n=e.y*i;e.x-=s,e.y-=n,t.move(s,n),ee.requestRender(()=>lo.animateMove(t,e,i))}}},lo=ho,{updateAllMatrix:co,updateMatrix:uo,updateAllWorldOpacity:po,updateAllChange:go,updateChange:_o}=lo;function fo(t,e){return t.updateLayout(),t.parent?lt.tempToInnerOf(e,t.parent.scrollWorldTransform):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,e)=>vo(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>vo(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>vo(t,e)&&t.__layout.localRenderBounds,excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))};let yo;function vo(t,e){return e||(yo=0),t.__.mask&&(yo=1),yo<0?null:(yo&&(yo=-1),!0)}const{updateBounds:xo}=ho,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,n=i.length;s<n;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),Eo(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&o(i[t.parent.innerId]);)e.add(t.parent),t=t.parent;else for(;t.parent;)e.add(t.parent),t=t.parent},pushAllBranchStack(t,e){let i=e.length;const{children:s}=t;for(let t=0,i=s.length;t<i;t++)s[t].isBranch&&e.push(s[t]);for(let t=i,s=e.length;t<s;t++)bo(e[t],e)},updateBounds(t,e){const i=[t];bo(t,i),ko(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++)xo(s[t]);e&&e===i||xo(i)}},move(t,e,i){let s;const{children:n}=t;for(let r=0,o=n.length;r<o;r++)s=(t=n[r]).__world,s.e+=e,s.f+=i,s.x+=e,s.y+=i,t.isBranch&&To(t,e,i)},scale(t,e,i,s,n,r,o){let a;const{children:h}=t,l=s-1,d=n-1;for(let c=0,u=h.length;c<u;c++)a=(t=h[c]).__world,a.a*=s,a.d*=n,(a.b||a.c)&&(a.b*=s,a.c*=n),a.e===a.x&&a.f===a.y?(a.x=a.e+=(a.e-r)*l+e,a.y=a.f+=(a.f-o)*d+i):(a.e+=(a.e-r)*l+e,a.f+=(a.f-o)*d+i,a.x+=(a.x-r)*l+e,a.y+=(a.y-o)*d+i),a.width*=s,a.height*=n,a.scaleX*=s,a.scaleY*=n,t.isBranch&&So(t,e,i,s,n,r,o)}},{pushAllChildBranch:Eo,pushAllBranchStack:bo,updateBoundsByBranchStack:ko,move:To,scale:So}=wo,Bo={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:Po,updateBounds:Lo}=ho,{toOuterOf:Ro,getPoints:Co,copy:Oo}=Xt,Mo="_localContentBounds",Do="_worldContentBounds",Io="_worldBoxBounds",Ao="_worldStrokeBounds";class Wo{get contentBounds(){return this._contentBounds||this.boxBounds}set contentBounds(t){this._contentBounds=t}get strokeBounds(){return this._strokeBounds||this.boxBounds}get renderBounds(){return this._renderBounds||this.boxBounds}set renderBounds(t){this._renderBounds=t}get localContentBounds(){return Ro(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 Ro(this.contentBounds,this.leaf.__world,this[Do]||(this[Do]={})),this[Do]}get worldBoxBounds(){return Ro(this.boxBounds,this.leaf.__world,this[Io]||(this[Io]={})),this[Io]}get worldStrokeBounds(){return Ro(this.strokeBounds,this.leaf.__world,this[Ao]||(this[Ao]={})),this[Ao]}get a(){return 1}get b(){return 0}get c(){return 0}get d(){return 1}get e(){return this.leaf.__.x}get f(){return this.leaf.__.y}get x(){return this.e+this.boxBounds.x}get y(){return this.f+this.boxBounds.y}get width(){return this.boxBounds.width}get height(){return this.boxBounds.height}constructor(t){this.leaf=t,this.leaf.__local&&(this._localRenderBounds=this._localStrokeBounds=this.leaf.__local),t.__world&&(this.boxBounds={x:0,y:0,width:0,height:0},this.boxChange(),this.matrixChange())}createLocal(){const t=this.leaf.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0};this._localStrokeBounds||(this._localStrokeBounds=t),this._localRenderBounds||(this._localRenderBounds=t)}update(){const{leaf:t}=this,{leafer:e}=t;if(t.isApp)return Lo(t);if(e)e.ready?e.watcher.changed&&e.layouter.layout():e.start();else{let e=t;for(;e.parent&&!e.parent.leafer;)e=e.parent;const i=e;if(i.__fullLayouting)return;i.__fullLayouting=!0,ee.layout(i),delete i.__fullLayouting}}getTransform(t="world"){this.update();const{leaf:e}=this;switch(t){case"world":return e.__world;case"local":return e.__localMatrix;case"inner":return J.defaultMatrix;case"page":t=e.zoomLayer;default:return Po(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 Kt(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,r,o,a=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(a),r=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;o={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},n=s.getLocalPointByInner(a);break;case"inner":n=a,r=J.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),r=Po(s,e,!0)}if(o||(o=J.getLayout(r)),Oo(o,a),lt.copy(o,n),i){const{scaleX:t,scaleY:e}=o,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(o.scaleX/=i,o.scaleY/=s,o.width*=i,o.height*=s)}return o}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=Co(this.getInnerBounds(t));let n;switch(e){case"world":n=null;break;case"local":n=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:n=e}return o(n)||s.forEach(t=>i.innerToWorld(t,null,!1,n)),s}shrinkContent(){const{x:t,y:e,width:i,height:s}=this.boxBounds;this._contentBounds={x:t,y:e,width:i,height:s}}spreadStroke(){const{x:t,y:e,width:i,height:s}=this.strokeBounds;this._strokeBounds={x:t,y:e,width:i,height:s},this._localStrokeBounds={x:t,y:e,width:i,height:s},this.renderSpread||this.spreadRenderCancel()}spreadRender(){const{x:t,y:e,width:i,height:s}=this.renderBounds;this._renderBounds={x:t,y:e,width:i,height:s},this._localRenderBounds={x:t,y:e,width:i,height:s}}shrinkContentCancel(){this._contentBounds=void 0}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this._strokeBounds=this.boxBounds,this._localStrokeBounds=this.leaf.__localBoxBounds,t&&this.spreadRenderCancel()}spreadRenderCancel(){this._renderBounds=this._strokeBounds,this._localRenderBounds=this._localStrokeBounds}boxChange(){this.boxChanged=!0,this.localBoxChanged?this.boundsChanged||(this.boundsChanged=!0):this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChange(),this.leaf.__local||this.createLocal()}matrixChange(){this.matrixChanged=!0,this.localBoxChanged?this.boundsChanged||(this.boundsChanged=!0):this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=this.affectChildrenSort=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class Fo{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&ee.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&ee.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&ee.event.stop(this.origin)}}class zo extends Fo{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";const Uo="property.scroll";class Ho extends Fo{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Ho.CHANGE="property.change",Ho.LEAFER_CHANGE="property.leafer_change",Ho.SCROLL=Uo;const No={scrollX:Uo,scrollY:Uo};class Yo extends Fo{constructor(t,e){super(t),Object.assign(this,e)}}Yo.LOAD="image.load",Yo.LOADED="image.loaded",Yo.ERROR="image.error";class Xo extends Fo{static checkHas(t,e,i){"on"===i?e===Ko?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Vo)||t.hasEvent(jo)||t.hasEvent(Go),t.__hasWorldEvent=t.hasEvent(Ko))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Vo,t),"inner"===e&&t.emit(jo,t)),t.emit(Go,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Ko,this)}}Xo.RESIZE="bounds.resize",Xo.INNER="bounds.inner",Xo.LOCAL="bounds.local",Xo.WORLD="bounds.world";const{RESIZE:Vo,INNER:jo,LOCAL:Go,WORLD:Ko}=Xo,Zo={};[Vo,jo,Go,Ko].forEach(t=>Zo[t]=1);class qo extends Fo{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){p(t)?(super(qo.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!o(this.resizingKeys[t.innerId])}}qo.RESIZE="resize";class Jo extends Fo{constructor(t,e){super(t),this.data=e}}Jo.REQUEST="watch.request",Jo.DATA="watch.data";class $o extends Fo{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}$o.REQUEST="layout.request",$o.START="layout.start",$o.BEFORE="layout.before",$o.LAYOUT="layout",$o.AFTER="layout.after",$o.AGAIN="layout.again",$o.END="layout.end";class Qo extends Fo{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Qo.REQUEST="render.request",Qo.CHILD_START="render.child_start",Qo.CHILD_END="render.child_end",Qo.START="render.start",Qo.BEFORE="render.before",Qo.RENDER="render",Qo.AFTER="render.after",Qo.AGAIN="render.again",Qo.END="render.end",Qo.NEXT="render.next";class ta extends Fo{}ta.START="leafer.start",ta.BEFORE_READY="leafer.before_ready",ta.READY="leafer.ready",ta.AFTER_READY="leafer.after_ready",ta.VIEW_READY="leafer.view_ready",ta.VIEW_COMPLETED="leafer.view_completed",ta.STOP="leafer.stop",ta.RESTART="leafer.restart",ta.END="leafer.end",ta.UPDATE_MODE="leafer.update_mode",ta.TRANSFORM="leafer.transform",ta.MOVE="leafer.move",ta.SCALE="leafer.scale",ta.ROTATE="leafer.rotate",ta.SKEW="leafer.skew";const{MOVE:ea,SCALE:ia,ROTATE:sa,SKEW:na}=ta,ra={x:ea,y:ea,scaleX:ia,scaleY:ia,rotation:sa,skewX:na,skewY:na},oa={};class aa{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(u(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)u(e=t[i])?this.on(i,e[0],e[1]):this.on(i,e);return}let s,n,r;i&&("once"===i?n=!0:"boolean"==typeof i?s=i:(s=i.capture,n=i.once));const o=ha(this,s,!0),a=h(t)?t.split(" "):t,l=n?{listener:e,once:n}:{listener:e};a.forEach(t=>{t&&(r=o[t],r?-1===r.findIndex(t=>t.listener===e)&&r.push(l):o[t]=[l],Zo[t]&&Xo.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=h(t)?t.split(" "):t;if(e){let t,n,r;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const o=ha(this,t);s.forEach(t=>{t&&(n=o[t],n&&(r=n.findIndex(t=>t.listener===e),r>-1&&n.splice(r,1),n.length||delete o[t],Zo[t]&&Xo.checkHas(this,t,"off")))})}else{const{__bubbleMap:t,__captureMap:e}=this;s.forEach(i=>{t&&delete t[i],e&&delete e[i]})}}else this.__bubbleMap=this.__captureMap=void 0}on_(t,e,i,s){return e?this.on(t,i?e=e.bind(i):e,s):u(t)&&t.forEach(t=>this.on(t[0],t[2]?t[1]=t[1].bind(t[2]):t[1],t[3])),{type:t,current:this,listener:e,options:s}}off_(t){if(!t)return;const e=u(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):u(t.type)&&t.type.forEach(e=>t.current.off(e[0],e[1],e[3])))}),e.length=0}once(t,e,i,s){if(!e)return u(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));p(i)?e=e.bind(i):s=i,this.on(t,e,{once:!0,capture:s})}emit(t,e,i){!e&&me.has(t)&&(e=me.get(t,{type:t,target:this,current:this}));const s=ha(this,i)[t];if(s){let n;for(let r=0,o=s.length;r<o&&!((n=s[r])&&(n.listener(e),n.once&&(this.off(t,n.listener,i),r--,o--),e&&e.isStopNow));r++);}this.syncEventer&&this.syncEventer.emitEvent(e,i)}emitEvent(t,e){t.current=this,this.emit(t.type,t,e)}hasEvent(t,e){if(this.syncEventer&&this.syncEventer.hasEvent(t,e))return!0;const{__bubbleMap:i,__captureMap:s}=this,n=i&&i[t],r=s&&s[t];return!!(o(e)?n||r:e?r:n)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function ha(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:oa)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:oa)}}const{on:la,on_:da,off:ca,off_:ua,once:pa,emit:ga,emitEvent:_a,hasEvent:fa,destroy:ma}=aa.prototype,ya={on:la,on_:da,off:ca,off_:ua,once:pa,emit:ga,emitEvent:_a,hasEvent:fa,destroyEventer:ma},va=ne.get("setAttr"),xa={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(!i||l(e)||o(e)||(va.warn(this.innerName,t,e),e=void 0),p(e)||s!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Ho(Ho.LEAFER_CHANGE,this,t,s,e));const i=ra[t];i&&(this.emitEvent(new ta(i,this)),this.emitEvent(new ta(ta.TRANSFORM,this)))}this.emitPropertyEvent(Ho.CHANGE,t,s,e);const i=No[t];return i&&this.emitPropertyEvent(i,t,s,e),!0}return!1}return this.__realSetAttr(t,e),!0},emitPropertyEvent(t,e,i,s){const n=new Ho(t,this,e,i,s);this.isLeafer||this.hasEvent(t)&&this.emitEvent(n),this.leafer.emitEvent(n)},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||o(i.normalStyle[t])||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:wa,multiplyParent:Ea,translateInner:ba,defaultWorld:ka}=J,{toPoint:Ta,tempPoint:Sa}=kt,Ba={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:n}=this;Ea(this.__local||e,t?t.__scrollWorld||t.__world:ka,i,!!e.affectScaleOrRotation,n),s&&ba(Object.assign(s,i),n.scrollX,n.scrollY)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged&&(t.resized||(t.resized="scale"))||t.rotationChanged)&&(wa(e,i,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=void 0),e.e=i.x+i.offsetX,e.f=i.y+i.offsetY,(i.around||i.origin)&&(Ta(i.around||i.origin,t.boxBounds,Sa),ba(e,-Sa.x,-Sa.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:Pa,updateAllMatrix:La}=ho,{updateBounds:Ra}=wo,{toOuterOf:Ca,copyAndSpread:Oa,copy:Ma}=Xt,{toBounds:Da}=Wn,Ia={__updateWorldBounds(){const{__layout:t,__world:e}=this;Ca(t.renderBounds,e,e),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Xo.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Xo.emitWorld(this)},__updateLocalBounds(){const t=this.__layout;t.boxChanged&&(this.__.__pathInputed||this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),t.resized="inner"),t.localBoxChanged&&(this.__local&&this.__updateLocalBoxBounds(),t.localBoxChanged=void 0,t.strokeSpread&&(t.strokeChanged=!0),t.renderSpread&&(t.renderChanged=!0),this.parent&&this.parent.__layout.boxChange()),t.boxChanged=void 0,t.strokeChanged&&(t.strokeSpread=this.__updateStrokeSpread(),t.strokeSpread?(t.strokeBounds===t.boxBounds&&t.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):t.spreadStrokeCancel(),t.strokeChanged=void 0,(t.renderSpread||t.strokeSpread!==t.strokeBoxSpread)&&(t.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),t.resized="inner"),t.renderChanged&&(t.renderSpread=this.__updateRenderSpread(),t.renderSpread?(t.renderBounds!==t.boxBounds&&t.renderBounds!==t.strokeBounds||t.spreadRender(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):t.spreadRenderCancel(),t.renderChanged=void 0,this.parent&&this.parent.__layout.renderChange()),t.resized||(t.resized="local"),t.boundsChanged=void 0},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),Ca(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Ca(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Ca(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?Da(s.path,i):(i.x=0,i.y=0,i.width=s.width,i.height=s.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.__extraUpdate(),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),La(this),Ra(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(La(this),Ra(this,this))):Pa(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;Oa(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;d(i)&&i<=0?Ma(e.renderBounds,e.strokeBounds):Oa(e.renderBounds,e.boxBounds,i)}},Aa={__render(t,e){if(e.shape)return this.__renderShape(t,e);if((!e.cellList||e.cellList.has(this))&&this.__worldOpacity){const i=this.__;if(i.bright&&!e.topRendering)return e.topList.add(this);if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=e.dimOpacity&&!i.dimskip?i.opacity*e.dimOpacity:i.opacity,this.__.__single){if("path"===i.eraser)return this.__renderEraser(t,e);const s=t.getSameCanvas(!0,!0);this.__draw(s,e,t),ho.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);ne.showBounds&&ne.drawBounds(this,t,e)}},__renderShape(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawShape(t,e))},__clip(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawRenderPath(t),t.clipUI(this))},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{excludeRenderBounds:Wa}=mo,{hasSize:Fa}=Xt,za={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){const i=this.__nowWorld=this.__getNowWorld(e);if(this.__worldOpacity&&Fa(i)){const s=this.__;if(s.__useDim)if(s.dim)e.dimOpacity=!0===s.dim?.2:s.dim;else{if(s.bright&&!e.topRendering)return e.topList.add(this);s.dimskip&&e.dimOpacity&&(e.dimOpacity=0)}if(s.__single&&!this.isBranchLeaf){if("path"===s.eraser)return this.__renderEraser(t,e);const n=t.getSameCanvas(!1,!0);this.__renderBranch(n,e),t.opacity=e.dimOpacity?s.opacity*e.dimOpacity:s.opacity,t.copyWorldByReset(n,i,i,s.__blendMode,!0),n.recycle(i)}else this.__renderBranch(t,e)}},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{let i;const{children:s}=this;for(let n=0,r=s.length;n<r;n++)i=s[n],Wa(i,e)||(i.__.complex?i.__renderComplex(t,e):i.__render(t,e))}},__clip(t,e){if(this.__worldOpacity){const{children:i}=this;for(let s=0,n=i.length;s<n;s++)Wa(i[s],e)||i[s].__clip(t,e)}}},Ua={},{LEAF:Ha,create:Na}=v,{stintSet:Ya}=f,{toInnerPoint:Xa,toOuterPoint:Va,multiplyParent:ja}=J,{toOuterOf:Ga}=Xt,{copy:Ka,move:Za}=lt,{moveLocal:qa,zoomOfLocal:Ja,rotateOfLocal:$a,skewOfLocal:Qa,moveWorld:th,zoomOfWorld:eh,rotateOfWorld:ih,skewOfWorld:sh,transform:nh,transformWorld:rh,setTransform:oh,getFlipTransform:ah,getLocalOrigin:hh,getRelativeWorld:lh,drop:dh}=ho;t.Leaf=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return y}get __LayoutProcessor(){return Wo}get leaferIsCreated(){return this.leafer&&this.leafer.created}get leaferIsReady(){return this.leafer&&this.leafer.ready}get isLeafer(){return!1}get isBranch(){return!1}get isBranchLeaf(){return!1}get __localMatrix(){return this.__local||this.__layout}get __localBoxBounds(){return this.__local||this.__layout}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get scrollWorldTransform(){return this.updateLayout(),this.__scrollWorld||this.__world}get boxBounds(){return this.getBounds("box","inner")}get renderBounds(){return this.getBounds("render","inner")}get worldBoxBounds(){return this.getBounds("box")}get worldStrokeBounds(){return this.getBounds("stroke")}get worldRenderBounds(){return this.getBounds("render")}get worldOpacity(){return this.updateLayout(),this.__worldOpacity}get __worldFlipped(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}get __inLazyBounds(){return this.leaferIsCreated&&this.leafer.lazyBounds.hit(this.__world)}get pathInputed(){return this.__.__pathInputed}set event(t){this.on(t)}constructor(t){this.innerId=Na(Ha),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(zo.CREATED)}reset(t){this.leafer&&this.leafer.forceRender(this.__world),0!==t&&(this.__world={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0,scaleX:1,scaleY:1},null!==t&&(this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0})),this.__worldOpacity=1,this.__=new this.__DataProcessor(this),this.__layout=new this.__LayoutProcessor(this),this.__level&&this.resetCustom(),t&&(t.__&&(t=t.toJSON()),t.children?this.set(t):Object.assign(this,t))}resetCustom(){this.__hasMask=this.__hasEraser=null,this.forceUpdate()}waitParent(t,e){e&&(t=t.bind(e)),this.parent?t():this.on(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){o(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=o(e)?null:void 0,this[t]=e}forceRender(t,e){this.forceUpdate("surface")}__extraUpdate(){this.leaferIsReady&&this.leafer.layouter.addExtra(this)}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(t,e){}__updateContentBounds(){}__updateStrokeBounds(t){}__updateRenderBounds(t){}__updateAutoLayout(){}__updateFlowLayout(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){this.__hasEraser=!!t||this.children.some(t=>t.__.eraser)}__renderEraser(t,e){t.save(),this.__clip(t,e);const{renderBounds:i}=this.__layout;t.clearRect(i.x,i.y,i.width,i.height),t.restore()}__updateMask(t){this.__hasMask=this.children.some(t=>t.__.mask&&t.__.visible&&t.__.opacity)}__renderMask(t,e){}__getNowWorld(t){if(t.matrix){this.__cameraWorld||(this.__cameraWorld={});const e=this.__cameraWorld,i=this.__world;return ja(i,t.matrix,e,void 0,i),Ga(this.__layout.renderBounds,e,e),Ya(e,"half",i.half),Ya(e,"ignorePixelSnap",i.ignorePixelSnap),e}return this.__world}getClampRenderScale(){let{scaleX:t}=this.__nowWorld||this.__world;return t<0&&(t=-t),t>1?t:1}getRenderScaleData(t,e){let{scaleX:i,scaleY:s}=sr.patternLocked?this.__world:this.__nowWorld;return t&&(i<0&&(i=-i),s<0&&(s=-s)),(!0===e||"zoom-in"===e&&i>1&&s>1)&&(i=s=1),Ua.scaleX=i,Ua.scaleY=s,Ua}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?lh(this,e):this.worldTransform,n=i?t:{};return Ga(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&Ka(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&Ka(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Xa(this.scrollWorldTransform,t,e,i)}innerToWorld(t,e,i,s){Va(this.scrollWorldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getBoxPoint(t,e,i,s){return this.getBoxPointByInner(this.getInnerPoint(t,e,i,s),null,null,!0)}getBoxPointByInner(t,e,i,s){const n=s?t:Object.assign({},t),{x:r,y:o}=this.boxBounds;return Za(n,-r,-o),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:r,y:o}=this.boxBounds;return Za(n,r,o),n}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const n=s?t:{};return this.worldToLocal(t,n,i,e),n}getLocalPointByInner(t,e,i,s){return this.getWorldPoint(t,this.parent,i,s)}getPagePoint(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,i,s)}getWorldPoint(t,e,i,s){const n=s?t:{};return this.innerToWorld(t,n,i,e),n}getWorldPointByBox(t,e,i,s){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,s),e,i,!0)}getWorldPointByLocal(t,e,i,s){const n=s?t:{};return this.localToWorld(t,n,i,e),n}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e,i){oh(this,t,e,i)}transform(t,e,i){nh(this,t,e,i)}move(t,e,i){qa(this,t,e,i)}moveInner(t,e,i){th(this,t,e,!0,i)}scaleOf(t,e,i,s,n){Ja(this,hh(this,t),e,i,s,n)}rotateOf(t,e,i){$a(this,hh(this,t),e,i)}skewOf(t,e,i,s,n){Qa(this,hh(this,t),e,i,s,n)}transformWorld(t,e,i){rh(this,t,e,i)}moveWorld(t,e,i){th(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){eh(this,t,e,i,s,n)}rotateOfWorld(t,e){ih(this,t,e)}skewOfWorld(t,e,i,s,n){sh(this,t,e,i,s,n)}flip(t,e){nh(this,ah(this,t),!1,e)}scaleResize(t,e=t,i){this.scaleX*=t,this.scaleY*=e}__scaleResize(t,e){}resizeWidth(t){}resizeHeight(t){}hit(t,e){return!0}__hitWorld(t,e){return!0}__hit(t,e){return!0}__hitFill(t){return!0}__hitStroke(t,e){return!0}__hitPixel(t){return!0}__drawHitPath(t){}__updateHitCanvas(){}__render(t,e){}__renderComplex(t,e){}__drawFast(t,e){}__draw(t,e,i){}__clip(t,e){}__renderShape(t,e){}__drawShape(t,e){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return ce.need("path")}getMotionPoint(t){return ce.need("path")}getMotionTotal(){return 0}__updateMotionPath(){}__runAnimation(t,e){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}dropTo(t,e,i){dh(this,t,e,i)}on(t,e,i){}off(t,e,i){}on_(t,e,i,s){}off_(t){}once(t,e,i,s){}emit(t,e,i){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,i){i?this.addAttr(t,e,i):Hr(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=xr),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new zo(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(zo.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}},t.Leaf=s([Kr(xa),Kr(Ba),Kr(Ia),Kr(ya),Kr(Aa)],t.Leaf);const{setListWithFn:ch}=Xt,{sort:uh}=wo,{localBoxBounds:ph,localStrokeBounds:gh,localRenderBounds:_h,maskLocalBoxBounds:fh,maskLocalStrokeBounds:mh,maskLocalRenderBounds:yh}=mo,vh=new ne("Branch");t.Branch=class extends t.Leaf{__updateStrokeSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(t,e){ch(e||this.__layout.boxBounds,this.children,this.__hasMask?fh:ph)}__updateStrokeBounds(t){ch(t||this.__layout.strokeBounds,this.children,this.__hasMask?mh:gh)}__updateRenderBounds(t){ch(t||this.__layout.renderBounds,this.children,this.__hasMask?yh:_h)}__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(uh),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return vh.warn("add self or destroyed");const i=o(e);if(!t.__){if(u(t))return t.forEach(t=>{this.add(t,e),i||e++});if(!(t=ge.get(t.tag,t)))return}t.parent&&t.parent.remove(t),t.parent=this,i?this.children.push(t):this.children.splice(e,0,t),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1);const s=t.__layout;s.boxChanged||s.boxChange(),s.matrixChanged||s.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(zo.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(zo.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}addMany(...t){this.add(t)}remove(t,e){t?t.__?t.animationOut?t.__runAnimation("out",()=>this.__remove(t,e)):this.__remove(t,e):this.find(t).forEach(t=>this.remove(t,e)):o(t)&&super.remove(null,e)}removeAll(t){const{children:e}=this;e.length&&(this.children=[],this.__preRemove(),this.__.__childBranchNumber=0,e.forEach(e=>{this.__realRemoveChild(e),t&&e.destroy()}))}clear(){this.removeAll(!0)}__remove(t,e){const i=this.children.indexOf(t);i>-1&&(this.children.splice(i,1),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),this.__preRemove(),this.__realRemoveChild(t),e&&t.destroy())}__preRemove(){this.__hasMask&&this.__updateMask(),this.__hasEraser&&this.__updateEraser(),this.__layout.boxChange(),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}__realRemoveChild(t){t.__emitLifeEvent(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)}},t.Branch=s([Kr(za)],t.Branch);class xh{get length(){return this.list.length}constructor(t){this.reset(),t&&(u(t)?this.addList(t):this.add(t))}has(t){return t&&!o(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return o(e)?-1:e}add(t){const{list:e,keys:i}=this;o(i[t.innerId])&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(o(i[t.innerId])){const{list:s}=this;for(let t=e,n=s.length;t<n;t++)i[s[t].innerId]++;0===e?s.unshift(t):(e>s.length&&(e=s.length),s.splice(e,0,t)),i[t.innerId]=e}}addList(t){for(let e=0;e<t.length;e++)this.add(t[e])}remove(t){const{list:e}=this;let i;for(let s=0,n=e.length;s<n;s++)o(i)?e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]):this.keys[e[s].innerId]=s-1;o(i)||e.splice(i,1)}sort(t){const{list:e}=this;t?e.sort((t,e)=>e.__level-t.__level):e.sort((t,e)=>t.__level-e.__level)}forEach(t){this.list.forEach(t)}clone(){const t=new xh;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 wh{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(u(t)?this.addList(t):this.add(t))}has(t){return!o(this.keys[t.innerId])}without(t){return o(this.keys[t.innerId])}sort(t){const{levels:e}=this;t?e.sort((t,e)=>e-t):e.sort((t,e)=>t-e)}addList(t){t.forEach(t=>{this.add(t)})}add(t){const{keys:e,levelMap:i}=this;e[t.innerId]||(e[t.innerId]=1,i[t.__level]?i[t.__level].push(t):(i[t.__level]=[t],this.levels.push(t.__level)),this._length++)}forEach(t){let e;this.levels.forEach(i=>{e=this.levelMap[i];for(let i=0,s=e.length;i<s;i++)t(e[i])})}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}}class Eh extends Me{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=ee.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}function bh(t,e){ee.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:Zn.mimeType(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:Zn.mimeType(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:(t,e,i)=>new Promise((e,i)=>{let s=new XMLHttpRequest;s.open("GET",ee.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then(t=>{e(t)}).catch(t=>{i(t)})},s.onerror=t=>i(t),s.send()}),loadContent(t){return n(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})}},ee.canvas=ue.canvas(),ee.conicGradientSupport=!!ee.canvas.context.createConicGradient}Kn(OffscreenCanvasRenderingContext2D.prototype),Kn(Path2D.prototype),Object.assign(ue,{canvas:(t,e)=>new Eh(t,e),image:t=>new ar(t)}),ee.name="web",ee.isWorker=!0,ee.backgrounder=!0,ee.requestRender=function(t){requestAnimationFrame(t)},hr(ee,"devicePixelRatio",{get:()=>1});const{userAgent:kh}=navigator;kh.indexOf("Firefox")>-1?(ee.conicGradientRotate90=!0,ee.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(ee.fullImageShadow=!0),kh.indexOf("Windows")>-1?(ee.os="Windows",ee.intWheelDeltaY=!0):kh.indexOf("Mac")>-1?ee.os="Mac":kh.indexOf("Linux")>-1&&(ee.os="Linux");class Th{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new xh;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 xh,this.target=t,e&&(this.config=f.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(Qo.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(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 Jo(Jo.DATA,{updatedList:this.updatedList})),this.__updatedList=new xh,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Ho.CHANGE,this.__onAttrChange,this],[[zo.ADD,zo.REMOVE],this.__onChildEvent,this],[Jo.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:Sh,updateBounds:Bh,updateChange:Ph}=ho,{pushAllChildBranch:Lh,pushAllParent:Rh}=wo;const{worldBounds:Ch}=mo;class Oh{constructor(t){this.updatedBounds=new Kt,this.beforeBounds=new Kt,this.afterBounds=new Kt,u(t)&&(t=new xh(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Ch)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Ch),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:Mh,updateAllChange:Dh}=ho,Ih=ne.get("Layouter");class Ah{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new wh,this.target=t,e&&(this.config=f.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit($o.START),this.layoutOnce(),t.emitEvent(new $o($o.END,this.layoutedBlocks,this.times))}catch(t){Ih.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Ih.warn("layouting"):this.times>3?Ih.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Jo.REQUEST),this.totalTimes>1&&this.config.usePartLayout?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=he.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:r,AFTER:o}=$o,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new $o(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?(Sh(t,!0),e.add(t),t.isBranch&&Lh(t,e),Rh(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Rh(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||Bh(s[t])}Bh(i)}})}(this.__levelList),function(t){t.list.forEach(Ph)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new $o(r,a,this.times)),i.emitEvent(new $o(o,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,he.end(e)}fullLayout(){const t=he.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=$o,r=this.getBlocks(new xh(e));e.emitEvent(new $o(i,r,this.times)),Ah.fullLayout(e),r.forEach(t=>{t.setAfter()}),e.emitEvent(new $o(s,r,this.times)),e.emitEvent(new $o(n,r,this.times)),this.addBlocks(r),he.end(t)}static fullLayout(t){Mh(t,!0),t.isBranch?wo.updateBounds(t):ho.updateBounds(t),Dh(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Oh([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Oh(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[$o.REQUEST,this.layout,this],[$o.AGAIN,this.layoutAgain,this],[Jo.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Wh=ne.get("Renderer");class Fh{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,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=f.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit($o.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(Qo.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(Qo.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(Qo.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new Kt,Wh.log(e.innerName,"---\x3e");try{this.emitRender(Qo.START),this.renderOnce(t),this.emitRender(Qo.END,this.totalBounds),sr.clearRecycled()}catch(t){this.rendering=!1,Wh.error(t)}Wh.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Wh.warn("rendering");if(this.times>3)return Wh.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new Kt,this.renderOptions={},t)this.emitRender(Qo.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Qo.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Qo.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Qo.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=he.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new Kt(s);i.save(),s.spread(Fh.clipSpread).ceil();const{ceilPartPixel:r}=this.config;i.clipWorld(s,r),i.clearWorld(s,r),this.__render(s,n),i.restore(),he.end(e)}fullRender(){const t=he.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),he.end(t)}__render(t,e){const{canvas:i,target:s}=this,n=t.includes(s.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),ne.showRepaint&&ne.drawRepaint(i,t),this.config.useCellRender&&(r.cellList=this.getCellList()),ee.render(s,i,r),this.renderBounds=e=e||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new Kt;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&t>i)return ee.requestRender(e);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};ee.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new Kt(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 Kt(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Wh.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new Qo(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[Qo.REQUEST,this.update,this],[$o.END,this.__onLayoutEnd,this],[Qo.AGAIN,this.renderAgain,this],[qo.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Fh.clipSpread=10;const zh={},{copyRadiusPoint:Uh}=lt,{hitRadiusPoint:Hh}=Xt;class Nh{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,r=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new xh(i.findList),i.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:o}=this.findList,a=this.getBestMatchLeaf(o,i.bottomList,n,!!i.findList),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:o.length?this.getThroughPath(o):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const n=this.findList=new xh;if(t.length){let e;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||ho.worldHittable(e))&&(this.hitChild(e,o),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&ho.hasParent(t,e))){n.reset();break}return n.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),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>ho.worldHittable(t))}getPath(t){const e=new xh,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new xh;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new xh,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,r;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(r=s.list[t],!n||!n.has(r));t++)e.add(r)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s,n;const{point:r}=this;for(let o=t.length-1;o>-1;o--)if(i=t[o],n=i.__,n.visible&&(!e||n.mask))if(s=Hh(i.__world,n.hitRadius?Uh(zh,r,n.hitRadius):r),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&n.__clipAfterFill&&!i.__hitWorld(r,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,r)}}else 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){let i,n=[];const{children:r}=s;for(let s=0,o=r.length;s<o;s++)if(i=r[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Yh{constructor(t,e){this.config={},e&&(this.config=f.default(e,this.config)),this.picker=new Nh(this.target=t,this),this.finder=ue.finder&&ue.finder()}getByPoint(t,e,i){const{target:s,picker:n}=this;return ee.backgrounder&&s&&s.updateLayout(),n.getByPoint(t,e,i)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):ce.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Xh(t){return cr(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Vh(t){return cr(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}function jh(){return(t,e)=>{const i="_"+e;hr(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(ue,{watcher:(t,e)=>new Th(t,e),layouter:(t,e)=>new Ah(t,e),renderer:(t,e,i)=>new Fh(t,e,i),selector:(t,e)=>new Yh(t,e)}),ee.layout=Ah.fullLayout,ee.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new xh,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const Gh={},Kh={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},Zh=Jt,qh={},Jh={},$h={},Qh={},tl={},el={apply(){ce.need("filter")}},il={},sl={setStyleName:()=>ce.need("state"),set:()=>ce.need("state")},nl={list:{},register(t,e){nl.list[t]=e},get:t=>nl.list[t]},{parse:rl,objectToCanvasData:ol}=ss,{stintSet:al}=f,{hasTransparent:hl}=Kh,ll={originPaint:{}},dl=ne.get("UIData");class cl extends y{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){return this.__getRealStrokeWidth()}get __maxStrokeWidth(){const t=this;return t.__hasMultiStrokeStyle?Math.max(t.__hasMultiStrokeStyle,t.strokeWidth):t.strokeWidth}get __hasMultiPaint(){const t=this;return t.fill&&this.__useStroke||t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return null==this._width}get __autoHeight(){return null==this._height}get __autoSide(){return null==this._width||null==this._height}get __autoSize(){return null==this._width&&null==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,dl.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,dl.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),h(t)||!t?(al(this,"__isTransparentFill",hl(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):p(t)&&this.__setPaint("fill",t)}setStroke(t){h(t)||!t?(al(this,"__isTransparentStroke",hl(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):p(t)&&this.__setPaint("stroke",t)}setPath(t){const e=h(t);e||t&&p(t[0])?(this.__setInput("path",t),this._path=e?rl(t):ol(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){ul(this,"shadow",t)}setInnerShadow(t){ul(this,"innerShadow",t)}setFilter(t){ul(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&Jh.compute("fill",this.__leaf),e&&Jh.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeWidthFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),o(t.strokeWidthFixed)||(i=t.strokeWidthFixed)),i){const t=this.__leaf.getClampRenderScale();return t>1?e/t:e}return e}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),u(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=ll)):(this.__isStrokes=!0,this._stroke||(this._stroke=ll))}__removePaint(t,e){e&&this.__removeInput(t),$h.recycleImage(t,this),"fill"===t?(al(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(al(this,"__isAlphaPixelStroke",void 0),al(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function ul(t,e,i){t.__setInput(e,i),u(i)?(i.some(t=>!1===t.visible)&&(i=i.filter(t=>!1!==t.visible)),i.length||(i=void 0)):i=i&&!1!==i.visible?[i]:void 0,t["_"+e]=i}class pl extends cl{}class gl extends pl{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return this.__single||this.__clipAfterFill}get __clipAfterFill(){const t=this;return"show"!==t.overflow&&t.__leaf.children.length&&(t.__leaf.isOverflow||super.__clipAfterFill)}}class _l extends pl{__getInputData(t,e){const i=super.__getInputData(t,e);return Oe.forEach(t=>delete i[t]),i}}class fl extends gl{}class ml extends cl{get __usePathBox(){return this.points||this.__pathInputed}}class yl extends cl{get __boxStroke(){return!this.__pathInputed}}class vl extends cl{get __boxStroke(){return!this.__pathInputed}}class xl extends ml{}class wl extends cl{}class El extends cl{get __pathInputed(){return 2}}class bl extends pl{}const kl={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Tl extends cl{get __useNaturalRatio(){return!1}setFontWeight(t){h(t)?(this.__setInput("fontWeight",t),t=kl[t]||400):this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=ge.get("Rect",0);const n=e.__layout,r=i.__layout;s||(i.parent=e,i.__world=e.__world,r.boxBounds=n.boxBounds),i.set(t),r.strokeChanged&&n.strokeChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}__getInputData(t,e){const i=super.__getInputData(t,e);return i.textEditing&&delete i.textEditing,i}}class Sl extends yl{get __urlType(){return"image"}setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.fill=t?{type:this.__urlType,mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return t.url&&delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url&&delete i.fill,i}}class Bl extends yl{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const{max:Pl,add:Ll}=S,Rl={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:n}=i,r=this.__box;if((i.stroke||"all"===i.hitStroke)&&n&&"inside"!==s&&(e=t="center"===s?n/2:n,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:n;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*n),r&&(t=Pl(t,r.__layout.strokeSpread=r.__updateStrokeSpread()),e=Math.max(e,r.__layout.strokeBoxSpread)),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n,filter:r,renderSpread:o}=this.__,{strokeSpread:a}=this.__layout,h=this.__box;e&&(t=tl.getShadowRenderSpread(this,e)),s&&(t=Pl(t,s)),r&&(t=Ll(t,el.getSpread(r))),o&&(t=Ll(t,o)),a&&(t=Ll(t,a));let l=t;return i&&(l=Pl(l,tl.getInnerShadowSpread(this,i))),n&&(l=Pl(l,n)),this.__layout.renderShapeSpread=l,h?Pl(h.__updateRenderSpread(),t):t}},{stintSet:Cl}=f,Ol={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);Cl(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),Cl(t,"__fillAfterStroke",e&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill)}if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,n=t.innerShadow||t.blur||t.backgroundBlur||t.filter;Cl(t,"__isFastShadow",e&&!n&&e.length<2&&!e[0].spread&&!tl.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(u(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!n)}t.__checkSingle(),Cl(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){Ml(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:n,stroke:r,__drawAfterFill:o,__fillAfterStroke:a,__isFastShadow:h}=s;if(this.__drawRenderPath(t),s.__useEffect&&!h){const h=Jh.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&tl.shadow(this,t,h),a&&(s.__isStrokes?Jh.strokes(r,this,t,e):Jh.stroke(r,this,t,e)),n&&(s.__isFills?Jh.fills(n,this,t,e):Jh.fill(n,this,t,e)),o&&this.__drawAfterFill(t,e),d&&tl.innerShadow(this,t,h),r&&!a&&(s.__isStrokes?Jh.strokes(r,this,t,e):Jh.stroke(r,this,t,e)),c&&el.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?Jh.strokes(r,this,t,e):Jh.stroke(r,this,t,e)),h){const e=s.shadow[0],{scaleX:i,scaleY:n}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*n,e.blur*i,Kh.string(e.color))}n&&(s.__isFills?Jh.fills(n,this,t,e):Jh.fill(n,this,t,e)),h&&t.restore(),o&&this.__drawAfterFill(t,e),r&&!a&&(s.__isStrokes?Jh.strokes(r,this,t,e):Jh.stroke(r,this,t,e))}}else s.__pathForRender?Ml(this,t,e):this.__drawFast(t,e)},__drawShape(t,e){this.__drawRenderPath(t);const i=this.__,{fill:s,stroke:n}=i;s&&!e.ignoreFill&&(i.__isAlphaPixelFill?Jh.fills(s,this,t,e):Jh.fill("#000000",this,t,e)),i.__isCanvas&&this.__drawAfterFill(t,e),n&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?Jh.strokes(n,this,t,e):Jh.stroke("#000000",this,t,e))},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),t.clipUI(this),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Ml(t,e,i){const{fill:s,stroke:n,__drawAfterFill:r,__fillAfterStroke:o}=t.__;t.__drawRenderPath(e),o&&Jh.stroke(n,t,e,i),s&&Jh.fill(s,t,e,i),r&&t.__drawAfterFill(e,i),n&&!o&&Jh.stroke(n,t,e,i)}const Dl={__drawFast(t,e){let{x:i,y:s,width:n,height:r}=this.__layout.boxBounds;const{fill:o,stroke:a,__drawAfterFill:h}=this.__;if(o&&(t.fillStyle=o,t.fillRect(i,s,n,r)),h&&this.__drawAfterFill(t,e),a){const{strokeAlign:o,__strokeWidth:h}=this.__;if(!h)return;t.setStroke(a,h,this.__);const l=h/2;switch(o){case"center":t.strokeRect(0,0,n,r);break;case"inside":n-=h,r-=h,n<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(i+l,s+l,n,r),t.restore()):t.strokeRect(i+l,s+l,n,r);break;case"outside":t.strokeRect(i-l,s-l,n+h,r+h)}}}};var Il,Al;t.UI=Il=class extends t.Leaf{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 isAutoWidth(){const t=this.__;return t.__autoWidth||t.autoWidth}get isAutoHeight(){const t=this.__;return t.__autoHeight||t.autoHeight}get pen(){const{path:t}=this.__;return jn.set(this.path=t||[]),t||this.__drawPathByBox(jn),jn}reset(t){}set(t,e){t&&Object.assign(this,t)}get(t){return h(t)?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return ce.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return ce.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(jn.set(i=[]),this.__drawPathByBox(jn,!e)),t?ss.toCanvasData(i,!0):i}getPathString(t,e,i){return ss.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||il.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?Xn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&qh.addArrows(this)):t.__pathForRender&&(t.__pathForRender=void 0)}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path,!0)}__drawPathByData(t,e,i){e?rn.drawPathByData(t,e):this.__drawPathByBox(t,i)}__drawPathByBox(t,e){const{x:i,y:s,width:n,height:r}=this.__layout.boxBounds;if(this.__.cornerRadius&&!e){const{cornerRadius:e}=this.__;t.roundRect(i,s,n,r,d(e)?[e]:e)}else t.rect(i,s,n,r);t.closePath()}drawImagePlaceholder(t,e,i){Jh.fill(this.__.placeholderColor,this,e,i)}animate(t,e,i,s){return this.set(t),ce.need("animate")}killAnimate(t,e){}export(t,e){return ce.need("export")}syncExport(t,e){return ce.need("export")}clone(t){const e=f.clone(this.toJSON());return t&&Object.assign(e,t),Il.one(e)}static one(t,e,i,s,n){return ge.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){Zr()(this)}static registerData(t){Ur(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}},s([Ur(cl)],t.UI.prototype,"__",void 0),s([jh()],t.UI.prototype,"zoomLayer",void 0),s([gr("")],t.UI.prototype,"id",void 0),s([gr("")],t.UI.prototype,"name",void 0),s([gr("")],t.UI.prototype,"className",void 0),s([Lr("pass-through")],t.UI.prototype,"blendMode",void 0),s([Cr(1)],t.UI.prototype,"opacity",void 0),s([Or(!0)],t.UI.prototype,"visible",void 0),s([Lr(!1)],t.UI.prototype,"locked",void 0),s([Rr(!1)],t.UI.prototype,"dim",void 0),s([Rr(!1)],t.UI.prototype,"dimskip",void 0),s([Ir(0)],t.UI.prototype,"zIndex",void 0),s([Ar(!1)],t.UI.prototype,"mask",void 0),s([Wr(!1)],t.UI.prototype,"eraser",void 0),s([_r(0,!0)],t.UI.prototype,"x",void 0),s([_r(0,!0)],t.UI.prototype,"y",void 0),s([xr(100,!0)],t.UI.prototype,"width",void 0),s([xr(100,!0)],t.UI.prototype,"height",void 0),s([yr(1,!0)],t.UI.prototype,"scaleX",void 0),s([yr(1,!0)],t.UI.prototype,"scaleY",void 0),s([vr(0,!0)],t.UI.prototype,"rotation",void 0),s([vr(0,!0)],t.UI.prototype,"skewX",void 0),s([vr(0,!0)],t.UI.prototype,"skewY",void 0),s([_r(0,!0)],t.UI.prototype,"offsetX",void 0),s([_r(0,!0)],t.UI.prototype,"offsetY",void 0),s([fr(0,!0)],t.UI.prototype,"scrollX",void 0),s([fr(0,!0)],t.UI.prototype,"scrollY",void 0),s([mr()],t.UI.prototype,"origin",void 0),s([mr()],t.UI.prototype,"around",void 0),s([gr(!1)],t.UI.prototype,"lazy",void 0),s([wr(1)],t.UI.prototype,"pixelRatio",void 0),s([Pr(0)],t.UI.prototype,"renderSpread",void 0),s([br()],t.UI.prototype,"path",void 0),s([kr()],t.UI.prototype,"windingRule",void 0),s([kr(!0)],t.UI.prototype,"closed",void 0),s([xr(0)],t.UI.prototype,"padding",void 0),s([xr(!1)],t.UI.prototype,"lockRatio",void 0),s([xr()],t.UI.prototype,"widthRange",void 0),s([xr()],t.UI.prototype,"heightRange",void 0),s([gr(!1)],t.UI.prototype,"draggable",void 0),s([gr()],t.UI.prototype,"dragBounds",void 0),s([gr("auto")],t.UI.prototype,"dragBoundsType",void 0),s([gr(!1)],t.UI.prototype,"editable",void 0),s([Fr(!0)],t.UI.prototype,"hittable",void 0),s([Fr("path")],t.UI.prototype,"hitFill",void 0),s([Br("path")],t.UI.prototype,"hitStroke",void 0),s([Fr(!1)],t.UI.prototype,"hitBox",void 0),s([Fr(!0)],t.UI.prototype,"hitChildren",void 0),s([Fr(!0)],t.UI.prototype,"hitSelf",void 0),s([Fr()],t.UI.prototype,"hitRadius",void 0),s([zr("")],t.UI.prototype,"cursor",void 0),s([Lr()],t.UI.prototype,"fill",void 0),s([Br(void 0,!0)],t.UI.prototype,"stroke",void 0),s([Br("inside")],t.UI.prototype,"strokeAlign",void 0),s([Br(1,!0)],t.UI.prototype,"strokeWidth",void 0),s([Br(!1)],t.UI.prototype,"strokeWidthFixed",void 0),s([Br("none")],t.UI.prototype,"strokeCap",void 0),s([Br("miter")],t.UI.prototype,"strokeJoin",void 0),s([Br()],t.UI.prototype,"dashPattern",void 0),s([Br(0)],t.UI.prototype,"dashOffset",void 0),s([Br(10)],t.UI.prototype,"miterLimit",void 0),s([kr(0)],t.UI.prototype,"cornerRadius",void 0),s([kr()],t.UI.prototype,"cornerSmoothing",void 0),s([Xh()],t.UI.prototype,"shadow",void 0),s([Xh()],t.UI.prototype,"innerShadow",void 0),s([Xh()],t.UI.prototype,"blur",void 0),s([Xh()],t.UI.prototype,"backgroundBlur",void 0),s([Xh()],t.UI.prototype,"grayscale",void 0),s([Xh()],t.UI.prototype,"filter",void 0),s([Lr()],t.UI.prototype,"placeholderColor",void 0),s([gr(100)],t.UI.prototype,"placeholderDelay",void 0),s([gr({})],t.UI.prototype,"data",void 0),s([Vr(t.Leaf.prototype.reset)],t.UI.prototype,"reset",null),t.UI=Il=s([Kr(Rl),Kr(Ol),jr()],t.UI),t.Group=class extends t.UI{get __tag(){return"Group"}get isBranch(){return!0}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach(t=>this.add(t)),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);if(!this.childlessJSON){const i=e.children=[];this.children.forEach(e=>e.skipJSON||i.push(e.toJSON(t)))}return 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(){}},s([Ur(pl)],t.Group.prototype,"__",void 0),s([xr(0)],t.Group.prototype,"width",void 0),s([xr(0)],t.Group.prototype,"height",void 0),t.Group=s([Kr(t.Branch),Zr()],t.Group);const Wl=ne.get("Leafer");t.Leafer=Al=class extends t.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&er.isComplete}get layoutLocked(){return!this.layouter.running}get view(){return this.canvas&&this.canvas.view}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||{x:0,y:0,width:0,height:0}}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Al.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,f.assign(s,t));const n=this.canvas=ue.canvas(s);this.__controllers.push(this.renderer=ue.renderer(this,n,s),this.watcher=ue.watcher(this,s),this.layouter=ue.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(),e||(this.selector=ue.selector(this),this.interaction=ue.interaction(this,n,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=ue.hitCanvasManager()),this.canvasManager=new ve,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(n),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),Bo.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit(()=>{super.set(t,e)})}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(ta.RESTART):this.emitLeafer(ta.START),this.__controllers.forEach(t=>t.start()),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach(t=>t.stop()),this.running=!1,this.emitLeafer(ta.STOP))}unlockLayout(t=!0){this.layouter.start(),t&&this.updateLayout()}lockLayout(t=!0){t&&this.updateLayout(),this.layouter.stop()}resize(t){const e=f.copyAttrs({},t,Oe);Object.keys(e).forEach(t=>this[t]=e[t])}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new Kt(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=f.copyAttrs({},this.canvas,Oe);e.resize(t),this.updateLazyBounds(),this.__onResize(new qo(t,i))}__onResize(t){this.emitEvent(t),f.copyAttrs(this.__,t,Oe),setTimeout(()=>{this.canvasManager&&this.canvasManager.clearRecycled()},0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(){const{config:t,parentApp:e}=this;e||(t.width&&t.height||(this.autoLayout=new qt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Oe.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t?(this.canvas.zIndex=e,setTimeout(()=>this.parent&&this.parent.__updateSortChildren())):"mode"===t&&this.emit(ta.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Oe.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,n=f.copyAttrs({},s,Oe);n[t]=i[t]=e,i.width&&i.height?s.stopAutoLayout():this.__checkAutoLayout(),this.__doResize(n)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(ta.BEFORE_READY),this.emitLeafer(ta.READY),this.emitLeafer(ta.AFTER_READY),Bo.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(ta.VIEW_READY),Bo.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:n,pixelRatio:r}=this;const o="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,o.x+o.width)),i||(n=Math.max(1,o.y+o.height)),this.__doResize({width:s,height:n,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){Bo.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender(()=>{this.imageReady&&(t&&this.emitLeafer(ta.VIEW_COMPLETED),Bo.run(this.__viewCompletedWait),this.viewCompleted=!0)})}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender(()=>this.interaction.updateCursor())}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return ce.need("view")}getValidMove(t,e,i){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new ta(t,this))}__listenEvents(){const t=he.start("FirstCreate "+this.innerName);this.once([[ta.START,()=>he.end(t)],[$o.START,this.updateLazyBounds,this],[Qo.START,this.__onCreated,this],[Qo.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Jo.DATA,this.__onWatchData,this],[$o.END,this.__onLayoutEnd,this],[Qo.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){Al.list.remove(this);try{this.stop(),this.emitLeafer(ta.END),this.__removeListenEvents(),this.__controllers.forEach(t=>!(this.parent&&t===this.interaction)&&t.destroy()),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager&&this.canvasManager.destroy()),this.canvas&&this.canvas.destroy(),this.config.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout(()=>{sr.clearRecycled()},100)}catch(t){Wl.error(t)}}};t?e():setTimeout(e)}},t.Leafer.list=new xh,s([Ur(_l)],t.Leafer.prototype,"__",void 0),s([xr()],t.Leafer.prototype,"pixelRatio",void 0),s([gr("normal")],t.Leafer.prototype,"mode",void 0),t.Leafer=Al=s([Zr()],t.Leafer),t.Rect=class extends t.UI{get __tag(){return"Rect"}},s([Ur(yl)],t.Rect.prototype,"__",void 0),t.Rect=s([Kr(Dl),jr(),Zr()],t.Rect);const{add:Fl,includes:zl,scroll:Ul}=Xt,Hl=t.Rect.prototype,Nl=t.Group.prototype;t.Box=class extends t.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){if(this.children.length&&!this.pathInputed){const t=this.__;if(t.__autoSide){t.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:e}=this.__layout;t.__autoSize||(t.__autoWidth?(e.width+=e.x,e.x=0,e.height=t.height,e.y=0):(e.height+=e.y,e.y=0,e.width=t.width,e.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t,e;if(this.children.length){const i=this.__,s=this.__layout,{renderBounds:n,boxBounds:r}=s,{overflow:o}=i,a=s.childrenRenderBounds||(s.childrenRenderBounds={x:0,y:0,width:0,height:0});super.__updateRenderBounds(a),(e=o&&o.includes("scroll"))&&(Fl(a,r),Ul(a,i)),this.__updateRectRenderBounds(),t=!zl(r,a),t&&"show"===o&&Fl(n,a)}else this.__updateRectRenderBounds();f.stintSet(this,"isOverflow",t),this.__checkScroll(e)}__updateRectRenderBounds(){}__checkScroll(t){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e)),this.hasScroller&&this.scroller.__render(t,e)}__drawContent(t,e){this.__renderGroup(t,e),(this.__.__useStroke||this.__.__useEffect)&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}},s([Ur(gl)],t.Box.prototype,"__",void 0),s([xr(100)],t.Box.prototype,"width",void 0),s([xr(100)],t.Box.prototype,"height",void 0),s([gr(!1)],t.Box.prototype,"resizeChildren",void 0),s([Pr("show")],t.Box.prototype,"overflow",void 0),s([Vr(Hl.__updateStrokeSpread)],t.Box.prototype,"__updateStrokeSpread",null),s([Vr(Hl.__updateRenderSpread)],t.Box.prototype,"__updateRectRenderSpread",null),s([Vr(Hl.__updateBoxBounds)],t.Box.prototype,"__updateRectBoxBounds",null),s([Vr(Hl.__updateStrokeBounds)],t.Box.prototype,"__updateStrokeBounds",null),s([Vr(Hl.__updateRenderBounds)],t.Box.prototype,"__updateRectRenderBounds",null),s([Vr(Hl.__updateChange)],t.Box.prototype,"__updateRectChange",null),s([Vr(Hl.__render)],t.Box.prototype,"__renderRect",null),s([Vr(Nl.__render)],t.Box.prototype,"__renderGroup",null),t.Box=s([jr(),Zr()],t.Box),t.Frame=class extends t.Box{get __tag(){return"Frame"}get isFrame(){return!0}},s([Ur(fl)],t.Frame.prototype,"__",void 0),s([Lr("#FFFFFF")],t.Frame.prototype,"fill",void 0),s([Pr("hide")],t.Frame.prototype,"overflow",void 0),t.Frame=s([Zr()],t.Frame);const{moveTo:Yl,closePath:Xl,ellipse:Vl}=Ss;t.Ellipse=class extends t.UI{get __tag(){return"Ellipse"}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:n}=this.__,r=t/2,o=e/2,a=this.__.path=[];let h;i?s||n?(i<1?Vl(a,r,o,r*i,o*i,0,s,n,!1):h=!0,Vl(a,r,o,r,o,0,n,s,!0)):(i<1&&(Vl(a,r,o,r*i,o*i),Yl(a,t,o)),Vl(a,r,o,r,o,0,360,0,!0)):s||n?(Yl(a,r,o),Vl(a,r,o,r,o,0,s,n,!1)):Vl(a,r,o,r,o),h||Xl(a),ee.ellipseToCurve&&(this.__.path=this.getPath(!0))}},s([Ur(vl)],t.Ellipse.prototype,"__",void 0),s([kr(0)],t.Ellipse.prototype,"innerRadius",void 0),s([kr(0)],t.Ellipse.prototype,"startAngle",void 0),s([kr(0)],t.Ellipse.prototype,"endAngle",void 0),t.Ellipse=s([Zr()],t.Ellipse);const{sin:jl,cos:Gl,PI:Kl}=Math,{moveTo:Zl,lineTo:ql,closePath:Jl,drawPoints:$l}=Ss;t.Polygon=class extends t.UI{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)$l(e,t.points,t.curve,!0);else{const{width:i,height:s,sides:n}=t,r=i/2,o=s/2;Zl(e,r,0);for(let t=1;t<n;t++)ql(e,r+r*jl(2*t*Kl/n),o-o*Gl(2*t*Kl/n));Jl(e)}}},s([Ur(xl)],t.Polygon.prototype,"__",void 0),s([kr(3)],t.Polygon.prototype,"sides",void 0),s([kr()],t.Polygon.prototype,"points",void 0),s([kr(0)],t.Polygon.prototype,"curve",void 0),t.Polygon=s([jr(),Zr()],t.Polygon);const{sin:Ql,cos:td,PI:ed}=Math,{moveTo:id,lineTo:sd,closePath:nd}=Ss;t.Star=class extends t.UI{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,r=e/2,o=this.__.path=[];id(o,n,0);for(let t=1;t<2*i;t++)sd(o,n+(t%2==0?n:n*s)*Ql(t*ed/i),r-(t%2==0?r:r*s)*td(t*ed/i));nd(o)}},s([Ur(wl)],t.Star.prototype,"__",void 0),s([kr(5)],t.Star.prototype,"corners",void 0),s([kr(.382)],t.Star.prototype,"innerRadius",void 0),t.Star=s([Zr()],t.Star);const{moveTo:rd,lineTo:od,drawPoints:ad}=Ss,{rotate:hd,getAngle:ld,getDistance:dd,defaultPoint:cd}=lt;t.Line=class extends t.UI{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&hd(i,e),i}set toPoint(t){this.width=dd(cd,t),this.rotation=ld(cd,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?ad(e,t.points,t.curve,t.closed):(rd(e,0,0),od(e,this.width,0))}},s([Ur(ml)],t.Line.prototype,"__",void 0),s([Tr("center")],t.Line.prototype,"strokeAlign",void 0),s([xr(0)],t.Line.prototype,"height",void 0),s([kr()],t.Line.prototype,"points",void 0),s([kr(0)],t.Line.prototype,"curve",void 0),s([kr(!1)],t.Line.prototype,"closed",void 0),t.Line=s([Zr()],t.Line),t.Image=class extends t.Rect{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return u(t)&&t[0].image}},s([Ur(Sl)],t.Image.prototype,"__",void 0),s([xr("")],t.Image.prototype,"url",void 0),t.Image=s([Zr()],t.Image);const ud=t.Image;t.Canvas=class extends t.Rect{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=ue.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new ar({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Yo(Yo.LOADED,{image:t}))})}draw(t,e,i,s){const n=new mt(t.worldTransform).invert(),r=new mt;e&&r.translate(e.x,e.y),i&&(d(i)?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),n.multiplyParent(r),t.__render(this.canvas,{matrix:n.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:n}=this.canvas;t.drawImage(n,0,0,n.width,n.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null),super.destroy()}},s([Ur(Bl)],t.Canvas.prototype,"__",void 0),s([Vh(100)],t.Canvas.prototype,"width",void 0),s([Vh(100)],t.Canvas.prototype,"height",void 0),s([Vh(1)],t.Canvas.prototype,"pixelRatio",void 0),s([Vh(!0)],t.Canvas.prototype,"smooth",void 0),s([gr(!1)],t.Canvas.prototype,"safeResize",void 0),s([Vh()],t.Canvas.prototype,"contextSettings",void 0),t.Canvas=s([Zr()],t.Canvas);const{copyAndSpread:pd,includes:gd,spread:_d,setList:fd}=Xt,{stintSet:md}=f;t.Text=class extends t.UI{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:n,fontWeight:r,italic:o,textCase:a,textOverflow:h,padding:l,width:d,height:c}=t;t.__lineHeight=Zh.number(e,n),t.__letterSpacing=Zh.number(i,n),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*n)/2,t.__font=`${o?"italic ":""}${"small-caps"===a?"small-caps ":""}${"normal"!==r?r+" ":""}${n||12}px ${s||"caption"}`,md(t,"__padding",l&&A.fourNumber(l)),md(t,"__clipText","show"!==h&&!t.__autoSize),md(t,"__isCharMode",d||c||t.__letterSpacing||"none"!==a),t.__textDrawData=Gh.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:n,__autoWidth:r,__autoHeight:o}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=a,t.__lineHeight<i&&_d(a,i/2),r||o){if(h.x=r?a.x:0,h.y=o?a.y:0,h.width=r?a.width:t.width,h.height=o?a.height:t.height,n){const[e,i,s,n]=t.__padding;r&&(h.x-=n,h.width+=i+n),o&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),f.stintSet(this,"isOverflow",!gd(h,a)),this.isOverflow?(fd(t.__textBoxBounds={},[h,a]),e.renderChanged=!0):t.__textBoxBounds=h}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;pd(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__updateChange(){super.__updateChange();const t=this.__box;t&&(t.__onUpdateSize(),t.__updateChange())}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!e.exporting||super.__draw(t,e,i)}__drawShape(t,e){e.shape&&this.__box&&this.__box.__drawShape(t,e),super.__drawShape(t,e)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}},s([Ur(Tl)],t.Text.prototype,"__",void 0),s([xr(0)],t.Text.prototype,"width",void 0),s([xr(0)],t.Text.prototype,"height",void 0),s([Lr()],t.Text.prototype,"boxStyle",void 0),s([gr(!1)],t.Text.prototype,"resizeFontSize",void 0),s([Lr("#000000")],t.Text.prototype,"fill",void 0),s([Tr("outside")],t.Text.prototype,"strokeAlign",void 0),s([Fr("all")],t.Text.prototype,"hitFill",void 0),s([xr("")],t.Text.prototype,"text",void 0),s([xr("")],t.Text.prototype,"placeholder",void 0),s([xr("caption")],t.Text.prototype,"fontFamily",void 0),s([xr(12)],t.Text.prototype,"fontSize",void 0),s([xr("normal")],t.Text.prototype,"fontWeight",void 0),s([xr(!1)],t.Text.prototype,"italic",void 0),s([xr("none")],t.Text.prototype,"textCase",void 0),s([xr("none")],t.Text.prototype,"textDecoration",void 0),s([xr(0)],t.Text.prototype,"letterSpacing",void 0),s([xr({type:"percent",value:1.5})],t.Text.prototype,"lineHeight",void 0),s([xr(0)],t.Text.prototype,"paraIndent",void 0),s([xr(0)],t.Text.prototype,"paraSpacing",void 0),s([xr("x")],t.Text.prototype,"writingMode",void 0),s([xr("left")],t.Text.prototype,"textAlign",void 0),s([xr("top")],t.Text.prototype,"verticalAlign",void 0),s([xr(!0)],t.Text.prototype,"autoSizeAlign",void 0),s([xr("normal")],t.Text.prototype,"textWrap",void 0),s([xr("show")],t.Text.prototype,"textOverflow",void 0),s([Lr(!1)],t.Text.prototype,"textEditing",void 0),t.Text=s([Zr()],t.Text),t.Path=class extends t.UI{get __tag(){return"Path"}},s([Ur(El)],t.Path.prototype,"__",void 0),s([Tr("center")],t.Path.prototype,"strokeAlign",void 0),t.Path=s([Zr()],t.Path),t.Pen=class extends t.Group{get __tag(){return"Pen"}setStyle(e){const i=this.pathElement=new t.Path(e);return this.pathStyle=e,this.__path=i.path||(i.path=[]),this.add(i),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,n,r){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,r,o,a){return this}arc(t,e,i,s,n,r){return this}arcTo(t,e,i,s,n){return this}drawEllipse(t,e,i,s,n,r,o,a){return this}drawArc(t,e,i,s,n,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}},s([Ur(bl)],t.Pen.prototype,"__",void 0),s([(t,e)=>{hr(t,e,{get(){return this.__path}})}],t.Pen.prototype,"path",void 0),t.Pen=s([Kr(Ys,["set","path","paint"]),Zr()],t.Pen),t.App=class extends t.Leafer{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){super(t,e)}init(t,e){if(super.init(t,e),t){const{ground:e,tree:i,sky:s,editor:n}=t;e&&(this.ground=this.addLeafer(e)),(i||n)&&(this.tree=this.addLeafer(i||{type:t.type||"design"})),(s||n)&&(this.sky=this.addLeafer(s)),n&&ue.editor(n,this)}}__setApp(){const{canvas:t}=this,{realCanvas:e,view:i}=this.config;e||i===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable()}__updateLocalBounds(){this.forEach(t=>t.updateLayout()),super.__updateLocalBounds()}start(){super.start(),this.forEach(t=>t.start())}stop(){this.forEach(t=>t.stop()),super.stop()}unlockLayout(){super.unlockLayout(),this.forEach(t=>t.unlockLayout())}lockLayout(){super.lockLayout(),this.forEach(t=>t.lockLayout())}forceRender(t,e){this.forEach(i=>i.forceRender(t,e))}addLeafer(e){const i=new t.Leafer(e);return this.add(i),i}add(t,e){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout(()=>this.add(t,e),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t,e),o(e)||(t.canvas.childIndex=e),this.__listenChildEvents(t)}forEach(t){this.children.forEach(t)}__onCreated(){this.created=this.children.every(t=>t.created)}__onReady(){this.children.every(t=>t.ready)&&super.__onReady()}__onViewReady(){this.children.every(t=>t.viewReady)&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){t.context&&this.forEach(i=>e.matrix?i.__render(t,e):t.copyWorld(i.canvas,e.bounds))}__onResize(t){this.forEach(e=>e.resize(t)),super.__onResize(t)}updateLayout(){this.forEach(t=>t.updateLayout())}__getChildConfig(t){const e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&f.assign(e,t),this.autoLayout&&f.copyAttrs(e,this,Oe),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[$o.END,this.__onReady,this],[Qo.START,this.__onCreated,this],[Qo.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(Qo.END,this.__onChildRenderEnd,this))}},t.App=s([Zr()],t.App);const yd={},vd={isHoldSpaceKey:()=>vd.isHold("Space"),isHold:t=>yd[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){yd[t]||(yd[t]=!0)},setUpCode(t){yd[t]=!1}},xd={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class wd extends Fo{get spaceKey(){return vd.isHoldSpaceKey()}get left(){return xd.left(this)}get right(){return xd.right(this)}get middle(){return xd.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return vd.isHoldKeys(t,this)}getBoxPoint(t){return(t||this.current).getBoxPoint(this)}getInnerPoint(t){return(t||this.current).getInnerPoint(this)}getLocalPoint(t){return(t||this.current).getLocalPoint(this)}getPagePoint(){return this.current.getPagePoint(this)}getInner(t){return this.getInnerPoint(t)}getLocal(t){return this.getLocalPoint(t)}getPage(){return this.getPagePoint()}static changeName(t,e){me.changeName(t,e)}}const{min:Ed,max:bd,abs:kd}=Math,{float:Td,sign:Sd}=A,{minX:Bd,maxX:Pd,minY:Ld,maxY:Rd}=Xt,Cd=new Kt,Od=new Kt,Md={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&Dd.getValidMove(t.__localBoxBounds,Dd.getDragBounds(t),s,e,!0),Dd.axisMove(t,e)},limitScaleOf(t,e,i,s){const{dragBounds:n,dragBoundsType:r}=t;n&&Dd.getValidScaleOf(t.__localBoxBounds,Dd.getDragBounds(t),r,t.getLocalPointByInner(t.getInnerPointByBox(e)),i,s,!0)},axisMove(t,e){const{draggable:i}=t;"x"===i&&(e.y=0),"y"===i&&(e.x=0)},getDragBounds(t){const{dragBounds:e}=t;return"parent"===e?t.parent.boxBounds:e},isInnerMode:(t,e,i,s)=>"inner"===i||"auto"===i&&t[s]>e[s],getValidMove(t,e,i,s,n){const r=t.x+s.x,o=t.y+s.y,a=r+t.width,h=o+t.height,l=e.x+e.width,d=e.y+e.height;return n||(s=Object.assign({},s)),Dd.isInnerMode(t,e,i,"width")?r>e.x?s.x+=e.x-r:a<l&&(s.x+=l-a):r<e.x?s.x+=e.x-r:a>l&&(s.x+=l-a),Dd.isInnerMode(t,e,i,"height")?o>e.y?s.y+=e.y-o:h<d&&(s.y+=d-h):o<e.y?s.y+=e.y-o:h>d&&(s.y+=d-h),s.x=Td(s.x),s.y=Td(s.y),s},getValidScaleOf(t,e,i,s,n,r,o){o||(n=Object.assign({},n)),Od.set(e),Cd.set(t).scaleOf(s,n.x,n.y);const a=(s.x-t.x)/t.width,h=1-a,d=(s.y-t.y)/t.height,c=1-d;let u,p,g,_,f=1,m=1;return Dd.isInnerMode(t,e,i,"width")?(n.x<0&&Cd.scaleOf(s,f=1/n.x,1),g=Td(Cd.minX-Od.minX),_=Td(Od.maxX-Cd.maxX),u=a&&g>0?1+g/(a*Cd.width):1,p=h&&_>0?1+_/(h*Cd.width):1,f*=bd(u,p)):(n.x<0&&((Td(Bd(t)-Bd(e))<=0||Td(Pd(e)-Pd(t))<=0)&&Cd.scaleOf(s,f=1/n.x,1),Cd.unsign()),g=Td(Od.minX-Cd.minX),_=Td(Cd.maxX-Od.maxX),u=a&&g>0?1-g/(a*Cd.width):1,p=h&&_>0?1-_/(h*Cd.width):1,f*=Ed(u,p)),Dd.isInnerMode(t,e,i,"height")?(n.y<0&&Cd.scaleOf(s,1,m=1/n.y),g=Td(Cd.minY-Od.minY),_=Td(Od.maxY-Cd.maxY),u=d&&g>0?1+g/(d*Cd.height):1,p=c&&_>0?1+_/(c*Cd.height):1,m*=bd(u,p),r&&(u=bd(kd(f),kd(m)),f=Sd(f)*u,m=Sd(m)*u)):(n.y<0&&((Td(Ld(t)-Ld(e))<=0||Td(Rd(e)-Rd(t))<=0)&&Cd.scaleOf(s,1,m=1/n.y),Cd.unsign()),g=Td(Od.minY-Cd.minY),_=Td(Cd.maxY-Od.maxY),u=d&&g>0?1-g/(d*Cd.height):1,p=c&&_>0?1-_/(c*Cd.height):1,m*=Ed(u,p)),n.x*=l(f)?f:1,n.y*=l(m)?m:1,n}},Dd=Md;t.PointerEvent=class extends wd{},t.PointerEvent.POINTER="pointer",t.PointerEvent.BEFORE_DOWN="pointer.before_down",t.PointerEvent.BEFORE_MOVE="pointer.before_move",t.PointerEvent.BEFORE_UP="pointer.before_up",t.PointerEvent.DOWN="pointer.down",t.PointerEvent.MOVE="pointer.move",t.PointerEvent.UP="pointer.up",t.PointerEvent.OVER="pointer.over",t.PointerEvent.OUT="pointer.out",t.PointerEvent.ENTER="pointer.enter",t.PointerEvent.LEAVE="pointer.leave",t.PointerEvent.TAP="tap",t.PointerEvent.DOUBLE_TAP="double_tap",t.PointerEvent.CLICK="click",t.PointerEvent.DOUBLE_CLICK="double_click",t.PointerEvent.LONG_PRESS="long_press",t.PointerEvent.LONG_TAP="long_tap",t.PointerEvent.MENU="pointer.menu",t.PointerEvent.MENU_TAP="pointer.menu_tap",t.PointerEvent=s([qr()],t.PointerEvent);const Id=t.PointerEvent,Ad={};t.DragEvent=class extends t.PointerEvent{static setList(t){this.list=t instanceof xh?t:new xh(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const n=t.getLocalPoint(i,null,!0);return lt.move(n,e.x-t.x,e.y-t.y),s&&this.limitMove(t,n),Md.axisMove(t,n),n}static limitMove(t,e){Md.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Ad,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Ad,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Ad,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 Xt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),Xt.unsign(i),i}assignMove(t){Ad.x=t?this.totalX:this.moveX,Ad.y=t?this.totalY:this.moveY}},t.DragEvent.BEFORE_DRAG="drag.before_drag",t.DragEvent.START="drag.start",t.DragEvent.DRAG="drag",t.DragEvent.END="drag.end",t.DragEvent.OVER="drag.over",t.DragEvent.OUT="drag.out",t.DragEvent.ENTER="drag.enter",t.DragEvent.LEAVE="drag.leave",t.DragEvent=s([qr()],t.DragEvent);const Wd=t.DragEvent;t.DropEvent=class extends t.PointerEvent{static setList(e){t.DragEvent.setList(e)}static setData(e){t.DragEvent.setData(e)}},t.DropEvent.DROP="drop",t.DropEvent=s([qr()],t.DropEvent),t.MoveEvent=class extends t.DragEvent{},t.MoveEvent.BEFORE_MOVE="move.before_move",t.MoveEvent.START="move.start",t.MoveEvent.MOVE="move",t.MoveEvent.DRAG_ANIMATE="move.drag_animate",t.MoveEvent.END="move.end",t.MoveEvent.PULL_DOWN="move.pull_down",t.MoveEvent.REACH_BOTTOM="move.reach_bottom",t.MoveEvent=s([qr()],t.MoveEvent),t.TouchEvent=class extends wd{},t.TouchEvent=s([qr()],t.TouchEvent);const Fd=t.TouchEvent;t.RotateEvent=class extends t.PointerEvent{},t.RotateEvent.BEFORE_ROTATE="rotate.before_rotate",t.RotateEvent.START="rotate.start",t.RotateEvent.ROTATE="rotate",t.RotateEvent.END="rotate.end",t.RotateEvent=s([qr()],t.RotateEvent),t.SwipeEvent=class extends t.DragEvent{},t.SwipeEvent.SWIPE="swipe",t.SwipeEvent.LEFT="swipe.left",t.SwipeEvent.RIGHT="swipe.right",t.SwipeEvent.UP="swipe.up",t.SwipeEvent.DOWN="swipe.down",t.SwipeEvent=s([qr()],t.SwipeEvent),t.ZoomEvent=class extends t.PointerEvent{},t.ZoomEvent.BEFORE_ZOOM="zoom.before_zoom",t.ZoomEvent.START="zoom.start",t.ZoomEvent.ZOOM="zoom",t.ZoomEvent.END="zoom.end",t.ZoomEvent=s([qr()],t.ZoomEvent),t.KeyEvent=class extends wd{},t.KeyEvent.BEFORE_DOWN="key.before_down",t.KeyEvent.BEFORE_UP="key.before_up",t.KeyEvent.DOWN="key.down",t.KeyEvent.HOLD="key.hold",t.KeyEvent.UP="key.up",t.KeyEvent=s([qr()],t.KeyEvent);const zd={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:e=>e<-45&&e>-135?t.SwipeEvent.UP:e>45&&e<135?t.SwipeEvent.DOWN:e<=45&&e>=-45?t.SwipeEvent.RIGHT:t.SwipeEvent.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:Ud.getSwipeDirection(lt.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,time:Date.now(),buttons:o(t.buttons)?1:0===t.buttons?e:t.buttons,origin:t}},pathHasEventType(t,e){const{list:i}=t;for(let t=0,s=i.length;t<s;t++)if(i[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const i=new xh,{list:s}=t;for(let t=0,n=s.length;t<n;t++)s[t].hasEvent(e)&&i.add(s[t]);return i},pathCanDrag:e=>e&&e.list.some(e=>ho.draggable(e)||!e.isLeafer&&e.hasEvent(t.DragEvent.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},Ud=zd,Hd=new xh,{getDragEventData:Nd,getDropEventData:Yd,getSwipeEventData:Xd}=zd;class Vd{constructor(t){this.dragDataList=[],this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Nd(t,t,t),this.canAnimate=this.canDragOut=!0}getList(e,i){const{proxy:s}=this.interaction.selector,n=s&&s.list.length,r=t.DragEvent.list||this.draggableList||Hd;return this.dragging&&(n?e?Hd:new xh(i?[...s.list,...s.dragHoverExclude]:s.list):r)}checkDrag(e,i){const{interaction:s}=this;if(this.moving&&e.buttons<1)return this.canAnimate=!1,void s.pointerCancel();!this.moving&&i&&(this.moving=s.canMove(this.downData)||s.isHoldRightKey||s.isMobileDragEmpty)&&(this.dragData.moveType="drag",s.emit(t.MoveEvent.START,this.dragData)),this.moving||this.dragStart(e,i),this.drag(e)}dragStart(e,i){this.dragging||(this.dragging=i&&xd.left(e),this.dragging&&(this.interaction.emit(t.DragEvent.START,this.dragData),this.getDraggableList(this.dragData.path),this.setDragStartPoints(this.realDraggableList=this.getList(!0))))}setDragStartPoints(t){this.dragStartPoints={},t.forEach(t=>this.dragStartPoints[t.innerId]={x:t.x,y:t.y})}getDraggableList(t){let e;for(let i=0,s=t.length;i<s;i++)if(e=t.list[i],ho.draggable(e)){this.draggableList=new xh(e);break}}drag(e){const{interaction:i,dragData:s,downData:n}=this,{path:r,throughPath:o}=n;this.dragData=Nd(n,s,e),o&&(this.dragData.throughPath=o),this.dragData.path=r,this.dragDataList.push(this.dragData),this.moving?(e.moving=!0,this.dragData.moveType="drag",i.emit(t.MoveEvent.BEFORE_MOVE,this.dragData),i.emit(t.MoveEvent.MOVE,this.dragData)):this.dragging&&(e.dragging=!0,this.dragReal(),i.emit(t.DragEvent.BEFORE_DRAG,this.dragData),i.emit(t.DragEvent.DRAG,this.dragData))}dragReal(e){const{interaction:i}=this,{running:s}=i,n=this.realDraggableList;if(n.length&&s){const{totalX:s,totalY:r}=this.dragData,{dragLimitAnimate:o}=i.p,a=!o||!!e;n.forEach(i=>{if(i.draggable){const n=h(i.draggable),l=t.DragEvent.getValidMove(i,this.dragStartPoints[i.innerId],{x:s,y:r},a||n);o&&!n&&e?ho.animateMove(i,l,d(o)?o:.3):i.move(l)}})}}dragOverOrOut(e){const{interaction:i}=this,{dragOverPath:s}=this,{path:n}=e;this.dragOverPath=n,s?n.indexAt(0)!==s.indexAt(0)&&(i.emit(t.DragEvent.OUT,e,s),i.emit(t.DragEvent.OVER,e,n)):i.emit(t.DragEvent.OVER,e,n)}dragEnterOrLeave(e){const{interaction:i}=this,{dragEnterPath:s}=this,{path:n}=e;i.emit(t.DragEvent.LEAVE,e,s,n),i.emit(t.DragEvent.ENTER,e,n,s),this.dragEnterPath=n}dragEnd(t){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t)||this.dragEndReal(t))}dragEndReal(e){const{interaction:i,downData:s,dragData:n}=this;e||(e=n);const{path:r,throughPath:o}=s,a=Nd(s,e,e);if(o&&(a.throughPath=o),a.path=r,this.moving&&(this.moving=!1,a.moveType="drag",i.emit(t.MoveEvent.END,a)),this.dragging){const r=this.getList();this.dragging=!1,i.p.dragLimitAnimate&&this.dragReal(!0),i.emit(t.DragEvent.END,a),this.swipe(e,s,n,a),this.drop(e,r,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(lt.getDistance(e,t)>n.config.pointer.swipeDistance){const t=Xd(e,i,s);this.interaction.emit(t.type,t)}}drop(e,i,s){const n=Yd(e,i,t.DragEvent.data);n.path=s,this.interaction.emit(t.DropEvent.DROP,n),this.interaction.emit(t.DragEvent.LEAVE,e,s)}dragReset(){t.DragEvent.list=t.DragEvent.data=this.draggableList=this.dragData=this.downData=this.dragOverPath=this.dragEnterPath=null,this.dragDataList=[]}checkDragEndAnimate(t,e){return!1}animate(t,e){}stopAnimate(){}checkDragOut(t){}autoMoveOnDragOut(t){}autoMoveCancel(){}destroy(){this.dragReset()}}const jd=ne.get("emit");const Gd=["move","zoom","rotate","key"];function Kd(t,e,i,s,n){if(Gd.some(t=>e.startsWith(t))&&t.__.hitChildren&&!qd(t,n)){let r;for(let o=0,a=t.children.length;o<a;o++)r=t.children[o],!i.path.has(r)&&r.__.hittable&&Zd(r,e,i,s,n)}}function Zd(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!qd(t,n)&&(sl.updateEventStyle&&!s&&sl.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=me.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function qd(t,e){return e&&e.has(t)}const Jd={wheel:{zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8}},pointer:{type:"pointer",snap:!0,hitRadius:5,tapTime:120,longPressTime:800,transformTime:500,hover:!0,dragHover:!0,dragDistance:2,swipeDistance:20},touch:{preventDefault:"auto"},multiTouch:{},move:{autoDistance:2},zoom:{},cursor:!0,keyEvent:!0},{pathHasEventType:$d,pathCanDrag:Qd,pathHasOutside:tc}=zd;class ec{get dragging(){return this.dragger.dragging}get transforming(){return this.transformer.transforming}get moveMode(){return!0===this.m.drag||this.isHoldSpaceKey||this.isHoldMiddleKey||this.isHoldRightKey&&this.dragger.moving||this.isDragEmpty}get canHover(){return this.p.hover&&!this.config.mobile}get isDragEmpty(){return this.m.dragEmpty&&this.isRootPath(this.hoverData)&&(!this.downData||this.isRootPath(this.downData))}get isMobileDragEmpty(){return this.m.dragEmpty&&!this.canHover&&this.downData&&this.isTreePath(this.downData)}get isHoldMiddleKey(){return this.m.holdMiddleKey&&this.downData&&xd.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&xd.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&vd.isHoldSpaceKey()}get m(){return this.config.move}get p(){return this.config.pointer}get hitRadius(){return this.p.hitRadius}constructor(t,e,i,s){this.config=f.clone(Jd),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new xh(t),this.createTransformer(),this.dragger=new Vd(this),s&&(this.config=f.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(e,i){e||(e=this.hoverData),e&&(xd.defaultLeft(e),this.updateDownData(e),this.checkPath(e,i),this.downTime=Date.now(),this.emit(t.PointerEvent.BEFORE_DOWN,e),e.path.needUpdate&&this.updateDownData(e),this.emit(t.PointerEvent.DOWN,e),xd.left(e)&&(this.tapWait(),this.longPressWait(e)),this.waitRightTap=xd.right(e),this.dragger.setDragData(e),this.isHoldRightKey||this.updateCursor(e))}pointerMove(t){if(t||(t=this.hoverData),!t)return;const{downData:e}=this;e&&xd.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(e){if(this.emit(t.PointerEvent.BEFORE_MOVE,e,this.defaultPath),this.downData){const t=lt.getDistance(this.downData,e)>this.p.dragDistance;t&&(this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(e,t)}this.dragger.moving||(this.updateHoverData(e),this.checkPath(e),this.emit(t.PointerEvent.MOVE,e),this.pointerHover(e),this.dragging&&(this.dragger.dragOverOrOut(e),this.dragger.dragEnterOrLeave(e))),this.updateCursor(this.downData||e)}pointerUp(e){const{downData:i}=this;if(e||(e=i),!i)return;xd.defaultLeft(e),e.multiTouch=i.multiTouch,this.findPath(e);const s=Object.assign(Object.assign({},e),{path:e.path.clone()});e.path.addList(i.path.list),this.checkPath(e),this.downData=null,this.emit(t.PointerEvent.BEFORE_UP,e),this.emit(t.PointerEvent.UP,e),this.touchLeave(e),e.isCancel||(this.tap(e),this.menuTap(e)),this.dragger.dragEnd(e),this.updateCursor(s)}pointerCancel(){const t=Object.assign({},this.dragger.dragData);t.isCancel=!0,this.pointerUp(t)}menu(e){this.findPath(e),this.emit(t.PointerEvent.MENU,e),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(e)}menuTap(e){this.waitRightTap&&this.waitMenuTap&&(this.emit(t.PointerEvent.MENU_TAP,e),this.waitRightTap=this.waitMenuTap=!1)}createTransformer(){}move(t){}zoom(t){}rotate(t){}transformEnd(){}wheel(t){}multiTouch(t,e){}keyDown(e){if(!this.config.keyEvent)return;this.emit(t.KeyEvent.BEFORE_DOWN,e,this.defaultPath);const{code:i}=e;this.downKeyMap[i]||(this.downKeyMap[i]=!0,vd.setDownCode(i),this.emit(t.KeyEvent.HOLD,e,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(t.KeyEvent.DOWN,e,this.defaultPath)}keyUp(e){if(!this.config.keyEvent)return;this.emit(t.KeyEvent.BEFORE_UP,e,this.defaultPath);const{code:i}=e;this.downKeyMap[i]=!1,vd.setUpCode(i),this.emit(t.KeyEvent.UP,e,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new xh),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t))}pointerOverOrOut(e){const{path:i}=e,{overPath:s}=this;this.overPath=i,s?i.indexAt(0)!==s.indexAt(0)&&(this.emit(t.PointerEvent.OUT,e,s),this.emit(t.PointerEvent.OVER,e,i)):this.emit(t.PointerEvent.OVER,e,i)}pointerEnterOrLeave(e){let{path:i}=e;this.downData&&!this.moveMode&&(i=i.clone(),this.downData.path.forEach(t=>i.add(t)));const{enterPath:s}=this;this.enterPath=i,this.emit(t.PointerEvent.LEAVE,e,s,i),this.emit(t.PointerEvent.ENTER,e,i,s)}touchLeave(e){"touch"===e.pointerType&&this.enterPath&&(this.emit(t.PointerEvent.LEAVE,e),this.dragger.dragging&&this.emit(t.DropEvent.LEAVE,e))}tap(e){const{pointer:i}=this.config,s=this.longTap(e);if(!i.tapMore&&s)return;if(!this.waitTap)return;i.tapMore&&this.emitTap(e);const n=Date.now()-this.downTime,r=[t.PointerEvent.DOUBLE_TAP,t.PointerEvent.DOUBLE_CLICK].some(t=>$d(e.path,t));n<i.tapTime+50&&r?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(e)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout(()=>{i.tapMore||(this.tapWaitCancel(),this.emitTap(e))},i.tapTime))):i.tapMore||(this.tapWaitCancel(),this.emitTap(e))}findPath(t,e){const{hitRadius:i,through:s}=this.p,{bottomList:n,target:r}=this;ee.backgrounder||t.origin||r&&r.updateLayout();const 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&&!tc(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!Qd(t.path))&&!tc(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))}stopDragAnimate(){this.dragger.stopAnimate()}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(e){e||(e=this.hoverData),e&&(this.findPath(e,{exclude:this.dragger.getList(!1,!0),name:t.PointerEvent.MOVE}),this.hoverData=e)}updateCursor(t){if(!this.config.cursor||!this.canHover)return;if(t||(this.updateHoverData(),t=this.downData||this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.canMove(t))return this.setCursor(this.downData?"grabbing":"grab");if(!t)return;let e,i;const{path:s}=t;for(let t=0,n=s.length;t<n&&(e=s.list[t],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);t++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e),s={x:t.clientX-i.x,y:t.clientY-i.y},{bounds:n}=this.canvas;return s.x*=n.width/i.width,s.y*=n.height/i.height,this.p.snap&&lt.round(s),s}emitTap(e){this.emit(t.PointerEvent.TAP,e),this.emit(t.PointerEvent.CLICK,e)}emitDoubleTap(e){this.emit(t.PointerEvent.DOUBLE_TAP,e),this.emit(t.PointerEvent.DOUBLE_CLICK,e)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){this.waitTap&&(clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0)}longPressWait(e){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout(()=>{this.longPressed=!0,this.emit(t.PointerEvent.LONG_PRESS,e)},this.p.longPressTime)}longTap(e){let i;return this.longPressed&&(this.emit(t.PointerEvent.LONG_TAP,e),($d(e.path,t.PointerEvent.LONG_TAP)||$d(e.path,t.PointerEvent.LONG_PRESS))&&(i=!0)),this.longPressWaitCancel(),i}longPressWaitCancel(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressed=!1)}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new Kt(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(d(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(qo.RESIZE,this.__onResize,this)],t.once(ta.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 r=i.length-1;r>-1;r--){if(n=i.list[r],Zd(n,t,e,!0,s))return;n.isApp&&Kd(n,t,e,!0,s)}for(let r=0,o=i.length;r<o;r++)if(n=i.list[r],n.isApp&&Kd(n,t,e,!1,s),Zd(n,t,e,!1,s))return}catch(t){jd.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer&&this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class ic{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}ic.custom={};class sc extends ve{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new xh,this.pixelList=new xh}getPixelType(t,e){return this.__autoClear(),this.pixelList.add(t),ue.hitCanvas(e)}getPathType(t){return this.__autoClear(),this.pathList.add(t),ue.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()}}ee.getSelector=function(t){return t.leafer?t.leafer.selector:ee.selector||(ee.selector=ue.selector())};const{toInnerRadiusPointOf:nc,copyRadiusPoint:rc}=lt,{hitRadiusPoint:oc,hitPoint:ac}=Xt,hc={},lc={},dc=t.Leaf.prototype;dc.hit=function(t,e=0){this.updateLayout(),rc(lc,t,e);const i=this.__world;return!!(e?oc(i,lc):ac(i,lc))&&(this.isBranch?ee.getSelector(this).hitPoint(Object.assign({},lc),e,{target:this}):this.__hitWorld(lc))},dc.__hitWorld=function(t,e){const i=this.__;if(!i.hitSelf)return!1;const s=this.__world,n=this.__layout,r=s.width<10&&s.height<10;if(i.hitRadius&&(rc(hc,t,i.hitRadius),t=hc),nc(t,s,hc),i.hitBox||r){if(Xt.hitRadiusPoint(n.boxBounds,hc))return!0;if(r)return!1}return!n.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),n.boundsChanged||(n.hitCanvasChanged=!1)),this.__hit(hc,e)},dc.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},dc.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},dc.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},dc.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const cc=new mt,uc=t.UI.prototype;uc.__updateHitCanvas=function(){this.__box&&this.__box.__updateHitCanvas();const{hitCanvasManager:t}=this.leafer||this.parent&&this.parent.leafer||{};if(!t)return;const e=this.__,i=(e.__isAlphaPixelFill||e.__isCanvas)&&"pixel"===e.hitFill,s=e.__isAlphaPixelStroke&&"pixel"===e.hitStroke,n=i||s;this.__hitCanvas||(this.__hitCanvas=n?t.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):t.getPathType(this));const r=this.__hitCanvas;if(n){const{renderBounds:t}=this.__layout,n=ee.image.hitCanvasSize,o=r.hitScale=Zt.set(0,0,n,n).getFitMatrix(t).a,{x:a,y:h,width:l,height:d}=Zt.set(t).scale(o);r.resize({width:l,height:d,pixelRatio:1}),r.clear(),sr.patternLocked=!0,this.__renderShape(r,{matrix:cc.setWith(this.__world).scaleWith(1/o).invertWith().translate(-a,-h),snapshot:!0,ignoreFill:!i,ignoreStroke:!s}),sr.patternLocked=!1,r.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(r),r.setStrokeOptions(e)},uc.__hit=function(t,e){if(this.__box&&this.__box.__hit(t))return!0;const i=this.__;if(i.__isHitPixel&&this.__hitPixel(t))return!0;const{hitFill:s}=i,n=(i.fill||i.__isCanvas)&&("path"===s||"pixel"===s&&!(i.__isAlphaPixelFill||i.__isCanvas))||"all"===s||e;if(n&&this.__hitFill(t))return!0;const{hitStroke:r,__maxStrokeWidth:o}=i,a=i.stroke&&("path"===r||"pixel"===r&&!i.__isAlphaPixelStroke)||"all"===r;if(!n&&!a)return!1;const h=2*t.radiusX;let l=h;if(a)switch(i.strokeAlign){case"inside":if(l+=2*o,!n&&this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h;break;case"center":l+=o;break;case"outside":if(l+=2*o,!n){if(!this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h}}return!!l&&this.__hitStroke(t,l)};const pc=t.UI.prototype,gc=t.Rect.prototype,_c=t.Box.prototype;gc.__updateHitCanvas=_c.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?pc.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},gc.__hitFill=_c.__hitFill=function(t){return this.__hitCanvas?pc.__hitFill.call(this,t):Xt.hitRadiusPoint(this.__layout.boxBounds,t)},t.Text.prototype.__drawHitPath=function(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__letterSpacing:n,__textDrawData:r}=this.__;t.beginPath(),n<0?this.__drawPathByBox(t):r.rows.forEach(n=>t.rect(n.x,n.y-s,n.width,e<i?i:e))},t.Group.prototype.pick=function(t,e){return e||(e=r),this.updateLayout(),ee.getSelector(this).getByPoint(t,e.hitRadius||0,Object.assign(Object.assign({},e),{target:this}))};const fc=Me.prototype;function mc(t,e,i){t.__.__font?Jh.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function yc(t,e,i,s,n){const r=i.__;p(t)?Jh.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,r.__strokeWidth*e,r),s.stroke()),r.__useArrow&&Jh.strokeArrow(t,i,s,n)}function vc(t,e,i,s,n){const r=i.__;p(t)?Jh.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,r.__strokeWidth*e,r),Jh.drawTextStroke(i,s,n))}function xc(t,e,i,s,n){const r=s.getSameCanvas(!0,!0);r.font=i.__.__font,vc(t,2,i,r,n),r.blendMode="outside"===e?"destination-out":"destination-in",Jh.fillText(i,r,n),r.blendMode="normal",ho.copyCanvasByWorld(i,s,r),r.recycle(i.__nowWorld)}fc.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},fc.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},fc.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:r,radiusY:o}=t;e&&(s-=e.x,n-=e.y),Zt.set(s-r,n-o,2*r,2*o).scale(i).ceil();const{data:a}=this.context.getImageData(Zt.x,Zt.y,Zt.width||1,Zt.height||1);for(let t=0,e=a.length;t<e;t+=4)if(a[t+3]>0)return!0;return a[3]>0};const{getSpread:wc,copyAndSpread:Ec,toOuterOf:bc,getOuterOf:kc,getByMove:Tc,move:Sc,getIntersectData:Bc}=Xt,Pc={};let Lc;const{stintSet:Rc}=f,{hasTransparent:Cc}=Kh;function Oc(t,e,i){if(!p(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout,{type:r}=e;switch(r){case"image":case"film":case"video":if(!e.url)return;s=$h.image(i,t,e,n,!Lc||!Lc[e.url]),"image"!==r&&$h[r](s);break;case"linear":s=Qh.linearGradient(e,n);break;case"radial":s=Qh.radialGradient(e,n);break;case"angular":s=Qh.conicGradient(e,n);break;case"solid":const{color:a,opacity:h}=e;s={type:r,style:Kh.string(a,h)};break;default:o(e.r)||(s={type:"solid",style:Kh.string(e)})}if(s&&(s.originPaint=e,h(s.style)&&Cc(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const Mc={compute:function(t,e){const i=e.__,s=[];let n,r,o,a=i.__input[t];u(a)||(a=[a]),Lc=$h.recycleImage(t,i);for(let i,n=0,r=a.length;n<r;n++)(i=Oc(t,a[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),r=!0),"fill"===t?(Rc(i,"__isAlphaPixelFill",n),Rc(i,"__isTransparentFill",r)):(Rc(i,"__isAlphaPixelStroke",n),Rc(i,"__isTransparentStroke",r),Rc(i,"__hasMultiStrokeStyle",o))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,mc(e,i,s)},fills:function(t,e,i,s){let n,r,o;for(let a=0,h=t.length;a<h;a++){if(n=t[a],r=n.originPaint,n.image){if(o?o++:o=1,$h.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===o&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||r.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),r.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===r.scaleFixed||"zoom-in"===r.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}r.blendMode&&(i.blendMode=r.blendMode),mc(e,i,s),i.restore()}else r.blendMode?(i.saveBlendMode(r.blendMode),mc(e,i,s),i.restoreBlendMode()):mc(e,i,s)}},fillPathOrText:mc,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:r}=s.__textDrawData;let o;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(r){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>r.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)Jh.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":yc(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),yc(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)yc(t,2,e,i,s);else{const{renderBounds:r}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),yc(t,2,e,o,s),o.clipUI(n),o.clearWorld(r),ho.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){Jh.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":vc(t,1,e,i,s);break;case"inside":xc(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?vc(t,2,e,i,s):xc(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:r,decorationY:o}=n;for(let t=0,i=r.length;t<i;t++)s=r[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(o){const{decorationHeight:t}=n;r.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,r){let o;const a=s.__,{__hasMultiStrokeStyle:h}=a;h||n.setStroke(void 0,a.__strokeWidth*e,a);for(let l=0,d=t.length;l<d;l++)if(o=t[l],(!o.image||!$h.checkImage(o,!1,s,n,r))&&o.style){if(h){const{strokeStyle:t}=o;t?n.setStroke(o.style,a.__getRealStrokeWidth(t)*e,a,t):n.setStroke(o.style,a.__strokeWidth*e,a)}else n.strokeStyle=o.style;o.originPaint.blendMode?(n.saveBlendMode(o.originPaint.blendMode),i?Jh.drawTextStroke(s,n,r):n.stroke(),n.restoreBlendMode()):i?Jh.drawTextStroke(s,n,r):n.stroke()}},shape:function(t,e,i){const s=e.getSameCanvas(),n=e.bounds,r=t.__nowWorld,o=t.__layout,a=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let h,l,d,c,u,p;bc(o.strokeSpread?(Ec(Pc,o.boxBounds,o.strokeSpread),Pc):o.boxBounds,r,a);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(a))p=s,h=u=a,l=r;else{let s;if(ee.fullImageShadow)s=a;else{const t=o.renderShapeSpread?wc(n,S.swapAndScale(o.renderShapeSpread,g,_)):n;s=Bc(t,a)}c=n.getFitMatrix(s);let{a:f,d:m}=c;c.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,i),g*=f,_*=m),u=kc(a,c),h=Tc(u,-c.e,-c.f),l=kc(r,c),Sc(l,-c.e,-c.f);const y=i.matrix;y?(d=new mt(c),d.multiply(y),f*=y.scaleX,m*=y.scaleY):d=c,d.withScale(f,m),i=Object.assign(Object.assign({},i),{matrix:d})}return t.__renderShape(s,i),{canvas:s,matrix:d,fitMatrix:c,bounds:h,renderBounds:l,worldCanvas:p,shapeBounds:u,scaleX:g,scaleY:_}}};let Dc,Ic=new Kt;const{isSame:Ac}=Xt;function Wc(t,e,i,s,n,r){const o=t.__;if("fill"===e&&!o.__naturalWidth&&(o.__naturalWidth=s.width/o.pixelRatio,o.__naturalHeight=s.height/o.pixelRatio,o.__autoSide))return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",o.width),t.setProxyAttr("height",o.height)),!1;if(!n.data){$h.createData(n,s,i,r);const{transform:t}=n.data,{opacity:e,blendMode:a}=i,h=t&&!t.onlyScale||o.path||o.cornerRadius;(h||e&&e<1||a)&&(n.complex=!h||2)}return!0}function Fc(t,e){Hc(t,Yo.LOAD,e)}function zc(t,e){Hc(t,Yo.LOADED,e)}function Uc(t,e,i){e.error=i,t.forceUpdate("surface"),Hc(t,Yo.ERROR,e)}function Hc(t,e,i){t.hasEvent(e)&&t.emitEvent(new Yo(e,i))}function Nc(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Yc,translate:Xc}=J,Vc=new Kt,jc={},Gc={};function Kc(t,e,i,s){const n=h(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let Zc={},qc={a:1,b:0,c:0,d:1,e:0,f:0};const{get:Jc,set:$c,rotateOfOuter:Qc,translate:tu,scaleOfOuter:eu,multiplyParent:iu,scale:su,rotate:nu,skew:ru}=J;function ou(t,e,i,s,n,r,o,a){o&&nu(t,o),a&&ru(t,a.x,a.y),n&&su(t,n,r),tu(t,e.x+i,e.y+s)}const{get:au,scale:hu,copy:lu}=J,{getFloorScale:du}=A,{abs:cu}=Math;const uu={image:function(t,e,i,s,n){let r,o;const a=sr.get(i,i.type);return Dc&&i===Dc.paint&&Ac(s,Dc.boxBounds)?r=Dc.leafPaint:(r={type:i.type,image:a},a.hasAlphaPixel&&(r.isTransparent=!0),Dc=a.use>1?{leafPaint:r,paint:i,boxBounds:Ic.set(s)}:null),(n||a.loading)&&(o={image:a,attrName:e,attrValue:i}),a.ready?(Wc(t,e,i,a,r,s),n&&(Fc(t,o),zc(t,o))):a.error?n&&Uc(t,o,a.error):(n&&(Nc(t,!0),Fc(t,o)),r.loadId=a.load(()=>{Nc(t,!1),t.destroyed||(Wc(t,e,i,a,r,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),zc(t,o)),r.loadId=void 0},e=>{Nc(t,!1),Uc(t,o,e),r.loadId=void 0},i.lod&&a.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),r},checkImage:function(t,e,i,s,n){const{scaleX:r,scaleY:o}=$h.getImageRenderScaleData(t,i,s,n),a=t.film?t.nowIndex:r+"-"+o,{image:h,data:l,originPaint:d}=t,{exporting:c,snapshot:u}=n;return!(!l||t.patternId===a&&!c||u)&&(e&&(l.repeat?e=!1:d.changeful||t.film||"miniapp"===ee.name&&qo.isResizing(i)||c||(e=ee.image.isLarge(h,r,o)||h.width*r>8096||h.height*o>8096)),e?(i.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),$h.drawImage(t,r,o,i,s,n),!0):(!t.style||d.sync||c?$h.createPattern(t,i,s,n):$h.createPatternTask(t,i,s,n),!1))},drawImage:function(t,e,i,s,n,r){const{data:o,image:a,complex:h}=t;let{width:l,height:d}=a;if(h){const{blendMode:r,opacity:c}=t.originPaint,{transform:u}=o;n.save(),2===h&&n.clipUI(s),r&&(n.blendMode=r),c&&(n.opacity*=c),u&&n.transform(u),a.render(n,0,0,l,d,s,t,e,i),n.restore()}else o.scaleX&&(l*=o.scaleX,d*=o.scaleY),a.render(n,0,0,l,d,s,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:r}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return r&&r.scaleX&&(n.scaleX*=Math.abs(r.scaleX),n.scaleY*=Math.abs(r.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(u(i)){let s,n,r,o,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(r||(r={}),r[a]=!0,sr.recyclePaint(s),n.loading&&(o||(o=e.__input&&e.__input[t]||[],u(o)||(o=[o])),n.unload(i[h].loadId,!o.some(t=>t.url===a))));return r}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=sr.patternTasker.add(()=>n(this,void 0,void 0,function*(){$h.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,i,s){let{scaleX:n,scaleY:r}=$h.getImageRenderScaleData(t,e,i,s),o=t.film?t.nowIndex:n+"-"+r;if(t.patternId!==o&&!e.destroyed&&(!ee.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:i,data:s}=t,{opacity:a,filters:h}=t.originPaint,{transform:l,gap:d}=s,c=$h.getPatternFixScale(t,n,r);let u,p,g,{width:_,height:f}=i;c&&(n*=c,r*=c),_*=n,f*=r,d&&(p=d.x*n/cu(s.scaleX||1),g=d.y*r/cu(s.scaleY||1)),(l||1!==n||1!==r)&&(n*=du(_+(p||0)),r*=du(f+(g||0)),u=au(),l&&lu(u,l),hu(u,1/n,1/r));const m=i.getCanvas(_,f,a,h,p,g,e.leafer&&e.leafer.config.smooth,s.interlace),y=i.getPattern(m,s.repeat||ee.origin.noRepeat||"no-repeat",u,t);t.style=y,t.patternId=o}},getPatternFixScale:function(t,e,i){const{image:s}=t;let n,r=ee.image.maxPatternSize,o=s.width*s.height;return s.isSVG?e>1&&(n=Math.ceil(e)/e):r>o&&(r=o),(o*=e*i)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,s){t.data=$h.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=Vc.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:n}=i,{mode:r,align:o,offset:a,scale:l,size:c,rotation:u,skew:g,clipSize:_,repeat:f,gap:m,interlace:y}=t,v=e.width===s&&e.height===n,x={mode:r},w="center"!==o&&(u||0)%180==90;let E,b;switch(Xt.set(Gc,0,0,w?n:s,w?s:n),r&&"cover"!==r&&"fit"!==r?((l||c)&&(A.getScaleData(l,c,i,jc),E=jc.scaleX,b=jc.scaleY),(o||m||f)&&(E&&Xt.scale(Gc,E,b,!0),o&&Bt.toPoint(o,Gc,e,Gc,!0,!0))):v&&!u||(E=b=Xt.getFitScale(e,Gc,"fit"!==r),Xt.put(e,i,o,E,!1,Gc),Xt.scale(Gc,E,b,!0)),a&&lt.move(Gc,a),r){case"stretch":v?E&&(E=b=void 0):(E=e.width/s,b=e.height/n,$h.stretchMode(x,e,E,b));break;case"normal":case"clip":if(Gc.x||Gc.y||E||_||u||g){let t,i;_&&(t=e.width/_.width,i=e.height/_.height),$h.clipMode(x,e,Gc.x,Gc.y,E,b,u,g,t,i),t&&(E=E?E*t:t,b=b?b*i:i)}break;case"repeat":(!v||E||u||g)&&$h.repeatMode(x,e,s,n,Gc.x,Gc.y,E,b,u,g,o,t.freeTransform),f||(x.repeat="repeat");const i=p(f);(m||i)&&(x.gap=function(t,e,i,s,n){let r,o;p(t)?(r=t.x,o=t.y):r=o=t;return{x:Kc(r,i,n.width,e&&e.x),y:Kc(o,s,n.height,e&&e.y)}}(m,i&&f,Gc.width,Gc.height,e));break;default:E&&$h.fillOrFitMode(x,e,Gc.x,Gc.y,E,b,u)}return x.transform||(e.x||e.y)&&Xc(x.transform=Yc(),e.x,e.y),E&&(x.scaleX=E,x.scaleY=b),f&&(x.repeat=h(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),y&&(x.interlace=d(y)||"percent"===y.type?{type:"x",offset:y}:y),x},stretchMode:function(t,e,i,s){const n=Jc(),{x:r,y:o}=e;r||o?tu(n,r,o):i>0&&s>0&&(n.onlyScale=!0),su(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,r,o){const a=Jc();tu(a,e.x+i,e.y+s),su(a,n,r),o&&Qc(a,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=a},clipMode:function(t,e,i,s,n,r,o,a,h,l){const d=Jc();ou(d,e,i,s,n,r,o,a),h&&(o||a?($c(qc),eu(qc,e,h,l),iu(d,qc)):eu(d,e,h,l)),t.transform=d},repeatMode:function(t,e,i,s,n,r,o,a,h,l,d,c){const u=Jc();if(c)ou(u,e,n,r,o,a,h,l);else{if(h)if("center"===d)Qc(u,{x:i/2,y:s/2},h);else switch(nu(u,h),h){case 90:tu(u,s,0);break;case 180:tu(u,i,s);break;case 270:tu(u,0,i)}Zc.x=e.x+n,Zc.y=e.y+r,tu(u,Zc.x,Zc.y),o&&eu(u,Zc,o,a)}t.transform=u}},{toPoint:pu}=kt,{hasTransparent:gu}=Kh,_u={},fu={};function mu(t,e,i,s){if(i){let n,r,o,a;for(let t=0,l=i.length;t<l;t++)n=i[t],h(n)?(o=t/(l-1),r=Kh.string(n,s)):(o=n.offset,r=Kh.string(n.color,s)),e.addColorStop(o,r),!a&&gu(r)&&(a=!0);a&&(t.isTransparent=!0)}}const{getAngle:yu,getDistance:vu}=lt,{get:xu,rotateOfOuter:wu,scaleOfOuter:Eu}=J,{toPoint:bu}=kt,ku={},Tu={};function Su(t,e,i,s,n){let r;const{width:o,height:a}=t;if(o!==a||s){const t=yu(e,i);r=xu(),n?(Eu(r,e,o/a*(s||1),1),wu(r,e,t+90)):(Eu(r,e,1,o/a*(s||1)),wu(r,e,t))}return r}const{getDistance:Bu}=lt,{toPoint:Pu}=kt,Lu={},Ru={};const Cu={linearGradient:function(t,e){let{from:i,to:s,type:n,opacity:r}=t;pu(i||"top",e,_u),pu(s||"bottom",e,fu);const o=ee.canvas.createLinearGradient(_u.x,_u.y,fu.x,fu.y),a={type:n,style:o};return mu(a,o,t.stops,r),a},radialGradient:function(t,e){let{from:i,to:s,type:n,opacity:r,stretch:o}=t;bu(i||"center",e,ku),bu(s||"bottom",e,Tu);const a=ee.canvas.createRadialGradient(ku.x,ku.y,0,ku.x,ku.y,vu(ku,Tu)),h={type:n,style:a};mu(h,a,t.stops,r);const l=Su(e,ku,Tu,o,!0);return l&&(h.transform=l),h},conicGradient:function(t,e){let{from:i,to:s,type:n,opacity:r,stretch:o}=t;Pu(i||"center",e,Lu),Pu(s||"bottom",e,Ru);const a=ee.conicGradientSupport?ee.canvas.createConicGradient(0,Lu.x,Lu.y):ee.canvas.createRadialGradient(Lu.x,Lu.y,0,Lu.x,Lu.y,Bu(Lu,Ru)),h={type:n,style:a};mu(h,a,t.stops,r);const l=Su(e,Lu,Ru,o||1,ee.conicGradientRotate90);return l&&(h.transform=l),h},getTransform:Su},{copy:Ou,move:Mu,toOffsetOutBounds:Du}=Xt,{max:Iu,abs:Au}=Math,Wu={},Fu=new mt,zu={};function Uu(t,e){let i,s,n,r,o=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,r=1.5*(t.blur||0),n=Au(t.spread||0),o=Iu(o,n+r-s),a=Iu(a,n+r+i),h=Iu(h,n+r+s),l=Iu(l,n+r-i)}),o===a&&a===h&&h===l?o:[o,a,h,l]}function Hu(t,e,i){const{shapeBounds:s}=i;let n,r;ee.fullImageShadow?(Ou(Wu,t.bounds),Mu(Wu,e.x-s.x,e.y-s.y),n=t.bounds,r=Wu):(n=s,r=e),t.copyWorld(i.canvas,n,r)}const{toOffsetOutBounds:Nu}=Xt,Yu={};const Xu=Uu;const Vu={shadow:function(t,e,i){let s,n;const{__nowWorld:r}=t,{shadow:o}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;Du(h,zu,l),o.forEach((o,_)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}p.setWorldShadow(zu.offsetX+(o.x||0)*c*f,zu.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f,Kh.string(o.color)),n=tl.getShadowTransform(t,p,i,o,zu,f),n&&p.setTransform(n),Hu(p,zu,i),n&&p.resetTransform(),s=l,o.box&&(p.restore(),p.save(),a&&(p.copyWorld(p,l,r,"copy"),s=r),a?p.copyWorld(a,r,r,"destination-out"):p.copyWorld(i.canvas,d,h,"destination-out")),ho.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:r}=t,{innerShadow:o}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;Nu(h,Yu,l),o.forEach((o,_)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}p.save(),p.setWorldShadow(Yu.offsetX+(o.x||0)*c*f,Yu.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f),n=tl.getShadowTransform(t,p,i,o,Yu,f,!0),n&&p.setTransform(n),Hu(p,Yu,i),p.restore(),a?(p.copyWorld(p,l,r,"copy"),p.copyWorld(a,r,r,"source-out"),s=r):(p.copyWorld(i.canvas,d,h,"source-out"),s=l),p.fillWorld(s,Kh.string(o.color),"source-in"),ho.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Uu,getShadowTransform:function(t,e,i,s,n,r,o){if(s.spread){const i=2*s.spread*r*(o?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return Fu.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),Fu}},isTransformShadow(t){},getInnerShadowSpread:Xu},{excludeRenderBounds:ju}=mo;let Gu;function Ku(t,e,i,s,n,r,o,a){switch(e){case"grayscale":Gu||(Gu=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,r){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),r&&s.recycle(o);qu(t,e,i,1,n,r)}(t,i,s,n,o,a);break;case"opacity-path":qu(t,i,s,r,o,a);break;case"path":a&&i.restore()}}function Zu(t){return t.getSameCanvas(!1,!0)}function qu(t,e,i,s,n,r){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),r?i.recycle(o):i.clearWorld(o)}t.Group.prototype.__renderMask=function(t,e){let i,s,n,r,o,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++){if(i=h[l],a=i.__.mask,a){o&&(Ku(this,o,t,n,s,r,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||ju(i,e)||i.__render(t,e),r=i.__.opacity,Gu=!1,"path"===a||"clipping-path"===a?(r<1?(o="opacity-path",n||(n=Zu(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===a?"grayscale":"alpha",s||(s=Zu(t)),n||(n=Zu(t)),i.__render(s,e));continue}const d=1===r&&i.__.__blendMode;d&&Ku(this,o,t,n,s,r,void 0,!1),ju(i,e)||i.__render(n||t,e),d&&Ku(this,o,t,n,s,r,d,!1)}Ku(this,o,t,n,s,r,void 0,!0)};const Ju=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",$u=Ju+"_#~&*+\\=|≮≯≈≠=…",Qu=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 tp(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ep=tp("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ip=tp("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),sp=tp(Ju),np=tp($u),rp=tp("- —/~|┆·");var op;!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"}(op||(op={}));const{Letter:ap,Single:hp,Before:lp,After:dp,Symbol:cp,Break:up}=op;function pp(t){return ep[t]?ap:rp[t]?up:ip[t]?lp:sp[t]?dp:np[t]?cp:Qu.test(t)?hp:ap}const gp={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let r=n-1;r>-1&&(i=e[r].data[0]," "===i.char);r--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function _p(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:fp}=gp,{Letter:mp,Single:yp,Before:vp,After:xp,Symbol:wp,Break:Ep}=op;let bp,kp,Tp,Sp,Bp,Pp,Lp,Rp,Cp,Op,Mp,Dp,Ip,Ap,Wp,Fp,zp,Up=[];function Hp(t,e){Cp&&!Rp&&(Rp=Cp),bp.data.push({char:t,width:e}),Tp+=e}function Np(){Sp+=Tp,bp.width=Tp,kp.words.push(bp),bp={data:[]},Tp=0}function Yp(){Ap&&(Wp.paraNumber++,kp.paraStart=!0,Ap=!1),Cp&&(kp.startCharSize=Rp,kp.endCharSize=Cp,Rp=0),kp.width=Sp,Fp.width?fp(kp):zp&&Xp(),Up.push(kp),kp={words:[]},Sp=0}function Xp(){Sp>(Wp.maxWidth||0)&&(Wp.maxWidth=Sp)}const{top:Vp,right:jp,bottom:Gp,left:Kp}=t.Direction4;function Zp(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 qp={getDrawData:function(t,e){h(t)||(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,r=e.__getInput("height")||0;const{__padding:o}=e;o&&(n?(i=o[Kp],n-=o[jp]+o[Kp],!n&&(n=.01)):e.autoSizeAlign||(i=o[Kp]),r?(s=o[Vp],r-=o[Vp]+o[Gp],!r&&(r=.01)):e.autoSizeAlign||(s=o[Vp]));const a={bounds:{x:i,y:s,width:n,height:r},rows:[],paraNumber:0,font:ee.canvas.font=e.__font};return function(t,e,i){Wp=t,Up=t.rows,Fp=t.bounds,zp=!Fp.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:r}=i,{canvas:o}=ee,{width:a}=Fp;if(i.__isCharMode){const t="none"!==i.textWrap,h="break"===i.textWrap;Ap=!0,Mp=null,Rp=Lp=Cp=Tp=Sp=0,bp={data:[]},kp={words:[]},s&&(e=[...e]);for(let i=0,l=e.length;i<l;i++)Pp=e[i],"\n"===Pp?(Tp&&Np(),kp.paraEnd=!0,Yp(),Ap=!0):(Op=pp(Pp),Op===mp&&"none"!==r&&(Pp=_p(Pp,r,!Tp)),Lp=o.measureText(Pp).width,s&&(s<0&&(Cp=Lp),Lp+=s),Dp=Op===yp&&(Mp===yp||Mp===mp)||Mp===yp&&Op!==xp,Ip=!(Op!==vp&&Op!==yp||Mp!==wp&&Mp!==xp),Bp=Ap&&n?a-n:a,t&&a&&Sp+Tp+Lp>Bp&&(h?(Tp&&Np(),Sp&&Yp()):(Ip||(Ip=Op===mp&&Mp==xp),Dp||Ip||Op===Ep||Op===vp||Op===yp||Tp+Lp>Bp?(Tp&&Np(),Sp&&Yp()):Sp&&Yp()))," "===Pp&&!0!==Ap&&Sp+Tp===0||(Op===Ep?(" "===Pp&&Tp&&Np(),Hp(Pp,Lp),Np()):Dp||Ip?(Tp&&Np(),Hp(Pp,Lp)):Hp(Pp,Lp)),Mp=Op);Tp&&Np(),Sp&&Yp(),Up.length>0&&(Up[Up.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Wp.paraNumber++,Sp=o.measureText(t).width,Up.push({x:n||0,text:t,width:Sp,paraStart:!0}),zp&&Xp()})}(a,t,e),o&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Zp(e,"x",t[Kp]);break;case"right":Zp(e,"x",-t[jp])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Zp(e,"y",t[Vp]);break;case"bottom":Zp(e,"y",-t[Gp])}}(o,a,e,n,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:r,__baseLine:o,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:p,y:g,width:_,height:f}=s,m=r*n+(c?c*(t.paraNumber-1):0),y=o;if(h&&m>f)m=Math.max(e.__autoHeight?m:f,r),n>1&&(t.overflow=n);else if(f||u)switch(d){case"middle":g+=(f-m)/2;break;case"bottom":g+=f-m}y+=g;let v,x,w,E=_||u?_:t.maxWidth;for(let o=0,d=n;o<d;o++){if(v=i[o],v.x=p,v.width<_||v.width>_&&!h)switch(l){case"center":v.x+=(E-v.width)/2;break;case"right":v.x+=E-v.width}v.paraStart&&c&&o>0&&(y+=c),v.y=y,y+=r,t.overflow>o&&y>m&&(v.isOverflow=!0,t.overflow=o+1),x=v.x,w=v.width,a<0&&(v.width<0?(w=-v.width+e.fontSize+a,x-=w,w+=e.fontSize):w-=a),x<s.x&&(s.x=x),w>s.width&&(s.width=w),h&&_&&_<w&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=m}(a,e),e.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:r,__letterSpacing:o}=e,a=i&&n.includes("both"),h=a||i&&n.includes("justify"),l=h&&n.includes("letter");let d,c,u,p,g,_,f,m,y,v;s.forEach(t=>{t.words&&(g=r&&t.paraStart?r:0,m=t.words.length,h&&(v=!t.paraEnd||a,c=i-t.width-g,l?p=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?c/(m-1):0),_=o||t.isOverflow||l?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===_?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,d=t.x,t.data=[],t.words.forEach((e,i)=>{1===_?(f={char:"",x:d},d=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,d,f),(t.isOverflow||" "!==f.char)&&t.data.push(f)):d=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,d,t.data,t.isOverflow,v&&p),v&&(y=i===m-1,u?y||(d+=u,t.width+=u):p&&(t.width+=p*(e.data.length-(y?1:0))))})),t.words=null)})}(a,e,n),a.overflow&&function(t,e,i,s){const{rows:n,overflow:r}=t;let{textOverflow:o}=e;if(r&&n.splice(r),s&&o&&"show"!==o){let t,a;"hide"===o?o="":"ellipsis"===o&&(o="...");const h=o?ee.canvas.measureText(o).width:0,l=i+s-h;("none"===e.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],a=t.x+t.width,!(s===i&&a<l));s--){if(a<l&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=h,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(a,e,i,n),"none"!==e.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:r}=e;switch(t.decorationHeight=n/11,p(r)?(i=r.type,r.color&&(t.decorationColor=Kh.string(r.color)),r.offset&&(s=Math.min(.3*n,Math.max(r.offset,.15*-n)))):i=r,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(a,e),a}};const Jp={string:function(t,e){if(!t)return"#000";const i=d(e)&&e<1;if(h(t)){if(!i||!Kh.object)return t;t=Kh.object(t)}let s=o(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};function $p(t){return t?u(t)?t:[t]:[]}Object.assign(Gh,qp),Object.assign(Kh,Jp),Object.assign(Jh,Mc),Object.assign($h,uu),Object.assign(Qh,Cu),Object.assign(tl,Vu),Object.assign(ue,{interaction:(t,e,i,s)=>new ec(t,e,i,s),hitCanvas:(t,e)=>new Eh(t,e),hitCanvasManager:()=>new sc}),bh();class Qp extends Fo{get list(){return $p(this.value)}get oldList(){return $p(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function tg(t){return(e,i)=>{const s="_"+i;hr(e,i,{get(){return this[s]},set(e){const n=this[s];if(n!==e){const r=this;if(r.config){const t="target"===i;if(t){const{beforeSelect:t}=r.config;if(t){const i=t({target:e});if(p(i))e=i;else if(!1===i)return}r.setDimOthers(!1),r.setBright(!1),u(e)&&e.length>1&&e[0].locked&&e.splice(0,1),r.single&&(delete r.element.syncEventer,delete r.element.__world.ignorePixelSnap)}const s=t?Qp.BEFORE_SELECT:Qp.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new Qp(s,{editor:r,value:e,oldValue:n}))}this[s]=e,t(this,n)}}})}}Qp.BEFORE_SELECT="editor.before_select",Qp.SELECT="editor.select",Qp.AFTER_SELECT="editor.after_select",Qp.BEFORE_HOVER="editor.before_hover",Qp.HOVER="editor.hover";const{abs:eg}=Math,{copy:ig}=J,{setListWithFn:sg}=Xt,{worldBounds:ng}=mo,rg={a:1,b:0,c:0,d:1,e:0,f:0},og={x:0,y:0,width:0,height:0};class ag extends t.UI{constructor(){super(),this.list=[],this.visible=0,this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){e&&this.set(e),this.target=t,this.update()}update(t){const{list:e}=this;e.length?(sg(og,e,ng),t&&this.set(t),this.set(og),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const n=this.__,{stroke:r,strokeWidth:o,fill:a}=n,{bounds:l}=e;for(let d=0;d<i.length;d++){s=i[d];const{worldTransform:c,worldRenderBounds:u}=s;if(u.width&&u.height&&(!l||l.hit(u,e.matrix))){const i=eg(c.scaleX),l=eg(c.scaleY);if(ig(rg,c),rg.half=o%2,t.setWorld(rg,e.matrix),t.beginPath(),"path"===this.strokePathType||s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=o/Math.max(i,l),n.shadow){const e=n.shadow[0],{scaleX:i,scaleY:s}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*s,e.blur*i,Kh.string(e.color))}r&&(h(r)?Jh.stroke(r,this,t,e):Jh.strokes(r,this,t,e)),a&&(h(a)?Jh.fill(a,this,t,e):Jh.fills(a,this,t,e)),n.shadow&&t.restore()}}n.strokeWidth=o}}destroy(){this.target=null,super.destroy()}}s([tg(function(t){const e=t.target;t.list=e?u(e)?e:[e]:[]})],ag.prototype,"target",void 0),s([Lr("render-path")],ag.prototype,"strokePathType",void 0);class hg extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=0,this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:n}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:n},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const lg={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return dg([t],i,e),i}};function dg(t,e,i){let s,n;for(let r=0,o=t.length;r<o;r++)if(s=t[r],n=s.__,n.hittable&&n.visible&&!n.locked&&i.hit(s.__world)){if(n.editable){if(s.isBranch&&!n.hitChildren){n.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&n.hitSelf&&e.push(s)}s.isBranch&&dg(s.children,e,i)}}const{findOne:cg,findByBounds:ug}=lg;class pg extends t.Group{get dragging(){return!!this.originList}get running(){const{editor:t,app:e}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector&&e&&"normal"===e.mode}get isMoveMode(){const{app:t}=this;return t&&t.interaction.moveMode}constructor(t){super(),this.hoverStroker=new ag,this.targetStroker=new ag,this.bounds=new Kt,this.selectArea=new hg,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{hoverTarget:e,mergeConfig:i}=t,s=Object.assign({},i);e&&e.editConfig&&Object.assign(s,e.editConfig);const{stroke:n,strokeWidth:r,hover:o,hoverStyle:a}=s;this.hoverStroker.setTarget(o?e:null,Object.assign({stroke:n,strokeWidth:r},a||{}))}}onSelect(){this.running&&(this.targetStroker.setTarget(this.editor.list),this.hoverStroker.target=null)}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedPathType:i,selectedStyle:s}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2),strokePathType:i},s||{}))}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i,selectKeep:s}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(s||(e.target=null))}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?(this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i,t.path.needUpdate=!0):this.allow(t.target)&&(this.isHoldMultipleSelectKey(t)||this.editor.mergedConfig.selectKeep||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:n,y:r}=t.getInnerPoint(this);this.bounds.set(n,r),this.selectArea.setStyle({visible:!0,stroke:i,x:n,y:r},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new xh(ug(e.app,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach(e=>{n.has(e)||t.push(e)}),n.forEach(e=>{this.originList.has(e)||t.push(e)}),(t.length!==e.list.length||e.list.some((e,i)=>e!==t[i]))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=0)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){const{boxSelect:e,multipleSelect:i}=this.editor.mergeConfig;return!(!(this.running&&i&&e)||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||this.isHoldMultipleSelectKey(t)&&!cg(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new xh(this.editor.editBox.rect)};return cg(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):cg(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(this.isHoldMultipleSelectKey(t)||i)}isHoldMultipleSelectKey(t){const{multipleSelectKey:e}=this.editor.mergedConfig;return e?t.isHoldKeys(e):t.shiftKey}__listenEvents(){const{editor:e}=this;e.waitLeafer(()=>{const{app:i}=e;i.selector.proxy=e,this.__eventIds=[e.on_([[Qp.HOVER,this.onHover,this],[Qp.SELECT,this.onSelect,this]]),i.on_([[t.PointerEvent.MOVE,this.onPointerMove,this],[t.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this],[t.PointerEvent.TAP,this.onTap,this],[t.DragEvent.START,this.onDragStart,this,!0],[t.DragEvent.DRAG,this.onDrag,this],[t.DragEvent.END,this.onDragEnd,this],[t.MoveEvent.MOVE,this.onAutoMove,this],[[t.ZoomEvent.ZOOM,t.MoveEvent.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:gg,top:_g,topRight:fg,right:mg,bottomRight:yg,bottom:vg,bottomLeft:xg,left:wg}=t.Direction9,{toPoint:Eg}=kt,{within:bg,sign:kg}=A,{abs:Tg}=Math,Sg={getScaleData(t,e,i,s,n,r,o,a){let h,l,c={},u=1,p=1;const{boxBounds:g,widthRange:_,heightRange:f,dragBounds:m,worldBoxBounds:y}=t,{width:v,height:x}=e,w=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,b=kg(w),k=kg(E),T=a?w:b*g.width/v,S=a?E:k*g.height/x;if(d(s))u=p=Math.sqrt(s);else{r&&(s.x*=2,s.y*=2),s.x*=a?w:b,s.y*=a?E:k;const t=(-s.y+x)/x,e=(s.x+v)/v,o=(s.y+x)/x,d=(-s.x+v)/v;switch(i){case _g:p=t,h="bottom";break;case mg:u=e,h="left";break;case vg:p=o,h="top";break;case wg:u=d,h="right";break;case gg:p=t,u=d,h="bottom-right";break;case fg:p=t,u=e,h="bottom-left";break;case yg:p=o,u=e,h="top-left";break;case xg:p=o,u=d,h="top-right"}if(n)if("corner"===n&&i%2)n=!1;else switch(i){case _g:case vg:u=p;break;case wg:case mg:p=u;break;default:l=Math.sqrt(Tg(u*p)),u=kg(u)*l,p=kg(p)*l}}const B=1!==u,P=1!==p;if(B&&(u/=T),P&&(p/=S),!o){const{worldTransform:e}=t;u<0&&(u=1/g.width/e.scaleX),p<0&&(p=1/g.height/e.scaleY)}if(Eg(r||h,g,c,!0),m){const e={x:u,y:p};Md.limitScaleOf(t,c,e,n),u=e.x,p=e.y}if(B&&_){const e=g.width*t.scaleX;u=bg(e*u,_)/e}if(P&&f){const e=g.height*t.scaleY;p=bg(e*p,f)/e}return B&&Tg(u*y.width)<1&&(u=kg(u)/y.width),P&&Tg(p*y.height)<1&&(p=kg(p)/y.height),n&&u!==p&&(l=Math.min(Tg(u),Tg(p)),u=kg(u)*l,p=kg(p)*l),isFinite(u)||(u=1),isFinite(p)||(p=1),{origin:c,scaleX:u,scaleY:p,direction:i,lockRatio:n,around:r}},getRotateData(t,e,i,s,n){let r,o={};switch(e){case gg:r="bottom-right";break;case fg:r="bottom-left";break;case yg:r="top-left";break;case xg:r="top-right";break;default:r="center"}return Eg(n||r,t.boxBounds,o,!0),{origin:o,rotation:lt.getRotation(s,t.getWorldPointByBox(o),i)}},getSkewData(t,e,i,s){let n,r,o={},a=0,h=0;switch(e){case _g:case gg:r={x:.5,y:0},n="bottom",a=1;break;case vg:case yg:r={x:.5,y:1},n="top",a=1;break;case wg:case xg:r={x:0,y:.5},n="right",h=1;break;case mg:case fg:r={x:1,y:.5},n="left",h=1}const{width:l,height:d}=t;r.x=r.x*l,r.y=r.y*d,Eg(s||n,t,o,!0);const c=lt.getRotation(r,o,{x:r.x+(a?i.x:0),y:r.y+(h?i.y:0)});return a?a=-c:h=c,{origin:o,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case wg:t=mg;break;case gg:t=fg;break;case xg:t=yg;break;case mg:t=wg;break;case fg:t=gg;break;case yg:t=xg}if(i)switch(t){case _g:t=vg;break;case gg:t=xg;break;case fg:t=yg;break;case vg:t=_g;break;case xg:t=gg;break;case yg:t=fg}return t}},Bg={};function Pg(t,e){const{enterPoint:i,dragging:s,skewing:n,resizing:r,flippedX:o,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return Lg(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:p,moveable:g,resizeable:_,rotateable:f,skewable:m}=t.mergeConfig;if("move"===l)return i.cursor=d,void(g||(i.visible=!1));if("button"===l)return void(i.cursor||(i.cursor="pointer"));let y=l.includes("resize");y&&f&&(t.isHoldRotateKey(e)||!_)&&(y=!1);const v=m&&!y&&("resize-line"===i.name||"skew"===l),x=s?n?p:r?c:u:v?p:y?c:u;h+=45*(Sg.getFlipDirection(i.direction,o,a)+1),h=2*Math.round(A.formatRotation(h,!0)/2);const{url:w,x:E,y:b}=x,k=w+h;Bg[k]?i.cursor=Bg[k]:Bg[k]=i.cursor={url:Rg(w,h),x:E,y:b}}function Lg(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function Rg(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Cg extends t.Box{constructor(t){super(t),this.useFastShadow=!0}}const Og=["top","right","bottom","left"],Mg=void 0;class Dg extends t.Group{get mergeConfig(){const{config:t}=this,{mergeConfig:e,editBox:i}=this.editor;return this.mergedConfig=t&&i!==this?Object.assign(Object.assign({},e),t):e}get target(){return this._target||this.editor.element}set target(t){this._target=t}get single(){return!!this._target||this.editor.single}get transformTool(){return this._transformTool||this.editor}set transformTool(t){this._transformTool=t}get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}get canUse(){return this.app&&this.editor.editing}get canGesture(){if(!this.canUse)return!1;const{moveable:t,resizeable:e,rotateable:i}=this.mergeConfig;return h(t)||h(e)||h(i)}get canDragLimitAnimate(){return this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds}constructor(e){super(),this.view=new t.Group,this.rect=new Cg({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Cg({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:n,rotatePoints:r,resizeLines:o,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Cg({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),r.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Cg({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),o.push(e),this.listenPointEvents(e,"resize",s)),i=new Cg({name:"resize-point",hitRadius:5}),n.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),this.listenPointEvents(a,"move",8),s.addMany(...r,a,h,l,...o,...n),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:n,resizePoints:r,resizeLines:o}=this,{stroke:h,strokeWidth:l,ignorePixelSnap:d}=e,c=this.getPointsStyle(),u=this.getMiddlePointsStyle(),p=this.getResizeLinesStyle();let g;this.visible=!t.locked;for(let t=0;t<8;t++)g=r[t],g.set(this.getPointStyle(t%2?u[(t-1)/2%u.length]:c[t/2%c.length])),g.rotation=(t-(t%2?1:0))/2*90,t%2&&o[(t-1)/2].set(Object.assign({pointType:"resize",rotation:(t-1)/2*90},p[(t-1)/2%p.length]||{}));n.set(this.getPointStyle(e.circle||e.rotatePoint||c[0])),s.set(Object.assign({stroke:h,strokeWidth:l,opacity:1,editConfig:Mg},e.rect||{}));const _=a(e.rectThrough)?i:e.rectThrough;s.hittable=!_,_&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),i&&f.stintSet(t.__world,"ignorePixelSnap",d),Lg(this)}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:n,rotation:r,skewX:o,skewY:a,width:h,height:l}=this.target.getLayoutBounds("box",t,!0);this.visible=!this.target.locked,this.set({x:e,y:i,scaleX:s,scaleY:n,rotation:r,skewX:o,skewY:a}),this.updateBounds({x:0,y:0,width:h,height:l})}unload(){this.visible=!1,this.app&&(this.rect.syncEventer=this.app.interaction.bottomList=null)}updateBounds(t){const{editor:e,mergeConfig:i,single:s,rect:n,circle:r,buttons:o,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{editMask:c}=e,{middlePoint:u,resizeable:p,rotateable:g,hideOnSmall:_,editBox:f,mask:m,dimOthers:y,bright:v,spread:x,hideRotatePoints:w,hideResizeLines:E}=i;if(c.visible=!!m||0,e.setDimOthers(y),e.setBright(!!y||v),x&&Xt.spread(t,x),this.view.worldOpacity){const{width:e,height:c}=t,m=d(_)?_:10,y=f&&!(_&&e<m&&c<m);let v,x,b,k={};for(let i=0;i<8;i++)kt.toPoint(kt.directionData[i],t,k),x=a[i],v=h[i],x.set(k),v.set(k),x.visible=y&&!(!p&&!g),v.visible=y&&g&&p&&!w,i%2&&(b=l[(i-1)/2],b.set(k),b.visible=x.visible&&!E,x.visible=v.visible=y&&!!u,(i+1)/2%2?(b.width=e+b.height,_&&2*x.width>e&&(x.visible=!1)):(b.width=c+b.height,_&&2*x.width>c&&(x.visible=!1)));r.visible=y&&g&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!s||f})),o.visible=y&&o.children.length>0||0,o.visible&&this.layoutButtons()}else n.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:n}=this.mergedConfig,r=Og.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,e||i,!!n)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:n}=this.mergedConfig,{flippedX:r,flippedY:o}=this;let a=Og.indexOf(e);(a%2&&r||(a+1)%2&&o)&&i&&(a=(a+2)%4);const h=i?Sg.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!n),i&&(t.rotation=90*(h-a)),t.scaleX=r?-1:1,t.scaleY=o?-1:1}setButtonPosition(t,e,i,s){const n=this.resizePoints[2*e+1],r=e%2,o=e&&3!==e?1:-1,a=(i+(e%2?(s?n.width:0)+t.boxBounds.width:(s?n.height:0)+t.boxBounds.height)/2)*o;r?(t.x=n.x+a,t.y=n.y):(t.x=n.x,t.y=n.y+a)}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:n,pointRadius:r}=this.mergedConfig,o={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",opacity:1,width:n,height:n,cornerRadius:r,offsetX:0,offsetY:0,editConfig:Mg};return t?Object.assign(o,t):o}getPointsStyle(){const{point:t}=this.mergedConfig;return u(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return u(t)?t:t?[t]:this.getPointsStyle()}getResizeLinesStyle(){const{resizeLine:t}=this.mergedConfig;return u(t)?t:[t]}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:n,rotateable:r,skewable:o}=this.mergeConfig;"move"===i?s&&(this.moving=!0):(i.includes("rotate")||this.isHoldRotateKey(t)||!n?(r&&(this.rotating=!0),"resize-rotate"===i?n&&(this.resizing=!0):"resize-line"===e.name&&(o&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&n&&(this.resizing=!0),"skew"===i&&o&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:n,skewing:r}=this;if(i)e.onMove(t);else if(s||n||r){const i=t.current;i.pointType&&(this.enterPoint=i),n&&e.onRotate(t),s&&e.onScale(t),r&&e.onSkew(t)}Pg(this,t)}onDragEnd(t){this.onTransformEnd(t),this.dragPoint=null}onTransformStart(t){(this.moving||this.gesturing)&&(this.editor.opacity=this.mergedConfig.hideOnMove?0:1),this.resizing&&(qo.resizingKeys=this.editor.leafList.keys);const{dragStartData:e,target:i}=this;e.x=t.x,e.y=t.y,e.totalOffset={x:0,y:0},e.point={x:i.x,y:i.y},e.bounds=Object.assign({},i.getLayoutBounds("box","local")),e.rotation=i.rotation}onTransformEnd(e){this.canDragLimitAnimate&&(e instanceof t.DragEvent||e instanceof t.MoveEvent)&&this.transformTool.onMove(e),this.resizing&&(qo.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(e){if(this.canGesture&&"drag"!==e.moveType&&(e.stop(),h(this.mergedConfig.moveable)))switch(this.gesturing=this.moving=!0,e.type){case t.MoveEvent.START:this.onTransformStart(e);break;case t.MoveEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onMove(e)}}onScale(e){if(this.canGesture&&(e.stop(),h(this.mergedConfig.resizeable)))switch(this.gesturing=this.resizing=!0,e.type){case t.ZoomEvent.START:this.onTransformStart(e);break;case t.ZoomEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onScale(e)}}onRotate(e){if(this.canGesture&&(e.stop(),h(this.mergedConfig.rotateable)))switch(this.gesturing=this.rotating=!0,e.type){case t.ZoomEvent.START:this.onTransformStart(e);break;case t.ZoomEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onRotate(e)}}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){Pg(this,t)}onArrow(t){if(this.canUse&&this.mergeConfig.keyEvent){let e=0,i=0;const s=t.shiftKey?10:1;switch(t.code){case"ArrowDown":i=s;break;case"ArrowUp":i=-s;break;case"ArrowLeft":e=-s;break;case"ArrowRight":e=s}(e||i)&&this.transformTool.move(e,i)}}onDoubleTap(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"double"!==e||i||this.openInner(t)}onLongPress(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"long"===e&&i&&this.openInner(t)}openInner(e){const{editor:i,target:s}=this;if(this.single){if(s.locked)return;if(s.isBranch&&!s.editInner){if(s.textBox){const{children:e}=s,n=e.find(e=>e.editable&&e instanceof t.Text)||e.find(e=>e instanceof t.Text);if(n)return i.openInnerEditor(n)}i.openGroup(s),i.target=i.selector.findDeepOne(e)}else i.openInnerEditor()}}listenPointEvents(e,i,s){e.direction=s,e.pointType=i,this.__eventIds.push(e.on_([[t.DragEvent.START,this.onDragStart,this],[t.DragEvent.DRAG,this.onDrag,this],[t.DragEvent.END,this.onDragEnd,this],[t.PointerEvent.ENTER,t=>{this.enterPoint=e,Pg(this,t)}],[t.PointerEvent.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:e,editor:i,__eventIds:s}=this;s.push(e.on_([[t.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this],[t.PointerEvent.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{s.push(i.app.on_([[[t.KeyEvent.HOLD,t.KeyEvent.UP],this.onKey,this],[t.KeyEvent.DOWN,this.onArrow,this],[[t.MoveEvent.START,t.MoveEvent.BEFORE_MOVE,t.MoveEvent.END],this.onMove,this,!0],[[t.ZoomEvent.START,t.ZoomEvent.BEFORE_ZOOM,t.ZoomEvent.END],this.onScale,this,!0],[[t.RotateEvent.START,t.RotateEvent.BEFORE_ROTATE,t.RotateEvent.END],this.onRotate,this,!0]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const Ig={x:0,y:0,width:1e5,height:1e5};class Ag extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,Ig),Object.assign(this.__world,Ig)}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergedConfig;if(s&&i.editing){if(t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),e.bounds&&!e.bounds.hit(i.editBox.rect.__world,e.matrix))return;t.saveBlendMode("destination-out"),e=Object.assign(Object.assign({},e),{shape:!0}),i.list.forEach(i=>{i.__render(t,e);const{parent:s}=i;s&&s.textBox&&s.__renderShape(t,e)}),t.restoreBlendMode()}}destroy(){this.editor=null,super.destroy()}}const Wg='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',Fg={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${Wg}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${Wg}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${Wg}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,editBox:!0,hover:!0,select:"press",openInner:"double",multipleSelect:!0,boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},zg=new Kt;function Ug(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{zg.setListWithFn(i,t=>t.getBounds("box","page")),0===zg.width&&(zg.width=.1),0===zg.height&&(zg.height=.1),e.reset(zg.get())}),s.add(e)}const Hg=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Ng=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Yg={group(e,i,s){e.sort(Ng);const{app:n,parent:r}=e[0];let o;o=s&&s.add?s:new t.Group(s),r.addAt(o,r.children.indexOf(e[0])),e.sort(Hg);const a=new mt(i.worldTransform);return a.divideParent(r.scrollWorldTransform),o.setTransform(a),o.editable=!0,o.hitChildren=!1,n.lockLayout(),e.forEach(t=>t.dropTo(o)),n.unlockLayout(),o},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach(t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort(Hg),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(Ng),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},Xg=ne.get("EditToolCreator");function Vg(){return t=>{Gg.register(t)}}const jg=Vg,Gg={list:{},register(t){const{tag:e}=t.prototype;Kg[e]&&Xg.repeat(e),Kg[e]=t},get:(t,e)=>new Kg[t](e)},{list:Kg}=Gg;class Zg extends Qp{constructor(t,e){super(t,e)}}Zg.BEFORE_OPEN="innerEditor.before_open",Zg.OPEN="innerEditor.open",Zg.BEFORE_CLOSE="innerEditor.before_close",Zg.CLOSE="innerEditor.close";class qg extends Qp{constructor(t,e){super(t,e)}}qg.BEFORE_GROUP="editor.before_group",qg.GROUP="editor.group",qg.BEFORE_UNGROUP="editor.before_ungroup",qg.UNGROUP="editor.ungroup",qg.BEFORE_OPEN="editor.before_open_group",qg.OPEN="editor.open_group",qg.BEFORE_CLOSE="editor.before_close_group",qg.CLOSE="editor.close_group";const{updateMatrix:Jg}=ho,$g={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},Qg="top-left";class t_ extends t.Rect{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.skipJSON=!0,this.on(Ho.CHANGE,e=>{if(this.checkChange&&$g[e.attrName]){const{attrName:i,newValue:s,oldValue:n}=e,r="s"===i[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const o=this.__;o[i]=n,Jg(this.parent),Jg(this);const a=new mt(this.__world);switch(o[i]=s,this.__layout.rotationChange(),Jg(this),this.changedTransform=new mt(this.__world).divide(a),i){case"x":t.move(r,0);break;case"y":t.move(0,r);break;case"rotation":t.rotateOf(Qg,r);break;case"scaleX":t.scaleOf(Qg,r,1);break;case"scaleY":t.scaleOf(Qg,1,r);break;case"skewX":t.skewOf(Qg,r,0);break;case"skewY":t.skewOf(Qg,0,r)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class e_ extends Qp{constructor(t,e){super(t,e)}}e_.BEFORE_MOVE="editor.before_move",e_.MOVE="editor.move";class i_ extends Qp{constructor(t,e){super(t,e)}}i_.BEFORE_SCALE="editor.before_scale",i_.SCALE="editor.scale";class s_ extends Qp{constructor(t,e){super(t,e)}}s_.BEFORE_ROTATE="editor.before_rotate",s_.ROTATE="editor.rotate";class n_ extends Qp{constructor(t,e){super(t,e)}}n_.BEFORE_SKEW="editor.before_skew",n_.SKEW="editor.skew";class r_{onMove(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox;let r,{dragLimitAnimate:o}=s;const a=e.type===t.MoveEvent.END||e.type===t.DragEvent.END,l=h(i.draggable),c=!o||a||l,u={x:e.totalX,y:e.totalY};e instanceof t.MoveEvent&&lt.move(u,i.getWorldPointByLocal(n.totalOffset,null,!0)),e.shiftKey&&(Math.abs(u.x)>Math.abs(u.y)?u.y=0:u.x=0),r=t.DragEvent.getValidMove(i,n.point,u,c),(r.x||r.y)&&(o&&!l&&a?ho.animateMove(this,r,d(o)?o:.3):this.move(r))}onScale(e){const{target:i,mergeConfig:s,single:n,dragStartData:r}=this.editBox;let o,{around:a,lockRatio:h,flipable:l,editSize:d}=s;e instanceof t.ZoomEvent?(a||(a=i.getBoxPoint(e)),o=e.totalScale):o=e.getInnerTotal(i);const{direction:c}=e.current;(e.shiftKey||i.lockRatio)&&(h=!0);const u=Sg.getScaleData(i,r.bounds,c,o,h,Sg.getAround(a,e.altKey),l,!n||"scale"===d),p=i.x,g=i.y;e instanceof t.DragEvent&&this.editTool&&this.editTool.onScaleWithDrag?(u.drag=e,this.scaleWithDrag(u)):this.scaleOf(u.origin,u.scaleX,u.scaleY),lt.move(r.totalOffset,i.x-p,i.y-g)}onRotate(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox,{around:r,rotateAround:o,rotateGap:a,diagonalRotateKey:h}=s,{direction:l}=e.current;let d,c;if(e instanceof t.RotateEvent)c=e.rotation,d=o?kt.getPoint(o,i.boxBounds):i.getBoxPoint(e);else{const t=h?e.isHoldKeys(h):e.shiftKey,s=Sg.getRotateData(i,l,e,n,t?null:o||i.around||i.origin||r||"center");c=n.rotation+s.rotation-i.rotation,d=s.origin}if(c=A.float(A.getGapRotation(c,a,i.rotation),2),!c)return;const u=i.x,p=i.y;this.rotateOf(d,c),lt.move(n.totalOffset,i.x-u,i.y-p)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:n,skewX:r,skewY:o}=Sg.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Sg.getAround(s,t.altKey));(r||o)&&this.skewOf(n,r,o)}move(t,e=0){if(!this.checkTransform("moveable"))return;p(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:n,editor:r}=this.editBox,{beforeMove:o}=s;if(o){const s=o({target:i,x:t,y:e});if(p(s))t=s.x,e=s.y;else if(!1===s)return}const a=i.getWorldPointByLocal({x:t,y:e},null,!0);n||i.safeChange(()=>i.move(t,e));const h={target:i,editor:r,moveX:a.x,moveY:a.y};this.emitEvent(new e_(e_.BEFORE_MOVE,h));const l=new e_(e_.MOVE,h);this.doMove(l),this.emitEvent(l)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{target:e,mergeConfig:i,editor:s}=this.editBox,{beforeScale:n}=i;if(n){const{origin:i,scaleX:s,scaleY:r,drag:o}=t;if(!1===n({target:e,drag:o,origin:i,scaleX:s,scaleY:r}))return}t=Object.assign(Object.assign({},t),{target:e,editor:s,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new i_(i_.BEFORE_SCALE,t));const r=new i_(i_.SCALE,t);this.editTool.onScaleWithDrag(r),this.emitEvent(r)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:n,mergeConfig:r,single:o,editor:a}=this.editBox,{beforeScale:h}=r;if(h){const s=h({target:n,origin:t,scaleX:e,scaleY:i});if(p(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!o&&this.getChangedTransform(()=>n.safeChange(()=>n.scaleOf(t,e,i))),c={target:n,editor:a,worldOrigin:l,scaleX:e,scaleY:i,transform:d};this.emitEvent(new i_(i_.BEFORE_SCALE,c));const u=new i_(i_.SCALE,c);this.doScale(u),this.emitEvent(u)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,n=this.getWorldOrigin("center"),r=i?new mt(ho.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),o={target:e,editor:s,worldOrigin:n,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:r};this.emitEvent(new i_(i_.BEFORE_SCALE,o));const a=new i_(i_.SCALE,o);this.doScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:n,editor:r}=this.editBox,{beforeRotate:o}=s;if(o){const s=o({target:i,origin:t,rotation:e});if(d(s))e=s;else if(!1===s)return}const a=this.getWorldOrigin(t),h=!n&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),l={target:i,editor:r,worldOrigin:a,rotation:e,transform:h};this.emitEvent(new s_(s_.BEFORE_ROTATE,l));const c=new s_(s_.ROTATE,l);this.doRotate(c),this.emitEvent(c)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:n,mergeConfig:r,single:o,editor:a}=this.editBox,{beforeSkew:h}=r;if(h){const s=h({target:n,origin:t,skewX:e,skewY:i});if(p(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!o&&this.getChangedTransform(()=>n.safeChange(()=>n.skewOf(t,e,i))),c={target:n,editor:a,worldOrigin:l,skewX:e,skewY:i,transform:d};this.emitEvent(new n_(n_.BEFORE_SKEW,c));const u=new n_(n_.SKEW,c);this.doSkew(u),this.emitEvent(u)}doMove(t){this.editTool.onMove(t)}doScale(t){this.editTool.onScale(t)}doRotate(t){this.editTool.onRotate(t)}doSkew(t){this.editTool.onSkew(t)}checkTransform(t){const{target:e,mergeConfig:i}=this.editBox;return e&&!e.locked&&i[t]}getWorldOrigin(t){const{target:e}=this.editBox;return e.getWorldPoint(ho.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const s=new mt(e.worldTransform);return t(),new mt(e.worldTransform).divide(s)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}t.Editor=class extends t.Group{get list(){return this.leafList.list}get dragHoverExclude(){return[this.editBox.rect]}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragPoint(){return this.editBox.dragPoint}get dragging(){return this.editBox.dragging}get gesturing(){return this.editBox.gesturing}get moving(){return this.editBox.moving}get resizing(){return this.editBox.resizing}get rotating(){return this.editBox.rotating}get skewing(){return this.editBox.skewing}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}get targetLeafer(){const t=this.list[0];return t&&t.leafer}constructor(t,e){super(e),this.leafList=new xh,this.openedGroupList=new xh,this.simulateTarget=new t_(this),this.editBox=new Dg(this),this.editToolList={},this.selector=new pg(this),this.editMask=new Ag(this),this.targetEventIds=[];let i=f.clone(Fg);t&&(i=f.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),ce.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}getItem(t){return this.list[t||0]}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}setDimOthers(t,e="dim",i){if(!i){const{dimTarget:t,targetLeafer:e}=this;i=t?u(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>f.stintSet(i,e,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&Ug(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||Gg.get(t,this)}updateEditTool(){if(this.unloadEditTool(),this.editing){const t=this.element;let e=t.editOuter||"EditTool";const{beforeEditOuter:i}=this.mergeConfig;if(i){const s=i({target:t,name:e});if(h(s))e=s;else if(!1===s)return}if(Gg.list[e]){const t=this.editTool=this.getEditTool(e);this.editBox.load(),t.load(),this.update()}}}unloadEditTool(){let t=this.editTool;t&&(this.editBox.unload(),t.unload(),this.editTool=null)}getEditSize(t){return this.mergeConfig.editSize}onMove(t){}onScale(t){}onRotate(t){}onSkew(t){}move(t,e=0){}scaleWithDrag(t){}scaleOf(t,e,i=e,s){}flip(t){}rotateOf(t,e){}skewOf(t,e,i=0,s){}checkTransform(t){}getWorldOrigin(t){}getChangedTransform(t){}group(t){return this.multiple&&(this.emitGroupEvent(qg.BEFORE_GROUP),this.target=Yg.group(this.list,this.element,t),this.emitGroupEvent(qg.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(qg.BEFORE_UNGROUP,t)),this.target=Yg.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(qg.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(qg.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(qg.OPEN,t)}closeGroup(t){this.emitGroupEvent(qg.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(qg.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!ho.hasParent(e,t))&&e.push(t))),e.forEach(t=>this.closeGroup(t))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new qg(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||Gg.get(t,this)}openInnerEditor(t,e,i){let s;if(h(e)?s=e:i||(i=e),t&&i&&(this.target=t),this.single){t||(t=this.element),s||(s=t.editInner);const{beforeEditInner:e}=this.mergeConfig;if(e){const i=e({target:t,name:s});if(h(i))s=i;else if(!1===i)return}Gg.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(Zg.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Zg.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Zg.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Zg.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Zg(t,{editTarget:i,innerEditor:e});this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach(t=>t.locked=!0),this.update()}unlock(){this.list.forEach(t=>t.locked=!1),this.update()}toTop(){this.list.length&&(Yg.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Yg.toBottom(this.list),this.leafList.update())}onAppRenderStart(t){(this.targetChanged=t.children.some(t=>t!==this.leafer&&t.renderer.changed))&&this.editBox.forceRender()}onRenderStart(){this.targetChanged&&this.update()}onChildScroll(){this.multiple&&this.updateEditBox()}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e,targetLeafer:i,editMask:s}=this;this.targetEventIds=[e.on_(Qo.START,this.onRenderStart,this),i&&i.on_(Ho.SCROLL,this.onChildScroll,this),t.on_(Qo.CHILD_START,this.onAppRenderStart,this),t.on_(ta.UPDATE_MODE,t=>{t.mode&&"normal"!==t.mode&&this.cancel()})],s.visible&&s.forceRender()}}removeTargetEvents(){const{targetEventIds:t,editMask:e}=this;t.length&&(this.off_(t),e.visible&&e.forceRender())}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach(t=>t.destroy()),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}},s([(t,e)=>{hr(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,app:n}=this,r=Object.assign({},t);if(e&&e.editConfig){let{editConfig:t}=e;(t.hover||t.hoverStyle)&&(t=Object.assign({},t),delete t.hover,delete t.hoverStyle),Object.assign(r,t)}return s.config&&Object.assign(r,s.config),i&&(i.editConfig&&Object.assign(r,i.editConfig),"font-size"===r.editSize&&(r.lockRatio=!0),"resize-rotate"===i.pointType&&(r.around||(r.around="center"),a(r.lockRatio)&&(r.lockRatio=!0))),o(r.dragLimitAnimate)&&(r.dragLimitAnimate=n&&n.config.pointer.dragLimitAnimate),this.mergedConfig=r}})}],t.Editor.prototype,"mergeConfig",void 0),s([tg(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof xh?i:new xh(i),t.multiple&&Ug(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new Qp(Qp.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new Qp(Qp.AFTER_SELECT,s))})],t.Editor.prototype,"target",void 0),s([tg(function(t,e){t.emitEvent(new Qp(Qp.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],t.Editor.prototype,"hoverTarget",void 0),t.Editor=s([Kr(r_,["editBox","editTool","emitEvent"])],t.Editor);class o_{static registerInnerEditor(){Gg.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get editBox(){return this._editBox||this.editor.editBox}set editBox(t){this._editBox=t}constructor(t){this.eventIds=[],this.editor=t,this.create()}onCreate(){}create(){this.view=new t.Group,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!0),this.onUnload())}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}t.EditTool=class extends o_{static registerEditTool(){Gg.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach(t=>{t.moveWorld(e,i)}),n.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:n,editor:r}=t,{app:o,list:a}=r;o.lockLayout(),a.forEach(t=>{const o="scale"!==r.getEditSize(t);s?t.transformWorld(s,o):t.scaleOfWorld(n,e,i,o)}),o.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:n}=t,{app:r,list:o}=n;r.lockLayout(),o.forEach(t=>{const r="scale"!==n.getEditSize(t);i?t.transformWorld(i,r):t.rotateOfWorld(s,e)}),r.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:n,editor:r}=t,{app:o,list:a}=r;o.lockLayout(),a.forEach(t=>{const o="scale"!==r.getEditSize(t);s?t.transformWorld(s,o):t.skewOfWorld(n,e,i,o)}),o.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){this.editBox.update(),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},t.EditTool=s([Vg()],t.EditTool);const{left:a_,right:h_}=t.Direction9,{move:l_,copy:d_,toNumberPoints:c_}=lt;t.LineEditTool=class extends t.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:n}=t,r=t.target,o=i===a_;if(r.pathInputed){const{path:t}=r.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,o,n,this.getInnerMove(r,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,r.path=t}else if(r.points){const{points:t}=r,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,o,n,this.getInnerMove(r,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,r.points=t}else{const t={x:0,y:0},{toPoint:i}=r;r.rotation=0,this.dragPoint(t,i,o,n,this.getInnerMove(r,e,s)),r.getLocalPointByInner(t,null,null,!0),r.getLocalPointByInner(i,null,null,!0),r.x=t.x,r.y=t.y,r.getInnerPointByLocal(i,null,null,!0),r.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){const e=c_(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,n){const{x:r,y:o}=n;i?(l_(t,r,o),s&&l_(e,-r,-o)):(s&&l_(t,-r,-o),l_(e,r,o))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:n}=t,r=t.target;let o,a;if(r.pathInputed?o=this.getFromToByPath(r.__.path):r.points&&(o=this.getFromToByPoints(r.__.points)),o){const{from:i,to:a}=o;r.innerToWorld(i,i,!1,t),r.innerToWorld(a,a,!1,t),n.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),d_(s[7],i),d_(e[7],i),d_(s[3],a),d_(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===a_||t===h_,s[t].visible=a,e[t].visible=!o&&a}},t.LineEditTool=s([Vg()],t.LineEditTool);const{M:u_,L:p_,C:g_,Q:__,Z:f_,N:m_,D:y_,X:v_,G:x_,F:w_,O:E_,P:b_,U:k_}=Ae,T_={scale(t,e,i){if(!t)return;let s,n=0,r=t.length;for(;n<r;)switch(s=t[n],s){case u_:case p_:S_(t,e,i,n,1),n+=3;break;case g_:S_(t,e,i,n,3),n+=7;break;case __:S_(t,e,i,n,2),n+=5;break;case f_:n+=1;break;case m_:S_(t,e,i,n,2),n+=5;break;case y_:S_(t,e,i,n,2),n+=9;break;case v_:S_(t,e,i,n,2),n+=6;break;case x_:S_(t,e,i,n,2),n+=9;break;case w_:S_(t,e,i,n,2),n+=5;break;case E_:t[n]=x_,t.splice(n+4,0,t[n+3],0),S_(t,e,i,n,2),n+=9,r+=2;break;case b_:t[n]=w_,t.splice(n+4,0,t[n+3]),S_(t,e,i,n,2),n+=5,r+=1;break;case k_:S_(t,e,i,n,2),n+=6}},scalePoints(t,e,i,s,n){for(let r=n?s+1:0,o=n?r+2*n:t.length;r<o;r+=2)t[r]*=e,t[r+1]*=i}},{scalePoints:S_}=T_,B_=J.get(),{topLeft:P_,top:L_,topRight:R_,right:C_,bottom:O_,left:M_}=t.Direction9;function D_(t,e,i){t.pathInputed?I_(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function I_(t,e,i){T_.scale(t.__.path,e,i),t.path=t.__.path}function A_(t,e,i){const{points:s}=t;p(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):T_.scalePoints(s,e,i),t.points=s}function W_(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)B_.a=e,B_.d=i,s[t].transform(B_,!0)}const F_=t.Leaf.prototype;function z_(t){const{scroll:e,disabled:i}=t.app.config.move;return!e||i?"":!0===e?"free":e}function U_(e,i,s){H_(e.parentApp?e.parentApp:e,i),e.isApp||s||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,t=>{const i=e.getValidMove(t.moveX,t.moveY,!1);if(z_(e).includes("limit")){const s=e.getValidMove(0,0);if(s.x||s.y){const e=100,n=200,r="drag"===t.moveType?.3:.05;Math.abs(s.x)>e?i.x=0:i.x*=r,Math.abs(s.y)>n?i.y=0:i.y*=r}}e.zoomLayer.move(i)}),e.on_(t.MoveEvent.DRAG_ANIMATE,()=>{const t=e.getValidMove(0,0);(t.x||t.y)&&e.interaction.stopDragAnimate()}),e.on_(t.MoveEvent.END,t=>{ho.animateMove(e.zoomLayer,e.getValidMove(t.moveX,t.moveY))}),e.on_(t.ZoomEvent.BEFORE_ZOOM,t=>{const{zoomLayer:i,layouter:s}=e,n=e.getValidScale(t.scale);1!==n&&(s.stop(),ho.updateMatrix(e),i.scaleOfWorld(t,n),s.start())}))}function H_(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&f.assign(i,e),f.assign(t.config,i,t.userConfig)}F_.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},F_.__scaleResize=function(t,e){D_(this,t,e)},F_.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},F_.resizeHeight=function(t){const e=t/this.getBounds("box","local").height||1;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},t.Text.prototype.__scaleResize=function(t,e){const{app:i,editConfig:s}=this,n=i&&i.editor,r=n&&n.dragPoint;if(this.__.resizeFontSize||s&&"font-size"===s.editSize||r&&"font-size"===n.mergedConfig.editSize)!function(t,e,i,s){let n=e;if(!o(s)){const r=t.__layout;let{width:o,height:a}=r.boxBounds;switch(o*=i-e,a*=e-i,s){case L_:case O_:n=i,r.affectScaleOrRotation?t.moveInner(-o/2,0):t.x-=o/2;break;case M_:case C_:r.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case P_:case R_:r.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const r=t.__,{padding:a}=r;a&&(t.padding=u(a)?a.map(t=>t*n):a*n),r.__autoWidth||(t.width*=n),r.__autoHeight||(t.height*=n)}(this,t,e,r&&r.direction);else{const{__autoWidth:i,__autoHeight:s,textAlign:n,verticalAlign:r}=this.__,{boxBounds:o}=this.__layout;i&&"left"!==n&&1!==t&&(this.x+=o.x),s&&"top"!==r&&1!==e&&(this.y+=o.y),D_(this,t,e)}},t.Path.prototype.__scaleResize=function(t,e){I_(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?I_(this,t,e):this.points?A_(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?I_(this,t,e):this.points?A_(this,t,e):D_(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){W_(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||D_(this,t,e),i&&W_(this,t,e)},ce.add("resize"),ce.add("editor","resize"),ue.editor=function(e,i){const s=new t.Editor(e);return i&&i.sky.add(i.editor=s),s},t.Box.addAttr("textBox",!1,gr),t.UI.addAttr("editConfig",void 0,gr),t.UI.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),gr),t.UI.addAttr("editInner","PathEditor",gr),t.Group.addAttr("editInner","",gr),t.Text.addAttr("editInner","TextEditor",gr),t.UI.setEditConfig=function(t){this.changeAttr("editConfig",t)},t.UI.setEditOuter=function(t){this.changeAttr("editOuter",t)},t.UI.setEditInner=function(t){this.changeAttr("editInner",t)};const N_=ne.get("LeaferTypeCreator"),Y_={list:{},register(t,e){X_[t]&&N_.repeat(t),X_[t]=e},run(t,e){const i=X_[t];i&&i(e)}},{list:X_,register:V_}=Y_;V_("viewport",U_),V_("custom",function(t){U_(t,null,!0)}),V_("design",function(t){U_(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),V_("document",function(t){U_(t,{zoom:{min:1},move:{scroll:"limit"}})});const j_={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],i=t[1],s=lt.getCenter(e.from,i.from),n=lt.getCenter(e.to,i.to),r={x:n.x-s.x,y:n.y-s.y},o=lt.getDistance(e.from,i.from);return{move:r,scale:lt.getDistance(e.to,i.to)/o,rotation:lt.getRotation(e.from,i.from,e.to,i.to),center:n}},getType(t,e){const i=Math.hypot(t.move.x,t.move.y)/(e.move||5),s=Math.abs(t.scale-1)/(e.scale||.03),n=Math.abs(t.rotation)/(e.rotation||2);return i<1&&s<1&&n<1?"none":i>=s&&i>=n?"move":s>=n?"zoom":"rotate"},detect(t,e){const{state:i}=G_,s=G_.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),G_.add(t,i.totalData),i.totalData=t,s===i.type){if(i.typeCount++,i.typeCount>=(e.count||3)&&"none"!==s)return s}else i.type=s,i.typeCount=1;return Date.now()-i.startTime>=(e.time||160)?G_.getType(i.totalData,e):"none"},add(t,e){e&&(lt.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=G_;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},G_=j_,{abs:K_,max:Z_}=Math,{sign:q_,within:J_}=A,$_={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;t.shiftKey&&!s&&(s=n,n=0);const r=K_(s),o=K_(n);return r>50&&(s=Z_(50,r/3)*q_(s)),o>50&&(n=Z_(50,o/3)*q_(n)),{x:-s*i*2,y:-n*i*2}},getScale(t,e){let i,s=1,{zoomMode:n,zoomSpeed:r}=e;const o=t.deltaY||t.deltaX;if(n?(i="mouse"===n||!t.deltaX&&(ee.intWheelDeltaY?Math.abs(o)>17:Math.ceil(o)!==o),(t.shiftKey||t.metaKey||t.ctrlKey)&&(i=!0)):i=!t.shiftKey&&(t.metaKey||t.ctrlKey),i){r=J_(r,0,1);const i=t.deltaY?e.delta.y:e.delta.x,n=J_(1-K_(o)/(4*i)*r,.5,2);s=o>0?n:1/n}return s}};let Q_,tf,ef,sf;class nf{get transforming(){return this.moving||this.zooming||this.rotating}get moving(){return!!this.moveData}get zooming(){return!!this.zoomData}get rotating(){return!!this.rotateData}constructor(t){this.interaction=t}move(e){const{interaction:i}=this;e.moveType||(e.moveType="move"),this.moveData||(this.setPath(e),Q_=0,tf=0,this.moveData=Object.assign(Object.assign({},e),{moveX:0,moveY:0,totalX:Q_,totalY:tf}),i.emit(t.MoveEvent.START,this.moveData)),e.path=this.moveData.path,e.totalX=Q_+=e.moveX,e.totalY=tf+=e.moveY,i.emit(t.MoveEvent.BEFORE_MOVE,e),i.emit(t.MoveEvent.MOVE,e),this.transformEndWait()}zoom(e){const{interaction:i}=this;this.zoomData||(this.setPath(e),ef=1,this.zoomData=Object.assign(Object.assign({},e),{scale:1,totalScale:ef}),i.emit(t.ZoomEvent.START,this.zoomData)),e.path=this.zoomData.path,e.totalScale=ef*=e.scale,i.emit(t.ZoomEvent.BEFORE_ZOOM,e),i.emit(t.ZoomEvent.ZOOM,e),this.transformEndWait()}rotate(e){const{interaction:i}=this;this.rotateData||(this.setPath(e),sf=0,this.rotateData=Object.assign(Object.assign({},e),{rotation:0,totalRotation:sf}),i.emit(t.RotateEvent.START,this.rotateData)),e.path=this.rotateData.path,e.totalRotation=sf+=e.rotation,i.emit(t.RotateEvent.BEFORE_ROTATE,e),i.emit(t.RotateEvent.ROTATE,e),this.transformEndWait()}setPath(t){const{interaction:e}=this,{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,e.cancelHover()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout(()=>{this.transformEnd()},this.interaction.p.transformTime)}transformEnd(){const{interaction:e,moveData:i,zoomData:s,rotateData:n}=this;i&&e.emit(t.MoveEvent.END,Object.assign(Object.assign({},i),{totalX:Q_,totalY:tf})),s&&e.emit(t.ZoomEvent.END,Object.assign(Object.assign({},s),{totalScale:ef})),n&&e.emit(t.RotateEvent.END,Object.assign(Object.assign({},n),{totalRotation:sf})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const rf=t.Leafer.prototype,of=new Kt,af=new _t;function hf(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function lf(t,e){return Object.assign(Object.assign({},e),{scale:t})}rf.initType=function(t){Y_.run(t,this)},rf.getValidMove=function(t,e,i=!0){const{disabled:s,scrollSpread:n}=this.app.config.move;af.set(t,e);const r=z_(this);return r&&(r.includes("x")?af.y=0:r.includes("y")?af.x=0:Math.abs(af.x)>Math.abs(af.y)?af.y=0:af.x=0,i&&r.includes("limit")&&(of.set(this.__world).addPoint(this.zoomLayer),n&&of.spread(n),Md.getValidMove(of,this.canvas.bounds,"auto",af,!0),r.includes("x")?af.y=0:r.includes("y")&&(af.x=0))),{x:s?0:af.x,y:s?0:af.y}},rf.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,r=Math.abs(e*t);return i&&r<i?t=i/e:s&&r>s&&(t=s/e),n?1:t};const df=ec.prototype;df.createTransformer=function(){this.transformer=new nf(this)},df.move=function(t){this.transformer.move(t)},df.zoom=function(t){this.transformer.zoom(t)},df.rotate=function(t){this.transformer.rotate(t)},df.transformEnd=function(){this.transformer.transformEnd()},df.wheel=function(t){const{wheel:e,pointer:i}=this.config,{posDeltaSpeed:s,negDeltaSpeed:n}=e;if(e.disabled)return;t.deltaX>0?s&&(t.deltaX*=s):n&&(t.deltaX*=n),t.deltaY>0?s&&(t.deltaY*=s):n&&(t.deltaY*=n);const r=e.getScale?e.getScale(t,e):$_.getScale(t,e);if(1!==r)this.zoom(lf(r,t));else{const s=e.getMove?e.getMove(t,e):$_.getMove(t,e);i.snap&&lt.round(s),this.move(hf(s,t))}},df.multiTouch=function(t,e){const{disabled:i,singleGesture:s}=this.config.multiTouch;if(i)return;this.pointerWaitCancel();let n=j_.getData(e),{moving:r,zooming:o,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch(j_.detect(n,p(s)?s:{})){case"move":r=!0;break;case"zoom":o=!0;break;case"rotate":a=!0;break;default:return}j_.reset()}r||(n.center=j_.state.center)}else r=o=a=!0;var h,l;Object.assign(t,n.center),t.multiTouch=!0,a&&this.rotate((h=n.rotation,l=t,Object.assign(Object.assign({},l),{rotation:h}))),o&&this.zoom(lf(n.scale,t)),r&&this.move(hf(n.move,t))};const cf=Vd.prototype,{abs:uf,min:pf,max:gf,hypot:_f}=Math;function ff(t,e){let i=1;const s="out"===e,n=Math.abs(t);if(n>1){for(;s?i<n:i<=n;)i*=2;s&&(i/=2)}else{for(;s?i>=n:i>n;)i/=2;s||(i*=2)}return i/t}cf.checkDragEndAnimate=function(e){const{interaction:i}=this,s=this.canAnimate&&this.moving&&i.m.dragAnimate;if(s){const n=d(s)?s:.95,r=.15,o=150;let a,h,l,c=0,u=0,p=0,g=0,_=3;const{dragDataList:f}=this,m=f.length;for(let t=m-1;t>=gf(m-3,0)&&(l=f[t],!(l.time&&Date.now()-l.time>100));t--)a=_--,c+=l.moveX*a,u+=l.moveY*a,g+=a,h=_f(l.moveX,l.moveY),h>p&&(p=h);if(g&&(c/=g,u/=g),p>8){const t=1.15+pf((p-8)/17,1)*(1.6-1.15);c*=t,u*=t}const y=gf(uf(c),uf(u));y>o&&(h=o/y,c*=h,u*=h);const v=()=>{if(c*=n,u*=n,e=Object.assign({},e),uf(c)<r&&uf(u)<r)return this.dragEndReal(e);lt.move(e,c,u),this.drag(e),this.animate(v),i.emit(t.MoveEvent.DRAG_ANIMATE,e)};this.animate(v)}return s},cf.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},cf.stopAnimate=function(){this.animate(null,"off"),this.interaction.target.nextRender(()=>{this.dragData&&this.dragEndReal(this.dragData)})},cf.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},cf.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:n,dragOut:r}=e.m;if(!r||!s||!n)return;const o=e.shrinkCanvasBounds,{x:a,y:h}=o,l=Xt.maxX(o),d=Xt.maxY(o),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let p=0,g=0;this.autoMoveTimer=setInterval(()=>{p+=c,g+=u,lt.move(i,c,u),lt.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:p,totalY:g,moveType:"drag"})),e.pointerMoveReal(t)},10)},cf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},ce.add("viewport"),ce.add("view"),t.Leafer.prototype.zoom=function(t,e,i,s){let n;g(e)?(n=e.padding,i=e.scroll,s=e.transition):n=e;const{zoomLayer:r}=this,o=this.canvas.bounds.clone().shrink(a(n)?30:n),l=new Kt,c={x:o.x+o.width/2,y:o.y+o.height/2};let _;r.killAnimate();const{x:f,y:m,scaleX:y,scaleY:v}=r.__,{boxBounds:x}=r;if(h(t))switch(t){case"in":_=ff(y,"in");break;case"out":_=ff(y,"out");break;case"fit":t=x;break;case"fit-width":(t=new Kt(x)).height=0;break;case"fit-height":(t=new Kt(x)).width=0}else d(t)&&(_=t/y);if(_)_=this.getValidScale(_),r.scaleOfWorld(c,_,_,!1,s);else if(p(t)){const e={x:f,y:m,scaleX:y,scaleY:v},n=u(t);if(n||t.tag){const e=n?t:[t];l.setListWithFn(e,mo.worldBounds)}else{const e=function(t,e){let i,{x:s,y:n,width:r,height:o}=t;return o||(o=r*(e.height/e.width),i=!0),r||(r=o*(e.width/e.height),i=!0),i?{x:s,y:n,width:r,height:o}:t}(t,o);l.set(r.getWorldBounds(e))}const{width:a,height:h}=l;let d=o.x-l.x,c=o.y-l.y;return i?(d+=Math.max((o.width-a)/2,0),c+=Math.max((o.height-h)/2,0)):(_=this.getValidScale(Math.min(o.width/a,o.height/h)),d+=(o.width-a*_)/2,c+=(o.height-h*_)/2,lt.scaleOf(e,l,_),l.scaleOf(l,_),e.scaleX*=_,e.scaleY*=_),"x"===i?c=0:"y"===i&&(d=0),lt.move(e,d,c),l.move(d,c),r.set(e,s),l}return r.worldBoxBounds};class mf extends t.Group{get isOutside(){return!0}constructor(t,e){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,e&&f.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(e){let i;h(e)?(i={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===e&&(i.fill="white",i.stroke="rgba(0,0,0,0.2)")):i=e,this.scrollXBar||this.addMany(this.scrollXBar=new t.Box,this.scrollYBar=new t.Box),i=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},i),i.height||(i.height=i.width),this.scrollXBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:e,padding:i}=this.config,{zoomLayer:s,canvas:n}=this.target.leafer,{worldRenderBounds:r}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(r))return;this.scrollBounds=new Kt(r);const o=n.bounds.clone().shrink(i),a=o.clone().add(r),h=this.ratioX=o.width/a.width,l=this.ratioY=o.height/a.height,d=(o.x-a.x)/a.width,c=(o.y-a.y)/a.height,u=h<1,p=l<1,{scrollXBar:g,scrollYBar:_}=this,{x:f,y:m,width:y,height:v}=o.shrink([2,p?_.width+6:2,u?g.height+6:2,2]);g.set({x:f+y*d,y:m+v+2,width:Math.max(y*h,e),visible:u}),_.set({x:f+y+2,y:m+v*c,height:Math.max(v*l,e),visible:p})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const e=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(e?-t.moveX/this.ratioX:0,e?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:e,scrollYBar:i}=this;this.__eventIds=[e.on_(t.DragEvent.DRAG,this.onDrag,this),i.on_(t.DragEvent.DRAG,this.onDrag,this),e.on_(t.DragEvent.END,this.onDragEnd,this),i.on_(t.DragEvent.END,this.onDragEnd,this),this.target.on_(Qo.BEFORE,()=>this.update(!0)),this.target.leafer.on_(qo.RESIZE,()=>this.update())]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}ce.add("scroll");class yf extends ml{}function vf(t){return cr(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__,e="none"!==t.startArrow||"none"!==t.endArrow;t.__useArrow!==e&&Er(this),t.__useArrow=e,Sr(this)}}}))}t.Arrow=class extends t.Line{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){qh.register(t,e)}},s([Ur(yf)],t.Arrow.prototype,"__",void 0),s([vf("angle")],t.Arrow.prototype,"endArrow",void 0),t.Arrow=s([Zr()],t.Arrow);const{M:xf,L:wf,C:Ef,Q:bf,O:kf}=Ae,{rotate:Tf,copyFrom:Sf,scale:Bf}=lt,Pf={},Lf={layout(t,e,i,s,n,r,o){let a,h,l=0,d=t.length;for(;l<d;)switch(a=t[l],a){case xf:case wf:Rf(t,l+1,e,i,s,n,r,o),l+=3;break;case Ef:for(h=1;h<6;h+=2)Rf(t,l+h,e,i,s,n,r,o);l+=7;break;case bf:for(h=1;h<4;h+=2)Rf(t,l+h,e,i,s,n,r,o);l+=5;break;case kf:t[l+1]+=e,t[l+2]+=i,s&&(t[l+3]*=s),r&&(t[l+4]+=r,t[l+5]+=r),l+=7}},rotate(t,e,i){Lf.layout(t,0,0,1,1,e,i)}};function Rf(t,e,i,s,n,r,o,a){Sf(Pf,t[e],t[e+1]),o&&Tf(Pf,o,a),n&&Bf(Pf,n,r),t[e]=i+Pf.x,t[e+1]=s+Pf.y}const{layout:Cf,rotate:Of}=Lf,{getAngle:Mf}=lt,Df={x:-.5},If={connect:Df,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},Af={connect:Df,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},Wf={connect:Df,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},Ff={connect:Df,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},zf={offset:Df,path:[...Wf.path],dashPath:[1,-2.5,0,2,-1,0]};Of(zf.path,180,{x:-1.5,y:0});const Uf={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},Hf={connect:{x:.5},path:[...Uf.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},Nf={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},Yf={path:[...Nf.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},Xf=f.clone(Nf),Vf=f.clone(Yf);Of(Xf.path,45),Of(Vf.path,45);const jf={angle:If,"angle-side":Af,arrow:Ff,triangle:Wf,"triangle-flip":zf,circle:Hf,"circle-line":Uf,square:Yf,"square-line":Nf,diamond:Vf,"diamond-line":Xf,mark:{offset:Df,path:[1,0,-2,2,0,2]}};function Gf(t,e,i,s,n,r,o){let a,h;const{strokeCap:l,strokeJoin:d}=t.__;p(e)?e.type?(h=e.scale,a=jf[e.type]):a=e:a=jf[e];const{offset:c,connect:u,path:g,dashPath:_}=a;let f=u?u.x:0,m=c?c.x:0;const y=[...g];return o&&_&&y.push(..._),"none"!==l&&(f-=.5),c&&("round"===d&&c.roundJoin?m+=c.roundJoin:"bevel"===d&&c.bevelJoin&&(m+=c.bevelJoin)),h&&Cf(y,0,0,h,h),m&&Cf(y,m,0),Cf(y,s.x,s.y,n,n,Mf(i,s)),r.x=(f+m)*n,y}const{M:Kf,L:Zf,C:qf,Q:Jf,Z:$f,N:Qf,D:tm,X:em,G:im,F:sm,O:nm,P:rm,U:om}=Ae,{copy:am,copyFrom:hm,getDistancePoint:lm}=lt,dm={},cm={},um={},pm={},gm={},_m={list:jf,addArrows(t){const{startArrow:e,endArrow:i,strokeWidth:s,dashPattern:n,__pathForRender:r,cornerRadius:o}=t.__,a=!o;let h,l=0,d=r.length,c=0,u=e&&"none"!==e;for(;l<d;){switch(h=r[l],h){case Kf:case Zf:(c<2||l+6>=d)&&(hm(gm,r[l+1],r[l+2]),!c&&u&&am(cm,gm)),l+=3;break;case qf:(1===c||l+7>=d-3)&&fm(r,pm,gm,l+3),l+=7;break;case Jf:(1===c||l+5>=d-3)&&fm(r,pm,gm,l+1),l+=5;break;case $f:return;case Qf:l+=5;break;case tm:l+=9;break;case em:l+=6;break;case im:l+=9;break;case sm:l+=5;break;case nm:l+=7;break;case rm:l+=4;break;case om:(1===c||l+6>=d-3)&&(fm(r,pm,gm,l+1),l+6!==d&&(gm.x-=(gm.x-pm.x)/10,gm.y-=(gm.y-pm.y)/10)),l+=6}if(c++,1===c&&h!==Kf)return;if(2===c&&u&&am(um,h===Zf?gm:pm),l===d){const o=t.__.__pathForRender=a?[...r]:r,d=t.__.__pathForArrow=[];if(u){const i=Gf(t,e,um,cm,s,dm,!!n);n?d.push(...i):o.push(...i),dm.x&&(lm(cm,um,-dm.x,!0),o[1]=um.x,o[2]=um.y)}if(i&&"none"!==i){const e=Gf(t,i,pm,gm,s,dm,!!n);if(n?d.push(...e):o.push(...e),dm.x){let t;switch(lm(gm,pm,-dm.x,!0),h){case Zf:t=l-3+1;break;case qf:t=l-7+5;break;case Jf:t=l-5+3;break;case om:t=l-6+3}t&&mm(o,pm,t)}}}else am(pm,gm)}},register(t,e){this.list[t]=e},get(t){return this.list[t]}};function fm(t,e,i,s){hm(e,t[s],t[s+1]),hm(i,t[s+2],t[s+3])}function mm(t,e,i){t[i]=e.x,t[i+1]=e.y}ce.add("arrow"),t.UI.addAttr("startArrow","none",vf),t.UI.addAttr("endArrow","none",vf),Object.assign(qh,_m),Object.assign(Jh,{strokeArrow(t,e,i,s){e.__.dashPattern&&(i.beginPath(),e.__drawPathByData(i,e.__.__pathForArrow),i.dashPattern=null,i.stroke())}});const{Yes:ym,NoAndSkip:vm,YesAndSkip:xm}=t.Answer,wm={},Em={},bm={};class km{constructor(t){this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},(this.target=t)&&this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":wm.id=t.substring(1),t=wm;break;case".":Em.className=t.substring(1),t=Em;break;default:bm.tag=t,t=bm}case"object":if(o(t.id)){if(t.tag){const{tag:s}=t,n=u(s);return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?f.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className)}{const s=this.getById(t.id,e);return i?s:s?[s]:[]}case"function":return this.getByMethod(t,e,i,s)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&ho.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,r;for(let o=0,a=t.length;o<a;o++){if(n=t[o],r=e(n,s),"boolean"==typeof r&&(r=r?1:0),r===ym||r===xm){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&r<vm&&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_(Ho.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){const{__eventIds:t}=this;t&&t.length&&(this.__removeListenEvents(),this.innerIdMap={},this.idMap={}),this.findLeaf=null}}const Tm=t.UI.prototype;function Sm(t){return t.leafer?t.leafer.selector:ee.selector||(ee.selector=ue.selector())}Tm.find=function(t,e){return Sm(this).getBy(t,this,!1,e)},Tm.findOne=function(t,e){return Sm(this).getBy(t,this,!0,e)},ce.add("find"),ue.finder=function(t){return new km(t)};const{setPoint:Bm,addPoint:Pm,toBounds:Lm}=vt;const Rm={syncExport(t,e,i){let s;il.running=!0;try{const n=Zn.fileType(e),r=e.includes(".");i=Zn.getExportOptions(i);const{toURL:a}=ee,{download:h}=ee.origin;if("json"===n)r&&h(a(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!r||t.toJSON(i.json)};else if("svg"===n)r&&h(a(t.toSVG(),"svg"),e),s={data:!!r||t.toSVG()};else{let n,r,a=1,h=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:u}=t,{slice:p,clip:g,trim:_,screenshot:f,padding:m,onCanvas:y}=i,v=o(i.smooth)?!c||c.config.smooth:i.smooth,x=i.contextSettings||(c?c.config.contextSettings:void 0),w=d&&f&&o(i.fill)?t.fill:i.fill,E=Zn.isOpaqueImage(e)||w,b=new mt;if(f)n=!0===f?d?c.canvas.bounds:t.worldRenderBounds:f;else{let e=i.relative||(d?"inner":"local");switch(a=l.scaleX,h=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),a/=t.scaleX,h/=t.scaleY;break;case"world":a=1,h=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,h/=h/i.scaleY}n=t.getBounds("render",e)}const k={scaleX:1,scaleY:1};A.getScaleData(i.scale,i.size,n,k);let T=i.pixelRatio||1,{x:S,y:B,width:P,height:L}=new Kt(n).scale(k.scaleX,k.scaleY);g&&(S+=g.x,B+=g.y,P=g.width,L=g.height,g.rotation&&b.rotateOfInner({x:S,y:B},-g.rotation));const R={exporting:!0,matrix:b.scale(1/k.scaleX,1/k.scaleY).invert().translate(-S,-B).withScale(1/a*k.scaleX,1/h*k.scaleY)};let C,O=ue.canvas({width:Math.floor(P),height:Math.floor(L),pixelRatio:T,smooth:v,contextSettings:x});p&&(C=t,C.__worldOpacity=0,t=c||t,R.bounds=O.bounds),O.save();const M=u&&!o(w),D=t.get("fill");if(M&&(t.fill=""),ee.render(t,O,R),M&&(t.fill=D),O.restore(),C&&C.__updateWorldOpacity(),_){r=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,r,o,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,r=(a-n)/e,o?Pm(o,n,r):Bm(o={},n,r)),a++;const h=new Kt;return o&&(Lm(o,h),h.scale(1/t.pixelRatio).ceil()),h}(O);const t=O,{width:e,height:i}=r,s={x:0,y:0,width:e,height:i,pixelRatio:T};O=ue.canvas(s),O.copyWorld(t,r,s),t.destroy()}if(m){const[t,e,i,s]=A.fourNumber(m),n=O,{width:r,height:o}=n;O=ue.canvas({width:r+s+e,height:o+t+i,pixelRatio:T}),O.copyWorld(n,n.bounds,{x:s,y:t,width:r,height:o}),n.destroy()}E&&O.fillWorld(O.bounds,w||"#FFFFFF","destination-over"),y&&y(O);s={data:"canvas"===e?O:O.export(e,i),width:O.pixelWidth,height:O.pixelHeight,renderBounds:n,trimBounds:r};const I=c&&c.app;I&&I.canvasManager&&I.canvasManager.clearRecycled()}}catch(t){s={data:"",error:t}}return il.running=!1,s},export(t,e,i){return il.running=!0,function(t){Cm||(Cm=new Qn);return new Promise(e=>{Cm.add(()=>n(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(r=>{const o=()=>n(this,void 0,void 0,function*(){if(!er.isComplete)return ee.requestRender(o);const n=il.syncExport(t,e,i);n.data instanceof Promise&&(n.data=yield n.data),s(n),r()});t.updateLayout(),Om(t);const{leafer:a}=t;a?a.waitViewCompleted(o):o()}))}};let Cm;function Om(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>Om(t))}const Mm=Me.prototype,Dm=ne.get("@leafer-in/export");Mm.export=function(t,e){const{quality:i,blob:s}=Zn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},Mm.toBlob=function(t,e){return new Promise(i=>{ee.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{Dm.error(t),i(null)})})},Mm.toDataURL=function(t,e){return ee.origin.canvasToDataURL(this.view,t,e)},Mm.saveAs=function(t,e){return new Promise(i=>{ee.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{Dm.error(t),i(!1)})})},ce.add("export"),Object.assign(il,Rm),t.UI.prototype.export=function(t,e){return il.export(this,t,e)},t.UI.prototype.syncExport=function(t,e){return il.syncExport(this,t,e)};const Im={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},Am={top:"flex-start",middle:"center",bottom:"flex-end"},Wm={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function Fm(t,e,i){const{style:s}=t,{fill:n,padding:r,textWrap:a,textOverflow:l,textDecoration:d}=e;let c;s.fontFamily=e.fontFamily,s.fontSize=e.fontSize*i+"px",function(t,e){let i="black";u(e)&&(e=e[0]);if(p(e))switch(e.type){case"solid":i=Kh.string(e.color);break;case"image":case"film":case"video":break;case"linear":case"radial":case"angular":const t=e.stops[0];i=Kh.string(h(t)?t:t.color);break;default:o(e.r)||(i=Kh.string(e))}else i=e;t.color=i}(s,n),s.fontStyle=e.italic?"italic":"normal",s.fontWeight=e.fontWeight,p(d)?(c=d.type,d.color&&(s.textDecorationColor=Kh.string(d.color))):c=d,s.textDecoration=Wm[c],s.textTransform=Im[e.textCase],s.textAlign="both"===e.textAlign?"justify":e.textAlign,s.display="flex",s.flexDirection="column",s.justifyContent=Am[e.verticalAlign],s.lineHeight=(e.__.__lineHeight||0)*i+"px",s.letterSpacing=(e.__.__letterSpacing||0)*i+"px",s.whiteSpace="none"===a||e.__.__autoWidth?"nowrap":"normal",s.wordBreak="break"===a?"break-all":"normal",s.textIndent=(e.paraIndent||0)*i+"px",s.padding=u(r)?r.map(t=>t*i+"px").join(" "):(r||0)*i+"px",s.textOverflow="show"===l?"":"hide"===l?"clip":l}t.TextEditor=class extends o_{constructor(){super(...arguments),this.config={selectAll:!0},this.eventIds=[]}get tag(){return"TextEditor"}onLoad(){const{editor:e}=this,{config:i}=e.app,s=this.editTarget;s.textEditing=!0,this.isHTMLText=!(s instanceof t.Text),this._keyEvent=i.keyEvent,i.keyEvent=!1;const n=this.editDom=document.createElement("div");n.classList.add("leafer-text-editor");const{style:r}=n;n.contentEditable="true",r.position="fixed",r.transformOrigin="left top",r.boxSizing="border-box",this.isHTMLText?n.innerHTML=String(s.text):n.innerText=String(s.text);const{view:o}=e.app;(this.inBody=o instanceof HTMLCanvasElement)?document.body.appendChild(n):o.appendChild(n),this.eventIds=[e.app.on_(t.PointerEvent.DOWN,t=>{let i,{target:s}=t.origin;for(;s;)s===n&&(i=!0),s=s.parentElement;i||e.closeInnerEditor()})],this.onFocus=this.onFocus.bind(this),this.onInput=this.onInput.bind(this),this.onPaste=this.onPaste.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onKeydown=this.onKeydown.bind(this),n.addEventListener("focus",this.onFocus),n.addEventListener("input",this.onInput),n.addEventListener("paste",this.onPaste),window.addEventListener("keydown",this.onKeydown),window.addEventListener("scroll",this.onUpdate);const a=window.getSelection(),h=document.createRange();if(this.config.selectAll)h.selectNodeContents(n);else{const t=n.childNodes[0];t&&(h.setStartAfter(t),h.setEndAfter(t)),h.collapse(!0)}a.removeAllRanges(),a.addRange(h)}onInput(){const{editDom:t}=this;this.editTarget.text=this.isHTMLText?t.innerHTML:t.innerText}onFocus(){this.editDom.style.outline="none"}onKeydown(t){if("Escape"===t.code&&this.editor.closeInnerEditor(),"Enter"===t.key){t.preventDefault();const e=document.createElement("br"),i=document.createTextNode("​"),s=window.getSelection().getRangeAt(0);s.deleteContents(),s.insertNode(i),s.insertNode(e),s.setStartAfter(e),s.setEndAfter(e),this.onInput()}}onPaste(t){if(this.isHTMLText)return;t.preventDefault();const e=t.clipboardData;if(!e)return;let i=e.getData("text/plain").replace(/\r\n?/g,"\n");const s=window.getSelection();if(!s||!s.rangeCount)return;const n=s.getRangeAt(0);n.deleteContents();const r=i.split("\n"),o=document.createDocumentFragment();r.forEach((t,e)=>{e>0&&o.appendChild(document.createElement("br")),o.appendChild(document.createTextNode(t))}),n.insertNode(o),n.collapse(!1),s.removeAllRanges(),s.addRange(n),this.onInput()}onUpdate(){const{editTarget:t}=this;let e=1;if(!this.isHTMLText){const{scaleX:i,scaleY:s}=t.worldTransform;e=Math.max(Math.abs(i),Math.abs(s));t.fontSize*e<12&&(e*=12/t.fontSize)}this.textScale=e;let{width:i,height:s}=t,n=0,r=0;i*=e,s*=e;const o=t.__;if(o.__autoWidth)switch(i+=20,o.textAlign){case"center":n=o.autoSizeAlign?-i/2:-10;break;case"right":n=o.autoSizeAlign?-i:-20}if(o.__autoHeight)switch(s+=20,o.verticalAlign){case"middle":r=o.autoSizeAlign?-s/2:-10;break;case"bottom":r=o.autoSizeAlign?-s:-20}const{x:a,y:h}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds,{a:l,b:d,c:c,d:u,e:p,f:g}=new mt(t.worldTransform).scale(1/e).translateInner(n,r),{style:_}=this.editDom;_.transform=`matrix(${l},${d},${c},${u},${p},${g})`,_.left=a+"px",_.top=h+"px",_.width=i+"px",_.height=s+"px",this.isHTMLText||Fm(this.editDom,t,e)}onUnload(){const{editTarget:t,editor:e,editDom:i}=this;t&&(this.onInput(),"\n"===t.text&&(t.text=""),t.textEditing=void 0,e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),i.removeEventListener("focus",this.onFocus),i.removeEventListener("input",this.onInput),i.removeEventListener("paste",this.onPaste),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("scroll",this.onUpdate),i.remove(),this.editDom=this.eventIds=void 0)}},t.TextEditor=s([jg()],t.TextEditor),ce.add("text-editor","editor");class zm extends Sl{setText(t){this._text=t,this.__htmlChanged=!0}}const Um={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",hellip:"…",middot:"·",bull:"•",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",cent:"¢",pound:"£",yen:"¥",euro:"€",times:"×",divide:"÷",plusmn:"±",minus:"−",frac12:"½",frac14:"¼",frac34:"¾",sup2:"²",sup3:"³",deg:"°",reg:"®",copy:"©",trade:"™",section:"§",para:"¶",dagger:"†",Dagger:"‡",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",alpha:"α",beta:"β",gamma:"γ",delta:"δ",pi:"π",sigma:"σ",omega:"ω",Omega:"Ω",micro:"µ",infinity:"∞",not:"¬",equiv:"≡",le:"≤",ge:"≥"};return t.HTMLText=class extends t.Image{get __tag(){return"HTMLText"}constructor(t){super(t)}__updateBoxBounds(){const t=this.__;if(t.__htmlChanged){const e=document.createElement("div"),{style:i}=e;i.all="initial",i.position="absolute",i.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:s,height:n}=e.getBoundingClientRect(),r=s+10,o=`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${n}">\n <foreignObject width="${r}" height="${n}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.decodeText(this.text)}\n </body>\n </foreignObject>\n </svg>`;t.__setImageFill("data:image/svg+xml,"+encodeURIComponent(o)),t.__naturalWidth=r/t.pixelRatio,t.__naturalHeight=n/t.pixelRatio,t.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}__draw(t,e,i){this.textEditing&&!e.exporting||super.__draw(t,e,i)}decodeText(t){if(!t.includes("&"))return t;let e,i,s="",n=0;for(;n<t.length;){if("&"===t[n]){const r=t.indexOf(";",n+1);if(r>n+1&&(e=t.slice(n+1,r),i=Um[e],void 0!==i)){s+=i,n=r+1;continue}}s+=t[n++]}return s}static addUnicodeEntity(t,e){h(t)?Um[t]=e:Object.assign(Um,t)}},s([Ur(zm)],t.HTMLText.prototype,"__",void 0),s([xr("")],t.HTMLText.prototype,"text",void 0),s([gr("TextEditor")],t.HTMLText.prototype,"editInner",void 0),s([Lr(!1)],t.HTMLText.prototype,"textEditing",void 0),t.HTMLText=s([Zr()],t.HTMLText),ce.add("html"),t.AlignHelper=Bt,t.AroundHelper=kt,t.ArrowData=yf,t.AutoBounds=qt,t.BezierHelper=li,t.Bounds=Kt,t.BoundsEvent=Xo,t.BoundsHelper=Xt,t.BoxData=gl,t.BranchHelper=wo,t.BranchRender=za,t.CanvasData=Bl,t.CanvasManager=ve,t.ChildEvent=zo,t.ColorConvert=Kh,t.Creator=ue,t.Cursor=ic,t.DataHelper=f,t.Debug=ne,t.DragBoundsHelper=Md,t.Dragger=Vd,t.EditBox=Dg,t.EditDataHelper=Sg,t.EditPoint=Cg,t.EditSelect=pg,t.EditSelectHelper=lg,t.EditToolCreator=Gg,t.EditorEvent=Qp,t.EditorGroupEvent=qg,t.EditorHelper=Yg,t.EditorMoveEvent=e_,t.EditorRotateEvent=s_,t.EditorScaleEvent=i_,t.EditorSkewEvent=n_,t.Effect=tl,t.EllipseData=vl,t.EllipseHelper=yi,t.Event=Fo,t.EventCreator=me,t.Eventer=aa,t.Export=il,t.FileHelper=Zn,t.Filter=el,t.Finder=km,t.FourNumberHelper=S,t.FrameData=fl,t.GroupData=pl,t.HTMLTextData=zm,t.HitCanvasManager=sc,t.ImageData=Sl,t.ImageEvent=Yo,t.ImageManager=sr,t.IncrementId=v,t.InnerEditor=o_,t.InnerEditorEvent=Zg,t.InteractionBase=ec,t.InteractionHelper=zd,t.Keyboard=vd,t.LayoutEvent=$o,t.Layouter=Ah,t.LeafBounds=Ia,t.LeafBoundsHelper=mo,t.LeafData=y,t.LeafDataProxy=xa,t.LeafEventer=ya,t.LeafHelper=ho,t.LeafLayout=Wo,t.LeafLevelList=wh,t.LeafList=xh,t.LeafMatrix=Ba,t.LeafRender=Aa,t.LeaferCanvas=Eh,t.LeaferCanvasBase=Me,t.LeaferData=_l,t.LeaferEvent=ta,t.LeaferFilm=class extends ar{get tag(){return"Film"}},t.LeaferImage=ar,t.LeaferTypeCreator=Y_,t.LeaferVideo=class extends ar{get tag(){return"Video"}},t.LineData=ml,t.MathHelper=A,t.Matrix=mt,t.MatrixHelper=J,t.MultiTouchHelper=j_,t.MyDragEvent=Wd,t.MyImage=ud,t.MyPointerEvent=Id,t.MyTouchEvent=Fd,t.NeedConvertToCanvasCommandMap=Fe,t.OneRadian=F,t.PI2=z,t.PI_2=U,t.Paint=Jh,t.PaintGradient=Qh,t.PaintImage=$h,t.PathArrow=qh,t.PathArrowModule=_m,t.PathBounds=Wn,t.PathCommandDataHelper=Ss,t.PathCommandMap=Ae,t.PathCommandNodeHelper=vi,t.PathConvert=ss,t.PathCorner=Xn,t.PathCreator=Ys,t.PathData=El,t.PathDrawer=rn,t.PathHelper=De,t.PathMatrixHelper=Lf,t.PathNumberCommandLengthMap=Ne,t.PathNumberCommandMap=He,t.PenData=bl,t.Picker=Nh,t.Platform=ee,t.Plugin=ce,t.Point=_t,t.PointHelper=lt,t.PointerButton=xd,t.PolygonData=xl,t.PropertyEvent=Ho,t.RectData=yl,t.RectHelper=Ye,t.RectRender=Dl,t.RenderEvent=Qo,t.Renderer=Fh,t.ResizeEvent=qo,t.Resource=er,t.Run=he,t.ScrollBar=mf,t.SelectArea=hg,t.Selector=Yh,t.StarData=wl,t.State=sl,t.StringNumberMap=$t,t.Stroker=ag,t.TaskItem=$n,t.TaskProcessor=Qn,t.TextConvert=Gh,t.TextData=Tl,t.TransformTool=r_,t.Transformer=nf,t.Transition=nl,t.TwoPointBoundsHelper=vt,t.UIBounds=Rl,t.UICreator=ge,t.UIData=cl,t.UIEvent=wd,t.UIRender=Ol,t.UnitConvert=Zh,t.UnitConvertHelper=Jt,t.WaitHelper=Bo,t.WatchEvent=Jo,t.Watcher=Th,t.WheelEventHelper=$_,t.addViewport=U_,t.addViewportConfig=H_,t.affectRenderBoundsType=Pr,t.affectStrokeBoundsType=Tr,t.arrowType=vf,t.attr=ur,t.autoLayoutType=mr,t.boundsType=xr,t.canvasPatch=Kn,t.canvasSizeAttrs=Oe,t.createAttr=function(t){return(e,i)=>{hr(e,i,dr(i,t))}},t.createDescriptor=dr,t.cursorType=zr,t.dataProcessor=Ur,t.dataType=gr,t.decorateLeafAttr=cr,t.defineDataProcessor=Hr,t.defineKey=hr,t.defineLeafAttr=pr,t.dimType=Rr,t.doBoundsType=Er,t.doStrokeType=Sr,t.effectType=Xh,t.emptyData=r,t.eraserType=Wr,t.extraPropertyEventMap=No,t.getBoundsData=N,t.getDescriptor=lr,t.getMatrixData=Y,t.getPointData=H,t.hitType=Fr,t.isArray=u,t.isData=g,t.isEmptyData=_,t.isFinite=l,t.isNull=a,t.isNumber=d,t.isObject=p,t.isString=h,t.isUndefined=o,t.layoutProcessor=function(t){return(e,i)=>{hr(e,"__LayoutProcessor",{get:()=>t})}},t.leaferTransformAttrMap=ra,t.maskType=Ar,t.naturalBoundsType=wr,t.opacityType=Cr,t.path=Vn,t.pathInputType=br,t.pathType=kr,t.pen=jn,t.positionType=_r,t.registerEditTool=Vg,t.registerInnerEditor=jg,t.registerUI=Zr,t.registerUIEvent=qr,t.resizeType=Vh,t.rewrite=Vr,t.rewriteAble=jr,t.rotationType=vr,t.scaleType=yr,t.scrollType=fr,t.sortType=Ir,t.strokeType=Br,t.surfaceType=Lr,t.tempBounds=Zt,t.tempMatrix=yt,t.tempPoint=ft,t.tryToNumber=function(t){return"string"==typeof t&&c.test(t)?+t:t},t.useCanvas=bh,t.useModule=Kr,t.version="2.0.2",t.visibleType=Or,t.zoomLayerType=jh,t}({});function Leafer(t){return new LeaferUI.Leafer(t)}Object.setPrototypeOf(Leafer,LeaferUI),Leafer.prototype=LeaferUI.Leafer.prototype;
2
2
  //# sourceMappingURL=worker.min.js.map