@netless/appliance-plugin 1.1.11 → 1.1.12

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.
package/cdn/cdn.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r="/fullWorker-CnB3KR.js",e="/subWorker-1E_izA.js";exports.fullWorkerUrl=r;exports.subWorkerUrl=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r="/fullWorker-DxZdUl.js",e="/subWorker-5GNo7p.js";exports.fullWorkerUrl=r;exports.subWorkerUrl=e;
@@ -396,7 +396,7 @@ _inherits(o,_e$default22);return _createClass(o,[{key:"texture",get:function get
396
396
  c=="length"||// Node.js 0.10 has enumerable non-index properties on buffers.
397
397
  n&&(c=="offset"||c=="parent")||// PhantomJS 2 has enumerable non-index properties on typed arrays.
398
398
  i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||// Skip index properties.
399
- mc(c,s)))&&o.push(c);return o;}var Jn=xc,Tc=Object.prototype;function Mc(h){var r=h&&h.constructor,t=typeof r=="function"&&r.prototype||Tc;return h===t;}var Er=Mc;function Pc(h,r){return function(t){return h(r(t));};}var Zn=Pc,Oc=Zn,Ec=Oc(Object.keys,Object),Cc=Ec,Ac=Er,Rc=Cc,Ic=Object.prototype,Lc=Ic.hasOwnProperty;function wc(h){if(!Ac(h))return Rc(h);var r=[];for(var t in Object(h))Lc.call(h,t)&&t!="constructor"&&r.push(t);return r;}var bc=wc,Dc=Un,Nc=Xn;function Wc(h){return h!=null&&Nc(h.length)&&!Dc(h);}var Cr=Wc,Bc=Jn,Fc=bc,Uc=Cr;function jc(h){return Uc(h)?Bc(h):Fc(h);}var Ar=jc,$c=ir,zc=Ar;function Gc(h,r){return h&&$c(r,zc(r),h);}var Hc=Gc;function Kc(h){var r=[];if(h!=null)for(var t in Object(h))r.push(t);return r;}var Yc=Kc,Vc=he,Xc=Er,kc=Yc,Jc=Object.prototype,Zc=Jc.hasOwnProperty;function Qc(h){if(!Vc(h))return kc(h);var r=Xc(h),t=[];for(var e in h)e=="constructor"&&(r||!Zc.call(h,e))||t.push(e);return t;}var qc=Qc,_c=Jn,tf=qc,ef=Cr;function rf(h){return ef(h)?_c(h,!0):tf(h);}var Rr=rf,nf=ir,sf=Rr;function of(h,r){return h&&nf(r,sf(r),h);}var af=of,He={exports:{}};He.exports;(function(h,r){var t=ee,e=r&&!r.nodeType&&r,n=e&&!0&&h&&!h.nodeType&&h,i=n&&n.exports===e,a=i?t.Buffer:void 0,o=a?a.allocUnsafe:void 0;function s(c,d){if(d)return c.slice();var l=c.length,p=o?o(l):new c.constructor(l);return c.copy(p),p;}h.exports=s;})(He,He.exports);var lf=He.exports;function cf(h,r){var t=-1,e=h.length;for(r||(r=Array(e));++t<e;)r[t]=h[t];return r;}var ff=cf;function hf(h,r){for(var t=-1,e=h==null?0:h.length,n=0,i=[];++t<e;){var a=h[t];r(a,t,h)&&(i[n++]=a);}return i;}var Qn=hf;function uf(){return[];}var qn=uf,df=Qn,gf=qn,pf=Object.prototype,mf=pf.propertyIsEnumerable,_r=Object.getOwnPropertySymbols,vf=_r?function(h){return h==null?[]:(h=Object(h),df(_r(h),function(r){return mf.call(h,r);}));}:gf,Ir=vf,yf=ir,Sf=Ir;function xf(h,r){return yf(h,Sf(h),r);}var Tf=xf;function Mf(h,r){for(var t=-1,e=r.length,n=h.length;++t<e;)h[n+t]=r[t];return h;}var Lr=Mf,Pf=Zn,Of=Pf(Object.getPrototypeOf,Object),_n=Of,Ef=Lr,Cf=_n,Af=Ir,Rf=qn,If=Object.getOwnPropertySymbols,Lf=If?function(h){for(var r=[];h;)Ef(r,Af(h)),h=Cf(h);return r;}:Rf,ti=Lf,wf=ir,bf=ti;function Df(h,r){return wf(h,bf(h),r);}var Nf=Df,Wf=Lr,Bf=Fe;function Ff(h,r,t){var e=r(h);return Bf(h)?e:Wf(e,t(h));}var ei=Ff,Uf=ei,jf=Ir,$f=Ar;function zf(h){return Uf(h,$f,jf);}var ri=zf,Gf=ei,Hf=ti,Kf=Rr;function Yf(h){return Gf(h,Kf,Hf);}var Vf=Yf,Xf=ge,kf=ee,Jf=Xf(kf,"DataView"),Zf=Jf,Qf=ge,qf=ee,_f=Qf(qf,"Promise"),th=_f,eh=ge,rh=ee,nh=eh(rh,"Set"),ni=nh,ih=ge,sh=ee,oh=ih(sh,"WeakMap"),ah=oh,dr=Zf,gr=Mr,pr=th,mr=ni,vr=ah,ii=de,Ae=jn,tn="[object Map]",lh="[object Object]",en="[object Promise]",rn="[object Set]",nn="[object WeakMap]",sn="[object DataView]",ch=Ae(dr),fh=Ae(gr),hh=Ae(pr),uh=Ae(mr),dh=Ae(vr),ue=ii;(dr&&ue(new dr(new ArrayBuffer(1)))!=sn||gr&&ue(new gr())!=tn||pr&&ue(pr.resolve())!=en||mr&&ue(new mr())!=rn||vr&&ue(new vr())!=nn)&&(ue=function ue(h){var r=ii(h),t=r==lh?h.constructor:void 0,e=t?Ae(t):"";if(e)switch(e){case ch:return sn;case fh:return tn;case hh:return en;case uh:return rn;case dh:return nn;}return r;});var or=ue,gh=Object.prototype,ph=gh.hasOwnProperty;function mh(h){var r=h.length,t=new h.constructor(r);return r&&typeof h[0]=="string"&&ph.call(h,"index")&&(t.index=h.index,t.input=h.input),t;}var vh=mh,yh=ee,Sh=yh.Uint8Array,si=Sh,on=si;function xh(h){var r=new h.constructor(h.byteLength);return new on(r).set(new on(h)),r;}var wr=xh,Th=wr;function Mh(h,r){var t=r?Th(h.buffer):h.buffer;return new h.constructor(t,h.byteOffset,h.byteLength);}var Ph=Mh,Oh=/\w*$/;function Eh(h){var r=new h.constructor(h.source,Oh.exec(h));return r.lastIndex=h.lastIndex,r;}var Ch=Eh,an=Be,ln=an?an.prototype:void 0,cn=ln?ln.valueOf:void 0;function Ah(h){return cn?Object(cn.call(h)):{};}var Rh=Ah,Ih=wr;function Lh(h,r){var t=r?Ih(h.buffer):h.buffer;return new h.constructor(t,h.byteOffset,h.length);}var wh=Lh,bh=wr,Dh=Ph,Nh=Ch,Wh=Rh,Bh=wh,Fh="[object Boolean]",Uh="[object Date]",jh="[object Map]",$h="[object Number]",zh="[object RegExp]",Gh="[object Set]",Hh="[object String]",Kh="[object Symbol]",Yh="[object ArrayBuffer]",Vh="[object DataView]",Xh="[object Float32Array]",kh="[object Float64Array]",Jh="[object Int8Array]",Zh="[object Int16Array]",Qh="[object Int32Array]",qh="[object Uint8Array]",_h="[object Uint8ClampedArray]",tu="[object Uint16Array]",eu="[object Uint32Array]";function ru(h,r,t){var e=h.constructor;switch(r){case Yh:return bh(h);case Fh:case Uh:return new e(+h);case Vh:return Dh(h,t);case Xh:case kh:case Jh:case Zh:case Qh:case qh:case _h:case tu:case eu:return Bh(h,t);case jh:return new e();case $h:case Hh:return new e(h);case zh:return Nh(h);case Gh:return new e();case Kh:return Wh(h);}}var nu=ru,iu=he,fn=Object.create,su=/* @__PURE__ */function(){function h(){}return function(r){if(!iu(r))return{};if(fn)return fn(r);h.prototype=r;var t=new h();return h.prototype=void 0,t;};}(),ou=su,au=ou,lu=_n,cu=Er;function fu(h){return typeof h.constructor=="function"&&!cu(h)?au(lu(h)):{};}var hu=fu,uu=or,du=ne,gu="[object Map]";function pu(h){return du(h)&&uu(h)==gu;}var mu=pu,vu=mu,yu=sr,hn=Or,un=hn&&hn.isMap,Su=un?yu(un):vu,xu=Su,Tu=or,Mu=ne,Pu="[object Set]";function Ou(h){return Mu(h)&&Tu(h)==Pu;}var Eu=Ou,Cu=Eu,Au=sr,dn=Or,gn=dn&&dn.isSet,Ru=gn?Au(gn):Cu,oi=Ru,Iu=/* @__PURE__ */fe(oi),Lu=zn,wu=el,bu=Kn,Du=Hc,Nu=af,Wu=lf,Bu=ff,Fu=Tf,Uu=Nf,ju=ri,$u=Vf,zu=or,Gu=vh,Hu=nu,Ku=hu,Yu=Fe,Vu=Pr,Xu=xu,ku=he,Ju=oi,Zu=Ar,Qu=Rr,qu=1,_u=2,td=4,ai="[object Arguments]",ed="[object Array]",rd="[object Boolean]",nd="[object Date]",id="[object Error]",li="[object Function]",sd="[object GeneratorFunction]",od="[object Map]",ad="[object Number]",ci="[object Object]",ld="[object RegExp]",cd="[object Set]",fd="[object String]",hd="[object Symbol]",ud="[object WeakMap]",dd="[object ArrayBuffer]",gd="[object DataView]",pd="[object Float32Array]",md="[object Float64Array]",vd="[object Int8Array]",yd="[object Int16Array]",Sd="[object Int32Array]",xd="[object Uint8Array]",Td="[object Uint8ClampedArray]",Md="[object Uint16Array]",Pd="[object Uint32Array]",Ft={};Ft[ai]=Ft[ed]=Ft[dd]=Ft[gd]=Ft[rd]=Ft[nd]=Ft[pd]=Ft[md]=Ft[vd]=Ft[yd]=Ft[Sd]=Ft[od]=Ft[ad]=Ft[ci]=Ft[ld]=Ft[cd]=Ft[fd]=Ft[hd]=Ft[xd]=Ft[Td]=Ft[Md]=Ft[Pd]=!0;Ft[id]=Ft[li]=Ft[ud]=!1;function $e(h,r,t,e,n,i){var a,o=r&qu,s=r&_u,c=r&td;if(t&&(a=n?t(h,e,n,i):t(h)),a!==void 0)return a;if(!ku(h))return h;var d=Yu(h);if(d){if(a=Gu(h),!o)return Bu(h,a);}else{var l=zu(h),p=l==li||l==sd;if(Vu(h))return Wu(h,o);if(l==ci||l==ai||p&&!n){if(a=s||p?{}:Ku(h),!o)return s?Uu(h,Nu(a,h)):Fu(h,Du(a,h));}else{if(!Ft[l])return n?h:{};a=Hu(h,l,o);}}i||(i=new Lu());var y=i.get(h);if(y)return y;i.set(h,a),Ju(h)?h.forEach(function(v){a.add($e(v,r,t,v,h,i));}):Xu(h)&&h.forEach(function(v,T){a.set(T,$e(v,r,t,T,h,i));});var P=c?s?$u:ju:s?Qu:Zu,x=d?void 0:P(h);return wu(x||h,function(v,T){x&&(T=v,v=h[T]),bu(a,T,$e(v,r,t,T,h,i));}),a;}var Od=$e,Ed=Od,Cd=1,Ad=4;function Rd(h){return Ed(h,Cd|Ad);}var Id=Rd,Xt=/* @__PURE__ */fe(Id);var fi="1.1.11",Ld="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var h=window.__netlessUA||"";h+=" ".concat(Ld,"@").concat(fi),window.__netlessUA=h;}var re={syncOpt:{interval:500},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:1e3},bezier:{combineUnitTime:100},pencilEraser:{useBitMap:!0},strokeWidth:{min:1,max:10}};function ae(h){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=h.length;if(t<2)return"";var e=h[0],n=h[1];if(t===2)return"M".concat(pe(e),"L").concat(pe(n));var i="";for(var a=2,o=t-1;a<o;a++)e=h[a],n=h[a+1],i+=me(e,n);return r?"M".concat(me(h[0],h[1]),"Q").concat(pe(h[1])).concat(me(h[1],h[2]),"T").concat(i).concat(me(h[t-1],h[0])).concat(me(h[0],h[1]),"Z"):"M".concat(pe(h[0]),"Q").concat(pe(h[1])).concat(me(h[1],h[2])).concat(h.length>3?"T":"").concat(i,"L").concat(pe(h[t-1]));}var Jt=/*#__PURE__*/function(){function Jt(r){_classCallCheck(this,Jt);et(this,"syncUnitTime",re.syncOpt.interval);et(this,"vNodes");et(this,"drawLayer");et(this,"fullLayer");et(this,"workId");var t=r.vNodes,e=r.fullLayer,n=r.drawLayer,i=r.workId,a=r.toolsOpt;this.vNodes=t,this.fullLayer=e,this.drawLayer=n,this.workId=i,this.syncUnitTime=a.syncUnitTime||this.syncUnitTime;}return _createClass(Jt,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return r.reduce(function(e,n){var i=e[e.length-1];return(n&&!i||n&&i&&!n.isNear(i,t))&&e.push(n),e;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(r){this.workId=r;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(r){var n,i,a;this.workOptions=r,this.syncUnitTime=r.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),e=t&&((i=this.vNodes)==null?void 0:i.get(t))||void 0;t&&e&&(e.opt=r,(a=this.vNodes)==null||a.setInfo(t,e));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(r){var n,i;var t;var e=(n=this.workId)==null?void 0:n.toString();if(e&&r){var a=this.fullLayer.getElementsByName(e)||this.drawLayer&&this.drawLayer.getElementsByName(e)||[];if(a.length!==1)return;var o=a[0],s=r.pos,c=r.zIndex,d=r.scale,l=r.angle,p=r.translate,y={};Zt(c)&&(y.zIndex=c),s&&(y.pos=[s[0],s[1]]),d&&(y.scale=d),l&&(y.rotate=l),p&&(y.translate=p),o.attr(y);var P=o==null?void 0:o.getBoundingClientRect();return P&&(t=Pt(t,{x:Math.floor(P.x-Jt.SafeBorderPadding),y:Math.floor(P.y-Jt.SafeBorderPadding),w:Math.floor(P.width+Jt.SafeBorderPadding*2),h:Math.floor(P.height+Jt.SafeBorderPadding*2)})),(i=this.vNodes)==null||i.setInfo(e,{rect:t,centerPos:s}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(r){var t=r.group,e=r.eraserlines,n=r.pos,i=r.layer,_r$isClear=r.isClear,a=_r$isClear===void 0?!0:_r$isClear,o=!!i.parent.gl;var _iterator13=_createForOfIteratorHelper(e),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var s=_step13.value;var c=s.thickness,d=s.op;var _iterator14=_createForOfIteratorHelper(d),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var l=_step14.value;var p=l.map(function(T,f){return f%2?T-n[1]:T-n[0];}),y=this.computEraserPoints(p,c),P=ae(y,!0),x={pos:[0,0],d:P,fillColor:"rgba(0,0,0,1)"},v=new ce(x);a&&(v.addEventListener("beforerender",function(_ref165){var T=_ref165.detail;var f=T.context;o?f.blendFuncSeparate(f.ZERO,f.ZERO,f.ZERO,f.ZERO):f.globalCompositeOperation="destination-out";}),v.addEventListener("afterrender",function(_ref166){var T=_ref166.detail;var f=T.context;o?f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA):f.globalCompositeOperation="source-over";})),t.append(v);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}},{key:"computEraserPoints",value:function computEraserPoints(r,t){var e=Math.ceil(t/2);return r.length===2?this.computDot(r,e):this.computLine(r,e);}},{key:"computDot",value:function computDot(r,t){var e=new xt(r[0],r[1]);return xt.GetDotStroke(e,t,8);}},{key:"computLine",value:function computLine(r,t){var e=[],n=[];var i,a;for(var o=0;o<r.length;o+=2){var s=new xt(r[o],r[o+1]);var c=void 0;if(o==r.length-2){var d=new xt(r[o-2],r[o-1]);c=_.Sub(s,d).uni(),i=s;}else{o===0&&(a=s);var _d4=new xt(r[o+2],r[o+3]);c=_.Sub(_d4,s).uni();}if(c){var _d5=_.Per(c).mul(t);e.push(xt.Sub(s,_d5)),n.push(xt.Add(s,_d5));}}if(i&&a){var _o3=xt.GetSemicircleStroke(i,e[e.length-1],-1,8),_s4=xt.GetSemicircleStroke(a,n[0],-1,8);return e.concat(_o3,n.reverse(),_s4);}return[];}},{key:"replace",value:function replace(r,t,e){var _this61=this;var o;var n=r.getElementsByName(t),i=n.length;if(i){if(i>1)for(var s=1;s<n.length;s++)r.removeChild(n[s]),n[s].disconnect();e?r.replaceChild(e,n[0]):r.removeChild(n[0]),n[0].disconnect();}else e&&r.append(e);this.fullLayer===r?(o=this.drawLayer)==null||o.getElementsByName(t).forEach(function(s){var c;(c=_this61.drawLayer)==null||c.removeChild(s),s.disconnect();}):this.fullLayer.getElementsByName(t).forEach(function(s){_this61.fullLayer.removeChild(s),s.disconnect();});}}],[{key:"updateNodeOpt",value:function updateNodeOpt(r){var f;var t=r.node,e=r.opt,n=r.vNodes,i=r.willSerializeData,a=r.targetNode,o=e.zIndex,s=e.translate,c=e.angle,d=e.originPoint,l=e.scenePoint,p=e.scale,y=e.pointMap,P=e.thickness;var x;var v=a&&Xt(a)||n.get(t.name);if(!v)return;Zt(o)&&(t.setAttribute("zIndex",o),v.opt.zIndex=o);var T=t.parent;if(T){if(d&&p&&a){var g=[v.op[0],v.op[1]];Ur(v.op,l,p,s);var u=[v.op[0],v.op[1]],m=[u[0]-g[0],u[1]-g[1]];if(v.centerPos=[v.centerPos[0]+m[0],v.centerPos[1]+m[1]],v.opt.translate=void 0,v.opt.scale=void 0,v.opt.eraserlines)for(var _i2=0,_Object$values=Object.values(v.opt.eraserlines);_i2<_Object$values.length;_i2++){var M=_Object$values[_i2];var E=M.op,A=M.thickness;M.thickness=A*Math.max(p[0],p[1]);for(var w=0;w<E.length;w++)jr(E[w],l,p,s);}}else if(s){if(t.setAttribute("translate",s),v.opt.translate=s,a){var _g6=[s[0]*T.worldScaling[0],s[1]*T.worldScaling[1]];x=Sr(v.rect,_g6),v.rect=x;}else{var _g7=Jt.getRectFromLayer(T,t.name);v.rect=_g7||v.rect;}}else if(Zt(c))if(t.setAttribute("rotate",c),v.opt.rotate=c,a)x=Ei(v.rect,c),v.rect=x;else{var _g8=Jt.getRectFromLayer(T,t.name);v.rect=_g8||v.rect;}if(y){var _g9=y.get(t.name);if(_g9)for(var _u10=0,_m9=0;_u10<v.op.length;_u10+=3,_m9++)v.op[_u10]=_g9[_m9][0],v.op[_u10+1]=_g9[_m9][1];}if(P&&(f=v==null?void 0:v.opt)!=null&&f.thickness&&(v.opt.thickness=P),i&&!(d&&p&&a)){if(s){var _g10=v.op.map(function(u,m){var M=m%3;return M===0?u+s[0]:M===1?u+s[1]:u;});if(v.op=_g10,v.centerPos=[v.centerPos[0]+s[0],v.centerPos[1]+s[1]],v!=null&&v.opt&&(v.opt.translate=void 0),v.opt.eraserlines)for(var _i3=0,_Object$values2=Object.values(v.opt.eraserlines);_i3<_Object$values2.length;_i3++){var _u11=_Object$values2[_i3];var _m10=_u11.op;for(var _M6=0;_M6<_m10.length;_M6++){var _E3=_m10[_M6].map(function(A,w){return w%2?A+s[1]:A+s[0];});_u11.op[_M6]=_E3;}}}else if(Zt(c)){var _g11=v.op;if(Hg(_g11,v.centerPos,c),v.op=_g11,v!=null&&v.opt&&(v.opt.rotate=void 0),v.opt.eraserlines)for(var _i4=0,_Object$values3=Object.values(v.opt.eraserlines);_i4<_Object$values3.length;_i4++){var _u12=_Object$values3[_i4];var _m11=_u12.op;for(var _M7=0;_M7<_m11.length;_M7++)Kg(_m11[_M7],v.centerPos,c);}}}v&&n.setInfo(t.name,v);}}},{key:"getCenterPos",value:function getCenterPos(r,t){var e=t.worldPosition,n=t.worldScaling;return[(r.x+r.w/2-e[0])/n[0],(r.y+r.h/2-e[1])/n[1]];}},{key:"getRectFromLayer",value:function getRectFromLayer(r,t){var e=r.getElementsByName(t)[0];if(e){var n=e.getBoundingClientRect();return{x:Math.floor(n.x-Jt.SafeBorderPadding),y:Math.floor(n.y-Jt.SafeBorderPadding),w:Math.floor(n.width+Jt.SafeBorderPadding*2),h:Math.floor(n.height+Jt.SafeBorderPadding*2)};}}}]);}();et(Jt,"SafeBorderPadding",10);var vt=Jt;var br={exports:{}};br.exports;(function(h){var r=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function a(s,c){if(!i[s]){i[s]={};for(var d=0;d<s.length;d++)i[s][s.charAt(d)]=d;}return i[s][c];}var o={compressToBase64:function compressToBase64(s){if(s==null)return"";var c=o._compress(s,6,function(d){return e.charAt(d);});switch(c.length%4){default:case 0:return c;case 1:return c+"===";case 2:return c+"==";case 3:return c+"=";}},decompressFromBase64:function decompressFromBase64(s){return s==null?"":s==""?null:o._decompress(s.length,32,function(c){return a(e,s.charAt(c));});},compressToUTF16:function compressToUTF16(s){return s==null?"":o._compress(s,15,function(c){return t(c+32);})+" ";},decompressFromUTF16:function decompressFromUTF16(s){return s==null?"":s==""?null:o._decompress(s.length,16384,function(c){return s.charCodeAt(c)-32;});},//compress into uint8array (UCS-2 big endian format)
399
+ mc(c,s)))&&o.push(c);return o;}var Jn=xc,Tc=Object.prototype;function Mc(h){var r=h&&h.constructor,t=typeof r=="function"&&r.prototype||Tc;return h===t;}var Er=Mc;function Pc(h,r){return function(t){return h(r(t));};}var Zn=Pc,Oc=Zn,Ec=Oc(Object.keys,Object),Cc=Ec,Ac=Er,Rc=Cc,Ic=Object.prototype,Lc=Ic.hasOwnProperty;function wc(h){if(!Ac(h))return Rc(h);var r=[];for(var t in Object(h))Lc.call(h,t)&&t!="constructor"&&r.push(t);return r;}var bc=wc,Dc=Un,Nc=Xn;function Wc(h){return h!=null&&Nc(h.length)&&!Dc(h);}var Cr=Wc,Bc=Jn,Fc=bc,Uc=Cr;function jc(h){return Uc(h)?Bc(h):Fc(h);}var Ar=jc,$c=ir,zc=Ar;function Gc(h,r){return h&&$c(r,zc(r),h);}var Hc=Gc;function Kc(h){var r=[];if(h!=null)for(var t in Object(h))r.push(t);return r;}var Yc=Kc,Vc=he,Xc=Er,kc=Yc,Jc=Object.prototype,Zc=Jc.hasOwnProperty;function Qc(h){if(!Vc(h))return kc(h);var r=Xc(h),t=[];for(var e in h)e=="constructor"&&(r||!Zc.call(h,e))||t.push(e);return t;}var qc=Qc,_c=Jn,tf=qc,ef=Cr;function rf(h){return ef(h)?_c(h,!0):tf(h);}var Rr=rf,nf=ir,sf=Rr;function of(h,r){return h&&nf(r,sf(r),h);}var af=of,He={exports:{}};He.exports;(function(h,r){var t=ee,e=r&&!r.nodeType&&r,n=e&&!0&&h&&!h.nodeType&&h,i=n&&n.exports===e,a=i?t.Buffer:void 0,o=a?a.allocUnsafe:void 0;function s(c,d){if(d)return c.slice();var l=c.length,p=o?o(l):new c.constructor(l);return c.copy(p),p;}h.exports=s;})(He,He.exports);var lf=He.exports;function cf(h,r){var t=-1,e=h.length;for(r||(r=Array(e));++t<e;)r[t]=h[t];return r;}var ff=cf;function hf(h,r){for(var t=-1,e=h==null?0:h.length,n=0,i=[];++t<e;){var a=h[t];r(a,t,h)&&(i[n++]=a);}return i;}var Qn=hf;function uf(){return[];}var qn=uf,df=Qn,gf=qn,pf=Object.prototype,mf=pf.propertyIsEnumerable,_r=Object.getOwnPropertySymbols,vf=_r?function(h){return h==null?[]:(h=Object(h),df(_r(h),function(r){return mf.call(h,r);}));}:gf,Ir=vf,yf=ir,Sf=Ir;function xf(h,r){return yf(h,Sf(h),r);}var Tf=xf;function Mf(h,r){for(var t=-1,e=r.length,n=h.length;++t<e;)h[n+t]=r[t];return h;}var Lr=Mf,Pf=Zn,Of=Pf(Object.getPrototypeOf,Object),_n=Of,Ef=Lr,Cf=_n,Af=Ir,Rf=qn,If=Object.getOwnPropertySymbols,Lf=If?function(h){for(var r=[];h;)Ef(r,Af(h)),h=Cf(h);return r;}:Rf,ti=Lf,wf=ir,bf=ti;function Df(h,r){return wf(h,bf(h),r);}var Nf=Df,Wf=Lr,Bf=Fe;function Ff(h,r,t){var e=r(h);return Bf(h)?e:Wf(e,t(h));}var ei=Ff,Uf=ei,jf=Ir,$f=Ar;function zf(h){return Uf(h,$f,jf);}var ri=zf,Gf=ei,Hf=ti,Kf=Rr;function Yf(h){return Gf(h,Kf,Hf);}var Vf=Yf,Xf=ge,kf=ee,Jf=Xf(kf,"DataView"),Zf=Jf,Qf=ge,qf=ee,_f=Qf(qf,"Promise"),th=_f,eh=ge,rh=ee,nh=eh(rh,"Set"),ni=nh,ih=ge,sh=ee,oh=ih(sh,"WeakMap"),ah=oh,dr=Zf,gr=Mr,pr=th,mr=ni,vr=ah,ii=de,Ae=jn,tn="[object Map]",lh="[object Object]",en="[object Promise]",rn="[object Set]",nn="[object WeakMap]",sn="[object DataView]",ch=Ae(dr),fh=Ae(gr),hh=Ae(pr),uh=Ae(mr),dh=Ae(vr),ue=ii;(dr&&ue(new dr(new ArrayBuffer(1)))!=sn||gr&&ue(new gr())!=tn||pr&&ue(pr.resolve())!=en||mr&&ue(new mr())!=rn||vr&&ue(new vr())!=nn)&&(ue=function ue(h){var r=ii(h),t=r==lh?h.constructor:void 0,e=t?Ae(t):"";if(e)switch(e){case ch:return sn;case fh:return tn;case hh:return en;case uh:return rn;case dh:return nn;}return r;});var or=ue,gh=Object.prototype,ph=gh.hasOwnProperty;function mh(h){var r=h.length,t=new h.constructor(r);return r&&typeof h[0]=="string"&&ph.call(h,"index")&&(t.index=h.index,t.input=h.input),t;}var vh=mh,yh=ee,Sh=yh.Uint8Array,si=Sh,on=si;function xh(h){var r=new h.constructor(h.byteLength);return new on(r).set(new on(h)),r;}var wr=xh,Th=wr;function Mh(h,r){var t=r?Th(h.buffer):h.buffer;return new h.constructor(t,h.byteOffset,h.byteLength);}var Ph=Mh,Oh=/\w*$/;function Eh(h){var r=new h.constructor(h.source,Oh.exec(h));return r.lastIndex=h.lastIndex,r;}var Ch=Eh,an=Be,ln=an?an.prototype:void 0,cn=ln?ln.valueOf:void 0;function Ah(h){return cn?Object(cn.call(h)):{};}var Rh=Ah,Ih=wr;function Lh(h,r){var t=r?Ih(h.buffer):h.buffer;return new h.constructor(t,h.byteOffset,h.length);}var wh=Lh,bh=wr,Dh=Ph,Nh=Ch,Wh=Rh,Bh=wh,Fh="[object Boolean]",Uh="[object Date]",jh="[object Map]",$h="[object Number]",zh="[object RegExp]",Gh="[object Set]",Hh="[object String]",Kh="[object Symbol]",Yh="[object ArrayBuffer]",Vh="[object DataView]",Xh="[object Float32Array]",kh="[object Float64Array]",Jh="[object Int8Array]",Zh="[object Int16Array]",Qh="[object Int32Array]",qh="[object Uint8Array]",_h="[object Uint8ClampedArray]",tu="[object Uint16Array]",eu="[object Uint32Array]";function ru(h,r,t){var e=h.constructor;switch(r){case Yh:return bh(h);case Fh:case Uh:return new e(+h);case Vh:return Dh(h,t);case Xh:case kh:case Jh:case Zh:case Qh:case qh:case _h:case tu:case eu:return Bh(h,t);case jh:return new e();case $h:case Hh:return new e(h);case zh:return Nh(h);case Gh:return new e();case Kh:return Wh(h);}}var nu=ru,iu=he,fn=Object.create,su=/* @__PURE__ */function(){function h(){}return function(r){if(!iu(r))return{};if(fn)return fn(r);h.prototype=r;var t=new h();return h.prototype=void 0,t;};}(),ou=su,au=ou,lu=_n,cu=Er;function fu(h){return typeof h.constructor=="function"&&!cu(h)?au(lu(h)):{};}var hu=fu,uu=or,du=ne,gu="[object Map]";function pu(h){return du(h)&&uu(h)==gu;}var mu=pu,vu=mu,yu=sr,hn=Or,un=hn&&hn.isMap,Su=un?yu(un):vu,xu=Su,Tu=or,Mu=ne,Pu="[object Set]";function Ou(h){return Mu(h)&&Tu(h)==Pu;}var Eu=Ou,Cu=Eu,Au=sr,dn=Or,gn=dn&&dn.isSet,Ru=gn?Au(gn):Cu,oi=Ru,Iu=/* @__PURE__ */fe(oi),Lu=zn,wu=el,bu=Kn,Du=Hc,Nu=af,Wu=lf,Bu=ff,Fu=Tf,Uu=Nf,ju=ri,$u=Vf,zu=or,Gu=vh,Hu=nu,Ku=hu,Yu=Fe,Vu=Pr,Xu=xu,ku=he,Ju=oi,Zu=Ar,Qu=Rr,qu=1,_u=2,td=4,ai="[object Arguments]",ed="[object Array]",rd="[object Boolean]",nd="[object Date]",id="[object Error]",li="[object Function]",sd="[object GeneratorFunction]",od="[object Map]",ad="[object Number]",ci="[object Object]",ld="[object RegExp]",cd="[object Set]",fd="[object String]",hd="[object Symbol]",ud="[object WeakMap]",dd="[object ArrayBuffer]",gd="[object DataView]",pd="[object Float32Array]",md="[object Float64Array]",vd="[object Int8Array]",yd="[object Int16Array]",Sd="[object Int32Array]",xd="[object Uint8Array]",Td="[object Uint8ClampedArray]",Md="[object Uint16Array]",Pd="[object Uint32Array]",Ft={};Ft[ai]=Ft[ed]=Ft[dd]=Ft[gd]=Ft[rd]=Ft[nd]=Ft[pd]=Ft[md]=Ft[vd]=Ft[yd]=Ft[Sd]=Ft[od]=Ft[ad]=Ft[ci]=Ft[ld]=Ft[cd]=Ft[fd]=Ft[hd]=Ft[xd]=Ft[Td]=Ft[Md]=Ft[Pd]=!0;Ft[id]=Ft[li]=Ft[ud]=!1;function $e(h,r,t,e,n,i){var a,o=r&qu,s=r&_u,c=r&td;if(t&&(a=n?t(h,e,n,i):t(h)),a!==void 0)return a;if(!ku(h))return h;var d=Yu(h);if(d){if(a=Gu(h),!o)return Bu(h,a);}else{var l=zu(h),p=l==li||l==sd;if(Vu(h))return Wu(h,o);if(l==ci||l==ai||p&&!n){if(a=s||p?{}:Ku(h),!o)return s?Uu(h,Nu(a,h)):Fu(h,Du(a,h));}else{if(!Ft[l])return n?h:{};a=Hu(h,l,o);}}i||(i=new Lu());var y=i.get(h);if(y)return y;i.set(h,a),Ju(h)?h.forEach(function(v){a.add($e(v,r,t,v,h,i));}):Xu(h)&&h.forEach(function(v,T){a.set(T,$e(v,r,t,T,h,i));});var P=c?s?$u:ju:s?Qu:Zu,x=d?void 0:P(h);return wu(x||h,function(v,T){x&&(T=v,v=h[T]),bu(a,T,$e(v,r,t,T,h,i));}),a;}var Od=$e,Ed=Od,Cd=1,Ad=4;function Rd(h){return Ed(h,Cd|Ad);}var Id=Rd,Xt=/* @__PURE__ */fe(Id);var fi="1.1.12",Ld="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var h=window.__netlessUA||"";h+=" ".concat(Ld,"@").concat(fi),window.__netlessUA=h;}var re={syncOpt:{interval:500},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:1e3},bezier:{combineUnitTime:100},pencilEraser:{useBitMap:!0},strokeWidth:{min:1,max:10}};function ae(h){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=h.length;if(t<2)return"";var e=h[0],n=h[1];if(t===2)return"M".concat(pe(e),"L").concat(pe(n));var i="";for(var a=2,o=t-1;a<o;a++)e=h[a],n=h[a+1],i+=me(e,n);return r?"M".concat(me(h[0],h[1]),"Q").concat(pe(h[1])).concat(me(h[1],h[2]),"T").concat(i).concat(me(h[t-1],h[0])).concat(me(h[0],h[1]),"Z"):"M".concat(pe(h[0]),"Q").concat(pe(h[1])).concat(me(h[1],h[2])).concat(h.length>3?"T":"").concat(i,"L").concat(pe(h[t-1]));}var Jt=/*#__PURE__*/function(){function Jt(r){_classCallCheck(this,Jt);et(this,"syncUnitTime",re.syncOpt.interval);et(this,"vNodes");et(this,"drawLayer");et(this,"fullLayer");et(this,"workId");var t=r.vNodes,e=r.fullLayer,n=r.drawLayer,i=r.workId,a=r.toolsOpt;this.vNodes=t,this.fullLayer=e,this.drawLayer=n,this.workId=i,this.syncUnitTime=a.syncUnitTime||this.syncUnitTime;}return _createClass(Jt,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return r.reduce(function(e,n){var i=e[e.length-1];return(n&&!i||n&&i&&!n.isNear(i,t))&&e.push(n),e;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(r){this.workId=r;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(r){var n,i,a;this.workOptions=r,this.syncUnitTime=r.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),e=t&&((i=this.vNodes)==null?void 0:i.get(t))||void 0;t&&e&&(e.opt=r,(a=this.vNodes)==null||a.setInfo(t,e));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(r){var n,i;var t;var e=(n=this.workId)==null?void 0:n.toString();if(e&&r){var a=this.fullLayer.getElementsByName(e)||this.drawLayer&&this.drawLayer.getElementsByName(e)||[];if(a.length!==1)return;var o=a[0],s=r.pos,c=r.zIndex,d=r.scale,l=r.angle,p=r.translate,y={};Zt(c)&&(y.zIndex=c),s&&(y.pos=[s[0],s[1]]),d&&(y.scale=d),l&&(y.rotate=l),p&&(y.translate=p),o.attr(y);var P=o==null?void 0:o.getBoundingClientRect();return P&&(t=Pt(t,{x:Math.floor(P.x-Jt.SafeBorderPadding),y:Math.floor(P.y-Jt.SafeBorderPadding),w:Math.floor(P.width+Jt.SafeBorderPadding*2),h:Math.floor(P.height+Jt.SafeBorderPadding*2)})),(i=this.vNodes)==null||i.setInfo(e,{rect:t,centerPos:s}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(r){var t=r.group,e=r.eraserlines,n=r.pos,i=r.layer,_r$isClear=r.isClear,a=_r$isClear===void 0?!0:_r$isClear,o=!!i.parent.gl;var _iterator13=_createForOfIteratorHelper(e),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var s=_step13.value;var c=s.thickness,d=s.op;var _iterator14=_createForOfIteratorHelper(d),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var l=_step14.value;var p=l.map(function(T,f){return f%2?T-n[1]:T-n[0];}),y=this.computEraserPoints(p,c),P=ae(y,!0),x={pos:[0,0],d:P,fillColor:"rgba(0,0,0,1)"},v=new ce(x);a&&(v.addEventListener("beforerender",function(_ref165){var T=_ref165.detail;var f=T.context;o?f.blendFuncSeparate(f.ZERO,f.ZERO,f.ZERO,f.ZERO):f.globalCompositeOperation="destination-out";}),v.addEventListener("afterrender",function(_ref166){var T=_ref166.detail;var f=T.context;o?f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA):f.globalCompositeOperation="source-over";})),t.append(v);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}},{key:"computEraserPoints",value:function computEraserPoints(r,t){var e=Math.ceil(t/2);return r.length===2?this.computDot(r,e):this.computLine(r,e);}},{key:"computDot",value:function computDot(r,t){var e=new xt(r[0],r[1]);return xt.GetDotStroke(e,t,8);}},{key:"computLine",value:function computLine(r,t){var e=[],n=[];var i,a;for(var o=0;o<r.length;o+=2){var s=new xt(r[o],r[o+1]);var c=void 0;if(o==r.length-2){var d=new xt(r[o-2],r[o-1]);c=_.Sub(s,d).uni(),i=s;}else{o===0&&(a=s);var _d4=new xt(r[o+2],r[o+3]);c=_.Sub(_d4,s).uni();}if(c){var _d5=_.Per(c).mul(t);e.push(xt.Sub(s,_d5)),n.push(xt.Add(s,_d5));}}if(i&&a){var _o3=xt.GetSemicircleStroke(i,e[e.length-1],-1,8),_s4=xt.GetSemicircleStroke(a,n[0],-1,8);return e.concat(_o3,n.reverse(),_s4);}return[];}},{key:"replace",value:function replace(r,t,e){var _this61=this;var o;var n=r.getElementsByName(t),i=n.length;if(i){if(i>1)for(var s=1;s<n.length;s++)r.removeChild(n[s]),n[s].disconnect();e?r.replaceChild(e,n[0]):r.removeChild(n[0]),n[0].disconnect();}else e&&r.append(e);this.fullLayer===r?(o=this.drawLayer)==null||o.getElementsByName(t).forEach(function(s){var c;(c=_this61.drawLayer)==null||c.removeChild(s),s.disconnect();}):this.fullLayer.getElementsByName(t).forEach(function(s){_this61.fullLayer.removeChild(s),s.disconnect();});}}],[{key:"updateNodeOpt",value:function updateNodeOpt(r){var f;var t=r.node,e=r.opt,n=r.vNodes,i=r.willSerializeData,a=r.targetNode,o=e.zIndex,s=e.translate,c=e.angle,d=e.originPoint,l=e.scenePoint,p=e.scale,y=e.pointMap,P=e.thickness;var x;var v=a&&Xt(a)||n.get(t.name);if(!v)return;Zt(o)&&(t.setAttribute("zIndex",o),v.opt.zIndex=o);var T=t.parent;if(T){if(d&&p&&a){var g=[v.op[0],v.op[1]];Ur(v.op,l,p,s);var u=[v.op[0],v.op[1]],m=[u[0]-g[0],u[1]-g[1]];if(v.centerPos=[v.centerPos[0]+m[0],v.centerPos[1]+m[1]],v.opt.translate=void 0,v.opt.scale=void 0,v.opt.eraserlines)for(var _i2=0,_Object$values=Object.values(v.opt.eraserlines);_i2<_Object$values.length;_i2++){var M=_Object$values[_i2];var E=M.op,A=M.thickness;M.thickness=A*Math.max(p[0],p[1]);for(var w=0;w<E.length;w++)jr(E[w],l,p,s);}}else if(s){if(t.setAttribute("translate",s),v.opt.translate=s,a){var _g6=[s[0]*T.worldScaling[0],s[1]*T.worldScaling[1]];x=Sr(v.rect,_g6),v.rect=x;}else{var _g7=Jt.getRectFromLayer(T,t.name);v.rect=_g7||v.rect;}}else if(Zt(c))if(t.setAttribute("rotate",c),v.opt.rotate=c,a)x=Ei(v.rect,c),v.rect=x;else{var _g8=Jt.getRectFromLayer(T,t.name);v.rect=_g8||v.rect;}if(y){var _g9=y.get(t.name);if(_g9)for(var _u10=0,_m9=0;_u10<v.op.length;_u10+=3,_m9++)v.op[_u10]=_g9[_m9][0],v.op[_u10+1]=_g9[_m9][1];}if(P&&(f=v==null?void 0:v.opt)!=null&&f.thickness&&(v.opt.thickness=P),i&&!(d&&p&&a)){if(s){var _g10=v.op.map(function(u,m){var M=m%3;return M===0?u+s[0]:M===1?u+s[1]:u;});if(v.op=_g10,v.centerPos=[v.centerPos[0]+s[0],v.centerPos[1]+s[1]],v!=null&&v.opt&&(v.opt.translate=void 0),v.opt.eraserlines)for(var _i3=0,_Object$values2=Object.values(v.opt.eraserlines);_i3<_Object$values2.length;_i3++){var _u11=_Object$values2[_i3];var _m10=_u11.op;for(var _M6=0;_M6<_m10.length;_M6++){var _E3=_m10[_M6].map(function(A,w){return w%2?A+s[1]:A+s[0];});_u11.op[_M6]=_E3;}}}else if(Zt(c)){var _g11=v.op;if(Hg(_g11,v.centerPos,c),v.op=_g11,v!=null&&v.opt&&(v.opt.rotate=void 0),v.opt.eraserlines)for(var _i4=0,_Object$values3=Object.values(v.opt.eraserlines);_i4<_Object$values3.length;_i4++){var _u12=_Object$values3[_i4];var _m11=_u12.op;for(var _M7=0;_M7<_m11.length;_M7++)Kg(_m11[_M7],v.centerPos,c);}}}v&&n.setInfo(t.name,v);}}},{key:"getCenterPos",value:function getCenterPos(r,t){var e=t.worldPosition,n=t.worldScaling;return[(r.x+r.w/2-e[0])/n[0],(r.y+r.h/2-e[1])/n[1]];}},{key:"getRectFromLayer",value:function getRectFromLayer(r,t){var e=r.getElementsByName(t)[0];if(e){var n=e.getBoundingClientRect();return{x:Math.floor(n.x-Jt.SafeBorderPadding),y:Math.floor(n.y-Jt.SafeBorderPadding),w:Math.floor(n.width+Jt.SafeBorderPadding*2),h:Math.floor(n.height+Jt.SafeBorderPadding*2)};}}}]);}();et(Jt,"SafeBorderPadding",10);var vt=Jt;var br={exports:{}};br.exports;(function(h){var r=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function a(s,c){if(!i[s]){i[s]={};for(var d=0;d<s.length;d++)i[s][s.charAt(d)]=d;}return i[s][c];}var o={compressToBase64:function compressToBase64(s){if(s==null)return"";var c=o._compress(s,6,function(d){return e.charAt(d);});switch(c.length%4){default:case 0:return c;case 1:return c+"===";case 2:return c+"==";case 3:return c+"=";}},decompressFromBase64:function decompressFromBase64(s){return s==null?"":s==""?null:o._decompress(s.length,32,function(c){return a(e,s.charAt(c));});},compressToUTF16:function compressToUTF16(s){return s==null?"":o._compress(s,15,function(c){return t(c+32);})+" ";},decompressFromUTF16:function decompressFromUTF16(s){return s==null?"":s==""?null:o._decompress(s.length,16384,function(c){return s.charCodeAt(c)-32;});},//compress into uint8array (UCS-2 big endian format)
400
400
  compressToUint8Array:function compressToUint8Array(s){for(var c=o.compress(s),d=new Uint8Array(c.length*2),l=0,p=c.length;l<p;l++){var y=c.charCodeAt(l);d[l*2]=y>>>8,d[l*2+1]=y%256;}return d;},//decompress from uint8array (UCS-2 big endian format)
