@netless/appliance-plugin 1.1.17-beta.8 → 1.1.17-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";var gn=Object.defineProperty;var yn=(a,s,e)=>s in a?gn(a,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[s]=e;var y=(a,s,e)=>yn(a,typeof s!="symbol"?s+"":s,e);const G=require("white-web-sdk"),ce=require("spritejs"),ro=require("lz-string"),Ze=require("clipper-lib"),Vs=require("lineclip"),Ps=require("eventemitter2"),A=require("lodash"),m=require("react"),hs=require("react-dom"),Lt=require("react-draggable"),mn=require("re-resizable"),Mn="/fullWorker.js",wn="/subWorker.js";var ne=(a=>(a.selector="selector",a.clicker="clicker",a.laserPointer="laserPointer",a.pencil="pencil",a.rectangle="rectangle",a.ellipse="ellipse",a.shape="shape",a.eraser="eraser",a.pencilEraser="pencilEraser",a.text="text",a.straight="straight",a.arrow="arrow",a.hand="hand",a.laserPen="laserPen",a))(ne||{}),te=(a=>(a.Normal="Normal",a.Stroke="Stroke",a.Dotted="Dotted",a.LongDotted="LongDotted",a))(te||{}),$e=(a=>(a.Triangle="triangle",a.Rhombus="rhombus",a.Pentagram="pentagram",a.SpeechBalloon="speechBalloon",a.Star="star",a.Polygon="polygon",a))($e||{}),V=(a=>(a.None="None",a.ShowFloatBar="ShowFloatBar",a.ZIndexFloatBar="ZIndexFloatBar",a.DeleteNode="DeleteNode",a.CopyNode="CopyNode",a.ZIndexActive="ZIndexActive",a.ZIndexNode="ZIndexNode",a.RotateNode="RotateNode",a.SetColorNode="SetColorNode",a.TranslateNode="TranslateNode",a.ScaleNode="ScaleNode",a.OriginalEvent="OriginalEvent",a.CreateScene="CreateScene",a.ActiveCursor="ActiveCursor",a.MoveCursor="MoveCursor",a.CommandEditor="CommandEditor",a.SetEditorData="SetEditorData",a.SetFontStyle="SetFontStyle",a.SetPoint="SetPoint",a.SetLock="SetLock",a.SetShapeOpt="SetShapeOpt",a.CameraChange="CameraChange",a.ActiveMethod="ActiveMethod",a.HidFloatBarBtn="HidFloatBarBtn",a))(V||{}),se=(a=>(a.DisplayState="DisplayState",a.MainEngine="MainEngine",a.Cursor="Cursor",a.BindMainView="BindMainView",a))(se||{}),ao=(a=>(a[a.MainView=0]="MainView",a[a.Plugin=1]="Plugin",a[a.Both=2]="Both",a))(ao||{}),us=(a=>(a.longPencil="longPencil",a))(us||{}),N=(a=>(a[a.Pencil=1]="Pencil",a[a.Eraser=2]="Eraser",a[a.PencilEraser=3]="PencilEraser",a[a.BitMapEraser=4]="BitMapEraser",a[a.Selector=5]="Selector",a[a.Clicker=6]="Clicker",a[a.Arrow=7]="Arrow",a[a.Hand=8]="Hand",a[a.LaserPen=9]="LaserPen",a[a.Text=10]="Text",a[a.Straight=11]="Straight",a[a.Rectangle=12]="Rectangle",a[a.Ellipse=13]="Ellipse",a[a.Star=14]="Star",a[a.Triangle=15]="Triangle",a[a.Rhombus=16]="Rhombus",a[a.Polygon=17]="Polygon",a[a.SpeechBalloon=18]="SpeechBalloon",a[a.Image=19]="Image",a))(N||{}),F=(a=>(a[a.Local=1]="Local",a[a.Service=2]="Service",a[a.Worker=3]="Worker",a))(F||{}),z=(a=>(a[a.Pending=0]="Pending",a[a.Start=1]="Start",a[a.Doing=2]="Doing",a[a.Done=3]="Done",a[a.Unwritable=4]="Unwritable",a))(z||{}),x=(a=>(a[a.None=0]="None",a[a.Init=1]="Init",a[a.UpdateCamera=2]="UpdateCamera",a[a.UpdateTools=3]="UpdateTools",a[a.CreateWork=4]="CreateWork",a[a.DrawWork=5]="DrawWork",a[a.FullWork=6]="FullWork",a[a.UpdateNode=7]="UpdateNode",a[a.RemoveNode=8]="RemoveNode",a[a.Clear=9]="Clear",a[a.Select=10]="Select",a[a.Destroy=11]="Destroy",a[a.Snapshot=12]="Snapshot",a[a.BoundingBox=13]="BoundingBox",a[a.Cursor=14]="Cursor",a[a.TextUpdate=15]="TextUpdate",a[a.GetTextActive=16]="GetTextActive",a[a.TasksQueue=17]="TasksQueue",a[a.CursorHover=18]="CursorHover",a[a.CursorBlur=19]="CursorBlur",a[a.Console=20]="Console",a[a.PriorityWorker=21]="PriorityWorker",a[a.PriorityMainThreadWorker=22]="PriorityMainThreadWorker",a[a.GetImageBitMap=23]="GetImageBitMap",a[a.AuthWriter=24]="AuthWriter",a[a.AuthReader=25]="AuthReader",a[a.AuthClear=26]="AuthClear",a[a.AuthPage=27]="AuthPage",a[a.GetVNodeInfo=28]="GetVNodeInfo",a[a.UpdateDpr=29]="UpdateDpr",a))(x||{}),me=(a=>(a[a.None=0]="None",a[a.Bg=1]="Bg",a[a.ServiceFloat=2]="ServiceFloat",a[a.Float=3]="Float",a[a.TopFloat=4]="TopFloat",a))(me||{}),Yt=(a=>(a[a.Cursor=1]="Cursor",a[a.TextCreate=2]="TextCreate",a))(Yt||{}),Ut=(a=>(a[a.Top=1]="Top",a[a.Bottom=2]="Bottom",a))(Ut||{}),re=(a=>(a[a.none=1]="none",a[a.all=2]="all",a[a.both=3]="both",a[a.proportional=4]="proportional",a))(re||{}),co=(a=>(a[a.Pending=0]="Pending",a[a.Start=1]="Start",a[a.Doing=2]="Doing",a[a.Done=3]="Done",a[a.Unwritable=4]="Unwritable",a))(co||{}),ft=(a=>(a[a.inside=0]="inside",a[a.outside=1]="outside",a[a.intersect=2]="intersect",a))(ft||{}),De=(a=>(a.renderPage="renderPage",a.addPage="addPage",a.deletePage="deletePage",a.addElement="addElement",a.deleteElement="deleteElement",a.clearPage="clearPage",a.clearViewScenePath="clearViewScenePath",a.clearView="clearView",a))(De||{}),Qe=(a=>(a.setAuth="setAuth",a.setShow="addShow",a.setHide="setHide",a.setClear="setClear",a))(Qe||{}),gt=(a=>(a.Image="image",a.Iconify="iconify",a))(gt||{});const vn={linear:a=>a,easeInQuad:a=>a*a,easeOutQuad:a=>a*(2-a),easeInOutQuad:a=>a<.5?2*a*a:-1+(4-2*a)*a,easeInCubic:a=>a*a*a,easeOutCubic:a=>--a*a*a+1,easeInOutCubic:a=>a<.5?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1,easeInQuart:a=>a*a*a*a,easeOutQuart:a=>1- --a*a*a*a,easeInOutQuart:a=>a<.5?8*a*a*a*a:1-8*--a*a*a*a,easeInQuint:a=>a*a*a*a*a,easeOutQuint:a=>1+--a*a*a*a*a,easeInOutQuint:a=>a<.5?16*a*a*a*a*a:1+16*--a*a*a*a*a,easeInSine:a=>1-Math.cos(a*Math.PI/2),easeOutSine:a=>Math.sin(a*Math.PI/2),easeInOutSine:a=>-(Math.cos(Math.PI*a)-1)/2,easeInExpo:a=>a<=0?0:Math.pow(2,10*a-10),easeOutExpo:a=>a>=1?1:1-Math.pow(2,-10*a),easeInOutExpo:a=>a<=0?0:a>=1?1:a<.5?Math.pow(2,20*a-10)/2:(2-Math.pow(2,-20*a+10))/2};class b{constructor(s=0,e=0,t=1){this.x=s,this.y=e,this.z=t}get XY(){return[this.x,this.y]}setz(s){return this.z=s,this}setXY(s=this.x,e=this.y){return this.x=s,this.y=e,this}set(s=this.x,e=this.y,t=this.z){return this.x=s,this.y=e,this.z=t,this}setTo({x:s=0,y:e=0,z:t=1}){return this.x=s,this.y=e,this.z=t,this}rot(s){if(s===0)return this;const{x:e,y:t}=this,i=Math.sin(s),o=Math.cos(s);return this.x=e*o-t*i,this.y=e*i+t*o,this}rotWith(s,e){if(e===0)return this;const t=this.x-s.x,i=this.y-s.y,o=Math.sin(e),n=Math.cos(e);return this.x=s.x+(t*n-i*o),this.y=s.y+(t*o+i*n),this}clone(){const{x:s,y:e,z:t}=this;return new b(s,e,t)}sub(s){return this.x-=s.x,this.y-=s.y,this}subXY(s,e){return this.x-=s,this.y-=e,this}subScalar(s){return this.x-=s,this.y-=s,this}add(s){return this.x+=s.x,this.y+=s.y,this}addXY(s,e){return this.x+=s,this.y+=e,this}addScalar(s){return this.x+=s,this.y+=s,this}clamp(s,e){return this.x=Math.max(this.x,s),this.y=Math.max(this.y,s),e!==void 0&&(this.x=Math.min(this.x,e),this.y=Math.min(this.y,e)),this}div(s){return this.x/=s,this.y/=s,this}divV(s){return this.x/=s.x,this.y/=s.y,this}mul(s){return this.x*=s,this.y*=s,this}mulV(s){return this.x*=s.x,this.y*=s.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(s,e){const t=b.Tan(s,this);return this.add(t.mul(e))}neg(){return this.x*=-1,this.y*=-1,this}cross(s){return this.x=this.y*s.z-this.z*s.y,this.y=this.z*s.x-this.x*s.z,this}dpr(s){return b.Dpr(this,s)}cpr(s){return b.Cpr(this,s)}len2(){return b.Len2(this)}len(){return b.Len(this)}pry(s){return b.Pry(this,s)}per(){const{x:s,y:e}=this;return this.x=e,this.y=-s,this}uni(){return b.Uni(this)}tan(s){return b.Tan(this,s)}dist(s){return b.Dist(this,s)}distanceToLineSegment(s,e){return b.DistanceToLineSegment(s,e,this)}slope(s){return b.Slope(this,s)}snapToGrid(s){return this.x=Math.round(this.x/s)*s,this.y=Math.round(this.y/s)*s,this}angle(s){return b.Angle(this,s)}toAngle(){return b.ToAngle(this)}lrp(s,e){return this.x=this.x+(s.x-this.x)*e,this.y=this.y+(s.y-this.y)*e,this}equals(s,e){return b.Equals(this,s,e)}equalsXY(s,e){return b.EqualsXY(this,s,e)}norm(){const s=this.len();return this.x=s===0?0:this.x/s,this.y=s===0?0:this.y/s,this}toFixed(){return b.ToFixed(this)}toString(){return b.ToString(b.ToFixed(this))}toJson(){return b.ToJson(this)}toArray(){return b.ToArray(this)}static Add(s,e){return new b(s.x+e.x,s.y+e.y)}static AddXY(s,e,t){return new b(s.x+e,s.y+t)}static Sub(s,e){return new b(s.x-e.x,s.y-e.y)}static SubXY(s,e,t){return new b(s.x-e,s.y-t)}static AddScalar(s,e){return new b(s.x+e,s.y+e)}static SubScalar(s,e){return new b(s.x-e,s.y-e)}static Div(s,e){return new b(s.x/e,s.y/e)}static Mul(s,e){return new b(s.x*e,s.y*e)}static DivV(s,e){return new b(s.x/e.x,s.y/e.y)}static MulV(s,e){return new b(s.x*e.x,s.y*e.y)}static Neg(s){return new b(-s.x,-s.y)}static Per(s){return new b(s.y,-s.x)}static Dist2(s,e){return b.Sub(s,e).len2()}static Abs(s){return new b(Math.abs(s.x),Math.abs(s.y))}static Dist(s,e){return Math.hypot(s.y-e.y,s.x-e.x)}static Dpr(s,e){return s.x*e.x+s.y*e.y}static Cross(s,e){return new b(s.y*e.z-s.z*e.y,s.z*e.x-s.x*e.z)}static Cpr(s,e){return s.x*e.y-e.x*s.y}static Len2(s){return s.x*s.x+s.y*s.y}static Len(s){return Math.hypot(s.x,s.y)}static Pry(s,e){return b.Dpr(s,e)/b.Len(e)}static Uni(s){return b.Div(s,b.Len(s))}static Tan(s,e){return b.Uni(b.Sub(s,e))}static Min(s,e){return new b(Math.min(s.x,e.x),Math.min(s.y,e.y))}static Max(s,e){return new b(Math.max(s.x,e.x),Math.max(s.y,e.y))}static From(s){return new b().add(s)}static FromArray(s){return new b(s[0],s[1])}static Rot(s,e=0){const t=Math.sin(e),i=Math.cos(e);return new b(s.x*i-s.y*t,s.x*t+s.y*i)}static RotWith(s,e,t){const i=s.x-e.x,o=s.y-e.y,n=Math.sin(t),r=Math.cos(t);return new b(e.x+(i*r-o*n),e.y+(i*n+o*r))}static NearestPointOnLineThroughPoint(s,e,t){return b.Mul(e,b.Sub(t,s).pry(e)).add(s)}static NearestPointOnLineSegment(s,e,t,i=!0){const o=b.Tan(e,s),n=b.Add(s,b.Mul(o,b.Sub(t,s).pry(o)));if(i){if(n.x<Math.min(s.x,e.x))return b.Cast(s.x<e.x?s:e);if(n.x>Math.max(s.x,e.x))return b.Cast(s.x>e.x?s:e);if(n.y<Math.min(s.y,e.y))return b.Cast(s.y<e.y?s:e);if(n.y>Math.max(s.y,e.y))return b.Cast(s.y>e.y?s:e)}return n}static DistanceToLineThroughPoint(s,e,t){return b.Dist(t,b.NearestPointOnLineThroughPoint(s,e,t))}static DistanceToLineSegment(s,e,t,i=!0){return b.Dist(t,b.NearestPointOnLineSegment(s,e,t,i))}static Snap(s,e=1){return new b(Math.round(s.x/e)*e,Math.round(s.y/e)*e)}static Cast(s){return s instanceof b?s:b.From(s)}static Slope(s,e){return s.x===e.y?NaN:(s.y-e.y)/(s.x-e.x)}static Angle(s,e){return Math.atan2(e.y-s.y,e.x-s.x)}static Lrp(s,e,t){return b.Sub(e,s).mul(t).add(s)}static Med(s,e){return new b((s.x+e.x)/2,(s.y+e.y)/2)}static Equals(s,e,t=1e-4){return Math.abs(s.x-e.x)<t&&Math.abs(s.y-e.y)<t}static EqualsXY(s,e,t){return s.x===e&&s.y===t}static EqualsXYZ(s,e,t=1e-4){return b.Equals(s,e,t)&&Math.abs((s.z||0)-(e.z||0))<t}static Clockwise(s,e,t){return(t.x-s.x)*(e.y-s.y)-(e.x-s.x)*(t.y-s.y)<0}static Rescale(s,e){const t=b.Len(s);return new b(e*s.x/t,e*s.y/t)}static ScaleWithOrigin(s,e,t){return b.Sub(s,t).mul(e).add(t)}static ScaleWOrigin(s,e,t){return b.Sub(s,t).mulV(e).add(t)}static ToFixed(s,e=2){return new b(+s.x.toFixed(e),+s.y.toFixed(e),+s.z.toFixed(e))}static Nudge(s,e,t){return b.Add(s,b.Tan(e,s).mul(t))}static ToString(s){return`${s.x}, ${s.y}`}static ToAngle(s){let e=Math.atan2(s.y,s.x);return e<0&&(e+=Math.PI*2),e}static FromAngle(s,e=1){return new b(Math.cos(s)*e,Math.sin(s)*e)}static ToArray(s){return[s.x,s.y,s.z]}static ToJson(s){const{x:e,y:t,z:i}=s;return{x:e,y:t,z:i}}static Average(s){const e=s.length,t=new b(0,0);for(let i=0;i<e;i++)t.add(s[i]);return t.div(e)}static Clamp(s,e,t){return t===void 0?new b(Math.min(Math.max(s.x,e)),Math.min(Math.max(s.y,e))):new b(Math.min(Math.max(s.x,e),t),Math.min(Math.max(s.y,e),t))}static PointsBetween(s,e,t=6){const i=[];for(let o=0;o<t;o++){const n=vn.easeInQuad(o/(t-1)),r=b.Lrp(s,e,n);r.z=Math.min(1,.5+Math.abs(.5-In(n))*.65),i.push(r)}return i}static SnapToGrid(s,e=8){return new b(Math.round(s.x/e)*e,Math.round(s.y/e)*e)}}const In=a=>a<.5?2*a*a:-1+(4-2*a)*a;class $ extends b{constructor(s=0,e=0,t=0,i={x:0,y:0},o=0,n=0){super(s,e,t),this.x=s,this.y=e,this.z=t,this.v=i,this.t=o,this.a=n}get timestamp(){return this.t}get pressure(){return this.z}get angleNum(){return this.a}get XY(){return[this.x,this.y]}setA(s){this.a=s}setT(s){this.t=s}setv(s){return this.v={x:s.x,y:s.y},this}set(s=this.x,e=this.y,t=this.z,i=this.v,o=this.t,n=this.a){return this.x=s,this.y=e,this.z=t,this.v=i,this.t=o,this.a=n,this}clone(){const{x:s,y:e,z:t,v:i,t:o,a:n}=this,r={x:i.x,y:i.y};return new $(s,e,t,r,o,n)}distance(s){return $.GetDistance(this,s)}isNear(s,e){return $.IsNear(this,s,e)}getAngleByPoints(s,e){return $.GetAngleByPoints(s,this,e)}static Sub(s,e){return new $(s.x-e.x,s.y-e.y)}static Add(s,e){return new $(s.x+e.x,s.y+e.y)}static GetDistance(s,e){return $.Len(s.clone().sub(e))}static GetAngleByPoints(s,e,t){const i=e.x-s.x,o=t.x-e.x,n=e.y-s.y,r=t.y-e.y;let c=0;const l=Math.sqrt(i*i+n*n),u=Math.sqrt(o*o+r*r);if(l&&u){const h=i*o+n*r;c=Math.acos(h/(l*u)),c=c/Math.PI*180;let d=i*r-n*o;d=d>0?1:-1,c=180+d*c}return c}static IsNear(s,e,t){return $.Len(s.clone().sub(e))<t}static RotWith(s,e,t,i=2){const o=s.x-e.x,n=s.y-e.y,r=Math.sin(t),c=Math.cos(t),l=Math.pow(10,i),u=Math.floor((e.x+(o*c-n*r))*l)/l,h=Math.floor((e.y+(o*r+n*c))*l)/l;return new $(u,h)}static GetDotStroke(s,e,t=16){const i=new b(1,1),o=Math.PI+.001,n=$.Add(s,$.Sub(s,i).uni().per().mul(-e)),r=[];for(let c=1/t,l=c;l<=1;l+=c)r.push($.RotWith(n,s,o*2*l));return r}static GetSemicircleStroke(s,e,t=-1,i=8){const o=t*(Math.PI+.001),n=[];for(let r=1/i,c=r;c<=1;c+=r)n.push($.RotWith(e,s,o*c));return n}}var Qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pt(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Tn=typeof Qt=="object"&&Qt&&Qt.Object===Object&&Qt,lo=Tn,Sn=lo,Nn=typeof self=="object"&&self&&self.Object===Object&&self,kn=Sn||Nn||Function("return this")(),Ge=kn,Cn=Ge,bn=Cn.Symbol,Vt=bn,pi=Vt,ho=Object.prototype,xn=ho.hasOwnProperty,Ln=ho.toString,Rt=pi?pi.toStringTag:void 0;function Pn(a){var s=xn.call(a,Rt),e=a[Rt];try{a[Rt]=void 0;var t=!0}catch{}var i=Ln.call(a);return t&&(s?a[Rt]=e:delete a[Rt]),i}var Dn=Pn,zn=Object.prototype,An=zn.toString;function jn(a){return An.call(a)}var En=jn,fi=Vt,On=Dn,Rn=En,Wn="[object Null]",Yn="[object Undefined]",gi=fi?fi.toStringTag:void 0;function Un(a){return a==null?a===void 0?Yn:Wn:gi&&gi in Object(a)?On(a):Rn(a)}var yt=Un;function Bn(a){return a!=null&&typeof a=="object"}var Ke=Bn,Fn=yt,Vn=Ke,$n="[object Number]";function Hn(a){return typeof a=="number"||Vn(a)&&Fn(a)==$n}var Qn=Hn;const be=Pt(Qn);function Gn(){this.__data__=[],this.size=0}var Zn=Gn;function qn(a,s){return a===s||a!==a&&s!==s}var $s=qn,Xn=$s;function Jn(a,s){for(var e=a.length;e--;)if(Xn(a[e][0],s))return e;return-1}var ds=Jn,Kn=ds,_n=Array.prototype,er=_n.splice;function tr(a){var s=this.__data__,e=Kn(s,a);if(e<0)return!1;var t=s.length-1;return e==t?s.pop():er.call(s,e,1),--this.size,!0}var sr=tr,ir=ds;function or(a){var s=this.__data__,e=ir(s,a);return e<0?void 0:s[e][1]}var nr=or,rr=ds;function ar(a){return rr(this.__data__,a)>-1}var cr=ar,lr=ds;function hr(a,s){var e=this.__data__,t=lr(e,a);return t<0?(++this.size,e.push([a,s])):e[t][1]=s,this}var ur=hr,dr=Zn,pr=sr,fr=nr,gr=cr,yr=ur;function Dt(a){var s=-1,e=a==null?0:a.length;for(this.clear();++s<e;){var t=a[s];this.set(t[0],t[1])}}Dt.prototype.clear=dr;Dt.prototype.delete=pr;Dt.prototype.get=fr;Dt.prototype.has=gr;Dt.prototype.set=yr;var ps=Dt,mr=ps;function Mr(){this.__data__=new mr,this.size=0}var wr=Mr;function vr(a){var s=this.__data__,e=s.delete(a);return this.size=s.size,e}var Ir=vr;function Tr(a){return this.__data__.get(a)}var Sr=Tr;function Nr(a){return this.__data__.has(a)}var kr=Nr;function Cr(a){var s=typeof a;return a!=null&&(s=="object"||s=="function")}var ct=Cr,br=yt,xr=ct,Lr="[object AsyncFunction]",Pr="[object Function]",Dr="[object GeneratorFunction]",zr="[object Proxy]";function Ar(a){if(!xr(a))return!1;var s=br(a);return s==Pr||s==Dr||s==Lr||s==zr}var uo=Ar,jr=Ge,Er=jr["__core-js_shared__"],Or=Er,Ns=Or,yi=function(){var a=/[^.]+$/.exec(Ns&&Ns.keys&&Ns.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}();function Rr(a){return!!yi&&yi in a}var Wr=Rr,Yr=Function.prototype,Ur=Yr.toString;function Br(a){if(a!=null){try{return Ur.call(a)}catch{}try{return a+""}catch{}}return""}var po=Br,Fr=uo,Vr=Wr,$r=ct,Hr=po,Qr=/[\\^$.*+?()[\]{}|]/g,Gr=/^\[object .+?Constructor\]$/,Zr=Function.prototype,qr=Object.prototype,Xr=Zr.toString,Jr=qr.hasOwnProperty,Kr=RegExp("^"+Xr.call(Jr).replace(Qr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _r(a){if(!$r(a)||Vr(a))return!1;var s=Fr(a)?Kr:Gr;return s.test(Hr(a))}var ea=_r;function ta(a,s){return a==null?void 0:a[s]}var sa=ta,ia=ea,oa=sa;function na(a,s){var e=oa(a,s);return ia(e)?e:void 0}var mt=na,ra=mt,aa=Ge,ca=ra(aa,"Map"),Hs=ca,la=mt,ha=la(Object,"create"),fs=ha,mi=fs;function ua(){this.__data__=mi?mi(null):{},this.size=0}var da=ua;function pa(a){var s=this.has(a)&&delete this.__data__[a];return this.size-=s?1:0,s}var fa=pa,ga=fs,ya="__lodash_hash_undefined__",ma=Object.prototype,Ma=ma.hasOwnProperty;function wa(a){var s=this.__data__;if(ga){var e=s[a];return e===ya?void 0:e}return Ma.call(s,a)?s[a]:void 0}var va=wa,Ia=fs,Ta=Object.prototype,Sa=Ta.hasOwnProperty;function Na(a){var s=this.__data__;return Ia?s[a]!==void 0:Sa.call(s,a)}var ka=Na,Ca=fs,ba="__lodash_hash_undefined__";function xa(a,s){var e=this.__data__;return this.size+=this.has(a)?0:1,e[a]=Ca&&s===void 0?ba:s,this}var La=xa,Pa=da,Da=fa,za=va,Aa=ka,ja=La;function zt(a){var s=-1,e=a==null?0:a.length;for(this.clear();++s<e;){var t=a[s];this.set(t[0],t[1])}}zt.prototype.clear=Pa;zt.prototype.delete=Da;zt.prototype.get=za;zt.prototype.has=Aa;zt.prototype.set=ja;var Ea=zt,Mi=Ea,Oa=ps,Ra=Hs;function Wa(){this.size=0,this.__data__={hash:new Mi,map:new(Ra||Oa),string:new Mi}}var Ya=Wa;function Ua(a){var s=typeof a;return s=="string"||s=="number"||s=="symbol"||s=="boolean"?a!=="__proto__":a===null}var Ba=Ua,Fa=Ba;function Va(a,s){var e=a.__data__;return Fa(s)?e[typeof s=="string"?"string":"hash"]:e.map}var gs=Va,$a=gs;function Ha(a){var s=$a(this,a).delete(a);return this.size-=s?1:0,s}var Qa=Ha,Ga=gs;function Za(a){return Ga(this,a).get(a)}var qa=Za,Xa=gs;function Ja(a){return Xa(this,a).has(a)}var Ka=Ja,_a=gs;function ec(a,s){var e=_a(this,a),t=e.size;return e.set(a,s),this.size+=e.size==t?0:1,this}var tc=ec,sc=Ya,ic=Qa,oc=qa,nc=Ka,rc=tc;function At(a){var s=-1,e=a==null?0:a.length;for(this.clear();++s<e;){var t=a[s];this.set(t[0],t[1])}}At.prototype.clear=sc;At.prototype.delete=ic;At.prototype.get=oc;At.prototype.has=nc;At.prototype.set=rc;var fo=At,ac=ps,cc=Hs,lc=fo,hc=200;function uc(a,s){var e=this.__data__;if(e instanceof ac){var t=e.__data__;if(!cc||t.length<hc-1)return t.push([a,s]),this.size=++e.size,this;e=this.__data__=new lc(t)}return e.set(a,s),this.size=e.size,this}var dc=uc,pc=ps,fc=wr,gc=Ir,yc=Sr,mc=kr,Mc=dc;function jt(a){var s=this.__data__=new pc(a);this.size=s.size}jt.prototype.clear=fc;jt.prototype.delete=gc;jt.prototype.get=yc;jt.prototype.has=mc;jt.prototype.set=Mc;var go=jt;function wc(a,s){for(var e=-1,t=a==null?0:a.length;++e<t&&s(a[e],e,a)!==!1;);return a}var vc=wc,Ic=mt,Tc=function(){try{var a=Ic(Object,"defineProperty");return a({},"",{}),a}catch{}}(),yo=Tc,wi=yo;function Sc(a,s,e){s=="__proto__"&&wi?wi(a,s,{configurable:!0,enumerable:!0,value:e,writable:!0}):a[s]=e}var mo=Sc,Nc=mo,kc=$s,Cc=Object.prototype,bc=Cc.hasOwnProperty;function xc(a,s,e){var t=a[s];(!(bc.call(a,s)&&kc(t,e))||e===void 0&&!(s in a))&&Nc(a,s,e)}var Mo=xc,Lc=Mo,Pc=mo;function Dc(a,s,e,t){var i=!e;e||(e={});for(var o=-1,n=s.length;++o<n;){var r=s[o],c=t?t(e[r],a[r],r,e,a):void 0;c===void 0&&(c=a[r]),i?Pc(e,r,c):Lc(e,r,c)}return e}var ys=Dc;function zc(a,s){for(var e=-1,t=Array(a);++e<a;)t[e]=s(e);return t}var Ac=zc,jc=yt,Ec=Ke,Oc="[object Arguments]";function Rc(a){return Ec(a)&&jc(a)==Oc}var Wc=Rc,vi=Wc,Yc=Ke,wo=Object.prototype,Uc=wo.hasOwnProperty,Bc=wo.propertyIsEnumerable,Fc=vi(function(){return arguments}())?vi:function(a){return Yc(a)&&Uc.call(a,"callee")&&!Bc.call(a,"callee")},vo=Fc,Vc=Array.isArray,$t=Vc,Kt={exports:{}};function $c(){return!1}var Hc=$c;Kt.exports;(function(a,s){var e=Ge,t=Hc,i=s&&!s.nodeType&&s,o=i&&!0&&a&&!a.nodeType&&a,n=o&&o.exports===i,r=n?e.Buffer:void 0,c=r?r.isBuffer:void 0,l=c||t;a.exports=l})(Kt,Kt.exports);var Qs=Kt.exports,Qc=9007199254740991,Gc=/^(?:0|[1-9]\d*)$/;function Zc(a,s){var e=typeof a;return s=s??Qc,!!s&&(e=="number"||e!="symbol"&&Gc.test(a))&&a>-1&&a%1==0&&a<s}var qc=Zc,Xc=9007199254740991;function Jc(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=Xc}var Io=Jc,Kc=yt,_c=Io,el=Ke,tl="[object Arguments]",sl="[object Array]",il="[object Boolean]",ol="[object Date]",nl="[object Error]",rl="[object Function]",al="[object Map]",cl="[object Number]",ll="[object Object]",hl="[object RegExp]",ul="[object Set]",dl="[object String]",pl="[object WeakMap]",fl="[object ArrayBuffer]",gl="[object DataView]",yl="[object Float32Array]",ml="[object Float64Array]",Ml="[object Int8Array]",wl="[object Int16Array]",vl="[object Int32Array]",Il="[object Uint8Array]",Tl="[object Uint8ClampedArray]",Sl="[object Uint16Array]",Nl="[object Uint32Array]",Me={};Me[yl]=Me[ml]=Me[Ml]=Me[wl]=Me[vl]=Me[Il]=Me[Tl]=Me[Sl]=Me[Nl]=!0;Me[tl]=Me[sl]=Me[fl]=Me[il]=Me[gl]=Me[ol]=Me[nl]=Me[rl]=Me[al]=Me[cl]=Me[ll]=Me[hl]=Me[ul]=Me[dl]=Me[pl]=!1;function kl(a){return el(a)&&_c(a.length)&&!!Me[Kc(a)]}var Cl=kl;function bl(a){return function(s){return a(s)}}var ms=bl,_t={exports:{}};_t.exports;(function(a,s){var e=lo,t=s&&!s.nodeType&&s,i=t&&!0&&a&&!a.nodeType&&a,o=i&&i.exports===t,n=o&&e.process,r=function(){try{var c=i&&i.require&&i.require("util").types;return c||n&&n.binding&&n.binding("util")}catch{}}();a.exports=r})(_t,_t.exports);var Gs=_t.exports,xl=Cl,Ll=ms,Ii=Gs,Ti=Ii&&Ii.isTypedArray,Pl=Ti?Ll(Ti):xl,To=Pl,Dl=Ac,zl=vo,Al=$t,jl=Qs,El=qc,Ol=To,Rl=Object.prototype,Wl=Rl.hasOwnProperty;function Yl(a,s){var e=Al(a),t=!e&&zl(a),i=!e&&!t&&jl(a),o=!e&&!t&&!i&&Ol(a),n=e||t||i||o,r=n?Dl(a.length,String):[],c=r.length;for(var l in a)(s||Wl.call(a,l))&&!(n&&(l=="length"||i&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||El(l,c)))&&r.push(l);return r}var So=Yl,Ul=Object.prototype;function Bl(a){var s=a&&a.constructor,e=typeof s=="function"&&s.prototype||Ul;return a===e}var Zs=Bl;function Fl(a,s){return function(e){return a(s(e))}}var No=Fl,Vl=No,$l=Vl(Object.keys,Object),Hl=$l,Ql=Zs,Gl=Hl,Zl=Object.prototype,ql=Zl.hasOwnProperty;function Xl(a){if(!Ql(a))return Gl(a);var s=[];for(var e in Object(a))ql.call(a,e)&&e!="constructor"&&s.push(e);return s}var Jl=Xl,Kl=uo,_l=Io;function eh(a){return a!=null&&_l(a.length)&&!Kl(a)}var qs=eh,th=So,sh=Jl,ih=qs;function oh(a){return ih(a)?th(a):sh(a)}var Xs=oh,nh=ys,rh=Xs;function ah(a,s){return a&&nh(s,rh(s),a)}var ch=ah;function lh(a){var s=[];if(a!=null)for(var e in Object(a))s.push(e);return s}var hh=lh,uh=ct,dh=Zs,ph=hh,fh=Object.prototype,gh=fh.hasOwnProperty;function yh(a){if(!uh(a))return ph(a);var s=dh(a),e=[];for(var t in a)t=="constructor"&&(s||!gh.call(a,t))||e.push(t);return e}var mh=yh,Mh=So,wh=mh,vh=qs;function Ih(a){return vh(a)?Mh(a,!0):wh(a)}var Js=Ih,Th=ys,Sh=Js;function Nh(a,s){return a&&Th(s,Sh(s),a)}var kh=Nh,es={exports:{}};es.exports;(function(a,s){var e=Ge,t=s&&!s.nodeType&&s,i=t&&!0&&a&&!a.nodeType&&a,o=i&&i.exports===t,n=o?e.Buffer:void 0,r=n?n.allocUnsafe:void 0;function c(l,u){if(u)return l.slice();var h=l.length,d=r?r(h):new l.constructor(h);return l.copy(d),d}a.exports=c})(es,es.exports);var Ch=es.exports;function bh(a,s){var e=-1,t=a.length;for(s||(s=Array(t));++e<t;)s[e]=a[e];return s}var xh=bh;function Lh(a,s){for(var e=-1,t=a==null?0:a.length,i=0,o=[];++e<t;){var n=a[e];s(n,e,a)&&(o[i++]=n)}return o}var ko=Lh;function Ph(){return[]}var Co=Ph,Dh=ko,zh=Co,Ah=Object.prototype,jh=Ah.propertyIsEnumerable,Si=Object.getOwnPropertySymbols,Eh=Si?function(a){return a==null?[]:(a=Object(a),Dh(Si(a),function(s){return jh.call(a,s)}))}:zh,Ks=Eh,Oh=ys,Rh=Ks;function Wh(a,s){return Oh(a,Rh(a),s)}var Yh=Wh;function Uh(a,s){for(var e=-1,t=s.length,i=a.length;++e<t;)a[i+e]=s[e];return a}var _s=Uh,Bh=No,Fh=Bh(Object.getPrototypeOf,Object),bo=Fh,Vh=_s,$h=bo,Hh=Ks,Qh=Co,Gh=Object.getOwnPropertySymbols,Zh=Gh?function(a){for(var s=[];a;)Vh(s,Hh(a)),a=$h(a);return s}:Qh,xo=Zh,qh=ys,Xh=xo;function Jh(a,s){return qh(a,Xh(a),s)}var Kh=Jh,_h=_s,eu=$t;function tu(a,s,e){var t=s(a);return eu(a)?t:_h(t,e(a))}var Lo=tu,su=Lo,iu=Ks,ou=Xs;function nu(a){return su(a,ou,iu)}var Po=nu,ru=Lo,au=xo,cu=Js;function lu(a){return ru(a,cu,au)}var hu=lu,uu=mt,du=Ge,pu=uu(du,"DataView"),fu=pu,gu=mt,yu=Ge,mu=gu(yu,"Promise"),Mu=mu,wu=mt,vu=Ge,Iu=wu(vu,"Set"),Do=Iu,Tu=mt,Su=Ge,Nu=Tu(Su,"WeakMap"),ku=Nu,Ds=fu,zs=Hs,As=Mu,js=Do,Es=ku,zo=yt,Et=po,Ni="[object Map]",Cu="[object Object]",ki="[object Promise]",Ci="[object Set]",bi="[object WeakMap]",xi="[object DataView]",bu=Et(Ds),xu=Et(zs),Lu=Et(As),Pu=Et(js),Du=Et(Es),ht=zo;(Ds&&ht(new Ds(new ArrayBuffer(1)))!=xi||zs&&ht(new zs)!=Ni||As&&ht(As.resolve())!=ki||js&&ht(new js)!=Ci||Es&&ht(new Es)!=bi)&&(ht=function(a){var s=zo(a),e=s==Cu?a.constructor:void 0,t=e?Et(e):"";if(t)switch(t){case bu:return xi;case xu:return Ni;case Lu:return ki;case Pu:return Ci;case Du:return bi}return s});var Ms=ht,zu=Object.prototype,Au=zu.hasOwnProperty;function ju(a){var s=a.length,e=new a.constructor(s);return s&&typeof a[0]=="string"&&Au.call(a,"index")&&(e.index=a.index,e.input=a.input),e}var Eu=ju,Ou=Ge,Ru=Ou.Uint8Array,Ao=Ru,Li=Ao;function Wu(a){var s=new a.constructor(a.byteLength);return new Li(s).set(new Li(a)),s}var ei=Wu,Yu=ei;function Uu(a,s){var e=s?Yu(a.buffer):a.buffer;return new a.constructor(e,a.byteOffset,a.byteLength)}var Bu=Uu,Fu=/\w*$/;function Vu(a){var s=new a.constructor(a.source,Fu.exec(a));return s.lastIndex=a.lastIndex,s}var $u=Vu,Pi=Vt,Di=Pi?Pi.prototype:void 0,zi=Di?Di.valueOf:void 0;function Hu(a){return zi?Object(zi.call(a)):{}}var Qu=Hu,Gu=ei;function Zu(a,s){var e=s?Gu(a.buffer):a.buffer;return new a.constructor(e,a.byteOffset,a.length)}var qu=Zu,Xu=ei,Ju=Bu,Ku=$u,_u=Qu,ed=qu,td="[object Boolean]",sd="[object Date]",id="[object Map]",od="[object Number]",nd="[object RegExp]",rd="[object Set]",ad="[object String]",cd="[object Symbol]",ld="[object ArrayBuffer]",hd="[object DataView]",ud="[object Float32Array]",dd="[object Float64Array]",pd="[object Int8Array]",fd="[object Int16Array]",gd="[object Int32Array]",yd="[object Uint8Array]",md="[object Uint8ClampedArray]",Md="[object Uint16Array]",wd="[object Uint32Array]";function vd(a,s,e){var t=a.constructor;switch(s){case ld:return Xu(a);case td:case sd:return new t(+a);case hd:return Ju(a,e);case ud:case dd:case pd:case fd:case gd:case yd:case md:case Md:case wd:return ed(a,e);case id:return new t;case od:case ad:return new t(a);case nd:return Ku(a);case rd:return new t;case cd:return _u(a)}}var Id=vd,Td=ct,Ai=Object.create,Sd=function(){function a(){}return function(s){if(!Td(s))return{};if(Ai)return Ai(s);a.prototype=s;var e=new a;return a.prototype=void 0,e}}(),Nd=Sd,kd=Nd,Cd=bo,bd=Zs;function xd(a){return typeof a.constructor=="function"&&!bd(a)?kd(Cd(a)):{}}var Ld=xd,Pd=Ms,Dd=Ke,zd="[object Map]";function Ad(a){return Dd(a)&&Pd(a)==zd}var jd=Ad,Ed=jd,Od=ms,ji=Gs,Ei=ji&&ji.isMap,Rd=Ei?Od(Ei):Ed,Wd=Rd,Yd=Ms,Ud=Ke,Bd="[object Set]";function Fd(a){return Ud(a)&&Yd(a)==Bd}var Vd=Fd,$d=Vd,Hd=ms,Oi=Gs,Ri=Oi&&Oi.isSet,Qd=Ri?Hd(Ri):$d,jo=Qd;const Gd=Pt(jo);var Zd=go,qd=vc,Xd=Mo,Jd=ch,Kd=kh,_d=Ch,ep=xh,tp=Yh,sp=Kh,ip=Po,op=hu,np=Ms,rp=Eu,ap=Id,cp=Ld,lp=$t,hp=Qs,up=Wd,dp=ct,pp=jo,fp=Xs,gp=Js,yp=1,mp=2,Mp=4,Eo="[object Arguments]",wp="[object Array]",vp="[object Boolean]",Ip="[object Date]",Tp="[object Error]",Oo="[object Function]",Sp="[object GeneratorFunction]",Np="[object Map]",kp="[object Number]",Ro="[object Object]",Cp="[object RegExp]",bp="[object Set]",xp="[object String]",Lp="[object Symbol]",Pp="[object WeakMap]",Dp="[object ArrayBuffer]",zp="[object DataView]",Ap="[object Float32Array]",jp="[object Float64Array]",Ep="[object Int8Array]",Op="[object Int16Array]",Rp="[object Int32Array]",Wp="[object Uint8Array]",Yp="[object Uint8ClampedArray]",Up="[object Uint16Array]",Bp="[object Uint32Array]",ye={};ye[Eo]=ye[wp]=ye[Dp]=ye[zp]=ye[vp]=ye[Ip]=ye[Ap]=ye[jp]=ye[Ep]=ye[Op]=ye[Rp]=ye[Np]=ye[kp]=ye[Ro]=ye[Cp]=ye[bp]=ye[xp]=ye[Lp]=ye[Wp]=ye[Yp]=ye[Up]=ye[Bp]=!0;ye[Tp]=ye[Oo]=ye[Pp]=!1;function Xt(a,s,e,t,i,o){var n,r=s&yp,c=s&mp,l=s&Mp;if(e&&(n=i?e(a,t,i,o):e(a)),n!==void 0)return n;if(!dp(a))return a;var u=lp(a);if(u){if(n=rp(a),!r)return ep(a,n)}else{var h=np(a),d=h==Oo||h==Sp;if(hp(a))return _d(a,r);if(h==Ro||h==Eo||d&&!i){if(n=c||d?{}:cp(a),!r)return c?sp(a,Kd(n,a)):tp(a,Jd(n,a))}else{if(!ye[h])return i?a:{};n=ap(a,h,r)}}o||(o=new Zd);var p=o.get(a);if(p)return p;o.set(a,n),pp(a)?a.forEach(function(M){n.add(Xt(M,s,e,M,a,o))}):up(a)&&a.forEach(function(M,S){n.set(S,Xt(M,s,e,S,a,o))});var f=l?c?op:ip:c?gp:fp,g=u?void 0:f(a);return qd(g||a,function(M,S){g&&(S=M,M=a[S]),Xd(n,S,Xt(M,s,e,S,a,o))}),n}var Fp=Xt,Vp=Fp,$p=1,Hp=4;function Qp(a){return Vp(a,$p|Hp)}var Gp=Qp;const Ce=Pt(Gp),Wo="1.1.17-beta.9",Zp="@netless/appliance-plugin",ti=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let a=window.__netlessUA||"";a+=` ${Zp}@${Wo}`,window.__netlessUA=a}const we={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:600},bezier:{maxDrawCount:1/0,combineUnitTime:500},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920},strokeWidth:{min:1,max:10}};function Xe(a,s=!0){const e=a.length;if(e<2)return"";let t=a[0],i=a[1];if(e===2)return`M${Mt(t)}L${Mt(i)}`;let o="";for(let n=2,r=e-1;n<r;n++)t=a[n],i=a[n+1],o+=wt(t,i);return s?`M${wt(a[0],a[1])}Q${Mt(a[1])}${wt(a[1],a[2])}T${o}${wt(a[e-1],a[0])}${wt(a[0],a[1])}Z`:`M${Mt(a[0])}Q${Mt(a[1])}${wt(a[1],a[2])}${a.length>3?"T":""}${o}L${Mt(a[e-1])}`}const Ye=class Ye{constructor(s){y(this,"maxImageWidth",we.pencilEraser.maxImageWidth);y(this,"maxImageHeight",we.pencilEraser.maxImageHeight);y(this,"syncUnitTime",we.syncOpt.interval);y(this,"vNodes");y(this,"drawLayer");y(this,"fullLayer");y(this,"workId");y(this,"isDelete",!1);const{vNodes:e,fullLayer:t,drawLayer:i,workId:o,toolsOpt:n}=s;this.vNodes=e,this.fullLayer=t,this.drawLayer=i,this.workId=o,this.syncUnitTime=n.syncUnitTime||this.syncUnitTime}get baseConsumeResult(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions}}filterSamePoints(s,e=.01){return s.reduce((t,i)=>{const o=t[t.length-1];return(i&&!o||i&&o&&!i.isNear(o,e))&&t.push(i),t},[])}setWorkId(s){this.workId=s}getWorkId(){return this.workId}getWorkOptions(){return this.workOptions}setWorkOptions(s){var i,o,n;this.workOptions=s,this.syncUnitTime=s.syncUnitTime||this.syncUnitTime;const e=(i=this.workId)==null?void 0:i.toString(),t=e&&((o=this.vNodes)==null?void 0:o.get(e))||void 0;e&&t&&(t.opt=s,(n=this.vNodes)==null||n.setInfo(e,t))}updataOptService(s){var i,o;let e;const t=(i=this.workId)==null?void 0:i.toString();if(t&&s){const n=this.fullLayer.getElementsByName(t)||this.drawLayer&&this.drawLayer.getElementsByName(t)||[];if(n.length!==1)return;const r=n[0],{pos:c,zIndex:l,scale:u,angle:h,translate:d}=s,p={};be(l)&&(p.zIndex=l),c&&(p.pos=[c[0],c[1]]),u&&(p.scale=u),h&&(p.rotate=h),d&&(p.translate=d),r.attr(p);const f=r==null?void 0:r.getBoundingClientRect();return f&&(e=le(e,{x:Math.floor(f.x-Ye.SafeBorderPadding),y:Math.floor(f.y-Ye.SafeBorderPadding),w:Math.floor(f.width+Ye.SafeBorderPadding*2),h:Math.floor(f.height+Ye.SafeBorderPadding*2)})),(o=this.vNodes)==null||o.setInfo(t,{rect:e,centerPos:c}),e}}drawEraserlines(s,e){const{group:t,eraserlines:i,pos:o,layer:n}=s,r=n.parent;if(!e)return;const l=(n.renderer.glRenderer||n.renderer.canvasRenderer).options.displayRatio,u=t.getBoundingClientRect(),h=u.width*l*n.worldScaling[0],d=u.height*l*n.worldScaling[1];let p=1;(h>this.maxImageWidth||d>this.maxImageHeight)&&(p=Math.min(this.maxImageWidth/h,this.maxImageHeight/d));let f=n.getAttribute("scale");f=[f[0]*p,f[1]*p];const g=n.parent.parent,M=n.getAttribute("translate"),S=this.createVmRenderNode(`${this.workId}_bitMapLayer`,g,{offscreen:r.offscreen,width:r.width,height:r.height,contextType:"2d",autoRender:!1,bufferSize:500},f,M),w=t.cloneNode(!0);this.addEraserlines(w,i,o,!1),S.appendChild(w);const I=S.parent;I.render();const k=S.renderer.canvasRenderer,T=k.context;if(!T)return;const v=k.options.displayRatio,P=w.getBoundingClientRect(),C={x:P.x,y:P.y,w:P.width,h:P.height},L={x:0,y:0,w:g.width,h:g.height};if(hi(C,L)===ft.outside){Re(w,I),g.removeChild(I),this.isDelete=!0;return}const R=Ce(C);R.x=Math.floor(Math.max(C.x,0)),R.y=Math.floor(Math.max(C.y,0)),R.w=Math.min(C.x+C.w,g.width)-R.x,R.h=Math.min(C.y+C.h,g.height)-R.y;const E=this.getGroupRect(R,v),j=E.x,D=E.y,q=E.w,oe=E.h;let X=T.getImageData(j,D,q,oe);if(this.isTransparentRectByCanvas(X)){Re(w,I),g.removeChild(I),this.isDelete=!0,X=null;return}Re(t,r);const _=this.createSpriteNode({imageData:X,safariRect:R,originRect:C,worldScaling:S.worldScaling});_&&t.append(_),Re(w,I),g.removeChild(I),r.deleteTexture(X),X=null}createVmRenderNode(s,e,t,i,o){const{width:n,height:r}=t,c=`bitMap-${s}`,l=e.layer(c,t),u=new ce.Group({anchor:[.5,.5],pos:[n*.5,r*.5],size:[n,r],name:"viewport",id:s});return u.setAttribute("scale",i),u.setAttribute("translate",o),l.append(u),u}getGroupRect(s,e){const t=Math.floor(s.x*e),i=Math.floor(s.y*e),o=Math.floor(s.w*e),n=Math.floor(s.h*e);return{x:t,y:i,w:o,h:n}}addEraserlines(s,e,t,i=!0){for(const o of e){const{thickness:n,op:r}=o;for(const c of r){const l=c.map((f,g)=>g%2?f-t[1]:f-t[0]),u=this.computEraserPoints(l,n),h=Xe(u,!0),d={pos:[0,0],d:h,fillColor:"rgba(0,0,0,1)"},p=new ce.Path(d);p.addEventListener("beforerender",({detail:f})=>{const g=f.context;i?g.blendFuncSeparate(g.ZERO,g.ZERO,g.ZERO,g.ZERO):g.globalCompositeOperation="destination-out"}),p.addEventListener("afterrender",({detail:f})=>{const g=f.context;i?g.blendFuncSeparate(g.SRC_ALPHA,g.ONE_MINUS_SRC_ALPHA,g.ONE,g.ONE_MINUS_SRC_ALPHA):g.globalCompositeOperation="source-over"}),s.append(p)}}}isTransparentRectByCanvas(s){let e=!0;for(let t=0;t<s.data.length;t+=4)if(s.data[t+3]!==0){e=!1;break}return e}createSpriteNode(s){const{imageData:e,worldScaling:t,safariRect:i,originRect:o}=s;let n;if(typeof OffscreenCanvas=="function"){n=new OffscreenCanvas(e.width,e.height);const u=n.getContext("2d");u&&u.putImageData(e,0,0)}else if(typeof document<"u"){n=document.createElement("canvas"),n.width=e.width,n.height=e.height;const u=n.getContext("2d");u&&u.putImageData(e,0,0)}if(!n)return console.warn("Failed to create imageEraserBitmap Sprite"),null;const r=[Math.floor(o.w/t[0]),Math.floor(o.h/t[1])],c=[Math.floor((i.x-o.x)/t[0]),Math.floor((i.y-o.y)/t[1]),Math.floor(i.w/t[0]),Math.floor(i.h/t[1])],l={name:"eraserTexture",anchor:[.5,.5],pos:[0,0],size:r,texture:n,textureRect:c};return new ce.Sprite(l)}computEraserPoints(s,e){const t=Math.ceil(e/2);return s.length===2?this.computDot(s,t):this.computLine(s,t)}computDot(s,e){const t=new $(s[0],s[1]);return $.GetDotStroke(t,e,8)}computLine(s,e){const t=[],i=[];let o,n;for(let r=0;r<s.length;r+=2){const c=new $(s[r],s[r+1]);let l;if(r==s.length-2){const u=new $(s[r-2],s[r-1]);l=b.Sub(c,u).uni(),o=c}else{r===0&&(n=c);const u=new $(s[r+2],s[r+3]);l=b.Sub(u,c).uni()}if(l){const u=b.Per(l).mul(e);t.push($.Sub(c,u)),i.push($.Add(c,u))}}if(o&&n){const r=$.GetSemicircleStroke(o,t[t.length-1],-1,8),c=$.GetSemicircleStroke(n,i[0],-1,8);return t.concat(r,i.reverse(),c)}return[]}replace(s,e,t){var n;if(!e){t&&s.append(t);return}const i=s.getElementsByName(e);if(i.length)for(const r of i)t?sm(t,r,s):(r.remove(),Oe(r,s.parent));else t&&s.append(t);this.fullLayer===s?(n=this.drawLayer)==null||n.getElementsByName(e).forEach(r=>{var c;r.remove(),Oe(r,(c=this.drawLayer)==null?void 0:c.parent)}):this.fullLayer.getElementsByName(e).forEach(r=>{r.remove(),Oe(r,this.fullLayer.parent)})}removeDrawCountNodes(s,e){const t=[];s.getElementsByName(this.workId).forEach(i=>{i.id&&e&&Number(i.id)<e&&t.push(i)});for(const i of t)i.remove(),Oe(i,s.parent)}static updateNodeOpt(s){var w;const{node:e,opt:t,vNodes:i,willSerializeData:o,targetNode:n}=s,{zIndex:r,translate:c,angle:l,originPoint:u,scenePoint:h,scale:d,pointMap:p,thickness:f}=t;let g;const M=n&&Ce(n)||i.get(e.name);if(!M)return;be(r)&&(e.setAttribute("zIndex",r),M.opt.zIndex=r);const S=e.parent;if(S){if(u&&d&&n){const I=[M.op[0],M.op[1]];ci(M.op,h,d,c);const k=[M.op[0],M.op[1]],T=[k[0]-I[0],k[1]-I[1]];if(M.centerPos=[M.centerPos[0]+T[0],M.centerPos[1]+T[1]],M.opt.translate=void 0,M.opt.scale=void 0,M.opt.eraserlines)for(const v of Object.values(M.opt.eraserlines)){const{op:P,thickness:C}=v;v.thickness=C*Math.max(d[0],d[1]);for(let L=0;L<P.length;L++)li(P[L],h,d,c)}}else if(c)if(e.setAttribute("translate",c),M.opt.translate=c,n){const I=[c[0]*S.worldScaling[0],c[1]*S.worldScaling[1]];g=Ft(M.rect,I),M.rect=g}else{const I=Ye.getRectFromLayer(S,e.name);M.rect=I||M.rect}else if(be(l))if(e.setAttribute("rotate",l),M.opt.rotate=l,n)g=nn(M.rect,l),M.rect=g;else{const I=Ye.getRectFromLayer(S,e.name);M.rect=I||M.rect}if(p){const I=p.get(e.name);if(I)for(let k=0,T=0;k<M.op.length;k+=3,T++)M.op[k]=I[T][0],M.op[k+1]=I[T][1]}if(f&&((w=M==null?void 0:M.opt)!=null&&w.thickness)&&(M.opt.thickness=f),o&&!(u&&d&&n)){if(c){const I=M.op.map((k,T)=>{const v=T%3;return v===0?k+c[0]:v===1?k+c[1]:k});if(M.op=I,M.centerPos=[M.centerPos[0]+c[0],M.centerPos[1]+c[1]],M!=null&&M.opt&&(M.opt.translate=void 0),M.opt.eraserlines)for(const k of Object.values(M.opt.eraserlines)){const{op:T}=k;for(let v=0;v<T.length;v++){const P=T[v].map((C,L)=>L%2?C+c[1]:C+c[0]);k.op[v]=P}}}else if(be(l)){const I=M.op;if(qy(I,M.centerPos,l),M.op=I,M!=null&&M.opt&&(M.opt.rotate=void 0),M.opt.eraserlines)for(const k of Object.values(M.opt.eraserlines)){const{op:T}=k;for(let v=0;v<T.length;v++)Xy(T[v],M.centerPos,l)}}}M&&i.setInfo(e.name,M)}}static getCenterPos(s,e){const{worldPosition:t,worldScaling:i}=e;return[(s.x+s.w/2-t[0])/i[0],(s.y+s.h/2-t[1])/i[1]]}static getRectFromLayer(s,e){const t=s.getElementsByName(e)[0];if(t){const i=t.getBoundingClientRect();return{x:Math.floor(i.x-Ye.SafeBorderPadding),y:Math.floor(i.y-Ye.SafeBorderPadding),w:Math.floor(i.width+Ye.SafeBorderPadding*2),h:Math.floor(i.height+Ye.SafeBorderPadding*2)}}}static isWillRefresh(s){const{toolsType:e,opt:t,node:i,updateOpt:o,willSerializeData:n}=s;return!!(n&&(o.angle||o.translate)||o.thickness&&t.thickness&&t.thickness!==o.thickness||o.strokeType&&t.strokeType&&t.strokeType!==o.strokeType||o.originPoint&&o.scenePoint&&o.scale||o.pointMap&&o.pointMap.has(i.name)||e===N.Text&&(o.fontSize||o.translate||o.textInfos&&o.textInfos.get(i.name))||e===N.Image&&(o.angle||o.translate||o.scale||o.strokeColor&&o.type===gt.Iconify)||e===o.toolsType&&o.willRefresh||t.eraserlines&&t.eraserlines.length&&(o.strokeColor||o.fillColor))}};y(Ye,"SafeBorderPadding",10);let B=Ye;const si=Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50}),Object.freeze({width:48,height:74})]);function lt(a){return JSON.parse(ro.decompress(a))}function We(a){return ro.compress(JSON.stringify(a))}const Le=Object.keys;function Yo(a,s,e=.01){return Math.abs(a[0]-s[0])<e&&Math.abs(a[1]-s[1])<e}function qp(a,s=.01){if(a.length===0)return[];const e=[[a[0][0],a[0][1]]];for(let t=1;t<a.length;t++)Yo([a[t][0],a[t][1]],e[e.length-1],s)||e.push([a[t][0],a[t][1]]);return e}function Xp(a,s=.01){if(a.length<=2)return a;const e=a[0],t=a[a.length-1];return Yo(e,t,s)?a.slice(0,-1):a}function Jp(a){const s=a.reduce((t,i)=>t+i[0],0)/a.length,e=a.reduce((t,i)=>t+i[1],0)/a.length;return[s,e]}function Wi(a,s){return Math.atan2(s[1]-a[1],s[0]-a[0])}function Kp(a,s=.01){if(a.length<=2)return a;const e=[];for(const i of a)e.some(n=>Math.abs(n[0]-i[0])<s&&Math.abs(n[1]-i[1])<s)||e.push([i[0],i[1]]);const t=Jp(e);return e.sort((i,o)=>{const n=Wi(t,i),r=Wi(t,o);return n-r})}function _p(a,s){const e=s[0].x<s[s.length-1].x;return a.map(i=>{const n=i.map(r=>{let c=-1,l=1/0,u=0;for(let h=0;h<s.length;h++){const d=s[h],p=Math.sqrt(Math.pow(d.x-r[0],2)+Math.pow(d.y-r[1],2));p<l&&(l=p,c=h,u=d.z)}return{point:r,index:c,bestZ:u}}).sort((r,c)=>r.index-c.index).map(r=>[...r.point,r.bestZ]);return e&&n[0][0]>n[n.length-1][0]||!e&&n[0][0]<n[n.length-1][0]?n.reverse():n}).sort((i,o)=>{const n=i[0][0],r=o[0][0];return e?n-r:r-n})}function ef(a,s,e=.01){const i=a.map(h=>[h.x,h.y]),o=(h,d)=>h.map(([p,f])=>({X:Math.round(p*d),Y:Math.round(f*d)})),n=new Ze.ClipperOffset;n.AddPath(o(i,1e3),Ze.JoinType.jtRound,Ze.EndType.etOpenButt);const r=[];n.Execute(r,1);const c=new Ze.Clipper;c.AddPaths(r,Ze.PolyType.ptSubject,!0),s.forEach(h=>{c.AddPath(o(h,1e3),Ze.PolyType.ptClip,!0)});const l=new Ze.Paths;c.Execute(Ze.ClipType.ctDifference,l,Ze.PolyFillType.pftNonZero,Ze.PolyFillType.pftNonZero);const u=l.map(h=>Xp(Kp(qp(h.map(d=>[d.X/1e3,d.Y/1e3]),e),e),e)).filter(h=>h.length>=2);return _p(u,a)}class Uo extends B{constructor(e){super(e);y(this,"canRotate",!0);y(this,"scaleType",re.all);y(this,"toolsType",N.Pencil);y(this,"syncTimestamp");y(this,"syncIndex",0);y(this,"tmpPoints",[]);y(this,"MAX_REPEAR",10);y(this,"uniThickness");y(this,"workOptions");y(this,"centerPos",[0,0]);this.workOptions=e.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}combineConsume(){var r;const e=(r=this.workId)==null?void 0:r.toString();if(this.tmpPoints.length<2)return{type:x.None};const t=this.transformDataAll(!0),i={name:e};let o;const n=this.drawLayer||this.fullLayer;return t.length&&(o=this.draw({attrs:i,tasks:t,replaceId:e,layer:n})),{rect:o,type:x.DrawWork,dataType:F.Local}}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n,drawCount:r,removeDrawCount:c}=e,{workId:l,syncUnitTime:u}=t;u&&(this.syncUnitTime=u);const{tasks:h,effects:d,consumeIndex:p}=this.transformData(t,!1);this.syncIndex=Math.min(this.syncIndex,p,Math.max(0,this.tmpPoints.length-2));const f={name:l,id:be(r)&&r.toString()||void 0};let g,M=!1;const S=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),h.length&&(h[0].taskId-this.syncTimestamp>this.syncUnitTime&&(M=!0,this.syncTimestamp=h[0].taskId,this.syncIndex=this.tmpPoints.length),o||n)){const I=i?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({attrs:f,tasks:h,effects:d,layer:I,removeDrawCount:c})}if(o)return p>10&&this.tmpPoints.splice(0,p-10),{rect:g,type:x.DrawWork,dataType:F.Local};const w=[];return this.tmpPoints.slice(S).forEach(I=>{w.push(I.x,I.y,this.computRadius(I.z,this.workOptions.thickness))}),{...this.baseConsumeResult,type:x.DrawWork,dataType:F.Local,rect:g,op:M?w:void 0,index:M?S*3:void 0,updateNodeOpt:{useAnimation:!0}}}consumeAll(e){var u;const t=this.workId;if(e.data){const{op:h,workState:d}=e.data;h!=null&&h.length&&d===z.Done&&this.workOptions.strokeType===te.Stroke&&this.updateTempPointsWithPressureWhenDone(h)}const i=this.transformDataAll(!0),o={name:t};let n;const r=this.fullLayer;if(i.length&&(n=this.draw({attrs:o,tasks:i,replaceId:t,layer:r})),this.tmpPoints.length<2)return this.replace(r,t),{type:x.RemoveNode,removeIds:[t],rect:n};const c=[];this.tmpPoints.map(h=>{c.push(h.x,h.y,h.z)}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const l=We(c);return(u=this.vNodes)==null||u.setInfo(t,{rect:n,op:c,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&B.getCenterPos(n,r)}),{...this.baseConsumeResult,rect:n,type:x.FullWork,dataType:F.Local,ops:l,updateNodeOpt:{pos:this.centerPos,useAnimation:!0}}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(e){var h,d;const{op:t,isFullWork:i,replaceId:o,workState:n=z.Done}=e;this.tmpPoints.length=0;for(let p=0;p<t.length;p+=3){const f=new $(t[p],t[p+1],t[p+2]);if(this.tmpPoints.length>0){const g=this.tmpPoints[this.tmpPoints.length-1],M=b.Sub(f,g).uni();f.setv(M)}this.tmpPoints.push(f)}if(this.tmpPoints.length<2)return;const r=this.transformDataAll(!0),c=(h=this.workId)==null?void 0:h.toString(),l={name:c};let u;if(c&&r.length){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({attrs:l,tasks:r,replaceId:o,layer:p,isDrawEraserlines:n===z.Done}),(d=this.vNodes)==null||d.setInfo(c,{rect:u,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:u&&B.getCenterPos(u,p)})}return u}computPencilPoints(e){const t=[],{op:i,eraserPolylines:o,eraserThickness:n}=e;this.tmpPoints.length=0;for(let c=0;c<i.length;c+=3){const l=new $(i[c],i[c+1],i[c+2]);if(this.tmpPoints.length>0){const u=this.tmpPoints[this.tmpPoints.length-1],h=b.Sub(l,u).uni();l.setv(h)}this.tmpPoints.push(l)}if(this.tmpPoints.length<2)return;const r=this.transformDataAll(!0);if(r.length)for(let c=0;c<r.length;c++){const{pos:l,points:u}=r[c],h=u.map(f=>f.point.addXY(l[0],l[1])),d=[];for(const f of o){const g=[];for(let S=0;S<f.length;S+=2){const w=new $(f[S],f[S+1]);if(g.length>0){const I=g[g.length-1].point,k=b.Sub(w,I).uni();w.setv(k)}g.push({point:w,radius:n})}const{ps:M}=this.computStroke(g,!1);d.push(M.map(S=>S.XY))}ef(h,d,.01).forEach(f=>{t.push(f.map(g=>[g[0],g[1],g[2]]).flat(1))})}return t}transformDataAll(e=!0){const t=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(t,e&&this.workOptions.thickness||void 0)}draw(e){const{attrs:t,tasks:i,replaceId:o,effects:n,layer:r,removeDrawCount:c,isDrawEraserlines:l=!0}=e,{strokeColor:u,strokeType:h,thickness:d,zIndex:p,scale:f,rotate:g,translate:M,eraserlines:S}=this.workOptions;n!=null&&n.size&&(n.forEach(P=>{var C;(C=r.getElementById(P+""))==null||C.remove()}),n.clear()),c&&this.removeDrawCountNodes(r,c);let w;const I=[],k=r.worldPosition,T=r.worldScaling;for(let P=0;P<i.length;P++){const{pos:C,points:L}=i[P],{ps:O,rect:R}=this.computDrawPoints(L);let E;const j=L.length===1;h===te.Stroke||j?E=Xe(O,!0):E=Xe(O,!1);const D={pos:C,d:E,fillColor:h===te.Stroke||j?u:void 0,lineDash:h===te.Dotted&&!j?[1,d*2]:h===te.LongDotted&&!j?[d,d*2]:void 0,strokeColor:u,lineCap:h===te.Stroke||j?void 0:"round",lineWidth:h===te.Stroke||j?0:d};w=le(w,{x:Math.floor((R.x+C[0])*T[0]+k[0]-B.SafeBorderPadding),y:Math.floor((R.y+C[1])*T[1]+k[1]-B.SafeBorderPadding),w:Math.floor(R.w*T[0]+2*B.SafeBorderPadding),h:Math.floor(R.h*T[1]+2*B.SafeBorderPadding)}),I.push(D)}f&&(t.scale=f),g&&(t.rotate=g),M&&(t.translate=M);const v=new ce.Group;if(w){this.centerPos=B.getCenterPos(w,r);const P=h===te.Stroke&&!S;v.attr({...t,normalize:!0,anchor:[.5,.5],bgcolor:P?u:void 0,pos:this.centerPos,size:[(w.w-2*B.SafeBorderPadding)/T[0],(w.h-2*B.SafeBorderPadding)/T[1]],zIndex:p});const C=I.map(L=>(L.pos=[L.pos[0]-this.centerPos[0],L.pos[1]-this.centerPos[1]],new ce.Path(L)));v.append(...C),P&&v.seal(),S&&(this.scaleType=re.proportional,this.drawEraserlines({group:v,eraserlines:S,pos:this.centerPos,layer:r},l)),this.replace(r,o,v)}if(f||g||M){const P=v==null?void 0:v.getBoundingClientRect();P&&(w={x:Math.floor(P.x-B.SafeBorderPadding),y:Math.floor(P.y-B.SafeBorderPadding),w:Math.floor(P.width+B.SafeBorderPadding*2),h:Math.floor(P.height+B.SafeBorderPadding*2)})}return this.isDelete&&v.setAttribute("opacity",0),w}computDrawPoints(e){return this.workOptions.strokeType===te.Stroke||e.length===1?this.computStroke(e):this.computNomal(e)}computNomal(e){let t=this.workOptions.thickness;const i=e.map(o=>(t=Math.max(t,o.radius),o.point));return{ps:i,rect:fe(i,t)}}computStroke(e,t=!0){return e.length===1?this.computDotStroke(e[0]):this.computLineStroke(e,t)}computLineStroke(e,t=!0){const i=[],o=[];for(let c=0;c<e.length;c++){const{point:l,radius:u}=e[c];let h=l.v;c===0&&e.length>1&&(h=e[c+1].point.v);const d=b.Per(h).mul(u);i.push($.Sub(l,d)),o.push($.Add(l,d))}const n=e[e.length-1];if(t){const c=$.GetSemicircleStroke(n.point,i[i.length-1],-1,8),l=$.GetSemicircleStroke(e[0].point,o[0],-1,8),u=i.concat(c,o.reverse(),l);return{ps:u,rect:fe(u)}}const r=i.concat(o.reverse());return{ps:r,rect:fe(r)}}computDotStroke(e){const{point:t,radius:i}=e,o={x:t.x-i,y:t.y-i,w:i*2,h:i*2};return{ps:$.GetDotStroke(t,i,8),rect:o}}transformData(e,t){const{op:i,workState:o}=e;let n=this.tmpPoints.length-1,r=[];if(i!=null&&i.length&&o){const{strokeType:c,thickness:l}=this.workOptions,u=new Set;n=c===te.Stroke?this.updateTempPointsWithPressure(i,l,u):this.updateTempPoints(i,l,u);const h=t?this.tmpPoints:this.tmpPoints.slice(n);return r=this.getTaskPoints(h,l),{tasks:r,effects:u,consumeIndex:n}}return{tasks:r,consumeIndex:n}}computRadius(e,t){return e*.03*t+t*.5}getMinZ(e,t){return((t||Math.max(1,Math.floor(e*.3)))-e*.5)*100/e/3}getTaskPoints(e,t){var h;const i=[];if(e.length===0)return[];let o=0,n=e[0].x,r=e[0].y,c=[n,r],l=[],u=e[0].t;for(;o<e.length;){const d=e[o],p=d.x-n,f=d.y-r,g=d.z,M=t?this.computRadius(g,t):g;if(l.push({point:new $(p,f,g,e[o].v),radius:M}),o>0&&o<e.length-1){const S=e[o].getAngleByPoints(e[o-1],e[o+1]);if(S<60||S>300){const w=(h=l.pop())==null?void 0:h.point.clone();w&&i.push({taskId:u,pos:c,points:[...l,{point:w,radius:M}]}),n=e[o].x,r=e[o].y,c=[n,r];const I=d.x-n,k=d.y-r;l=[{point:new $(I,k,g),radius:M}],u=Date.now()}}o++}return i.push({taskId:u,pos:c,points:l}),i}updateTempPointsWithPressure(e,t,i){const o=Date.now(),n=this.tmpPoints.length;let r=n;for(let l=0;l<e.length;l+=2){r=Math.min(r,n);const u=this.tmpPoints.length,h=new $(e[l],e[l+1]);if(u===0){this.tmpPoints.push(h);continue}const d=u-1,p=this.tmpPoints[d],f=b.Sub(h,p).uni();if(h.isNear(p,t)){if(p.z<this.MAX_REPEAR){if(p.setz(Math.min(p.z+1,this.MAX_REPEAR)),r=Math.min(r,d),u>1){let S=u-1;for(;S>0;){const w=this.tmpPoints[S].distance(this.tmpPoints[S-1]),I=Math.max(this.tmpPoints[S].z-this.uniThickness*w,0);if(this.tmpPoints[S-1].z>=I)break;this.tmpPoints[S-1].setz(I),r=Math.min(r,S-1),S--}}}else r=1/0;continue}h.setv(f);const g=h.distance(p),M=Math.max(p.z-this.uniThickness*g,0);u>1&&b.Equals(f,p.v,.02)&&(M>0||p.z<=0)&&(i&&p.t&&i.add(p.t),this.tmpPoints.pop(),r=Math.min(d,r)),h.setz(M),this.tmpPoints.push(h)}if(r===1/0)return this.tmpPoints.length;let c=n;if(r===n){c=Math.max(c-1,0);const l=this.tmpPoints[c].t;l&&(i==null||i.add(l))}else{let l=n-1;for(c=r;l>=0;){const u=this.tmpPoints[l].t;if(u&&(i==null||i.add(u),l<=r)){c=l,l=-1;break}l--}}return this.tmpPoints[c].setT(o),c}updateTempPoints(e,t,i){var l;const o=Date.now(),n=this.tmpPoints.length;let r=n;for(let u=0;u<e.length;u+=2){const h=this.tmpPoints.length,d=new $(e[u],e[u+1]);if(h===0){this.tmpPoints.push(d);continue}const p=h-1,f=this.tmpPoints[p],g=b.Sub(d,f).uni();if(d.isNear(f,t/2)){r=Math.min(p,r);continue}b.Equals(g,f.v,.02)&&(i&&f.t&&i.add(f.t),this.tmpPoints.pop(),r=Math.min(p,r)),d.setv(g),this.tmpPoints.push(d)}let c=n;if(r===n){c=Math.max(c-1,0);const u=this.tmpPoints[c].t;u&&(i==null||i.add(u))}else{let u=Math.min(n-1,r);for(c=r;u>=0;){const h=(l=this.tmpPoints[u])==null?void 0:l.t;if(h&&(i==null||i.add(h),u<=r)){c=u,u=-1;break}u--}}return this.tmpPoints[c].setT(o),c}updateTempPointsWithPressureWhenDone(e){const{thickness:t}=this.workOptions,i=e.length,o=this.getMinZ(t);for(let n=0;n<i;n+=2){const r=this.tmpPoints.length,c=new $(e[n],e[n+1]);if(r===0){this.tmpPoints.push(c);continue}const l=r-1,u=this.tmpPoints[l],h=b.Sub(c,u).uni(),d=c.distance(u);if(r>1&&u.z===o)break;if(c.isNear(u,t/2)){if(i<3&&u.z<this.MAX_REPEAR&&(u.setz(Math.min(u.z+1,this.MAX_REPEAR)),r>1)){let f=r-1;for(;f>0;){const g=this.tmpPoints[f].distance(this.tmpPoints[f-1]),M=Math.max(this.tmpPoints[f].z-this.uniThickness*g,-t/4);if(this.tmpPoints[f-1].z>=M)break;this.tmpPoints[f-1].setz(M),f--}}continue}c.setv(h);const p=Math.max(u.z-this.uniThickness*d,o);r>1&&b.Equals(h,u.v,.02)&&u.z<=0&&this.tmpPoints.pop(),c.setz(p),this.tmpPoints.push(c)}}static updateNodeOpt(e){var l,u;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,strokeType:r}=i,c=o.get(t.name);return n&&(t.tagName==="GROUP"?tm(t)?t.setAttribute("bgcolor",n):t.children.forEach(h=>{h.setAttribute("strokeColor",n),h.getAttribute("fillColor")&&h.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),r&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=r),c&&o.setInfo(t.name,c),B.updateNodeOpt(e)}}class Bo extends B{constructor(e){super(e);y(this,"toolsType",N.LaserPen);y(this,"canRotate",!1);y(this,"scaleType",re.none);y(this,"syncTimestamp");y(this,"syncIndex",0);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"consumeIndex",0);this.workOptions=e.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:t,isSubWorker:i}=e,{workId:o,op:n,syncUnitTime:r}=t;if((n==null?void 0:n.length)===0)return{type:x.None};if(r&&(this.syncUnitTime=r),this.updateTempPoints(n||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:x.None};const{strokeColor:c,thickness:l,strokeType:u}=this.workOptions,h=fe(this.tmpPoints,l);let d=!1;const p=this.syncIndex,f=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const g={name:o==null?void 0:o.toString(),opacity:1,lineDash:u===te.Dotted?[1,l*2]:u===te.LongDotted?[l,l*2]:void 0,strokeColor:c,lineCap:"round",lineWidth:l,anchor:[.5,.5]},M=this.getTaskPoints(f);if(M.length){const w=Date.now();w-this.syncTimestamp>this.syncUnitTime&&(d=!0,this.syncTimestamp=w,this.syncIndex=this.tmpPoints.length),i&&this.draw({attrs:g,tasks:M,isDot:!1,layer:this.drawLayer||this.fullLayer})}const S=[];return this.tmpPoints.slice(p).forEach(w=>{S.push(w.x,w.y)}),{rect:{x:h.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:h.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:h.w*this.fullLayer.worldScaling[0],h:h.h*this.fullLayer.worldScaling[1]},type:x.DrawWork,dataType:F.Local,op:d?S:void 0,index:d?p*2:void 0,...this.baseConsumeResult}}consumeAll(){var n;const e=(n=this.workId)==null?void 0:n.toString();let t;if(this.tmpPoints.length-1>this.consumeIndex){let r=this.tmpPoints.slice(this.consumeIndex);const c=r.length===1,{strokeColor:l,thickness:u,strokeType:h}=this.workOptions;if(c){const f=this.computDotStroke({point:r[0],radius:u/2});r=f.ps,t=f.rect}else t=fe(this.tmpPoints,u);const d={name:e==null?void 0:e.toString(),fillColor:c?l:void 0,opacity:1,lineDash:h===te.Dotted&&!c?[1,u*2]:h===te.LongDotted&&!c?[u,u*2]:void 0,strokeColor:l,lineCap:c?void 0:"round",lineWidth:c?0:u,anchor:[.5,.5]},p=this.getTaskPoints(r);p.length&&this.draw({attrs:d,tasks:p,isDot:c,layer:this.drawLayer||this.fullLayer})}const i=[];this.tmpPoints.forEach(r=>{i.push(r.x,r.y)});const o=We(i);return{rect:t&&{x:t.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:t.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:t.w*this.fullLayer.worldScaling[0],h:t.h*this.fullLayer.worldScaling[1]},type:x.FullWork,dataType:F.Local,ops:o,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(e){var g;const{op:t,replaceId:i,isFullWork:o}=e,{strokeColor:n,thickness:r,strokeType:c}=this.workOptions;if(!t.length){const M=fe(this.tmpPoints,r);return{x:M.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:M.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:M.w*this.fullLayer.worldScaling[0],h:M.h*this.fullLayer.worldScaling[1]}}const l=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(t||[]);let u,h=this.tmpPoints.slice(l);const d=h.length===1;if(d){const M=this.computDotStroke({point:h[0],radius:r/2});h=M.ps,u=M.rect}else u=fe(this.tmpPoints,r);const p={name:(g=this.workId)==null?void 0:g.toString(),fillColor:d?n:void 0,opacity:1,lineDash:c===te.Dotted&&!d?[1,r*2]:c===te.LongDotted&&!d?[r,r*2]:void 0,strokeColor:n,lineCap:d?void 0:"round",lineWidth:d?0:r,anchor:[.5,.5]},f=this.getTaskPoints(h);if(f.length){const M=o?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:p,tasks:f,isDot:d,replaceId:i,layer:M})}return{x:u.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:u.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:u.w*this.fullLayer.worldScaling[0],h:u.h*this.fullLayer.worldScaling[1]}}computDotStroke(e){const{point:t,radius:i}=e,o={x:t.x-i,y:t.y-i,w:i*2,h:i*2};return{ps:$.GetDotStroke(t,i,8),rect:o}}updateTempPoints(e){const t=this.tmpPoints.length;for(let i=0;i<e.length;i+=2){if(t){const o=this.tmpPoints.slice(-1)[0];o&&o.x===e[i]&&o.y===e[i+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new $(e[i],e[i+1]))}}async draw(e){const{attrs:t,tasks:i,isDot:o,layer:n}=e,{duration:r}=this.workOptions;for(const c of i){const l=new ce.Path,{pos:u,points:h}=c;let d;o?d=Xe(h,!0):d=Xe(h,!1),l.attr({...t,pos:u,d});const{vertex:p,fragment:f}=this.workOptions;if(p&&f){const g=n.renderer.createProgram({vertex:p,fragment:f}),{width:M,height:S}=n.getResolution();l.setUniforms({u_time:0,u_resolution:[M,S]}),l.setProgram(g)}n.appendChild(l),l.transition(r).attr({scale:o?[.1,.1]:[1,1],lineWidth:o?0:1}).then(()=>{l.remove()})}}getTaskPoints(e){var l;const t=[];if(e.length===0)return[];let i=0,o=e[0].x,n=e[0].y,r=[o,n],c=[];for(;i<e.length;){const u=e[i],h=u.x-o,d=u.y-n;if(c.push(new $(h,d)),i>0&&i<e.length-1){const p=e[i].getAngleByPoints(e[i-1],e[i+1]);if(p<60||p>300){const f=(l=c.pop())==null?void 0:l.clone();f&&t.push({pos:r,points:[...c,f]}),o=e[i].x,n=e[i].y,r=[o,n];const g=u.x-o,M=u.y-n;c=[new $(g,M)]}}i++}return t.push({pos:r,points:c}),t}removeLocal(){}removeService(e){let t;const i=[];return this.fullLayer.getElementsByName(e).forEach(o=>{if(o.name===e){const n=o.getBoundingClientRect();t=le(t,{x:n.x,y:n.y,w:n.width,h:n.height}),i.push(o)}}),i.length&&i.forEach(o=>o.remove()),t}}const St=class St extends B{constructor(e,t){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.none);y(this,"toolsType",N.Eraser);y(this,"serviceWork");y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"worldPosition");y(this,"worldScaling");y(this,"eraserRect");y(this,"eraserPolyline");this.serviceWork=t,this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(e){super.setWorkOptions(e)}createEraserRect(e){const t=e[0]*this.worldScaling[0]+this.worldPosition[0],i=e[1]*this.worldScaling[1]+this.worldPosition[1],{width:o,height:n}=St.eraserSizes[this.workOptions.thickness];this.eraserRect={x:t-o*.5,y:i-n*.5,w:o,h:n},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const e=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const t=new b(this.tmpPoints[0],this.tmpPoints[1]),i=new b(this.tmpPoints[2],this.tmpPoints[3]),o=b.Sub(i,t).uni(),n=b.Dist(t,i),{width:r,height:c}=St.eraserSizes[this.workOptions.thickness],l=Math.min(r,c),u=Math.round(n/l);if(u>1){const h=[];for(let d=0;d<u;d++){const p=b.Mul(o,d*l);h.push(this.tmpPoints[0]+p.x,this.tmpPoints[1]+p.y)}return h.concat(e)}}return e}isNear(e,t){const i=new b(e[0],e[1]),o=new b(t[0],t[1]),{width:n,height:r}=St.eraserSizes[this.workOptions.thickness];return b.Dist(i,o)<Math.hypot(n,r)*.5}remove(e){const{curNodeMap:t,removeIds:i}=e;let o;for(const n of t.values())if(n.rect&&this.eraserRect&&this.eraserPolyline&&Rs(this.eraserRect,n.rect)){const{op:r}=n,c=[],l=[];for(let h=0;h<r.length;h+=3){const d=new b(r[h]*this.worldScaling[0]+this.worldPosition[0],r[h+1]*this.worldScaling[1]+this.worldPosition[1],r[h+2]);l.push(d),c.push(new $(d.x,d.y))}const u=c.length&&fe(c)||n.rect;Rs(u,this.eraserRect)&&(l.length>1?Vs.polyline(l.map(d=>d.XY),this.eraserPolyline).length&&i.add(n.name):i.add(n.name),o=le(o,n.rect||u))}return i.forEach(n=>{var c;const r=this.fullLayer.getElementsByName(n);r[0]&&(r[0].remove(),Oe(r[0],this.fullLayer.parent),(c=this.vNodes)==null||c.delete(n))}),o&&(o.x-=B.SafeBorderPadding,o.y-=B.SafeBorderPadding,o.w+=B.SafeBorderPadding*2,o.h+=B.SafeBorderPadding*2),o}consume(e){const{op:t,disableEraseImage:i,disableEraseText:o}=e.data;if(!t||t.length===0)return{type:x.None,...this.baseConsumeResult};const n=this.tmpPoints.length;if(n>1&&this.isNear([t[0],t[1]],[this.tmpPoints[n-2],this.tmpPoints[n-1]]))return{type:x.None,...this.baseConsumeResult};n<3?this.tmpPoints.push(t[0],t[1]):this.tmpPoints.splice(2,2,t[0],t[1]);const r=this.computRectCenterPoints();let c;const l=new Set;if(!this.vNodes)return{type:x.None,...this.baseConsumeResult};const u=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.curNodeMap,{disableEraseImage:i,disableEraseText:o}));for(let h=0;h<r.length-1;h+=2){this.createEraserRect(r.slice(h,h+2));const d=this.remove({curNodeMap:u,removeIds:l});c=le(c,d)}return c&&l.size?{type:x.RemoveNode,rect:c,removeIds:[...l]}:{type:x.None,...this.baseConsumeResult}}consumeAll(e){return this.consume(e)}clearTmpPoints(){this.tmpPoints.length=0}getCanEraserNodeMap(e){var t;if(this.serviceWork){const i=new Map(e),o=this.serviceWork.selectorWorkShapes,n=this.serviceWork.workShapes;for(const r of o.values())if((t=r.selectIds)!=null&&t.length)for(const c of r.selectIds)i.delete(c);for(const r of n.keys())i.delete(r);return i}return e}};y(St,"eraserSizes",si);let ts=St;const Ee="++",H="selector",Jt="all";var tf="__lodash_hash_undefined__";function sf(a){return this.__data__.set(a,tf),this}var of=sf;function nf(a){return this.__data__.has(a)}var rf=nf,af=fo,cf=of,lf=rf;function ss(a){var s=-1,e=a==null?0:a.length;for(this.__data__=new af;++s<e;)this.add(a[s])}ss.prototype.add=ss.prototype.push=cf;ss.prototype.has=lf;var ii=ss;function hf(a,s){for(var e=-1,t=a==null?0:a.length;++e<t;)if(s(a[e],e,a))return!0;return!1}var uf=hf;function df(a,s){return a.has(s)}var oi=df,pf=ii,ff=uf,gf=oi,yf=1,mf=2;function Mf(a,s,e,t,i,o){var n=e&yf,r=a.length,c=s.length;if(r!=c&&!(n&&c>r))return!1;var l=o.get(a),u=o.get(s);if(l&&u)return l==s&&u==a;var h=-1,d=!0,p=e&mf?new pf:void 0;for(o.set(a,s),o.set(s,a);++h<r;){var f=a[h],g=s[h];if(t)var M=n?t(g,f,h,s,a,o):t(f,g,h,a,s,o);if(M!==void 0){if(M)continue;d=!1;break}if(p){if(!ff(s,function(S,w){if(!gf(p,w)&&(f===S||i(f,S,e,t,o)))return p.push(w)})){d=!1;break}}else if(!(f===g||i(f,g,e,t,o))){d=!1;break}}return o.delete(a),o.delete(s),d}var Fo=Mf;function wf(a){var s=-1,e=Array(a.size);return a.forEach(function(t,i){e[++s]=[i,t]}),e}var vf=wf;function If(a){var s=-1,e=Array(a.size);return a.forEach(function(t){e[++s]=t}),e}var ni=If,Yi=Vt,Ui=Ao,Tf=$s,Sf=Fo,Nf=vf,kf=ni,Cf=1,bf=2,xf="[object Boolean]",Lf="[object Date]",Pf="[object Error]",Df="[object Map]",zf="[object Number]",Af="[object RegExp]",jf="[object Set]",Ef="[object String]",Of="[object Symbol]",Rf="[object ArrayBuffer]",Wf="[object DataView]",Bi=Yi?Yi.prototype:void 0,ks=Bi?Bi.valueOf:void 0;function Yf(a,s,e,t,i,o,n){switch(e){case Wf:if(a.byteLength!=s.byteLength||a.byteOffset!=s.byteOffset)return!1;a=a.buffer,s=s.buffer;case Rf:return!(a.byteLength!=s.byteLength||!o(new Ui(a),new Ui(s)));case xf:case Lf:case zf:return Tf(+a,+s);case Pf:return a.name==s.name&&a.message==s.message;case Af:case Ef:return a==s+"";case Df:var r=Nf;case jf:var c=t&Cf;if(r||(r=kf),a.size!=s.size&&!c)return!1;var l=n.get(a);if(l)return l==s;t|=bf,n.set(a,s);var u=Sf(r(a),r(s),t,i,o,n);return n.delete(a),u;case Of:if(ks)return ks.call(a)==ks.call(s)}return!1}var Uf=Yf,Fi=Po,Bf=1,Ff=Object.prototype,Vf=Ff.hasOwnProperty;function $f(a,s,e,t,i,o){var n=e&Bf,r=Fi(a),c=r.length,l=Fi(s),u=l.length;if(c!=u&&!n)return!1;for(var h=c;h--;){var d=r[h];if(!(n?d in s:Vf.call(s,d)))return!1}var p=o.get(a),f=o.get(s);if(p&&f)return p==s&&f==a;var g=!0;o.set(a,s),o.set(s,a);for(var M=n;++h<c;){d=r[h];var S=a[d],w=s[d];if(t)var I=n?t(w,S,d,s,a,o):t(S,w,d,a,s,o);if(!(I===void 0?S===w||i(S,w,e,t,o):I)){g=!1;break}M||(M=d=="constructor")}if(g&&!M){var k=a.constructor,T=s.constructor;k!=T&&"constructor"in a&&"constructor"in s&&!(typeof k=="function"&&k instanceof k&&typeof T=="function"&&T instanceof T)&&(g=!1)}return o.delete(a),o.delete(s),g}var Hf=$f,Cs=go,Qf=Fo,Gf=Uf,Zf=Hf,Vi=Ms,$i=$t,Hi=Qs,qf=To,Xf=1,Qi="[object Arguments]",Gi="[object Array]",Gt="[object Object]",Jf=Object.prototype,Zi=Jf.hasOwnProperty;function Kf(a,s,e,t,i,o){var n=$i(a),r=$i(s),c=n?Gi:Vi(a),l=r?Gi:Vi(s);c=c==Qi?Gt:c,l=l==Qi?Gt:l;var u=c==Gt,h=l==Gt,d=c==l;if(d&&Hi(a)){if(!Hi(s))return!1;n=!0,u=!1}if(d&&!u)return o||(o=new Cs),n||qf(a)?Qf(a,s,e,t,i,o):Gf(a,s,c,e,t,i,o);if(!(e&Xf)){var p=u&&Zi.call(a,"__wrapped__"),f=h&&Zi.call(s,"__wrapped__");if(p||f){var g=p?a.value():a,M=f?s.value():s;return o||(o=new Cs),i(g,M,e,t,o)}}return d?(o||(o=new Cs),Zf(a,s,e,t,i,o)):!1}var _f=Kf,eg=_f,qi=Ke;function Vo(a,s,e,t,i){return a===s?!0:a==null||s==null||!qi(a)&&!qi(s)?a!==a&&s!==s:eg(a,s,e,t,Vo,i)}var tg=Vo,sg=tg;function ig(a,s){return sg(a,s)}var og=ig;const tt=Pt(og),ls=class ls extends B{constructor(e){super(e);y(this,"toolsType",N.Selector);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"vNodes");y(this,"selectIds");y(this,"selectorColor");y(this,"strokeColor");y(this,"fillColor");y(this,"oldSelectRect");y(this,"canRotate",!1);y(this,"canTextEdit",!1);y(this,"canLock",!1);y(this,"scaleType",re.all);y(this,"toolsTypes");y(this,"shapeOpt");y(this,"textOpt");y(this,"isLocked");y(this,"thickness");y(this,"strokeType");y(this,"useStroke");this.workOptions=e.toolsOpt,this.vNodes=e.vNodes}computSelector(e=!0){const t=fe(this.tmpPoints);if(t.w===0||t.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:i,nodeRange:o}=this.vNodes.getRectIntersectRange(t,e);return{selectIds:[...o.keys()],intersectRect:i,subNodeMap:o}}updateTempPoints(e){const t=this.tmpPoints.length,i=e.length;if(i>1){const o=new $(e[i-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[i-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);t===2?this.tmpPoints.splice(1,1,o):this.tmpPoints.push(o)}}drawSelector(e){const{drawRect:t,subNodeMap:i,selectorId:o,layer:n,isService:r}=e,c=new ce.Group({pos:[t.x,t.y],anchor:[0,0],size:[t.w,t.h],id:o,name:o,zIndex:9999}),l=[];if(r){const u=new ce.Rect({normalize:!0,pos:[t.w/2,t.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:t.w,height:t.h,name:ls.selectorBorderId});l.push(u)}i.forEach((u,h)=>{const d=[u.rect.x+u.rect.w/2-t.x,u.rect.y+u.rect.h/2-t.y],p=new ce.Rect({normalize:!0,pos:d,lineWidth:1,strokeColor:i.size>1?this.selectorColor||this.workOptions.strokeColor:void 0,width:u.rect.w,height:u.rect.h,id:`selector-${h}`,name:`selector-${h}`});l.push(p)}),l&&c.append(...l),(n==null?void 0:n.parent).appendChild(c)}draw(e,t,i,o=!1){var c,l;const{intersectRect:n,subNodeMap:r}=i;(l=(c=t.parent)==null?void 0:c.getElementById(e))==null||l.remove(),n&&this.drawSelector({drawRect:n,subNodeMap:r,selectorId:e,layer:t,isService:o})}getSelecteorInfo(e){this.scaleType=re.all,this.canRotate=!1,this.textOpt=void 0,this.strokeColor=void 0,this.fillColor=void 0,this.canTextEdit=!1,this.canLock=!1,this.isLocked=!1,this.toolsTypes=void 0,this.shapeOpt=void 0,this.thickness=void 0,this.strokeType=void 0,this.useStroke=!1;const t=new Set;let i,o=!0;for(const n of e.values()){const{opt:r,canRotate:c,scaleType:l,toolsType:u}=n;this.selectorColor=this.workOptions.strokeColor,r.strokeColor&&(this.strokeColor=r.strokeColor),r.fillColor&&(this.fillColor=r.fillColor),r.textOpt&&(this.textOpt=r.textOpt),r.thickness&&(this.thickness=r.thickness),u!==N.Pencil&&(o=!1),r.strokeType&&(this.strokeType=r.strokeType),u===N.SpeechBalloon&&(t.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=r.placement),u===N.Polygon&&(t.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=r.vertices),u===N.Star&&(t.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=r.vertices,this.shapeOpt.innerRatio=r.innerRatio,this.shapeOpt.innerVerticeStep=r.innerVerticeStep),u===N.Text&&(this.textOpt=r),e.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),u===N.Image&&(i=n),(l===re.proportional&&this.scaleType!==re.none||l===re.none)&&(this.scaleType=l)}o&&(this.useStroke=!0),t.size&&(this.toolsTypes=[...t]),i&&(e.size===1?(this.canLock=!0,i.opt.locked&&(this.isLocked=!0,this.scaleType=re.none,this.canRotate=!1,this.textOpt=void 0,this.fillColor=void 0,this.selectorColor="rgb(177,177,177)",this.strokeColor=void 0,this.canTextEdit=!1,this.thickness=void 0,this.strokeType=void 0,this.useStroke=void 0)):e.size>1&&!i.opt.locked&&(this.canLock=!1,this.canRotate=!1))}getChildrenPoints(){var e,t;if(this.scaleType===re.both&&((e=this.selectIds)==null?void 0:e.length)===1){const i=this.selectIds[0],o=(t=this.vNodes.get(i))==null?void 0:t.op;if(o){const n=[];for(let r=0;r<o.length;r+=3)n.push([o[r],o[r+1]]);return n}}}consume(e){const{op:t,workState:i}=e.data;let o=this.oldSelectRect;if(i===z.Start&&(o=this.unSelectedAllIds()),!(t!=null&&t.length)||!this.vNodes.curNodeMap.size)return{type:x.None};this.updateTempPoints(t);const n=this.computSelector();if(this.selectIds&&tt(this.selectIds,n.selectIds))return{type:x.None};this.selectIds=n.selectIds;const r=n.intersectRect;this.getSelecteorInfo(n.subNodeMap),this.draw(H,this.fullLayer,n),this.oldSelectRect=r;const c=this.getChildrenPoints();return{type:x.Select,dataType:F.Local,rect:le(r,o),selectIds:n.selectIds,selectRect:r,selectorColor:this.selectorColor,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:c,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}consumeAll(){var t,i;let e=this.oldSelectRect;if(!((t=this.selectIds)!=null&&t.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,H,!1),(i=this.selectIds)!=null&&i.length&&(e=this.selectedByIds(this.selectIds)),e){const o=this.getChildrenPoints();return{type:x.Select,dataType:F.Local,rect:this.oldSelectRect,selectIds:this.selectIds,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:o,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}return{type:x.None}}consumeService(){}clearTmpPoints(){this.tmpPoints.length=0}clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0}selectSingleTool(e,t=H,i=!1){if(e.length===2){const o=e[0],n=e[1];let r;const{nodeRange:c}=this.vNodes.getRectIntersectRange({x:o,y:n,w:0,h:0},!1),l=[...c.values()].sort((u,h)=>(h.opt.zIndex||0)-(u.opt.zIndex||0));for(const u of l){const h=this.fullLayer.getElementsByName(u.name);if(Ko(h).find(p=>p.isPointCollision(o,n))){r=u;break}}if(r){const u=r.name;if(!tt(this.oldSelectRect,r.rect)){const h=new Map([[u,r]]);this.getSelecteorInfo(h),this.draw(t,this.fullLayer,{intersectRect:r.rect,subNodeMap:h,selectIds:this.selectIds||[]},i)}this.selectIds=[u],this.oldSelectRect=r.rect}}}unSelectedAllIds(){let e;for(const[t,i]of this.vNodes.curNodeMap.entries())i.isSelected&&(e=le(e,i.rect),this.vNodes.unSelected(t));return e}unSelectedByIds(e){let t;for(const i of e){const o=this.vNodes.get(i);o&&o.isSelected&&(t=le(t,o.rect),this.vNodes.unSelected(i))}return t}selectedByIds(e){let t;for(const i of e){const o=this.vNodes.get(i);o&&(t=le(t,o.rect),this.vNodes.selected(i))}return t}getSelectorRect(e,t){var r;let i;const o=(r=e.parent)==null?void 0:r.getElementById(t),n=o==null?void 0:o.getBoundingClientRect();return n&&(i=le(i,{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.floor(n.width+1),h:Math.floor(n.height+1)})),i}isCanFillColor(e){return e===N.Ellipse||e===N.Triangle||e===N.Rectangle||e===N.Polygon||e===N.Star||e===N.SpeechBalloon}async updateSelector(e){const{updateSelectorOpt:t,selectIds:i,vNodes:o,willSerializeData:n,worker:r,offset:c}=e,l=this.fullLayer;if(!l)return;let u;const h=new Map,{originPoint:d,workState:p,angle:f,translate:g,dir:M,scale:S}=t;c&&(g?t.translate=[g[0]+c[0],g[1]+c[1]]:t.translate=c);let w;if(d||g||be(f)){if(p===z.Start&&i)return o.setTargetAssignKeys(i),{type:x.Select,dataType:F.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};if(w=o.getLastTarget(),!w)return}if(i)for(const T of i){const v=o.get(T);if(v){const{toolsType:P,opt:C}=v,L=(l==null?void 0:l.getElementsByName(T))[0];if(L){const O={...t};let R;const E=B.isWillRefresh({toolsType:P,opt:C,updateOpt:O,vNodes:o,node:L,willSerializeData:n});if(P){R=w==null?void 0:w.get(T);const j=Jo(P);if(j==null||j.updateNodeOpt({node:L,opt:O,vNodes:o,willSerializeData:n,targetNode:R}),v&&r&&E){const D=r.createWorkShapeNode({workId:T,toolsType:P,toolsOpt:v.opt});D==null||D.setWorkId(T);let q;if(P===N.Image)q=await D.consumeServiceAsync({isFullWork:!0,replaceId:T,worker:r});else if(P===N.Text)q=await D.consumeServiceAsync({isFullWork:!0,replaceId:T});else try{q=D==null?void 0:D.consumeService({op:v.op,isFullWork:!0,replaceId:T,workState:p})}catch{continue}q&&(v.rect=q)}v&&(h.set(T,v),u=le(u,v.rect))}}}}w&&p===z.Done&&(o.deleteLastTarget(),w=void 0);const I=u;if(d&&g&&S&&M&&I&&!c){const T=[[I.x,I.y],[I.x+I.w,I.y],[I.x+I.w,I.y+I.h],[I.x,I.y+I.h]];let v;switch(M){case"top":case"topLeft":case"left":g[0]>0&&g[1]>0?v=T[0]:g[0]>0?v=T[3]:g[1]>0?v=T[1]:v=T[2];break;case"topRight":g[0]<0&&g[1]>0?v=T[1]:g[0]<0?v=T[2]:g[1]>0?v=T[0]:v=T[3];break;case"right":case"bottomRight":case"bottom":g[0]<0&&g[1]<0?v=T[2]:g[0]<0?v=T[1]:g[1]<0?v=T[3]:v=T[0];break;case"bottomLeft":g[0]>0&&g[1]<0?v=T[3]:g[0]>0?v=T[0]:g[1]<0?v=T[2]:v=T[1];break}const P=v&&[d[0]-v[0],d[1]-v[1]]||[0,0];if(!tt(P,[0,0]))return await this.updateSelector({...e,updateSelectorOpt:{workState:p},offset:P})}this.getSelecteorInfo(h),this.draw(H,l,{selectIds:i||[],subNodeMap:h,intersectRect:I});const k=le(this.oldSelectRect,I);return this.oldSelectRect=I,{type:x.Select,dataType:F.Local,selectRect:I,renderRect:u,rect:le(k,I),selectIds:i}}blurSelector(){const e=this.unSelectedAllIds();return{type:x.Select,dataType:F.Local,rect:e,selectIds:[],willSyncService:!0}}getRightServiceId(e){return e.replace(Ee,"-")}selectServiceNode(e,t,i){const{selectIds:o}=t,n=this.getRightServiceId(e),r=this.getSelectorRect(this.fullLayer,n);let c;const l=new Map;return o==null||o.forEach(u=>{const h=this.vNodes.get(u);h&&(c=le(c,h.rect),l.set(u,h))}),this.getSelecteorInfo(l),this.draw(n,this.fullLayer,{intersectRect:c,selectIds:o||[],subNodeMap:l},i),le(c,r)}reRenderSelector(){var i;let e;const t=new Map;return(i=this.selectIds)==null||i.forEach(o=>{const n=this.vNodes.get(o);n&&(e=le(e,n.rect),t.set(o,n))},this),this.getSelecteorInfo(t),this.draw(H,this.fullLayer,{intersectRect:e,subNodeMap:t,selectIds:this.selectIds||[]}),this.oldSelectRect=e,e}updateSelectIds(e){var n;let t;const i=(n=this.selectIds)==null?void 0:n.filter(r=>!e.includes(r));if(i!=null&&i.length&&(t=this.unSelectedByIds(i)),e.length){const r=this.selectedByIds(e);t=le(t,r)}this.selectIds=e;const o=this.reRenderSelector();return{bgRect:t,selectRect:o}}cursorHover(e){var n,r;const t=this.oldSelectRect;this.selectIds=[];const i=(n=this.workId)==null?void 0:n.toString(),o=[e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(o,i,!0),this.oldSelectRect&&!tt(t,this.oldSelectRect))return{type:x.CursorHover,dataType:F.Local,rect:le(t,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((r=this.selectIds)!=null&&r.length||(this.oldSelectRect=void 0),t&&!this.oldSelectRect)return this.cursorBlur(),{type:x.CursorHover,dataType:F.Local,rect:t,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var t,i;this.selectIds=[];const e=(t=this.workId)==null?void 0:t.toString();((i=this.fullLayer)==null?void 0:i.parent).children.forEach(o=>{o.name===e&&o.remove()})}};y(ls,"selectorBorderId","selector-border");let is=ls;class $o extends B{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.both);y(this,"toolsType",N.Arrow);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"arrowTipWidth");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=this.workId,{op:c,syncUnitTime:l}=t;l&&(this.syncUnitTime=l);const u=c==null?void 0:c.length;if(!u||u<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new $(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let d;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:r,layer:f})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{...this.baseConsumeResult,type:x.DrawWork,dataType:F.Local,op:this.tmpPoints.map(g=>[...g.XY,0]).flat(1),isSync:!0,index:0}):{type:x.None}}const p=le(d,this.oldRect);return this.oldRect=d,{rect:p,...this.baseConsumeResult,type:x.DrawWork,dataType:F.Local}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=We(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:B.getCenterPos(i,t)}),{rect:i,...this.baseConsumeResult,type:x.FullWork,dataType:F.Local,ops:n,isSync:!0}}draw(e){const{workId:t,layer:i,isDrawEraserlines:o}=e,{strokeColor:n,thickness:r,zIndex:c,scale:l,rotate:u,translate:h,strokeType:d,eraserlines:p}=this.workOptions,f=i.worldPosition,g=i.worldScaling,{points:M,pos:S,rect:w,isTriangle:I,trianglePoints:k,trianglePos:T}=this.computDrawPoints(r),v=[w.x+w.w/2,w.y+w.h/2],P={pos:v,name:t,id:t,zIndex:c,anchor:[.5,.5],size:[w.w,w.h]};l&&(P.scale=l),u&&(P.rotate=u),h&&(P.translate=h);const C=new ce.Group(P),L={points:k,pos:[T[0]-v[0],T[1]-v[1]],fillColor:n,strokeColor:n,lineWidth:0,normalize:!1},O=new ce.Polyline(L);if(C.append(O),!I&&M&&S){const E={points:M,pos:[S[0]-v[0],S[1]-v[1]],fillColor:n,strokeColor:n,lineDash:d===te.Dotted&&!I?[1,r*2]:d===te.LongDotted&&!I?[r,r*2]:void 0,lineCap:d===te.Normal?void 0:"round",lineWidth:r,normalize:!1},j=new ce.Polyline(E);C.append(j)}p&&(this.scaleType=re.proportional,this.drawEraserlines({group:C,eraserlines:p,pos:v,layer:i},o)),this.replace(i,t,C);let R={x:Math.floor(w.x*g[0]+f[0]-B.SafeBorderPadding),y:Math.floor(w.y*g[1]+f[1]-B.SafeBorderPadding),w:Math.floor(w.w*g[0]+2*B.SafeBorderPadding),h:Math.floor(w.h*g[1]+2*B.SafeBorderPadding)};if(l||u||h){const E=C.getBoundingClientRect();R={x:Math.floor(E.x-B.SafeBorderPadding),y:Math.floor(E.y-B.SafeBorderPadding),w:Math.floor(E.width+B.SafeBorderPadding*2),h:Math.floor(E.height+B.SafeBorderPadding*2)}}return this.isDelete&&C.setAttribute("opacity",0),R}computDrawPoints(e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(e):this.computTrianglePoints()}computFullArrowPoints(e){const t=b.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),i=b.Per(t).mul(e/2),o=$.Sub(this.tmpPoints[0],i),n=$.Add(this.tmpPoints[0],i),r=b.Mul(t,this.arrowTipWidth),c=b.Sub(this.tmpPoints[1],r),l=$.Sub(c,i),u=$.Add(c,i),h=b.Per(t).mul(e*1.5),d=$.Sub(c,h),p=$.Add(c,h),f=[this.tmpPoints[0],c],g=[d,this.tmpPoints[1],p],M=[o,n,...g,l,u];return{trianglePoints:g.map(S=>$.Sub(S,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:f.map(S=>$.Sub(S,this.tmpPoints[0]).XY).flat(1),rect:fe(M),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const e=b.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),t=this.tmpPoints[1].distance(this.tmpPoints[0]),i=b.Per(e).mul(Math.floor(t*3/8)),o=$.Sub(this.tmpPoints[0],i),n=$.Add(this.tmpPoints[0],i),r=[o,this.tmpPoints[1],n];return{trianglePoints:r.map(c=>$.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:fe(r),isTriangle:!0}}updateTempPoints(e){const t=e.slice(-2),i=new $(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var l,u;const{op:t,isFullWork:i,workState:o=z.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new $(t[h],t[h+1],t[h+2]));const r=i?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:r,isDrawEraserlines:o===z.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:B.getCenterPos(c,r)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,u;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,strokeType:r}=i,c=o.get(t.name);return n&&(t.tagName==="GROUP"?t.children.forEach(h=>{h.setAttribute("strokeColor",n),h.getAttribute("fillColor")&&h.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),r&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=r),c&&o.setInfo(t.name,c),B.updateNodeOpt(e)}}class Ho extends B{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.all);y(this,"toolsType",N.Ellipse);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=this.workId,{op:c,syncUnitTime:l}=t;l&&(this.syncUnitTime=l);const u=c==null?void 0:c.length;if(!u||u<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new $(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};if(!o){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:x.DrawWork,dataType:F.Local,...this.baseConsumeResult,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0}):{type:x.None}}let d;if(o||n){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:r,layer:p,isDrawing:!0});const f=p.parent.parent,g={x:0,y:0,w:Math.floor(f.width),h:Math.floor(f.height)};if(hi(d,g)!==ft.outside){const S=le(d,this.oldRect);return this.oldRect=d,{rect:S,type:x.DrawWork,dataType:F.Local,...this.baseConsumeResult}}return{type:x.None}}return{type:x.None}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=We(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:i&&B.getCenterPos(i,t)}),{rect:i,type:x.FullWork,dataType:F.Local,...this.baseConsumeResult,ops:n,isSync:!0}}draw(e){const{workId:t,layer:i,isDrawing:o,isDrawEraserlines:n}=e,{strokeColor:r,fillColor:c,thickness:l,zIndex:u,scale:h,rotate:d,translate:p,strokeType:f,eraserlines:g}=this.workOptions,M=i.worldScaling,{radius:S,rect:w,pos:I}=this.computDrawPoints(l),k={closeType:"normal",radius:S,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:r,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:f===te.Dotted?[1,l*2]:f===te.LongDotted?[l,l*2]:void 0},T={name:t,id:t,zIndex:u,pos:I,anchor:[.5,.5],size:[w.w,w.h]};h&&(T.scale=h),d&&(T.rotate=d),p&&(T.translate=p);const v=new ce.Group(T);if(o){const L=new ce.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:r,lineWidth:1,scale:[1/M[0],1/M[1]]});v.append(L)}const P=new ce.Ellipse({...k,pos:[0,0]});v.append(P),g&&(this.scaleType=re.proportional,this.drawEraserlines({group:v,eraserlines:g,pos:I,layer:i},n)),this.replace(i,t,v);const C=v.getBoundingClientRect();return this.isDelete&&v.setAttribute("opacity",0),{x:Math.floor(C.x-B.SafeBorderPadding),y:Math.floor(C.y-B.SafeBorderPadding),w:Math.floor(C.width+B.SafeBorderPadding*2),h:Math.floor(C.height+B.SafeBorderPadding*2)}}computDrawPoints(e){const t=fe(this.tmpPoints),i=fe(this.tmpPoints,e),o=[Math.floor(t.x+t.w/2),Math.floor(t.y+t.h/2)];return{rect:i,pos:o,radius:[Math.floor(t.w/2),Math.floor(t.h/2)]}}updateTempPoints(e){const t=e.slice(-2),i=new $(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var l,u;const{op:t,isFullWork:i,workState:o=z.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new $(t[h],t[h+1],t[h+2]));const r=i?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:r,isDrawing:!1,isDrawEraserlines:o===z.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:B.getCenterPos(c,r)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var h,d,p;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,fillColor:r,strokeType:c}=i,l=o.get(t.name);let u=t;return t.tagName==="GROUP"&&(u=t.children[0]),n&&(u.setAttribute("strokeColor",n),(h=l==null?void 0:l.opt)!=null&&h.strokeColor&&(l.opt.strokeColor=n)),r&&(r==="transparent"?u.setAttribute("fillColor","rgba(0,0,0,0)"):u.setAttribute("fillColor",r),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=r)),c&&(l!=null&&l.opt)&&((p=l.opt)!=null&&p.strokeType)&&(l.opt.strokeType=c),l&&o.setInfo(t.name,l),B.updateNodeOpt(e)}}class Qo extends B{constructor(e){super(e);y(this,"canRotate",!0);y(this,"scaleType",re.all);y(this,"toolsType",N.Rectangle);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}transformData(){const e=fe(this.tmpPoints);return[[e.x,e.y,0],[e.x+e.w,e.y,0],[e.x+e.w,e.y+e.h,0],[e.x,e.y+e.h,0]]}computDrawPoints(e){const{thickness:t}=this.workOptions,i=[];for(const r of e)i.push(new b(...r));const o=fe(i,t),n=[o.x+o.w/2,o.y+o.h/2];return{rect:o,pos:n,points:i.map(r=>r.XY).flat(1)}}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=this.workId,{op:c}=t,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let u;if(this.tmpPoints.length===0?(this.tmpPoints=[new $(c[0],c[1])],u=!1):u=this.updateTempPoints(c),!u)return{type:x.None};const h=this.transformData();let d;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({ps:h,workId:r,layer:f,isDrawing:!0})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:F.Local,op:h.flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const p=le(d,this.oldRect);return this.oldRect=d,{rect:p,type:x.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var c;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.transformData(),i=this.fullLayer,o=this.draw({ps:t,workId:e,layer:i,isDrawing:!1});this.oldRect=o;const n=t.flat(1),r=We(n);return(c=this.vNodes)==null||c.setInfo(e,{rect:o,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&B.getCenterPos(o,i)}),{rect:o,type:x.FullWork,dataType:F.Local,ops:r,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:i,isDrawing:o,ps:n,replaceId:r,isDrawEraserlines:c=!0}=e,{strokeColor:l,fillColor:u,thickness:h,zIndex:d,scale:p,rotate:f,translate:g,strokeType:M,eraserlines:S}=this.workOptions,w=i.worldPosition,I=i.worldScaling,{points:k,rect:T,pos:v}=this.computDrawPoints(n),P={close:!0,normalize:!0,points:k,lineWidth:h,fillColor:u!=="transparent"&&u||void 0,strokeColor:l,lineJoin:"round",lineCap:"round",lineDash:M===te.Dotted?[1,h*2]:M===te.LongDotted?[h,h*2]:void 0};let C={x:Math.floor(T.x*I[0]+w[0]-B.SafeBorderPadding),y:Math.floor(T.y*I[1]+w[1]-B.SafeBorderPadding),w:Math.floor(T.w*I[0]+2*B.SafeBorderPadding),h:Math.floor(T.h*I[0]+2*B.SafeBorderPadding)};const L=new ce.Group({name:t,id:t,zIndex:d,pos:v,anchor:[.5,.5],size:[T.w,T.h],scale:p,rotate:f,translate:g}),O=new ce.Polyline({...P,pos:[0,0]});if(L.appendChild(O),o){const R=new ce.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:l,lineWidth:1,scale:[1/I[0],1/I[1]]});L.appendChild(R)}if(S&&(this.scaleType=re.proportional,this.drawEraserlines({group:L,eraserlines:S,pos:v,layer:i},c)),this.replace(i,r||t,L),p||f||g){const R=L.getBoundingClientRect();C={x:Math.floor(R.x-B.SafeBorderPadding),y:Math.floor(R.y-B.SafeBorderPadding),w:Math.floor(R.width+2*B.SafeBorderPadding),h:Math.floor(R.height+2*B.SafeBorderPadding)}}return this.isDelete&&L.setAttribute("opacity",0),C}updateTempPoints(e){const t=e.slice(-2),i=new $(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var h,d;const{op:t,isFullWork:i,replaceId:o,workState:n=z.Done}=e,r=(h=this.workId)==null?void 0:h.toString();if(!r)return;const c=[];for(let p=0;p<t.length;p+=3)c.push([t[p],t[p+1],t[p+2]]);const l=i?this.fullLayer:this.drawLayer||this.fullLayer,u=this.draw({ps:c,workId:r,layer:l,isDrawing:!1,replaceId:o,isDrawEraserlines:n===z.Done});return this.oldRect=u,(d=this.vNodes)==null||d.setInfo(r,{rect:u,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:u&&B.getCenterPos(u,l)}),u}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var h,d,p;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,fillColor:r,strokeType:c}=i,l=o.get(t.name);let u=t;return t.tagName==="GROUP"&&(u=t.children[0]),n&&(u.setAttribute("strokeColor",n),(h=l==null?void 0:l.opt)!=null&&h.strokeColor&&(l.opt.strokeColor=n)),r&&(r==="transparent"?u.setAttribute("fillColor","rgba(0,0,0,0)"):u.setAttribute("fillColor",r),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=r)),c&&(l!=null&&l.opt)&&((p=l.opt)!=null&&p.strokeType)&&(l.opt.strokeType=c),l&&o.setInfo(t.name,l),B.updateNodeOpt(e)}}class Go extends B{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.all);y(this,"toolsType",N.Star);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=this.workId,{op:c,syncUnitTime:l}=t,u=c==null?void 0:c.length;if(!u||u<2)return{type:x.None};l&&(this.syncUnitTime=l);let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new $(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let d;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:r,layer:f,isDrawing:!0})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:F.Local,op:this.tmpPoints.map(g=>[...g.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const p=le(d,this.oldRect);return this.oldRect=d,{rect:p,type:x.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=We(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&B.getCenterPos(i,t)}),{rect:i,type:x.FullWork,dataType:F.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:i,isDrawing:o,isDrawEraserlines:n=!0}=e,{strokeColor:r,fillColor:c,thickness:l,zIndex:u,vertices:h,innerVerticeStep:d,innerRatio:p,scale:f,rotate:g,translate:M,strokeType:S,eraserlines:w}=this.workOptions,I=i.worldScaling,{rect:k,pos:T,points:v}=this.computDrawPoints(l,h,d,p),P={close:!0,points:v,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:r,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:S===te.Dotted?[1,l*2]:S===te.LongDotted?[l,l*2]:void 0},C={name:t,id:t,zIndex:u,pos:T,anchor:[.5,.5],size:[k.w,k.h]};f&&(C.scale=f),g&&(C.rotate=g),M&&(C.translate=M);const L=new ce.Group(C);if(o){const E=new ce.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:r,lineWidth:1,scale:[1/I[0],1/I[1]]});L.append(E)}const O=new ce.Polyline({...P,pos:[0,0]});L.append(O),w&&(this.scaleType=re.proportional,this.drawEraserlines({group:L,eraserlines:w,pos:T,layer:i},n)),this.replace(i,t,L);const R=L.getBoundingClientRect();return this.isDelete&&L.setAttribute("opacity",0),{x:Math.floor(R.x-B.SafeBorderPadding),y:Math.floor(R.y-B.SafeBorderPadding),w:Math.floor(R.width+B.SafeBorderPadding*2),h:Math.floor(R.height+B.SafeBorderPadding*2)}}computDrawPoints(e,t,i,o){const n=fe(this.tmpPoints),r=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],c=cn(n.w,n.h),l=Math.floor(Math.min(n.w,n.h)/2),u=o*l,h=[],d=2*Math.PI/t;for(let f=0;f<t;f++){const g=f*d-.5*Math.PI;let M,S;f%i===1?(M=u*c[0]*Math.cos(g),S=u*c[1]*Math.sin(g)):(M=l*c[0]*Math.cos(g),S=l*c[1]*Math.sin(g),h.push(M,S)),h.push(M,S)}return{rect:fe(this.tmpPoints,e),pos:r,points:h}}updateTempPoints(e){const t=e.slice(-2),i=new $(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n)||$.Sub(o,i).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var l,u;const{op:t,isFullWork:i,workState:o=z.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new $(t[h],t[h+1],t[h+2]));const r=i?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:r,isDrawing:!1,isDrawEraserlines:o===z.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&B.getCenterPos(c,r)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var M;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,fillColor:r,toolsType:c,vertices:l,innerVerticeStep:u,innerRatio:h,strokeType:d}=i,p=o.get(t.name),f=p==null?void 0:p.opt;let g=t;return t.tagName==="GROUP"&&(g=t.children[0]),n&&(g.setAttribute("strokeColor",n),f!=null&&f.strokeColor&&(f.strokeColor=n)),r&&(r==="transparent"?g.setAttribute("fillColor","rgba(0,0,0,0)"):g.setAttribute("fillColor",r),f!=null&&f.fillColor&&(f.fillColor=r)),c===N.Star&&(l&&(f.vertices=l),u&&(f.innerVerticeStep=u),h&&(f.innerRatio=h)),d&&(p!=null&&p.opt)&&((M=p.opt)!=null&&M.strokeType)&&(p.opt.strokeType=d),p&&o.setInfo(t.name,{...p,opt:f}),B.updateNodeOpt(e)}}class Zo extends B{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.all);y(this,"toolsType",N.Polygon);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,{op:r,syncUnitTime:c}=t;c&&(this.syncUnitTime=c);const l=this.workId,u=r==null?void 0:r.length;if(!u||u<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new $(r[0],r[1])],h=!1):h=this.updateTempPoints(r),!h)return{type:x.None};let d;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:l,layer:f,isDrawing:!0})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:F.Local,op:this.tmpPoints.map(g=>[...g.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const p=le(d,this.oldRect);return this.oldRect=d,{rect:p,type:x.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=We(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&B.getCenterPos(i,t)}),{rect:i,type:x.FullWork,dataType:F.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:i,isDrawing:o,isDrawEraserlines:n=!0}=e,{strokeColor:r,fillColor:c,thickness:l,zIndex:u,vertices:h,scale:d,rotate:p,translate:f,strokeType:g,eraserlines:M}=this.workOptions,S=i.worldScaling,{rect:w,pos:I,points:k}=this.computDrawPoints(l,h),T={close:!0,points:k,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:r,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:g===te.Dotted?[1,l*2]:g===te.LongDotted?[l,l*2]:void 0},v={name:t,id:t,zIndex:u,pos:I,anchor:[.5,.5],size:[w.w,w.h]};d&&(v.scale=d),p&&(v.rotate=p),f&&(v.translate=f);const P=new ce.Group(v);if(o){const O=new ce.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:r,lineWidth:1,scale:[1/S[0],1/S[1]]});P.append(O)}const C=new ce.Polyline({...T,pos:[0,0]});P.append(C),M&&(this.scaleType=re.proportional,this.drawEraserlines({group:P,eraserlines:M,pos:I,layer:i},n)),this.replace(i,t,P);const L=P.getBoundingClientRect();return this.isDelete&&P.setAttribute("opacity",0),{x:Math.floor(L.x-B.SafeBorderPadding),y:Math.floor(L.y-B.SafeBorderPadding),w:Math.floor(L.width+B.SafeBorderPadding*2),h:Math.floor(L.height+B.SafeBorderPadding*2)}}computDrawPoints(e,t){const i=fe(this.tmpPoints),o=[Math.floor(i.x+i.w/2),Math.floor(i.y+i.h/2)],n=cn(i.w,i.h),r=Math.floor(Math.min(i.w,i.h)/2),c=[],l=2*Math.PI/t;for(let h=0;h<t;h++){const d=h*l-.5*Math.PI,p=r*n[0]*Math.cos(d),f=r*n[1]*Math.sin(d);c.push(p,f)}return{rect:fe(this.tmpPoints,e),pos:o,points:c}}updateTempPoints(e){const t=e.slice(-2),i=new $(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n)||$.Sub(o,i).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var l,u;const{op:t,isFullWork:i,workState:o=z.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new $(t[h],t[h+1],t[h+2]));const r=i?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:r,isDrawing:!1,isDrawEraserlines:o===z.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&B.getCenterPos(c,r)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var f;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,fillColor:r,toolsType:c,vertices:l,strokeType:u}=i,h=o.get(t.name),d=h==null?void 0:h.opt;let p=t;return t.tagName==="GROUP"&&(p=t.children[0]),n&&(p.setAttribute("strokeColor",n),d!=null&&d.strokeColor&&(d.strokeColor=n)),r&&(r==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",r),d!=null&&d.fillColor&&(d.fillColor=r)),c===N.Polygon&&l&&(d.vertices=l),u&&(h!=null&&h.opt)&&((f=h.opt)!=null&&f.strokeType)&&(h.opt.strokeType=u),h&&o.setInfo(t.name,{...h,opt:d}),B.updateNodeOpt(e)}}class He{static bezier(s,e){const t=[];for(let i=0;i<e.length;i+=4){const o=e[i],n=e[i+1],r=e[i+2],c=e[i+3];o&&n&&r&&c?t.push(...He.getBezierPoints(s,o,n,r,c)):o&&n&&r?t.push(...He.getBezierPoints(s,o,n,r)):o&&n?t.push(...He.getBezierPoints(s,o,n)):o&&t.push(o)}return t}static getBezierPoints(s=10,e,t,i,o){let n=null;const r=[];!i&&!o?n=He.oneBezier:i&&!o?n=He.twoBezier:i&&o&&(n=He.threeBezier);for(let c=0;c<s;c++)n&&r.push(n(c/s,e,t,i,o));return o?r.push(o):i&&r.push(i),r}static oneBezier(s,e,t){const i=e.x+(t.x-e.x)*s,o=e.y+(t.y-e.y)*s;return new b(i,o)}static twoBezier(s,e,t,i){const o=(1-s)*(1-s)*e.x+2*s*(1-s)*t.x+s*s*i.x,n=(1-s)*(1-s)*e.y+2*s*(1-s)*t.y+s*s*i.y;return new b(o,n)}static threeBezier(s,e,t,i,o){const n=e.x*(1-s)*(1-s)*(1-s)+3*t.x*s*(1-s)*(1-s)+3*i.x*s*s*(1-s)+o.x*s*s*s,r=e.y*(1-s)*(1-s)*(1-s)+3*t.y*s*(1-s)*(1-s)+3*i.y*s*s*(1-s)+o.y*s*s*s;return new b(n,r)}}class qo extends B{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.all);y(this,"toolsType",N.SpeechBalloon);y(this,"ratio",.8);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){var p;const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=(p=t==null?void 0:t.workId)==null?void 0:p.toString();if(!r)return{type:x.None};const{op:c}=t,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let u;if(this.tmpPoints.length===0?(this.tmpPoints=[new $(c[0],c[1])],u=!1):u=this.updateTempPoints(c),!u)return{type:x.None};let h;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;h=this.draw({workId:r,layer:f,isDrawing:!0})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:F.Local,op:this.tmpPoints.map(g=>[...g.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const d=le(h,this.oldRect);return this.oldRect=h,{rect:d,type:x.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=We(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&B.getCenterPos(i,t)}),{rect:i,type:x.FullWork,dataType:F.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:i,isDrawEraserlines:o=!0}=e,{strokeColor:n,fillColor:r,thickness:c,zIndex:l,placement:u,scale:h,rotate:d,translate:p,strokeType:f,eraserlines:g}=this.workOptions,{rect:M,pos:S,points:w}=this.computDrawPoints(c,u),I={points:w.map(C=>C.XY),lineWidth:c,fillColor:r!=="transparent"&&r||void 0,strokeColor:n,normalize:!0,className:`${S[0]},${S[1]}`,close:!0,lineJoin:"round",lineCap:"round",lineDash:f===te.Dotted?[1,c*2]:f===te.LongDotted?[c,c*2]:void 0},k={name:t,id:t,zIndex:l,pos:S,anchor:[.5,.5],size:[M.w,M.h]};h&&(k.scale=h),d&&(k.rotate=d),p&&(k.translate=p);const T=new ce.Group(k),v=new ce.Polyline({...I,pos:[0,0]});T.append(v),g&&(this.scaleType=re.proportional,this.drawEraserlines({group:T,eraserlines:g,pos:S,layer:i},o)),this.replace(i,t,T);const P=T.getBoundingClientRect();return this.isDelete&&T.setAttribute("opacity",0),{x:Math.floor(P.x-B.SafeBorderPadding),y:Math.floor(P.y-B.SafeBorderPadding),w:Math.floor(P.width+B.SafeBorderPadding*2),h:Math.floor(P.height+B.SafeBorderPadding*2)}}transformControlPoints(e){const t=fe(this.tmpPoints);switch(e){case"bottom":case"bottomLeft":case"bottomRight":{const i=t.y+t.h*this.ratio;return[new b(t.x,t.y,0),new b(t.x+t.w,t.y,0),new b(t.x+t.w,i,0),new b(t.x,i,0)]}case"top":case"topLeft":case"topRight":{const i=t.y+t.h*(1-this.ratio);return[new b(t.x,i,0),new b(t.x+t.w,i,0),new b(t.x+t.w,t.y+t.h,0),new b(t.x,t.y+t.h,0)]}case"left":case"leftBottom":case"leftTop":{const i=t.x+t.w*(1-this.ratio);return[new b(i,t.y,0),new b(t.x+t.w,t.y,0),new b(t.x+t.w,t.y+t.h,0),new b(i,t.y+t.h,0)]}case"right":case"rightBottom":case"rightTop":{const i=t.x+t.w*this.ratio;return[new b(t.x,t.y,0),new b(i,t.y,0),new b(i,t.y+t.h,0),new b(t.x,t.y+t.h,0)]}}}computDrawPoints(e,t){const i=fe(this.tmpPoints),o=this.transformControlPoints(t),n=Math.floor(i.w*.1),r=Math.floor(i.h*.1),c=[],l=b.Add(o[0],new b(0,r,0)),u=b.Add(o[0],new b(n,0,0)),h=He.getBezierPoints(10,l,o[0],u),d=b.Sub(o[1],new b(n,0,0)),p=b.Add(o[1],new b(0,r,0)),f=He.getBezierPoints(10,d,o[1],p),g=b.Sub(o[2],new b(0,r,0)),M=b.Sub(o[2],new b(n,0,0)),S=He.getBezierPoints(10,g,o[2],M),w=b.Add(o[3],new b(n,0,0)),I=b.Sub(o[3],new b(0,r,0)),k=He.getBezierPoints(10,w,o[3],I),T=n*(1-this.ratio)*10,v=r*(1-this.ratio)*10;switch(t){case"bottom":{const L=b.Sub(o[2],new b(n*5-T/2,0,0)),O=b.Sub(o[2],new b(n*5,-v,0)),R=b.Sub(o[2],new b(n*5+T/2,0,0));c.push(O,R,...k,...h,...f,...S,L);break}case"bottomRight":{const L=b.Sub(o[2],new b(n*1.1,0,0)),O=b.Sub(o[2],new b(n*1.1+T/2,-v,0)),R=b.Sub(o[2],new b(n*1.1+T,0,0));c.push(O,R,...k,...h,...f,...S,L);break}case"bottomLeft":{const L=b.Add(o[3],new b(n*1.1+T,0,0)),O=b.Add(o[3],new b(n*1.1+T/2,v,0)),R=b.Add(o[3],new b(n*1.1,0,0));c.push(O,R,...k,...h,...f,...S,L);break}case"top":{const L=b.Sub(o[1],new b(n*5-T/2,0,0)),O=b.Sub(o[1],new b(n*5,v,0)),R=b.Sub(o[1],new b(n*5+T/2,0,0));c.push(O,L,...f,...S,...k,...h,R);break}case"topRight":{const L=b.Sub(o[1],new b(n*1.1,0,0)),O=b.Sub(o[1],new b(n*1.1+T/2,v,0)),R=b.Sub(o[1],new b(n*1.1+T,0,0));c.push(O,L,...f,...S,...k,...h,R);break}case"topLeft":{const L=b.Add(o[0],new b(n*1.1+T,0,0)),O=b.Add(o[0],new b(n*1.1+T/2,-v,0)),R=b.Add(o[0],new b(n*1.1,0,0));c.push(O,L,...f,...S,...k,...h,R);break}case"left":{const L=b.Add(o[0],new b(0,r*5-v/2,0)),O=b.Add(o[0],new b(-T,r*5,0)),R=b.Add(o[0],new b(0,r*5+v/2,0));c.push(O,L,...h,...f,...S,...k,R);break}case"leftTop":{const L=b.Add(o[0],new b(0,r*1.1,0)),O=b.Add(o[0],new b(-T,r*1.1+v/2,0)),R=b.Add(o[0],new b(0,r*1.1+v,0));c.push(O,L,...h,...f,...S,...k,R);break}case"leftBottom":{const L=b.Sub(o[3],new b(0,r*1.1+v,0)),O=b.Sub(o[3],new b(T,r*1.1+v/2,0)),R=b.Sub(o[3],new b(0,r*1.1,0));c.push(O,L,...h,...f,...S,...k,R);break}case"right":{const L=b.Add(o[1],new b(0,r*5-v/2,0)),O=b.Add(o[1],new b(T,r*5,0)),R=b.Add(o[1],new b(0,r*5+v/2,0));c.push(O,R,...S,...k,...h,...f,L);break}case"rightTop":{const L=b.Add(o[1],new b(0,r*1.1,0)),O=b.Add(o[1],new b(T,r*1.1+v/2,0)),R=b.Add(o[1],new b(0,r*1.1+v,0));c.push(O,R,...S,...k,...h,...f,L);break}case"rightBottom":{const L=b.Sub(o[2],new b(0,r*1.1+v,0)),O=b.Sub(o[2],new b(-T,r*1.1+v/2,0)),R=b.Sub(o[2],new b(0,r*1.1,0));c.push(O,R,...S,...k,...h,...f,L);break}}const P=fe(this.tmpPoints,e),C=[Math.floor(P.x+P.w/2),Math.floor(P.y+P.h/2)];return{rect:P,pos:C,points:c}}updateTempPoints(e){const t=e.slice(-2),i=new $(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n)||$.Sub(o,i).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var l,u;const{op:t,isFullWork:i,workState:o=z.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new $(t[h],t[h+1],t[h+2]));const r=i?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:r,isDrawing:!1,isDrawEraserlines:o===z.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&B.getCenterPos(c,r)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var f;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,fillColor:r,toolsType:c,placement:l,strokeType:u}=i,h=o.get(t.name),d=h==null?void 0:h.opt;let p=t;return t.tagName==="GROUP"&&(p=t.children[0]),n&&(p.setAttribute("strokeColor",n),d!=null&&d.strokeColor&&(d.strokeColor=n)),r&&(r==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",r),d!=null&&d.fillColor&&(d.fillColor=r)),c===N.SpeechBalloon&&l&&(d.placement=l),u&&(h!=null&&h.opt)&&((f=h.opt)!=null&&f.strokeType)&&(h.opt.strokeType=u),h&&o.setInfo(t.name,{...h,opt:d}),B.updateNodeOpt(e)}}var ng=yt,rg=Ke,ag="[object Boolean]";function cg(a){return a===!0||a===!1||rg(a)&&ng(a)==ag}var lg=cg;const Tt=Pt(lg);class Xo extends B{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.both);y(this,"toolsType",N.Straight);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"straightTipWidth");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=this.workId,{op:c,syncUnitTime:l}=t,u=c==null?void 0:c.length;if(!u||u<2)return{type:x.None};l&&(this.syncUnitTime=l);let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new $(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let d;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:r,layer:f})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:F.Local,op:this.tmpPoints.map(g=>[...g.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const p=le(d,this.oldRect);return this.oldRect=d,{rect:p,type:x.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=We(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&B.getCenterPos(i,t)}),{rect:i,type:x.FullWork,dataType:F.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:i,isDrawEraserlines:o=!0}=e,{strokeColor:n,thickness:r,zIndex:c,scale:l,rotate:u,translate:h,strokeType:d,eraserlines:p}=this.workOptions,f=i.worldPosition,g=i.worldScaling,{d:M,rect:S,isDot:w}=this.computDrawPoints(r,d),I=[S.x+S.w/2,S.y+S.h/2],k=new ce.Group({pos:I,anchor:[.5,.5],size:[S.w,S.h],name:t,id:t,normalize:!0,zIndex:c}),T={pos:[0,0],normalize:!0,d:M,fillColor:n,strokeColor:n,lineDash:d===te.Dotted&&!w?[1,r*2]:d===te.LongDotted&&!w?[r,r*2]:void 0,lineCap:d===te.Normal||w?void 0:"round",lineWidth:d===te.Normal||w?0:r};l&&(T.scale=l),u&&(T.rotate=u),h&&(T.translate=h);const v=new ce.Path(T);k.append(v),p&&(this.scaleType=re.proportional,this.drawEraserlines({group:k,eraserlines:p,pos:I,layer:i},o)),this.replace(i,t,k);let P={x:Math.floor(S.x*g[0]+f[0]-B.SafeBorderPadding),y:Math.floor(S.y*g[1]+f[1]-B.SafeBorderPadding),w:Math.floor(S.w*g[0]+2*B.SafeBorderPadding),h:Math.floor(S.h*g[1]+2*B.SafeBorderPadding)};if(u||l||h){const C=v.getBoundingClientRect();P={x:Math.floor(C.x-B.SafeBorderPadding),y:Math.floor(C.y-B.SafeBorderPadding),w:Math.floor(C.width+B.SafeBorderPadding*2),h:Math.floor(C.height+B.SafeBorderPadding*2)}}return this.isDelete&&k.setAttribute("opacity",0),P}computDrawPoints(e,t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(e,t):this.computDotPoints(e)}computFullPoints(e,t){const i=b.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),o=b.Per(i).mul(e/2),n=$.Sub(this.tmpPoints[0],o),r=$.Add(this.tmpPoints[0],o),c=$.Sub(this.tmpPoints[1],o),l=$.Add(this.tmpPoints[1],o),u=$.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),h=$.GetSemicircleStroke(this.tmpPoints[0],r,-1,8),d=[n,c,...u,l,r,...h];let p;return t!==te.Normal?p=Xe(this.tmpPoints,!1):p=Xe(d,!0),{d:p,rect:fe(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(e){const t=$.GetDotStroke(this.tmpPoints[0],e/2,8);return{d:Xe(t,!0),rect:fe(t),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(e){const t=e.slice(-2),i=new $(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var l,u;const{op:t,isFullWork:i,workState:o=z.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new $(t[h],t[h+1],t[h+2]));const r=i?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:r,isDrawEraserlines:o===z.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&B.getCenterPos(c,r)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,u;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,strokeType:r}=i,c=o.get(t.name);return n&&(t.tagName==="GROUP"?t.children.forEach(h=>{h.setAttribute("strokeColor",n),h.getAttribute("fillColor")&&h.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),r&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=r),c&&o.setInfo(t.name,c),B.updateNodeOpt(e)}}const at=class at extends B{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.proportional);y(this,"toolsType",N.Text);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");this.workOptions=e.toolsOpt}consume(){return{type:x.None}}consumeAll(){return{type:x.None}}consumeService(){}async draw(e){const{workId:t,layer:i,isDrawLabel:o}=e,{boxSize:n,boxPoint:r,zIndex:c}=this.workOptions,l=i.worldPosition,u=i.worldScaling;if(!r||!n)return;const h={name:t,id:t,pos:[r[0],r[1]],anchor:[0,0],size:n,zIndex:c},d=new ce.Group(h),p={x:r[0],y:r[1],w:n[0],h:n[1]},f={x:Math.floor(p.x*u[0]+l[0]),y:Math.floor(p.y*u[1]+l[1]),w:Math.floor(p.w*u[0])+2,h:Math.floor(p.h*u[1])+2};if(this.replace(i,t,d),o&&i&&this.workOptions.text){const g=await at.createLabels(this.workOptions,i,f),{labels:M,maxWidth:S}=g;d.append(...M),f.w=Math.ceil(Math.max(S*i.worldScaling[0],f.w))}return f}async consumeServiceAsync(e){var l,u,h,d;const t=(l=this.workId)==null?void 0:l.toString();if(!t)return;const{isFullWork:i,replaceId:o,isDrawLabel:n}=e;this.oldRect=o&&((h=(u=this.vNodes)==null?void 0:u.get(o))==null?void 0:h.rect)||void 0;const r=i?this.fullLayer:this.drawLayer||this.fullLayer,c=await this.draw({workId:t,layer:r,isDrawLabel:typeof n>"u"&&this.workOptions.workState===z.Done||n});return(d=this.vNodes)==null||d.setInfo(t,{rect:c,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&B.getCenterPos(c,r)}),c}updataOptService(){}async updataOptServiceAsync(e,t){var f,g;if(!this.workId)return;const i=this.workId.toString(),{fontColor:o,fontBgColor:n,bold:r,italic:c,lineThrough:l,underline:u,zIndex:h}=e,d=(f=this.vNodes)==null?void 0:f.get(i);if(!d)return;o&&(d.opt.fontColor=o),n&&(d.opt.fontBgColor=n),r&&(d.opt.bold=r),c&&(d.opt.italic=c),Tt(l)&&(d.opt.lineThrough=l),Tt(u)&&(d.opt.underline=u),be(h)&&(d.opt.zIndex=h),this.oldRect=d.rect;const p=await this.draw({workId:i,layer:this.fullLayer,isDrawLabel:typeof t>"u"&&this.workOptions.workState===z.Done||t});return(g=this.vNodes)==null||g.setInfo(i,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&B.getCenterPos(p,this.fullLayer)}),p}clearTmpPoints(){this.tmpPoints.length=0}static getSafetySnippetRatio(e){const t=(e==null?void 0:e.parent).displayRatio||1,i=Math.ceil(e.worldScaling[0]*10)/10;let o=i;return i>=.2&&i<1?o=i*t:i<=2&&i>=1?o=i*t*1.6:i>2&&i<=3?o=i*t*1.4:i>3&&i<=4?o=i*t*.8:i>4&&(o=i*t*.6),Math.floor(o*1e3)/1e3}static getSafetySnippetFontLength(e){return Math.floor(at.textImageSnippetSize*3/4/e)||1}static async createLabels(e,t,i){var R;const o=[],{x:n,y:r}=i,{width:c,height:l}=(R=t.parent)==null?void 0:R.parent,u=lt(e.text),h=u.length,{fontSize:d,lineHeight:p,bold:f,textAlign:g,italic:M,fontFamily:S,verticalAlign:w,fontColor:I,fontBgColor:k,underline:T,lineThrough:v}=e,P=at.getSafetySnippetRatio(t)||1,C=Math.floor(d*P),L=at.getSafetySnippetFontLength(C);let O=0;for(let E=0;E<h;E++){const j=u[E],D=p||C*1.5;if(j){const q=om(j),oe=[0,0],X=[0,d*1.2];w==="middle"&&(oe[1]=E*d*1.2+5);const Z=[0,-d*.15];oe[0]=5;const _=Math.sin(Math.PI/180*20);let Q=0;const J=[];let K=0;for(;K<q;){g==="left"&&(Z[0]=Q),K===0&&M==="italic"&&(Z[0]=Z[0]-_/2*d);const Se=j.slice(K,K+L),Ae={anchor:[0,0],pos:Z,text:Se,fontFamily:S,fontSize:C,lineHeight:D,strokeColor:I,fontWeight:f,fillColor:I,textAlign:g,fontStyle:M,scale:[1/P,1/P]},ve=new ce.Label(Ae),U=await ve.textImageReady;let ae=!0;if(U){const ee=U.rect&&U.rect[2],de=U.rect&&U.rect[3];if(ee&&de){const ue=ee/P,ge=de/P;Q=ue+Q,M==="italic"&&(f==="bold"?Q=Q-_*d*1.2:Q=Q-_*d),((Z[0]+oe[0]+ue)*t.worldScaling[0]+n<=0||(Z[0]+oe[0])*t.worldScaling[0]+n>=c||(Z[1]+oe[1]+ge)*t.worldScaling[1]+r<=0||(Z[1]+oe[1])*t.worldScaling[1]+r>=l)&&(ve.disconnect(),ae=!1),ae&&J.push(ve)}}K+=L}X[0]=Q,M==="italic"&&(X[0]=X[0]+_*d),O=Math.max(O,X[0]);let he=!0;if(((oe[0]+X[0])*t.worldScaling[0]+n<=0||oe[0]*t.worldScaling[0]+n>=c||(oe[1]+X[1])*t.worldScaling[0]+r<=0||oe[1]*t.worldScaling[1]+r>=l)&&(he=!1),he){if(T){const ve=Math.floor(d/10),U={normalize:!1,pos:[0,d*1.1+ve/2],lineWidth:ve,points:[0,0,Math.ceil(X[0]),0],strokeColor:I,className:"underline"},ae=new ce.Polyline(U);J.push(ae)}if(v){const ve={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(X[0]),0],strokeColor:I,className:"lineThrough"},U=new ce.Polyline(ve);J.push(U)}const Se={pos:oe,anchor:[0,0],size:X,bgcolor:k},Ae=new ce.Group(Se);Ae.append(...J),o.push(Ae)}}}return{labels:o,maxWidth:O}}static updateNodeOpt(e){const{node:t,opt:i,vNodes:o,targetNode:n}=e,{fontBgColor:r,fontColor:c,translate:l,originPoint:u,scenePoint:h,scale:d,bold:p,italic:f,lineThrough:g,underline:M,fontSize:S,textInfos:w,zIndex:I}=i,k=n&&Ce(n)||o.get(t.name);if(!k||!t.parent)return;const v=k.opt;if(be(I)&&(t.setAttribute("zIndex",I),k.opt.zIndex=I),c&&v.fontColor&&(v.fontColor=c,t.children.forEach(P=>{P.tagName==="GROUP"&&P.children.forEach(C=>{C.tagName==="LABEL"?(C.setAttribute("fillColor",c),C.setAttribute("strokeColor",c)):C.tagName==="POLYLINE"&&C.setAttribute("strokeColor",c)})})),r&&v.fontBgColor&&(v.fontBgColor=r,t.children.forEach(P=>{P.tagName==="GROUP"&&P.setAttribute("bgcolor",r)})),p&&(v.bold=p),f&&(v.italic=f),Tt(g)&&(v.lineThrough=g),Tt(M)&&(v.underline=M),S&&(v.fontSize=S),u&&h&&d&&n&&v.boxPoint){const P=w==null?void 0:w.get(t.name);if(P){const{fontSize:R,boxSize:E}=P;v.boxSize=E||v.boxSize,v.fontSize=R||v.fontSize}const C=[v.boxPoint[0],v.boxPoint[1]];ci(v.boxPoint,h,d,l);const L=[k.op[0],k.op[1]],O=[L[0]-C[0],L[1]-C[1]];if(k.centerPos=[k.centerPos[0]+O[0],k.centerPos[1]+O[1]],k.opt.eraserlines)for(const R of Object.values(k.opt.eraserlines)){const{op:E,thickness:j}=R;R.thickness=j*Math.max(d[0],d[1]);for(let D=0;D<E.length;D++)li(E[D],h,d,l)}}else if(l&&v.boxPoint&&(v.boxPoint=[v.boxPoint[0]+l[0],v.boxPoint[1]+l[1]],k.centerPos=[k.centerPos[0]+l[0],k.centerPos[1]+l[1]],k.opt.eraserlines))for(const P of Object.values(k.opt.eraserlines)){const{op:C}=P;for(let L=0;L<C.length;L++){const O=C[L].map((R,E)=>E%2?R+l[1]:R+l[0]);P.op[L]=O}}return k&&o.setInfo(t.name,k),k==null?void 0:k.rect}static getRectFromLayer(e,t){const i=e.getElementsByName(t)[0];if(i){const o=i.getBoundingClientRect();let n={x:Math.floor(o.x),y:Math.floor(o.y),w:Math.floor(o.width+2),h:Math.floor(o.height+2)};return i.children.forEach(r=>{if(r.tagName==="GROUP"){const c=i.getBoundingClientRect();n=le(n,{x:Math.floor(c.x),y:Math.floor(c.y),w:Math.floor(c.width+2),h:Math.floor(c.height+2)})}}),n}}};y(at,"textImageSnippetSize",1024*4),y(at,"SafeBorderPadding",30);let os=at;const Nt=class Nt extends B{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.none);y(this,"toolsType",N.PencilEraser);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"worldPosition");y(this,"worldScaling");y(this,"eraserRect");y(this,"eraserPolyline");y(this,"syncUnitTime",we.syncOpt.interval);y(this,"syncIndex",0);y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling,this.syncTimestamp=0}combineConsume(){if(this.tmpPoints.length<2)return{type:x.None};const{thickness:e}=this.workOptions,{width:t,height:i}=Nt.eraserSizes[e],o=Math.max(t,i)/this.worldScaling[0],n=this.drawLayer||this.fullLayer,r=this.workId,c={name:r};return{rect:this.draw({attrs:c,consumePoints:this.tmpPoints,replaceId:r,layer:n,thickness:o}),type:x.DrawWork,dataType:F.Local}}consumeService(e){const{op:t,isFullWork:i,replaceId:o}=e;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3){const d=new $(t[h],t[h+1],t[h+2]);if(this.tmpPoints.length>0){const p=this.tmpPoints[this.tmpPoints.length-1],f=b.Sub(d,p).uni();d.setv(f)}this.tmpPoints.push(d)}if(this.tmpPoints.length<2)return;const n=this.tmpPoints[0].z*2,r=i?this.fullLayer:this.drawLayer||this.fullLayer,l={name:this.workId};return this.draw({attrs:l,consumePoints:this.tmpPoints,layer:r,thickness:n,replaceId:o})}updateTempPoints(e,t){let i=this.tmpPoints.length-1;const o=Date.now();for(let n=0;n<e.length;n+=2){const r=this.tmpPoints.length,c=new $(e[n],e[n+1]);if(r===0){this.tmpPoints.push(c);continue}const l=r-1,u=this.tmpPoints[l],h=b.Sub(c,u).uni();c.isNear(u,t/2)||(b.Equals(h,u.v,.02)&&(this.tmpPoints.pop(),i--),c.setv(h),c.setT(o),this.tmpPoints.push(c))}return Math.max(i,0)}getChangeNodes(e,t){const i=new Map,o=new Set;let n;if(!this.vNodes)return{willDeleteNodes:o,willNewNodes:i,rect:n};const r=this.worldPosition;let c=fe(this.tmpPoints,e);c=Ft(c,r),c=rn(c,this.worldScaling,r);const{nodeRange:l}=this.vNodes.getRectIntersectRange(c);if(!l.size)return{willDeleteNodes:o,willNewNodes:i,rect:n};const u=this.computEraserPointLines(this.tmpPoints,90);for(const[h,d]of l.entries()){if(d.toolsType!==N.Pencil)continue;let p=Ft(d.rect,[-r[0],-r[1]]);p={x:p.x/this.worldScaling[0],y:p.y/this.worldScaling[1],w:p.w/this.worldScaling[0],h:p.h/this.worldScaling[1]};const f=[p.x,p.y,p.x+p.w,p.y+p.h],g=[],M=[];for(const S of u)Vs.polyline(S,f,g);if(g.length&&d.opt)for(const S of g){const w=[];for(let I=0;I<S.length;I++)I!==0&&tt(S[I],S[I-1])||w.push(...S[I]);M.push(w)}if(M.length&&t){const S=t.createWorkShapeNode({workId:h,toolsType:N.Pencil,toolsOpt:d.opt});S.setWorkId(h);const w=S==null?void 0:S.computPencilPoints({op:d.op,eraserPolylines:M,eraserThickness:e});if(n=le(n,d.rect),o.add(h),t.removeNode(h),w.length)for(let I=0;I<w.length;I++){const k=`${h}_${Date.now()}_${I}`,T=k,P=t.setFullWork({workId:T,opt:d.opt,toolsType:N.Pencil}).consumeService({op:w[I],isFullWork:!0,replaceId:T});t.clearWorkShapeNodeCache(T),n=le(n,P),i.set(k,{...d,rect:P??d.rect,name:k,op:w[I]})}}}return{willNewNodes:i,willDeleteNodes:o,rect:n}}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n,removeDrawCount:r,drawCount:c}=e,{op:l,syncUnitTime:u}=t;if(!l||l.length===0)return{type:x.None,...this.baseConsumeResult};u&&(this.syncUnitTime=u);const{thickness:h}=this.workOptions,{width:d,height:p}=Nt.eraserSizes[h],f=Math.max(d,p)/this.worldScaling[0],g=this.tmpPoints.length,M=this.tmpPoints[this.tmpPoints.length-1],S=this.updateTempPoints(l,f),w=this.tmpPoints[this.tmpPoints.length-1];if(g===this.tmpPoints.length&&w.equalsXY(M.x,M.y))return{type:x.None,...this.baseConsumeResult};this.syncIndex=Math.min(this.syncIndex,S,Math.max(0,this.tmpPoints.length-2));const I={name:this.workId,id:be(c)&&c.toString()||void 0},k=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());let T=!1,v;const P=this.tmpPoints.slice(S);if(o||n){const L=i?this.fullLayer:this.drawLayer||this.fullLayer;v=this.draw({attrs:I,consumePoints:P,layer:L,removeDrawCount:r,thickness:f})}if(o)return S>10&&this.tmpPoints.splice(0,S-10),{rect:v,type:x.DrawWork,dataType:F.Local};P[0].t-this.syncTimestamp>this.syncUnitTime&&(T=!0,this.syncTimestamp=P[0].t,this.syncIndex=this.tmpPoints.length);const C=[];return this.tmpPoints.slice(k).forEach(L=>{C.push(L.x,L.y,f/2)}),{...this.baseConsumeResult,type:x.DrawWork,dataType:F.Local,rect:v,op:T?C:void 0,index:T?k*3:void 0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{attrs:t,consumePoints:i,layer:o,thickness:n,replaceId:r,removeDrawCount:c}=e;c&&this.removeDrawCountNodes(o,c);let l=fe(i,n);l={x:Math.floor(l.x*this.worldScaling[0]+this.worldPosition[0]-B.SafeBorderPadding),y:Math.floor(l.y*this.worldScaling[1]+this.worldPosition[1]-B.SafeBorderPadding),w:Math.floor(l.w*this.worldScaling[0]+2*B.SafeBorderPadding),h:Math.floor(l.h*this.worldScaling[1]+2*B.SafeBorderPadding)};const u=new ce.Group({...t,normalize:!0,pos:[0,0],anchor:[.5,.5],zIndex:9999,bgcolor:this.workOptions.eraserColor}),h=this.computEraserPointLines(i,90),d=[];for(const p of h)d.push({op:p,thickness:n});for(const p of d){const{thickness:f,op:g}=p,M=g.reduce((T,v,P,C)=>P>0&&C[P-1][0]===v[0]&&C[P-1][1]===v[1]?T:T.concat(v[0],v[1]),[]),S=this.computEraserPoints(M,f),w=Xe(S,!0),I={pos:[0,0],d:w,fillColor:this.workOptions.eraserColor},k=new ce.Path(I);u.append(k),u.seal()}return this.replace(o,r,u),l}computEraserPointLines(e,t=60){const i=[];let o=0;const n=360-t;for(let r=1;r<e.length;r++){const c=e[r-1],l=e[r];if(r===1&&o===0&&(i[o]=[c.XY]),i[o].push(l.XY),r<e.length-1){const u=l.getAngleByPoints(c,e[r+1]);(u<t||u>n)&&(o++,i[o]=[l.XY])}}return e.length===1&&i.length===0&&i.push([e[0].XY,e[0].XY]),i}consumeAll(e){const{workerEngine:t}=e;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return{type:x.None,...this.baseConsumeResult};const{thickness:i}=this.workOptions,{width:o,height:n}=Nt.eraserSizes[i],r=Math.max(o,n)/this.worldScaling[0],{willDeleteNodes:c,willNewNodes:l,rect:u}=this.getChangeNodes(r,t);if(c.size===0&&l.size===0)return{type:x.FullWork,...this.baseConsumeResult,rect:u};const h=[];this.tmpPoints.map(p=>{h.push(p.x,p.y,r/2)});const d=We(h);return{...this.baseConsumeResult,type:x.FullWork,dataType:F.Local,rect:u,ops:d,willNewNodes:l,willDeleteNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};y(Nt,"eraserSizes",si);let ns=Nt;const kt=class kt extends B{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.none);y(this,"toolsType",N.BitMapEraser);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"worldPosition");y(this,"worldScaling");y(this,"eraserRect");y(this,"eraserPolyline");y(this,"syncUnitTime",we.syncOpt.interval);y(this,"syncIndex",0);y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling,this.syncTimestamp=0}combineConsume(){if(this.tmpPoints.length<2)return{type:x.None};const{thickness:e}=this.workOptions,{width:t,height:i}=kt.eraserSizes[e],o=Math.max(t,i)/this.worldScaling[0],n=this.drawLayer||this.fullLayer,r=this.workId,c={name:r};return{rect:this.draw({attrs:c,consumePoints:this.tmpPoints,replaceId:r,layer:n,thickness:o}),type:x.DrawWork,dataType:F.Local}}consumeService(e){const{op:t,isFullWork:i,replaceId:o}=e;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3){const d=new $(t[h],t[h+1],t[h+2]);if(this.tmpPoints.length>0){const p=this.tmpPoints[this.tmpPoints.length-1],f=b.Sub(d,p).uni();d.setv(f)}this.tmpPoints.push(d)}if(this.tmpPoints.length<2)return;const n=this.tmpPoints[0].z*2,r=i?this.fullLayer:this.drawLayer||this.fullLayer,l={name:this.workId};return this.draw({attrs:l,consumePoints:this.tmpPoints,layer:r,thickness:n,replaceId:o})}updateTempPoints(e,t){let i=this.tmpPoints.length-1;const o=Date.now();for(let n=0;n<e.length;n+=2){const r=this.tmpPoints.length,c=new $(e[n],e[n+1]);if(r===0){this.tmpPoints.push(c);continue}const l=r-1,u=this.tmpPoints[l],h=b.Sub(c,u).uni();c.isNear(u,t/2)||(b.Equals(h,u.v,.02)&&(this.tmpPoints.pop(),i--),c.setv(h),c.setT(o),this.tmpPoints.push(c))}return Math.max(i,0)}getChangeNodes(e,t){const i=new Map,o=new Set;let n;if(!this.vNodes)return{willDeleteNodes:o,willUpdateNodes:i,rect:n};const r=this.worldPosition;let c=fe(this.tmpPoints,e);c=Ft(c,r),c=rn(c,this.worldScaling,r);const{nodeRange:l}=this.vNodes.getRectIntersectRange(c);if(!l.size)return{willDeleteNodes:o,willUpdateNodes:i,rect:n};const u=this.computEraserPointLines(this.tmpPoints);for(const[h,d]of l.entries()){if(d.toolsType===N.Text||d.toolsType===N.Image)continue;let p=Ft(d.rect,[-r[0],-r[1]]);p={x:p.x/this.worldScaling[0],y:p.y/this.worldScaling[1],w:p.w/this.worldScaling[0],h:p.h/this.worldScaling[1]};const f=[p.x,p.y,p.x+p.w,p.y+p.h],g=[],M=[];for(const w of u)Vs.polyline(w,f,g);if(g.length&&d.opt)for(const w of g){const I=[];for(let k=0;k<w.length;k++)k!==0&&tt(w[k],w[k-1])||I.push(...w[k]);M.push(I)}if(d.opt.eraserlines||(d.opt.eraserlines=[]),d.opt.eraserlines){if(d.opt.eraserlines.push({op:M,thickness:e}),t){const{toolsType:w}=d,I=t.createWorkShapeNode({workId:h,toolsType:w,toolsOpt:d.opt});I==null||I.setWorkId(h);const k=I==null?void 0:I.consumeService({op:d.op,isFullWork:!0,replaceId:h});if(n=le(n,k),I!=null&&I.isDelete){t.removeNode(h),o.add(h);continue}}i.set(h,d)}}return{willUpdateNodes:i,willDeleteNodes:o,rect:n}}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n,removeDrawCount:r,drawCount:c}=e,{op:l,syncUnitTime:u}=t;if(!l||l.length===0)return{type:x.None,...this.baseConsumeResult};u&&(this.syncUnitTime=u);const{thickness:h}=this.workOptions,{width:d,height:p}=kt.eraserSizes[h],f=Math.max(d,p)/this.worldScaling[0],g=this.tmpPoints.length,M=this.tmpPoints[this.tmpPoints.length-1],S=this.updateTempPoints(l,f),w=this.tmpPoints[this.tmpPoints.length-1];if(g===this.tmpPoints.length&&w.equalsXY(M.x,M.y))return{type:x.None,...this.baseConsumeResult};this.syncIndex=Math.min(this.syncIndex,S,Math.max(0,this.tmpPoints.length-2));const I={name:this.workId,id:be(c)&&c.toString()||void 0},k=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());let T=!1,v;const P=this.tmpPoints.slice(S);if(o||n){const L=i?this.fullLayer:this.drawLayer||this.fullLayer;v=this.draw({attrs:I,consumePoints:P,layer:L,removeDrawCount:r,thickness:f})}if(o)return S>10&&this.tmpPoints.splice(0,S-10),{rect:v,type:x.DrawWork,dataType:F.Local};P[0].t-this.syncTimestamp>this.syncUnitTime&&(T=!0,this.syncTimestamp=P[0].t,this.syncIndex=this.tmpPoints.length);const C=[];return this.tmpPoints.slice(k).forEach(L=>{C.push(L.x,L.y,f/2)}),{...this.baseConsumeResult,type:x.DrawWork,dataType:F.Local,rect:v,op:T?C:void 0,index:T?k*3:void 0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{attrs:t,consumePoints:i,layer:o,thickness:n,replaceId:r,removeDrawCount:c}=e;c&&this.removeDrawCountNodes(o,c);let l=fe(i,n);l={x:Math.floor(l.x*this.worldScaling[0]+this.worldPosition[0]-B.SafeBorderPadding),y:Math.floor(l.y*this.worldScaling[1]+this.worldPosition[1]-B.SafeBorderPadding),w:Math.floor(l.w*this.worldScaling[0]+2*B.SafeBorderPadding),h:Math.floor(l.h*this.worldScaling[1]+2*B.SafeBorderPadding)};const u=new ce.Group({...t,normalize:!0,pos:[0,0],anchor:[.5,.5],zIndex:9999,bgcolor:this.workOptions.eraserColor}),h=this.computEraserPointLines(i),d=[];for(const p of h)d.push({op:p,thickness:n});for(const p of d){const{thickness:f,op:g}=p,M=g.reduce((T,v,P,C)=>P>0&&C[P-1][0]===v[0]&&C[P-1][1]===v[1]?T:T.concat(v[0],v[1]),[]),S=this.computEraserPoints(M,f),w=Xe(S,!0),I={pos:[0,0],d:w,fillColor:this.workOptions.eraserColor},k=new ce.Path(I);u.append(k),u.seal()}return this.replace(o,r,u),l}computEraserPointLines(e,t=60){const i=[];let o=0;const n=360-t;for(let r=1;r<e.length;r++){const c=e[r-1],l=e[r];if(r===1&&o===0&&(i[o]=[c.XY]),i[o].push(l.XY),r<e.length-1){const u=l.getAngleByPoints(c,e[r+1]);(u<t||u>n)&&(o++,i[o]=[l.XY])}}return e.length===1&&i.length===0&&i.push([e[0].XY,e[0].XY]),i}consumeAll(e){const{workerEngine:t}=e;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return{type:x.None,...this.baseConsumeResult};const{thickness:i}=this.workOptions,{width:o,height:n}=kt.eraserSizes[i],r=Math.max(o,n)/this.worldScaling[0],{willDeleteNodes:c,willUpdateNodes:l,rect:u}=this.getChangeNodes(r,t);if(c.size===0&&l.size===0)return{type:x.FullWork,...this.baseConsumeResult,rect:u};const h=[];this.tmpPoints.map(p=>{h.push(p.x,p.y,r/2)});const d=We(h);return{...this.baseConsumeResult,type:x.FullWork,dataType:F.Local,rect:u,ops:d,willUpdateNodes:l,willDeleteNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};y(kt,"eraserSizes",si);let rs=kt;function Jo(a){switch(a){case N.Arrow:return $o;case N.Pencil:return Uo;case N.Straight:return Xo;case N.Ellipse:return Ho;case N.Polygon:case N.Triangle:return Zo;case N.Star:case N.Rhombus:return Go;case N.Rectangle:return Qo;case N.SpeechBalloon:return qo;case N.Text:return os;case N.LaserPen:return Bo;case N.Eraser:return ts;case N.PencilEraser:return ns;case N.BitMapEraser:return rs;case N.Selector:return is;case N.Image:return Bt}}function ws(a,s){const{toolsType:e,...t}=a;switch(e){case N.Arrow:return new $o(t);case N.Pencil:return new Uo(t);case N.Straight:return new Xo(t);case N.Ellipse:return new Ho(t);case N.Polygon:case N.Triangle:return new Zo(t);case N.Star:case N.Rhombus:return new Go(t);case N.Rectangle:return new Qo(t);case N.SpeechBalloon:return new qo(t);case N.Text:return new os(t);case N.LaserPen:return new Bo(t);case N.Eraser:return new ts(t,s);case N.BitMapEraser:return new rs(t);case N.PencilEraser:return new ns(t);case N.Selector:return t.vNodes?new is({...t,vNodes:t.vNodes,drawLayer:t.fullLayer}):void 0;case N.Image:return new Bt(t);default:return}}function Ko(a){const s=[],e=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];for(const t of a){if(t.tagName==="GROUP"&&t.children.length){const i=Ko(t.children);s.push(...i)}t.tagName&&e.includes(t.tagName)&&s.push(t)}return s}const hg="cursorhover",ri=20,pe="mainView";class _o{constructor(s,e){y(this,"viewId");y(this,"scene");y(this,"fullLayer");y(this,"curNodeMap",new Map);y(this,"targetNodeMap",[]);y(this,"highLevelIds");y(this,"canClearUids");y(this,"localUid");this.viewId=s,this.scene=e}init(s){this.fullLayer=s}get(s){return this.curNodeMap.get(s)}setLocalUid(s){this.localUid=s}getLocalUid(){return this.localUid}setCanClearUids(s){this.canClearUids=s}getCanClearUids(){return this.canClearUids}getCanEraserNodes(s,e){const t=new Map;for(const[i,o]of s.entries())o.toolsType===N.Image&&(o.opt.locked||e&&e.disableEraseImage)||o.toolsType===N.Text&&(o.opt.workState===z.Doing||o.opt.workState===z.Start||e&&e.disableEraseText)||this.isCanClearWorkId(i)&&t.set(i,o);return t}getNodesByType(s){const e=new Map;return this.curNodeMap.forEach((t,i)=>{t.toolsType===s&&e.set(i,t)}),e}gethasEraserNodes(){const s=new Map;return this.curNodeMap.forEach((e,t)=>{var i;(i=e.opt.eraserlines)!=null&&i.length&&s.set(t,e)}),s}hasRenderNodes(){return!0}has(s){return this.curNodeMap.has(s)}setInfo(s,e){const t=this.curNodeMap.get(s)||{name:s,rect:e.rect};e.rect&&(t.rect=Ce(e.rect)),e.op&&Jy(e.op)&&(t.op=Ce(e.op)),e.canRotate&&(t.canRotate=e.canRotate),e.scaleType&&(t.scaleType=e.scaleType),e.opt&&(t.opt=Ce(e.opt)),e.toolsType&&(t.toolsType=e.toolsType),e.centerPos&&(t.centerPos=Ce(e.centerPos)),Tt(e.isSelected)&&(t.isSelected=e.isSelected),t.rect?this.curNodeMap.set(s,t):this.curNodeMap.delete(s)}selected(s){this.setInfo(s,{isSelected:!0})}unSelected(s){this.setInfo(s,{isSelected:!1})}delete(s){this.curNodeMap.delete(s)}clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0}getRectIntersectRange(s,e=!0,t=!0){let i;const o=new Map;for(const[n,r]of this.curNodeMap.entries())if(Rs(s,r.rect)){if(e&&r.toolsType===N.Image&&r.opt.locked||t&&r.toolsType===N.Text&&(r.opt.workState===z.Doing||r.opt.workState===z.Start))continue;i=le(i,r.rect),o.set(n,r)}return{rectRange:i,nodeRange:o}}getNodeRectFormShape(s,e){const t=Jo(e.toolsType);return this.fullLayer&&(t==null?void 0:t.getRectFromLayer(this.fullLayer,s))}updateNodeRect(s){const e=this.curNodeMap.get(s);if(e){const t=this.getNodeRectFormShape(s,e);if(!t){this.curNodeMap.delete(s);return}e.rect=t,this.curNodeMap.set(s,e)}}updateHighLevelNodesRect(s){this.highLevelIds=s;for(const e of this.highLevelIds.keys())this.updateNodeRect(e)}updateLowLevelNodesRect(){var s;for(const e of this.curNodeMap.keys())(s=this.highLevelIds)!=null&&s.has(e)||this.updateNodeRect(e)}clearHighLevelIds(){this.highLevelIds=void 0}setTargetAssignKeys(s){const e=new Map;for(const t of s){const i=this.curNodeMap.get(t);i&&e.set(t,Ce(i))}return this.targetNodeMap.push(Ce(e)),this.targetNodeMap.length-1}setTarget(){return this.targetNodeMap.push(Ce(this.curNodeMap)),this.targetNodeMap.length-1}getLastTarget(){return this.targetNodeMap[this.targetNodeMap.length-1]}deleteLastTarget(){this.targetNodeMap.length&&(this.targetNodeMap.length=this.targetNodeMap.length-1)}getTarget(s){return this.targetNodeMap[s]}deleteTarget(s){this.targetNodeMap.length=s}clearTarget(){this.targetNodeMap.length=0}isLocalWorkId(s){return s.split(Ee).length===1}isCanClearWorkId(s){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(Gd(this.canClearUids)){const e=s.split(Ee);if(e.length===1)return this.canClearUids.has("localSelf")||this.localUid&&this.canClearUids.has(this.localUid);if(e.length===2)return this.canClearUids.has(e[0])}return!1}}class ug{constructor(s,e,t){y(this,"viewId");y(this,"scene");y(this,"fullLayer");y(this,"vNodes");y(this,"dpr");y(this,"contextType");y(this,"opt");y(this,"cameraOpt");y(this,"isSafari",!1);y(this,"combinePostMsg",new Set);y(this,"workerTaskId");y(this,"protectedTask");y(this,"hasPriorityDraw",!0);y(this,"delayPostDoneResolve");y(this,"cacheImages",new Map);y(this,"imageResolveMap",new Map);y(this,"taskUpdateCameraId");y(this,"debounceUpdateCameraId");var i,o;if(this.viewId=s,this.opt=e,this.dpr=e.dpr,this.contextType=this.getSupportContextType(t,(i=e==null?void 0:e.offscreenCanvasOpt)==null?void 0:i.contextType),!this.contextType)throw new Error("Sorry, your browser doesn't support canvas context type 2d or webgl");try{this.createRenderLayer(e)}catch{if(this.contextType!=="2d")this.contextType="2d",(o=this.scene)==null||o.disconnect(),this.createRenderLayer(e);else throw new Error(`Sorry, your browser doesn't support canvas context type ${this.contextType}`)}this.vNodes=new _o(s,this.scene)}createRenderLayer(s){this.scene=this.createScene(s.offscreenCanvasOpt);const e=we.bufferSize.full,t=we.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",this.scene,{...s.layerOpt,bufferSize:this.viewId===pe?e:t*2})}async updateDpr(s){this.dpr=s,this.scene.displayRatio=s}getCachedImages(s){var e;return(e=this.cacheImages.get(s))==null?void 0:e.imageBitmap}getCachedImagesByWorkId(s){for(const[e,t]of this.cacheImages.entries())if(e===s&&t.imageBitmap)return t.imageBitmap}deleteCachedImagesByWorkId(s,e){for(const[t,i]of this.cacheImages.entries())e&&t===e||i.workId===s&&(i.imageBitmap.close(),this.cacheImages.delete(t))}clearCacheImages(){this.cacheImages.forEach(s=>s.imageBitmap.close()),this.cacheImages.clear()}clearImageResolveMap(){this.imageResolveMap.forEach(({timer:s})=>{s&&clearTimeout(s)}),this.imageResolveMap.clear()}setHasPriorityDraw(s){this.hasPriorityDraw=s}getPriorityDraw(){return this.hasPriorityDraw}setIsSafari(s){this.isSafari=s}async on(s){const{msgType:e,toolsType:t,opt:i,imageSrc:o,imageBitmap:n,workId:r,dpr:c}=s;switch(e){case x.UpdateDpr:be(c)&&await this.updateDpr(c);break;case x.UpdateCamera:await this.updateCamera(s);break;case x.Destroy:this.destroy();break;case x.Clear:await this.clearAll();break;case x.UpdateTools:if(t&&i){const l={toolsType:t,toolsOpt:i};this.localWork.setToolsOpt(l)}break;case x.GetImageBitMap:if(o&&n&&r){const l=r.toString();this.cacheImages.set(o,{imageBitmap:n,workId:l});const u=this.imageResolveMap.get(o);if(u){const{resolve:h,timer:d}=u;d&&clearTimeout(d),h&&h(o)}this.deleteCachedImagesByWorkId(l,o)}break}}getIconSize(s,e,t){const i=s*t,o=e*t;return i<=50||o<=50?[50,50]:i<=100||o<=100?[100,100]:i<=200||o<=200?[200,200]:i<=400||o<=400?[400,400]:i<=800||o<=800?[800,800]:[1600,1600]}async loadImageBitMap(s){const{toolsType:e,opt:t,workId:i,isSubWorker:o}=s;if(e===N.Image&&t&&i){const n=i.toString(),{src:r,type:c,width:l,height:u,strokeColor:h}=t;if(!r||!c||!l||!u)return;let d=r;if(c===gt.Iconify){const[M,S]=this.getIconSize(l,u,this.dpr);d=`${r}?width=${M}&height=${S}&color=${h}`}if(this.cacheImages.has(d)){const M=this.getCachedImages(d);if(M)return M}if(this.imageResolveMap.has(d)){const M=this.getCachedImagesByWorkId(n);if(M)return M}const g=await new Promise(M=>{const S=this.imageResolveMap.get(d)||{resolve:void 0,timer:void 0};S.timer&&clearTimeout(S.timer),S.resolve=M,S.timer=setTimeout(()=>{const w=this.imageResolveMap.get(d);w!=null&&w.resolve&&w.resolve(d)},5e3),this.imageResolveMap.set(d,S),this._post({sp:[{imageSrc:d,workId:n,viewId:this.viewId,isgl:!!this.fullLayer.parent.gl,isSubWorker:o,type:x.GetImageBitMap}]})});return this.imageResolveMap.delete(g),this.getCachedImages(d)}}createLocalWork(s){const{workId:e,opt:t,toolsType:i}=s;e&&t&&(!this.localWork.getToolsOpt()&&i&&this.setToolsOpt({toolsType:i,toolsOpt:t}),this.setWorkOpt({workId:e,toolsOpt:t}))}updateScene(s){this.scene.attr({...s});const{width:e,height:t}=s;this.scene.container.width=e,this.scene.container.height=t,this.scene.width=e,this.scene.height=t,this.updateLayer({width:e,height:t})}updateLayer(s){const{width:e,height:t}=s;this.fullLayer&&(this.fullLayer.parent.setAttribute("width",e),this.fullLayer.parent.setAttribute("height",t),this.fullLayer.setAttribute("size",[e,t]),this.fullLayer.setAttribute("pos",[e*.5,t*.5]))}getSupportContextType(s,e){const t=new OffscreenCanvas(100,100);let i=["2d"];s===Os.Full&&this.viewId===pe&&(i=["webgl2","webgl","2d"],e&&i.unshift(e));for(const o of i)try{if(t.getContext(o))return o}catch{continue}}createScene(s){const{width:e,height:t}=s,i=new OffscreenCanvas(e,t);s.contextType&&delete s.contextType;const o=new ce.Scene({container:i,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0,...s,contextType:this.contextType,id:this.viewId});return o.setAttribute("id",this.viewId),o}createLayer(s,e,t){const{width:i,height:o}=t,n=`offscreen-${s}`,r=e.layer(n,t),c=new ce.Group({anchor:[.5,.5],pos:[i*.5,o*.5],size:[i,o],name:"viewport",id:s});return r.append(c),c}async clearAll(){var s;this.fullLayer&&(this.fullLayer.parent.children.forEach(e=>{e.name!=="viewport"&&e.remove()}),Re(this.fullLayer,this.fullLayer.parent)),this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0),this.debounceUpdateCameraId&&(clearTimeout(this.debounceUpdateCameraId),this.debounceUpdateCameraId=void 0),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(s=this.serviceWork)==null||s.destroy()}setToolsOpt(s){this.localWork.setToolsOpt(s)}setWorkOpt(s){const{workId:e,toolsOpt:t}=s;e&&t&&this.localWork.setWorkOptions(e.toString(),t)}destroy(){var s;this.vNodes.clear(),this.fullLayer.remove(),Oe(this.fullLayer,this.fullLayer.parent),this.clearCacheImages(),this.clearImageResolveMap(),this.scene.remove(),this.localWork.destroy(),(s=this.serviceWork)==null||s.destroy()}async post(s){this.combinePostMsg.add(s),await this.runBatchPostData()}async runBatchPostData(){this.workerTaskId||(this.workerTaskId=setTimeout(()=>{this.workerTaskId=void 0,this.combinePost()},16)),this.type===Os.Full&&!this.delayPostDoneResolve&&await new Promise(e=>{this.delayPostDoneResolve=e})&&(this.delayPostDoneResolve=void 0)}combinePostData(){var r,c;this.workerTaskId=void 0;const s=[],e=[];let t,i,o;const n=new Set;for(const l of this.combinePostMsg.values()){if((r=l.render)!=null&&r.length)for(const u of l.render){let h=!1;if(u.workId&&n.add(u.workId),u.isClearAll&&(u.rect=this.getSceneRect(),u.isClear=!0,delete u.isClearAll),u.drawCanvas){const d=this.getLayer(u.drawCanvas);if(!d||!(d.parent instanceof ce.Layer))continue;if(d.parent.render(),u.isDrawAll){const p=this.getSceneRect();u.rect=p,delete u.isDrawAll}}for(const d of s)if(u.viewId===d.viewId){u.isClear&&d.clearCanvas&&d.isClear&&d.clearCanvas===u.clearCanvas&&(d.rect=le(d.rect,u.rect),h=!0),d.drawCanvas&&d.drawCanvas===u.drawCanvas&&(d.rect=le(d.rect,u.rect),h=!0);continue}h||(u.isClear&&!u.drawCanvas?s.unshift(u):s.push(u))}if((c=l.sp)!=null&&c.length)for(const u of l.sp){let h=!1;for(const d of e)if(tt(u,d)){h=!0;break}h||e.push(u)}be(l.fullWorkerDrawCount)&&(t=l.fullWorkerDrawCount),be(l.subWorkerDrawCount)&&(i=l.subWorkerDrawCount),be(l.consumeCount)&&(o=l.consumeCount)}return this.combinePostMsg.clear(),{render:s,sp:e,fullWorkerDrawCount:t,subWorkerDrawCount:i,consumeCount:o,workIds:n,viewId:this.viewId}}getSceneRect(){const{width:s,height:e}=this.scene;return{x:0,y:0,w:Math.floor(s),h:Math.floor(e)}}}class dg{constructor(s){y(this,"viewId");y(this,"vNodes");y(this,"thread");y(this,"fullLayer");y(this,"drawLayer");y(this,"_post");y(this,"tmpOpt");y(this,"workShapes",new Map);y(this,"drawCount",0);y(this,"consumeCount",0);y(this,"syncUnitTime",we.syncOpt.interval);this.thread=s.thread,this.viewId=s.viewId,this.vNodes=s.vNodes,this.fullLayer=s.fullLayer,this.drawLayer=s.drawLayer,this._post=this.thread.post.bind(s.thread)}destroy(){this.workShapes.clear()}getWorkShapes(){return this.workShapes}getWorkShape(s){return this.workShapes.get(s)}createWorkShape(s,e){if(s&&this.tmpOpt){const t={toolsType:this.tmpOpt.toolsType,toolsOpt:e||this.tmpOpt.toolsOpt},i=this.createWorkShapeNode({...t,workId:s});i&&this.workShapes.set(s,i)}}setWorkOptions(s,e){const t=this.getWorkShape(s);t||this.createWorkShape(s,e),t==null||t.setWorkOptions(e)}createWorkShapeNode(s){var e;return ws({...s,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},(e=this.thread)==null?void 0:e.serviceWork)}setToolsOpt(s){var e,t,i;((e=this.tmpOpt)==null?void 0:e.toolsType)!==s.toolsType&&(t=this.tmpOpt)!=null&&t.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=s,(i=s.toolsOpt)!=null&&i.syncUnitTime&&(this.syncUnitTime=s.toolsOpt.syncUnitTime)}getToolsOpt(){return this.tmpOpt}clearWorkShapeNodeCache(s){var e;(e=this.getWorkShape(s))==null||e.clearTmpPoints(),this.workShapes.delete(s)}clearAllWorkShapesCache(){this.workShapes.forEach(s=>s.clearTmpPoints()),this.workShapes.clear()}setFullWork(s){const{workId:e,opt:t,toolsType:i}=s;if(e&&t&&i){const o=e.toString();let n;return e&&this.workShapes.has(o)?(n=this.workShapes.get(o),n==null||n.setWorkOptions(t)):n=this.createWorkShapeNode({toolsOpt:t,toolsType:i,workId:o}),n?(this.workShapes.set(o,n),n):void 0}}}function pg(a){return a}var en=pg;function fg(a,s,e){switch(e.length){case 0:return a.call(s);case 1:return a.call(s,e[0]);case 2:return a.call(s,e[0],e[1]);case 3:return a.call(s,e[0],e[1],e[2])}return a.apply(s,e)}var gg=fg,yg=gg,Xi=Math.max;function mg(a,s,e){return s=Xi(s===void 0?a.length-1:s,0),function(){for(var t=arguments,i=-1,o=Xi(t.length-s,0),n=Array(o);++i<o;)n[i]=t[s+i];i=-1;for(var r=Array(s+1);++i<s;)r[i]=t[i];return r[s]=e(n),yg(a,this,r)}}var Mg=mg;function wg(a){return function(){return a}}var vg=wg,Ig=vg,Ji=yo,Tg=en,Sg=Ji?function(a,s){return Ji(a,"toString",{configurable:!0,enumerable:!1,value:Ig(s),writable:!0})}:Tg,Ng=Sg,kg=800,Cg=16,bg=Date.now;function xg(a){var s=0,e=0;return function(){var t=bg(),i=Cg-(t-e);if(e=t,i>0){if(++s>=kg)return arguments[0]}else s=0;return a.apply(void 0,arguments)}}var Lg=xg,Pg=Ng,Dg=Lg,zg=Dg(Pg),Ag=zg,jg=en,Eg=Mg,Og=Ag;function Rg(a,s){return Og(Eg(a,s,jg),a+"")}var Wg=Rg;function Yg(a,s,e,t){for(var i=a.length,o=e+(t?1:-1);t?o--:++o<i;)if(s(a[o],o,a))return o;return-1}var Ug=Yg;function Bg(a){return a!==a}var Fg=Bg;function Vg(a,s,e){for(var t=e-1,i=a.length;++t<i;)if(a[t]===s)return t;return-1}var $g=Vg,Hg=Ug,Qg=Fg,Gg=$g;function Zg(a,s,e){return s===s?Gg(a,s,e):Hg(a,Qg,e)}var qg=Zg,Xg=qg;function Jg(a,s){var e=a==null?0:a.length;return!!e&&Xg(a,s,0)>-1}var tn=Jg;function Kg(a,s,e){for(var t=-1,i=a==null?0:a.length;++t<i;)if(e(s,a[t]))return!0;return!1}var sn=Kg;function _g(a,s){for(var e=-1,t=a==null?0:a.length,i=Array(t);++e<t;)i[e]=s(a[e],e,a);return i}var ey=_g,ty=ii,sy=tn,iy=sn,oy=ey,ny=ms,ry=oi,ay=200;function cy(a,s,e,t){var i=-1,o=sy,n=!0,r=a.length,c=[],l=s.length;if(!r)return c;e&&(s=oy(s,ny(e))),t?(o=iy,n=!1):s.length>=ay&&(o=ry,n=!1,s=new ty(s));e:for(;++i<r;){var u=a[i],h=e==null?u:e(u);if(u=t||u!==0?u:0,n&&h===h){for(var d=l;d--;)if(s[d]===h)continue e;c.push(u)}else o(s,h,t)||c.push(u)}return c}var ly=cy,Ki=Vt,hy=vo,uy=$t,_i=Ki?Ki.isConcatSpreadable:void 0;function dy(a){return uy(a)||hy(a)||!!(_i&&a&&a[_i])}var py=dy,fy=_s,gy=py;function on(a,s,e,t,i){var o=-1,n=a.length;for(e||(e=gy),i||(i=[]);++o<n;){var r=a[o];s>0&&e(r)?s>1?on(r,s-1,e,t,i):fy(i,r):t||(i[i.length]=r)}return i}var yy=on;function my(){}var My=my,bs=Do,wy=My,vy=ni,Iy=1/0,Ty=bs&&1/vy(new bs([,-0]))[1]==Iy?function(a){return new bs(a)}:wy,Sy=Ty,Ny=ii,ky=tn,Cy=sn,by=oi,xy=Sy,Ly=ni,Py=200;function Dy(a,s,e){var t=-1,i=ky,o=a.length,n=!0,r=[],c=r;if(e)n=!1,i=Cy;else if(o>=Py){var l=s?null:xy(a);if(l)return Ly(l);n=!1,i=by,c=new Ny}else c=s?[]:r;e:for(;++t<o;){var u=a[t],h=s?s(u):u;if(u=e||u!==0?u:0,n&&h===h){for(var d=c.length;d--;)if(c[d]===h)continue e;s&&c.push(h),r.push(u)}else i(c,h,e)||(c!==r&&c.push(h),r.push(u))}return r}var zy=Dy,Ay=ly,jy=yy,eo=zy;function Ey(a,s,e){var t=a.length;if(t<2)return t?eo(a[0]):[];for(var i=-1,o=Array(t);++i<t;)for(var n=a[i],r=-1;++r<t;)r!=i&&(o[i]=Ay(o[i]||n,a[r],s,e));return eo(jy(o,1),s,e)}var Oy=Ey,Ry=qs,Wy=Ke;function Yy(a){return Wy(a)&&Ry(a)}var Uy=Yy,By=ko,Fy=Wg,Vy=Oy,$y=Uy;Fy(function(a){return Vy(By(a,$y))});class Hy extends dg{constructor(e){super(e);y(this,"drawWorkActiveId")}async runFullWork(e){var o;const t=this.setFullWork(e),i=e.ops&&lt(e.ops);if(t){let n,r;const c=(o=t.getWorkId())==null?void 0:o.toString();return t.toolsType===N.Image?n=await t.consumeServiceAsync({isFullWork:!0,worker:this.thread}):t.toolsType===N.Text?n=await t.consumeServiceAsync({isFullWork:!0,replaceId:c,isDrawLabel:!0}):(n=t.consumeService({op:i,isFullWork:!0,replaceId:c}),r=(e==null?void 0:e.updateNodeOpt)&&t.updataOptService(e.updateNodeOpt)),e.workId&&this.workShapes.delete(e.workId.toString()),le(n,r)}}runSelectWork(e){var i;const t=this.setFullWork(e);t&&((i=e.selectIds)!=null&&i.length)&&e.workId&&t.selectServiceNode(e.workId.toString(),{selectIds:e.selectIds},!1)}workShapesDone(){for(const e of this.workShapes.keys())this.clearWorkShapeNodeCache(e);Re(this.fullLayer,this.fullLayer.parent)}canUseSubWorker(e){const t=this.thread.getPriorityDraw();return t||!t&&e!==N.Pencil}async consumeDraw(e){const{workId:t,fullWorkerDrawCount:i,postCount:o}=e,n=t==null?void 0:t.toString(),r=n&&this.workShapes.get(n);if(!r)return;this.drawWorkActiveId&&this.drawWorkActiveId!==n&&(await this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:x.DrawWork,dataType:F.Local}),this.drawWorkActiveId=void 0),!this.drawWorkActiveId&&n!==H&&(this.drawWorkActiveId=n);const c=r.toolsType;be(o)&&(this.consumeCount=o);const l=r.consume({data:e,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0,removeDrawCount:i});switch(c){case N.Ellipse:case N.Arrow:case N.Straight:case N.Rectangle:case N.Star:case N.Polygon:case N.SpeechBalloon:{l&&(this.drawCount++,await this.drawShape(l));break}case N.Pencil:case N.PencilEraser:case N.BitMapEraser:{l&&(this.drawCount++,await this.drawPencil(l,t==null?void 0:t.toString()));break}}}async consumeDrawAll(e){const{workId:t}=e;if(t){const i=t.toString();this.drawWorkActiveId===i&&(this.drawWorkActiveId=void 0);const o=this.workShapes.get(i);if(!o)return;switch(o.toolsType){case N.Arrow:case N.Straight:case N.Ellipse:case N.Pencil:case N.Rectangle:case N.Star:case N.Polygon:case N.SpeechBalloon:case N.BitMapEraser:case N.PencilEraser:this.drawCount=0,Re(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(i);break}}}async removeWork(e){const{workId:t}=e,i=t==null?void 0:t.toString();if(i){const o=this.removeNode(i);if(o){const n=[];n.push({rect:Wt(o),clearCanvas:me.Float,isClear:!0,viewId:this.viewId},{rect:Wt(o),drawCanvas:me.Float,viewId:this.viewId}),await this._post({render:n})}}}removeNode(e){const t=this.workShapes.has(e);let i;return t&&(this.fullLayer.getElementsByName(e).forEach(o=>{const n=o.getBoundingClientRect();i=le(i,{x:n.x-B.SafeBorderPadding,y:n.y-B.SafeBorderPadding,w:n.width+B.SafeBorderPadding*2,h:n.height+B.SafeBorderPadding*2}),o.remove(),Oe(o,this.fullLayer.parent)}),i&&this.clearWorkShapeNodeCache(e)),i}async drawPencil(e,t){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:e==null?void 0:e.rect,workId:t,drawCanvas:me.Float,viewId:this.viewId}],sp:(e==null?void 0:e.op)&&[e]})}async drawShape(e){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(e==null?void 0:e.rect)&&Wt(e.rect),isClear:!0,clearCanvas:me.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&Wt(e.rect),drawCanvas:me.Float,viewId:this.viewId}]})}}class Qy{constructor(s){y(this,"viewId");y(this,"vNodes");y(this,"topLayer");y(this,"thread");y(this,"post");y(this,"serviceWorkShapes",new Map);y(this,"localWorkShapes",new Map);y(this,"tmpOpt");y(this,"syncUnitTime",we.syncOpt.interval);y(this,"animationId");this.viewId=s.viewId,this.vNodes=s.vNodes,this.topLayer=s.topLayer,this.thread=s.thread,this.post=s.thread.post.bind(s.thread)}canUseTopLayer(s){return s===N.LaserPen}getWorkShape(s){return this.localWorkShapes.get(s)}createWorkShape(s,e){if(s&&this.tmpOpt){const t={toolsType:this.tmpOpt.toolsType,toolsOpt:e||this.tmpOpt.toolsOpt},i=this.createWorkShapeNode({...t,workId:s});return i&&this.localWorkShapes.set(s,{node:i,toolsType:i.toolsType,workState:z.Start}),i}}setWorkOptions(s,e){var i;const t=(i=this.localWorkShapes.get(s))==null?void 0:i.node;t||this.createWorkShape(s,e),t==null||t.setWorkOptions(e)}createWorkShapeNode(s){const{toolsType:e}=s;if(e===N.LaserPen)return ws({...s,vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer})}clearAllWorkShapesCache(){this.localWorkShapes.forEach(s=>{var e;return(e=s.node)==null?void 0:e.clearTmpPoints()}),this.localWorkShapes.clear()}setToolsOpt(s){var e;this.tmpOpt=s,(e=s.toolsOpt)!=null&&e.syncUnitTime&&(this.syncUnitTime=s.toolsOpt.syncUnitTime)}getToolsOpt(){return this.tmpOpt}consumeDraw(s){const{workId:e,dataType:t}=s;if(t===F.Service)this.activeServiceWorkShape(s);else{const i=e==null?void 0:e.toString(),o=i&&this.localWorkShapes.get(i);if(!o)return;const n=o.node.consume({data:s,isFullWork:!1,isSubWorker:!0});n.rect&&(o.totalRect=le(n.rect,o.totalRect),o.result=n,o.workState=z.Doing,i&&this.localWorkShapes.set(i,o))}this.runAnimation()}consumeDrawAll(s){const{workId:e,dataType:t}=s;if(t===F.Service)this.activeServiceWorkShape(s);else{const i=e==null?void 0:e.toString(),o=i&&this.localWorkShapes.get(i);if(!o)return;const n=o.node.consumeAll({data:s});o.totalRect=le(n.rect,o.totalRect),o.result=n,o.workState=z.Done,i&&this.localWorkShapes.set(i,o)}this.runAnimation()}destroy(){this.serviceWorkShapes.clear(),this.localWorkShapes.clear()}setNodeKey(s,e,t,i){return e.toolsType=t,e.node=this.createWorkShapeNode({workId:s,toolsType:t,toolsOpt:i}),e}activeServiceWorkShape(s){var d,p;const{workId:e,opt:t,toolsType:i,type:o,updateNodeOpt:n,ops:r,op:c}=s;if(!e)return;const l=e.toString(),u=(d=this.vNodes.get(l))==null?void 0:d.rect;if(!((p=this.serviceWorkShapes)!=null&&p.has(l))){let f={toolsType:i,animationWorkData:c||[],animationIndex:0,type:o,updateNodeOpt:n,ops:r,oldRect:u};i&&t&&(f=this.setNodeKey(l,f,i,t)),this.serviceWorkShapes.set(l,f)}const h=this.serviceWorkShapes.get(l);o&&(h.type=o),r&&(h.animationWorkData=lt(r),h.ops=r),n&&(h.updateNodeOpt=n),c&&(h.animationWorkData=c),h.node&&h.node.getWorkId()!==l&&h.node.setWorkId(l),u&&(h.oldRect=u),i&&t&&(h.toolsType!==i&&i&&t&&this.setNodeKey(l,h,i,t),h.node&&h.node.setWorkOptions(t))}computNextAnimationIndex(s,e){const t=Math.floor((s.animationWorkData||[]).slice(s.animationIndex).length*32/e/this.syncUnitTime)*e;return Math.min((s.animationIndex||0)+(t||e),(s.animationWorkData||[]).length)}async animationDraw(){var n,r,c,l;this.animationId=void 0;let s=!1;const e=new Map,t=[],i=[],o=[];for(const[u,h]of this.serviceWorkShapes.entries())switch(h.toolsType){case N.LaserPen:{const p=this.computNextAnimationIndex(h,8),f=Math.max(0,h.animationIndex||0),g=(h.animationWorkData||[]).slice(f,p);if((h.animationIndex||0)<p){const M=(n=h.node)==null?void 0:n.consumeService({op:g,isFullWork:!1});h.totalRect=le(h.totalRect,M),h.animationIndex=p,g.length&&e.set(u,{workState:f===0?z.Start:p===((r=h.animationWorkData)==null?void 0:r.length)?z.Done:z.Doing,op:g.slice(-2)})}if(i.push({isClear:!0,rect:h.totalRect,clearCanvas:me.TopFloat,viewId:this.viewId}),t.push({rect:h.totalRect,drawCanvas:me.TopFloat,viewId:this.viewId}),h.isDel){(c=h.node)==null||c.clearTmpPoints(),this.serviceWorkShapes.delete(u);break}h.ops&&h.animationIndex===((l=h.animationWorkData)==null?void 0:l.length)&&!h.isDel&&(this.topLayer.getElementsByName(u.toString())[0]||(h.isDel=!0,this.serviceWorkShapes.set(u,h))),s=!0;break}}for(const[u,h]of this.localWorkShapes.entries()){const{result:d,toolsType:p,totalRect:f,isDel:g,workState:M}=h;switch(p){case N.LaserPen:{if(f&&(i.push({isClear:!0,rect:f,clearCanvas:me.TopFloat,viewId:this.viewId}),t.push({rect:f,drawCanvas:me.TopFloat,viewId:this.viewId})),g){h.node.clearTmpPoints(),this.localWorkShapes.delete(u),o.push({removeIds:[u.toString()],viewId:this.viewId,type:x.RemoveNode});break}d&&((d.op||d.ops)&&o.push(d),h.result=void 0),!this.topLayer.getElementsByName(u.toString())[0]&&M===z.Done&&(h.isDel=!0,this.localWorkShapes.set(u,h)),s=!0;break}}}s&&this.runAnimation(),e.size&&e.forEach((u,h)=>{o.push({type:x.Cursor,uid:h.split(Ee)[0],op:u.op,workState:u.workState,viewId:this.viewId})}),(t.length||i.length||o.length)&&this.post({render:[...i,...t],sp:o})}runAnimation(){this.animationId||(this.animationId=setTimeout(()=>{this.animationId=void 0,this.animationDraw()},16))}}var Os=(a=>(a.Full="full",a.Sub="sub",a))(Os||{});class Gy extends ug{constructor(e,t,i){super(e,t,"sub");y(this,"type","sub");y(this,"_post");y(this,"topLayer");y(this,"snapshotFullLayer");y(this,"serviceWork");y(this,"localWork");y(this,"topLayerWork");this._post=i;const o=we.bufferSize.sub;this.topLayer=this.createLayer("topLayer",this.scene,{...t.layerOpt,bufferSize:o,contextType:"2d"});const n={thread:this,viewId:this.viewId,vNodes:this.vNodes,fullLayer:this.fullLayer,topLayer:this.topLayer};this.localWork=new Hy(n),this.topLayerWork=new Qy(n),this.vNodes.init(this.fullLayer)}async combinePost(){var n,r;const{render:e,...t}=this.combinePostData();let i;if(e!=null&&e.length){const c=[];for(const l of e)if(l.rect){if(l.rect=im(Ce(l.rect),this.scene,this.dpr),!l.rect)continue;if(l.drawCanvas&&l.rect&&l.rect.w>0&&l.rect.h>0){const u=await this.getRectImageBitmap(l);l.imageBitmap=u,i||(i=[]),i.push(u)}c.push(l)}t.render=c}const o=(n=t.sp)==null?void 0:n.filter(c=>c.type!==x.None||c.isLockSentEventCursor);o!=null&&o.length?t.sp=o.map(c=>({...c,viewId:this.viewId})):delete t.sp,t.consumeCount===void 0&&delete t.consumeCount,t.subWorkerDrawCount===void 0&&delete t.subWorkerDrawCount,(o!=null&&o.length||t.consumeCount||t.subWorkerDrawCount||(r=t==null?void 0:t.render)!=null&&r.length)&&this._post(t,i),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0)}getLayer(e,t){if(t&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(e){case me.TopFloat:return this.topLayer;default:return this.fullLayer}}async on(e){const{msgType:t,toolsType:i,opt:o,dataType:n,workState:r,isLockSentEventCursor:c}=e;switch(t){case x.UpdateTools:if(i&&this.topLayerWork.canUseTopLayer(i)&&o){const l={toolsType:i,toolsOpt:o};this.topLayerWork.setToolsOpt(l);return}break;case x.CreateWork:this.createLocalWork(e);return;case x.DrawWork:r===z.Done&&n===F.Local?(await this.consumeDrawAll(n,e),i===N.LaserPen&&c&&this.post({sp:[{type:x.None,isLockSentEventCursor:c}]})):this.consumeDraw(n,e);return;case x.RemoveNode:await this.removeNode(e);return;case x.FullWork:i&&this.topLayerWork.canUseTopLayer(i)&&await this.consumeDrawAll(n,e);return;case x.Snapshot:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId===pe?6e3:3e3,contextType:"2d"}),this.snapshotFullLayer&&(await this.getSnapshot(e),this.snapshotFullLayer=void 0);return;case x.BoundingBox:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId===pe?6e3:3e3,contextType:"2d"}),this.snapshotFullLayer&&(await this.getBoundingRect(e),this.snapshotFullLayer=void 0);return}await super.on(e)}createLocalWork(e){const{workId:t,toolsType:i,opt:o}=e;if(i&&this.topLayerWork.canUseTopLayer(i)&&t&&o){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:i,toolsOpt:o}),this.topLayerWork.setWorkOptions(t.toString(),o);return}i&&this.localWork.canUseSubWorker(i)&&super.createLocalWork(e)}async removeNode(e){const{dataType:t}=e;t===F.Local&&await this.localWork.removeWork(e)}getOffscreen(e,t){return this.getLayer(e,t).parent.canvas}async consumeDraw(e,t){const{workId:i,toolsType:o}=t;if(i){if(o&&this.topLayerWork.canUseTopLayer(o)){e===F.Local&&(this.topLayerWork.getWorkShape(i.toString())||this.createLocalWork(t)),this.topLayerWork.consumeDraw(t);return}o&&this.localWork.canUseSubWorker(o)&&(this.localWork.getWorkShape(i.toString())||this.createLocalWork(t),await this.localWork.consumeDraw(t));return}}async consumeDrawAll(e,t){const{workId:i,toolsType:o,dataType:n}=t;if(i){const r=i.toString();if(o&&this.topLayerWork.canUseTopLayer(o)){n===F.Local&&(this.topLayerWork.getWorkShape(r)||this.createLocalWork(t)),this.topLayerWork.consumeDrawAll(t);return}o&&this.localWork.canUseSubWorker(o)&&(this.localWork.getWorkShape(r)||super.createLocalWork(t),this.localWork.consumeDrawAll(t));return}}async clearAll(){this.vNodes.clear(),super.clearAll(),this.topLayer&&(this.topLayer.parent.children.forEach(e=>{e.name!=="viewport"&&e.remove()}),Re(this.topLayer,this.topLayer.parent)),await this.post({render:[{isClearAll:!0,clearCanvas:me.TopFloat,viewId:this.viewId}],sp:[{type:x.Clear}]})}getRectImageBitmap(e,t=!1,i){const{rect:o,drawCanvas:n}=e,r=Math.floor(o.x*this.dpr),c=Math.floor(o.y*this.dpr),l=Math.floor(o.w*this.dpr||1),u=Math.floor(o.h*this.dpr||1);return createImageBitmap(this.getOffscreen(n,t),r,c,l,u,i)}updateLayer(e){const{width:t,height:i}=e;super.updateLayer(e),this.topLayer&&(this.topLayer.parent.setAttribute("width",t),this.topLayer.parent.setAttribute("height",i),this.topLayer.setAttribute("size",[t,i]),this.topLayer.setAttribute("pos",[t*.5,i*.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",t),this.snapshotFullLayer.parent.setAttribute("height",i),this.snapshotFullLayer.setAttribute("size",[t,i]),this.snapshotFullLayer.setAttribute("pos",[t*.5,i*.5]))}async updateDpr(e){super.updateDpr(e);const t=!!this.topLayerWork.localWorkShapes.size,i=!!this.localWork.getWorkShapes().size,o=[];i&&o.push({isClearAll:!0,clearCanvas:me.Float,viewId:this.viewId}),t&&o.push({isClearAll:!0,clearCanvas:me.TopFloat,viewId:this.viewId}),o.length&&await this.post({render:o})}async updateCamera(e){const t=[],{cameraOpt:i}=e;if(i&&!tt(this.cameraOpt,i)){const o=!!this.topLayerWork.localWorkShapes.size,n=!!this.localWork.getWorkShapes().size;if(n&&this.localWork.workShapesDone(),this.setCameraOpt(i),n&&t.push({isClearAll:!0,clearCanvas:me.Float,viewId:this.viewId}),o){t.push({isClearAll:!0,clearCanvas:me.TopFloat,viewId:this.viewId});for(const[r,c]of this.topLayerWork.localWorkShapes.entries())if(c.totalRect){let l;this.topLayer.getElementsByName(r.toString()).forEach(u=>{const h=u.getBoundingClientRect(),d=Wt({x:h.x,y:h.y,w:h.width,h:h.height});l=le(l,d)}),c.totalRect=l,this.topLayerWork.localWorkShapes.set(r,c)}}t.length&&await this.post({render:t})}}setCameraOpt(e,t){this.cameraOpt=e;const{scale:i,centerX:o,centerY:n,width:r,height:c}=e;(r!==this.scene.width||c!==this.scene.height)&&this.updateScene({width:r,height:c}),t?(t.setAttribute("scale",[i,i]),t.setAttribute("translate",[-o,-n])):(this.fullLayer.setAttribute("scale",[i,i]),this.fullLayer.setAttribute("translate",[-o,-n]),this.topLayer.setAttribute("scale",[i,i]),this.topLayer.setAttribute("translate",[-o,-n]))}async getSnapshot(e){const{scenePath:t,scenes:i,cameraOpt:o,w:n,h:r}=e;if(t&&i&&o&&this.snapshotFullLayer){const c=Ce(this.cameraOpt);this.setCameraOpt(o,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;let l;for(const[h,d]of Object.entries(i))if(d!=null&&d.type)switch(d==null?void 0:d.type){case x.UpdateNode:case x.FullWork:{const{opt:p}=d,f={...d,opt:p,workId:h,msgType:x.FullWork,dataType:F.Service,viewId:this.viewId},g=await this.localWork.runFullWork(f);l=le(l,g);break}}let u;n&&r&&(u={resizeWidth:n,resizeHeight:r}),await this.getSnapshotRender({scenePath:t,curCameraOpt:c,options:u}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0}}async getSnapshotRender(e){var r;const{scenePath:t,curCameraOpt:i,options:o}=e;((r=this.snapshotFullLayer)==null?void 0:r.parent).render();const n=await this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:me.None},!0,o);n&&(this._post({sp:[{type:x.Snapshot,scenePath:t,imageBitmap:n,viewId:this.viewId}]},[n]),n.close(),this.snapshotFullLayer&&Re(this.snapshotFullLayer,this.snapshotFullLayer.parent),this.setCameraOpt(i,this.fullLayer))}async getBoundingRect(e){const{scenePath:t,scenes:i,cameraOpt:o}=e;if(t&&i&&o&&this.snapshotFullLayer){const n=Ce(this.cameraOpt);this.setCameraOpt(o,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;let r;for(const[c,l]of Object.entries(i))if(l!=null&&l.type)switch(l==null?void 0:l.type){case x.UpdateNode:case x.FullWork:{const u=await this.localWork.runFullWork({...l,workId:c,msgType:x.FullWork,dataType:F.Service,viewId:this.viewId});r=le(r,u);break}}r&&await this.post({sp:[{type:x.BoundingBox,scenePath:t,rect:r}]}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0,Re(this.snapshotFullLayer,this.snapshotFullLayer.parent),this.setCameraOpt(n,this.fullLayer)}}}class Bt extends B{constructor(e){super(e);y(this,"canRotate",!0);y(this,"scaleType",re.all);y(this,"toolsType",N.Image);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");this.workOptions=e.toolsOpt,this.scaleType=Bt.getScaleType(this.workOptions)}consume(){return{type:x.None}}consumeAll(){return{type:x.None}}draw(e){const{layer:t,workId:i,replaceId:o,imageBitmap:n}=e,{centerX:r,centerY:c,width:l,height:u,rotate:h,zIndex:d,eraserlines:p}=this.workOptions,f=new ce.Group({anchor:[.5,.5],pos:[r,c],name:i,size:[l,u],zIndex:d,rotate:h}),g={anchor:[.5,.5],pos:[0,0],size:[l,u],texture:n};n||(g.bgcolor="rgba(0,0,0,0.3)");const M=new ce.Sprite(g);f.append(M),p&&this.drawEraserlines({group:f,eraserlines:p,pos:[r,c],layer:t}),this.replace(t,o||i,f);const S=f.getBoundingClientRect();if(S)return{x:Math.floor(S.x-B.SafeBorderPadding),y:Math.floor(S.y-B.SafeBorderPadding),w:Math.floor(S.width+B.SafeBorderPadding*2),h:Math.floor(S.height+B.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(e){var u,h,d,p;const{isFullWork:t,replaceId:i,worker:o}=e,{src:n,uuid:r}=this.workOptions,c=((u=this.workId)==null?void 0:u.toString())||r,l=t?this.fullLayer:this.drawLayer||this.fullLayer;if(n){const f=await o.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:c,isSubWorker:o instanceof Gy});if(f){const g=this.draw({workId:c,layer:l,replaceId:i,imageBitmap:f});return this.oldRect=c&&((d=(h=this.vNodes)==null?void 0:h.get(c))==null?void 0:d.rect)||void 0,(p=this.vNodes)==null||p.setInfo(c,{rect:g,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:g&&B.getCenterPos(g,l)}),g}}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(e){const{uniformScale:t,rotate:i}=e;return t!==!1||i&&Math.abs(i)%90>0?re.proportional:re.all}static updateNodeOpt(e){const{node:t,opt:i,vNodes:o,targetNode:n}=e,{translate:r,originPoint:c,scenePoint:l,scale:u,angle:h,isLocked:d,zIndex:p,strokeColor:f}=i,g=n&&Ce(n)||o.get(t.name);if(!g)return;const M=t.parent;if(M){if(f&&(g.opt.strokeColor=f),be(p)&&(t.setAttribute("zIndex",p),g.opt.zIndex=p),Tt(d)&&(g.opt.locked=d),c&&l&&u&&r){const{centerX:S,centerY:w,width:I,height:k,uniformScale:T}=g.opt,v=T!==!1?[u[0],u[0]]:u,P=[S,w],C=[S,w];ci(C,l,v,r);const L=[C[0]-P[0],C[1]-P[1]];if(g.centerPos=[g.centerPos[0]+L[0],g.centerPos[1]+L[1]],g.opt.width=Math.round(I*v[0]),g.opt.height=Math.round(k*v[1]),g.opt.centerX=C[0],g.opt.centerY=C[1],g.opt.eraserlines)for(const O of Object.values(g.opt.eraserlines)){const{op:R,thickness:E}=O;O.thickness=E*Math.max(u[0],u[1]);for(let j=0;j<R.length;j++)li(R[j],l,u,r)}}else if(r){if(g.opt.centerX=g.opt.centerX+r[0],g.opt.centerY=g.opt.centerY+r[1],g.centerPos=[g.centerPos[0]+r[0],g.centerPos[1]+r[1]],g.opt.eraserlines)for(const S of Object.values(g.opt.eraserlines)){const{op:w}=S;for(let I=0;I<w.length;I++){const k=w[I].map((T,v)=>v%2?T+r[1]:T+r[0]);S.op[I]=k}}}else if(be(h))if(g.opt.rotate=h,g.scaleType=Bt.getScaleType(g.opt),n){const S=nn(g.rect,h);g.rect=S}else{const S=B.getRectFromLayer(M,t.name);g.rect=S||g.rect}return g&&o.setInfo(t.name,g),g==null?void 0:g.rect}}}function le(a,s){if(a&&s){const e=Math.min(a.x,s.x),t=Math.min(a.y,s.y),i=Math.max(a.x+a.w,s.x+s.w),o=Math.max(a.y+a.h,s.y+s.h),n=i-e,r=o-t;return{x:e,y:t,w:n,h:r}}return s||a}function ai(a,s){if(a&&s){const e=Math.min(a.originX,s.originX),t=Math.min(a.originY,s.originY),i=Math.max(a.originX+a.width,s.originX+s.width),o=Math.max(a.originY+a.height,s.originY+s.height),n=i-e,r=o-t;return{originX:e,originY:t,width:n,height:r}}return s||a}function fe(a,s=0){const e={x:0,y:0,w:0,h:0};let t=1/0,i=1/0,o=-1/0,n=-1/0;return a.forEach(r=>{const[c,l]=r.XY;t=Math.min(t,c-s),i=Math.min(i,l-s),o=Math.max(o,c+s),n=Math.max(n,l+s)}),e.x=t,e.y=i,e.w=o-t,e.h=n-i,e}function Rs(a,s){return!(a.x+a.w<s.x||a.x>s.x+s.w||a.y+a.h<s.y||a.y>s.y+s.h)}function Wt(a,s=10){return{x:Math.floor(a.x-s),y:Math.floor(a.y-s),w:Math.ceil(a.w+s*2),h:Math.ceil(a.h+s*2)}}function Ft(a,s){return{x:a.x+s[0],y:a.y+s[1],w:a.w,h:a.h}}function Zy(a,s){const e=new b(a.x,a.y),t=new b(a.x+a.w,a.y),i=new b(a.x+a.w,a.y+a.h),o=new b(a.x,a.y+a.h),n=new b(a.x+a.w/2,a.y+a.h/2),r=Math.PI*s/180,c=b.RotWith(e,n,r),l=b.RotWith(t,n,r),u=b.RotWith(i,n,r),h=b.RotWith(o,n,r);return[c,l,u,h]}function nn(a,s){const e=Zy(a,s);return fe(e)}function rn(a,s,e){const t=new b(a.x,a.y),i=new b(a.x+a.w,a.y),o=new b(a.x+a.w,a.y+a.h),n=new b(a.x,a.y+a.h),r=new b(e[0],e[1]),c=new b(s[0],s[1]),l=b.ScaleWOrigin(t,c,r),u=b.ScaleWOrigin(i,c,r),h=b.ScaleWOrigin(o,c,r),d=b.ScaleWOrigin(n,c,r);return fe([l,u,h,d])}function qy(a,s,e){const t=new b(s[0],s[1]);for(let i=0;i<a.length;i+=3){const o=new b(a[i],a[i+1]),n=Math.PI*e/180,r=b.RotWith(o,t,n);a[i]=r.x,a[i+1]=r.y}}function Xy(a,s,e){const t=new b(s[0],s[1]);for(let i=0;i<a.length;i+=2){const o=new b(a[i],a[i+1]),n=Math.PI*e/180,r=b.RotWith(o,t,n);a[i]=r.x,a[i+1]=r.y}}function ci(a,s,e,t=[0,0]){const i=new b(s[0],s[1]);for(let o=0;o<a.length;o+=3){const n=new b(a[o],a[o+1]),r=new b(e[0],e[1]),c=b.ScaleWOrigin(n,r,i);a[o]=c.x+t[0],a[o+1]=c.y+t[1]}}function li(a,s,e,t=[0,0]){const i=new b(s[0],s[1]);for(let o=0;o<a.length;o+=2){const n=new b(a[o],a[o+1]),r=new b(e[0],e[1]),c=b.ScaleWOrigin(n,r,i);a[o]=c.x+t[0],a[o+1]=c.y+t[1]}}function an(a,s){return a[0]>=s.x&&a[0]<=s.x+s.w&&a[1]>=s.y&&a[1]<=s.y+s.h}function cn(a,s){const e=a<=s?1:a/s,t=s<=a?1:s/a;return[e,t]}function Jy(a){for(const s of a)if(isNaN(s)||s===1/0||s===-1/0)return!1;return!0}function Ky(a){return a!==Math.floor(a)}function _y(a){const s=a.toString();return s.indexOf(".")!==-1?s.split(".")[1].length:0}function em(a,s){for(;s!==0;)[a,s]=[s,a%s];return a}const tm=a=>{if(a.tagName==="GROUP"){const s=Object.getOwnPropertySymbols(a).find(e=>e.toString()==="Symbol(sealed)");if(s&&a[s])return!0}return!1},Oe=(a,s)=>{if(a.mesh&&a.mesh.texture&&a.name==="eraserTexture"){const e=a.mesh.texture.image;s.deleteTexture(e)}else if(a.tagName==="GROUP"&&a&&a.children)for(const e of a.children)Oe(e,s)},Re=(a,s)=>{Oe(a,s),a.removeAllChildren()},sm=(a,s,e)=>{const t=e.parent;if(s){const i=s.children;if(i){for(const o of i)if(Oe(o,t),o.tagName==="GROUP")for(const n of o.children)Oe(n,t)}}s.parent.replaceChild(a,s)},im=(a,s,e)=>{if(a.w+a.x<=0||a.h+a.y<=0||a.w<=0||a.h<=0)return;const t=s.width,i=s.height,o={x:Math.floor(Math.max(0,a.x)),y:Math.floor(Math.max(0,a.y)),w:Math.floor(Math.min(t,a.w)),h:Math.floor(Math.min(i,a.h))};if(o.x+o.w>t&&(o.w=Math.floor(t-o.x)),o.y+o.h>i&&(o.h=Math.floor(i-o.y)),Ky(e)){const n=_y(e),r=Math.pow(10,n),c=em(r,e*r),l=o.x%c,u=o.x-l;u>=0?(o.x=u,o.w=o.w+l):(o.x=0,o.w=o.w+l-u);const h=o.y%c,d=o.y-h;d>=0?(o.y=d,o.h=o.h+h):(o.y=0,o.h=o.h+h-d)}return o};function Mt(a){return`${as(a.x)},${as(a.y)} `}function wt(a,s){return`${as((a.x+s.x)/2)},${as((a.y+s.y)/2)} `}function as(a){return+a.toFixed(4)}const st=async(a,s)=>{let e,t;return new Promise(function(i){if(typeof window.requestIdleCallback=="function"){const o=typeof s=="number"&&!isNaN(s)&&s>0?s:0;t=window.requestIdleCallback(()=>{clearTimeout(e),i(1)},{timeout:o})}e=setTimeout(()=>{t&&window.cancelIdleCallback(t),i(1)},s||0)}).then(function(){a()}).catch(function(){a()})},it=a=>{const s=(a==null?void 0:a.webkitBackingStorePixelRatio)||(a==null?void 0:a.mozBackingStorePixelRatio)||(a==null?void 0:a.msBackingStorePixelRatio)||(a==null?void 0:a.oBackingStorePixelRatio)||(a==null?void 0:a.backingStorePixelRatio)||1;return Math.max(1,(window.devicePixelRatio||1)/s)},hi=(a,s)=>a.x+a.w<s.x||a.x>s.x+s.w||a.y+a.h<s.y||a.y>s.y+s.h?ft.outside:a.x>=s.x&&a.y>=s.y&&a.x+a.w<=s.x+s.w&&a.y+a.h<=s.y+s.h?ft.inside:ft.intersect;function om(a){let s=0;for(let e=0;e<a.length;e++){const t=a.charCodeAt(e);t>=1&&t<=126||65376<=t&&t<=65439?s++:s+=2}return s}class nm{constructor(s,e){y(this,"plugin");y(this,"uid");y(this,"control");this.control=s,this.plugin=e,this.uid=e.displayer.uid}getNamespaceData(){var s;return G.toJS((s=this.plugin)==null?void 0:s.attributes[this.namespace])||{}}getAuthSpaceData(){var s;return G.toJS((s=this.plugin)==null?void 0:s.attributes[this.authSpace])||{}}getUidFromKey(s){return s.split(Ee).length===2&&s.split(Ee)[0]||this.uid}isLocalId(s){return s.split(Ee).length===1}getLocalId(s){return s.split(Ee)[1]}isSelector(s){return this.getLocalId(s)===H}}const Ie=class Ie extends nm{constructor(e,t,i){super(e,t);y(this,"authSpace");y(this,"namespace");y(this,"serviceStorage",{});y(this,"storage",{});y(this,"authStorage",{});y(this,"stateDisposer");y(this,"authDisposer");y(this,"asyncClockState",!1);y(this,"limitNums",new Map);y(this,"limitComponents",A.debounce((e,t)=>{var n,r,c,l,u,h,d,p;const i=((r=(n=this.storage)==null?void 0:n[e])==null?void 0:r[t])&&Object.keys(this.storage[e][t]).length||0;if(i===0)return;let o=this.limitNums.get(`${e}/${t}`);if(!o){const f=this.getLimitNum(i);this.limitNums.set(`${e}/${t}`,f),o=f}if(o>0&&i>=o){const f=Ie.componentsLimits.indexOf(o),g=f>=0&&f<Ie.componentsLimits.length-1;if((u=(l=(c=this.control.room)==null?void 0:c.callbacks)==null?void 0:l.listeners)!=null&&u.map.onObjectsLimit&&((d=(h=this.control.room)==null?void 0:h.callbacks)==null||d.dispatch("onObjectsLimit",S=>S(o,g))),!g){this.control.room.logger.error(`exceeds the limit of ${o} components, current: ${i}`),(p=this.control.room)==null||p.disconnect().then(()=>{var S,w,I,k,T;(I=(w=(S=this.control.room)==null?void 0:S.callbacks)==null?void 0:w.listeners)!=null&&I.map.onKickedWithReason&&((T=(k=this.control.room)==null?void 0:k.callbacks)==null||T.dispatch("onKickedWithReason",v=>v("kickByAdmin")))});return}console.warn(`exceeds the limit of ${o} components, current: ${i}`);const M=g?Ie.componentsLimits[f+1]:0;this.limitNums.set(`${e}/${t}`,M)}},2e3,{maxWait:5e3}));y(this,"clearLimitComponents",(e,t)=>{if(t)this.limitNums.delete(`${e}/${t}`);else for(const i of this.limitNums.keys())`${e}/`.indexOf(i)===0&&this.limitNums.delete(i)});Ie.syncInterval=(i||Ie.syncInterval)*.5,this.namespace=Ie.namespace,this.authSpace=Ie.authSpace,this.serviceStorage=this.getNamespaceData(),this.storage=A.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData(),this.getLimitNums()}getLimitNum(e){return e>=Ie.componentsLimits[0]?Ie.componentsLimits[1]:Ie.componentsLimits[0]}getLimitNums(){for(const[e,t]of Object.entries(this.storage))if(e&&t){for(const[i,o]of Object.entries(t))if(i&&o){const n=this.getLimitNum(Object.keys(o).length);this.limitNums.set(`${e}/${i}`,n)}}}getViewIdBySecenPath(e){const t=this.getNamespaceData();for(const[i,o]of Object.entries(t))if(o){for(const n of Object.keys(o))if(n===e)return i}}getScenePathData(e){const t=this.getNamespaceData();for(const i of Object.values(t))if(i){for(const o of Object.keys(i))if(o===e)return A.cloneDeep(i[o])}}getStorageData(e,t){const i=this.getNamespaceData();return i&&i[e]&&A.cloneDeep(i[e][t])||void 0}hasSelector(e,t){const i=this.storage&&this.storage[e]&&this.storage[e][t];return!!(i&&Object.keys(i).find(o=>this.isOwn(o)&&this.getLocalId(o)===H))}addStorageStateListener(e){this.stateDisposer=G.autorun(async()=>{var c,l,u,h,d,p;const t=this.getNamespaceData(),{diffView:i,diffScenePath:o,diffData:n}=this.diffFunByView(this.serviceStorage,t);this.serviceStorage=t;const r={};if(Object.keys(i).length>0)for(const[f,g]of Object.entries(i))g&&!A.isEqual((c=this.storage)==null?void 0:c[f],g.newValue)&&(r.diffView||(r.diffView={}),r.diffView[f]=g,this.storage||(this.storage={}),g.newValue===void 0?delete this.storage[f]:this.storage[f]=A.cloneDeep(g.newValue));if(Object.keys(o).length>0){for(const[f,g]of Object.entries(o))if(g){const{viewId:M,newValue:S}=g;g&&!A.isEqual((u=(l=this.storage)==null?void 0:l[M])==null?void 0:u[f],S)&&(r.diffScenePath||(r.diffScenePath={}),r.diffScenePath[f]=g,this.storage||(this.storage={}),this.storage[M]||(this.storage[M]={}),g.newValue===void 0?delete this.storage[M][f]:this.storage[M][f]=A.cloneDeep(g.newValue))}}if(Object.keys(n).length>0){for(const[f,g]of Object.entries(n))if(g){const{viewId:M,scenePath:S,newValue:w}=g;g&&!A.isEqual((p=(d=(h=this.storage)==null?void 0:h[M])==null?void 0:d[S])==null?void 0:p[f],w)&&(r.diffData||(r.diffData={}),r.diffData[f]=g,this.storage||(this.storage={}),this.storage[M]||(this.storage[M]={}),this.storage[M][S]||(this.storage[M][S]={}),g.newValue===void 0?delete this.storage[M][S][f]:this.storage[M][S][f]=A.cloneDeep(g.newValue))}}Object.keys(r).length>0&&e(r)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(e,t){const i=Le(e),o=Le(t),n={},r={},c={};for(const l of o)if(!i.includes(l)||e[l]===void 0){n[l]={newValue:t[l],oldValue:void 0};continue}for(const l of i){if(A.isEqual(e[l],t[l]))continue;if(!o.includes(l)||t[l]===void 0){n[l]={newValue:void 0,oldValue:e[l]};continue}const u=this.diffFunByScenePath(e[l],t[l],l);Object.assign(r,u.diffScenePath),Object.assign(c,u.diffData)}return{diffData:c,diffScenePath:r,diffView:n}}diffFunByScenePath(e,t,i){const o=Le(e),n=Le(t),r={},c={};for(const l of n)if(!o.includes(l)||e[l]===void 0){r[l]={newValue:t[l],oldValue:void 0,viewId:i};continue}for(const l of o){if(A.isEqual(e[l],t[l]))continue;if(!n.includes(l)||t[l]===void 0){r[l]={newValue:void 0,oldValue:e[l],viewId:i};continue}const u=this.diffFunByKeys(e[l],t[l],l,i);Object.assign(c,u)}return{diffScenePath:r,diffData:c}}diffFunByKeys(e,t,i,o){const n=Le(e),r=Le(t),c={};for(const l of r)(!n.includes(l)||e[l]===void 0)&&(c[l]={oldValue:void 0,newValue:t[l],viewId:o,scenePath:i});for(const l of n)if(!A.isEqual(e[l],t[l])){if(!r.includes(l)||t[l]===void 0){c[l]={newValue:void 0,oldValue:e[l],viewId:o,scenePath:i};continue}r.includes(l)&&(c[l]={oldValue:e[l],newValue:t[l],viewId:o,scenePath:i})}return c}transformKey(e){return this.uid+Ee+e}isOwn(e){return e.split(Ee)[0]===this.uid}dispatch(e){const{type:t,workId:i,ops:o,index:n,opt:r,toolsType:c,removeIds:l,updateNodeOpt:u,op:h,selectIds:d,isSync:p,scenePath:f,viewId:g}=e;if(g)switch(t){case x.Clear:const M={};f&&this.storage[g]&&this.storage[g][f]?(delete this.storage[g][f],this.setState(M,{isSync:p,viewId:g,scenePath:f})):this.storage[g]&&(delete this.storage[g],this.setState(M,{isSync:p,viewId:g,scenePath:""})),st(()=>{var T;this.control.pluginManager.dispatchPluginEvent("syncStorage",g,f),(T=this.control.miniMapManager)==null||T.updateMiniMapCamera(g),this.clearLimitComponents(g,f)},Ie.syncInterval);break;case x.CreateWork:if(f&&i&&c&&r){const T=this.isLocalId(i.toString())?this.transformKey(i):i;this.control.renderControl.isUsePageAuth(g)&&this.control.renderControl.addRenderPageElementId({viewId:g,scenePath:f,elementId:T.toString()}),this.updateValue(T.toString(),{type:x.CreateWork,workId:i,toolsType:c,opt:r},{isSync:p,viewId:g,scenePath:f})}break;case x.DrawWork:if(f&&i&&typeof n=="number"&&(h!=null&&h.length)){const T=this.isLocalId(i.toString())?this.transformKey(i):i,v=this.storage[g]&&this.storage[g][f]&&this.storage[g][f][T]||void 0;if(v!=null&&v.ops||(v==null?void 0:v.type)===x.FullWork)return;const P=n?((v==null?void 0:v.op)||[]).slice(0,n).concat(h):h||(v==null?void 0:v.op),C=c||(v==null?void 0:v.toolsType),L=r||(v==null?void 0:v.opt),O=u||(v==null?void 0:v.updateNodeOpt);i&&C&&L&&P&&(this.control.renderControl.isUsePageAuth(g)&&this.control.renderControl.addRenderPageElementId({viewId:g,scenePath:f,elementId:T.toString()}),this.updateValue(T.toString(),{...v,type:x.DrawWork,workId:i,updateNodeOpt:O,toolsType:C,opt:L,op:P,index:n},{isSync:p,viewId:g,scenePath:f}))}break;case x.FullWork:if(f&&i){const T=this.isLocalId(i.toString())?this.transformKey(i):i,v=this.storage[g]&&this.storage[g][f]&&this.storage[g][f][T]||void 0,P=u||(v==null?void 0:v.updateNodeOpt),C=c||(v==null?void 0:v.toolsType),L=r||(v==null?void 0:v.opt),O=o||(v==null?void 0:v.ops);C&&L&&(this.control.renderControl.isUsePageAuth(g)&&this.control.renderControl.addRenderPageElementId({viewId:g,scenePath:f,elementId:T.toString()}),this.updateValue(T.toString(),{type:x.FullWork,updateNodeOpt:P,workId:T,toolsType:C,opt:L,ops:O},{isSync:p,viewId:g,scenePath:f}),st(()=>{var R;this.control.pluginManager.dispatchPluginEvent("syncStorage",g,f),(R=this.control.miniMapManager)==null||R.updateMiniMapCamera(g),this.limitComponents(g,f)},Ie.syncInterval))}break;case x.RemoveNode:if(f&&(l!=null&&l.length)){const T=l.map(v=>this.isLocalId(v+"")?this.transformKey(v):v);this.storage[g]&&this.storage[g][f]&&(Object.keys(this.storage[g][f]).map(v=>{T!=null&&T.includes(v)&&(this.control.renderControl.isUsePageAuth(g)&&this.control.renderControl.delRenderPageElementId({viewId:g,scenePath:f,elementId:v}),this.updateValue(v,void 0,{isSync:p,viewId:g,scenePath:f}))}),st(()=>{var v;this.control.pluginManager.dispatchPluginEvent("syncStorage",g,f),(v=this.control.miniMapManager)==null||v.updateMiniMapCamera(g)},Ie.syncInterval))}break;case x.UpdateNode:if(f&&i&&(u||o||r)){const T=this.isLocalId(i.toString())?this.transformKey(i):i,v=this.storage[g]&&this.storage[g][f]&&this.storage[g][f][T]||void 0;v&&(v.updateNodeOpt=u,(o||h)&&(v.ops=o,v.op=h),r&&(v.opt=r),v.type=x.FullWork,this.updateValue(T.toString(),v,{isSync:p,viewId:g,scenePath:f}),st(()=>{var P;(P=this.control.miniMapManager)==null||P.updateMiniMapCamera(g)},Ie.syncInterval))}break;case x.Select:if(!f)return;let S;d!=null&&d.length&&(S=d.map(T=>this.isLocalId(T+"")?this.transformKey(T):T));const w=this.transformKey(H),I=this.storage[g]&&this.storage[g][f]&&this.storage[g][f][w]||void 0,k=r||(I==null?void 0:I.opt);S&&this.checkOtherSelector(w,S,{isSync:p,viewId:g,scenePath:f}),this.updateValue(w,S&&{type:x.Select,toolsType:N.Selector,opt:k,selectIds:S},{isSync:p,viewId:g,scenePath:f});break}}checkOtherSelector(e,t,i){const{viewId:o,scenePath:n}=i;for(const r of Object.keys(this.storage[o][n]))if(r!==e&&this.getLocalId(r)===H){const c=this.storage[o][n][r];if(c&&c.selectIds){const l=c.selectIds.filter(u=>!t.includes(u));l.length>0&&(c.selectIds=l),this.updateValue(r,l.length&&c||void 0,i)}}}setState(e,t){const{viewId:i,scenePath:o}=t,n=Le(e);for(let r=0;r<n.length;r++){const c=n[r],l=e[c];typeof l<"u"?(this.storage[i]||(this.storage[i]={}),this.storage[i][o]||(this.storage[i][o]={}),this.storage[i][o][c]=l):delete this.storage[i][o][c]}this.runSyncService(t)}updateValue(e,t,i){const{viewId:o,scenePath:n,storage:r}=i,c=r||this.storage;t===void 0?delete c[o][n][e]:(c[o]||(c[o]={}),c[o][n]||(c[o][n]={}),c[o][n][e]=t),this.runSyncService(i)}runSyncService(e){this.asyncClockState||(this.asyncClockState=!0,setTimeout(()=>{this.asyncClockState=!1,this.syncSerivice(e)},e.isSync?0:Ie.syncInterval))}syncSerivice(e={storage:this.storage}){const{storage:t}=e,i=t||this.storage,o=Le(this.serviceStorage),n=Le(i),r=new Map;for(const c of o){if(!n.includes(c)){r.set(c,void 0);continue}A.isEqual(this.serviceStorage[c],i[c])||this.syncViewData(i,c)}for(const c of n)o.includes(c)||r.set(c,i[c]);if(r.size>5)this.syncStorageView(i);else for(const[c,l]of r.entries())this.syncUpdataView(i,c,l)}syncViewData(e,t){const i=Le(this.serviceStorage[t]),o=Le(e[t]),n=new Map;for(const r of i){if(!o.includes(r)){n.set(r,void 0);continue}A.isEqual(this.serviceStorage[t][r],e[t][r])||this.syncScenePathData(e,t,r)}for(const r of o)i.includes(r)||n.set(r,e[t][r]);if(n.size>5)this.syncStorageScenePath(t,e[t]);else for(const[r,c]of n.entries())this.syncUpdataScenePath(e,t,r,c)}syncScenePathData(e,t,i){const o=Le(this.serviceStorage[t][i]),n=Le(e[t][i]),r=new Map;for(const c of o){if(!n.includes(c)){r.set(c,void 0);continue}A.isEqual(this.serviceStorage[t][i][c],e[t][i][c])||r.set(c,e[t][i][c])}for(const c of n)o.includes(c)||r.set(c,e[t][i][c]);if(r.size>5)this.syncStorageKey(t,i,e[t][i]);else for(const[c,l]of r.entries())this.syncUpdataKey(e,t,i,c,l)}syncUpdataView(e,t,i){var n;Object.keys(this.serviceStorage).length?(n=this.plugin)==null||n.updateAttributes([this.namespace,t],i):this.syncStorageView(e)}syncStorageView(e){var t;(t=this.plugin)==null||t.updateAttributes([this.namespace],e)}syncUpdataScenePath(e,t,i,o){var r;Object.keys(this.serviceStorage[t]).length?(r=this.plugin)==null||r.updateAttributes([this.namespace,t,i],o):this.syncStorageScenePath(t,e[t])}syncStorageScenePath(e,t){var i;(i=this.plugin)==null||i.updateAttributes([this.namespace,e],t)}syncUpdataKey(e,t,i,o,n){var c;Object.keys(this.serviceStorage[t][i]).length?(c=this.plugin)==null||c.updateAttributes([this.namespace,t,i,o],n):this.syncStorageKey(t,i,e[t][i])}syncStorageKey(e,t,i){var o;(o=this.plugin)==null||o.updateAttributes([this.namespace,e,t],i)}keyTransformWorkId(e){const t=e.split(Ee);return t.length===2?t[1]:e}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={}}dispatchPageAuth(e,t=!0){var l,u,h,d,p,f,g,M,S,w,I,k,T,v,P,C,L,O,R,E,j,D,q,oe,X,Z,_,Q,J,K,he,Se,Ae,ve,U,ae,ee,de;const{operation:i,viewId:o,scenePath:n,pageId:r,pageData:c}=e;switch(i){case De.addPage:{if(!o||!n||!r)return;const ue=[this.authSpace];Object.keys(this.authStorage).length&&ue.push("pageAuth");const ge=this.authStorage.pageAuth||{};this.authStorage.pageAuth=ge,Object.keys(ge).length&&ue.push(o),ge[o]=ge[o]||{},Object.keys(ge[o]).length&&ue.push(n),ge[o][n]=ge[o][n]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(ge[o][n].pages).length&&ue.push("pages",r);const ot={};if(c!=null&&c.elementIds)for(const nt of c.elementIds.keys())ot[nt]=!0;ge[o][n].pages[r]=ot,t&&(ue.length===1?(l=this.plugin)==null||l.updateAttributes(ue,A.cloneDeep(this.authStorage)):ue.length===2?(u=this.plugin)==null||u.updateAttributes(ue,A.cloneDeep(ge)):ue.length===3?(h=this.plugin)==null||h.updateAttributes(ue,A.cloneDeep(ge[o])):ue.length===4?(d=this.plugin)==null||d.updateAttributes(ue,A.cloneDeep(ge[o][n])):(p=this.plugin)==null||p.updateAttributes(ue,A.cloneDeep(ot)));return}case De.renderPage:{if(!o||!n||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[o]&&this.authStorage.pageAuth[o][n]&&c.render!==this.authStorage.pageAuth[o][n].render&&(this.authStorage.pageAuth[o][n].render=c.render,t&&((f=this.plugin)==null||f.updateAttributes([this.authSpace,"pageAuth",o,n,"render"],c.render)));return}case De.deletePage:{if(!o||!n||!r)return;(I=(w=(S=(M=(g=this.authStorage)==null?void 0:g.pageAuth)==null?void 0:M[o])==null?void 0:S[n])==null?void 0:w.pages)!=null&&I[r]&&(delete this.authStorage.pageAuth[o][n].pages[r],t&&((k=this.plugin)==null||k.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",r],void 0)));return}case De.clearPage:{if(!o||!n||!r)return;(L=(C=(P=(v=(T=this.authStorage)==null?void 0:T.pageAuth)==null?void 0:v[o])==null?void 0:P[n])==null?void 0:C.pages)!=null&&L[r]&&(delete this.authStorage.pageAuth[o][n].pages[r],t&&((O=this.plugin)==null||O.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",r],{})));return}case De.addElement:{if(!o||!n||!r||!(c!=null&&c.elementId))return;(q=(D=(j=(E=(R=this.authStorage)==null?void 0:R.pageAuth)==null?void 0:E[o])==null?void 0:j[n])==null?void 0:D.pages)!=null&&q[r]&&(this.authStorage.pageAuth[o][n].pages[r][c.elementId]=!0,t&&((oe=this.plugin)==null||oe.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",r,c.elementId],!0)));return}case De.deleteElement:{if(!o||!n||!r||!(c!=null&&c.elementId))return;(K=(J=(Q=(_=(Z=(X=this.authStorage)==null?void 0:X.pageAuth)==null?void 0:Z[o])==null?void 0:_[n])==null?void 0:Q.pages)==null?void 0:J[r])!=null&&K[c.elementId]&&(delete this.authStorage.pageAuth[o][n].pages[r][c.elementId],t&&((he=this.plugin)==null||he.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",r,c.elementId],void 0)));return}case De.clearViewScenePath:{if(!o||!n)return;(ve=(Ae=(Se=this.authStorage)==null?void 0:Se.pageAuth)==null?void 0:Ae[o])!=null&&ve[n]&&(delete this.authStorage.pageAuth[o][n],t&&((U=this.plugin)==null||U.updateAttributes([this.authSpace,"pageAuth",o,n],void 0)));return}case De.clearView:{if(!o)return;(ee=(ae=this.authStorage)==null?void 0:ae.pageAuth)!=null&&ee[o]&&(delete this.authStorage.pageAuth[o],t&&((de=this.plugin)==null||de.updateAttributes([this.authSpace,"pageAuth",o],void 0)));return}}}dispatchRenderAuth(e,t=!0){var l,u,h,d,p,f,g,M,S,w,I,k,T,v,P,C,L,O,R,E;const{operation:i,viewId:o,uid:n,renderData:r,isClear:c}=e;if(o)switch(i){case Qe.setAuth:{if(!r||r.render===void 0&&r.hide===void 0&&r.clear===void 0){this.authStorage.renderAuth&&this.authStorage.renderAuth[o]&&(delete this.authStorage.renderAuth[o],t&&((l=this.plugin)==null||l.updateAttributes([this.authSpace,"renderAuth",o],void 0)));return}const j=[this.authSpace];Object.keys(this.authStorage).length&&j.push("renderAuth");const D=this.authStorage.renderAuth||{};Object.keys(D).length&&j.push(o),D[o]={},this.authStorage.renderAuth=D;const{render:q,hide:oe,clear:X}=r;if(q===!0)D[o].render=!0;else if(A.isSet(q)){D[o].render={};for(const Z of q.keys())D[o].render[Z]=!0}if(oe===!0)D[o].hide=!0;else if(A.isSet(oe)){D[o].hide={};for(const Z of oe.keys())D[o].hide[Z]=!0}if(X===!0)D[o].clear=!0;else if(A.isSet(X)){D[o].clear={};for(const Z of X.keys())D[o].clear[Z]=!0}t&&(j.length===1?(u=this.plugin)==null||u.updateAttributes(j,A.cloneDeep(this.authStorage)):j.length===2?(h=this.plugin)==null||h.updateAttributes(j,A.cloneDeep(D)):(d=this.plugin)==null||d.updateAttributes(j,A.cloneDeep(D[o])));return}case Qe.setShow:{if(!n)return;const j=[this.authSpace];Object.keys(this.authStorage).length&&j.push("renderAuth");const D=this.authStorage.renderAuth||{};Object.keys(D).length&&j.push(o),D[o]=D[o]||{},this.authStorage.renderAuth=D,Object.keys(D[o]).length&&j.push("render"),D[o].render=D[o].render||{},D[o].render!==!0&&(Object.keys(D[o].render).length&&j.push(n),D[o].render[n]=!0),D[o].hide!==!0&&((p=D[o].hide)!=null&&p[n])&&(delete D[o].hide[n],t&&((f=this.plugin)==null||f.updateAttributes([this.authSpace,"renderAuth",o,"hide",n],void 0))),t&&(j.length===1?(g=this.plugin)==null||g.updateAttributes(j,A.cloneDeep(this.authStorage)):j.length===2?(M=this.plugin)==null||M.updateAttributes(j,A.cloneDeep(D)):j.length===3?(S=this.plugin)==null||S.updateAttributes(j,A.cloneDeep(D[o])):(w=this.plugin)==null||w.updateAttributes(j,!0));return}case Qe.setHide:{if(!n)return;const j=[this.authSpace];Object.keys(this.authStorage).length&&j.push("renderAuth");const D=this.authStorage.renderAuth||{};Object.keys(D).length&&j.push(o),D[o]=D[o]||{},this.authStorage.renderAuth=D,Object.keys(D[o]).length&&j.push("hide"),D[o].hide=D[o].hide||{},D[o].hide!==!0&&(Object.keys(D[o].hide).length&&j.push(n),D[o].hide[n]=!0),D[o].render!==!0&&((I=D[o].render)!=null&&I[n])&&(delete D[o].render[n],t&&((k=this.plugin)==null||k.updateAttributes([this.authSpace,"renderAuth",o,"render",n],void 0))),t&&(j.length===1?(T=this.plugin)==null||T.updateAttributes(j,A.cloneDeep(this.authStorage)):j.length===2?(v=this.plugin)==null||v.updateAttributes(j,A.cloneDeep(D)):j.length===3?(P=this.plugin)==null||P.updateAttributes(j,A.cloneDeep(D[o])):(C=this.plugin)==null||C.updateAttributes(j,!0));return}case Qe.setClear:{if(!n)return;const j=[this.authSpace];Object.keys(this.authStorage).length&&j.push("renderAuth");const D=this.authStorage.renderAuth||{};Object.keys(D).length&&j.push(o),D[o]=D[o]||{},this.authStorage.renderAuth=D,Object.keys(D[o]).length&&j.push("clear"),D[o].clear=D[o].clear||{},D[o].clear!==!0&&(Object.keys(D[o].clear).length&&j.push(n),c?D[o].clear[n]=!0:delete D[o].clear[n]),t&&(j.length===1?(L=this.plugin)==null||L.updateAttributes(j,A.cloneDeep(this.authStorage)):j.length===2?(O=this.plugin)==null||O.updateAttributes(j,A.cloneDeep(D)):j.length===3?(R=this.plugin)==null||R.updateAttributes(j,A.cloneDeep(D[o])):(E=this.plugin)==null||E.updateAttributes(j,c?!0:void 0));return}}}addAuthStateListener(e){this.authDisposer=G.autorun(async()=>{const t=this.getAuthSpaceData(),{renderAuth:i,pageAuth:o}=t;let n,r;A.isEqual(i,this.authStorage.renderAuth)||(n=this.diffAuthFun(this.authStorage.renderAuth||{},i||{}),this.authStorage.renderAuth=i),A.isEqual(o,this.authStorage.pageAuth)||(r=this.diffAuthPageFun(this.authStorage.pageAuth||{},o||{}),this.authStorage.pageAuth=o),(n||r)&&e(n,r)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(e,t){const i=Le(e),o=Le(t),n={};for(const r of o)if(!i.includes(r)||e[r]===void 0){n[r]={newValue:t[r],oldValue:void 0};continue}for(const r of i)if(!A.isEqual(e[r],t[r])){if(!o.includes(r)||t[r]===void 0){n[r]={newValue:void 0,oldValue:e[r]};continue}n[r]={newValue:t[r],oldValue:e[r]}}return n}diffAuthPageFun(e,t){const i=Le(e),o=Le(t),n={};for(const r of o)if(!i.includes(r)||e[r]===void 0){n[r]={newValue:t[r],oldValue:void 0};continue}for(const r of i)if(!A.isEqual(e[r],t[r])){if(!o.includes(r)||t[r]===void 0){n[r]={newValue:void 0,oldValue:e[r]};continue}n[r]={newValue:t[r],oldValue:e[r]}}return n}};y(Ie,"namespace","PluginState"),y(Ie,"authSpace","PluginAuth"),y(Ie,"syncInterval",500),y(Ie,"componentsLimits",[500,1e3]);let Ws=Ie;class rm{constructor(){y(this,"roomMembers",[]);y(this,"onChangeHooks",new Set)}setRoomMembers(s){this.executChangeUidHook(this.roomMembers,s),this.roomMembers=s}executChangeUidHook(s,e){const t={online:e.map(i=>{var o;return((o=i.payload)==null?void 0:o.uid)||i.session}),offline:s.map(i=>{var o;return((o=i.payload)==null?void 0:o.uid)||i.session})};this.onChangeHooks.forEach(i=>i(t))}getAllRoomMembers(){return this.roomMembers}getRoomMember(s){return this.roomMembers.find(e=>{var t;return((t=e.payload)==null?void 0:t.uid)===s})}isOnLine(s){return!!this.getRoomMember(s)}onUidChangeHook(s){this.onChangeHooks.add(s)}destroy(){this.onChangeHooks.clear()}}var Je=(a=>(a[a.Text=1]="Text",a[a.Shape=2]="Shape",a))(Je||{});const je=class je{createProxy(s){const e=new Proxy(s,{get(t,i,o){const n=je.interceptors.hasOwnProperty(i)?je.interceptors:t;return Reflect.get(n,i,o)}});return je.proxyToRaw.set(e,s),e}};y(je,"proxyToRaw",new WeakMap),y(je,"interceptors",{entries(...s){return je.proxyToRaw.get(this).entries(...s)},forEach(...s){return je.proxyToRaw.get(this).forEach(...s)},size(){return je.proxyToRaw.get(this).size},get(s){return je.proxyToRaw.get(this).get(s)},set(s,e){return je.proxyToRaw.get(this).set(s,e)},delete(s,e){return je.proxyToRaw.get(this).delete(s)},clear(){return je.proxyToRaw.get(this).clear()}});let ut=je;class am{constructor(s){y(this,"internalMsgEmitter");y(this,"publicMsgEmitter");y(this,"control");y(this,"editors");y(this,"activeId");y(this,"proxyMap");y(this,"taskqueue",new Map);const{control:e,internalMsgEmitter:t,publicMsgEmitter:i}=s;this.control=e,this.internalMsgEmitter=t,this.publicMsgEmitter=i;const o=new Map;this.proxyMap=new ut;const n=this,r=ut.interceptors.set;ut.interceptors.set=function(l,u){return n.interceptors.set(l,u),r.call(this,l,u)};const c=ut.interceptors.delete;ut.interceptors.delete=function(l,u){return n.interceptors.delete(l,u),c.call(this,l)},this.editors=this.proxyMap.createProxy(o)}get collector(){return this.control.collector}filterEditor(s){const e=new Map;return this.editors.forEach((t,i)=>{t.viewId===s&&e.set(i,t)}),e}get interceptors(){return{set:(s,e)=>{var p,f,g,M,S,w,I,k;if(!this.collector)return!0;const{viewId:t,scenePath:i,canSync:o,canWorker:n,type:r,opt:c,dataType:l}=e;if(!n&&!o)return!0;const h=((p=this.collector)==null?void 0:p.isLocalId(s))?(f=this.collector)==null?void 0:f.transformKey(s):s,d=((g=this.collector)==null?void 0:g.storage[t])&&this.collector.storage[t][i]&&this.collector.storage[t][i][h]||void 0;d?d.toolsType===N.Text&&(n&&(this.control.worker.queryTaskBatchData({workId:s,msgType:x.UpdateNode}).forEach(T=>{var v;(v=this.control.worker)==null||v.taskBatchData.delete(T)}),(I=this.control.worker)==null||I.taskBatchData.add({workId:s,msgType:x.UpdateNode,dataType:l||F.Local,toolsType:N.Text,opt:c,viewId:t,scenePath:i,willRefresh:!0}),(k=this.control.worker)==null||k.runAnimation()),o&&(st(()=>{var T;(T=this.collector)==null||T.dispatch({type:x.UpdateNode,workId:s,toolsType:N.Text,opt:c,viewId:t,scenePath:i})},this.control.worker.maxLastSyncTime),c.workState===z.Done&&this.control.runEffectWork(()=>{this.control.worker.setShapeSelectorByWorkId(s,t)}))):r===Je.Text&&(o&&((M=this.collector)==null||M.dispatch({type:c.text&&x.FullWork||x.CreateWork,workId:s,toolsType:N.Text,opt:c,isSync:!0,viewId:t,scenePath:i})),n&&((S=this.control.worker)==null||S.taskBatchData.add({workId:s,msgType:c.text&&x.FullWork||x.CreateWork,dataType:l||F.Local,toolsType:N.Text,opt:c,viewId:t,scenePath:i,willRefresh:!0}),(w=this.control.worker)==null||w.runAnimation()))},delete:s=>{var r,c;if(!this.collector)return!0;const e=this.editors.get(s);if(!e)return!0;const{viewId:t,scenePath:i,canSync:o,canWorker:n}=e;if(!n&&!o)return!0;n&&((r=this.control.worker)==null||r.taskBatchData.add({workId:s,toolsType:N.Text,msgType:x.RemoveNode,dataType:F.Local,viewId:t,scenePath:i,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),o&&st(()=>{var l;(l=this.collector)==null||l.dispatch({type:x.RemoveNode,removeIds:[s],toolsType:N.Text,viewId:t,scenePath:i})},this.control.worker.maxLastSyncTime)},clear(){return!0}}}computeTextActive(s,e){var o,n,r,c;const t=(o=this.control.viewContainerManager)==null?void 0:o.transformToScenePoint(s,e),i=(n=this.control.viewContainerManager)==null?void 0:n.getCurScenePath(e);e&&i&&((r=this.control.worker)==null||r.taskBatchData.add({msgType:x.GetTextActive,dataType:F.Local,op:t,viewId:e,scenePath:i}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var e;let s=this.activeId;for(const[t,i]of this.editors.entries())if(i.opt.uid&&i.opt.uid===((e=this.collector)==null?void 0:e.uid)){s=t;break}if(s){const t=this.editors.get(s);(t==null?void 0:t.opt.text)&&(t==null?void 0:t.opt.text.replace(/\s*,/g,""))?this.unActive(s):this.delete(s,!0,!0)}}onCameraChange(s,e){var t,i;for(const[o,n]of this.editors.entries())if(n.viewId===e){const{boxPoint:r,boxSize:c}=n.opt,l=r&&((t=this.control.viewContainerManager)==null?void 0:t.transformToOriginPoint(r,n.viewId)),u=(i=this.control.viewContainerManager)==null?void 0:i.getCurScenePath(e);if(u&&e){const h={x:l&&l[0]||0,y:l&&l[1]||0,w:c&&c[0]||0,h:c&&c[1]||0,opt:n.opt,scale:s.scale,type:Je.Text,viewId:e,scenePath:u,canWorker:!1,canSync:!1};this.editors.set(o,h),this.control.viewContainerManager.setActiveTextEditor(e,this.activeId)}}}onServiceDerive(s){var f,g;const{workId:e,opt:t,msgType:i,viewId:o,scenePath:n,dataType:r}=s;if(!e||!o||!n)return;const c=e.toString();if(i===x.RemoveNode){this.delete(c,!0,!0);return}const{boxPoint:l,boxSize:u}=t,h=l&&((f=this.control.viewContainerManager)==null?void 0:f.transformToOriginPoint(l,o)),d=this.control.viewContainerManager.getView(o),p={x:h&&h[0]||0,y:h&&h[1]||0,w:u&&u[0]||0,h:u&&u[1]||0,opt:t,type:Je.Text,canWorker:!0,canSync:!1,dataType:r,scale:((g=d==null?void 0:d.cameraOpt)==null?void 0:g.scale)||1,viewId:o,scenePath:n};this.editors.set(c,p),r===F.Service&&t.workState===z.Done&&this.activeId===c&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(o,this.activeId)}updateForViewEdited(s,e){var i;this.editors.set(s,e);const t=(i=this.taskqueue.get(s))==null?void 0:i.resolve;t&&t(e)}active(s){var t;const e=this.editors.get(s);e&&e.viewId&&(e.opt.workState=z.Start,e.opt.uid=(t=this.collector)==null?void 0:t.uid,this.activeId=s,e.canWorker=!0,e.canSync=!0,this.editors.set(s,e),this.control.viewContainerManager.setActiveTextEditor(e.viewId,this.activeId))}unActive(s){const e=this.editors.get(s);e&&e.viewId&&(e.opt.workState=z.Done,e.opt.uid=void 0,e.canWorker=!0,e.canSync=!0,this.editors.set(s,e),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(e.viewId,this.activeId))}createTextForMasterController(s,e){var n;const{workId:t,isActive:i,...o}=s;e&&this.internalMsgEmitter.emit("addUndoTicker",e,o.viewId),o.opt.uid=(n=this.collector)==null?void 0:n.uid,i&&(this.activeId=t),o.dataType=F.Local,o.canWorker=!0,o.canSync=!0,this.editors.set(t,o),this.control.viewContainerManager.setActiveTextEditor(o.viewId,this.activeId)}updateTextForMasterController(s,e){var n;const{workId:t,...i}=s;e&&this.internalMsgEmitter.emit("addUndoTicker",e,i.viewId);const o=this.editors.get(t)||{};i.opt&&(i.opt.uid=(n=this.collector)==null?void 0:n.uid),i.dataType=F.Local,this.editors.set(t,{...o,...i}),this.control.viewContainerManager.setActiveTextEditor(i.viewId,this.activeId)}async updateTextControllerWithEffectAsync(s,e){var u;const{workId:t,...i}=s;e&&this.internalMsgEmitter.emit("addUndoTicker",e,i.viewId);const o=this.editors.get(t)||{};i.opt&&(i.opt.uid=(u=this.collector)==null?void 0:u.uid),i.dataType=F.Local;const n={...o,...i};if(this.editors.set(t,n),this.control.viewContainerManager.setActiveTextEditor(i.viewId,this.activeId),this.taskqueue.has(t)){const h=this.taskqueue.get(t);return h&&(h.clocker&&clearTimeout(h.clocker),this.taskqueue.delete(t)),await this.updateTextControllerWithEffectAsync(s)}const r=setTimeout(()=>{var d;const h=(d=this.taskqueue.get(t))==null?void 0:d.resolve;h&&h(n)},50),c=await new Promise(h=>{this.taskqueue.set(t,{resolve:h,clocker:r})}),l=this.taskqueue.get(t);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(t)),c}updateTextForWorker(s,e){const{workId:t,isActive:i,...o}=s,r={...this.editors.get(t)||{},...o};if(i){r.canWorker=!1,r.canSync=!1,this.editors.set(t,r),this.active(t);return}this.editors.set(t,r),this.control.viewContainerManager.setActiveTextEditor(o.viewId,this.activeId),e&&this.internalMsgEmitter.emit("addUndoTicker",e,o.viewId)}get(s){return this.editors.get(s)}delete(s,e,t){const i=this.editors.get(s);if(i){const o=i.viewId;i.canSync=e,i.canWorker=t,this.editors.delete(s),this.activeId===s&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(o,this.activeId)}}deleteBatch(s,e,t){const i=new Set;for(const o of s){const n=this.editors.get(o);if(n){const r=n.viewId;n.canSync=e,n.canWorker=t,this.editors.delete(o),this.activeId===o&&(this.activeId=void 0),i.add(r)}}for(const o of i)this.control.viewContainerManager.setActiveTextEditor(o,this.activeId)}clear(s,e){this.editors.forEach((t,i)=>{t.viewId===s&&(e&&(t.canSync=!1),t.canWorker=!1,this.editors.delete(i))}),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(s,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}}class cm{constructor(s){y(this,"expirationTime",we.cursor.expirationTime);y(this,"internalMsgEmitter");y(this,"control");y(this,"eventName","applianc-cursor");y(this,"displayer");y(this,"roomMember");y(this,"animationId");y(this,"maxLastSyncTime",we.syncOpt.interval);y(this,"willSendEventWorkers",[]);y(this,"willConsumeEventWorkers",new Map);y(this,"sendEventTimerId");y(this,"animationDrawWorkers",new Map);y(this,"animationEventWorkers",new Map);y(this,"cursorInfoMap",new Map);y(this,"doneRenderCursorInfoMap",new Map);y(this,"eventCollector");var i,o;const{control:e,internalMsgEmitter:t}=s;this.internalMsgEmitter=t,this.control=e,this.roomMember=e.roomMember,this.maxLastSyncTime=((o=(i=this.control.pluginOptions)==null?void 0:i.syncOpt)==null?void 0:o.interval)||this.maxLastSyncTime}activeCollector(){this.control.plugin&&(this.displayer=this.control.room||this.control.play,this.displayer.addMagixEventListener(this.eventName,this.mainMagixEventListener.bind(this)))}mainMagixEventListener(s){var r;const{event:e,payload:t}=s;if(e!==this.eventName)return;const{uid:i,op:o,type:n}=t;if(((r=this.control.collector)==null?void 0:r.uid)!==i&&n===Yt.Cursor&&(o!=null&&o.length)){const c=this.willConsumeEventWorkers.get(i)||[];for(const l of o){const{viewId:u}=l;A.isNumber(l.consumPoint[0])&&A.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,u)),this.control.renderControl.isFilterCursor(u)&&c.unshift({...l,timestamp:Date.now()})}this.willConsumeEventWorkers.set(i,c),this.runAnimation()}}onFocusViewChange(){this.checkDrawWorks(),this.runAnimation()}updateRoomMembers(s){const{offline:e}=s;for(const t of this.cursorInfoMap.keys())t&&e.includes(t)&&this.cursorInfoMap.delete(t)}getKey(s,e){return`${s}${Ee}${e}`}getUidAndviewId(s){const[e,t]=s.split(Ee);return{uid:e,viewId:t}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var e;const s=this.control.viewContainerManager.focuedViewId;for(const[t,i]of this.animationDrawWorkers.entries()){const{viewId:o,uid:n}=this.getUidAndviewId(t);n!==((e=this.control.collector)==null?void 0:e.uid)&&o!==s&&i.workState===z.Done&&(i.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const s=Date.now();for(const[t,i]of this.animationDrawWorkers.entries()){const{uid:o,viewId:n}=this.getUidAndviewId(t),r=this.roomMember.getRoomMember(o);if(!r){this.animationDrawWorkers.delete(t);continue}const{consumPoint:c,timestamp:l,workState:u}=i,h=this.cursorInfoMap.get(n)||new Map;c&&A.isNumber(c[0])&&A.isNumber(c[1])&&l+this.expirationTime>s?h.set(r.memberId,{x:c[0],y:c[1],roomMember:r,timestamp:l,type:1,workState:u}):h.delete(r.memberId),h.size?this.cursorInfoMap.set(n,h):this.cursorInfoMap.delete(n),this.animationDrawWorkers.delete(t)}const e=new Set;for(const[t,i]of this.cursorInfoMap.entries())if(i)for(const[o,n]of i.entries())n.type===1&&n.workState!==z.Done&&e.add(o);else this.cursorInfoMap.delete(t);for(const[t,i]of this.willConsumeEventWorkers.entries()){const o=this.roomMember.getRoomMember(t);if(A.isNumber(o==null?void 0:o.memberId)&&!e.has(o.memberId)){const n=i.pop();n?this.animationEventWorkers.set(t,n):this.willConsumeEventWorkers.delete(t)}}for(const[t,i]of this.animationEventWorkers.entries()){const o=this.roomMember.getRoomMember(t);if(!o){this.animationEventWorkers.delete(t);continue}const{viewId:n,consumPoint:r,timestamp:c}=i,l=this.cursorInfoMap.get(n)||new Map;r&&A.isNumber(r[0])&&A.isNumber(r[1])&&c+this.expirationTime>s?l.set(o.memberId,{x:r[0],y:r[1],roomMember:o,timestamp:c,type:0}):l.delete(o.memberId),l.size?this.cursorInfoMap.set(n,l):this.cursorInfoMap.delete(n),this.animationEventWorkers.delete(t)}for(const t of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(t)||(this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([se.Cursor,t],[]));for(const[t,i]of this.cursorInfoMap.entries())if(i!=null&&i.size){const o=[];for(const[r,c]of i.entries()){const{timestamp:l,...u}=c;l+this.expirationTime>s?o.push(u):(i.delete(r),i.size===0&&(this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([se.Cursor,t],[])))}const n=this.doneRenderCursorInfoMap.get(t);A.isEqual(n,o)||(this.doneRenderCursorInfoMap.set(t,o),this.internalMsgEmitter.emit([se.Cursor,t],o))}else this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([se.Cursor,t],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(s,e){if(this.displayer&&G.isRoom(this.displayer)){const t=A.isNumber(s[0])&&A.isNumber(s[1])&&this.control.viewContainerManager.transformToScenePoint(s,e)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:t,viewId:e}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var s;this.displayer&&G.isRoom(this.displayer)&&this.displayer.isWritable&&this.displayer.dispatchMagixEvent(this.eventName,{type:Yt.Cursor,op:A.cloneDeep(this.willSendEventWorkers),uid:(s=this.control.collector)==null?void 0:s.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(s){var n;const{op:e,uid:t,workState:i,viewId:o}=s;if(t&&e&&i&&o){const r=this.roomMember.getRoomMember(t);if(!r||t===((n=this.control.collector)==null?void 0:n.uid))return;const c=this.getKey(t,o);let l=[void 0,void 0];if(A.isNumber(e[0])&&A.isNumber(e[1])){const[h,d]=this.control.viewContainerManager.transformToOriginPoint(e,o);l=[h,d]}if(i===z.Start){for(const h of this.cursorInfoMap.values())if(h!=null&&h.size)for(const d of h.keys())d===r.memberId&&h.delete(d)}const u={consumPoint:l,workState:i,viewId:o,timestamp:Date.now()};if(i===z.Start||i===z.Done){const h=this.willConsumeEventWorkers.get(t);i===z.Start&&h&&this.willConsumeEventWorkers.delete(t),h&&i===z.Done&&(u.timestamp=u.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,u),this.runAnimation()}}unabled(){var s;this.displayer&&G.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Yt.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(s=this.control.collector)==null?void 0:s.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0))}clearViewCursor(s){var e,t,i;for(const[o]of this.animationDrawWorkers.entries()){const{uid:n}=this.getUidAndviewId(o);n===((e=this.control.collector)==null?void 0:e.uid)&&s===s&&this.animationDrawWorkers.delete(o)}for(const[o]of this.willConsumeEventWorkers.entries())o===((t=this.control.collector)==null?void 0:t.uid)&&this.willConsumeEventWorkers.delete(o);for(const[o]of this.animationEventWorkers.entries())o===((i=this.control.collector)==null?void 0:i.uid)&&this.animationEventWorkers.delete(o);for(const[o]of this.cursorInfoMap.entries())o===o&&(this.cursorInfoMap.delete(o),this.doneRenderCursorInfoMap.delete(o),this.internalMsgEmitter.emit([se.Cursor,o],[]))}stopAnimation(){this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.cursorInfoMap.clear()}destroy(){var s;(s=this.displayer)==null||s.removeMagixEventListener(this.eventName),this.stopAnimation()}}class Fe{constructor(){y(this,"useEmtMsg");y(this,"emtType");y(this,"control");y(this,"mainEngine");y(this,"collectListener",(s,e)=>{this.collect(s,e)})}static dispatch(s,e,t){var i;(i=Ne.InternalMsgEmitter)==null||i.emit([s,e],t)}get serviceColloctor(){return this.control.collector}registerForMainEngine(s,e){return this.emtType=s,this.control=e,this.mainEngine=e.worker,this.mainEngine.internalMsgEmitter.on([this.emtType,this.emitEventType],this.collectListener),this}destroy(){this.emtType&&this.mainEngine&&this.mainEngine.internalMsgEmitter.off([this.emtType,this.emitEventType],this.collectListener)}collectForLocalWorker(s,e){var t,i,o;for(const[n,r]of s)(t=this.mainEngine)==null||t.queryTaskBatchData(r).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(i=this.mainEngine)==null||i.taskBatchData.add(n);if(e){this.mainEngine.consume();return}(o=this.mainEngine)==null||o.runAnimation()}collectForServiceWorker(s){st(()=>{s.forEach(e=>{var t;(t=this.serviceColloctor)==null||t.dispatch(e)})},this.mainEngine.maxLastSyncTime)}pause(){var s;if(this.lastEmtData){this.useEmtMsg=!0;const e={...this.lastEmtData,workState:z.Done};this.collect(e,!0),(s=Ne.InternalMsgEmitter)==null||s.emit(V.ActiveMethod,!1)}}recover(){var s;this.useEmtMsg&&Ne.InternalMsgEmitter.hasListeners(V.ActiveMethod)&&((s=Ne.InternalMsgEmitter)==null||s.emit(V.ActiveMethod,!0))}}class lm extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.CopyNode)}collect(e){var c;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:i}=e,o=this.control.viewContainerManager.getView(i);if(!(o!=null&&o.displayer))return;const n=o.focusScenePath,r=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",r,i);for(const l of t){const u=l.toString(),d=this.serviceColloctor.isLocalId(u)?this.serviceColloctor.transformKey(l):u,p=(c=this.serviceColloctor.getStorageData(i,n))==null?void 0:c[d];if(p){if(l===H){const f=p&&this.copySelector({viewId:i,store:p});f&&this.pasteSelector({...f,viewId:i,scenePath:n,undoTickerId:r});break}if(p.toolsType===N.Text&&p.opt&&p.opt.workState&&p.opt.workState!==z.Done){const f=p&&this.copyText({viewId:i,store:p});f&&this.pasteText({...f,viewId:i,scenePath:n,key:d,store:p,undoTickerId:r});break}}}}copyText(e){const{viewId:t,store:i}=e,o=this.control.viewContainerManager.getView(t);if(!this.serviceColloctor||!o)return;const n=o==null?void 0:o.cameraOpt,r=n&&[n.centerX,n.centerY],c=i.opt,l=c.boxPoint&&c.boxSize&&[c.boxPoint[0]+c.boxSize[0]/2,c.boxPoint[1]+c.boxSize[1]/2];return{bgCenter:r,textCenter:l}}pasteText(e){var M,S;const{bgCenter:t,textCenter:i,store:o,key:n,viewId:r,scenePath:c,undoTickerId:l}=e,u=this.control.viewContainerManager.getView(r);if(!this.serviceColloctor||!u)return;const h=Math.floor(Math.random()*30+1),d=((M=u.cameraOpt)==null?void 0:M.scale)||1,p=t&&i&&[t[0]-i[0]+h,t[1]-i[1]+h]||[h/d,h/d],g=(this.serviceColloctor.isLocalId(n)?n:this.serviceColloctor.getLocalId(n.toString()))+"-"+l;if(o.toolsType===N.Text&&o.opt){const w=o.opt;if(w&&w.boxPoint&&w.text){w.workState=z.Done;const I=w.boxPoint;w.boxPoint=[I[0]+p[0],I[1]+p[1]],w.workState=z.Done;const k=this.control.viewContainerManager.transformToOriginPoint(w.boxPoint,r);this.control.textEditorManager.createTextForMasterController({workId:g,x:k[0],y:k[1],opt:w,scale:((S=u.cameraOpt)==null?void 0:S.scale)||1,type:Je.Text,isActive:!1,viewId:r,scenePath:c}),this.collectForServiceWorker([{...o,opt:w,type:x.FullWork,workId:g,viewId:r,scenePath:c}])}}}copySelector(e){var g,M,S,w,I,k,T,v,P;const{viewId:t,store:i}=e,o=this.control.viewContainerManager.getView(t),n=i.selectIds;if(!this.serviceColloctor||!(n!=null&&n.length)||!o)return;const r=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((g=o.cameraOpt)==null?void 0:g.centerX)||0,centerY:((M=o.cameraOpt)==null?void 0:M.centerY)||0,scale:((S=o.cameraOpt)==null?void 0:S.scale)||1}},l=this.control.hasOffscreenCanvas()&&((w=o.displayer.canvasBgRef.current)==null?void 0:w.getBoundingClientRect())||((I=o.displayer.canvasContainerRef.current)==null?void 0:I.getBoundingClientRect()),u=(T=(k=o.displayer)==null?void 0:k.floatBarRef.current)==null?void 0:T.getBoundingClientRect(),h=l&&[l.x+l.width/2,l.y+l.height/2],d=u&&[u.x+u.width/2,u.y+u.height/2],p=h&&o.viewData&&o.viewData.convertToPointInWorld({x:h[0],y:h[1]}),f=d&&o.viewData&&o.viewData.convertToPointInWorld({x:d[0],y:d[1]});p&&f&&(c.offset={x:p.x-f.x,y:p.y-f.y});for(const C of n){const L=(P=(v=this.serviceColloctor)==null?void 0:v.getStorageData(o.id,o.focusScenePath))==null?void 0:P[C];L&&r.set(C,L)}return{copyStores:r,copyCoordInfo:c}}pasteSelector(e){var M,S;const{copyStores:t,copyCoordInfo:i,viewId:o,scenePath:n,undoTickerId:r}=e,c=this.control.viewContainerManager.getView(o);if(!t.size||!this.serviceColloctor||!c)return;const{offset:l,cameraOpt:u}=i,{scale:h}=u,d=Math.floor(Math.random()*30+1),p=l&&[l.x+d,l.y+d]||[d/h,d/h],f=[],g=[];for(const[w,I]of t.entries()){const T=(this.serviceColloctor.isLocalId(w)?w:this.serviceColloctor.getLocalId(w.toString()))+"-"+r,v={useAnimation:!1};if(I.toolsType===N.Text&&I.opt){const C=I.opt;if(C&&C.boxPoint&&C.text){C.workState=z.Done;const L=C.boxPoint;C.boxPoint=[L[0]+p[0],L[1]+p[1]],C.workState=z.Done;const O=this.control.viewContainerManager.transformToOriginPoint(C.boxPoint,o);this.control.textEditorManager.createTextForMasterController({workId:T,x:O[0],y:O[1],opt:C,scale:((M=c.cameraOpt)==null?void 0:M.scale)||1,type:Je.Text,isActive:!1,viewId:o,scenePath:n})}g.push({...I,opt:C,type:x.FullWork,workId:T,viewId:o,scenePath:n});continue}if(I.toolsType===N.Image&&(I.opt.uuid=T,I.opt.centerX=I.opt.centerX+p[0],I.opt.centerY=I.opt.centerY+p[1]),I.ops){const C=lt(I.ops).map((O,R)=>{const E=R%3;return E===0?O+p[0]:E===1?O+p[1]:O}),L=We(C);I.ops=L}const P=((S=I==null?void 0:I.opt)==null?void 0:S.eraserlines)??[];if(P.length)for(const C of Object.values(P)){const{op:L}=C;for(let O=0;O<L.length;O++){const R=L[O].map((E,j)=>j%2?E+p[1]:E+p[0]);C.op[O]=R}}g.push({...I,updateNodeOpt:v,type:x.FullWork,workId:T,viewId:o,scenePath:n}),f.push([{...I,updateNodeOpt:v,workId:T,msgType:x.FullWork,dataType:F.Local,emitEventType:V.CopyNode,willSyncService:!1,willRefresh:!0,viewId:o},{workId:T,msgType:x.FullWork,emitEventType:V.CopyNode}])}f.length&&this.collectForLocalWorker(f),g.length&&this.collectForServiceWorker(g)}}function Ht(a,s,e){return"#"+((a<<16)+(s<<8)+e).toString(16).padStart(6,"0")}function ke(a,s=1){return"rgba("+parseInt("0x"+a.slice(1,3))+","+parseInt("0x"+a.slice(3,5))+","+parseInt("0x"+a.slice(5,7))+","+s+")"}function vt(a,s,e,t=1){return`rgba(${a},${s},${e},${t})`}function vs(a){const s=a.split(","),e=parseInt(s[0].split("(")[1]),t=parseInt(s[1]),i=parseInt(s[2]),o=Number(s[3].split(")")[0]);return[Ht(e,t,i),o]}function Zt(a){const s=a.split(","),e=parseInt(s[0].split("(")[1]),t=parseInt(s[1]),i=parseInt(s[2]),o=Number(s[3].split(")")[0]);return[e,t,i,o]}function qt(a){return a==="transparent"}class hm extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.SetColorNode);y(this,"undoTickerId")}setTextColor(e,t,i,o){const{fontColor:n,fontBgColor:r}=i;t.opt&&(n&&(t.opt.fontColor=n),r&&(t.opt.fontBgColor=r),this.control.textEditorManager.updateTextForMasterController({workId:e,opt:t.opt,viewId:o,canSync:!0,canWorker:!0}))}collect(e){var w,I;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,strokeColor:i,fillColor:o,fontColor:n,fontBgColor:r,viewId:c,workState:l,thickness:u,strokeType:h}=e,d=this.control.viewContainerManager.getView(c);if(!(d!=null&&d.displayer))return;const p=d.focusScenePath,f=[...t],g=this.serviceColloctor.storage,M=[],S={};for((l===z.Start||!this.undoTickerId&&l===z.Done)&&(this.undoTickerId=Date.now(),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));f.length;){const k=f.pop();if(!k)continue;const T=k.toString(),v=this.serviceColloctor.isLocalId(T),P=v?this.serviceColloctor.transformKey(k):T;let C=T;!v&&this.serviceColloctor.isOwn(C)&&(C=this.serviceColloctor.getLocalId(C));const L=(I=(w=g==null?void 0:g[c])==null?void 0:w[p])==null?void 0:I[P];if(L){const O=L.updateNodeOpt||{};if(n||r){if(n){O.fontColor=n;const[E,j,D,q]=Zt(n);S.textColor=[E,j,D],S.textOpacity=q}if(r)if(O.fontBgColor=qt(r)?"transparent":r,qt(r))S.textBgColor=void 0,S.textBgOpacity=void 0;else{const[E,j,D,q]=Zt(r);S.textBgColor=[E,j,D],S.textBgOpacity=q}if(L.toolsType===N.Text&&L.opt&&l!==z.Start){this.setTextColor(C,Ce(L),O,c),l===z.Done&&(this.undoTickerId=void 0);continue}}if(i){O.strokeColor=i;const[E,j,D,q]=Zt(i);S.strokeColor=[E,j,D],S.strokeOpacity=q}if(o)if(O.fillColor=qt(o)?"transparent":o,qt(o))S.fillColor=void 0,S.fillOpacity=void 0;else{const[E,j,D,q]=Zt(o);S.fillColor=[E,j,D],S.fillOpacity=q}u&&(O.thickness=u,S.strokeWidth=u),h&&(O.strokeType=h,S.strokeType=h);const R={workId:C,msgType:x.UpdateNode,dataType:F.Local,updateNodeOpt:O,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c};M.push([R,{workId:C,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}}M.length&&(l===z.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(M)),Object.keys(S).length&&setTimeout(()=>{var k;(k=this.control.room)==null||k.setMemberState(S)},0)}}class um extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.ZIndexNode);y(this,"zIndexMap",new Map)}clearZIndex(e){this.zIndexMap.delete(e)}getMinZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.min)||0}getMaxZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.max)||0}setMaxZIndex(e,t){const i=this.getMinZIndex(t);this.zIndexMap.set(t,{min:i,max:e})}setMinZIndex(e,t){const i=this.getMaxZIndex(t);this.zIndexMap.set(t,{min:e,max:i})}addMaxLayer(e){const t=this.getMaxZIndex(e)+1;this.setMaxZIndex(t,e)}addMinLayer(e){const t=this.getMinZIndex(e)-1;this.setMinZIndex(t,e)}correct(e){const t=e.sort((i,o)=>i[1]-o[1]);for(let i=1;i<t.length;i++){const o=t[i][1],n=t[i-1][1];o<=n&&(t[i][1]=n+1)}return t}collect(e){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,layer:i,viewId:o}=e,n=this.control.viewContainerManager.getView(o);if(!(n!=null&&n.displayer))return;const r=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,u=[],h=[];for(;c.length;){const p=c.pop();if(!p)continue;const f=p.toString(),g=this.serviceColloctor.isLocalId(f),M=g?this.serviceColloctor.transformKey(p):f;let S=f;!g&&this.serviceColloctor.isOwn(S)&&(S=this.serviceColloctor.getLocalId(S));const w=Ce(l[o][r][M]);let I;if(w&&S===H){if(w.selectIds){h.push(...w.selectIds),h.sort((P,C)=>{var R,E,j,D;const L=((E=(R=l[d(P,this.serviceColloctor)])==null?void 0:R.opt)==null?void 0:E.zIndex)||0,O=((D=(j=l[d(P,this.serviceColloctor)])==null?void 0:j.opt)==null?void 0:D.zIndex)||0;return L>O?1:P<C?-1:0});const k=w.updateNodeOpt||{};k.zIndexLayer=i;const T={workId:p,msgType:x.UpdateNode,dataType:F.Local,updateNodeOpt:k,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:o},v=new Map;i===Ut.Top?(this.addMaxLayer(o),I=this.getMaxZIndex(o)):(this.addMinLayer(o),I=this.getMinZIndex(o)),h.forEach(P=>{var R,E,j,D,q;const C=(R=this.serviceColloctor)==null?void 0:R.isLocalId(P);let L=C&&((E=this.serviceColloctor)==null?void 0:E.transformKey(P))||P;const O=(D=(j=l==null?void 0:l[o])==null?void 0:j[r])==null?void 0:D[L];O&&(!C&&((q=this.serviceColloctor)!=null&&q.isOwn(L))&&(L=this.serviceColloctor.getLocalId(L)),k.zIndex=I,O!=null&&O.opt&&(O.opt.zIndex=I),O!=null&&O.opt&&v.set(L,{updateNodeOpt:O.updateNodeOpt,opt:O.opt}))}),T.selectStore=v,T.willSerializeData=!0,u.push([T,{workId:p,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}continue}}u.length&&this.collectForLocalWorker(u);function d(p,f){return f.isLocalId(p)&&f.transformKey(p)||p}}}class dm extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.TranslateNode);y(this,"cachePosition")}collect(e,t){var f,g,M;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,position:o,workState:n,viewId:r}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(r);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,u=[...i],h=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=n===z.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,r);u.length;){const S=u.pop();if(!S)continue;const w=S.toString(),I=this.serviceColloctor.isLocalId(w),k=I&&this.serviceColloctor.transformKey(S)||w;let T=w;!I&&this.serviceColloctor.isOwn(T)&&(T=this.serviceColloctor.getLocalId(T));const v=(M=(g=h==null?void 0:h[r])==null?void 0:g[l])==null?void 0:M[k];if(v&&T===H){if(v.selectIds){const P=this.control.viewContainerManager.transformToScenePoint([o.x,o.y],r);if(n===z.Start&&(this.cachePosition=P),this.cachePosition){const C=v.updateNodeOpt||{};C.translate=[P[0]-this.cachePosition[0],P[1]-this.cachePosition[1]],C.workState=n;const L={workId:S,msgType:x.UpdateNode,dataType:F.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:r};n===z.Done&&(L.textUpdateForWoker=!0,L.willSerializeData=!0,this.cachePosition=void 0),d.push([L,{workId:S,msgType:x.UpdateNode,emitEventType:this.emitEventType,workState:n}])}}continue}}n===z.Start?this.mainEngine.unWritable():n===z.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,t)}}class pm extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.DeleteNode)}collect(e){var d,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:i}=e,o=this.control.viewContainerManager.getView(i);if(!(o!=null&&o.displayer))return;const n=o.focusScenePath,r=this.serviceColloctor.storage,c=[...t],l=[],u=[],h=Date.now();for(;c.length;){const f=c.pop();if(!f)continue;const g=f.toString(),M=this.serviceColloctor.isLocalId(g),S=M?this.serviceColloctor.transformKey(f):g,w=(p=(d=r==null?void 0:r[i])==null?void 0:d[n])==null?void 0:p[S];if(w){let I=g;if(!M&&this.serviceColloctor.isOwn(I)&&(I=this.serviceColloctor.getLocalId(I)),w.toolsType===N.Text){this.control.textEditorManager.delete(I,!0,!0);continue}u.push(I)}}u.length&&(l.push([{msgType:x.RemoveNode,emitEventType:V.DeleteNode,removeIds:u,dataType:F.Local,willSyncService:!0,willRefresh:!0,viewId:i},void 0]),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,i),this.collectForLocalWorker(l))}}class fm extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.ScaleNode);y(this,"targetText",new Map);y(this,"cacheTextInfo",new Map)}async setTextStyle(e,t,i){const o=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t,viewId:i,canSync:!1,canWorker:!1});return{key:e,textInfo:o}}async collect(e,t){var w,I,k,T,v,P,C;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,workState:o,viewId:n,originPoint:r,scenePoint:c,dir:l,scale:u,translate:h}=e;this.lastEmtData=e;const d=this.control.viewContainerManager.getView(n);if(!(d!=null&&d.displayer))return;const p=d.focusScenePath,f=[...i],g=(w=this.serviceColloctor)==null?void 0:w.storage,M=[],S=o===z.Start&&Date.now()||void 0;for(S&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",S,n);f.length;){const L=f.pop();if(!L)continue;const O=L.toString(),R=this.serviceColloctor.isLocalId(O),E=R&&this.serviceColloctor.transformKey(L)||O;let j=O;!R&&this.serviceColloctor.isOwn(j)&&(j=this.serviceColloctor.getLocalId(j));const D=(k=(I=g==null?void 0:g[n])==null?void 0:I[p])==null?void 0:k[E];if(D&&j===H&&D.selectIds){const q=D.updateNodeOpt||{};if(q.dir=l,q.originPoint=r,q.scenePoint=c,q.workState=o,q.scale=u,q.translate=h,o===z.Start){this.cacheTextInfo.clear();for(const X of D.selectIds){const Z=(T=this.serviceColloctor)==null?void 0:T.isLocalId(X),_=Z&&((v=this.serviceColloctor)==null?void 0:v.transformKey(X))||X;let Q=_;!Z&&((P=this.serviceColloctor)!=null&&P.isOwn(_))&&(Q=this.serviceColloctor.getLocalId(_));const J=this.control.textEditorManager.get(Q);J&&o===z.Start&&this.targetText.set(Q,Ce(J))}}if(this.targetText.size&&o!==z.Start&&u){const X=[];for(const[_,Q]of this.targetText.entries()){const{opt:J}=Q,K=Math.floor(J.fontSize*u[0]),he=this.cacheTextInfo.get(_),Se=!he&&J.fontSize!==K||he&&he.fontSize!==K||!1,Ae=(C=this.control.textEditorManager.get(_))==null?void 0:C.opt;if(Se&&Ae&&J.boxSize&&J.boxPoint){const ve=this.setTextStyle(_,{...Ae,fontSize:K},n);X.push(ve)}}const Z=await Promise.all(X);for(const _ of Z)if(_){const{key:Q,textInfo:J}=_;this.cacheTextInfo.set(Q,{fontSize:J.opt.fontSize,boxSize:J.opt.boxSize,boxPoint:J.opt.boxPoint})}q.textInfos=this.cacheTextInfo}const oe={workId:L,msgType:x.UpdateNode,dataType:F.Local,updateNodeOpt:q,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};o===z.Done&&(oe.willSerializeData=!0,this.targetText.clear()),M.push([oe,{workId:L,msgType:x.UpdateNode,emitEventType:this.emitEventType,workState:o}]);continue}}o===z.Start?this.mainEngine.unWritable():o===z.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),M.length&&this.collectForLocalWorker(M,t)}}class gm extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.RotateNode);y(this,"cacheOriginRotate",0)}collect(e,t){var f,g,M,S,w,I,k;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,angle:o,workState:n,viewId:r}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(r);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,u=[...i],h=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=n===z.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,r);u.length;){const T=u.pop();if(!T)continue;const v=T.toString(),P=this.serviceColloctor.isLocalId(v),C=P&&this.serviceColloctor.transformKey(T)||v;let L=v;!P&&this.serviceColloctor.isOwn(L)&&(L=this.serviceColloctor.getLocalId(L));const O=(M=(g=h==null?void 0:h[r])==null?void 0:g[l])==null?void 0:M[C];if(O&&L===H){if(((S=O.selectIds)==null?void 0:S.length)===1){const R=O.selectIds[0];if(n===z.Start){const q=((w=this.serviceColloctor)==null?void 0:w.isLocalId(R))&&((I=this.serviceColloctor)==null?void 0:I.transformKey(R))||R,oe=h[r][l][q];this.cacheOriginRotate=((k=oe==null?void 0:oe.opt)==null?void 0:k.rotate)||0}const E=O.updateNodeOpt||{};E.angle=(o+this.cacheOriginRotate)%360,E.workState=n;const j={workId:T,msgType:x.UpdateNode,dataType:F.Local,updateNodeOpt:E,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:r};n===z.Done&&(j.willRefreshSelector=!0,j.willSerializeData=!0,this.cacheOriginRotate=0),d.push([j,{workId:T,msgType:x.UpdateNode,emitEventType:this.emitEventType,workState:n}])}continue}}n===z.Start?this.mainEngine.unWritable():n===z.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,t)}}function ym(a){switch(a){case N.Text:return Je.Text;case N.SpeechBalloon:case N.Star:case N.Ellipse:case N.Rectangle:case N.Triangle:case N.Rhombus:case N.Polygon:return Je.Shape}}class mm extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.SetFontStyle);y(this,"timerId")}async setTextStyle(e,t,i,o){const{bold:n,underline:r,lineThrough:c,italic:l,fontSize:u}=i;if(t.toolsType&&ym(t.toolsType)===Je.Text){t.opt&&(n&&(t.opt.bold=n),A.isBoolean(r)&&(t.opt.underline=r),A.isBoolean(c)&&(t.opt.lineThrough=c),l&&(t.opt.italic=l),u&&(t.opt.fontSize=u));const d=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t.opt,viewId:o,canSync:!1,canWorker:!1});return{key:e,textInfo:d}}}async collect(e){var w,I,k,T,v,P;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,bold:i,italic:o,lineThrough:n,underline:r,viewId:c,fontSize:l}=e,u=this.control.viewContainerManager.getView(c);if(!(u!=null&&u.displayer))return;const h=u.focusScenePath,d=[...t],p=this.serviceColloctor.storage,f={},g=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",g,c);const M=[];for(;d.length;){const C=d.pop();if(!C)continue;const L=C.toString(),O=this.serviceColloctor.isLocalId(L),R=O?this.serviceColloctor.transformKey(C):L;let E=L;!O&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const j=(I=(w=p==null?void 0:p[c])==null?void 0:w[h])==null?void 0:I[R];if(j){const D=j.updateNodeOpt||{};if(i&&(D.bold=i,f.bold=i==="bold"),o&&(D.italic=o,f.italic=o==="italic"),A.isBoolean(n)&&(D.lineThrough=n,f.lineThrough=n),A.isBoolean(r)&&(D.underline=r,f.underline=r),l&&(D.fontSize=l,f.textSize=l),j.toolsType===N.Text&&j.opt){const q=this.setTextStyle(E,A.cloneDeep(j),D,c);M.push(q);continue}if(j&&E===H&&((k=j.selectIds)!=null&&k.length))for(const q of j.selectIds){const oe=(T=this.serviceColloctor)==null?void 0:T.isLocalId(q);let X=oe&&((v=this.serviceColloctor)==null?void 0:v.transformKey(q))||q;const Z=p[c][h][X]||void 0;if(!oe&&((P=this.serviceColloctor)!=null&&P.isOwn(X))&&(X=this.serviceColloctor.getLocalId(X)),Z&&Z.toolsType===N.Text&&j.opt){const _=this.setTextStyle(X,A.cloneDeep(Z),D,c);M.push(_);continue}}}}const S=await Promise.all(M);for(const C of S)if(C){const{key:L,textInfo:O}=C;O&&(O.canSync=!0,O.canWorker=!0,this.control.textEditorManager.updateForViewEdited(L,O))}Object.keys(f).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var C;this.timerId=void 0,(C=this.control.room)==null||C.setMemberState(f)},0))}}class Mm extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.SetPoint);y(this,"undoTickerId")}collect(e){var w,I,k;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:t,pointMap:i,workState:o,viewId:n}=e,r=this.control.viewContainerManager.getView(n);if(!(r!=null&&r.displayer))return;const c=r.focusScenePath,l=(w=this.serviceColloctor)==null?void 0:w.storage,u=[],h=o===z.Start&&Date.now()||void 0;h&&(this.undoTickerId=h,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,n));const d=t;if(!d)return;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),g=f&&this.serviceColloctor.transformKey(d)||p;let M=p;!f&&this.serviceColloctor.isOwn(M)&&(M=this.serviceColloctor.getLocalId(M));const S=(k=(I=l==null?void 0:l[n])==null?void 0:I[c])==null?void 0:k[g];if(S&&M===H&&S.selectIds){const T=S.updateNodeOpt||{};T.pointMap=i,T.workState=o;const v={workId:d,msgType:x.UpdateNode,dataType:F.Local,updateNodeOpt:T,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};o===z.Done&&(v.undoTickerId=this.undoTickerId),u.push([v,{workId:d,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}o===z.Start?this.mainEngine.unWritable():o===z.Done&&this.mainEngine.abled(),u.length&&this.collectForLocalWorker(u)}}class wm extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.SetLock)}collect(e){var d,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,isLocked:i,viewId:o}=e,n=this.control.viewContainerManager.getView(o);if(!(n!=null&&n.displayer))return;const r=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,u=[],h=Date.now();for(;c.length;){const f=c.pop();if(!f)continue;const g=f.toString(),M=this.serviceColloctor.isLocalId(g),S=M?this.serviceColloctor.transformKey(f):g;let w=g;!M&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const I=(p=(d=l==null?void 0:l[o])==null?void 0:d[r])==null?void 0:p[S];if(I){const k=I.updateNodeOpt||{};k.isLocked=i;const T={workId:w,msgType:x.UpdateNode,dataType:F.Local,updateNodeOpt:k,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:o};u.push([T,{workId:w,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}}this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,o),u.length&&this.collectForLocalWorker(u)}}class vm extends Fe{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",V.SetShapeOpt)}collect(e){var d,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:i,...o}=e,n=this.control.viewContainerManager.getView(i);if(!(n!=null&&n.displayer))return;const r=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,u=[],h=Date.now();for(;c.length;){const f=c.pop();if(!f)continue;const g=f.toString(),M=this.serviceColloctor.isLocalId(g),S=M?this.serviceColloctor.transformKey(f):g;let w=g;!M&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const I=(p=(d=l==null?void 0:l[i])==null?void 0:d[r])==null?void 0:p[S];if(I){const k={...I.updateNodeOpt,...o,willRefresh:!0};if(I&&w===H){const T={workId:w,msgType:x.UpdateNode,dataType:F.Local,updateNodeOpt:k,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:i};u.push([T,{workId:w,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}}}u.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,i),this.collectForLocalWorker(u))}}class ie{constructor(s){y(this,"builders",new Map);this.builders=new Map(s.map(e=>[e,this.build(e)]))}build(s){switch(s){case V.TranslateNode:return new dm;case V.ZIndexNode:return new um;case V.CopyNode:return new lm;case V.SetColorNode:return new hm;case V.DeleteNode:return new pm;case V.ScaleNode:return new fm;case V.RotateNode:return new gm;case V.SetFontStyle:return new mm;case V.SetPoint:return new Mm;case V.SetLock:return new wm;case V.SetShapeOpt:return new vm}}getBuilder(s){return this.builders.get(s)}registerForMainEngine(s,e){return this.builders.forEach(t=>{t&&t.registerForMainEngine(s,e)}),this}destroy(){this.builders.forEach(s=>{s&&s.destroy()}),this.builders.clear()}pause(){return this.builders.forEach(s=>{s&&s.pause()}),this}recover(){return this.builders.forEach(s=>{s&&s.recover()}),this}static emitMethod(s,e,t){Fe.dispatch(s,e,t)}static activeListener(s){Ne.InternalMsgEmitter.on(V.ActiveMethod,s)}static unmountActiveListener(s){Ne.InternalMsgEmitter.off(V.ActiveMethod,s)}}class Im{constructor(s){y(this,"master");y(this,"mainThreadWorkerMap",new Map);this.master=s}updateCamera(){for(const[s,e]of this.mainThreadWorkerMap.entries()){const t=this.master.control.viewContainerManager.getView(s);if(t){const{cameraOpt:i}=t;e.updateCamera({cameraOpt:i,viewId:t.viewId,msgType:x.UpdateCamera,dataType:F.Local})}}}notifyDrawCount(s){const e=this.master.getFullWorkDrawCount(),t=this.mainThreadWorkerMap.get(s);t&&t.clearDrawLayer(e)}clearDrawCount(s){const e=this.mainThreadWorkerMap.get(s);e&&e.clearDrawLayer(1/0)}createMainThreadWorker(s,e){return new Tm(s,e,this)}consume(s){var e;for(const t of s.values()){const{msgType:i,viewId:o,layerOpt:n,offscreenCanvasOpt:r,cameraOpt:c}=t;if(i===x.Console){console.log(this);continue}if(i===x.Init){const u=(e=this.master.control.viewContainerManager.getView(o))==null?void 0:e.displayer,h=u==null?void 0:u.subLocalCanvasContainerRef.current;if(u&&h&&n&&r){const d=this.createMainThreadWorker(o,{displayer:u,container:h,layerOpt:n,master:this.master,canvasOpt:r,post:this.post.bind(this)});this.mainThreadWorkerMap.set(o,d),d&&c&&d.setCameraOpt(c)}continue}if(i===x.TasksQueue)continue;const l=this.mainThreadWorkerMap.get(o);l&&(l.on(t),i===x.Destroy&&(l.destroy(),this.mainThreadWorkerMap.delete(o)))}}post(s){const{sp:e}=s;e&&this.master.collectorSyncData(e)}destroy(){for(const s of this.mainThreadWorkerMap.values())s.destroy();this.mainThreadWorkerMap.clear()}active(){}}class Tm{constructor(s,e,t){y(this,"viewId");y(this,"opt");y(this,"manager");y(this,"subLocalLayer");y(this,"subLocalWork");y(this,"scene");y(this,"cameraOpt");this.viewId=s,this.opt=e,this.manager=t,this.scene=this.createScene({...e.canvasOpt,container:e.container});const i=we.bufferSize.full,o=we.bufferSize.sub;this.subLocalLayer=this.createLayer("subLocalLayer",this.scene,{...e.layerOpt,bufferSize:this.viewId===pe?i:o,contextType:"2d"});const n={thread:this};this.subLocalWork=new Sm(n)}createScene(s){return new ce.Scene({displayRatio:this.opt.displayer.dpr,depth:!1,desynchronized:!0,...s,contextType:"2d",autoRender:!0,id:this.viewId})}createLayer(s,e,t){const{width:i,height:o}=t,n=`canvas-${s}`,r=e.layer(n,{...t,offscreen:!1}),c=new ce.Group({anchor:[.5,.5],pos:[i*.5,o*.5],size:[i,o],name:"viewport",id:s});return r.append(c),c}updateScene(s){this.scene.attr({...s});const{width:e,height:t}=s;this.scene.width=e,this.scene.height=t,this.updateLayer({width:e,height:t})}updateLayer(s){const{width:e,height:t}=s;this.subLocalLayer.parent.setAttribute("width",e),this.subLocalLayer.parent.setAttribute("height",t),this.subLocalLayer.setAttribute("size",[e,t]),this.subLocalLayer.setAttribute("pos",[e*.5,t*.5])}updateDpr(s){this.scene.displayRatio=s}on(s){const{msgType:e,toolsType:t,opt:i,dataType:o,workId:n,workState:r}=s,c=n==null?void 0:n.toString();switch(e){case x.Destroy:this.destroy();break;case x.Clear:this.clearAll();break;case x.UpdateDpr:A.isNumber(s.dpr)&&this.updateDpr(s.dpr);break;case x.UpdateCamera:this.updateCamera(s);break;case x.UpdateTools:if(t&&this.subLocalWork.canUseSubWorkerLayer(t)&&i){const l={toolsType:t,toolsOpt:i};this.subLocalWork.setToolsOpt(l)}break;case x.CreateWork:c&&i&&t&&this.subLocalWork.canUseSubWorkerLayer(t)&&(this.subLocalWork.getToolsOpt()||this.subLocalWork.setToolsOpt({toolsType:t,toolsOpt:i}),this.subLocalWork.setWorkOptions(c,i));break;case x.DrawWork:t&&this.subLocalWork.canUseSubWorkerLayer(t)&&(r===z.Done&&o===F.Local?this.subLocalWork.consumeDrawAll(s):this.subLocalWork.consumeDraw(s));break;case x.RemoveNode:this.subLocalWork.removeNode(s);return}}setCameraOpt(s){this.cameraOpt=s;const{scale:e,centerX:t,centerY:i,width:o,height:n}=s;(o!==this.scene.width||n!==this.scene.height)&&this.updateScene({width:o,height:n}),this.subLocalLayer&&(this.subLocalLayer.setAttribute("scale",[e,e]),this.subLocalLayer.setAttribute("translate",[-t,-i]))}updateCamera(s){const{cameraOpt:e}=s;e&&!A.isEqual(this.cameraOpt,e)&&(this.subLocalWork.workShapes.size&&this.clearAll(),this.setCameraOpt(e))}clearAll(){this.subLocalLayer.children.length&&(this.subLocalLayer.parent.children.forEach(s=>{s.name!=="viewport"&&s.remove()}),Re(this.subLocalLayer,this.subLocalLayer.parent)),this.subLocalWork.clearAll()}destroy(){this.subLocalLayer.remove(),Oe(this.subLocalLayer,this.subLocalLayer.parent),this.scene.remove(),this.subLocalWork.destroy()}clearDrawLayer(s){if(s===1/0){this.clearAll();return}const e=this.subLocalLayer.children.filter(t=>t.id&&A.isNumber(parseInt(t.id))&&parseInt(t.id)<s);for(const t of e)t.remove(),Oe(t,this.subLocalLayer.parent)}}class Sm{constructor(s){y(this,"thread");y(this,"workShapes",new Map);y(this,"tmpOpt");y(this,"syncUnitTime",we.syncOpt.interval);y(this,"subWorkerDrawCount",0);this.thread=s.thread}getToolsOpt(){return this.tmpOpt}consumeDrawAll(s){const{workId:e}=s,t=e==null?void 0:e.toString();t&&this.workShapes.get(t)&&(this.subWorkerDrawCount=0,Re(this.thread.subLocalLayer,this.thread.subLocalLayer.parent),this.clearWorkShapeNodeCache(t))}consumeDraw(s){const{workId:e,toolsType:t,postCount:i}=s;e&&t&&this.canUseSubWorkerLayer(t)&&(this.getWorkShape(e.toString())||this.createLocalWork(s));const o=e==null?void 0:e.toString(),n=o&&this.workShapes.get(o);if(!n)return;n.consume({data:s,drawCount:this.subWorkerDrawCount,isFullWork:!1,isSubWorker:!0}),this.subWorkerDrawCount++;const r=this.thread.manager.master;r.setSubWorkerDrawCount(this.subWorkerDrawCount);const c=Math.max(r.getMaxDrawCount(),this.subWorkerDrawCount);r.setMaxDrawCount(c),A.isNumber(i)&&r.setConsumeCount(i)}removeNode(s){const{workId:e}=s,t=e==null?void 0:e.toString();t&&this.workShapes.has(t)&&(this.thread.subLocalLayer.getElementsByName(t).forEach(o=>{o.remove()}),this.clearWorkShapeNodeCache(t))}createLocalWork(s){const{workId:e,toolsType:t,opt:i}=s,o=e==null?void 0:e.toString();t&&this.canUseSubWorkerLayer(t)&&o&&i&&(this.getToolsOpt()||this.setToolsOpt({toolsType:t,toolsOpt:i}),this.setWorkOptions(o,i))}setWorkOptions(s,e){let t=this.workShapes.get(s);if(!t&&this.tmpOpt){const{toolsType:i}=this.tmpOpt;this.tmpOpt.toolsOpt=e,t=this.createWorkShapeNode({workId:s,toolsType:i,toolsOpt:e}),t&&this.workShapes.set(s,t),this.setToolsOpt(this.tmpOpt)}e!=null&&e.syncUnitTime||(e.syncUnitTime=this.syncUnitTime),t&&t.setWorkOptions(e)}destroy(){this.clearAll()}clearAll(){Re(this.thread.subLocalLayer,this.thread.subLocalLayer.parent),this.workShapes.clear()}canUseSubWorkerLayer(s){return s===N.Pencil}setToolsOpt(s){var e;this.tmpOpt=s,(e=s.toolsOpt)!=null&&e.syncUnitTime&&(this.syncUnitTime=s.toolsOpt.syncUnitTime)}createWorkShapeNode(s){return ws({...s,fullLayer:this.thread.subLocalLayer,drawLayer:this.thread.subLocalLayer})}clearWorkShapeNodeCache(s){this.workShapes.delete(s)}getWorkShape(s){return this.workShapes.get(s)}}const Nm=async(a,s)=>{const{src:e,isgl:t,isCache:i}=a;if(typeof Image=="function"){const o=new Image;return typeof e=="string"&&(o.crossOrigin="anonymous"),new Promise(n=>{o.onload=function(){createImageBitmap(o,{imageOrientation:t?"flipY":"none"}).then(r=>{n(r)})},o.onerror=function(){n(void 0)},o.src=e})}else return fetch(e,{method:"GET",mode:"cors",cache:"default"}).then(o=>o.blob()).then(o=>createImageBitmap(o,{imageOrientation:t?"flipY":"none"}).then(n=>n))};class km{constructor(){y(this,"maxLastSyncTime",we.syncOpt.interval)}setCurrentToolsData(s){this.currentToolsData=s}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(s){this.currentLocalWorkData=s}getWorkId(){return this.currentLocalWorkData.workId}getWorkState(){return this.currentLocalWorkData.workState}}class Cm extends km{constructor(e){var n,r;super();y(this,"isActive",!1);y(this,"currentToolsData");y(this,"currentLocalWorkData");y(this,"control");y(this,"internalMsgEmitter");y(this,"publicMsgEmitter");y(this,"taskBatchData",new Set);y(this,"fullWorker");y(this,"subWorker");y(this,"fullWorkerUrl");y(this,"subWorkerUrl");y(this,"methodBuilder");y(this,"zIndexNodeMethod");y(this,"subWorkerDrawCount",0);y(this,"fullWorkerDrawCount",0);y(this,"maxDrawCount",0);y(this,"_consumeCount",0);y(this,"_postCount",0);y(this,"reRenders",new Map);y(this,"localWorkViewId");y(this,"localPointsBatchData",new Map);y(this,"tasksqueue",new Map);y(this,"useTasksqueue",!1);y(this,"useTasksClockId");y(this,"mainTasksqueueCount");y(this,"workerTasksqueueCount");y(this,"snapshotMap",new Map);y(this,"boundingRectMap",new Map);y(this,"clearAllResolveMap",new Map);y(this,"delayWorkStateToDoneResolve");y(this,"animationId");y(this,"tmpImageConfigMap",new Map);y(this,"mainThread");y(this,"willSelectorWorkId");y(this,"isLockSentEventCursor",!1);y(this,"subMainThreadWorker");y(this,"getVNodeInfoResolveMap",new Map);y(this,"isLocalWorkActive",!1);const{control:t,internalMsgEmitter:i,publicMsgEmitter:o}=e;this.control=t,this.maxLastSyncTime=((r=(n=this.control.pluginOptions)==null?void 0:n.syncOpt)==null?void 0:r.interval)||this.maxLastSyncTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl,this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl,this.internalMsgEmitter=i,this.publicMsgEmitter=o,this.currentLocalWorkData={workState:z.Pending}}destroy(){var e,t,i;(e=this.methodBuilder)==null||e.destroy(),this.unWritable(),this.taskBatchData.clear(),this.tasksqueue.clear(),this.tmpImageConfigMap.clear(),this.localPointsBatchData.clear(),this.isActive=!1,this.clearAllResolveMap.clear(),this.snapshotMap.clear(),this.boundingRectMap.clear(),(t=this.fullWorker)==null||t.terminate(),(i=this.subWorker)==null||i.terminate()}get consumeCount(){return this._consumeCount}set consumeCount(e){this._consumeCount=e}get postCount(){return this._postCount}set postCount(e){this._postCount=e}get viewContainerManager(){return this.control.viewContainerManager}get collector(){return this.control.collector}get isRunSubWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===N.Pencil||e===N.PencilEraser||e===N.BitMapEraser||e===N.LaserPen||e===N.Arrow||e===N.Straight||e===N.Ellipse||e===N.Rectangle||e===N.Star||e===N.Polygon||e===N.SpeechBalloon}get isCanDrawWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===N.Pencil||e===N.LaserPen||e===N.Arrow||e===N.Straight||e===N.Ellipse||e===N.Rectangle||e===N.Star||e===N.Polygon||e===N.SpeechBalloon||e===N.Triangle||e===N.Rhombus||e===N.BitMapEraser||e===N.PencilEraser}get isUseZIndex(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===N.Pencil||e===N.Arrow||e===N.Straight||e===N.Ellipse||e===N.Rectangle||e===N.Star||e===N.Polygon||e===N.SpeechBalloon||e===N.Text||e===N.Image}get isCanRecordUndoRedo(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===N.Pencil||e===N.Eraser||e===N.PencilEraser||e===N.BitMapEraser||e===N.Arrow||e===N.Straight||e===N.Ellipse||e===N.Rectangle||e===N.Star||e===N.Polygon||e===N.SpeechBalloon||e===N.Text||e===N.Image}get isCanSentCursor(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===N.Pencil||e===N.Text||e===N.LaserPen||e===N.Arrow||e===N.Straight||e===N.Ellipse||e===N.Rectangle||e===N.Star||e===N.Polygon||e===N.SpeechBalloon||e===N.Triangle||e===N.Rhombus||e===N.Eraser||e===N.PencilEraser||e===N.BitMapEraser}get isPostCountType(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===N.Pencil||e===N.Arrow||e===N.Straight||e===N.Ellipse||e===N.Rectangle||e===N.Star||e===N.Polygon||e===N.SpeechBalloon||e===N.Triangle||e===N.Rhombus||e===N.Eraser||e===N.PencilEraser||e===N.BitMapEraser}get isCanPostDraw(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===N.Pencil||e===N.PencilEraser||e===N.BitMapEraser}get isCanStartEventConsum(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===N.Selector||e===N.Eraser||e===N.PencilEraser||e===N.BitMapEraser}async init(){this.destroy(),await this.on(),this.internalMsgEmitterListener(),this.isActive=!0}async useMainThread(){console.info("no OffscreenCanvas");const{MainThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-BSGcWUci.js"));this.mainThread=new e(this)}async on(){if(!this.control.hasOffscreenCanvas()){await this.useMainThread();return}if(!this.fullWorkerUrl||!this.subWorkerUrl){console.error("no worker url config");return}this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"}),this.subMainThreadWorker=new Im(this),this.fullWorker.onmessage=e=>{var t,i;if(e.data){const{render:o,sp:n,fullWorkerDrawCount:r,workerTasksqueueCount:c,viewId:l,consumeCount:u}=e.data;u&&(this.consumeCount=u),this.isBusy&&c&&this.setWorkerTasksqueueCount(c),n!=null&&n.length&&this.collectorSyncData(n);const h=(o==null?void 0:o.length)&&o||[];if(r&&l){if(this.fullWorkerDrawCount=r,this.fullWorkerDrawCount<1/0){const d=Math.max(this.maxDrawCount,this.fullWorkerDrawCount);this.setMaxDrawCount(d),this.control.priority==="ui"?(t=this.subMainThreadWorker)==null||t.notifyDrawCount(l):this.clearReRenders(this.fullWorkerDrawCount)}else this.setMaxDrawCount(0),this.control.priority==="ui"?(i=this.subMainThreadWorker)==null||i.clearDrawCount(l):this.clearReRenders(1/0);if(this.reRenders.size)for(const d of this.reRenders.values())h.push(...d)}h.length&&this.viewContainerManager.render(h)}},this.subWorker.onmessage=e=>{if(e.data){const{render:t,sp:i,subWorkerDrawCount:o,consumeCount:n}=e.data;n&&(this.consumeCount=n),i!=null&&i.length&&this.collectorSyncData(i);const r=(t==null?void 0:t.length)&&t||[];if(this.control.priority==="cpu"&&A.isNumber(o)){if(this.subWorkerDrawCount=o,this.fullWorkerDrawCount<1/0){const c=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(c)}if(t!=null&&t.length)if(this.subWorkerDrawCount>this.fullWorkerDrawCount){const c=[];for(const l of t)l.imageBitmap&&(l.isUnClose=!0,c.push(l));this.reRenders.set(this.subWorkerDrawCount,c)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}r.length&&this.viewContainerManager.render(r)}}}clearReRenders(e=1/0){for(const t of this.reRenders.keys())if(A.isNumber(Number(t))&&Number(t)<=e){const i=this.reRenders.get(Number(t));i==null||i.forEach(o=>{var n;(n=o.imageBitmap)==null||n.close()}),this.reRenders.delete(t)}}get isBusy(){return this.getTasksqueueState()===z.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(e){this.isLockSentEventCursor=e}getTasksqueueState(){return this.useTasksqueue&&z.Doing||z.Done}setMaxDrawCount(e){this.maxDrawCount=e}getFullWorkDrawCount(){return this.fullWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setSubWorkerDrawCount(e){this.subWorkerDrawCount=e}setConsumeCount(e){this.consumeCount=e}getConsumeCount(){return this.consumeCount}setWorkerTasksqueueCount(e){const t=Math.max(this.workerTasksqueueCount||0,e);this.workerTasksqueueCount=t}collectorSyncData(e){var i,o,n,r;let t=!1;for(const c of e){const{type:l,selectIds:u,opt:h,selectRect:d,strokeColor:p,fillColor:f,willSyncService:g,isSync:M,imageBitmap:S,canvasHeight:w,canvasWidth:I,rect:k,op:T,canTextEdit:v,points:P,selectorColor:C,canRotate:L,scaleType:O,textOpt:R,toolsType:E,workId:j,viewId:D,dataType:q,canLock:oe,isLocked:X,shapeOpt:Z,toolsTypes:_,thickness:Q,strokeType:J,useStroke:K,isgl:he,imageSrc:Se,isSubWorker:Ae}=c;if(!D)return;const ve=c.scenePath||this.viewContainerManager.getCurScenePath(D);switch(l){case x.Select:{const U=u!=null&&u.length?{...d,selectIds:u,canvasHeight:w,canvasWidth:I,points:P}:void 0;U&&(h!=null&&h.strokeColor)&&(U.selectorColor=h.strokeColor),U&&C&&(U.selectorColor=C),U&&p&&(U.strokeColor=p),U&&(h!=null&&h.fillColor)&&(U.fillColor=h.fillColor),U&&f&&(U.fillColor=f),U&&A.isBoolean(L)&&(U.canRotate=L),U&&O&&(U.scaleType=O),U&&v&&(U.canTextEdit=v),U&&R&&(U.textOpt=R),U&&A.isBoolean(oe)&&(U.canLock=oe),U&&A.isBoolean(X)&&(U.isLocked=X),U&&Z&&(U.shapeOpt=Z),U&&_&&(U.toolsTypes=_),U&&Q&&(U.thickness=Q),U&&J&&(U.strokeType=J),U&&A.isBoolean(K)&&(U.useStroke=K),D&&this.viewContainerManager.showFloatBar(D,!!U,U),g&&((i=this.collector)==null||i.dispatch({type:l,selectIds:u,opt:h,isSync:M,viewId:D,scenePath:ve}));break}case x.Snapshot:if(S&&ve){const U=this.snapshotMap.get(ve);U&&U(S)}break;case x.BoundingBox:if(k&&ve){const U=this.boundingRectMap.get(ve);U&&U(k)}break;case x.Cursor:T&&this.control.cursor.collectServiceCursor({...c});break;case x.Clear:if(D){this.viewContainerManager.showFloatBar(D,!1);const U=(o=this.clearAllResolveMap.get(D))==null?void 0:o.resolve;U&&U(D)}break;case x.TextUpdate:if(E===N.Text&&j&&D){const U=this.viewContainerManager.transformToOriginPoint((h==null?void 0:h.boxPoint)||[0,0],D),ae=(h==null?void 0:h.boxSize)||[0,0],ee=(n=this.viewContainerManager.getView(D))==null?void 0:n.cameraOpt;h?this.control.textEditorManager.updateTextForWorker({x:U[0],y:U[1],w:ae[0],h:ae[1],scale:(ee==null?void 0:ee.scale)||1,workId:j,opt:h,dataType:q,viewId:D,canSync:g||!1,canWorker:!1}):this.control.textEditorManager.delete(j,g||!1,!1)}break;case x.GetTextActive:E===N.Text&&j&&D&&this.control.textEditorManager.updateTextForWorker({workId:j,isActive:!0,viewId:D,dataType:F.Local,canWorker:!1,canSync:!0},Date.now());break;case x.GetImageBitMap:Se&&D&&j&&Nm({src:Se,isgl:he}).then(U=>{var ee;const ae=new Set;if(ae.add({msgType:x.GetImageBitMap,dataType:F.Local,workId:j,viewId:D,imageSrc:Se,isSubWorker:Ae,imageBitmap:U}),!this.control.hasOffscreenCanvas())(ee=this.mainThread)==null||ee.consume(ae);else{const de=Ae?this.subWorker:this.fullWorker;U?de.postMessage(ae,[U]):de.postMessage(ae)}});break;case x.GetVNodeInfo:if(j){const U=j.toString(),ae=(r=this.getVNodeInfoResolveMap.get(U))==null?void 0:r.resolve,ee={...c,uuid:U};ae&&ae(ee)}break;default:t=!0;break}}t&&this.collectorAsyncData(e)}collectorAsyncData(e){var t,i,o,n;for(const r of e){const{type:c,op:l,workId:u,index:h,removeIds:d,ops:p,opt:f,updateNodeOpt:g,toolsType:M,isSync:S,viewId:w,isLockSentEventCursor:I,nextTasks:k}=r;if(!w){console.error("collectorAsyncData",r);return}const T=r.scenePath||this.viewContainerManager.getCurScenePath(w);switch(c){case x.None:{I&&st(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime);break}case x.DrawWork:{(t=this.collector)==null||t.dispatch({type:c,op:l,opt:f,toolsType:M,workId:u,index:h,isSync:S,viewId:w,scenePath:T,updateNodeOpt:g});break}case x.FullWork:{(i=this.collector)==null||i.dispatch({type:c,ops:p,workId:u,updateNodeOpt:g,opt:f,toolsType:M,isSync:S,viewId:w,scenePath:T}),this.willSelectorWorkId&&u&&u.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,w),this.willSelectorWorkId=void 0});break}case x.UpdateNode:{(o=this.collector)==null||o.dispatch({type:c,updateNodeOpt:g,workId:u,opt:f,ops:p,op:l,isSync:S,viewId:w,scenePath:T});break}case x.RemoveNode:{d&&this.control.textEditorManager.deleteBatch(d,!1,!1),(n=this.collector)==null||n.dispatch({type:c,removeIds:d,isSync:S,viewId:w,scenePath:T}),this.willSelectorWorkId&&(d!=null&&d.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}k&&this.collectorAsyncData(k)}}async onLocalEventEnd(e,t){var l;const i=this.viewContainerManager.getView(t);if(!i)return;const{focusScenePath:o,cameraOpt:n}=i,r=this.viewContainerManager.transformToScenePoint(e,t),c=[];for(const u of this.localPointsBatchData.keys())if(((l=this.currentToolsData)==null?void 0:l.toolsType)===N.Text){const h=this.getLocalPointInfo(u),d=h==null?void 0:h.state;if(d&&d===z.Start){const p=this.currentLocalWorkData.toolsOpt;p.workState=z.Doing,p.boxPoint=r,p.boxSize=[p.fontSize,p.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:Date.now().toString(),x:e[0],y:e[1],scale:(n==null?void 0:n.scale)||1,opt:p,type:Je.Text,isActive:!0,viewId:t,scenePath:o},Date.now())}this.deleteLocalPoint(u);continue}else this.pushLocalPoint(u,r,z.Done,t),c.push(u);if(c.length){try{if(await new Promise(h=>{setTimeout(async()=>{c.forEach(d=>{this.setLocalPointIsFullWork(d)}),this.delayWorkStateToDoneResolve=h,this.consume()},0)})&&c[0]){const h=c[0];c.forEach(d=>{this.deleteLocalPoint(d)}),this.willSelectorWorkId=h.toString()}}catch(u){console.log("error",u)}this.delayWorkStateToDoneResolve=void 0,c.length=0}}onLocalEventDoing(e,t){var o;if(((o=this.currentToolsData)==null?void 0:o.toolsType)===N.Text)return;this.currentLocalWorkData.workState===z.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:z.Doing});let i=!1;for(const[n,{state:r}]of this.localPointsBatchData.entries())if(this.isAbled()&&r!==z.Pending){const c=this.viewContainerManager.transformToScenePoint(e,t);this.pushLocalPoint(n,c,r===z.Start?z.Doing:r,t),i=!0}if(i){this.runAnimation();return}this.useTasksqueue||this.hoverCursor(e,t)}onLocalEventStart(e,t){var c,l,u;this.viewContainerManager.focuedViewId!==t&&this.viewContainerManager.setFocuedViewId(t),this.isCanDrawWork&&this.control.room&&!this.control.room.disableDeviceInputs&&(this.control.room.disableDeviceInputs=!0);const i=(c=this.currentToolsData)==null?void 0:c.toolsType,o=i===N.Selector?H:Date.now(),n=this.setZIndex(t);this.setCurrentLocalWorkData({workState:z.Start,toolsOpt:n,viewId:t});const r=this.viewContainerManager.transformToScenePoint(e,t);if(this.pushLocalPoint(o,r,z.Start,t,n),i!==N.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo&&this.internalMsgEmitter.emit("addUndoTicker",o,t),o&&n&&i&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:o,toolsOpt:n,viewId:t},i),this.consumeCount=0,this.postCount=0,this.maxDrawCount=0,this.fullWorkerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),(l=this.subMainThreadWorker)==null||l.clearDrawCount(t),this.isCanDrawWork){const h=this.viewContainerManager.getCurScenePath(t);h&&((u=this.collector)!=null&&u.hasSelector(t,h))&&this.blurSelector(t,h)}this.consume()}}setLocalPointIsFullWork(e){const t=this.getLocalPointInfo(e);t&&(t.isFullWork=!0,this.localPointsBatchData.set(e,t))}pushLocalPoint(e,t,i,o,n){let r=this.getLocalPointInfo(e);i===z.Start?r={state:z.Start,points:t,opt:n||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:o}:r&&(r.state=i,r.points.push(t[0],t[1])),r&&this.localPointsBatchData.set(e,r)}deleteLocalPoint(e){this.localPointsBatchData.delete(e)}getLocalPointInfo(e){return this.localPointsBatchData.get(e)}getLocalPointsInfo(){return this.localPointsBatchData}correctStorage(e,t,i){var c;const o=new Map,n=[];Object.keys(e).forEach(l=>{var h,d;const u=(d=(h=e[l])==null?void 0:h.opt)==null?void 0:d.zIndex;A.isNumber(u)&&n.push([l,u])});const r=n.length&&((c=this.zIndexNodeMethod)==null?void 0:c.correct(n))||[];this.zIndexNodeMethod&&r.length&&(this.zIndexNodeMethod.setMinZIndex(r[0][1]||0,t),this.zIndexNodeMethod.setMaxZIndex(r[r.length-1][1]||0,t));for(const[l,u]of r){if(!e[l])continue;const h=e[l];h.opt&&A.isNumber(h.opt.zIndex)&&h.opt.zIndex!==u&&(h.opt.zIndex=u,o.set(l,h))}return o.size&&o.forEach((l,u)=>{var h;(h=this.collector)==null||h.updateValue(u,l,{viewId:t,scenePath:i,isSync:!0}),e[u]=l}),e}async originalEventLintener(e,t,i){var r,c;if(!this.isAbled())return;const o=(r=this.collector)==null?void 0:r.uid,n=this.viewContainerManager.getCurScenePath(i);if(!(o&&!this.control.renderControl.isWritable)){switch((c=this.currentToolsData)==null?void 0:c.toolsType){case N.Eraser:case N.PencilEraser:case N.BitMapEraser:{if(o&&!this.control.renderControl.isClearAble({uid:o,viewId:i,scenePath:n}))return;break}default:{if(o&&!this.control.renderControl.isRenderAble({uid:o,viewId:i,scenePath:n}))return;break}}switch(st(()=>{this.control.pluginManager.dispatchPluginEvent("localEvent",i,e,t)},ri),e){case z.Start:this.isLocalWorkActive=!0,this.setLocalWorkViewId(i),i&&this.onLocalEventStart(t,i);break;case z.Doing:i&&i===this.getLocalWorkViewId()&&this.onLocalEventDoing(t,i);break;case z.Done:i&&i===this.getLocalWorkViewId()&&(await this.onLocalEventEnd(t,i),setTimeout(()=>{this.isLocalWorkActive=!1},0));break}this.isLocalWorkActive&&this.viewContainerManager.focuedViewId===i&&this.publicMsgEmitter.emit("workState",e,i)}}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(e){this.localWorkViewId=e}setCurrentToolsData(e){var o,n,r;const t=e.toolsType,i=((o=this.currentToolsData)==null?void 0:o.toolsType)!==e.toolsType;if(super.setCurrentToolsData(e),i){const c=(n=this.viewContainerManager)==null?void 0:n.getAllViews();for(const l of c)if(l){const{id:u,focusScenePath:h}=l;i&&u&&h&&((r=this.collector)!=null&&r.hasSelector(u,h)&&this.blurSelector(u,h),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:x.UpdateTools,dataType:F.Local,toolsType:t,opt:{...e.toolsOpt,syncUnitTime:this.maxLastSyncTime},isRunSubWork:this.isRunSubWork,viewId:Jt}),this.runAnimation()}}prepareOnceWork(e,t){const{workId:i,toolsOpt:o,viewId:n}=e,r={msgType:x.CreateWork,dataType:F.Local,viewId:n,toolsType:t};this.queryTaskBatchData(r).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({...r,workId:i,opt:{...o,syncUnitTime:this.maxLastSyncTime},dataType:F.Local,isRunSubWork:this.isRunSubWork}),this.runAnimation()}createViewWorker(e,t){const{offscreenCanvasOpt:i,layerOpt:o,dpr:n,cameraOpt:r}=t;this.taskBatchData.add({msgType:x.Init,dataType:F.Local,viewId:e,offscreenCanvasOpt:i,layerOpt:o,dpr:n,cameraOpt:r,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1}),this.isBusy&&this.destroyTaskQueue(),this.consume()}destroyViewWorker(e,t=!1){var i;this.getLocalWorkViewId()===e&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e),this.taskBatchData.add({msgType:x.Destroy,dataType:F.Local,viewId:e,isRunSubWork:!0}),this.consume(),t||(i=this.collector)==null||i.dispatch({type:x.Clear,viewId:e}),this.control.renderControl.destoryByViewId(e,t)}onServiceDerive(e,t){var p,f,g,M,S,w,I;const{newValue:i,oldValue:o,viewId:n,scenePath:r}=t,c=A.cloneDeep(i)||{},l=e;let u=c.type;if(!i&&o){if(l&&((p=this.collector)==null?void 0:p.getLocalId(l))===H){this.collector.isOwn(l)?this.blurSelector(n,r):this.blurSelector(n,r,l);return}if(u=x.RemoveNode,o.toolsType===N.LaserPen)return}const h=(f=this.viewContainerManager.getView(n))==null?void 0:f.focusScenePath;if(h&&h!==r)return;if((g=this.collector)!=null&&g.isSelector(e)){const k=(M=this.collector)==null?void 0:M.getUidFromKey(e);if(k&&!this.control.roomMember.isOnLine(k))return}if(u&&l){if(!this.control.renderControl.isFilterAble({viewId:n,elementId:e,scenePath:r},u))return;const k=c;if(k.workId=(S=this.collector)!=null&&S.isOwn(l)?(w=this.collector)==null?void 0:w.getLocalId(l):l,k.msgType=u,k.toolsType===N.LaserPen&&(k.isRunSubWork=!0),k.dataType=F.Service,k.viewId=n,k.scenePath=r,k.selectIds&&(k.selectIds=k.selectIds.map(T=>{var v,P;return(v=this.collector)!=null&&v.isOwn(T)?(P=this.collector)==null?void 0:P.getLocalId(T):T})),k&&k.toolsType===N.Text||(o==null?void 0:o.toolsType)===N.Text){this.control.textEditorManager.onServiceDerive(k);return}this.taskBatchData.add(k)}this.runAnimation();const d=t.newValue&&((I=t.newValue.opt)==null?void 0:I.zIndex);if(this.zIndexNodeMethod&&A.isNumber(d)){const k=this.zIndexNodeMethod.getMinZIndex(n);this.zIndexNodeMethod.getMaxZIndex(n)<d&&this.zIndexNodeMethod.setMaxZIndex(d,n),k>d&&this.zIndexNodeMethod.setMinZIndex(d,n)}}pullServiceData(e,t,i={isAsync:!1,useAnimation:!1}){var c,l,u,h,d,p,f;let o=(c=this.collector)==null?void 0:c.getStorageData(e,t);const{isAsync:n,useAnimation:r}=i;if(o){this.control.renderControl.isWritable&&(o=this.correctStorage(o,e,t));const g=Object.keys(o);for(const M of g){if((l=this.collector)!=null&&l.isSelector(M)){const w=(u=this.collector)==null?void 0:u.getUidFromKey(M);if(w&&!this.control.roomMember.isOnLine(w))continue}const S=(h=o[M])==null?void 0:h.type;if(S&&M){if(!this.control.renderControl.isFilterAble({viewId:e,elementId:M,scenePath:t},S))continue;const w=o[M];if(w.workId=(d=this.collector)!=null&&d.isOwn(M)?(p=this.collector)==null?void 0:p.getLocalId(M):M,w.msgType=S,w.dataType=F.Service,w.viewId=e,w.scenePath=t,w.useAnimation=w.ops?!!r:((f=w.updateNodeOpt)==null?void 0:f.useAnimation)||!1,w.selectIds&&(w.selectIds=w.selectIds.map(I=>{var k,T;return(k=this.collector)!=null&&k.isOwn(I)?(T=this.collector)==null?void 0:T.getLocalId(I):I})),w.toolsType===N.Text){this.control.textEditorManager.onServiceDerive(w);continue}this.taskBatchData.add(w)}this.internalMsgEmitter.emit("excludeIds",g,e)}n?this.consume():this.runAnimation()}}runAnimation(){!this.animationId&&!this.isBusy&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}consume(){var t;this.animationId=void 0;const{viewId:e}=this.currentLocalWorkData;if(this.tasksqueue.size){const i=this.consumeQueue(),o=!!i.size;if(this.taskBatchData.size)for(const n of this.taskBatchData.values())n.dataType===F.Service&&(i.add(n),this.taskBatchData.delete(n));i.size?(this.post(i),o&&this.tasksqueue.clear()):this.tasksqueue.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)));return}if(this.isAbled()&&this.localPointsBatchData.size&&e)for(const[i,{state:o,isFullWork:n,points:r,opt:c}]of this.localPointsBatchData.entries()){if(o===z.Done&&!n||o===z.Start&&!this.isCanStartEventConsum)continue;const l=r.map(u=>u);if(l.length){if(this.isPostCountType&&o===z.Doing){if(this.postCount>this.consumeCount)continue;this.postCount++}this.delayWorkStateToDoneResolve&&o===z.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:o,workId:i,dataType:F.Local,msgType:x.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(t=this.currentToolsData)==null?void 0:t.toolsType,viewId:e,scenePath:e&&this.viewContainerManager.getCurScenePath(e),opt:c,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime,disableEraseImage:this.control.disableEraseImage,disableEraseText:this.control.disableEraseText,postCount:this.isPostCountType&&this.postCount||void 0,fullWorkerDrawCount:this.isCanPostDraw&&this.fullWorkerDrawCount||void 0}),r.length=0}}this.taskBatchData.size&&(this.post(this.taskBatchData),this.taskBatchData.clear()),this.taskBatchData.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}unWritable(){this.setCurrentLocalWorkData({workState:z.Unwritable,workId:void 0}),this.setLockSentEventCursor(!0)}abled(){this.setCurrentLocalWorkData({workState:z.Pending,workId:void 0}),this.setLockSentEventCursor(!1)}isAbled(){return this.currentLocalWorkData.workState!==z.Unwritable}post(e){var i;if(!this.control.hasOffscreenCanvas()){if(!this.mainThread){let o=[];o=A.cloneDeep([...e]),setTimeout(()=>{for(const n of o)this.taskBatchData.add(n)},0);return}this.mainThread.consume(e);return}this.fullWorker.postMessage(e);const t=new Set;for(const o of e.values()){const n=o.msgType;(n===x.Init||n===x.Clear||n===x.Destroy||n===x.UpdateCamera||o.isRunSubWork)&&t.add(o)}t.size&&(this.subWorker.postMessage(t),this.control.priority==="ui"&&((i=this.subMainThreadWorker)==null||i.consume(t)))}updateNode(e,t,i,o){this.taskBatchData.add({msgType:x.UpdateNode,workId:e,updateNodeOpt:t,viewId:i,scenePath:o,dataType:F.Local}),this.runAnimation()}destroyTaskQueue(){this.useTasksqueue=!1,this.useTasksClockId&&(clearTimeout(this.useTasksClockId),this.useTasksClockId=void 0),this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0}updateDpr(e,t){this.queryTaskBatchData({msgType:x.UpdateDpr,dataType:F.Local,viewId:e}).forEach(i=>{this.taskBatchData.delete(i)}),this.taskBatchData.add({dataType:F.Local,msgType:x.UpdateDpr,viewId:e,dpr:t,isRunSubWork:!0}),this.runAnimation()}updateCamera(e,t){var i;this.useTasksqueue||((i=this.methodBuilder)==null||i.pause(),this.blurCursor(e),this.checkDrawingWork(e),this.useTasksqueue=!0,this.mainTasksqueueCount=1,this.workerTasksqueueCount=1),this.useTasksqueue&&(this.tasksqueue.set(e,{msgType:x.UpdateCamera,dataType:F.Local,cameraOpt:{...t,width:t.width,height:t.height},scenePath:this.viewContainerManager.getCurScenePath(e),isRunSubWork:!0,viewId:e}),this.consume(),this.useTasksClockId&&clearTimeout(this.useTasksClockId),this.updateCameraDone())}updateCameraDone(){this.useTasksClockId=setTimeout(()=>{var e,t;this.useTasksClockId=void 0,this.mainTasksqueueCount===this.workerTasksqueueCount?(this.tasksqueue.size&&this.consume(),this.useTasksqueue=!1,this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0,this.control.priority==="ui"&&((e=this.subMainThreadWorker)==null||e.updateCamera()),(t=this.methodBuilder)==null||t.recover(),this.runAnimation()):this.updateCameraDone()},this.maxLastSyncTime)}consumeQueue(){const e=new Set;let t=!this.isBusy;if(this.isBusy&&this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount<=this.workerTasksqueueCount&&(t=!0),t){this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount++,e.add({msgType:x.TasksQueue,dataType:F.Local,isRunSubWork:!0,mainTasksqueueCount:this.mainTasksqueueCount,tasksqueue:this.tasksqueue,viewId:""});for(const[i,o]of this.tasksqueue.entries())o.cameraOpt&&this.control.textEditorManager.onCameraChange(o.cameraOpt,i)}return e}async clearViewScenePath(e,t,i){var n,r;const o=this.viewContainerManager.getCurScenePath(e);if(i){const c=(n=this.collector)==null?void 0:n.uid;if(c&&!this.control.renderControl.isClearAble({uid:c,viewId:e,scenePath:o}))return}this.control.textEditorManager.clear(e,t),this.queryTaskBatchData({msgType:x.Clear,dataType:F.Local,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({dataType:F.Local,msgType:x.Clear,viewId:e}),this.runAnimation(),t||(this.control.renderControl.isUsePageAuth(e)&&o?this.control.renderControl.clearRenderPage(e,o):(r=this.collector)==null||r.dispatch({type:x.Clear,viewId:e,scenePath:o})),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e),this.localPointsBatchData.clear(),await new Promise(c=>{const l=this.clearAllResolveMap.get(e)||{resolve:void 0,timer:void 0};l.timer&&clearTimeout(l.timer),l.resolve=c,l.timer=setTimeout(()=>{const u=this.clearAllResolveMap.get(e);u!=null&&u.resolve&&u.resolve(e)},this.maxLastSyncTime),this.clearAllResolveMap.set(e,l)}).then(c=>{this.clearAllResolveMap.delete(c)})}internalMsgEmitterListener(){var e;this.methodBuilder=new ie([V.CopyNode,V.SetColorNode,V.DeleteNode,V.RotateNode,V.ScaleNode,V.TranslateNode,V.ZIndexNode,V.SetFontStyle,V.SetPoint,V.SetLock,V.SetShapeOpt]).registerForMainEngine(se.MainEngine,this.control),this.zIndexNodeMethod=(e=this.methodBuilder)==null?void 0:e.getBuilder(V.ZIndexNode)}setZIndex(e){const t=this.currentToolsData&&A.cloneDeep(this.currentToolsData.toolsOpt);return t&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(e),t.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),t}checkDrawingWork(e){var o,n,r;let t=!1;const i=[];for(const[c,{state:l,viewId:u,points:h,opt:d}]of this.localPointsBatchData.entries())if(e===u&&l===z.Start||l===z.Doing){if(l===z.Doing&&this.isCanDrawWork){Number(c)&&Number(c)+60>Date.now()&&(i.push(c.toString()),this.taskBatchData.add({msgType:x.RemoveNode,workId:c,viewId:u,dataType:F.Local,isRunSubWork:!0}));const p=h.map(f=>f);this.taskBatchData.add({op:p,workState:z.Done,workId:c,dataType:F.Local,msgType:x.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(o=this.currentToolsData)==null?void 0:o.toolsType,viewId:u,opt:d,scenePath:u&&this.viewContainerManager.getCurScenePath(u)}),t=!0}this.deleteLocalPoint(c)}if((t||i.length)&&(this.consume(),i.length)){const c=(n=this.viewContainerManager.getView(e))==null?void 0:n.focusScenePath;(r=this.collector)==null||r.dispatch({type:x.RemoveNode,removeIds:i,viewId:e,scenePath:c})}}removeDrawingWork(e){var i,o;const t=[];for(const[n,{state:r,viewId:c}]of this.localPointsBatchData.entries())(e===c&&r===z.Start||r===z.Doing)&&(this.deleteLocalPoint(n),r===z.Doing&&this.isCanDrawWork&&(t.push(n.toString()),this.taskBatchData.add({msgType:x.RemoveNode,workId:n,viewId:c,dataType:F.Local,isRunSubWork:!0})));if(t.length){this.consume();const n=(i=this.viewContainerManager.getView(e))==null?void 0:i.focusScenePath;(o=this.collector)==null||o.dispatch({type:x.RemoveNode,removeIds:t,viewId:e,scenePath:n})}}removeNodes(e,t){var o,n;const i=(o=this.viewContainerManager.getView(e))==null?void 0:o.focusScenePath;if(i&&t.length){for(const r of t)this.taskBatchData.add({msgType:x.RemoveNode,workId:r,viewId:e,dataType:F.Local,isRunSubWork:!1});this.consume(),(n=this.collector)==null||n.dispatch({type:x.RemoveNode,removeIds:t,viewId:e,scenePath:i})}}hoverCursor(e,t){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)===N.Selector&&!this.isBusy){const o=this.viewContainerManager.getView(t);if(o&&o.displayer&&o.displayer.vDom){const c=o.displayer.vDom.state.floatBarData;if(c){const{x:l,y:u,w:h,h:d}=c;if(an(e,{x:l,y:u,w:h,h:d}))return}}const n=this.viewContainerManager.transformToScenePoint(e,t),r={msgType:x.CursorHover,dataType:F.Local,point:n,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:x.CursorHover,dataType:F.Local,toolsType:this.currentToolsData.toolsType,viewId:t}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(r),this.runAnimation()}}blurCursor(e){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)!==N.Selector)return;const t={msgType:x.CursorBlur,dataType:F.Local,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:x.CursorHover,dataType:F.Local,viewId:e}).forEach(o=>{this.taskBatchData.delete(o)}),this.taskBatchData.add(t),this.consume()}sendCursorEvent(e,t){var r,c;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===z.Unwritable||!this.currentToolsData||!this.isCanSentCursor||this.isBusy)return;const i=(r=this.collector)==null?void 0:r.uid,o=this.viewContainerManager.getCurScenePath(t);switch((c=this.currentToolsData)==null?void 0:c.toolsType){case N.Eraser:case N.PencilEraser:case N.BitMapEraser:{if(i&&!this.control.renderControl.isClearAble({uid:i,viewId:t,filterLocalSelf:!1,scenePath:o}))return;break}default:if(i&&!this.control.renderControl.isWritable||i&&!this.control.renderControl.isRenderAble({uid:i,viewId:t,filterLocalSelf:!1,scenePath:o}))return;break}let n=[void 0,void 0];this.currentToolsData&&this.isCanSentCursor&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(n=e,this.control.cursor.sendEvent(n,t))}getBoundingRect(e){var i,o;if(!((i=this.boundingRectMap)==null?void 0:i.get(e))){const n=(o=this.collector)==null?void 0:o.getScenePathData(e);if(!n)return;if(Object.keys(n).forEach(r=>{var c;((c=this.collector)==null?void 0:c.getLocalId(r))===H&&delete n[r]}),Object.keys(n).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const r={msgType:x.BoundingBox,dataType:F.Local,scenePath:e,scenes:n,cameraOpt:{...this.viewContainerManager.mainView.cameraOpt},isRunSubWork:!0,viewId:this.viewContainerManager.mainView.id};return this.taskBatchData.add(r),this.runAnimation(),new Promise(c=>{this.boundingRectMap.set(e,c)}).then(c=>(this.boundingRectMap.delete(e),c))}}}getSnapshot(e,t,i,o){var r,c,l,u,h;if(!((r=this.snapshotMap)==null?void 0:r.get(e))){const d=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(e);if(!d)return;const p=(l=this.collector)==null?void 0:l.getStorageData(d,e);if(!p)return;if(Object.keys(p).forEach(f=>{var g;((g=this.collector)==null?void 0:g.getLocalId(f))===H&&delete p[f]}),Object.keys(p).length){const f=this.viewContainerManager.mainView;if(!f)return;const g=t||((u=f.cameraOpt)==null?void 0:u.width),M=i||((h=f.cameraOpt)==null?void 0:h.height),S={msgType:x.Snapshot,dataType:F.Local,scenePath:e,scenes:p,w:g,h:M,cameraOpt:o&&{...o,width:g,height:M}||f.cameraOpt,isRunSubWork:!0,viewId:f.id};return this.taskBatchData.add(S),this.runAnimation(),new Promise(w=>{this.snapshotMap.set(e,w)}).then(w=>(this.snapshotMap.delete(e),w))}}}queryTaskBatchData(e){const t=[];if(e)for(const i of this.taskBatchData.values()){let o=!0;for(const[n,r]of Object.entries(e))if(i[n]!==r){o=!1;break}o&&t.push(i)}return t}insertIconify(e,t){var r;const i=this.viewContainerManager.getView(e);if(!i)throw new Error("insertIconify viewId is not exist");if(!t.src)throw new Error("iconify src must be required");if(!/^(http|https):\/\//.test(t.src))throw new Error("iconify src must be http or https");t.strokeColor||(t.strokeColor=(r=this.currentLocalWorkData.toolsOpt)==null?void 0:r.strokeColor);const n=i==null?void 0:i.focusScenePath;if(e&&n){const c=Date.now();Ne.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:gt.Iconify};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:x.FullWork,dataType:F.Local,toolsType:N.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}insertImage(e,t){const i=this.viewContainerManager.getView(e);if(!i)throw new Error("insertImage viewId is not exist");if(t.src&&!/^(http|https):\/\//.test(t.src))throw new Error("Image src must be http or https");const o=i==null?void 0:i.focusScenePath;if(e&&o){const{src:n,uuid:r}=t;if(r&&!n){this.tmpImageConfigMap.set(r,t);return}const c=Date.now();Ne.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:gt.Image};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:x.FullWork,dataType:F.Local,toolsType:N.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}lockImage(e,t,i){var r,c;const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");const n=o==null?void 0:o.focusScenePath;if(e&&n&&this.collector){const l=this.collector.getStorageData(e,n);if(!l)return;for(const[u,h]of Object.entries(l))if(h&&h.toolsType===N.Image&&h.opt.uuid===t){const d=Date.now();Ne.InternalMsgEmitter.emit("addUndoTicker",d,e);const p=(r=this.collector)!=null&&r.isOwn(u)?(c=this.collector)==null?void 0:c.getLocalId(u):u,f={...h.opt,locked:i,type:gt.Image};this.taskBatchData.add({msgType:x.FullWork,dataType:F.Local,toolsType:N.Image,workId:p,opt:f,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation();return}}}completeImageUpload(e,t,i){const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");const n=o==null?void 0:o.focusScenePath;if(e&&n){const r=this.tmpImageConfigMap.get(t);r&&(r.src=i,this.insertImage(e,r),this.tmpImageConfigMap.delete(t));return}}getImagesInformation(e){const t=[];if(this.collector){const i=this.collector.getScenePathData(e);if(!i)return t;for(const o of Object.values(i))if(o&&o.toolsType===N.Image){const n=o.opt;t.push({uuid:n.uuid,centerX:n.centerX,centerY:n.centerY,width:n.width,height:n.height,locked:n.locked,uniformScale:n.uniformScale,crossOrigin:n.crossOrigin})}}return t}setShapeSelectorByWorkId(e,t){this.taskBatchData.add({workId:H,selectIds:[e],msgType:x.Select,dataType:F.Local,viewId:t,willSyncService:!0}),this.runAnimation()}blurSelector(e,t,i){this.taskBatchData.add({workId:i||H,selectIds:[],msgType:x.Select,dataType:F.Service,viewId:e,scenePath:t}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:x.Console,dataType:F.Local,isRunSubWork:!0,viewId:""}),this.consume()}setPriority(e){var o,n;const t=new Set,i=new Set;if(e==="cpu"&&((o=this.subMainThreadWorker)==null||o.destroy(),t.add({msgType:x.PriorityWorker,viewId:Jt,dataType:F.Local,isRunSubWork:!0})),e==="ui"){t.add({msgType:x.PriorityMainThreadWorker,viewId:Jt,dataType:F.Local,isRunSubWork:!0});const r=this.viewContainerManager.mainView;if(r){const l=this.viewContainerManager.getViewInitData(r.id);if(l){const{offscreenCanvasOpt:u,layerOpt:h,dpr:d,cameraOpt:p}=l;i.add({msgType:x.Init,dataType:F.Local,viewId:r.id,offscreenCanvasOpt:u,layerOpt:h,dpr:d,cameraOpt:p,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}const c=this.viewContainerManager.appViews;for(const l of c.keys()){const u=this.viewContainerManager.getViewInitData(l);if(u){const{offscreenCanvasOpt:h,layerOpt:d,dpr:p,cameraOpt:f}=u;i.add({msgType:x.Init,dataType:F.Local,viewId:l,offscreenCanvasOpt:h,layerOpt:d,dpr:p,cameraOpt:f,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}}t.size&&this.subWorker.postMessage(t),i.size&&((n=this.subMainThreadWorker)==null||n.consume(i))}sendClearUids(e,t){var o,n;const i=new Set;i.add({msgType:x.AuthClear,dataType:F.Local,viewId:e,clearUids:t,localUid:(o=this.collector)==null?void 0:o.uid}),this.control.hasOffscreenCanvas()?this.fullWorker.postMessage(i):(n=this.mainThread)==null||n.consume(i)}async getVNodeInfo(e,t,i){if(!this.getVNodeInfoResolveMap.has(e))return this.taskBatchData.add({msgType:x.GetVNodeInfo,dataType:F.Local,isRunSubWork:!0,viewId:t,workIds:i,workId:e}),this.consume(),await new Promise(o=>{const n=this.getVNodeInfoResolveMap.get(e)||{resolve:void 0,timer:void 0};n.timer&&clearTimeout(n.timer),n.resolve=o,n.timer=setTimeout(()=>{const r=this.getVNodeInfoResolveMap.get(e);r!=null&&r.resolve&&r.resolve({uuid:e})},this.maxLastSyncTime*5),this.getVNodeInfoResolveMap.set(e,n)}).then(o=>{const{uuid:n}=o;return this.getVNodeInfoResolveMap.delete(n),o})}}var bm=Ge,xm=function(){return bm.Date.now()},Lm=xm,Pm=/\s/;function Dm(a){for(var s=a.length;s--&&Pm.test(a.charAt(s)););return s}var zm=Dm,Am=zm,jm=/^\s+/;function Em(a){return a&&a.slice(0,Am(a)+1).replace(jm,"")}var Om=Em,Rm=yt,Wm=Ke,Ym="[object Symbol]";function Um(a){return typeof a=="symbol"||Wm(a)&&Rm(a)==Ym}var Bm=Um,Fm=Om,to=ct,Vm=Bm,so=NaN,$m=/^[-+]0x[0-9a-f]+$/i,Hm=/^0b[01]+$/i,Qm=/^0o[0-7]+$/i,Gm=parseInt;function Zm(a){if(typeof a=="number")return a;if(Vm(a))return so;if(to(a)){var s=typeof a.valueOf=="function"?a.valueOf():a;a=to(s)?s+"":s}if(typeof a!="string")return a===0?a:+a;a=Fm(a);var e=Hm.test(a);return e||Qm.test(a)?Gm(a.slice(2),e?2:8):$m.test(a)?so:+a}var qm=Zm,Xm=ct,xs=Lm,io=qm,Jm="Expected a function",Km=Math.max,_m=Math.min;function eM(a,s,e){var t,i,o,n,r,c,l=0,u=!1,h=!1,d=!0;if(typeof a!="function")throw new TypeError(Jm);s=io(s)||0,Xm(e)&&(u=!!e.leading,h="maxWait"in e,o=h?Km(io(e.maxWait)||0,s):o,d="trailing"in e?!!e.trailing:d);function p(v){var P=t,C=i;return t=i=void 0,l=v,n=a.apply(C,P),n}function f(v){return l=v,r=setTimeout(S,s),u?p(v):n}function g(v){var P=v-c,C=v-l,L=s-P;return h?_m(L,o-C):L}function M(v){var P=v-c,C=v-l;return c===void 0||P>=s||P<0||h&&C>=o}function S(){var v=xs();if(M(v))return w(v);r=setTimeout(S,g(v))}function w(v){return r=void 0,d&&t?p(v):(t=i=void 0,n)}function I(){r!==void 0&&clearTimeout(r),l=0,t=c=i=r=void 0}function k(){return r===void 0?n:w(xs())}function T(){var v=xs(),P=M(v);if(t=arguments,i=this,c=v,P){if(r===void 0)return f(c);if(h)return clearTimeout(r),r=setTimeout(S,s),p(c)}return r===void 0&&(r=setTimeout(S,s)),n}return T.cancel=I,T.flush=k,T}var tM=eM,sM=tM,iM=ct,oM="Expected a function";function nM(a,s,e){var t=!0,i=!0;if(typeof a!="function")throw new TypeError(oM);return iM(e)&&(t="leading"in e?!!e.leading:t,i="trailing"in e?!!e.trailing:i),sM(a,s,{leading:t,maxWait:s,trailing:i})}var rM=nM;const ui=Pt(rM);class aM{constructor(s){y(this,"internalMsgEmitter");y(this,"control");y(this,"roomHotkeyCheckers");y(this,"tmpCopyStore",new Map);y(this,"tmpCopyCoordInfo");var i;const{control:e,internalMsgEmitter:t}=s;this.control=e,this.internalMsgEmitter=t,this.roomHotkeyCheckers=((i=this.control.room)==null?void 0:i.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var s;return((s=this.control)==null?void 0:s.disableDeviceInputs)||!1}get isSelector(){var s;return((s=this.control.worker.currentToolsData)==null?void 0:s.toolsType)===N.Selector}get collector(){return this.control.collector}get mainEngine(){return this.control.worker}get keyboardKind(){return/^Mac/i.test(navigator.platform)?"mac":"windows"}getEventKey(s){switch(s.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(s){var i,o,n;const e=this.control.viewContainerManager.focuedViewId,t=(i=this.control.viewContainerManager.focuedView)==null?void 0:i.focusScenePath;if(e&&t)switch(s){case"delete":this.isSelector&&((o=this.collector)!=null&&o.hasSelector(e,t))&&ie.emitMethod(se.MainEngine,V.DeleteNode,{workIds:[H],viewId:e});break;case"copy":this.isSelector&&((n=this.collector)!=null&&n.hasSelector(e,t))&&this.copySelectorToTemp(e,t);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(e,t);break}(s==="changeToPencil"||s==="redo"||s==="undo")&&this.onSelfActiveHotkey(s)}colloctHotkey(s){if(this.isUseSelf){const e=this.checkHotkey(s);e&&this.onSelfActiveHotkey(e)}}onSelfActiveHotkey(s){switch(s){case"changeToPencil":this.setMemberState({currentApplianceName:ne.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:ne.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:ne.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:ne.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:ne.eraser,isLine:!0});break;case"changeToHand":this.setMemberState({currentApplianceName:ne.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:ne.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:ne.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:ne.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:ne.straight});break;case"redo":this.control.room&&!this.control.room.disableSerialization&&this.control.viewContainerManager.redo();break;case"undo":this.control.room&&!this.control.room.disableSerialization&&this.control.viewContainerManager.undo();break;case"changeToText":this.setMemberState({currentApplianceName:ne.text});break}}checkHotkey(s){for(const e of this.roomHotkeyCheckers){const{kind:t,checker:i}=e;if(i({nativeEvent:s,kind:this.getEventKey(s),key:s.key,altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey},this.keyboardKind))return t}}copySelectorToTemp(s,e){var l,u;const t=this.control.viewContainerManager.getView(s),i=(u=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:u.getBuilder(V.CopyNode);if(!t||!this.collector||!i)return;const o=this.collector.transformKey(H),n=this.collector.getStorageData(s,e);if(!n)return;const r=n[o],c=r&&i.copySelector({viewId:s,store:r});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(s,e){var o,n;const t=this.control.viewContainerManager.getView(s),i=(n=(o=this.mainEngine)==null?void 0:o.methodBuilder)==null?void 0:n.getBuilder(V.CopyNode);if(!(!t||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!i)&&t.viewData&&this.tmpCopyCoordInfo){const r=A.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=t.viewData.camera;r.x=r.x+l.centerX-c.centerX,r.y=r.y+l.centerY-c.centerY;const u=Date.now();this.control.worker.internalMsgEmitter.emit("addUndoTicker",u,s),i.pasteSelector({viewId:s,scenePath:e,copyStores:A.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:r,cameraOpt:l},undoTickerId:u})}}setMemberState(s){var e;(e=this.control.room)==null||e.setMemberState(s)}}class cM{constructor(s){y(this,"control");y(this,"roomMemberManager");y(this,"worker");y(this,"publicMsgEmitter");y(this,"renderUids",new Map);y(this,"pageAuth",new Map);y(this,"isLocalRender",!1);y(this,"isCurWritable",!1);var i;const{control:e,publicMsgEmitter:t}=s;this.control=e,this.publicMsgEmitter=t,this.roomMemberManager=e.roomMember,this.worker=e.worker,this.isCurWritable=((i=this.control.room)==null?void 0:i.isWritable)||!1}get isWritable(){return this.isCurWritable}onWritableChange(s){this.isCurWritable=s}addPage(s,e=!0){var l,u;const{viewId:t,render:i="localSelf",elementIds:o,pageId:n=(l=this.control.collector)==null?void 0:l.uid}=s,r=this.pageAuth.get(t)||new Map,c=this.control.viewContainerManager.getCurScenePath(t);if(c&&n){const h=r.get(c)||{render:"localSelf",pages:new Map};e&&(h.render=i);const d=o&&this.cloneElementIds(t,c,o,n)||new Set;h.pages.set(n,d),r.set(c,h),this.pageAuth.set(t,r),e&&this.pageAuthEffect(t),this.isLocalRender=!1,(u=this.control.collector)==null||u.dispatchPageAuth({operation:De.addPage,viewId:t,scenePath:c,pageId:n,pageData:{render:i,elementIds:d}},!0)}}delPage(s,e){var n,r;const t=this.pageAuth.get(e);if(!t)return;const i=[...t.keys()].find(c=>{const l=t.get(c);return!!(l&&l.pages.has(s))});if(!i)return;const o=t.get(i);if(o){const{render:c,pages:l}=o,u=c==="localSelf"?(n=this.control.collector)==null?void 0:n.uid:c,h=l.get(s);h!=null&&h.size&&this.delElementIds(e,i,h),l.delete(s),u===s&&this.pageAuthEffect(e)}(r=this.control.collector)==null||r.dispatchPageAuth({operation:De.deletePage,viewId:e,scenePath:i,pageId:s},!0)}delViewPage(s,e=!0){var i;this.pageAuth.get(s)&&(this.pageAuth.delete(s),e&&((i=this.control.collector)==null||i.dispatchPageAuth({operation:De.clearView,viewId:s},e)))}clearRenderPage(s,e,t=!0){var r,c;const i=this.pageAuth.get(s);if(!i)return;const o=i.get(e);let n;if(o){const{render:l,pages:u}=o,h=l==="localSelf"?(r=this.control.collector)==null?void 0:r.uid:l;if(h){if(t){const d=u.get(h);d&&this.delElementIds(s,e,d)}u.set(h,new Set),n=h}}t&&n&&((c=this.control.collector)==null||c.dispatchPageAuth({operation:De.clearPage,viewId:s,scenePath:e,pageId:n},t))}hasPage(s,e,t){const i=this.pageAuth.get(e);if(!i)return!1;const o=i.get(t);return o?o.pages.has(s):!1}getPageInfo(s,e,t){const i=this.pageAuth.get(e);if(!i)return;const o=i.get(t);if(o)return o.pages.get(s)}addRenderPageElementId(s,e=!0,t=!1){var u,h;const{viewId:i,elementId:o,scenePath:n}=s,r=this.pageAuth.get(i);if(!r)throw new Error(`no view info in viewId: ${i}`);const c=r.get(n);let l;if(c){const{render:d,pages:p}=c,f=d==="localSelf"?(u=this.control.collector)==null?void 0:u.uid:d;if(f&&p.has(f)){const g=p.get(f)||new Set;g.add(o),p.set(f,g),l=f}}t&&this.pageAuthEffect(i),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:De.addElement,viewId:i,scenePath:n,pageId:l,pageData:{elementId:o}},e))}delRenderPageElementId(s,e=!0,t=!1){var u,h;const{viewId:i,elementId:o,scenePath:n}=s,r=this.pageAuth.get(i);if(!r)throw new Error(`no view info in viewId: ${i}`);const c=r.get(n);let l;if(c){const{render:d,pages:p}=c,f=d==="localSelf"?(u=this.control.collector)==null?void 0:u.uid:d;if(f&&p.has(f)){const g=p.get(f);g&&(g.delete(o),p.set(f,g),l=f)}}t&&this.pageAuthEffect(i),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:De.deleteElement,viewId:i,scenePath:n,pageId:l,pageData:{elementId:o}},e))}setPageRender(s,e,t,i=!0){var r;const o=this.pageAuth.get(s);if(!o)throw new Error(`no view info in viewId: ${s}`);const n=o.get(e);n&&(n.render=t),e===this.control.viewContainerManager.getCurScenePath(s)&&this.pageAuthEffect(s),i||(this.isLocalRender=!0),i&&(this.isLocalRender=!1,(r=this.control.collector)==null||r.dispatchPageAuth({operation:De.renderPage,viewId:s,scenePath:e,pageData:{render:t}},i))}isRenderAble(s){var c,l;const{uid:e,viewId:t,filterLocalSelf:i=!0,scenePath:o}=s,n=this.renderUids.get(t);if(n){const{render:u,hide:h}=n;if(u===void 0&&h===void 0)return!0;if(A.isSet(u)){if(u.has(e)||i&&((c=this.control.collector)==null?void 0:c.uid)===e&&u.has("localSelf"))return!0}else if(u===!0&&(!h||A.isSet(h)&&!h.has(e)&&!(i&&h.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===e)))return!0;return!1}const r=this.pageAuth.get(t);if(r&&o){const u=r.get(o);if(u){const{render:h}=u;if(h)return!(h==="localSelf"&&!i)}}return!0}isClearAble(s){var c;const{uid:e,viewId:t,filterLocalSelf:i=!0,scenePath:o}=s,n=this.renderUids.get(t);if(n){const{clear:l}=n;return!!(l===void 0||l===!0||A.isSet(l)&&(l.has(e)||i&&((c=this.control.collector)==null?void 0:c.uid)===e&&l.has("localSelf")))}const r=this.pageAuth.get(t);if(r&&o){const l=r.get(o);if(l){const{render:u}=l;if(u)return!(u==="localSelf"&&!i)}}return!0}isFilterAble(s,e){var c,l,u,h;const{viewId:t,scenePath:i,elementId:o}=s,n=this.renderUids.get(t);if(n&&o){const{render:d,hide:p}=n;if(d===void 0&&p===void 0)return!0;const f=(c=this.control.collector)==null?void 0:c.getUidFromKey(o);return f?!!(A.isSet(d)&&(d.has(f)||d.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===f)||d===!0&&(!p||A.isSet(p)&&!p.has(f)&&!(p.has("localSelf")&&((u=this.control.collector)==null?void 0:u.uid)===f))):!1}const r=this.pageAuth.get(t);if(r&&i&&o){const d=r.get(i);if(d){const{render:p,pages:f}=d;if(!p)return!0;const g=(h=this.control.collector)==null?void 0:h.uid,M=p==="localSelf"?g:p,S=M&&f.get(M)||void 0;if(S)switch(e){case x.RemoveNode:return!0;default:return S.has(o)}return!1}}return!0}isFilterCursor(s){if(this.isUsePageAuth(s)){const e=this.control.viewContainerManager.getCurScenePath(s),t=this.pageAuth.get(s);if(e&&t){const i=t.get(e);if(i){const{render:o}=i;return o!=="localSelf"}}}return!0}isUsePageAuth(s){var i;if(!this.pageAuth.has(s))return!1;const t=this.control.viewContainerManager.getCurScenePath(s);return t&&((i=this.pageAuth.get(s))==null?void 0:i.has(t))||!1}publishRender(s){var n;const{viewId:e,option:t,isSync:i=!0}=s,o={};if(t){const{render:r,hide:c,clear:l}=t;r&&(o.render=r===!0&&!0||new Set(r)),c&&(o.hide=c===!0&&!0||new Set(c)),l&&(o.clear=l===!0&&!0||new Set(l)),this.renderUids.set(e,o)}else this.renderUids.delete(e);i&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:Qe.setAuth,viewId:e,renderData:o},i)),this.renderEffect(e)}publishOneRender(s,e,t,i=!0){var r;const o=this.renderUids.get(s);let n;switch(t){case"show":o?(o.render||(o.render=new Set),A.isSet(o.render)&&o.render.add(e),A.isSet(o.hide)&&o.hide.delete(e)):this.renderUids.set(s,{render:new Set([e])}),n=Qe.setShow;break;case"hide":o?(o.hide||(o.hide=new Set),A.isSet(o.hide)&&o.hide.add(e),A.isSet(o.render)&&o.render.delete(e)):this.renderUids.set(s,{hide:new Set([e])}),n=Qe.setHide;break}o?this.renderUids.set(s,o):this.renderUids.delete(s),i&&n&&((r=this.control.collector)==null||r.dispatchRenderAuth({operation:n,viewId:s,uid:e},i)),this.renderEffect(s)}publishOneClear(s,e,t,i=!0){var n;const o=this.renderUids.get(s);t?o?(o.clear||(o.clear=new Set),A.isSet(o.clear)&&o.clear.add(e)):this.renderUids.set(s,{clear:new Set([e])}):o&&A.isSet(o.clear)&&o.clear.has(e)&&o.clear.delete(e),o?this.renderUids.set(s,o):this.renderUids.delete(s),i&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:Qe.setClear,viewId:s,uid:e,isClear:t},i)),this.renderEffect(s)}syncRenderUids(s,e,t,i){const o=e===!0?!0:e&&Object.keys(e)?new Set(Object.keys(e)):void 0,n=t===!0?!0:t&&Object.keys(t)?new Set(Object.keys(t)):void 0,r=i===!0?!0:i&&Object.keys(i)?new Set(Object.keys(i)):void 0;o||n||r?this.renderUids.set(s,{render:o,hide:n,clear:r}):this.renderUids.delete(s),this.renderEffect(s),this.publicMsgEmitter.emit("syncRenderUids",s,{render:o,hide:n,clear:r})}syncPageAuth(s,e,t=!1){let i=!1;if(!e)this.pageAuth.delete(s);else{const o=this.pageAuth.get(s)||new Map;for(const[n,r]of Object.entries(e)){const{render:c,pages:l}=r,u=o.get(n),h=this.isLocalRender?u==null?void 0:u.render:c;if(h){h!==(u==null?void 0:u.render)&&(i=!0);const d=new Map;for(const[f,g]of Object.entries(l))d.set(f,new Set(Object.keys(g)));const p={render:h,pages:d};d.size&&o.set(n,p)}}o.size&&(this.pageAuth.set(s,o),this.publicMsgEmitter.emit("syncPageAuth",s,o))}(t||i)&&this.pageAuthEffect(s)}destoryByViewId(s,e=!1){var t;this.renderUids.has(s)&&(this.renderUids.delete(s),e||(t=this.control.collector)==null||t.dispatchRenderAuth({operation:Qe.setAuth,viewId:s})),this.pageAuth.has(s)&&this.control.renderControl.delViewPage(s,!e)}renderEffect(s){var t;const e=(t=this.control.viewContainerManager.getView(s))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(s,!0).then(()=>{var i;this.worker.pullServiceData(s,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(s,(i=this.renderUids.get(s))==null?void 0:i.clear)})}pageAuthEffect(s){var t;const e=(t=this.control.viewContainerManager.getView(s))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(s,!0).then(()=>{this.worker.pullServiceData(s,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(s,!0)})}cloneElementIds(s,e,t,i){var r,c;const o=(r=this.control.collector)==null?void 0:r.getStorageData(s,e),n=new Set;if(o){for(const l of Object.keys(o))if(t.has(l)){const u=`${l}_${i}`;if(n.add(u),!Object.keys(o).includes(u)){const h=A.cloneDeep(o[l]);(c=this.control.collector)==null||c.updateValue(u,{type:x.FullWork,...h,workId:u},{isSync:!0,viewId:s,scenePath:e})}}}return n}delElementIds(s,e,t){var o,n;const i=(o=this.control.collector)==null?void 0:o.getStorageData(s,e);if(i)for(const r of Object.keys(i))t.has(r)&&Object.keys(i).includes(r)&&((n=this.control.collector)==null||n.updateValue(r,void 0,{isSync:!0,viewId:s,scenePath:e}))}}class lM{constructor(s){y(this,"internalMsgEmitter");y(this,"control");y(this,"maps",new Map);y(this,"showId");y(this,"color");y(this,"timer");y(this,"updateMiniMapCamera",A.debounce(async s=>{const e=this.maps.get(s);if(e){const t=await this.getMiniMapCamera(s);if(t){const i=t.width/t.scale,o=t.height/t.scale,n=e.miniMapCamera.width/e.miniMapCamera.scale,r=e.miniMapCamera.height/e.miniMapCamera.scale;(i>=n||o>=r)&&(e.miniMapCamera=t);const c=e.miniMapCanvas.current;if(c){const l=c.getContext("2d");if(l){const u=this.control.viewContainerManager.getView(s);if(!(u!=null&&u.focusScenePath))return;const{miniMapCamera:h,contianer:d}=e,{width:p,height:f}=d.getBoundingClientRect(),g=Math.min(p/h.width,f/h.height);l.clearRect(0,0,c.width,c.height),c.width=h.width,c.height=h.height,c.style.width=`${h.width*g}px`,c.style.height=`${h.height*g}px`,await this.control.screenshotToCanvas(l,u.focusScenePath,h.width,h.height,h),this.listener.emitAsync([s,"viewCameraUpate"],1)}}}}},2e3,{maxWait:5e3}));var i;const{control:e,internalMsgEmitter:t}=s;this.control=e,this.internalMsgEmitter=t,this.color=((i=this.control.worker.currentToolsData)==null?void 0:i.toolsOpt.strokeColor)||"#000"}get listener(){return this.internalMsgEmitter}get activeViewId(){return this.showId}get highlightColor(){return this.color}setHighlightColor(s){this.color=s}async createMiniMap(s,e,t){const i=this.control.viewContainerManager.getView(s);if(!i)throw new Error("view not found");const o=i.cameraOpt;if(!o)throw new Error("view camera not found");const{width:n,height:r}=e.getBoundingClientRect();if(!n||!r)throw new Error("contianer width or height is 0");const c=m.createRef();this.maps.set(s,{contianer:e,miniMapCanvas:c,miniMapCamera:t,viewCamera:o}),this.showId=s,this.control.viewContainerManager.setActiveMiniMap(this.showId,!0);const l=Math.min(n/t.width,r/t.height),u=await new Promise(h=>{this.listener.once([s,"miniMapCreate"],()=>{const d=c.current;d&&(d.width=t.width,d.height=t.height,d.style.width=`${t.width*l}px`,d.style.height=`${t.height*l}px`),h(!0)}),this.timer=setTimeout(()=>{h(!1)},2e3)});return this.timer&&clearTimeout(this.timer),u}async getMiniMapCamera(s){const e=this.control.viewContainerManager.getView(s);if(!e)return;const{cameraOpt:t,focusScenePath:i}=e;if(!t||!i)return;const o={originX:t.centerX-t.width/t.scale/2,originY:t.centerY-t.height/t.scale/2,width:t.width/t.scale,height:t.height/t.scale};let n=await this.control.getBoundingRect(i)||o;n=ai(n,o)||o;let r=n.width,c=n.height,l=1;const u=r>t.width&&Math.min(t.width/r,l)||l,h=c>t.height&&Math.min(t.height/c,l)||l;return u<=h?(r=u<1&&t.width||r,c=Math.floor(c*u)+1,l=u):u>h&&(c=h<1&&t.height||c,r=Math.floor(r*h)+1,l=h),{scale:l,centerX:n.originX+n.width/2,centerY:n.originY+n.height/2,width:r,height:c}}getMiniMapCanvas(s){const e=this.maps.get(s);return(e==null?void 0:e.miniMapCanvas.current)||null}updateViewCamera(s,e){const t=this.maps.get(s);t&&(t.viewCamera=e,this.listener.emitAsync([s,"viewCameraUpate"],1))}destroyMiniMap(s){const e=s||this.showId;e&&(this.maps.delete(e),this.control.viewContainerManager.setActiveMiniMap(e,!1))}}class ln{constructor(){y(this,"control");y(this,"_listeners",{})}_inject(s){this.control=s}_onEvent(s,e){this._listeners[s]&&this._listeners[s](...e)}callbacks(s,e){this._listeners[s]=e}removeCallback(s){delete this._listeners[s]}}class hM{constructor(s){y(this,"control");y(this,"worker");y(this,"publicMsgEmitter");y(this,"plugins",new Map);const{control:e,publicMsgEmitter:t}=s;this.control=e,this.publicMsgEmitter=t,this.worker=e.worker}use(s){this.plugins.set(s.kind,s),s._inject(this.control),s.onCreate()}destroy(){this.plugins.forEach(s=>{this.plugins.delete(s.kind),s.onDestroy()})}dispatchPluginEvent(s,...e){this.plugins.forEach(t=>{t._onEvent(s,e)})}}const dt=class dt{constructor(s){y(this,"version",Wo);y(this,"plugin");y(this,"room");y(this,"play");y(this,"collector");y(this,"hasSwitchToSelectorEffect");y(this,"snapshootStateMap");y(this,"_disableDeviceInputs");y(this,"_disableEraseImage");y(this,"_disableEraseText");y(this,"_disableCameraTransform");y(this,"priority","cpu");y(this,"effectResolve");y(this,"hotkeyManager");y(this,"pluginOptions");y(this,"roomMember");y(this,"cursor");y(this,"textEditorManager");y(this,"worker");y(this,"renderControl");y(this,"miniMapManager");y(this,"pluginManager");y(this,"onSceneChange",async(s,e)=>{var n;const t=this.viewContainerManager.getView(e);t!=null&&t.focusScenePath&&(n=this.collector)!=null&&n.hasSelector(e,t.focusScenePath)&&this.worker.blurSelector(e,t.focusScenePath),this.textEditorManager.checkEmptyTextBlur();const i=t==null?void 0:t.displayer;i&&(i.setActive(!1),await i.stopEventHandler());const o=s;o&&this.viewContainerManager.setViewScenePath(e,o),i==null||i.setActive(!0)});y(this,"onRoomMembersChange",s=>{this.roomMember.setRoomMembers(G.toJS(s))});y(this,"onMemberChange",ui(s=>{var n;if(!this.room||!this.worker||!s||!this.room.isWritable)return;const e=this.getToolsKey(s),t=(n=this.worker.getCurrentToolsData())==null?void 0:n.toolsType,i=this.viewContainerManager.focuedViewId;i&&t===N.Selector&&e!==N.Selector&&this.worker.blurCursor(i);const o=this.getToolsOpt(e,s);this.worker.setCurrentToolsData(o),this.pluginManager.dispatchPluginEvent("setToolkey",e),this.effectViewContainer(e),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));y(this,"internalSceneChange",(s,e)=>{var i;this.miniMapManager.activeViewId===s&&this.miniMapManager.destroyMiniMap(s),this.pluginManager.dispatchPluginEvent("sceneChange",s,e),(i=this.worker)==null||i.clearViewScenePath(s,!0).then(()=>{var o;(o=this.worker)==null||o.pullServiceData(s,e,{isAsync:!0,useAnimation:!1})})});y(this,"internalCameraChange",(s,e)=>{var t;(t=this.worker)==null||t.updateCamera(s,e),this.miniMapManager.updateViewCamera(s,e)});const{displayer:e,plugin:t,options:i}=s;this.plugin=t,this.room=G.isRoom(e)?e:void 0,this.play=G.isPlayer(e)?e:void 0,this.room&&(this._disableDeviceInputs=this.room.disableDeviceInputs,this._disableEraseImage=this.room.disableEraseImage,this._disableEraseText=!1),this.pluginOptions=i,this.roomMember=new rm;const o={control:this,internalMsgEmitter:dt.InternalMsgEmitter,publicMsgEmitter:dt.PublicMsgEmitter};this.cursor=new cm(o),this.textEditorManager=new am(o),this.worker=new Cm(o),this.hotkeyManager=new aM(o),this.renderControl=new cM(o),this.miniMapManager=new lM(o),this.pluginManager=new hM(o)}get disableEraseText(){return this._disableEraseText||!1}set disableEraseText(s){this._disableEraseText=s}get disableEraseImage(){return this._disableEraseImage||!1}set disableEraseImage(s){this._disableEraseImage=s}get disableDeviceInputs(){return this._disableDeviceInputs||!1}set disableDeviceInputs(s){var t;this._disableDeviceInputs=s;const e=(t=this.worker.getCurrentToolsData())==null?void 0:t.toolsType;e&&this.effectViewContainer(e)}get disableCameraTransform(){return this._disableCameraTransform||!1}set disableCameraTransform(s){this._disableCameraTransform=s}setPriority(s){var e;this.priority=s,this.hasOffscreenCanvas()&&((e=this.worker)==null||e.setPriority(s))}hasOffscreenCanvas(){return ti==="worker"}bindPlugin(s){var e,t;this.plugin=s,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new Ws(this,s,(t=(e=this.pluginOptions)==null?void 0:e.syncOpt)==null?void 0:t.interval),this.activePlugin()}destroy(){var s,e,t,i,o,n;this.roomMember.destroy(),(s=this.collector)==null||s.destroy(),(e=this.worker)==null||e.destroy(),(t=this.viewContainerManager)==null||t.destroy(),(i=this.cursor)==null||i.destroy(),(o=this.textEditorManager)==null||o.destory(),(n=this.pluginManager)==null||n.destroy()}cleanCurrentScene(){const s=Date.now(),e=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;e&&(dt.InternalMsgEmitter.emit("addUndoTicker",s,e),this.worker.clearViewScenePath(e,!1,!0))}async setWritable(s){var e,t;if(!s){(e=this.cursor)==null||e.unabled(),this.textEditorManager.checkEmptyTextBlur();const i=this.viewContainerManager.getAllViews();for(const o of i){o!=null&&o.focusScenePath&&(t=this.collector)!=null&&t.hasSelector(o.id,o.focusScenePath)&&this.worker.blurSelector(o.id,o.focusScenePath);const n=o==null?void 0:o.displayer;n&&n.getActive()&&(n.setActive(!1),await n.stopEventHandler())}}await new Promise(i=>{setTimeout(()=>{i()},500)})}onWritableChange(s){s?this.worker.abled():this.worker.unWritable(),this.renderControl.onWritableChange(s),this.viewContainerManager.getAllViews().forEach(t=>{const i=t==null?void 0:t.displayer;i&&(i.bindToolsClass(),s?i.setActive(!0):i.setActive(!1))})}getToolsKey(s){var t;const e=s.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,e){case ne.text:return s.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),N.Text;case ne.pencil:return s.useLaserPen?N.LaserPen:N.Pencil;case ne.eraser:return N.Eraser;case ne.pencilEraser:return((t=this.pluginOptions.pencilEraser)==null?void 0:t.useBitMap)===!1?N.PencilEraser:N.BitMapEraser;case ne.selector:return N.Selector;case ne.arrow:return s.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),N.Arrow;case ne.straight:return s.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),N.Straight;case ne.ellipse:return s.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),N.Ellipse;case ne.rectangle:return s.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),N.Rectangle;case ne.shape:if(s.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),s.shapeType===$e.Pentagram||s.shapeType===$e.Star)return N.Star;if(s.shapeType===$e.Polygon||s.shapeType===$e.Triangle||s.shapeType===$e.Rhombus)return N.Polygon;if(s.shapeType===$e.SpeechBalloon)return N.SpeechBalloon;break}return N.Clicker}getToolsOpt(s,e){if(s===N.Clicker)return{toolsType:s,toolsOpt:{}};const t={strokeColor:vt(e.strokeColor[0],e.strokeColor[1],e.strokeColor[2],e.strokeOpacity||1),thickness:e.strokeWidth,isOpacity:(e==null?void 0:e.strokeOpacity)&&e.strokeOpacity<1||(e==null?void 0:e.fillOpacity)&&e.fillOpacity<1||(e==null?void 0:e.textOpacity)&&e.textOpacity<1||(e==null?void 0:e.textBgOpacity)&&e.textBgOpacity<1||!1};switch(s){case N.Text:t.fontFamily=window.getComputedStyle(document.documentElement).getPropertyValue("font-family"),t.fontSize=(e==null?void 0:e.textSizeOverride)||(e==null?void 0:e.textSize)||Number(window.getComputedStyle(document.body).fontSize),t.textAlign=(e==null?void 0:e.textAlign)||"left",t.verticalAlign=(e==null?void 0:e.verticalAlign)||"middle",t.fontColor=(e==null?void 0:e.textColor)&&vt(e.textColor[0],e.textColor[1],e.textColor[2],e.textOpacity||1)||t.strokeColor||"rgba(0,0,0,1)",t.fontBgColor=Array.isArray(e==null?void 0:e.textBgColor)&&vt(e.textBgColor[0],e.textBgColor[1],e.textBgColor[2],e.textBgOpacity||1)||"transparent",t.bold=(e==null?void 0:e.bold)&&"bold"||void 0,t.italic=(e==null?void 0:e.italic)&&"italic"||void 0,t.underline=(e==null?void 0:e.underline)||void 0,t.lineThrough=(e==null?void 0:e.lineThrough)||void 0,t.text="",t.strokeColor=void 0;break;case N.Pencil:t.strokeType=(e==null?void 0:e.strokeType)||te.Normal;break;case N.PencilEraser:case N.BitMapEraser:case N.Eraser:t.thickness=Math.min(4,Math.max(1,Math.floor(e.pencilEraserSize||1)))-1,(s===N.BitMapEraser||s===N.PencilEraser)&&(t.eraserColor=e.eraserColor&&vt(e.eraserColor[0],e.eraserColor[1],e.eraserColor[2],e.eraserOpacity||.3)||"rgba(136,136,136,0.3)");break;case N.LaserPen:t.duration=(e==null?void 0:e.duration)||1,e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===te.Stroke?t.strokeType=te.Normal:t.strokeType=(e==null?void 0:e.strokeType)||te.Normal;break;case N.Arrow:case N.Straight:e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===te.Stroke?t.strokeType=te.Normal:t.strokeType=(e==null?void 0:e.strokeType)||te.Normal;break;case N.Ellipse:case N.Rectangle:case N.Star:case N.Polygon:case N.SpeechBalloon:e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===te.Stroke?t.strokeType=te.Normal:t.strokeType=(e==null?void 0:e.strokeType)||te.Normal,s===N.Star&&(e.shapeType===$e.Pentagram?(t.vertices=10,t.innerVerticeStep=2,t.innerRatio=.4):e!=null&&e.vertices&&(e!=null&&e.innerVerticeStep)&&(e!=null&&e.innerRatio)&&(t.vertices=e.vertices,t.innerVerticeStep=e.innerVerticeStep,t.innerRatio=e.innerRatio)),s===N.Polygon&&(e.shapeType===$e.Triangle?t.vertices=3:e.shapeType===$e.Rhombus?t.vertices=4:e.vertices&&(t.vertices=e.vertices)),t.fillColor=(e==null?void 0:e.fillColor)&&vt(e.fillColor[0],e.fillColor[1],e.fillColor[2],e==null?void 0:e.fillOpacity)||"transparent",s===N.SpeechBalloon&&(t.placement=e.placement||"bottomLeft");break}return{toolsType:s,toolsOpt:t}}effectViewContainer(s){var e,t,i,o,n,r,c;if(this.disableDeviceInputs===!0)this.room.disableDeviceInputs=!0,(e=this.worker)==null||e.unWritable(),(t=this.cursor)==null||t.unabled();else switch(s){case N.Text:case N.Pencil:case N.LaserPen:case N.Arrow:case N.Straight:case N.Rectangle:case N.Ellipse:case N.Star:case N.Polygon:case N.SpeechBalloon:case N.Triangle:case N.Rhombus:case N.Eraser:case N.PencilEraser:case N.BitMapEraser:this.room.disableDeviceInputs=!0,(i=this.worker)==null||i.abled();break;case N.Selector:this.room.disableDeviceInputs=!1,(o=this.cursor)==null||o.unabled(),(n=this.worker)==null||n.abled();break;default:this.room.disableDeviceInputs=!1,(r=this.worker)==null||r.unWritable(),(c=this.cursor)==null||c.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(u=>{u!=null&&u.displayer&&u.displayer.bindToolsClass()})},0)}async getBoundingRect(s){var t,i,o,n,r;const e=await((t=this.worker)==null?void 0:t.getBoundingRect(s));if(e){const c=((o=(i=this.viewContainerManager.mainView)==null?void 0:i.viewData)==null?void 0:o.convertToPointInWorld({x:e.x,y:e.y}))||{x:e.x,y:e.y},l=((r=(n=this.viewContainerManager.mainView)==null?void 0:n.viewData)==null?void 0:r.camera.scale)||1;return{width:Math.floor(e.w/l)+1,height:Math.floor(e.h/l)+1,originX:c.x,originY:c.y}}}async screenshotToCanvas(s,e,t,i,o,n,r){const c=await this.worker.getSnapshot(e,t,i,o);c&&(s.drawImage(c,n||0,r||0),c.close())}async scenePreview(s,e){var n,r,c,l;const t=(n=this.collector)==null?void 0:n.getViewIdBySecenPath(s);if(!t)return;const i=this.viewContainerManager.getView(t);if(!i||!((r=i.cameraOpt)!=null&&r.width)||!((c=i.cameraOpt)!=null&&c.height))return;const o=await((l=this.worker)==null?void 0:l.getSnapshot(s));if(o&&this.worker){const u=document.createElement("canvas"),h=u.getContext("2d"),{width:d,height:p}=i.cameraOpt;u.width=d,u.height=p,h&&(h.drawImage(o,0,0),e.crossOrigin="anonymous",e.src=u.toDataURL(),e.onload=()=>{u.remove()},e.onerror=()=>{u.remove(),e.remove()}),o.close()}}switchToText(){var s;(s=this.room)==null||s.setMemberState({currentApplianceName:ne.text})}switchToSelector(){var s;(s=this.room)==null||s.setMemberState({currentApplianceName:ne.selector})}async runEffectWork(s){if(this.hasSwitchToSelectorEffect){const e=await new Promise(t=>{this.switchToSelector(),this.effectResolve=t});this.effectResolve=void 0,e&&s&&s()}}setSnapshootData(){var s;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(s=this.room)==null?void 0:s.state.memberState))}getSnapshootData(s){var e;return(e=this.snapshootStateMap)==null?void 0:e.get(s)}clearSnapshootData(){var s;(s=this.snapshootStateMap)==null||s.clear(),this.snapshootStateMap=void 0}useBitMapEraser(s){var e;if(((e=this.pluginOptions.pencilEraser)==null?void 0:e.useBitMap)===void 0){this.pluginOptions.pencilEraser={useBitMap:s,maxImageWidth:we.pencilEraser.maxImageWidth,maxImageHeight:we.pencilEraser.maxImageHeight};return}this.pluginOptions.pencilEraser.useBitMap=s}consoleWorkerInfo(){var s;(s=this.worker)==null||s.consoleWorkerInfo()}filterRenderByUid(s,e,t=!0){var o;this.viewContainerManager.getView(s)&&((o=this.renderControl)==null||o.publishRender({viewId:s,option:e,isSync:t}))}cancelFilterRender(s,e=!0){var t;(t=this.renderControl)==null||t.publishRender({viewId:s,isSync:e})}async createMiniMap(s,e){const t=await this.miniMapManager.getMiniMapCamera(s);if(t&&await this.miniMapManager.createMiniMap(s,e,t)){const o=this.miniMapManager.getMiniMapCanvas(s);if(o){const n=o.getContext("2d");if(n){const r=this.viewContainerManager.getView(s);r!=null&&r.focusScenePath&&this.screenshotToCanvas(n,r.focusScenePath,t.width,t.height,t)}}}}async destroyMiniMap(s){this.miniMapManager.destroyMiniMap(s)}insertIconify(s,e){var i;if(this.viewContainerManager.getView(s)&&this.room){const o=this.room.state.memberState,n=vt(o.strokeColor[0],o.strokeColor[1],o.strokeColor[2],o.strokeOpacity||1);(i=this.worker)==null||i.insertIconify(s,{...e,strokeColor:n})}}usePlugin(s){return this.pluginManager.use(s)}};y(dt,"InternalMsgEmitter",new Ps),y(dt,"PublicMsgEmitter",new Ps);let Ne=dt;const pt=class pt{constructor(s){y(this,"emitter",new Ps);y(this,"undoStack");y(this,"redoStack");y(this,"worker");y(this,"control");y(this,"room");y(this,"isTicking");y(this,"undoTickerId");y(this,"viewId");y(this,"scenePath");y(this,"tickStartStorerCache");y(this,"excludeIds",new Set);y(this,"onChangeScene",A.debounce(()=>{const s=this.control.viewContainerManager.getCurScenePath(this.viewId);if(s){let e=this.undoStack.filter(i=>i.scenePath===s).length;const t=this.redoStack.filter(i=>i.scenePath===s).length;e===0&&t===0&&this.tickStartStorerCache&&this.scenePath===s&&(e=1),this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",t)}},pt.waitTime));const{control:e,internalMsgEmitter:t,viewId:i}=s;this.control=e,this.emitter=t,this.undoStack=[],this.redoStack=[],this.room=e.room,this.worker=e.worker,this.isTicking=!1,this.viewId=i}get collector(){return this.control.collector}addExcludeIds(s){if(this.isTicking)for(const e of s)this.excludeIds.add(e)}undoTickerStart(s,e){var t,i;if(this.collector&&(this.undoTickerId!==s||this.scenePath!==e)){!this.undoTickerId&&!this.tickStartStorerCache&&!this.scenePath&&this.emitter.emit("onCanUndoStepsUpdate",1),this.undoTickerId&&this.viewId&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath),this.isTicking=!0;const o=this.collector.transformKey(H);this.excludeIds.add(o),this.undoTickerId=s,this.scenePath=e;const n=((t=this.collector)==null?void 0:t.storage[this.viewId])&&((i=this.collector)==null?void 0:i.storage[this.viewId][this.scenePath])||{};this.tickStartStorerCache=new Map(Object.entries(A.cloneDeep(n)))}}undoTickerEndSync(s,e,t,i=!0){var o,n;if(s===this.undoTickerId&&t===this.scenePath&&e===this.viewId&&this.tickStartStorerCache){const r=((o=this.collector)==null?void 0:o.storage[e])&&((n=this.collector)==null?void 0:n.storage[e][t])||{},c=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(r)));c.size&&(this.undoStack.push({id:s,type:2,data:A.cloneDeep(c),scenePath:t}),this.undoStack.length>pt.MaxStackLength&&this.undoStack.shift(),i&&this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length+1)),this.redoStack.length&&(this.redoStack.length=0,this.emitter.emit("onCanRedoStepsUpdate",this.redoStack.length)),this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this.undoTickerId=void 0,this.excludeIds.clear()}}undo(s){this.undoTickerId&&this.tickStartStorerCache&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath,!1);let e=this.undoStack.length-1;for(;e>=0;){if(this.undoStack[e].scenePath===s){const n=this.undoStack[e];n&&(this.redoStack.push(n),n.type===2&&n.data&&this.refreshPlugin(n)),this.undoStack.splice(e,1);break}e--}const t=this.undoStack.filter(o=>o.scenePath===s).length,i=this.redoStack.filter(o=>o.scenePath===s).length;return this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",i),t}redo(s){let e=this.redoStack.length-1;for(;e>=0;){if(this.redoStack[e].scenePath===s){const n=this.redoStack[e];n&&(!this.undoTickerId&&n.tickStartStorerCache?(this.undoTickerId=n.id,this.tickStartStorerCache=n.tickStartStorerCache,this.scenePath=n.scenePath):this.undoStack.push(n),n.type===2&&n.data&&this.refreshPlugin(n,!0)),this.redoStack.splice(e,1);break}e--}const t=this.undoStack.filter(o=>o.scenePath===s).length,i=this.redoStack.filter(o=>o.scenePath===s).length;return this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",i),i}clear(){this.clearUndo(),this.clearRedo()}clearUndo(){this.undoStack.length=0,this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length)}clearRedo(){this.redoStack.length=0,this.emitter.emit("onCanRedoStepsUpdate",this.redoStack.length)}canUndo(){return!!this.undoStack.length}canRedo(){return!!this.redoStack.length}onFocusView(){const s=this.control.viewContainerManager.getCurScenePath(this.viewId);if(s){let e=this.undoStack.filter(i=>i.scenePath===s).length;const t=this.redoStack.filter(i=>i.scenePath===s).length;e===0&&t===0&&this.tickStartStorerCache&&this.scenePath===s&&(e=1),this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",t)}}diffFun(s,e){const t=new Set,i=s.keys(),o=e.keys();for(const n of i){if(this.excludeIds.has(n))continue;const r=s.get(n),c=e.get(n);if(r&&c){if(A.isEqual(c,r))continue;t.add({dataType:3,key:n,data:[r,c]});continue}r&&t.add({dataType:2,key:n,data:r})}for(const n of o){if(this.excludeIds.has(n))continue;const r=e.get(n);r&&!s.has(n)&&t.add({dataType:1,key:n,data:r})}return t}isDrawEffectiveScene(s,e){const{key:t}=s;return!e.includes(t)}isDeleteEffectiveScene(s,e,t){var n;const{key:i}=s;if(!e.includes(i))return!1;const o=e.filter(r=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(r))===H&&!((l=this.collector)!=null&&l.isOwn(r))}).map(r=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][t][r]});for(const r of o)if((n=r==null?void 0:r.selectIds)!=null&&n.includes(i))return!1;return!0}isOldEffectiveScene(s,e,t){var n;const{key:i}=s;if(!e.includes(i))return!1;const o=e.filter(r=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(r))===H&&!((l=this.collector)!=null&&l.isOwn(r))}).map(r=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][t][r]});for(const r of o)if((n=r==null?void 0:r.selectIds)!=null&&n.includes(i))return!1;return!0}isNewEffectiveScene(s,e){const{key:t}=s;return!!e.includes(t)}refreshPlugin(s,e=!1){var r,c,l,u,h,d,p,f,g,M,S,w,I,k,T,v,P,C,L,O,R;let t;const{scenePath:i}=s,o=s.data;if(!o||!this.collector)return;const n=A.cloneDeep(this.collector.storage);for(const E of o.values()){const{dataType:j,data:D,key:q}=E,oe=this.collector.getStorageData(this.viewId,i),X=oe&&Object.keys(oe)||[];switch(j){case 1:if(t=e?this.isDrawEffectiveScene(E,X):this.isDeleteEffectiveScene(E,X,i),t)if(e&&!Array.isArray(D)){if((r=D.updateNodeOpt)!=null&&r.useAnimation&&(D.updateNodeOpt.useAnimation=!1),((c=this.collector)==null?void 0:c.getLocalId(q))===H&&((l=this.collector)!=null&&l.isOwn(E.key))){const Z=D.selectIds;if(Z){const _=X.filter(J=>{var K,he;return((K=this.collector)==null?void 0:K.getLocalId(J))===H&&!((he=this.collector)!=null&&he.isOwn(J))}).map(J=>{var K;return(K=this.collector)==null?void 0:K.storage[this.viewId][i][J]});let Q=!1;for(const J of _)for(let K=0;K<Z.length;K++)(u=J==null?void 0:J.selectIds)!=null&&u.includes(Z[K])&&(delete Z[K],Q=!0);Q&&(D.selectIds=Z.filter(J=>!!J))}}(h=this.collector)==null||h.updateValue(E.key,D,{viewId:this.viewId,scenePath:i,isSync:!0,storage:n})}else!e&&!Array.isArray(E.data)&&((d=this.collector)==null||d.updateValue(E.key,void 0,{viewId:this.viewId,scenePath:i,isSync:!0,storage:n}));break;case 2:if(t=e?this.isDeleteEffectiveScene(E,X,i):this.isDrawEffectiveScene(E,X),t){if(e&&!Array.isArray(D))(p=this.collector)==null||p.updateValue(q,void 0,{viewId:this.viewId,scenePath:i,isSync:!0,storage:n});else if(!e&&!Array.isArray(D)){if((f=D.updateNodeOpt)!=null&&f.useAnimation&&(D.updateNodeOpt.useAnimation=!1),((g=this.collector)==null?void 0:g.getLocalId(E.key))===H&&((M=this.collector)!=null&&M.isOwn(E.key))){const Z=D.selectIds;if(Z){const _=X.filter(J=>{var K,he;return((K=this.collector)==null?void 0:K.getLocalId(J))===H&&!((he=this.collector)!=null&&he.isOwn(J))}).map(J=>{var K;return(K=this.collector)==null?void 0:K.storage[this.viewId][i][J]});let Q=!1;for(const J of _)for(let K=0;K<Z.length;K++)(S=J==null?void 0:J.selectIds)!=null&&S.includes(Z[K])&&(delete Z[K],Q=!0);Q&&(D.selectIds=Z.filter(J=>!!J))}}(w=this.collector)==null||w.updateValue(E.key,E.data,{viewId:this.viewId,scenePath:i,isSync:!0,storage:n})}}break;case 3:if(t=e?this.isNewEffectiveScene(E,X):this.isOldEffectiveScene(E,X,i),t){if(e&&Array.isArray(D)&&D.length===2){const Z=D[1];if((I=Z.updateNodeOpt)!=null&&I.useAnimation&&(Z.updateNodeOpt.useAnimation=!1),((k=this.collector)==null?void 0:k.getLocalId(E.key))===H&&((T=this.collector)!=null&&T.isOwn(E.key))){const _=Z.selectIds;if(_){const Q=X.filter(K=>{var he,Se;return((he=this.collector)==null?void 0:he.getLocalId(K))===H&&!((Se=this.collector)!=null&&Se.isOwn(K))}).map(K=>{var he;return(he=this.collector)==null?void 0:he.storage[this.viewId][i][K]});let J=!1;for(const K of Q)for(let he=0;he<_.length;he++)K!=null&&K.selectIds&&((v=K.selectIds)!=null&&v.includes(_[he]))&&(delete _[he],J=!0);J&&(Z.selectIds=_.filter(K=>!!K))}}(P=this.collector)==null||P.updateValue(q,Z,{viewId:this.viewId,scenePath:i,isSync:!0,storage:n})}else if(!e&&Array.isArray(D)&&D.length===2){const Z=D[0];if((C=Z.updateNodeOpt)!=null&&C.useAnimation&&(Z.updateNodeOpt.useAnimation=!1),((L=this.collector)==null?void 0:L.getLocalId(E.key))===H&&((O=this.collector)!=null&&O.isOwn(E.key))){const _=Z.selectIds;if(_){const Q=X.filter(K=>{var he,Se;return((he=this.collector)==null?void 0:he.getLocalId(K))===H&&!((Se=this.collector)!=null&&Se.isOwn(K))}).map(K=>{var he;return(he=this.collector)==null?void 0:he.storage[this.viewId][i][K]});let J=!1;for(const K of Q)for(let he=0;he<_.length;he++)K!=null&&K.selectIds&&K.selectIds.includes(_[he])&&(delete _[he],J=!0);J&&(Z.selectIds=_.filter(K=>!!K))}}(R=this.collector)==null||R.updateValue(E.key,Z,{viewId:this.viewId,scenePath:i,isSync:!0,storage:n})}}break}}}};y(pt,"sdkCallBack"),y(pt,"MaxStackLength",20),y(pt,"waitTime",100);let cs=pt;function uM(a){return a instanceof TouchEvent||a instanceof window.TouchEvent||(a==null?void 0:a.touches)&&(a==null?void 0:a.touches.length)||(a==null?void 0:a.changedTouches)&&(a==null?void 0:a.changedTouches.length)}function bt(a){return uM(a)&&(a.touches&&a.touches.length===1||a.changedTouches&&a.changedTouches.length===1)}function hn(a){return a.touches&&a.touches.length?{x:a.touches[0].pageX,y:a.touches[0].pageY}:a.changedTouches&&a.changedTouches.length?{x:a.changedTouches[0].pageX,y:a.changedTouches[0].pageY}:{x:a.pageX,y:a.pageY}}class xt{constructor(s){y(this,"internalMsgEmitter");y(this,"control");y(this,"mainView");y(this,"appViews",new Map);y(this,"undoTickerStart",(s,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.undoTickerStart(s,t.focusScenePath)});y(this,"addExcludeIds",(s,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.addExcludeIds(s)});const{control:e,internalMsgEmitter:t}=s;this.control=e,this.internalMsgEmitter=t,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds)}get worker(){return this.control.worker}undo(){const s=this.focuedView;let e=0;if(s){const t=s.focusScenePath;e=s.displayer.commiter.undo(t)||0}return e}redo(){const s=this.focuedView;let e=0;if(s){const t=s.focusScenePath;e=s.displayer.commiter.redo(t)||0}return e}validator(s,e,t){var n;const i=A.clone(s[e]),o=A.clone(t);e==="focusScenePath"&&t&&!A.isEqual(i,o)&&(this.control.internalSceneChange(s.id,o),(n=this.focuedView)==null||n.displayer.commiter.onChangeScene()),e==="cameraOpt"&&!A.isEqual(i,o)&&this.control.internalCameraChange(s.id,o)}destroyAppView(s,e=!1){const t=this.appViews.get(s);t&&(this.control.textEditorManager.clear(s,e),t.displayer.destroy(),this.appViews.delete(s))}createMianView(s){this.mainView=new Proxy(s,{set:(e,t,i)=>(this.worker.isActive&&this.validator(e,t,i),e[t]=i,!0)})}createAppView(s){const e=s.id,t=new Proxy(s,{set:(i,o,n)=>(this.worker.isActive&&this.validator(i,o,n),i[o]=n,!0)});this.appViews.set(e,t)}isAppView(s){return s!==pe&&this.appViews.has(s)}getView(s){var e;return s===pe?this.mainView:(e=this.appViews)==null?void 0:e.get(s)}getCurScenePath(s){const e=this.getView(s);if(e)return e.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(s,e){var t;if(s===pe&&this.mainView)this.mainView.focusScenePath=e;else{const i=s&&((t=this.appViews)==null?void 0:t.get(s))||void 0;i&&(i.focusScenePath=e)}}setViewData(s,e){var t;if(s===pe&&this.mainView)this.mainView.viewData=e;else{const i=s&&((t=this.appViews)==null?void 0:t.get(s))||void 0;i&&(i.viewData=e)}}setFocuedViewId(s){var e;this.focuedViewId=s,s===pe?this.focuedView=this.mainView:this.focuedView=s&&((e=this.appViews)==null?void 0:e.get(s))||void 0,this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(s,e){var i;let t;s===pe?t=this.mainView:t=(i=this.appViews)==null?void 0:i.get(s),t&&(t.focusScenePath=e)}destroy(){var s;this.internalMsgEmitter.off("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.off("excludeIds",this.addExcludeIds),(s=this.mainView)==null||s.displayer.destroy(),this.control.destroyMiniMap(pe),this.appViews.forEach(e=>{this.destroyAppView(e.id,!0),this.worker.destroyViewWorker(e.id),this.control.destroyMiniMap(e.id)})}setFocuedViewCameraOpt(s){if(this.focuedView){const e=this.focuedView.cameraOpt;A.isEqual(e,s)||(this.focuedView.cameraOpt=s)}}transformToOriginPoint(s,e){const t=this.getView(e);if(t!=null&&t.viewData){const i=t.viewData.convertToPointOnScreen(s[0],s[1]);return[i.x,i.y]}return s}transformToScenePoint(s,e){const t=this.getView(e);if(t!=null&&t.viewData){const i=t.viewData.convertToPointInWorld({x:s[0],y:s[1]});return[i.x,i.y]}return s}render(s){var e,t,i,o,n,r,c,l,u,h,d,p,f,g,M,S,w;for(const I of s){const{rect:k,imageBitmap:T,isClear:v,isUnClose:P,drawCanvas:C,clearCanvas:L,viewId:O}=I,R=(e=this.getView(O))==null?void 0:e.displayer;if(R&&k){const{dpr:E,canvasBgRef:j,canvasFloatRef:D,canvasServiceFloatRef:q,canvasTopRef:oe}=R,X=Math.floor(k.w*E),Z=Math.floor(k.h*E),_=k.x*E,Q=k.y*E;if(v){switch(L){case me.TopFloat:(i=(t=oe.current)==null?void 0:t.getContext("2d"))==null||i.clearRect(_,Q,X,Z);break;case me.Float:(n=(o=D.current)==null?void 0:o.getContext("2d"))==null||n.clearRect(_,Q,X,Z);break;case me.ServiceFloat:(c=(r=q.current)==null?void 0:r.getContext("2d"))==null||c.clearRect(_,Q,X,Z);break;case me.Bg:(u=(l=j.current)==null?void 0:l.getContext("2d"))==null||u.clearRect(_,Q,X,Z);break}continue}if(C&&T)switch(C){case me.TopFloat:(d=(h=oe.current)==null?void 0:h.getContext("2d"))==null||d.drawImage(T,0,0,X,Z,_,Q,X,Z);break;case me.Float:{(f=(p=D.current)==null?void 0:p.getContext("2d"))==null||f.drawImage(T,0,0,X,Z,_,Q,X,Z);break}case me.ServiceFloat:{(M=(g=q.current)==null?void 0:g.getContext("2d"))==null||M.drawImage(T,0,0,X,Z,_,Q,X,Z);break}case me.Bg:{(w=(S=j.current)==null?void 0:S.getContext("2d"))==null||w.drawImage(T,0,0,X,Z,_,Q,X,Z);break}}if(P)continue;T==null||T.close()}}}showFloatBar(s,e,t){const i=this.getView(s),o=i==null?void 0:i.displayer.vDom;o&&o.showFloatBar(e,t)}showFloatBarBtn(s,e){const t=this.getView(s),i=t==null?void 0:t.displayer.vDom;i&&i.showFloatBarBtn(e)}setActiveTextEditor(s,e){const t=this.getView(s),i=t==null?void 0:t.displayer.vDom;i&&i.setActiveTextEditor(e)}setActiveMiniMap(s,e){const t=this.getView(s),i=t==null?void 0:t.displayer.vDom;i&&i.setActiveMiniMap(e&&s||void 0)}}y(xt,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),y(xt,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"webgl2"}),y(xt,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class dM{constructor(s,e,t){y(this,"viewId");y(this,"control");y(this,"internalMsgEmitter");y(this,"commiter");y(this,"cachePoint");y(this,"cacheCursorPoint");y(this,"active",!0);y(this,"toolsKey");y(this,"mousedown",s=>{var e;if(this.active&&s.button===0&&this.viewId){this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset(),this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType;const t=this.getPoint(s);this.cachePoint=t,t&&this.worker.originalEventLintener(z.Start,t,this.viewId),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseleave",this.mouseup,!1),document.addEventListener("mouseup",this.mouseup,!1)}});y(this,"mousemove",s=>{if(this.active&&this.viewId){const e=this.getPoint(s);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(z.Doing,e,this.viewId)}});y(this,"mouseup",s=>{if(this.active&&s.button===0&&this.viewId){const e=this.getPoint(s)||this.cachePoint;e?(this.worker.originalEventLintener(z.Done,e,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0):(document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1))}});y(this,"touchstart",s=>{var e;if(this.active){if(!bt(s)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(s);this.cachePoint=t,t&&this.worker.originalEventLintener(z.Start,t,this.viewId),document.addEventListener("touchmove",this.touchmove,!1),document.addEventListener("touchend",this.touchend,!1)}}});y(this,"touchmove",s=>{if(this.active){if(!bt(s)){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(s);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(z.Doing,e,this.viewId)}}});y(this,"touchend",s=>{if(this.active){if(!bt(s)||!this.worker.isAbled()){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(s)||this.cachePoint;e?(this.worker.originalEventLintener(z.Done,e,this.viewId).finally(()=>{document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0):(document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1))}}});y(this,"cursorMouseMove",A.throttle(s=>{const e=this.getPoint(s);this.cacheCursorPoint&&A.isEqual(e,this.cacheCursorPoint)||!this.viewId||(this.cacheCursorPoint=e,e&&this.worker.sendCursorEvent(e,this.viewId))},30,{leading:!1}));y(this,"cursorMouseLeave",A.throttle(()=>{this.viewId&&(this.cacheCursorPoint=[void 0,void 0],this.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId))},30,{leading:!1}));y(this,"keydown",s=>{this.control.hotkeyManager.colloctHotkey(s)});this.viewId=s,this.control=e,this.internalMsgEmitter=t;const i={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new cs(i)}get worker(){return this.control.worker}bindToolsClass(){var e,t;const s=(t=(e=this.worker)==null?void 0:e.currentToolsData)==null?void 0:t.toolsType;switch(s){case N.Text:case N.Pencil:case N.LaserPen:case N.Arrow:case N.Straight:case N.Rectangle:case N.Ellipse:case N.Star:case N.Polygon:case N.SpeechBalloon:case N.Eraser:case N.PencilEraser:case N.BitMapEraser:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${s===N.Text?"cursor-text":s===N.Eraser||s===N.PencilEraser||s===N.BitMapEraser?"cursor-eraser":s===N.Pencil||s===N.LaserPen?"cursor-pencil":"cursor-arrow"}`);break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}updateSize(){this.setCanvassStyle(),this.reflashContainerOffset()}setViewId(s){this.viewId=s}get parentElement(){var s;return(s=this.eventTragetElement)==null?void 0:s.parentElement}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([se.Cursor,this.viewId])}getPoint(s){const e=hn(s);if(e&&A.isNumber(e.x)&&A.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){this.active=!0}setActive(s){this.active=s}async stopEventHandler(){this.cachePoint&&(await this.worker.originalEventLintener(z.Done,this.cachePoint,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0)}getTranslate(s){const t=(s.style.WebkitTransform||getComputedStyle(s,"").getPropertyValue("-webkit-transform")||s.style.transform||getComputedStyle(s,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),i=t&&parseInt(t[0])||0,o=t&&parseInt(t[1])||0;return[i,o]}getContainerOffset(s,e){var o;const t=this.getTranslate(s);let i={x:e.x+s.offsetLeft-s.scrollLeft+t[0],y:e.y+s.offsetTop-s.scrollTop+t[1]};return(o=s.offsetParent)!=null&&o.nodeName&&s.offsetParent.nodeName!=="BODY"&&(i=this.getContainerOffset(s.offsetParent,i)),i}checkConsumeCount(){return this.cachePoint&&this.control.pluginOptions.bezier&&this.worker.getConsumeCount()>this.control.pluginOptions.bezier.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",us.longPencil,this.viewId)}),!0):!1}bindDisplayerEvent(s){s.addEventListener("mousedown",this.mousedown,!1),s.addEventListener("touchstart",this.touchstart,!1),s.addEventListener("mousemove",this.cursorMouseMove,!1),s.addEventListener("mouseleave",this.cursorMouseLeave,!1),s.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(s){s.removeEventListener("mousedown",this.mousedown,!1),s.removeEventListener("touchstart",this.touchstart,!1),document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1),s.removeEventListener("mousemove",this.cursorMouseMove,!1),s.removeEventListener("mouseleave",this.cursorMouseLeave,!1),s.removeEventListener("keydown",this.keydown,!0)}}class un{constructor(s,e){y(this,"viewId",pe);y(this,"control");y(this,"internalMsgEmitter");y(this,"commiter");y(this,"cachePoint");y(this,"cacheCursorPoint");y(this,"active",!0);y(this,"toolsKey");y(this,"mousedown",s=>{var e;if(this.active&&s.button===0){this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(s);this.cachePoint=t,this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,t?(this.worker.originalEventLintener(z.Start,t,this.viewId).finally(()=>{document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseleave",this.mouseup,!1),document.addEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0):(document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseleave",this.mouseup,!1),document.addEventListener("mouseup",this.mouseup,!1))}});y(this,"mousemove",s=>{if(!this.active)return;const e=this.getPoint(s);this.cachePoint=e,!this.checkConsumeCount()&&e&&this.worker.originalEventLintener(z.Doing,e,this.viewId)});y(this,"mouseup",s=>{if(this.active&&s.button===0){const e=this.getPoint(s)||this.cachePoint;e&&(this.worker.originalEventLintener(z.Done,e,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0)}});y(this,"touchstart",s=>{var t;if(!this.active)return;if(!bt(s)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}this.toolsKey=(t=this.worker.getCurrentToolsData())==null?void 0:t.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const e=this.getPoint(s);this.cachePoint=e,e&&this.worker.originalEventLintener(z.Start,e,this.viewId),document.addEventListener("touchmove",this.touchmove,!1),document.addEventListener("touchend",this.touchend,!1)});y(this,"touchmove",s=>{if(!this.active)return;if(!bt(s)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}const e=this.getPoint(s);this.cachePoint=e,!this.checkConsumeCount()&&e&&this.worker.originalEventLintener(z.Doing,e,this.viewId)});y(this,"touchend",s=>{if(!this.active)return;if(!bt(s)||!this.worker.isAbled()){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}const e=this.getPoint(s)||this.cachePoint;e?(this.worker.originalEventLintener(z.Done,e,this.viewId).finally(()=>{document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0):(document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1))});y(this,"cursorMouseMove",A.throttle(s=>{const e=this.getPoint(s);this.cacheCursorPoint&&A.isEqual(e,this.cacheCursorPoint)||(this.cacheCursorPoint=e,e&&this.worker.sendCursorEvent(e,this.viewId))},30,{leading:!1}));y(this,"cursorMouseLeave",A.throttle(()=>{this.cacheCursorPoint=[void 0,void 0],this.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)},30,{leading:!1}));y(this,"keydown",s=>{this.control.hotkeyManager.colloctHotkey(s)});this.control=s,this.internalMsgEmitter=e;const t={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new cs(t)}get worker(){return this.control.worker}bindToolsClass(){var i,o;const s=(o=(i=this.worker)==null?void 0:i.currentToolsData)==null?void 0:o.toolsType,e=this.control.renderControl.isWritable,t=this.worker.isAbled();switch(s){case N.Text:case N.Pencil:case N.LaserPen:case N.Arrow:case N.Straight:case N.Rectangle:case N.Ellipse:case N.Star:case N.Polygon:case N.SpeechBalloon:case N.Eraser:case N.PencilEraser:case N.BitMapEraser:this.eventTragetElement&&(this.eventTragetElement.className=e&&t?`netless-whiteboard ${s===N.Text?"cursor-text":s===N.Eraser||s===N.PencilEraser||s===N.BitMapEraser?"cursor-eraser":s===N.Pencil||s===N.LaserPen?"cursor-pencil":"cursor-arrow"}`:"netless-whiteboard");break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}updateSize(){this.setCanvassStyle()}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}get parentElement(){var s;return(s=this.eventTragetElement)==null?void 0:s.parentElement}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.destroy(),this.internalMsgEmitter.removeAllListeners([se.Cursor,this.viewId])}getPoint(s){const e=hn(s);if(e&&A.isNumber(e.x)&&A.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){return this.active}setActive(s){this.active=s}async stopEventHandler(){this.cachePoint&&(await this.worker.originalEventLintener(z.Done,this.cachePoint,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0)}getTranslate(s){const t=(s.style.WebkitTransform||getComputedStyle(s,"").getPropertyValue("-webkit-transform")||s.style.transform||getComputedStyle(s,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),i=t&&parseInt(t[0])||0,o=t&&parseInt(t[1])||0;return[i,o]}getContainerOffset(s,e){var o;const t=this.getTranslate(s);let i={x:e.x+s.offsetLeft-s.scrollLeft+t[0],y:e.y+s.offsetTop-s.scrollTop+t[1]};return(o=s.offsetParent)!=null&&o.nodeName&&s.offsetParent.nodeName!=="BODY"&&(i=this.getContainerOffset(s.offsetParent,i)),i}checkConsumeCount(){const s=this.worker.getConsumeCount();return this.cachePoint&&this.toolsKey&&this.toolsKey===N.Pencil&&this.control.pluginOptions.bezier&&s>this.control.pluginOptions.bezier.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",us.longPencil,this.viewId)}),!0):!1}bindDisplayerEvent(s){s.addEventListener("mousedown",this.mousedown,!1),s.addEventListener("touchstart",this.touchstart,!1),s.addEventListener("mousemove",this.cursorMouseMove,!1),s.addEventListener("mouseleave",this.cursorMouseLeave,!1),s.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(s){s.removeEventListener("mousedown",this.mousedown,!1),document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),s.removeEventListener("touchstart",this.touchstart,!1),document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1),s.removeEventListener("mousemove",this.cursorMouseMove,!1),s.removeEventListener("mouseleave",this.cursorMouseLeave,!1),s.removeEventListener("keydown",this.keydown,!0)}}const pM="index-module__Container__nLsM3",fM="index-module__CanvasBox__j2Xe-",gM="index-module__FloatCanvas__d1YR7",yM="index-module__TopFloatCanvas__7IaCw",mM="index-module__CanvasBoxSub__hcMeK",MM="index-module__SnapshotBox__--eeE",wM="index-module__FloatBar__cm-EL",vM="index-module__RotateBtn__HSSkf",IM="index-module__ResizeBtn__yjvda",TM="index-module__CursorBox__2UHvI",SM="index-module__TextEditorContainer__Qm8KC",NM="index-module__ResizeTowBox__HOllX",kM="index-module__FloatBarBtn__FJrOG",Pe={Container:pM,CanvasBox:fM,FloatCanvas:gM,TopFloatCanvas:yM,CanvasBoxSub:mM,SnapshotBox:MM,FloatBar:wM,RotateBtn:vM,ResizeBtn:IM,CursorBox:TM,TextEditorContainer:SM,ResizeTowBox:NM,FloatBarBtn:kM},CM={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDZ2NmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTItMlY2aDBtMS0yYTIgMiAwIDAgMSAyLTJoMmEyIDIgMCAwIDEgMiAyaDBNMyA0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",duplicate:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik0xMSAySDZhMSAxIDAgMCAwLTEgMXY4YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjRoMGwtMi0yeiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+PHBhdGggZD0iTTExIDJ2MWExIDEgMCAwIDAgMSAxaDFsLTItMnoiLz48cGF0aCBkPSJNOSAxNEg0YTEgMSAwIDAgMS0xLTFWNWgwIiBzdHJva2UtbGluZWNhcD0icm91bmQiLz48L2c+PC9zdmc+","layer-pressed":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTE2IDEwLTYgNCA2IDQgNi00em0tNiA4IDYgNCA2LTQiIHN0cm9rZT0iIzMzODFGRiIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+",layer:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTE2IDEwLTYgNCA2IDQgNi00em0tNiA4IDYgNCA2LTQiIHN0cm9rZT0iIzQ0NEU2MCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+",rotate:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjUiIGhlaWdodD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggZD0iTTEzIDZhNiA2IDAgMSAxLTMuNzA5IDEuMjgzIi8+PHBhdGggZD0ibTEzIDYgMS40MTQgMi40NUwxMyA2bDIuNDUtMS40MTQiLz48L2c+PC9zdmc+","rotation-button":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBvcGFjaXR5PSIuMDEiIGQ9Ik0wIDI0VjBoMjR2MjR6Ii8+PHBhdGggZD0iTTUuNzI0IDUuNzI0QTguODQ3IDguODQ3IDAgMCAxIDEyIDMuMTI1YzIuMjcxIDAgNC41NDMuODY2IDYuMjc2IDIuNmE4Ljg0NiA4Ljg0NiAwIDAgMSAyLjU5OCA2LjE0IDguODQ5IDguODQ5IDAgMCAxLTIuNTU5IDYuMzdsLTEuNS0uOTgzQTcuMTA1IDcuMTA1IDAgMCAwIDE5LjEyNSAxMmE3LjEwMyA3LjEwMyAwIDAgMC0yLjA4Ny01LjAzOEE3LjEwMyA3LjEwMyAwIDAgMCAxMiA0Ljg3NWE3LjEwMyA3LjEwMyAwIDAgMC01LjAzOCAyLjA4NyA3LjEwMSA3LjEwMSAwIDAgMC0yLjA4NiA0LjkyIDcuMTAzIDcuMTAzIDAgMCAwIDEuNzY2IDQuODE1bDEuOTQ1LTEuNTg0IDIuMzk0IDcuMTgyLTcuMjIyLTIuNDA4IDEuNzkxLTEuNzlBOC44NDYgOC44NDYgMCAwIDEgMy4xMjUgMTJjMC0yLjI3MS44NjYtNC41NDMgMi42LTYuMjc2eiIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9Ii41IiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L2c+PC9zdmc+",rotation:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjRkZGIiBvcGFjaXR5PSIuMDEiIGQ9Ik0wIDI0VjBoMjR2MjR6Ii8+PHBhdGggZD0iTTUuNzI0IDUuNzI0QTguODQ3IDguODQ3IDAgMCAxIDEyIDMuMTI1YzIuMjcxIDAgNC41NDMuODY2IDYuMjc2IDIuNmE4Ljg0NiA4Ljg0NiAwIDAgMSAyLjU5OCA2LjE0IDguODQ5IDguODQ5IDAgMCAxLTIuNTU5IDYuMzdsLTEuNS0uOTgzQTcuMTA1IDcuMTA1IDAgMCAwIDE5LjEyNSAxMmE3LjEwMyA3LjEwMyAwIDAgMC0yLjA4Ny01LjAzOEE3LjEwMyA3LjEwMyAwIDAgMCAxMiA0Ljg3NWE3LjEwMyA3LjEwMyAwIDAgMC01LjAzOCAyLjA4NyA3LjEwMSA3LjEwMSAwIDAgMC0yLjA4NiA0LjkyIDcuMTAzIDcuMTAzIDAgMCAwIDEuNzY2IDQuODE1bDEuOTQ1LTEuNTg0IDIuMzk0IDcuMTgyLTcuMjIyLTIuNDA4IDEuNzkxLTEuNzlBOC44NDYgOC44NDYgMCAwIDEgMy4xMjUgMTJjMC0yLjI3MS44NjYtNC41NDMgMi42LTYuMjc2eiIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9Ii41IiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L2c+PC9zdmc+","font-colors-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","font-colors":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","to-bottom":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDEwdjhtMCAwLTItMm0yIDIgMi0ybS00IDZoMTJtLTYtNGg2bS02LTRoNm0tNi00aDYiIHN0cm9rZT0iIzQ0NEU2MCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+","to-top":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDIydi04bTAgMC0yIDJtMi0yIDIgMm0tNC02aDEybS02IDRoNm0tNiA0aDZtLTYgNGg2IiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","bold-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",bold:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","underline-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",underline:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","line-through-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgOGg4bS0xLTNhMyAzIDAgMCAwLTMtM2gtLjkzOEEyLjY0IDIuNjQgMCAwIDAgNC41IDRhMi41NyAyLjU3IDAgMCAwIDEuMzQ0IDIuOTIybDQuMzEyIDIuMTU2QTIuNTcgMi41NyAwIDAgMSAxMS41IDEyYTIuNjQgMi42NCAwIDAgMS0yLjU2MiAySDdhMyAzIDAgMCAxLTMtM2gwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","line-through":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgOGg4bS0xLTNhMyAzIDAgMCAwLTMtM2gtLjkzOEEyLjY0IDIuNjQgMCAwIDAgNC41IDRhMi41NyAyLjU3IDAgMCAwIDEuMzQ0IDIuOTIybDQuMzEyIDIuMTU2QTIuNTcgMi41NyAwIDAgMSAxMS41IDEyYTIuNjQgMi42NCAwIDAgMS0yLjU2MiAySDdhMyAzIDAgMCAxLTMtM2gwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","italic-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgMTQgOSAyTTUgMTRoNE03IDJoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",italic:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgMTQgOSAyTTUgMTRoNE03IDJoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","unlock-new":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGZpbGw9IiMzMzgxRkYiIGN4PSIxNiIgY3k9IjE3IiByPSIxIi8+PHJlY3Qgc3Ryb2tlPSIjMzM4MUZGIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHg9IjExIiB5PSIxNCIgd2lkdGg9IjEwIiBoZWlnaHQ9IjgiIHJ4PSIyIi8+PHBhdGggZD0iTTEzIDE0di0xYTMgMyAwIDAgMSA2IDB2MWgwbS0zIDN2MyIgc3Ryb2tlPSIjMzM4MUZGIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L2c+PC9zdmc+","lock-new":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGZpbGw9IiM0NDRFNjAiIGN4PSIxNiIgY3k9IjE3IiByPSIxIi8+PHJlY3Qgc3Ryb2tlPSIjNDQ0RTYwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHg9IjExIiB5PSIxNCIgd2lkdGg9IjEwIiBoZWlnaHQ9IjgiIHJ4PSIyIi8+PHBhdGggZD0iTTEzIDE0di0zYTMgMyAwIDAgMSA2IDB2MWgwbS0zIDV2MyIgc3Ryb2tlPSIjNDQ0RTYwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L2c+PC9zdmc+",shapes:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTY4Mi42NjY2NjcgMTAyNEM2ODIuNjY2NjY3IDEwMjQgNjgyLjY2NjY2NyAxMDI0IDY4Mi42NjY2NjcgMTAyNEwxNzAuNjY2NjY3IDEwMjRjLTE3LjA2NjY2NyAwLTI5Ljg2NjY2Ny04LjUzMzMzMy0zOC40LTIxLjMzMzMzMy04LjUzMzMzMy0xMi44LTguNTMzMzMzLTI5Ljg2NjY2NyAwLTQyLjY2NjY2N2wyNTYtMzg0YzE3LjA2NjY2Ny0yNS42IDU1LjQ2NjY2Ny0yNS42IDcyLjUzMzMzMyAwbDI1MS43MzMzMzMgMzc5LjczMzMzM2M4LjUzMzMzMyA4LjUzMzMzMyAxMi44IDE3LjA2NjY2NyAxMi44IDI5Ljg2NjY2N0M3MjUuMzMzMzMzIDEwMDYuOTMzMzMzIDcwOC4yNjY2NjcgMTAyNCA2ODIuNjY2NjY3IDEwMjR6TTI1MS43MzMzMzMgOTM4LjY2NjY2N2wzNTQuMTMzMzMzIDBMNDI2LjY2NjY2NyA2NzQuMTMzMzMzIDI1MS43MzMzMzMgOTM4LjY2NjY2N3oiIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48cGF0aCBkPSJNOTgxLjMzMzMzMyA3MjUuMzMzMzMzbC0zNDEuMzMzMzMzIDBjLTI1LjYgMC00Mi42NjY2NjctMTcuMDY2NjY3LTQyLjY2NjY2Ny00Mi42NjY2NjdMNTk3LjMzMzMzMyAzNDEuMzMzMzMzYzAtMjUuNiAxNy4wNjY2NjctNDIuNjY2NjY3IDQyLjY2NjY2Ny00Mi42NjY2NjdsMzQxLjMzMzMzMyAwYzI1LjYgMCA0Mi42NjY2NjcgMTcuMDY2NjY3IDQyLjY2NjY2NyA0Mi42NjY2NjdsMCAzNDEuMzMzMzMzQzEwMjQgNzA4LjI2NjY2NyAxMDA2LjkzMzMzMyA3MjUuMzMzMzMzIDk4MS4zMzMzMzMgNzI1LjMzMzMzM3pNNjgyLjY2NjY2NyA2NDBsMjU2IDBMOTM4LjY2NjY2NyAzODRsLTI1NiAwTDY4Mi42NjY2NjcgNjQweiIgZmlsbD0iIzQ0NEU2MCI+PC9wYXRoPjxwYXRoIGQ9Ik0yNzcuMzMzMzMzIDU1NC42NjY2NjdDMTIzLjczMzMzMyA1NTQuNjY2NjY3IDAgNDMwLjkzMzMzMyAwIDI3Ny4zMzMzMzNTMTIzLjczMzMzMyAwIDI3Ny4zMzMzMzMgMCA1NTQuNjY2NjY3IDEyMy43MzMzMzMgNTU0LjY2NjY2NyAyNzcuMzMzMzMzIDQzMC45MzMzMzMgNTU0LjY2NjY2NyAyNzcuMzMzMzMzIDU1NC42NjY2Njd6TTI3Ny4zMzMzMzMgODUuMzMzMzMzQzE3MC42NjY2NjcgODUuMzMzMzMzIDg1LjMzMzMzMyAxNzAuNjY2NjY3IDg1LjMzMzMzMyAyNzcuMzMzMzMzUzE3MC42NjY2NjcgNDY5LjMzMzMzMyAyNzcuMzMzMzMzIDQ2OS4zMzMzMzMgNDY5LjMzMzMzMyAzODQgNDY5LjMzMzMzMyAyNzcuMzMzMzMzIDM4NCA4NS4zMzMzMzMgMjc3LjMzMzMzMyA4NS4zMzMzMzN6IiBmaWxsPSIjNDQ0RTYwIj48L3BhdGg+PC9zdmc+","shapes-active":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTY4Mi42NjY2NjcgMTAyNEM2ODIuNjY2NjY3IDEwMjQgNjgyLjY2NjY2NyAxMDI0IDY4Mi42NjY2NjcgMTAyNEwxNzAuNjY2NjY3IDEwMjRjLTE3LjA2NjY2NyAwLTI5Ljg2NjY2Ny04LjUzMzMzMy0zOC40LTIxLjMzMzMzMy04LjUzMzMzMy0xMi44LTguNTMzMzMzLTI5Ljg2NjY2NyAwLTQyLjY2NjY2N2wyNTYtMzg0YzE3LjA2NjY2Ny0yNS42IDU1LjQ2NjY2Ny0yNS42IDcyLjUzMzMzMyAwbDI1MS43MzMzMzMgMzc5LjczMzMzM2M4LjUzMzMzMyA4LjUzMzMzMyAxMi44IDE3LjA2NjY2NyAxMi44IDI5Ljg2NjY2N0M3MjUuMzMzMzMzIDEwMDYuOTMzMzMzIDcwOC4yNjY2NjcgMTAyNCA2ODIuNjY2NjY3IDEwMjR6TTI1MS43MzMzMzMgOTM4LjY2NjY2N2wzNTQuMTMzMzMzIDBMNDI2LjY2NjY2NyA2NzQuMTMzMzMzIDI1MS43MzMzMzMgOTM4LjY2NjY2N3oiIGZpbGw9IiMzMzgxRkYiPjwvcGF0aD48cGF0aCBkPSJNOTgxLjMzMzMzMyA3MjUuMzMzMzMzbC0zNDEuMzMzMzMzIDBjLTI1LjYgMC00Mi42NjY2NjctMTcuMDY2NjY3LTQyLjY2NjY2Ny00Mi42NjY2NjdMNTk3LjMzMzMzMyAzNDEuMzMzMzMzYzAtMjUuNiAxNy4wNjY2NjctNDIuNjY2NjY3IDQyLjY2NjY2Ny00Mi42NjY2NjdsMzQxLjMzMzMzMyAwYzI1LjYgMCA0Mi42NjY2NjcgMTcuMDY2NjY3IDQyLjY2NjY2NyA0Mi42NjY2NjdsMCAzNDEuMzMzMzMzQzEwMjQgNzA4LjI2NjY2NyAxMDA2LjkzMzMzMyA3MjUuMzMzMzMzIDk4MS4zMzMzMzMgNzI1LjMzMzMzM3pNNjgyLjY2NjY2NyA2NDBsMjU2IDBMOTM4LjY2NjY2NyAzODRsLTI1NiAwTDY4Mi42NjY2NjcgNjQweiIgZmlsbD0iIzMzODFGRiI+PC9wYXRoPjxwYXRoIGQ9Ik0yNzcuMzMzMzMzIDU1NC42NjY2NjdDMTIzLjczMzMzMyA1NTQuNjY2NjY3IDAgNDMwLjkzMzMzMyAwIDI3Ny4zMzMzMzNTMTIzLjczMzMzMyAwIDI3Ny4zMzMzMzMgMCA1NTQuNjY2NjY3IDEyMy43MzMzMzMgNTU0LjY2NjY2NyAyNzcuMzMzMzMzIDQzMC45MzMzMzMgNTU0LjY2NjY2NyAyNzcuMzMzMzMzIDU1NC42NjY2Njd6TTI3Ny4zMzMzMzMgODUuMzMzMzMzQzE3MC42NjY2NjcgODUuMzMzMzMzIDg1LjMzMzMzMyAxNzAuNjY2NjY3IDg1LjMzMzMzMyAyNzcuMzMzMzMzUzE3MC42NjY2NjcgNDY5LjMzMzMzMyAyNzcuMzMzMzMzIDQ2OS4zMzMzMzMgNDY5LjMzMzMzMyAzODQgNDY5LjMzMzMzMyAyNzcuMzMzMzMzIDM4NCA4NS4zMzMzMzMgMjc3LjMzMzMzMyA4NS4zMzMzMzN6IiBmaWxsPSIjMzM4MUZGIj48L3BhdGg+PC9zdmc+","font-style-active":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTM2MC4yMzQ2NjcgMjEzLjMzMzMzM0w1NTQuNjY2NjY3IDc3Ni4yNzczMzNoLTc2LjU0NGwtNTQuNjEzMzM0LTE3Mi4wMzJIMjE0LjE4NjY2N2wtNTUuNDY2NjY3IDE3Mi4wMzJIODUuMzMzMzMzTDI3OS43NjUzMzMgMjEzLjMzMzMzM2g4MC40NjkzMzR6IG00MTAuMDI2NjY2IDE3My44MjRjOTAuMTEyIDAgMTI4LjM0MTMzMyA2MC43NTczMzMgMTI4LjM0MTMzNCAxNTIuMjM0NjY3djIyOC4wMTA2NjdoLTUxLjJsLTUuNDYxMzM0LTQ0LjM3MzMzNGgtMi4wNDhjLTM1LjQ5ODY2NyAyOS4zNTQ2NjctNzcuMTQxMzMzIDUzLjI0OC0xMjIuODggNTMuMjQ4LTYyLjEyMjY2NyAwLTEwOC41NDQtMzguMjI5MzMzLTEwOC41NDQtMTA1LjEzMDY2NiAwLTgwLjU1NDY2NyA3MC4zMTQ2NjctMTIwLjgzMiAyMjguMDEwNjY3LTEzOC41ODEzMzQgMC00Ny43ODY2NjctMTUuNzAxMzMzLTkzLjUyNTMzMy03Ni40NTg2NjctOTMuNTI1MzMzLTQzLjAwOCAwLTgxLjkyIDE5Ljc5NzMzMy0xMTEuMjc0NjY2IDM5LjU5NDY2N2wtMjQuNTc2LTQzLjAwOGMzNC4xMzMzMzMtMjEuODQ1MzMzIDg2LjY5ODY2Ny00OC40NjkzMzMgMTQ2LjA5MDY2Ni00OC40NjkzMzR6IG02Ni4yMTg2NjcgMTg2LjM2OGMtMTI0LjkyOCAxNS4wMTg2NjctMTY3LjI1MzMzMyA0NS43Mzg2NjctMTY3LjI1MzMzMyA5My41MjUzMzQgMCA0Mi4zMjUzMzMgMjguNjcyIDU5LjM5MiA2NS41MzYgNTkuMzkyIDM2LjE4MTMzMyAwIDY1LjUzNi0xNy4wNjY2NjcgMTAxLjcxNzMzMy00OS4xNTJ6TTMyMC4zODQgMjcwLjkzMzMzM2gtMy4xMTQ2NjdjLTE3Ljk2MjY2NyA2Ni4wNDgtMzYuNjkzMzMzIDEyNi43Mi01Ny4wMDI2NjYgMTkwLjQ2NGwtMjguMTYgODYuMDE2aDE3My4zOTczMzNsLTI3LjMwNjY2Ny04Ni4wMTZBNDkxMy40OTMzMzMgNDkxMy40OTMzMzMgMCAwIDEgMzIwLjM4NCAyNzAuOTMzMzMzeiIgZmlsbD0iIzMzODFGRiI+PC9wYXRoPjwvc3ZnPg==","font-style":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTM2MC4yMzQ2NjcgMjEzLjMzMzMzM0w1NTQuNjY2NjY3IDc3Ni4yNzczMzNoLTc2LjU0NGwtNTQuNjEzMzM0LTE3Mi4wMzJIMjE0LjE4NjY2N2wtNTUuNDY2NjY3IDE3Mi4wMzJIODUuMzMzMzMzTDI3OS43NjUzMzMgMjEzLjMzMzMzM2g4MC40NjkzMzR6IG00MTAuMDI2NjY2IDE3My44MjRjOTAuMTEyIDAgMTI4LjM0MTMzMyA2MC43NTczMzMgMTI4LjM0MTMzNCAxNTIuMjM0NjY3djIyOC4wMTA2NjdoLTUxLjJsLTUuNDYxMzM0LTQ0LjM3MzMzNGgtMi4wNDhjLTM1LjQ5ODY2NyAyOS4zNTQ2NjctNzcuMTQxMzMzIDUzLjI0OC0xMjIuODggNTMuMjQ4LTYyLjEyMjY2NyAwLTEwOC41NDQtMzguMjI5MzMzLTEwOC41NDQtMTA1LjEzMDY2NiAwLTgwLjU1NDY2NyA3MC4zMTQ2NjctMTIwLjgzMiAyMjguMDEwNjY3LTEzOC41ODEzMzQgMC00Ny43ODY2NjctMTUuNzAxMzMzLTkzLjUyNTMzMy03Ni40NTg2NjctOTMuNTI1MzMzLTQzLjAwOCAwLTgxLjkyIDE5Ljc5NzMzMy0xMTEuMjc0NjY2IDM5LjU5NDY2N2wtMjQuNTc2LTQzLjAwOGMzNC4xMzMzMzMtMjEuODQ1MzMzIDg2LjY5ODY2Ny00OC40NjkzMzMgMTQ2LjA5MDY2Ni00OC40NjkzMzR6IG02Ni4yMTg2NjcgMTg2LjM2OGMtMTI0LjkyOCAxNS4wMTg2NjctMTY3LjI1MzMzMyA0NS43Mzg2NjctMTY3LjI1MzMzMyA5My41MjUzMzQgMCA0Mi4zMjUzMzMgMjguNjcyIDU5LjM5MiA2NS41MzYgNTkuMzkyIDM2LjE4MTMzMyAwIDY1LjUzNi0xNy4wNjY2NjcgMTAxLjcxNzMzMy00OS4xNTJ6TTMyMC4zODQgMjcwLjkzMzMzM2gtMy4xMTQ2NjdjLTE3Ljk2MjY2NyA2Ni4wNDgtMzYuNjkzMzMzIDEyNi43Mi01Ny4wMDI2NjYgMTkwLjQ2NGwtMjguMTYgODYuMDE2aDE3My4zOTczMzNsLTI3LjMwNjY2Ny04Ni4wMTZBNDkxMy40OTMzMzMgNDkxMy40OTMzMzMgMCAwIDEgMzIwLjM4NCAyNzAuOTMzMzMzeiIgZmlsbD0iIzQ0NEU2MCI+PC9wYXRoPjwvc3ZnPg==",polygon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTkzMy4xMiA0OTAuNjY2NjY3bC0xOTItMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwLTM3LjEyLTIxLjMzMzMzM2gtMzg0YTQyLjY2NjY2NyA0Mi42NjY2NjcgMCAwIDAtMzcuMTIgMjEuMzMzMzMzbC0xOTIgMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDAgNDIuNjY2NjY2bDE5MiAzMzIuMzczMzM0YTQyLjY2NjY2NyA0Mi42NjY2NjcgMCAwIDAgMzcuMTIgMjEuMzMzMzMzaDM4NGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDM3LjEyLTIxLjMzMzMzM2wxOTItMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDAtNDIuNjY2NjY2eiBtLTI1NiAzMTEuMDRIMzQ0Ljc0NjY2N0wxNzcuMDY2NjY3IDUxMmwxNjcuNjgtMjg5LjcwNjY2N2gzMzQuNTA2NjY2TDg0Ni45MzMzMzMgNTEyeiIgZmlsbD0iIzQ0NEU2MCI+PC9wYXRoPjwvc3ZnPg==","polygon-active":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTkzMy4xMiA0OTAuNjY2NjY3bC0xOTItMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwLTM3LjEyLTIxLjMzMzMzM2gtMzg0YTQyLjY2NjY2NyA0Mi42NjY2NjcgMCAwIDAtMzcuMTIgMjEuMzMzMzMzbC0xOTIgMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDAgNDIuNjY2NjY2bDE5MiAzMzIuMzczMzM0YTQyLjY2NjY2NyA0Mi42NjY2NjcgMCAwIDAgMzcuMTIgMjEuMzMzMzMzaDM4NGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDM3LjEyLTIxLjMzMzMzM2wxOTItMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDAtNDIuNjY2NjY2eiBtLTI1NiAzMTEuMDRIMzQ0Ljc0NjY2N0wxNzcuMDY2NjY3IDUxMmwxNjcuNjgtMjg5LjcwNjY2N2gzMzQuNTA2NjY2TDg0Ni45MzMzMzMgNTEyeiIgZmlsbD0iIzMzODFGRiI+PC9wYXRoPjwvc3ZnPg==","polygon-vertex":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTA3NyAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTU0My40NzQ1MjYgNDIuMzA3MzY4YTExOS4zNzY4NDIgMTE5LjM3Njg0MiAwIDAgMSAxMTAuODA3NTc5IDE2My44NGwxOTAuNTcxNzkgMTM4LjYxNzI2NGExMTkuMzc2ODQyIDExOS4zNzY4NDIgMCAxIDEgODMuMzc1MTU4IDIxOC43MDQ4NDJsLTc0LjMyMDg0MiAyMjguODM3MDUyYTExOS4zMjI5NDcgMTE5LjMyMjk0NyAwIDAgMS02MS4yNzgzMTYgMjIxLjg4NDYzMmMtNDYuNzgwNjMyIDAtODcuMzA5NDc0LTI2Ljk0NzM2OC0xMDYuODczMjYzLTY2LjEyODg0MmgtMjg5LjQxNDczN2ExMTkuMzc2ODQyIDExOS4zNzY4NDIgMCAxIDEtMTc5LjczODk0OC0xNDcuODMzMjYzbC03Mi4yNzI4NDItMjIyLjY5MzA1My0zLjM5NTM2OCAwLjEwNzc4OUExMTkuMzc2ODQyIDExOS4zNzY4NDIgMCAwIDEgMjEuODI3MzY4IDQ2Ni43Mjg0MjFMMjEuNTU3ODk1IDQ1OC4yMTMwNTNhMTE5LjM3Njg0MiAxMTkuMzc2ODQyIDAgMCAxIDE4My44MzQ5NDctMTAwLjUxMzY4NWwyMjMuNTAxNDc0LTE2Mi4zODQ4NDJhMTE5LjQzMDczNyAxMTkuNDMwNzM3IDAgMCAxIDExNC41ODAyMS0xNTMuMDYxMDUyek0yODkuNDE0NzM3IDg0MC4wNTcyNjNhNTQuNzAzMTU4IDU0LjcwMzE1OCAwIDEgMCAwIDEwOS40MDYzMTYgNTQuNzAzMTU4IDU0LjcwMzE1OCAwIDAgMCAwLTEwOS40MDYzMTZ6IG01MDMuMTYxMjYzIDBhNTQuNzAzMTU4IDU0LjcwMzE1OCAwIDEgMCAwIDEwOS40MDYzMTYgNTQuNzAzMTU4IDU0LjcwMzE1OCAwIDAgMCAwLTEwOS40MDYzMTZ6TTQ2Mi42ODYzMTYgMjQ5LjU4NjUyNkwyNDguMTMxMzY4IDQwNS41NTc4OTVhMTE5LjMyMjk0NyAxMTkuMzIyOTQ3IDAgMCAxLTQyLjg0NjMxNSAxNTMuMjIyNzM3bDcwLjcwOTg5NCAyMTcuMzU3NDczYTExOS40MzA3MzcgMTE5LjQzMDczNyAwIDAgMSAxMzIuNDE5MzY5IDEwOC4yMjA2MzJINjczLjY4NDIxMWExMTkuNDMwNzM3IDExOS40MzA3MzcgMCAwIDEgMTE5LjE2MTI2My0xMDguOTc1MTU4bDcxLjE0MTA1Mi0yMTguOTc0MzE2YTExOS40MzA3MzcgMTE5LjQzMDczNyAwIDAgMS02Mi4wODY3MzctMTY0LjIxNzI2M2wtMTg2LjM2OC0xMzUuMjc1Nzg5Yy0xOS45OTQ5NDcgMTUuMDkwNTI2LTQ1LjAwMjEwNSAyNC4xNDQ4NDItNzIuMDU3MjYzIDI0LjE0NDg0MmExMTguOTQ1Njg0IDExOC45NDU2ODQgMCAwIDEtODAuNzg4MjEtMzEuNDc0NTI3eiBtLTMyMS43NTE1NzkgMTUzLjkyMzM2OWE1NC43MDMxNTggNTQuNzAzMTU4IDAgMSAwIDAgMTA5LjQwNjMxNiA1NC43MDMxNTggNTQuNzAzMTU4IDAgMCAwIDAtMTA5LjQwNjMxNnogbTc2Ny43MzA1MjYtMTIuNTU3NDc0YTU0LjcwMzE1OCA1NC43MDMxNTggMCAxIDAgMCAxMDkuNDA2MzE2IDU0LjcwMzE1OCA1NC43MDMxNTggMCAwIDAgMC0xMDkuNDA2MzE2eiBtLTM2NS4xOTA3MzctMjg0LjAyNTI2M2E1NC43MDMxNTggNTQuNzAzMTU4IDAgMSAwIDAgMTA5LjQ2MDIxIDU0LjcwMzE1OCA1NC43MDMxNTggMCAwIDAgMC0xMDkuNDA2MzE1eiIgZmlsbD0iIzQ0NEU2MCI+PC9wYXRoPjwvc3ZnPg==",star:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTkwOC4xIDM1My4xbC0yNTMuOS0zNi45TDU0MC43IDg2LjFjLTMuMS02LjMtOC4yLTExLjQtMTQuNS0xNC41LTE1LjgtNy44LTM1LTEuMy00Mi45IDE0LjVMMzY5LjggMzE2LjJsLTI1My45IDM2LjljLTcgMS0xMy40IDQuMy0xOC4zIDkuMy0xMi4zIDEyLjctMTIuMSAzMi45IDAuNiA0NS4zbDE4My43IDE3OS4xLTQzLjQgMjUyLjljLTEuMiA2LjktMC4xIDE0LjEgMy4yIDIwLjMgOC4yIDE1LjYgMjcuNiAyMS43IDQzLjIgMTMuNEw1MTIgNzU0bDIyNy4xIDExOS40YzYuMiAzLjMgMTMuNCA0LjQgMjAuMyAzLjIgMTcuNC0zIDI5LjEtMTkuNSAyNi4xLTM2LjlsLTQzLjQtMjUyLjkgMTgzLjctMTc5LjFjNS00LjkgOC4zLTExLjMgOS4zLTE4LjMgMi43LTE3LjUtOS41LTMzLjctMjctMzYuM3pNNjY0LjggNTYxLjZsMzYuMSAyMTAuM0w1MTIgNjcyLjcgMzIzLjEgNzcybDM2LjEtMjEwLjMtMTUyLjgtMTQ5TDQxNy42IDM4MiA1MTIgMTkwLjcgNjA2LjQgMzgybDIxMS4yIDMwLjctMTUyLjggMTQ4Ljl6IiBmaWxsPSIjNDQ0RTYwIj48L3BhdGg+PC9zdmc+","star-active":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTkwOC4xIDM1My4xbC0yNTMuOS0zNi45TDU0MC43IDg2LjFjLTMuMS02LjMtOC4yLTExLjQtMTQuNS0xNC41LTE1LjgtNy44LTM1LTEuMy00Mi45IDE0LjVMMzY5LjggMzE2LjJsLTI1My45IDM2LjljLTcgMS0xMy40IDQuMy0xOC4zIDkuMy0xMi4zIDEyLjctMTIuMSAzMi45IDAuNiA0NS4zbDE4My43IDE3OS4xLTQzLjQgMjUyLjljLTEuMiA2LjktMC4xIDE0LjEgMy4yIDIwLjMgOC4yIDE1LjYgMjcuNiAyMS43IDQzLjIgMTMuNEw1MTIgNzU0bDIyNy4xIDExOS40YzYuMiAzLjMgMTMuNCA0LjQgMjAuMyAzLjIgMTcuNC0zIDI5LjEtMTkuNSAyNi4xLTM2LjlsLTQzLjQtMjUyLjkgMTgzLjctMTc5LjFjNS00LjkgOC4zLTExLjMgOS4zLTE4LjMgMi43LTE3LjUtOS41LTMzLjctMjctMzYuM3pNNjY0LjggNTYxLjZsMzYuMSAyMTAuM0w1MTIgNjcyLjcgMzIzLjEgNzcybDM2LjEtMjEwLjMtMTUyLjgtMTQ5TDQxNy42IDM4MiA1MTIgMTkwLjcgNjA2LjQgMzgybDIxMS4yIDMwLjctMTUyLjggMTQ4Ljl6IiBmaWxsPSIjMzM4MUZGIj48L3BhdGg+PC9zdmc+","star-innerVertex":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTg1LjMzMzMzMyAwYTg1LjMzMzMzMyA4NS4zMzMzMzMgMCAwIDEgODEuNDA4IDU5LjczMzMzM2g0OC4yMTMzMzR2ODUuMzMzMzM0TDE3MC42NjY2NjcgMTQ0Ljk4MTMzM1Y4NTMuMzMzMzMzaDY5My4zMzMzMzNsLTI2LjQ1MzMzMy02My40ODggNzguNzYyNjY2LTMyLjc2OCAzMi44NTMzMzQgNzguNzYyNjY3LTQyLjI0IDE3LjQ5MzMzM0g5MzguNjY2NjY3YTg1LjMzMzMzMyA4NS4zMzMzMzMgMCAwIDEgODQuNzM2IDc1LjM0OTMzNEwxMDI0IDkzOC42NjY2NjdhODUuMzMzMzMzIDg1LjMzMzMzMyAwIDAgMS0xNzAuNjY2NjY3IDBIMTcwLjY2NjY2N2E4NS4zMzMzMzMgODUuMzMzMzMzIDAgMSAxLTg1LjMzMzMzNC04NS4zMzMzMzRWMTcwLjY2NjY2N2E4NS4zMzMzMzMgODUuMzMzMzMzIDAgMSAxIDAtMTcwLjY2NjY2N3ogbTc2NS4zNTQ2NjcgNTk5LjQ2NjY2N2wzMi44NTMzMzMgNzguNzYyNjY2LTc4Ljg0OCAzMi44NTMzMzQtMzIuNzY4LTc4Ljc2MjY2NyA3OC43NjI2NjctMzIuODUzMzMzeiBtLTY1LjcwNjY2Ny0xNTcuNTI1MzM0bDMyLjg1MzMzNCA3OC43NjI2NjctNzguNzYyNjY3IDMyLjg1MzMzMy0zMi43NjgtNzguNzYyNjY2IDc4Ljc2MjY2Ny0zMi44NTMzMzR6TTcxOS4zNiAyODQuNDE2bDMyLjg1MzMzMyA3OC43NjI2NjctNzguNzYyNjY2IDMyLjg1MzMzMy0zMi44NTMzMzQtNzguNzYyNjY3IDc4Ljc2MjY2Ny0zMi44NTMzMzN6IG0tNjUuNjIxMzMzLTE1Ny41MjUzMzNsMzIuODUzMzMzIDc4Ljc2MjY2Ni03OC43NjI2NjcgMzIuODUzMzM0LTMyLjg1MzMzMy03OC43NjI2NjcgNzguNzYyNjY3LTMyLjg1MzMzM3pNMzg1LjcwNjY2NyA1OS43MzMzMzN2ODUuMzMzMzM0aC04NS4zMzMzMzR2LTg1LjMzMzMzNGg4NS4zMzMzMzR6IG0xNzAuNjY2NjY2IDB2ODUuMzMzMzM0aC04NS4zMzMzMzN2LTg1LjMzMzMzNGg4NS4zMzMzMzN6IiBmaWxsPSIjNDQ0RTYwIiA+PC9wYXRoPjwvc3ZnPg==","star-innerRatio":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTU2OS4zNDQgNDQ5LjUzNmwxNDYuOTQ0IDI4LjY3MiAxLjAyNC00LjYwOHY0LjYwOGgxLjAyNGM5LjcyOCAwIDE2Ljg5Ni03LjY4IDIwLjQ4LTE0Ljg0OGwxLjAyNC0yLjA0OHYtMi41NmMwLTUuNjMyIDAtMTEuMjY0LTUuMTItMTYuMzg0LTMuMDcyLTMuMDcyLTcuMTY4LTcuMTY4LTEyLjgtNy42OGwtMTI0LjkyOC0yNC4wNjRMNTQxLjY5NiAyODYuNzJjLTIuMDQ4LTQuNjA4LTYuNjU2LTguMTkyLTExLjc3Ni05LjcyOC01LjEyLTEuNTM2LTEwLjc1Mi0xLjUzNi0xNS4zNiAxLjAyNGwtMS41MzYgMC41MTItMS4wMjQgMS4wMjRjLTguMTkyIDguMTkyLTEwLjc1MiAxOS40NTYtNi42NTYgMjcuMTM2bDY0IDE0Mi44NDh6IiBmaWxsPSIjMzM4MUZGIj48L3BhdGg+PHBhdGggZD0iTTkzMS4zMjggNDAzLjQ1NmMtMTAuMjQtMzUuMzI4LTM4LjQtNjEuNDQtNzEuNjgtNjYuNTZsLTE4NC44MzItMzUuODQtODIuNDMyLTE4Mi43ODRjLTEyLjgtMzMuMjgtNDYuMDgtNTYuMzItODAuMzg0LTU2LjMyLTMzLjc5MiAwLTY0LjUxMiAyMC40OC03OS44NzIgNTMuNzZMMzQ5LjE4NCAyOTkuMDA4bC0xODQuMzIgMzUuMzI4Yy0zMy43OTIgNS4xMi02MS45NTIgMzEuMjMyLTcyLjE5MiA2Ni41Ni05LjcyOCAzNC4zMDQtMS4wMjQgNzIuMTkyIDIzLjA0IDk4LjgxNmwxMzEuNTg0IDEzMy42MzItMzUuODQgMTk2LjYwOGMtNS42MzIgMzQuODE2IDguNzA0IDcxLjY4IDM1Ljg0IDk0LjIwOCAxMy44MjQgMTEuMjY0IDM0LjMwNCAxOC40MzIgNTIuMjI0IDE4LjQzMiAxNi44OTYgMCAyOS42OTYtMy4wNzIgNDEuNDcyLTEwLjI0bDE2OC45Ni05MS4xMzYgMTY2LjkxMiA5MS4xMzYgMS4wMjQgMC41MTJjMTYuODk2IDYuNjU2IDI5LjY5NiA5LjcyOCA0MC40NDggOS43MjggMTQuMzM2IDAgMjcuNjQ4LTQuMDk2IDQwLjQ0OC03LjY4IDQuNjA4LTEuNTM2IDkuNzI4LTMuMDcyIDE0Ljg0OC00LjA5NmwyLjU2LTAuNTEyIDIuMDQ4LTEuNTM2YzI1LjA4OC0yMy4wNCAzNy44ODgtNTguODggMzIuNzY4LTkzLjY5NmwtMzMuMjgtMTk2LjYwOCAxMzEuNTg0LTEzNi4xOTJjMjQuMDY0LTI3LjY0OCAzMi4yNTYtNjIuOTc2IDIyLjAxNi05OC44MTZ6TTI3Ni45OTIgODM2LjA5Nmw0MS45ODQtMjMxLjkzNi0xNTcuMTg0LTE1OS4yMzJjLTUuNjMyLTUuNjMyLTguMTkyLTE3LjQwOC02LjY1Ni0yOS4xODQgMy41ODQtMTAuMjQgMTAuMjQtMTYuMzg0IDE5LjQ1Ni0xNy45MmwyMTguMTEyLTQxLjk4NCA5Ni4yNTYtMjE1LjU1MmMzLjA3Mi03LjE2OCAxMi44LTE0LjMzNiAyMC40OC0xNC4zMzZzMTcuNDA4IDcuMTY4IDIwLjQ4IDE0Ljg0OGw5OC4zMDQgMjE1LjA0IDIxOC4xMTIgNDEuOTg0YzcuMTY4IDEuNTM2IDE1LjM2IDcuMTY4IDE2Ljg5NiAxNi4zODR2My4wNzJjMi4wNDggMTEuNzc2LTAuNTEyIDIyLjUyOC02LjY1NiAzMC43Mkw2OTkuOTA0IDYwOS4yOGwzOS45MzYgMjMxLjQyNGMxLjUzNiAxMC43NTItMi4wNDggMjAuNDgtMTAuMjQgMjcuMTM2bC0xLjAyNCAwLjUxMmMtMi41NiAyLjU2LTYuNjU2IDQuMDk2LTExLjI2NCA0LjA5Ni0yLjA0OCAwLTcuMTY4LTEuNTM2LTExLjI2NC0zLjU4NGwtMTk3LjEyLTEwOC4wMzItMTk5LjE2OCAxMDIuOTEyYy00LjA5NiAyLjA0OC05LjIxNiAzLjU4NC0xMS43NzYgMy41ODQtNC42MDggMC04LjcwNC0xLjUzNi0xMS4yNjQtNC4wOTZsLTEuMDI0LTAuNTEyYy02LjY1Ni02LjE0NC0xMC43NTItMTYuMzg0LTguNzA0LTI2LjYyNHoiIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4=",speechBallon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTgzMiA4MzJINDQ4bC0xMjggMTkyLTEyOC0xOTJjLTEwNi4wNDggMC0xOTItODYuMDE2LTE5Mi0xOTJWMTkyYTE5MiAxOTIgMCAwIDEgMTkyLTE5Mmg2NDBjMTA1Ljk4NCAwIDE5MiA4NS45NTIgMTkyIDE5MnY0NDhjMCAxMDUuOTg0LTg2LjAxNiAxOTItMTkyIDE5MnogbTY0LTY0MGE2NCA2NCAwIDAgMC02NC02NEgxOTJDMTU2LjY3MiAxMjggMTI4IDE1Ni42NzIgMTI4IDE5MnY0NDhhNjQgNjQgMCAwIDAgNjQgNjRoNDIuNjg4TDMyMCA4MzJsODUuMzEyLTEyOEg4MzJjMzUuMzkyIDAgNjQtMjguNjA4IDY0LTY0VjE5MnoiIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4=","speechBallon-active":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTgzMiA4MzJINDQ4bC0xMjggMTkyLTEyOC0xOTJjLTEwNi4wNDggMC0xOTItODYuMDE2LTE5Mi0xOTJWMTkyYTE5MiAxOTIgMCAwIDEgMTkyLTE5Mmg2NDBjMTA1Ljk4NCAwIDE5MiA4NS45NTIgMTkyIDE5MnY0NDhjMCAxMDUuOTg0LTg2LjAxNiAxOTItMTkyIDE5MnogbTY0LTY0MGE2NCA2NCAwIDAgMC02NC02NEgxOTJDMTU2LjY3MiAxMjggMTI4IDE1Ni42NzIgMTI4IDE5MnY0NDhhNjQgNjQgMCAwIDAgNjQgNjRoNDIuNjg4TDMyMCA4MzJsODUuMzEyLTEyOEg4MzJjMzUuMzkyIDAgNjQtMjguNjA4IDY0LTY0VjE5MnoiIGZpbGw9IiMzMzgxRkYiPjwvcGF0aD48L3N2Zz4=","speechBallon-placement":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTU3NiAyMTMuMzMzMzMzbDIyLjYxMzMzMyAyMi42MTMzMzRhMzIgMzIgMCAwIDAgMC00NS4yMjY2NjdMNTc2IDIxMy4zMzMzMzN6IG0tNjIuNzItMTA3Ljk0NjY2NmEzMiAzMiAwIDEgMC00NS4yMjY2NjcgNDUuMjI2NjY2bDQ1LjIyNjY2Ny00NS4yMjY2NjZ6IG0tNDUuMjI2NjY3IDE3MC42NjY2NjZhMzIgMzIgMCAwIDAgNDUuMjI2NjY3IDQ1LjIyNjY2N2wtNDUuMjI2NjY3LTQ1LjIyNjY2N3pNNDQ4IDgxMC42NjY2NjdsLTIyLjYxMzMzMy0yMi42MTMzMzRhMzIgMzIgMCAwIDAgMCA0NS4yMjY2NjdsMjIuNjEzMzMzLTIyLjYxMzMzM3ogbTEwNy45NDY2NjctNjIuNzJhMzIgMzIgMCAxIDAtNDUuMjI2NjY3LTQ1LjIyNjY2N2w0NS4yMjY2NjcgNDUuMjI2NjY3eiBtLTQ1LjIyNjY2NyAxNzAuNjY2NjY2YTMyIDMyIDAgMSAwIDQ1LjIyNjY2Ny00NS4yMjY2NjZsLTQ1LjIyNjY2NyA0NS4yMjY2NjZ6TTgxMC42NjY2NjcgNTc2bC0yMi42MTMzMzQgMjIuNjEzMzMzYTMyIDMyIDAgMCAwIDQ1LjIyNjY2NyAwTDgxMC42NjY2NjcgNTc2eiBtMTA3Ljk0NjY2Ni02Mi43MmEzMiAzMiAwIDEgMC00NS4yMjY2NjYtNDUuMjI2NjY3bDQ1LjIyNjY2NiA0NS4yMjY2Njd6IG0tMTcwLjY2NjY2Ni00NS4yMjY2NjdhMzIgMzIgMCAxIDAtNDUuMjI2NjY3IDQ1LjIyNjY2N2w0NS4yMjY2NjctNDUuMjI2NjY3ek0yMTMuMzMzMzMzIDQ0OGwyMi42MTMzMzQtMjIuNjEzMzMzYTMyIDMyIDAgMCAwLTQ1LjIyNjY2NyAwbDIyLjYxMzMzMyAyMi42MTMzMzN6IG02Mi43MiAxMDcuOTQ2NjY3YTMyIDMyIDAgMCAwIDQ1LjIyNjY2Ny00NS4yMjY2NjdsLTQ1LjIyNjY2NyA0NS4yMjY2Njd6IG0tMTcwLjY2NjY2Ni00NS4yMjY2NjdhMzIgMzIgMCAxIDAgNDUuMjI2NjY2IDQ1LjIyNjY2N2wtNDUuMjI2NjY2LTQ1LjIyNjY2N3pNMzA5LjMzMzMzMyAyMTMuMzMzMzMzQTc0LjY2NjY2NyA3NC42NjY2NjcgMCAwIDEgMjM0LjY2NjY2NyAyODh2NjRBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDM3My4zMzMzMzMgMjEzLjMzMzMzM2gtNjR6TTIzNC42NjY2NjcgMjg4QTc0LjY2NjY2NyA3NC42NjY2NjcgMCAwIDEgMTYwIDIxMy4zMzMzMzNoLTY0QTEzOC42NjY2NjcgMTM4LjY2NjY2NyAwIDAgMCAyMzQuNjY2NjY3IDM1MnYtNjR6TTE2MCAyMTMuMzMzMzMzYzAtNDEuMjE2IDMzLjQ1MDY2Ny03NC42NjY2NjcgNzQuNjY2NjY3LTc0LjY2NjY2NnYtNjRBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDk2IDIxMy4zMzMzMzNoNjR6TTIzNC42NjY2NjcgMTM4LjY2NjY2N2M0MS4yMTYgMCA3NC42NjY2NjcgMzMuNDUwNjY3IDc0LjY2NjY2NiA3NC42NjY2NjZoNjRBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDIzNC42NjY2NjcgNzQuNjY2NjY3djY0ek0zNDEuMzMzMzMzIDI0NS4zMzMzMzNoMjM0LjY2NjY2N3YtNjRIMzQxLjMzMzMzM3Y2NHogbTI1Ny4yOC01NC42MTMzMzNsLTg1LjMzMzMzMy04NS4zMzMzMzMtNDUuMjI2NjY3IDQ1LjIyNjY2NiA4NS4zMzMzMzQgODUuMzMzMzM0IDQ1LjIyNjY2Ni00NS4yMjY2Njd6IG0tNDUuMjI2NjY2IDBsLTg1LjMzMzMzNCA4NS4zMzMzMzMgNDUuMjI2NjY3IDQ1LjIyNjY2NyA4NS4zMzMzMzMtODUuMzMzMzMzLTQ1LjIyNjY2Ni00NS4yMjY2Njd6TTY1MC42NjY2NjcgODEwLjY2NjY2N2ExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAgMTM4LjY2NjY2NiAxMzguNjY2NjY2di02NEE3NC42NjY2NjcgNzQuNjY2NjY3IDAgMCAxIDcxNC42NjY2NjcgODEwLjY2NjY2N2gtNjR6IG0xMzguNjY2NjY2IDEzOC42NjY2NjZBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDkyOCA4MTAuNjY2NjY3aC02NGE3NC42NjY2NjcgNzQuNjY2NjY3IDAgMCAxLTc0LjY2NjY2NyA3NC42NjY2NjZ2NjR6TTkyOCA4MTAuNjY2NjY3YTEzOC42NjY2NjcgMTM4LjY2NjY2NyAwIDAgMC0xMzguNjY2NjY3LTEzOC42NjY2Njd2NjRjNDEuMjE2IDAgNzQuNjY2NjY3IDMzLjQ1MDY2NyA3NC42NjY2NjcgNzQuNjY2NjY3aDY0eiBtLTEzOC42NjY2NjctMTM4LjY2NjY2N0ExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAgNjUwLjY2NjY2NyA4MTAuNjY2NjY3aDY0YzAtNDEuMjE2IDMzLjQ1MDY2Ny03NC42NjY2NjcgNzQuNjY2NjY2LTc0LjY2NjY2N3YtNjR6IG0tMTA2LjY2NjY2NiAxMDYuNjY2NjY3aC0yMzQuNjY2NjY3djY0SDY4Mi42NjY2Njd2LTY0eiBtLTIxMi4wNTMzMzQgNTQuNjEzMzMzbDg1LjMzMzMzNC04NS4zMzMzMzMtNDUuMjI2NjY3LTQ1LjIyNjY2Ny04NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2NiA0NS4yMjY2Njd6IG0tNDUuMjI2NjY2IDBsODUuMzMzMzMzIDg1LjMzMzMzMyA0NS4yMjY2NjctNDUuMjI2NjY2LTg1LjMzMzMzNC04NS4zMzMzMzQtNDUuMjI2NjY2IDQ1LjIyNjY2N3pNNjcyIDIzNC42NjY2NjdBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDgxMC42NjY2NjcgMzczLjMzMzMzM3YtNjRhNzQuNjY2NjY3IDc0LjY2NjY2NyAwIDAgMS03NC42NjY2NjctNzQuNjY2NjY2aC02NHpNODEwLjY2NjY2NyAzNzMuMzMzMzMzYTEzOC42NjY2NjcgMTM4LjY2NjY2NyAwIDAgMCAxMzguNjY2NjY2LTEzOC42NjY2NjZoLTY0QTc0LjY2NjY2NyA3NC42NjY2NjcgMCAwIDEgODEwLjY2NjY2NyAzMDkuMzMzMzMzdjY0eiBtMTM4LjY2NjY2Ni0xMzguNjY2NjY2QTEzOC42NjY2NjcgMTM4LjY2NjY2NyAwIDAgMCA4MTAuNjY2NjY3IDk2djY0YzQxLjIxNiAwIDc0LjY2NjY2NyAzMy40NTA2NjcgNzQuNjY2NjY2IDc0LjY2NjY2N2g2NHpNODEwLjY2NjY2NyA5NmExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAtMTM4LjY2NjY2NyAxMzguNjY2NjY3aDY0YzAtNDEuMjE2IDMzLjQ1MDY2Ny03NC42NjY2NjcgNzQuNjY2NjY3LTc0LjY2NjY2N3YtNjR6TTc3OC42NjY2NjcgMzQxLjMzMzMzM3YyMzQuNjY2NjY3aDY0VjM0MS4zMzMzMzNoLTY0eiBtNTQuNjEzMzMzIDI1Ny4yOGw4NS4zMzMzMzMtODUuMzMzMzMzLTQ1LjIyNjY2Ni00NS4yMjY2NjctODUuMzMzMzM0IDg1LjMzMzMzNCA0NS4yMjY2NjcgNDUuMjI2NjY2eiBtMC00NS4yMjY2NjZsLTg1LjMzMzMzMy04NS4zMzMzMzQtNDUuMjI2NjY3IDQ1LjIyNjY2NyA4NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2Ny00NS4yMjY2NjZ6TTEzOC42NjY2NjcgNzg5LjMzMzMzM2MwLTQxLjIxNiAzMy40NTA2NjctNzQuNjY2NjY3IDc0LjY2NjY2Ni03NC42NjY2NjZ2LTY0YTEzOC42NjY2NjcgMTM4LjY2NjY2NyAwIDAgMC0xMzguNjY2NjY2IDEzOC42NjY2NjZoNjR6TTIxMy4zMzMzMzMgNzE0LjY2NjY2N2M0MS4yMTYgMCA3NC42NjY2NjcgMzMuNDUwNjY3IDc0LjY2NjY2NyA3NC42NjY2NjZoNjRBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDIxMy4zMzMzMzMgNjUwLjY2NjY2N3Y2NHogbTc0LjY2NjY2NyA3NC42NjY2NjZBNzQuNjY2NjY3IDc0LjY2NjY2NyAwIDAgMSAyMTMuMzMzMzMzIDg2NHY2NGExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAgMTM4LjY2NjY2Ny0xMzguNjY2NjY3aC02NHpNMjEzLjMzMzMzMyA4NjRhNzQuNjY2NjY3IDc0LjY2NjY2NyAwIDAgMS03NC42NjY2NjYtNzQuNjY2NjY3aC02NEExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAgMjEzLjMzMzMzMyA5Mjh2LTY0ek0yNDUuMzMzMzMzIDY4Mi42NjY2Njd2LTIzNC42NjY2NjdoLTY0VjY4Mi42NjY2NjdoNjR6IG0tNTQuNjEzMzMzLTIxMi4wNTMzMzRsODUuMzMzMzMzIDg1LjMzMzMzNCA0NS4yMjY2NjctNDUuMjI2NjY3LTg1LjMzMzMzMy04NS4zMzMzMzMtNDUuMjI2NjY3IDQ1LjIyNjY2NnogbTAtNDUuMjI2NjY2bC04NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2NiA0NS4yMjY2NjcgODUuMzMzMzM0LTg1LjMzMzMzNC00NS4yMjY2NjctNDUuMjI2NjY2eiIgIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4="};function xe(a){return CM[a]}const bM=a=>{const{workIds:s,mananger:e}=a;return m.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onPointerUp:t=>{t.cancelable&&t.preventDefault(),t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),ie.emitMethod(se.MainEngine,V.DeleteNode,{workIds:s||[H],viewId:e.viewId})}},m.createElement("img",{alt:"icon",src:xe("delete")}))},xM=a=>{const{workIds:s,viewId:e}=a;return m.createElement("div",{className:"button normal-button",onPointerUp:t=>{t.stopPropagation(),ie.emitMethod(se.MainEngine,V.CopyNode,{workIds:s||[H],viewId:e})}},m.createElement("img",{alt:"icon",src:xe("duplicate")}))},oo=a=>{const{icon:s,onPointerUpHandler:e}=a;return m.createElement("div",{className:"button normal-button",onPointerUp:e},m.createElement("img",{src:xe(s)}))},LM=a=>{const{open:s,setOpen:e,floatBarRef:t}=a,{floatBarData:i,mananger:o}=m.useContext(Te),[n,r]=m.useState([]),c=m.useMemo(()=>{if(t!=null&&t.current&&A.isNumber(i==null?void 0:i.y)&&(o!=null&&o.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>180){const h={};return h.top="inherit",h.bottom=50,h}else if(!t.current.offsetTop&&(o==null?void 0:o.height)-t.current.offsetTop-i.y<120){const h={};return h.top="inherit",h.bottom=50,h}}},[t==null?void 0:t.current,i,o]),l=m.useMemo(()=>s?m.createElement("div",{className:"image-layer-menu",style:c},m.createElement(oo,{icon:"to-top",onPointerUpHandler:h=>{h.stopPropagation(),ie.emitMethod(se.MainEngine,V.ZIndexNode,{workIds:[H],layer:Ut.Top,viewId:o==null?void 0:o.viewId})}}),m.createElement(oo,{icon:"to-bottom",onPointerUpHandler:h=>{h.stopPropagation(),ie.emitMethod(se.MainEngine,V.ZIndexNode,{workIds:[H],layer:Ut.Bottom,viewId:o==null?void 0:o.viewId})}})):null,[s,c]),u=h=>{h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),e(!s)};return m.useEffect(()=>{A.isEqual(i==null?void 0:i.selectIds,n)||i!=null&&i.selectIds&&!A.isEqual(i==null?void 0:i.selectIds,n)&&(r(i==null?void 0:i.selectIds),e(!1))},[s,i,n,e]),m.createElement("div",{className:`button normal-button ${s&&"active"}`,onPointerUp:u},l,m.createElement("img",{alt:"icon",src:xe(s?"layer-pressed":"layer")}))},PM=()=>m.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},m.createElement("path",{d:"M1016.5248 493.8752c-9.984-9.984-26.2144-9.984-36.1984 0l-183.6032 183.6032c-29.952 29.952-78.6944 29.952-108.5952 0l-239.2064-239.2064c-14.4384-14.4384-22.3744-33.6896-22.3744-54.3232s7.936-39.8848 22.3744-54.3232l183.6032-183.6032c9.984-9.984 9.984-26.2144 0-36.1984s-26.2144-9.984-36.1984 0l-183.6032 183.6032c-24.1152 24.1152-37.376 56.2176-37.376 90.5216 0 14.592 2.4576 28.8256 7.0656 42.1888l-374.8864 374.8864c-4.8128 4.8128-7.4752 11.3152-7.4752 18.1248l0 76.8c0 14.1312 11.4688 25.6 25.6 25.6l486.4 0c6.8096 0 13.312-2.7136 18.1248-7.4752l170.0864-170.0864c13.3632 4.6592 27.5968 7.0656 42.1888 7.0656 34.2528 0 66.4064-13.2608 90.5216-37.376l183.6032-183.6032c9.984-9.984 9.984-26.2144 0-36.1984zM501.4016 870.4l-450.2016 0 0-40.6016 358.5024-358.5024c1.024 1.0752 1.9968 2.1504 3.0208 3.1744l239.2064 239.2064c1.024 1.024 2.0992 2.048 3.1744 3.0208l-153.7024 153.7024z",fill:"#000000"})),dn=a=>{const{activeColor:s,onPointerUpHandler:e}=a;return m.createElement("div",{className:`font-color-button ${s==="transparent"?"active":""}`,onPointerUp:e},m.createElement("div",{className:"circle none"}))},Is=a=>{const{color:s,activeColor:e,onPointerUpHandler:t}=a;return m.createElement("div",{className:`font-color-button ${s===e?"active":""}`,onPointerUp:t},m.createElement("div",{className:"circle",style:{backgroundColor:ke(s,1)}}))},Ts=a=>{const{opacity:s,activeColor:e,setCurOpacity:t}=a,[i,o]=m.useState({x:108,y:0});if(m.useEffect(()=>{o({x:s*100+8,y:0})},[]),!e)return null;const n=A.throttle((l,u)=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),u.x!==(i==null?void 0:i.x)&&o({x:u.x,y:0});const h=Math.min(Math.max(u.x-8,0),100)/100;s!==h&&t(h,e,z.Doing)},100,{trailing:!0}),r=l=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),t(s,e,z.Start)},c=(l,u)=>{n.cancel(),l.cancelable&&l.preventDefault(),l.stopPropagation(),u.x!==(i==null?void 0:i.x)&&o({x:u.x,y:0});const h=Math.min(Math.max(u.x-8,0),100)/100;t(h,e,z.Done)};return m.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onClick:l=>{const u=l.nativeEvent.offsetX,h=Math.min(Math.max(u-12,0),100)/100;o({x:h*100+8,y:0}),t(h,e,z.Done)}},m.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${ke(e,0)}, ${ke(e,1)})`}}),m.createElement("div",{className:"range-opacity"},m.createElement(Lt,{bounds:"parent",axis:"x",position:i,onDrag:n,onStart:r,onStop:c},m.createElement("div",{className:"circle",style:{backgroundColor:ke(e,s)},onClick:l=>{l.cancelable&&l.preventDefault(),l.stopPropagation()}}))))},DM=a=>{const{min:s,max:e,activeNumber:t,setActiveNumber:i,color:o}=a,[n,r]=m.useState({x:108,y:0});if(m.useEffect(()=>{const h=Math.ceil((t-s)/(e-s)*100)+8;r({x:h,y:0})},[]),!t)return null;const c=A.throttle((h,d)=>{h.cancelable&&h.preventDefault(),h.stopPropagation(),d.x!==(n==null?void 0:n.x)&&r({x:d.x,y:0});const p=Math.ceil(Math.max(d.x-8,0)/100*(e-s)+s);t!==p&&i(p,z.Doing)},100,{trailing:!0}),l=h=>{h.cancelable&&h.preventDefault(),h.stopPropagation(),i(t,z.Start)},u=(h,d)=>{c.cancel(),h.cancelable&&h.preventDefault(),h.stopPropagation(),d.x!==(n==null?void 0:n.x)&&r({x:d.x,y:0});const p=Math.ceil(Math.max(d.x-8,0)/100*(e-s)+s);i(p,z.Done)};return m.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onClick:h=>{const d=h.nativeEvent.offsetX,p=Math.ceil(Math.max(d-12,0)/100*(e-s)+s),f=Math.ceil((p-s)/(e-s)*100)+8;r({x:f,y:0}),i(p,z.Done)}},m.createElement("div",{className:"range-color",style:{backgroundColor:o}}),m.createElement("div",{className:"range-opacity"},m.createElement(Lt,{bounds:"parent",axis:"x",position:n,onDrag:c,onStart:l,onStop:u},m.createElement("div",{className:"circle",style:{backgroundColor:o},onClick:h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()}},m.createElement("div",{className:"range-opacity-data-icon"},t)))))},zM=a=>{const{useStroke:s,color:e,activeStrokeType:t,setStrokeType:i}=a;return m.createElement("div",{className:"stroke-type-box"},!!s&&m.createElement("div",{className:`stroke-type-box-item Stroke ${t===te.Stroke&&"active"}`,style:{backgroundColor:e},onPointerUp:()=>{i(te.Stroke)}}),m.createElement("div",{className:`stroke-type-box-item Normal ${t===te.Normal&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(te.Normal)}}),m.createElement("div",{className:`stroke-type-box-item Dotted ${t===te.Dotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(te.Dotted)}}),m.createElement("div",{className:`stroke-type-box-item LongDotted ${t===te.LongDotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(te.LongDotted)}}))},AM=a=>{const{open:s,setOpen:e,floatBarRef:t}=a,{floatBarData:i,floatBarColors:o,mananger:n,setFloatBarData:r}=m.useContext(Te),[c,l]=m.useState(),[u,h]=m.useState(1);m.useEffect(()=>{if(i!=null&&i.strokeColor){const[w,I]=vs(i.strokeColor);l(w),h(I)}},[i]);const d=m.useMemo(()=>{if(t!=null&&t.current&&A.isNumber(i==null?void 0:i.y)&&(n!=null&&n.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!t.current.offsetTop&&(n==null?void 0:n.height)-t.current.offsetTop-i.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[(t==null?void 0:t.current)&&i,n==null?void 0:n.height]),p=m.useMemo(()=>m.createElement(Ts,{key:"strokeColors",opacity:u,activeColor:c,setCurOpacity:(w,I,k)=>{k===z.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),k===z.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=n.control.disableDeviceInputs),h(w);const T=ke(I,w);i!=null&&i.strokeColor&&r({strokeColor:T}),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:[H],strokeColor:T,workState:k,viewId:n==null?void 0:n.viewId})}}),[u,c,n==null?void 0:n.control.room,n==null?void 0:n.viewId,i]),f=m.useMemo(()=>{var w,I;return c&&(i!=null&&i.thickness)?m.createElement(DM,{key:"strokeThickness",min:Math.min(i.thickness,((w=n==null?void 0:n.control.pluginOptions.strokeWidth)==null?void 0:w.min)||1),max:Math.max(i.thickness,((I=n==null?void 0:n.control.pluginOptions.strokeWidth)==null?void 0:I.max)||10),activeNumber:i.thickness,setActiveNumber:(k,T)=>{T===z.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),T===z.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=n.control.disableDeviceInputs),i!=null&&i.thickness&&r({thickness:k}),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:[H],thickness:k,workState:T,viewId:n==null?void 0:n.viewId})},color:c}):null},[c,i==null?void 0:i.thickness,n==null?void 0:n.control.room,n==null?void 0:n.viewId]),g=m.useMemo(()=>c&&(i!=null&&i.strokeType)?m.createElement(zM,{key:"strokeType",useStroke:i==null?void 0:i.useStroke,activeStrokeType:i.strokeType,setStrokeType:w=>{i.strokeType&&r({strokeType:w}),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:[H],strokeType:w,workState:z.Done,viewId:n==null?void 0:n.viewId})},color:c}):null,[c,i==null?void 0:i.strokeType,n==null?void 0:n.control.room,n==null?void 0:n.viewId,i==null?void 0:i.useStroke]),M=m.useMemo(()=>s?m.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},g,f,m.createElement("div",{className:"font-colors-line"}),o.concat().map((w,I)=>{const k=Ht(...w);return m.createElement(Is,{key:I,color:k,activeColor:c,onPointerUpHandler:T=>{T.stopPropagation(),l(k);const v=ke(k,u);i!=null&&i.strokeColor&&(i.strokeColor=v,r({strokeColor:v})),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:[H],workState:z.Done,strokeColor:v,viewId:n==null?void 0:n.viewId})}})}),p):null,[s,o,p,c,u,i,n==null?void 0:n.viewId,d]),S=m.useMemo(()=>c?m.createElement("div",{className:"color-bar-ring",style:{backgroundColor:ke(c,u)}},m.createElement("div",{className:"circle"})):null,[c,u]);return m.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),e(!s)}},S,M)},jM=a=>{const{open:s,setOpen:e,floatBarRef:t}=a,{floatBarData:i,floatBarColors:o,mananger:n,setFloatBarData:r}=m.useContext(Te),[c,l]=m.useState(),[u,h]=m.useState(1);m.useEffect(()=>{if(i!=null&&i.fillColor){const[M,S]=(i==null?void 0:i.fillColor)==="transparent"&&["transparent",1]||vs(i.fillColor);l(M),h(S)}},[i]);const d=m.useMemo(()=>{if(t!=null&&t.current&&A.isNumber(i==null?void 0:i.y)&&(n!=null&&n.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>200){const M={};return M.top="inherit",M.bottom=50,M}else if(!t.current.offsetTop&&(n==null?void 0:n.height)-t.current.offsetTop-i.y<140){const M={};return M.top="inherit",M.bottom=50,M}}},[t==null?void 0:t.current,i,n==null?void 0:n.height]),p=m.useMemo(()=>c&&c!=="transparent"?m.createElement(Ts,{key:"fillColors",opacity:u||0,activeColor:c,setCurOpacity:(M,S,w)=>{w===z.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),w===z.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=n.control.disableDeviceInputs),h(M);const I=ke(S,M);i!=null&&i.fillColor&&(i.fillColor=I,r({fillColor:I})),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:[H],fillColor:c&&ke(S,M),workState:w,viewId:n==null?void 0:n.viewId})}}):null,[c,u,n==null?void 0:n.control.room,n==null?void 0:n.viewId,i]),f=m.useMemo(()=>s?m.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:M=>{M.stopPropagation(),M.nativeEvent.stopImmediatePropagation()}},m.createElement(dn,{activeColor:c,onPointerUpHandler:M=>{M.stopPropagation(),l("transparent");const S="transparent";i!=null&&i.fillColor&&(i.fillColor=S,r({fillColor:S})),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:[H],workState:z.Done,fillColor:S,viewId:n==null?void 0:n.viewId})}}),o.map((M,S)=>{const w=Ht(...M);return m.createElement(Is,{key:S,color:w,activeColor:c,onPointerUpHandler:I=>{I.cancelable&&I.preventDefault(),I.stopPropagation(),l(w);const k=ke(w,u);i!=null&&i.fillColor&&(i.fillColor=k,r({fillColor:k})),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:[H],workState:z.Done,fillColor:k,viewId:n==null?void 0:n.viewId})}})}),p):null,[s,c,o,p,i,n==null?void 0:n.viewId,u,d]),g=m.useMemo(()=>{const M=c&&c!=="transparent"&&ke(c,u)||"transparent";return m.createElement("div",{className:"color-bar-fill"},m.createElement("div",{className:"circle",style:{backgroundColor:M}}))},[c,u]);return m.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onPointerUp:M=>{M.stopPropagation(),M.nativeEvent.stopImmediatePropagation(),e(!s)}},g,f)},EM=a=>{const{open:s,setOpen:e,textOpt:t,workIds:i,floatBarRef:o}=a,{floatBarColors:n,mananger:r,setFloatBarData:c,floatBarData:l}=m.useContext(Te),[u,h]=m.useState(),[d,p]=m.useState(1);m.useEffect(()=>{if(t!=null&&t.fontColor){const[w,I]=(t==null?void 0:t.fontColor)==="transparent"&&["transparent",0]||vs(t.fontColor);h(w),p(I)}},[t==null?void 0:t.fontColor]);const f=m.useMemo(()=>{if(o!=null&&o.current&&A.isNumber(l==null?void 0:l.y)&&(r!=null&&r.height)){if(o.current.offsetTop&&o.current.offsetTop+l.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!o.current.offsetTop&&(r==null?void 0:r.height)-o.current.offsetTop-l.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[o==null?void 0:o.current,l,r]),g=m.useMemo(()=>u&&u!=="transparent"?m.createElement(Ts,{key:"fontColors",opacity:d,activeColor:u,setCurOpacity:(w,I,k)=>{k===z.Start&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!0),k===z.Done&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=r.control.disableDeviceInputs),p(w);const T=ke(I,w);l!=null&&l.textOpt&&(l.textOpt.fontColor=T,c({textOpt:l.textOpt})),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:i||[H],fontColor:u&&T,workState:k,viewId:r==null?void 0:r.viewId})}}):null,[u,d,r==null?void 0:r.control.room,r==null?void 0:r.viewId,l==null?void 0:l.textOpt,i]),M=m.useMemo(()=>s?m.createElement("div",{className:"font-colors-menu",style:f,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},n.map((w,I)=>{const k=Ht(...w);return m.createElement(Is,{key:I,color:k,activeColor:u,onPointerUpHandler:T=>{T.stopPropagation(),h(k);const v=ke(k,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=v,c({textOpt:l.textOpt})),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:i||[H],workState:z.Done,fontColor:v,viewId:r==null?void 0:r.viewId})}})}),g):null,[s,n,g,u,d,l==null?void 0:l.textOpt,i,r==null?void 0:r.viewId,f]),S=m.useMemo(()=>{const w=u&&u!=="transparent"&&ke(u,d)||"transparent";return m.createElement("div",{className:"color-bar"},m.createElement("div",{className:"color-bar-color",style:{backgroundColor:w}}))},[u,d]);return m.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),e(!s)}},m.createElement("img",{alt:"icon",src:xe("font-colors")}),S,M)},OM=a=>{const{open:s,setOpen:e,textOpt:t,workIds:i,floatBarRef:o}=a,{floatBarColors:n,mananger:r,setFloatBarData:c,floatBarData:l}=m.useContext(Te),[u,h]=m.useState(),[d,p]=m.useState(1);m.useEffect(()=>{if(t!=null&&t.fontBgColor){const[w,I]=(t==null?void 0:t.fontBgColor)==="transparent"&&["transparent",1]||vs(t.fontBgColor);h(w),p(I)}},[t==null?void 0:t.fontBgColor]);const f=m.useMemo(()=>{if(o!=null&&o.current&&A.isNumber(l==null?void 0:l.y)&&(r!=null&&r.height)){if(o.current.offsetTop&&o.current.offsetTop+l.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!o.current.offsetTop&&(r==null?void 0:r.height)-o.current.offsetTop-l.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[o==null?void 0:o.current,l,r]),g=m.useMemo(()=>u&&u!=="transparent"?m.createElement(Ts,{key:"fontBgColor",opacity:d||0,activeColor:u,setCurOpacity:(w,I,k)=>{k===z.Start&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!0),k===z.Done&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=r.control.disableDeviceInputs),p(w);const T=ke(I,w);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=T,c({textOpt:l.textOpt})),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:i||[H],fontBgColor:u&&ke(I,w),workState:k,viewId:r==null?void 0:r.viewId})}}):null,[u,d,r==null?void 0:r.control.room,r==null?void 0:r.viewId,l==null?void 0:l.textOpt,i]),M=m.useMemo(()=>s?m.createElement("div",{className:"font-colors-menu",style:f,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},m.createElement(dn,{activeColor:u,onPointerUpHandler:w=>{w.stopPropagation();const I="transparent";h(I),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=I,c({textOpt:l.textOpt})),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:i||[H],workState:z.Done,fontBgColor:I,viewId:r==null?void 0:r.viewId})}}),n.map((w,I)=>{const k=Ht(...w);return m.createElement(Is,{key:I,color:k,activeColor:u,onPointerUpHandler:T=>{T.stopPropagation(),h(k);const v=ke(k,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=v,c({textOpt:l.textOpt})),ie.emitMethod(se.MainEngine,V.SetColorNode,{workIds:i||[H],workState:z.Done,fontBgColor:ke(k,d),viewId:r==null?void 0:r.viewId})}})}),g):null,[s,n,g,d,u,l==null?void 0:l.textOpt,i,r==null?void 0:r.viewId,f]),S=m.useMemo(()=>{const w=u&&u!=="transparent"&&ke(u,d)||"transparent";return m.createElement("div",{className:"color-bar",style:{marginTop:0}},m.createElement("div",{className:"color-bar-color",style:{backgroundColor:w}}))},[u,d]);return m.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),e(!s)}},m.createElement(PM,null),S,M)},RM=a=>{const{bold:s,setBold:e,workIds:t,viewId:i}=a,o=n=>{const r=s==="bold"?"normal":"bold";n==null||n.stopPropagation(),e(r),ie.emitMethod(se.MainEngine,V.SetFontStyle,{workIds:t,viewId:i,bold:r})};return m.createElement("div",{className:"font-style-button",onPointerUp:o},m.createElement("img",{alt:"icon",src:xe(s==="bold"?"bold-active":"bold")}))},WM=a=>{const{underline:s,setUnderline:e,workIds:t,viewId:i}=a,o=n=>{const r=!s;n==null||n.stopPropagation(),e(r),ie.emitMethod(se.MainEngine,V.SetFontStyle,{workIds:t,viewId:i,underline:r})};return m.createElement("div",{className:"font-style-button",onPointerUp:o},m.createElement("img",{alt:"icon",src:xe(s?"underline-active":"underline")}))},YM=a=>{const{lineThrough:s,setLineThrough:e,workIds:t,viewId:i}=a,o=n=>{const r=!s;n==null||n.stopPropagation(),e(r),ie.emitMethod(se.MainEngine,V.SetFontStyle,{workIds:t,viewId:i,lineThrough:r})};return m.createElement("div",{className:"font-style-button",onPointerUp:o},m.createElement("img",{alt:"icon",src:xe(s?"line-through-active":"line-through")}))},UM=a=>{const{italic:s,setItalic:e,workIds:t,viewId:i}=a,o=n=>{const r=s==="italic"?"normal":"italic";n==null||n.stopPropagation(),e(r),ie.emitMethod(se.MainEngine,V.SetFontStyle,{workIds:t,viewId:i,italic:r})};return m.createElement("div",{className:"font-style-button",onPointerUp:o},m.createElement("img",{alt:"icon",src:xe(s==="italic"?"italic-active":"italic")}))},BM=a=>{const{open:s,setOpen:e,textOpt:t,workIds:i,style:o,floatBarRef:n}=a,{mananger:r,floatBarData:c}=m.useContext(Te),[l,u]=m.useState("normal"),[h,d]=m.useState("normal"),[p,f]=m.useState(!1),[g,M]=m.useState(!1);m.useEffect(()=>{t!=null&&t.bold&&u(t.bold),A.isBoolean(t==null?void 0:t.underline)&&f(t.underline||!1),A.isBoolean(t==null?void 0:t.lineThrough)&&M(t.lineThrough||!1),t!=null&&t.italic&&d(t.italic)},[t]);const S=m.useMemo(()=>{if(o&&(n!=null&&n.current)&&A.isNumber(c==null?void 0:c.y)&&(r!=null&&r.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const I={};return I.top="inherit",I.bottom=50,I}else if(!n.current.offsetTop&&(r==null?void 0:r.height)-n.current.offsetTop-c.y<120){const I={};return I.top="inherit",I.bottom=50,I}}},[o,n==null?void 0:n.current,c,r]),w=m.useMemo(()=>s?m.createElement("div",{className:"font-style-menu",style:S,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},m.createElement(RM,{workIds:i||[H],bold:l,setBold:u,viewId:r==null?void 0:r.viewId}),m.createElement(WM,{workIds:i||[H],underline:p,setUnderline:f,viewId:r==null?void 0:r.viewId}),m.createElement(YM,{workIds:i||[H],lineThrough:g,setLineThrough:M,viewId:r==null?void 0:r.viewId}),m.createElement(UM,{workIds:i||[H],italic:h,setItalic:d,viewId:r==null?void 0:r.viewId})):null,[s,i,l,r==null?void 0:r.viewId,p,g,h,S]);return m.createElement("div",{className:`button normal-button ${s&&"active"}`,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),e(!s)}},m.createElement("img",{alt:"icon",src:xe(s?"font-style-active":"font-style")}),w)},qe=Object.freeze([12,14,18,24,36,48,64,80,144,288]),It=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],FM=a=>{const{style:s,onClickHandler:e}=a;return m.createElement("div",{className:"font-size-menu",style:s,onPointerUp:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation()}},qe.map(t=>m.createElement("div",{className:"font-size-btn",key:t,onPointerUp:()=>{e(t)}},t)))},VM=a=>{const s=m.useRef(null),{open:e,setOpen:t,textOpt:i,workIds:o,floatBarRef:n}=a,{mananger:r,floatBarData:c}=m.useContext(Te),[l,u]=m.useState(0),[h,d]=m.useState(),p=qe.length-1;m.useEffect(()=>{i!=null&&i.fontSize&&(u(i.fontSize),s.current&&(s.current.value=i.fontSize.toString()))},[i==null?void 0:i.fontSize]);const f=m.useMemo(()=>{if(n!=null&&n.current&&A.isNumber(c==null?void 0:c.y)&&(r!=null&&r.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const I={};return I.top="inherit",I.bottom=35,I}else if(!n.current.offsetTop&&(r==null?void 0:r.height)-n.current.offsetTop-c.y<120){const I={};return I.top="inherit",I.bottom=35,I}}},[n==null?void 0:n.current,c,r]);function g(I){u(I),I&&I>=qe[0]&&I<=qe[p]&&ie.emitMethod(se.MainEngine,V.SetFontStyle,{workIds:o||[H],fontSize:I,viewId:r==null?void 0:r.viewId})}const M=I=>{var k;(k=s.current)==null||k.blur(),t(!1),w(I)},S=m.useMemo(()=>e?m.createElement(FM,{onClickHandler:M,style:f}):null,[e,M,f]),w=I=>{I>qe[p]&&(I=qe[p]),I<qe[0]&&(I=qe[0]),g(I)};return m.useEffect(()=>()=>{r!=null&&r.control.room&&A.isBoolean(h)&&(r.control.room.disableDeviceInputs=h)},[r,h]),m.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},m.createElement("input",{className:"font-size-input",ref:s,onTouchEnd:()=>{s.current&&s.current.focus()},onClick:()=>{t(!e),s.current&&s.current.focus()},onKeyDown:I=>{if(I.key==="Backspace"){const k=window.getSelection(),T=k==null?void 0:k.getRangeAt(0);if(T!=null&&T.collapsed)return I.cancelable&&I.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:I=>{var k;if(s.current){const T=s.current.value,v=parseInt(T);isNaN(v)?s.current.value="0":s.current.value=v.toString(),v&&I.key==="Enter"&&(w(v),(k=s.current)==null||k.blur(),t(!1))}},onFocus:()=>{r!=null&&r.control.room&&!r.control.disableDeviceInputs&&(d(r.control.disableDeviceInputs),r.control.room.disableDeviceInputs=!0)},onBlur:()=>{r!=null&&r.control.room&&A.isBoolean(h)&&(r.control.room.disableDeviceInputs=h)}}),m.createElement("div",{className:"font-size-btns"},m.createElement("div",{className:"font-size-add",onPointerUp:()=>{w(l+qe[0])}}),m.createElement("div",{className:"font-size-cut",onPointerUp:()=>{w(l-qe[0])}})),S)},$M=a=>{const{workIds:s,mananger:e,islocked:t}=a;return m.createElement("div",{className:"button normal-button",onPointerUp:i=>{i.stopPropagation(),ie.emitMethod(se.MainEngine,V.SetLock,{workIds:s||[H],isLocked:!t,viewId:e==null?void 0:e.viewId})}},m.createElement("img",{alt:"icon",src:xe(t?"unlock-new":"lock-new")}))},Ys=a=>{const{icon:s,min:e,max:t,step:i,value:o,onInputHandler:n}=a,[r,c]=m.useState(0),l=m.useRef(null),u=h=>{h>t&&(h=t),h<e&&(h=e),c(h),n(h),l.current&&(l.current.value=h.toString())};return m.useEffect(()=>{o&&(c(o),l.current&&(l.current.value=o.toString()))},[o]),m.createElement("div",{className:"button input-button",onPointerUp:h=>{h.stopPropagation(),h.nativeEvent.stopImmediatePropagation()}},m.createElement("img",{src:xe(s)}),m.createElement("input",{className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&l.current.focus()},onKeyDown:h=>{if(h.key==="Backspace"){const d=window.getSelection(),p=d==null?void 0:d.getRangeAt(0);if(p!=null&&p.collapsed)return h.cancelable&&h.preventDefault(),document.execCommand("delete",!1),!1}},onKeyUp:()=>{if(l.current){const h=l.current.value,d=parseInt(h);isNaN(d)?l.current.value="0":l.current.value=d.toString()}},onChange:h=>{const d=h.target.value,p=parseInt(d);p&&p&&p>=e&&p<=t&&u(p)}}),m.createElement("div",{className:"input-number-btns"},m.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(r+i)}}),m.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(r-i)}})))},HM=a=>{const{icon:s,min:e,max:t,step:i,value:o,onInputHandler:n}=a;return m.createElement("div",{className:"button input-button"},m.createElement("img",{src:xe(s)}),m.createElement(QM,{min:e,max:t,step:i,value:o,onInputHandler:n}))},QM=a=>{const{value:s,min:e,max:t,onInputHandler:i}=a,[o,n]=m.useState({x:0,y:0});m.useEffect(()=>{n({x:s*100,y:0})},[]);const r=A.throttle((u,h)=>{u.cancelable&&u.preventDefault(),u.stopPropagation();let d=Math.floor(Math.max(h.x,e*100));d=Math.floor(Math.min(d,t*100)),h.x!==(o==null?void 0:o.x)&&n({x:d,y:0});const p=d/100;s!==p&&i(p)},100,{trailing:!0}),c=u=>{u.cancelable&&u.preventDefault(),u.stopPropagation()},l=(u,h)=>{r.cancel(),u.cancelable&&u.preventDefault(),u.stopPropagation();let d=Math.floor(Math.max(h.x,e*100));d=Math.floor(Math.min(d,t*100)),h.x!==(o==null?void 0:o.x)&&n({x:d,y:0});const p=d/100;s!==p&&i(p)};return m.createElement("div",{className:"range-number-container",onClick:u=>{const h=u.nativeEvent.offsetX-6;let d=Math.floor(Math.max(h,e*100));d=Math.floor(Math.min(d,t*100)),n({x:d,y:0});const p=d/100;s!==p&&i(p)}},m.createElement("div",{className:"range-number-color"}),m.createElement("div",{className:"range-number"},m.createElement(Lt,{bounds:"parent",axis:"x",position:o,onDrag:r,onStart:c,onStop:l},m.createElement("div",{className:"circle",onClick:c}))))},GM=a=>{const{icon:s,value:e,onChangeHandler:t,style:i}=a,[o,n]=m.useState(0),[r,c]=m.useState(),l=m.useRef(null),u=m.useCallback(p=>{p>=It.length&&(p=0),p<0&&(p=It.length-1),n(p),t(It[p]),c(!1),l.current&&(l.current.value=It[p])},[t]),h=m.useMemo(()=>{if(i&&i.bottom){const p={};return p.top="inherit",p.bottom=50,p}},[i]);m.useEffect(()=>{e&&(n(It.indexOf(e)),l.current&&(l.current.value=e))},[e]);const d=m.useMemo(()=>r?m.createElement(ZM,{options:It,onClickHandler:u,style:h}):null,[r,u,h]);return m.createElement("div",{className:"button input-button"},m.createElement("img",{src:xe(s)}),m.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onTouchEnd:p=>{p.stopPropagation(),l.current&&l.current.focus()},onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),l.current&&(l.current.focus(),c(!r))}}),m.createElement("div",{className:"input-number-btns"},m.createElement("div",{className:"input-number-add",onPointerUp:p=>{p.stopPropagation(),u(o+1)}}),m.createElement("div",{className:"input-number-cut",onPointerUp:p=>{p.stopPropagation(),u(o-1)}})),d)},ZM=a=>{const{options:s,style:e,onClickHandler:t}=a;return m.createElement("div",{className:"select-option-menu",style:e,onPointerUp:i=>{i.stopPropagation(),i.nativeEvent.stopImmediatePropagation()}},s.map((i,o)=>m.createElement("div",{className:"select-option-btn",key:i,onPointerUp:n=>{n.stopPropagation(),t(o)}},i)))},qM=a=>{const{mananger:s,innerRatio:e,innerVerticeStep:t,vertices:i}=a,o=c=>{ie.emitMethod(se.MainEngine,V.SetShapeOpt,{workIds:[H],toolsType:N.Star,viewId:s.viewId,vertices:c})},n=c=>{ie.emitMethod(se.MainEngine,V.SetShapeOpt,{workIds:[H],toolsType:N.Star,viewId:s.viewId,innerVerticeStep:c})},r=c=>{ie.emitMethod(se.MainEngine,V.SetShapeOpt,{workIds:[H],toolsType:N.Star,viewId:s.viewId,innerRatio:c})};return m.createElement(m.Fragment,null,m.createElement(Ys,{value:i,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:o}),m.createElement(Ys,{value:t,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:n}),m.createElement(HM,{value:e,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:r}))},XM=a=>{const{mananger:s,vertices:e}=a,t=i=>{ie.emitMethod(se.MainEngine,V.SetShapeOpt,{workIds:[H],toolsType:N.Polygon,viewId:s.viewId,vertices:i})};return m.createElement(Ys,{value:e,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:t})},JM=a=>{const{mananger:s,placement:e}=a,t=i=>{ie.emitMethod(se.MainEngine,V.SetShapeOpt,{workIds:[H],toolsType:N.SpeechBalloon,viewId:s.viewId,placement:i})};return m.createElement(GM,{value:e,icon:"speechBallon-placement",onChangeHandler:t})},Ls=a=>{const{icon:s,isActive:e,onPointerUpHandler:t}=a;return m.createElement("div",{className:`button tab-button ${e?"active":""}`,onPointerUp:t},m.createElement("img",{src:xe(s)}))},KM=a=>{const{toolsTypes:s,style:e,mananger:t,shapeOpt:i}=a,[o,n]=m.useState();m.useEffect(()=>{s.includes(N.Polygon)?n(N.Polygon):s.includes(N.Star)?n(N.Star):n(N.SpeechBalloon)},[s]);const r=(h,d)=>{d==null||d.stopPropagation(),n(h)},c=m.useMemo(()=>o===N.Polygon&&t&&i.vertices?m.createElement(XM,{vertices:i.vertices,mananger:t}):null,[t,o,i]),l=m.useMemo(()=>o===N.Star&&t&&i.vertices&&i.innerVerticeStep&&i.innerRatio?m.createElement(qM,{mananger:t,vertices:i.vertices,innerVerticeStep:i.innerVerticeStep,innerRatio:i.innerRatio}):null,[t,o,i]),u=m.useMemo(()=>o===N.SpeechBalloon&&t&&i.placement?m.createElement(JM,{mananger:t,placement:i.placement}):null,[t,o,i]);return m.createElement("div",{className:"shapeOpt-sub-menu",style:e,onClick:h=>{h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),h.cancelable&&h.preventDefault()}},m.createElement("div",{className:"shapeOpt-sub-menu-tabs"},s.includes(N.Polygon)&&m.createElement(Ls,{isActive:o===N.Polygon,icon:o===N.Polygon?"polygon-active":"polygon",onPointerUpHandler:r.bind(void 0,N.Polygon)})||null,s.includes(N.Star)&&m.createElement(Ls,{isActive:o===N.Star,icon:o===N.Star?"star-active":"star",onPointerUpHandler:r.bind(void 0,N.Star)})||null,s.includes(N.SpeechBalloon)&&m.createElement(Ls,{isActive:o===N.SpeechBalloon,icon:o===N.SpeechBalloon?"speechBallon-active":"speechBallon",onPointerUpHandler:r.bind(void 0,N.SpeechBalloon)})||null),m.createElement("div",{className:"shapeOpt-sub-menu-content"},c,l,u))},_M=a=>{const{open:s,setOpen:e,floatBarRef:t,toolsTypes:i,shapeOpt:o}=a,{floatBarData:n,mananger:r}=m.useContext(Te),[c,l]=m.useState([]),[u,h]=m.useState(),d=m.useMemo(()=>{if(t!=null&&t.current&&A.isNumber(n==null?void 0:n.x)&&A.isNumber(n==null?void 0:n.y)&&(r!=null&&r.height)){if(t.current.offsetTop&&t.current.offsetTop+n.y>200){const g={};return g.top="inherit",g.bottom=50,g}else if(!t.current.offsetTop&&(r==null?void 0:r.height)-t.current.offsetTop-(n==null?void 0:n.y)<140){const g={};return g.top="inherit",g.bottom=50,g}}},[t,n==null?void 0:n.x,n==null?void 0:n.y,r==null?void 0:r.height]),p=m.useMemo(()=>s&&i&&r&&o?(r.control.room&&!r.control.room.disableDeviceInputs&&(h(r.control.room.disableDeviceInputs),r.control.room.disableDeviceInputs=!0),m.createElement(KM,{shapeOpt:o,style:d,toolsTypes:i,mananger:r})):(r!=null&&r.control.room&&A.isBoolean(u)&&(r.control.room.disableDeviceInputs=u),null),[s,d,i,r,o]),f=g=>{g.stopPropagation(),g.nativeEvent.stopImmediatePropagation(),e(!s)};return m.useEffect(()=>{A.isEqual(n==null?void 0:n.selectIds,c)||n!=null&&n.selectIds&&!A.isEqual(n==null?void 0:n.selectIds,c)&&(l(n==null?void 0:n.selectIds),e(!1))},[s,n,c,e]),m.useEffect(()=>()=>{s&&r!=null&&r.control.room&&A.isBoolean(u)&&(r.control.room.disableDeviceInputs=u)},[s,r,u]),m.createElement("div",{className:`button normal-button ${s&&"active"}`,onPointerUp:f},p,m.createElement("img",{alt:"icon",src:xe(s?"shapes-active":"shapes")}))},pn=m.memo(a=>{const{textOpt:s,workIds:e,noLayer:t,position:i,noDelete:o,noCopy:n}=a,{floatBarData:r,mananger:c}=m.useContext(Te),[l,u]=m.useState(0),[h,d]=m.useState(),p=m.useRef(null);m.useEffect(()=>{var R,E,j,D;const C={},L=(r==null?void 0:r.w)||((R=s==null?void 0:s.boxSize)==null?void 0:R[0])||0,O=(r==null?void 0:r.h)||((E=s==null?void 0:s.boxSize)==null?void 0:E[1])||0;if(i&&L&&O&&(c!=null&&c.width)&&(c!=null&&c.height)){if(i.y<60?i.y+O<c.height-60?C.bottom=-120:i.y+O<c.height?C.bottom=-58:i.y>0?C.top=62:C.top=-i.y+62:C.top=0,i.x<0)C.left=-i.x+3;else if(i.x+(((j=p.current)==null?void 0:j.offsetWidth)||L)>c.width){const q=c.width-(((D=p.current)==null?void 0:D.offsetWidth)||L)-i.x;C.left=q}d(C);return}d(void 0)},[p,i,r==null?void 0:r.w,r==null?void 0:r.h,c==null?void 0:c.width,c==null?void 0:c.height,s==null?void 0:s.boxSize]);const f=m.useMemo(()=>r!=null&&r.fillColor?m.createElement(jM,{floatBarRef:p,open:l===3,setOpen:C=>{u(C===!0?3:0)}}):null,[r==null?void 0:r.fillColor,l,p]),g=m.useMemo(()=>r!=null&&r.strokeColor?m.createElement(AM,{floatBarRef:p,open:l===2,setOpen:C=>{u(C===!0?2:0)}}):null,[r==null?void 0:r.strokeColor,l,p]),M=m.useMemo(()=>s!=null&&s.fontColor&&(c!=null&&c.viewId)?m.createElement(EM,{floatBarRef:p,open:l===4,setOpen:C=>{u(C===!0?4:0)},textOpt:s,workIds:e}):null,[s,l,e,c,p]),S=m.useMemo(()=>s!=null&&s.fontBgColor&&(c!=null&&c.viewId)?m.createElement(OM,{floatBarRef:p,open:l===5,setOpen:C=>{u(C===!0?5:0)},textOpt:s,workIds:e}):null,[s,l,e,c,p]),w=m.useMemo(()=>s&&(c!=null&&c.viewId)?m.createElement(BM,{floatBarRef:p,open:l===6,setOpen:C=>{u(C===!0?6:0)},textOpt:s,workIds:e,style:h}):null,[s,l,e,c,h,p]),I=m.useMemo(()=>s&&(c!=null&&c.viewId)?m.createElement(VM,{open:l===7,setOpen:C=>{u(C===!0?7:0)},textOpt:s,workIds:e,floatBarRef:p}):null,[s,l,e,c,p]),k=m.useMemo(()=>t?null:m.createElement(LM,{open:l===1,setOpen:C=>{u(C===!0?1:0)},floatBarRef:p}),[t,l,p]),T=m.useMemo(()=>r!=null&&r.canLock&&c?m.createElement($M,{workIds:e,mananger:c,islocked:r.isLocked}):null,[r,c,e]),v=m.useMemo(()=>c&&(c!=null&&c.viewId)&&h&&(r!=null&&r.shapeOpt)&&(r!=null&&r.toolsTypes)?m.createElement(_M,{open:l===8,setOpen:C=>{u(C===!0?8:0)},floatBarRef:p,workIds:e,toolsTypes:r.toolsTypes,shapeOpt:r.shapeOpt}):null,[r,c,l,h,e,p]),P=m.useCallback(C=>{C.stopPropagation(),C.stopImmediatePropagation(),c==null||c.control.worker.blurCursor(c.viewId)},[c]);return m.useEffect(()=>{const C=p.current;return C&&(C.addEventListener("touchstart",P,!1),C.addEventListener("pointerover",P,!1),C.addEventListener("mousemove",P,!1)),()=>{C&&(C.removeEventListener("touchstart",P,!1),C.removeEventListener("pointerover",P,!1),C.removeEventListener("mousemove",P,!1))}},[P]),m.createElement("div",{className:"appliance-plugin-floatbtns",style:h,ref:p},c&&!o&&m.createElement(bM,{workIds:e,mananger:c}),k,T,!!(c!=null&&c.viewId)&&!n&&m.createElement(xM,{workIds:e,viewId:c.viewId}),v,w,I,M,S,g,f)}),ew=a=>{const{data:s,isActive:e,manager:t,workId:i}=a,{opt:o,scale:n,translate:r,x:c,y:l}=s,u=`scale(${n||1}) ${r&&"translate("+r[0]+"px,"+r[1]+"px)"||""}`,{fontSize:h,fontFamily:d,underline:p,fontColor:f,lineThrough:g,textAlign:M,strokeColor:S,lineHeight:w,bold:I,italic:k,uid:T,workState:v}=o,P=h,C=w||P*1.2,L={fontSize:`${P}px`,lineHeight:`${C}px`,color:f,borderColor:S,minHeight:`${C}px`,paddingRight:`${k==="italic"?Math.round(P*.3):5}px`};d&&(L.fontFamily=`${d}`),(g||p)&&(L.textDecoration=`${g&&"line-through"||""}${p&&" underline"||""}`),I&&(L.fontWeight=`${I}`),k&&(L.fontStyle=`${k}`),M&&(L.textAlign=`${M}`);function O(){var E;e&&(T&&T===((E=t.control.collector)==null?void 0:E.uid)||!T)&&t.control.textEditorManager.active(i)}const R=m.useMemo(()=>{const E=[];if(o.text){const j=lt(o.text);for(let D=0;D<j.length;D++){const q=j[D];q===""?E.push(m.createElement("div",{style:{backgroundColor:o.fontBgColor},key:D},m.createElement("br",null))):E.push(m.createElement("div",{style:{backgroundColor:o.fontBgColor},key:D},q))}}return E.length?E:null},[o.fontBgColor,o.text]);return m.createElement("div",{className:"editor-box",style:{left:`${c}px`,top:`${l}px`,transform:u,transformOrigin:"left top",pointerEvents:"none",opacity:v===z.Done?0:1}},m.createElement("div",{className:`editor ${e?"":"readOnly"}`,style:L,onClick:O},R))},tw=m.memo(a=>{const{data:s,left:e,top:t,workId:i,updateOptInfo:o}=a,{opt:n,scale:r,translate:c}=s,l=m.useRef(null);m.useEffect(()=>{var L,O;if((L=l.current)!=null&&L.offsetWidth&&((O=l.current)!=null&&O.offsetHeight)){const R=n.boxSize;if((R==null?void 0:R[0])!==l.current.offsetWidth||R[1]!==l.current.offsetHeight||!R){const E=[l.current.offsetWidth,l.current.offsetHeight];o({activeTextId:i,update:{boxSize:E,workState:z.Done}})}}},[n.fontSize,n.italic,n.bold,n.boxSize,i]);const u=`scale(${r||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`,{fontSize:h,fontFamily:d,underline:p,fontColor:f,lineThrough:g,textAlign:M,strokeColor:S,lineHeight:w,bold:I,italic:k}=n,T=h,v=w||T*1.2,P={fontSize:`${T}px`,lineHeight:`${v}px`,color:f,borderColor:S,minHeight:`${v}px`,pointerEvents:"none",paddingRight:`${k==="italic"?Math.round(T*.3):5}px`};d&&(P.fontFamily=`${d}`),(g||p)&&(P.textDecoration=`${g&&"line-through"||""}${p&&" underline"||""}`),M&&(P.textAlign=`${M}`),I&&(P.fontWeight=`${I}`),k&&(P.fontStyle=`${k}`);const C=m.useMemo(()=>{const L=[];if(n.text){const O=lt(n.text);for(let R=0;R<O.length;R++){const E=O[R];E===""?L.push(m.createElement("div",{key:R},m.createElement("br",null))):L.push(m.createElement("div",{key:R},E))}}return L.length?L:null},[n.text]);return m.createElement("div",{className:"editor-box",style:{left:`${e}`,top:`${t}`,transform:u,transformOrigin:"left top",zIndex:1,pointerEvents:"none",opacity:0}},m.createElement("div",{className:"editor readOnly",ref:l,style:P},C))},(a,s)=>!(a.workId!==s.workId||a.left!==s.left||a.top!==s.top||!A.isEqual(a.data,s.data))),sw=a=>{const{data:s,workId:e,isSelect:t,showFloatBtns:i,handleKeyUp:o,handleFocus:n,updateOptInfo:r,manager:c,runAnimation:l}=a,[u,h]=m.useState(!1),{opt:d,scale:p,translate:f,x:g,y:M}=s,{fontSize:S,fontFamily:w,underline:I,fontColor:k,lineThrough:T,textAlign:v,strokeColor:P,lineHeight:C,bold:L,italic:O,boxSize:R}=d,E=m.useRef(null),j=m.useMemo(()=>{const U=S,ae=C||U*1.2,ee={fontSize:`${U}px`,lineHeight:`${ae}px`,color:k,borderColor:P,minHeight:`${ae}px`,paddingRight:`${O==="italic"?Math.round(U*.3):5}px`,borderWidth:`${Math.max(Math.round(1/(p||1)),1)}px`};return w&&(ee.fontFamily=`${w}`),(T||I)&&(ee.textDecoration=`${T&&"line-through"||""} ${I&&" underline"||""}`),v&&(ee.textAlign=`${v}`),L&&(ee.fontWeight=`${L}`),O&&(ee.fontStyle=`${O}`),ee},[L,k,w,S,O,C,T,p,P,v,I]),D=m.useMemo(()=>{const U=`scale(${p||1}) ${f&&"translate("+f[0]+"px,"+f[1]+"px)"||""}`;return{left:`${g}px`,top:`${M}px`,zIndex:2,pointerEvents:"none",transform:U,transformOrigin:"left top"}},[p,f,g,M]),q=m.useMemo(()=>{var U,ae;return!t&&p&&i&&A.isNumber(g)&&A.isNumber(M)&&d.boxSize&&A.isNumber((U=d.boxSize)==null?void 0:U[0])&&A.isNumber((ae=d.boxSize)==null?void 0:ae[1])?m.createElement("div",{className:Pe.FloatBarBtn,style:{left:g,top:M,width:d.boxSize[0]*p,height:d.boxSize[1]*p}},m.createElement(pn,{position:{x:g,y:M},textOpt:d,workIds:[e],noLayer:!0,noCopy:!0,noDelete:!0})):null},[t,d,i,e,g,M,p]),oe=m.useMemo(()=>{let U="";if(d.text){const ae=lt(d.text);for(let ee=0;ee<ae.length;ee++){const de=ae[ee];de===""?U=U+"<div><br/></div>":U=U+`<div style="background-color:${d.fontBgColor}">${de}</div>`}}else U=`<div style="background-color:${d.fontBgColor}"></div>`;return U},[d.fontBgColor,d.text]),X=m.useMemo(()=>typeof oe=="string"?m.createElement("div",{id:e,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor use-hover",ref:E,style:j,onKeyDown:_,onPointerDown:()=>{console.log("pointerdown===>"),Z()},onClick:()=>{console.log("onClick===>"),Z()},onFocus:U=>{n(U),c.control.room&&!c.control.room.disableDeviceInputs&&(c.control.room.disableDeviceInputs=!0)},onPaste:K,onInput:he,onCompositionStart:Se,onCompositionUpdate:ve,onCompositionEnd:Ae,dangerouslySetInnerHTML:{__html:oe}}):null,[oe,j,e]);m.useEffect(()=>()=>{c.control.room&&c.control.room.disableDeviceInputs!==c.control.disableDeviceInputs&&(c.control.room.disableDeviceInputs=c.control.disableDeviceInputs)},[c.control.disableDeviceInputs,c.control.room]),m.useEffect(()=>{if(X){const U=E.current;U&&requestAnimationFrame(()=>{U.click()})}},[X]),m.useEffect(()=>{var U,ae,ee,de;if(X&&((U=E.current)!=null&&U.offsetWidth||(ae=E.current)!=null&&ae.offsetHeight||(ee=E.current)!=null&&ee.offsetLeft||(de=E.current)!=null&&de.offsetTop)){const ue=[E.current.offsetWidth,E.current.offsetHeight];(R&&R[0]!==ue[0]&&R[1]!==ue[1]||!R)&&r({activeTextId:e,update:{boxSize:ue,workState:z.Doing}})}},[R,X,j,e]);function Z(){var U,ae;if(E.current){const ee=window==null?void 0:window.getSelection(),de=(U=E.current)==null?void 0:U.lastChild;if(ee&&de){const ue=document.createRange(),ge=((ae=de.textContent)==null?void 0:ae.length)||0;(de==null?void 0:de.nodeName)==="#text"?ue.setStart(de,ge):ue.setStart(de,ge&&1||0),ue.collapse(!0),ee.removeAllRanges(),ee.addRange(ue)}E.current.focus()}}function _(U){if(U.key==="Backspace"){const ae=window.getSelection(),ee=ae==null?void 0:ae.getRangeAt(0);if(ee!=null&&ee.collapsed)return U.cancelable&&U.preventDefault(),document.execCommand("delete",!1),!1}return l(),!1}function Q(U,ae){const ee=window==null?void 0:window.getSelection();if(ee!=null&&ee.rangeCount&&U&&ee&&ee.anchorNode){const de=ee.anchorOffset,ue=ee.anchorNode.textContent||"",ge=ue.slice(0,de)||"",ot=ue.slice(de)||"",nt=ge.concat(U)||"";J(nt,ot,ae)}}function J(U,ae,ee){const de=window==null?void 0:window.getSelection();if(!(de!=null&&de.rangeCount)||!de.anchorNode)return;const ue=U.split(/\n/);let ge=de.anchorNode.parentNode;ge===ee&&(ge=de.anchorNode);const ot=[...ee.childNodes],nt=[];let _e,Ss=de.anchorOffset;for(;ot.length;){const ze=ot.pop();if(ze){if(ze===ge){let Ve=ue[0];ue.length===1&&(Ss=ue[0].length,Ve=ue[0].concat(ae)),ge.nodeName==="#text"?(ge.textContent=Ve,_e=ge):ge.nodeName==="DIV"&&(ge.innerText=Ve,_e=ge.childNodes[0]);break}nt.push(ze),ee.removeChild(ze)}}if(ue.length>1)for(let ze=1;ze<ue.length;ze++){let Ve=ue[ze];const Ot=document.createElement("div");d.fontBgColor&&(Ot.style.backgroundColor=d.fontBgColor),ze===ue.length-1&&(Ss=Ve.length,Ve=Ve.concat(ae)),Ve===""?Ot.innerHTML="<br/>":Ot.innerText=Ve,ee.appendChild(Ot),ze===ue.length-1&&(_e=Ot.childNodes[0])}if(nt.length){nt.reverse();for(const ze of nt)ee.appendChild(ze)}if(_e&&_e.nodeName==="#text"){de.deleteFromDocument();const ze=document.createRange(),Ve=Math.min(Ss,(_e==null?void 0:_e.length)||0);ze.setStart(_e,Ve),ze.collapse(!0),de.removeAllRanges(),de.addRange(ze)}}function K(U){if(U.cancelable&&U.preventDefault(),U.stopPropagation(),E.current){const ae=(U.clipboardData||window.clipboardData).getData("text"),ee=window==null?void 0:window.getSelection();if(!(ee!=null&&ee.rangeCount))return;ae&&ee&&ee.anchorNode&&Q(ae,E.current),l()}}function he(U){U.persist(),setTimeout(()=>{u||(console.log("handleInput",u,U.nativeEvent.isComposing),o(U))},0)}function Se(U){h(!0),console.log("handleCompositionStart",!1,U.nativeEvent.isComposing),l()}function Ae(U){h(!1),console.log("handleCompositionEnd",!1,U.nativeEvent.isComposing),o(U)}function ve(U){console.log("handleCompositionUpdate",U.nativeEvent.isComposing)}return m.createElement(m.Fragment,null,q,m.createElement("div",{className:"editor-box",style:D},X))};class fn extends m.Component{constructor(s){super(s)}getInnerText(s){const e=[];for(let t=0;t<s.childNodes.length;t++){const i=s.childNodes[t];if(i.nodeName==="#text"&&t===0){const o=i.textContent.split(/\n/),n=o.pop();e.push(...o),n&&e.push(n)}else if(i.nodeName==="DIV"){const o=i.innerText.split(/\n/);if(o.length===2&&o[0]===""&&o[1]==="")e.push("");else{const n=o.shift();n&&e.push(n);const r=o.pop();e.push(...o),r&&e.push(r)}}}return e}updateOptInfo(s){var n,r;const{activeTextId:e,update:t,syncData:i}=s,o=e&&A.cloneDeep(((n=this.props.manager.control.textEditorManager)==null?void 0:n.get(e))||((r=this.props.editors)==null?void 0:r.get(e)));o&&o.opt&&(o.opt={...o.opt,...t},i&&(o.canSync=Object.keys(i).includes("canSync")&&i.canSync||o.canSync,o.canWorker=Object.keys(i).includes("canWorker")&&i.canWorker||o.canWorker),this.props.manager.control.textEditorManager.updateForViewEdited(e,o))}get editorUI(){var s;if((s=this.props.editors)!=null&&s.size){const e=[];return this.props.editors.forEach((t,i)=>{if(this.props.selectIds.includes(i)&&!(this.props.activeTextId==i)&&this.props.box){const{x:n,y:r}=this.props.box,{x:c,y:l}=t,u=`${c-n}px`,h=`${l-r}px`,d=m.createElement(tw,{left:u,top:h,key:i,data:t,workId:i,isSelect:!0,updateOptInfo:this.updateOptInfo.bind(this),manager:this.props.manager});e.push(d)}}),e}return null}render(){return m.createElement(m.Fragment,null,this.editorUI)}}class iw extends fn{constructor(e){super(e);y(this,"ref");y(this,"isRunAnimation");this.ref=m.createRef(),this.isRunAnimation=void 0}runAnimation(){this.isRunAnimation||(this.isRunAnimation=requestAnimationFrame(()=>{var e,t;(e=this.ref)!=null&&e.current&&((t=this.ref)==null||t.current.scrollTo({left:0,behavior:"instant"})),this.isRunAnimation=void 0}))}handleKeyUp(e){var o,n;const t=this.getInnerText(e.nativeEvent.target),i=this.props.activeTextId;if(i){const r=this.props.manager.control.textEditorManager.get(i),c=We(t),l=z.Doing,u=[e.nativeEvent.target.offsetWidth,e.nativeEvent.target.offsetHeight];if(!r||r&&(r.opt.text!==c||!A.isEqual(r.opt.boxSize,u)||!A.isEqual(r.opt.workState,l))){const h=i&&A.cloneDeep(((o=this.props.manager.control.textEditorManager)==null?void 0:o.get(i))||((n=this.props.editors)==null?void 0:n.get(i)));h&&h.opt&&(h.opt={...h.opt,text:c,boxSize:u,workState:l},h.canSync=!0,h.canWorker=!0,this.props.manager.control.textEditorManager.updateForViewEdited(i,h)),this.props.manager.control.textEditorManager.publicMsgEmitter.emit("textChange",i,e.nativeEvent.target,t,h)}}}handleFocus(e){const t=this.props.activeTextId;if(t){const i=this.props.manager.control.textEditorManager.get(t),o=z.Doing,n=[e.nativeEvent.target.offsetWidth,e.nativeEvent.target.offsetHeight];(!i||i&&(!A.isEqual(i.opt.boxSize,n)||!A.isEqual(i.opt.workState,o)))&&this.updateOptInfo({activeTextId:t,update:{boxSize:n,workState:o},syncData:{canSync:!0,canWorker:!0}})}}get editorUI(){var e;if((e=this.props.editors)!=null&&e.size){const t=[];return this.props.editors.forEach((i,o)=>{if(!(this.props.selectIds.includes(o)&&this.props.activeTextId!==o)){const c=this.props.activeTextId==o?m.createElement(sw,{key:o,data:i,workId:o,showFloatBtns:this.props.showFloatBtns||!1,handleFocus:this.handleFocus.bind(this),handleKeyUp:this.handleKeyUp.bind(this),updateOptInfo:this.updateOptInfo.bind(this),manager:this.props.manager,runAnimation:this.runAnimation.bind(this)}):m.createElement(ew,{manager:this.props.manager,isActive:i.opt.workState===z.Doing||i.opt.workState===z.Start||!1,key:o,data:i,workId:o});t.push(c)}}),t}return null}render(){return m.createElement("div",{className:`${this.props.className}`,ref:this.ref},this.editorUI)}}const ow=()=>{const{floatBarData:a}=m.useContext(Te);return m.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},m.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),m.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),m.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),m.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),m.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),m.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),m.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),m.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}))},nw=()=>{const{floatBarData:a,mananger:s}=m.useContext(Te),[e,t]=m.useState(),[i,o]=m.useState();m.useEffect(()=>{const c=[];if(s&&A.isNumber(a==null?void 0:a.x)&&A.isNumber(a==null?void 0:a.y)&&(a!=null&&a.points)){const l=s.viewId;if(s.control.viewContainerManager.getView(l))for(const h of a.points){const d=s.control.viewContainerManager.transformToOriginPoint(h,l);c.push(d)}c[0]&&t({x:c[0][0]-((a==null?void 0:a.x)||0),y:c[0][1]-((a==null?void 0:a.y)||0)}),c[1]&&o({x:c[1][0]-((a==null?void 0:a.x)||0),y:c[1][1]-((a==null?void 0:a.y)||0)})}},[s,a==null?void 0:a.points,a==null?void 0:a.x,a==null?void 0:a.y]);const n=m.useMemo(()=>e?m.createElement("div",{className:"point point-dot",style:{borderColor:a==null?void 0:a.selectorColor,left:e.x,top:e.y}}):null,[a==null?void 0:a.selectorColor,e]),r=m.useMemo(()=>i?m.createElement("div",{className:"point point-dot",style:{borderColor:a==null?void 0:a.selectorColor,left:i.x,top:i.y}}):null,[i,a==null?void 0:a.selectorColor]);return m.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},n,r)},rw=()=>{const{floatBarData:a}=m.useContext(Te);return m.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},m.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),m.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),m.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),m.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}))},aw=()=>{const{floatBarData:a}=m.useContext(Te);return m.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},m.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},cw=a=>{const{className:s}=a,{floatBarData:e,angle:t,setAngle:i,setOperationType:o,mananger:n}=m.useContext(Te),[r,c]=m.useState(),[l,u]=m.useState(!1),[h,d]=m.useState(new $),[p,f]=m.useState(new $),[g,M]=m.useState(!1);m.useEffect(()=>(ie.activeListener(S),()=>{ie.unmountActiveListener(S)}),[]),m.useEffect(()=>{if(e){const T={x:(e==null?void 0:e.x)-20,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)},v={x:(e==null?void 0:e.x)+(e==null?void 0:e.w)/2,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)/2};f(new $(v.x,v.y)),d(new $(T.x,T.y)),c({x:T.x,y:T.y})}},[e==null?void 0:e.x,e==null?void 0:e.y,e==null?void 0:e.h]);const S=T=>{var v;if(!T){M(!0),u(!1),o(V.None);return}M(!1),(v=n==null?void 0:n.control.room)!=null&&v.disableDeviceInputs&&(n.control.room.disableDeviceInputs=n.control.disableDeviceInputs)},w=(T,v)=>{if(T.cancelable&&T.preventDefault(),T.stopPropagation(),n!=null&&n.control.worker.isBusy){M(!0);return}u(!0);const P=Math.round($.GetAngleByPoints(h,p,new $(v.x,v.y)))||0;i(P),o(V.RotateNode),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!0),ie.emitMethod(se.MainEngine,V.RotateNode,{workIds:[H],angle:0,workState:z.Start,viewId:n==null?void 0:n.viewId})},I=(T,v)=>{if(k.cancel(),T.cancelable&&T.preventDefault(),T.stopPropagation(),n!=null&&n.control.worker.isBusy){M(!0);return}u(!1);const P=Math.round($.GetAngleByPoints(h,p,new $(v.x,v.y)))||0;i(P),o(V.None),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=n.control.disableDeviceInputs),ie.emitMethod(se.MainEngine,V.RotateNode,{workIds:[H],angle:P,workState:z.Done,viewId:n==null?void 0:n.viewId})},k=ui((T,v)=>{if(T.cancelable&&T.preventDefault(),T.stopPropagation(),n!=null&&n.control.worker.isBusy){M(!0);return}u(!0);const P=Math.round($.GetAngleByPoints(h,p,new $(v.x,v.y)))||0;i(P),c({x:v.x,y:v.y}),o(V.RotateNode),ie.emitMethod(se.MainEngine,V.RotateNode,{workIds:[H],angle:P,workState:z.Doing,viewId:n==null?void 0:n.viewId})},100,{trailing:!0});return m.createElement(Lt,{disabled:g,position:r,handle:".appliance-plugin-rotate-mouse-pointer",onStart:w,onDrag:k,onStop:I},m.createElement("div",{className:`${s}`,style:e?{left:0,top:0,touchAction:"none"}:void 0},!l&&m.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:e==null?void 0:e.selectorColor}},m.createElement("img",{alt:"icon",src:xe("rotation-button")})),m.createElement("div",{className:`appliance-plugin-rotate-mouse-pointer ${l?"active":""}`},m.createElement("img",{alt:"icon",src:xe("rotation")}),m.createElement("div",{className:"angle-icon"},t,"°"))))},lw=a=>{const{floatBarData:s,setOperationType:e,mananger:t,isNoPointerEvents:i}=m.useContext(Te),{onClickHandle:o}=a,[n,r]=m.useState(z.Pending),[c,l]=m.useState(),[u,h]=m.useState(),[d,p]=m.useState(!1),f=m.useRef(0),g=m.useRef(0);m.useEffect(()=>(ie.activeListener(M),()=>{ie.unmountActiveListener(M)}),[]);const M=v=>{var P;if(!v||s!=null&&s.isLocked){p(!0),r(z.Pending),e(V.None);return}p(!1),(P=t==null?void 0:t.control.room)!=null&&P.disableDeviceInputs&&(t.control.room.disableDeviceInputs=t.control.disableDeviceInputs)};m.useEffect(()=>{if(s!=null&&s.isLocked||t!=null&&t.control.worker.isBusy){p(!0),r(z.Pending);return}p(!1)},[s==null?void 0:s.isLocked]),m.useEffect(()=>{A.isNumber(s==null?void 0:s.x)&&A.isNumber(s==null?void 0:s.y)&&(n===z.Pending||n===z.Done)&&h({x:s==null?void 0:s.x,y:s==null?void 0:s.y})},[n,s==null?void 0:s.x,s==null?void 0:s.y]);const S=v=>{if(v.cancelable&&v.preventDefault(),v.stopPropagation(),t!=null&&t.control.worker.isBusy){p(!0),r(z.Pending);return}A.isNumber(s==null?void 0:s.x)&&A.isNumber(s==null?void 0:s.y)&&(f.current&&(clearTimeout(f.current),f.current=0),t!=null&&t.control.room&&(t.control.room.disableDeviceInputs=!0),e(V.TranslateNode),r(z.Start),l({x:s==null?void 0:s.x,y:s==null?void 0:s.y}),ie.emitMethod(se.MainEngine,V.TranslateNode,{workIds:[H],position:{x:s==null?void 0:s.x,y:s==null?void 0:s.y},workState:z.Start,viewId:t==null?void 0:t.viewId}),f.current=setTimeout(()=>{w(v,{x:s.x,y:s.y})},500))},w=(v,P)=>{if(I.cancel(),t!=null&&t.control.room&&(t.control.room.disableDeviceInputs=t.control.disableDeviceInputs),t!=null&&t.control.worker.isBusy){p(!0),r(z.Pending);return}f.current&&(clearTimeout(f.current),f.current=0),v.stopPropagation();const C={x:P.x,y:P.y};e(V.None),r(z.Done),ie.emitMethod(se.MainEngine,V.TranslateNode,{workIds:[H],position:C,workState:z.Done,viewId:t==null?void 0:t.viewId})},I=A.throttle((v,P)=>{if(v.cancelable&&v.preventDefault(),v.stopPropagation(),t!=null&&t.control.worker.isBusy){p(!0),r(z.Pending);return}f.current&&(clearTimeout(f.current),f.current=0);const C={x:P.x,y:P.y};(P.x!==(s==null?void 0:s.x)||P.y!==(s==null?void 0:s.y))&&(r(z.Doing),ie.emitMethod(se.MainEngine,V.TranslateNode,{workIds:[H],position:C,workState:z.Doing,viewId:t==null?void 0:t.viewId}))},100,{trailing:!1}),k=m.useMemo(()=>!!((s==null?void 0:s.scaleType)===re.none&&(s!=null&&s.canLock)),[s]),T=v=>(v.stopPropagation(),v.cancelable&&v.preventDefault(),(c==null?void 0:c.x)===(s==null?void 0:s.x)&&(c==null?void 0:c.y)===(s==null?void 0:s.y)&&o(v),!1);return m.createElement(Lt,{disabled:d,position:u,onStart:S,onDrag:I,onStop:w},m.createElement("div",{style:s?{position:"absolute",left:0,top:0,width:s.w,height:s.h,zIndex:2,pointerEvents:k||i?"none":"auto",touchAction:"none"}:void 0,onPointerUp:v=>{I.cancel(),v.persist(),g.current&&(clearTimeout(g.current),g.current=0),g.current=setTimeout(()=>{g.current=0,T(v)},200)}}))},hw=a=>{const{className:s}=a,[e,t]=m.useState({x:0,y:0,h:0,w:0}),[i,o]=m.useState(),[n,r]=m.useState(),[c,l]=m.useState(),{floatBarData:u,mananger:h,isNoPointerEvents:d}=m.useContext(Te),[p,f]=m.useState(),[g,M]=m.useState(!1);m.useEffect(()=>{if(u&&h){const C={x:u.x,y:u.y,w:u.w,h:u.h};t(C)}return ie.activeListener(S),()=>{ie.unmountActiveListener(S)}},[]);const S=C=>{var L;if(!C){M(!0);return}M(!1),(L=h==null?void 0:h.control.room)!=null&&L.disableDeviceInputs&&(h.control.room.disableDeviceInputs=h.control.disableDeviceInputs)},w=C=>[[C.x,C.y],[C.x+C.w,C.y],[C.x+C.w,C.y+C.h],[C.x,C.y+C.h]],I=(C,L)=>{switch(L){case"top":case"topLeft":case"left":return C[2];case"topRight":return C[3];case"right":case"bottomRight":case"bottom":return C[0];case"bottomLeft":return C[1]}},k=(C,L,O,R)=>{let E=!1,j=!1;const D={x:e.x,y:e.y,w:e.w,h:e.h},q=[1,1],oe=[0,0];switch(C){case"top":{const Q=L.height+e.h;Q<0?(j=!0,D.y=e.y+e.h,D.h=Math.abs(Q)):(D.y=e.y-L.height,D.h=e.h+L.height);break}case"topLeft":{const Q=L.width+e.w;Q<0?(E=!0,D.x=e.x+e.w,D.w=Math.abs(Q)):(D.x=e.x-L.width,D.w=e.w+L.width);const J=L.height+e.h;J<0?(j=!0,D.y=e.y+e.h,D.h=Math.abs(J)):(D.y=e.y-L.height,D.h=e.h+L.height);break}case"topRight":{const Q=L.width+e.w;Q<0?(E=!0,D.x=e.x+Q,D.w=Math.abs(Q)):D.w=e.w+L.width;const J=L.height+e.h;J<0?(j=!0,D.y=e.y+e.h,D.h=Math.abs(J)):(D.y=e.y-L.height,D.h=e.h+L.height);break}case"bottom":{const Q=L.height+e.h;Q<0?(j=!0,D.y=e.y+Q,D.h=Math.abs(Q)):D.h=e.h+L.height;break}case"bottomLeft":{const Q=L.width+e.w;Q<0?(E=!0,D.x=e.x+e.w,D.w=Math.abs(Q)):(D.x=e.x-L.width,D.w=e.w+L.width);const J=L.height+e.h;J<0?(j=!0,D.y=e.y+J,D.h=Math.abs(J)):D.h=e.h+L.height;break}case"left":{const Q=L.width+e.w;Q<0?(E=!0,D.x=e.x+e.w,D.w=Math.abs(Q)):(D.x=e.x-L.width,D.w=e.w+L.width);break}case"bottomRight":{const Q=L.width+e.w;Q<0?(E=!0,D.x=e.x+Q,D.w=Math.abs(Q)):D.w=e.w+L.width;const J=L.height+e.h;J<0?(j=!0,D.y=e.y+J,D.h=Math.abs(J)):D.h=e.h+L.height;break}case"right":{const Q=L.width+e.w;Q<0?(E=!0,D.x=e.x+Q,D.w=Math.abs(Q)):D.w=e.w+L.width;break}}q[0]=D.w/e.w,q[1]=D.h/e.h;const Z=w(D).map(Q=>O.control.viewContainerManager.transformToScenePoint(Q,O.viewId)),_=I(Z,C);return j&&(oe[1]=_[1]-R[1]),E&&(oe[0]=_[0]-R[0]),{scale:q,translate:oe}},T=(C,L)=>{if(C.cancelable&&C.preventDefault(),C.stopPropagation(),h!=null&&h.control.worker.isBusy){M(!0);return}if(u!=null&&u.w&&(u!=null&&u.h)&&h){const O={x:u.x,y:u.y,w:u.w,h:u.h},R=w(O),E=R.map(q=>h.control.viewContainerManager.transformToScenePoint(q,h.viewId)),j=I(R,L),D=I(E,L);t(O),o(j),r(D),l(L),h!=null&&h.control.room&&(h.control.room.disableDeviceInputs=!0),ie.emitMethod(se.MainEngine,V.ScaleNode,{workIds:[H],originPoint:j,scenePoint:D,workState:z.Start,viewId:h.viewId})}},v=A.throttle((C,L,O,R)=>{if(C.cancelable&&C.preventDefault(),C.stopPropagation(),!h||!i||!n)return;if(h!=null&&h.control.worker.isBusy){M(!0);return}const{scale:E,translate:j}=k(L,R,h,n);(!A.isEqual(E,p==null?void 0:p.scale)||!A.isEqual(j,p==null?void 0:p.translate))&&(f({scale:E,translate:j}),ie.emitMethod(se.MainEngine,V.ScaleNode,{workIds:[H],scale:E,dir:L,translate:j,originPoint:i,scenePoint:n,workState:z.Doing,viewId:h.viewId}))},100,{trailing:!0}),P=C=>{if(v.cancel(),C.cancelable&&C.preventDefault(),C.stopPropagation(),!(!h||!i||!n)){if(h!=null&&h.control.worker.isBusy){M(!0);return}if(h!=null&&h.control.room&&(h.control.room.disableDeviceInputs=h.control.disableDeviceInputs),p){const{scale:L,translate:O}=p;ie.emitMethod(se.MainEngine,V.ScaleNode,{workIds:[H],scale:L,dir:c,translate:O,originPoint:i,scenePoint:n,workState:z.Done,viewId:h.viewId})}}};return m.createElement(mn.Resizable,{className:`${s}`,boundsByDirection:!0,minWidth:-(((u==null?void 0:u.x)||0)+((u==null?void 0:u.w)||0)),minHeight:-(((u==null?void 0:u.y)||0)+((u==null?void 0:u.h)||0)),size:{width:(u==null?void 0:u.w)||0,height:(u==null?void 0:u.h)||0},style:{position:"absolute",left:u==null?void 0:u.x,top:u==null?void 0:u.y,pointerEvents:d?"none":"auto"},enable:g?!1:{top:(u==null?void 0:u.scaleType)===re.all&&!0||!1,right:(u==null?void 0:u.scaleType)===re.all&&!0||!1,bottom:(u==null?void 0:u.scaleType)===re.all&&!0||!1,left:(u==null?void 0:u.scaleType)===re.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(u==null?void 0:u.scaleType)===re.proportional,onResizeStart:T,onResize:v,onResizeStop:P})},no=a=>{const{id:s,pos:e,pointMap:t,type:i}=a,{setOperationType:o,mananger:n,floatBarData:r}=m.useContext(Te),[c,l]=m.useState({x:0,y:0}),[u,h]=m.useState(z.Pending),[d,p]=m.useState(!1);m.useEffect(()=>(ie.activeListener(f),()=>{ie.unmountActiveListener(f)}),[]);const f=w=>{var I;if(!w||r!=null&&r.isLocked){p(!0),h(z.Pending),o(V.None);return}p(!1),(I=n==null?void 0:n.control.room)!=null&&I.disableDeviceInputs&&(n.control.room.disableDeviceInputs=n.control.disableDeviceInputs)};m.useEffect(()=>{A.isNumber(e.x)&&A.isNumber(e.y)&&(u===z.Pending||u===z.Done)&&l({x:e.x,y:e.y})},[e,u]);const g=w=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),n!=null&&n.control.worker.isBusy){p(!0),h(z.Pending);return}A.isNumber(e.x)&&A.isNumber(e.y)&&(o(V.SetPoint),h(z.Start),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!0),ie.emitMethod(se.MainEngine,V.SetPoint,{workId:H,pointMap:t,workState:z.Start,viewId:n==null?void 0:n.viewId}))},M=A.throttle((w,I)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),n!=null&&n.control.worker.isBusy){p(!0),h(z.Pending);return}const k={x:I.x,y:I.y};if((k.x!==(e==null?void 0:e.x)||k.y!==(e==null?void 0:e.y))&&(n!=null&&n.control.viewContainerManager)){const T=n.control.viewContainerManager.transformToScenePoint([k.x,k.y],n.viewId),v=t.get(s);v&&i==="start"?v[0]=T:v&&i==="end"&&(v[1]=T),h(z.Doing),ie.emitMethod(se.MainEngine,V.SetPoint,{workId:H,pointMap:t,workState:z.Doing,viewId:n==null?void 0:n.viewId})}},100,{trailing:!0}),S=(w,I)=>{if(M.cancel(),w.cancelable&&w.preventDefault(),n!=null&&n.control.worker.isBusy){p(!0),h(z.Pending);return}w.stopPropagation(),o(V.None),h(z.Done);const k={x:I.x,y:I.y};if(n!=null&&n.control.viewContainerManager){const T=n.control.viewContainerManager.transformToScenePoint([k.x,k.y],n.viewId),v=t.get(s);v&&i==="start"?v[0]=T:v&&i==="end"&&(v[1]=T),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=n.control.disableDeviceInputs),ie.emitMethod(se.MainEngine,V.SetPoint,{workId:H,pointMap:t,workState:z.Done,viewId:n==null?void 0:n.viewId})}};return m.createElement(Lt,{disabled:d,position:c,onStart:g,onDrag:M,onStop:S},m.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:r?{left:0,top:0}:void 0}))},uw=a=>{const{className:s}=a,{floatBarData:e,mananger:t}=m.useContext(Te),[i,o]=m.useState(),[n,r]=m.useState(),[c,l]=m.useState(new Map);m.useEffect(()=>{const d=[];if(t&&(e!=null&&e.points)){const p=t.viewId;if(t.control.viewContainerManager.getView(p))for(const g of e.points){const M=t.control.viewContainerManager.transformToOriginPoint(g,p);d.push(M)}e!=null&&e.selectIds&&e.selectIds.length===1&&(c.set(e.selectIds[0],e.points),l(c))}d[0]&&o({x:d[0][0],y:d[0][1]}),d[1]&&r({x:d[1][0],y:d[1][1]})},[t,e==null?void 0:e.points,e==null?void 0:e.selectIds,c]);const u=m.useMemo(()=>i&&(e!=null&&e.selectIds)?m.createElement(no,{pos:i,type:"start",id:e.selectIds[0],pointMap:c}):null,[i,e==null?void 0:e.selectIds,c]),h=m.useMemo(()=>n&&(e!=null&&e.selectIds)?m.createElement(no,{pos:n,type:"end",id:e.selectIds[0],pointMap:c}):null,[n,e==null?void 0:e.selectIds,c]);return m.createElement("div",{className:`${s}`},u,h)},dw=m.forwardRef((a,s)=>{const{floatBarData:e,operationType:t}=m.useContext(Te),i=m.useMemo(()=>(e==null?void 0:e.scaleType)!==re.all||t===V.RotateNode?null:m.createElement(ow,null),[e,t]),o=m.useMemo(()=>(e==null?void 0:e.scaleType)!==re.both||t===V.RotateNode?null:m.createElement(nw,null),[e,t]),n=m.useMemo(()=>(e==null?void 0:e.scaleType)!==re.proportional||t===V.RotateNode?null:m.createElement(rw,null),[e,t]),r=m.useMemo(()=>(e==null?void 0:e.scaleType)===re.none&&(e!=null&&e.canLock)?m.createElement(aw,null):null,[e]);return m.createElement("div",{ref:s,style:e?{transform:`translate(${e.x}px,${e.y}px)`,width:e.w,height:e.h,pointerEvents:"none"}:void 0},r,i,o,n,a.children)}),pw=m.forwardRef((a,s)=>{var p;const{floatBarData:e,operationType:t,mananger:i}=m.useContext(Te),{editors:o,activeTextId:n,isHide:r}=a,c=m.useMemo(()=>{var f;return e!=null&&e.canRotate&&((f=e==null?void 0:e.selectIds)==null?void 0:f.length)===1&&(t===V.None||t===V.RotateNode)?m.createElement(cw,{className:Pe.RotateBtn}):null},[e==null?void 0:e.canRotate,(p=e==null?void 0:e.selectIds)==null?void 0:p.length,t]),l=m.useMemo(()=>((e==null?void 0:e.scaleType)===re.all||(e==null?void 0:e.scaleType)===re.proportional)&&(t===V.None||t===V.ScaleNode)&&A.isNumber(e==null?void 0:e.x)&&A.isNumber(e==null?void 0:e.y)?m.createElement(hw,{className:Pe.ResizeBtn}):null,[e==null?void 0:e.scaleType,t,e==null?void 0:e.x,e==null?void 0:e.y]),u=m.useMemo(()=>(e==null?void 0:e.scaleType)===re.both&&(t===V.None||t===V.SetPoint)?m.createElement(uw,{className:Pe.ResizeTowBox}):null,[e==null?void 0:e.scaleType,t]),h=m.useMemo(()=>{const f=(e==null?void 0:e.selectIds)||[];return o&&i&&f&&A.isNumber(e==null?void 0:e.x)&&A.isNumber(e==null?void 0:e.y)&&A.isNumber(e==null?void 0:e.w)&&A.isNumber(e==null?void 0:e.h)?m.createElement(fn,{box:{x:e==null?void 0:e.x,y:e==null?void 0:e.y,w:e==null?void 0:e.w,h:e==null?void 0:e.h},manager:i,selectIds:f,activeTextId:n,editors:o}):null},[e==null?void 0:e.selectIds,e==null?void 0:e.x,e==null?void 0:e.y,e==null?void 0:e.w,e==null?void 0:e.h,o,i,n]),d=m.useMemo(()=>r&&t===V.None&&A.isNumber(e==null?void 0:e.x)&&A.isNumber(e==null?void 0:e.y)&&A.isNumber(e==null?void 0:e.w)&&A.isNumber(e==null?void 0:e.h)?m.createElement("div",{className:Pe.FloatBarBtn,style:{left:e==null?void 0:e.x,top:e==null?void 0:e.y,width:e.w,height:e.h}},m.createElement(pn,{position:{x:e.x,y:e.y},textOpt:e==null?void 0:e.textOpt,noLayer:e==null?void 0:e.isLocked})):null,[e==null?void 0:e.x,e==null?void 0:e.y,e==null?void 0:e.w,e==null?void 0:e.h,e==null?void 0:e.textOpt,e==null?void 0:e.isLocked,t,r]);return m.createElement("div",{className:Pe.FloatBar,onPointerOver:f=>(f.stopPropagation(),f.nativeEvent.stopImmediatePropagation(),i==null||i.control.worker.blurCursor(i.viewId),!1)},m.createElement(dw,{ref:s},m.createElement(m.Fragment,null,h)),m.createElement(lw,{onClickHandle:f=>{if(i&&(o!=null&&o.size)){const g=i.getPoint(f.nativeEvent);g&&i.control.textEditorManager.computeTextActive(g,i.viewId)}}}),c,l,u,d)}),fw=m.memo(pw,(a,s)=>!!A.isEqual(a,s)),gw="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9DwaDv/v9/n/076JgbtWUYPchwrW8qD7UnOvr6wFNkpubm+/wu7f0c7y6mrnlvQufxB0Iau7V1dX3BDA/P6/V1dVpzc3N2uLiIofK1c8VYHys/wRKBUN3/hGHqaysNOjc3FwMis6hc0FtLTHuvYLxCCZgci8uLn4wg5Gh6Fy8Jk+/NkcCAlAAuUkoW4g0B+d5tLS05O/r67O8eGxsDNra2uDy8nKsoKCAwCIQDxQa0yTxgrvCYXyTk5Ml+Orf2dlJeeHIyAigFSE/P38ELfUNqNdSkjgF5FF89jL1TU1NlQwODl5gZPujp6cHWltbUw7Koc7Pz8mkZpHPFeFrJuZeqLnoMoPoZqe0JjDP/IZgnyLUG/o8NDRkuo5Ua2pjY6MC4oFCFf1cA0oKzRSOp6enRfTaGh0d/QxBt+1CUVgnOTs7+xrHfQzGyOcKkK3QTJMnQffZ6e/v/xwttmsHqqmpKXbdycnJCxy7ABLh3FEgVZ6hZJhnFZoFFMF0d3c/w7v+dyookXBnZ2c/xvHfhriVcvXfdBRItsxjnOhYqjwjoAimq6vrCysoGofk+Ph4Esd/F/UdiFtJAGUd2DygTpp5dmBUUJ2dnc9VUALm8PDwJY7/BPU9VD8k3M4RC6kskxZMKigKIMLN9vf3p3H8DyWgfEhEOwOQD9IXOTz7EObbwsLC4YWFBRgeHrY9ECXYo6MjaGlpKWlsbPxkYGDgRW1tbSEWquVlZWXBzc3Nl1VVVa8hXiXc6ioqBqGaPDk7AACJTRZ3NS9lcUp86cJwoSQ7Pj4Op6enfxUXF3/V0NCQv7q6GsCvwrqGUG/01xAD4+VQTOxaSF43d5bBOisrGBJRCtXX17+/trb268rKSgASFgmz97KFkmo6OztWuVyPweiWGc4WRkhFRQVEIpHg8vJyQAIQVlLBROVxvBYQHsXnO8tk62ZcyN0wecLBwcEvYHSzEPscBqOLCRhLC4n9uqaA8UAWAcAKhtbQ3t7eTHl5+Y9gtAp3twhT056CDMQ7MRzIFTeTYKb1yYYVQFH9VdzsqNmYKpfTJBDX3Ixgdnd3XyHMT2AMALJlBBSPaMpNngrIsTyTCgaj288YDGakictrxizvKFNOjgSSBLS+vv6UYHDb7DgMVgsChjTEgCIKGG4ZU+EWkgNBzN1qamq+pAMTExPgFMzW1tZrhHkFyWE5KxgSszx0527RaDRmOSpRshEOU11dPQPG8CwHARHJlMnTSrwSRFIlfXt7m3V5ngJGuJtqzaQtZkFBVNJezN5ZAdmwjKo2k9tVtrcI3OXk4tPgcg7ChCDZ1URgMOu72Xa5VFHOkymQhWVU60YVmjN6wiC7k6p+S1syCACOwJBYFaexV+yhBekNPsMBO6KAEeE4BMaCU67RsoYhSbXgaT//ht709vZCaWmp6YkEbLFmVJWzas04+iBL7EKpm0J7duqu0B7+CTUpNJuyvb1NCfMj1CqI9wLKUOlOUMeG+gGFkHii4HizUF4z/KFUrPsJ8WbEIyx7nnZ0dDynME6BAuce09iFHo+GrnmGltltb2//E4wVAN82y7vOjKOZXSBhJdHNiT3TYWD8OY2PTUJkdd7MkJMnT5wZVQF2RFX6yBMUdzPMvvfqxz3sXHF+GNT9ANXit/10O1sgHkZvdQAOKvs9B5L7ARELGAAXLSTvM8QExTE+YbHe+HURhZp1aRyF4CJXClbbWwGketgkW9VsY+YaiBCVhfgE+XvxRwgZSM4jUVCDZFQ9pytmXR8hUTB2gnidx4XffVWydN0yQjwmx/jkAZJBrIBI5J7ZvQGZWUgVSuU/EqmOAzicKNMVu816DdRWUV1/7xAP8n+SfwF3Du3NF2sYhwAAAABJRU5ErkJggg==",yw="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='40px'%20height='40px'%20viewBox='0%200%2040%2040'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!--%20Generator:%20Sketch%2060.1%20(88133)%20-%20https://sketch.com%20--%3e%3ctitle%3eshape-cursor%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3cpath%20d='M20,21.5%20C20.2454599,21.5%2020.4496084,21.6768752%2020.4919443,21.9101244%20L20.5,22%20L20.5,27%20C20.5,27.2761424%2020.2761424,27.5%2020,27.5%20C19.7545401,27.5%2019.5503916,27.3231248%2019.5080557,27.0898756%20L19.5,27%20L19.5,22%20C19.5,21.7238576%2019.7238576,21.5%2020,21.5%20Z%20M27,19.5%20C27.2761424,19.5%2027.5,19.7238576%2027.5,20%20C27.5,20.2454599%2027.3231248,20.4496084%2027.0898756,20.4919443%20L27,20.5%20L22,20.5%20C21.7238576,20.5%2021.5,20.2761424%2021.5,20%20C21.5,19.7545401%2021.6768752,19.5503916%2021.9101244,19.5080557%20L22,19.5%20L27,19.5%20Z%20M18,19.5%20C18.2761424,19.5%2018.5,19.7238576%2018.5,20%20C18.5,20.2454599%2018.3231248,20.4496084%2018.0898756,20.4919443%20L18,20.5%20L13,20.5%20C12.7238576,20.5%2012.5,20.2761424%2012.5,20%20C12.5,19.7545401%2012.6768752,19.5503916%2012.9101244,19.5080557%20L13,19.5%20L18,19.5%20Z%20M20,12.5%20C20.2454599,12.5%2020.4496084,12.6768752%2020.4919443,12.9101244%20L20.5,13%20L20.5,18%20C20.5,18.2761424%2020.2761424,18.5%2020,18.5%20C19.7545401,18.5%2019.5503916,18.3231248%2019.5080557,18.0898756%20L19.5,18%20L19.5,13%20C19.5,12.7238576%2019.7238576,12.5%2020,12.5%20Z'%20id='path-1'%3e%3c/path%3e%3cfilter%20x='-64.6%25'%20y='-59.5%25'%20width='229.3%25'%20height='246.1%25'%20filterUnits='objectBoundingBox'%20id='filter-2'%3e%3cfeMorphology%20radius='1'%20operator='dilate'%20in='SourceAlpha'%20result='shadowSpreadOuter1'%3e%3c/feMorphology%3e%3cfeOffset%20dx='0'%20dy='2'%20in='shadowSpreadOuter1'%20result='shadowOffsetOuter1'%3e%3c/feOffset%3e%3cfeGaussianBlur%20stdDeviation='3'%20in='shadowOffsetOuter1'%20result='shadowBlurOuter1'%3e%3c/feGaussianBlur%3e%3cfeComposite%20in='shadowBlurOuter1'%20in2='SourceAlpha'%20operator='out'%20result='shadowBlurOuter1'%3e%3c/feComposite%3e%3cfeColorMatrix%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.16%200'%20type='matrix'%20in='shadowBlurOuter1'%3e%3c/feColorMatrix%3e%3c/filter%3e%3c/defs%3e%3cg%20id='页面-4'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='Whiteboard-Guidelines'%20transform='translate(-344.000000,%20-751.000000)'%3e%3cg%20id='shape-cursor'%20transform='translate(344.000000,%20751.000000)'%3e%3crect%20id='矩形备份-44'%20fill='%23FFFFFF'%20opacity='0.01'%20x='0'%20y='0'%20width='40'%20height='40'%20rx='2'%3e%3c/rect%3e%3cg%20id='形状结合'%20fill-rule='nonzero'%3e%3cuse%20fill='black'%20fill-opacity='1'%20filter='url(%23filter-2)'%20xlink:href='%23path-1'%3e%3c/use%3e%3cpath%20stroke='%23FFFFFF'%20stroke-width='1'%20d='M20,21%20C20.4854103,21%2020.898085,21.3479993%2020.9899479,21.8654877%20L21,22%20L21,27%20C21,27.5522847%2020.5522847,28%2020,28%20C19.5145897,28%2019.101915,27.6520007%2019.0100521,27.1345123%20L19,27%20L19,22%20C19,21.4477153%2019.4477153,21%2020,21%20Z%20M27,19%20C27.5522847,19%2028,19.4477153%2028,20%20C28,20.4854103%2027.6520007,20.898085%2027.1345123,20.9899479%20L27,21%20L22,21%20C21.4477153,21%2021,20.5522847%2021,20%20C21,19.5145897%2021.3479993,19.101915%2021.8654877,19.0100521%20L22,19%20L27,19%20Z%20M18,19%20C18.5522847,19%2019,19.4477153%2019,20%20C19,20.4854103%2018.6520007,20.898085%2018.1345123,20.9899479%20L18,21%20L13,21%20C12.4477153,21%2012,20.5522847%2012,20%20C12,19.5145897%2012.3479993,19.101915%2012.8654877,19.0100521%20L13,19%20L18,19%20Z%20M20,12%20C20.4854103,12%2020.898085,12.3479993%2020.9899479,12.8654877%20L21,13%20L21,18%20C21,18.5522847%2020.5522847,19%2020,19%20C19.5145897,19%2019.101915,18.6520007%2019.0100521,18.1345123%20L19,18%20L19,13%20C19,12.4477153%2019.4477153,12%2020,12%20Z'%20fill='%23212324'%20fill-rule='evenodd'%3e%3c/path%3e%3c/g%3e%3crect%20id='矩形'%20fill='%23FFFFFF'%20x='18.5'%20y='17'%20width='3'%20height='6'%3e%3c/rect%3e%3crect%20id='矩形'%20fill='%23FFFFFF'%20x='17'%20y='18.5'%20width='6'%20height='3'%3e%3c/rect%3e%3cpath%20d='M20,21.5%20C20.2454599,21.5%2020.4496084,21.6768752%2020.4919443,21.9101244%20L20.5,22%20L20.5,27%20C20.5,27.2761424%2020.2761424,27.5%2020,27.5%20C19.7545401,27.5%2019.5503916,27.3231248%2019.5080557,27.0898756%20L19.5,27%20L19.5,22%20C19.5,21.7238576%2019.7238576,21.5%2020,21.5%20Z%20M27,19.5%20C27.2761424,19.5%2027.5,19.7238576%2027.5,20%20C27.5,20.2454599%2027.3231248,20.4496084%2027.0898756,20.4919443%20L27,20.5%20L22,20.5%20C21.7238576,20.5%2021.5,20.2761424%2021.5,20%20C21.5,19.7545401%2021.6768752,19.5503916%2021.9101244,19.5080557%20L22,19.5%20L27,19.5%20Z%20M18,19.5%20C18.2761424,19.5%2018.5,19.7238576%2018.5,20%20C18.5,20.2454599%2018.3231248,20.4496084%2018.0898756,20.4919443%20L18,20.5%20L13,20.5%20C12.7238576,20.5%2012.5,20.2761424%2012.5,20%20C12.5,19.7545401%2012.6768752,19.5503916%2012.9101244,19.5080557%20L13,19.5%20L18,19.5%20Z%20M20,12.5%20C20.2454599,12.5%2020.4496084,12.6768752%2020.4919443,12.9101244%20L20.5,13%20L20.5,18%20C20.5,18.2761424%2020.2761424,18.5%2020,18.5%20C19.7545401,18.5%2019.5503916,18.3231248%2019.5080557,18.0898756%20L19.5,18%20L19.5,13%20C19.5,12.7238576%2019.7238576,12.5%2020,12.5%20Z'%20id='形状结合'%20fill='%23212324'%20fill-rule='nonzero'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",mw="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='47px'%20height='40px'%20viewBox='0%200%2047%2040'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!--%20Generator:%20Sketch%2060.1%20(88133)%20-%20https://sketch.com%20--%3e%3ctitle%3etext-cursor%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3cpath%20d='M16,26.5%20C15.7238576,26.5%2015.5,26.2761424%2015.5,26%20C15.5,25.7545401%2015.6768752,25.5503916%2015.9101244,25.5080557%20L16,25.5%20L19.5,25.5%20L19.5,14.5%20L16,14.5%20C15.7238576,14.5%2015.5,14.2761424%2015.5,14%20C15.5,13.7545401%2015.6768752,13.5503916%2015.9101244,13.5080557%20L16,13.5%20L24,13.5%20C24.2761424,13.5%2024.5,13.7238576%2024.5,14%20C24.5,14.2454599%2024.3231248,14.4496084%2024.0898756,14.4919443%20L24,14.5%20L20.5,14.5%20L20.5,25.5%20L24,25.5%20C24.2761424,25.5%2024.5,25.7238576%2024.5,26%20C24.5,26.2454599%2024.3231248,26.4496084%2024.0898756,26.4919443%20L24,26.5%20L16,26.5%20Z'%20id='path-1'%3e%3c/path%3e%3cfilter%20x='-284.0%25'%20y='-81.5%25'%20width='668.1%25'%20height='293.9%25'%20filterUnits='objectBoundingBox'%20id='filter-2'%3e%3cfeMorphology%20radius='1'%20operator='dilate'%20in='SourceAlpha'%20result='shadowSpreadOuter1'%3e%3c/feMorphology%3e%3cfeOffset%20dx='0'%20dy='2'%20in='shadowSpreadOuter1'%20result='shadowOffsetOuter1'%3e%3c/feOffset%3e%3cfeGaussianBlur%20stdDeviation='3'%20in='shadowOffsetOuter1'%20result='shadowBlurOuter1'%3e%3c/feGaussianBlur%3e%3cfeComposite%20in='shadowBlurOuter1'%20in2='SourceAlpha'%20operator='out'%20result='shadowBlurOuter1'%3e%3c/feComposite%3e%3cfeColorMatrix%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.16%200'%20type='matrix'%20in='shadowBlurOuter1'%3e%3c/feColorMatrix%3e%3c/filter%3e%3c/defs%3e%3cg%20id='页面-4'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='Whiteboard-Guidelines'%20transform='translate(-388.000000,%20-672.000000)'%3e%3cg%20id='text-cursor'%20transform='translate(392.000000,%20672.000000)'%3e%3crect%20id='矩形备份-40'%20fill='%23FFFFFF'%20opacity='0.01'%20x='0'%20y='0'%20width='40'%20height='40'%20rx='2'%3e%3c/rect%3e%3cg%20id='形状结合'%20fill-rule='nonzero'%3e%3cuse%20fill='black'%20fill-opacity='1'%20filter='url(%23filter-2)'%20xlink:href='%23path-1'%3e%3c/use%3e%3cpath%20stroke='%23FFFFFF'%20stroke-width='1'%20d='M19,25%20L19,15%20L16,15%20C15.4477153,15%2015,14.5522847%2015,14%20C15,13.5145897%2015.3479993,13.101915%2015.8654877,13.0100521%20L16,13%20L24,13%20C24.5522847,13%2025,13.4477153%2025,14%20C25,14.4854103%2024.6520007,14.898085%2024.1345123,14.9899479%20L24,15%20L21,15%20L21,25%20L24,25%20C24.5522847,25%2025,25.4477153%2025,26%20C25,26.4854103%2024.6520007,26.898085%2024.1345123,26.9899479%20L24,27%20L16,27%20C15.4477153,27%2015,26.5522847%2015,26%20C15,25.5145897%2015.3479993,25.101915%2015.8654877,25.0100521%20L16,25%20L19,25%20Z'%20fill='%23212324'%20fill-rule='evenodd'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Mw="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAgrSURBVHgB7ZprTBRXFIDP7gIt8lQppTwE5V0KaAn6o1pqNGkDDTEmTUhsgKRp+gNJw68CFkLbVC2QkDS+gD8KJdWmARvbFBNNWpuIRGPFWBXQRMPDqIki+KLATs+ZnTvcvXtnX8w2beJJToaduTP3fHPOPffcOwC8kP+2WCDwIvahGFxTuN8KmNSZmULPNjLeqF9F8rdPkIEGEn+r+vjx46LQ0NA8/Dsader58+e/h4WFDWntFO7ot6fMFAt3JLWi2lCDpqamCux2+2+KROj82NhYGrXT2lu5Z/DP/deFByElA4Pv3LlTiHY/nJ6eVnbv3q1s2bJFyc7OVrZu3arU1dUp4+PjxPUQoT+g9tp9PkMFgpo9kxljHRoaWp2Xl3duYmIiurKyEvDoclNCQgIcPnxYPc7MzHwcGRnZhaft4Ag7O9fUbRhaITCie4lgcnNzT7qDIaHz27dvh+vXr0NEREQneqoCHKFnAR+8ZCaQGGq2CxcurCGYycnJZHcwTNAzUFFRoUJFRUV1IFQ5OKBsXB9uxSwgl0TQ3d29Yt26dccwoyVXV1d7hGEiQmGi2AzOUHx/hob4K2yuYS9G987s7OwPISEh7xPM6dOnwVfBsIMjR45AZmbmo5s3b76Xnp7+J55egMVxBSAZT0v1ED+76yn66dOnLQSzd+9ev2BIyFP0MjBco1JTU/sxfFeDazp3cYgZHmKqdoaGNISHh9fv378fSJcqlPV6e3sBJ+I/goOD34VFL0k95Y+HxPHCYGxmw5DQ2NuzZw8EBQVtunXr1jvgwUP+hhz/QDXMMCNVE8zx48dNg2FCz6QQjI2N/RA8VBFmANnu3btXihnpG8pM9fX1EAi5du0aeWkVOAMBCF7yN+R0z4yOjq6NiYlpp9CgdBtIwXpPH6vgDKWLt0CygtM6MDCwBuUYZSKaOCksAiVY9wFOBePgDOOytPAGSKzNVCCC2bBhw69YdK7ypgpYimzbtk2dl7CM+hFcveOUHDylbTFO1YdhFbByx44dA1QFUP0VSJj4+Hjo6+sDq9U6iEmHKvFZTedQ50GYbN15SITVlwNlZWUnLRZL8s6dOwMOQ9UCTtKTra2ttdppt9V2kMF5cbmsjxuM43bMNrmUzc6fP6+GQiDGDoOJi4ubwb4qm5ubafyIE6nLxGqTPEsGo1cBOGNX0TyDYafC0CyOaxcVziyh53Z2dkJycvLMvn37PmpoaBgFR4jxYSbWdVIgI89Iq4CjR48CZjlYv369+tssqI6ODsjPz4f+/v668vLycxrEHHfkYdwC8SB6mGEV8Cl64cuuri5oa2tTG+EyGjZu3AiXLl1qefDgwV8lJSUFZkDV1tZCcXExXLx4sbWoqKgPFj0zx8GI9ZwO5W4M6ekZYeqpaqbqmaSqqkpNpcPDw4dwzfM9nrLduHEjEs+X0XV/Sx96LnqE1kLtBQUF3eDwCO8dGQyzV5rl+JyuegfXI29jRotiRlKnpFghHMzKyjqotVXS0tLacKPjF3bdHxjSq1evduAkepAD+ZsDYlC8V5w8ZBVg+PPq2MGMlkInqE4joTf45MmT4YyMjAPcA+ltLSQlJX2BafxnX6HI29QeK44TOTk57mCYZ0QoJ8OBM4yB6dkNkwGlSygsLFQvYtYB3BTMxFL+M+0eFgZqp4mJiU2+QKGX1fGIk/QIrn0aYXGsyDxjmAyMhO2jhaCGoUbX1NSkLSwsPMJqV8Fspu6lIZS6OYhjiOLwdU7fQM1HfRPD7wS1obZ0j0xpb4726Z49ezaJf2/S7s9ATUGNR41BjdJseRnke3WGwhrRTS9pD1mOGoeG15BxOOfoxuCkp0Ih6NeaEaSZGlieJyiCoc1FgsGldokGk8nBvAKOrWIGQ5uPsm0tt0BWDiicAaGuGhkZ+YqMw9StGzU4OKhCnT179hNsswY1FTXdE5QEJhc1S3tGogazXLOBwQSBl3tzIhQPtAL1VQJCTcNx8y1vHIUghSKFZE9PT7H2dlM1b+Wgrr1y5Uq77J75+fnplpaWMg2ch4nlYEI5z7hdensDpI4hrYNErcMMXJ32koG4ztf3pultz83NjWG99Ra2WQ0OL2VjZjwgeufUqVOqV8+cOdPIwdBLSNJeHg8TAh5WqJ6EfSmgt7IMNRJ1JThiOlnrOAMHshprmMKdoGSCpb9s3B3SYLIFGIqICJB7xisYi+RvfiypXw40DWGdlJaWRmMd141hk8V2OWm7ieYTXhBc3+BgaZyqAISjOYxSMVvXsBTNlzdiNQDgRao2AtK3pjggpmrqbGpqSsLPIN/dv38/gaBwUjTshMHcvn27JyUlpRmc5xpPMD599LIYnLNyUKKndKjGxsakXbt2deMCLIE8IVvs0YRM1fjdu3d/wrXN5+BcnzEgvor2uN3rjzAYMp5lPEoQlE5fA0fWo8GfhlCbKVFQ1pKNIfzcOHH58mWqaimVUwJI0+6n59D4pIlzmdZPMPiZzXjDjX47Le5g0Uu8x2zgPqWyKpjVe7x3+AUbq9NYjQbgp2dsBud5o8TP7d5kHAWcQchQfoEmLgn8HjOiBIF7o5hI1x6CEbLNP3bdqYAF44JzyWLzcN1i8DcT/o3awbm8Fz3DAy2A62INwPV/E3wWdx5inmBHuwChCBD6R2JwHge80TIQRQLjt7e8DTkGZgfX8cUMZTDAteFDkveaIlzjX9ySQs8X18r2t2VHUURPKoICmDR+eCO9aSdmOIub3/w9RgpgUpiJhvraXpa6jZKHGEqyusw0GLFzX+5RhN/8kYnMSNMMfyH/V/kHST6OYVElTPAAAAAASUVORK5CYII=";class ww extends m.Component{constructor(e){super(e);y(this,"renderAvatar",e=>{var i;const t=`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`;if(this.detectAvatar(e)){const o=this.getCursorName(e);return m.createElement("img",{className:"cursor-selector-avatar",style:{width:o?19:28,height:o?19:28,position:o?"initial":"absolute",borderColor:o?"white":t,marginRight:o?4:0},src:(i=e.payload)==null?void 0:i.avatar,alt:"avatar"})}else return null});y(this,"getOpacity",e=>{const t=this.getCursorName(e),i=this.detectAvatar(e);return t===void 0&&i===void 0?0:1});y(this,"getCursorName",e=>{if(e.payload)return e.payload.nickName||e.payload.cursorName||e.payload.uid});y(this,"getThemeClass",e=>e.payload&&e.payload.theme?"cursor-inner-mellow":"cursor-inner");y(this,"getCursorBackgroundColor",e=>{const t=this.getCursorName(e);return e.payload&&e.payload.cursorBackgroundColor?e.payload.cursorBackgroundColor:t?`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`:void 0});y(this,"getCursorTextColor",e=>e.payload&&e.payload.cursorTextColor?e.payload.cursorTextColor:"#FFFFFF");y(this,"getCursorTagBackgroundColor",e=>e.payload&&e.payload.cursorTagBackgroundColor?e.payload.cursorTagBackgroundColor:this.getCursorBackgroundColor(e));y(this,"detectAvatar",e=>!!(e.payload&&e.payload.avatar));y(this,"renderTag",e=>{if(e.payload&&e.payload.cursorTagName)return m.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(e)}},e.payload.cursorTagName)})}render(){const{roomMember:e}=this.props,t=this.getCursorName(e);switch(e.memberState.currentApplianceName){case ne.pencil:return m.createElement("div",{className:"cursor-box"},m.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"10px"}},m.createElement("div",{className:"cursor-name"},m.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),t,this.renderTag(e))),m.createElement("div",null,m.createElement("img",{className:"cursor-pencil-image",src:gw,alt:"pencilCursor"}))));case ne.eraser:case ne.pencilEraser:return m.createElement("div",{className:"cursor-box"},m.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"0px"}},m.createElement("div",{className:"cursor-name"},m.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),t,this.renderTag(e))),m.createElement("div",null,m.createElement("img",{className:"cursor-pencil-image",src:Mw,alt:"pencilEraser"}))));case ne.text:return m.createElement("div",{className:"cursor-box"},m.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},m.createElement("div",{className:"cursor-name"},m.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),t,this.renderTag(e))),m.createElement("div",null,m.createElement("img",{className:"cursor-arrow-image",src:mw,alt:"textCursor"}))));case ne.rectangle:case ne.arrow:case ne.straight:case ne.shape:case ne.ellipse:return m.createElement("div",{className:"cursor-box"},m.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},m.createElement("div",{className:"cursor-name"},m.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),t,this.renderTag(e))),m.createElement("div",null,m.createElement("img",{className:"cursor-arrow-image",src:yw,alt:"shapeCursor"}))));default:return null}}}const vw=a=>{var o;const{className:s,info:e}=a,{roomMember:t,...i}=e||{};return m.createElement("div",{"data-cursor-uid":(o=t==null?void 0:t.payload)==null?void 0:o.uid,className:`${s}`,style:i?{transform:`translate(${i.x}px, ${i.y}px)`}:{display:"none"}},t&&m.createElement(ww,{roomMember:t}))},Iw=a=>{const{className:s,manager:e}=a,[t,i]=m.useState();m.useEffect(()=>(e.internalMsgEmitter.on([se.Cursor,e.viewId],o),()=>{e.internalMsgEmitter.off([se.Cursor,e.viewId],o)}),[e]);function o(r){i(r)}return m.useMemo(()=>{if(t!=null&&t.length){const r=t.map(c=>{var l;return c.roomMember?m.createElement(vw,{key:(l=c.roomMember)==null?void 0:l.memberId,className:s,info:c}):null});return m.createElement(m.Fragment,null,r)}return null},[t])},Tw=a=>{const{viewId:s,miniMapCanvas:e,highlightColor:t,miniMapManager:i,contianer:o}=a,[n,r]=m.useState();m.useEffect(()=>(c(),i.listener.addListener([s,"viewCameraUpate"],c),i.listener.emitAsync([s,"miniMapCreate"],!0),()=>{i.listener.removeListener([s,"viewCameraUpate"],c)}),[]);const c=()=>{const h=i.maps.get(s);h&&l(h.miniMapCamera,h.viewCamera)},l=(h,d)=>{const{width:p,height:f}=o.getBoundingClientRect(),g=Math.min(p/h.width,f/h.height),M=d.width/d.scale,S=d.height/d.scale,w=[d.centerX,d.centerY],I=[h.centerX,h.centerY],k=[w[0]-I[0],w[1]-I[1]],T=Math.min(h.scale*g,h.scale*g),v=[k[0]*T,k[1]*T,M,S,T];r(v)},u=h=>{var d;if(i.control.renderControl.isWritable){const p=h.nativeEvent.target||h.nativeEvent.srcElement;if(p&&h.nativeEvent&&n){const{width:f,height:g}=p.getBoundingClientRect(),[M,S]=[f/2,g/2],[w,I]=[(h.nativeEvent.offsetX-M)/n[4],(h.nativeEvent.offsetY-S)/n[4]],k=i.maps.get(s);if(k!=null&&k.viewCamera){const[T,v]=[k.miniMapCamera.centerX+w,k.miniMapCamera.centerY+I];(d=i.control.room)==null||d.moveCamera({centerX:T,centerY:v,animationMode:"immediately"})}}}};return m.createElement("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",pointerEvents:"auto"},onClick:u},m.createElement("canvas",{style:{pointerEvents:"none"},ref:e}),n&&m.createElement("div",{className:"minimap-highlightBox",style:{position:"absolute",top:"50%",left:"50%",width:n[2]*n[4],height:n[3]*n[4],boxSizing:"content-box",border:`2px solid ${t}`,transform:`translate(calc(-50% + ${n[0]}px), calc(-50% + ${n[1]}px))`,pointerEvents:"none"}}))},Sw=a=>{const{miniMapManager:s,active:e,className:t}=a,i=m.useMemo(()=>{const o=s.maps;if(e){const n=o.get(e);if(n){const{miniMapCamera:r,viewCamera:c,...l}=n;if(l.contianer&&r&&c){const u=s.highlightColor;return hs.createPortal(m.createElement(Tw,{viewId:e,...l,highlightColor:u,miniMapManager:s}),l.contianer)}}}return null},[e,s]);return m.createElement("div",{className:t},i)},Te=m.createContext({mananger:void 0,floatBarColors:[],floatBarData:void 0,dpr:1,angle:0,operationType:V.None,scale:[1,1],isNoPointerEvents:!1,setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class di extends m.Component{constructor(e){var t,i;super(e);y(this,"setAngle",e=>{this.setState({angle:e})});y(this,"setOperationType",e=>{this.setState({operationType:e})});this.state={floatBarData:void 0,showFloatBar:!1,showFloatBarBtn:!0,dpr:1,angle:0,operationType:V.None,scale:[1,1],editors:this.editors,activeTextId:(t=this.props.mananger.control.textEditorManager)==null?void 0:t.activeId,activeMiniMapViewId:(i=this.props.mananger.control.miniMapManager)==null?void 0:i.activeViewId}}get editors(){return Ce(this.props.mananger.control.textEditorManager.filterEditor(this.props.mananger.viewId))}componentDidMount(){this.props.mananger.vDom=this,this.props.mananger.mountView(),this.setState({dpr:this.props.mananger.dpr})}componentWillUnmount(){}setActiveMiniMap(e){this.setState({activeMiniMapViewId:e})}showFloatBarBtn(e){this.setState({showFloatBarBtn:e})}showFloatBar(e,t){const i=e&&t&&{...this.state.floatBarData,...t}||void 0;this.setState({showFloatBar:e,floatBarData:i,angle:0})}setActiveTextEditor(e){this.setState({activeTextId:e,editors:this.editors})}setFloatBarData(e){this.state.floatBarData&&this.setState({floatBarData:{...this.state.floatBarData,...e}})}render(){var t,i,o,n,r,c,l;const e=!!((i=(t=this.props.mananger.control)==null?void 0:t.room)!=null&&i.floatBarOptions);return m.createElement("div",{className:Pe.Container},!this.props.mananger.control.hasOffscreenCanvas()&&m.createElement("div",{className:Pe.CanvasBox,ref:this.props.refs.canvasContainerRef})||m.createElement("div",{className:Pe.CanvasBox},m.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),m.createElement("canvas",{id:"serviceCanvas",className:Pe.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),m.createElement("canvas",{id:"localCanvas",className:Pe.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),m.createElement("div",{id:"subLocalCanvas",className:Pe.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),m.createElement("canvas",{id:"topCanvas",className:Pe.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas()&&this.props.refs.snapshotContainerRef&&m.createElement("div",{className:Pe.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,m.createElement(Te.Provider,{value:{mananger:this.props.mananger,floatBarColors:e&&((r=(n=(o=this.props.mananger.control)==null?void 0:o.room)==null?void 0:n.floatBarOptions)==null?void 0:r.colors)||[],isNoPointerEvents:!this.state.showFloatBarBtn,floatBarData:this.state.floatBarData,dpr:this.state.dpr,angle:this.state.angle,operationType:this.state.operationType,scale:this.state.scale,setAngle:this.setAngle.bind(this),setOperationType:this.setOperationType.bind(this),setFloatBarData:this.setFloatBarData.bind(this)}},this.state.showFloatBar&&m.createElement(fw,{ref:this.props.refs.floatBarRef,editors:this.state.editors,activeTextId:this.state.activeTextId,isHide:e&&this.state.showFloatBarBtn})||null,((c=this.state.editors)==null?void 0:c.size)&&m.createElement(iw,{className:Pe.TextEditorContainer,showFloatBtns:e&&this.state.showFloatBarBtn,manager:this.props.mananger,selectIds:((l=this.state.floatBarData)==null?void 0:l.selectIds)||[],editors:this.state.editors,activeTextId:this.state.activeTextId})||null),m.createElement(Iw,{className:Pe.CursorBox,manager:this.props.mananger}),m.createElement(Sw,{className:Pe.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class Nw extends un{constructor(e,t){super(e,t);y(this,"width",1e3);y(this,"height",1e3);y(this,"dpr",it());y(this,"vDom");y(this,"eventTragetElement");y(this,"snapshotContainerRef");y(this,"canvasContainerRef",m.createRef());y(this,"subLocalCanvasContainerRef",m.createRef());y(this,"canvasTopRef",m.createRef());y(this,"canvasServiceFloatRef",m.createRef());y(this,"canvasFloatRef",m.createRef());y(this,"canvasBgRef",m.createRef());y(this,"floatBarRef",m.createRef());y(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=m.createRef())}setCanvassStyle(){if(this.eventTragetElement){const e=this.eventTragetElement.offsetWidth||this.width,t=this.eventTragetElement.offsetHeight||this.height;let i=it();this.canvasBgRef.current&&(i=it(this.canvasBgRef.current.getContext("2d"))),i!==this.dpr&&(this.dpr=i,this.control.worker.updateDpr(this.viewId,this.dpr)),e&&t&&this.canvasContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasContainerRef.current.style.width=`${e}px`,this.canvasContainerRef.current.style.height=`${t}px`),e&&t&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t),e&&t&&this.canvasBgRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasBgRef.current.width=e*this.dpr,this.canvasBgRef.current.height=t*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=e*this.dpr,this.canvasFloatRef.current.height=t*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=e*this.dpr,this.canvasServiceFloatRef.current.height=t*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=e*this.dpr,this.canvasTopRef.current.height=t*this.dpr))}}destroy(){if(super.destroy(),this.eventTragetElement){const e=this.eventTragetElement.parentElement;if(e){const t=e.querySelectorAll(".appliance-plugin-main-view-displayer");for(const i of t)i.remove()}}}createMainViewDisplayer(e){const t=document.createElement("div");return t.className="appliance-plugin-main-view-displayer",e.appendChild(t),this.eventTragetElement=e.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),hs.render(m.createElement(di,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),t),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class kw extends dM{constructor(e,t,i){super(e,t,i);y(this,"dpr",it());y(this,"width",1e3);y(this,"height",1e3);y(this,"vDom");y(this,"eventTragetElement");y(this,"canvasContainerRef",m.createRef());y(this,"subLocalCanvasContainerRef",m.createRef());y(this,"canvasTopRef",m.createRef());y(this,"canvasServiceFloatRef",m.createRef());y(this,"canvasFloatRef",m.createRef());y(this,"canvasBgRef",m.createRef());y(this,"floatBarRef",m.createRef());y(this,"containerOffset",{x:0,y:0})}setCanvassStyle(){if(this.eventTragetElement){let e=it();if(this.canvasBgRef.current&&(e=it(this.canvasBgRef.current.getContext("2d"))),e!==this.dpr&&(this.dpr=e,this.control.worker.updateDpr(this.viewId,this.dpr)),this.canvasContainerRef.current){const t=this.eventTragetElement.offsetWidth||this.width,i=this.eventTragetElement.offsetHeight||this.height;t&&i&&(t!==this.width||i!==this.height)&&(this.width=t,this.height=i,this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${i}px`)}if(this.canvasBgRef.current){const t=this.eventTragetElement.offsetWidth||this.width,i=this.eventTragetElement.offsetHeight||this.height;t&&i&&(t!==this.width||i!==this.height)&&(this.width=t,this.height=i,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=i*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=i*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=i*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=i*this.dpr))}}}createAppViewDisplayer(e,t){const i=document.createElement("div");return i.className="appliance-plugin-app-view-displayer",t.appendChild(i),this.eventTragetElement=t.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),hs.render(m.createElement(di,{viewId:e,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),i),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class Ue extends xt{constructor(e){super(e);y(this,"focuedViewId");y(this,"focuedView");y(this,"control");y(this,"tmpFocusedViewId");y(this,"checkScaleTimer");y(this,"onMainViewRelease",async e=>{this.control.textEditorManager.clear(pe,!0),this.mainViewDestroy(e),await new Promise(i=>{setTimeout(()=>{i(!0)},0)}),this.onMainViewMounted(e);const t=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(t),this.control.clearSnapshootData()});y(this,"mainViewDestroy",e=>{var t;if(this.mainView&&this.mainView.displayer){this.mainView.displayer.destroy();const i=e.divElement;if(i){const o=i.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of o)n.remove()}if(this.mainView.container&&i!==this.mainView.container){const o=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of o)n.remove()}(t=this.control.worker)==null||t.destroyViewWorker(this.mainView.id,!0),this.mainView.displayer.destroy(),this.mainView=void 0}});y(this,"onMainViewMounted",e=>{const t=e.divElement;if(!t||!e.focusScenePath||!(e.focusScenePath||e.scenePath))return;const o=new Nw(this.control,Ne.InternalMsgEmitter),n=e.size.width||o.width,r=e.size.height||o.height,l={dpr:o.dpr,originalPoint:[n/2,r/2],offscreenCanvasOpt:{...Ue.defaultScreenCanvasOpt,width:n,height:r},layerOpt:{...Ue.defaultLayerOpt,width:n,height:r},cameraOpt:{...Ue.defaultCameraOpt,width:n,height:r}},{scale:u,...h}=e.camera;l.cameraOpt={...l.cameraOpt,...h,scale:u===1/0?1:u},this.createMianView({id:pe,container:t,displayer:o,focusScenePath:e.focusScenePath,cameraOpt:l.cameraOpt,viewData:e}),this.setFocuedViewId(pe),o.createMainViewDisplayer(t),e.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this))});y(this,"onMainViewSizeUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});y(this,"onMainViewCameraUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateMainViewCamera()});y(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const e=this.mainView.viewData.camera,t=this.mainView.cameraOpt;if(t){const i=t.width,o=t.height,{width:n,height:r}=this.mainView.viewData.size;(n!==i||r!==o)&&this.mainView.displayer.updateSize();const c=e.scale===1/0?1:e.scale,l=e.centerX||0,u=e.centerY||0,h={...t,scale:c,centerX:l,centerY:u,width:n,height:r};A.isEqual(t,h)||(this.mainView.cameraOpt=h),this.checkScaleTimer&&e.scale==1/0&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),!this.checkScaleTimer&&e.scale===1/0&&this.mainView.viewData&&this.mainView.viewData.camera.scale===1/0&&(this.checkScaleTimer=setTimeout(()=>{var d,p;(p=(d=this.mainView)==null?void 0:d.viewData)==null||p.moveCamera({scale:c,centerX:l,centerY:u,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});y(this,"onAppViewMounted",async e=>{var d;const{appId:t,view:i}=e,o=i.divElement;if(!o||!i.focusScenePath)return;const n=this.appViews.get(t);if(n&&n.displayer){let p=o.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove();if(n.container&&n.container!==o){p=n.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove()}this.destroyAppView(e.appId,!0),(d=this.control.worker)==null||d.destroyViewWorker(t,!0),await new Promise(f=>{setTimeout(()=>{f(!0)},0)})}const r=new kw(t,this.control,Ne.InternalMsgEmitter),c=i.size.width||r.width,l=i.size.height||r.height,h={dpr:r.dpr,originalPoint:[c/2,l/2],offscreenCanvasOpt:{...Ue.defaultScreenCanvasOpt,width:c,height:l},layerOpt:{...Ue.defaultLayerOpt,width:c,height:l},cameraOpt:{...Ue.defaultCameraOpt,...i.camera,width:c,height:l}};if(this.createAppView({id:t,container:o,displayer:r,cameraOpt:h.cameraOpt,focusScenePath:i.focusScenePath,viewData:i}),r.createAppViewDisplayer(t,o),i.callbacks.on("onSizeUpdated",this.onAppViewSizeUpdated.bind(this,t)),i.callbacks.on("onCameraUpdated",this.onAppViewCameraUpdated.bind(this,t)),i.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this)),this.tmpFocusedViewId===t){const p=this.control.worker.getLocalWorkViewId();p&&p!==t?this.setFocuedViewId(p):this.setFocuedViewId(t),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(t)},0)});y(this,"onAppViewSizeUpdated",async e=>{await new Promise(i=>{setTimeout(()=>{i(!0)},0)});const t=this.appViews.get(e);t&&t.viewData&&this.updateAppCamera(e)});y(this,"onAppViewCameraUpdated",async e=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.updateAppCamera(e)});y(this,"updateAppCamera",e=>{const t=this.appViews.get(e);if(t&&t.viewData){const i=t.viewData.camera,o=t.cameraOpt;if(o){const{width:n,height:r}=t.viewData.size,c=o.width,l=o.height;(n!==c||r!==l)&&t.displayer.updateSize();const u=i.scale===1/0?1:i.scale,h=i.centerX||0,d=i.centerY||0,p={...o,scale:u,centerX:h,centerY:d,width:n,height:r};A.isEqual(p,o)||(t.cameraOpt=p)}}});this.control=e.control}getViewInitData(e){var i;const t=this.getView(e);if(t){const{width:o,height:n,dpr:r}=t.displayer;(i=this.control.pluginOptions.canvasOpt)!=null&&i.contextType&&(Ue.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.canvasOpt.contextType);const c={dpr:r,originalPoint:[o/2,n/2],offscreenCanvasOpt:{...Ue.defaultScreenCanvasOpt,width:o,height:n},layerOpt:{...Ue.defaultLayerOpt,width:o,height:n},cameraOpt:{...Ue.defaultCameraOpt,width:o,height:n}};if(t.viewData){const{scale:l,...u}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...u,scale:l===1/0?1:l}}return c}}async mountView(e){var i,o;const t=this.getView(e);if(t){e===((i=this.mainView)==null?void 0:i.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker());const n=this.getViewInitData(e);if(n&&((o=this.control.worker)==null||o.createViewWorker(e,n)),t.focusScenePath&&this.control.collector){if(this.control.collector.authStorage){const{renderAuth:r,pageAuth:c}=this.control.collector.authStorage;if(r){const l=r[e];if(l){const{render:u,hide:h,clear:d}=l;this.control.renderControl.syncRenderUids(e,u,h,d);return}}if(c){const l=c[e];if(l){this.control.renderControl.syncPageAuth(e,l,!0);return}}}this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}listenerWindowManager(e){e.emitter.on("focusedChange",t=>{const i=t||pe;if(this.focuedViewId!==i)if(this.getView(i)){const n=this.control.worker.getLocalWorkViewId();n&&n!==i?this.setFocuedViewId(n):this.setFocuedViewId(i)}else this.tmpFocusedViewId=i}),e.emitter.on("mainViewScenePathChange",t=>{this.control.onSceneChange(t,pe)}),e.emitter.on("onMainViewMounted",this.onMainViewMounted),e.emitter.on("onAppViewMounted",this.onAppViewMounted),e.emitter.on("onMainViewRebind",this.onMainViewRelease),e.emitter.on("onBoxClose",t=>{this.appViews.get(t.appId)&&(this.destroyAppView(t.appId),this.control.worker.destroyViewWorker(t.appId))}),e.emitter.on("onAppScenePathChange",t=>{const{appId:i,view:o}=t;this.control.onSceneChange(o.focusScenePath,i)}),e.emitter.on("appsChange",t=>{for(const i of this.appViews.keys())t.includes(i)||(this.destroyAppView(i),this.control.worker.destroyViewWorker(i,!0))})}onActiveHotkeyChange(e){this.control.hotkeyManager.onActiveHotkey(e)}}class rt extends Ne{constructor(e){super(e);y(this,"windowManager");y(this,"viewContainerManager");const t={control:this,internalMsgEmitter:Ne.InternalMsgEmitter,publicMsgEmitter:Ne.PublicMsgEmitter};this.viewContainerManager=new Ue(t)}init(){}activePlugin(){this.collector&&(this.collector.addAuthStateListener((e,t)=>{e&&Object.keys(e).forEach(i=>{var n;const o=(n=e[i])==null?void 0:n.newValue;this.renderControl.syncRenderUids(i,o==null?void 0:o.render,o==null?void 0:o.hide,o==null?void 0:o.clear)}),t&&Object.keys(t).forEach(i=>{var n;const o=(n=t[i])==null?void 0:n.newValue;this.renderControl.syncPageAuth(i,o)})}),this.collector.addStorageStateListener(e=>{var r,c;if((r=this.collector)!=null&&r.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(pe,!0);return}const{diffView:t,diffScenePath:i,diffData:o}=e,n=new Map;if(t){let l;Object.keys(t).forEach(u=>{var d;const h=t[u];if(h&&!h.newValue)(d=this.worker)==null||d.clearViewScenePath(u,!0),h.oldValue&&(l=h.oldValue);else if(h&&h.newValue){for(const p of Object.keys(h.newValue))this.worker.pullServiceData(u,p,{isAsync:!1,useAnimation:!1});l=h.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const g of Object.keys(p))g&&f.add(g);n.set(u,f)}})}if(i){let l;Object.keys(i).forEach(u=>{var d;const h=i[u];if(h&&h.viewId&&!h.newValue?((d=this.worker)==null||d.clearViewScenePath(h.viewId,!0),h.oldValue&&(l=h.oldValue)):h&&h.viewId&&h.newValue&&(this.worker.pullServiceData(h.viewId,u,{isAsync:!1,useAnimation:!1}),l=h.newValue),h!=null&&h.viewId&&l){const p=new Set;for(const f of Object.keys(l))f&&p.add(f),n.set(h.viewId,p)}})}o&&Object.keys(o).forEach(l=>{var h,d;const u=o[l];if(u){const{viewId:p}=u,f=n.get(p)||new Set;f.add(l),n.set(p,f),(h=this.worker)==null||h.onServiceDerive(l,u),(d=this.miniMapManager)==null||d.updateMiniMapCamera(p)}});for(const[l,u]of n.entries())Ne.InternalMsgEmitter.emit("excludeIds",[...u],l)}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})}),this.room&&this.roomMember.onUidChangeHook(e=>{var t,i;if((t=this.collector)!=null&&t.serviceStorage){const o=[];this.viewContainerManager.getAllViews().forEach(n=>{var r;if(n&&n.focusScenePath&&((r=this.collector)!=null&&r.serviceStorage[n.id])&&this.collector.serviceStorage[n.id][n.focusScenePath]){const c=Object.keys(this.collector.serviceStorage[n.id][n.focusScenePath]).filter(l=>{var u;return(u=this.collector)==null?void 0:u.isSelector(l)}).map(l=>({viewId:n.id,scenePath:n.focusScenePath,key:l}));c.length&&o.push(...c)}}),o.forEach(({key:n,viewId:r,scenePath:c})=>{var u,h;const l=(u=this.collector)==null?void 0:u.getUidFromKey(n);l&&!e.online.includes(l)&&(this.renderControl.isWritable&&((h=this.collector)==null||h.updateValue(n,void 0,{viewId:r,scenePath:c,isSync:!0})),this.worker.blurSelector(r,c,n))})}(i=this.cursor)==null||i.updateRoomMembers(e)}))}async activeWorker(){await this.worker.init()}setWindowManager(e){var t,i,o,n,r;this.windowManager=e,(i=(t=this.windowManager)==null?void 0:t.mainView)!=null&&i.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(r=(n=(o=this.windowManager.appManager)==null?void 0:o.viewManager)==null?void 0:n.views)!=null&&r.size&&this.windowManager.appManager.viewManager.views.forEach((c,l)=>{this.viewContainerManager.onAppViewMounted({appId:l,view:c})}),this.viewContainerManager.listenerWindowManager(this.windowManager)}}const Y=class Y extends G.InvisiblePlugin{constructor(){super(...arguments);y(this,"onPhaseChanged",e=>{var t;e===G.RoomPhase.Reconnecting&&((t=Y.currentManager)==null||t.setSnapshootData())});y(this,"updateRoomWritable",()=>{var e;(e=Y.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});y(this,"roomStateChangeListener",async e=>{var t,i;e!=null&&e.roomMembers&&((t=Y.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(G.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((i=Y.currentManager)==null||i.onMemberChange(e.memberState))})}static async getInstance(e,t){!t.options.cdn.fullWorkerUrl&&!t.options.cdn.subWorkerUrl&&Y.logger.error("[ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl");const i=e.displayer,o=i.callbacks.on,n=i.callbacks.off,r=i.callbacks.once,c=e.cleanCurrentScene,l=e.mainView.setMemberState;let u;G.isRoom(i)&&(u=i.setWritable),t!=null&&t.logger&&(Y.logger=t.logger),t.options&&(Y.options={...we,...t.options});let h=i.getInvisiblePlugin(Y.kind);h||(h=await Y.createApplianceMultiPlugin(i,Y.kind)),i&&h&&Y.createCurrentManager(e,Y.options,h),h&&Y.currentManager&&(Y.currentManager.bindPlugin(h),h.init(i));const d={displayer:i,windowManager:e,currentManager:Y.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(f){var S;Y.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const g=(e.mainView||i).getBoundingRect(f),M=await((S=Y.currentManager)==null?void 0:S.getBoundingRect(f));return!g.width||!g.height?M:ai(g,M)},screenshotToCanvasAsync:async function(f,g,M,S,w,I){var L;Y.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let k=M,T=S,v=w.scale;k>this.maxScreenshotWidth&&(v=this.maxScreenshotWidth/k*v,k=this.maxScreenshotWidth),T>this.maxScreenshotHeight&&(v=Math.min(this.maxScreenshotHeight/T*v,v),T=this.maxScreenshotHeight),w.scale=v;const P=document.createElement("canvas"),C=P.getContext("2d");P.width=k*(I||1),P.height=T*(I||1),C&&((e.mainView||i).screenshotToCanvas(C,g,k,T,w,I),f.drawImage(P,Math.floor((M-k)/2),Math.floor((S-T)/2),k*(I||1),T*(I||1),0,0,k,T),P.remove()),Y.currentManager&&await((L=Y.currentManager)==null?void 0:L.screenshotToCanvas(f,g,k,T,w,Math.floor((M-k)/2),Math.floor((S-T)/2)))},scenePreviewAsync:async function(f,g,M,S,w){Y.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(e.mainView||i).scenePreview(f,g,M,S,w);const I=document.createElement("img");I.className="appliance-plugin-fill-scene-snapshot-img",g.append(I),getComputedStyle(g).position||(g.style.position="relative"),Y.currentManager&&await Y.currentManager.scenePreview(f,I)},fillSceneSnapshotAsync:async function(f,g,M,S,w){Y.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),g.innerHTML="",(e.mainView||i).fillSceneSnapshot(f,g,M,S,w);const I=M||e.mainView.size.width,k=S||e.mainView.size.height;let T=await this.getBoundingRectAsync(f);T||(T={originX:0,originY:0,width:I,height:k});let v=Math.max(T==null?void 0:T.width,I),P=Math.max(T==null?void 0:T.height,k),C=1;const L=v>I&&Math.min(I/v,C)||C,O=P>k&&Math.min(k/P,C)||C;L<=O?(v=L<1&&I||v,P=Math.floor(P*L)+1,C=L):L>O&&(P=O<1&&k||P,v=Math.floor(v*O)+1,C=O);const R={scale:C,centerX:T.originX+T.width/2,centerY:T.originY+T.height/2},E=document.createElement("canvas"),j=E.getContext("2d");E.width=v,E.height=P,j&&await this.screenshotToCanvasAsync(j,f,v,P,R,devicePixelRatio);const D=document.createElement("img");D.className="appliance-plugin-fill-scene-snapshot-img",D.src=E.toDataURL(),D.onload=()=>{E.remove()},D.onerror=()=>{E.remove(),D.remove()},g.append(D),getComputedStyle(g).position||(g.style.position="relative")},_callbacksOn:function(f,g){Y.logger.info(`[ApplianceMultiPlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&G.isRoom(i)&&i.isWritable?rt.InternalMsgEmitter.on(f,g):o.call(i.callbacks,f,g)},_callbacksOnce:function(f,g){Y.logger.info(`[ApplianceMultiPlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&G.isRoom(i)&&i.isWritable?rt.InternalMsgEmitter.on(f,g):r.call(i.callbacks,f,g)},_callbacksOff:function(f,g){Y.logger.info(`[ApplianceMultiPlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&G.isRoom(i)&&i.isWritable?rt.InternalMsgEmitter.off(f,g):n.call(i.callbacks,f,g)},canRedoSteps(){if(Y.logger.info("[ApplianceMultiPlugin] canRedoSteps"),Y.currentManager&&G.isRoom(i)&&!i.disableSerialization){const f=Y.currentManager.viewContainerManager.focuedView,g=f==null?void 0:f.focusScenePath;if(f&&g)return f.displayer.commiter.redoStack.filter(M=>M.scenePath===g).length}return 0},canUndoSteps(){if(Y.logger.info("[ApplianceMultiPlugin] canUndoSteps"),Y.currentManager&&G.isRoom(i)&&!i.disableSerialization){const f=Y.currentManager.viewContainerManager.focuedView,g=f==null?void 0:f.focusScenePath;if(f&&g)return f.displayer.commiter.undoStack.filter(M=>M.scenePath===g).length}return 0},undo:function(){return Y.logger.info("[ApplianceMultiPlugin] undo"),Y.currentManager&&G.isRoom(i)&&!i.disableSerialization?Y.currentManager.viewContainerManager.undo():0},redo:function(){return Y.logger.info("[ApplianceMultiPlugin] redo"),Y.currentManager&&G.isRoom(i)&&!i.disableSerialization?Y.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){Y.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),Y.currentManager&&G.isRoom(i)&&i.isWritable&&(Y.currentManager.cleanCurrentScene(),c.call(e))},insertImage:function(f){Y.logger.info("[ApplianceMultiPlugin] insertImage"),Y.currentManager&&G.isRoom(i)&&i.isWritable&&Y.currentManager.worker.insertImage(pe,f)},lockImage:function(f,g){Y.logger.info("[ApplianceMultiPlugin] lockImage"),Y.currentManager&&G.isRoom(i)&&i.isWritable&&Y.currentManager.worker.lockImage(pe,f,g)},completeImageUpload:function(f,g){Y.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Y.currentManager&&G.isRoom(i)&&i.isWritable&&Y.currentManager.worker.completeImageUpload(pe,f,g)},getImagesInformation:function(f){return Y.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Y.currentManager&&G.isRoom(i)&&i.isWritable?Y.currentManager.worker.getImagesInformation(f):[]},callbacks:()=>(Y.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...i.callbacks,on:d._callbacksOn.bind(d),once:d._callbacksOnce.bind(d),off:d._callbacksOff.bind(d)}),destroy(){Y.currentManager&&(Y.logger.info("[ApplianceMultiPlugin] destroy"),Y.currentManager.destroy(),Y.currentManager=void 0)},setMemberState(f){Y.logger.info(`[ApplianceMultiPlugin] setMemberState ${JSON.stringify(f)}`);const g=Object.keys(f);if(G.isRoom(i)&&i.isWritable){g.includes("currentApplianceName")&&(f.currentApplianceName&&f.currentApplianceName===ne.laserPen?(f.currentApplianceName=ne.pencil,f.useLaserPen=!0):f.currentApplianceName&&f.currentApplianceName===ne.pencil&&(f.useLaserPen=!1)),l.call(e.mainView,f);return}throw new Error("[ApplianceMultiPlugin] setMemberState must be called in writable room")},setPerformancePriority(f){Y.logger.info("[ApplianceMultiPlugin] setPriority"),Y.currentManager&&Y.currentManager.setPriority(f)},createMiniMap:async function(f,g){if(Y.logger.info("[ApplianceMultiPlugin] createMiniMap"),Y.currentManager&&G.isRoom(i)&&i.isWritable)return Y.currentManager.createMiniMap(f,g)},destroyMiniMap:async function(f){if(Y.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),Y.currentManager&&G.isRoom(i)&&i.isWritable)return Y.currentManager.destroyMiniMap(f)},filterRenderByUid(f,g,M){if(Y.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),Y.currentManager&&G.isRoom(i)&&i.isWritable)return Y.currentManager.filterRenderByUid(f,g,M)},cancelFilterRender(f,g){if(Y.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),Y.currentManager&&G.isRoom(i)&&i.isWritable)return Y.currentManager.cancelFilterRender(f,g)},addListener:(f,g)=>{Y.logger.info(`[ApplianceMultiPlugin] addListener ${f}`),rt.PublicMsgEmitter.on(f,g)},removeListener:(f,g)=>{Y.logger.info(`[ApplianceMultiPlugin] removeListener ${f}`),rt.PublicMsgEmitter.off(f,g)},usePlugin:f=>{var g;Y.logger.info("[ApplianceMultiPlugin] usePlugin",f.kind),(g=Y.currentManager)==null||g.usePlugin(f)},getDisableDeviceInputs(){if(Y.logger.info("[ApplianceMultiPlugin] getDisableDeviceInputs"),Y.currentManager&&G.isRoom(i))return Y.currentManager.disableDeviceInputs},setDisableDeviceInputs(f){Y.logger.info("[ApplianceMultiPlugin] setDisableDeviceInputs"),Y.currentManager&&G.isRoom(i)&&(Y.currentManager.disableDeviceInputs=f)},getDisableCameraTransform(){if(Y.currentManager&&G.isRoom(i))return Y.currentManager.disableCameraTransform},setDisableCameraTransform(f){Y.logger.info(`[ApplianceMultiPlugin] setDisableCameraTransform ${f}`),Y.currentManager&&G.isRoom(i)&&(Y.currentManager.disableCameraTransform=f)},getDisableEraseImage(){if(Y.currentManager&&G.isRoom(i))return Y.currentManager.disableEraseImage},setDisableEraseImage(f){Y.logger.info(`[ApplianceMultiPlugin] setDisableEraseImage ${f}`),Y.currentManager&&G.isRoom(i)&&(Y.currentManager.disableEraseImage=f)},setWritable:async function(f){var g;Y.logger.info(`[ApplianceMultiPlugin] setWritable ${f}`),G.isRoom(i)&&u&&(await((g=Y.currentManager)==null?void 0:g.setWritable(f)),await u.call(i,f))},requestIdleCallback:(f,g)=>{const M=(g==null?void 0:g.timeout)||0,S=performance.now();let w;const I=new MessageChannel;let k;const T=v=>{try{f({didTimeout:v,timeRemaining:()=>{const C=performance.now()-S;return Math.max(0,M-C)}})}catch(P){Y.logger.error("[ApplianceMultiPlugin] requestIdleCallback error:",P)}finally{I.port1.close(),I.port2.close(),w!==void 0&&cancelAnimationFrame(w),k!==void 0&&clearTimeout(k)}};return I.port1.onmessage=()=>{w=requestAnimationFrame(()=>{M>0&&performance.now()-S>=M?T(!0):T(!1)})},I.port2.postMessage(null),M>0&&(k=setTimeout(()=>{T(!0)},M)),k||w||0},cancelIdleCallback:f=>{try{clearTimeout(f),cancelAnimationFrame(f)}catch(g){Y.logger.error("[ApplianceMultiPlugin] cancelIdleCallback error:",g)}},injectMethodToObject:(f,g)=>{if(Y.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${g}`),typeof f[g]=="function"||typeof f[g]>"u"){f[g]=d[g];return}g==="callbacks"&&(f.callbacks.on=d._callbacksOn.bind(d),f.callbacks.off=d._callbacksOff.bind(d),f.callbacks.once=d._callbacksOnce.bind(d))}};d.injectMethodToObject(e,"undo"),d.injectMethodToObject(e,"redo"),d.injectMethodToObject(e,"cleanCurrentScene"),d.injectMethodToObject(e,"insertImage"),d.injectMethodToObject(e,"completeImageUpload"),d.injectMethodToObject(e,"lockImage"),d.injectMethodToObject(i,"getImagesInformation"),d.injectMethodToObject(i,"callbacks"),d.injectMethodToObject(i,"screenshotToCanvasAsync"),d.injectMethodToObject(i,"getBoundingRectAsync"),d.injectMethodToObject(i,"scenePreviewAsync"),d.injectMethodToObject(i,"fillSceneSnapshotAsync"),d.injectMethodToObject(e.mainView,"setMemberState"),G.isRoom(i)&&d.injectMethodToObject(i,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return d.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return d.canRedoSteps()}}),rt.InternalMsgEmitter.on("onCanUndoStepsUpdate",f=>{e.emitter.emit("canUndoStepsChange",f)}),rt.InternalMsgEmitter.on("onCanRedoStepsUpdate",f=>{e.emitter.emit("canRedoStepsChange",f)});const p={...d,callbacks:d.callbacks()};return Object.defineProperty(p,"disableDeviceInputs",{set(f){d.setDisableDeviceInputs(f)},get(){return d.getDisableDeviceInputs()}}),Object.defineProperty(p,"disableCameraTransform",{set(f){d.setDisableCameraTransform(f)},get(){return d.getDisableCameraTransform()}}),Object.defineProperty(p,"disableEraseImage",{set(f){d.setDisableEraseImage(f)},get(){return d.getDisableEraseImage()}}),e._appliancePlugin=p,e._appliancePlugin}static onCreate(e){e&&Y.currentManager&&(Y.currentManager.bindPlugin(e),e.init(e.displayer))}static async createApplianceMultiPlugin(e,t){try{await e.createInvisiblePlugin(Y,{})}catch{if(!e.isWritable){await e.setWritable(!0);const n=await this.createApplianceMultiPlugin(e,t);return await e.setWritable(!1),n}}let i=e.getInvisiblePlugin(t);return i||(i=await Y.createApplianceMultiPlugin(e,t)),i}get isReplay(){return G.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var i,o;const t=e.state;(i=Y.currentManager)==null||i.onRoomMembersChange(t.roomMembers),G.isRoom(e)&&((o=Y.currentManager)==null||o.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;Y.logger.info("[ApplianceMultiPlugin] passive destroy"),(e=Y.currentManager)==null||e.destroy(),Y.currentManager=void 0}};y(Y,"kind","appliance-multi-plugin"),y(Y,"currentManager"),y(Y,"logger",{info:console.log,warn:console.warn,error:console.error}),y(Y,"options",we),y(Y,"createCurrentManager",(e,t,i)=>{Y.currentManager&&Y.currentManager.destroy();const o={plugin:i,displayer:e.displayer,options:t},n=new rt(o);Y.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),n.setWindowManager(e),Y.currentManager=n,e.room&&e.room.logger.info(`[ApplianceMultiPlugin] use ${ti}`)});let Us=Y;class Cw extends un{constructor(e,t){super(e,t);y(this,"width",1e3);y(this,"height",1e3);y(this,"dpr",it());y(this,"vDom");y(this,"viewId",pe);y(this,"eventTragetElement");y(this,"snapshotContainerRef");y(this,"canvasContainerRef",m.createRef());y(this,"subLocalCanvasContainerRef",m.createRef());y(this,"canvasTopRef",m.createRef());y(this,"canvasServiceFloatRef",m.createRef());y(this,"canvasFloatRef",m.createRef());y(this,"canvasBgRef",m.createRef());y(this,"floatBarRef",m.createRef());y(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=m.createRef())}setCanvassStyle(){if(this.eventTragetElement){const e=this.eventTragetElement.offsetWidth,t=this.eventTragetElement.offsetHeight;let i=it();this.canvasBgRef.current&&(i=it(this.canvasBgRef.current.getContext("2d"))),i!==this.dpr&&(this.dpr=i,this.control.worker.updateDpr(this.viewId,this.dpr)),e&&t&&this.canvasContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t),e&&t&&this.canvasBgRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasBgRef.current.width=e*this.dpr,this.canvasBgRef.current.height=t*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=e*this.dpr,this.canvasFloatRef.current.height=t*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=e*this.dpr,this.canvasServiceFloatRef.current.height=t*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=e*this.dpr,this.canvasTopRef.current.height=t*this.dpr))}}createMainViewDisplayer(e){return this.vDom||(this.containerOffset=this.getContainerOffset(e,this.containerOffset),this.eventTragetElement=e.parentElement.children[0],e.innerHTML="",hs.render(m.createElement(di,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),e),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement)),this}}class et extends xt{constructor(e){super(e);y(this,"focuedViewId");y(this,"control");y(this,"focuedView");this.control=e.control}bindMainView(){if(!this.control.divMainView)return;const e=new Cw(this.control,Ne.InternalMsgEmitter),{width:t,height:i,dpr:o}=e,n={dpr:o,originalPoint:[t/2,i/2],offscreenCanvasOpt:{...et.defaultScreenCanvasOpt,width:t,height:i},layerOpt:{...et.defaultLayerOpt,width:t,height:i},cameraOpt:{...et.defaultCameraOpt,width:t,height:i}},r=this.control.room&&this.control.room.mainView||this.control.play&&this.control.play.mainView;if(r){const{scale:c,...l}=r.camera;n.cameraOpt={...n.cameraOpt,...l,scale:c===1/0?1:c},this.createMianView({id:pe,displayer:e,focusScenePath:r.focusScenePath||r.scenePath,cameraOpt:n.cameraOpt,viewData:r}),this.setFocuedViewId(pe),e.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(e){var i;const t=this.getView(e);if(t){const{width:o,height:n,dpr:r}=t.displayer;(i=this.control.pluginOptions.canvasOpt)!=null&&i.contextType&&(et.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.canvasOpt.contextType);const c={dpr:r,originalPoint:[o/2,n/2],offscreenCanvasOpt:{...et.defaultScreenCanvasOpt,width:o,height:n},layerOpt:{...et.defaultLayerOpt,width:o,height:n},cameraOpt:{...et.defaultCameraOpt,width:o,height:n}};if(t.viewData){const{scale:l,...u}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...u,scale:l===1/0?1:l}}return c}}async mountView(e){var i;const t=this.getView(e);if(t){this.control.worker.isActive||(this.control.cursor.activeCollector(),await this.control.activeWorker());const o=this.getViewInitData(e);o&&((i=this.control.worker)==null||i.createViewWorker(e,o)),t.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class Be extends Ne{constructor(e){super(e);y(this,"viewContainerManager");y(this,"divMainView");y(this,"onCameraChange",ui(e=>{var i;const t=this.viewContainerManager.mainView;t&&t.cameraOpt&&(t.cameraOpt.width!==e.width||t.cameraOpt.height!==e.height)&&((i=this.viewContainerManager.mainView)==null||i.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(e)},ri,{leading:!1}));const t={control:this,internalMsgEmitter:Be.InternalMsgEmitter,publicMsgEmitter:Be.PublicMsgEmitter};this.viewContainerManager=new et(t)}init(){Be.InternalMsgEmitter.on(se.BindMainView,e=>{this.divMainView=e,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()})}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(e=>{var r,c;if((r=this.collector)!=null&&r.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(pe,!0);return}const{diffView:t,diffScenePath:i,diffData:o}=e,n=new Map;if(t){let l;Object.keys(t).forEach(u=>{var d;const h=t[u];if(h&&!h.newValue)(d=this.worker)==null||d.clearViewScenePath(u,!0),h.oldValue&&(l=h.oldValue);else if(h&&h.newValue){for(const p of Object.keys(h.newValue))this.worker.pullServiceData(u,p,{isAsync:!1,useAnimation:!0});l=h.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const g of Object.keys(p))g&&f.add(g);n.set(u,f)}})}if(i){let l;Object.keys(i).forEach(u=>{var d;const h=i[u];if(h&&h.viewId&&!h.newValue?((d=this.worker)==null||d.clearViewScenePath(h.viewId,!0),h.oldValue&&(l=h.oldValue)):h&&h.viewId&&h.newValue&&(this.worker.pullServiceData(h.viewId,u,{isAsync:!1,useAnimation:!0}),l=h.newValue),h!=null&&h.viewId&&l){const p=new Set;for(const f of Object.keys(l))f&&p.add(f),n.set(h.viewId,p)}})}o&&Object.keys(o).forEach(l=>{var h,d;const u=o[l];if(u){const{viewId:p}=u,f=n.get(p)||new Set;f.add(l),n.set(p,f),(h=this.worker)==null||h.onServiceDerive(l,u),(d=this.miniMapManager)==null||d.updateMiniMapCamera(p)}});for(const[l,u]of n.entries())Ne.InternalMsgEmitter.emit("excludeIds",[...u],l)}),this.room&&(this.roomMember.onUidChangeHook(e=>{var t,i,o,n;if((t=this.collector)!=null&&t.serviceStorage){const r=[];this.viewContainerManager.getAllViews().forEach(c=>{var l,u,h;if(c&&c.focusScenePath&&((l=this.collector)!=null&&l.serviceStorage[c.id])&&((u=this.collector)!=null&&u.serviceStorage[c.id][c.focusScenePath])){const d=Object.keys((h=this.collector)==null?void 0:h.serviceStorage[c.id][c.focusScenePath]).filter(p=>{var f;return(f=this.collector)==null?void 0:f.isSelector(p)}).map(p=>({viewId:c.id,scenePath:c.focusScenePath,key:p}));d.length&&r.push(...d)}}),r.forEach(({key:c,viewId:l,scenePath:u})=>{var d,p;const h=(d=this.collector)==null?void 0:d.getUidFromKey(c);h&&!e.online.includes(h)&&(this.renderControl.isWritable&&((p=this.collector)==null||p.updateValue(c,void 0,{viewId:l,scenePath:u,isSync:!0})),this.worker.blurSelector(l,u,c))})}(o=(i=this.cursor)==null?void 0:i.eventCollector)!=null&&o.serviceStorage&&Object.keys((n=this.cursor)==null?void 0:n.eventCollector.serviceStorage).forEach(c=>{var l,u;e.online.includes(c)||(u=(l=this.cursor)==null?void 0:l.eventCollector)==null||u.clearValue(c)})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.worker.init()}}const W=class W extends G.InvisiblePlugin{constructor(){super(...arguments);y(this,"onPhaseChanged",e=>{var t;e===G.RoomPhase.Reconnecting&&((t=W.currentManager)==null||t.setSnapshootData())});y(this,"updateRoomWritable",()=>{var e;(e=W.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});y(this,"roomStateChangeListener",async e=>{var t,i;W.currentManager instanceof Be&&(e.cameraState&&W.currentManager.onCameraChange(e.cameraState),e.sceneState&&W.currentManager.onSceneChange(e.sceneState.scenePath,pe)),e!=null&&e.roomMembers&&((t=W.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(G.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((i=W.currentManager)==null||i.onMemberChange(e.memberState))})}static async getInstance(e,t){const i=e.callbacks.on,o=e.callbacks.off,n=e.callbacks.once,r=e.cleanCurrentScene.bind(e),c=e.setMemberState.bind(e);let l;G.isRoom(e)&&(l=e.setWritable),t!=null&&t.logger&&(W.logger=t.logger),t.options&&(W.options={...we,...t.options});let u=e.getInvisiblePlugin(W.kind);u||(u=await W.createAppliancePlugin(e,W.kind)),e&&u&&W.createCurrentManager(e,W.options,u),u&&W.currentManager&&(W.currentManager.bindPlugin(u),u.init(e)),t!=null&&t.cursorAdapter&&(W.cursorAdapter=t.cursorAdapter),W.effectInstance();const h={displayer:e,currentManager:W.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(p){var M;W.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const f=e.getBoundingRect(p),g=await((M=W.currentManager)==null?void 0:M.getBoundingRect(p));return!f.width||!f.height?g:ai(f,g)},screenshotToCanvasAsync:async function(p,f,g,M,S,w){var C;W.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let I=g,k=M,T=S.scale;I>this.maxScreenshotWidth&&(T=this.maxScreenshotWidth/I*T,I=this.maxScreenshotWidth),k>this.maxScreenshotHeight&&(T=Math.min(this.maxScreenshotHeight/k*T,T),k=this.maxScreenshotHeight),S.scale=T;const v=document.createElement("canvas"),P=v.getContext("2d");v.width=I*(w||1),v.height=k*(w||1),P&&(e.screenshotToCanvas(P,f,I,k,S,w),p.drawImage(v,Math.floor((g-I)/2),Math.floor((M-k)/2),I*(w||1),k*(w||1),0,0,I,k),v.remove()),W.currentManager&&await((C=W.currentManager)==null?void 0:C.screenshotToCanvas(p,f,I,k,S,Math.floor((g-I)/2),Math.floor((M-k)/2)))},scenePreviewAsync:async function(p,f,g,M,S){W.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),e.scenePreview(p,f,g,M,S);const w=document.createElement("img");w.className="appliance-plugin-fill-scene-snapshot-img",f.append(w),getComputedStyle(f).position||(f.style.position="relative"),W.currentManager&&await W.currentManager.scenePreview(p,w)},fillSceneSnapshotAsync:async function(p,f,g,M,S){var D,q;W.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),f.innerHTML="",e.fillSceneSnapshot(p,f,g,M,S);const w=g||((D=e.state.cameraState)==null?void 0:D.width)||0,I=M||((q=e.state.cameraState)==null?void 0:q.height)||0;let k=await this.getBoundingRectAsync(p);k||(k={originX:0,originY:0,width:w,height:I});let T=Math.max(k==null?void 0:k.width,w),v=Math.max(k==null?void 0:k.height,I),P=1;const C=T>w&&Math.min(w/T,P)||P,L=v>I&&Math.min(I/v,P)||P;C<=L?(T=C<1&&w||T,v=Math.floor(v*C)+1,P=C):C>L&&(v=L<1&&I||v,T=Math.floor(T*L)+1,P=L);const O={scale:P,centerX:k.originX+k.width/2,centerY:k.originY+k.height/2},R=document.createElement("canvas"),E=R.getContext("2d");R.width=T,R.height=v,E&&await this.screenshotToCanvasAsync(E,p,T,v,O,devicePixelRatio);const j=document.createElement("img");j.className="appliance-plugin-fill-scene-snapshot-img",j.src=R.toDataURL(),j.onload=()=>{R.remove()},j.onerror=()=>{R.remove(),j.remove()},f.append(j),getComputedStyle(f).position||(f.style.position="relative")},_callbacksOn:function(p,f){W.logger.info(`[ApplianceSinglePlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&G.isRoom(e)&&e.isWritable?Be.InternalMsgEmitter.on(p,f):i.call(e.callbacks,p,f)},_callbacksOnce:function(p,f){W.logger.info(`[ApplianceSinglePlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&G.isRoom(e)&&e.isWritable?Be.InternalMsgEmitter.on(p,f):n.call(e.callbacks,p,f)},_callbacksOff:function(p,f){W.logger.info(`[ApplianceSinglePlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&G.isRoom(e)&&e.isWritable?Be.InternalMsgEmitter.off(p,f):o.call(e.callbacks,p,f)},canRedoSteps(){if(W.logger.info("[ApplianceSinglePlugin] canRedoSteps"),W.currentManager&&G.isRoom(e)&&!e.disableSerialization){const p=W.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.redoStack.filter(g=>g.scenePath===f).length}return 0},canUndoSteps(){if(W.logger.info("[ApplianceSinglePlugin] canUndoSteps"),W.currentManager&&G.isRoom(e)&&!e.disableSerialization){const p=W.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.undoStack.filter(g=>g.scenePath===f).length}return 0},undo:function(){return W.logger.info("[ApplianceSinglePlugin] undo"),W.currentManager&&G.isRoom(e)&&!e.disableSerialization?W.currentManager.viewContainerManager.undo():0},redo:function(){return W.logger.info("[ApplianceSinglePlugin] redo"),W.currentManager&&G.isRoom(e)&&!e.disableSerialization?W.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(p){W.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),W.currentManager&&G.isRoom(e)&&e.isWritable&&(W.currentManager.cleanCurrentScene(),r.call(e,p))},insertImage:function(p){W.logger.info("[ApplianceSinglePlugin] insertImage"),W.currentManager&&G.isRoom(e)&&e.isWritable&&W.currentManager.worker.insertImage(pe,p)},lockImage:function(p,f){W.logger.info("[ApplianceSinglePlugin] lockImage"),W.currentManager&&G.isRoom(e)&&e.isWritable&&W.currentManager.worker.lockImage(pe,p,f)},completeImageUpload:function(p,f){W.logger.info("[ApplianceSinglePlugin] completeImageUpload"),W.currentManager&&G.isRoom(e)&&e.isWritable&&W.currentManager.worker.completeImageUpload(pe,p,f)},getImagesInformation:function(p){return W.logger.info("[ApplianceSinglePlugin] completeImageUpload"),W.currentManager&&G.isRoom(e)&&e.isWritable?W.currentManager.worker.getImagesInformation(p):[]},callbacks:()=>({...e.callbacks,on:h._callbacksOn.bind(h),once:h._callbacksOnce.bind(h),off:h._callbacksOff.bind(h)}),destroy(){W.currentManager&&(W.logger.info("[ApplianceSinglePlugin] destroy"),W.currentManager.destroy(),W.currentManager=void 0,W.cursorAdapter=void 0)},setMemberState(p){W.logger.info(`[ApplianceSinglePlugin] setMemberState ${JSON.stringify(p)}`);const f=Object.keys(p);if(G.isRoom(e)&&e.isWritable){f.includes("currentApplianceName")&&(p.currentApplianceName&&p.currentApplianceName===ne.laserPen?(p.currentApplianceName=ne.pencil,p.useLaserPen=!0):p.currentApplianceName&&p.currentApplianceName===ne.pencil&&(p.useLaserPen=!1)),c(p);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(p){W.logger.info("[ApplianceSinglePlugin] setPriority"),W.currentManager&&W.currentManager.setPriority(p)},createMiniMap:async function(p,f){if(W.logger.info("[ApplianceSinglePlugin] createMiniMap"),W.currentManager&&G.isRoom(e)&&e.isWritable)return W.currentManager.createMiniMap(p,f)},destroyMiniMap:async function(p){if(W.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),W.currentManager&&G.isRoom(e)&&e.isWritable)return W.currentManager.destroyMiniMap(p)},filterRenderByUid(p,f,g){if(W.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),W.currentManager&&G.isRoom(e)&&e.isWritable)return W.currentManager.filterRenderByUid(p,f,g)},cancelFilterRender(p,f){if(W.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),W.currentManager&&G.isRoom(e)&&e.isWritable)return W.currentManager.cancelFilterRender(p,f)},addListener:(p,f)=>{W.logger.info(`[ApplianceSinglePlugin] addListener ${p}`),Be.PublicMsgEmitter.on(p,f)},removeListener:(p,f)=>{W.logger.info(`[ApplianceSinglePlugin] removeListener ${p}`),Be.PublicMsgEmitter.off(p,f)},usePlugin:p=>{var f;W.logger.info("[ApplianceSinglePlugin] usePlugin",p.kind),(f=W.currentManager)==null||f.usePlugin(p)},getDisableDeviceInputs(){if(W.logger.info("[ApplianceSinglePlugin] getDisableDeviceInputs"),W.currentManager&&G.isRoom(e))return W.currentManager.disableDeviceInputs},setDisableDeviceInputs(p){W.logger.info("[ApplianceSinglePlugin] setDisableDeviceInputs"),W.currentManager&&G.isRoom(e)&&(W.currentManager.disableDeviceInputs=p)},getDisableCameraTransform(){if(W.currentManager&&G.isRoom(e))return W.currentManager.disableCameraTransform},setDisableCameraTransform(p){W.logger.info(`[ApplianceSinglePlugin] setDisableCameraTransform ${p}`),W.currentManager&&G.isRoom(e)&&(W.currentManager.disableCameraTransform=p)},getDisableEraseImage(){if(W.logger.info("[ApplianceSinglePlugin] getDisableEraseImage"),W.currentManager&&G.isRoom(e))return W.currentManager.disableEraseImage},setDisableEraseImage(p){W.logger.info("[ApplianceSinglePlugin] setDisableEraseImage"),W.currentManager&&G.isRoom(e)&&(W.currentManager.disableEraseImage=p)},setWritable:async function(p){var f;W.logger.info(`[ApplianceSinglePlugin] setWritable ${p}`),G.isRoom(e)&&l&&(await((f=W.currentManager)==null?void 0:f.setWritable(p)),await l.call(e,p))},requestIdleCallback:(p,f)=>{const g=(f==null?void 0:f.timeout)||0,M=performance.now();let S;const w=new MessageChannel;let I;const k=T=>{try{p({didTimeout:T,timeRemaining:()=>{const P=performance.now()-M;return Math.max(0,g-P)}})}catch(v){W.logger.error("[ApplianceSinglePlugin] requestIdleCallback error:",v)}finally{w.port1.close(),w.port2.close(),S!==void 0&&cancelAnimationFrame(S),I!==void 0&&clearTimeout(I)}};return w.port1.onmessage=()=>{S=requestAnimationFrame(()=>{g>0&&performance.now()-M>=g?k(!0):k(!1)})},w.port2.postMessage(null),g>0&&(I=setTimeout(()=>{k(!0)},g)),I||S||0},cancelIdleCallback:p=>{try{clearTimeout(p),cancelAnimationFrame(p)}catch(f){W.logger.error("[ApplianceSinglePlugin] cancelIdleCallback error:",f)}},injectMethodToObject:(p,f)=>{if(W.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${f}`),typeof p[f]=="function"||typeof p[f]>"u"){p[f]=h[f];return}f==="callbacks"&&(p.callbacks.on=h._callbacksOn.bind(h),p.callbacks.off=h._callbacksOff.bind(h),p.callbacks.once=h._callbacksOnce.bind(h))}};h.injectMethodToObject(e,"undo"),h.injectMethodToObject(e,"redo"),h.injectMethodToObject(e,"cleanCurrentScene"),h.injectMethodToObject(e,"insertImage"),h.injectMethodToObject(e,"completeImageUpload"),h.injectMethodToObject(e,"lockImage"),h.injectMethodToObject(e,"getImagesInformation"),h.injectMethodToObject(e,"callbacks"),h.injectMethodToObject(e,"screenshotToCanvasAsync"),h.injectMethodToObject(e,"getBoundingRectAsync"),h.injectMethodToObject(e,"scenePreviewAsync"),h.injectMethodToObject(e,"fillSceneSnapshotAsync"),h.injectMethodToObject(e,"setMemberState"),G.isRoom(e)&&h.injectMethodToObject(e,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return h.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return h.canRedoSteps()}});const d={...h,callbacks:h.callbacks()};return Object.defineProperty(d,"disableDeviceInputs",{set(p){h.setDisableDeviceInputs(p)},get(){return h.getDisableDeviceInputs()}}),Object.defineProperty(d,"disableEraseImage",{set(p){h.setDisableEraseImage(p)},get(){return h.getDisableEraseImage()}}),Object.defineProperty(d,"disableCameraTransform",{set(p){h.setDisableCameraTransform(p)},get(){return h.getDisableCameraTransform()}}),e._appliancePlugin=d,e._appliancePlugin}static onCreate(e){e&&W.currentManager&&(W.currentManager.bindPlugin(e),e.init(e.displayer))}static async createAppliancePlugin(e,t){try{await e.createInvisiblePlugin(W,{})}catch{if(!e.isWritable){await e.setWritable(!0);const n=await this.createAppliancePlugin(e,t);return await e.setWritable(!1),n}}let i=e.getInvisiblePlugin(t);return i||(i=await W.createAppliancePlugin(e,t)),i}static effectInstance(){if(W.cursorAdapter){const e=W.cursorAdapter.onAddedCursor;W.cursorAdapter.onAddedCursor=function(t){t.onCursorMemberChanged=i=>{try{i.appliance===ne.pencil||i.appliance===ne.shape||i.appliance===ne.text||i.appliance===ne.arrow||i.appliance===ne.straight||i.appliance===ne.rectangle||i.appliance===ne.ellipse||i.appliance===ne.eraser?t!=null&&t.divElement&&(t.divElement.style.display="none"):t!=null&&t.divElement&&(t.divElement.style.display="block")}catch{}},e.call(W.cursorAdapter,t)}}}get isReplay(){return G.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var i,o;const t=e.state;(i=W.currentManager)==null||i.onRoomMembersChange(t.roomMembers),G.isRoom(e)&&t!=null&&t.memberState&&((o=W.currentManager)==null||o.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;W.logger.info("[ApplianceSinglePlugin] passive destroy"),(e=W.currentManager)==null||e.destroy(),W.currentManager=void 0,W.cursorAdapter=void 0}};y(W,"kind","appliance-aids-single-plugin"),y(W,"cursorAdapter"),y(W,"currentManager"),y(W,"logger",{info:console.log,warn:console.warn,error:console.error}),y(W,"options",we),y(W,"createCurrentManager",(e,t,i)=>{W.currentManager&&W.currentManager.destroy();const o={plugin:i,displayer:e,options:t},n=new Be(o);n.init(),W.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),W.currentManager=n,G.isRoom(e)&&e.logger.info(`[ApplianceSinglePlugin] use ${ti}`)});let Bs=W;const Ct=class Ct extends m.Component{constructor(){super(...arguments);y(this,"mainViewRef",null)}componentDidMount(){Ct.emiter||(Ct.emiter=Be.InternalMsgEmitter),Ct.emiter.emit(se.BindMainView,this.mainViewRef)}render(){return m.createElement(m.Fragment,null,this.props.children,m.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:e=>this.mainViewRef=e}))}};y(Ct,"emiter");let Fs=Ct;class bw extends ln{constructor(e){super();y(this,"kind","autoDraw");y(this,"localStorage",[]);y(this,"excludeStorage",[]);y(this,"timer");y(this,"hostServer");y(this,"iconsContainer");y(this,"icons",[]);y(this,"iconRect");y(this,"isActive",!1);y(this,"viewId",pe);y(this,"scenePath");y(this,"delay",2e3);const{container:t,hostServer:i,delay:o}=e;this.hostServer=i,this.iconsContainer=t,this.delay=o||2e3}get collector(){return this.control.collector}onDestroy(){this.unMount()}onCreate(){}onSetToolkey(e){e===N.Pencil?this.isActive=!0:(this.isActive&&(this.localStorage.length=0,this.timer&&clearTimeout(this.timer),this.timer=void 0,this.iconRect&&(this.iconRect=void 0),this.icons.length=0),this.isActive=!1)}syncStorage(e,t){if(!this.isActive||e!==this.viewId)return;if(!t){this.localStorage.length=0;return}const i=this.getOwnStorage(this.viewId,t);this.localStorage=i.map(o=>{var n;return((n=this.collector)==null?void 0:n.getLocalId(o))||o})}getOwnStorage(e,t){var n,r;if(!e||!t)return[];const i=(r=(n=this.collector)==null?void 0:n.storage[e])==null?void 0:r[t];return i?Object.keys(i).filter(c=>{var l,u;return((l=this.collector)==null?void 0:l.isOwn(c))&&((u=i[c])==null?void 0:u.toolsType)===N.Pencil&&!this.excludeStorage.includes(c)}):[]}async batchLocalDraw(){var r;if(this.localStorage.length===0||!this.scenePath||!((r=this.collector)==null?void 0:r.getStorageData(this.viewId,this.scenePath)))return;const t=this.localStorage.toString(),i=await this.control.worker.getVNodeInfo(this.localStorage.toString(),this.viewId,this.localStorage);if(!i)return;const{vInfo:o,uuid:n}=i;if(n===t&&o){const c={rect:{centerX:0,centerY:0,width:0,height:0},ink:[]};let l;const u=[];for(const{rect:h,op:d}of o){l=le(l,h);const p=[],f=[];for(let g=0;g<d.length;g+=3){p.push(d[g]),f.push(d[g+1]);const M=u.length&&u[u.length-1]||0;g===0?u.length===0?u.push(0):u.push(M+100):u.push(M+15)}c.ink.push([p,f,u])}return l&&(c.rect.centerX=Math.floor(l.x+l.w/2),c.rect.centerY=Math.floor(l.y+l.h/2),c.rect.width=Math.floor(l.w),c.rect.height=Math.floor(l.h)),c}}async computAutoDraw(e){const{rect:t,ink:i}=e;this.iconRect=t;const o=await fetch(this.hostServer,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({width:t.width,height:t.height,ink:i})}).then(n=>n.json()).then(n=>n.data);this.icons=o||[]}buildHTML(){var i;this.iconsContainer.innerHTML="";const e=document.createElement("div");e.style.display="flex",e.style.overflow="auto",e.style.padding="10px 0";const t=((i=this.control.worker.currentToolsData)==null?void 0:i.toolsOpt.strokeColor)||"#7f7f7f";this.icons.forEach(o=>{const n=document.createElement("img");n.src=`https://api.iconify.design/${o}.svg?color=${t}`,n.onclick=()=>{this.onClickIcon(o)},n.onload=()=>{e.appendChild(n)}}),this.iconsContainer.appendChild(e)}onClickIcon(e){var t,i;if(this.iconRect){const o=this.control.viewContainerManager.transformToScenePoint([this.iconRect.centerX,this.iconRect.centerY],this.viewId),n=((i=(t=this.control.viewContainerManager.getView(this.viewId))==null?void 0:t.cameraOpt)==null?void 0:i.scale)||1;this.icons.length=0,this.iconsContainer.innerHTML="";const r=Date.now().toString();this.control.worker.removeNodes(this.viewId,this.localStorage),this.localStorage.length=0,this.control.insertIconify(this.viewId,{uuid:r,centerX:o[0],centerY:o[1],width:Math.floor(this.iconRect.width/n),height:Math.floor(this.iconRect.height/n),src:`https://api.iconify.design/${e}.svg`,uniformScale:!1,locked:!1}),this.iconRect=void 0}}sceneChange(e,t){e===this.viewId&&(this.scenePath=t,this.excludeStorage=this.getOwnStorage(e,t)),this.localStorage.length=0}localEvent(e,t){var i;if(e===this.viewId&&((i=this.control.worker.currentToolsData)==null?void 0:i.toolsType)===N.Pencil)switch(t){case z.Start:this.timer&&(clearTimeout(this.timer),this.timer=void 0);break;case z.Done:this.timer&&clearTimeout(this.timer),this.timer=setTimeout(async()=>{this.timer=void 0;const o=await this.batchLocalDraw();o&&(await this.computAutoDraw(o),this.buildHTML())},this.delay);break}}mount(){var t,i;this.scenePath=(t=this.control.viewContainerManager.getView(this.viewId))==null?void 0:t.focusScenePath,this.excludeStorage=this.getOwnStorage(this.viewId,this.scenePath);const e=(i=this.control.worker.currentToolsData)==null?void 0:i.toolsType;e&&this.onSetToolkey(e),this.callbacks("setToolkey",this.onSetToolkey.bind(this)),this.callbacks("syncStorage",this.syncStorage.bind(this)),this.callbacks("sceneChange",this.sceneChange.bind(this)),this.callbacks("localEvent",this.localEvent.bind(this))}unMount(){this.timer&&clearTimeout(this.timer),this.timer=void 0,this.iconRect&&(this.iconRect=void 0),this.icons.length=0,this.excludeStorage.length=0,this.localStorage.length=0,this.iconsContainer.innerHTML="",this.removeCallback("setToolkey"),this.removeCallback("syncStorage"),this.removeCallback("sceneChange"),this.removeCallback("localEvent")}}exports.ActiveContainerType=ao;exports.ApplianceMultiPlugin=Us;exports.ApplianceNames=ne;exports.ApplianceSigleWrapper=Fs;exports.ApplianceSinglePlugin=Bs;exports.AutoDrawPlugin=bw;exports.Cursor_Hover_Id=hg;exports.DefaultAppliancePluginOptions=we;exports.ECanvasShowType=me;exports.EDataType=F;exports.EForceStopReason=us;exports.EImageType=gt;exports.EMatrixrRelationType=ft;exports.EOperationType=De;exports.EPostMessageType=x;exports.ERenderFilterType=Qe;exports.EScaleType=re;exports.EStrokeType=te;exports.EToolsKey=N;exports.ElayerType=Ut;exports.EmitEventType=V;exports.EventMessageType=Yt;exports.EvevtWorkState=z;exports.EvevtWorkType=co;exports.InternalMsgEmitterType=se;exports.Main_View_Id=pe;exports.Plugin=ln;exports.ShapeType=$e;exports.Storage_Selector_key=H;exports.Storage_Splitter=Ee;exports.Storage_ViewId_ALL=Jt;exports.Task_Time_Interval=ri;exports.VNodeManager=_o;exports.ViewContainerManager=xt;exports.computRect=le;exports.fullWorker=Mn;exports.getRectMatrixrRelation=hi;exports.getShapeInstance=ws;exports.isEqual=tt;exports.isIntersectForPoint=an;exports.isNumber=be;exports.removeAllChildren=Re;exports.removeTexture=Oe;exports.subWorker=wn;exports.transformToNormalData=lt;exports.transformToSerializableData=We;