401
401
  decompressFromUint8Array:function decompressFromUint8Array(s){if(s==null)return o.decompress(s);for(var c=new Array(s.length/2),d=0,l=c.length;d<l;d++)c[d]=s[d*2]*256+s[d*2+1];var p=[];return c.forEach(function(y){p.push(t(y));}),o.decompress(p.join(""));},//compress into a string that is already URI encoded
402
402
  compressToEncodedURIComponent:function compressToEncodedURIComponent(s){return s==null?"":o._compress(s,6,function(c){return n.charAt(c);});},//decompress from an output of compressToEncodedURIComponent
@@ -435,5 +435,5 @@ et(Se,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.fr
435
435
  * @param {Array} cp2 控制点2
436
436
  */},{key:"threeBezier",value:function threeBezier(r,t,e,n,i){var a=t.x*(1-r)*(1-r)*(1-r)+3*e.x*r*(1-r)*(1-r)+3*n.x*r*r*(1-r)+i.x*r*r*r,o=t.y*(1-r)*(1-r)*(1-r)+3*e.y*r*(1-r)*(1-r)+3*n.y*r*r*(1-r)+i.y*r*r*r;return new _(a,o);}}]);}();var Ti=/*#__PURE__*/function(_vt10){function Ti(t){var _this80;_classCallCheck(this,Ti);_this80=_callSuper(this,Ti,[t]);et(_this80,"canRotate",!1);et(_this80,"scaleType",jt.all);et(_this80,"toolsType",ut.SpeechBalloon);et(_this80,"ratio",0.8);et(_this80,"tmpPoints",[]);et(_this80,"workOptions");et(_this80,"oldRect");et(_this80,"syncTimestamp");_this80.workOptions=t.toolsOpt,_this80.syncTimestamp=0,_this80.syncUnitTime=50;return _this80;}_inherits(Ti,_vt10);return _createClass(Ti,[{key:"consume",value:function consume(t){var y;var e=t.data,n=t.isFullWork,i=t.isSubWorker,a=t.isMainThread,o=(y=e==null?void 0:e.workId)==null?void 0:y.toString();if(!o)return{type:ot.None};var s=e.op,c=s==null?void 0:s.length;if(!c||c<2)return{type:ot.None};var d;if(this.tmpPoints.length===0?(this.tmpPoints=[new xt(s[0],s[1])],d=!1):d=this.updateTempPoints(s),!d)return{type:ot.None};var l;if(i||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;l=this.draw({workId:o,layer:P,isDrawing:!0});}if(!i){var _P3=Date.now();return _P3-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P3,_objectSpread({type:ot.DrawWork,dataType:Mt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:ot.None};}var p=Pt(l,this.oldRect);return this.oldRect=l,_objectSpread({rect:p,type:ot.DrawWork,dataType:Mt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:ot.RemoveNode,removeIds:[t]};var e=this.fullLayer,n=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(s){return[].concat(_toConsumableArray(s.XY),[0]);}).flat(1),a=Qt(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&vt.getCenterPos(n,e)}),_objectSpread({rect:n,type:ot.FullWork,dataType:Mt.Local,ops:a,isSync:!0},this.baseConsumeResult);}},{key:"draw",value:function draw(t){var e=t.workId,n=t.layer,_this$workOptions11=this.workOptions,i=_this$workOptions11.strokeColor,a=_this$workOptions11.fillColor,o=_this$workOptions11.thickness,s=_this$workOptions11.zIndex,c=_this$workOptions11.placement,d=_this$workOptions11.scale,l=_this$workOptions11.rotate,p=_this$workOptions11.translate,y=_this$workOptions11.strokeType,P=_this$workOptions11.eraserlines,_this$computDrawPoint7=this.computDrawPoints(o,c),x=_this$computDrawPoint7.rect,v=_this$computDrawPoint7.pos,T=_this$computDrawPoint7.points,f={points:T.map(function(E){return E.XY;}),lineWidth:o,fillColor:a!=="transparent"&&a||void 0,strokeColor:i,normalize:!0,className:"".concat(v[0],",").concat(v[1]),close:!0,lineJoin:"round",lineCap:"round",lineDash:y===Lt.Dotted?[1,o*2]:y===Lt.LongDotted?[o,o*2]:void 0},g={name:e,id:e,zIndex:s,pos:v,anchor:[0.5,0.5],size:[x.w,x.h]};d&&(g.scale=d),l&&(g.rotate=l),p&&(g.translate=p);var u=new kt(g),m=new le(_objectSpread(_objectSpread({},f),{},{pos:[0,0]}));u.append(m),P&&this.drawEraserlines({group:u,eraserlines:P,pos:v,layer:n}),this.replace(n,e,u);var M=u.getBoundingClientRect();return{x:Math.floor(M.x-vt.SafeBorderPadding),y:Math.floor(M.y-vt.SafeBorderPadding),w:Math.floor(M.width+vt.SafeBorderPadding*2),h:Math.floor(M.height+vt.SafeBorderPadding*2)};}},{key:"transformControlPoints",value:function transformControlPoints(t){var e=Bt(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{var n=e.y+e.h*this.ratio;return[new _(e.x,e.y,0),new _(e.x+e.w,e.y,0),new _(e.x+e.w,n,0),new _(e.x,n,0)];}case"top":case"topLeft":case"topRight":{var _n4=e.y+e.h*(1-this.ratio);return[new _(e.x,_n4,0),new _(e.x+e.w,_n4,0),new _(e.x+e.w,e.y+e.h,0),new _(e.x,e.y+e.h,0)];}case"left":case"leftBottom":case"leftTop":{var _n5=e.x+e.w*(1-this.ratio);return[new _(_n5,e.y,0),new _(e.x+e.w,e.y,0),new _(e.x+e.w,e.y+e.h,0),new _(_n5,e.y+e.h,0)];}case"right":case"rightBottom":case"rightTop":{var _n6=e.x+e.w*this.ratio;return[new _(e.x,e.y,0),new _(_n6,e.y,0),new _(_n6,e.y+e.h,0),new _(e.x,e.y+e.h,0)];}}}},{key:"computDrawPoints",value:function computDrawPoints(t,e){var n=Bt(this.tmpPoints),i=this.transformControlPoints(e),a=Math.floor(n.w*0.1),o=Math.floor(n.h*0.1),s=[],c=_.Add(i[0],new _(0,o,0)),d=_.Add(i[0],new _(a,0,0)),l=_t.getBezierPoints(10,c,i[0],d),p=_.Sub(i[1],new _(a,0,0)),y=_.Add(i[1],new _(0,o,0)),P=_t.getBezierPoints(10,p,i[1],y),x=_.Sub(i[2],new _(0,o,0)),v=_.Sub(i[2],new _(a,0,0)),T=_t.getBezierPoints(10,x,i[2],v),f=_.Add(i[3],new _(a,0,0)),g=_.Sub(i[3],new _(0,o,0)),u=_t.getBezierPoints(10,f,i[3],g),m=a*(1-this.ratio)*10,M=o*(1-this.ratio)*10;switch(e){case"bottom":{var w=_.Sub(i[2],new _(a*5-m/2,0,0)),O=_.Sub(i[2],new _(a*5,-M,0)),L=_.Sub(i[2],new _(a*5+m/2,0,0));s.push.apply(s,[O,L].concat(_toConsumableArray(u),_toConsumableArray(l),_toConsumableArray(P),_toConsumableArray(T),[w]));break;}case"bottomRight":{var _w11=_.Sub(i[2],new _(a*1.1,0,0)),_O11=_.Sub(i[2],new _(a*1.1+m/2,-M,0)),_L8=_.Sub(i[2],new _(a*1.1+m,0,0));s.push.apply(s,[_O11,_L8].concat(_toConsumableArray(u),_toConsumableArray(l),_toConsumableArray(P),_toConsumableArray(T),[_w11]));break;}case"bottomLeft":{var _w12=_.Add(i[3],new _(a*1.1+m,0,0)),_O12=_.Add(i[3],new _(a*1.1+m/2,M,0)),_L9=_.Add(i[3],new _(a*1.1,0,0));s.push.apply(s,[_O12,_L9].concat(_toConsumableArray(u),_toConsumableArray(l),_toConsumableArray(P),_toConsumableArray(T),[_w12]));break;}case"top":{var _w13=_.Sub(i[1],new _(a*5-m/2,0,0)),_O13=_.Sub(i[1],new _(a*5,M,0)),_L10=_.Sub(i[1],new _(a*5+m/2,0,0));s.push.apply(s,[_O13,_w13].concat(_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(l),[_L10]));break;}case"topRight":{var _w14=_.Sub(i[1],new _(a*1.1,0,0)),_O14=_.Sub(i[1],new _(a*1.1+m/2,M,0)),_L11=_.Sub(i[1],new _(a*1.1+m,0,0));s.push.apply(s,[_O14,_w14].concat(_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(l),[_L11]));break;}case"topLeft":{var _w15=_.Add(i[0],new _(a*1.1+m,0,0)),_O15=_.Add(i[0],new _(a*1.1+m/2,-M,0)),_L12=_.Add(i[0],new _(a*1.1,0,0));s.push.apply(s,[_O15,_w15].concat(_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(l),[_L12]));break;}case"left":{var _w16=_.Add(i[0],new _(0,o*5-M/2,0)),_O16=_.Add(i[0],new _(-m,o*5,0)),_L13=_.Add(i[0],new _(0,o*5+M/2,0));s.push.apply(s,[_O16,_w16].concat(_toConsumableArray(l),_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),[_L13]));break;}case"leftTop":{var _w17=_.Add(i[0],new _(0,o*1.1,0)),_O17=_.Add(i[0],new _(-m,o*1.1+M/2,0)),_L14=_.Add(i[0],new _(0,o*1.1+M,0));s.push.apply(s,[_O17,_w17].concat(_toConsumableArray(l),_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),[_L14]));break;}case"leftBottom":{var _w18=_.Sub(i[3],new _(0,o*1.1+M,0)),_O18=_.Sub(i[3],new _(m,o*1.1+M/2,0)),_L15=_.Sub(i[3],new _(0,o*1.1,0));s.push.apply(s,[_O18,_w18].concat(_toConsumableArray(l),_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),[_L15]));break;}case"right":{var _w19=_.Add(i[1],new _(0,o*5-M/2,0)),_O19=_.Add(i[1],new _(m,o*5,0)),_L16=_.Add(i[1],new _(0,o*5+M/2,0));s.push.apply(s,[_O19,_L16].concat(_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(l),_toConsumableArray(P),[_w19]));break;}case"rightTop":{var _w20=_.Add(i[1],new _(0,o*1.1,0)),_O20=_.Add(i[1],new _(m,o*1.1+M/2,0)),_L17=_.Add(i[1],new _(0,o*1.1+M,0));s.push.apply(s,[_O20,_L17].concat(_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(l),_toConsumableArray(P),[_w20]));break;}case"rightBottom":{var _w21=_.Sub(i[2],new _(0,o*1.1+M,0)),_O21=_.Sub(i[2],new _(-m,o*1.1+M/2,0)),_L18=_.Sub(i[2],new _(0,o*1.1,0));s.push.apply(s,[_O21,_L18].concat(_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(l),_toConsumableArray(P),[_w21]));break;}}var E=Bt(this.tmpPoints,t),A=[Math.floor(E.x+E.w/2),Math.floor(E.y+E.h/2)];return{rect:E,pos:A,points:s};}},{key:"updateTempPoints",value:function updateTempPoints(t){var e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],a=this.workOptions.thickness;if(i.isNear(n,a)||xt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var s,c;var e=t.op,n=t.isFullWork,i=(s=this.workId)==null?void 0:s.toString();if(!i)return;this.tmpPoints.length=0;for(var d=0;d<e.length;d+=3)this.tmpPoints.push(new xt(e[d],e[d+1],e[d+2]));var a=n?this.fullLayer:this.drawLayer||this.fullLayer,o=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=o,(c=this.vNodes)==null||c.setInfo(i,{rect:o,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&vt.getCenterPos(o,a)}),o;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var P;var e=t.node,n=t.opt,i=t.vNodes,a=n.strokeColor,o=n.fillColor,s=n.toolsType,c=n.placement,d=n.strokeType,l=i.get(e.name),p=l==null?void 0:l.opt;var y=e;return e.tagName==="GROUP"&&(y=e.children[0]),a&&(y.setAttribute("strokeColor",a),p!=null&&p.strokeColor&&(p.strokeColor=a)),o&&(o==="transparent"?y.setAttribute("fillColor","rgba(0,0,0,0)"):y.setAttribute("fillColor",o),p!=null&&p.fillColor&&(p.fillColor=o)),s===ut.SpeechBalloon&&c&&(p.placement=c),d&&l!=null&&l.opt&&(P=l.opt)!=null&&P.strokeType&&(l.opt.strokeType=d),l&&i.setInfo(e.name,_objectSpread(_objectSpread({},l),{},{opt:p})),vt.updateNodeOpt(t);}}]);}(vt);var Bg=de,Fg=ne,Ug="[object Boolean]";function jg(h){return h===!0||h===!1||Fg(h)&&Bg(h)==Ug;}var $g=jg,ye=/* @__PURE__ */fe($g);var Ne=/*#__PURE__*/function(_vt11){function Ne(t){var _this81;_classCallCheck(this,Ne);_this81=_callSuper(this,Ne,[t]);et(_this81,"canRotate",!0);et(_this81,"scaleType",jt.all);et(_this81,"toolsType",ut.Image);et(_this81,"tmpPoints",[]);et(_this81,"workOptions");et(_this81,"oldRect");_this81.workOptions=t.toolsOpt,_this81.scaleType=Ne.getScaleType(_this81.workOptions);return _this81;}_inherits(Ne,_vt11);return _createClass(Ne,[{key:"consume",value:function consume(){return{type:ot.None};}},{key:"consumeAll",value:function consumeAll(){return{type:ot.None};}},{key:"draw",value:function draw(t){var e=t.layer,n=t.workId,i=t.replaceId,a=t.imageBitmap,_this$workOptions12=this.workOptions,o=_this$workOptions12.centerX,s=_this$workOptions12.centerY,c=_this$workOptions12.width,d=_this$workOptions12.height,l=_this$workOptions12.rotate,p=_this$workOptions12.zIndex,y=_this$workOptions12.eraserlines,P=new kt({anchor:[0.5,0.5],pos:[o,s],name:n,size:[c,d],zIndex:p,rotate:l}),x={anchor:[0.5,0.5],pos:[0,0],size:[c,d],texture:a};a||(x.bgcolor="rgba(0,0,0,0.3)");var v=new es(x);P.append(v),y&&this.drawEraserlines({group:P,eraserlines:y,pos:[o,s],layer:e}),this.replace(e,i||n,P);var T=P.getBoundingClientRect();if(T)return{x:Math.floor(T.x-vt.SafeBorderPadding),y:Math.floor(T.y-vt.SafeBorderPadding),w:Math.floor(T.width+vt.SafeBorderPadding*2),h:Math.floor(T.height+vt.SafeBorderPadding*2)};}},{key:"consumeService",value:function consumeService(){}},{key:"consumeServiceAsync",value:function(){var _consumeServiceAsync=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(t){var d,l,p,y,e,n,i,_this$workOptions13,a,o,s,c,P,x;return _regeneratorRuntime().wrap(function _callee23$(_context25){while(1)switch(_context25.prev=_context25.next){case 0:e=t.isFullWork,n=t.replaceId,i=t.worker,_this$workOptions13=this.workOptions,a=_this$workOptions13.src,o=_this$workOptions13.uuid,s=((d=this.workId)==null?void 0:d.toString())||o,c=e?this.fullLayer:this.drawLayer||this.fullLayer;if(!a){_context25.next=8;break;}_context25.next=4;return i.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:s,isSubWorker:i instanceof Di});case 4:P=_context25.sent;if(!P){_context25.next=8;break;}x=this.draw({workId:s,layer:c,replaceId:n,imageBitmap:P});return _context25.abrupt("return",(this.oldRect=s&&((p=(l=this.vNodes)==null?void 0:l.get(s))==null?void 0:p.rect)||void 0,(y=this.vNodes)==null||y.setInfo(s,{rect:x,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:x&&vt.getCenterPos(x,c)}),x));case 8:case"end":return _context25.stop();}},_callee23,this);}));function consumeServiceAsync(_x27){return _consumeServiceAsync.apply(this,arguments);}return consumeServiceAsync;}()},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"getScaleType",value:function getScaleType(t){var e=t.uniformScale,n=t.rotate;return e!==!1||n&&Math.abs(n)%90>0?jt.proportional:jt.all;}},{key:"updateNodeOpt",value:function updateNodeOpt(t){var e=t.node,n=t.opt,i=t.vNodes,a=t.targetNode,o=n.translate,s=n.originPoint,c=n.scenePoint,d=n.scale,l=n.angle,p=n.isLocked,y=n.zIndex,P=n.strokeColor,x=a&&Xt(a)||i.get(e.name);if(!x)return;var v=e.parent;if(v){if(P&&(x.opt.strokeColor=P),Zt(y)&&(e.setAttribute("zIndex",y),x.opt.zIndex=y),ye(p)&&(x.opt.locked=p),s&&c&&d&&o){var _x$opt=x.opt,_T33=_x$opt.centerX,_f29=_x$opt.centerY,g=_x$opt.width,u=_x$opt.height,m=_x$opt.uniformScale,M=m!==!1?[d[0],d[0]]:d,E=[_T33,_f29],A=[_T33,_f29];Ur(A,c,M,o);var w=[A[0]-E[0],A[1]-E[1]];if(x.centerPos=[x.centerPos[0]+w[0],x.centerPos[1]+w[1]],x.opt.width=Math.round(g*M[0]),x.opt.height=Math.round(u*M[1]),x.opt.centerX=A[0],x.opt.centerY=A[1],x.opt.eraserlines)for(var _i5=0,_Object$values4=Object.values(x.opt.eraserlines);_i5<_Object$values4.length;_i5++){var O=_Object$values4[_i5];var L=O.op,b=O.thickness;O.thickness=b*Math.max(d[0],d[1]);for(var I=0;I<L.length;I++)jr(L[I],c,d,o);}}else if(o){if(x.opt.centerX=x.opt.centerX+o[0],x.opt.centerY=x.opt.centerY+o[1],x.centerPos=[x.centerPos[0]+o[0],x.centerPos[1]+o[1]],x.opt.eraserlines)for(var _i6=0,_Object$values5=Object.values(x.opt.eraserlines);_i6<_Object$values5.length;_i6++){var _T34=_Object$values5[_i6];var _f30=_T34.op;for(var _g12=0;_g12<_f30.length;_g12++){var _u13=_f30[_g12].map(function(m,M){return M%2?m+o[1]:m+o[0];});_T34.op[_g12]=_u13;}}}else if(Zt(l))if(x.opt.rotate=l,x.scaleType=Ne.getScaleType(x.opt),a){var _T35=Ei(x.rect,l);x.rect=_T35;}else{var _T36=vt.getRectFromLayer(v,e.name);x.rect=_T36||x.rect;}return x&&i.setInfo(e.name,x),x==null?void 0:x.rect;}}}]);}(vt);var Mi=/*#__PURE__*/function(_vt12){function Mi(t){var _this82;_classCallCheck(this,Mi);_this82=_callSuper(this,Mi,[t]);et(_this82,"canRotate",!1);et(_this82,"scaleType",jt.both);et(_this82,"toolsType",ut.Straight);et(_this82,"tmpPoints",[]);et(_this82,"workOptions");et(_this82,"oldRect");et(_this82,"straightTipWidth");et(_this82,"syncTimestamp");_this82.workOptions=t.toolsOpt,_this82.straightTipWidth=_this82.workOptions.thickness/2,_this82.syncTimestamp=0,_this82.syncUnitTime=50;return _this82;}_inherits(Mi,_vt12);return _createClass(Mi,[{key:"consume",value:function consume(t){var e=t.data,n=t.isFullWork,i=t.isSubWorker,a=t.isMainThread,o=this.workId,s=e.op,c=s==null?void 0:s.length;if(!c||c<2)return{type:ot.None};var d;if(this.tmpPoints.length===0?(this.tmpPoints=[new xt(s[0],s[1])],d=!1):d=this.updateTempPoints(s),!d)return{type:ot.None};var l;if(i||a){var y=n?this.fullLayer:this.drawLayer||this.fullLayer;l=this.draw({workId:o,layer:y});}if(!i){var _y12=Date.now();return _y12-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_y12,_objectSpread({type:ot.DrawWork,dataType:Mt.Local,op:this.tmpPoints.map(function(P){return[].concat(_toConsumableArray(P.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:ot.None};}var p=Pt(l,this.oldRect);return this.oldRect=l,_objectSpread({rect:p,type:ot.DrawWork,dataType:Mt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:ot.RemoveNode,removeIds:[t]};var e=this.fullLayer,n=this.draw({workId:t,layer:e});this.oldRect=n;var i=this.tmpPoints.map(function(s){return[].concat(_toConsumableArray(s.XY),[0]);}).flat(1),a=Qt(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&vt.getCenterPos(n,e)}),_objectSpread({rect:n,type:ot.FullWork,dataType:Mt.Local,ops:a,isSync:!0},this.baseConsumeResult);}},{key:"draw",value:function draw(t){var e=t.workId,n=t.layer,_this$workOptions14=this.workOptions,i=_this$workOptions14.strokeColor,a=_this$workOptions14.thickness,o=_this$workOptions14.zIndex,s=_this$workOptions14.scale,c=_this$workOptions14.rotate,d=_this$workOptions14.translate,l=_this$workOptions14.strokeType,p=_this$workOptions14.eraserlines,y=n.worldPosition,P=n.worldScaling,_this$computDrawPoint8=this.computDrawPoints(a,l),x=_this$computDrawPoint8.d,v=_this$computDrawPoint8.rect,T=_this$computDrawPoint8.isDot,f=[v.x+v.w/2,v.y+v.h/2],g=new kt({pos:f,anchor:[0.5,0.5],size:[v.w,v.h],name:e,id:e,normalize:!0,zIndex:o}),u={pos:[0,0],normalize:!0,d:x,fillColor:i,strokeColor:i,lineDash:l===Lt.Dotted&&!T?[1,a*2]:l===Lt.LongDotted&&!T?[a,a*2]:void 0,lineCap:l===Lt.Normal||T?void 0:"round",lineWidth:l===Lt.Normal||T?0:a};s&&(u.scale=s),c&&(u.rotate=c),d&&(u.translate=d);var m=new ce(u);if(g.append(m),p&&this.drawEraserlines({group:g,eraserlines:p,pos:f,layer:n}),this.replace(n,e,g),c||s||d){var E=m.getBoundingClientRect();return{x:Math.floor(E.x-vt.SafeBorderPadding),y:Math.floor(E.y-vt.SafeBorderPadding),w:Math.floor(E.width+vt.SafeBorderPadding*2),h:Math.floor(E.height+vt.SafeBorderPadding*2)};}return{x:Math.floor(v.x*P[0]+y[0]-vt.SafeBorderPadding),y:Math.floor(v.y*P[1]+y[1]-vt.SafeBorderPadding),w:Math.floor(v.w*P[0]+2*vt.SafeBorderPadding),h:Math.floor(v.h*P[1]+2*vt.SafeBorderPadding)};}},{key:"computDrawPoints",value:function computDrawPoints(t,e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t,e):this.computDotPoints(t);}},{key:"computFullPoints",value:function computFullPoints(t,e){var n=_.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),i=_.Per(n).mul(t/2),a=xt.Sub(this.tmpPoints[0],i),o=xt.Add(this.tmpPoints[0],i),s=xt.Sub(this.tmpPoints[1],i),c=xt.Add(this.tmpPoints[1],i),d=xt.GetSemicircleStroke(this.tmpPoints[1],s,-1,8),l=xt.GetSemicircleStroke(this.tmpPoints[0],o,-1,8),p=[a,s].concat(_toConsumableArray(d),[c,o],_toConsumableArray(l));var y;return e!==Lt.Normal?y=ae(this.tmpPoints,!1):y=ae(p,!0),{d:y,rect:Bt(p),isDot:!1,pos:this.tmpPoints[0].XY};}},{key:"computDotPoints",value:function computDotPoints(t){var e=xt.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:ae(e,!0),rect:Bt(e),isDot:!0,pos:this.tmpPoints[0].XY};}},{key:"updateTempPoints",value:function updateTempPoints(t){var e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],a=this.workOptions.thickness;if(i.isNear(n,a))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var s,c;var e=t.op,n=t.isFullWork,i=(s=this.workId)==null?void 0:s.toString();if(!i)return;this.tmpPoints.length=0;for(var d=0;d<e.length;d+=3)this.tmpPoints.push(new xt(e[d],e[d+1],e[d+2]));var a=n?this.fullLayer:this.drawLayer||this.fullLayer,o=this.draw({workId:i,layer:a});return this.oldRect=o,(c=this.vNodes)==null||c.setInfo(i,{rect:o,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&vt.getCenterPos(o,a)}),o;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var c,d;var e=t.node,n=t.opt,i=t.vNodes,a=n.strokeColor,o=n.strokeType,s=i.get(e.name);return a&&(e.tagName==="GROUP"?e.children.forEach(function(l){l.setAttribute("strokeColor",a),l.getAttribute("fillColor")&&l.setAttribute("fillColor",a);}):(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a)),(c=s==null?void 0:s.opt)!=null&&c.strokeColor&&(s.opt.strokeColor=a)),o&&s!=null&&s.opt&&(d=s.opt)!=null&&d.strokeType&&(s.opt.strokeType=o),s&&i.setInfo(e.name,s),vt.updateNodeOpt(t);}}]);}(vt);var ie=/*#__PURE__*/function(_vt13){function ie(t){var _this83;_classCallCheck(this,ie);_this83=_callSuper(this,ie,[t]);et(_this83,"canRotate",!1);et(_this83,"scaleType",jt.proportional);et(_this83,"toolsType",ut.Text);et(_this83,"tmpPoints",[]);et(_this83,"workOptions");et(_this83,"oldRect");_this83.workOptions=t.toolsOpt;return _this83;}_inherits(ie,_vt13);return _createClass(ie,[{key:"consume",value:function consume(){return{type:ot.None};}},{key:"consumeAll",value:function consumeAll(){return{type:ot.None};}},{key:"consumeService",value:function consumeService(){}},{key:"draw",value:function(){var _draw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(t){var e,n,i,_this$workOptions15,a,o,s,c,d,l,p,y,P,x,v,_T37,_f31;return _regeneratorRuntime().wrap(function _callee24$(_context26){while(1)switch(_context26.prev=_context26.next){case 0:e=t.workId,n=t.layer,i=t.isDrawLabel,_this$workOptions15=this.workOptions,a=_this$workOptions15.boxSize,o=_this$workOptions15.boxPoint,s=_this$workOptions15.zIndex,c=_this$workOptions15.eraserlines,d=n.worldPosition,l=n.worldScaling;if(!(!o||!a)){_context26.next=3;break;}return _context26.abrupt("return");case 3:p={name:e,id:e,pos:[o[0],o[1]],anchor:[0,0],size:a,zIndex:s},y=new kt(p),P={x:o[0],y:o[1],w:a[0],h:a[1]},x={x:Math.floor(P.x*l[0]+d[0]),y:Math.floor(P.y*l[1]+d[1]),w:Math.floor(P.w*l[0])+2,h:Math.floor(P.h*l[1])+2};if(!(this.replace(n,e,y),i&&n&&this.workOptions.text)){_context26.next=11;break;}_context26.next=7;return ie.createLabels(this.workOptions,n,x);case 7:v=_context26.sent;_T37=v.labels;_f31=v.maxWidth;y.append.apply(y,_toConsumableArray(_T37)),x.w=Math.ceil(Math.max(_f31*n.worldScaling[0],x.w));case 11:return _context26.abrupt("return",(c&&this.drawEraserlines({group:y,eraserlines:c,pos:[o[0],o[1]],layer:n}),x));case 12:case"end":return _context26.stop();}},_callee24,this);}));function draw(_x28){return _draw3.apply(this,arguments);}return draw;}()},{key:"consumeServiceAsync",value:function(){var _consumeServiceAsync2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(t){var c,d,l,p,e,n,i,a,o,s;return _regeneratorRuntime().wrap(function _callee25$(_context27){while(1)switch(_context27.prev=_context27.next){case 0:e=(c=this.workId)==null?void 0:c.toString();if(e){_context27.next=3;break;}return _context27.abrupt("return");case 3:n=t.isFullWork,i=t.replaceId,a=t.isDrawLabel;this.oldRect=i&&((l=(d=this.vNodes)==null?void 0:d.get(i))==null?void 0:l.rect)||void 0;o=n?this.fullLayer:this.drawLayer||this.fullLayer;_context27.next=8;return this.draw({workId:e,layer:o,isDrawLabel:_typeof(a)>"u"&&this.workOptions.workState===It.Done||a});case 8:s=_context27.sent;return _context27.abrupt("return",((p=this.vNodes)==null||p.setInfo(e,{rect:s,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&vt.getCenterPos(s,o)}),s));case 10:case"end":return _context27.stop();}},_callee25,this);}));function consumeServiceAsync(_x29){return _consumeServiceAsync2.apply(this,arguments);}return consumeServiceAsync;}()},{key:"updataOptService",value:function updataOptService(){}},{key:"updataOptServiceAsync",value:function(){var _updataOptServiceAsync=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(t,e){var P,x,n,i,a,o,s,c,d,l,p,y;return _regeneratorRuntime().wrap(function _callee26$(_context28){while(1)switch(_context28.prev=_context28.next){case 0:if(this.workId){_context28.next=2;break;}return _context28.abrupt("return");case 2:n=this.workId.toString(),i=t.fontColor,a=t.fontBgColor,o=t.bold,s=t.italic,c=t.lineThrough,d=t.underline,l=t.zIndex,p=(P=this.vNodes)==null?void 0:P.get(n);if(p){_context28.next=5;break;}return _context28.abrupt("return");case 5:i&&(p.opt.fontColor=i),a&&(p.opt.fontBgColor=a),o&&(p.opt.bold=o),s&&(p.opt.italic=s),ye(c)&&(p.opt.lineThrough=c),ye(d)&&(p.opt.underline=d),Zt(l)&&(p.opt.zIndex=l),this.oldRect=p.rect;_context28.next=8;return this.draw({workId:n,layer:this.fullLayer,isDrawLabel:_typeof(e)>"u"&&this.workOptions.workState===It.Done||e});case 8:y=_context28.sent;return _context28.abrupt("return",((x=this.vNodes)==null||x.setInfo(n,{rect:y,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:y&&vt.getCenterPos(y,this.fullLayer)}),y));case 10:case"end":return _context28.stop();}},_callee26,this);}));function updataOptServiceAsync(_x30,_x31){return _updataOptServiceAsync.apply(this,arguments);}return updataOptServiceAsync;}()},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"getSafetySnippetRatio",value:function getSafetySnippetRatio(t){var e=(t==null?void 0:t.parent).displayRatio||1,n=Math.ceil(t.worldScaling[0]*10)/10;var i=n;return n>=0.2&&n<1?i=n*e:n<=2&&n>=1?i=n*e*1.6:n>2&&n<=3?i=n*e*1.4:n>3&&n<=4?i=n*e*0.8:n>4&&(i=n*e*0.6),Math.floor(i*1e3)/1e3;}},{key:"getSafetySnippetFontLength",value:function getSafetySnippetFontLength(t){return Math.floor(ie.textImageSnippetSize*3/4/t)||1;}},{key:"createLabels",value:function(){var _createLabels=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(t,e,n){var L,i,a,o,_ref167,s,c,d,l,p,y,P,x,v,T,f,g,u,m,M,E,A,w,O,b,I,R,W,z,K,k,q,U,G,Z,rt,tt,J,ht,dt,B,F,Y,X,nt,_J2,_ht,_dt,_J3,_ht2,_rt3,_tt2;return _regeneratorRuntime().wrap(function _callee27$(_context29){while(1)switch(_context29.prev=_context29.next){case 0:i=[],a=n.x,o=n.y,_ref167=(L=e.parent)==null?void 0:L.parent,s=_ref167.width,c=_ref167.height,d=Me(t.text),l=d.length,p=t.fontSize,y=t.lineHeight,P=t.bold,x=t.textAlign,v=t.italic,T=t.fontFamily,f=t.verticalAlign,g=t.fontColor,u=t.fontBgColor,m=t.underline,M=t.lineThrough,E=ie.getSafetySnippetRatio(e)||1,A=Math.floor(p*E),w=ie.getSafetySnippetFontLength(A);O=0;b=0;case 3:if(!(b<l)){_context29.next=33;break;}I=d[b],R=y||A*1.5;if(!I){_context29.next=30;break;}W=Qg(I),z=[0,0],K=[0,p*1.2];f==="middle"&&(z[1]=b*p*1.2+5);k=[0,-p*0.15];z[0]=5;q=Math.sin(Math.PI/180*20);U=0;G=[];Z=0;case 14:if(!(Z<W)){_context29.next=27;break;}x==="left"&&(k[0]=U),Z===0&&v==="italic"&&(k[0]=k[0]-q/2*p);rt=I.slice(Z,Z+w);tt={anchor:[0,0],pos:k,text:rt,fontFamily:T,fontSize:A,lineHeight:R,strokeColor:g,fontWeight:P,fillColor:g,textAlign:x,fontStyle:v,scale:[1/E,1/E]};J=new qi(tt);_context29.next=21;return J.textImageReady;case 21:ht=_context29.sent;dt=!0;if(ht){B=ht.rect&&ht.rect[2],F=ht.rect&&ht.rect[3];if(B&&F){Y=B/E,X=F/E;U=Y+U,v==="italic"&&(P==="bold"?U=U-q*p*1.2:U=U-q*p),((k[0]+z[0]+Y)*e.worldScaling[0]+a<=0||(k[0]+z[0])*e.worldScaling[0]+a>=s||(k[1]+z[1]+X)*e.worldScaling[1]+o<=0||(k[1]+z[1])*e.worldScaling[1]+o>=c)&&(J.disconnect(),dt=!1),dt&&G.push(J);}}Z+=w;case 25:_context29.next=14;break;case 27:K[0]=U,v==="italic"&&(K[0]=K[0]+q*p),O=Math.max(O,K[0]);nt=!0;if(((z[0]+K[0])*e.worldScaling[0]+a<=0||z[0]*e.worldScaling[0]+a>=s||(z[1]+K[1])*e.worldScaling[0]+o<=0||z[1]*e.worldScaling[1]+o>=c)&&(nt=!1),nt){if(m){_J2=Math.floor(p/10),_ht={normalize:!1,pos:[0,p*1.1+_J2/2],lineWidth:_J2,points:[0,0,Math.ceil(K[0]),0],strokeColor:g,className:"underline"},_dt=new le(_ht);G.push(_dt);}if(M){_J3={normalize:!1,pos:[0,p*1.2/2],lineWidth:Math.floor(p/10),points:[0,0,Math.ceil(K[0]),0],strokeColor:g,className:"lineThrough"},_ht2=new le(_J3);G.push(_ht2);}_rt3={pos:z,anchor:[0,0],size:K,bgcolor:u},_tt2=new kt(_rt3);_tt2.append.apply(_tt2,G),i.push(_tt2);}case 30:b++;_context29.next=3;break;case 33:return _context29.abrupt("return",{labels:i,maxWidth:O});case 34:case"end":return _context29.stop();}},_callee27);}));function createLabels(_x32,_x33,_x34){return _createLabels.apply(this,arguments);}return createLabels;}()},{key:"updateNodeOpt",value:function updateNodeOpt(t){var e=t.node,n=t.opt,i=t.vNodes,a=t.targetNode,o=n.fontBgColor,s=n.fontColor,c=n.translate,d=n.originPoint,l=n.scenePoint,p=n.scale,y=n.bold,P=n.italic,x=n.lineThrough,v=n.underline,T=n.fontSize,f=n.textInfos,g=n.zIndex,u=a&&Xt(a)||i.get(e.name);if(!u||!e.parent)return;var M=u.opt;if(Zt(g)&&(e.setAttribute("zIndex",g),u.opt.zIndex=g),s&&M.fontColor&&(M.fontColor=s,e.children.forEach(function(E){E.tagName==="GROUP"&&E.children.forEach(function(A){A.tagName==="LABEL"?(A.setAttribute("fillColor",s),A.setAttribute("strokeColor",s)):A.tagName==="POLYLINE"&&A.setAttribute("strokeColor",s);});})),o&&M.fontBgColor&&(M.fontBgColor=o,e.children.forEach(function(E){E.tagName==="GROUP"&&E.setAttribute("bgcolor",o);})),y&&(M.bold=y),P&&(M.italic=P),ye(x)&&(M.lineThrough=x),ye(v)&&(M.underline=v),T&&(M.fontSize=T),d&&l&&p&&a&&M.boxPoint){var E=f==null?void 0:f.get(e.name);if(E){var L=E.fontSize,b=E.boxSize;M.boxSize=b||M.boxSize,M.fontSize=L||M.fontSize;}var A=[M.boxPoint[0],M.boxPoint[1]];Ur(M.boxPoint,l,p,c);var w=[u.op[0],u.op[1]],O=[w[0]-A[0],w[1]-A[1]];if(u.centerPos=[u.centerPos[0]+O[0],u.centerPos[1]+O[1]],u.opt.eraserlines)for(var _i7=0,_Object$values6=Object.values(u.opt.eraserlines);_i7<_Object$values6.length;_i7++){var _L19=_Object$values6[_i7];var _b9=_L19.op,I=_L19.thickness;_L19.thickness=I*Math.max(p[0],p[1]);for(var R=0;R<_b9.length;R++)jr(_b9[R],l,p,c);}}else if(c&&M.boxPoint&&(M.boxPoint=[M.boxPoint[0]+c[0],M.boxPoint[1]+c[1]],u.centerPos=[u.centerPos[0]+c[0],u.centerPos[1]+c[1]],u.opt.eraserlines))for(var _i8=0,_Object$values7=Object.values(u.opt.eraserlines);_i8<_Object$values7.length;_i8++){var _E5=_Object$values7[_i8];var _A6=_E5.op;for(var _w22=0;_w22<_A6.length;_w22++){var _O22=_A6[_w22].map(function(L,b){return b%2?L+c[1]:L+c[0];});_E5.op[_w22]=_O22;}}return u&&i.setInfo(e.name,u),u==null?void 0:u.rect;}},{key:"getRectFromLayer",value:function getRectFromLayer(t,e){var n=t.getElementsByName(e)[0];if(n){var i=n.getBoundingClientRect();var a={x:Math.floor(i.x),y:Math.floor(i.y),w:Math.floor(i.width+2),h:Math.floor(i.height+2)};return n.children.forEach(function(o){if(o.tagName==="GROUP"){var s=n.getBoundingClientRect();a=Pt(a,{x:Math.floor(s.x),y:Math.floor(s.y),w:Math.floor(s.width+2),h:Math.floor(s.height+2)});}}),a;}}}]);}(vt);// 4k
437
437
  et(ie,"textImageSnippetSize",1024*4),et(ie,"SafeBorderPadding",30);var Xe=ie;var xe=/*#__PURE__*/function(_vt14){function xe(t,e){var _this84;_classCallCheck(this,xe);_this84=_callSuper(this,xe,[t]);et(_this84,"canRotate",!1);et(_this84,"scaleType",jt.none);et(_this84,"toolsType",ut.PencilEraser);et(_this84,"serviceWork");et(_this84,"tmpPoints",[]);et(_this84,"workOptions");et(_this84,"worldPosition");et(_this84,"worldScaling");et(_this84,"eraserRect");et(_this84,"eraserPolyline");_this84.serviceWork=e,_this84.workOptions=t.toolsOpt,_this84.worldPosition=_this84.fullLayer.worldPosition,_this84.worldScaling=_this84.fullLayer.worldScaling;return _this84;}_inherits(xe,_vt14);return _createClass(xe,[{key:"consumeService",value:function consumeService(){}},{key:"createEraserRect",value:function createEraserRect(t){var e=t[0]*this.worldScaling[0]+this.worldPosition[0],n=t[1]*this.worldScaling[1]+this.worldPosition[1],_xe$eraserSizes$this$=xe.eraserSizes[this.workOptions.thickness],i=_xe$eraserSizes$this$.width,a=_xe$eraserSizes$this$.height;this.eraserRect={x:e-i*0.5,y:n-a*0.5,w:i,h:a},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h];}},{key:"computRectCenterPoints",value:function computRectCenterPoints(){var t=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){var _e5=new _(this.tmpPoints[0],this.tmpPoints[1]),n=new _(this.tmpPoints[2],this.tmpPoints[3]),i=_.Sub(n,_e5).uni(),a=_.Dist(_e5,n),_xe$eraserSizes$this$2=xe.eraserSizes[this.workOptions.thickness],o=_xe$eraserSizes$this$2.width,s=_xe$eraserSizes$this$2.height,c=Math.min(o,s),d=Math.round(a/c);if(d>1){var l=[];for(var p=0;p<d;p++){var y=_.Mul(i,p*c);l.push(this.tmpPoints[0]+y.x,this.tmpPoints[1]+y.y);}return l.concat(t);}}return t;}},{key:"isNear",value:function isNear(t,e){var n=new _(t[0],t[1]),i=new _(e[0],e[1]),_xe$eraserSizes$this$3=xe.eraserSizes[this.workOptions.thickness],a=_xe$eraserSizes$this$3.width,o=_xe$eraserSizes$this$3.height;return _.Dist(n,i)<Math.hypot(a,o)*0.5;}},{key:"cutPolyline",value:function cutPolyline(t,e){var n=[e],i=0;for(;i<t.length;){var s=t[i];if(s.length<2)break;n=a(n,s),i++;}return n;function a(s,c){var d=s;var _loop4=function _loop4(){var p=s[l],y=p.findIndex(function(P,x){return x<p.length-1?o([P,p[x+1]],[c[0],c[1]]):!1;});if(y!==-1&&y>-1){var P=[],x=p.slice(0,y+1);if(_.Equals(p[y],c[0])||x.push(c[0].clone().setz(p[y].z)),x.length>1&&P.push(x),y+c.length-1<p.length-1){var v=y+c.length-1,_T38=p.slice(v),_f32=c[c.length-1];_.Equals(p[v],_f32)||_T38.unshift(_f32.clone().setz(p[v].z)),_T38.length>1&&P.push(_T38);}return{v:(d.splice.apply(d,[l,1].concat(P)),d)};}},_ret;for(var l=0;l<s.length;l++){_ret=_loop4();if(_ret)return _ret.v;}return d;}function o(s,c){var d=_.Sub(s[1],s[0]),l=_.Sub(c[1],c[0]),p=_.Sub(c[0],s[0]);return Math.abs(_.Cpr(d,l))<0.1&&Math.abs(_.Cpr(d,p))<0.1;}}},{key:"isSamePoint",value:function isSamePoint(t,e){return t[0]===e[0]&&t[1]===e[1];}},{key:"translateIntersect",value:function translateIntersect(t){var _this85=this;var e=[];for(var n=0;n<t.length;n++){var i=t[n].filter(function(s,c,d){return!(c>0&&_this85.isSamePoint(s,d[c-1]));}),a=[];var o=0;for(;o<i.length;){var s=i[o],c=new _(s[0],s[1]);a.push(c),o++;}e.push(a);}return e;}},{key:"isLineEraser",value:function isLineEraser(t,e){return!(t===ut.Pencil&&!e);}},{key:"remove",value:function remove(t){var _this86=this;var e=t.curNodeMap,n=t.removeIds,i=t.newWorkDatas;var a;var _iterator27=_createForOfIteratorHelper(e.entries()),_step27;try{for(_iterator27.s();!(_step27=_iterator27.n()).done;){var _step27$value=_slicedToArray(_step27.value,2),o=_step27$value[0],s=_step27$value[1];if(s.rect&&this.eraserRect&&this.eraserPolyline&&We(this.eraserRect,s.rect)){var c=s.op,d=s.toolsType,l=this.isLineEraser(d,!1),p=[],y=[];for(var x=0;x<c.length;x+=3){var v=new _(c[x]*this.worldScaling[0]+this.worldPosition[0],c[x+1]*this.worldScaling[1]+this.worldPosition[1],c[x+2]);y.push(v),p.push(new xt(v.x,v.y));}var P=p.length&&Bt(p)||s.rect;if(We(P,this.eraserRect)){if(y.length>1){var _x35=Dr.polyline(y.map(function(v){return v.XY;}),this.eraserPolyline);if(_x35.length&&(n.add(s.name),!l)){var _v8=this.translateIntersect(_x35),_T39=this.cutPolyline(_v8,y);var _loop5=function _loop5(){var g="".concat(o,"_s_").concat(_f33),u=[];_T39[_f33].forEach(function(m){u.push((m.x-_this86.worldPosition[0])/_this86.worldScaling[0],(m.y-_this86.worldPosition[1])/_this86.worldScaling[1],m.z);}),s.opt&&s.toolsType&&_this86.vNodes&&(_this86.vNodes.setInfo(g,{rect:P,op:u,opt:s.opt,canRotate:s.canRotate,scaleType:s.scaleType,toolsType:s.toolsType}),i.set(g,{workId:g,op:u,opt:s.opt,toolsType:s.toolsType}));};for(var _f33=0;_f33<_T39.length;_f33++){_loop5();}}}else n.add(s.name);a=Pt(a,P);}}}}catch(err){_iterator27.e(err);}finally{_iterator27.f();}return n.forEach(function(o){var s;return(s=_this86.vNodes)==null?void 0:s["delete"](o);}),a&&(a.x-=vt.SafeBorderPadding,a.y-=vt.SafeBorderPadding,a.w+=vt.SafeBorderPadding*2,a.h+=vt.SafeBorderPadding*2),a;}},{key:"consume",value:function consume(t){var _t$data4=t.data,e=_t$data4.op,n=_t$data4.disableEraseImage;if(!e||e.length===0)return _objectSpread({type:ot.None},this.baseConsumeResult);var i=this.tmpPoints.length;if(i>1&&this.isNear([e[0],e[1]],[this.tmpPoints[i-2],this.tmpPoints[i-1]]))return _objectSpread({type:ot.None},this.baseConsumeResult);i<3?this.tmpPoints.push(e[0],e[1]):this.tmpPoints.splice(2,2,e[0],e[1]);var a=this.computRectCenterPoints();var o;var s=/* @__PURE__ */new Set(),c=/* @__PURE__ */new Map();if(!this.vNodes)return _objectSpread({type:ot.None},this.baseConsumeResult);this.vNodes.setTarget();var d=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.getLastTarget(),n));for(var l=0;l<a.length-1;l+=2){this.createEraserRect(a.slice(l,l+2));var p=this.remove({curNodeMap:d,removeIds:s,newWorkDatas:c});o=Pt(o,p);}if(this.vNodes.deleteLastTarget(),o&&s.size){var _iterator28=_createForOfIteratorHelper(c.keys()),_step28;try{for(_iterator28.s();!(_step28=_iterator28.n()).done;){var _l6=_step28.value;s.has(_l6)&&c["delete"](_l6);}}catch(err){_iterator28.e(err);}finally{_iterator28.f();}return{type:ot.RemoveNode,rect:o,removeIds:_toConsumableArray(s),newWorkDatas:c};}return _objectSpread({type:ot.None},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(t){return this.consume(t);}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}},{key:"getCanEraserNodeMap",value:function getCanEraserNodeMap(t){var e;if(this.serviceWork){var n=Xt(t),i=this.serviceWork.selectorWorkShapes,a=this.serviceWork.workShapes;var _iterator29=_createForOfIteratorHelper(i.values()),_step29;try{for(_iterator29.s();!(_step29=_iterator29.n()).done;){var o=_step29.value;if((e=o.selectIds)!=null&&e.length){var _iterator31=_createForOfIteratorHelper(o.selectIds),_step31;try{for(_iterator31.s();!(_step31=_iterator31.n()).done;){var s=_step31.value;n["delete"](s);}}catch(err){_iterator31.e(err);}finally{_iterator31.f();}}}}catch(err){_iterator29.e(err);}finally{_iterator29.f();}var _iterator30=_createForOfIteratorHelper(a.keys()),_step30;try{for(_iterator30.s();!(_step30=_iterator30.n()).done;){var _o5=_step30.value;n["delete"](_o5);}}catch(err){_iterator30.e(err);}finally{_iterator30.f();}return n;}return t;}}]);}(vt);// 来源于white-sdk
438
- et(xe,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));var ke=xe;var be=/*#__PURE__*/function(_vt15){function be(t){var _this87;_classCallCheck(this,be);_this87=_callSuper(this,be,[t]);et(_this87,"canRotate",!1);et(_this87,"scaleType",jt.none);et(_this87,"toolsType",ut.BitMapEraser);et(_this87,"tmpPoints",[]);et(_this87,"workOptions");et(_this87,"worldPosition");et(_this87,"worldScaling");et(_this87,"eraserRect");et(_this87,"eraserPolyline");et(_this87,"syncUnitTime",re.syncOpt.interval);et(_this87,"syncIndex",0);et(_this87,"syncTimestamp");_this87.workOptions=t.toolsOpt,_this87.worldPosition=_this87.fullLayer.worldPosition,_this87.worldScaling=_this87.fullLayer.worldScaling,_this87.syncTimestamp=0;return _this87;}_inherits(be,_vt15);return _createClass(be,[{key:"consumeService",value:function consumeService(t){var e=t.op,n=t.isFullWork;this.tmpPoints.length=0;for(var s=0;s<e.length;s+=3){var c=new xt(e[s],e[s+1],e[s+2]);if(this.tmpPoints.length>0){var d=this.tmpPoints[this.tmpPoints.length-1],l=_.Sub(c,d).uni();c.setv(l);}this.tmpPoints.push(c);}if(this.tmpPoints.length<2)return;var i=this.tmpPoints[0].z*2,a=n?this.fullLayer:this.drawLayer||this.fullLayer;return this.draw({consumePoints:this.tmpPoints,layer:a,thickness:i});}},{key:"updateTempPoints",value:function updateTempPoints(t,e){var n=this.tmpPoints.length-1;var i=Date.now();for(var a=0;a<t.length;a+=2){var o=this.tmpPoints.length,s=new xt(t[a],t[a+1]);if(o===0){this.tmpPoints.push(s);continue;}var c=o-1,d=this.tmpPoints[c],l=_.Sub(s,d).uni();s.isNear(d,e/2)||(_.Equals(l,d.v,0.02)&&(this.tmpPoints.pop(),n--),s.setv(l),s.setT(i),this.tmpPoints.push(s));}return Math.max(n,0);}},{key:"getChangeNodes",value:function getChangeNodes(t){if(!this.vNodes)return;var e=this.worldPosition;var n=Bt(this.tmpPoints,t);n=Sr(n,e),n=Gg(n,this.worldScaling,e);var _this$vNodes$getRectI3=this.vNodes.getRectIntersectRange(n),i=_this$vNodes$getRectI3.nodeRange;if(!i.size)return;var a=[];var o=0;for(var d=1;d<this.tmpPoints.length;d++){var l=this.tmpPoints[d-1],p=this.tmpPoints[d];if(d===1&&o===0&&(a[o]=[l.XY]),a[o].push(p.XY),d<this.tmpPoints.length-1){var y=p.getAngleByPoints(l,this.tmpPoints[d+1]);(y<90||y>270)&&(o++,a[o]=[p.XY]);}}this.tmpPoints.length===1&&a.length===0&&a.push([this.tmpPoints[0].XY,this.tmpPoints[0].XY]);var s=/* @__PURE__ */new Map(),c=/* @__PURE__ */new Set();var _iterator32=_createForOfIteratorHelper(i.entries()),_step32;try{for(_iterator32.s();!(_step32=_iterator32.n()).done;){var _step32$value=_slicedToArray(_step32.value,2),_d10=_step32$value[0],_l7=_step32$value[1];if(this.isTransparentRect(_l7.rect)){c.add(_d10);continue;}var _y13=Sr(_l7.rect,[-e[0],-e[1]]);_y13={x:_y13.x/this.worldScaling[0],y:_y13.y/this.worldScaling[1],w:_y13.w/this.worldScaling[0],h:_y13.h/this.worldScaling[1]};var P=[_y13.x,_y13.y,_y13.x+_y13.w,_y13.y+_y13.h],x=[],v=[];var _iterator33=_createForOfIteratorHelper(a),_step33;try{for(_iterator33.s();!(_step33=_iterator33.n()).done;){var _f35=_step33.value;Dr.polyline(_f35,P,x);}}catch(err){_iterator33.e(err);}finally{_iterator33.f();}if(x.length&&_l7.opt){var _iterator34=_createForOfIteratorHelper(x),_step34;try{for(_iterator34.s();!(_step34=_iterator34.n()).done;){var _f34=_step34.value;var g=[];for(var u=0;u<_f34.length;u++)u!==0&&oe(_f34[u],_f34[u-1])||g.push.apply(g,_toConsumableArray(_f34[u]));v.push(g);}}catch(err){_iterator34.e(err);}finally{_iterator34.f();}}_l7.opt.eraserlines||(_l7.opt.eraserlines=[]),_l7.opt.eraserlines&&(_l7.opt.eraserlines.push({op:v,thickness:t}),s.set(_d10,_l7));}}catch(err){_iterator32.e(err);}finally{_iterator32.f();}return{willUpdateNodes:s,willDeleteNodes:c};}},{key:"reRenderEffectNodes",value:function(){var _reRenderEffectNodes=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(t){var o,e,n,i,a,_iterator35,_step35,s,_iterator36,_step36,_step36$value,_s5,c,d,l,p;return _regeneratorRuntime().wrap(function _callee28$(_context30){while(1)switch(_context30.prev=_context30.next){case 0:n=t.willUpdateNodes,i=t.willDeleteNodes,a=t.worker;if(i!=null&&i.size){_iterator35=_createForOfIteratorHelper(i.keys());try{for(_iterator35.s();!(_step35=_iterator35.n()).done;){s=_step35.value;this.replace(this.fullLayer,s),(o=this.vNodes)==null||o["delete"](s);}}catch(err){_iterator35.e(err);}finally{_iterator35.f();}}if(!(n!=null&&n.size)){_context30.next=41;break;}_iterator36=_createForOfIteratorHelper(n.entries());_context30.prev=4;_iterator36.s();case 6:if((_step36=_iterator36.n()).done){_context30.next=33;break;}_step36$value=_slicedToArray(_step36.value,2),_s5=_step36$value[0],c=_step36$value[1];d=c.toolsType,l=a.createWorkShapeNode({workId:_s5,toolsType:d,toolsOpt:c.opt});l==null||l.setWorkId(_s5);p=void 0;if(!(d===ut.Image)){_context30.next=17;break;}_context30.next=14;return l.consumeServiceAsync({isFullWork:!0,replaceId:_s5,worker:a});case 14:p=_context30.sent;_context30.next=30;break;case 17:if(!(d===ut.Text)){_context30.next=23;break;}_context30.next=20;return l.consumeServiceAsync({isFullWork:!0,replaceId:_s5});case 20:p=_context30.sent;_context30.next=30;break;case 23:_context30.prev=23;p=l==null?void 0:l.consumeService({op:c.op,isFullWork:!0,replaceId:_s5});_context30.next=30;break;case 27:_context30.prev=27;_context30.t0=_context30["catch"](23);return _context30.abrupt("continue",31);case 30:p&&(e=Pt(e,p));case 31:_context30.next=6;break;case 33:_context30.next=38;break;case 35:_context30.prev=35;_context30.t1=_context30["catch"](4);_iterator36.e(_context30.t1);case 38:_context30.prev=38;_iterator36.f();return _context30.finish(38);case 41:return _context30.abrupt("return",e);case 42:case"end":return _context30.stop();}},_callee28,this,[[4,35,38,41],[23,27]]);}));function reRenderEffectNodes(_x36){return _reRenderEffectNodes.apply(this,arguments);}return reRenderEffectNodes;}()},{key:"consume",value:function consume(t){var e=t.data.op;if(!e||e.length===0)return _objectSpread({type:ot.None},this.baseConsumeResult);var n=this.workOptions.thickness,_be$eraserSizes$n=be.eraserSizes[n],i=_be$eraserSizes$n.width,a=_be$eraserSizes$n.height,o=Math.max(i,a)/this.worldScaling[0],s=this.tmpPoints.length,c=this.tmpPoints[this.tmpPoints.length-1],d=this.updateTempPoints(e,o),l=this.tmpPoints[this.tmpPoints.length-1];if(s===this.tmpPoints.length&&l.equalsXY(c.x,c.y))return _objectSpread({type:ot.None},this.baseConsumeResult);this.syncIndex=Math.min(this.syncIndex,d,Math.max(0,this.tmpPoints.length-2));var p=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());var y=!1;var P=this.tmpPoints.slice(d),x=this.draw({consumePoints:P,layer:this.fullLayer,thickness:o});P[0].t-this.syncTimestamp>this.syncUnitTime&&(y=!0,this.syncTimestamp=P[0].t,this.syncIndex=this.tmpPoints.length);var v=[];return this.tmpPoints.slice(p).forEach(function(T){v.push(T.x,T.y,o/2);}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:ot.DrawWork,dataType:Mt.Local,rect:x,op:y?v:void 0,index:y?p*3:void 0,updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var e=t.consumePoints,n=t.layer,i=t.thickness,a=this.workId;var o=n.getElementsByName(this.workId)[0],s=Bt(e,i);var d=[{op:[e.map(function(l){return[l.x,l.y];}).flat(1)],thickness:i}];return o||(o=new kt({normalize:!0,name:a,pos:[0,0],anchor:[0.5,0.5],bgcolor:"rgba(0,0,0,0.3)",zIndex:9999}),n.appendChild(o)),this.drawEraserlines({group:o,eraserlines:d,pos:[0,0],layer:n,isClear:!0}),s={x:Math.floor(s.x*this.worldScaling[0]+this.worldPosition[0]-vt.SafeBorderPadding),y:Math.floor(s.y*this.worldScaling[1]+this.worldPosition[1]-vt.SafeBorderPadding),w:Math.floor(s.w*this.worldScaling[0]+2*vt.SafeBorderPadding),h:Math.floor(s.h*this.worldScaling[1]+2*vt.SafeBorderPadding)},s;}},{key:"isTransparentRectByGL",value:function isTransparentRectByGL(t,e){var n=e.x,i=e.y,a=e.w,o=e.h,s=new Uint8Array(a*o*4);t.readPixels(n,t.drawingBufferHeight-i-o,a,o,t.RGBA,t.UNSIGNED_BYTE,s);var c=!0;for(var d=0;d<s.length;d+=4)if(s[d+3]!==0){c=!1;break;}return c;}},{key:"isTransparentRectByCanvas",value:function isTransparentRectByCanvas(t,e){var n=t.getContext("2d",{willReadFrequently:!0});if(!n)return!1;var i=e.x,a=e.y,o=e.w,s=e.h,c=n.getImageData(i,a,o,s);var d=!0;for(var l=0;l<c.data.length;l+=4)if(c.data[l+3]!==0){d=!1;break;}return d;}},{key:"isTransparentRect",value:function isTransparentRect(t){var e=this.fullLayer.parent.displayRatio||1,n=Math.floor(t.x*e),i=Math.floor(t.y*e),a=Math.floor(t.w*e),o=Math.floor(t.h*e),s=this.fullLayer.renderer.glRenderer;if(s)return this.isTransparentRectByGL(s,{x:n,y:i,w:a,h:o});var c=this.fullLayer.renderer.canvas;return c&&this.isTransparentRectByCanvas(c,{x:n,y:i,w:a,h:o})||!1;}},{key:"consumeAll",value:function consumeAll(){var l;var t=this.fullLayer.getElementsByName(this.workId);var e;if(t.length&&(e=vt.getRectFromLayer(this.fullLayer,this.workId)),t.forEach(function(p){p.remove(),p.disconnect();}),!this.tmpPoints.length)return _objectSpread({type:ot.None},this.baseConsumeResult);var n=this.workOptions.thickness,_be$eraserSizes$n2=be.eraserSizes[n],i=_be$eraserSizes$n2.width,a=_be$eraserSizes$n2.height,o=Math.max(i,a)/this.worldScaling[0],s=this.getChangeNodes(o);if(!s||s&&!((l=s.willUpdateNodes)!=null&&l.size)&&!s.willDeleteNodes.size)return _objectSpread(_objectSpread({type:ot.FullWork},this.baseConsumeResult),{},{rect:e});var c=[];this.tmpPoints.map(function(p){c.push(p.x,p.y,o/2);});var d=Qt(c);return _objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:ot.FullWork,dataType:Mt.Local,rect:e,ops:d,willUpdateNodes:s.willUpdateNodes,willDeleteNodes:s.willDeleteNodes});}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}]);}(vt);// 来源于white-sdk
438
+ et(xe,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));var ke=xe;var be=/*#__PURE__*/function(_vt15){function be(t){var _this87;_classCallCheck(this,be);_this87=_callSuper(this,be,[t]);et(_this87,"canRotate",!1);et(_this87,"scaleType",jt.none);et(_this87,"toolsType",ut.BitMapEraser);et(_this87,"tmpPoints",[]);et(_this87,"workOptions");et(_this87,"worldPosition");et(_this87,"worldScaling");et(_this87,"eraserRect");et(_this87,"eraserPolyline");et(_this87,"syncUnitTime",re.syncOpt.interval);et(_this87,"syncIndex",0);et(_this87,"syncTimestamp");_this87.workOptions=t.toolsOpt,_this87.worldPosition=_this87.fullLayer.worldPosition,_this87.worldScaling=_this87.fullLayer.worldScaling,_this87.syncTimestamp=0;return _this87;}_inherits(be,_vt15);return _createClass(be,[{key:"consumeService",value:function consumeService(t){var e=t.op,n=t.isFullWork;this.tmpPoints.length=0;for(var s=0;s<e.length;s+=3){var c=new xt(e[s],e[s+1],e[s+2]);if(this.tmpPoints.length>0){var d=this.tmpPoints[this.tmpPoints.length-1],l=_.Sub(c,d).uni();c.setv(l);}this.tmpPoints.push(c);}if(this.tmpPoints.length<2)return;var i=this.tmpPoints[0].z*2,a=n?this.fullLayer:this.drawLayer||this.fullLayer;return this.draw({consumePoints:this.tmpPoints,layer:a,thickness:i});}},{key:"updateTempPoints",value:function updateTempPoints(t,e){var n=this.tmpPoints.length-1;var i=Date.now();for(var a=0;a<t.length;a+=2){var o=this.tmpPoints.length,s=new xt(t[a],t[a+1]);if(o===0){this.tmpPoints.push(s);continue;}var c=o-1,d=this.tmpPoints[c],l=_.Sub(s,d).uni();s.isNear(d,e/2)||(_.Equals(l,d.v,0.02)&&(this.tmpPoints.pop(),n--),s.setv(l),s.setT(i),this.tmpPoints.push(s));}return Math.max(n,0);}},{key:"getChangeNodes",value:function getChangeNodes(t){if(!this.vNodes)return;var e=this.worldPosition;var n=Bt(this.tmpPoints,t);n=Sr(n,e),n=Gg(n,this.worldScaling,e);var _this$vNodes$getRectI3=this.vNodes.getRectIntersectRange(n),i=_this$vNodes$getRectI3.nodeRange;if(!i.size)return;var a=[];var o=0;for(var d=1;d<this.tmpPoints.length;d++){var l=this.tmpPoints[d-1],p=this.tmpPoints[d];if(d===1&&o===0&&(a[o]=[l.XY]),a[o].push(p.XY),d<this.tmpPoints.length-1){var y=p.getAngleByPoints(l,this.tmpPoints[d+1]);(y<90||y>270)&&(o++,a[o]=[p.XY]);}}this.tmpPoints.length===1&&a.length===0&&a.push([this.tmpPoints[0].XY,this.tmpPoints[0].XY]);var s=/* @__PURE__ */new Map(),c=/* @__PURE__ */new Set();var _iterator32=_createForOfIteratorHelper(i.entries()),_step32;try{for(_iterator32.s();!(_step32=_iterator32.n()).done;){var _step32$value=_slicedToArray(_step32.value,2),_d10=_step32$value[0],_l7=_step32$value[1];if(this.isTransparentRect(_l7.rect)){c.add(_d10);continue;}var _y13=Sr(_l7.rect,[-e[0],-e[1]]);_y13={x:_y13.x/this.worldScaling[0],y:_y13.y/this.worldScaling[1],w:_y13.w/this.worldScaling[0],h:_y13.h/this.worldScaling[1]};var P=[_y13.x,_y13.y,_y13.x+_y13.w,_y13.y+_y13.h],x=[],v=[];var _iterator33=_createForOfIteratorHelper(a),_step33;try{for(_iterator33.s();!(_step33=_iterator33.n()).done;){var _f35=_step33.value;Dr.polyline(_f35,P,x);}}catch(err){_iterator33.e(err);}finally{_iterator33.f();}if(x.length&&_l7.opt){var _iterator34=_createForOfIteratorHelper(x),_step34;try{for(_iterator34.s();!(_step34=_iterator34.n()).done;){var _f34=_step34.value;var g=[];for(var u=0;u<_f34.length;u++)u!==0&&oe(_f34[u],_f34[u-1])||g.push.apply(g,_toConsumableArray(_f34[u]));v.push(g);}}catch(err){_iterator34.e(err);}finally{_iterator34.f();}}_l7.opt.eraserlines||(_l7.opt.eraserlines=[]),_l7.opt.eraserlines&&(_l7.opt.eraserlines.push({op:v,thickness:t}),s.set(_d10,_l7));}}catch(err){_iterator32.e(err);}finally{_iterator32.f();}return{willUpdateNodes:s,willDeleteNodes:c};}},{key:"reRenderEffectNodes",value:function(){var _reRenderEffectNodes=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(t){var o,e,n,i,a,_iterator35,_step35,s,_iterator36,_step36,_step36$value,_s5,c,d,l,p;return _regeneratorRuntime().wrap(function _callee28$(_context30){while(1)switch(_context30.prev=_context30.next){case 0:n=t.willUpdateNodes,i=t.willDeleteNodes,a=t.worker;if(i!=null&&i.size){_iterator35=_createForOfIteratorHelper(i.keys());try{for(_iterator35.s();!(_step35=_iterator35.n()).done;){s=_step35.value;this.replace(this.fullLayer,s),(o=this.vNodes)==null||o["delete"](s);}}catch(err){_iterator35.e(err);}finally{_iterator35.f();}}if(!(n!=null&&n.size)){_context30.next=41;break;}_iterator36=_createForOfIteratorHelper(n.entries());_context30.prev=4;_iterator36.s();case 6:if((_step36=_iterator36.n()).done){_context30.next=33;break;}_step36$value=_slicedToArray(_step36.value,2),_s5=_step36$value[0],c=_step36$value[1];d=c.toolsType,l=a.createWorkShapeNode({workId:_s5,toolsType:d,toolsOpt:c.opt});l==null||l.setWorkId(_s5);p=void 0;if(!(d===ut.Image)){_context30.next=17;break;}_context30.next=14;return l.consumeServiceAsync({isFullWork:!0,replaceId:_s5,worker:a});case 14:p=_context30.sent;_context30.next=30;break;case 17:if(!(d===ut.Text)){_context30.next=23;break;}_context30.next=20;return l.consumeServiceAsync({isFullWork:!0,replaceId:_s5});case 20:p=_context30.sent;_context30.next=30;break;case 23:_context30.prev=23;p=l==null?void 0:l.consumeService({op:c.op,isFullWork:!0,replaceId:_s5});_context30.next=30;break;case 27:_context30.prev=27;_context30.t0=_context30["catch"](23);return _context30.abrupt("continue",31);case 30:p&&(e=Pt(e,p));case 31:_context30.next=6;break;case 33:_context30.next=38;break;case 35:_context30.prev=35;_context30.t1=_context30["catch"](4);_iterator36.e(_context30.t1);case 38:_context30.prev=38;_iterator36.f();return _context30.finish(38);case 41:return _context30.abrupt("return",e);case 42:case"end":return _context30.stop();}},_callee28,this,[[4,35,38,41],[23,27]]);}));function reRenderEffectNodes(_x36){return _reRenderEffectNodes.apply(this,arguments);}return reRenderEffectNodes;}()},{key:"consume",value:function consume(t){var e=t.data.op;if(!e||e.length===0)return _objectSpread({type:ot.None},this.baseConsumeResult);var n=this.workOptions.thickness,_be$eraserSizes$n=be.eraserSizes[n],i=_be$eraserSizes$n.width,a=_be$eraserSizes$n.height,o=Math.max(i,a)/this.worldScaling[0],s=this.tmpPoints.length,c=this.tmpPoints[this.tmpPoints.length-1],d=this.updateTempPoints(e,o),l=this.tmpPoints[this.tmpPoints.length-1];if(s===this.tmpPoints.length&&l.equalsXY(c.x,c.y))return _objectSpread({type:ot.None},this.baseConsumeResult);this.syncIndex=Math.min(this.syncIndex,d,Math.max(0,this.tmpPoints.length-2));var p=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());var y=!1;var P=this.tmpPoints.slice(d),x=this.draw({consumePoints:P,layer:this.fullLayer,thickness:o});P[0].t-this.syncTimestamp>this.syncUnitTime&&(y=!0,this.syncTimestamp=P[0].t,this.syncIndex=this.tmpPoints.length);var v=[];return this.tmpPoints.slice(p).forEach(function(T){v.push(T.x,T.y,o/2);}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:ot.DrawWork,dataType:Mt.Local,rect:x,op:y?v:void 0,index:y?p*3:void 0,updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var e=t.consumePoints,n=t.layer,i=t.thickness,a=this.workId;var o=n.getElementsByName(this.workId)[0],s=Bt(e,i);var d=[{op:[e.map(function(l){return[l.x,l.y];}).flat(1)],thickness:i}];return o||(o=new kt({normalize:!0,name:a,pos:[0,0],anchor:[0.5,0.5],bgcolor:"rgba(0,0,0,0.3)",zIndex:9999}),n.appendChild(o)),this.drawEraserlines({group:o,eraserlines:d,pos:[0,0],layer:n,isClear:!0}),s={x:Math.floor(s.x*this.worldScaling[0]+this.worldPosition[0]-vt.SafeBorderPadding),y:Math.floor(s.y*this.worldScaling[1]+this.worldPosition[1]-vt.SafeBorderPadding),w:Math.floor(s.w*this.worldScaling[0]+2*vt.SafeBorderPadding),h:Math.floor(s.h*this.worldScaling[1]+2*vt.SafeBorderPadding)},s;}},{key:"isTransparentRectByGL",value:function isTransparentRectByGL(t,e){var n=e.x,i=e.y,a=e.w,o=e.h,s=new Uint8Array(a*o*4);t.readPixels(n,t.drawingBufferHeight-i-o,a,o,t.RGBA,t.UNSIGNED_BYTE,s);var c=!0;for(var d=0;d<s.length;d+=4)if(s[d+3]!==0){c=!1;break;}return c;}},{key:"isTransparentRectByCanvas",value:function isTransparentRectByCanvas(t,e){var n=t.getContext("2d",{willReadFrequently:!0});if(!n)return!1;var i=e.x,a=e.y,o=e.w,s=e.h,c=n.getImageData(i,a,o,s);var d=!0;for(var l=0;l<c.data.length;l+=4)if(c.data[l+3]!==0){d=!1;break;}return d;}},{key:"isTransparentRect",value:function isTransparentRect(t){var e=this.fullLayer.parent.displayRatio||1,n=Math.floor(t.x*e),i=Math.floor(t.y*e),a=Math.floor(t.w*e),o=Math.floor(t.h*e),s=this.fullLayer.renderer.glRenderer;if(s&&s.gl)return this.isTransparentRectByGL(s.gl,{x:n,y:i,w:a,h:o});var c=this.fullLayer.renderer.canvas;return c&&this.isTransparentRectByCanvas(c,{x:n,y:i,w:a,h:o})||!1;}},{key:"consumeAll",value:function consumeAll(){var l;var t=this.fullLayer.getElementsByName(this.workId);var e;if(t.length&&(e=vt.getRectFromLayer(this.fullLayer,this.workId)),t.forEach(function(p){p.remove(),p.disconnect();}),!this.tmpPoints.length)return _objectSpread({type:ot.None},this.baseConsumeResult);var n=this.workOptions.thickness,_be$eraserSizes$n2=be.eraserSizes[n],i=_be$eraserSizes$n2.width,a=_be$eraserSizes$n2.height,o=Math.max(i,a)/this.worldScaling[0],s=this.getChangeNodes(o);if(!s||s&&!((l=s.willUpdateNodes)!=null&&l.size)&&!s.willDeleteNodes.size)return _objectSpread(_objectSpread({type:ot.FullWork},this.baseConsumeResult),{},{rect:e});var c=[];this.tmpPoints.map(function(p){c.push(p.x,p.y,o/2);});var d=Qt(c);return _objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:ot.FullWork,dataType:Mt.Local,rect:e,ops:d,willUpdateNodes:s.willUpdateNodes,willDeleteNodes:s.willDeleteNodes});}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}]);}(vt);// 来源于white-sdk
439
439
  et(be,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));var Je=be;function Pi(h){switch(h){case ut.Arrow:return mi;case ut.Pencil:return ui;case ut.Straight:return Mi;case ut.Ellipse:return vi;case ut.Polygon:case ut.Triangle:return xi;case ut.Star:case ut.Rhombus:return Si;case ut.Rectangle:return yi;case ut.SpeechBalloon:return Ti;case ut.Text:return Xe;case ut.LaserPen:return di;case ut.Eraser:return se;case ut.PencilEraser:return ke;case ut.BitMapEraser:return Je;case ut.Selector:return Ve;case ut.Image:return Ne;}}function Fr(h,r){var t=h.toolsType,e=_objectWithoutProperties(h,_excluded);switch(t){case ut.Arrow:return new mi(e);case ut.Pencil:return new ui(e);case ut.Straight:return new Mi(e);case ut.Ellipse:return new vi(e);case ut.Polygon:case ut.Triangle:return new xi(e);case ut.Star:case ut.Rhombus:return new Si(e);case ut.Rectangle:return new yi(e);case ut.SpeechBalloon:return new Ti(e);case ut.Text:return new Xe(e);case ut.LaserPen:return new di(e);case ut.Eraser:return new se(e,r);case ut.BitMapEraser:return new Je(e);case ut.PencilEraser:return new ke(e,r);case ut.Selector:return e.vNodes?new Ve(_objectSpread(_objectSpread({},e),{},{vNodes:e.vNodes,drawLayer:e.fullLayer})):void 0;case ut.Image:return new Ne(e);default:return;}}function Oi(h){var r=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];var _iterator37=_createForOfIteratorHelper(h),_step37;try{for(_iterator37.s();!(_step37=_iterator37.n()).done;){var _e6=_step37.value;if(_e6.tagName==="GROUP"&&_e6.children.length)return Oi(_e6.children);_e6.tagName&&t.includes(_e6.tagName)&&r.push(_e6);}}catch(err){_iterator37.e(err);}finally{_iterator37.f();}return r;}function Pt(h,r){if(h&&r){var t=Math.min(h.x,r.x),_e7=Math.min(h.y,r.y),n=Math.max(h.x+h.w,r.x+r.w),i=Math.max(h.y+h.h,r.y+r.h),a=n-t,o=i-_e7;return{x:t,y:_e7,w:a,h:o};}return r||h;}function Bt(h){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var t={x:0,y:0,w:0,h:0};var e=1/0,n=1/0,i=-1/0,a=-1/0;return h.forEach(function(o){var _o$XY=_slicedToArray(o.XY,2),s=_o$XY[0],c=_o$XY[1];e=Math.min(e,s-r),n=Math.min(n,c-r),i=Math.max(i,s+r),a=Math.max(a,c+r);}),t.x=e,t.y=n,t.w=i-e,t.h=a-n,t;}function We(h,r){return!(h.x+h.w<r.x||h.x>r.x+r.w||h.y+h.h<r.y||h.y>r.y+r.h);}function bt(h){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;return{x:Math.floor(h.x-r),y:Math.floor(h.y-r),w:Math.ceil(h.w+r*2),h:Math.ceil(h.h+r*2)};}function Sr(h,r){return{x:h.x+r[0],y:h.y+r[1],w:h.w,h:h.h};}function zg(h,r){var t=new _(h.x,h.y),e=new _(h.x+h.w,h.y),n=new _(h.x+h.w,h.y+h.h),i=new _(h.x,h.y+h.h),a=new _(h.x+h.w/2,h.y+h.h/2),o=Math.PI*r/180,s=_.RotWith(t,a,o),c=_.RotWith(e,a,o),d=_.RotWith(n,a,o),l=_.RotWith(i,a,o);return[s,c,d,l];}function Ei(h,r){var t=zg(h,r);return Bt(t);}function Gg(h,r,t){var e=new _(h.x,h.y),n=new _(h.x+h.w,h.y),i=new _(h.x+h.w,h.y+h.h),a=new _(h.x,h.y+h.h),o=new _(t[0],t[1]),s=new _(r[0],r[1]),c=_.ScaleWOrigin(e,s,o),d=_.ScaleWOrigin(n,s,o),l=_.ScaleWOrigin(i,s,o),p=_.ScaleWOrigin(a,s,o);return Bt([c,d,l,p]);}function Hg(h,r,t){var e=new _(r[0],r[1]);for(var n=0;n<h.length;n+=3){var i=new _(h[n],h[n+1]),a=Math.PI*t/180,o=_.RotWith(i,e,a);h[n]=o.x,h[n+1]=o.y;}}function Kg(h,r,t){var e=new _(r[0],r[1]);for(var n=0;n<h.length;n+=2){var i=new _(h[n],h[n+1]),a=Math.PI*t/180,o=_.RotWith(i,e,a);h[n]=o.x,h[n+1]=o.y;}}function Ur(h,r,t){var e=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[0,0];var n=new _(r[0],r[1]);for(var i=0;i<h.length;i+=3){var a=new _(h[i],h[i+1]),o=new _(t[0],t[1]),s=_.ScaleWOrigin(a,o,n);h[i]=s.x+e[0],h[i+1]=s.y+e[1];}}function jr(h,r,t){var e=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[0,0];var n=new _(r[0],r[1]);for(var i=0;i<h.length;i+=2){var a=new _(h[i],h[i+1]),o=new _(t[0],t[1]),s=_.ScaleWOrigin(a,o,n);h[i]=s.x+e[0],h[i+1]=s.y+e[1];}}function Yg(h,r){return h[0]>=r.x&&h[0]<=r.x+r.w&&h[1]>=r.y&&h[1]<=r.y+r.h;}function Ci(h,r){var t=h<=r?1:h/r,e=r<=h?1:r/h;return[t,e];}function Vg(h){var _iterator38=_createForOfIteratorHelper(h),_step38;try{for(_iterator38.s();!(_step38=_iterator38.n()).done;){var r=_step38.value;if(isNaN(r)||r===1/0||r===-1/0)return!1;}}catch(err){_iterator38.e(err);}finally{_iterator38.f();}return!0;}function Xg(h){return h!==Math.floor(h);}function kg(h){var r=h.toString();return r.indexOf(".")!==-1?r.split(".")[1].length:0;}function Jg(h,r){for(;r!==0;){var _ref168=[r,h%r];h=_ref168[0];r=_ref168[1];}return h;}var Zg=function Zg(h){if(h.tagName==="GROUP"){var r=Object.getOwnPropertySymbols(h).find(function(t){return t.toString()==="Symbol(sealed)";});if(r&&h[r])return!0;}return!1;};function pe(h){return"".concat(Ze(h.x),",").concat(Ze(h.y)," ");}function me(h,r){return"".concat(Ze((h.x+r.x)/2),",").concat(Ze((h.y+r.y)/2)," ");}function Ze(h){return+h.toFixed(4);}var fr=function fr(h,r){return h.x+h.w<r.x||h.x>r.x+r.w||h.y+h.h<r.y||h.y>r.y+r.h?Te.outside:h.x>=r.x&&h.y>=r.y&&h.x+h.w<=r.x+r.w&&h.y+h.h<=r.y+r.h?Te.inside:Te.intersect;};function Qg(h){var r=0;for(var t=0;t<h.length;t++){var _e8=h.charCodeAt(t);_e8>=1&&_e8<=126||65376<=_e8&&_e8<=65439?r++:r+=2;}return r;}var we="cursorhover",Cn=20,Qe="mainView";var qg=/*#__PURE__*/function(){function qg(r,t){_classCallCheck(this,qg);et(this,"viewId");et(this,"scene");et(this,"fullLayer");et(this,"curNodeMap",/* @__PURE__ */new Map());et(this,"targetNodeMap",[]);et(this,"highLevelIds");et(this,"canClearUids");et(this,"localUid");this.viewId=r,this.scene=t;}return _createClass(qg,[{key:"init",value:function init(r){this.fullLayer=r;}},{key:"get",value:function get(r){return this.curNodeMap.get(r);}},{key:"setLocalUid",value:function setLocalUid(r){this.localUid=r;}},{key:"getLocalUid",value:function getLocalUid(){return this.localUid;}},{key:"setCanClearUids",value:function setCanClearUids(r){this.canClearUids=r;}},{key:"getCanClearUids",value:function getCanClearUids(){return this.canClearUids;}},{key:"getCanEraserNodes",value:function getCanEraserNodes(r,t){var e=/* @__PURE__ */new Map();var _iterator39=_createForOfIteratorHelper(r.entries()),_step39;try{for(_iterator39.s();!(_step39=_iterator39.n()).done;){var _step39$value=_slicedToArray(_step39.value,2),n=_step39$value[0],i=_step39$value[1];i.toolsType===ut.Image&&(i.opt.locked||t)||i.toolsType===ut.Text&&(i.opt.workState===It.Doing||i.opt.workState===It.Start)||this.isCanClearWorkId(n)&&e.set(n,i);}}catch(err){_iterator39.e(err);}finally{_iterator39.f();}return e;}},{key:"getNodesByType",value:function getNodesByType(r){var t=/* @__PURE__ */new Map();return this.curNodeMap.forEach(function(e,n){e.toolsType===r&&t.set(n,e);}),t;}},{key:"hasRenderNodes",value:function hasRenderNodes(){return!0;}},{key:"has",value:function has(r){return this.curNodeMap.has(r);}},{key:"setInfo",value:function setInfo(r,t){var e=this.curNodeMap.get(r)||{name:r,rect:t.rect};t.rect&&(e.rect=Xt(t.rect)),t.op&&Vg(t.op)&&(e.op=Xt(t.op)),t.canRotate&&(e.canRotate=t.canRotate),t.scaleType&&(e.scaleType=t.scaleType),t.opt&&(e.opt=Xt(t.opt)),t.toolsType&&(e.toolsType=t.toolsType),t.centerPos&&(e.centerPos=Xt(t.centerPos)),ye(t.isSelected)&&(e.isSelected=t.isSelected),e.rect?this.curNodeMap.set(r,e):this.curNodeMap["delete"](r);}},{key:"selected",value:function selected(r){this.setInfo(r,{isSelected:!0});}},{key:"unSelected",value:function unSelected(r){this.setInfo(r,{isSelected:!1});}},{key:"delete",value:function _delete(r){this.curNodeMap["delete"](r);}},{key:"clear",value:function clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0;}},{key:"getRectIntersectRange",value:function getRectIntersectRange(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var e=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!0;var n;var i=/* @__PURE__ */new Map();var _iterator40=_createForOfIteratorHelper(this.curNodeMap.entries()),_step40;try{for(_iterator40.s();!(_step40=_iterator40.n()).done;){var _step40$value=_slicedToArray(_step40.value,2),a=_step40$value[0],o=_step40$value[1];if(We(r,o.rect)){if(t&&o.toolsType===ut.Image&&o.opt.locked||e&&o.toolsType===ut.Text&&(o.opt.workState===It.Doing||o.opt.workState===It.Start))continue;n=Pt(n,o.rect),i.set(a,o);}}}catch(err){_iterator40.e(err);}finally{_iterator40.f();}return{rectRange:n,nodeRange:i};}},{key:"getNodeRectFormShape",value:function getNodeRectFormShape(r,t){var e=Pi(t.toolsType);return this.fullLayer&&(e==null?void 0:e.getRectFromLayer(this.fullLayer,r));}},{key:"updateNodeRect",value:function updateNodeRect(r){var t=this.curNodeMap.get(r);if(t){var _e9=this.getNodeRectFormShape(r,t);if(!_e9){this.curNodeMap["delete"](r);return;}t.rect=_e9,this.curNodeMap.set(r,t);}}},{key:"updateHighLevelNodesRect",value:function updateHighLevelNodesRect(r){this.highLevelIds=r;var _iterator41=_createForOfIteratorHelper(this.highLevelIds.keys()),_step41;try{for(_iterator41.s();!(_step41=_iterator41.n()).done;){var t=_step41.value;this.updateNodeRect(t);}}catch(err){_iterator41.e(err);}finally{_iterator41.f();}}},{key:"updateLowLevelNodesRect",value:function updateLowLevelNodesRect(){var r;var _iterator42=_createForOfIteratorHelper(this.curNodeMap.keys()),_step42;try{for(_iterator42.s();!(_step42=_iterator42.n()).done;){var t=_step42.value;(r=this.highLevelIds)!=null&&r.has(t)||this.updateNodeRect(t);}}catch(err){_iterator42.e(err);}finally{_iterator42.f();}}},{key:"clearHighLevelIds",value:function clearHighLevelIds(){this.highLevelIds=void 0;}},{key:"setTargetAssignKeys",value:function setTargetAssignKeys(r){var t=/* @__PURE__ */new Map();var _iterator43=_createForOfIteratorHelper(r),_step43;try{for(_iterator43.s();!(_step43=_iterator43.n()).done;){var _e10=_step43.value;var n=this.curNodeMap.get(_e10);n&&t.set(_e10,Xt(n));}}catch(err){_iterator43.e(err);}finally{_iterator43.f();}return this.targetNodeMap.push(Xt(t)),this.targetNodeMap.length-1;}},{key:"setTarget",value:function setTarget(){return this.targetNodeMap.push(Xt(this.curNodeMap)),this.targetNodeMap.length-1;}},{key:"getLastTarget",value:function getLastTarget(){return this.targetNodeMap[this.targetNodeMap.length-1];}},{key:"deleteLastTarget",value:function deleteLastTarget(){this.targetNodeMap.length&&(this.targetNodeMap.length=this.targetNodeMap.length-1);}},{key:"getTarget",value:function getTarget(r){return this.targetNodeMap[r];}},{key:"deleteTarget",value:function deleteTarget(r){this.targetNodeMap.length=r;}},{key:"clearTarget",value:function clearTarget(){this.targetNodeMap.length=0;}},{key:"isLocalWorkId",value:function isLocalWorkId(r){return r.split(De).length===1;}},{key:"isCanClearWorkId",value:function isCanClearWorkId(r){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(Iu(this.canClearUids)){var t=r.split(De);if(t.length===1)return this.canClearUids.has("localSelf")||this.localUid&&this.canClearUids.has(this.localUid);if(t.length===2)return this.canClearUids.has(t[0]);}return!1;}}]);}();var Ai=/*#__PURE__*/function(){function Ai(r,t,e){_classCallCheck(this,Ai);et(this,"viewId");et(this,"scene");et(this,"fullLayer");et(this,"vNodes");et(this,"dpr");et(this,"contextType");et(this,"opt");et(this,"cameraOpt");et(this,"isSafari",!1);et(this,"combinePostMsg",/* @__PURE__ */new Set());et(this,"workerTaskId");et(this,"protectedTask");et(this,"hasPriorityDraw",!0);et(this,"delayPostDoneResolve");et(this,"cacheImages",/* @__PURE__ */new Map());et(this,"imageResolveMap",/* @__PURE__ */new Map());var n,i;if(this.viewId=r,this.opt=t,this.dpr=t.dpr,this.contextType=this.getSupportContextType(e,(n=t==null?void 0:t.offscreenCanvasOpt)==null?void 0:n.contextType),!this.contextType)throw new Error("Sorry, your browser doesn't support canvas context type 2d or webgl");try{this.createRenderLayer(t);}catch(_unused25){if(this.contextType!=="2d")this.contextType="2d",(i=this.scene)==null||i.disconnect(),this.createRenderLayer(t);else throw new Error("Sorry, your browser doesn't support canvas context type ".concat(this.contextType));}this.vNodes=new qg(r,this.scene);}return _createClass(Ai,[{key:"createRenderLayer",value:function createRenderLayer(r){this.scene=this.createScene(r.offscreenCanvasOpt);var t=re.bufferSize.full,e=re.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",this.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:this.viewId===Qe?t:e}));}},{key:"updateDpr",value:function(){var _updateDpr=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(r){return _regeneratorRuntime().wrap(function _callee29$(_context31){while(1)switch(_context31.prev=_context31.next){case 0:this.dpr=r,this.scene.displayRatio=r;case 1:case"end":return _context31.stop();}},_callee29,this);}));function updateDpr(_x37){return _updateDpr.apply(this,arguments);}return updateDpr;}()},{key:"getCachedImages",value:function getCachedImages(r){var t;return(t=this.cacheImages.get(r))==null?void 0:t.imageBitmap;}},{key:"getCachedImagesByWorkId",value:function getCachedImagesByWorkId(r){var _iterator44=_createForOfIteratorHelper(this.cacheImages.entries()),_step44;try{for(_iterator44.s();!(_step44=_iterator44.n()).done;){var _step44$value=_slicedToArray(_step44.value,2),t=_step44$value[0],_e11=_step44$value[1];if(t===r&&_e11.imageBitmap)return _e11.imageBitmap;}}catch(err){_iterator44.e(err);}finally{_iterator44.f();}}},{key:"deleteCachedImagesByWorkId",value:function deleteCachedImagesByWorkId(r,t){var _iterator45=_createForOfIteratorHelper(this.cacheImages.entries()),_step45;try{for(_iterator45.s();!(_step45=_iterator45.n()).done;){var _step45$value=_slicedToArray(_step45.value,2),_e12=_step45$value[0],n=_step45$value[1];t&&_e12===t||n.workId===r&&(n.imageBitmap.close(),this.cacheImages["delete"](_e12));}}catch(err){_iterator45.e(err);}finally{_iterator45.f();}}},{key:"clearCacheImages",value:function clearCacheImages(){this.cacheImages.forEach(function(r){return r.imageBitmap.close();}),this.cacheImages.clear();}},{key:"clearImageResolveMap",value:function clearImageResolveMap(){this.imageResolveMap.forEach(function(_ref169){var r=_ref169.timer;r&&clearTimeout(r);}),this.imageResolveMap.clear();}},{key:"setHasPriorityDraw",value:function setHasPriorityDraw(r){this.hasPriorityDraw=r;}},{key:"getPriorityDraw",value:function getPriorityDraw(){return this.hasPriorityDraw;}},{key:"setIsSafari",value:function setIsSafari(r){this.isSafari=r;}},{key:"on",value:function(){var _on=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(r){var t,e,n,i,a,o,s,c,_c6,d,l,p;return _regeneratorRuntime().wrap(function _callee30$(_context32){while(1)switch(_context32.prev=_context32.next){case 0:t=r.msgType,e=r.toolsType,n=r.opt,i=r.imageSrc,a=r.imageBitmap,o=r.workId,s=r.dpr;_context32.t0=t;_context32.next=_context32.t0===ot.UpdateDpr?4:_context32.t0===ot.UpdateCamera?9:_context32.t0===ot.Destroy?12:_context32.t0===ot.Clear?14:_context32.t0===ot.UpdateTools?17:_context32.t0===ot.GetImageBitMap?19:21;break;case 4:_context32.t1=Zt(s);if(!_context32.t1){_context32.next=8;break;}_context32.next=8;return this.updateDpr(s);case 8:return _context32.abrupt("break",21);case 9:_context32.next=11;return this.updateCamera(r);case 11:return _context32.abrupt("break",21);case 12:this.destroy();return _context32.abrupt("break",21);case 14:_context32.next=16;return this.clearAll();case 16:return _context32.abrupt("break",21);case 17:if(e&&n){c={toolsType:e,toolsOpt:n};this.localWork.setToolsOpt(c);}return _context32.abrupt("break",21);case 19:if(i&&a&&o){_c6=o.toString();this.cacheImages.set(i,{imageBitmap:a,workId:_c6});d=this.imageResolveMap.get(i);if(d){l=d.resolve,p=d.timer;p&&clearTimeout(p),l&&l(i);}this.deleteCachedImagesByWorkId(_c6,i);}return _context32.abrupt("break",21);case 21:case"end":return _context32.stop();}},_callee30,this);}));function on(_x38){return _on.apply(this,arguments);}return on;}()},{key:"getIconSize",value:function getIconSize(r,t,e){var n=r*e,i=t*e;return n<=50||i<=50?[50,50]:n<=100||i<=100?[100,100]:n<=200||i<=200?[200,200]:n<=400||i<=400?[400,400]:n<=800||i<=800?[800,800]:[1600,1600];}},{key:"loadImageBitMap",value:function(){var _loadImageBitMap=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(r){var _this88=this;var t,e,n,i,a,o,s,c,d,l,p,_this$getIconSize,_this$getIconSize2,v,_T40,_v9,_v10,x;return _regeneratorRuntime().wrap(function _callee31$(_context33){while(1)switch(_context33.prev=_context33.next){case 0:t=r.toolsType,e=r.opt,n=r.workId,i=r.isSubWorker;if(!(t===ut.Image&&e&&n)){_context33.next=19;break;}a=n.toString(),o=e.src,s=e.type,c=e.width,d=e.height,l=e.strokeColor;if(!(!o||!s||!c||!d)){_context33.next=5;break;}return _context33.abrupt("return");case 5:p=o;if(s===xr.Iconify){_this$getIconSize=this.getIconSize(c,d,this.dpr),_this$getIconSize2=_slicedToArray(_this$getIconSize,2),v=_this$getIconSize2[0],_T40=_this$getIconSize2[1];p="".concat(o,"?width=").concat(v,"&height=").concat(_T40,"&color=").concat(l);}if(!this.cacheImages.has(p)){_context33.next=11;break;}_v9=this.getCachedImages(p);if(!_v9){_context33.next=11;break;}return _context33.abrupt("return",_v9);case 11:if(!this.imageResolveMap.has(p)){_context33.next=15;break;}_v10=this.getCachedImagesByWorkId(a);if(!_v10){_context33.next=15;break;}return _context33.abrupt("return",_v10);case 15:_context33.next=17;return new Promise(function(v){var T=_this88.imageResolveMap.get(p)||{resolve:void 0,timer:void 0};T.timer&&clearTimeout(T.timer),T.resolve=v,T.timer=setTimeout(function(){var f=_this88.imageResolveMap.get(p);f!=null&&f.resolve&&f.resolve(p);},5e3),_this88.imageResolveMap.set(p,T),_this88._post({sp:[{imageSrc:p,workId:a,viewId:_this88.viewId,isgl:!!_this88.fullLayer.parent.gl,isSubWorker:i,type:ot.GetImageBitMap}]});});case 17:x=_context33.sent;return _context33.abrupt("return",(this.imageResolveMap["delete"](x),this.getCachedImages(p)));case 19:case"end":return _context33.stop();}},_callee31,this);}));function loadImageBitMap(_x39){return _loadImageBitMap.apply(this,arguments);}return loadImageBitMap;}()},{key:"createLocalWork",value:function createLocalWork(r){var t=r.workId,e=r.opt,n=r.toolsType;t&&e&&(!this.localWork.getToolsOpt()&&n&&this.setToolsOpt({toolsType:n,toolsOpt:e}),this.setWorkOpt({workId:t,toolsOpt:e}));}},{key:"updateScene",value:function updateScene(r){this.scene.attr(_objectSpread({},r));var t=r.width,e=r.height;this.scene.container.width=t,this.scene.container.height=e,this.scene.width=t,this.scene.height=e,this.updateLayer({width:t,height:e});}},{key:"updateLayer",value:function updateLayer(r){var t=r.width,e=r.height;this.fullLayer&&(this.fullLayer.parent.setAttribute("width",t),this.fullLayer.parent.setAttribute("height",e),this.fullLayer.setAttribute("size",[t,e]),this.fullLayer.setAttribute("pos",[t*0.5,e*0.5]));}},{key:"getSupportContextType",value:function getSupportContextType(r,t){var e=new OffscreenCanvas(100,100);var n=["2d"];r===qe.Full&&this.viewId===Qe&&(n=["webgl2","webgl","2d"],t&&n.unshift(t));for(var _i9=0,_n7=n;_i9<_n7.length;_i9++){var i=_n7[_i9];try{if(e.getContext(i))return i;}catch(_unused26){continue;}}}},{key:"createScene",value:function createScene(r){var t=r.width,e=r.height,n=new OffscreenCanvas(t,e);r.contextType&&delete r.contextType;var i=new ts(_objectSpread(_objectSpread({container:n,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0},r),{},{contextType:this.contextType,id:this.viewId}));return i.setAttribute("id",this.viewId),i;}},{key:"createLayer",value:function createLayer(r,t,e){var n=e.width,i=e.height,a="offscreen-".concat(r),o=t.layer(a,e),s=new kt({anchor:[0.5,0.5],pos:[n*0.5,i*0.5],size:[n,i],name:"viewport",id:r});return o.append(s),s;}},{key:"clearAll",value:function(){var _clearAll=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(){var r;return _regeneratorRuntime().wrap(function _callee32$(_context34){while(1)switch(_context34.prev=_context34.next){case 0:this.fullLayer&&(this.fullLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),this.fullLayer.removeAllChildren()),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(r=this.serviceWork)==null||r.destroy();case 1:case"end":return _context34.stop();}},_callee32,this);}));function clearAll(){return _clearAll.apply(this,arguments);}return clearAll;}()},{key:"setToolsOpt",value:function setToolsOpt(r){this.localWork.setToolsOpt(r);}},{key:"setWorkOpt",value:function setWorkOpt(r){var t=r.workId,e=r.toolsOpt;t&&e&&this.localWork.setWorkOptions(t.toString(),e);}},{key:"destroy",value:function destroy(){var r;this.vNodes.clear(),this.fullLayer.remove(),this.clearCacheImages(),this.clearImageResolveMap(),this.scene.remove(),this.localWork.destroy(),(r=this.serviceWork)==null||r.destroy();}},{key:"post",value:function(){var _post=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee33(r){return _regeneratorRuntime().wrap(function _callee33$(_context35){while(1)switch(_context35.prev=_context35.next){case 0:this.combinePostMsg.add(r);_context35.next=3;return this.runBatchPostData();case 3:case"end":return _context35.stop();}},_callee33,this);}));function post(_x40){return _post.apply(this,arguments);}return post;}()},{key:"runBatchPostData",value:function(){var _runBatchPostData=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(){var _this89=this;return _regeneratorRuntime().wrap(function _callee34$(_context36){while(1)switch(_context36.prev=_context36.next){case 0:this.workerTaskId||(this.workerTaskId=setTimeout(function(){_this89.workerTaskId=void 0,_this89.combinePost();},16));_context36.t0=this.type===qe.Full&&!this.delayPostDoneResolve;if(!_context36.t0){_context36.next=6;break;}_context36.next=5;return new Promise(function(t){_this89.delayPostDoneResolve=t;});case 5:_context36.t0=_context36.sent;case 6:_context36.t1=_context36.t0;if(!_context36.t1){_context36.next=9;break;}this.delayPostDoneResolve=void 0;case 9:case"end":return _context36.stop();}},_callee34,this);}));function runBatchPostData(){return _runBatchPostData.apply(this,arguments);}return runBatchPostData;}()},{key:"combinePostData",value:function combinePostData(){var i,a;this.workerTaskId=void 0;var r=[],t=[];var e;var n=/* @__PURE__ */new Set();var _iterator46=_createForOfIteratorHelper(this.combinePostMsg.values()),_step46;try{for(_iterator46.s();!(_step46=_iterator46.n()).done;){var o=_step46.value;if((i=o.render)!=null&&i.length){var _iterator47=_createForOfIteratorHelper(o.render),_step47;try{for(_iterator47.s();!(_step47=_iterator47.n()).done;){var s=_step47.value;var c=!1;if(s.workId&&n.add(s.workId),s.isClearAll&&(s.rect=this.getSceneRect(),s.isClear=!0,delete s.isClearAll),s.drawCanvas){var d=this.getLayer(s.drawCanvas);if(!d||!(d.parent instanceof _i))continue;if(d.parent.render(),s.isDrawAll){var l=this.getSceneRect();s.rect=l,delete s.isDrawAll;}}var _iterator48=_createForOfIteratorHelper(r),_step48;try{for(_iterator48.s();!(_step48=_iterator48.n()).done;){var _d11=_step48.value;if(s.viewId===_d11.viewId){s.isClear&&_d11.clearCanvas&&_d11.isClear&&_d11.clearCanvas===s.clearCanvas&&(_d11.rect=Pt(_d11.rect,s.rect),c=!0),_d11.drawCanvas&&_d11.drawCanvas===s.drawCanvas&&(_d11.rect=Pt(_d11.rect,s.rect),c=!0);continue;}}}catch(err){_iterator48.e(err);}finally{_iterator48.f();}c||(s.isClear&&!s.drawCanvas?r.unshift(s):r.push(s));}}catch(err){_iterator47.e(err);}finally{_iterator47.f();}}if((a=o.sp)!=null&&a.length){var _iterator49=_createForOfIteratorHelper(o.sp),_step49;try{for(_iterator49.s();!(_step49=_iterator49.n()).done;){var _s6=_step49.value;var _c7=!1;var _iterator50=_createForOfIteratorHelper(t),_step50;try{for(_iterator50.s();!(_step50=_iterator50.n()).done;){var _d12=_step50.value;if(oe(_s6,_d12)){_c7=!0;break;}}}catch(err){_iterator50.e(err);}finally{_iterator50.f();}_c7||t.push(_s6);}}catch(err){_iterator49.e(err);}finally{_iterator49.f();}}Zt(o.drawCount)&&(e=o.drawCount);}}catch(err){_iterator46.e(err);}finally{_iterator46.f();}return this.combinePostMsg.clear(),{render:r,sp:t,drawCount:e,workIds:n,viewId:this.viewId};}},{key:"safariFixRect",value:function safariFixRect(r,t){if(r.w+r.x<=0||r.h+r.y<=0||r.w<=0||r.h<=0)return;var e=this.scene.width,n=this.scene.height,i={x:Math.floor(Math.max(0,r.x)),y:Math.floor(Math.max(0,r.y)),w:Math.floor(Math.min(e,r.w)),h:Math.floor(Math.min(n,r.h))};if(i.x+i.w>e&&(i.w=Math.floor(e-i.x)),i.y+i.h>n&&(i.h=Math.floor(n-i.y)),Xg(t)){var a=kg(t),o=Math.pow(10,a),s=Jg(o,t*o),c=i.x%s,d=i.x-c;d>=0?(i.x=d,i.w=i.w+c):(i.x=0,i.w=i.w+c-d);var l=i.y%s,p=i.y-l;p>=0?(i.y=p,i.h=i.h+l):(i.y=0,i.h=i.h+l-p);}return i;}},{key:"getSceneRect",value:function getSceneRect(){var _this$scene=this.scene,r=_this$scene.width,t=_this$scene.height;return{x:0,y:0,w:Math.floor(r),h:Math.floor(t)};}}]);}();var Ri=/*#__PURE__*/function(){function Ri(r){_classCallCheck(this,Ri);et(this,"viewId");et(this,"vNodes");et(this,"thread");et(this,"fullLayer");et(this,"drawLayer");et(this,"_post");et(this,"tmpOpt");et(this,"workShapes",/* @__PURE__ */new Map());et(this,"drawCount",0);et(this,"syncUnitTime",re.syncOpt.interval);this.thread=r.thread,this.viewId=r.viewId,this.vNodes=r.vNodes,this.fullLayer=r.fullLayer,this.drawLayer=r.drawLayer,this._post=this.thread.post.bind(r.thread);}return _createClass(Ri,[{key:"destroy",value:function destroy(){this.workShapes.clear();}},{key:"getWorkShapes",value:function getWorkShapes(){return this.workShapes;}},{key:"getWorkShape",value:function getWorkShape(r){return this.workShapes.get(r);}},{key:"createWorkShape",value:function createWorkShape(r,t){if(r&&this.tmpOpt){var _e13={toolsType:this.tmpOpt.toolsType,toolsOpt:t||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode(_objectSpread(_objectSpread({},_e13),{},{workId:r}));n&&this.workShapes.set(r,n);}}},{key:"setWorkOptions",value:function setWorkOptions(r,t){var e=this.getWorkShape(r);e||this.createWorkShape(r,t),e==null||e.setWorkOptions(t);}},{key:"createWorkShapeNode",value:function createWorkShapeNode(r){var t;return Fr(_objectSpread(_objectSpread({},r),{},{vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer}),(t=this.thread)==null?void 0:t.serviceWork);}},{key:"setToolsOpt",value:function setToolsOpt(r){var t,e,n;((t=this.tmpOpt)==null?void 0:t.toolsType)!==r.toolsType&&(e=this.tmpOpt)!=null&&e.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=r,(n=r.toolsOpt)!=null&&n.syncUnitTime&&(this.syncUnitTime=r.toolsOpt.syncUnitTime);}},{key:"getToolsOpt",value:function getToolsOpt(){return this.tmpOpt;}},{key:"clearWorkShapeNodeCache",value:function clearWorkShapeNodeCache(r){var t;(t=this.getWorkShape(r))==null||t.clearTmpPoints(),this.workShapes["delete"](r);}},{key:"clearAllWorkShapesCache",value:function clearAllWorkShapesCache(){this.workShapes.forEach(function(r){return r.clearTmpPoints();}),this.workShapes.clear();}},{key:"setFullWork",value:function setFullWork(r){var t=r.workId,e=r.opt,n=r.toolsType;if(t&&e&&n){var i=t.toString();var a;return t&&this.workShapes.has(i)?(a=this.workShapes.get(i),a==null||a.setWorkOptions(e)):a=this.createWorkShapeNode({toolsOpt:e,toolsType:n,workId:i}),a?(this.workShapes.set(i,a),a):void 0;}}}]);}();var _g=ee,t0=function t0(){return _g.Date.now();},e0=t0,r0=/\s/;function n0(h){for(var r=h.length;r--&&r0.test(h.charAt(r)););return r;}var i0=n0,s0=i0,o0=/^\s+/;function a0(h){return h&&h.slice(0,s0(h)+1).replace(o0,"");}var l0=a0,c0=de,f0=ne,h0="[object Symbol]";function u0(h){return _typeof(h)=="symbol"||f0(h)&&c0(h)==h0;}var d0=u0,g0=l0,An=he,p0=d0,Rn=NaN,m0=/^[-+]0x[0-9a-f]+$/i,v0=/^0b[01]+$/i,y0=/^0o[0-7]+$/i,S0=parseInt;function x0(h){if(typeof h=="number")return h;if(p0(h))return Rn;if(An(h)){var r=typeof h.valueOf=="function"?h.valueOf():h;h=An(r)?r+"":r;}if(typeof h!="string")return h===0?h:+h;h=g0(h);var t=v0.test(h);return t||y0.test(h)?S0(h.slice(2),t?2:8):m0.test(h)?Rn:+h;}var T0=x0,M0=he,hr=e0,In=T0,P0="Expected a function",O0=Math.max,E0=Math.min;function C0(h,r,t){var e,n,i,a,o,s,c=0,d=!1,l=!1,p=!0;if(typeof h!="function")throw new TypeError(P0);r=In(r)||0,M0(t)&&(d=!!t.leading,l="maxWait"in t,i=l?O0(In(t.maxWait)||0,r):i,p="trailing"in t?!!t.trailing:p);function y(M){var E=e,A=n;return e=n=void 0,c=M,a=h.apply(A,E),a;}function P(M){return c=M,o=setTimeout(T,r),d?y(M):a;}function x(M){var E=M-s,A=M-c,w=r-E;return l?E0(w,i-A):w;}function v(M){var E=M-s,A=M-c;return s===void 0||E>=r||E<0||l&&A>=i;}function T(){var M=hr();if(v(M))return f(M);o=setTimeout(T,x(M));}function f(M){return o=void 0,p&&e?y(M):(e=n=void 0,a);}function g(){o!==void 0&&clearTimeout(o),c=0,e=s=n=o=void 0;}function u(){return o===void 0?a:f(hr());}function m(){var M=hr(),E=v(M);if(e=arguments,n=this,s=M,E){if(o===void 0)return P(s);if(l)return clearTimeout(o),o=setTimeout(T,r),y(s);}return o===void 0&&(o=setTimeout(T,r)),a;}return m.cancel=g,m.flush=u,m;}var A0=C0,R0=A0,I0=he,L0="Expected a function";function w0(h,r,t){var e=!0,n=!0;if(typeof h!="function")throw new TypeError(L0);return I0(t)&&(e="leading"in t?!!t.leading:e,n="trailing"in t?!!t.trailing:n),R0(h,r,{leading:e,maxWait:r,trailing:n});}var b0=w0,D0=/* @__PURE__ */fe(b0);function N0(h){return h;}var Ii=N0;function W0(h,r,t){switch(t.length){case 0:return h.call(r);case 1:return h.call(r,t[0]);case 2:return h.call(r,t[0],t[1]);case 3:return h.call(r,t[0],t[1],t[2]);}return h.apply(r,t);}var B0=W0,F0=B0,Ln=Math.max;function U0(h,r,t){return r=Ln(r===void 0?h.length-1:r,0),function(){for(var e=arguments,n=-1,i=Ln(e.length-r,0),a=Array(i);++n<i;)a[n]=e[r+n];n=-1;for(var o=Array(r+1);++n<r;)o[n]=e[n];return o[r]=t(a),F0(h,this,o);};}var j0=U0;function $0(h){return function(){return h;};}var z0=$0,G0=z0,wn=Gn,H0=Ii,K0=wn?function(h,r){return wn(h,"toString",{configurable:!0,enumerable:!1,value:G0(r),writable:!0});}:H0,Y0=K0,V0=800,X0=16,k0=Date.now;function J0(h){var r=0,t=0;return function(){var e=k0(),n=X0-(e-t);if(t=e,n>0){if(++r>=V0)return arguments[0];}else r=0;return h.apply(void 0,arguments);};}var Z0=J0,Q0=Y0,q0=Z0,_0=q0(Q0),tp=_0,ep=Ii,rp=j0,np=tp;function ip(h,r){return np(rp(h,r,ep),h+"");}var sp=ip;function op(h,r,t,e){for(var n=h.length,i=t+(e?1:-1);e?i--:++i<n;)if(r(h[i],i,h))return i;return-1;}var ap=op;function lp(h){return h!==h;}var cp=lp;function fp(h,r,t){for(var e=t-1,n=h.length;++e<n;)if(h[e]===r)return e;return-1;}var hp=fp,up=ap,dp=cp,gp=hp;function pp(h,r,t){return r===r?gp(h,r,t):up(h,dp,t);}var mp=pp,vp=mp;function yp(h,r){var t=h==null?0:h.length;return!!t&&vp(h,r,0)>-1;}var Li=yp;function Sp(h,r,t){for(var e=-1,n=h==null?0:h.length;++e<n;)if(t(r,h[e]))return!0;return!1;}var wi=Sp;function xp(h,r){for(var t=-1,e=h==null?0:h.length,n=Array(e);++t<e;)n[t]=r(h[t],t,h);return n;}var Tp=xp,Mp=Nr,Pp=Li,Op=wi,Ep=Tp,Cp=sr,Ap=Wr,Rp=200;function Ip(h,r,t,e){var n=-1,i=Pp,a=!0,o=h.length,s=[],c=r.length;if(!o)return s;t&&(r=Ep(r,Cp(t))),e?(i=Op,a=!1):r.length>=Rp&&(i=Ap,a=!1,r=new Mp(r));t:for(;++n<o;){var d=h[n],l=t==null?d:t(d);if(d=e||d!==0?d:0,a&&l===l){for(var p=c;p--;)if(r[p]===l)continue t;s.push(d);}else i(r,l,e)||s.push(d);}return s;}var Lp=Ip,bn=Be,wp=Vn,bp=Fe,Dn=bn?bn.isConcatSpreadable:void 0;function Dp(h){return bp(h)||wp(h)||!!(Dn&&h&&h[Dn]);}var Np=Dp,Wp=Lr,Bp=Np;function bi(h,r,t,e,n){var i=-1,a=h.length;for(t||(t=Bp),n||(n=[]);++i<a;){var o=h[i];r>0&&t(o)?r>1?bi(o,r-1,t,e,n):Wp(n,o):e||(n[n.length]=o);}return n;}var Fp=bi;function Up(){}var jp=Up,ur=ni,$p=jp,zp=Br,Gp=1/0,Hp=ur&&1/zp(new ur([,-0]))[1]==Gp?function(h){return new ur(h);}:$p,Kp=Hp,Yp=Nr,Vp=Li,Xp=wi,kp=Wr,Jp=Kp,Zp=Br,Qp=200;function qp(h,r,t){var e=-1,n=Vp,i=h.length,a=!0,o=[],s=o;if(t)a=!1,n=Xp;else if(i>=Qp){var c=r?null:Jp(h);if(c)return Zp(c);a=!1,n=kp,s=new Yp();}else s=r?[]:o;t:for(;++e<i;){var d=h[e],l=r?r(d):d;if(d=t||d!==0?d:0,a&&l===l){for(var p=s.length;p--;)if(s[p]===l)continue t;r&&s.push(l),o.push(d);}else n(s,l,t)||(s!==o&&s.push(l),o.push(d));}return o;}var _p=qp,tm=Lp,em=Fp,Nn=_p;function rm(h,r,t){var e=h.length;if(e<2)return e?Nn(h[0]):[];for(var n=-1,i=Array(e);++n<e;)for(var a=h[n],o=-1;++o<e;)o!=n&&(i[n]=tm(i[n]||a,h[o],r,t));return Nn(em(i,1),r,t);}var nm=rm,im=Cr,sm=ne;function om(h){return sm(h)&&im(h);}var am=om,lm=Qn,cm=sp,fm=nm,hm=am,um=cm(function(h){return fm(lm(h,hm));}),dm=um,gm=/* @__PURE__ */fe(dm);var pm=/*#__PURE__*/function(_Ri){function pm(t){var _this90;_classCallCheck(this,pm);_this90=_callSuper(this,pm,[t]);et(_this90,"combineUnitTime",re.bezier.combineUnitTime);et(_this90,"combineTimerId");et(_this90,"combineDrawResolve");et(_this90,"combineDrawActiveId");et(_this90,"drawWorkActiveId");et(_this90,"effectSelectNodeData",/* @__PURE__ */new Set());et(_this90,"batchEraserWorks",/* @__PURE__ */new Set());et(_this90,"batchEraserRemoveNodes",/* @__PURE__ */new Set());et(_this90,"batchEraserCombine",D0(function(){var t=_this90.updateBatchEraserCombineNode(_this90.batchEraserWorks,_this90.batchEraserRemoveNodes);_this90.batchEraserWorks.clear(),_this90.batchEraserRemoveNodes.clear(),t.length&&_this90._post({render:t});},200,{leading:!1}));return _this90;}_inherits(pm,_Ri);return _createClass(pm,[{key:"loadImageBitMap",value:function(){var _loadImageBitMap2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(t){return _regeneratorRuntime().wrap(function _callee35$(_context37){while(1)switch(_context37.prev=_context37.next){case 0:_context37.next=2;return this.thread.loadImageBitMap(t);case 2:return _context37.abrupt("return",_context37.sent);case 3:case"end":return _context37.stop();}},_callee35,this);}));function loadImageBitMap(_x41){return _loadImageBitMap2.apply(this,arguments);}return loadImageBitMap;}()},{key:"consumeDraw",value:function(){var _consumeDraw=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(t,e){var _this91=this;var n,i,a,o,s,c,d;return _regeneratorRuntime().wrap(function _callee36$(_context38){while(1)switch(_context38.prev=_context38.next){case 0:n=t.op,i=t.workId,a=t.scenePath;if(!(n!=null&&n.length&&i)){_context38.next=57;break;}o=i.toString(),s=this.getWorkShape(o);if(s){_context38.next=5;break;}return _context38.abrupt("return");case 5:c=s.toolsType;if(!(c===ut.LaserPen)){_context38.next=8;break;}return _context38.abrupt("return");case 8:_context38.t0=this.combineDrawActiveId&&this.combineDrawActiveId!==o;if(!_context38.t0){_context38.next=13;break;}this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1),this.combineDrawActiveId=void 0);_context38.next=13;return this.consumeDrawAll({workId:this.combineDrawActiveId,scenePath:a,viewId:this.viewId,msgType:ot.DrawWork,dataType:Mt.Local},e);case 13:_context38.t1=this.drawWorkActiveId&&this.drawWorkActiveId!==o;if(!_context38.t1){_context38.next=18;break;}_context38.next=17;return this.consumeDrawAll({workId:this.drawWorkActiveId,scenePath:a,viewId:this.viewId,msgType:ot.DrawWork,dataType:Mt.Local},e);case 17:this.drawWorkActiveId=void 0;case 18:!this.drawWorkActiveId&&o!==Nt&&(this.drawWorkActiveId=o);d=s.consume({data:t,isFullWork:!0});_context38.t2=c;_context38.next=_context38.t2===ut.Selector?23:_context38.t2===ut.PencilEraser?29:_context38.t2===ut.BitMapEraser?34:_context38.t2===ut.Eraser?39:_context38.t2===ut.Arrow?44:_context38.t2===ut.Straight?44:_context38.t2===ut.Ellipse?44:_context38.t2===ut.Rectangle?44:_context38.t2===ut.Star?44:_context38.t2===ut.Polygon?44:_context38.t2===ut.SpeechBalloon?44:_context38.t2===ut.Pencil?50:57;break;case 23:_context38.t3=d.type===ot.Select;if(!_context38.t3){_context38.next=28;break;}d.selectIds&&e.runReverseSelectWork(d.selectIds);_context38.next=28;return this.drawSelector(d);case 28:return _context38.abrupt("break",57);case 29:_context38.t4=d!=null&&d.rect;if(!_context38.t4){_context38.next=33;break;}_context38.next=33;return this.drawPencilEraser(d);case 33:return _context38.abrupt("break",57);case 34:_context38.t5=d!=null&&d.rect;if(!_context38.t5){_context38.next=38;break;}_context38.next=38;return this.drawBitMapEraser(d);case 38:return _context38.abrupt("break",57);case 39:_context38.t6=d!=null&&d.rect;if(!_context38.t6){_context38.next=43;break;}_context38.next=43;return this.drawEraser(d);case 43:return _context38.abrupt("break",57);case 44:_context38.t7=d;if(!_context38.t7){_context38.next=49;break;}this.drawCount++;_context38.next=49;return this.drawShape(d);case 49:return _context38.abrupt("break",57);case 50:this.drawCount++;this.combineTimerId||new Promise(function(l){_this91.combineDrawActiveId=o,_this91.combineDrawResolve=l,_this91.combineTimerId=setTimeout(function(){_this91.combineTimerId=void 0,_this91.combineDrawResolve&&_this91.combineDrawResolve(!0);},_this91.combineUnitTime);}).then(function(l){l&&_this91.drawPencilCombine(o,_this91.drawCount),_this91.combineDrawResolve=void 0;});_context38.t8=d;if(!_context38.t8){_context38.next=56;break;}_context38.next=56;return this.drawPencil(d);case 56:return _context38.abrupt("break",57);case 57:case"end":return _context38.stop();}},_callee36,this);}));function consumeDraw(_x42,_x43){return _consumeDraw.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(t,e){var o,s,c,d,n,i,a,l,p,y,P,x,v;return _regeneratorRuntime().wrap(function _callee37$(_context39){while(1)switch(_context39.prev=_context39.next){case 0:this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1),this.combineDrawActiveId=void 0);n=t.workId,i=t.scenePath,a=t.isLockSentEventCursor;if(!n){_context39.next=42;break;}l=n.toString();this.drawWorkActiveId===l&&(this.drawWorkActiveId=void 0);p=this.workShapes.get(l);if(p){_context39.next=8;break;}return _context39.abrupt("return");case 8:y=p.toolsType;if(!(y===ut.LaserPen)){_context39.next=11;break;}return _context39.abrupt("return");case 11:P=this.workShapes.get(we),x=(o=P==null?void 0:P.selectIds)==null?void 0:o[0],v=p.consumeAll({data:t});_context39.t0=y;_context39.next=_context39.t0===ut.Selector?15:_context39.t0===ut.PencilEraser?21:_context39.t0===ut.BitMapEraser?23:_context39.t0===ut.Eraser?28:_context39.t0===ut.Arrow?30:_context39.t0===ut.Straight?30:_context39.t0===ut.Ellipse?30:_context39.t0===ut.Rectangle?30:_context39.t0===ut.Star?30:_context39.t0===ut.Polygon?30:_context39.t0===ut.SpeechBalloon?30:_context39.t0===ut.Pencil?35:42;break;case 15:v.selectIds&&x&&(s=v.selectIds)!=null&&s.includes(x)&&P.cursorBlur();v.selectIds&&e.runReverseSelectWork(v.selectIds);_context39.next=19;return this.drawSelector(_objectSpread(_objectSpread({},v),{},{scenePath:i}));case 19:(c=p.selectIds)!=null&&c.length?p.clearTmpPoints():this.clearWorkShapeNodeCache(l);return _context39.abrupt("break",42);case 21:this.drawPencilEraser(_objectSpread(_objectSpread({},v),{},{scenePath:i}),a),p.clearTmpPoints();return _context39.abrupt("break",42);case 23:_context39.t1=v.rect||(d=v.newWorkDatas)!=null&&d.size;if(!_context39.t1){_context39.next=27;break;}_context39.next=27;return this.drawBitMapEraserFull(p,v,a);case 27:return _context39.abrupt("break",42);case 28:this.drawEraser(_objectSpread(_objectSpread({},v),{},{scenePath:i}),a),p.clearTmpPoints();return _context39.abrupt("break",42);case 30:_context39.next=32;return this.drawPencilFull(_objectSpread(_objectSpread({},v),{},{scenePath:i}),a);case 32:this.drawCount=0;this.clearWorkShapeNodeCache(l);return _context39.abrupt("break",42);case 35:_context39.t2=v!=null&&v.rect;if(!_context39.t2){_context39.next=40;break;}_context39.next=39;return this.drawPencilFull(_objectSpread(_objectSpread({},v),{},{scenePath:i}),a);case 39:this.drawCount=0;case 40:this.clearWorkShapeNodeCache(l);return _context39.abrupt("break",42);case 42:case"end":return _context39.stop();}},_callee37,this);}));function consumeDrawAll(_x44,_x45){return _consumeDrawAll.apply(this,arguments);}return consumeDrawAll;}()},{key:"workShapesDone",value:function(){var _workShapesDone=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(t,e){var _iterator51,_step51,n;return _regeneratorRuntime().wrap(function _callee38$(_context40){while(1)switch(_context40.prev=_context40.next){case 0:_iterator51=_createForOfIteratorHelper(this.workShapes.keys());_context40.prev=1;_iterator51.s();case 3:if((_step51=_iterator51.n()).done){_context40.next=9;break;}n=_step51.value;_context40.next=7;return this.consumeDrawAll({workId:n,scenePath:t,viewId:this.viewId,msgType:ot.DrawWork,dataType:Mt.Local},e);case 7:_context40.next=3;break;case 9:_context40.next=14;break;case 11:_context40.prev=11;_context40.t0=_context40["catch"](1);_iterator51.e(_context40.t0);case 14:_context40.prev=14;_iterator51.f();return _context40.finish(14);case 17:case"end":return _context40.stop();}},_callee38,this,[[1,11,14,17]]);}));function workShapesDone(_x46,_x47){return _workShapesDone.apply(this,arguments);}return workShapesDone;}()},{key:"consumeFull",value:function(){var _consumeFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee39(t){var i,a,e,n,o,s,c,d,l,p,y;return _regeneratorRuntime().wrap(function _callee39$(_context41){while(1)switch(_context41.prev=_context41.next){case 0:e=this.setFullWork(t),n=t.ops&&Me(t.ops)||t.op;if(!e){_context41.next=26;break;}o=(i=t.workId)==null?void 0:i.toString();if(o){_context41.next=5;break;}return _context41.abrupt("return");case 5:s=(a=this.vNodes.get(o))==null?void 0:a.rect;if(!(e.toolsType===ut.Image)){_context41.next=13;break;}_context41.next=9;return e.consumeServiceAsync({isFullWork:!0,replaceId:o,worker:this});case 9:c=_context41.sent;d=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt);_context41.next=20;break;case 13:if(!(e.toolsType===ut.Text)){_context41.next=19;break;}_context41.next=16;return e.consumeServiceAsync({isFullWork:!0,replaceId:o});case 16:c=_context41.sent;_context41.next=20;break;case 19:c=e.consumeService({op:n,isFullWork:!0,replaceId:o}),d=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt);case 20:c=Pt(c,d);l=[],p=[];if(!(t.workId&&this.workShapes["delete"](t.workId.toString()),c&&t.willRefresh&&(s&&l.push({rect:bt(s),isClear:!0,clearCanvas:St.Bg,viewId:this.viewId}),l.push({rect:bt(c),drawCanvas:St.Bg,viewId:this.viewId})),t.willSyncService&&p.push({opt:t.opt,toolsType:t.toolsType,type:ot.FullWork,workId:t.workId,ops:t.ops,updateNodeOpt:t.updateNodeOpt,viewId:this.viewId}),l.length||p.length)){_context41.next=26;break;}y={render:l,sp:p};_context41.next=26;return this._post(y);case 26:case"end":return _context41.stop();}},_callee39,this);}));function consumeFull(_x48){return _consumeFull.apply(this,arguments);}return consumeFull;}()},{key:"commandDeleteText",value:function commandDeleteText(t){var e=this.vNodes.get(t);if(e&&e.toolsType===ut.Text)return{type:ot.TextUpdate,toolsType:ut.Text,workId:t,dataType:Mt.Local};}},{key:"removeSelector",value:function(){var _removeSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee40(t,e){var n,i,a,o,s,c,_iterator52,_step52,d,y,p;return _regeneratorRuntime().wrap(function _callee40$(_context42){while(1)switch(_context42.prev=_context42.next){case 0:n=t.willSyncService,i=[],a=[],o=[],s=this.workShapes.get(Nt);if(s){_context42.next=3;break;}return _context42.abrupt("return");case 3:c=s.selectIds&&_toConsumableArray(s.selectIds)||[];_iterator52=_createForOfIteratorHelper(c);try{for(_iterator52.s();!(_step52=_iterator52.n()).done;){d=_step52.value;if(this.vNodes.get(d)){y=this.commandDeleteText(d);y&&i.push(y);}p=this._removeWork(d);p.length&&a.push.apply(a,_toConsumableArray(p)),e==null||e.deleteCachedImagesByWorkId(d),o.push(d);}}catch(err){_iterator52.e(err);}finally{_iterator52.f();}o.length&&i.push({type:ot.RemoveNode,removeIds:o});i.push({type:ot.Select,selectIds:[],willSyncService:n});_context42.next=10;return this.blurSelector();case 10:_context42.t0=a.length||i.length;if(!_context42.t0){_context42.next=14;break;}_context42.next=14;return this._post({render:a,sp:i});case 14:case"end":return _context42.stop();}},_callee40,this);}));function removeSelector(_x49,_x50){return _removeSelector.apply(this,arguments);}return removeSelector;}()},{key:"removeWork",value:function(){var _removeWork2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee41(t){var e,n,i;return _regeneratorRuntime().wrap(function _callee41$(_context43){while(1)switch(_context43.prev=_context43.next){case 0:e=t.workId,n=e==null?void 0:e.toString();if(!n){_context43.next=7;break;}i=this._removeWork(n);_context43.t0=i.length;if(!_context43.t0){_context43.next=7;break;}_context43.next=7;return this._post({render:i});case 7:case"end":return _context43.stop();}},_callee41,this);}));function removeWork(_x51){return _removeWork2.apply(this,arguments);}return removeWork;}()},{key:"removeNode",value:function removeNode(t){var i,a,o;var e=this.vNodes.get(t);e&&((i=this.fullLayer)==null||i.getElementsByName(t).forEach(function(s){s.remove();}),this.vNodes["delete"](t));var n=this.drawLayer&&vt.getRectFromLayer(this.drawLayer,t);if(n){var s=(a=this.drawLayer)==null?void 0:a.getElementsByName(t)[0];(o=this.drawLayer)==null||o.removeChild(s);}return this.getWorkShape(t)&&this.clearWorkShapeNodeCache(t),{fullRect:e==null?void 0:e.rect,drawRect:n};}},{key:"_removeWork",value:function _removeWork(t){var _this$removeNode=this.removeNode(t),e=_this$removeNode.fullRect,n=_this$removeNode.drawRect,i=[];return e&&i.push({rect:bt(e),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:bt(e),drawCanvas:St.Bg,viewId:this.viewId}),n&&i.push({rect:bt(n),clearCanvas:St.Float,isClear:!0,viewId:this.viewId},{rect:bt(n),drawCanvas:St.Float,viewId:this.viewId}),i;}},{key:"checkTextActive",value:function(){var _checkTextActive=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee42(t){var e,n,i,a,o,s,c,_iterator53,_step53,d,l,p,y,P;return _regeneratorRuntime().wrap(function _callee42$(_context44){while(1)switch(_context44.prev=_context44.next){case 0:e=t.op,n=t.viewId,i=t.dataType;if(!(e!=null&&e.length)){_context44.next=32;break;}s=e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],c=e[1]*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1];_iterator53=_createForOfIteratorHelper(this.vNodes.curNodeMap.values());_context44.prev=4;_iterator53.s();case 6:if((_step53=_iterator53.n()).done){_context44.next=14;break;}d=_step53.value;l=d.rect,p=d.name,y=d.toolsType,P=d.opt;if(!(y===ut.Text&&P.workState===It.Done&&Yg([s,c],l))){_context44.next=12;break;}a=p,o=this.setFullWork({workId:p,toolsType:y,opt:P});return _context44.abrupt("break",14);case 12:_context44.next=6;break;case 14:_context44.next=19;break;case 16:_context44.prev=16;_context44.t0=_context44["catch"](4);_iterator53.e(_context44.t0);case 19:_context44.prev=19;_iterator53.f();return _context44.finish(19);case 22:_context44.t1=a;if(!_context44.t1){_context44.next=32;break;}_context44.t2=o;if(!_context44.t2){_context44.next=28;break;}_context44.next=28;return o.consumeServiceAsync({isFullWork:!0,replaceId:o.getWorkId(),isDrawLabel:!1});case 28:_context44.next=30;return this.blurSelector({viewId:n,msgType:ot.Select,dataType:i,isSync:!0});case 30:_context44.next=32;return this._post({sp:[{type:ot.GetTextActive,toolsType:ut.Text,workId:a}]});case 32:case"end":return _context44.stop();}},_callee42,this,[[4,16,19,22]]);}));function checkTextActive(_x52){return _checkTextActive.apply(this,arguments);}return checkTextActive;}()},{key:"colloctEffectSelectWork",value:function(){var _colloctEffectSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee43(t){var _this92=this;var e,n,i;return _regeneratorRuntime().wrap(function _callee43$(_context45){while(1)switch(_context45.prev=_context45.next){case 0:e=this.workShapes.get(Nt),n=t.workId,i=t.msgType;if(!(e&&n&&e.selectIds&&e.selectIds.includes(n.toString()))){_context45.next=6;break;}i===ot.RemoveNode?e.selectIds=e.selectIds.filter(function(a){return a!==n.toString();}):this.effectSelectNodeData.add(t);_context45.next=5;return this.runEffectSelectWork(!0).then(function(){var a;(a=_this92.effectSelectNodeData)==null||a.clear();});case 5:return _context45.abrupt("return");case 6:return _context45.abrupt("return",t);case 7:case"end":return _context45.stop();}},_callee43,this);}));function colloctEffectSelectWork(_x53){return _colloctEffectSelectWork.apply(this,arguments);}return colloctEffectSelectWork;}()},{key:"updateSelector",value:function(){var _updateSelector2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee44(t){var _this93=this;var P,e,n,i,a,o,s,c,d,l,p,y;return _regeneratorRuntime().wrap(function _callee44$(_context46){while(1)switch(_context46.prev=_context46.next){case 0:e=this.workShapes.get(Nt);if((P=e==null?void 0:e.selectIds)!=null&&P.length){_context46.next=3;break;}return _context46.abrupt("return");case 3:n=t.callback;i=_objectWithoutProperties(t,_excluded2);a=i.updateSelectorOpt;o=i.willSerializeData;_context46.next=9;return e==null?void 0:e.updateSelector({updateSelectorOpt:a,selectIds:Xt(e.selectIds),vNodes:this.vNodes,willSerializeData:o,worker:this});case 9:s=_context46.sent;c=/* @__PURE__ */new Map();s!=null&&s.selectIds&&(d=gm(e.selectIds,s.selectIds),s.selectIds.forEach(function(x){var v=_this93.vNodes.get(x);if(v){var _T41=v.toolsType,_f36=v.op,g=v.opt;c.set(x,{opt:g,toolsType:_T41,ops:(_f36==null?void 0:_f36.length)&&Qt(_f36)||void 0});}}),e.selectIds=s.selectIds);l=[],p=[];s!=null&&s.rect&&l.push({rect:bt(s.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:bt(s.rect),drawCanvas:St.Bg,viewId:this.viewId});y=n&&n({res:s,workShapeNode:e,param:i,postData:{render:l,sp:p},newServiceStore:c})||{render:l,sp:p};d&&y.sp.push({type:ot.RemoveNode,removeIds:d,viewId:this.viewId});_context46.t0=y.render.length||y.sp.length;if(!_context46.t0){_context46.next=20;break;}_context46.next=20;return this._post(y);case 20:case"end":return _context46.stop();}},_callee44,this);}));function updateSelector(_x54){return _updateSelector2.apply(this,arguments);}return updateSelector;}()},{key:"blurSelector",value:function(){var _blurSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee45(t){var i,e,n,a;return _regeneratorRuntime().wrap(function _callee45$(_context47){while(1)switch(_context47.prev=_context47.next){case 0:e=this.workShapes.get(Nt),n=e==null?void 0:e.blurSelector();if(!(this.clearWorkShapeNodeCache(Nt),((i=this.fullLayer)==null?void 0:i.parent).children.forEach(function(a){a.name===Nt&&a.remove();}),n)){_context47.next=6;break;}a=[];a.push(_objectSpread(_objectSpread({},n),{},{isSync:t==null?void 0:t.isSync}));_context47.next=6;return this._post({render:(n==null?void 0:n.rect)&&[{rect:bt(n.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:bt(n.rect),drawCanvas:St.Bg,viewId:this.viewId}],sp:a});case 6:case"end":return _context47.stop();}},_callee45,this);}));function blurSelector(_x55){return _blurSelector.apply(this,arguments);}return blurSelector;}()},{key:"hasSelector",value:function hasSelector(){return this.workShapes.has(Nt);}},{key:"getSelector",value:function getSelector(){return this.workShapes.get(Nt);}},{key:"reRenderSelector",value:function(){var _reRenderSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee46(){var t,a,e,n,i,o,_args48=arguments;return _regeneratorRuntime().wrap(function _callee46$(_context48){while(1)switch(_context48.prev=_context48.next){case 0:t=_args48.length>0&&_args48[0]!==undefined?_args48[0]:!1;e=this.workShapes.get(Nt);if(e){_context48.next=4;break;}return _context48.abrupt("return");case 4:if(!(e&&!((a=e.selectIds)!=null&&a.length))){_context48.next=8;break;}_context48.next=7;return this.blurSelector();case 7:return _context48.abrupt("return");case 8:n=e.oldSelectRect,i=e.reRenderSelector();if(!i){_context48.next=13;break;}o=Pt(n,i)||i;_context48.next=13;return this._post({render:[{rect:bt(o),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:bt(o),drawCanvas:St.Bg,viewId:this.viewId}],sp:[{type:ot.Select,selectIds:e.selectIds,selectRect:i,willSyncService:t,viewId:this.viewId,points:e.getChildrenPoints(),textOpt:e.textOpt,selectorColor:e.selectorColor,strokeColor:e.strokeColor,fillColor:e.fillColor,canTextEdit:e.canTextEdit,canRotate:e.canRotate,scaleType:e.scaleType,opt:e.getWorkOptions()||void 0,canLock:e.canLock,isLocked:e.isLocked,toolsTypes:e.toolsTypes,shapeOpt:e.shapeOpt,thickness:e.thickness,useStroke:e.useStroke,strokeType:e.strokeType}]});case 13:case"end":return _context48.stop();}},_callee46,this);}));function reRenderSelector(){return _reRenderSelector.apply(this,arguments);}return reRenderSelector;}()},{key:"updateFullSelectWork",value:function(){var _updateFullSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee47(t){var i,a,o,s,c,d,l,e,n,_e$updateSelectIds,p,y,P;return _regeneratorRuntime().wrap(function _callee47$(_context49){while(1)switch(_context49.prev=_context49.next){case 0:e=this.workShapes.get(Nt),n=t.selectIds;if(n!=null&&n.length){_context49.next=5;break;}_context49.next=4;return this.blurSelector(t);case 4:return _context49.abrupt("return");case 5:if(e){_context49.next=10;break;}!this.setFullWork(t)&&t.workId&&((i=this.tmpOpt)==null?void 0:i.toolsType)===ut.Selector&&this.createWorkShape(t.workId.toString());_context49.next=9;return this.updateFullSelectWork(t);case 9:return _context49.abrupt("return");case 10:if(!(e&&n!=null&&n.length)){_context49.next=16;break;}_e$updateSelectIds=e.updateSelectIds(n),p=_e$updateSelectIds.bgRect,y=_e$updateSelectIds.selectRect,P={render:[],sp:[]};p&&((a=P.render)==null||a.push({rect:bt(p),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:bt(p),drawCanvas:St.Bg,viewId:this.viewId}));(l=P.sp)==null||l.push(_objectSpread(_objectSpread({},t),{},{selectorColor:((o=t.opt)==null?void 0:o.strokeColor)||e.selectorColor,strokeColor:((s=t.opt)==null?void 0:s.strokeColor)||e.strokeColor,fillColor:((c=t.opt)==null?void 0:c.fillColor)||e.fillColor,textOpt:((d=t.opt)==null?void 0:d.textOpt)||e.textOpt,canTextEdit:e.canTextEdit,canRotate:e.canRotate,scaleType:e.scaleType,type:ot.Select,selectRect:y,points:e.getChildrenPoints(),willSyncService:(t==null?void 0:t.willSyncService)||!1,opt:(t==null?void 0:t.willSyncService)&&e.getWorkOptions()||void 0,canLock:e.canLock,isLocked:e.isLocked,toolsTypes:e.toolsTypes,shapeOpt:e.shapeOpt,thickness:e.thickness,useStroke:e.useStroke,strokeType:e.strokeType}));_context49.next=16;return this._post(P);case 16:case"end":return _context49.stop();}},_callee47,this);}));function updateFullSelectWork(_x56){return _updateFullSelectWork.apply(this,arguments);}return updateFullSelectWork;}()},{key:"destroy",value:function destroy(){this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1)),_superPropGet(pm,"destroy",this,3)([]),this.effectSelectNodeData.clear(),this.batchEraserWorks.clear(),this.batchEraserRemoveNodes.clear();}},{key:"drawBitMapEraser",value:function(){var _drawBitMapEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee48(t){var e,n,i;return _regeneratorRuntime().wrap(function _callee48$(_context50){while(1)switch(_context50.prev=_context50.next){case 0:e=[];t.op&&e.push(t);n=[];if(t.rect){i=bt(t.rect);n.push({rect:i,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:i,drawCanvas:St.Bg,viewId:this.viewId});}_context50.t0=e.length||n.length;if(!_context50.t0){_context50.next=8;break;}_context50.next=8;return this._post({sp:e,render:n});case 8:case"end":return _context50.stop();}},_callee48,this);}));function drawBitMapEraser(_x57){return _drawBitMapEraser.apply(this,arguments);}return drawBitMapEraser;}()},{key:"drawBitMapEraserFull",value:function(){var _drawBitMapEraserFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee49(t,e,n){var i,a,o,s,c,d,l,p,P,_iterator54,_step54,_step54$value,x,v,y,_P4;return _regeneratorRuntime().wrap(function _callee49$(_context51){while(1)switch(_context51.prev=_context51.next){case 0:i=e.rect,a=e.willUpdateNodes,o=e.willDeleteNodes,s=e.scenePath,c=_objectWithoutProperties(e,_excluded3);d=i;l=t.getWorkId(),p=[_objectSpread(_objectSpread({},c),{},{workId:l,scenePath:s,updateNodeOpt:{useAnimation:!1},isSync:!0,nextTasks:[{type:ot.RemoveNode,removeIds:[l],viewId:this.viewId}]})];if(!(n&&p.push({type:ot.None,isLockSentEventCursor:n}),a!=null&&a.size||o!=null&&o.size)){_context51.next=9;break;}_context51.next=6;return t==null?void 0:t.reRenderEffectNodes({willDeleteNodes:o,willUpdateNodes:a,worker:this});case 6:P=_context51.sent;if(d=Pt(d,P),a!=null&&a.size){_iterator54=_createForOfIteratorHelper(a);try{for(_iterator54.s();!(_step54=_iterator54.n()).done;){_step54$value=_slicedToArray(_step54.value,2),x=_step54$value[0],v=_step54$value[1];p.push({type:ot.UpdateNode,dataType:Mt.Local,opt:v.opt,workId:x,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator54.e(err);}finally{_iterator54.f();}}o!=null&&o.size&&p.push({type:ot.RemoveNode,removeIds:_toConsumableArray(o),viewId:this.thread.viewId});case 9:y=[];if(d){_P4=bt(d);y.push({rect:_P4,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:_P4,drawCanvas:St.Bg,viewId:this.viewId});}_context51.t0=p.length||y.length;if(!_context51.t0){_context51.next=15;break;}_context51.next=15;return this._post({sp:p,render:y});case 15:case"end":return _context51.stop();}},_callee49,this);}));function drawBitMapEraserFull(_x58,_x59,_x60){return _drawBitMapEraserFull.apply(this,arguments);}return drawBitMapEraserFull;}()},{key:"drawPencilCombine",value:function(){var _drawPencilCombine=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee50(t,e){var i,a,o,n,s,c;return _regeneratorRuntime().wrap(function _callee50$(_context52){while(1)switch(_context52.prev=_context52.next){case 0:n=(i=this.workShapes.get(t))==null?void 0:i.combineConsume();if(!n){_context52.next=6;break;}s={render:[],drawCount:e};if(n!=null&&n.rect){c=bt(n.rect);(a=s.render)==null||a.push({rect:c,isClear:!0,clearCanvas:St.Float,viewId:this.viewId}),(o=s.render)==null||o.push({rect:c,drawCanvas:St.Float,viewId:this.viewId});}_context52.next=6;return this._post(s);case 6:case"end":return _context52.stop();}},_callee50,this);}));function drawPencilCombine(_x61,_x62){return _drawPencilCombine.apply(this,arguments);}return drawPencilCombine;}()},{key:"drawSelector",value:function(){var _drawSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee51(t){var n,e;return _regeneratorRuntime().wrap(function _callee51$(_context53){while(1)switch(_context53.prev=_context53.next){case 0:e={render:[],sp:[t]};t.rect&&((n=e.render)==null||n.push({rect:bt(t.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:bt(t.rect),drawCanvas:St.Bg,viewId:this.viewId}));_context53.next=4;return this._post(e);case 4:case"end":return _context53.stop();}},_callee51,this);}));function drawSelector(_x63){return _drawSelector.apply(this,arguments);}return drawSelector;}()},{key:"drawPencilEraser",value:function(){var _drawPencilEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee52(t,e){var _this94=this;var i,a,n,_iterator55,_step55,o,s;return _regeneratorRuntime().wrap(function _callee52$(_context54){while(1)switch(_context54.prev=_context54.next){case 0:n=[];if((i=t.newWorkDatas)!=null&&i.size){_iterator55=_createForOfIteratorHelper(t.newWorkDatas.values());try{for(_iterator55.s();!(_step55=_iterator55.n()).done;){o=_step55.value;s=o.workId.toString();this.batchEraserWorks.add(s),n.push({type:ot.FullWork,workId:s,ops:Qt(o.op),opt:o.opt,toolsType:o.toolsType,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator55.e(err);}finally{_iterator55.f();}delete t.newWorkDatas;}(a=t.removeIds)==null||a.forEach(function(o){_this94.batchEraserRemoveNodes.add(o);});e&&n.push({type:ot.None,isLockSentEventCursor:e});t.rect&&n.push(t);_context54.next=7;return this._post({sp:n});case 7:this.batchEraserCombine();case 8:case"end":return _context54.stop();}},_callee52,this);}));function drawPencilEraser(_x64,_x65){return _drawPencilEraser.apply(this,arguments);}return drawPencilEraser;}()},{key:"drawEraser",value:function(){var _drawEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee53(t,e){var n,i;return _regeneratorRuntime().wrap(function _callee53$(_context55){while(1)switch(_context55.prev=_context55.next){case 0:n=[],i=[];e&&n.push({type:ot.None,isLockSentEventCursor:e});t.removeIds&&n.push(t);t.rect&&i.push({rect:t.rect,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:St.Bg,viewId:this.viewId});_context55.next=6;return this._post({sp:n,render:i});case 6:case"end":return _context55.stop();}},_callee53,this);}));function drawEraser(_x66,_x67){return _drawEraser.apply(this,arguments);}return drawEraser;}()},{key:"drawShape",value:function(){var _drawShape=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee54(t){return _regeneratorRuntime().wrap(function _callee54$(_context56){while(1)switch(_context56.prev=_context56.next){case 0:_context56.next=2;return this._post({drawCount:this.drawCount,sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context56.stop();}},_callee54,this);}));function drawShape(_x68){return _drawShape.apply(this,arguments);}return drawShape;}()},{key:"drawPencil",value:function(){var _drawPencil=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee55(t){return _regeneratorRuntime().wrap(function _callee55$(_context57){while(1)switch(_context57.prev=_context57.next){case 0:_context57.next=2;return this._post({sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context57.stop();}},_callee55,this);}));function drawPencil(_x69){return _drawPencil.apply(this,arguments);}return drawPencil;}()},{key:"drawPencilFull",value:function(){var _drawPencilFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(t,e){var i,a,n;return _regeneratorRuntime().wrap(function _callee56$(_context58){while(1)switch(_context58.prev=_context58.next){case 0:n={drawCount:1/0,render:[],sp:[t]};e&&((i=n.sp)==null||i.push({type:ot.None,isLockSentEventCursor:e}));(a=n.render)==null||a.push({isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId},{rect:t.rect,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:St.Bg,viewId:this.viewId});_context58.next=5;return this._post(n);case 5:case"end":return _context58.stop();}},_callee56,this);}));function drawPencilFull(_x70,_x71){return _drawPencilFull.apply(this,arguments);}return drawPencilFull;}()},{key:"updateBatchEraserCombineNode",value:function updateBatchEraserCombineNode(t,e){var _this95=this;var n=[];var i;var _iterator56=_createForOfIteratorHelper(e.keys()),_step56;try{for(_iterator56.s();!(_step56=_iterator56.n()).done;){var a=_step56.value;this.fullLayer.getElementsByName(a).forEach(function(o){var s=o.getBoundingClientRect();i=Pt(i,{x:s.x-se.SafeBorderPadding,y:s.y-se.SafeBorderPadding,w:s.width+se.SafeBorderPadding*2,h:s.height+se.SafeBorderPadding*2}),o.remove();});}}catch(err){_iterator56.e(err);}finally{_iterator56.f();}return t.forEach(function(a){var o=_this95.vNodes.get(a);if(o)if(_this95.fullLayer.getElementsByName(a)[0])i=Pt(i,o.rect);else{var c=_this95.setFullWork(_objectSpread(_objectSpread({},o),{},{workId:a})),d=c&&c.consumeService({op:o.op,isFullWork:!0});d&&(o.rect=d,i=Pt(i,d));}}),i&&n.push({rect:i,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:i,drawCanvas:St.Bg,viewId:this.viewId}),n;}},{key:"runEffectSelectWork",value:function(){var _runEffectSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee57(t){var e,_iterator57,_step57,n,i,a,o;return _regeneratorRuntime().wrap(function _callee57$(_context59){while(1)switch(_context59.prev=_context59.next){case 0:_iterator57=_createForOfIteratorHelper(this.effectSelectNodeData.values());_context59.prev=1;_iterator57.s();case 3:if((_step57=_iterator57.n()).done){_context59.next=23;break;}n=_step57.value;i=this.setFullWork(n);if(!i){_context59.next=21;break;}a=(e=i.getWorkId())==null?void 0:e.toString();if(!(i.toolsType===ut.Image)){_context59.next=13;break;}_context59.next=11;return i.consumeServiceAsync({isFullWork:!0,replaceId:a,worker:this});case 11:_context59.next=20;break;case 13:if(!(i.toolsType===ut.Text)){_context59.next=18;break;}_context59.next=16;return i.consumeServiceAsync({isFullWork:!0,replaceId:a});case 16:_context59.next=20;break;case 18:o=n.ops&&Me(n.ops);i.consumeService({op:o,isFullWork:!0,replaceId:a}),n!=null&&n.updateNodeOpt&&i.updataOptService(n.updateNodeOpt);case 20:n.workId&&this.workShapes["delete"](n.workId.toString());case 21:_context59.next=3;break;case 23:_context59.next=28;break;case 25:_context59.prev=25;_context59.t0=_context59["catch"](1);_iterator57.e(_context59.t0);case 28:_context59.prev=28;_iterator57.f();return _context59.finish(28);case 31:_context59.next=33;return this.reRenderSelector(t);case 33:case"end":return _context59.stop();}},_callee57,this,[[1,25,28,31]]);}));function runEffectSelectWork(_x72){return _runEffectSelectWork.apply(this,arguments);}return runEffectSelectWork;}()},{key:"cursorHover",value:function(){var _cursorHover=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee58(t){var o,e,n,i,a,s,c;return _regeneratorRuntime().wrap(function _callee58$(_context60){while(1)switch(_context60.prev=_context60.next){case 0:e=t.opt,n=t.toolsType,i=t.point,a=this.setFullWork({workId:we,toolsType:n,opt:e});if(!(a&&i)){_context60.next=8;break;}s=a.cursorHover(i),c={render:[]};_context60.t0=s&&s.type===ot.CursorHover&&s.rect;if(!_context60.t0){_context60.next=8;break;}(o=c.render)==null||o.push({rect:bt(s.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:bt(s.rect),drawCanvas:St.Bg,viewId:this.viewId});_context60.next=8;return this._post(c);case 8:case"end":return _context60.stop();}},_callee58,this);}));function cursorHover(_x73){return _cursorHover.apply(this,arguments);}return cursorHover;}()},{key:"cursorBlur",value:function(){var _cursorBlur=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee59(){var n,t,e;return _regeneratorRuntime().wrap(function _callee59$(_context61){while(1)switch(_context61.prev=_context61.next){case 0:t=this.getWorkShape(we);_context61.t0=t&&(n=t.selectIds)!=null&&n.length;if(!_context61.t0){_context61.next=10;break;}e=t.oldSelectRect;t.cursorBlur();this.clearWorkShapeNodeCache(we);_context61.t1=e;if(!_context61.t1){_context61.next=10;break;}_context61.next=10;return this._post({render:[{rect:bt(e),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:bt(e),drawCanvas:St.Bg,viewId:this.viewId}]});case 10:this.fullLayer.parent.children.forEach(function(i){i.name==="Cursor_Hover_Id"&&i.remove();});case 11:case"end":return _context61.stop();}},_callee59,this);}));function cursorBlur(){return _cursorBlur.apply(this,arguments);}return cursorBlur;}()}]);}(Ri);var mm=/*#__PURE__*/function(){function mm(r){_classCallCheck(this,mm);et(this,"viewId");et(this,"vNodes");et(this,"fullLayer");et(this,"drawLayer");et(this,"workShapes",/* @__PURE__ */new Map());et(this,"selectorWorkShapes",/* @__PURE__ */new Map());et(this,"thread");et(this,"animationId");et(this,"willRunEffectSelectorIds",/* @__PURE__ */new Set());et(this,"runEffectId");et(this,"noAnimationRect");et(this,"syncUnitTime",re.syncOpt.interval);et(this,"post");this.viewId=r.viewId,this.vNodes=r.vNodes,this.fullLayer=r.fullLayer,this.drawLayer=r.drawLayer,this.thread=r.thread,this.post=r.thread.post.bind(r.thread);}return _createClass(mm,[{key:"destroy",value:function destroy(){this.workShapes.clear(),this.selectorWorkShapes.clear(),this.willRunEffectSelectorIds.clear();}},{key:"consumeDraw",value:function(){var _consumeDraw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee60(r){return _regeneratorRuntime().wrap(function _callee60$(_context62){while(1)switch(_context62.prev=_context62.next){case 0:this.activeWorkShape(r),this.runAnimation();case 1:case"end":return _context62.stop();}},_callee60,this);}));function consumeDraw(_x74){return _consumeDraw2.apply(this,arguments);}return consumeDraw;}()},{key:"consumeFull",value:function consumeFull(r){this.activeWorkShape(r),this.runAnimation();}},{key:"runSelectWork",value:function runSelectWork(r){this.activeSelectorShape(r);var t=r.workId,e=t==null?void 0:t.toString();e&&this.willRunEffectSelectorIds.add(e),this.runEffect();}},{key:"setNodeKey",value:function setNodeKey(r,t,e,n){return t.toolsType=e,t.node=Fr({workId:r,toolsType:e,toolsOpt:n,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},this),t;}},{key:"runReverseSelectWork",value:function runReverseSelectWork(r){var _this96=this;r.forEach(function(t){_this96.selectorWorkShapes.forEach(function(e,n){var i;if((i=e.selectIds)!=null&&i.length){var a=e.selectIds.indexOf(t);a>-1&&(e.selectIds.splice(a,1),_this96.willRunEffectSelectorIds.add(n));}});}),this.willRunEffectSelectorIds.size&&this.runEffect();}},{key:"removeWork",value:function(){var _removeWork3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee61(r){var t,e,n;return _regeneratorRuntime().wrap(function _callee61$(_context63){while(1)switch(_context63.prev=_context63.next){case 0:t=r.workId,e=t==null?void 0:t.toString();if(!e){_context63.next=10;break;}n=this.workShapes.get(e);if(!n){_context63.next=8;break;}this.workShapes["delete"](e);_context63.next=7;return this.removeNode(e,r,n==null?void 0:n.totalRect,!1);case 7:return _context63.abrupt("return");case 8:_context63.next=10;return this.removeNode(e,r);case 10:case"end":return _context63.stop();}},_callee61,this);}));function removeWork(_x75){return _removeWork3.apply(this,arguments);}return removeWork;}()},{key:"removeSelectWork",value:function removeSelectWork(r){var t=r.workId,e=t==null?void 0:t.toString();e&&(this.activeSelectorShape(r),this.willRunEffectSelectorIds.add(e)),this.runEffect();}},{key:"removeNode",value:function(){var _removeNode=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee62(r,t,e){var n,o,i,a,_args64=arguments;return _regeneratorRuntime().wrap(function _callee62$(_context64){while(1)switch(_context64.prev=_context64.next){case 0:n=_args64.length>3&&_args64[3]!==undefined?_args64[3]:!0;r.indexOf(Nt)>-1&&this.removeSelectWork(t);i=e;a=(o=this.vNodes.get(r))==null?void 0:o.rect;a&&(i=Pt(a,i));this.fullLayer.getElementsByName(r).forEach(function(s){s.remove();});this.drawLayer.getElementsByName(r).forEach(function(s){s.remove();});this.vNodes["delete"](r);_context64.t0=i;if(!_context64.t0){_context64.next=12;break;}_context64.next=12;return this.post({render:[{rect:bt(i),isClear:!0,clearCanvas:n?St.Bg:St.ServiceFloat,workerType:n?void 0:Mt.Service,viewId:this.viewId},{rect:bt(i),drawCanvas:n?St.Bg:St.ServiceFloat,workerType:n?void 0:Mt.Service,viewId:this.viewId}]});case 12:case"end":return _context64.stop();}},_callee62,this);}));function removeNode(_x76,_x77,_x78){return _removeNode.apply(this,arguments);}return removeNode;}()},{key:"activeWorkShape",value:function activeWorkShape(r){var y,P,x,v;var t=r.workId,e=r.opt,n=r.toolsType,i=r.type,a=r.updateNodeOpt,o=r.ops,s=r.op,c=r.useAnimation;if(!t)return;var d=t.toString(),l=(y=this.vNodes.get(d))==null?void 0:y.rect;if(!((P=this.workShapes)!=null&&P.has(d))){var _T42={toolsType:n,animationWorkData:s||[],animationIndex:0,type:i,updateNodeOpt:a,ops:o,useAnimation:_typeof(c)<"u"?c:_typeof(a==null?void 0:a.useAnimation)<"u"?a==null?void 0:a.useAnimation:!0,oldRect:l,isDiff:!1};n&&e&&(_T42=this.setNodeKey(d,_T42,n,e)),(x=this.workShapes)==null||x.set(d,_T42);}var p=(v=this.workShapes)==null?void 0:v.get(d);i&&(p.type=i),o&&(p.animationWorkData=Me(o),p.ops=o),a&&(p.updateNodeOpt=a),s&&(p.isDiff=this.hasDiffData(p.animationWorkData||[],s,p.toolsType),p.animationWorkData=s),p.node&&p.node.getWorkId()!==d&&p.node.setWorkId(d),l&&(p.oldRect=l),n&&e&&(e.syncUnitTime&&(this.syncUnitTime=e.syncUnitTime),p.toolsType!==n&&n&&e&&this.setNodeKey(d,p,n,e),p.node&&p.node.setWorkOptions(e));}},{key:"hasDiffData",value:function hasDiffData(r,t,e){var n=r.length;if(t.length<n)return!0;switch(e){case ut.Pencil:{for(var i=0;i<n;i+=3)if(t[i]!==r[i]||t[i+1]!==r[i+1])return!0;break;}case ut.LaserPen:{for(var _i10=0;_i10<n;_i10+=2)if(t[_i10]!==r[_i10]||t[_i10+1]!==r[_i10+1])return!0;break;}}return!1;}},{key:"animationDraw",value:function(){var _animationDraw=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee63(){var _this97=this;var n,i,a,o,s,c,d,l,p,y,P,x,v,T,f,g,u,m,M,E,A,w,O,L,b,I,R,W,z,K,k,q,U,G,Z,nt,r,t,e,_iterator58,_step58,_loop6;return _regeneratorRuntime().wrap(function _callee63$(_context66){while(1)switch(_context66.prev=_context66.next){case 0:this.animationId=void 0;r=!1;t={render:[]},e=/* @__PURE__ */new Map();_iterator58=_createForOfIteratorHelper(this.workShapes.entries());_context66.prev=4;_loop6=/*#__PURE__*/_regeneratorRuntime().mark(function _loop6(){var _step58$value,rt,tt,J,ht,_J4,_ht3,_J5,_ht4,dt,B,_J6,_ht5,_J7,_ht6,_dt2,_B,F,Y,X,_Y,_J8,_ht7,_dt3,_B2,_F,_Y2;return _regeneratorRuntime().wrap(function _loop6$(_context65){while(1)switch(_context65.prev=_context65.next){case 0:_step58$value=_slicedToArray(_step58.value,2),rt=_step58$value[0],tt=_step58$value[1];_context65.t0=tt.toolsType;_context65.next=_context65.t0===ut.Image?4:_context65.t0===ut.Text?11:_context65.t0===ut.Arrow?19:_context65.t0===ut.Straight?19:_context65.t0===ut.Rectangle?19:_context65.t0===ut.Ellipse?19:_context65.t0===ut.Star?19:_context65.t0===ut.Polygon?19:_context65.t0===ut.SpeechBalloon?19:_context65.t0===ut.Pencil?22:_context65.t0===ut.BitMapEraser?37:_context65.t0===ut.PencilEraser?37:50;break;case 4:J=tt.oldRect;J&&((n=t.render)==null||n.push({rect:J,isClear:!0,clearCanvas:St.Bg,viewId:_this97.viewId}),(i=t.render)==null||i.push({rect:J,drawCanvas:St.Bg,viewId:_this97.viewId}));_context65.next=8;return(a=tt.node)==null?void 0:a.consumeServiceAsync({isFullWork:!0,worker:_this97.thread});case 8:ht=_context65.sent;_this97.selectorWorkShapes.forEach(function(dt,B){var F;(F=dt.selectIds)!=null&&F.includes(rt)&&(_this97.willRunEffectSelectorIds.add(B),_this97.noAnimationRect=Pt(_this97.noAnimationRect,J),_this97.noAnimationRect=Pt(_this97.noAnimationRect,ht),_this97.runEffect());}),_this97.workShapes["delete"](rt),(o=t.render)==null||o.push({rect:ht,drawCanvas:St.Bg,viewId:_this97.viewId});return _context65.abrupt("break",50);case 11:if(!tt.node){_context65.next=18;break;}_J4=tt.oldRect;_J4&&((s=t.render)==null||s.push({rect:_J4,isClear:!0,clearCanvas:St.Bg,viewId:_this97.viewId}),(c=t.render)==null||c.push({rect:_J4,drawCanvas:St.Bg,viewId:_this97.viewId}));_context65.next=16;return tt.node.consumeServiceAsync({isFullWork:!0,replaceId:rt});case 16:_ht3=_context65.sent;_this97.selectorWorkShapes.forEach(function(dt,B){var F;(F=dt.selectIds)!=null&&F.includes(rt)&&(_this97.willRunEffectSelectorIds.add(B),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_J4),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_ht3),_this97.runEffect());}),(d=tt.node)==null||d.clearTmpPoints(),_this97.workShapes["delete"](rt),(l=t.render)==null||l.push({rect:_ht3,drawCanvas:St.Bg,viewId:_this97.viewId});case 18:return _context65.abrupt("break",50);case 19:_J5=!!tt.ops;if((p=tt.animationWorkData)!=null&&p.length){_ht4=tt.oldRect,dt=tt.node.oldRect;_ht4&&((y=t.render)==null||y.push({rect:_ht4,isClear:!0,clearCanvas:St.Bg,viewId:_this97.viewId}),(P=t.render)==null||P.push({rect:_ht4,drawCanvas:St.Bg,viewId:_this97.viewId})),dt&&((x=t.render)==null||x.push({rect:dt,isClear:!0,clearCanvas:St.ServiceFloat,viewId:_this97.viewId}));B=(v=tt.node)==null?void 0:v.consumeService({op:tt.animationWorkData,isFullWork:_J5});e.set(rt,{workState:_ht4?tt.ops?It.Done:It.Doing:It.Start,op:tt.animationWorkData.filter(function(F,Y){if(Y%3!==2)return!0;}).slice(-2)}),_J5?(_this97.selectorWorkShapes.forEach(function(F,Y){var X;(X=F.selectIds)!=null&&X.includes(rt)&&(_this97.willRunEffectSelectorIds.add(Y),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_ht4),_this97.noAnimationRect=Pt(_this97.noAnimationRect,dt),_this97.noAnimationRect=Pt(_this97.noAnimationRect,B),_this97.runEffect());}),(T=tt.node)==null||T.clearTmpPoints(),_this97.workShapes["delete"](rt),(f=t.render)==null||f.push({rect:B,drawCanvas:St.Bg,viewId:_this97.viewId})):(g=t.render)==null||g.push({rect:B,drawCanvas:St.ServiceFloat,workerType:_J5?void 0:Mt.Service,viewId:_this97.viewId}),tt.animationWorkData.length=0;}return _context65.abrupt("break",50);case 22:if(!(!tt.useAnimation&&tt.ops)){_context65.next=28;break;}_J6=(u=tt.node)==null?void 0:u.consumeService({op:tt.animationWorkData||[],isFullWork:!0,replaceId:rt});_ht5=(m=tt.node)==null?void 0:m.updataOptService(tt.updateNodeOpt);_J6=Pt(_J6,_ht5),(M=t.render)==null||M.push({isClear:!0,rect:Pt(tt.oldRect,_J6),clearCanvas:St.Bg,viewId:_this97.viewId}),(E=t.render)==null||E.push({rect:Pt(tt.oldRect,_J6),drawCanvas:St.Bg,viewId:_this97.viewId}),_this97.selectorWorkShapes.forEach(function(dt,B){var F;(F=dt.selectIds)!=null&&F.includes(rt)&&(_this97.willRunEffectSelectorIds.add(B),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_J6),_this97.runEffect());}),(A=tt.node)==null||A.clearTmpPoints(),_this97.workShapes["delete"](rt);_context65.next=36;break;case 28:if(!tt.useAnimation){_context65.next=36;break;}if(!tt.isDel){_context65.next=32;break;}(w=tt.node)==null||w.clearTmpPoints(),_this97.workShapes["delete"](rt);return _context65.abrupt("break",50);case 32:_J7=3,_ht6=_this97.computNextAnimationIndex(tt,_J7),_dt2=tt.isDiff?0:Math.max(0,(tt.animationIndex||0)-_J7),_B=(tt.animationWorkData||[]).slice(_dt2,_ht6),F=(L=(O=tt.node)==null?void 0:O.getWorkId())==null?void 0:L.toString();if((tt.animationIndex||0)<_ht6||tt.isDiff){Y=(b=tt.node)==null?void 0:b.consumeService({op:_B,isFullWork:!1});if((I=t.render)==null||I.push({rect:Y,drawCanvas:St.ServiceFloat,viewId:_this97.viewId}),tt.animationIndex=_ht6,tt.isDiff&&(tt.isDiff=!1),_B.length){X=_B.filter(function(N,$){if($%_J7!==_J7-1)return!0;}).slice(-2);e.set(rt,{workState:_dt2===0?It.Start:_ht6===((R=tt.animationWorkData)==null?void 0:R.length)?It.Done:It.Doing,op:X});}}else if(tt.ops){_Y=(W=tt.node)==null?void 0:W.consumeService({op:tt.animationWorkData||[],isFullWork:!0,replaceId:F});tt.isDel=!0,(z=t.render)==null||z.push({isClear:!0,rect:_Y,clearCanvas:St.ServiceFloat,viewId:_this97.viewId},{rect:_Y,drawCanvas:St.ServiceFloat,viewId:_this97.viewId},{isClear:!0,rect:_Y,clearCanvas:St.Bg,viewId:_this97.viewId},{rect:_Y,drawCanvas:St.Bg,viewId:_this97.viewId}),e.set(rt,{workState:It.Done,op:_B.filter(function(X,N){if(N%_J7!==_J7-1)return!0;}).slice(-2)});}r=!0;return _context65.abrupt("break",50);case 36:return _context65.abrupt("break",50);case 37:if(!tt.isDel){_context65.next=40;break;}(K=tt.node)==null||K.clearTmpPoints(),_this97.workShapes["delete"](rt);return _context65.abrupt("break",50);case 40:if(!(tt.ops&&(k=tt.animationWorkData)!=null&&k.length)){_context65.next=44;break;}_J8=tt.animationWorkData.slice(-3,-1);e.set(rt,{workState:It.Done,op:_J8}),tt.isDel=!0;return _context65.abrupt("break",50);case 44:if(!tt.useAnimation){_context65.next=49;break;}_ht7=_this97.computNextAnimationIndex(tt,3),_dt3=tt.isDiff?0:Math.max(0,(tt.animationIndex||0)-3),_B2=(tt.animationWorkData||[]).slice(_dt3,_ht7);if((tt.animationIndex||0)<_ht7||tt.isDiff){_F=(q=tt.node)==null?void 0:q.consumeService({op:_B2,isFullWork:!0});if((U=t.render)==null||U.push({isClear:!0,rect:Pt(tt.oldRect,_F),clearCanvas:St.Bg,viewId:_this97.viewId}),(G=t.render)==null||G.push({rect:Pt(tt.oldRect,_F),drawCanvas:St.Bg,viewId:_this97.viewId}),tt.animationIndex=_ht7,tt.isDiff&&(tt.isDiff=!1),_B2.length){_Y2=_B2.filter(function(X,N){if(N%3!==2)return!0;}).slice(-2);e.set(rt,{workState:_dt3===0?It.Start:_ht7===((Z=tt.animationWorkData)==null?void 0:Z.length)?It.Done:It.Doing,op:_Y2});}}r=!0;return _context65.abrupt("break",50);case 49:return _context65.abrupt("break",50);case 50:case"end":return _context65.stop();}},_loop6);});_iterator58.s();case 7:if((_step58=_iterator58.n()).done){_context66.next=11;break;}return _context66.delegateYield(_loop6(),"t0",9);case 9:_context66.next=7;break;case 11:_context66.next=16;break;case 13:_context66.prev=13;_context66.t1=_context66["catch"](4);_iterator58.e(_context66.t1);case 16:_context66.prev=16;_iterator58.f();return _context66.finish(16);case 19:r&&this.runAnimation();e.size&&(t.sp=[],e.forEach(function(rt,tt){var J;(J=t.sp)==null||J.push({type:ot.Cursor,uid:tt.split(De)[0],op:rt.op,workState:rt.workState,viewId:_this97.viewId});}));_context66.t2=(nt=t.render)!=null&&nt.length;if(!_context66.t2){_context66.next=25;break;}_context66.next=25;return this.post(t);case 25:case"end":return _context66.stop();}},_callee63,this,[[4,13,16,19]]);}));function animationDraw(){return _animationDraw.apply(this,arguments);}return animationDraw;}()},{key:"runAnimation",value:function runAnimation(){var _this98=this;this.animationId||(this.animationId=setTimeout(function(){_this98.animationId=void 0,_this98.animationDraw();},16));}},{key:"computNextAnimationIndex",value:function computNextAnimationIndex(r,t){var e=Math.floor((r.animationWorkData||[]).slice(r.animationIndex).length*32/t/this.syncUnitTime)*t;return Math.min((r.animationIndex||0)+(e||t),(r.animationWorkData||[]).length);}},{key:"runEffect",value:function runEffect(){this.runEffectId||(this.runEffectId=setTimeout(this.effectRunSelector.bind(this),0));}},{key:"effectRunSelector",value:function(){var _effectRunSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee64(){var _this99=this;var r;return _regeneratorRuntime().wrap(function _callee64$(_context67){while(1)switch(_context67.prev=_context67.next){case 0:this.runEffectId=void 0;r=this.noAnimationRect;this.willRunEffectSelectorIds.forEach(function(t){var i,a;var e=_this99.selectorWorkShapes.get(t),n=e&&e.selectIds&&((i=e.node)==null?void 0:i.selectServiceNode(t,e,!0));r=Pt(r,n),(a=e==null?void 0:e.selectIds)!=null&&a.length||_this99.selectorWorkShapes["delete"](t);});_context67.t0=r;if(!_context67.t0){_context67.next=7;break;}_context67.next=7;return this.post({render:[{rect:bt(r),isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:bt(r),drawCanvas:St.Bg,viewId:this.viewId}]});case 7:this.willRunEffectSelectorIds.clear();this.noAnimationRect=void 0;case 9:case"end":return _context67.stop();}},_callee64,this);}));function effectRunSelector(){return _effectRunSelector.apply(this,arguments);}return effectRunSelector;}()},{key:"activeSelectorShape",value:function activeSelectorShape(r){var d,l,p;var t=r.workId,e=r.opt,n=r.toolsType,i=r.type,a=r.selectIds,o=r.imageBitmap;if(!t)return;var s=t.toString();if(!((d=this.selectorWorkShapes)!=null&&d.has(s))){var y={toolsType:n,selectIds:a,type:i,opt:e,imageBitmap:o};n&&e&&(y=this.setNodeKey(s,y,n,e)),(l=this.selectorWorkShapes)==null||l.set(s,y);}var c=(p=this.selectorWorkShapes)==null?void 0:p.get(s);i&&(c.type=i),c.node&&c.node.getWorkId()!==s&&c.node.setWorkId(s),o&&(c.imageBitmap=o),c.selectIds=a||[];}}]);}();var vm=/*#__PURE__*/function(_Ri2){function vm(t){var _this100;_classCallCheck(this,vm);_this100=_callSuper(this,vm,[t]);et(_this100,"drawWorkActiveId");return _this100;}_inherits(vm,_Ri2);return _createClass(vm,[{key:"runFullWork",value:function(){var _runFullWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee65(t){var i,e,n,a,o,s;return _regeneratorRuntime().wrap(function _callee65$(_context68){while(1)switch(_context68.prev=_context68.next){case 0:e=this.setFullWork(t),n=t.ops&&Me(t.ops);if(!e){_context68.next=18;break;}s=(i=e.getWorkId())==null?void 0:i.toString();if(!(e.toolsType===ut.Image)){_context68.next=9;break;}_context68.next=6;return e.consumeServiceAsync({isFullWork:!0,worker:this.thread});case 6:a=_context68.sent;_context68.next=16;break;case 9:if(!(e.toolsType===ut.Text)){_context68.next=15;break;}_context68.next=12;return e.consumeServiceAsync({isFullWork:!0,replaceId:s,isDrawLabel:!0});case 12:a=_context68.sent;_context68.next=16;break;case 15:a=e.consumeService({op:n,isFullWork:!0,replaceId:s}),o=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt);case 16:t.workId&&this.workShapes["delete"](t.workId.toString());return _context68.abrupt("return",Pt(a,o));case 18:case"end":return _context68.stop();}},_callee65,this);}));function runFullWork(_x79){return _runFullWork.apply(this,arguments);}return runFullWork;}()},{key:"runSelectWork",value:function runSelectWork(t){var n;var e=this.setFullWork(t);e&&(n=t.selectIds)!=null&&n.length&&t.workId&&e.selectServiceNode(t.workId.toString(),{selectIds:t.selectIds},!1);}},{key:"workShapesDone",value:function workShapesDone(){var _iterator59=_createForOfIteratorHelper(this.workShapes.keys()),_step59;try{for(_iterator59.s();!(_step59=_iterator59.n()).done;){var t=_step59.value;this.clearWorkShapeNodeCache(t);}}catch(err){_iterator59.e(err);}finally{_iterator59.f();}this.fullLayer.removeAllChildren();}},{key:"canUseSubWorker",value:function canUseSubWorker(t){var e=this.thread.getPriorityDraw();return e||!e&&t!==ut.Pencil;}},{key:"consumeDraw",value:function(){var _consumeDraw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee66(t){var e,n,i,a,o;return _regeneratorRuntime().wrap(function _callee66$(_context69){while(1)switch(_context69.prev=_context69.next){case 0:e=t.workId,n=e==null?void 0:e.toString(),i=n&&this.workShapes.get(n);if(i){_context69.next=3;break;}return _context69.abrupt("return");case 3:_context69.t0=this.drawWorkActiveId&&this.drawWorkActiveId!==n;if(!_context69.t0){_context69.next=8;break;}_context69.next=7;return this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:ot.DrawWork,dataType:Mt.Local});case 7:this.drawWorkActiveId=void 0;case 8:!this.drawWorkActiveId&&n!==Nt&&(this.drawWorkActiveId=n);a=i.toolsType,o=i.consume({data:t,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0});_context69.t1=a;_context69.next=_context69.t1===ut.Arrow?13:_context69.t1===ut.Straight?13:_context69.t1===ut.Ellipse?13:_context69.t1===ut.Rectangle?13:_context69.t1===ut.Star?13:_context69.t1===ut.Polygon?13:_context69.t1===ut.SpeechBalloon?13:_context69.t1===ut.Pencil?19:25;break;case 13:_context69.t2=o;if(!_context69.t2){_context69.next=18;break;}this.drawCount++;_context69.next=18;return this.drawShape(o);case 18:return _context69.abrupt("break",25);case 19:_context69.t3=o;if(!_context69.t3){_context69.next=24;break;}this.drawCount++;_context69.next=24;return this.drawPencil(o,e==null?void 0:e.toString());case 24:return _context69.abrupt("break",25);case 25:case"end":return _context69.stop();}},_callee66,this);}));function consumeDraw(_x80){return _consumeDraw3.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee67(t){var e,n,i;return _regeneratorRuntime().wrap(function _callee67$(_context70){while(1)switch(_context70.prev=_context70.next){case 0:e=t.workId;if(!e){_context70.next=12;break;}n=e.toString();this.drawWorkActiveId===n&&(this.drawWorkActiveId=void 0);i=this.workShapes.get(n);if(i){_context70.next=7;break;}return _context70.abrupt("return");case 7:_context70.t0=i.toolsType;_context70.next=_context70.t0===ut.Arrow?10:_context70.t0===ut.Straight?10:_context70.t0===ut.Ellipse?10:_context70.t0===ut.Pencil?10:_context70.t0===ut.Rectangle?10:_context70.t0===ut.Star?10:_context70.t0===ut.Polygon?10:_context70.t0===ut.SpeechBalloon?10:12;break;case 10:this.drawCount=0,this.fullLayer.removeAllChildren(),this.clearWorkShapeNodeCache(n);return _context70.abrupt("break",12);case 12:case"end":return _context70.stop();}},_callee67,this);}));function consumeDrawAll(_x81){return _consumeDrawAll2.apply(this,arguments);}return consumeDrawAll;}()},{key:"removeWork",value:function(){var _removeWork4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee68(t){var e,n,i,a;return _regeneratorRuntime().wrap(function _callee68$(_context71){while(1)switch(_context71.prev=_context71.next){case 0:e=t.workId,n=e==null?void 0:e.toString();if(!n){_context71.next=8;break;}i=this.removeNode(n);if(!i){_context71.next=8;break;}a=[];a.push({rect:bt(i),clearCanvas:St.Float,isClear:!0,viewId:this.viewId},{rect:bt(i),drawCanvas:St.Float,viewId:this.viewId});_context71.next=8;return this._post({render:a});case 8:case"end":return _context71.stop();}},_callee68,this);}));function removeWork(_x82){return _removeWork4.apply(this,arguments);}return removeWork;}()},{key:"removeNode",value:function removeNode(t){var e=this.workShapes.has(t);var n;return e&&(this.fullLayer.getElementsByName(t).forEach(function(i){var a=i.getBoundingClientRect();n=Pt(n,{x:a.x-vt.SafeBorderPadding,y:a.y-vt.SafeBorderPadding,w:a.width+vt.SafeBorderPadding*2,h:a.height+vt.SafeBorderPadding*2}),i.remove();}),n&&this.clearWorkShapeNodeCache(t)),n;}},{key:"drawPencil",value:function(){var _drawPencil2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee69(t,e){return _regeneratorRuntime().wrap(function _callee69$(_context72){while(1)switch(_context72.prev=_context72.next){case 0:_context72.next=2;return this._post({drawCount:this.drawCount,render:[{rect:t==null?void 0:t.rect,workId:e,drawCanvas:St.Float,viewId:this.viewId}],sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context72.stop();}},_callee69,this);}));function drawPencil(_x83,_x84){return _drawPencil2.apply(this,arguments);}return drawPencil;}()},{key:"drawShape",value:function(){var _drawShape2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee70(t){return _regeneratorRuntime().wrap(function _callee70$(_context73){while(1)switch(_context73.prev=_context73.next){case 0:_context73.next=2;return this._post({drawCount:this.drawCount,render:[{rect:(t==null?void 0:t.rect)&&bt(t.rect),isClear:!0,clearCanvas:St.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&bt(t.rect),drawCanvas:St.Float,viewId:this.viewId}]});case 2:case"end":return _context73.stop();}},_callee70,this);}));function drawShape(_x85){return _drawShape2.apply(this,arguments);}return drawShape;}()}]);}(Ri);var ym=/*#__PURE__*/function(){function ym(r){_classCallCheck(this,ym);et(this,"viewId");et(this,"vNodes");et(this,"topLayer");et(this,"thread");et(this,"post");et(this,"serviceWorkShapes",/* @__PURE__ */new Map());et(this,"localWorkShapes",/* @__PURE__ */new Map());et(this,"tmpOpt");et(this,"syncUnitTime",re.syncOpt.interval);et(this,"animationId");this.viewId=r.viewId,this.vNodes=r.vNodes,this.topLayer=r.topLayer,this.thread=r.thread,this.post=r.thread.post.bind(r.thread);}return _createClass(ym,[{key:"canUseTopLayer",value:function canUseTopLayer(r){return r===ut.LaserPen;}},{key:"getWorkShape",value:function getWorkShape(r){return this.localWorkShapes.get(r);}},{key:"createWorkShape",value:function createWorkShape(r,t){if(r&&this.tmpOpt){var _e14={toolsType:this.tmpOpt.toolsType,toolsOpt:t||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode(_objectSpread(_objectSpread({},_e14),{},{workId:r}));return n&&this.localWorkShapes.set(r,{node:n,toolsType:n.toolsType,workState:It.Start}),n;}}},{key:"setWorkOptions",value:function setWorkOptions(r,t){var n;var e=(n=this.localWorkShapes.get(r))==null?void 0:n.node;e||this.createWorkShape(r,t),e==null||e.setWorkOptions(t);}},{key:"createWorkShapeNode",value:function createWorkShapeNode(r){var t=r.toolsType;if(t===ut.LaserPen)return Fr(_objectSpread(_objectSpread({},r),{},{vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer}));}},{key:"clearAllWorkShapesCache",value:function clearAllWorkShapesCache(){this.localWorkShapes.forEach(function(r){var t;return(t=r.node)==null?void 0:t.clearTmpPoints();}),this.localWorkShapes.clear();}},{key:"setToolsOpt",value:function setToolsOpt(r){var t;this.tmpOpt=r,(t=r.toolsOpt)!=null&&t.syncUnitTime&&(this.syncUnitTime=r.toolsOpt.syncUnitTime);}},{key:"getToolsOpt",value:function getToolsOpt(){return this.tmpOpt;}},{key:"consumeDraw",value:function consumeDraw(r){var t=r.workId,e=r.dataType;if(e===Mt.Service)this.activeServiceWorkShape(r);else{var n=t==null?void 0:t.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;var a=i.node.consume({data:r,isFullWork:!1,isSubWorker:!0});a.rect&&(i.totalRect=Pt(a.rect,i.totalRect),i.result=a,i.workState=It.Doing,n&&this.localWorkShapes.set(n,i));}this.runAnimation();}},{key:"consumeDrawAll",value:function consumeDrawAll(r){var t=r.workId,e=r.dataType;if(e===Mt.Service)this.activeServiceWorkShape(r);else{var n=t==null?void 0:t.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;var a=i.node.consumeAll({data:r});i.totalRect=Pt(a.rect,i.totalRect),i.result=a,i.workState=It.Done,n&&this.localWorkShapes.set(n,i);}this.runAnimation();}},{key:"destroy",value:function destroy(){this.serviceWorkShapes.clear(),this.localWorkShapes.clear();}},{key:"setNodeKey",value:function setNodeKey(r,t,e,n){return t.toolsType=e,t.node=this.createWorkShapeNode({workId:r,toolsType:e,toolsOpt:n}),t;}},{key:"activeServiceWorkShape",value:function activeServiceWorkShape(r){var p,y;var t=r.workId,e=r.opt,n=r.toolsType,i=r.type,a=r.updateNodeOpt,o=r.ops,s=r.op;if(!t)return;var c=t.toString(),d=(p=this.vNodes.get(c))==null?void 0:p.rect;if(!((y=this.serviceWorkShapes)!=null&&y.has(c))){var P={toolsType:n,animationWorkData:s||[],animationIndex:0,type:i,updateNodeOpt:a,ops:o,oldRect:d};n&&e&&(P=this.setNodeKey(c,P,n,e)),this.serviceWorkShapes.set(c,P);}var l=this.serviceWorkShapes.get(c);i&&(l.type=i),o&&(l.animationWorkData=Me(o),l.ops=o),a&&(l.updateNodeOpt=a),s&&(l.animationWorkData=s),l.node&&l.node.getWorkId()!==c&&l.node.setWorkId(c),d&&(l.oldRect=d),n&&e&&(l.toolsType!==n&&n&&e&&this.setNodeKey(c,l,n,e),l.node&&l.node.setWorkOptions(e));}},{key:"computNextAnimationIndex",value:function computNextAnimationIndex(r,t){var e=Math.floor((r.animationWorkData||[]).slice(r.animationIndex).length*32/t/this.syncUnitTime)*t;return Math.min((r.animationIndex||0)+(e||t),(r.animationWorkData||[]).length);}},{key:"animationDraw",value:function(){var _animationDraw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee71(){var _this101=this;var a,o,s,c,r,t,e,n,i,_iterator60,_step60,_step60$value,d,l,y,P,x,v,_iterator61,_step61,_step61$value,_d13,_l8,p,_y14,_P5,_x86,_v11;return _regeneratorRuntime().wrap(function _callee71$(_context74){while(1)switch(_context74.prev=_context74.next){case 0:this.animationId=void 0;r=!1;t=/* @__PURE__ */new Map(),e=[],n=[],i=[];_iterator60=_createForOfIteratorHelper(this.serviceWorkShapes.entries());_context74.prev=4;_iterator60.s();case 6:if((_step60=_iterator60.n()).done){_context74.next=20;break;}_step60$value=_slicedToArray(_step60.value,2),d=_step60$value[0],l=_step60$value[1];_context74.t0=l.toolsType;_context74.next=_context74.t0===ut.LaserPen?11:18;break;case 11:y=this.computNextAnimationIndex(l,8),P=Math.max(0,l.animationIndex||0),x=(l.animationWorkData||[]).slice(P,y);if((l.animationIndex||0)<y){v=(a=l.node)==null?void 0:a.consumeService({op:x,isFullWork:!1});l.totalRect=Pt(l.totalRect,v),l.animationIndex=y,x.length&&t.set(d,{workState:P===0?It.Start:y===((o=l.animationWorkData)==null?void 0:o.length)?It.Done:It.Doing,op:x.slice(-2)});}if(!(n.push({isClear:!0,rect:l.totalRect,clearCanvas:St.TopFloat,viewId:this.viewId}),e.push({rect:l.totalRect,drawCanvas:St.TopFloat,viewId:this.viewId}),l.isDel)){_context74.next=16;break;}(s=l.node)==null||s.clearTmpPoints(),this.serviceWorkShapes["delete"](d);return _context74.abrupt("break",18);case 16:l.ops&&l.animationIndex===((c=l.animationWorkData)==null?void 0:c.length)&&!l.isDel&&(this.topLayer.getElementsByName(d.toString())[0]||(l.isDel=!0,this.serviceWorkShapes.set(d,l))),r=!0;return _context74.abrupt("break",18);case 18:_context74.next=6;break;case 20:_context74.next=25;break;case 22:_context74.prev=22;_context74.t1=_context74["catch"](4);_iterator60.e(_context74.t1);case 25:_context74.prev=25;_iterator60.f();return _context74.finish(25);case 28:_iterator61=_createForOfIteratorHelper(this.localWorkShapes.entries());_context74.prev=29;_iterator61.s();case 31:if((_step61=_iterator61.n()).done){_context74.next=44;break;}_step61$value=_slicedToArray(_step61.value,2),_d13=_step61$value[0],_l8=_step61$value[1];p=_l8.result,_y14=_l8.toolsType,_P5=_l8.totalRect,_x86=_l8.isDel,_v11=_l8.workState;_context74.t2=_y14;_context74.next=_context74.t2===ut.LaserPen?37:42;break;case 37:if(!(_P5&&(n.push({isClear:!0,rect:_P5,clearCanvas:St.TopFloat,viewId:this.viewId}),e.push({rect:_P5,drawCanvas:St.TopFloat,viewId:this.viewId})),_x86)){_context74.next=40;break;}_l8.node.clearTmpPoints(),this.localWorkShapes["delete"](_d13),i.push({removeIds:[_d13.toString()],viewId:this.viewId,type:ot.RemoveNode});return _context74.abrupt("break",42);case 40:p&&((p.op||p.ops)&&i.push(p),_l8.result=void 0),!this.topLayer.getElementsByName(_d13.toString())[0]&&_v11===It.Done&&(_l8.isDel=!0,this.localWorkShapes.set(_d13,_l8)),r=!0;return _context74.abrupt("break",42);case 42:_context74.next=31;break;case 44:_context74.next=49;break;case 46:_context74.prev=46;_context74.t3=_context74["catch"](29);_iterator61.e(_context74.t3);case 49:_context74.prev=49;_iterator61.f();return _context74.finish(49);case 52:r&&this.runAnimation(),t.size&&t.forEach(function(d,l){i.push({type:ot.Cursor,uid:l.split(De)[0],op:d.op,workState:d.workState,viewId:_this101.viewId});}),(e.length||n.length||i.length)&&this.post({render:[].concat(n,e),sp:i});case 53:case"end":return _context74.stop();}},_callee71,this,[[4,22,25,28],[29,46,49,52]]);}));function animationDraw(){return _animationDraw2.apply(this,arguments);}return animationDraw;}()},{key:"runAnimation",value:function runAnimation(){var _this102=this;this.animationId||(this.animationId=setTimeout(function(){_this102.animationId=void 0,_this102.animationDraw();},16));}}]);}();var qe=/* @__PURE__ */function(h){return h.Full="full",h.Sub="sub",h;}(qe||{});var Sm=/*#__PURE__*/function(){function Sm(r,t){_classCallCheck(this,Sm);et(this,"_self");et(this,"version",fi);et(this,"type");et(this,"hasPriorityDraw",!0);et(this,"workThreadMap",/* @__PURE__ */new Map());this._self=r,this.type=t,this.register();}return _createClass(Sm,[{key:"init",value:function init(r){var t=r.viewId,e=r.dpr,n=r.offscreenCanvasOpt,i=r.layerOpt,a=r.isSafari;if(!e||!n||!i)return;var o;this.type==="full"&&(o=new xm(t,{dpr:e,offscreenCanvasOpt:n,layerOpt:i},this.post.bind(this))),this.type==="sub"&&(o=new Di(t,{dpr:e,offscreenCanvasOpt:n,layerOpt:i},this.post.bind(this)),o.setHasPriorityDraw(this.hasPriorityDraw)),o&&a&&o.setIsSafari(a),o&&r.cameraOpt&&o.setCameraOpt(r.cameraOpt),o&&this.workThreadMap.set(t,o);}},{key:"register",value:function register(){var _this103=this;onmessage=/*#__PURE__*/function(){var _ref170=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee72(r){var t,_iteratorAbruptCompletion,_didIteratorError,_iteratorError,_iterator,_step,_e15,n,i,a,o,_iterator62,_step62,c,_iterator63,_step63,_step63$value,_c8,d,l,_iterator64,_step64,_c9,s;return _regeneratorRuntime().wrap(function _callee72$(_context75){while(1)switch(_context75.prev=_context75.next){case 0:t=r.data;if(!t){_context75.next=56;break;}_iteratorAbruptCompletion=false;_didIteratorError=false;_context75.prev=4;_iterator=_asyncIterator(t.values());case 6:_context75.next=8;return _iterator.next();case 8:if(!(_iteratorAbruptCompletion=!(_step=_context75.sent).done)){_context75.next=40;break;}_e15=_step.value;n=_e15.msgType,i=_e15.viewId,a=_e15.tasksqueue,o=_e15.mainTasksqueueCount;if(!(n===ot.Console)){_context75.next=14;break;}console.log(_this103);return _context75.abrupt("continue",37);case 14:if(!(n===ot.Init)){_context75.next=17;break;}_this103.init(_e15);return _context75.abrupt("continue",37);case 17:if(!(_this103.type==="sub"&&(n===ot.PriorityWorker||n===ot.PriorityMainThreadWorker))){_context75.next=22;break;}n===ot.PriorityWorker?_this103.hasPriorityDraw=!0:n===ot.PriorityMainThreadWorker&&(_this103.hasPriorityDraw=!1);_iterator62=_createForOfIteratorHelper(_this103.workThreadMap.values());try{for(_iterator62.s();!(_step62=_iterator62.n()).done;){c=_step62.value;c.setHasPriorityDraw(_this103.hasPriorityDraw);}}catch(err){_iterator62.e(err);}finally{_iterator62.f();}return _context75.abrupt("continue",37);case 22:if(!(n===ot.TasksQueue&&a!=null&&a.size)){_context75.next=27;break;}_iterator63=_createForOfIteratorHelper(_this103.workThreadMap.entries());try{for(_iterator63.s();!(_step63=_iterator63.n()).done;){_step63$value=_slicedToArray(_step63.value,2),_c8=_step63$value[0],d=_step63$value[1];l=a.get(_c8);l&&d.on(l);}}catch(err){_iterator63.e(err);}finally{_iterator63.f();}_this103.type==="full"&&Zt(o)&&_this103.post({workerTasksqueueCount:o});return _context75.abrupt("continue",37);case 27:if(!(i===Fi)){_context75.next=31;break;}_iterator64=_createForOfIteratorHelper(_this103.workThreadMap.values());try{for(_iterator64.s();!(_step64=_iterator64.n()).done;){_c9=_step64.value;_c9.on(_e15),n===ot.Destroy&&_this103.workThreadMap["delete"](i);}}catch(err){_iterator64.e(err);}finally{_iterator64.f();}return _context75.abrupt("continue",37);case 31:s=_this103.workThreadMap.get(i);_context75.t0=s;if(!_context75.t0){_context75.next=37;break;}_context75.next=36;return s.on(_e15);case 36:n===ot.Destroy&&_this103.workThreadMap["delete"](i);case 37:_iteratorAbruptCompletion=false;_context75.next=6;break;case 40:_context75.next=46;break;case 42:_context75.prev=42;_context75.t1=_context75["catch"](4);_didIteratorError=true;_iteratorError=_context75.t1;case 46:_context75.prev=46;_context75.prev=47;if(!(_iteratorAbruptCompletion&&_iterator["return"]!=null)){_context75.next=51;break;}_context75.next=51;return _iterator["return"]();case 51:_context75.prev=51;if(!_didIteratorError){_context75.next=54;break;}throw _iteratorError;case 54:return _context75.finish(51);case 55:return _context75.finish(46);case 56:case"end":return _context75.stop();}},_callee72,null,[[4,42,46,56],[47,,51,55]]);}));return function onmessage(_x87){return _ref170.apply(this,arguments);};}();}},{key:"post",value:function post(r,t){t?this._self.postMessage(r,t):this._self.postMessage(r);}}]);}();var xm=/*#__PURE__*/function(_Ai){function xm(t,e,n){var _this104;_classCallCheck(this,xm);_this104=_callSuper(this,xm,[t,e,"full"/* Full */]);et(_this104,"type","full");et(_this104,"serviceDrawLayer");et(_this104,"localDrawLayer");et(_this104,"snapshotFullLayer");et(_this104,"methodBuilder");et(_this104,"localWork");et(_this104,"serviceWork");et(_this104,"_post");et(_this104,"taskUpdateCameraId");et(_this104,"debounceUpdateCameraId");et(_this104,"debounceUpdateCache",/* @__PURE__ */new Set());_this104._post=n;var i=re.bufferSize.sub;_this104.serviceDrawLayer=_this104.createLayer("serviceDrawLayer",_this104.scene,_objectSpread(_objectSpread({},e.layerOpt),{},{bufferSize:i})),_this104.localDrawLayer=_this104.createLayer("localDrawLayer",_this104.scene,_objectSpread(_objectSpread({},e.layerOpt),{},{bufferSize:i}));var a={thread:_this104,viewId:_this104.viewId,vNodes:_this104.vNodes,fullLayer:_this104.fullLayer};_this104.localWork=new pm(_objectSpread(_objectSpread({},a),{},{drawLayer:_this104.localDrawLayer})),_this104.serviceWork=new mm(_objectSpread(_objectSpread({},a),{},{drawLayer:_this104.serviceDrawLayer})),_this104.methodBuilder=new ki([wt.CopyNode,wt.SetColorNode,wt.DeleteNode,wt.RotateNode,wt.ScaleNode,wt.TranslateNode,wt.ZIndexNode,wt.SetFontStyle,wt.SetPoint,wt.SetLock,wt.SetShapeOpt]).registerForWorker(_this104),_this104.vNodes.init(_this104.fullLayer);return _this104;}_inherits(xm,_Ai);return _createClass(xm,[{key:"combinePost",value:function(){var _combinePost=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee73(){var _this105=this;var a,o,_this$combinePostData,t,e,n,s,_iterator65,_step65,c,d,i;return _regeneratorRuntime().wrap(function _callee73$(_context76){while(1)switch(_context76.prev=_context76.next){case 0:_this$combinePostData=this.combinePostData(),t=_this$combinePostData.render,e=_objectWithoutProperties(_this$combinePostData,_excluded4);if(!(t!=null&&t.length)){_context76.next=28;break;}s=[];_iterator65=_createForOfIteratorHelper(t);_context76.prev=4;_iterator65.s();case 6:if((_step65=_iterator65.n()).done){_context76.next=19;break;}c=_step65.value;if(!c.rect){_context76.next=17;break;}if(!(c.rect=this.safariFixRect(Xt(c.rect),this.dpr),!c.rect)){_context76.next=11;break;}return _context76.abrupt("continue",17);case 11:if(!(c.drawCanvas&&c.rect&&c.rect.w>0&&c.rect.h>0)){_context76.next=16;break;}_context76.next=14;return this.getRectImageBitmap(c);case 14:d=_context76.sent;c.imageBitmap=d,n||(n=[]),n.push(d);case 16:s.push(c);case 17:_context76.next=6;break;case 19:_context76.next=24;break;case 21:_context76.prev=21;_context76.t0=_context76["catch"](4);_iterator65.e(_context76.t0);case 24:_context76.prev=24;_iterator65.f();return _context76.finish(24);case 27:e.render=s;case 28:i=(a=e.sp)==null?void 0:a.filter(function(s){return s.type!==ot.None||s.isLockSentEventCursor;});i!=null&&i.length?e.sp=i.map(function(s){return _objectSpread(_objectSpread({},s),{},{viewId:_this105.viewId});}):delete e.sp,e.drawCount===void 0&&delete e.drawCount,(e!=null&&e.drawCount||i!=null&&i.length||(o=e.render)!=null&&o.length)&&this._post(e,n),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0);case 30:case"end":return _context76.stop();}},_callee73,this,[[4,21,24,27]]);}));function combinePost(){return _combinePost.apply(this,arguments);}return combinePost;}()},{key:"on",value:function(){var _on2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee74(t){var _this106=this;var e,n,i,a,o,s,c,d,_c10;return _regeneratorRuntime().wrap(function _callee74$(_context77){while(1)switch(_context77.prev=_context77.next){case 0:if(!this.methodBuilder.consumeForWorker(t)){_context77.next=2;break;}return _context77.abrupt("return");case 2:e=t.msgType,n=t.dataType,i=t.workId,a=t.toolsType,o=t.workState,s=t.workIds;_context77.t0=e;_context77.next=_context77.t0===ot.AuthClear?6:_context77.t0===ot.CreateWork?9:_context77.t0===ot.DrawWork?11:_context77.t0===ot.Select?20:_context77.t0===ot.UpdateNode?27:_context77.t0===ot.FullWork?27:_context77.t0===ot.RemoveNode?29:_context77.t0===ot.GetTextActive?32:_context77.t0===ot.CursorHover?35:_context77.t0===ot.CursorBlur?38:_context77.t0===ot.GetVNodeInfo?41:43;break;case 6:c=t.clearUids,d=t.localUid;this.vNodes.setCanClearUids(c),this.vNodes.setLocalUid(d);return _context77.abrupt("break",43);case 9:a!==ut.LaserPen&&this.createLocalWork(t);return _context77.abrupt("break",43);case 11:_context77.t1=a!==ut.LaserPen;if(!_context77.t1){_context77.next=19;break;}if(!(o===It.Done&&n===Mt.Local)){_context77.next=18;break;}_context77.next=16;return this.consumeDrawAll(n,t);case 16:_context77.next=19;break;case 18:this.consumeDraw(n,t);case 19:return _context77.abrupt("break",43);case 20:if(!(i===Nt)){_context77.next=25;break;}_context77.next=23;return this.localWork.updateFullSelectWork(t);case 23:_context77.next=26;break;case 25:this.serviceWork.runSelectWork(t);case 26:return _context77.abrupt("return");case 27:this.consumeFull(n,t);return _context77.abrupt("return");case 29:_context77.next=31;return this.removeNode(t);case 31:return _context77.abrupt("return");case 32:_context77.next=34;return this.checkTextActive(t);case 34:return _context77.abrupt("return");case 35:_context77.next=37;return this.cursorHover(t);case 37:return _context77.abrupt("return");case 38:_context77.next=40;return this.cursorBlur();case 40:return _context77.abrupt("return");case 41:if(i&&s){_c10=s.map(function(d){return _this106.vNodes.get(d);});this.post({sp:[{type:ot.GetVNodeInfo,dataType:Mt.Worker,workId:i,vInfo:_c10}]});}return _context77.abrupt("break",43);case 43:_context77.next=45;return _superPropGet(xm,"on",this,3)([t]);case 45:case"end":return _context77.stop();}},_callee74,this);}));function on(_x88){return _on2.apply(this,arguments);}return on;}()},{key:"removeNode",value:function(){var _removeNode2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee75(t){var _this107=this;var e,n,i,a,o,_iterator66,_step66,_loop7;return _regeneratorRuntime().wrap(function _callee75$(_context79){while(1)switch(_context79.prev=_context79.next){case 0:e=t.dataType,n=t.workId,i=t.removeIds,a=[],o=i||[];if(!(n&&o.push(n.toString()),o.length)){_context79.next=20;break;}_iterator66=_createForOfIteratorHelper(o);_context79.prev=3;_loop7=/*#__PURE__*/_regeneratorRuntime().mark(function _loop7(){var s;return _regeneratorRuntime().wrap(function _loop7$(_context78){while(1)switch(_context78.prev=_context78.next){case 0:s=_step66.value;s===Nt?a.push(_this107.localWork.removeSelector(t,_this107)):e===Mt.Local?a.push(_this107.localWork.removeWork(t).then(function(){_this107.localWork.colloctEffectSelectWork(t),_this107.deleteCachedImagesByWorkId(s);})):e===Mt.Service&&a.push(_this107.serviceWork.removeWork(t).then(function(){_this107.localWork.colloctEffectSelectWork(t),_this107.deleteCachedImagesByWorkId(s);}));case 2:case"end":return _context78.stop();}},_loop7);});_iterator66.s();case 6:if((_step66=_iterator66.n()).done){_context79.next=10;break;}return _context79.delegateYield(_loop7(),"t0",8);case 8:_context79.next=6;break;case 10:_context79.next=15;break;case 12:_context79.prev=12;_context79.t1=_context79["catch"](3);_iterator66.e(_context79.t1);case 15:_context79.prev=15;_iterator66.f();return _context79.finish(15);case 18:_context79.next=20;return Promise.all(a);case 20:case"end":return _context79.stop();}},_callee75,null,[[3,12,15,18]]);}));function removeNode(_x89){return _removeNode2.apply(this,arguments);}return removeNode;}()},{key:"checkTextActive",value:function(){var _checkTextActive2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76(t){var e;return _regeneratorRuntime().wrap(function _callee76$(_context80){while(1)switch(_context80.prev=_context80.next){case 0:e=t.dataType;_context80.t0=e===Mt.Local;if(!_context80.t0){_context80.next=5;break;}_context80.next=5;return this.localWork.checkTextActive(t);case 5:case"end":return _context80.stop();}},_callee76,this);}));function checkTextActive(_x90){return _checkTextActive2.apply(this,arguments);}return checkTextActive;}()},{key:"clearAll",value:function(){var _clearAll2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee77(){return _regeneratorRuntime().wrap(function _callee77$(_context81){while(1)switch(_context81.prev=_context81.next){case 0:this.vNodes.clear();_superPropGet(xm,"clearAll",this,3)([]);this.localDrawLayer&&(this.localDrawLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),this.localDrawLayer.removeAllChildren());this.serviceDrawLayer&&(this.serviceDrawLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),this.serviceDrawLayer.removeAllChildren());_context81.next=6;return this.post({render:[{isClearAll:!0,clearCanvas:St.Bg,viewId:this.viewId},{isClearAll:!0,clearCanvas:St.ServiceFloat,viewId:this.viewId},{isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId}],sp:[{type:ot.Clear}]});case 6:case"end":return _context81.stop();}},_callee77,this);}));function clearAll(){return _clearAll2.apply(this,arguments);}return clearAll;}()},{key:"updateLayer",value:function updateLayer(t){var e=t.width,n=t.height;_superPropGet(xm,"updateLayer",this,3)([t]),this.localDrawLayer&&(this.localDrawLayer.parent.setAttribute("width",e),this.localDrawLayer.parent.setAttribute("height",n),this.localDrawLayer.setAttribute("size",[e,n]),this.localDrawLayer.setAttribute("pos",[e*0.5,n*0.5])),this.serviceDrawLayer&&(this.serviceDrawLayer.parent.setAttribute("width",e),this.serviceDrawLayer.parent.setAttribute("height",n),this.serviceDrawLayer.setAttribute("size",[e,n]),this.serviceDrawLayer.setAttribute("pos",[e*0.5,n*0.5]));}},{key:"setCameraOpt",value:function setCameraOpt(t){this.cameraOpt=t;var e=t.scale,n=t.centerX,i=t.centerY,a=t.width,o=t.height;(a!==this.scene.width||o!==this.scene.height)&&this.updateScene({width:a,height:o}),this.fullLayer&&(this.fullLayer.setAttribute("scale",[e,e]),this.fullLayer.setAttribute("translate",[-n,-i])),this.localDrawLayer&&(this.localDrawLayer.setAttribute("scale",[e,e]),this.localDrawLayer.setAttribute("translate",[-n,-i])),this.serviceDrawLayer&&(this.serviceDrawLayer.setAttribute("scale",[e,e]),this.serviceDrawLayer.setAttribute("translate",[-n,-i]));}},{key:"getLayer",value:function getLayer(t){switch(t){case St.Bg:return this.fullLayer;case St.ServiceFloat:return this.serviceDrawLayer;case St.Float:return this.localDrawLayer;}}},{key:"getOffscreen",value:function getOffscreen(t){return this.getLayer(t).parent.canvas;}},{key:"consumeFull",value:function(){var _consumeFull2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee78(t,e){var n;return _regeneratorRuntime().wrap(function _callee78$(_context82){while(1)switch(_context82.prev=_context82.next){case 0:_context82.next=2;return this.localWork.colloctEffectSelectWork(e);case 2:n=_context82.sent;_context82.t0=n&&t===Mt.Local;if(!_context82.t0){_context82.next=7;break;}_context82.next=7;return this.localWork.consumeFull(n);case 7:n&&t===Mt.Service&&this.serviceWork.consumeFull(n);case 8:case"end":return _context82.stop();}},_callee78,this);}));function consumeFull(_x91,_x92){return _consumeFull2.apply(this,arguments);}return consumeFull;}()},{key:"consumeDraw",value:function(){var _consumeDraw4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee79(t,e){var n;return _regeneratorRuntime().wrap(function _callee79$(_context83){while(1)switch(_context83.prev=_context83.next){case 0:n=e.workId;_context83.t0=t===Mt.Local&&n;if(!_context83.t0){_context83.next=6;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(e);_context83.next=6;return this.localWork.consumeDraw(e,this.serviceWork);case 6:t===Mt.Service&&this.serviceWork.consumeDraw(e);case 7:case"end":return _context83.stop();}},_callee79,this);}));function consumeDraw(_x93,_x94){return _consumeDraw4.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee80(t,e){var n;return _regeneratorRuntime().wrap(function _callee80$(_context84){while(1)switch(_context84.prev=_context84.next){case 0:n=e.workId;_context84.t0=t===Mt.Local&&n;if(!_context84.t0){_context84.next=6;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(e);_context84.next=6;return this.localWork.consumeDrawAll(e,this.serviceWork);case 6:case"end":return _context84.stop();}},_callee80,this);}));function consumeDrawAll(_x95,_x96){return _consumeDrawAll3.apply(this,arguments);}return consumeDrawAll;}()},{key:"updateDpr",value:function(){var _updateDpr2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee81(t){return _regeneratorRuntime().wrap(function _callee81$(_context85){while(1)switch(_context85.prev=_context85.next){case 0:_superPropGet(xm,"updateDpr",this,3)([t]);_context85.next=3;return this.post({render:[{isClearAll:!0,clearCanvas:St.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:St.Bg,viewId:this.viewId}]});case 3:case"end":return _context85.stop();}},_callee81,this);}));function updateDpr(_x97){return _updateDpr2.apply(this,arguments);}return updateDpr;}()},{key:"updateCamera",value:function(){var _updateCamera=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee82(t){var _this108=this;var a,e,n,i,o,p,_iterator67,_step67,_step67$value,y,P,s,_iterator68,_step68,_step68$value,_p8,_y19,_P9,c,d,_p4,_iterator69,_step69,_y15,l,_iterator70,_step70,_p5,_y16,_iterator71,_step71,_P6,_iterator72,_step72,_step72$value,_p7,_y18,_P8,x,v,_T44,_f38,g,u,m,M,_iterator73,_step73,_step73$value,_p6,_y17;return _regeneratorRuntime().wrap(function _callee82$(_context86){while(1)switch(_context86.prev=_context86.next){case 0:e=[],n=t.cameraOpt,i=t.scenePath;if(!(n&&!oe(this.cameraOpt,n))){_context86.next=40;break;}this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0);o=!!this.serviceDrawLayer.children.length;if(!i){_context86.next=30;break;}p=!1;_iterator67=_createForOfIteratorHelper(this.localWork.getWorkShapes().entries());_context86.prev=7;_iterator67.s();case 9:if((_step67=_iterator67.n()).done){_context86.next=19;break;}_step67$value=_slicedToArray(_step67.value,2),y=_step67$value[0],P=_step67$value[1];_context86.t0=P.toolsType;_context86.next=_context86.t0===ut.Text?14:_context86.t0===ut.BitMapEraser?14:_context86.t0===ut.PencilEraser?14:_context86.t0===ut.Eraser?14:_context86.t0===ut.Selector?14:_context86.t0===ut.LaserPen?14:15;break;case 14:return _context86.abrupt("break",17);case 15:y!==we&&y!==Nt&&(p=!0);return _context86.abrupt("break",17);case 17:_context86.next=9;break;case 19:_context86.next=24;break;case 21:_context86.prev=21;_context86.t1=_context86["catch"](7);_iterator67.e(_context86.t1);case 24:_context86.prev=24;_iterator67.f();return _context86.finish(24);case 27:if(!p){_context86.next=30;break;}this.taskUpdateCameraId=setTimeout(function(){_this108.taskUpdateCameraId=void 0,_this108.updateCamera(t);},Cn);return _context86.abrupt("return");case 30:s=/* @__PURE__ */new Map();_iterator68=_createForOfIteratorHelper(this.vNodes.getNodesByType(ut.Text).entries());try{for(_iterator68.s();!(_step68=_iterator68.n()).done;){_step68$value=_slicedToArray(_step68.value,2),_p8=_step68$value[0],_y19=_step68$value[1];_P9=_y19.rect;s.set(_p8,Xt(_P9));}}catch(err){_iterator68.e(err);}finally{_iterator68.f();}c=new Set(s.keys());d=!1;if(this.localWork.hasSelector()){_p4=(a=this.localWork.getSelector())==null?void 0:a.selectIds;if(_p4){d=!0;_iterator69=_createForOfIteratorHelper(_p4);try{for(_iterator69.s();!(_step69=_iterator69.n()).done;){_y15=_step69.value;c.add(_y15);}}catch(err){_iterator69.e(err);}finally{_iterator69.f();}}}l=!1;if(this.serviceWork.selectorWorkShapes.size){_iterator70=_createForOfIteratorHelper(this.serviceWork.selectorWorkShapes.values());try{for(_iterator70.s();!(_step70=_iterator70.n()).done;){_p5=_step70.value;_y16=_p5.selectIds;if(_y16){l=!0;_iterator71=_createForOfIteratorHelper(_y16);try{for(_iterator71.s();!(_step71=_iterator71.n()).done;){_P6=_step71.value;c.add(_P6);}}catch(err){_iterator71.e(err);}finally{_iterator71.f();}}}}catch(err){_iterator70.e(err);}finally{_iterator70.f();}}if(this.setCameraOpt(n),this.vNodes.curNodeMap.size){this.vNodes.clearTarget(),this.vNodes.updateHighLevelNodesRect(c),this.debounceUpdateCameraId&&clearTimeout(this.debounceUpdateCameraId);_iterator72=_createForOfIteratorHelper(s.entries());try{for(_iterator72.s();!(_step72=_iterator72.n()).done;){_step72$value=_slicedToArray(_step72.value,2),_p7=_step72$value[0],_y18=_step72$value[1];_P8=this.vNodes.get(_p7);if(_P8){x=_y18,v=_P8.rect,_T44=this.getSceneRect(),_f38=fr(x,_T44),g=fr(v,_T44);u=!1;if((_f38!==g||x.w!==v.w||x.h!==v.h||g===Te.intersect)&&(u=!0),u){m=_P8.toolsType,M=_P8.opt;m===ut.Text&&M.workState===It.Done&&this.debounceUpdateCache.add(_p7);}}}}catch(err){_iterator72.e(err);}finally{_iterator72.f();}if(d&&this.localWork.reRenderSelector(),l){_iterator73=_createForOfIteratorHelper(this.serviceWork.selectorWorkShapes.entries());try{for(_iterator73.s();!(_step73=_iterator73.n()).done;){_step73$value=_slicedToArray(_step73.value,2),_p6=_step73$value[0],_y17=_step73$value[1];this.serviceWork.runSelectWork({workId:_p6,selectIds:_y17.selectIds,msgType:ot.Select,dataType:Mt.Service,viewId:this.viewId});}}catch(err){_iterator73.e(err);}finally{_iterator73.f();}}this.debounceUpdateCameraId=setTimeout(function(){var y;_this108.debounceUpdateCameraId=void 0;var p=[];var _iterator74=_createForOfIteratorHelper(_this108.debounceUpdateCache.values()),_step74;try{for(_iterator74.s();!(_step74=_iterator74.n()).done;){var _P7=_step74.value;if((y=_this108.fullLayer)==null?void 0:y.getElementsByName(_P7)[0]){var v=_this108.vNodes.get(_P7);if(v){var _T43=v.toolsType,_f37=v.opt,g=v.rect,u=_this108.localWork.setFullWork({toolsType:_T43,opt:_f37,workId:_P7});if(u){var m=_this108.getSceneRect(),M=fr(g,m);p.push(u.consumeServiceAsync({isFullWork:!0,replaceId:_P7,isDrawLabel:M!==Te.outside}));}}}_this108.debounceUpdateCache["delete"](_P7);}}catch(err){_iterator74.e(err);}finally{_iterator74.f();}p.length?Promise.all(p).then(function(){var P=[];P.push({isClearAll:!0,clearCanvas:St.Bg,viewId:_this108.viewId},{isDrawAll:!0,drawCanvas:St.Bg,viewId:_this108.viewId}),P.length&&_this108.post({render:P}),_this108.vNodes.updateLowLevelNodesRect(),_this108.vNodes.clearHighLevelIds();}):(_this108.vNodes.updateLowLevelNodesRect(),_this108.vNodes.clearHighLevelIds());},Cn);}o&&e.push({isClearAll:!0,clearCanvas:St.ServiceFloat,viewId:this.viewId}),this.vNodes.hasRenderNodes()&&e.push({isClearAll:!0,clearCanvas:St.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:St.Bg,viewId:this.viewId}),e.length&&this.post({render:e});case 40:case"end":return _context86.stop();}},_callee82,this,[[7,21,24,27]]);}));function updateCamera(_x98){return _updateCamera.apply(this,arguments);}return updateCamera;}()},{key:"getRectImageBitmap",value:function getRectImageBitmap(t){var e=t.rect,n=t.drawCanvas,i=Math.floor(e.x*this.dpr),a=Math.floor(e.y*this.dpr),o=Math.floor(e.w*this.dpr||1),s=Math.floor(e.h*this.dpr||1);return createImageBitmap(this.getOffscreen(n),i,a,o,s,{resizeQuality:"low"});}},{key:"cursorHover",value:function(){var _cursorHover2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee83(t){return _regeneratorRuntime().wrap(function _callee83$(_context87){while(1)switch(_context87.prev=_context87.next){case 0:_context87.next=2;return this.localWork.cursorHover(t);case 2:case"end":return _context87.stop();}},_callee83,this);}));function cursorHover(_x99){return _cursorHover2.apply(this,arguments);}return cursorHover;}()},{key:"cursorBlur",value:function(){var _cursorBlur2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee84(){return _regeneratorRuntime().wrap(function _callee84$(_context88){while(1)switch(_context88.prev=_context88.next){case 0:_context88.next=2;return this.localWork.cursorBlur();case 2:case"end":return _context88.stop();}},_callee84,this);}));function cursorBlur(){return _cursorBlur2.apply(this,arguments);}return cursorBlur;}()},{key:"destroy",value:function destroy(){_superPropGet(xm,"destroy",this,3)([]);}}]);}(Ai);var Di=/*#__PURE__*/function(_Ai2){function Di(t,e,n){var _this109;_classCallCheck(this,Di);_this109=_callSuper(this,Di,[t,e,"sub"/* Sub */]);et(_this109,"type","sub");et(_this109,"_post");et(_this109,"topLayer");et(_this109,"snapshotFullLayer");et(_this109,"serviceWork");et(_this109,"localWork");et(_this109,"topLayerWork");_this109._post=n;var i=re.bufferSize.sub;_this109.topLayer=_this109.createLayer("topLayer",_this109.scene,_objectSpread(_objectSpread({},e.layerOpt),{},{bufferSize:i}));var a={thread:_this109,viewId:_this109.viewId,vNodes:_this109.vNodes,fullLayer:_this109.fullLayer,topLayer:_this109.topLayer};_this109.localWork=new vm(a),_this109.topLayerWork=new ym(a),_this109.vNodes.init(_this109.fullLayer);return _this109;}_inherits(Di,_Ai2);return _createClass(Di,[{key:"combinePost",value:function(){var _combinePost2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee85(){var _this110=this;var a,o,s,_this$combinePostData2,t,e,n,c,_iterator75,_step75,_d14,_i11,_c11,d,_c12,_iterator76,_step76,_d15,l,i;return _regeneratorRuntime().wrap(function _callee85$(_context89){while(1)switch(_context89.prev=_context89.next){case 0:_this$combinePostData2=this.combinePostData(),t=_this$combinePostData2.render,e=_objectWithoutProperties(_this$combinePostData2,_excluded5);if((a=e.workIds)!=null&&a.size&&e.drawCount){c=[];_iterator75=_createForOfIteratorHelper(e.workIds.values());try{for(_iterator75.s();!(_step75=_iterator75.n()).done;){_d14=_step75.value;this.fullLayer.getElementsByName(_d14).forEach(function(l){l.id&&e.drawCount&&Number(l.id)<e.drawCount&&c.push(l);});}}catch(err){_iterator75.e(err);}finally{_iterator75.f();}for(_i11=0,_c11=c;_i11<_c11.length;_i11++){d=_c11[_i11];d.remove(),d.disconnect();}}if(!(t!=null&&t.length)){_context89.next=29;break;}_c12=[];_iterator76=_createForOfIteratorHelper(t);_context89.prev=5;_iterator76.s();case 7:if((_step76=_iterator76.n()).done){_context89.next=20;break;}_d15=_step76.value;if(!_d15.rect){_context89.next=18;break;}if(!(_d15.rect=this.safariFixRect(Xt(_d15.rect),this.dpr),!_d15.rect)){_context89.next=12;break;}return _context89.abrupt("continue",18);case 12:if(!(_d15.drawCanvas&&_d15.rect&&_d15.rect.w>0&&_d15.rect.h>0)){_context89.next=17;break;}_context89.next=15;return this.getRectImageBitmap(_d15);case 15:l=_context89.sent;_d15.imageBitmap=l,n||(n=[]),n.push(l);case 17:_c12.push(_d15);case 18:_context89.next=7;break;case 20:_context89.next=25;break;case 22:_context89.prev=22;_context89.t0=_context89["catch"](5);_iterator76.e(_context89.t0);case 25:_context89.prev=25;_iterator76.f();return _context89.finish(25);case 28:e.render=_c12;case 29:i=(o=e.sp)==null?void 0:o.filter(function(c){return c.type!==ot.None;});i!=null&&i.length?e.sp=i.map(function(c){return _objectSpread(_objectSpread({},c),{},{viewId:_this110.viewId});}):delete e.sp,e.drawCount===void 0&&delete e.drawCount,(i!=null&&i.length||e.drawCount||(s=e==null?void 0:e.render)!=null&&s.length)&&this._post(e,n),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0);case 31:case"end":return _context89.stop();}},_callee85,this,[[5,22,25,28]]);}));function combinePost(){return _combinePost2.apply(this,arguments);}return combinePost;}()},{key:"getLayer",value:function getLayer(t,e){if(e&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(t){case St.TopFloat:return this.topLayer;default:return this.fullLayer;}}},{key:"on",value:function(){var _on3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee86(t){var e,n,i,a,o,s;return _regeneratorRuntime().wrap(function _callee86$(_context90){while(1)switch(_context90.prev=_context90.next){case 0:e=t.msgType,n=t.toolsType,i=t.opt,a=t.dataType,o=t.workState;_context90.t0=e;_context90.next=_context90.t0===ot.UpdateTools?4:_context90.t0===ot.CreateWork?9:_context90.t0===ot.DrawWork?11:_context90.t0===ot.RemoveNode?18:_context90.t0===ot.FullWork?21:_context90.t0===ot.Snapshot?26:_context90.t0===ot.BoundingBox?33:40;break;case 4:if(!(n&&this.topLayerWork.canUseTopLayer(n)&&i)){_context90.next=8;break;}s={toolsType:n,toolsOpt:i};this.topLayerWork.setToolsOpt(s);return _context90.abrupt("return");case 8:return _context90.abrupt("break",40);case 9:this.createLocalWork(t);return _context90.abrupt("return");case 11:if(!(o===It.Done&&a===Mt.Local)){_context90.next=16;break;}_context90.next=14;return this.consumeDrawAll(a,t);case 14:_context90.next=17;break;case 16:this.consumeDraw(a,t);case 17:return _context90.abrupt("return");case 18:_context90.next=20;return this.removeNode(t);case 20:return _context90.abrupt("return");case 21:_context90.t1=n&&this.topLayerWork.canUseTopLayer(n);if(!_context90.t1){_context90.next=25;break;}_context90.next=25;return this.consumeDrawAll(a,t);case 25:return _context90.abrupt("return");case 26:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,_objectSpread(_objectSpread({},this.opt.layerOpt),{},{bufferSize:this.viewId===Qe?6e3:3e3}));_context90.t2=this.snapshotFullLayer;if(!_context90.t2){_context90.next=32;break;}_context90.next=31;return this.getSnapshot(t);case 31:this.snapshotFullLayer=void 0;case 32:return _context90.abrupt("return");case 33:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,_objectSpread(_objectSpread({},this.opt.layerOpt),{},{bufferSize:this.viewId===Qe?6e3:3e3}));_context90.t3=this.snapshotFullLayer;if(!_context90.t3){_context90.next=39;break;}_context90.next=38;return this.getBoundingRect(t);case 38:this.snapshotFullLayer=void 0;case 39:return _context90.abrupt("return");case 40:_context90.next=42;return _superPropGet(Di,"on",this,3)([t]);case 42:case"end":return _context90.stop();}},_callee86,this);}));function on(_x100){return _on3.apply(this,arguments);}return on;}()},{key:"createLocalWork",value:function createLocalWork(t){var e=t.workId,n=t.toolsType,i=t.opt;if(n&&this.topLayerWork.canUseTopLayer(n)&&e&&i){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:n,toolsOpt:i}),this.topLayerWork.setWorkOptions(e.toString(),i);return;}n&&this.localWork.canUseSubWorker(n)&&_superPropGet(Di,"createLocalWork",this,3)([t]);}},{key:"removeNode",value:function(){var _removeNode3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee87(t){var e;return _regeneratorRuntime().wrap(function _callee87$(_context91){while(1)switch(_context91.prev=_context91.next){case 0:e=t.dataType;_context91.t0=e===Mt.Local;if(!_context91.t0){_context91.next=5;break;}_context91.next=5;return this.localWork.removeWork(t);case 5:case"end":return _context91.stop();}},_callee87,this);}));function removeNode(_x101){return _removeNode3.apply(this,arguments);}return removeNode;}()},{key:"getOffscreen",value:function getOffscreen(t,e){return this.getLayer(t,e).parent.canvas;}},{key:"consumeDraw",value:function(){var _consumeDraw5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee88(t,e){var n,i;return _regeneratorRuntime().wrap(function _callee88$(_context92){while(1)switch(_context92.prev=_context92.next){case 0:n=e.workId,i=e.toolsType;if(!n){_context92.next=11;break;}if(!(i&&this.topLayerWork.canUseTopLayer(i))){_context92.next=5;break;}t===Mt.Local&&(this.topLayerWork.getWorkShape(n.toString())||this.createLocalWork(e)),this.topLayerWork.consumeDraw(e);return _context92.abrupt("return");case 5:_context92.t0=i&&this.localWork.canUseSubWorker(i);if(!_context92.t0){_context92.next=10;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(e);_context92.next=10;return this.localWork.consumeDraw(e);case 10:return _context92.abrupt("return");case 11:case"end":return _context92.stop();}},_callee88,this);}));function consumeDraw(_x102,_x103){return _consumeDraw5.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee89(t,e){var n,i,a,o;return _regeneratorRuntime().wrap(function _callee89$(_context93){while(1)switch(_context93.prev=_context93.next){case 0:n=e.workId,i=e.toolsType,a=e.dataType;if(!n){_context93.next=8;break;}o=n.toString();if(!(i&&this.topLayerWork.canUseTopLayer(i))){_context93.next=6;break;}a===Mt.Local&&(this.topLayerWork.getWorkShape(o)||this.createLocalWork(e)),this.topLayerWork.consumeDrawAll(e);return _context93.abrupt("return");case 6:i&&this.localWork.canUseSubWorker(i)&&(this.localWork.getWorkShape(o)||_superPropGet(Di,"createLocalWork",this,3)([e]),this.localWork.consumeDrawAll(e));return _context93.abrupt("return");case 8:case"end":return _context93.stop();}},_callee89,this);}));function consumeDrawAll(_x104,_x105){return _consumeDrawAll4.apply(this,arguments);}return consumeDrawAll;}()},{key:"clearAll",value:function(){var _clearAll3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee90(){return _regeneratorRuntime().wrap(function _callee90$(_context94){while(1)switch(_context94.prev=_context94.next){case 0:this.vNodes.clear();_superPropGet(Di,"clearAll",this,3)([]);this.topLayer&&(this.topLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),this.topLayer.removeAllChildren());_context94.next=5;return this.post({render:[{isClearAll:!0,clearCanvas:St.TopFloat,viewId:this.viewId}],sp:[{type:ot.Clear}]});case 5:case"end":return _context94.stop();}},_callee90,this);}));function clearAll(){return _clearAll3.apply(this,arguments);}return clearAll;}()},{key:"getRectImageBitmap",value:function getRectImageBitmap(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var n=arguments.length>2?arguments[2]:undefined;var i=t.rect,a=t.drawCanvas,o=Math.floor(i.x*this.dpr),s=Math.floor(i.y*this.dpr),c=Math.floor(i.w*this.dpr||1),d=Math.floor(i.h*this.dpr||1);return createImageBitmap(this.getOffscreen(a,e),o,s,c,d,n);}},{key:"updateLayer",value:function updateLayer(t){var e=t.width,n=t.height;_superPropGet(Di,"updateLayer",this,3)([t]),this.topLayer&&(this.topLayer.parent.setAttribute("width",e),this.topLayer.parent.setAttribute("height",n),this.topLayer.setAttribute("size",[e,n]),this.topLayer.setAttribute("pos",[e*0.5,n*0.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",e),this.snapshotFullLayer.parent.setAttribute("height",n),this.snapshotFullLayer.setAttribute("size",[e,n]),this.snapshotFullLayer.setAttribute("pos",[e*0.5,n*0.5]));}},{key:"updateDpr",value:function(){var _updateDpr3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee91(t){var e,n,i;return _regeneratorRuntime().wrap(function _callee91$(_context95){while(1)switch(_context95.prev=_context95.next){case 0:_superPropGet(Di,"updateDpr",this,3)([t]);e=!!this.topLayerWork.localWorkShapes.size,n=!!this.localWork.getWorkShapes().size,i=[];n&&i.push({isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId});e&&i.push({isClearAll:!0,clearCanvas:St.TopFloat,viewId:this.viewId});_context95.t0=i.length;if(!_context95.t0){_context95.next=8;break;}_context95.next=8;return this.post({render:i});case 8:case"end":return _context95.stop();}},_callee91,this);}));function updateDpr(_x106){return _updateDpr3.apply(this,arguments);}return updateDpr;}()},{key:"updateCamera",value:function(){var _updateCamera2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee92(t){var _this111=this;var e,n,i,a,_iterator77,_step77,_loop8;return _regeneratorRuntime().wrap(function _callee92$(_context97){while(1)switch(_context97.prev=_context97.next){case 0:e=[],n=t.cameraOpt;if(!(n&&!oe(this.cameraOpt,n))){_context97.next=25;break;}i=!!this.topLayerWork.localWorkShapes.size,a=!!this.localWork.getWorkShapes().size;if(!(a&&this.localWork.workShapesDone(),this.setCameraOpt(n),a&&e.push({isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId}),i)){_context97.next=21;break;}e.push({isClearAll:!0,clearCanvas:St.TopFloat,viewId:this.viewId});_iterator77=_createForOfIteratorHelper(this.topLayerWork.localWorkShapes.entries());_context97.prev=6;_loop8=/*#__PURE__*/_regeneratorRuntime().mark(function _loop8(){var _step77$value,o,s,c;return _regeneratorRuntime().wrap(function _loop8$(_context96){while(1)switch(_context96.prev=_context96.next){case 0:_step77$value=_slicedToArray(_step77.value,2),o=_step77$value[0],s=_step77$value[1];if(s.totalRect){_this111.topLayer.getElementsByName(o.toString()).forEach(function(d){var l=d.getBoundingClientRect(),p=bt({x:l.x,y:l.y,w:l.width,h:l.height});c=Pt(c,p);}),s.totalRect=c,_this111.topLayerWork.localWorkShapes.set(o,s);}case 2:case"end":return _context96.stop();}},_loop8);});_iterator77.s();case 9:if((_step77=_iterator77.n()).done){_context97.next=13;break;}return _context97.delegateYield(_loop8(),"t0",11);case 11:_context97.next=9;break;case 13:_context97.next=18;break;case 15:_context97.prev=15;_context97.t1=_context97["catch"](6);_iterator77.e(_context97.t1);case 18:_context97.prev=18;_iterator77.f();return _context97.finish(18);case 21:_context97.t2=e.length;if(!_context97.t2){_context97.next=25;break;}_context97.next=25;return this.post({render:e});case 25:case"end":return _context97.stop();}},_callee92,this,[[6,15,18,21]]);}));function updateCamera(_x107){return _updateCamera2.apply(this,arguments);}return updateCamera;}()},{key:"setCameraOpt",value:function setCameraOpt(t,e){this.cameraOpt=t;var n=t.scale,i=t.centerX,a=t.centerY,o=t.width,s=t.height;(o!==this.scene.width||s!==this.scene.height)&&this.updateScene({width:o,height:s}),e?(e.setAttribute("scale",[n,n]),e.setAttribute("translate",[-i,-a])):(this.fullLayer.setAttribute("scale",[n,n]),this.fullLayer.setAttribute("translate",[-i,-a]),this.topLayer.setAttribute("scale",[n,n]),this.topLayer.setAttribute("translate",[-i,-a]));}},{key:"getSnapshot",value:function(){var _getSnapshot=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee93(t){var e,n,i,a,o,s,c,_i12,_Object$entries,_Object$entries$_i,l,p,y,P,x,d;return _regeneratorRuntime().wrap(function _callee93$(_context98){while(1)switch(_context98.prev=_context98.next){case 0:e=t.scenePath,n=t.scenes,i=t.cameraOpt,a=t.w,o=t.h;if(!(e&&n&&i&&this.snapshotFullLayer)){_context98.next=26;break;}s=Xt(this.cameraOpt);this.setCameraOpt(i,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;_i12=0,_Object$entries=Object.entries(n);case 5:if(!(_i12<_Object$entries.length)){_context98.next=21;break;}_Object$entries$_i=_slicedToArray(_Object$entries[_i12],2),l=_Object$entries$_i[0],p=_Object$entries$_i[1];if(!(p!=null&&p.type)){_context98.next=18;break;}_context98.t0=p==null?void 0:p.type;_context98.next=_context98.t0===ot.UpdateNode?11:_context98.t0===ot.FullWork?11:18;break;case 11:y=p.opt;P=_objectSpread(_objectSpread({},p),{},{opt:y,workId:l,msgType:ot.FullWork,dataType:Mt.Service,viewId:this.viewId});_context98.next=15;return this.localWork.runFullWork(P);case 15:x=_context98.sent;c=Pt(c,x);return _context98.abrupt("break",18);case 18:_i12++;_context98.next=5;break;case 21:a&&o&&(d={resizeWidth:a,resizeHeight:o});_context98.next=24;return this.getSnapshotRender({scenePath:e,curCameraOpt:s,options:d});case 24:this.localWork.fullLayer=this.fullLayer;this.localWork.drawLayer=void 0;case 26:case"end":return _context98.stop();}},_callee93,this);}));function getSnapshot(_x108){return _getSnapshot.apply(this,arguments);}return getSnapshot;}()},{key:"getSnapshotRender",value:function(){var _getSnapshotRender=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee94(t){var o,s,e,n,i,a;return _regeneratorRuntime().wrap(function _callee94$(_context99){while(1)switch(_context99.prev=_context99.next){case 0:e=t.scenePath,n=t.curCameraOpt,i=t.options;((o=this.snapshotFullLayer)==null?void 0:o.parent).render();_context99.next=4;return this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:St.None},!0,i);case 4:a=_context99.sent;a&&(this._post({sp:[{type:ot.Snapshot,scenePath:e,imageBitmap:a,viewId:this.viewId}]},[a]),a.close(),(s=this.snapshotFullLayer)==null||s.removeAllChildren(),this.setCameraOpt(n,this.fullLayer));case 6:case"end":return _context99.stop();}},_callee94,this);}));function getSnapshotRender(_x109){return _getSnapshotRender.apply(this,arguments);}return getSnapshotRender;}()},{key:"getBoundingRect",value:function(){var _getBoundingRect=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee95(t){var e,n,i,a,o,_i13,_Object$entries2,_Object$entries2$_i,s,c,d;return _regeneratorRuntime().wrap(function _callee95$(_context100){while(1)switch(_context100.prev=_context100.next){case 0:e=t.scenePath,n=t.scenes,i=t.cameraOpt;if(!(e&&n&&i&&this.snapshotFullLayer)){_context100.next=27;break;}a=Xt(this.cameraOpt);this.setCameraOpt(i,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;_i13=0,_Object$entries2=Object.entries(n);case 5:if(!(_i13<_Object$entries2.length)){_context100.next=19;break;}_Object$entries2$_i=_slicedToArray(_Object$entries2[_i13],2),s=_Object$entries2$_i[0],c=_Object$entries2$_i[1];if(!(c!=null&&c.type)){_context100.next=16;break;}_context100.t0=c==null?void 0:c.type;_context100.next=_context100.t0===ot.UpdateNode?11:_context100.t0===ot.FullWork?11:16;break;case 11:_context100.next=13;return this.localWork.runFullWork(_objectSpread(_objectSpread({},c),{},{workId:s,msgType:ot.FullWork,dataType:Mt.Service,viewId:this.viewId}));case 13:d=_context100.sent;o=Pt(o,d);return _context100.abrupt("break",16);case 16:_i13++;_context100.next=5;break;case 19:_context100.t1=o;if(!_context100.t1){_context100.next=23;break;}_context100.next=23;return this.post({sp:[{type:ot.BoundingBox,scenePath:e,rect:o}]});case 23:this.localWork.fullLayer=this.fullLayer;this.localWork.drawLayer=void 0;this.snapshotFullLayer.removeAllChildren();this.setCameraOpt(a,this.fullLayer);case 27:case"end":return _context100.stop();}},_callee95,this);}));function getBoundingRect(_x110){return _getBoundingRect.apply(this,arguments);}return getBoundingRect;}()}]);}(Ai);var Wn=self;Wn.full=new Sm(Wn,qe.Full);